@livedigital/client 3.32.0 → 3.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +3 -3
- package/dist/index.js +3 -3
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -26,9 +26,9 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
26
26
|
|
|
27
27
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
28
28
|
and limitations under the License.
|
|
29
|
-
***************************************************************************** */!function(e){!function(t){var r="object"==typeof globalThis?globalThis:"object"==typeof l?l:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),n=i(e);function i(e,t){return function(r,n){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0!==r.Reflect&&(n=i(r.Reflect,n)),function(e,t){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,i=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",s=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",o="function"==typeof Object.create,a={__proto__:[]}instanceof Array,c=!o&&!a,d={create:o?function(){return le(Object.create(null))}:a?function(){return le({__proto__:null})}:function(){return le({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),l="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),p="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:de(),h="function"==typeof WeakMap?WeakMap:ue(),f=n?Symbol.for("@reflect-metadata:registry"):void 0,m=ie(),g=se(m);function v(e,t,r,n){if(F(r)){if(!$(e))throw new TypeError;if(!G(t))throw new TypeError;return T(e,t)}if(!$(e))throw new TypeError;if(!W(t))throw new TypeError;if(!W(n)&&!F(n)&&!N(n))throw new TypeError;return N(n)&&(n=void 0),E(e,t,r=H(r),n)}function y(e,t){function r(r,n){if(!W(r))throw new TypeError;if(!F(n)&&!Q(n))throw new TypeError;O(e,t,r,n)}return r}function b(e,t,r,n){if(!W(r))throw new TypeError;return F(n)||(n=H(n)),O(e,t,r,n)}function w(e,t,r){if(!W(t))throw new TypeError;return F(r)||(r=H(r)),D(e,t,r)}function _(e,t,r){if(!W(t))throw new TypeError;return F(r)||(r=H(r)),I(e,t,r)}function S(e,t,r){if(!W(t))throw new TypeError;return F(r)||(r=H(r)),M(e,t,r)}function k(e,t,r){if(!W(t))throw new TypeError;return F(r)||(r=H(r)),x(e,t,r)}function C(e,t){if(!W(e))throw new TypeError;return F(t)||(t=H(t)),L(e,t)}function R(e,t){if(!W(e))throw new TypeError;return F(t)||(t=H(t)),A(e,t)}function P(e,t,r){if(!W(t))throw new TypeError;if(F(r)||(r=H(r)),!W(t))throw new TypeError;F(r)||(r=H(r));var n=ae(t,r,!1);return!F(n)&&n.OrdinaryDeleteMetadata(e,t,r)}function T(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!F(n)&&!N(n)){if(!G(n))throw new TypeError;t=n}}return t}function E(e,t,r,n){for(var i=e.length-1;i>=0;--i){var s=(0,e[i])(t,r,n);if(!F(s)&&!N(s)){if(!W(s))throw new TypeError;n=s}}return n}function D(e,t,r){if(I(e,t,r))return!0;var n=re(t);return!N(n)&&D(e,n,r)}function I(e,t,r){var n=ae(t,r,!1);return!F(n)&&z(n.OrdinaryHasOwnMetadata(e,t,r))}function M(e,t,r){if(I(e,t,r))return x(e,t,r);var n=re(t);return N(n)?void 0:M(e,n,r)}function x(e,t,r){var n=ae(t,r,!1);if(!F(n))return n.OrdinaryGetOwnMetadata(e,t,r)}function O(e,t,r,n){ae(r,n,!0).OrdinaryDefineOwnMetadata(e,t,r,n)}function L(e,t){var r=A(e,t),n=re(e);if(null===n)return r;var i=L(n,t);if(i.length<=0)return r;if(r.length<=0)return i;for(var s=new p,o=[],a=0,c=r;a<c.length;a++){var d=c[a];s.has(d)||(s.add(d),o.push(d))}for(var u=0,l=i;u<l.length;u++){d=l[u];s.has(d)||(s.add(d),o.push(d))}return o}function A(e,t){var r=ae(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function j(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function F(e){return void 0===e}function N(e){return null===e}function B(e){return"symbol"==typeof e}function W(e){return"object"==typeof e?null!==e:"function"==typeof e}function q(e,t){switch(j(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r=3===t?"string":5===t?"number":"default",n=Y(e,i);if(void 0!==n){var s=n.call(e,r);if(W(s))throw new TypeError;return s}return U(e,"default"===r?"number":r)}function U(e,t){if("string"===t){var r=e.toString;if(K(r))if(!W(i=r.call(e)))return i;if(K(n=e.valueOf))if(!W(i=n.call(e)))return i}else{var n;if(K(n=e.valueOf))if(!W(i=n.call(e)))return i;var i,s=e.toString;if(K(s))if(!W(i=s.call(e)))return i}throw new TypeError}function z(e){return!!e}function V(e){return""+e}function H(e){var t=q(e,3);return B(t)?t:V(t)}function $(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function K(e){return"function"==typeof e}function G(e){return"function"==typeof e}function Q(e){switch(j(e)){case 3:case 4:return!0;default:return!1}}function J(e,t){return e===t||e!=e&&t!=t}function Y(e,t){var r=e[t];if(null!=r){if(!K(r))throw new TypeError;return r}}function Z(e){var t=Y(e,s);if(!K(t))throw new TypeError;var r=t.call(e);if(!W(r))throw new TypeError;return r}function X(e){return e.value}function ee(e){var t=e.next();return!t.done&&t}function te(e){var t=e.return;t&&t.call(e)}function re(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===u)return t;if(t!==u)return t;var r=e.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return t;var i=n.constructor;return"function"!=typeof i||i===e?t:i}function ne(){var e,r,n,i;F(f)||void 0===t.Reflect||f in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=oe(t.Reflect));var s=new h,o={registerProvider:a,getProvider:d,setProvider:m};return o;function a(t){if(!Object.isExtensible(o))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case F(r):r=t;break;case r===t:break;case F(n):n=t;break;case n===t:break;default:void 0===i&&(i=new p),i.add(t)}}function c(t,s){if(!F(r)){if(r.isProviderFor(t,s))return r;if(!F(n)){if(n.isProviderFor(t,s))return r;if(!F(i))for(var o=Z(i);;){var a=ee(o);if(!a)return;var c=X(a);if(c.isProviderFor(t,s))return te(o),c}}}if(!F(e)&&e.isProviderFor(t,s))return e}function d(e,t){var r,n=s.get(e);return F(n)||(r=n.get(t)),F(r)?(F(r=c(e,t))||(F(n)&&(n=new l,s.set(e,n)),n.set(t,r)),r):r}function u(e){if(F(e))throw new TypeError;return r===e||n===e||!F(i)&&i.has(e)}function m(e,t,r){if(!u(r))throw new Error("Metadata provider not registered.");var n=d(e,t);if(n!==r){if(!F(n))return!1;var i=s.get(e);F(i)&&(i=new l,s.set(e,i)),i.set(t,r)}return!0}}function ie(){var e;return!F(f)&&W(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[f]),F(e)&&(e=ne()),!F(f)&&W(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,f,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function se(e){var t=new h,r={isProviderFor:function(e,r){var n=t.get(e);return!F(n)&&n.has(r)},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:i,OrdinaryGetOwnMetadata:s,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:c};return m.registerProvider(r),r;function n(n,i,s){var o=t.get(n),a=!1;if(F(o)){if(!s)return;o=new l,t.set(n,o),a=!0}var c=o.get(i);if(F(c)){if(!s)return;if(c=new l,o.set(i,c),!e.setProvider(n,i,r))throw o.delete(i),a&&t.delete(n),new Error("Wrong provider for target.")}return c}function i(e,t,r){var i=n(t,r,!1);return!F(i)&&z(i.has(e))}function s(e,t,r){var i=n(t,r,!1);if(!F(i))return i.get(e)}function o(e,t,r,i){n(r,i,!0).set(e,t)}function a(e,t){var r=[],i=n(e,t,!1);if(F(i))return r;for(var s=Z(i.keys()),o=0;;){var a=ee(s);if(!a)return r.length=o,r;var c=X(a);try{r[o]=c}catch(e){try{te(s)}finally{throw e}}o++}}function c(e,r,i){var s=n(r,i,!1);if(F(s))return!1;if(!s.delete(e))return!1;if(0===s.size){var o=t.get(r);F(o)||(o.delete(i),0===o.size&&t.delete(o))}return!0}}function oe(e){var t=e.defineMetadata,r=e.hasOwnMetadata,n=e.getOwnMetadata,i=e.getOwnMetadataKeys,s=e.deleteMetadata,o=new h,a={isProviderFor:function(e,t){var r=o.get(e);return!(F(r)||!r.has(t))||!!i(e,t).length&&(F(r)&&(r=new p,o.set(e,r)),r.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:s};return a}function ae(e,t,r){var n=m.getProvider(e,t);if(!F(n))return n;if(r){if(m.setProvider(e,t,g))return g;throw new Error("Illegal state.")}}function ce(){var e={},t=[],r=function(){function e(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return e.prototype["@@iterator"]=function(){return this},e.prototype[s]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}(),n=function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},t.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var n=this._keys.length,i=r+1;i<n;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,J(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new r(this._keys,this._values,i)},t.prototype.values=function(){return new r(this._keys,this._values,o)},t.prototype.entries=function(){return new r(this._keys,this._values,a)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[s]=function(){return this.entries()},t.prototype._find=function(e,t){if(!J(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(J(this._keys[r],e)){this._cacheIndex=r;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();return n;function i(e,t){return e}function o(e,t){return t}function a(e,t){return[e,t]}}function de(){var e=function(){function e(){this._map=new l}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[s]=function(){return this.keys()},e}();return e}function ue(){var e=16,t=d.create(),n=i();return function(){function e(){this._key=i()}return e.prototype.has=function(e){var t=s(e,!1);return void 0!==t&&d.has(t,this._key)},e.prototype.get=function(e){var t=s(e,!1);return void 0!==t?d.get(t,this._key):void 0},e.prototype.set=function(e,t){return s(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=s(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=i()},e}();function i(){var e;do{e="@@WeakMap@@"+c()}while(d.has(t,e));return t[e]=!0,e}function s(e,t){if(!r.call(e,n)){if(!t)return;Object.defineProperty(e,n,{value:d.create()})}return e[n]}function o(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function a(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):o(t,e),t}return o(new Array(e),e)}function c(){var t=a(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var r="",n=0;n<e;++n){var i=t[n];4!==n&&6!==n&&8!==n||(r+="-"),i<16&&(r+="0"),r+=i.toString(16).toLowerCase()}return r}}function le(e){return e.__=void 0,delete e.__,e}e("decorate",v),e("metadata",y),e("defineMetadata",b),e("hasMetadata",w),e("hasOwnMetadata",_),e("getMetadata",S),e("getOwnMetadata",k),e("getMetadataKeys",C),e("getOwnMetadataKeys",R),e("deleteMetadata",P)}(n,r),void 0===r.Reflect&&(r.Reflect=e)}()}(u||(u={}));var f=["inject","multi_inject","name","unmanaged","named","optional"],m="Request",g="Singleton",v="Transient",y="ConstantValue",b="Constructor",w="DynamicValue",_="Factory",S="Function",k="Instance",C="Invalid",R="Provider",P="ClassProperty",T="ConstructorArgument",E="Variable",D=0;function I(){return D++}var M=function(){function e(e,t){this.id=I(),this.activated=!1,this.serviceIdentifier=e,this.scope=t,this.type=C,this.constraint=function(e){return!0},this.implementationType=null,this.cache=null,this.factory=null,this.provider=null,this.onActivation=null,this.onDeactivation=null,this.dynamicValue=null}return e.prototype.clone=function(){var t=new e(this.serviceIdentifier,this.scope);return t.activated=t.scope===g&&this.activated,t.implementationType=this.implementationType,t.dynamicValue=this.dynamicValue,t.scope=this.scope,t.type=this.type,t.factory=this.factory,t.provider=this.provider,t.constraint=this.constraint,t.onActivation=this.onActivation,t.onDeactivation=this.onDeactivation,t.cache=this.cache,t},e}(),x="No matching bindings found for serviceIdentifier:",O="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.",L=function(e,t){return"onDeactivation() error in class "+e+": "+t},A=function(){function e(){}return e.prototype.getConstructorMetadata=function(e){return{compilerGeneratedMetadata:Reflect.getMetadata("inversify:paramtypes",e),userGeneratedMetadata:Reflect.getMetadata("inversify:tagged",e)||{}}},e.prototype.getPropertiesMetadata=function(e){return Reflect.getMetadata("inversify:tagged_props",e)||[]},e}(),j=0,F=1;function N(e){return e instanceof RangeError||"Maximum call stack size exceeded"===e.message}function B(e){return"function"==typeof e?e.name:"symbol"==typeof e?e.toString():e}function W(e,t,r){var n="",i=r(e,t);return 0!==i.length&&(n="\nRegistered bindings:",i.forEach((function(e){var t="Object";null!==e.implementationType&&(t=z(e.implementationType)),n=n+"\n "+t,e.constraint.metaData&&(n=n+" - "+e.constraint.metaData)}))),n}function q(e,t){return null!==e.parentRequest&&(e.parentRequest.serviceIdentifier===t||q(e.parentRequest,t))}function U(e){e.childRequests.forEach((function(e){if(q(e,e.serviceIdentifier)){var t=function(e){return function e(t,r){void 0===r&&(r=[]);var n=B(t.serviceIdentifier);return r.push(n),null!==t.parentRequest?e(t.parentRequest,r):r}(e).reverse().join(" --\x3e ")}(e);throw new Error("Circular dependency found: "+t)}U(e)}))}function z(e){if(e.name)return e.name;var t=e.toString(),r=t.match(/^function\s*([^\s(]+)/);return r?r[1]:"Anonymous function: "+t}var V=function(){function e(e){this.id=I(),this.container=e}return e.prototype.addPlan=function(e){this.plan=e},e.prototype.setCurrentRequest=function(e){this.currentRequest=e},e}(),H=function(){function e(e,t){this.key=e,this.value=t}return e.prototype.toString=function(){return"named"===this.key?"named: "+String(this.value).toString()+" ":"tagged: { key:"+this.key.toString()+", value: "+String(this.value)+" }"},e}(),$=function(e,t){this.parentContext=e,this.rootRequest=t},K=function(){function e(e){this._cb=e}return e.prototype.unwrap=function(){return this._cb()},e}(),G=function(){function e(e){this.str=e}return e.prototype.startsWith=function(e){return 0===this.str.indexOf(e)},e.prototype.endsWith=function(e){var t,r=e.split("").reverse().join("");return t=this.str.split("").reverse().join(""),this.startsWith.call({str:t},r)},e.prototype.contains=function(e){return-1!==this.str.indexOf(e)},e.prototype.equals=function(e){return this.str===e},e.prototype.value=function(){return this.str},e}(),Q=function(){function e(e,t,r,n){this.id=I(),this.type=e,this.serviceIdentifier=r;var i="symbol"==typeof t?t.toString().slice(7,-1):t;this.name=new G(i||""),this.identifier=t,this.metadata=new Array;var s=null;"string"==typeof n?s=new H("named",n):n instanceof H&&(s=n),null!==s&&this.metadata.push(s)}return e.prototype.hasTag=function(e){for(var t=0,r=this.metadata;t<r.length;t++){if(r[t].key===e)return!0}return!1},e.prototype.isArray=function(){return this.hasTag("multi_inject")},e.prototype.matchesArray=function(e){return this.matchesTag("multi_inject")(e)},e.prototype.isNamed=function(){return this.hasTag("named")},e.prototype.isTagged=function(){return this.metadata.some((function(e){return f.every((function(t){return e.key!==t}))}))},e.prototype.isOptional=function(){return this.matchesTag("optional")(!0)},e.prototype.getNamedTag=function(){return this.isNamed()?this.metadata.filter((function(e){return"named"===e.key}))[0]:null},e.prototype.getCustomTags=function(){return this.isTagged()?this.metadata.filter((function(e){return f.every((function(t){return e.key!==t}))})):null},e.prototype.matchesNamedTag=function(e){return this.matchesTag("named")(e)},e.prototype.matchesTag=function(e){var t=this;return function(r){for(var n=0,i=t.metadata;n<i.length;n++){var s=i[n];if(s.key===e&&s.value===r)return!0}return!1}},e}(),J=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function Y(e,t,r,n){var i=e.getConstructorMetadata(r),s=i.compilerGeneratedMetadata;if(void 0===s)throw new Error("Missing required @injectable annotation in: "+t+".");var o=i.userGeneratedMetadata,a=Object.keys(o),c=0===r.length&&a.length>0,d=a.length>r.length,u=function(e,t,r,n,i){for(var s=[],o=0;o<i;o++){var a=Z(o,e,t,r,n);null!==a&&s.push(a)}return s}(n,t,s,o,c||d?a.length:r.length),l=ee(e,r,t);return J(J([],u,!0),l,!0)}function Z(e,t,r,n,i){var s=i[e.toString()]||[],o=re(s),a=!0!==o.unmanaged,c=n[e],d=o.inject||o.multiInject;if((c=d||c)instanceof K&&(c=c.unwrap()),a){if(!t&&(c===Object||c===Function||void 0===c))throw new Error("Missing required @inject or @multiInject annotation in: argument "+e+" in class "+r+".");var u=new Q(T,o.targetName,c);return u.metadata=s,u}return null}function X(e,t,r,n){var i=e||t;if(void 0===i){var s="Missing required @injectable annotation in: for property "+String(r)+" in class "+n+".";throw new Error(s)}return i}function ee(e,t,r){for(var n=e.getPropertiesMetadata(t),i=[],s=Object.getOwnPropertySymbols(n),o=0,a=Object.keys(n).concat(s);o<a.length;o++){var c=a[o],d=n[c],u=re(d),l=u.targetName||c,p=X(u.inject,u.multiInject,c,r),h=new Q(P,l,p);h.metadata=d,i.push(h)}var f=Object.getPrototypeOf(t.prototype).constructor;if(f!==Object){var m=ee(e,f,r);i=J(J([],i,!0),m,!0)}return i}function te(e,t){var r=Object.getPrototypeOf(t.prototype).constructor;if(r!==Object){var n=Y(e,z(r),r,!0),i=n.map((function(e){return e.metadata.filter((function(e){return"unmanaged"===e.key}))})),s=[].concat.apply([],i).length,o=n.length-s;return o>0?o:te(e,r)}return 0}function re(e){var t={};return e.forEach((function(e){t[e.key.toString()]=e.value})),{inject:t.inject,multiInject:t.multi_inject,targetName:t.name,unmanaged:t.unmanaged}}var ne=function(){function e(e,t,r,n,i){this.id=I(),this.serviceIdentifier=e,this.parentContext=t,this.parentRequest=r,this.target=i,this.childRequests=[],this.bindings=Array.isArray(n)?n:[n],this.requestScope=null===r?new Map:null}return e.prototype.addChildRequest=function(t,r,n){var i=new e(t,this.parentContext,this,r,n);return this.childRequests.push(i),i},e}();function ie(e){return e._bindingDictionary}function se(e,t,r,n,i){var s=ae(r.container,i.serviceIdentifier),o=[];return s.length===j&&r.container.options.autoBindInjectable&&"function"==typeof i.serviceIdentifier&&e.getConstructorMetadata(i.serviceIdentifier).compilerGeneratedMetadata&&(r.container.bind(i.serviceIdentifier).toSelf(),s=ae(r.container,i.serviceIdentifier)),o=t?s:s.filter((function(e){var t=new ne(e.serviceIdentifier,r,n,e,i);return e.constraint(t)})),function(e,t,r,n){switch(t.length){case j:if(r.isOptional())return t;var i=B(e),s=x;throw s+=function(e,t){if(t.isTagged()||t.isNamed()){var r="",n=t.getNamedTag(),i=t.getCustomTags();return null!==n&&(r+=n.toString()+"\n"),null!==i&&i.forEach((function(e){r+=e.toString()+"\n"}))," "+e+"\n "+e+" - "+r}return" "+e}(i,r),s+=W(n,i,ae),new Error(s);case F:return t;default:if(r.isArray())return t;s="Ambiguous match found for serviceIdentifier: "+(i=B(e));throw s+=W(n,i,ae),new Error(s)}}(i.serviceIdentifier,o,i,r.container),o}function oe(e,t,r,n,i,s){var o,a;if(null===i){o=se(e,t,n,null,s),a=new ne(r,n,null,o,s);var c=new $(n,a);n.addPlan(c)}else o=se(e,t,n,i,s),a=i.addChildRequest(s.serviceIdentifier,o,s);o.forEach((function(t){var r=null;if(s.isArray())r=a.addChildRequest(t.serviceIdentifier,t,s);else{if(t.cache)return;r=a}if(t.type===k&&null!==t.implementationType){var i=function(e,t){return Y(e,z(t),t,!1)}(e,t.implementationType);if(!n.container.options.skipBaseClassChecks){var o=te(e,t.implementationType);if(i.length<o){var c=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"The number of constructor arguments in the derived class "+e[0]+" must be >= than the number of constructor arguments of its base class."}(z(t.implementationType));throw new Error(c)}}i.forEach((function(t){oe(e,!1,t.serviceIdentifier,n,r,t)}))}}))}function ae(e,t){var r=[],n=ie(e);return n.hasKey(t)?r=n.get(t):null!==e.parent&&(r=ae(e.parent,t)),r}function ce(e,t,r,n,i,s,o,a){void 0===a&&(a=!1);var c=new V(t),d=function(e,t,r,n,i,s){var o=new H(e?"multi_inject":"inject",r),a=new Q(t,n,r,o);if(void 0!==i){var c=new H(i,s);a.metadata.push(c)}return a}(r,n,i,"",s,o);try{return oe(e,a,i,c,null,d),c}catch(e){throw N(e)&&U(c.plan.rootRequest),e}}function de(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then}function ue(e){return!!de(e)||Array.isArray(e)&&e.some(de)}var le,pe=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},he=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},fe=function(e,t,r){e.has(t.id)||e.set(t.id,r)},me=function(e,t){e.cache=t,e.activated=!0,de(t)&&ge(e,t)},ge=function(e,t){return pe(void 0,void 0,void 0,(function(){var r,n;return he(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t];case 1:return r=i.sent(),e.cache=r,[3,3];case 2:throw n=i.sent(),e.cache=null,e.activated=!1,n;case 3:return[2]}}))}))};!function(e){e.DynamicValue="toDynamicValue",e.Factory="toFactory",e.Provider="toProvider"}(le||(le={}));var ve=function(){return ve=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ve.apply(this,arguments)},ye=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},be=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},we=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function _e(e,t,r){var n;if(t.length>0){var i=function(e,t){return e.reduce((function(e,r){var n=t(r);return r.target.type===T?e.constructorInjections.push(n):(e.propertyRequests.push(r),e.propertyInjections.push(n)),e.isAsync||(e.isAsync=ue(n)),e}),{constructorInjections:[],propertyInjections:[],propertyRequests:[],isAsync:!1})}(t,r),s=ve(ve({},i),{constr:e});n=i.isAsync?function(e){return ye(this,void 0,void 0,(function(){var t,r;return be(this,(function(n){switch(n.label){case 0:return[4,ke(e.constructorInjections)];case 1:return t=n.sent(),[4,ke(e.propertyInjections)];case 2:return r=n.sent(),[2,Se(ve(ve({},e),{constructorInjections:t,propertyInjections:r}))]}}))}))}(s):Se(s)}else n=new e;return n}function Se(e){var t,r=new((t=e.constr).bind.apply(t,we([void 0],e.constructorInjections,!1)));return e.propertyRequests.forEach((function(t,n){var i=t.target.identifier,s=e.propertyInjections[n];t.target.isOptional()&&void 0===s||(r[i]=s)})),r}function ke(e){return ye(this,void 0,void 0,(function(){var t,r,n,i;return be(this,(function(s){for(t=[],r=0,n=e;r<n.length;r++)i=n[r],Array.isArray(i)?t.push(Promise.all(i)):t.push(i);return[2,Promise.all(t)]}))}))}function Ce(e,t){var r=function(e,t){var r,n;if(Reflect.hasMetadata("post_construct",e)){var i=Reflect.getMetadata("post_construct",e);try{return null===(n=(r=t)[i.value])||void 0===n?void 0:n.call(r)}catch(t){if(t instanceof Error)throw new Error((s=e.name,o=t.message,"@postConstruct error in class "+s+": "+o))}}var s,o}(e,t);return de(r)?r.then((function(){return t})):t}function Re(e,t){e.scope!==g&&function(e,t){var r="Class cannot be instantiated in "+(e.scope===m?"request":"transient")+" scope.";if("function"==typeof e.onDeactivation)throw new Error(L(t.name,r));if(Reflect.hasMetadata("pre_destroy",t))throw new Error("@preDestroy error in class "+t.name+": "+r)}(e,t)}var Pe=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},Te=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},Ee=function(e){return function(t){t.parentContext.setCurrentRequest(t);var r=t.bindings,n=t.childRequests,i=t.target&&t.target.isArray(),s=!(t.parentRequest&&t.parentRequest.target&&t.target&&t.parentRequest.target.matchesArray(t.target.serviceIdentifier));if(i&&s)return n.map((function(t){return Ee(e)(t)}));if(!t.target.isOptional()||0!==r.length){var o=r[0];return xe(e,t,o)}}},De=function(e,t){var r=function(e){switch(e.type){case _:return{factory:e.factory,factoryType:le.Factory};case R:return{factory:e.provider,factoryType:le.Provider};case w:return{factory:e.dynamicValue,factoryType:le.DynamicValue};default:throw new Error("Unexpected factory type "+e.type)}}(e);return function(e,t){try{return e()}catch(e){throw N(e)&&(e=t()),e}}((function(){return r.factory.bind(e)(t)}),(function(){return new Error((e=r.factoryType,n=t.currentRequest.serviceIdentifier.toString(),"It looks like there is a circular dependency in one of the '"+e+"' bindings. Please investigate bindings with service identifier '"+n+"'."));var e,n}))},Ie=function(e,t,r){var n,i=t.childRequests;switch(function(e){var t=null;switch(e.type){case y:case S:t=e.cache;break;case b:case k:t=e.implementationType;break;case w:t=e.dynamicValue;break;case R:t=e.provider;break;case _:t=e.factory}if(null===t){var r=B(e.serviceIdentifier);throw new Error("Invalid binding type: "+r)}}(r),r.type){case y:case S:n=r.cache;break;case b:n=r.implementationType;break;case k:n=function(e,t,r,n){Re(e,t);var i=_e(t,r,n);return de(i)?i.then((function(e){return Ce(t,e)})):Ce(t,i)}(r,r.implementationType,i,Ee(e));break;default:n=De(r,t.parentContext)}return n},Me=function(e,t,r){var n=function(e,t){return t.scope===g&&t.activated?t.cache:t.scope===m&&e.has(t.id)?e.get(t.id):null}(e,t);return null!==n||function(e,t,r){t.scope===g&&me(t,r),t.scope===m&&fe(e,t,r)}(e,t,n=r()),n},xe=function(e,t,r){return Me(e,r,(function(){var n=Ie(e,t,r);return n=de(n)?n.then((function(e){return Oe(t,r,e)})):Oe(t,r,n)}))};function Oe(e,t,r){var n,i=Le(e.parentContext,t,r),s=Ne(e.parentContext.container),o=s.next();do{n=o.value;var a=e.parentContext,c=e.serviceIdentifier,d=Fe(n,c);i=de(i)?je(d,a,i):Ae(d,a,i),o=s.next()}while(!0!==o.done&&!ie(n).hasKey(e.serviceIdentifier));return i}var Le=function(e,t,r){return"function"==typeof t.onActivation?t.onActivation(e,r):r},Ae=function(e,t,r){for(var n=e.next();!n.done;){if(de(r=n.value(t,r)))return je(e,t,r);n=e.next()}return r},je=function(e,t,r){return Pe(void 0,void 0,void 0,(function(){var n,i;return Te(this,(function(s){switch(s.label){case 0:return[4,r];case 1:n=s.sent(),i=e.next(),s.label=2;case 2:return i.done?[3,4]:[4,i.value(t,n)];case 3:return n=s.sent(),i=e.next(),[3,2];case 4:return[2,n]}}))}))},Fe=function(e,t){var r=e._activations;return r.hasKey(t)?r.get(t).values():[].values()},Ne=function(e){for(var t=[e],r=e.parent;null!==r;)t.push(r),r=r.parent;return{next:function(){var e=t.pop();return void 0!==e?{done:!1,value:e}:{done:!0,value:void 0}}}};var Be=function(e,t){var r=e.parentRequest;return null!==r&&(!!t(r)||Be(r,t))},We=function(e){return function(t){var r=function(r){return null!==r&&null!==r.target&&r.target.matchesTag(e)(t)};return r.metaData=new H(e,t),r}},qe=We("named"),Ue=function(e){return function(t){var r=null;if(null!==t){if(r=t.bindings[0],"string"==typeof e)return r.serviceIdentifier===e;var n=t.bindings[0].implementationType;return e===n}return!1}},ze=function(){function e(e){this._binding=e}return e.prototype.when=function(e){return this._binding.constraint=e,new Ve(this._binding)},e.prototype.whenTargetNamed=function(e){return this._binding.constraint=qe(e),new Ve(this._binding)},e.prototype.whenTargetIsDefault=function(){return this._binding.constraint=function(e){return null!==e&&(null!==e.target&&!e.target.isNamed()&&!e.target.isTagged())},new Ve(this._binding)},e.prototype.whenTargetTagged=function(e,t){return this._binding.constraint=We(e)(t),new Ve(this._binding)},e.prototype.whenInjectedInto=function(e){return this._binding.constraint=function(t){return null!==t&&Ue(e)(t.parentRequest)},new Ve(this._binding)},e.prototype.whenParentNamed=function(e){return this._binding.constraint=function(t){return null!==t&&qe(e)(t.parentRequest)},new Ve(this._binding)},e.prototype.whenParentTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&We(e)(t)(r.parentRequest)},new Ve(this._binding)},e.prototype.whenAnyAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&Be(t,Ue(e))},new Ve(this._binding)},e.prototype.whenNoAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&!Be(t,Ue(e))},new Ve(this._binding)},e.prototype.whenAnyAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&Be(t,qe(e))},new Ve(this._binding)},e.prototype.whenNoAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&!Be(t,qe(e))},new Ve(this._binding)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&Be(r,We(e)(t))},new Ve(this._binding)},e.prototype.whenNoAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&!Be(r,We(e)(t))},new Ve(this._binding)},e.prototype.whenAnyAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&Be(t,e)},new Ve(this._binding)},e.prototype.whenNoAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&!Be(t,e)},new Ve(this._binding)},e}(),Ve=function(){function e(e){this._binding=e}return e.prototype.onActivation=function(e){return this._binding.onActivation=e,new ze(this._binding)},e.prototype.onDeactivation=function(e){return this._binding.onDeactivation=e,new ze(this._binding)},e}(),He=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new ze(this._binding),this._bindingOnSyntax=new Ve(this._binding)}return e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e.prototype.onDeactivation=function(e){return this._bindingOnSyntax.onDeactivation(e)},e}(),$e=function(){function e(e){this._binding=e}return e.prototype.inRequestScope=function(){return this._binding.scope=m,new He(this._binding)},e.prototype.inSingletonScope=function(){return this._binding.scope=g,new He(this._binding)},e.prototype.inTransientScope=function(){return this._binding.scope=v,new He(this._binding)},e}(),Ke=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new ze(this._binding),this._bindingOnSyntax=new Ve(this._binding),this._bindingInSyntax=new $e(e)}return e.prototype.inRequestScope=function(){return this._bindingInSyntax.inRequestScope()},e.prototype.inSingletonScope=function(){return this._bindingInSyntax.inSingletonScope()},e.prototype.inTransientScope=function(){return this._bindingInSyntax.inTransientScope()},e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e.prototype.onDeactivation=function(e){return this._bindingOnSyntax.onDeactivation(e)},e}(),Ge=function(){function e(e){this._binding=e}return e.prototype.to=function(e){return this._binding.type=k,this._binding.implementationType=e,new Ke(this._binding)},e.prototype.toSelf=function(){if("function"!=typeof this._binding.serviceIdentifier)throw new Error("The toSelf function can only be applied when a constructor is used as service identifier");var e=this._binding.serviceIdentifier;return this.to(e)},e.prototype.toConstantValue=function(e){return this._binding.type=y,this._binding.cache=e,this._binding.dynamicValue=null,this._binding.implementationType=null,this._binding.scope=g,new He(this._binding)},e.prototype.toDynamicValue=function(e){return this._binding.type=w,this._binding.cache=null,this._binding.dynamicValue=e,this._binding.implementationType=null,new Ke(this._binding)},e.prototype.toConstructor=function(e){return this._binding.type=b,this._binding.implementationType=e,this._binding.scope=g,new He(this._binding)},e.prototype.toFactory=function(e){return this._binding.type=_,this._binding.factory=e,this._binding.scope=g,new He(this._binding)},e.prototype.toFunction=function(e){if("function"!=typeof e)throw new Error("Value provided to function binding must be a function!");var t=this.toConstantValue(e);return this._binding.type=S,this._binding.scope=g,t},e.prototype.toAutoFactory=function(e){return this._binding.type=_,this._binding.factory=function(t){return function(){return t.container.get(e)}},this._binding.scope=g,new He(this._binding)},e.prototype.toAutoNamedFactory=function(e){return this._binding.type=_,this._binding.factory=function(t){return function(r){return t.container.getNamed(e,r)}},new He(this._binding)},e.prototype.toProvider=function(e){return this._binding.type=R,this._binding.provider=e,this._binding.scope=g,new He(this._binding)},e.prototype.toService=function(e){this.toDynamicValue((function(t){return t.container.get(e)}))},e}(),Qe=function(){function e(){}return e.of=function(t,r,n,i,s){var o=new e;return o.bindings=t,o.middleware=r,o.deactivations=i,o.activations=n,o.moduleActivationStore=s,o},e}();var Je=function(){function e(){this._map=new Map}return e.prototype.getMap=function(){return this._map},e.prototype.add=function(e,t){if(null==e)throw new Error("NULL argument");if(null==t)throw new Error("NULL argument");var r=this._map.get(e);void 0!==r?r.push(t):this._map.set(e,[t])},e.prototype.get=function(e){if(null==e)throw new Error("NULL argument");var t=this._map.get(e);if(void 0!==t)return t;throw new Error("Key Not Found")},e.prototype.remove=function(e){if(null==e)throw new Error("NULL argument");if(!this._map.delete(e))throw new Error("Key Not Found")},e.prototype.removeIntersection=function(e){var t=this;this.traverse((function(r,n){var i=e.hasKey(r)?e.get(r):void 0;if(void 0!==i){var s=n.filter((function(e){return!i.some((function(t){return e===t}))}));t._setValue(r,s)}}))},e.prototype.removeByCondition=function(e){var t=this,r=[];return this._map.forEach((function(n,i){for(var s=[],o=0,a=n;o<a.length;o++){var c=a[o];e(c)?r.push(c):s.push(c)}t._setValue(i,s)})),r},e.prototype.hasKey=function(e){if(null==e)throw new Error("NULL argument");return this._map.has(e)},e.prototype.clone=function(){var t=new e;return this._map.forEach((function(e,r){e.forEach((function(e){return t.add(r,"object"==typeof(n=e)&&null!==n&&"clone"in n&&"function"==typeof n.clone?e.clone():e);var n}))})),t},e.prototype.traverse=function(e){this._map.forEach((function(t,r){e(r,t)}))},e.prototype._setValue=function(e,t){t.length>0?this._map.set(e,t):this._map.delete(e)},e}(),Ye=function(){function e(){this._map=new Map}return e.prototype.remove=function(e){if(this._map.has(e)){var t=this._map.get(e);return this._map.delete(e),t}return this._getEmptyHandlersStore()},e.prototype.addDeactivation=function(e,t,r){this._getModuleActivationHandlers(e).onDeactivations.add(t,r)},e.prototype.addActivation=function(e,t,r){this._getModuleActivationHandlers(e).onActivations.add(t,r)},e.prototype.clone=function(){var t=new e;return this._map.forEach((function(e,r){t._map.set(r,{onActivations:e.onActivations.clone(),onDeactivations:e.onDeactivations.clone()})})),t},e.prototype._getModuleActivationHandlers=function(e){var t=this._map.get(e);return void 0===t&&(t=this._getEmptyHandlersStore(),this._map.set(e,t)),t},e.prototype._getEmptyHandlersStore=function(){return{onActivations:new Je,onDeactivations:new Je}},e}(),Ze=function(){return Ze=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ze.apply(this,arguments)},Xe=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},et=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},tt=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},rt=function(){function e(e){var t=e||{};if("object"!=typeof t)throw new Error("Invalid Container constructor argument. Container options must be an object.");if(void 0===t.defaultScope)t.defaultScope=v;else if(t.defaultScope!==g&&t.defaultScope!==v&&t.defaultScope!==m)throw new Error('Invalid Container option. Default scope must be a string ("singleton" or "transient").');if(void 0===t.autoBindInjectable)t.autoBindInjectable=!1;else if("boolean"!=typeof t.autoBindInjectable)throw new Error("Invalid Container option. Auto bind injectable must be a boolean");if(void 0===t.skipBaseClassChecks)t.skipBaseClassChecks=!1;else if("boolean"!=typeof t.skipBaseClassChecks)throw new Error("Invalid Container option. Skip base check must be a boolean");this.options={autoBindInjectable:t.autoBindInjectable,defaultScope:t.defaultScope,skipBaseClassChecks:t.skipBaseClassChecks},this.id=I(),this._bindingDictionary=new Je,this._snapshots=[],this._middleware=null,this._activations=new Je,this._deactivations=new Je,this.parent=null,this._metadataReader=new A,this._moduleActivationStore=new Ye}return e.merge=function(t,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var s=new e,o=tt([t,r],n,!0).map((function(e){return ie(e)})),a=ie(s);function c(e,t){e.traverse((function(e,r){r.forEach((function(e){t.add(e.serviceIdentifier,e.clone())}))}))}return o.forEach((function(e){c(e,a)})),s},e.prototype.load=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=this._getContainerModuleHelpersFactory(),n=0,i=e;n<i.length;n++){var s=i[n],o=r(s.id);s.registry(o.bindFunction,o.unbindFunction,o.isboundFunction,o.rebindFunction,o.unbindAsyncFunction,o.onActivationFunction,o.onDeactivationFunction)}},e.prototype.loadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Xe(this,void 0,void 0,(function(){var t,r,n,i,s;return et(this,(function(o){switch(o.label){case 0:t=this._getContainerModuleHelpersFactory(),r=0,n=e,o.label=1;case 1:return r<n.length?(i=n[r],s=t(i.id),[4,i.registry(s.bindFunction,s.unbindFunction,s.isboundFunction,s.rebindFunction,s.unbindAsyncFunction,s.onActivationFunction,s.onDeactivationFunction)]):[3,4];case 2:o.sent(),o.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}))},e.prototype.unload=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];t.forEach((function(t){var r=e._removeModuleBindings(t.id);e._deactivateSingletons(r),e._removeModuleHandlers(t.id)}))},e.prototype.unloadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Xe(this,void 0,void 0,(function(){var t,r,n,i;return et(this,(function(s){switch(s.label){case 0:t=0,r=e,s.label=1;case 1:return t<r.length?(n=r[t],i=this._removeModuleBindings(n.id),[4,this._deactivateSingletonsAsync(i)]):[3,4];case 2:s.sent(),this._removeModuleHandlers(n.id),s.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},e.prototype.bind=function(e){var t=this.options.defaultScope||v,r=new M(e,t);return this._bindingDictionary.add(e,r),new Ge(r)},e.prototype.rebind=function(e){return this.unbind(e),this.bind(e)},e.prototype.rebindAsync=function(e){return Xe(this,void 0,void 0,(function(){return et(this,(function(t){switch(t.label){case 0:return[4,this.unbindAsync(e)];case 1:return t.sent(),[2,this.bind(e)]}}))}))},e.prototype.unbind=function(e){if(this._bindingDictionary.hasKey(e)){var t=this._bindingDictionary.get(e);this._deactivateSingletons(t)}this._removeServiceFromDictionary(e)},e.prototype.unbindAsync=function(e){return Xe(this,void 0,void 0,(function(){var t;return et(this,(function(r){switch(r.label){case 0:return this._bindingDictionary.hasKey(e)?(t=this._bindingDictionary.get(e),[4,this._deactivateSingletonsAsync(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return this._removeServiceFromDictionary(e),[2]}}))}))},e.prototype.unbindAll=function(){var e=this;this._bindingDictionary.traverse((function(t,r){e._deactivateSingletons(r)})),this._bindingDictionary=new Je},e.prototype.unbindAllAsync=function(){return Xe(this,void 0,void 0,(function(){var e,t=this;return et(this,(function(r){switch(r.label){case 0:return e=[],this._bindingDictionary.traverse((function(r,n){e.push(t._deactivateSingletonsAsync(n))})),[4,Promise.all(e)];case 1:return r.sent(),this._bindingDictionary=new Je,[2]}}))}))},e.prototype.onActivation=function(e,t){this._activations.add(e,t)},e.prototype.onDeactivation=function(e,t){this._deactivations.add(e,t)},e.prototype.isBound=function(e){var t=this._bindingDictionary.hasKey(e);return!t&&this.parent&&(t=this.parent.isBound(e)),t},e.prototype.isCurrentBound=function(e){return this._bindingDictionary.hasKey(e)},e.prototype.isBoundNamed=function(e,t){return this.isBoundTagged(e,"named",t)},e.prototype.isBoundTagged=function(e,t,r){var n=!1;if(this._bindingDictionary.hasKey(e)){var i=this._bindingDictionary.get(e),s=function(e,t,r,n){var i=new Q(E,"",t,new H(r,n)),s=new V(e);return new ne(t,s,null,[],i)}(this,e,t,r);n=i.some((function(e){return e.constraint(s)}))}return!n&&this.parent&&(n=this.parent.isBoundTagged(e,t,r)),n},e.prototype.snapshot=function(){this._snapshots.push(Qe.of(this._bindingDictionary.clone(),this._middleware,this._activations.clone(),this._deactivations.clone(),this._moduleActivationStore.clone()))},e.prototype.restore=function(){var e=this._snapshots.pop();if(void 0===e)throw new Error("No snapshot available to restore.");this._bindingDictionary=e.bindings,this._activations=e.activations,this._deactivations=e.deactivations,this._middleware=e.middleware,this._moduleActivationStore=e.moduleActivationStore},e.prototype.createChild=function(t){var r=new e(t||this.options);return r.parent=this,r},e.prototype.applyMiddleware=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=this._middleware?this._middleware:this._planAndResolve();this._middleware=e.reduce((function(e,t){return t(e)}),r)},e.prototype.applyCustomMetadataReader=function(e){this._metadataReader=e},e.prototype.get=function(e){var t=this._getNotAllArgs(e,!1);return this._getButThrowIfAsync(t)},e.prototype.getAsync=function(e){return Xe(this,void 0,void 0,(function(){var t;return et(this,(function(r){return t=this._getNotAllArgs(e,!1),[2,this._get(t)]}))}))},e.prototype.getTagged=function(e,t,r){var n=this._getNotAllArgs(e,!1,t,r);return this._getButThrowIfAsync(n)},e.prototype.getTaggedAsync=function(e,t,r){return Xe(this,void 0,void 0,(function(){var n;return et(this,(function(i){return n=this._getNotAllArgs(e,!1,t,r),[2,this._get(n)]}))}))},e.prototype.getNamed=function(e,t){return this.getTagged(e,"named",t)},e.prototype.getNamedAsync=function(e,t){return this.getTaggedAsync(e,"named",t)},e.prototype.getAll=function(e){var t=this._getAllArgs(e);return this._getButThrowIfAsync(t)},e.prototype.getAllAsync=function(e){var t=this._getAllArgs(e);return this._getAll(t)},e.prototype.getAllTagged=function(e,t,r){var n=this._getNotAllArgs(e,!0,t,r);return this._getButThrowIfAsync(n)},e.prototype.getAllTaggedAsync=function(e,t,r){var n=this._getNotAllArgs(e,!0,t,r);return this._getAll(n)},e.prototype.getAllNamed=function(e,t){return this.getAllTagged(e,"named",t)},e.prototype.getAllNamedAsync=function(e,t){return this.getAllTaggedAsync(e,"named",t)},e.prototype.resolve=function(e){var t=this.isBound(e);t||this.bind(e).toSelf();var r=this.get(e);return t||this.unbind(e),r},e.prototype._preDestroy=function(e,t){var r,n;if(Reflect.hasMetadata("pre_destroy",e))return null===(n=(r=t)[Reflect.getMetadata("pre_destroy",e).value])||void 0===n?void 0:n.call(r)},e.prototype._removeModuleHandlers=function(e){var t=this._moduleActivationStore.remove(e);this._activations.removeIntersection(t.onActivations),this._deactivations.removeIntersection(t.onDeactivations)},e.prototype._removeModuleBindings=function(e){return this._bindingDictionary.removeByCondition((function(t){return t.moduleId===e}))},e.prototype._deactivate=function(e,t){var r=this,n=Object.getPrototypeOf(t).constructor;try{if(this._deactivations.hasKey(e.serviceIdentifier)){var i=this._deactivateContainer(t,this._deactivations.get(e.serviceIdentifier).values());if(de(i))return this._handleDeactivationError(i.then((function(){return r._propagateContainerDeactivationThenBindingAndPreDestroyAsync(e,t,n)})),n)}var s=this._propagateContainerDeactivationThenBindingAndPreDestroy(e,t,n);if(de(s))return this._handleDeactivationError(s,n)}catch(e){if(e instanceof Error)throw new Error(L(n.name,e.message))}},e.prototype._handleDeactivationError=function(e,t){return Xe(this,void 0,void 0,(function(){var r;return et(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e];case 1:return n.sent(),[3,3];case 2:if((r=n.sent())instanceof Error)throw new Error(L(t.name,r.message));return[3,3];case 3:return[2]}}))}))},e.prototype._deactivateContainer=function(e,t){for(var r=this,n=t.next();n.value;){var i=n.value(e);if(de(i))return i.then((function(){return r._deactivateContainerAsync(e,t)}));n=t.next()}},e.prototype._deactivateContainerAsync=function(e,t){return Xe(this,void 0,void 0,(function(){var r;return et(this,(function(n){switch(n.label){case 0:r=t.next(),n.label=1;case 1:return r.value?[4,r.value(e)]:[3,3];case 2:return n.sent(),r=t.next(),[3,1];case 3:return[2]}}))}))},e.prototype._getContainerModuleHelpersFactory=function(){var e=this,t=function(e,t){e._binding.moduleId=t},r=function(r){return function(n){var i=e.rebind(n);return t(i,r),i}},n=function(t){return function(r,n){e._moduleActivationStore.addActivation(t,r,n),e.onActivation(r,n)}},i=function(t){return function(r,n){e._moduleActivationStore.addDeactivation(t,r,n),e.onDeactivation(r,n)}};return function(s){return{bindFunction:(o=s,function(r){var n=e.bind(r);return t(n,o),n}),isboundFunction:function(t){return e.isBound(t)},onActivationFunction:n(s),onDeactivationFunction:i(s),rebindFunction:r(s),unbindFunction:function(t){return e.unbind(t)},unbindAsyncFunction:function(t){return e.unbindAsync(t)}};var o}},e.prototype._getAll=function(e){return Promise.all(this._get(e))},e.prototype._get=function(e){var t=Ze(Ze({},e),{contextInterceptor:function(e){return e},targetType:E});if(this._middleware){var r=this._middleware(t);if(null==r)throw new Error("Invalid return type in middleware. Middleware must return!");return r}return this._planAndResolve()(t)},e.prototype._getButThrowIfAsync=function(e){var t=this._get(e);if(ue(t))throw new Error("You are attempting to construct '"+e.serviceIdentifier+"' in a synchronous way\n but it has asynchronous dependencies.");return t},e.prototype._getAllArgs=function(e){return{avoidConstraints:!0,isMultiInject:!0,serviceIdentifier:e}},e.prototype._getNotAllArgs=function(e,t,r,n){return{avoidConstraints:!1,isMultiInject:t,serviceIdentifier:e,key:r,value:n}},e.prototype._planAndResolve=function(){var e=this;return function(t){var r=ce(e._metadataReader,e,t.isMultiInject,t.targetType,t.serviceIdentifier,t.key,t.value,t.avoidConstraints);return function(e){return Ee(e.plan.rootRequest.requestScope)(e.plan.rootRequest)}(r=t.contextInterceptor(r))}},e.prototype._deactivateIfSingleton=function(e){var t=this;if(e.activated)return de(e.cache)?e.cache.then((function(r){return t._deactivate(e,r)})):this._deactivate(e,e.cache)},e.prototype._deactivateSingletons=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(de(this._deactivateIfSingleton(n)))throw new Error("Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)")}},e.prototype._deactivateSingletonsAsync=function(e){return Xe(this,void 0,void 0,(function(){var t=this;return et(this,(function(r){switch(r.label){case 0:return[4,Promise.all(e.map((function(e){return t._deactivateIfSingleton(e)})))];case 1:return r.sent(),[2]}}))}))},e.prototype._propagateContainerDeactivationThenBindingAndPreDestroy=function(e,t,r){return this.parent?this._deactivate.bind(this.parent)(e,t):this._bindingDeactivationAndPreDestroy(e,t,r)},e.prototype._propagateContainerDeactivationThenBindingAndPreDestroyAsync=function(e,t,r){return Xe(this,void 0,void 0,(function(){return et(this,(function(n){switch(n.label){case 0:return this.parent?[4,this._deactivate.bind(this.parent)(e,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,this._bindingDeactivationAndPreDestroyAsync(e,t,r)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},e.prototype._removeServiceFromDictionary=function(e){try{this._bindingDictionary.remove(e)}catch(t){throw new Error("Could not unbind serviceIdentifier: "+B(e))}},e.prototype._bindingDeactivationAndPreDestroy=function(e,t,r){var n=this;if("function"==typeof e.onDeactivation){var i=e.onDeactivation(t);if(de(i))return i.then((function(){return n._preDestroy(r,t)}))}return this._preDestroy(r,t)},e.prototype._bindingDeactivationAndPreDestroyAsync=function(e,t,r){return Xe(this,void 0,void 0,(function(){return et(this,(function(n){switch(n.label){case 0:return"function"!=typeof e.onDeactivation?[3,2]:[4,e.onDeactivation(t)];case 1:n.sent(),n.label=2;case 2:return[4,this._preDestroy(r,t)];case 3:return n.sent(),[2]}}))}))},e}();function nt(e,t,r,n){!function(e){if(void 0!==e)throw new Error(O)}(t),st("inversify:tagged",e,r.toString(),n)}function it(e){var t=[];if(Array.isArray(e)){var r=function(e){for(var t=new Set,r=0,n=e;r<n.length;r++){var i=n[r];if(t.has(i))return i;t.add(i)}}((t=e).map((function(e){return e.key})));if(void 0!==r)throw new Error("Metadata key was used more than once in a parameter: "+r.toString())}else t=[e];return t}function st(e,t,r,n){var i=it(n),s={};Reflect.hasOwnMetadata(e,t)&&(s=Reflect.getMetadata(e,t));var o=s[r];if(void 0===o)o=[];else for(var a=function(e){if(i.some((function(t){return t.key===e.key})))throw new Error("Metadata key was used more than once in a parameter: "+e.key.toString())},c=0,d=o;c<d.length;c++){a(d[c])}o.push.apply(o,i),s[r]=o,Reflect.defineMetadata(e,s,t)}function ot(e){return function(t,r,n){"number"==typeof n?nt(t,r,n,e):function(e,t,r){if(void 0!==e.prototype)throw new Error(O);st("inversify:tagged_props",e.constructor,t,r)}(t,r,e)}}function at(){return function(e){if(Reflect.hasOwnMetadata("inversify:paramtypes",e))throw new Error("Cannot apply @injectable decorator multiple times.");var t=Reflect.getMetadata("design:paramtypes",e)||[];return Reflect.defineMetadata("inversify:paramtypes",t,e),e}}var ct,dt=(ct="inject",function(e){return function(t,r,n){if(void 0===e){var i="function"==typeof t?t.name:t.constructor.name;throw new Error(function(e){return"@inject called with undefined this could mean that the class "+e+" has a circular dependency problem. You can use a LazyServiceIdentifier to overcome this limitation."}(i))}return ot(new H(ct,e))(t,r,n)}});const ut=3,lt=4,pt=6,ht=7;var ft;const mt={baseURL:"https://lb.livedigital.space/v1",timeout:5e3},gt={customerId:"b149fa74b11d989a60fb08e98e6a82883de0b468",version:"2.3.5"},vt={customerId:"89c41ecf3b3f46fef5dfa9f96842014c21d4901c"},yt=()=>{};let bt=class{constructor(e){var t,r,n,i,s;ft.set(this,void 0),d(this,ft,{denoiser:e.denoiser||"rnnoise",asdk:Object.assign(Object.assign({},gt),e.asdk),loadbalancer:Object.assign(mt,(null===(t=e.network)||void 0===t?void 0:t.loadbalancer)||{}),logLevel:null!==(r=e.logLevel)&&void 0!==r?r:ut,sendAnalytics:null!==(n=e.sendAnalytics)&&void 0!==n&&n,onLogMessage:e.onLogMessage||yt,onIssues:e.onIssues||yt,disableWid:null!==(i=e.disableWid)&&void 0!==i&&i,effectsSDKParams:Object.assign(Object.assign({},vt),e.effectsSDKParams),onNetworkScoresUpdated:e.onNetworkScoresUpdated||yt,staticFilesPath:null!==(s=e.staticFilesPath)&&void 0!==s?s:window.location.origin},"f")}get(e){return c(this,ft,"f")[e]}set(e,t){c(this,ft,"f")[e]=t}};ft=new WeakMap,bt=i([at(),o("design:paramtypes",[Object])],bt);var wt,_t,St,kt,Ct=bt;class Rt extends t{constructor(){super(),this.setMaxListeners(1/0)}emit(e,...t){return super.emit(e,...t)}safeEmit(e,...t){try{return super.emit(e,...t)}catch(t){try{super.emit("listenererror",e,t)}catch(e){}return Boolean(super.listenerCount(e))}}on(e,t){return super.on(e,t),this}off(e,t){return super.off(e,t),this}addListener(e,t){return super.on(e,t),this}prependListener(e,t){return super.prependListener(e,t),this}once(e,t){return super.once(e,t),this}prependOnceListener(e,t){return super.prependOnceListener(e,t),this}removeListener(e,t){return super.off(e,t),this}removeAllListeners(e){return super.removeAllListeners(e),this}listenerCount(e){return super.listenerCount(e)}listeners(e){return super.listeners(e)}rawListeners(e){return super.rawListeners(e)}}function Pt(){}function Tt(){Tt.init.call(this)}function Et(e){return void 0===e._maxListeners?Tt.defaultMaxListeners:e._maxListeners}function Dt(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Ft(e,n),s=0;s<n;++s)i[s].call(r)}function It(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,s=Ft(e,i),o=0;o<i;++o)s[o].call(r,n)}function Mt(e,t,r,n,i){if(t)e.call(r,n,i);else for(var s=e.length,o=Ft(e,s),a=0;a<s;++a)o[a].call(r,n,i)}function xt(e,t,r,n,i,s){if(t)e.call(r,n,i,s);else for(var o=e.length,a=Ft(e,o),c=0;c<o;++c)a[c].call(r,n,i,s)}function Ot(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,s=Ft(e,i),o=0;o<i;++o)s[o].apply(r,n)}function Lt(e,t,r,n){var i,s,o,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]):(s=e._events=new Pt,e._eventsCount=0),o){if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(i=Et(e))&&i>0&&o.length>i){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else o=s[t]=r,++e._eventsCount;return e}function At(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function jt(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Ft(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}Pt.prototype=Object.create(null),Tt.EventEmitter=Tt,Tt.usingDomains=!1,Tt.prototype.domain=void 0,Tt.prototype._events=void 0,Tt.prototype._maxListeners=void 0,Tt.defaultMaxListeners=10,Tt.init=function(){this.domain=null,Tt.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Pt,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Tt.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Tt.prototype.getMaxListeners=function(){return Et(this)},Tt.prototype.emit=function(e){var t,r,n,i,s,o,a,c="error"===e;if(o=this._events)c=c&&null==o.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var d=new Error('Uncaught, unspecified "error" event. ('+t+")");throw d.context=t,d}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=o[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:Dt(r,u,this);break;case 2:It(r,u,this,arguments[1]);break;case 3:Mt(r,u,this,arguments[1],arguments[2]);break;case 4:xt(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),s=1;s<n;s++)i[s-1]=arguments[s];Ot(r,u,this,i)}return!0},Tt.prototype.addListener=function(e,t){return Lt(this,e,t,!1)},Tt.prototype.on=Tt.prototype.addListener,Tt.prototype.prependListener=function(e,t){return Lt(this,e,t,!0)},Tt.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,At(this,e,t)),this},Tt.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,At(this,e,t)),this},Tt.prototype.removeListener=function(e,t){var r,n,i,s,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new Pt:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new Pt,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,o||t)}return this},Tt.prototype.off=function(e,t){return this.removeListener(e,t)},Tt.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new Pt,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new Pt:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),s=0;s<i.length;++s)"removeListener"!==(n=i[s])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new Pt,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Tt.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},Tt.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):jt.call(e,t)},Tt.prototype.listenerCount=jt,Tt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};class Nt extends Tt{}!function(e){e.Issue="issue",e.NetworkScoresUpdated="network-scores-updated",e.StatsParsingFinished="stats-parsing-finished"}(wt||(wt={})),function(e){e.Network="network",e.CPU="cpu",e.Server="server",e.Stream="stream"}(_t||(_t={})),function(e){e.OutboundNetworkQuality="outbound-network-quality",e.InboundNetworkQuality="inbound-network-quality",e.OutboundNetworkMediaLatency="outbound-network-media-latency",e.InboundNetworkMediaLatency="inbound-network-media-latency",e.NetworkMediaSyncFailure="network-media-sync-failure",e.OutboundNetworkThroughput="outbound-network-throughput",e.InboundNetworkThroughput="inbound-network-throughput",e.EncoderCPUThrottling="encoder-cpu-throttling",e.DecoderCPUThrottling="decoder-cpu-throttling",e.ServerIssue="server-issue",e.UnknownVideoDecoderIssue="unknown-video-decoder",e.LowInboundMOS="low-inbound-mean-opinion-score",e.LowOutboundMOS="low-outbound-mean-opinion-score",e.FrozenVideoTrack="frozen-video-track",e.MissingVideoStreamData="missing-video-stream-data",e.MissingAudioStreamData="missing-audio-stream-data"}(St||(St={})),function(e){e[e.BAD=2.1]="BAD",e[e.POOR=2.6]="POOR",e[e.FAIR=3.1]="FAIR",e[e.GOOD=3.8]="GOOD",e[e.EXCELLENT=4.3]="EXCELLENT"}(kt||(kt={}));class Bt extends Tt{static STATS_REPORT_READY_EVENT="stats-report-ready";static STATS_REPORTS_PARSED="stats-reports-parsed";isStopped=!1;reportTimer;getStatsInterval;compositeStatsParser;constructor(e){super(),this.compositeStatsParser=e.compositeStatsParser,this.getStatsInterval=e.getStatsInterval??1e4}get isRunning(){return!!this.reportTimer&&!this.isStopped}startReporting(){if(this.reportTimer)return;const e=()=>setTimeout((()=>{this.isStopped?this.reportTimer=void 0:this.parseReports().finally((()=>{this.reportTimer=e()}))}),this.getStatsInterval);this.isStopped=!1,this.reportTimer=e()}stopReporting(){this.isStopped=!0,this.reportTimer&&(clearTimeout(this.reportTimer),this.reportTimer=void 0)}async parseReports(){const e=Date.now(),t=await this.compositeStatsParser.parse(),r=Date.now()-e;this.emit(Bt.STATS_REPORTS_PARSED,{timeTaken:r,reportItems:t}),t.forEach((e=>{this.emit(Bt.STATS_REPORT_READY_EVENT,e)}))}}const Wt=(()=>{const e=new Map;return t=>{const{taskId:r,delayMs:n,maxJitterMs:i,callback:s}=t,o=Math.ceil(Math.random()*(i||0)),a=e.get(r);a&&clearTimeout(a);const c=setTimeout((()=>{s(),e.delete(r)}),n+o);e.set(r,c)}})();class qt{#e={};calculate(e){const{connection:{id:t}}=e,{mos:r,stats:n}=this.calculateOutboundScore(e)||{},{mos:i,stats:s}=this.calculateInboundScore(e)||{};return this.#e[t]=e,Wt({taskId:t,delayMs:35e3,callback:()=>delete this.#e[t]}),{outbound:r,inbound:i,connectionId:t,statsSamples:{inboundStatsSample:s,outboundStatsSample:n}}}calculateOutboundScore(e){const t=[...e.remote?.audio.inbound||[],...e.remote?.video.inbound||[]];if(!t.length)return;const r=this.#e[e.connection.id];if(!r)return;const n=[...r.remote?.audio.inbound||[],...r.remote?.video.inbound||[]],{packetsSent:i}=e.connection,s=r.connection.packetsSent,o=t.reduce(((e,t)=>{const r=n.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),a=1e3*e.connection.currentRoundTripTime||0,{sumJitter:c}=o,d=c/t.length,u=i-s,l=o.packetsLost-o.lastPacketsLost,p=u&&l?Math.round(100*l/(u+l)):0;return{mos:this.calculateMOS({avgJitter:d,rtt:a,packetsLoss:p}),stats:{avgJitter:d,rtt:a,packetsLoss:p}}}calculateInboundScore(e){const t=[...e.audio?.inbound,...e.video?.inbound];if(!t.length)return;const r=this.#e[e.connection.id];if(!r)return;const n=[...r.video?.inbound,...r.audio?.inbound],{packetsReceived:i}=e.connection,s=r.connection.packetsReceived,o=t.reduce(((e,t)=>{const r=n.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),a=1e3*e.connection.currentRoundTripTime||0,{sumJitter:c}=o,d=c/t.length,u=i-s,l=o.packetsLost-o.lastPacketsLost,p=u&&l?Math.round(100*l/(u+l)):0;return{mos:this.calculateMOS({avgJitter:d,rtt:a,packetsLoss:p}),stats:{avgJitter:d,rtt:a,packetsLoss:p}}}calculateMOS({avgJitter:e,rtt:t,packetsLoss:r}){const n=t+2*e+10;let i=n<160?93.2-n/40:93.2-n/120-10;return i-=2.5*r,1+.035*i+7e-6*i*(i-60)*(100-i)}}class Ut{#t=new Map;#r;#n;constructor(e={}){this.#r=e.statsCleanupTtlMs??35e3,this.#n=e.maxParsedStatsStorageSize??5}detect(e,t){const r={...e,networkScores:{...t,statsSamples:t?.statsSamples||{}}},n=this.performDetection(r);return this.setLastProcessedStats(e.connection.id,r),this.performPrevStatsCleanup({connectionId:e.connection.id}),n}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;this.#t.has(t)&&Wt({taskId:t,delayMs:this.#r,callback:()=>{this.deleteLastProcessedStats(t),"function"==typeof r&&r()}})}setLastProcessedStats(e,t){if(!e||t.connection.id!==e)return;const r=this.#t.get(e)??[];r.push(t),r.length>this.#n&&r.shift(),this.#t.set(e,r)}getLastProcessedStats(e){const t=this.#t.get(e);return t?.[t.length-1]}getAllLastProcessedStats(e){return this.#t.get(e)??[]}deleteLastProcessedStats(e){this.#t.delete(e)}}class zt extends Ut{#i;constructor(e={}){super(e),this.#i=e.availableOutgoingBitrateThreshold??1e5}performDetection(e){const t=[],{availableOutgoingBitrate:r}=e.connection;if(void 0===r)return t;const n=e.audio.outbound.reduce(((e,t)=>e+t.targetBitrate),0),i=e.video.outbound.reduce(((e,t)=>e+t.bitrate),0);if(!n&&!i)return t;const s={availableOutgoingBitrate:r,videoStreamsTotalBitrate:i,audioStreamsTotalTargetBitrate:n};return n>r||i>0&&r<this.#i?(t.push({statsSample:s,type:_t.Network,reason:St.OutboundNetworkThroughput}),t):t}}class Vt extends Ut{#s;#o;#a;#c;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200,this.#a=e.highJitterBufferDelayThresholdMs??500,this.#c=e.highRttThresholdMs??250}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...e.audio?.inbound,...e.video?.inbound];if(!r.length)return t;const n=this.getLastProcessedStats(e.connection.id);if(!n)return t;const i=[...n.video?.inbound,...n.audio?.inbound],{packetsReceived:s}=e.connection,o=n.connection.packetsReceived,a=r.reduce(((e,t)=>{const r=i.find((e=>e.ssrc===t.ssrc)),n=r?.jitterBufferDelay||0,s=r?.jitterBufferEmittedCount||0,o=t.jitterBufferDelay-n,a=t.jitterBufferEmittedCount-s,c=o&&a?1e3*o/a:0;return{sumJitter:e.sumJitter+t.jitter,sumJitterBufferDelayMs:e.sumJitterBufferDelayMs+c,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,sumJitterBufferDelayMs:0,packetsLost:0,lastPacketsLost:0}),c=1e3*e.connection.currentRoundTripTime||0,{sumJitter:d,sumJitterBufferDelayMs:u}=a,l=d/r.length,p=u/r.length,h=s-o,f=a.packetsLost-a.lastPacketsLost,m=h&&f?Math.round(100*f/(h+f)):0,g=m>this.#s,v=l>=this.#o,y=c>=this.#c,b=p>this.#a,w=y&&!v&&!g,_=g&&v,S=v&&b,k={rtt:c,packetLossPct:m,avgJitter:l,avgJitterBufferDelay:p};return(v||g)&&t.push({statsSample:k,type:_t.Network,reason:St.InboundNetworkQuality,iceCandidate:e.connection.local.id}),w&&t.push({statsSample:k,type:_t.Server,reason:St.ServerIssue,iceCandidate:e.connection.remote.id}),_&&t.push({statsSample:k,type:_t.Network,reason:St.InboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),S&&t.push({statsSample:k,type:_t.Network,reason:St.NetworkMediaSyncFailure,iceCandidate:e.connection.local.id}),t}}class Ht extends Ut{#d;constructor(e={}){super(),this.#d=e.correctedSamplesThresholdPct??5}performDetection(e){return this.processData(e)}processData(e){const t=e.audio.inbound,r=[],n=this.getLastProcessedStats(e.connection.id)?.audio.inbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;const i=e.track.insertedSamplesForDeceleration+e.track.removedSamplesForAcceleration,s=t.track.insertedSamplesForDeceleration+t.track.removedSamplesForAcceleration;if(i===s)return;const o=e.track.totalSamplesReceived-t.track.totalSamplesReceived,a=i-s,c=Math.round(100*a/o),d={correctedSamplesPct:c};c>this.#d&&r.push({statsSample:d,type:_t.Network,reason:St.NetworkMediaSyncFailure,ssrc:e.ssrc})})),r):r}}class $t extends Ut{#s;#o;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...e.remote?.audio.inbound||[],...e.remote?.video.inbound||[]];if(!r.length)return t;const n=this.getLastProcessedStats(e.connection.id);if(!n)return t;const i=[...n.remote?.audio.inbound||[],...n.remote?.video.inbound||[]],{packetsSent:s}=e.connection,o=n.connection.packetsSent,a=r.reduce(((e,t)=>{const r=i.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),c=1e3*e.connection.currentRoundTripTime||0,{sumJitter:d}=a,u=d/r.length,l=s-o,p=a.packetsLost-a.lastPacketsLost,h=l&&p?Math.round(100*p/(l+p)):0,f=h>this.#s,m=u>=this.#o,g=!f&&m||m||f,v={rtt:c,avgJitter:u,packetLossPct:h};return f&&m&&t.push({statsSample:v,type:_t.Network,reason:St.OutboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),g&&t.push({statsSample:v,type:_t.Network,reason:St.OutboundNetworkQuality,iceCandidate:e.connection.local.id}),t}}class Kt extends Ut{performDetection(e){return this.processData(e)}processData(e){const t=e.video.outbound.filter((e=>"none"!==e.qualityLimitationReason)),r=[],n=this.getLastProcessedStats(e.connection.id)?.video.outbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;const i={qualityLimitationReason:e.qualityLimitationReason};e.framesSent>t.framesSent||("cpu"===e.qualityLimitationReason&&r.push({statsSample:i,type:_t.CPU,reason:St.EncoderCPUThrottling,ssrc:e.ssrc}),"bandwidth"===e.qualityLimitationReason&&r.push({statsSample:i,type:_t.Network,reason:St.OutboundNetworkThroughput,ssrc:e.ssrc}))})),r):r}}class Gt extends Ut{UNKNOWN_DECODER="unknown";#u={};performDetection(e){return this.processData(e)}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;super.performPrevStatsCleanup({...e,cleanupCallback:()=>{delete this.#u[t],"function"==typeof r&&r()}})}processData(e){const t=[],{id:r}=e.connection,n=this.getLastProcessedStats(r)?.video.inbound;return e.video.inbound.forEach((e=>{const{decoderImplementation:i,ssrc:s}=e,o=n?.find((e=>e.ssrc===s));if(o)if(i===this.UNKNOWN_DECODER){if(!this.hadLastDecoderWithIssue(r,s)){this.setLastDecoderWithIssue(r,s,this.UNKNOWN_DECODER);const n={mimeType:e.mimeType,decoderImplementation:i};t.push({ssrc:s,statsSample:n,type:_t.Stream,reason:St.UnknownVideoDecoderIssue,trackIdentifier:e.track.trackIdentifier})}}else this.setLastDecoderWithIssue(r,s,void 0)})),t}setLastDecoderWithIssue(e,t,r){const n=this.#u[e]??{};void 0===r?delete n[t]:n[t]=r,this.#u[e]=n}hadLastDecoderWithIssue(e,t){const r=this.#u[e];return(r&&r[t])===this.UNKNOWN_DECODER}}const Qt=(e,t)=>{for(let r=1;r<t.length;r+=1){const n=t[r].video.inbound.find((t=>t.ssrc===e));if(!n)continue;const i=t[r-1].video.inbound.find((t=>t.ssrc===e)),s=n.frameWidth!==i?.frameWidth,o=n.frameHeight!==i?.frameHeight;if(s||o)return!0}return!1};class Jt extends Ut{#l;#p;#h;constructor(e={}){super(),this.#l=e.avgFreezeDurationThresholdMs??1e3,this.#p=e.frozenDurationThresholdPct??30,this.#h=e.minMosQuality??kt.BAD}performDetection(e){const t=e.networkScores.inbound;return void 0!==t&&t<=this.#h?[]:this.processData(e)}processData(e){const t=[],r=this.getAllLastProcessedStats(e.connection.id);if(0===r.length)return[];const n=e.video.inbound.map((t=>{const n=r[r.length-1].video.inbound.find((e=>e.ssrc===t.ssrc));if(!n)return;if(Qt(t.ssrc,[r[r.length-1],e]))return;const i=t.freezeCount-(n.freezeCount??0),s=1e3*(t.totalFreezesDuration-(n.totalFreezesDuration??0)),o=i>0?s/i:0,a=s/(t.timestamp-n.timestamp)*100;return a>this.#p||o>this.#l?{ssrc:t.ssrc,avgFreezeDurationMs:o,frozenDurationPct:a}:void 0})).filter((e=>void 0!==e));return n.length>0&&(t.push({type:_t.Stream,reason:St.FrozenVideoTrack,statsSample:{ssrcs:n.map((e=>e.ssrc))}}),this.deleteLastProcessedStats(e.connection.id)),t}}class Yt extends Ut{#f;#m;#h;constructor(e={}){super(e),this.#f=e.volatilityThreshold??8,this.#m=e.affectedStreamsPercentThreshold??30,this.#h=e.minMosQuality??kt.BAD}performDetection(e){return[...this.getAllLastProcessedStats(e.connection.id),e].find((e=>void 0!==e.networkScores.inbound&&e.networkScores.inbound<=this.#h))?[]:this.processData(e)}processData(e){const t=[],r=[...this.getAllLastProcessedStats(e.connection.id),e],n=e.video.inbound.map((e=>{if(r.length<5)return;if(Qt(e.ssrc,r))return;const t=[];for(let n=0;n<r.length-1;n+=1){const i=r[n].video.inbound.find((t=>t.ssrc===e.ssrc));void 0!==i?.framesPerSecond&&t.push(i.framesPerSecond)}if(t.length<5)return;const n=(e=>{if(0===e.length)throw new Error("Cannot calculate volatility for empty array");const t=(e=>e.reduce(((e,t)=>e+t),0)/e.length)(e);return e.reduce(((e,r)=>e+Math.abs(r-t)),0)/e.length*100/t})(t);return n>this.#f?{ssrc:e.ssrc,allFps:t,volatility:n}:void 0})).filter((e=>Boolean(e)));if(0===n.length)return t;const i=n.length/(e.video.inbound.length/100);return i>this.#m&&(t.push({type:_t.CPU,reason:St.DecoderCPUThrottling,statsSample:{affectedStreamsPercent:i,throtthedStreams:n}}),this.deleteLastProcessedStats(e.connection.id)),t}}const Zt=e=>"closed"===e.iceConnectionState||"closed"===e.connectionState,Xt=(e,t,r)=>8*((e,t,r)=>{if(!t)return 0;const n=e[r],i=t[r];if(null==n||null==i)return 0;const s=Math.floor(e.timestamp)-Math.floor(t.timestamp);return 0===s?0:(Number(n)-Number(i))/s*1e3})(e,t,r);class er{connections=[];statsParser;constructor(e){this.statsParser=e.statsParser}listConnections(){return[...this.connections]}addPeerConnection(e){this.connections.push({id:e.id??String(Date.now()+Math.random().toString(32)),pc:e.pc})}removePeerConnection(e){const t=this.connections.findIndex((({pc:t})=>t===e.pc));t>=0&&this.removeConnectionsByIndexes([t])}async parse(){const e=[],t=this.connections.map((async(t,r)=>{if(!Zt(t.pc))return this.statsParser.parse(t);e.unshift(r)}));return e.length&&this.removeConnectionsByIndexes(e),(await Promise.all(t)).filter((e=>void 0!==e))}removeConnectionsByIndexes(e){e.forEach((e=>{this.connections.splice(e,1)}))}}class tr{prevStats=new Map;allowedReportTypes=new Set(["candidate-pair","inbound-rtp","outbound-rtp","remote-outbound-rtp","remote-inbound-rtp","track","transport"]);ignoreSSRCList;logger;constructor(e){this.ignoreSSRCList=e.ignoreSSRCList??[],this.logger=e.logger}get previouslyParsedStatsConnectionsIds(){return[...this.prevStats.keys()]}async parse(e){if(!Zt(e.pc))return this.getConnectionStats(e);this.logger.debug("Skip stats parsing. Connection is closed.",{connection:e})}async getConnectionStats(e){const{pc:t,id:r}=e;try{const n=Date.now(),i=t.getReceivers().filter((e=>e.track?.enabled)),s=t.getSenders().filter((e=>e.track?.enabled)),o=await Promise.all(i.map((e=>e.getStats()))),a=await Promise.all(s.map((e=>e.getStats())));return{id:r,stats:this.mapReportsStats([...o,...a],e),timeTaken:Date.now()-n}}catch(e){return void this.logger.error("Failed to get stats for PC",{id:r,pc:t,error:e})}}mapReportsStats(e,t){const r={audio:{inbound:[],outbound:[]},video:{inbound:[],outbound:[]},connection:{},remote:{video:{inbound:[],outbound:[]},audio:{inbound:[],outbound:[]}}};e.forEach((e=>{e.forEach((t=>{this.allowedReportTypes.has(t.type)&&this.updateMappedStatsWithReportItemData(t,r,e)}))}));const{id:n}=t,i=this.prevStats.get(n);return i&&this.propagateStatsWithRateValues(r,i.stats),this.prevStats.set(n,{stats:r,ts:Date.now()}),Wt({taskId:n,delayMs:35e3,callback:()=>this.prevStats.delete(n)}),r}updateMappedStatsWithReportItemData(e,t,r){const n=e.type;if("candidate-pair"===n&&"succeeded"===e.state&&e.nominated)return void(t.connection=this.prepareConnectionStats(e,r));const i=this.getMediaType(e);if(!i)return;const s=e.ssrc;if(!s||!this.ignoreSSRCList.includes(s))if("outbound-rtp"!==n)if("inbound-rtp"!==n)"remote-outbound-rtp"!==n?"remote-inbound-rtp"===n&&(this.mapConnectionStatsIfNecessary(t,e,r),t.remote[i].inbound.push({...e})):t.remote[i].outbound.push({...e});else{const n=r.get(e.trackId)||r.get(e.mediaSourceId)||{};this.mapConnectionStatsIfNecessary(t,e,r);const s={...e,track:{...n}};t[i].inbound.push(s)}else{const n=r.get(e.trackId)||r.get(e.mediaSourceId)||{},s={...e,track:{...n}};t[i].outbound.push(s)}}getMediaType(e){const t=e.mediaType||e.kind;if(!["audio","video"].includes(t)){const{id:t}=e;if(!t)return;return String(t).includes("Video")?"video":String(t).includes("Audio")?"audio":void 0}return t}propagateStatsWithRateValues(e,t){e.audio.inbound.forEach((e=>{const r=t.audio.inbound.find((({id:t})=>t===e.id));e.bitrate=Xt(e,r,"bytesReceived"),e.packetRate=Xt(e,r,"packetsReceived")})),e.audio.outbound.forEach((e=>{const r=t.audio.outbound.find((({id:t})=>t===e.id));e.bitrate=Xt(e,r,"bytesSent"),e.packetRate=Xt(e,r,"packetsSent")})),e.video.inbound.forEach((e=>{const r=t.video.inbound.find((({id:t})=>t===e.id));e.bitrate=Xt(e,r,"bytesReceived"),e.packetRate=Xt(e,r,"packetsReceived")})),e.video.outbound.forEach((e=>{const r=t.video.outbound.find((({id:t})=>t===e.id));e.bitrate=Xt(e,r,"bytesSent"),e.packetRate=Xt(e,r,"packetsSent")}))}mapConnectionStatsIfNecessary(e,t,r){if(e.connection.id||!t.transportId)return;const n=r.get(t.transportId);if(n&&n.selectedCandidatePairId){const t=r.get(n.selectedCandidatePairId);e.connection=this.prepareConnectionStats(t,r)}}prepareConnectionStats(e,t){if(!e||!t)return{};const r={...e};if(r.remoteCandidateId){const e=t.get(r.remoteCandidateId);r.remote={...e}}if(r.localCandidateId){const e=t.get(r.localCandidateId);r.local={...e}}return r}}class rr extends Ut{#g=new Map;#v;#y;constructor(e={}){super(),this.#v=e.timeoutMs??15e3,this.#y=e.steps??3}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...this.getAllLastProcessedStats(e.connection.id),e];if(r.length<this.#y)return t;const n=r.slice(-this.#y),i=n.map((e=>e.video.inbound)),s=n.map((e=>e.audio.inbound));return t.push(...this.detectMissingData(s,_t.Stream,St.MissingAudioStreamData)),t.push(...this.detectMissingData(i,_t.Stream,St.MissingVideoStreamData)),new Set(this.#g.keys()).forEach((e=>{const t=this.#g.get(e);t&&Date.now()-t>this.#v&&this.removeMarkedIssue(e)})),t}detectMissingData(e,t,r){const n=[],i=e.pop(),s=rr.mapStatsByTrackId(e);return i.forEach((e=>{const i=e.track.trackIdentifier,o=s.get(i);if(!Array.isArray(o)||0===o.length)return;if(e.track.detached||e.track.ended)return;if(!rr.isAllBytesReceivedDidntChange(e.bytesReceived,o))return void this.removeMarkedIssue(i);if(!this.markIssue(i))return;const a={bytesReceived:e.bytesReceived};n.push({type:t,reason:r,statsSample:a,trackIdentifier:i})})),n}static mapStatsByTrackId(e){const t=new Map;return e.forEach((e=>{e.forEach((e=>{const r=t.get(e.track.trackIdentifier)||[];r.push(e),t.set(e.track.trackIdentifier,r)}))})),t}static isAllBytesReceivedDidntChange(e,t){for(let r=0;r<t.length;r+=1)if(t[r].bytesReceived!==e)return!1;return!0}markIssue(e){const t=Date.now(),r=this.#g.get(e);return(!r||t-r>this.#v)&&(this.#g.set(e,t),!0)}removeMarkedIssue(e){this.#g.delete(e)}}class nr{eventEmitter;#b=!1;detectors=[];networkScoresCalculator;statsReporter;compositeStatsParser;logger;autoAddPeerConnections;constructor(e){this.logger=e.logger??{debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},this.eventEmitter=e.issueEmitter??new Nt,e.onIssues&&this.eventEmitter.on(wt.Issue,e.onIssues),e.onNetworkScoresUpdated&&this.eventEmitter.on(wt.NetworkScoresUpdated,e.onNetworkScoresUpdated),this.detectors=e.detectors??[new Kt,new Vt,new $t,new Ht,new zt,new Gt,new Jt,new Yt,new rr],this.networkScoresCalculator=e.networkScoresCalculator??new qt,this.compositeStatsParser=e.compositeStatsParser??new er({statsParser:new tr({ignoreSSRCList:e.ignoreSSRCList,logger:this.logger})}),this.statsReporter=e.statsReporter??new Bt({compositeStatsParser:this.compositeStatsParser,getStatsInterval:e.getStatsInterval??5e3}),window.wid=this,this.autoAddPeerConnections=e.autoAddPeerConnections??!0,this.autoAddPeerConnections&&this.wrapRTCPeerConnection(),this.statsReporter.on(Bt.STATS_REPORT_READY_EVENT,(e=>{const t=this.calculateNetworkScores(e.stats);this.detectIssues({data:e.stats},t)})),this.statsReporter.on(Bt.STATS_REPORTS_PARSED,(t=>{const r={timeTaken:t.timeTaken,ts:Date.now()};e.onStats&&e.onStats(t.reportItems),this.eventEmitter.emit(wt.StatsParsingFinished,r)}))}watchNewPeerConnections(){if(!this.autoAddPeerConnections)throw new Error("Auto add peer connections was disabled in the constructor.");this.#b?this.logger.warn("WebRTCIssueDetector is already started. Skip processing"):(this.logger.info("Start watching peer connections"),this.#b=!0,this.statsReporter.startReporting())}stopWatchingNewPeerConnections(){this.#b?(this.logger.info("Stop watching peer connections"),this.#b=!1,this.statsReporter.stopReporting()):this.logger.warn("WebRTCIssueDetector is already stopped. Skip processing")}handleNewPeerConnection(e,t){this.#b||!this.autoAddPeerConnections?(this.#b||!1!==this.autoAddPeerConnections||(this.logger.info("Starting stats reporting for new peer connection"),this.#b=!0,this.statsReporter.startReporting()),this.logger.debug("Handling new peer connection",e),this.compositeStatsParser.addPeerConnection({pc:e,id:t})):this.logger.debug("Skip handling new peer connection. Detector is not running",e)}emitIssues(e){this.eventEmitter.emit(wt.Issue,e)}detectIssues({data:e},t){const r=this.detectors.reduce(((r,n)=>[...r,...n.detect(e,t)]),[]);r.length>0&&this.emitIssues(r)}calculateNetworkScores(e){const t=this.networkScoresCalculator.calculate(e);return this.eventEmitter.emit(wt.NetworkScoresUpdated,t),t}wrapRTCPeerConnection(){if(!window.RTCPeerConnection)return void this.logger.warn("No RTCPeerConnection found in browser window. Skipping");const e=window.RTCPeerConnection,t=e=>this.handleNewPeerConnection(e);function r(r){const n=new e(r);return t(n),n}r.prototype=e.prototype,window.RTCPeerConnection=r}}var ir={};Object.defineProperty(ir,"__esModule",{value:!0}),ir.InvalidStateError=ir.UnsupportedError=void 0;class sr extends Error{constructor(e){super(e),this.name="UnsupportedError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,sr):this.stack=new Error(e).stack}}var or=ir.UnsupportedError=sr;class ar extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,ar):this.stack=new Error(e).stack}}ir.InvalidStateError=ar;Error;const cr=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],dr=({from:e,seen:t,to_:r,forceEnumerable:n})=>{const i=r||(Array.isArray(e)?[]:{});t.push(e);for(const[r,s]of Object.entries(e))"function"!=typeof s&&(s&&"object"==typeof s?t.includes(e[r])?i[r]="[Circular]":i[r]=dr({from:e[r],seen:t.slice(),forceEnumerable:n}):i[r]=s);for(const{property:t,enumerable:r}of cr)"string"==typeof e[t]&&Object.defineProperty(i,t,{value:e[t],enumerable:!!n||r,configurable:!0,writable:!0});return i};var ur,lr,pr,hr=e=>"object"==typeof e&&null!==e?dr({from:e,seen:[],forceEnumerable:!0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e;ur=new WeakMap,lr=new WeakMap,pr=new WeakMap;var fr=new class{constructor(){ur.set(this,void 0),lr.set(this,void 0),pr.set(this,void 0)}get meta(){return{peerId:c(this,ur,"f"),channelId:c(this,lr,"f"),appId:c(this,pr,"f")}}setPeerId(e){d(this,ur,e,"f")}setChannelId(e){d(this,lr,e,"f")}setAppId(e){d(this,pr,e,"f")}clear(){d(this,ur,void 0,"f"),d(this,lr,void 0,"f"),d(this,pr,void 0,"f")}};const mr="channel.event",gr="channel.join",vr="channel.getPeers",yr="peer.disconnected",br="peer.updateAppData",wr="channel.confirmActivity",_r="channel.activityConfirmationAcquired",Sr="channel.activityConfirmationRequired",kr="channel.activityConfirmationExpired",Cr="channel.getAudioObserverProducer",Rr="channel.getGeneralDataProducer",Pr="channel.getChannelStateSyncDataProducer",Tr="channel.changeProducePermissions",Er="channel.deleteProducePermissions",Dr="peer.changeProducePermissions",Ir="peer.addProducePermissions",Mr="peer.removeProducePermissions",xr="peer.groupsChanged",Or="peer.ping",Lr="channel-event",Ar="peer-joined",jr="peer-left",Fr="channel-activity-confirmation-required",Nr="channel-activity-confirmation-acquired",Br="channel-activity-confirmation-expired",Wr="channel-rejoin-required",qr="devices-list-updated",Ur="transport-connection-timeout",zr="track-force-closed",Vr="track-failed",Hr="active-speaker-changed",$r="channel-state-inconsistent",Kr="connection-lost",Gr="connection-restored",Qr="forced-disconnect",Jr="reject-unauthorized",Yr="denoiser-initializing",Zr="volume-changed",Xr={trackProduced:"track-produced",trackUnproduced:"track-unproduced",trackPaused:"track-paused",trackResumed:"track-resumed",trackClosed:"track-closed",trackReopened:"track-reopened",trackFailed:"track-failed"},en="media-published",tn="media-unpublished",rn="publisher-paused",nn="publisher-resumed",sn="track-start",on="track-end",an="track-paused",cn="track-resumed",dn="track-failed",un="app-data-updated",ln="produce-permissions-changed",pn="groups-changed",hn="peer.newProducer",fn="producer.close",mn="producer.pause",gn="producer.resume",vn="producer.paused",yn="producer.resumed",bn="producer.forceClosed",wn="producer.setMaxSpatialLayer",_n="producer.requestMaxSpatialLayer",Sn="consumer.create",kn="dataConsumer.create",Cn="consumer.close",Rn="consumer.pause",Pn="consumer.resume",Tn="consumer.score",En="consumer.changeConsumerPreferredLayers",Dn="consumer.requestKeyFrame",In="transport.create",Mn="transport.connect",xn="transport.produce",On="transport.produceData",Ln="transport.connectionTimeout",An="transport.getIceParameters",jn=[In,Mn,xn,On,An,fn,mn,gn,Rn,Pn,Sn,Cn,Or],Fn="socket-state",Nn="transport-state";class Bn extends Error{constructor(e,t,r){super(e),this.errorCode=null!=t?t:"unknown_error",this.meta=r}}class Wn extends Bn{constructor(e,t){super(e,null!=t?t:"unsupported_error")}}Wn.UNSUPPORTED_DEVICE_CODE="unsupported_device_error",Wn.UNSUPPORTED_OPERATION_CODE="unsupported_operation_error";const qn=e=>{let t;try{t=JSON.stringify(e)}catch(e){throw new Error("Invalid appData")}if(!((new TextEncoder).encode(t).length<=2048))throw new Error("Maximum size appData reached")};var Un={exports:{}},zn=p(Un.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=r(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var i=e.getVersionPrecision(t),s=e.getVersionPrecision(r),o=Math.max(i,s),a=0,c=e.map([t,r],(function(t){var r=o-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(a=o-Math.min(i,s)),o-=1;o>=a;){if(c[0][o]>c[1][o])return 1;if(c[0][o]===c[1][o]){if(o===a)return 0;o-=1}else if(c[0][o]<c[1][o])return-1}},e.map=function(e,t){var r,n=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)n.push(t(e[r]));return n},e.find=function(e,t){var r,n;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(r=0,n=e.length;r<n;r+=1){var i=e[r];if(t(i,r))return i}},e.assign=function(e){for(var t,r,n=e,i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];if(Object.assign)return Object.assign.apply(Object,[e].concat(s));var a=function(){var e=s[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){n[t]=e[t]}))};for(t=0,r=s.length;t<r;t+=1)a();return e},e.getBrowserAlias=function(e){return n.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return n.BROWSER_MAP[e]||""},e}();t.default=i,e.exports=t.default},18:function(e,t,r){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(91))&&n.__esModule?n:{default:n},s=r(18);function o(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,n.key,n)}}var a=function(){function e(){}var t,r,n;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new i.default(e,t)},e.parse=function(e){return new i.default(e).getResult()},t=e,n=[{key:"BROWSER_MAP",get:function(){return s.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return s.ENGINE_MAP}},{key:"OS_MAP",get:function(){return s.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return s.PLATFORMS_MAP}}],(r=null)&&o(t.prototype,r),n&&o(t,n),e}();t.default=a,e.exports=t.default},91:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=c(r(92)),i=c(r(93)),s=c(r(94)),o=c(r(95)),a=c(r(17));function c(e){return e&&e.__esModule?e:{default:e}}var d=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=a.default.find(n.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=a.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=a.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=a.default.find(o.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return a.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,r={},n=0,i={},s=0;if(Object.keys(e).forEach((function(t){var o=e[t];"string"==typeof o?(i[t]=o,s+=1):"object"==typeof o&&(r[t]=o,n+=1)})),n>0){var o=Object.keys(r),c=a.default.find(o,(function(e){return t.isOS(e)}));if(c){var d=this.satisfies(r[c]);if(void 0!==d)return d}var u=a.default.find(o,(function(e){return t.isPlatform(e)}));if(u){var l=this.satisfies(r[u]);if(void 0!==l)return l}}if(s>0){var p=Object.keys(i),h=a.default.find(p,(function(e){return t.isBrowser(e,!0)}));if(void 0!==h)return this.compareVersion(i[h])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),i=a.default.getBrowserTypeByAlias(n);return t&&i&&(n=i.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(a.default.compareVersions(i,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=d,e.exports=t.default},92:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=/version\/(\d+(\.?_?\d+)+)/i,o=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=o,e.exports=t.default},93:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18),o=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:s.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return{name:s.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:s.OS_MAP.iOS},r=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),n={name:s.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:s.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),n={name:s.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:s.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:s.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:s.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:s.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.PlayStation4,version:t}}}];t.default=o,e.exports=t.default},94:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18),o=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:s.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:s.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.tv}}}];t.default=o,e.exports=t.default},95:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18),o=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:s.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:s.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:s.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:s.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:s.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:s.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:s.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=o,e.exports=t.default}}));const Vn=e=>{var t;return(null===(t=e.rtpCapabilities.codecs)||void 0===t?void 0:t.reduce(((e,t)=>{var r;const n=null===(r=t.mimeType)||void 0===r?void 0:r.toLowerCase();return e.includes(n)||e.push(n),e}),[]))||[]},Hn=e=>["video/vp9","vp9"].includes(e.toLowerCase());class $n{sleepMs(e){return a(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}now(){return new Date(Date.now())}}const Kn=new $n,Gn=(e,t={})=>a(void 0,void 0,void 0,(function*(){var r;const n=t.maxRetries||2,i=t.minBackoffDelayMs||50;let s,o=0;for(;o<n;){o+=1;try{return yield e()}catch(e){if(s=e,t.logger&&t.logger.info("Action retry failed",{currentAttempt:o,actionName:t.actionName,error:e}),t.abortOnError&&t.abortOnError(e))throw s;if(t.onError&&(yield t.onError(e)),o<n){const e=Math.pow(2,o-1)*i;yield Kn.sleepMs(Math.min(e,null!==(r=t.maxBackoffDelayMs)&&void 0!==r?r:e))}}}throw s}));var Qn,Jn,Yn,Zn;!function(e){e.Config="Config",e.Engine="Engine",e.System="System",e.Media="Media",e.Network="Network",e.MediaSoupEventHandler="MediaSoupEventHandler",e.ChannelEventHandler="ChannelEventHandler",e.ChannelAudioObserverEventHandler="ChannelAudioObserverEventHandler",e.ChannelStateSynchronizer="ChannelStateSynchronizer",e.ChannelStateSyncEventHandler="ChannelStateSyncEventHandler",e.WebRTCIssueDetector="WebRTCIssueDetector",e.LoggerFactory="LoggerFactory",e.MediaStreamTrackManager="MediaStreamTrackManager",e.SocketIO="SocketIO",e.LoadBalancerApiClient="LoadBalancerApiClient",e.EventsQueue="EventsQueue",e.ClientEventEmitter="ClientEventEmitter",e.Peers="Peers",e.CallState="CallState",e.RemotePeerTracks="RemotePeerTracks",e.MyPeer="MyPeer",e.InternalEventEmitter="InternalEventEmitter",e.PeerTrackFactory="PeerTrackFactory",e.PeerFactory="PeerFactory",e.PeerConsumerFactory="PeerConsumerFactory",e.AudioTrackFactory="AudioTrackFactory",e.VideoTrackFactory="VideoTrackFactory",e.AudioTrackProcessorFactory="AudioTrackProcessorFactory",e.IntegrationsService="IntegrationsService",e.ProcessorsCache="ProcessorsCache",e.StatsHandler="StatsHandler",e.DataChannelsManager="DataChannelsManager"}(Qn||(Qn={})),function(e){e.Camera="camera",e.CameraPreview="camera-preview",e.Microphone="microphone",e.MicrophonePreview="microphone-preview",e.ScreenVideo="screen-video",e.ScreenAudio="screen-audio",e.Unknown="unknown"}(Jn||(Jn={})),function(e){e.NotFoundError="NotFoundError",e.NoDevices="NoDevices",e.DeviceIsBusy="DeviceIsBusy",e.NotAllowedError="NotAllowedError",e.RequestDevicesUnknownError="RequestDevicesUnknownError"}(Yn||(Yn={})),function(e){e.Connect="connect",e.Connected="connected",e.ConnectError="connect_error",e.Reconnect="reconnect",e.Reconnecting="reconnecting",e.Reconnected="reconnected",e.ReconnectAttempt="reconnect_attempt",e.NeedToJoinFirst="need_to_join_first",e.Disconnect="disconnect",e.Disconnected="disconnected",e.Error="error",e.State="state",e.BufferingStart="buffering_start",e.BufferingEnd="buffering_end"}(Zn||(Zn={}));let Xn=class{constructor(){this.isJoined=!1,this.isChannelJoining=!1}reset(){this.appId=void 0,this.channelId=void 0}};Xn=i([at()],Xn);var ei={},ti={exports:{}},ri=1e3,ni=6e4,ii=60*ni,si=24*ii,oi=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*si;case"hours":case"hour":case"hrs":case"hr":case"h":return r*ii;case"minutes":case"minute":case"mins":case"min":case"m":return r*ni;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=si)return ai(e,t,si,"day");if(t>=ii)return ai(e,t,ii,"hour");if(t>=ni)return ai(e,t,ni,"minute");if(t>=1e3)return ai(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=si)return Math.round(e/si)+"d";if(t>=ii)return Math.round(e/ii)+"h";if(t>=ni)return Math.round(e/ni)+"m";if(t>=ri)return Math.round(e/ri)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ai(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var ci=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r<i;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=oi,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=ci(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(ti,ti.exports);var di,ui,li={},pi={exports:{}};di=pi,ui=pi.exports,function(e,t){var r,n="",i="function",s="undefined",o="object",a="string",c="major",d="model",u="name",l="type",p="vendor",h="version",f="architecture",m="console",g="mobile",v="tablet",y="smarttv",b="wearable",w="xr",_="embedded",S="inapp",k="user-agent",C="brands",R="formFactors",P="fullVersionList",T="platform",E="platformVersion",D="bitness",I="sec-ch-ua",M="sec-ch-ua-platform",x=[C,P,g,d,T,E,f,R,D],O="browser",L="cpu",A="device",j="engine",F="os",N="result",B="Amazon",W="Apple",q="ASUS",U="BlackBerry",z="Google",V="Huawei",H="Lenovo",$="LG",K="Microsoft",G="Motorola",Q="Samsung",J="Sharp",Y="Sony",Z="Xiaomi",X="Zebra",ee="Chromecast",te="Opera",re="Facebook",ne="Windows",ie=typeof e!==s,se=ie&&e.navigator?e.navigator:t,oe=se&&se.userAgentData?se.userAgentData:t,ae=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},ce=function(e,t){if(typeof e===o&&e.length>0){for(var r in e)if(pe(e[r])==pe(t))return!0;return!1}return!!ue(e)&&-1!==pe(t).indexOf(pe(e))},de=function(e,t){for(var r in e)return/^(browser|cpu|device|engine|os)$/.test(r)||!!t&&de(e[r])},ue=function(e){return typeof e===a},le=function(e){if(!e)return t;for(var r=[],n=me(/\\?\"/g,e).split(","),i=0;i<n.length;i++)if(n[i].indexOf(";")>-1){var s=ve(n[i]).split(";v=");r[i]={brand:s[0],version:s[1]}}else r[i]=ve(n[i]);return r},pe=function(e){return ue(e)?e.toLowerCase():e},he=function(e){return ue(e)?me(/[^\d\.]/g,e).split(".")[0]:t},fe=function(e){for(var r in e){var n=e[r];typeof n==o&&2==n.length?this[n[0]]=n[1]:this[n]=t}return this},me=function(e,t){return ue(t)?t.replace(e,n):t},ge=function(e){return me(/\\?\"/g,e)},ve=function(e,t){if(ue(e))return e=me(/^\s\s*/,e),typeof t===s?e:e.substring(0,500)},ye=function(e,r){if(e&&r)for(var n,s,a,c,d,u,l=0;l<r.length&&!d;){var p=r[l],h=r[l+1];for(n=s=0;n<p.length&&!d&&p[n];)if(d=p[n++].exec(e))for(a=0;a<h.length;a++)u=d[++s],typeof(c=h[a])===o&&c.length>0?2===c.length?typeof c[1]==i?this[c[0]]=c[1].call(this,u):this[c[0]]=c[1]:3===c.length?typeof c[1]!==i||c[1].exec&&c[1].test?this[c[0]]=u?u.replace(c[1],c[2]):t:this[c[0]]=u?c[1].call(this,u,c[2]):t:4===c.length&&(this[c[0]]=u?c[3].call(this,u.replace(c[1],c[2])):t):this[c]=u||t;l+=2}},be=function(e,r){for(var n in r)if(typeof r[n]===o&&r[n].length>0){for(var i=0;i<r[n].length;i++)if(ce(r[n][i],e))return"?"===n?t:n}else if(ce(r[n],e))return"?"===n?t:n;return r.hasOwnProperty("*")?r["*"]:e},we={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},_e={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":t},Se={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[h,[u,"Mobile Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[h,[u,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[u,h],[/opios[\/ ]+([\w\.]+)/i],[h,[u,"Opera Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[h,[u,"Opera GX"]],[/\bopr\/([\w\.]+)/i],[h,[u,te]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[h,[u,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[h,[u,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[u,h],[/quark(?:pc)?\/([-\w\.]+)/i],[h,[u,"Quark"]],[/\bddg\/([\w\.]+)/i],[h,[u,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[h,[u,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[h,[u,"WeChat"]],[/konqueror\/([\w\.]+)/i],[h,[u,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[h,[u,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[h,[u,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[h,[u,"Smart Lenovo Browser"]],[/(avast|avg)\/([\w\.]+)/i],[[u,/(.+)/,"$1 Secure Browser"],h],[/\bfocus\/([\w\.]+)/i],[h,[u,"Firefox Focus"]],[/\bopt\/([\w\.]+)/i],[h,[u,"Opera Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[h,[u,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[h,[u,"Dolphin"]],[/coast\/([\w\.]+)/i],[h,[u,"Opera Coast"]],[/miuibrowser\/([\w\.]+)/i],[h,[u,"MIUI Browser"]],[/fxios\/([\w\.-]+)/i],[h,[u,"Mobile Firefox"]],[/\bqihoobrowser\/?([\w\.]*)/i],[h,[u,"360"]],[/\b(qq)\/([\w\.]+)/i],[[u,/(.+)/,"$1Browser"],h],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[u,/(.+)/,"$1 Browser"],h],[/samsungbrowser\/([\w\.]+)/i],[h,[u,"Samsung Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[h,[u,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[u,"Sogou Mobile"],h],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[u,h],[/(lbbrowser|rekonq)/i],[u],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[h,u],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[u,re],h,[l,S]],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(instagram|snapchat)[\/ ]([-\w\.]+)/i],[u,h,[l,S]],[/\bgsa\/([\w\.]+) .*safari\//i],[h,[u,"GSA"],[l,S]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[h,[u,"TikTok"],[l,S]],[/\[(linkedin)app\]/i],[u,[l,S]],[/(chromium)[\/ ]([-\w\.]+)/i],[u,h],[/headlesschrome(?:\/([\w\.]+)| )/i],[h,[u,"Chrome Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[u,"Chrome WebView"],h],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[h,[u,"Android Browser"]],[/chrome\/([\w\.]+) mobile/i],[h,[u,"Mobile Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[u,h],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[h,[u,"Mobile Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[u,"Mobile Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[h,u],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[u,[h,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[u,h],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[u,"Mobile Firefox"],h],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[u,"Netscape"],h],[/(wolvic|librewolf)\/([\w\.]+)/i],[u,h],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[h,[u,"Firefox Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[u,[h,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[u,[h,/[^\d\.]+./,n]]],cpu:[[/\b(?:(amd|x|x86[-_]?|wow|win)64)\b/i],[[f,"amd64"]],[/(ia32(?=;))/i,/((?:i[346]|x)86)[;\)]/i],[[f,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[f,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[f,"armhf"]],[/windows (ce|mobile); ppc;/i],[[f,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[f,/ower/,n,pe]],[/(sun4\w)[;\)]/i],[[f,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[f,pe]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[p,Q],[l,v]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[d,[p,Q],[l,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[d,[p,W],[l,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[p,W],[l,v]],[/(macintosh);/i],[d,[p,W]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[p,J],[l,g]],[/(?:honor)([-\w ]+)[;\)]/i],[d,[p,"Honor"],[l,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[d,[p,V],[l,v]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[p,V],[l,g]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i],[[d,/_/g," "],[p,Z],[l,g]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[d,/_/g," "],[p,Z],[l,v]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[d,[p,"OPPO"],[l,g]],[/\b(opd2\d{3}a?) bui/i],[d,[p,"OPPO"],[l,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[p,"Vivo"],[l,g]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[d,[p,"Realme"],[l,g]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[d,[p,G],[l,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[p,G],[l,v]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[p,$],[l,v]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[d,[p,$],[l,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[d,[p,H],[l,v]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[d,/_/g," "],[p,"Nokia"],[l,g]],[/(pixel c)\b/i],[d,[p,z],[l,v]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[p,z],[l,g]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[d,[p,Y],[l,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,"Xperia Tablet"],[p,Y],[l,v]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[p,"OnePlus"],[l,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[p,B],[l,v]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,"Fire Phone $1"],[p,B],[l,g]],[/(playbook);[-\w\),; ]+(rim)/i],[d,p,[l,v]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[p,U],[l,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[p,q],[l,v]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[p,q],[l,g]],[/(nexus 9)/i],[d,[p,"HTC"],[l,v]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[p,[d,/_/g," "],[l,g]],[/tcl (xess p17aa)/i,/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])(_\w(\w|\w\w))?(\)| bui)/i],[d,[p,"TCL"],[l,v]],[/droid [\w\.]+; (418(?:7d|8v)|5087z|5102l|61(?:02[dh]|25[adfh]|27[ai]|56[dh]|59k|65[ah])|a509dl|t(?:43(?:0w|1[adepqu])|50(?:6d|7[adju])|6(?:09dl|10k|12b|71[efho]|76[hjk])|7(?:66[ahju]|67[hw]|7[045][bh]|71[hk]|73o|76[ho]|79w|81[hks]?|82h|90[bhsy]|99b)|810[hs]))(_\w(\w|\w\w))?(\)| bui)/i],[d,[p,"TCL"],[l,g]],[/(itel) ((\w+))/i],[[p,pe],d,[l,be,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[p,"Acer"],[l,v]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[p,"Meizu"],[l,g]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[d,[p,"Ulefone"],[l,g]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[d,[p,"Energizer"],[l,g]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[d,[p,"Cat"],[l,g]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[d,[p,"Smartfren"],[l,g]],[/droid.+; (a(?:015|06[35]|142p?))/i],[d,[p,"Nothing"],[l,g]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[p,d,[l,g]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[p,d,[l,v]],[/(surface duo)/i],[d,[p,K],[l,v]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[p,"Fairphone"],[l,g]],[/(shield[\w ]+) b/i],[d,[p,"Nvidia"],[l,v]],[/(sprint) (\w+)/i],[p,d,[l,g]],[/(kin\.[onetw]{3})/i],[[d,/\./g," "],[p,K],[l,g]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[p,X],[l,v]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[p,X],[l,g]],[/smart-tv.+(samsung)/i],[p,[l,y]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,"SmartTV"],[p,Q],[l,y]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[p,$],[l,y]],[/(apple) ?tv/i],[p,[d,"Apple TV"],[l,y]],[/crkey.*devicetype\/chromecast/i],[[d,"Chromecast Third Generation"],[p,z],[l,y]],[/crkey.*devicetype\/([^/]*)/i],[[d,/^/,"Chromecast "],[p,z],[l,y]],[/fuchsia.*crkey/i],[[d,"Chromecast Nest Hub"],[p,z],[l,y]],[/crkey/i],[[d,ee],[p,z],[l,y]],[/droid.+aft(\w+)( bui|\))/i],[d,[p,B],[l,y]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[p,J],[l,y]],[/(bravia[\w ]+)( bui|\))/i],[d,[p,Y],[l,y]],[/(mitv-\w{5}) bui/i],[d,[p,Z],[l,y]],[/Hbbtv.*(technisat) (.*);/i],[p,d,[l,y]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[p,ve],[d,ve],[l,y]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[l,y]],[/(ouya)/i,/(nintendo) (\w+)/i],[p,d,[l,m]],[/droid.+; (shield) bui/i],[d,[p,"Nvidia"],[l,m]],[/(playstation \w+)/i],[d,[p,Y],[l,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[p,K],[l,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[d,[p,Q],[l,b]],[/((pebble))app/i],[p,d,[l,b]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[p,W],[l,b]],[/droid.+; (wt63?0{2,3})\)/i],[d,[p,X],[l,b]],[/droid.+; (glass) \d/i],[d,[p,z],[l,w]],[/(pico) (4|neo3(?: link|pro)?)/i],[p,d,[l,w]],[/; (quest( \d| pro)?)/i],[d,[p,re],[l,w]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[p,[l,_]],[/(aeobc)\b/i],[d,[p,B],[l,_]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[d,[l,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[l,v]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[l,v]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[l,g]],[/(android[-\w\. ]{0,9});.+buil/i],[d,[p,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[h,[u,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[u,h],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[h,[u,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[u,h],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[h,u]],os:[[/microsoft (windows) (vista|xp)/i],[u,h],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[u,[h,be,we]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[h,be,we],[u,ne]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[h,/_/g,"."],[u,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[u,"macOS"],[h,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[h,[u,"Chromecast Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[h,[u,"Chromecast Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[h,[u,"Chromecast SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[h,[u,"Chromecast Linux"]],[/crkey\/([\d\.]+)/i],[h,[u,ee]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[h,u],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[u,h],[/\(bb(10);/i],[h,[u,U]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[h,[u,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[h,[u,"Firefox OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[h,[u,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[h,[u,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[u,"Chrome OS"],h],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) (\w+)/i,/(xbox); +xbox ([^\);]+)/i,/(pico) .+os([\w\.]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[u,h],[/(sunos) ?([\w\.\d]*)/i],[[u,"Solaris"],h],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[u,h]]},ke=(fe.call((r={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}}).init,[[O,[u,h,c,l]],[L,[f]],[A,[l,d,p]],[j,[u,h]],[F,[u,h]]]),fe.call(r.isIgnore,[[O,[h,c]],[j,[h]],[F,[h]]]),fe.call(r.isIgnoreRgx,[[O,/ ?browser$/i],[F,/ ?os$/i]]),fe.call(r.toString,[[O,[u,h]],[L,[f]],[A,[p,d]],[j,[u,h]],[F,[u,h]]]),r),Ce=function(e,t){var r=ke.init[t],i=ke.isIgnore[t]||0,o=ke.isIgnoreRgx[t]||0,a=ke.toString[t]||0;function c(){fe.call(this,r)}return c.prototype.getItem=function(){return e},c.prototype.withClientHints=function(){return oe?oe.getHighEntropyValues(x).then((function(t){return e.setCH(new Re(t,!1)).parseCH().get()})):e.parseCH().get()},c.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=N&&(c.prototype.is=function(e){var t=!1;for(var r in this)if(this.hasOwnProperty(r)&&!ce(i,r)&&pe(o?me(o,this[r]):this[r])==pe(o?me(o,e):e)){if(t=!0,e!=s)break}else if(e==s&&t){t=!t;break}return t},c.prototype.toString=function(){var e=n;for(var t in a)typeof this[a[t]]!==s&&(e+=(e?" ":n)+this[a[t]]);return e||s}),oe||(c.prototype.then=function(e){var t=this,r=function(){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e])};r.prototype={is:c.prototype.is,toString:c.prototype.toString};var n=new r;return e(n),n}),new c};function Re(e,t){if(e=e||{},fe.call(this,x),t)fe.call(this,[[C,le(e[I])],[P,le(e["sec-ch-ua-full-version-list"])],[g,/\?1/.test(e["sec-ch-ua-mobile"])],[d,ge(e["sec-ch-ua-model"])],[T,ge(e[M])],[E,ge(e["sec-ch-ua-platform-version"])],[f,ge(e["sec-ch-ua-arch"])],[R,le(e["sec-ch-ua-form-factors"])],[D,ge(e["sec-ch-ua-bitness"])]]);else for(var r in e)this.hasOwnProperty(r)&&typeof e[r]!==s&&(this[r]=e[r])}function Pe(e,r,n,o){return this.get=function(e){return e?this.data.hasOwnProperty(e)?this.data[e]:t:this.data},this.set=function(e,t){return this.data[e]=t,this},this.setCH=function(e){return this.uaCH=e,this},this.detectFeature=function(){if(se&&se.userAgent==this.ua)switch(this.itemType){case O:se.brave&&typeof se.brave.isBrave==i&&this.set(u,"Brave");break;case A:!this.get(l)&&oe&&oe.mobile&&this.set(l,g),"Macintosh"==this.get(d)&&se&&typeof se.standalone!==s&&se.maxTouchPoints&&se.maxTouchPoints>2&&this.set(d,"iPad").set(l,v);break;case F:!this.get(u)&&oe&&oe.platform&&this.set(u,oe.platform);break;case N:var e=this.data,t=function(t){return e[t].getItem().detectFeature().get()};this.set(O,t(O)).set(L,t(L)).set(A,t(A)).set(j,t(j)).set(F,t(F))}return this},this.parseUA=function(){return this.itemType!=N&&ye.call(this.data,this.ua,this.rgxMap),this.itemType==O&&this.set(c,he(this.get(h))),this},this.parseCH=function(){var e=this.uaCH,r=this.rgxMap;switch(this.itemType){case O:var n,i=e[P]||e.brands;if(i)for(var s in i){var o=me(/(Google|Microsoft) /,i[s].brand||i[s]),a=i[s].version;/not.a.brand/i.test(o)||n&&(!/chrom/i.test(n)||/chromi/i.test(o))||(this.set(u,o).set(h,a).set(c,he(a)),n=o)}break;case L:var f=e.architecture;f&&(f&&"64"==e.bitness&&(f+="64"),ye.call(this.data,f+";",r));break;case A:if(e.mobile&&this.set(l,g),e.model&&this.set(d,e.model),"Xbox"==e.model&&this.set(l,m).set(p,K),e.formFactors){var v;if("string"!=typeof e.formFactors)for(var y=0;!v&&y<e.formFactors.length;)v=be(e.formFactors[y++],_e);else v=be(e.formFactors,_e);this.set(l,v)}break;case F:var b=e.platform;if(b){var w=e[E];b==ne&&(w=parseInt(he(w),10)>=13?"11":"10"),this.set(u,b).set(h,w)}this.get(u)==ne&&"Xbox"==e.model&&this.set(u,"Xbox").set(h,t);break;case N:var _=this.data,S=function(t){return _[t].getItem().setCH(e).parseCH().get()};this.set(O,S(O)).set(L,S(L)).set(A,S(A)).set(j,S(j)).set(F,S(F))}return this},fe.call(this,[["itemType",e],["ua",r],["uaCH",o],["rgxMap",n],["data",Ce(this,e)]]),this}function Te(e,r,s){if(typeof e===o?(de(e,!0)?(typeof r===o&&(s=r),r=e):(s=e,r=t),e=t):typeof e!==a||de(r,!0)||(s=r,r=t),s&&typeof s.append===i){var c={};s.forEach((function(e,t){c[t]=e})),s=c}if(!(this instanceof Te))return new Te(e,r,s).getResult();var d=typeof e===a?e:s&&s[k]?s[k]:se&&se.userAgent?se.userAgent:n,u=new Re(s,!0),l=r?function(e,t){var r={},n=t;if(!de(t))for(var i in n={},t)for(var s in t[i])n[s]=t[i][s].concat(n[s]?n[s]:[]);for(var o in e)r[o]=n[o]&&n[o].length%2==0?n[o].concat(e[o]):e[o];return r}(Se,r):Se,p=function(e){return e==N?function(){return new Pe(e,d,l,u).set("ua",d).set(O,this.getBrowser()).set(L,this.getCPU()).set(A,this.getDevice()).set(j,this.getEngine()).set(F,this.getOS()).get()}:function(){return new Pe(e,d,l[e],u).parseUA().get()}};return fe.call(this,[["getBrowser",p(O)],["getCPU",p(L)],["getDevice",p(A)],["getEngine",p(j)],["getOS",p(F)],["getResult",p(N)],["getUA",function(){return d}],["setUA",function(e){return ue(e)&&(d=e.length>500?ve(e,500):e),this}]]).setUA(d),this}Te.VERSION="2.0.0",Te.BROWSER=ae([u,h,c,l]),Te.CPU=ae([f]),Te.DEVICE=ae([d,p,l,m,g,y,v,b,_]),Te.ENGINE=Te.OS=ae([u,h]),di.exports&&(ui=di.exports=Te),ui.UAParser=Te;var Ee=ie&&(e.jQuery||e.Zepto);if(Ee&&!Ee.ua){var De=new Te;Ee.ua=De.getResult(),Ee.ua.get=function(){return De.getUA()},Ee.ua.set=function(e){De.setUA(e);var t=De.getResult();for(var r in t)Ee.ua[r]=t[r]}}}("object"==typeof window?window:l);var hi={},fi=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(hi,"__esModule",{value:!0}),hi.Logger=void 0;const mi=fi(ti.exports),gi="mediasoup-client";hi.Logger=class{constructor(e){e?(this._debug=(0,mi.default)(`${gi}:${e}`),this._warn=(0,mi.default)(`${gi}:WARN:${e}`),this._error=(0,mi.default)(`${gi}:ERROR:${e}`)):(this._debug=(0,mi.default)(gi),this._warn=(0,mi.default)(`${gi}:WARN`),this._error=(0,mi.default)(`${gi}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}};var vi,yi={},bi={exports:{}},wi="object"==typeof Reflect?Reflect:null,_i=wi&&"function"==typeof wi.apply?wi.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};vi=wi&&"function"==typeof wi.ownKeys?wi.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var Si=Number.isNaN||function(e){return e!=e};function ki(){ki.init.call(this)}bi.exports=ki,bi.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,s),n(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}Oi(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&Oi(e,"error",t,r)}(e,i,{once:!0})}))},ki.EventEmitter=ki,ki.prototype._events=void 0,ki.prototype._eventsCount=0,ki.prototype._maxListeners=void 0;var Ci=10;function Ri(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Pi(e){return void 0===e._maxListeners?ki.defaultMaxListeners:e._maxListeners}function Ti(e,t,r,n){var i,s,o,a;if(Ri(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(i=Pi(e))>0&&o.length>i&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,console&&console.warn&&console.warn(a)}return e}function Ei(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Di(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=Ei.bind(n);return i.listener=r,n.wrapFn=i,i}function Ii(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):xi(i,i.length)}function Mi(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function xi(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function Oi(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(s){n.once&&e.removeEventListener(t,i),r(s)}))}}Object.defineProperty(ki,"defaultMaxListeners",{enumerable:!0,get:function(){return Ci},set:function(e){if("number"!=typeof e||e<0||Si(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Ci=e}}),ki.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},ki.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||Si(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},ki.prototype.getMaxListeners=function(){return Pi(this)},ki.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,i=this._events;if(void 0!==i)n=n&&void 0===i.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)_i(a,this,t);else{var c=a.length,d=xi(a,c);for(r=0;r<c;++r)_i(d[r],this,t)}return!0},ki.prototype.addListener=function(e,t){return Ti(this,e,t,!1)},ki.prototype.on=ki.prototype.addListener,ki.prototype.prependListener=function(e,t){return Ti(this,e,t,!0)},ki.prototype.once=function(e,t){return Ri(t),this.on(e,Di(this,e,t)),this},ki.prototype.prependOnceListener=function(e,t){return Ri(t),this.prependListener(e,Di(this,e,t)),this},ki.prototype.removeListener=function(e,t){var r,n,i,s,o;if(Ri(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,o||t)}return this},ki.prototype.off=ki.prototype.removeListener,ki.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,s=Object.keys(r);for(n=0;n<s.length;++n)"removeListener"!==(i=s[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},ki.prototype.listeners=function(e){return Ii(this,e,!0)},ki.prototype.rawListeners=function(e){return Ii(this,e,!1)},ki.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Mi.call(e,t)},ki.prototype.listenerCount=Mi,ki.prototype.eventNames=function(){return this._eventsCount>0?vi(this._events):[]},Object.defineProperty(yi,"__esModule",{value:!0}),yi.EnhancedEventEmitter=void 0;const Li=bi.exports,Ai=new hi.Logger("EnhancedEventEmitter");class ji extends Li.EventEmitter{constructor(){super(),this.setMaxListeners(1/0)}emit(e,...t){return super.emit(e,...t)}safeEmit(e,...t){try{return super.emit(e,...t)}catch(t){Ai.error("safeEmit() | event listener threw an error [eventName:%s]:%o",e,t);try{super.emit("listenererror",e,t)}catch(e){}return Boolean(super.listenerCount(e))}}on(e,t){return super.on(e,t),this}off(e,t){return super.off(e,t),this}addListener(e,t){return super.on(e,t),this}prependListener(e,t){return super.prependListener(e,t),this}once(e,t){return super.once(e,t),this}prependOnceListener(e,t){return super.prependOnceListener(e,t),this}removeListener(e,t){return super.off(e,t),this}removeAllListeners(e){return super.removeAllListeners(e),this}listenerCount(e){return super.listenerCount(e)}listeners(e){return super.listeners(e)}rawListeners(e){return super.rawListeners(e)}}yi.EnhancedEventEmitter=ji;var Fi={};Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},Fi.generateRandomNumber=function(){return Math.round(1e7*Math.random())},Fi.deepFreeze=function e(t){const r=Reflect.ownKeys(t);for(const n of r){const r=t[n];(r&&"object"==typeof r||"function"==typeof r)&&e(r)}return Object.freeze(t)};var Ni={},Bi={},Wi={},qi={exports:{}},Ui=1e3,zi=6e4,Vi=60*zi,Hi=24*Vi,$i=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*Hi;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Vi;case"minutes":case"minute":case"mins":case"min":case"m":return r*zi;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=Hi)return Ki(e,t,Hi,"day");if(t>=Vi)return Ki(e,t,Vi,"hour");if(t>=zi)return Ki(e,t,zi,"minute");if(t>=1e3)return Ki(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=Hi)return Math.round(e/Hi)+"d";if(t>=Vi)return Math.round(e/Vi)+"h";if(t>=zi)return Math.round(e/zi)+"m";if(t>=Ui)return Math.round(e/Ui)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ki(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var Gi=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r<i;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=$i,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Gi(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(qi,qi.exports);var Qi=qi.exports,Ji=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.Logger=void 0;const Yi=Ji(qi.exports),Zi="h264-profile-level-id";Wi.Logger=class{constructor(e){e?(this._debug=(0,Yi.default)(`${Zi}:${e}`),this._warn=(0,Yi.default)(`${Zi}:WARN:${e}`),this._error=(0,Yi.default)(`${Zi}:ERROR:${e}`)):(this._debug=(0,Yi.default)(Zi),this._warn=(0,Yi.default)(`${Zi}:WARN`),this._error=(0,Yi.default)(`${Zi}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}},Object.defineProperty(Bi,"__esModule",{value:!0}),Bi.generateProfileLevelIdStringForAnswer=Bi.isSameProfile=Bi.parseSdpProfileLevelId=Bi.levelToString=Bi.profileToString=Bi.profileLevelIdToString=Bi.parseProfileLevelId=Bi.ProfileLevelId=Bi.Level=Bi.Profile=void 0;const Xi=new Wi.Logger;var es,ts;!function(e){e[e.ConstrainedBaseline=1]="ConstrainedBaseline",e[e.Baseline=2]="Baseline",e[e.Main=3]="Main",e[e.ConstrainedHigh=4]="ConstrainedHigh",e[e.High=5]="High",e[e.PredictiveHigh444=6]="PredictiveHigh444"}(es||(Bi.Profile=es={})),function(e){e[e.L1_b=0]="L1_b",e[e.L1=10]="L1",e[e.L1_1=11]="L1_1",e[e.L1_2=12]="L1_2",e[e.L1_3=13]="L1_3",e[e.L2=20]="L2",e[e.L2_1=21]="L2_1",e[e.L2_2=22]="L2_2",e[e.L3=30]="L3",e[e.L3_1=31]="L3_1",e[e.L3_2=32]="L3_2",e[e.L4=40]="L4",e[e.L4_1=41]="L4_1",e[e.L4_2=42]="L4_2",e[e.L5=50]="L5",e[e.L5_1=51]="L5_1",e[e.L5_2=52]="L5_2"}(ts||(Bi.Level=ts={}));class rs{constructor(e,t){this.profile=e,this.level=t}}Bi.ProfileLevelId=rs;const ns=new rs(es.ConstrainedBaseline,ts.L3_1);class is{constructor(e){this.mask=~us("x",e),this.masked_value=us("1",e)}isMatch(e){return this.masked_value===(e&this.mask)}}class ss{constructor(e,t,r){this.profile_idc=e,this.profile_iop=t,this.profile=r}}const os=[new ss(66,new is("x1xx0000"),es.ConstrainedBaseline),new ss(77,new is("1xxx0000"),es.ConstrainedBaseline),new ss(88,new is("11xx0000"),es.ConstrainedBaseline),new ss(66,new is("x0xx0000"),es.Baseline),new ss(88,new is("10xx0000"),es.Baseline),new ss(77,new is("0x0x0000"),es.Main),new ss(100,new is("00000000"),es.High),new ss(100,new is("00001100"),es.ConstrainedHigh),new ss(244,new is("00000000"),es.PredictiveHigh444)];function as(e){if("string"!=typeof e||6!==e.length)return;const t=parseInt(e,16);if(0===t)return;const r=255&t,n=t>>8&255,i=t>>16&255;let s;switch(r){case ts.L1_1:s=0!=(16&n)?ts.L1_b:ts.L1_1;break;case ts.L1:case ts.L1_2:case ts.L1_3:case ts.L2:case ts.L2_1:case ts.L2_2:case ts.L3:case ts.L3_1:case ts.L3_2:case ts.L4:case ts.L4_1:case ts.L4_2:case ts.L5:case ts.L5_1:case ts.L5_2:s=r;break;default:return void Xi.warn(`parseProfileLevelId() | unrecognized level_idc [str:${e}, level_idc:${r}]`)}for(const e of os)if(i===e.profile_idc&&e.profile_iop.isMatch(n))return new rs(e.profile,s);Xi.warn(`parseProfileLevelId() | unrecognized profile_idc/profile_iop combination [str:${e}, profile_idc:${i}, profile_iop:${n}]`)}function cs(e){if(e.level==ts.L1_b)switch(e.profile){case es.ConstrainedBaseline:return"42f00b";case es.Baseline:return"42100b";case es.Main:return"4d100b";default:return void Xi.warn(`profileLevelIdToString() | Level 1_b not is allowed for profile ${e.profile}`)}let t;switch(e.profile){case es.ConstrainedBaseline:t="42e0";break;case es.Baseline:t="4200";break;case es.Main:t="4d00";break;case es.ConstrainedHigh:t="640c";break;case es.High:t="6400";break;case es.PredictiveHigh444:t="f400";break;default:return void Xi.warn(`profileLevelIdToString() | unrecognized profile ${e.profile}`)}let r=e.level.toString(16);return 1===r.length&&(r=`0${r}`),`${t}${r}`}function ds(e={}){const t=e["profile-level-id"];return t?as(t):ns}function us(e,t){return Number(t[0]===e)<<7|Number(t[1]===e)<<6|Number(t[2]===e)<<5|Number(t[3]===e)<<4|Number(t[4]===e)<<3|Number(t[5]===e)<<2|Number(t[6]===e)<<1|Number(t[7]===e)<<0}function ls(e={}){const t=e["level-asymmetry-allowed"];return!0===t||1===t||"1"===t}Bi.parseProfileLevelId=as,Bi.profileLevelIdToString=cs,Bi.profileToString=function(e){switch(e){case es.ConstrainedBaseline:return"ConstrainedBaseline";case es.Baseline:return"Baseline";case es.Main:return"Main";case es.ConstrainedHigh:return"ConstrainedHigh";case es.High:return"High";case es.PredictiveHigh444:return"PredictiveHigh444";default:return void Xi.warn(`profileToString() | unrecognized profile ${e}`)}},Bi.levelToString=function(e){switch(e){case ts.L1_b:return"1b";case ts.L1:return"1";case ts.L1_1:return"1.1";case ts.L1_2:return"1.2";case ts.L1_3:return"1.3";case ts.L2:return"2";case ts.L2_1:return"2.1";case ts.L2_2:return"2.2";case ts.L3:return"3";case ts.L3_1:return"3.1";case ts.L3_2:return"3.2";case ts.L4:return"4";case ts.L4_1:return"4.1";case ts.L4_2:return"4.2";case ts.L5:return"5";case ts.L5_1:return"5.1";case ts.L5_2:return"5.2";default:return void Xi.warn(`levelToString() | unrecognized level ${e}`)}},Bi.parseSdpProfileLevelId=ds,Bi.isSameProfile=function(e={},t={}){const r=ds(e),n=ds(t);return Boolean(r&&n&&r.profile===n.profile)},Bi.generateProfileLevelIdStringForAnswer=function(e={},t={}){if(!e["profile-level-id"]&&!t["profile-level-id"])return void Xi.warn("generateProfileLevelIdStringForAnswer() | profile-level-id missing in local and remote params");const r=ds(e),n=ds(t);if(!r)throw new TypeError("invalid local_profile_level_id");if(!n)throw new TypeError("invalid remote_profile_level_id");if(r.profile!==n.profile)throw new TypeError("H264 Profile mismatch");const i=ls(e)&&ls(t),s=r.level,o=function(e,t){return function(e,t){if(e===ts.L1_b)return t!==ts.L1&&t!==ts.L1_b;if(t===ts.L1_b)return e!==ts.L1;return e<t}(e,t)?e:t}(s,n.level),a=i?s:o;return Xi.debug(`generateProfileLevelIdStringForAnswer() | result [profile:${r.profile}, level:${a}]`),cs(new rs(r.profile,a))};var ps,hs=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),fs=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ms=l&&l.__importStar||(ps=function(e){return ps=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},ps(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=ps(e),n=0;n<r.length;n++)"default"!==r[n]&&hs(t,e,r[n]);return fs(t,e),t});Object.defineProperty(Ni,"__esModule",{value:!0}),Ni.validateRtpCapabilities=function(e){if("object"!=typeof e)throw new TypeError("caps is not an object");if(e.codecs&&!Array.isArray(e.codecs))throw new TypeError("caps.codecs is not an array");e.codecs||(e.codecs=[]);for(const t of e.codecs)bs(t);if(e.headerExtensions&&!Array.isArray(e.headerExtensions))throw new TypeError("caps.headerExtensions is not an array");e.headerExtensions||(e.headerExtensions=[]);for(const t of e.headerExtensions)_s(t)},Ni.validateRtpParameters=ys,Ni.validateSctpStreamParameters=function(e){if("object"!=typeof e)throw new TypeError("params is not an object");if("number"!=typeof e.streamId)throw new TypeError("missing params.streamId");let t=!1;"boolean"==typeof e.ordered?t=!0:e.ordered=!0;if(e.maxPacketLifeTime&&"number"!=typeof e.maxPacketLifeTime)throw new TypeError("invalid params.maxPacketLifeTime");if(e.maxRetransmits&&"number"!=typeof e.maxRetransmits)throw new TypeError("invalid params.maxRetransmits");if(e.maxPacketLifeTime&&e.maxRetransmits)throw new TypeError("cannot provide both maxPacketLifeTime and maxRetransmits");if(t&&e.ordered&&(e.maxPacketLifeTime||e.maxRetransmits))throw new TypeError("cannot be ordered with maxPacketLifeTime or maxRetransmits");t||!e.maxPacketLifeTime&&!e.maxRetransmits||(e.ordered=!1);if(e.label&&"string"!=typeof e.label)throw new TypeError("invalid params.label");if(e.protocol&&"string"!=typeof e.protocol)throw new TypeError("invalid params.protocol")},Ni.validateSctpCapabilities=function(e){if("object"!=typeof e)throw new TypeError("caps is not an object");if(!e.numStreams||"object"!=typeof e.numStreams)throw new TypeError("missing caps.numStreams");!function(e){if("object"!=typeof e)throw new TypeError("numStreams is not an object");if("number"!=typeof e.OS)throw new TypeError("missing numStreams.OS");if("number"!=typeof e.MIS)throw new TypeError("missing numStreams.MIS")}(e.numStreams)},Ni.getExtendedRtpCapabilities=function(e,t){const r={codecs:[],headerExtensions:[]};for(const n of t.codecs??[]){if(Rs(n))continue;const t=(e.codecs??[]).find((e=>Ps(e,n,{strict:!0,modify:!0})));if(!t)continue;const i={mimeType:t.mimeType,kind:t.kind,clockRate:t.clockRate,channels:t.channels,localPayloadType:t.preferredPayloadType,localRtxPayloadType:void 0,remotePayloadType:n.preferredPayloadType,remoteRtxPayloadType:void 0,localParameters:t.parameters,remoteParameters:n.parameters,rtcpFeedback:Es(t,n)};r.codecs.push(i)}for(const n of r.codecs){const r=e.codecs.find((e=>Rs(e)&&e.parameters.apt===n.localPayloadType)),i=t.codecs.find((e=>Rs(e)&&e.parameters.apt===n.remotePayloadType));r&&i&&(n.localRtxPayloadType=r.preferredPayloadType,n.remoteRtxPayloadType=i.preferredPayloadType)}for(const n of t.headerExtensions){const t=e.headerExtensions.find((e=>Ts(e,n)));if(!t)continue;const i={kind:n.kind,uri:n.uri,sendId:t.preferredId,recvId:n.preferredId,encrypt:t.preferredEncrypt,direction:"sendrecv"};switch(n.direction){case"sendrecv":i.direction="sendrecv";break;case"recvonly":i.direction="sendonly";break;case"sendonly":i.direction="recvonly";break;case"inactive":i.direction="inactive"}r.headerExtensions.push(i)}return r},Ni.getRecvRtpCapabilities=function(e){const t={codecs:[],headerExtensions:[]};for(const r of e.codecs){const e={mimeType:r.mimeType,kind:r.kind,preferredPayloadType:r.remotePayloadType,clockRate:r.clockRate,channels:r.channels,parameters:r.localParameters,rtcpFeedback:r.rtcpFeedback};if(t.codecs.push(e),!r.remoteRtxPayloadType)continue;const n={mimeType:`${r.kind}/rtx`,kind:r.kind,preferredPayloadType:r.remoteRtxPayloadType,clockRate:r.clockRate,parameters:{apt:r.remotePayloadType},rtcpFeedback:[]};t.codecs.push(n)}for(const r of e.headerExtensions){if("sendrecv"!==r.direction&&"recvonly"!==r.direction)continue;const e={kind:r.kind,uri:r.uri,preferredId:r.recvId,preferredEncrypt:r.encrypt,direction:r.direction};t.headerExtensions.push(e)}return t},Ni.getSendingRtpParameters=function(e,t){const r={mid:void 0,codecs:[],headerExtensions:[],encodings:[],rtcp:{}};for(const n of t.codecs){if(n.kind!==e)continue;const t={mimeType:n.mimeType,payloadType:n.localPayloadType,clockRate:n.clockRate,channels:n.channels,parameters:n.localParameters,rtcpFeedback:n.rtcpFeedback};if(r.codecs.push(t),n.localRtxPayloadType){const e={mimeType:`${n.kind}/rtx`,payloadType:n.localRtxPayloadType,clockRate:n.clockRate,parameters:{apt:n.localPayloadType},rtcpFeedback:[]};r.codecs.push(e)}}for(const n of t.headerExtensions){if(n.kind&&n.kind!==e||"sendrecv"!==n.direction&&"sendonly"!==n.direction)continue;const t={uri:n.uri,id:n.sendId,encrypt:n.encrypt,parameters:{}};r.headerExtensions.push(t)}return r},Ni.getSendingRemoteRtpParameters=function(e,t){const r={mid:void 0,codecs:[],headerExtensions:[],encodings:[],rtcp:{}};for(const n of t.codecs){if(n.kind!==e)continue;const t={mimeType:n.mimeType,payloadType:n.localPayloadType,clockRate:n.clockRate,channels:n.channels,parameters:n.remoteParameters,rtcpFeedback:n.rtcpFeedback};if(r.codecs.push(t),n.localRtxPayloadType){const e={mimeType:`${n.kind}/rtx`,payloadType:n.localRtxPayloadType,clockRate:n.clockRate,parameters:{apt:n.localPayloadType},rtcpFeedback:[]};r.codecs.push(e)}}for(const n of t.headerExtensions){if(n.kind&&n.kind!==e||"sendrecv"!==n.direction&&"sendonly"!==n.direction)continue;const t={uri:n.uri,id:n.sendId,encrypt:n.encrypt,parameters:{}};r.headerExtensions.push(t)}if(r.headerExtensions.some((e=>"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"===e.uri)))for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback??[]).filter((e=>"goog-remb"!==e.type));else if(r.headerExtensions.some((e=>"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"===e.uri)))for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback??[]).filter((e=>"transport-cc"!==e.type));else for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback??[]).filter((e=>"transport-cc"!==e.type&&"goog-remb"!==e.type));return r},Ni.reduceCodecs=function(e,t){const r=[];if(t){for(let n=0;n<e.length;++n)if(Ps(e[n],t,{strict:!0})){r.push(e[n]),Rs(e[n+1])&&r.push(e[n+1]);break}if(0===r.length)throw new TypeError("no matching codec found")}else r.push(e[0]),Rs(e[1])&&r.push(e[1]);return r},Ni.generateProbatorRtpParameters=function(e){ys(e=vs.clone(e));const t={mid:"probator",codecs:[],headerExtensions:[],encodings:[{ssrc:1234}],rtcp:{cname:"probator"}};return t.codecs.push(e.codecs[0]),t.codecs[0].payloadType=127,t.headerExtensions=e.headerExtensions,t},Ni.canSend=function(e,t){return t.codecs.some((t=>t.kind===e))},Ni.canReceive=function(e,t){if(ys(e),0===e.codecs.length)return!1;const r=e.codecs[0];return t.codecs.some((e=>e.remotePayloadType===r.payloadType))};const gs=ms(Bi),vs=ms(Fi);function ys(e){if("object"!=typeof e)throw new TypeError("params is not an object");if(e.mid&&"string"!=typeof e.mid)throw new TypeError("params.mid is not a string");if(!Array.isArray(e.codecs))throw new TypeError("missing params.codecs");for(const t of e.codecs)Ss(t);if(e.headerExtensions&&!Array.isArray(e.headerExtensions))throw new TypeError("params.headerExtensions is not an array");e.headerExtensions||(e.headerExtensions=[]);for(const t of e.headerExtensions)ks(t);if(e.encodings&&!Array.isArray(e.encodings))throw new TypeError("params.encodings is not an array");e.encodings||(e.encodings=[]);for(const t of e.encodings)Cs(t);if(e.rtcp&&"object"!=typeof e.rtcp)throw new TypeError("params.rtcp is not an object");e.rtcp||(e.rtcp={}),function(e){if("object"!=typeof e)throw new TypeError("rtcp is not an object");if(e.cname&&"string"!=typeof e.cname)throw new TypeError("invalid rtcp.cname");e.reducedSize&&"boolean"==typeof e.reducedSize||(e.reducedSize=!0)}(e.rtcp)}function bs(e){const t=new RegExp("^(audio|video)/(.+)","i");if("object"!=typeof e)throw new TypeError("codec is not an object");if(!e.mimeType||"string"!=typeof e.mimeType)throw new TypeError("missing codec.mimeType");const r=t.exec(e.mimeType);if(!r)throw new TypeError("invalid codec.mimeType");if(e.kind=r[1].toLowerCase(),e.preferredPayloadType&&"number"!=typeof e.preferredPayloadType)throw new TypeError("invalid codec.preferredPayloadType");if("number"!=typeof e.clockRate)throw new TypeError("missing codec.clockRate");"audio"===e.kind?"number"!=typeof e.channels&&(e.channels=1):delete e.channels,e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError(`invalid codec parameter [key:${t}s, value:${r}]`);if("apt"===t&&"number"!=typeof r)throw new TypeError("invalid codec apt parameter")}e.rtcpFeedback&&Array.isArray(e.rtcpFeedback)||(e.rtcpFeedback=[]);for(const t of e.rtcpFeedback)ws(t)}function ws(e){if("object"!=typeof e)throw new TypeError("fb is not an object");if(!e.type||"string"!=typeof e.type)throw new TypeError("missing fb.type");e.parameter&&"string"==typeof e.parameter||(e.parameter="")}function _s(e){if("object"!=typeof e)throw new TypeError("ext is not an object");if("audio"!==e.kind&&"video"!==e.kind)throw new TypeError("invalid ext.kind");if(!e.uri||"string"!=typeof e.uri)throw new TypeError("missing ext.uri");if("number"!=typeof e.preferredId)throw new TypeError("missing ext.preferredId");if(e.preferredEncrypt&&"boolean"!=typeof e.preferredEncrypt)throw new TypeError("invalid ext.preferredEncrypt");if(e.preferredEncrypt||(e.preferredEncrypt=!1),e.direction&&"string"!=typeof e.direction)throw new TypeError("invalid ext.direction");e.direction||(e.direction="sendrecv")}function Ss(e){const t=new RegExp("^(audio|video)/(.+)","i");if("object"!=typeof e)throw new TypeError("codec is not an object");if(!e.mimeType||"string"!=typeof e.mimeType)throw new TypeError("missing codec.mimeType");const r=t.exec(e.mimeType);if(!r)throw new TypeError("invalid codec.mimeType");if("number"!=typeof e.payloadType)throw new TypeError("missing codec.payloadType");if("number"!=typeof e.clockRate)throw new TypeError("missing codec.clockRate");"audio"===r[1].toLowerCase()?"number"!=typeof e.channels&&(e.channels=1):delete e.channels,e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError(`invalid codec parameter [key:${t}s, value:${r}]`);if("apt"===t&&"number"!=typeof r)throw new TypeError("invalid codec apt parameter")}e.rtcpFeedback&&Array.isArray(e.rtcpFeedback)||(e.rtcpFeedback=[]);for(const t of e.rtcpFeedback)ws(t)}function ks(e){if("object"!=typeof e)throw new TypeError("ext is not an object");if(!e.uri||"string"!=typeof e.uri)throw new TypeError("missing ext.uri");if("number"!=typeof e.id)throw new TypeError("missing ext.id");if(e.encrypt&&"boolean"!=typeof e.encrypt)throw new TypeError("invalid ext.encrypt");e.encrypt||(e.encrypt=!1),e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError("invalid header extension parameter")}}function Cs(e){if("object"!=typeof e)throw new TypeError("encoding is not an object");if(e.ssrc&&"number"!=typeof e.ssrc)throw new TypeError("invalid encoding.ssrc");if(e.rid&&"string"!=typeof e.rid)throw new TypeError("invalid encoding.rid");if(e.rtx&&"object"!=typeof e.rtx)throw new TypeError("invalid encoding.rtx");if(e.rtx&&"number"!=typeof e.rtx.ssrc)throw new TypeError("missing encoding.rtx.ssrc");if(e.dtx&&"boolean"==typeof e.dtx||(e.dtx=!1),e.scalabilityMode&&"string"!=typeof e.scalabilityMode)throw new TypeError("invalid encoding.scalabilityMode")}function Rs(e){return!!e&&/.+\/rtx$/i.test(e.mimeType)}function Ps(e,t,{strict:r=!1,modify:n=!1}={}){const i=e.mimeType.toLowerCase();if(i!==t.mimeType.toLowerCase())return!1;if(e.clockRate!==t.clockRate)return!1;if(e.channels!==t.channels)return!1;switch(i){case"video/h264":if(r){if((e.parameters["packetization-mode"]||0)!==(t.parameters["packetization-mode"]||0))return!1;if(!gs.isSameProfile(e.parameters,t.parameters))return!1;let r;try{r=gs.generateProfileLevelIdStringForAnswer(e.parameters,t.parameters)}catch(e){return!1}n&&(r?(e.parameters["profile-level-id"]=r,t.parameters["profile-level-id"]=r):(delete e.parameters["profile-level-id"],delete t.parameters["profile-level-id"]))}break;case"video/vp9":if(r){if((e.parameters["profile-id"]||0)!==(t.parameters["profile-id"]||0))return!1}}return!0}function Ts(e,t){return(!e.kind||!t.kind||e.kind===t.kind)&&e.uri===t.uri}function Es(e,t){const r=[];for(const n of e.rtcpFeedback??[]){const e=(t.rtcpFeedback??[]).find((e=>e.type===n.type&&(e.parameter===n.parameter||!e.parameter&&!n.parameter)));e&&r.push(e)}return r}var Ds={},Is={},Ms={},xs={exports:{}},Os=1e3,Ls=60*Os,As=60*Ls,js=24*As,Fs=7*js,Ns=365.25*js,Bs=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*Ns;case"weeks":case"week":case"w":return r*Fs;case"days":case"day":case"d":return r*js;case"hours":case"hour":case"hrs":case"hr":case"h":return r*As;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ls;case"seconds":case"second":case"secs":case"sec":case"s":return r*Os;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=js)return Ws(e,t,js,"day");if(t>=As)return Ws(e,t,As,"hour");if(t>=Ls)return Ws(e,t,Ls,"minute");if(t>=Os)return Ws(e,t,Os,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=js)return Math.round(e/js)+"d";if(t>=As)return Math.round(e/As)+"h";if(t>=Ls)return Math.round(e/Ls)+"m";if(t>=Os)return Math.round(e/Os)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ws(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var qs=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r<i;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=Bs,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=qs(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(xs,xs.exports),Object.defineProperty(Ms,"__esModule",{value:!0}),Ms.Logger=void 0;const Us=xs.exports,zs="awaitqueue";Ms.Logger=class{constructor(e){e?(this._debug=(0,Us.default)(`awaitqueue:${e}`),this._warn=(0,Us.default)(`awaitqueue:WARN:${e}`),this._error=(0,Us.default)(`awaitqueue:ERROR:${e}`)):(this._debug=(0,Us.default)(zs),this._warn=(0,Us.default)("awaitqueue:WARN"),this._error=(0,Us.default)("awaitqueue:ERROR")),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}},Object.defineProperty(Is,"__esModule",{value:!0}),Is.AwaitQueue=Is.AwaitQueueRemovedTaskError=Is.AwaitQueueStoppedError=void 0;const Vs=new Ms.Logger;class Hs extends Error{constructor(e){super(e??"AwaitQueue stopped"),this.name="AwaitQueueStoppedError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Hs)}}Is.AwaitQueueStoppedError=Hs;class $s extends Error{constructor(e){super(e??"AwaitQueue task removed"),this.name="AwaitQueueRemovedTaskError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,$s)}}Is.AwaitQueueRemovedTaskError=$s;
|
|
29
|
+
***************************************************************************** */!function(e){!function(t){var r="object"==typeof globalThis?globalThis:"object"==typeof l?l:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),n=i(e);function i(e,t){return function(r,n){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0!==r.Reflect&&(n=i(r.Reflect,n)),function(e,t){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,i=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",s=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",o="function"==typeof Object.create,a={__proto__:[]}instanceof Array,c=!o&&!a,d={create:o?function(){return le(Object.create(null))}:a?function(){return le({__proto__:null})}:function(){return le({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),l="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),p="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:de(),h="function"==typeof WeakMap?WeakMap:ue(),f=n?Symbol.for("@reflect-metadata:registry"):void 0,m=ie(),g=se(m);function v(e,t,r,n){if(F(r)){if(!$(e))throw new TypeError;if(!G(t))throw new TypeError;return T(e,t)}if(!$(e))throw new TypeError;if(!W(t))throw new TypeError;if(!W(n)&&!F(n)&&!N(n))throw new TypeError;return N(n)&&(n=void 0),E(e,t,r=H(r),n)}function y(e,t){function r(r,n){if(!W(r))throw new TypeError;if(!F(n)&&!Q(n))throw new TypeError;O(e,t,r,n)}return r}function b(e,t,r,n){if(!W(r))throw new TypeError;return F(n)||(n=H(n)),O(e,t,r,n)}function w(e,t,r){if(!W(t))throw new TypeError;return F(r)||(r=H(r)),D(e,t,r)}function _(e,t,r){if(!W(t))throw new TypeError;return F(r)||(r=H(r)),M(e,t,r)}function S(e,t,r){if(!W(t))throw new TypeError;return F(r)||(r=H(r)),I(e,t,r)}function k(e,t,r){if(!W(t))throw new TypeError;return F(r)||(r=H(r)),x(e,t,r)}function C(e,t){if(!W(e))throw new TypeError;return F(t)||(t=H(t)),L(e,t)}function R(e,t){if(!W(e))throw new TypeError;return F(t)||(t=H(t)),A(e,t)}function P(e,t,r){if(!W(t))throw new TypeError;if(F(r)||(r=H(r)),!W(t))throw new TypeError;F(r)||(r=H(r));var n=ae(t,r,!1);return!F(n)&&n.OrdinaryDeleteMetadata(e,t,r)}function T(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!F(n)&&!N(n)){if(!G(n))throw new TypeError;t=n}}return t}function E(e,t,r,n){for(var i=e.length-1;i>=0;--i){var s=(0,e[i])(t,r,n);if(!F(s)&&!N(s)){if(!W(s))throw new TypeError;n=s}}return n}function D(e,t,r){if(M(e,t,r))return!0;var n=re(t);return!N(n)&&D(e,n,r)}function M(e,t,r){var n=ae(t,r,!1);return!F(n)&&z(n.OrdinaryHasOwnMetadata(e,t,r))}function I(e,t,r){if(M(e,t,r))return x(e,t,r);var n=re(t);return N(n)?void 0:I(e,n,r)}function x(e,t,r){var n=ae(t,r,!1);if(!F(n))return n.OrdinaryGetOwnMetadata(e,t,r)}function O(e,t,r,n){ae(r,n,!0).OrdinaryDefineOwnMetadata(e,t,r,n)}function L(e,t){var r=A(e,t),n=re(e);if(null===n)return r;var i=L(n,t);if(i.length<=0)return r;if(r.length<=0)return i;for(var s=new p,o=[],a=0,c=r;a<c.length;a++){var d=c[a];s.has(d)||(s.add(d),o.push(d))}for(var u=0,l=i;u<l.length;u++){d=l[u];s.has(d)||(s.add(d),o.push(d))}return o}function A(e,t){var r=ae(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function j(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function F(e){return void 0===e}function N(e){return null===e}function B(e){return"symbol"==typeof e}function W(e){return"object"==typeof e?null!==e:"function"==typeof e}function q(e,t){switch(j(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r=3===t?"string":5===t?"number":"default",n=Y(e,i);if(void 0!==n){var s=n.call(e,r);if(W(s))throw new TypeError;return s}return U(e,"default"===r?"number":r)}function U(e,t){if("string"===t){var r=e.toString;if(K(r))if(!W(i=r.call(e)))return i;if(K(n=e.valueOf))if(!W(i=n.call(e)))return i}else{var n;if(K(n=e.valueOf))if(!W(i=n.call(e)))return i;var i,s=e.toString;if(K(s))if(!W(i=s.call(e)))return i}throw new TypeError}function z(e){return!!e}function V(e){return""+e}function H(e){var t=q(e,3);return B(t)?t:V(t)}function $(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function K(e){return"function"==typeof e}function G(e){return"function"==typeof e}function Q(e){switch(j(e)){case 3:case 4:return!0;default:return!1}}function J(e,t){return e===t||e!=e&&t!=t}function Y(e,t){var r=e[t];if(null!=r){if(!K(r))throw new TypeError;return r}}function Z(e){var t=Y(e,s);if(!K(t))throw new TypeError;var r=t.call(e);if(!W(r))throw new TypeError;return r}function X(e){return e.value}function ee(e){var t=e.next();return!t.done&&t}function te(e){var t=e.return;t&&t.call(e)}function re(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===u)return t;if(t!==u)return t;var r=e.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return t;var i=n.constructor;return"function"!=typeof i||i===e?t:i}function ne(){var e,r,n,i;F(f)||void 0===t.Reflect||f in t.Reflect||"function"!=typeof t.Reflect.defineMetadata||(e=oe(t.Reflect));var s=new h,o={registerProvider:a,getProvider:d,setProvider:m};return o;function a(t){if(!Object.isExtensible(o))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case e===t:break;case F(r):r=t;break;case r===t:break;case F(n):n=t;break;case n===t:break;default:void 0===i&&(i=new p),i.add(t)}}function c(t,s){if(!F(r)){if(r.isProviderFor(t,s))return r;if(!F(n)){if(n.isProviderFor(t,s))return r;if(!F(i))for(var o=Z(i);;){var a=ee(o);if(!a)return;var c=X(a);if(c.isProviderFor(t,s))return te(o),c}}}if(!F(e)&&e.isProviderFor(t,s))return e}function d(e,t){var r,n=s.get(e);return F(n)||(r=n.get(t)),F(r)?(F(r=c(e,t))||(F(n)&&(n=new l,s.set(e,n)),n.set(t,r)),r):r}function u(e){if(F(e))throw new TypeError;return r===e||n===e||!F(i)&&i.has(e)}function m(e,t,r){if(!u(r))throw new Error("Metadata provider not registered.");var n=d(e,t);if(n!==r){if(!F(n))return!1;var i=s.get(e);F(i)&&(i=new l,s.set(e,i)),i.set(t,r)}return!0}}function ie(){var e;return!F(f)&&W(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[f]),F(e)&&(e=ne()),!F(f)&&W(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,f,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function se(e){var t=new h,r={isProviderFor:function(e,r){var n=t.get(e);return!F(n)&&n.has(r)},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:i,OrdinaryGetOwnMetadata:s,OrdinaryOwnMetadataKeys:a,OrdinaryDeleteMetadata:c};return m.registerProvider(r),r;function n(n,i,s){var o=t.get(n),a=!1;if(F(o)){if(!s)return;o=new l,t.set(n,o),a=!0}var c=o.get(i);if(F(c)){if(!s)return;if(c=new l,o.set(i,c),!e.setProvider(n,i,r))throw o.delete(i),a&&t.delete(n),new Error("Wrong provider for target.")}return c}function i(e,t,r){var i=n(t,r,!1);return!F(i)&&z(i.has(e))}function s(e,t,r){var i=n(t,r,!1);if(!F(i))return i.get(e)}function o(e,t,r,i){n(r,i,!0).set(e,t)}function a(e,t){var r=[],i=n(e,t,!1);if(F(i))return r;for(var s=Z(i.keys()),o=0;;){var a=ee(s);if(!a)return r.length=o,r;var c=X(a);try{r[o]=c}catch(e){try{te(s)}finally{throw e}}o++}}function c(e,r,i){var s=n(r,i,!1);if(F(s))return!1;if(!s.delete(e))return!1;if(0===s.size){var o=t.get(r);F(o)||(o.delete(i),0===o.size&&t.delete(o))}return!0}}function oe(e){var t=e.defineMetadata,r=e.hasOwnMetadata,n=e.getOwnMetadata,i=e.getOwnMetadataKeys,s=e.deleteMetadata,o=new h,a={isProviderFor:function(e,t){var r=o.get(e);return!(F(r)||!r.has(t))||!!i(e,t).length&&(F(r)&&(r=new p,o.set(e,r)),r.add(t),!0)},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:r,OrdinaryGetOwnMetadata:n,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:s};return a}function ae(e,t,r){var n=m.getProvider(e,t);if(!F(n))return n;if(r){if(m.setProvider(e,t,g))return g;throw new Error("Illegal state.")}}function ce(){var e={},t=[],r=function(){function e(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return e.prototype["@@iterator"]=function(){return this},e.prototype[s]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}(),n=function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},t.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var n=this._keys.length,i=r+1;i<n;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,J(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new r(this._keys,this._values,i)},t.prototype.values=function(){return new r(this._keys,this._values,o)},t.prototype.entries=function(){return new r(this._keys,this._values,a)},t.prototype["@@iterator"]=function(){return this.entries()},t.prototype[s]=function(){return this.entries()},t.prototype._find=function(e,t){if(!J(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(J(this._keys[r],e)){this._cacheIndex=r;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();return n;function i(e,t){return e}function o(e,t){return t}function a(e,t){return[e,t]}}function de(){var e=function(){function e(){this._map=new l}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype["@@iterator"]=function(){return this.keys()},e.prototype[s]=function(){return this.keys()},e}();return e}function ue(){var e=16,t=d.create(),n=i();return function(){function e(){this._key=i()}return e.prototype.has=function(e){var t=s(e,!1);return void 0!==t&&d.has(t,this._key)},e.prototype.get=function(e){var t=s(e,!1);return void 0!==t?d.get(t,this._key):void 0},e.prototype.set=function(e,t){return s(e,!0)[this._key]=t,this},e.prototype.delete=function(e){var t=s(e,!1);return void 0!==t&&delete t[this._key]},e.prototype.clear=function(){this._key=i()},e}();function i(){var e;do{e="@@WeakMap@@"+c()}while(d.has(t,e));return t[e]=!0,e}function s(e,t){if(!r.call(e,n)){if(!t)return;Object.defineProperty(e,n,{value:d.create()})}return e[n]}function o(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function a(e){if("function"==typeof Uint8Array){var t=new Uint8Array(e);return"undefined"!=typeof crypto?crypto.getRandomValues(t):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(t):o(t,e),t}return o(new Array(e),e)}function c(){var t=a(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var r="",n=0;n<e;++n){var i=t[n];4!==n&&6!==n&&8!==n||(r+="-"),i<16&&(r+="0"),r+=i.toString(16).toLowerCase()}return r}}function le(e){return e.__=void 0,delete e.__,e}e("decorate",v),e("metadata",y),e("defineMetadata",b),e("hasMetadata",w),e("hasOwnMetadata",_),e("getMetadata",S),e("getOwnMetadata",k),e("getMetadataKeys",C),e("getOwnMetadataKeys",R),e("deleteMetadata",P)}(n,r),void 0===r.Reflect&&(r.Reflect=e)}()}(u||(u={}));var f=["inject","multi_inject","name","unmanaged","named","optional"],m="Request",g="Singleton",v="Transient",y="ConstantValue",b="Constructor",w="DynamicValue",_="Factory",S="Function",k="Instance",C="Invalid",R="Provider",P="ClassProperty",T="ConstructorArgument",E="Variable",D=0;function M(){return D++}var I=function(){function e(e,t){this.id=M(),this.activated=!1,this.serviceIdentifier=e,this.scope=t,this.type=C,this.constraint=function(e){return!0},this.implementationType=null,this.cache=null,this.factory=null,this.provider=null,this.onActivation=null,this.onDeactivation=null,this.dynamicValue=null}return e.prototype.clone=function(){var t=new e(this.serviceIdentifier,this.scope);return t.activated=t.scope===g&&this.activated,t.implementationType=this.implementationType,t.dynamicValue=this.dynamicValue,t.scope=this.scope,t.type=this.type,t.factory=this.factory,t.provider=this.provider,t.constraint=this.constraint,t.onActivation=this.onActivation,t.onDeactivation=this.onDeactivation,t.cache=this.cache,t},e}(),x="No matching bindings found for serviceIdentifier:",O="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.",L=function(e,t){return"onDeactivation() error in class "+e+": "+t},A=function(){function e(){}return e.prototype.getConstructorMetadata=function(e){return{compilerGeneratedMetadata:Reflect.getMetadata("inversify:paramtypes",e),userGeneratedMetadata:Reflect.getMetadata("inversify:tagged",e)||{}}},e.prototype.getPropertiesMetadata=function(e){return Reflect.getMetadata("inversify:tagged_props",e)||[]},e}(),j=0,F=1;function N(e){return e instanceof RangeError||"Maximum call stack size exceeded"===e.message}function B(e){return"function"==typeof e?e.name:"symbol"==typeof e?e.toString():e}function W(e,t,r){var n="",i=r(e,t);return 0!==i.length&&(n="\nRegistered bindings:",i.forEach((function(e){var t="Object";null!==e.implementationType&&(t=z(e.implementationType)),n=n+"\n "+t,e.constraint.metaData&&(n=n+" - "+e.constraint.metaData)}))),n}function q(e,t){return null!==e.parentRequest&&(e.parentRequest.serviceIdentifier===t||q(e.parentRequest,t))}function U(e){e.childRequests.forEach((function(e){if(q(e,e.serviceIdentifier)){var t=function(e){return function e(t,r){void 0===r&&(r=[]);var n=B(t.serviceIdentifier);return r.push(n),null!==t.parentRequest?e(t.parentRequest,r):r}(e).reverse().join(" --\x3e ")}(e);throw new Error("Circular dependency found: "+t)}U(e)}))}function z(e){if(e.name)return e.name;var t=e.toString(),r=t.match(/^function\s*([^\s(]+)/);return r?r[1]:"Anonymous function: "+t}var V=function(){function e(e){this.id=M(),this.container=e}return e.prototype.addPlan=function(e){this.plan=e},e.prototype.setCurrentRequest=function(e){this.currentRequest=e},e}(),H=function(){function e(e,t){this.key=e,this.value=t}return e.prototype.toString=function(){return"named"===this.key?"named: "+String(this.value).toString()+" ":"tagged: { key:"+this.key.toString()+", value: "+String(this.value)+" }"},e}(),$=function(e,t){this.parentContext=e,this.rootRequest=t},K=function(){function e(e){this._cb=e}return e.prototype.unwrap=function(){return this._cb()},e}(),G=function(){function e(e){this.str=e}return e.prototype.startsWith=function(e){return 0===this.str.indexOf(e)},e.prototype.endsWith=function(e){var t,r=e.split("").reverse().join("");return t=this.str.split("").reverse().join(""),this.startsWith.call({str:t},r)},e.prototype.contains=function(e){return-1!==this.str.indexOf(e)},e.prototype.equals=function(e){return this.str===e},e.prototype.value=function(){return this.str},e}(),Q=function(){function e(e,t,r,n){this.id=M(),this.type=e,this.serviceIdentifier=r;var i="symbol"==typeof t?t.toString().slice(7,-1):t;this.name=new G(i||""),this.identifier=t,this.metadata=new Array;var s=null;"string"==typeof n?s=new H("named",n):n instanceof H&&(s=n),null!==s&&this.metadata.push(s)}return e.prototype.hasTag=function(e){for(var t=0,r=this.metadata;t<r.length;t++){if(r[t].key===e)return!0}return!1},e.prototype.isArray=function(){return this.hasTag("multi_inject")},e.prototype.matchesArray=function(e){return this.matchesTag("multi_inject")(e)},e.prototype.isNamed=function(){return this.hasTag("named")},e.prototype.isTagged=function(){return this.metadata.some((function(e){return f.every((function(t){return e.key!==t}))}))},e.prototype.isOptional=function(){return this.matchesTag("optional")(!0)},e.prototype.getNamedTag=function(){return this.isNamed()?this.metadata.filter((function(e){return"named"===e.key}))[0]:null},e.prototype.getCustomTags=function(){return this.isTagged()?this.metadata.filter((function(e){return f.every((function(t){return e.key!==t}))})):null},e.prototype.matchesNamedTag=function(e){return this.matchesTag("named")(e)},e.prototype.matchesTag=function(e){var t=this;return function(r){for(var n=0,i=t.metadata;n<i.length;n++){var s=i[n];if(s.key===e&&s.value===r)return!0}return!1}},e}(),J=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function Y(e,t,r,n){var i=e.getConstructorMetadata(r),s=i.compilerGeneratedMetadata;if(void 0===s)throw new Error("Missing required @injectable annotation in: "+t+".");var o=i.userGeneratedMetadata,a=Object.keys(o),c=0===r.length&&a.length>0,d=a.length>r.length,u=function(e,t,r,n,i){for(var s=[],o=0;o<i;o++){var a=Z(o,e,t,r,n);null!==a&&s.push(a)}return s}(n,t,s,o,c||d?a.length:r.length),l=ee(e,r,t);return J(J([],u,!0),l,!0)}function Z(e,t,r,n,i){var s=i[e.toString()]||[],o=re(s),a=!0!==o.unmanaged,c=n[e],d=o.inject||o.multiInject;if((c=d||c)instanceof K&&(c=c.unwrap()),a){if(!t&&(c===Object||c===Function||void 0===c))throw new Error("Missing required @inject or @multiInject annotation in: argument "+e+" in class "+r+".");var u=new Q(T,o.targetName,c);return u.metadata=s,u}return null}function X(e,t,r,n){var i=e||t;if(void 0===i){var s="Missing required @injectable annotation in: for property "+String(r)+" in class "+n+".";throw new Error(s)}return i}function ee(e,t,r){for(var n=e.getPropertiesMetadata(t),i=[],s=Object.getOwnPropertySymbols(n),o=0,a=Object.keys(n).concat(s);o<a.length;o++){var c=a[o],d=n[c],u=re(d),l=u.targetName||c,p=X(u.inject,u.multiInject,c,r),h=new Q(P,l,p);h.metadata=d,i.push(h)}var f=Object.getPrototypeOf(t.prototype).constructor;if(f!==Object){var m=ee(e,f,r);i=J(J([],i,!0),m,!0)}return i}function te(e,t){var r=Object.getPrototypeOf(t.prototype).constructor;if(r!==Object){var n=Y(e,z(r),r,!0),i=n.map((function(e){return e.metadata.filter((function(e){return"unmanaged"===e.key}))})),s=[].concat.apply([],i).length,o=n.length-s;return o>0?o:te(e,r)}return 0}function re(e){var t={};return e.forEach((function(e){t[e.key.toString()]=e.value})),{inject:t.inject,multiInject:t.multi_inject,targetName:t.name,unmanaged:t.unmanaged}}var ne=function(){function e(e,t,r,n,i){this.id=M(),this.serviceIdentifier=e,this.parentContext=t,this.parentRequest=r,this.target=i,this.childRequests=[],this.bindings=Array.isArray(n)?n:[n],this.requestScope=null===r?new Map:null}return e.prototype.addChildRequest=function(t,r,n){var i=new e(t,this.parentContext,this,r,n);return this.childRequests.push(i),i},e}();function ie(e){return e._bindingDictionary}function se(e,t,r,n,i){var s=ae(r.container,i.serviceIdentifier),o=[];return s.length===j&&r.container.options.autoBindInjectable&&"function"==typeof i.serviceIdentifier&&e.getConstructorMetadata(i.serviceIdentifier).compilerGeneratedMetadata&&(r.container.bind(i.serviceIdentifier).toSelf(),s=ae(r.container,i.serviceIdentifier)),o=t?s:s.filter((function(e){var t=new ne(e.serviceIdentifier,r,n,e,i);return e.constraint(t)})),function(e,t,r,n){switch(t.length){case j:if(r.isOptional())return t;var i=B(e),s=x;throw s+=function(e,t){if(t.isTagged()||t.isNamed()){var r="",n=t.getNamedTag(),i=t.getCustomTags();return null!==n&&(r+=n.toString()+"\n"),null!==i&&i.forEach((function(e){r+=e.toString()+"\n"}))," "+e+"\n "+e+" - "+r}return" "+e}(i,r),s+=W(n,i,ae),new Error(s);case F:return t;default:if(r.isArray())return t;s="Ambiguous match found for serviceIdentifier: "+(i=B(e));throw s+=W(n,i,ae),new Error(s)}}(i.serviceIdentifier,o,i,r.container),o}function oe(e,t,r,n,i,s){var o,a;if(null===i){o=se(e,t,n,null,s),a=new ne(r,n,null,o,s);var c=new $(n,a);n.addPlan(c)}else o=se(e,t,n,i,s),a=i.addChildRequest(s.serviceIdentifier,o,s);o.forEach((function(t){var r=null;if(s.isArray())r=a.addChildRequest(t.serviceIdentifier,t,s);else{if(t.cache)return;r=a}if(t.type===k&&null!==t.implementationType){var i=function(e,t){return Y(e,z(t),t,!1)}(e,t.implementationType);if(!n.container.options.skipBaseClassChecks){var o=te(e,t.implementationType);if(i.length<o){var c=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"The number of constructor arguments in the derived class "+e[0]+" must be >= than the number of constructor arguments of its base class."}(z(t.implementationType));throw new Error(c)}}i.forEach((function(t){oe(e,!1,t.serviceIdentifier,n,r,t)}))}}))}function ae(e,t){var r=[],n=ie(e);return n.hasKey(t)?r=n.get(t):null!==e.parent&&(r=ae(e.parent,t)),r}function ce(e,t,r,n,i,s,o,a){void 0===a&&(a=!1);var c=new V(t),d=function(e,t,r,n,i,s){var o=new H(e?"multi_inject":"inject",r),a=new Q(t,n,r,o);if(void 0!==i){var c=new H(i,s);a.metadata.push(c)}return a}(r,n,i,"",s,o);try{return oe(e,a,i,c,null,d),c}catch(e){throw N(e)&&U(c.plan.rootRequest),e}}function de(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then}function ue(e){return!!de(e)||Array.isArray(e)&&e.some(de)}var le,pe=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},he=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},fe=function(e,t,r){e.has(t.id)||e.set(t.id,r)},me=function(e,t){e.cache=t,e.activated=!0,de(t)&&ge(e,t)},ge=function(e,t){return pe(void 0,void 0,void 0,(function(){var r,n;return he(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t];case 1:return r=i.sent(),e.cache=r,[3,3];case 2:throw n=i.sent(),e.cache=null,e.activated=!1,n;case 3:return[2]}}))}))};!function(e){e.DynamicValue="toDynamicValue",e.Factory="toFactory",e.Provider="toProvider"}(le||(le={}));var ve=function(){return ve=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ve.apply(this,arguments)},ye=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},be=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},we=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};function _e(e,t,r){var n;if(t.length>0){var i=function(e,t){return e.reduce((function(e,r){var n=t(r);return r.target.type===T?e.constructorInjections.push(n):(e.propertyRequests.push(r),e.propertyInjections.push(n)),e.isAsync||(e.isAsync=ue(n)),e}),{constructorInjections:[],propertyInjections:[],propertyRequests:[],isAsync:!1})}(t,r),s=ve(ve({},i),{constr:e});n=i.isAsync?function(e){return ye(this,void 0,void 0,(function(){var t,r;return be(this,(function(n){switch(n.label){case 0:return[4,ke(e.constructorInjections)];case 1:return t=n.sent(),[4,ke(e.propertyInjections)];case 2:return r=n.sent(),[2,Se(ve(ve({},e),{constructorInjections:t,propertyInjections:r}))]}}))}))}(s):Se(s)}else n=new e;return n}function Se(e){var t,r=new((t=e.constr).bind.apply(t,we([void 0],e.constructorInjections,!1)));return e.propertyRequests.forEach((function(t,n){var i=t.target.identifier,s=e.propertyInjections[n];t.target.isOptional()&&void 0===s||(r[i]=s)})),r}function ke(e){return ye(this,void 0,void 0,(function(){var t,r,n,i;return be(this,(function(s){for(t=[],r=0,n=e;r<n.length;r++)i=n[r],Array.isArray(i)?t.push(Promise.all(i)):t.push(i);return[2,Promise.all(t)]}))}))}function Ce(e,t){var r=function(e,t){var r,n;if(Reflect.hasMetadata("post_construct",e)){var i=Reflect.getMetadata("post_construct",e);try{return null===(n=(r=t)[i.value])||void 0===n?void 0:n.call(r)}catch(t){if(t instanceof Error)throw new Error((s=e.name,o=t.message,"@postConstruct error in class "+s+": "+o))}}var s,o}(e,t);return de(r)?r.then((function(){return t})):t}function Re(e,t){e.scope!==g&&function(e,t){var r="Class cannot be instantiated in "+(e.scope===m?"request":"transient")+" scope.";if("function"==typeof e.onDeactivation)throw new Error(L(t.name,r));if(Reflect.hasMetadata("pre_destroy",t))throw new Error("@preDestroy error in class "+t.name+": "+r)}(e,t)}var Pe=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},Te=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},Ee=function(e){return function(t){t.parentContext.setCurrentRequest(t);var r=t.bindings,n=t.childRequests,i=t.target&&t.target.isArray(),s=!(t.parentRequest&&t.parentRequest.target&&t.target&&t.parentRequest.target.matchesArray(t.target.serviceIdentifier));if(i&&s)return n.map((function(t){return Ee(e)(t)}));if(!t.target.isOptional()||0!==r.length){var o=r[0];return xe(e,t,o)}}},De=function(e,t){var r=function(e){switch(e.type){case _:return{factory:e.factory,factoryType:le.Factory};case R:return{factory:e.provider,factoryType:le.Provider};case w:return{factory:e.dynamicValue,factoryType:le.DynamicValue};default:throw new Error("Unexpected factory type "+e.type)}}(e);return function(e,t){try{return e()}catch(e){throw N(e)&&(e=t()),e}}((function(){return r.factory.bind(e)(t)}),(function(){return new Error((e=r.factoryType,n=t.currentRequest.serviceIdentifier.toString(),"It looks like there is a circular dependency in one of the '"+e+"' bindings. Please investigate bindings with service identifier '"+n+"'."));var e,n}))},Me=function(e,t,r){var n,i=t.childRequests;switch(function(e){var t=null;switch(e.type){case y:case S:t=e.cache;break;case b:case k:t=e.implementationType;break;case w:t=e.dynamicValue;break;case R:t=e.provider;break;case _:t=e.factory}if(null===t){var r=B(e.serviceIdentifier);throw new Error("Invalid binding type: "+r)}}(r),r.type){case y:case S:n=r.cache;break;case b:n=r.implementationType;break;case k:n=function(e,t,r,n){Re(e,t);var i=_e(t,r,n);return de(i)?i.then((function(e){return Ce(t,e)})):Ce(t,i)}(r,r.implementationType,i,Ee(e));break;default:n=De(r,t.parentContext)}return n},Ie=function(e,t,r){var n=function(e,t){return t.scope===g&&t.activated?t.cache:t.scope===m&&e.has(t.id)?e.get(t.id):null}(e,t);return null!==n||function(e,t,r){t.scope===g&&me(t,r),t.scope===m&&fe(e,t,r)}(e,t,n=r()),n},xe=function(e,t,r){return Ie(e,r,(function(){var n=Me(e,t,r);return n=de(n)?n.then((function(e){return Oe(t,r,e)})):Oe(t,r,n)}))};function Oe(e,t,r){var n,i=Le(e.parentContext,t,r),s=Ne(e.parentContext.container),o=s.next();do{n=o.value;var a=e.parentContext,c=e.serviceIdentifier,d=Fe(n,c);i=de(i)?je(d,a,i):Ae(d,a,i),o=s.next()}while(!0!==o.done&&!ie(n).hasKey(e.serviceIdentifier));return i}var Le=function(e,t,r){return"function"==typeof t.onActivation?t.onActivation(e,r):r},Ae=function(e,t,r){for(var n=e.next();!n.done;){if(de(r=n.value(t,r)))return je(e,t,r);n=e.next()}return r},je=function(e,t,r){return Pe(void 0,void 0,void 0,(function(){var n,i;return Te(this,(function(s){switch(s.label){case 0:return[4,r];case 1:n=s.sent(),i=e.next(),s.label=2;case 2:return i.done?[3,4]:[4,i.value(t,n)];case 3:return n=s.sent(),i=e.next(),[3,2];case 4:return[2,n]}}))}))},Fe=function(e,t){var r=e._activations;return r.hasKey(t)?r.get(t).values():[].values()},Ne=function(e){for(var t=[e],r=e.parent;null!==r;)t.push(r),r=r.parent;return{next:function(){var e=t.pop();return void 0!==e?{done:!1,value:e}:{done:!0,value:void 0}}}};var Be=function(e,t){var r=e.parentRequest;return null!==r&&(!!t(r)||Be(r,t))},We=function(e){return function(t){var r=function(r){return null!==r&&null!==r.target&&r.target.matchesTag(e)(t)};return r.metaData=new H(e,t),r}},qe=We("named"),Ue=function(e){return function(t){var r=null;if(null!==t){if(r=t.bindings[0],"string"==typeof e)return r.serviceIdentifier===e;var n=t.bindings[0].implementationType;return e===n}return!1}},ze=function(){function e(e){this._binding=e}return e.prototype.when=function(e){return this._binding.constraint=e,new Ve(this._binding)},e.prototype.whenTargetNamed=function(e){return this._binding.constraint=qe(e),new Ve(this._binding)},e.prototype.whenTargetIsDefault=function(){return this._binding.constraint=function(e){return null!==e&&(null!==e.target&&!e.target.isNamed()&&!e.target.isTagged())},new Ve(this._binding)},e.prototype.whenTargetTagged=function(e,t){return this._binding.constraint=We(e)(t),new Ve(this._binding)},e.prototype.whenInjectedInto=function(e){return this._binding.constraint=function(t){return null!==t&&Ue(e)(t.parentRequest)},new Ve(this._binding)},e.prototype.whenParentNamed=function(e){return this._binding.constraint=function(t){return null!==t&&qe(e)(t.parentRequest)},new Ve(this._binding)},e.prototype.whenParentTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&We(e)(t)(r.parentRequest)},new Ve(this._binding)},e.prototype.whenAnyAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&Be(t,Ue(e))},new Ve(this._binding)},e.prototype.whenNoAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&!Be(t,Ue(e))},new Ve(this._binding)},e.prototype.whenAnyAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&Be(t,qe(e))},new Ve(this._binding)},e.prototype.whenNoAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&!Be(t,qe(e))},new Ve(this._binding)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&Be(r,We(e)(t))},new Ve(this._binding)},e.prototype.whenNoAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&!Be(r,We(e)(t))},new Ve(this._binding)},e.prototype.whenAnyAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&Be(t,e)},new Ve(this._binding)},e.prototype.whenNoAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&!Be(t,e)},new Ve(this._binding)},e}(),Ve=function(){function e(e){this._binding=e}return e.prototype.onActivation=function(e){return this._binding.onActivation=e,new ze(this._binding)},e.prototype.onDeactivation=function(e){return this._binding.onDeactivation=e,new ze(this._binding)},e}(),He=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new ze(this._binding),this._bindingOnSyntax=new Ve(this._binding)}return e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e.prototype.onDeactivation=function(e){return this._bindingOnSyntax.onDeactivation(e)},e}(),$e=function(){function e(e){this._binding=e}return e.prototype.inRequestScope=function(){return this._binding.scope=m,new He(this._binding)},e.prototype.inSingletonScope=function(){return this._binding.scope=g,new He(this._binding)},e.prototype.inTransientScope=function(){return this._binding.scope=v,new He(this._binding)},e}(),Ke=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new ze(this._binding),this._bindingOnSyntax=new Ve(this._binding),this._bindingInSyntax=new $e(e)}return e.prototype.inRequestScope=function(){return this._bindingInSyntax.inRequestScope()},e.prototype.inSingletonScope=function(){return this._bindingInSyntax.inSingletonScope()},e.prototype.inTransientScope=function(){return this._bindingInSyntax.inTransientScope()},e.prototype.when=function(e){return this._bindingWhenSyntax.when(e)},e.prototype.whenTargetNamed=function(e){return this._bindingWhenSyntax.whenTargetNamed(e)},e.prototype.whenTargetIsDefault=function(){return this._bindingWhenSyntax.whenTargetIsDefault()},e.prototype.whenTargetTagged=function(e,t){return this._bindingWhenSyntax.whenTargetTagged(e,t)},e.prototype.whenInjectedInto=function(e){return this._bindingWhenSyntax.whenInjectedInto(e)},e.prototype.whenParentNamed=function(e){return this._bindingWhenSyntax.whenParentNamed(e)},e.prototype.whenParentTagged=function(e,t){return this._bindingWhenSyntax.whenParentTagged(e,t)},e.prototype.whenAnyAncestorIs=function(e){return this._bindingWhenSyntax.whenAnyAncestorIs(e)},e.prototype.whenNoAncestorIs=function(e){return this._bindingWhenSyntax.whenNoAncestorIs(e)},e.prototype.whenAnyAncestorNamed=function(e){return this._bindingWhenSyntax.whenAnyAncestorNamed(e)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenAnyAncestorTagged(e,t)},e.prototype.whenNoAncestorNamed=function(e){return this._bindingWhenSyntax.whenNoAncestorNamed(e)},e.prototype.whenNoAncestorTagged=function(e,t){return this._bindingWhenSyntax.whenNoAncestorTagged(e,t)},e.prototype.whenAnyAncestorMatches=function(e){return this._bindingWhenSyntax.whenAnyAncestorMatches(e)},e.prototype.whenNoAncestorMatches=function(e){return this._bindingWhenSyntax.whenNoAncestorMatches(e)},e.prototype.onActivation=function(e){return this._bindingOnSyntax.onActivation(e)},e.prototype.onDeactivation=function(e){return this._bindingOnSyntax.onDeactivation(e)},e}(),Ge=function(){function e(e){this._binding=e}return e.prototype.to=function(e){return this._binding.type=k,this._binding.implementationType=e,new Ke(this._binding)},e.prototype.toSelf=function(){if("function"!=typeof this._binding.serviceIdentifier)throw new Error("The toSelf function can only be applied when a constructor is used as service identifier");var e=this._binding.serviceIdentifier;return this.to(e)},e.prototype.toConstantValue=function(e){return this._binding.type=y,this._binding.cache=e,this._binding.dynamicValue=null,this._binding.implementationType=null,this._binding.scope=g,new He(this._binding)},e.prototype.toDynamicValue=function(e){return this._binding.type=w,this._binding.cache=null,this._binding.dynamicValue=e,this._binding.implementationType=null,new Ke(this._binding)},e.prototype.toConstructor=function(e){return this._binding.type=b,this._binding.implementationType=e,this._binding.scope=g,new He(this._binding)},e.prototype.toFactory=function(e){return this._binding.type=_,this._binding.factory=e,this._binding.scope=g,new He(this._binding)},e.prototype.toFunction=function(e){if("function"!=typeof e)throw new Error("Value provided to function binding must be a function!");var t=this.toConstantValue(e);return this._binding.type=S,this._binding.scope=g,t},e.prototype.toAutoFactory=function(e){return this._binding.type=_,this._binding.factory=function(t){return function(){return t.container.get(e)}},this._binding.scope=g,new He(this._binding)},e.prototype.toAutoNamedFactory=function(e){return this._binding.type=_,this._binding.factory=function(t){return function(r){return t.container.getNamed(e,r)}},new He(this._binding)},e.prototype.toProvider=function(e){return this._binding.type=R,this._binding.provider=e,this._binding.scope=g,new He(this._binding)},e.prototype.toService=function(e){this.toDynamicValue((function(t){return t.container.get(e)}))},e}(),Qe=function(){function e(){}return e.of=function(t,r,n,i,s){var o=new e;return o.bindings=t,o.middleware=r,o.deactivations=i,o.activations=n,o.moduleActivationStore=s,o},e}();var Je=function(){function e(){this._map=new Map}return e.prototype.getMap=function(){return this._map},e.prototype.add=function(e,t){if(null==e)throw new Error("NULL argument");if(null==t)throw new Error("NULL argument");var r=this._map.get(e);void 0!==r?r.push(t):this._map.set(e,[t])},e.prototype.get=function(e){if(null==e)throw new Error("NULL argument");var t=this._map.get(e);if(void 0!==t)return t;throw new Error("Key Not Found")},e.prototype.remove=function(e){if(null==e)throw new Error("NULL argument");if(!this._map.delete(e))throw new Error("Key Not Found")},e.prototype.removeIntersection=function(e){var t=this;this.traverse((function(r,n){var i=e.hasKey(r)?e.get(r):void 0;if(void 0!==i){var s=n.filter((function(e){return!i.some((function(t){return e===t}))}));t._setValue(r,s)}}))},e.prototype.removeByCondition=function(e){var t=this,r=[];return this._map.forEach((function(n,i){for(var s=[],o=0,a=n;o<a.length;o++){var c=a[o];e(c)?r.push(c):s.push(c)}t._setValue(i,s)})),r},e.prototype.hasKey=function(e){if(null==e)throw new Error("NULL argument");return this._map.has(e)},e.prototype.clone=function(){var t=new e;return this._map.forEach((function(e,r){e.forEach((function(e){return t.add(r,"object"==typeof(n=e)&&null!==n&&"clone"in n&&"function"==typeof n.clone?e.clone():e);var n}))})),t},e.prototype.traverse=function(e){this._map.forEach((function(t,r){e(r,t)}))},e.prototype._setValue=function(e,t){t.length>0?this._map.set(e,t):this._map.delete(e)},e}(),Ye=function(){function e(){this._map=new Map}return e.prototype.remove=function(e){if(this._map.has(e)){var t=this._map.get(e);return this._map.delete(e),t}return this._getEmptyHandlersStore()},e.prototype.addDeactivation=function(e,t,r){this._getModuleActivationHandlers(e).onDeactivations.add(t,r)},e.prototype.addActivation=function(e,t,r){this._getModuleActivationHandlers(e).onActivations.add(t,r)},e.prototype.clone=function(){var t=new e;return this._map.forEach((function(e,r){t._map.set(r,{onActivations:e.onActivations.clone(),onDeactivations:e.onDeactivations.clone()})})),t},e.prototype._getModuleActivationHandlers=function(e){var t=this._map.get(e);return void 0===t&&(t=this._getEmptyHandlersStore(),this._map.set(e,t)),t},e.prototype._getEmptyHandlersStore=function(){return{onActivations:new Je,onDeactivations:new Je}},e}(),Ze=function(){return Ze=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ze.apply(this,arguments)},Xe=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))},et=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},tt=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},rt=function(){function e(e){var t=e||{};if("object"!=typeof t)throw new Error("Invalid Container constructor argument. Container options must be an object.");if(void 0===t.defaultScope)t.defaultScope=v;else if(t.defaultScope!==g&&t.defaultScope!==v&&t.defaultScope!==m)throw new Error('Invalid Container option. Default scope must be a string ("singleton" or "transient").');if(void 0===t.autoBindInjectable)t.autoBindInjectable=!1;else if("boolean"!=typeof t.autoBindInjectable)throw new Error("Invalid Container option. Auto bind injectable must be a boolean");if(void 0===t.skipBaseClassChecks)t.skipBaseClassChecks=!1;else if("boolean"!=typeof t.skipBaseClassChecks)throw new Error("Invalid Container option. Skip base check must be a boolean");this.options={autoBindInjectable:t.autoBindInjectable,defaultScope:t.defaultScope,skipBaseClassChecks:t.skipBaseClassChecks},this.id=M(),this._bindingDictionary=new Je,this._snapshots=[],this._middleware=null,this._activations=new Je,this._deactivations=new Je,this.parent=null,this._metadataReader=new A,this._moduleActivationStore=new Ye}return e.merge=function(t,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];var s=new e,o=tt([t,r],n,!0).map((function(e){return ie(e)})),a=ie(s);function c(e,t){e.traverse((function(e,r){r.forEach((function(e){t.add(e.serviceIdentifier,e.clone())}))}))}return o.forEach((function(e){c(e,a)})),s},e.prototype.load=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=this._getContainerModuleHelpersFactory(),n=0,i=e;n<i.length;n++){var s=i[n],o=r(s.id);s.registry(o.bindFunction,o.unbindFunction,o.isboundFunction,o.rebindFunction,o.unbindAsyncFunction,o.onActivationFunction,o.onDeactivationFunction)}},e.prototype.loadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Xe(this,void 0,void 0,(function(){var t,r,n,i,s;return et(this,(function(o){switch(o.label){case 0:t=this._getContainerModuleHelpersFactory(),r=0,n=e,o.label=1;case 1:return r<n.length?(i=n[r],s=t(i.id),[4,i.registry(s.bindFunction,s.unbindFunction,s.isboundFunction,s.rebindFunction,s.unbindAsyncFunction,s.onActivationFunction,s.onDeactivationFunction)]):[3,4];case 2:o.sent(),o.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}))},e.prototype.unload=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];t.forEach((function(t){var r=e._removeModuleBindings(t.id);e._deactivateSingletons(r),e._removeModuleHandlers(t.id)}))},e.prototype.unloadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Xe(this,void 0,void 0,(function(){var t,r,n,i;return et(this,(function(s){switch(s.label){case 0:t=0,r=e,s.label=1;case 1:return t<r.length?(n=r[t],i=this._removeModuleBindings(n.id),[4,this._deactivateSingletonsAsync(i)]):[3,4];case 2:s.sent(),this._removeModuleHandlers(n.id),s.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},e.prototype.bind=function(e){var t=this.options.defaultScope||v,r=new I(e,t);return this._bindingDictionary.add(e,r),new Ge(r)},e.prototype.rebind=function(e){return this.unbind(e),this.bind(e)},e.prototype.rebindAsync=function(e){return Xe(this,void 0,void 0,(function(){return et(this,(function(t){switch(t.label){case 0:return[4,this.unbindAsync(e)];case 1:return t.sent(),[2,this.bind(e)]}}))}))},e.prototype.unbind=function(e){if(this._bindingDictionary.hasKey(e)){var t=this._bindingDictionary.get(e);this._deactivateSingletons(t)}this._removeServiceFromDictionary(e)},e.prototype.unbindAsync=function(e){return Xe(this,void 0,void 0,(function(){var t;return et(this,(function(r){switch(r.label){case 0:return this._bindingDictionary.hasKey(e)?(t=this._bindingDictionary.get(e),[4,this._deactivateSingletonsAsync(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return this._removeServiceFromDictionary(e),[2]}}))}))},e.prototype.unbindAll=function(){var e=this;this._bindingDictionary.traverse((function(t,r){e._deactivateSingletons(r)})),this._bindingDictionary=new Je},e.prototype.unbindAllAsync=function(){return Xe(this,void 0,void 0,(function(){var e,t=this;return et(this,(function(r){switch(r.label){case 0:return e=[],this._bindingDictionary.traverse((function(r,n){e.push(t._deactivateSingletonsAsync(n))})),[4,Promise.all(e)];case 1:return r.sent(),this._bindingDictionary=new Je,[2]}}))}))},e.prototype.onActivation=function(e,t){this._activations.add(e,t)},e.prototype.onDeactivation=function(e,t){this._deactivations.add(e,t)},e.prototype.isBound=function(e){var t=this._bindingDictionary.hasKey(e);return!t&&this.parent&&(t=this.parent.isBound(e)),t},e.prototype.isCurrentBound=function(e){return this._bindingDictionary.hasKey(e)},e.prototype.isBoundNamed=function(e,t){return this.isBoundTagged(e,"named",t)},e.prototype.isBoundTagged=function(e,t,r){var n=!1;if(this._bindingDictionary.hasKey(e)){var i=this._bindingDictionary.get(e),s=function(e,t,r,n){var i=new Q(E,"",t,new H(r,n)),s=new V(e);return new ne(t,s,null,[],i)}(this,e,t,r);n=i.some((function(e){return e.constraint(s)}))}return!n&&this.parent&&(n=this.parent.isBoundTagged(e,t,r)),n},e.prototype.snapshot=function(){this._snapshots.push(Qe.of(this._bindingDictionary.clone(),this._middleware,this._activations.clone(),this._deactivations.clone(),this._moduleActivationStore.clone()))},e.prototype.restore=function(){var e=this._snapshots.pop();if(void 0===e)throw new Error("No snapshot available to restore.");this._bindingDictionary=e.bindings,this._activations=e.activations,this._deactivations=e.deactivations,this._middleware=e.middleware,this._moduleActivationStore=e.moduleActivationStore},e.prototype.createChild=function(t){var r=new e(t||this.options);return r.parent=this,r},e.prototype.applyMiddleware=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=this._middleware?this._middleware:this._planAndResolve();this._middleware=e.reduce((function(e,t){return t(e)}),r)},e.prototype.applyCustomMetadataReader=function(e){this._metadataReader=e},e.prototype.get=function(e){var t=this._getNotAllArgs(e,!1);return this._getButThrowIfAsync(t)},e.prototype.getAsync=function(e){return Xe(this,void 0,void 0,(function(){var t;return et(this,(function(r){return t=this._getNotAllArgs(e,!1),[2,this._get(t)]}))}))},e.prototype.getTagged=function(e,t,r){var n=this._getNotAllArgs(e,!1,t,r);return this._getButThrowIfAsync(n)},e.prototype.getTaggedAsync=function(e,t,r){return Xe(this,void 0,void 0,(function(){var n;return et(this,(function(i){return n=this._getNotAllArgs(e,!1,t,r),[2,this._get(n)]}))}))},e.prototype.getNamed=function(e,t){return this.getTagged(e,"named",t)},e.prototype.getNamedAsync=function(e,t){return this.getTaggedAsync(e,"named",t)},e.prototype.getAll=function(e){var t=this._getAllArgs(e);return this._getButThrowIfAsync(t)},e.prototype.getAllAsync=function(e){var t=this._getAllArgs(e);return this._getAll(t)},e.prototype.getAllTagged=function(e,t,r){var n=this._getNotAllArgs(e,!0,t,r);return this._getButThrowIfAsync(n)},e.prototype.getAllTaggedAsync=function(e,t,r){var n=this._getNotAllArgs(e,!0,t,r);return this._getAll(n)},e.prototype.getAllNamed=function(e,t){return this.getAllTagged(e,"named",t)},e.prototype.getAllNamedAsync=function(e,t){return this.getAllTaggedAsync(e,"named",t)},e.prototype.resolve=function(e){var t=this.isBound(e);t||this.bind(e).toSelf();var r=this.get(e);return t||this.unbind(e),r},e.prototype._preDestroy=function(e,t){var r,n;if(Reflect.hasMetadata("pre_destroy",e))return null===(n=(r=t)[Reflect.getMetadata("pre_destroy",e).value])||void 0===n?void 0:n.call(r)},e.prototype._removeModuleHandlers=function(e){var t=this._moduleActivationStore.remove(e);this._activations.removeIntersection(t.onActivations),this._deactivations.removeIntersection(t.onDeactivations)},e.prototype._removeModuleBindings=function(e){return this._bindingDictionary.removeByCondition((function(t){return t.moduleId===e}))},e.prototype._deactivate=function(e,t){var r=this,n=Object.getPrototypeOf(t).constructor;try{if(this._deactivations.hasKey(e.serviceIdentifier)){var i=this._deactivateContainer(t,this._deactivations.get(e.serviceIdentifier).values());if(de(i))return this._handleDeactivationError(i.then((function(){return r._propagateContainerDeactivationThenBindingAndPreDestroyAsync(e,t,n)})),n)}var s=this._propagateContainerDeactivationThenBindingAndPreDestroy(e,t,n);if(de(s))return this._handleDeactivationError(s,n)}catch(e){if(e instanceof Error)throw new Error(L(n.name,e.message))}},e.prototype._handleDeactivationError=function(e,t){return Xe(this,void 0,void 0,(function(){var r;return et(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e];case 1:return n.sent(),[3,3];case 2:if((r=n.sent())instanceof Error)throw new Error(L(t.name,r.message));return[3,3];case 3:return[2]}}))}))},e.prototype._deactivateContainer=function(e,t){for(var r=this,n=t.next();n.value;){var i=n.value(e);if(de(i))return i.then((function(){return r._deactivateContainerAsync(e,t)}));n=t.next()}},e.prototype._deactivateContainerAsync=function(e,t){return Xe(this,void 0,void 0,(function(){var r;return et(this,(function(n){switch(n.label){case 0:r=t.next(),n.label=1;case 1:return r.value?[4,r.value(e)]:[3,3];case 2:return n.sent(),r=t.next(),[3,1];case 3:return[2]}}))}))},e.prototype._getContainerModuleHelpersFactory=function(){var e=this,t=function(e,t){e._binding.moduleId=t},r=function(r){return function(n){var i=e.rebind(n);return t(i,r),i}},n=function(t){return function(r,n){e._moduleActivationStore.addActivation(t,r,n),e.onActivation(r,n)}},i=function(t){return function(r,n){e._moduleActivationStore.addDeactivation(t,r,n),e.onDeactivation(r,n)}};return function(s){return{bindFunction:(o=s,function(r){var n=e.bind(r);return t(n,o),n}),isboundFunction:function(t){return e.isBound(t)},onActivationFunction:n(s),onDeactivationFunction:i(s),rebindFunction:r(s),unbindFunction:function(t){return e.unbind(t)},unbindAsyncFunction:function(t){return e.unbindAsync(t)}};var o}},e.prototype._getAll=function(e){return Promise.all(this._get(e))},e.prototype._get=function(e){var t=Ze(Ze({},e),{contextInterceptor:function(e){return e},targetType:E});if(this._middleware){var r=this._middleware(t);if(null==r)throw new Error("Invalid return type in middleware. Middleware must return!");return r}return this._planAndResolve()(t)},e.prototype._getButThrowIfAsync=function(e){var t=this._get(e);if(ue(t))throw new Error("You are attempting to construct '"+e.serviceIdentifier+"' in a synchronous way\n but it has asynchronous dependencies.");return t},e.prototype._getAllArgs=function(e){return{avoidConstraints:!0,isMultiInject:!0,serviceIdentifier:e}},e.prototype._getNotAllArgs=function(e,t,r,n){return{avoidConstraints:!1,isMultiInject:t,serviceIdentifier:e,key:r,value:n}},e.prototype._planAndResolve=function(){var e=this;return function(t){var r=ce(e._metadataReader,e,t.isMultiInject,t.targetType,t.serviceIdentifier,t.key,t.value,t.avoidConstraints);return function(e){return Ee(e.plan.rootRequest.requestScope)(e.plan.rootRequest)}(r=t.contextInterceptor(r))}},e.prototype._deactivateIfSingleton=function(e){var t=this;if(e.activated)return de(e.cache)?e.cache.then((function(r){return t._deactivate(e,r)})):this._deactivate(e,e.cache)},e.prototype._deactivateSingletons=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(de(this._deactivateIfSingleton(n)))throw new Error("Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)")}},e.prototype._deactivateSingletonsAsync=function(e){return Xe(this,void 0,void 0,(function(){var t=this;return et(this,(function(r){switch(r.label){case 0:return[4,Promise.all(e.map((function(e){return t._deactivateIfSingleton(e)})))];case 1:return r.sent(),[2]}}))}))},e.prototype._propagateContainerDeactivationThenBindingAndPreDestroy=function(e,t,r){return this.parent?this._deactivate.bind(this.parent)(e,t):this._bindingDeactivationAndPreDestroy(e,t,r)},e.prototype._propagateContainerDeactivationThenBindingAndPreDestroyAsync=function(e,t,r){return Xe(this,void 0,void 0,(function(){return et(this,(function(n){switch(n.label){case 0:return this.parent?[4,this._deactivate.bind(this.parent)(e,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,this._bindingDeactivationAndPreDestroyAsync(e,t,r)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},e.prototype._removeServiceFromDictionary=function(e){try{this._bindingDictionary.remove(e)}catch(t){throw new Error("Could not unbind serviceIdentifier: "+B(e))}},e.prototype._bindingDeactivationAndPreDestroy=function(e,t,r){var n=this;if("function"==typeof e.onDeactivation){var i=e.onDeactivation(t);if(de(i))return i.then((function(){return n._preDestroy(r,t)}))}return this._preDestroy(r,t)},e.prototype._bindingDeactivationAndPreDestroyAsync=function(e,t,r){return Xe(this,void 0,void 0,(function(){return et(this,(function(n){switch(n.label){case 0:return"function"!=typeof e.onDeactivation?[3,2]:[4,e.onDeactivation(t)];case 1:n.sent(),n.label=2;case 2:return[4,this._preDestroy(r,t)];case 3:return n.sent(),[2]}}))}))},e}();function nt(e,t,r,n){!function(e){if(void 0!==e)throw new Error(O)}(t),st("inversify:tagged",e,r.toString(),n)}function it(e){var t=[];if(Array.isArray(e)){var r=function(e){for(var t=new Set,r=0,n=e;r<n.length;r++){var i=n[r];if(t.has(i))return i;t.add(i)}}((t=e).map((function(e){return e.key})));if(void 0!==r)throw new Error("Metadata key was used more than once in a parameter: "+r.toString())}else t=[e];return t}function st(e,t,r,n){var i=it(n),s={};Reflect.hasOwnMetadata(e,t)&&(s=Reflect.getMetadata(e,t));var o=s[r];if(void 0===o)o=[];else for(var a=function(e){if(i.some((function(t){return t.key===e.key})))throw new Error("Metadata key was used more than once in a parameter: "+e.key.toString())},c=0,d=o;c<d.length;c++){a(d[c])}o.push.apply(o,i),s[r]=o,Reflect.defineMetadata(e,s,t)}function ot(e){return function(t,r,n){"number"==typeof n?nt(t,r,n,e):function(e,t,r){if(void 0!==e.prototype)throw new Error(O);st("inversify:tagged_props",e.constructor,t,r)}(t,r,e)}}function at(){return function(e){if(Reflect.hasOwnMetadata("inversify:paramtypes",e))throw new Error("Cannot apply @injectable decorator multiple times.");var t=Reflect.getMetadata("design:paramtypes",e)||[];return Reflect.defineMetadata("inversify:paramtypes",t,e),e}}var ct,dt=(ct="inject",function(e){return function(t,r,n){if(void 0===e){var i="function"==typeof t?t.name:t.constructor.name;throw new Error(function(e){return"@inject called with undefined this could mean that the class "+e+" has a circular dependency problem. You can use a LazyServiceIdentifier to overcome this limitation."}(i))}return ot(new H(ct,e))(t,r,n)}});const ut=3,lt=4,pt=6,ht=7;var ft;const mt={baseURL:"https://lb.livedigital.space/v1",timeout:5e3},gt={customerId:"b149fa74b11d989a60fb08e98e6a82883de0b468",version:"2.3.5"},vt={customerId:"89c41ecf3b3f46fef5dfa9f96842014c21d4901c"},yt=()=>{};let bt=class{constructor(e){var t,r,n,i,s;ft.set(this,void 0),d(this,ft,{denoiser:e.denoiser||"rnnoise",asdk:Object.assign(Object.assign({},gt),e.asdk),loadbalancer:Object.assign(mt,(null===(t=e.network)||void 0===t?void 0:t.loadbalancer)||{}),logLevel:null!==(r=e.logLevel)&&void 0!==r?r:ut,sendAnalytics:null!==(n=e.sendAnalytics)&&void 0!==n&&n,onLogMessage:e.onLogMessage||yt,onIssues:e.onIssues||yt,disableWid:null!==(i=e.disableWid)&&void 0!==i&&i,effectsSDKParams:Object.assign(Object.assign({},vt),e.effectsSDKParams),onNetworkScoresUpdated:e.onNetworkScoresUpdated||yt,staticFilesPath:null!==(s=e.staticFilesPath)&&void 0!==s?s:window.location.origin},"f")}get(e){return c(this,ft,"f")[e]}set(e,t){c(this,ft,"f")[e]=t}};ft=new WeakMap,bt=i([at(),o("design:paramtypes",[Object])],bt);var wt,_t,St,kt,Ct=bt;class Rt extends t{constructor(){super(),this.setMaxListeners(1/0)}emit(e,...t){return super.emit(e,...t)}safeEmit(e,...t){try{return super.emit(e,...t)}catch(t){try{super.emit("listenererror",e,t)}catch(e){}return Boolean(super.listenerCount(e))}}on(e,t){return super.on(e,t),this}off(e,t){return super.off(e,t),this}addListener(e,t){return super.on(e,t),this}prependListener(e,t){return super.prependListener(e,t),this}once(e,t){return super.once(e,t),this}prependOnceListener(e,t){return super.prependOnceListener(e,t),this}removeListener(e,t){return super.off(e,t),this}removeAllListeners(e){return super.removeAllListeners(e),this}listenerCount(e){return super.listenerCount(e)}listeners(e){return super.listeners(e)}rawListeners(e){return super.rawListeners(e)}}function Pt(){}function Tt(){Tt.init.call(this)}function Et(e){return void 0===e._maxListeners?Tt.defaultMaxListeners:e._maxListeners}function Dt(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Ft(e,n),s=0;s<n;++s)i[s].call(r)}function Mt(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,s=Ft(e,i),o=0;o<i;++o)s[o].call(r,n)}function It(e,t,r,n,i){if(t)e.call(r,n,i);else for(var s=e.length,o=Ft(e,s),a=0;a<s;++a)o[a].call(r,n,i)}function xt(e,t,r,n,i,s){if(t)e.call(r,n,i,s);else for(var o=e.length,a=Ft(e,o),c=0;c<o;++c)a[c].call(r,n,i,s)}function Ot(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,s=Ft(e,i),o=0;o<i;++o)s[o].apply(r,n)}function Lt(e,t,r,n){var i,s,o,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=e._events)?(s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]):(s=e._events=new Pt,e._eventsCount=0),o){if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(i=Et(e))&&i>0&&o.length>i){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else o=s[t]=r,++e._eventsCount;return e}function At(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function jt(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function Ft(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}Pt.prototype=Object.create(null),Tt.EventEmitter=Tt,Tt.usingDomains=!1,Tt.prototype.domain=void 0,Tt.prototype._events=void 0,Tt.prototype._maxListeners=void 0,Tt.defaultMaxListeners=10,Tt.init=function(){this.domain=null,Tt.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new Pt,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Tt.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Tt.prototype.getMaxListeners=function(){return Et(this)},Tt.prototype.emit=function(e){var t,r,n,i,s,o,a,c="error"===e;if(o=this._events)c=c&&null==o.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var d=new Error('Uncaught, unspecified "error" event. ('+t+")");throw d.context=t,d}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=o[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:Dt(r,u,this);break;case 2:Mt(r,u,this,arguments[1]);break;case 3:It(r,u,this,arguments[1],arguments[2]);break;case 4:xt(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),s=1;s<n;s++)i[s-1]=arguments[s];Ot(r,u,this,i)}return!0},Tt.prototype.addListener=function(e,t){return Lt(this,e,t,!1)},Tt.prototype.on=Tt.prototype.addListener,Tt.prototype.prependListener=function(e,t){return Lt(this,e,t,!0)},Tt.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,At(this,e,t)),this},Tt.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,At(this,e,t)),this},Tt.prototype.removeListener=function(e,t){var r,n,i,s,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new Pt:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length;s-- >0;)if(r[s]===t||r[s].listener&&r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new Pt,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,o||t)}return this},Tt.prototype.off=function(e,t){return this.removeListener(e,t)},Tt.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new Pt,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new Pt:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),s=0;s<i.length;++s)"removeListener"!==(n=i[s])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new Pt,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Tt.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},Tt.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):jt.call(e,t)},Tt.prototype.listenerCount=jt,Tt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};class Nt extends Tt{}!function(e){e.Issue="issue",e.NetworkScoresUpdated="network-scores-updated",e.StatsParsingFinished="stats-parsing-finished"}(wt||(wt={})),function(e){e.Network="network",e.CPU="cpu",e.Server="server",e.Stream="stream"}(_t||(_t={})),function(e){e.OutboundNetworkQuality="outbound-network-quality",e.InboundNetworkQuality="inbound-network-quality",e.OutboundNetworkMediaLatency="outbound-network-media-latency",e.InboundNetworkMediaLatency="inbound-network-media-latency",e.NetworkMediaSyncFailure="network-media-sync-failure",e.OutboundNetworkThroughput="outbound-network-throughput",e.InboundNetworkThroughput="inbound-network-throughput",e.EncoderCPUThrottling="encoder-cpu-throttling",e.DecoderCPUThrottling="decoder-cpu-throttling",e.ServerIssue="server-issue",e.UnknownVideoDecoderIssue="unknown-video-decoder",e.LowInboundMOS="low-inbound-mean-opinion-score",e.LowOutboundMOS="low-outbound-mean-opinion-score",e.FrozenVideoTrack="frozen-video-track",e.MissingVideoStreamData="missing-video-stream-data",e.MissingAudioStreamData="missing-audio-stream-data"}(St||(St={})),function(e){e[e.BAD=2.1]="BAD",e[e.POOR=2.6]="POOR",e[e.FAIR=3.1]="FAIR",e[e.GOOD=3.8]="GOOD",e[e.EXCELLENT=4.3]="EXCELLENT"}(kt||(kt={}));class Bt extends Tt{static STATS_REPORT_READY_EVENT="stats-report-ready";static STATS_REPORTS_PARSED="stats-reports-parsed";isStopped=!1;reportTimer;getStatsInterval;compositeStatsParser;constructor(e){super(),this.compositeStatsParser=e.compositeStatsParser,this.getStatsInterval=e.getStatsInterval??1e4}get isRunning(){return!!this.reportTimer&&!this.isStopped}startReporting(){if(this.reportTimer)return;const e=()=>setTimeout((()=>{this.isStopped?this.reportTimer=void 0:this.parseReports().finally((()=>{this.reportTimer=e()}))}),this.getStatsInterval);this.isStopped=!1,this.reportTimer=e()}stopReporting(){this.isStopped=!0,this.reportTimer&&(clearTimeout(this.reportTimer),this.reportTimer=void 0)}async parseReports(){const e=Date.now(),t=await this.compositeStatsParser.parse(),r=Date.now()-e;this.emit(Bt.STATS_REPORTS_PARSED,{timeTaken:r,reportItems:t}),t.forEach((e=>{this.emit(Bt.STATS_REPORT_READY_EVENT,e)}))}}const Wt=(()=>{const e=new Map;return t=>{const{taskId:r,delayMs:n,maxJitterMs:i,callback:s}=t,o=Math.ceil(Math.random()*(i||0)),a=e.get(r);a&&clearTimeout(a);const c=setTimeout((()=>{s(),e.delete(r)}),n+o);e.set(r,c)}})();class qt{#e={};calculate(e){const{connection:{id:t}}=e,{mos:r,stats:n}=this.calculateOutboundScore(e)||{},{mos:i,stats:s}=this.calculateInboundScore(e)||{};return this.#e[t]=e,Wt({taskId:t,delayMs:35e3,callback:()=>delete this.#e[t]}),{outbound:r,inbound:i,connectionId:t,statsSamples:{inboundStatsSample:s,outboundStatsSample:n}}}calculateOutboundScore(e){const t=[...e.remote?.audio.inbound||[],...e.remote?.video.inbound||[]];if(!t.length)return;const r=this.#e[e.connection.id];if(!r)return;const n=[...r.remote?.audio.inbound||[],...r.remote?.video.inbound||[]],{packetsSent:i}=e.connection,s=r.connection.packetsSent,o=t.reduce(((e,t)=>{const r=n.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),a=1e3*e.connection.currentRoundTripTime||0,{sumJitter:c}=o,d=c/t.length,u=i-s,l=o.packetsLost-o.lastPacketsLost,p=u&&l?Math.round(100*l/(u+l)):0;return{mos:this.calculateMOS({avgJitter:d,rtt:a,packetsLoss:p}),stats:{avgJitter:d,rtt:a,packetsLoss:p}}}calculateInboundScore(e){const t=[...e.audio?.inbound,...e.video?.inbound];if(!t.length)return;const r=this.#e[e.connection.id];if(!r)return;const n=[...r.video?.inbound,...r.audio?.inbound],{packetsReceived:i}=e.connection,s=r.connection.packetsReceived,o=t.reduce(((e,t)=>{const r=n.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),a=1e3*e.connection.currentRoundTripTime||0,{sumJitter:c}=o,d=c/t.length,u=i-s,l=o.packetsLost-o.lastPacketsLost,p=u&&l?Math.round(100*l/(u+l)):0;return{mos:this.calculateMOS({avgJitter:d,rtt:a,packetsLoss:p}),stats:{avgJitter:d,rtt:a,packetsLoss:p}}}calculateMOS({avgJitter:e,rtt:t,packetsLoss:r}){const n=t+2*e+10;let i=n<160?93.2-n/40:93.2-n/120-10;return i-=2.5*r,1+.035*i+7e-6*i*(i-60)*(100-i)}}class Ut{#t=new Map;#r;#n;constructor(e={}){this.#r=e.statsCleanupTtlMs??35e3,this.#n=e.maxParsedStatsStorageSize??5}detect(e,t){const r={...e,networkScores:{...t,statsSamples:t?.statsSamples||{}}},n=this.performDetection(r);return this.setLastProcessedStats(e.connection.id,r),this.performPrevStatsCleanup({connectionId:e.connection.id}),n}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;this.#t.has(t)&&Wt({taskId:t,delayMs:this.#r,callback:()=>{this.deleteLastProcessedStats(t),"function"==typeof r&&r()}})}setLastProcessedStats(e,t){if(!e||t.connection.id!==e)return;const r=this.#t.get(e)??[];r.push(t),r.length>this.#n&&r.shift(),this.#t.set(e,r)}getLastProcessedStats(e){const t=this.#t.get(e);return t?.[t.length-1]}getAllLastProcessedStats(e){return this.#t.get(e)??[]}deleteLastProcessedStats(e){this.#t.delete(e)}}class zt extends Ut{#i;constructor(e={}){super(e),this.#i=e.availableOutgoingBitrateThreshold??1e5}performDetection(e){const t=[],{availableOutgoingBitrate:r}=e.connection;if(void 0===r)return t;const n=e.audio.outbound.reduce(((e,t)=>e+t.targetBitrate),0),i=e.video.outbound.reduce(((e,t)=>e+t.bitrate),0);if(!n&&!i)return t;const s={availableOutgoingBitrate:r,videoStreamsTotalBitrate:i,audioStreamsTotalTargetBitrate:n};return n>r||i>0&&r<this.#i?(t.push({statsSample:s,type:_t.Network,reason:St.OutboundNetworkThroughput}),t):t}}class Vt extends Ut{#s;#o;#a;#c;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200,this.#a=e.highJitterBufferDelayThresholdMs??500,this.#c=e.highRttThresholdMs??250}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...e.audio?.inbound,...e.video?.inbound];if(!r.length)return t;const n=this.getLastProcessedStats(e.connection.id);if(!n)return t;const i=[...n.video?.inbound,...n.audio?.inbound],{packetsReceived:s}=e.connection,o=n.connection.packetsReceived,a=r.reduce(((e,t)=>{const r=i.find((e=>e.ssrc===t.ssrc)),n=r?.jitterBufferDelay||0,s=r?.jitterBufferEmittedCount||0,o=t.jitterBufferDelay-n,a=t.jitterBufferEmittedCount-s,c=o&&a?1e3*o/a:0;return{sumJitter:e.sumJitter+t.jitter,sumJitterBufferDelayMs:e.sumJitterBufferDelayMs+c,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,sumJitterBufferDelayMs:0,packetsLost:0,lastPacketsLost:0}),c=1e3*e.connection.currentRoundTripTime||0,{sumJitter:d,sumJitterBufferDelayMs:u}=a,l=d/r.length,p=u/r.length,h=s-o,f=a.packetsLost-a.lastPacketsLost,m=h&&f?Math.round(100*f/(h+f)):0,g=m>this.#s,v=l>=this.#o,y=c>=this.#c,b=p>this.#a,w=y&&!v&&!g,_=g&&v,S=v&&b,k={rtt:c,packetLossPct:m,avgJitter:l,avgJitterBufferDelay:p};return(v||g)&&t.push({statsSample:k,type:_t.Network,reason:St.InboundNetworkQuality,iceCandidate:e.connection.local.id}),w&&t.push({statsSample:k,type:_t.Server,reason:St.ServerIssue,iceCandidate:e.connection.remote.id}),_&&t.push({statsSample:k,type:_t.Network,reason:St.InboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),S&&t.push({statsSample:k,type:_t.Network,reason:St.NetworkMediaSyncFailure,iceCandidate:e.connection.local.id}),t}}class Ht extends Ut{#d;constructor(e={}){super(),this.#d=e.correctedSamplesThresholdPct??5}performDetection(e){return this.processData(e)}processData(e){const t=e.audio.inbound,r=[],n=this.getLastProcessedStats(e.connection.id)?.audio.inbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;const i=e.track.insertedSamplesForDeceleration+e.track.removedSamplesForAcceleration,s=t.track.insertedSamplesForDeceleration+t.track.removedSamplesForAcceleration;if(i===s)return;const o=e.track.totalSamplesReceived-t.track.totalSamplesReceived,a=i-s,c=Math.round(100*a/o),d={correctedSamplesPct:c};c>this.#d&&r.push({statsSample:d,type:_t.Network,reason:St.NetworkMediaSyncFailure,ssrc:e.ssrc})})),r):r}}class $t extends Ut{#s;#o;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...e.remote?.audio.inbound||[],...e.remote?.video.inbound||[]];if(!r.length)return t;const n=this.getLastProcessedStats(e.connection.id);if(!n)return t;const i=[...n.remote?.audio.inbound||[],...n.remote?.video.inbound||[]],{packetsSent:s}=e.connection,o=n.connection.packetsSent,a=r.reduce(((e,t)=>{const r=i.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),c=1e3*e.connection.currentRoundTripTime||0,{sumJitter:d}=a,u=d/r.length,l=s-o,p=a.packetsLost-a.lastPacketsLost,h=l&&p?Math.round(100*p/(l+p)):0,f=h>this.#s,m=u>=this.#o,g=!f&&m||m||f,v={rtt:c,avgJitter:u,packetLossPct:h};return f&&m&&t.push({statsSample:v,type:_t.Network,reason:St.OutboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),g&&t.push({statsSample:v,type:_t.Network,reason:St.OutboundNetworkQuality,iceCandidate:e.connection.local.id}),t}}class Kt extends Ut{performDetection(e){return this.processData(e)}processData(e){const t=e.video.outbound.filter((e=>"none"!==e.qualityLimitationReason)),r=[],n=this.getLastProcessedStats(e.connection.id)?.video.outbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;const i={qualityLimitationReason:e.qualityLimitationReason};e.framesSent>t.framesSent||("cpu"===e.qualityLimitationReason&&r.push({statsSample:i,type:_t.CPU,reason:St.EncoderCPUThrottling,ssrc:e.ssrc}),"bandwidth"===e.qualityLimitationReason&&r.push({statsSample:i,type:_t.Network,reason:St.OutboundNetworkThroughput,ssrc:e.ssrc}))})),r):r}}class Gt extends Ut{UNKNOWN_DECODER="unknown";#u={};performDetection(e){return this.processData(e)}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;super.performPrevStatsCleanup({...e,cleanupCallback:()=>{delete this.#u[t],"function"==typeof r&&r()}})}processData(e){const t=[],{id:r}=e.connection,n=this.getLastProcessedStats(r)?.video.inbound;return e.video.inbound.forEach((e=>{const{decoderImplementation:i,ssrc:s}=e,o=n?.find((e=>e.ssrc===s));if(o)if(i===this.UNKNOWN_DECODER){if(!this.hadLastDecoderWithIssue(r,s)){this.setLastDecoderWithIssue(r,s,this.UNKNOWN_DECODER);const n={mimeType:e.mimeType,decoderImplementation:i};t.push({ssrc:s,statsSample:n,type:_t.Stream,reason:St.UnknownVideoDecoderIssue,trackIdentifier:e.track.trackIdentifier})}}else this.setLastDecoderWithIssue(r,s,void 0)})),t}setLastDecoderWithIssue(e,t,r){const n=this.#u[e]??{};void 0===r?delete n[t]:n[t]=r,this.#u[e]=n}hadLastDecoderWithIssue(e,t){const r=this.#u[e];return(r&&r[t])===this.UNKNOWN_DECODER}}const Qt=e=>e.reduce(((e,t)=>e+t),0)/e.length,Jt=(e,t,r=30)=>{const n=[];for(let r=1;r<t.length-1;r+=1){const i=t[r]?.video?.inbound.find((t=>t.ssrc===e));if(!i)continue;const s=t[r-1]?.video?.inbound?.find((t=>t.ssrc===e));if(!i||!s)continue;const o=i.timestamp-s.timestamp,a=i.framesDecoded-s.framesDecoded;if(a>0){const e=o/a;n.push(e)}}return!(n.length<=1)&&(e=>{const t=((e,t)=>t.reduce(((t,r)=>t+(r-e)**2),0)/t.length)(Qt(e),e);return Math.sqrt(t)})(n)>r},Yt=(e,t)=>{for(let r=1;r<t.length;r+=1){const n=t[r].video.inbound.find((t=>t.ssrc===e));if(!n)continue;const i=t[r-1].video.inbound.find((t=>t.ssrc===e)),s=n.frameWidth!==i?.frameWidth,o=n.frameHeight!==i?.frameHeight;if(s||o)return!0}return!1};class Zt extends Ut{#l;#p;#h;constructor(e={}){super(),this.#l=e.avgFreezeDurationThresholdMs??1e3,this.#p=e.frozenDurationThresholdPct??30,this.#h=e.minMosQuality??kt.BAD}performDetection(e){const t=e.networkScores.inbound;return void 0!==t&&t<=this.#h?[]:this.processData(e)}processData(e){const t=[],r=this.getAllLastProcessedStats(e.connection.id);if(0===r.length)return[];const n=e.video.inbound.map((t=>{const n=r[r.length-1].video.inbound.find((e=>e.ssrc===t.ssrc));if(!n)return;if(Yt(t.ssrc,[r[r.length-1],e]))return;if(Jt(t.ssrc,r))return;const i=t.freezeCount-(n.freezeCount??0),s=1e3*(t.totalFreezesDuration-(n.totalFreezesDuration??0)),o=i>0?s/i:0,a=s/(t.timestamp-n.timestamp)*100;return a>this.#p||o>this.#l?{ssrc:t.ssrc,avgFreezeDurationMs:o,frozenDurationPct:a}:void 0})).filter((e=>void 0!==e));return n.length>0&&(t.push({type:_t.Stream,reason:St.FrozenVideoTrack,statsSample:{ssrcs:n.map((e=>e.ssrc))}}),this.deleteLastProcessedStats(e.connection.id)),t}}class Xt extends Ut{#f;#m;#h;constructor(e={}){super(e),this.#f=e.volatilityThreshold??8,this.#m=e.affectedStreamsPercentThreshold??30,this.#h=e.minMosQuality??kt.BAD}performDetection(e){return[...this.getAllLastProcessedStats(e.connection.id),e].find((e=>void 0!==e.networkScores.inbound&&e.networkScores.inbound<=this.#h))?[]:this.processData(e)}processData(e){const t=[],r=[...this.getAllLastProcessedStats(e.connection.id),e],n=e.video.inbound.map((e=>{if(r.length<5)return;if(Yt(e.ssrc,r))return;const t=[];for(let n=0;n<r.length-1;n+=1){const i=r[n].video.inbound.find((t=>t.ssrc===e.ssrc));void 0!==i?.framesPerSecond&&t.push(i.framesPerSecond)}if(t.length<5)return;if(Jt(e.ssrc,r))return;const n=(e=>{if(0===e.length)throw new Error("Cannot calculate volatility for empty array");const t=Qt(e);return e.reduce(((e,r)=>e+Math.abs(r-t)),0)/e.length*100/t})(t);return n>this.#f?{ssrc:e.ssrc,allFps:t,volatility:n}:void 0})).filter((e=>Boolean(e)));if(0===n.length)return t;const i=n.length/(e.video.inbound.length/100);return i>this.#m&&(t.push({type:_t.CPU,reason:St.DecoderCPUThrottling,statsSample:{affectedStreamsPercent:i,throtthedStreams:n}}),this.deleteLastProcessedStats(e.connection.id)),t}}const er=e=>"closed"===e.iceConnectionState||"closed"===e.connectionState,tr=(e,t,r)=>8*((e,t,r)=>{if(!t)return 0;const n=e[r],i=t[r];if(null==n||null==i)return 0;const s=Math.floor(e.timestamp)-Math.floor(t.timestamp);return 0===s?0:(Number(n)-Number(i))/s*1e3})(e,t,r);class rr{connections=[];statsParser;constructor(e){this.statsParser=e.statsParser}listConnections(){return[...this.connections]}addPeerConnection(e){this.connections.push({id:e.id??String(Date.now()+Math.random().toString(32)),pc:e.pc})}removePeerConnection(e){const t=this.connections.findIndex((({pc:t})=>t===e.pc));t>=0&&this.removeConnectionsByIndexes([t])}async parse(){const e=[],t=this.connections.map((async(t,r)=>{if(!er(t.pc))return this.statsParser.parse(t);e.unshift(r)}));return e.length&&this.removeConnectionsByIndexes(e),(await Promise.all(t)).filter((e=>void 0!==e))}removeConnectionsByIndexes(e){e.forEach((e=>{this.connections.splice(e,1)}))}}class nr{prevStats=new Map;allowedReportTypes=new Set(["candidate-pair","inbound-rtp","outbound-rtp","remote-outbound-rtp","remote-inbound-rtp","track","transport"]);ignoreSSRCList;logger;constructor(e){this.ignoreSSRCList=e.ignoreSSRCList??[],this.logger=e.logger}get previouslyParsedStatsConnectionsIds(){return[...this.prevStats.keys()]}async parse(e){if(!er(e.pc))return this.getConnectionStats(e);this.logger.debug("Skip stats parsing. Connection is closed.",{connection:e})}async getConnectionStats(e){const{pc:t,id:r}=e;try{const n=Date.now(),i=t.getReceivers().filter((e=>e.track?.enabled)),s=t.getSenders().filter((e=>e.track?.enabled)),o=await Promise.all(i.map((e=>e.getStats()))),a=await Promise.all(s.map((e=>e.getStats())));return{id:r,stats:this.mapReportsStats([...o,...a],e),timeTaken:Date.now()-n}}catch(e){return void this.logger.error("Failed to get stats for PC",{id:r,pc:t,error:e})}}mapReportsStats(e,t){const r={audio:{inbound:[],outbound:[]},video:{inbound:[],outbound:[]},connection:{},remote:{video:{inbound:[],outbound:[]},audio:{inbound:[],outbound:[]}}};e.forEach((e=>{e.forEach((t=>{this.allowedReportTypes.has(t.type)&&this.updateMappedStatsWithReportItemData(t,r,e)}))}));const{id:n}=t,i=this.prevStats.get(n);return i&&this.propagateStatsWithRateValues(r,i.stats),this.prevStats.set(n,{stats:r,ts:Date.now()}),Wt({taskId:n,delayMs:35e3,callback:()=>this.prevStats.delete(n)}),r}updateMappedStatsWithReportItemData(e,t,r){const n=e.type;if("candidate-pair"===n&&"succeeded"===e.state&&e.nominated)return void(t.connection=this.prepareConnectionStats(e,r));const i=this.getMediaType(e);if(!i)return;const s=e.ssrc;if(!s||!this.ignoreSSRCList.includes(s))if("outbound-rtp"!==n)if("inbound-rtp"!==n)"remote-outbound-rtp"!==n?"remote-inbound-rtp"===n&&(this.mapConnectionStatsIfNecessary(t,e,r),t.remote[i].inbound.push({...e})):t.remote[i].outbound.push({...e});else{const n=r.get(e.trackId)||r.get(e.mediaSourceId)||{};this.mapConnectionStatsIfNecessary(t,e,r);const s={...e,track:{...n}};t[i].inbound.push(s)}else{const n=r.get(e.trackId)||r.get(e.mediaSourceId)||{},s={...e,track:{...n}};t[i].outbound.push(s)}}getMediaType(e){const t=e.mediaType||e.kind;if(!["audio","video"].includes(t)){const{id:t}=e;if(!t)return;return String(t).includes("Video")?"video":String(t).includes("Audio")?"audio":void 0}return t}propagateStatsWithRateValues(e,t){e.audio.inbound.forEach((e=>{const r=t.audio.inbound.find((({id:t})=>t===e.id));e.bitrate=tr(e,r,"bytesReceived"),e.packetRate=tr(e,r,"packetsReceived")})),e.audio.outbound.forEach((e=>{const r=t.audio.outbound.find((({id:t})=>t===e.id));e.bitrate=tr(e,r,"bytesSent"),e.packetRate=tr(e,r,"packetsSent")})),e.video.inbound.forEach((e=>{const r=t.video.inbound.find((({id:t})=>t===e.id));e.bitrate=tr(e,r,"bytesReceived"),e.packetRate=tr(e,r,"packetsReceived")})),e.video.outbound.forEach((e=>{const r=t.video.outbound.find((({id:t})=>t===e.id));e.bitrate=tr(e,r,"bytesSent"),e.packetRate=tr(e,r,"packetsSent")}))}mapConnectionStatsIfNecessary(e,t,r){if(e.connection.id||!t.transportId)return;const n=r.get(t.transportId);if(n&&n.selectedCandidatePairId){const t=r.get(n.selectedCandidatePairId);e.connection=this.prepareConnectionStats(t,r)}}prepareConnectionStats(e,t){if(!e||!t)return{};const r={...e};if(r.remoteCandidateId){const e=t.get(r.remoteCandidateId);r.remote={...e}}if(r.localCandidateId){const e=t.get(r.localCandidateId);r.local={...e}}return r}}class ir extends Ut{#g=new Map;#v;#y;constructor(e={}){super(),this.#v=e.timeoutMs??15e3,this.#y=e.steps??3}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...this.getAllLastProcessedStats(e.connection.id),e];if(r.length<this.#y)return t;const n=r.slice(-this.#y),i=n.map((e=>e.video.inbound)),s=n.map((e=>e.audio.inbound));return t.push(...this.detectMissingData(s,_t.Stream,St.MissingAudioStreamData)),t.push(...this.detectMissingData(i,_t.Stream,St.MissingVideoStreamData)),new Set(this.#g.keys()).forEach((e=>{const t=this.#g.get(e);t&&Date.now()-t>this.#v&&this.removeMarkedIssue(e)})),t}detectMissingData(e,t,r){const n=[],i=e.pop(),s=ir.mapStatsByTrackId(e);return i.forEach((e=>{const i=e.track.trackIdentifier,o=s.get(i);if(!Array.isArray(o)||0===o.length)return;if(e.track.detached||e.track.ended)return;if(!ir.isAllBytesReceivedDidntChange(e.bytesReceived,o))return void this.removeMarkedIssue(i);if(!this.markIssue(i))return;const a={bytesReceived:e.bytesReceived};n.push({type:t,reason:r,statsSample:a,trackIdentifier:i})})),n}static mapStatsByTrackId(e){const t=new Map;return e.forEach((e=>{e.forEach((e=>{const r=t.get(e.track.trackIdentifier)||[];r.push(e),t.set(e.track.trackIdentifier,r)}))})),t}static isAllBytesReceivedDidntChange(e,t){for(let r=0;r<t.length;r+=1)if(t[r].bytesReceived!==e)return!1;return!0}markIssue(e){const t=Date.now(),r=this.#g.get(e);return(!r||t-r>this.#v)&&(this.#g.set(e,t),!0)}removeMarkedIssue(e){this.#g.delete(e)}}class sr{eventEmitter;#b=!1;detectors=[];networkScoresCalculator;statsReporter;compositeStatsParser;logger;autoAddPeerConnections;constructor(e){this.logger=e.logger??{debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},this.eventEmitter=e.issueEmitter??new Nt,e.onIssues&&this.eventEmitter.on(wt.Issue,e.onIssues),e.onNetworkScoresUpdated&&this.eventEmitter.on(wt.NetworkScoresUpdated,e.onNetworkScoresUpdated),this.detectors=e.detectors??[new Kt,new Vt,new $t,new Ht,new zt,new Gt,new Zt,new Xt,new ir],this.networkScoresCalculator=e.networkScoresCalculator??new qt,this.compositeStatsParser=e.compositeStatsParser??new rr({statsParser:new nr({ignoreSSRCList:e.ignoreSSRCList,logger:this.logger})}),this.statsReporter=e.statsReporter??new Bt({compositeStatsParser:this.compositeStatsParser,getStatsInterval:e.getStatsInterval??5e3}),window.wid=this,this.autoAddPeerConnections=e.autoAddPeerConnections??!0,this.autoAddPeerConnections&&this.wrapRTCPeerConnection(),this.statsReporter.on(Bt.STATS_REPORT_READY_EVENT,(e=>{const t=this.calculateNetworkScores(e.stats);this.detectIssues({data:e.stats},t)})),this.statsReporter.on(Bt.STATS_REPORTS_PARSED,(t=>{const r={timeTaken:t.timeTaken,ts:Date.now()};e.onStats&&e.onStats(t.reportItems),this.eventEmitter.emit(wt.StatsParsingFinished,r)}))}watchNewPeerConnections(){if(!this.autoAddPeerConnections)throw new Error("Auto add peer connections was disabled in the constructor.");this.#b?this.logger.warn("WebRTCIssueDetector is already started. Skip processing"):(this.logger.info("Start watching peer connections"),this.#b=!0,this.statsReporter.startReporting())}stopWatchingNewPeerConnections(){this.#b?(this.logger.info("Stop watching peer connections"),this.#b=!1,this.statsReporter.stopReporting()):this.logger.warn("WebRTCIssueDetector is already stopped. Skip processing")}handleNewPeerConnection(e,t){this.#b||!this.autoAddPeerConnections?(this.#b||!1!==this.autoAddPeerConnections||(this.logger.info("Starting stats reporting for new peer connection"),this.#b=!0,this.statsReporter.startReporting()),this.logger.debug("Handling new peer connection",e),this.compositeStatsParser.addPeerConnection({pc:e,id:t})):this.logger.debug("Skip handling new peer connection. Detector is not running",e)}emitIssues(e){this.eventEmitter.emit(wt.Issue,e)}detectIssues({data:e},t){const r=this.detectors.reduce(((r,n)=>[...r,...n.detect(e,t)]),[]);r.length>0&&this.emitIssues(r)}calculateNetworkScores(e){const t=this.networkScoresCalculator.calculate(e);return this.eventEmitter.emit(wt.NetworkScoresUpdated,t),t}wrapRTCPeerConnection(){if(!window.RTCPeerConnection)return void this.logger.warn("No RTCPeerConnection found in browser window. Skipping");const e=window.RTCPeerConnection,t=e=>this.handleNewPeerConnection(e);function r(r){const n=new e(r);return t(n),n}r.prototype=e.prototype,window.RTCPeerConnection=r}}var or={};Object.defineProperty(or,"__esModule",{value:!0}),or.InvalidStateError=or.UnsupportedError=void 0;class ar extends Error{constructor(e){super(e),this.name="UnsupportedError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,ar):this.stack=new Error(e).stack}}var cr=or.UnsupportedError=ar;class dr extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,dr):this.stack=new Error(e).stack}}or.InvalidStateError=dr;Error;const ur=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],lr=({from:e,seen:t,to_:r,forceEnumerable:n})=>{const i=r||(Array.isArray(e)?[]:{});t.push(e);for(const[r,s]of Object.entries(e))"function"!=typeof s&&(s&&"object"==typeof s?t.includes(e[r])?i[r]="[Circular]":i[r]=lr({from:e[r],seen:t.slice(),forceEnumerable:n}):i[r]=s);for(const{property:t,enumerable:r}of ur)"string"==typeof e[t]&&Object.defineProperty(i,t,{value:e[t],enumerable:!!n||r,configurable:!0,writable:!0});return i};var pr,hr,fr,mr=e=>"object"==typeof e&&null!==e?lr({from:e,seen:[],forceEnumerable:!0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e;pr=new WeakMap,hr=new WeakMap,fr=new WeakMap;var gr=new class{constructor(){pr.set(this,void 0),hr.set(this,void 0),fr.set(this,void 0)}get meta(){return{peerId:c(this,pr,"f"),channelId:c(this,hr,"f"),appId:c(this,fr,"f")}}setPeerId(e){d(this,pr,e,"f")}setChannelId(e){d(this,hr,e,"f")}setAppId(e){d(this,fr,e,"f")}clear(){d(this,pr,void 0,"f"),d(this,hr,void 0,"f"),d(this,fr,void 0,"f")}};const vr="channel.event",yr="channel.join",br="channel.getPeers",wr="peer.disconnected",_r="peer.updateAppData",Sr="channel.confirmActivity",kr="channel.activityConfirmationAcquired",Cr="channel.activityConfirmationRequired",Rr="channel.activityConfirmationExpired",Pr="channel.getAudioObserverProducer",Tr="channel.getGeneralDataProducer",Er="channel.getChannelStateSyncDataProducer",Dr="channel.changeProducePermissions",Mr="channel.deleteProducePermissions",Ir="peer.changeProducePermissions",xr="peer.addProducePermissions",Or="peer.removeProducePermissions",Lr="peer.groupsChanged",Ar="peer.ping",jr="channel-event",Fr="peer-joined",Nr="peer-left",Br="channel-activity-confirmation-required",Wr="channel-activity-confirmation-acquired",qr="channel-activity-confirmation-expired",Ur="channel-rejoin-required",zr="devices-list-updated",Vr="transport-connection-timeout",Hr="track-force-closed",$r="track-failed",Kr="active-speaker-changed",Gr="channel-state-inconsistent",Qr="connection-lost",Jr="connection-restored",Yr="forced-disconnect",Zr="reject-unauthorized",Xr="denoiser-initializing",en="volume-changed",tn={trackProduced:"track-produced",trackUnproduced:"track-unproduced",trackPaused:"track-paused",trackResumed:"track-resumed",trackClosed:"track-closed",trackReopened:"track-reopened",trackFailed:"track-failed"},rn="media-published",nn="media-unpublished",sn="publisher-paused",on="publisher-resumed",an="track-start",cn="track-end",dn="track-paused",un="track-resumed",ln="track-failed",pn="app-data-updated",hn="produce-permissions-changed",fn="groups-changed",mn="peer.newProducer",gn="producer.close",vn="producer.pause",yn="producer.resume",bn="producer.paused",wn="producer.resumed",_n="producer.forceClosed",Sn="producer.setMaxSpatialLayer",kn="producer.requestMaxSpatialLayer",Cn="consumer.create",Rn="dataConsumer.create",Pn="consumer.close",Tn="consumer.pause",En="consumer.resume",Dn="consumer.score",Mn="consumer.changeConsumerPreferredLayers",In="consumer.requestKeyFrame",xn="transport.create",On="transport.connect",Ln="transport.produce",An="transport.produceData",jn="transport.connectionTimeout",Fn="transport.getIceParameters",Nn=[xn,On,Ln,An,Fn,gn,vn,yn,Tn,En,Cn,Pn,Ar],Bn="socket-state",Wn="transport-state";class qn extends Error{constructor(e,t,r){super(e),this.errorCode=null!=t?t:"unknown_error",this.meta=r}}class Un extends qn{constructor(e,t){super(e,null!=t?t:"unsupported_error")}}Un.UNSUPPORTED_DEVICE_CODE="unsupported_device_error",Un.UNSUPPORTED_OPERATION_CODE="unsupported_operation_error";const zn=e=>{let t;try{t=JSON.stringify(e)}catch(e){throw new Error("Invalid appData")}if(!((new TextEncoder).encode(t).length<=2048))throw new Error("Maximum size appData reached")};var Vn={exports:{}},Hn=p(Vn.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=r(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var i=e.getVersionPrecision(t),s=e.getVersionPrecision(r),o=Math.max(i,s),a=0,c=e.map([t,r],(function(t){var r=o-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(a=o-Math.min(i,s)),o-=1;o>=a;){if(c[0][o]>c[1][o])return 1;if(c[0][o]===c[1][o]){if(o===a)return 0;o-=1}else if(c[0][o]<c[1][o])return-1}},e.map=function(e,t){var r,n=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r+=1)n.push(t(e[r]));return n},e.find=function(e,t){var r,n;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(r=0,n=e.length;r<n;r+=1){var i=e[r];if(t(i,r))return i}},e.assign=function(e){for(var t,r,n=e,i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];if(Object.assign)return Object.assign.apply(Object,[e].concat(s));var a=function(){var e=s[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){n[t]=e[t]}))};for(t=0,r=s.length;t<r;t+=1)a();return e},e.getBrowserAlias=function(e){return n.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return n.BROWSER_MAP[e]||""},e}();t.default=i,e.exports=t.default},18:function(e,t,r){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(91))&&n.__esModule?n:{default:n},s=r(18);function o(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,n.key,n)}}var a=function(){function e(){}var t,r,n;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new i.default(e,t)},e.parse=function(e){return new i.default(e).getResult()},t=e,n=[{key:"BROWSER_MAP",get:function(){return s.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return s.ENGINE_MAP}},{key:"OS_MAP",get:function(){return s.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return s.PLATFORMS_MAP}}],(r=null)&&o(t.prototype,r),n&&o(t,n),e}();t.default=a,e.exports=t.default},91:function(e,t,r){t.__esModule=!0,t.default=void 0;var n=c(r(92)),i=c(r(93)),s=c(r(94)),o=c(r(95)),a=c(r(17));function c(e){return e&&e.__esModule?e:{default:e}}var d=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=a.default.find(n.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=a.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=a.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=a.default.find(o.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return a.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,r={},n=0,i={},s=0;if(Object.keys(e).forEach((function(t){var o=e[t];"string"==typeof o?(i[t]=o,s+=1):"object"==typeof o&&(r[t]=o,n+=1)})),n>0){var o=Object.keys(r),c=a.default.find(o,(function(e){return t.isOS(e)}));if(c){var d=this.satisfies(r[c]);if(void 0!==d)return d}var u=a.default.find(o,(function(e){return t.isPlatform(e)}));if(u){var l=this.satisfies(r[u]);if(void 0!==l)return l}}if(s>0){var p=Object.keys(i),h=a.default.find(p,(function(e){return t.isBrowser(e,!0)}));if(void 0!==h)return this.compareVersion(i[h])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),i=a.default.getBrowserTypeByAlias(n);return t&&i&&(n=i.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(a.default.compareVersions(i,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=d,e.exports=t.default},92:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=/version\/(\d+(\.?_?\d+)+)/i,o=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(s,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(s,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=o,e.exports=t.default},93:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18),o=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:s.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return{name:s.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:s.OS_MAP.iOS},r=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),n={name:s.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:s.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),n={name:s.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:s.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:s.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:s.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:s.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:s.OS_MAP.PlayStation4,version:t}}}];t.default=o,e.exports=t.default},94:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18),o=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:s.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:s.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:s.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:s.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:s.PLATFORMS_MAP.tv}}}];t.default=o,e.exports=t.default},95:function(e,t,r){t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},s=r(18),o=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:s.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:s.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:s.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:s.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:s.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:s.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:s.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=o,e.exports=t.default}}));const $n=e=>{var t;return(null===(t=e.rtpCapabilities.codecs)||void 0===t?void 0:t.reduce(((e,t)=>{var r;const n=null===(r=t.mimeType)||void 0===r?void 0:r.toLowerCase();return e.includes(n)||e.push(n),e}),[]))||[]},Kn=e=>["video/vp9","vp9"].includes(e.toLowerCase());class Gn{sleepMs(e){return a(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}now(){return new Date(Date.now())}}const Qn=new Gn,Jn=(e,t={})=>a(void 0,void 0,void 0,(function*(){var r;const n=t.maxRetries||2,i=t.minBackoffDelayMs||50;let s,o=0;for(;o<n;){o+=1;try{return yield e()}catch(e){if(s=e,t.logger&&t.logger.info("Action retry failed",{currentAttempt:o,actionName:t.actionName,error:e}),t.abortOnError&&t.abortOnError(e))throw s;if(t.onError&&(yield t.onError(e)),o<n){const e=Math.pow(2,o-1)*i;yield Qn.sleepMs(Math.min(e,null!==(r=t.maxBackoffDelayMs)&&void 0!==r?r:e))}}}throw s}));var Yn,Zn,Xn,ei;!function(e){e.Config="Config",e.Engine="Engine",e.System="System",e.Media="Media",e.Network="Network",e.MediaSoupEventHandler="MediaSoupEventHandler",e.ChannelEventHandler="ChannelEventHandler",e.ChannelAudioObserverEventHandler="ChannelAudioObserverEventHandler",e.ChannelStateSynchronizer="ChannelStateSynchronizer",e.ChannelStateSyncEventHandler="ChannelStateSyncEventHandler",e.WebRTCIssueDetector="WebRTCIssueDetector",e.LoggerFactory="LoggerFactory",e.MediaStreamTrackManager="MediaStreamTrackManager",e.SocketIO="SocketIO",e.LoadBalancerApiClient="LoadBalancerApiClient",e.EventsQueue="EventsQueue",e.ClientEventEmitter="ClientEventEmitter",e.Peers="Peers",e.CallState="CallState",e.RemotePeerTracks="RemotePeerTracks",e.MyPeer="MyPeer",e.InternalEventEmitter="InternalEventEmitter",e.PeerTrackFactory="PeerTrackFactory",e.PeerFactory="PeerFactory",e.PeerConsumerFactory="PeerConsumerFactory",e.AudioTrackFactory="AudioTrackFactory",e.VideoTrackFactory="VideoTrackFactory",e.AudioTrackProcessorFactory="AudioTrackProcessorFactory",e.IntegrationsService="IntegrationsService",e.ProcessorsCache="ProcessorsCache",e.StatsHandler="StatsHandler",e.DataChannelsManager="DataChannelsManager"}(Yn||(Yn={})),function(e){e.Camera="camera",e.CameraPreview="camera-preview",e.Microphone="microphone",e.MicrophonePreview="microphone-preview",e.ScreenVideo="screen-video",e.ScreenAudio="screen-audio",e.Unknown="unknown"}(Zn||(Zn={})),function(e){e.NotFoundError="NotFoundError",e.NoDevices="NoDevices",e.DeviceIsBusy="DeviceIsBusy",e.NotAllowedError="NotAllowedError",e.RequestDevicesUnknownError="RequestDevicesUnknownError"}(Xn||(Xn={})),function(e){e.Connect="connect",e.Connected="connected",e.ConnectError="connect_error",e.Reconnect="reconnect",e.Reconnecting="reconnecting",e.Reconnected="reconnected",e.ReconnectAttempt="reconnect_attempt",e.NeedToJoinFirst="need_to_join_first",e.Disconnect="disconnect",e.Disconnected="disconnected",e.Error="error",e.State="state",e.BufferingStart="buffering_start",e.BufferingEnd="buffering_end"}(ei||(ei={}));let ti=class{constructor(){this.isJoined=!1,this.isChannelJoining=!1}reset(){this.appId=void 0,this.channelId=void 0}};ti=i([at()],ti);var ri={},ni={exports:{}},ii=1e3,si=6e4,oi=60*si,ai=24*oi,ci=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*ai;case"hours":case"hour":case"hrs":case"hr":case"h":return r*oi;case"minutes":case"minute":case"mins":case"min":case"m":return r*si;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=ai)return di(e,t,ai,"day");if(t>=oi)return di(e,t,oi,"hour");if(t>=si)return di(e,t,si,"minute");if(t>=1e3)return di(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=ai)return Math.round(e/ai)+"d";if(t>=oi)return Math.round(e/oi)+"h";if(t>=si)return Math.round(e/si)+"m";if(t>=ii)return Math.round(e/ii)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function di(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var ui=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r<i;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=ci,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=ui(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(ni,ni.exports);var li,pi,hi={},fi={exports:{}};li=fi,pi=fi.exports,function(e,t){var r,n="",i="function",s="undefined",o="object",a="string",c="major",d="model",u="name",l="type",p="vendor",h="version",f="architecture",m="console",g="mobile",v="tablet",y="smarttv",b="wearable",w="xr",_="embedded",S="inapp",k="user-agent",C="brands",R="formFactors",P="fullVersionList",T="platform",E="platformVersion",D="bitness",M="sec-ch-ua",I="sec-ch-ua-platform",x=[C,P,g,d,T,E,f,R,D],O="browser",L="cpu",A="device",j="engine",F="os",N="result",B="Amazon",W="Apple",q="ASUS",U="BlackBerry",z="Google",V="Huawei",H="Lenovo",$="LG",K="Microsoft",G="Motorola",Q="Samsung",J="Sharp",Y="Sony",Z="Xiaomi",X="Zebra",ee="Chromecast",te="Opera",re="Facebook",ne="Windows",ie=typeof e!==s,se=ie&&e.navigator?e.navigator:t,oe=se&&se.userAgentData?se.userAgentData:t,ae=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},ce=function(e,t){if(typeof e===o&&e.length>0){for(var r in e)if(pe(e[r])==pe(t))return!0;return!1}return!!ue(e)&&-1!==pe(t).indexOf(pe(e))},de=function(e,t){for(var r in e)return/^(browser|cpu|device|engine|os)$/.test(r)||!!t&&de(e[r])},ue=function(e){return typeof e===a},le=function(e){if(!e)return t;for(var r=[],n=me(/\\?\"/g,e).split(","),i=0;i<n.length;i++)if(n[i].indexOf(";")>-1){var s=ve(n[i]).split(";v=");r[i]={brand:s[0],version:s[1]}}else r[i]=ve(n[i]);return r},pe=function(e){return ue(e)?e.toLowerCase():e},he=function(e){return ue(e)?me(/[^\d\.]/g,e).split(".")[0]:t},fe=function(e){for(var r in e){var n=e[r];typeof n==o&&2==n.length?this[n[0]]=n[1]:this[n]=t}return this},me=function(e,t){return ue(t)?t.replace(e,n):t},ge=function(e){return me(/\\?\"/g,e)},ve=function(e,t){if(ue(e))return e=me(/^\s\s*/,e),typeof t===s?e:e.substring(0,500)},ye=function(e,r){if(e&&r)for(var n,s,a,c,d,u,l=0;l<r.length&&!d;){var p=r[l],h=r[l+1];for(n=s=0;n<p.length&&!d&&p[n];)if(d=p[n++].exec(e))for(a=0;a<h.length;a++)u=d[++s],typeof(c=h[a])===o&&c.length>0?2===c.length?typeof c[1]==i?this[c[0]]=c[1].call(this,u):this[c[0]]=c[1]:3===c.length?typeof c[1]!==i||c[1].exec&&c[1].test?this[c[0]]=u?u.replace(c[1],c[2]):t:this[c[0]]=u?c[1].call(this,u,c[2]):t:4===c.length&&(this[c[0]]=u?c[3].call(this,u.replace(c[1],c[2])):t):this[c]=u||t;l+=2}},be=function(e,r){for(var n in r)if(typeof r[n]===o&&r[n].length>0){for(var i=0;i<r[n].length;i++)if(ce(r[n][i],e))return"?"===n?t:n}else if(ce(r[n],e))return"?"===n?t:n;return r.hasOwnProperty("*")?r["*"]:e},we={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},_e={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":t},Se={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[h,[u,"Mobile Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[h,[u,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[u,h],[/opios[\/ ]+([\w\.]+)/i],[h,[u,"Opera Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[h,[u,"Opera GX"]],[/\bopr\/([\w\.]+)/i],[h,[u,te]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[h,[u,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[h,[u,"Maxthon"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,/(heytap|ovi|115)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[u,h],[/quark(?:pc)?\/([-\w\.]+)/i],[h,[u,"Quark"]],[/\bddg\/([\w\.]+)/i],[h,[u,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[h,[u,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[h,[u,"WeChat"]],[/konqueror\/([\w\.]+)/i],[h,[u,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[h,[u,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[h,[u,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[h,[u,"Smart Lenovo Browser"]],[/(avast|avg)\/([\w\.]+)/i],[[u,/(.+)/,"$1 Secure Browser"],h],[/\bfocus\/([\w\.]+)/i],[h,[u,"Firefox Focus"]],[/\bopt\/([\w\.]+)/i],[h,[u,"Opera Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[h,[u,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[h,[u,"Dolphin"]],[/coast\/([\w\.]+)/i],[h,[u,"Opera Coast"]],[/miuibrowser\/([\w\.]+)/i],[h,[u,"MIUI Browser"]],[/fxios\/([\w\.-]+)/i],[h,[u,"Mobile Firefox"]],[/\bqihoobrowser\/?([\w\.]*)/i],[h,[u,"360"]],[/\b(qq)\/([\w\.]+)/i],[[u,/(.+)/,"$1Browser"],h],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[u,/(.+)/,"$1 Browser"],h],[/samsungbrowser\/([\w\.]+)/i],[h,[u,"Samsung Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[h,[u,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[u,"Sogou Mobile"],h],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[u,h],[/(lbbrowser|rekonq)/i],[u],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[h,u],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[u,re],h,[l,S]],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(twitter)(?:and| f.+e\/([\w\.]+))/i,/(instagram|snapchat)[\/ ]([-\w\.]+)/i],[u,h,[l,S]],[/\bgsa\/([\w\.]+) .*safari\//i],[h,[u,"GSA"],[l,S]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[h,[u,"TikTok"],[l,S]],[/\[(linkedin)app\]/i],[u,[l,S]],[/(chromium)[\/ ]([-\w\.]+)/i],[u,h],[/headlesschrome(?:\/([\w\.]+)| )/i],[h,[u,"Chrome Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[u,"Chrome WebView"],h],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[h,[u,"Android Browser"]],[/chrome\/([\w\.]+) mobile/i],[h,[u,"Mobile Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[u,h],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[h,[u,"Mobile Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[u,"Mobile Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[h,u],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[u,[h,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[u,h],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[u,"Mobile Firefox"],h],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[u,"Netscape"],h],[/(wolvic|librewolf)\/([\w\.]+)/i],[u,h],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[h,[u,"Firefox Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/\b(links) \(([\w\.]+)/i],[u,[h,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[u,[h,/[^\d\.]+./,n]]],cpu:[[/\b(?:(amd|x|x86[-_]?|wow|win)64)\b/i],[[f,"amd64"]],[/(ia32(?=;))/i,/((?:i[346]|x)86)[;\)]/i],[[f,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[f,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[f,"armhf"]],[/windows (ce|mobile); ppc;/i],[[f,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[f,/ower/,n,pe]],[/(sun4\w)[;\)]/i],[[f,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[f,pe]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[d,[p,Q],[l,v]],[/\b((?:s[cgp]h|gt|sm)-(?![lr])\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]((?!sm-[lr])[-\w]+)/i,/sec-(sgh\w+)/i],[d,[p,Q],[l,g]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[d,[p,W],[l,g]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[d,[p,W],[l,v]],[/(macintosh);/i],[d,[p,W]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[d,[p,J],[l,g]],[/(?:honor)([-\w ]+)[;\)]/i],[d,[p,"Honor"],[l,g]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[d,[p,V],[l,v]],[/(?:huawei)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[d,[p,V],[l,g]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite|pro)?)(?: bui|\))/i],[[d,/_/g," "],[p,Z],[l,g]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[d,/_/g," "],[p,Z],[l,v]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[d,[p,"OPPO"],[l,g]],[/\b(opd2\d{3}a?) bui/i],[d,[p,"OPPO"],[l,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[d,[p,"Vivo"],[l,g]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[d,[p,"Realme"],[l,g]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[d,[p,G],[l,g]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[d,[p,G],[l,v]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[d,[p,$],[l,v]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[d,[p,$],[l,g]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[d,[p,H],[l,v]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[d,/_/g," "],[p,"Nokia"],[l,g]],[/(pixel c)\b/i],[d,[p,z],[l,v]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[d,[p,z],[l,g]],[/droid.+; (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[d,[p,Y],[l,g]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[d,"Xperia Tablet"],[p,Y],[l,v]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[d,[p,"OnePlus"],[l,g]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[d,[p,B],[l,v]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[d,/(.+)/g,"Fire Phone $1"],[p,B],[l,g]],[/(playbook);[-\w\),; ]+(rim)/i],[d,p,[l,v]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[d,[p,U],[l,g]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[d,[p,q],[l,v]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[d,[p,q],[l,g]],[/(nexus 9)/i],[d,[p,"HTC"],[l,v]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[p,[d,/_/g," "],[l,g]],[/tcl (xess p17aa)/i,/droid [\w\.]+; ((?:8[14]9[16]|9(?:0(?:48|60|8[01])|1(?:3[27]|66)|2(?:6[69]|9[56])|466))[gqswx])(_\w(\w|\w\w))?(\)| bui)/i],[d,[p,"TCL"],[l,v]],[/droid [\w\.]+; (418(?:7d|8v)|5087z|5102l|61(?:02[dh]|25[adfh]|27[ai]|56[dh]|59k|65[ah])|a509dl|t(?:43(?:0w|1[adepqu])|50(?:6d|7[adju])|6(?:09dl|10k|12b|71[efho]|76[hjk])|7(?:66[ahju]|67[hw]|7[045][bh]|71[hk]|73o|76[ho]|79w|81[hks]?|82h|90[bhsy]|99b)|810[hs]))(_\w(\w|\w\w))?(\)| bui)/i],[d,[p,"TCL"],[l,g]],[/(itel) ((\w+))/i],[[p,pe],d,[l,be,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[d,[p,"Acer"],[l,v]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[d,[p,"Meizu"],[l,g]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[d,[p,"Ulefone"],[l,g]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[d,[p,"Energizer"],[l,g]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[d,[p,"Cat"],[l,g]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[d,[p,"Smartfren"],[l,g]],[/droid.+; (a(?:015|06[35]|142p?))/i],[d,[p,"Nothing"],[l,g]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno|micromax|advan)[-_ ]?([-\w]*)/i,/; (imo) ((?!tab)[\w ]+?)(?: bui|\))/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[p,d,[l,g]],[/(imo) (tab \w+)/i,/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[p,d,[l,v]],[/(surface duo)/i],[d,[p,K],[l,v]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[d,[p,"Fairphone"],[l,g]],[/(shield[\w ]+) b/i],[d,[p,"Nvidia"],[l,v]],[/(sprint) (\w+)/i],[p,d,[l,g]],[/(kin\.[onetw]{3})/i],[[d,/\./g," "],[p,K],[l,g]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[d,[p,X],[l,v]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[d,[p,X],[l,g]],[/smart-tv.+(samsung)/i],[p,[l,y]],[/hbbtv.+maple;(\d+)/i],[[d,/^/,"SmartTV"],[p,Q],[l,y]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[p,$],[l,y]],[/(apple) ?tv/i],[p,[d,"Apple TV"],[l,y]],[/crkey.*devicetype\/chromecast/i],[[d,"Chromecast Third Generation"],[p,z],[l,y]],[/crkey.*devicetype\/([^/]*)/i],[[d,/^/,"Chromecast "],[p,z],[l,y]],[/fuchsia.*crkey/i],[[d,"Chromecast Nest Hub"],[p,z],[l,y]],[/crkey/i],[[d,ee],[p,z],[l,y]],[/droid.+aft(\w+)( bui|\))/i],[d,[p,B],[l,y]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[d,[p,J],[l,y]],[/(bravia[\w ]+)( bui|\))/i],[d,[p,Y],[l,y]],[/(mitv-\w{5}) bui/i],[d,[p,Z],[l,y]],[/Hbbtv.*(technisat) (.*);/i],[p,d,[l,y]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[p,ve],[d,ve],[l,y]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[l,y]],[/(ouya)/i,/(nintendo) (\w+)/i],[p,d,[l,m]],[/droid.+; (shield) bui/i],[d,[p,"Nvidia"],[l,m]],[/(playstation \w+)/i],[d,[p,Y],[l,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[d,[p,K],[l,m]],[/\b(sm-[lr]\d\d[05][fnuw]?s?)\b/i],[d,[p,Q],[l,b]],[/((pebble))app/i],[p,d,[l,b]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[d,[p,W],[l,b]],[/droid.+; (wt63?0{2,3})\)/i],[d,[p,X],[l,b]],[/droid.+; (glass) \d/i],[d,[p,z],[l,w]],[/(pico) (4|neo3(?: link|pro)?)/i],[p,d,[l,w]],[/; (quest( \d| pro)?)/i],[d,[p,re],[l,w]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[p,[l,_]],[/(aeobc)\b/i],[d,[p,B],[l,_]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[d,[l,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[d,[l,v]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[l,v]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[l,g]],[/(android[-\w\. ]{0,9});.+buil/i],[d,[p,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[h,[u,"EdgeHTML"]],[/(arkweb)\/([\w\.]+)/i],[u,h],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[h,[u,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna|servo)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[u,h],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[h,u]],os:[[/microsoft (windows) (vista|xp)/i],[u,h],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[u,[h,be,we]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[h,be,we],[u,ne]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[h,/_/g,"."],[u,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[u,"macOS"],[h,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[h,[u,"Chromecast Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[h,[u,"Chromecast Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[h,[u,"Chromecast SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[h,[u,"Chromecast Linux"]],[/crkey\/([\d\.]+)/i],[h,[u,ee]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[h,u],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish|openharmony)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[u,h],[/\(bb(10);/i],[h,[u,U]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[h,[u,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[h,[u,"Firefox OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[h,[u,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[h,[u,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[u,"Chrome OS"],h],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) (\w+)/i,/(xbox); +xbox ([^\);]+)/i,/(pico) .+os([\w\.]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[u,h],[/(sunos) ?([\w\.\d]*)/i],[[u,"Solaris"],h],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[u,h]]},ke=(fe.call((r={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}}).init,[[O,[u,h,c,l]],[L,[f]],[A,[l,d,p]],[j,[u,h]],[F,[u,h]]]),fe.call(r.isIgnore,[[O,[h,c]],[j,[h]],[F,[h]]]),fe.call(r.isIgnoreRgx,[[O,/ ?browser$/i],[F,/ ?os$/i]]),fe.call(r.toString,[[O,[u,h]],[L,[f]],[A,[p,d]],[j,[u,h]],[F,[u,h]]]),r),Ce=function(e,t){var r=ke.init[t],i=ke.isIgnore[t]||0,o=ke.isIgnoreRgx[t]||0,a=ke.toString[t]||0;function c(){fe.call(this,r)}return c.prototype.getItem=function(){return e},c.prototype.withClientHints=function(){return oe?oe.getHighEntropyValues(x).then((function(t){return e.setCH(new Re(t,!1)).parseCH().get()})):e.parseCH().get()},c.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=N&&(c.prototype.is=function(e){var t=!1;for(var r in this)if(this.hasOwnProperty(r)&&!ce(i,r)&&pe(o?me(o,this[r]):this[r])==pe(o?me(o,e):e)){if(t=!0,e!=s)break}else if(e==s&&t){t=!t;break}return t},c.prototype.toString=function(){var e=n;for(var t in a)typeof this[a[t]]!==s&&(e+=(e?" ":n)+this[a[t]]);return e||s}),oe||(c.prototype.then=function(e){var t=this,r=function(){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e])};r.prototype={is:c.prototype.is,toString:c.prototype.toString};var n=new r;return e(n),n}),new c};function Re(e,t){if(e=e||{},fe.call(this,x),t)fe.call(this,[[C,le(e[M])],[P,le(e["sec-ch-ua-full-version-list"])],[g,/\?1/.test(e["sec-ch-ua-mobile"])],[d,ge(e["sec-ch-ua-model"])],[T,ge(e[I])],[E,ge(e["sec-ch-ua-platform-version"])],[f,ge(e["sec-ch-ua-arch"])],[R,le(e["sec-ch-ua-form-factors"])],[D,ge(e["sec-ch-ua-bitness"])]]);else for(var r in e)this.hasOwnProperty(r)&&typeof e[r]!==s&&(this[r]=e[r])}function Pe(e,r,n,o){return this.get=function(e){return e?this.data.hasOwnProperty(e)?this.data[e]:t:this.data},this.set=function(e,t){return this.data[e]=t,this},this.setCH=function(e){return this.uaCH=e,this},this.detectFeature=function(){if(se&&se.userAgent==this.ua)switch(this.itemType){case O:se.brave&&typeof se.brave.isBrave==i&&this.set(u,"Brave");break;case A:!this.get(l)&&oe&&oe.mobile&&this.set(l,g),"Macintosh"==this.get(d)&&se&&typeof se.standalone!==s&&se.maxTouchPoints&&se.maxTouchPoints>2&&this.set(d,"iPad").set(l,v);break;case F:!this.get(u)&&oe&&oe.platform&&this.set(u,oe.platform);break;case N:var e=this.data,t=function(t){return e[t].getItem().detectFeature().get()};this.set(O,t(O)).set(L,t(L)).set(A,t(A)).set(j,t(j)).set(F,t(F))}return this},this.parseUA=function(){return this.itemType!=N&&ye.call(this.data,this.ua,this.rgxMap),this.itemType==O&&this.set(c,he(this.get(h))),this},this.parseCH=function(){var e=this.uaCH,r=this.rgxMap;switch(this.itemType){case O:var n,i=e[P]||e.brands;if(i)for(var s in i){var o=me(/(Google|Microsoft) /,i[s].brand||i[s]),a=i[s].version;/not.a.brand/i.test(o)||n&&(!/chrom/i.test(n)||/chromi/i.test(o))||(this.set(u,o).set(h,a).set(c,he(a)),n=o)}break;case L:var f=e.architecture;f&&(f&&"64"==e.bitness&&(f+="64"),ye.call(this.data,f+";",r));break;case A:if(e.mobile&&this.set(l,g),e.model&&this.set(d,e.model),"Xbox"==e.model&&this.set(l,m).set(p,K),e.formFactors){var v;if("string"!=typeof e.formFactors)for(var y=0;!v&&y<e.formFactors.length;)v=be(e.formFactors[y++],_e);else v=be(e.formFactors,_e);this.set(l,v)}break;case F:var b=e.platform;if(b){var w=e[E];b==ne&&(w=parseInt(he(w),10)>=13?"11":"10"),this.set(u,b).set(h,w)}this.get(u)==ne&&"Xbox"==e.model&&this.set(u,"Xbox").set(h,t);break;case N:var _=this.data,S=function(t){return _[t].getItem().setCH(e).parseCH().get()};this.set(O,S(O)).set(L,S(L)).set(A,S(A)).set(j,S(j)).set(F,S(F))}return this},fe.call(this,[["itemType",e],["ua",r],["uaCH",o],["rgxMap",n],["data",Ce(this,e)]]),this}function Te(e,r,s){if(typeof e===o?(de(e,!0)?(typeof r===o&&(s=r),r=e):(s=e,r=t),e=t):typeof e!==a||de(r,!0)||(s=r,r=t),s&&typeof s.append===i){var c={};s.forEach((function(e,t){c[t]=e})),s=c}if(!(this instanceof Te))return new Te(e,r,s).getResult();var d=typeof e===a?e:s&&s[k]?s[k]:se&&se.userAgent?se.userAgent:n,u=new Re(s,!0),l=r?function(e,t){var r={},n=t;if(!de(t))for(var i in n={},t)for(var s in t[i])n[s]=t[i][s].concat(n[s]?n[s]:[]);for(var o in e)r[o]=n[o]&&n[o].length%2==0?n[o].concat(e[o]):e[o];return r}(Se,r):Se,p=function(e){return e==N?function(){return new Pe(e,d,l,u).set("ua",d).set(O,this.getBrowser()).set(L,this.getCPU()).set(A,this.getDevice()).set(j,this.getEngine()).set(F,this.getOS()).get()}:function(){return new Pe(e,d,l[e],u).parseUA().get()}};return fe.call(this,[["getBrowser",p(O)],["getCPU",p(L)],["getDevice",p(A)],["getEngine",p(j)],["getOS",p(F)],["getResult",p(N)],["getUA",function(){return d}],["setUA",function(e){return ue(e)&&(d=e.length>500?ve(e,500):e),this}]]).setUA(d),this}Te.VERSION="2.0.0",Te.BROWSER=ae([u,h,c,l]),Te.CPU=ae([f]),Te.DEVICE=ae([d,p,l,m,g,y,v,b,_]),Te.ENGINE=Te.OS=ae([u,h]),li.exports&&(pi=li.exports=Te),pi.UAParser=Te;var Ee=ie&&(e.jQuery||e.Zepto);if(Ee&&!Ee.ua){var De=new Te;Ee.ua=De.getResult(),Ee.ua.get=function(){return De.getUA()},Ee.ua.set=function(e){De.setUA(e);var t=De.getResult();for(var r in t)Ee.ua[r]=t[r]}}}("object"==typeof window?window:l);var mi={},gi=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(mi,"__esModule",{value:!0}),mi.Logger=void 0;const vi=gi(ni.exports),yi="mediasoup-client";mi.Logger=class{constructor(e){e?(this._debug=(0,vi.default)(`${yi}:${e}`),this._warn=(0,vi.default)(`${yi}:WARN:${e}`),this._error=(0,vi.default)(`${yi}:ERROR:${e}`)):(this._debug=(0,vi.default)(yi),this._warn=(0,vi.default)(`${yi}:WARN`),this._error=(0,vi.default)(`${yi}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}};var bi,wi={},_i={exports:{}},Si="object"==typeof Reflect?Reflect:null,ki=Si&&"function"==typeof Si.apply?Si.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};bi=Si&&"function"==typeof Si.ownKeys?Si.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var Ci=Number.isNaN||function(e){return e!=e};function Ri(){Ri.init.call(this)}_i.exports=Ri,_i.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,s),n(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}Ai(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&Ai(e,"error",t,r)}(e,i,{once:!0})}))},Ri.EventEmitter=Ri,Ri.prototype._events=void 0,Ri.prototype._eventsCount=0,Ri.prototype._maxListeners=void 0;var Pi=10;function Ti(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Ei(e){return void 0===e._maxListeners?Ri.defaultMaxListeners:e._maxListeners}function Di(e,t,r,n){var i,s,o,a;if(Ti(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(i=Ei(e))>0&&o.length>i&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,console&&console.warn&&console.warn(a)}return e}function Mi(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ii(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=Mi.bind(n);return i.listener=r,n.wrapFn=i,i}function xi(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):Li(i,i.length)}function Oi(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function Li(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function Ai(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(s){n.once&&e.removeEventListener(t,i),r(s)}))}}Object.defineProperty(Ri,"defaultMaxListeners",{enumerable:!0,get:function(){return Pi},set:function(e){if("number"!=typeof e||e<0||Ci(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Pi=e}}),Ri.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Ri.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||Ci(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},Ri.prototype.getMaxListeners=function(){return Ei(this)},Ri.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,i=this._events;if(void 0!==i)n=n&&void 0===i.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)ki(a,this,t);else{var c=a.length,d=Li(a,c);for(r=0;r<c;++r)ki(d[r],this,t)}return!0},Ri.prototype.addListener=function(e,t){return Di(this,e,t,!1)},Ri.prototype.on=Ri.prototype.addListener,Ri.prototype.prependListener=function(e,t){return Di(this,e,t,!0)},Ri.prototype.once=function(e,t){return Ti(t),this.on(e,Ii(this,e,t)),this},Ri.prototype.prependOnceListener=function(e,t){return Ti(t),this.prependListener(e,Ii(this,e,t)),this},Ri.prototype.removeListener=function(e,t){var r,n,i,s,o;if(Ti(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,o||t)}return this},Ri.prototype.off=Ri.prototype.removeListener,Ri.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,s=Object.keys(r);for(n=0;n<s.length;++n)"removeListener"!==(i=s[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},Ri.prototype.listeners=function(e){return xi(this,e,!0)},Ri.prototype.rawListeners=function(e){return xi(this,e,!1)},Ri.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Oi.call(e,t)},Ri.prototype.listenerCount=Oi,Ri.prototype.eventNames=function(){return this._eventsCount>0?bi(this._events):[]},Object.defineProperty(wi,"__esModule",{value:!0}),wi.EnhancedEventEmitter=void 0;const ji=_i.exports,Fi=new mi.Logger("EnhancedEventEmitter");class Ni extends ji.EventEmitter{constructor(){super(),this.setMaxListeners(1/0)}emit(e,...t){return super.emit(e,...t)}safeEmit(e,...t){try{return super.emit(e,...t)}catch(t){Fi.error("safeEmit() | event listener threw an error [eventName:%s]:%o",e,t);try{super.emit("listenererror",e,t)}catch(e){}return Boolean(super.listenerCount(e))}}on(e,t){return super.on(e,t),this}off(e,t){return super.off(e,t),this}addListener(e,t){return super.on(e,t),this}prependListener(e,t){return super.prependListener(e,t),this}once(e,t){return super.once(e,t),this}prependOnceListener(e,t){return super.prependOnceListener(e,t),this}removeListener(e,t){return super.off(e,t),this}removeAllListeners(e){return super.removeAllListeners(e),this}listenerCount(e){return super.listenerCount(e)}listeners(e){return super.listeners(e)}rawListeners(e){return super.rawListeners(e)}}wi.EnhancedEventEmitter=Ni;var Bi={};Object.defineProperty(Bi,"__esModule",{value:!0}),Bi.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},Bi.generateRandomNumber=function(){return Math.round(1e7*Math.random())},Bi.deepFreeze=function e(t){const r=Reflect.ownKeys(t);for(const n of r){const r=t[n];(r&&"object"==typeof r||"function"==typeof r)&&e(r)}return Object.freeze(t)};var Wi={},qi={},Ui={},zi={exports:{}},Vi=1e3,Hi=6e4,$i=60*Hi,Ki=24*$i,Gi=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*Ki;case"hours":case"hour":case"hrs":case"hr":case"h":return r*$i;case"minutes":case"minute":case"mins":case"min":case"m":return r*Hi;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=Ki)return Qi(e,t,Ki,"day");if(t>=$i)return Qi(e,t,$i,"hour");if(t>=Hi)return Qi(e,t,Hi,"minute");if(t>=1e3)return Qi(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=Ki)return Math.round(e/Ki)+"d";if(t>=$i)return Math.round(e/$i)+"h";if(t>=Hi)return Math.round(e/Hi)+"m";if(t>=Vi)return Math.round(e/Vi)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Qi(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var Ji=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r<i;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=Gi,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Ji(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(zi,zi.exports);var Yi=zi.exports,Zi=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ui,"__esModule",{value:!0}),Ui.Logger=void 0;const Xi=Zi(zi.exports),es="h264-profile-level-id";Ui.Logger=class{constructor(e){e?(this._debug=(0,Xi.default)(`${es}:${e}`),this._warn=(0,Xi.default)(`${es}:WARN:${e}`),this._error=(0,Xi.default)(`${es}:ERROR:${e}`)):(this._debug=(0,Xi.default)(es),this._warn=(0,Xi.default)(`${es}:WARN`),this._error=(0,Xi.default)(`${es}:ERROR`)),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}},Object.defineProperty(qi,"__esModule",{value:!0}),qi.generateProfileLevelIdStringForAnswer=qi.isSameProfile=qi.parseSdpProfileLevelId=qi.levelToString=qi.profileToString=qi.profileLevelIdToString=qi.parseProfileLevelId=qi.ProfileLevelId=qi.Level=qi.Profile=void 0;const ts=new Ui.Logger;var rs,ns;!function(e){e[e.ConstrainedBaseline=1]="ConstrainedBaseline",e[e.Baseline=2]="Baseline",e[e.Main=3]="Main",e[e.ConstrainedHigh=4]="ConstrainedHigh",e[e.High=5]="High",e[e.PredictiveHigh444=6]="PredictiveHigh444"}(rs||(qi.Profile=rs={})),function(e){e[e.L1_b=0]="L1_b",e[e.L1=10]="L1",e[e.L1_1=11]="L1_1",e[e.L1_2=12]="L1_2",e[e.L1_3=13]="L1_3",e[e.L2=20]="L2",e[e.L2_1=21]="L2_1",e[e.L2_2=22]="L2_2",e[e.L3=30]="L3",e[e.L3_1=31]="L3_1",e[e.L3_2=32]="L3_2",e[e.L4=40]="L4",e[e.L4_1=41]="L4_1",e[e.L4_2=42]="L4_2",e[e.L5=50]="L5",e[e.L5_1=51]="L5_1",e[e.L5_2=52]="L5_2"}(ns||(qi.Level=ns={}));class is{constructor(e,t){this.profile=e,this.level=t}}qi.ProfileLevelId=is;const ss=new is(rs.ConstrainedBaseline,ns.L3_1);class os{constructor(e){this.mask=~ps("x",e),this.masked_value=ps("1",e)}isMatch(e){return this.masked_value===(e&this.mask)}}class as{constructor(e,t,r){this.profile_idc=e,this.profile_iop=t,this.profile=r}}const cs=[new as(66,new os("x1xx0000"),rs.ConstrainedBaseline),new as(77,new os("1xxx0000"),rs.ConstrainedBaseline),new as(88,new os("11xx0000"),rs.ConstrainedBaseline),new as(66,new os("x0xx0000"),rs.Baseline),new as(88,new os("10xx0000"),rs.Baseline),new as(77,new os("0x0x0000"),rs.Main),new as(100,new os("00000000"),rs.High),new as(100,new os("00001100"),rs.ConstrainedHigh),new as(244,new os("00000000"),rs.PredictiveHigh444)];function ds(e){if("string"!=typeof e||6!==e.length)return;const t=parseInt(e,16);if(0===t)return;const r=255&t,n=t>>8&255,i=t>>16&255;let s;switch(r){case ns.L1_1:s=0!=(16&n)?ns.L1_b:ns.L1_1;break;case ns.L1:case ns.L1_2:case ns.L1_3:case ns.L2:case ns.L2_1:case ns.L2_2:case ns.L3:case ns.L3_1:case ns.L3_2:case ns.L4:case ns.L4_1:case ns.L4_2:case ns.L5:case ns.L5_1:case ns.L5_2:s=r;break;default:return void ts.warn(`parseProfileLevelId() | unrecognized level_idc [str:${e}, level_idc:${r}]`)}for(const e of cs)if(i===e.profile_idc&&e.profile_iop.isMatch(n))return new is(e.profile,s);ts.warn(`parseProfileLevelId() | unrecognized profile_idc/profile_iop combination [str:${e}, profile_idc:${i}, profile_iop:${n}]`)}function us(e){if(e.level==ns.L1_b)switch(e.profile){case rs.ConstrainedBaseline:return"42f00b";case rs.Baseline:return"42100b";case rs.Main:return"4d100b";default:return void ts.warn(`profileLevelIdToString() | Level 1_b not is allowed for profile ${e.profile}`)}let t;switch(e.profile){case rs.ConstrainedBaseline:t="42e0";break;case rs.Baseline:t="4200";break;case rs.Main:t="4d00";break;case rs.ConstrainedHigh:t="640c";break;case rs.High:t="6400";break;case rs.PredictiveHigh444:t="f400";break;default:return void ts.warn(`profileLevelIdToString() | unrecognized profile ${e.profile}`)}let r=e.level.toString(16);return 1===r.length&&(r=`0${r}`),`${t}${r}`}function ls(e={}){const t=e["profile-level-id"];return t?ds(t):ss}function ps(e,t){return Number(t[0]===e)<<7|Number(t[1]===e)<<6|Number(t[2]===e)<<5|Number(t[3]===e)<<4|Number(t[4]===e)<<3|Number(t[5]===e)<<2|Number(t[6]===e)<<1|Number(t[7]===e)<<0}function hs(e={}){const t=e["level-asymmetry-allowed"];return!0===t||1===t||"1"===t}qi.parseProfileLevelId=ds,qi.profileLevelIdToString=us,qi.profileToString=function(e){switch(e){case rs.ConstrainedBaseline:return"ConstrainedBaseline";case rs.Baseline:return"Baseline";case rs.Main:return"Main";case rs.ConstrainedHigh:return"ConstrainedHigh";case rs.High:return"High";case rs.PredictiveHigh444:return"PredictiveHigh444";default:return void ts.warn(`profileToString() | unrecognized profile ${e}`)}},qi.levelToString=function(e){switch(e){case ns.L1_b:return"1b";case ns.L1:return"1";case ns.L1_1:return"1.1";case ns.L1_2:return"1.2";case ns.L1_3:return"1.3";case ns.L2:return"2";case ns.L2_1:return"2.1";case ns.L2_2:return"2.2";case ns.L3:return"3";case ns.L3_1:return"3.1";case ns.L3_2:return"3.2";case ns.L4:return"4";case ns.L4_1:return"4.1";case ns.L4_2:return"4.2";case ns.L5:return"5";case ns.L5_1:return"5.1";case ns.L5_2:return"5.2";default:return void ts.warn(`levelToString() | unrecognized level ${e}`)}},qi.parseSdpProfileLevelId=ls,qi.isSameProfile=function(e={},t={}){const r=ls(e),n=ls(t);return Boolean(r&&n&&r.profile===n.profile)},qi.generateProfileLevelIdStringForAnswer=function(e={},t={}){if(!e["profile-level-id"]&&!t["profile-level-id"])return void ts.warn("generateProfileLevelIdStringForAnswer() | profile-level-id missing in local and remote params");const r=ls(e),n=ls(t);if(!r)throw new TypeError("invalid local_profile_level_id");if(!n)throw new TypeError("invalid remote_profile_level_id");if(r.profile!==n.profile)throw new TypeError("H264 Profile mismatch");const i=hs(e)&&hs(t),s=r.level,o=function(e,t){return function(e,t){if(e===ns.L1_b)return t!==ns.L1&&t!==ns.L1_b;if(t===ns.L1_b)return e!==ns.L1;return e<t}(e,t)?e:t}(s,n.level),a=i?s:o;return ts.debug(`generateProfileLevelIdStringForAnswer() | result [profile:${r.profile}, level:${a}]`),us(new is(r.profile,a))};var fs,ms=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),gs=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),vs=l&&l.__importStar||(fs=function(e){return fs=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},fs(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=fs(e),n=0;n<r.length;n++)"default"!==r[n]&&ms(t,e,r[n]);return gs(t,e),t});Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.validateRtpCapabilities=function(e){if("object"!=typeof e)throw new TypeError("caps is not an object");if(e.codecs&&!Array.isArray(e.codecs))throw new TypeError("caps.codecs is not an array");e.codecs||(e.codecs=[]);for(const t of e.codecs)_s(t);if(e.headerExtensions&&!Array.isArray(e.headerExtensions))throw new TypeError("caps.headerExtensions is not an array");e.headerExtensions||(e.headerExtensions=[]);for(const t of e.headerExtensions)ks(t)},Wi.validateRtpParameters=ws,Wi.validateSctpStreamParameters=function(e){if("object"!=typeof e)throw new TypeError("params is not an object");if("number"!=typeof e.streamId)throw new TypeError("missing params.streamId");let t=!1;"boolean"==typeof e.ordered?t=!0:e.ordered=!0;if(e.maxPacketLifeTime&&"number"!=typeof e.maxPacketLifeTime)throw new TypeError("invalid params.maxPacketLifeTime");if(e.maxRetransmits&&"number"!=typeof e.maxRetransmits)throw new TypeError("invalid params.maxRetransmits");if(e.maxPacketLifeTime&&e.maxRetransmits)throw new TypeError("cannot provide both maxPacketLifeTime and maxRetransmits");if(t&&e.ordered&&(e.maxPacketLifeTime||e.maxRetransmits))throw new TypeError("cannot be ordered with maxPacketLifeTime or maxRetransmits");t||!e.maxPacketLifeTime&&!e.maxRetransmits||(e.ordered=!1);if(e.label&&"string"!=typeof e.label)throw new TypeError("invalid params.label");if(e.protocol&&"string"!=typeof e.protocol)throw new TypeError("invalid params.protocol")},Wi.validateSctpCapabilities=function(e){if("object"!=typeof e)throw new TypeError("caps is not an object");if(!e.numStreams||"object"!=typeof e.numStreams)throw new TypeError("missing caps.numStreams");!function(e){if("object"!=typeof e)throw new TypeError("numStreams is not an object");if("number"!=typeof e.OS)throw new TypeError("missing numStreams.OS");if("number"!=typeof e.MIS)throw new TypeError("missing numStreams.MIS")}(e.numStreams)},Wi.getExtendedRtpCapabilities=function(e,t){const r={codecs:[],headerExtensions:[]};for(const n of t.codecs??[]){if(Ts(n))continue;const t=(e.codecs??[]).find((e=>Es(e,n,{strict:!0,modify:!0})));if(!t)continue;const i={mimeType:t.mimeType,kind:t.kind,clockRate:t.clockRate,channels:t.channels,localPayloadType:t.preferredPayloadType,localRtxPayloadType:void 0,remotePayloadType:n.preferredPayloadType,remoteRtxPayloadType:void 0,localParameters:t.parameters,remoteParameters:n.parameters,rtcpFeedback:Ms(t,n)};r.codecs.push(i)}for(const n of r.codecs){const r=e.codecs.find((e=>Ts(e)&&e.parameters.apt===n.localPayloadType)),i=t.codecs.find((e=>Ts(e)&&e.parameters.apt===n.remotePayloadType));r&&i&&(n.localRtxPayloadType=r.preferredPayloadType,n.remoteRtxPayloadType=i.preferredPayloadType)}for(const n of t.headerExtensions){const t=e.headerExtensions.find((e=>Ds(e,n)));if(!t)continue;const i={kind:n.kind,uri:n.uri,sendId:t.preferredId,recvId:n.preferredId,encrypt:t.preferredEncrypt,direction:"sendrecv"};switch(n.direction){case"sendrecv":i.direction="sendrecv";break;case"recvonly":i.direction="sendonly";break;case"sendonly":i.direction="recvonly";break;case"inactive":i.direction="inactive"}r.headerExtensions.push(i)}return r},Wi.getRecvRtpCapabilities=function(e){const t={codecs:[],headerExtensions:[]};for(const r of e.codecs){const e={mimeType:r.mimeType,kind:r.kind,preferredPayloadType:r.remotePayloadType,clockRate:r.clockRate,channels:r.channels,parameters:r.localParameters,rtcpFeedback:r.rtcpFeedback};if(t.codecs.push(e),!r.remoteRtxPayloadType)continue;const n={mimeType:`${r.kind}/rtx`,kind:r.kind,preferredPayloadType:r.remoteRtxPayloadType,clockRate:r.clockRate,parameters:{apt:r.remotePayloadType},rtcpFeedback:[]};t.codecs.push(n)}for(const r of e.headerExtensions){if("sendrecv"!==r.direction&&"recvonly"!==r.direction)continue;const e={kind:r.kind,uri:r.uri,preferredId:r.recvId,preferredEncrypt:r.encrypt,direction:r.direction};t.headerExtensions.push(e)}return t},Wi.getSendingRtpParameters=function(e,t){const r={mid:void 0,codecs:[],headerExtensions:[],encodings:[],rtcp:{}};for(const n of t.codecs){if(n.kind!==e)continue;const t={mimeType:n.mimeType,payloadType:n.localPayloadType,clockRate:n.clockRate,channels:n.channels,parameters:n.localParameters,rtcpFeedback:n.rtcpFeedback};if(r.codecs.push(t),n.localRtxPayloadType){const e={mimeType:`${n.kind}/rtx`,payloadType:n.localRtxPayloadType,clockRate:n.clockRate,parameters:{apt:n.localPayloadType},rtcpFeedback:[]};r.codecs.push(e)}}for(const n of t.headerExtensions){if(n.kind&&n.kind!==e||"sendrecv"!==n.direction&&"sendonly"!==n.direction)continue;const t={uri:n.uri,id:n.sendId,encrypt:n.encrypt,parameters:{}};r.headerExtensions.push(t)}return r},Wi.getSendingRemoteRtpParameters=function(e,t){const r={mid:void 0,codecs:[],headerExtensions:[],encodings:[],rtcp:{}};for(const n of t.codecs){if(n.kind!==e)continue;const t={mimeType:n.mimeType,payloadType:n.localPayloadType,clockRate:n.clockRate,channels:n.channels,parameters:n.remoteParameters,rtcpFeedback:n.rtcpFeedback};if(r.codecs.push(t),n.localRtxPayloadType){const e={mimeType:`${n.kind}/rtx`,payloadType:n.localRtxPayloadType,clockRate:n.clockRate,parameters:{apt:n.localPayloadType},rtcpFeedback:[]};r.codecs.push(e)}}for(const n of t.headerExtensions){if(n.kind&&n.kind!==e||"sendrecv"!==n.direction&&"sendonly"!==n.direction)continue;const t={uri:n.uri,id:n.sendId,encrypt:n.encrypt,parameters:{}};r.headerExtensions.push(t)}if(r.headerExtensions.some((e=>"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"===e.uri)))for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback??[]).filter((e=>"goog-remb"!==e.type));else if(r.headerExtensions.some((e=>"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"===e.uri)))for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback??[]).filter((e=>"transport-cc"!==e.type));else for(const e of r.codecs)e.rtcpFeedback=(e.rtcpFeedback??[]).filter((e=>"transport-cc"!==e.type&&"goog-remb"!==e.type));return r},Wi.reduceCodecs=function(e,t){const r=[];if(t){for(let n=0;n<e.length;++n)if(Es(e[n],t,{strict:!0})){r.push(e[n]),Ts(e[n+1])&&r.push(e[n+1]);break}if(0===r.length)throw new TypeError("no matching codec found")}else r.push(e[0]),Ts(e[1])&&r.push(e[1]);return r},Wi.generateProbatorRtpParameters=function(e){ws(e=bs.clone(e));const t={mid:"probator",codecs:[],headerExtensions:[],encodings:[{ssrc:1234}],rtcp:{cname:"probator"}};return t.codecs.push(e.codecs[0]),t.codecs[0].payloadType=127,t.headerExtensions=e.headerExtensions,t},Wi.canSend=function(e,t){return t.codecs.some((t=>t.kind===e))},Wi.canReceive=function(e,t){if(ws(e),0===e.codecs.length)return!1;const r=e.codecs[0];return t.codecs.some((e=>e.remotePayloadType===r.payloadType))};const ys=vs(qi),bs=vs(Bi);function ws(e){if("object"!=typeof e)throw new TypeError("params is not an object");if(e.mid&&"string"!=typeof e.mid)throw new TypeError("params.mid is not a string");if(!Array.isArray(e.codecs))throw new TypeError("missing params.codecs");for(const t of e.codecs)Cs(t);if(e.headerExtensions&&!Array.isArray(e.headerExtensions))throw new TypeError("params.headerExtensions is not an array");e.headerExtensions||(e.headerExtensions=[]);for(const t of e.headerExtensions)Rs(t);if(e.encodings&&!Array.isArray(e.encodings))throw new TypeError("params.encodings is not an array");e.encodings||(e.encodings=[]);for(const t of e.encodings)Ps(t);if(e.rtcp&&"object"!=typeof e.rtcp)throw new TypeError("params.rtcp is not an object");e.rtcp||(e.rtcp={}),function(e){if("object"!=typeof e)throw new TypeError("rtcp is not an object");if(e.cname&&"string"!=typeof e.cname)throw new TypeError("invalid rtcp.cname");e.reducedSize&&"boolean"==typeof e.reducedSize||(e.reducedSize=!0)}(e.rtcp)}function _s(e){const t=new RegExp("^(audio|video)/(.+)","i");if("object"!=typeof e)throw new TypeError("codec is not an object");if(!e.mimeType||"string"!=typeof e.mimeType)throw new TypeError("missing codec.mimeType");const r=t.exec(e.mimeType);if(!r)throw new TypeError("invalid codec.mimeType");if(e.kind=r[1].toLowerCase(),e.preferredPayloadType&&"number"!=typeof e.preferredPayloadType)throw new TypeError("invalid codec.preferredPayloadType");if("number"!=typeof e.clockRate)throw new TypeError("missing codec.clockRate");"audio"===e.kind?"number"!=typeof e.channels&&(e.channels=1):delete e.channels,e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError(`invalid codec parameter [key:${t}s, value:${r}]`);if("apt"===t&&"number"!=typeof r)throw new TypeError("invalid codec apt parameter")}e.rtcpFeedback&&Array.isArray(e.rtcpFeedback)||(e.rtcpFeedback=[]);for(const t of e.rtcpFeedback)Ss(t)}function Ss(e){if("object"!=typeof e)throw new TypeError("fb is not an object");if(!e.type||"string"!=typeof e.type)throw new TypeError("missing fb.type");e.parameter&&"string"==typeof e.parameter||(e.parameter="")}function ks(e){if("object"!=typeof e)throw new TypeError("ext is not an object");if("audio"!==e.kind&&"video"!==e.kind)throw new TypeError("invalid ext.kind");if(!e.uri||"string"!=typeof e.uri)throw new TypeError("missing ext.uri");if("number"!=typeof e.preferredId)throw new TypeError("missing ext.preferredId");if(e.preferredEncrypt&&"boolean"!=typeof e.preferredEncrypt)throw new TypeError("invalid ext.preferredEncrypt");if(e.preferredEncrypt||(e.preferredEncrypt=!1),e.direction&&"string"!=typeof e.direction)throw new TypeError("invalid ext.direction");e.direction||(e.direction="sendrecv")}function Cs(e){const t=new RegExp("^(audio|video)/(.+)","i");if("object"!=typeof e)throw new TypeError("codec is not an object");if(!e.mimeType||"string"!=typeof e.mimeType)throw new TypeError("missing codec.mimeType");const r=t.exec(e.mimeType);if(!r)throw new TypeError("invalid codec.mimeType");if("number"!=typeof e.payloadType)throw new TypeError("missing codec.payloadType");if("number"!=typeof e.clockRate)throw new TypeError("missing codec.clockRate");"audio"===r[1].toLowerCase()?"number"!=typeof e.channels&&(e.channels=1):delete e.channels,e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError(`invalid codec parameter [key:${t}s, value:${r}]`);if("apt"===t&&"number"!=typeof r)throw new TypeError("invalid codec apt parameter")}e.rtcpFeedback&&Array.isArray(e.rtcpFeedback)||(e.rtcpFeedback=[]);for(const t of e.rtcpFeedback)Ss(t)}function Rs(e){if("object"!=typeof e)throw new TypeError("ext is not an object");if(!e.uri||"string"!=typeof e.uri)throw new TypeError("missing ext.uri");if("number"!=typeof e.id)throw new TypeError("missing ext.id");if(e.encrypt&&"boolean"!=typeof e.encrypt)throw new TypeError("invalid ext.encrypt");e.encrypt||(e.encrypt=!1),e.parameters&&"object"==typeof e.parameters||(e.parameters={});for(const t of Object.keys(e.parameters)){let r=e.parameters[t];if(void 0===r&&(e.parameters[t]="",r=""),"string"!=typeof r&&"number"!=typeof r)throw new TypeError("invalid header extension parameter")}}function Ps(e){if("object"!=typeof e)throw new TypeError("encoding is not an object");if(e.ssrc&&"number"!=typeof e.ssrc)throw new TypeError("invalid encoding.ssrc");if(e.rid&&"string"!=typeof e.rid)throw new TypeError("invalid encoding.rid");if(e.rtx&&"object"!=typeof e.rtx)throw new TypeError("invalid encoding.rtx");if(e.rtx&&"number"!=typeof e.rtx.ssrc)throw new TypeError("missing encoding.rtx.ssrc");if(e.dtx&&"boolean"==typeof e.dtx||(e.dtx=!1),e.scalabilityMode&&"string"!=typeof e.scalabilityMode)throw new TypeError("invalid encoding.scalabilityMode")}function Ts(e){return!!e&&/.+\/rtx$/i.test(e.mimeType)}function Es(e,t,{strict:r=!1,modify:n=!1}={}){const i=e.mimeType.toLowerCase();if(i!==t.mimeType.toLowerCase())return!1;if(e.clockRate!==t.clockRate)return!1;if(e.channels!==t.channels)return!1;switch(i){case"video/h264":if(r){if((e.parameters["packetization-mode"]||0)!==(t.parameters["packetization-mode"]||0))return!1;if(!ys.isSameProfile(e.parameters,t.parameters))return!1;let r;try{r=ys.generateProfileLevelIdStringForAnswer(e.parameters,t.parameters)}catch(e){return!1}n&&(r?(e.parameters["profile-level-id"]=r,t.parameters["profile-level-id"]=r):(delete e.parameters["profile-level-id"],delete t.parameters["profile-level-id"]))}break;case"video/vp9":if(r){if((e.parameters["profile-id"]||0)!==(t.parameters["profile-id"]||0))return!1}}return!0}function Ds(e,t){return(!e.kind||!t.kind||e.kind===t.kind)&&e.uri===t.uri}function Ms(e,t){const r=[];for(const n of e.rtcpFeedback??[]){const e=(t.rtcpFeedback??[]).find((e=>e.type===n.type&&(e.parameter===n.parameter||!e.parameter&&!n.parameter)));e&&r.push(e)}return r}var Is={},xs={},Os={},Ls={exports:{}},As=1e3,js=60*As,Fs=60*js,Ns=24*Fs,Bs=7*Ns,Ws=365.25*Ns,qs=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*Ws;case"weeks":case"week":case"w":return r*Bs;case"days":case"day":case"d":return r*Ns;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Fs;case"minutes":case"minute":case"mins":case"min":case"m":return r*js;case"seconds":case"second":case"secs":case"sec":case"s":return r*As;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=Ns)return Us(e,t,Ns,"day");if(t>=Fs)return Us(e,t,Fs,"hour");if(t>=js)return Us(e,t,js,"minute");if(t>=As)return Us(e,t,As,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=Ns)return Math.round(e/Ns)+"d";if(t>=Fs)return Math.round(e/Fs)+"h";if(t>=js)return Math.round(e/js)+"m";if(t>=As)return Math.round(e/As)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Us(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var zs=function(e){function t(e){let n,i,s,o=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";o++;const s=t.formatters[i];if("function"==typeof s){const t=e[o];n=s.call(r,t),e.splice(o,1),o--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r<i;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=qs,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t};!function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=zs(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Ls,Ls.exports),Object.defineProperty(Os,"__esModule",{value:!0}),Os.Logger=void 0;const Vs=Ls.exports,Hs="awaitqueue";Os.Logger=class{constructor(e){e?(this._debug=(0,Vs.default)(`awaitqueue:${e}`),this._warn=(0,Vs.default)(`awaitqueue:WARN:${e}`),this._error=(0,Vs.default)(`awaitqueue:ERROR:${e}`)):(this._debug=(0,Vs.default)(Hs),this._warn=(0,Vs.default)("awaitqueue:WARN"),this._error=(0,Vs.default)("awaitqueue:ERROR")),this._debug.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}get debug(){return this._debug}get warn(){return this._warn}get error(){return this._error}},Object.defineProperty(xs,"__esModule",{value:!0}),xs.AwaitQueue=xs.AwaitQueueRemovedTaskError=xs.AwaitQueueStoppedError=void 0;const $s=new Os.Logger;class Ks extends Error{constructor(e){super(e??"AwaitQueue stopped"),this.name="AwaitQueueStoppedError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Ks)}}xs.AwaitQueueStoppedError=Ks;class Gs extends Error{constructor(e){super(e??"AwaitQueue task removed"),this.name="AwaitQueueRemovedTaskError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Gs)}}xs.AwaitQueueRemovedTaskError=Gs;
|
|
30
30
|
/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
31
|
-
let Ks;Is.AwaitQueue=class{constructor(){this.pendingTasks=new Map,this.nextTaskId=0,this.stopping=!1}get size(){return this.pendingTasks.size}async push(e,t){if(t=t??e.name,Vs.debug(`push() [name:${t}]`),"function"!=typeof e)throw new TypeError("given task is not a function");if(t)try{Object.defineProperty(e,"name",{value:t})}catch(e){}return new Promise(((r,n)=>{const i={id:this.nextTaskId++,task:e,name:t,enqueuedAt:Date.now(),executedAt:void 0,completed:!1,resolve:e=>{if(i.completed)return;i.completed=!0,this.pendingTasks.delete(i.id),Vs.debug(`resolving task [name:${i.name}]`),r(e);const[t]=this.pendingTasks.values();t&&!t.executedAt&&this.execute(t)},reject:e=>{if(!i.completed&&(i.completed=!0,this.pendingTasks.delete(i.id),Vs.debug(`rejecting task [name:${i.name}]: %s`,String(e)),n(e),!this.stopping)){const[e]=this.pendingTasks.values();e&&!e.executedAt&&this.execute(e)}}};this.pendingTasks.set(i.id,i),1===this.pendingTasks.size&&this.execute(i)}))}stop(){Vs.debug("stop()"),this.stopping=!0;for(const e of this.pendingTasks.values())Vs.debug(`stop() | stopping task [name:${e.name}]`),e.reject(new Hs);this.stopping=!1}remove(e){Vs.debug(`remove() [taskIdx:${e}]`);const t=Array.from(this.pendingTasks.values())[e];t?t.reject(new $s):Vs.debug(`stop() | no task with given idx [taskIdx:${e}]`)}dump(){const e=Date.now();let t=0;return Array.from(this.pendingTasks.values()).map((r=>({idx:t++,task:r.task,name:r.name,enqueuedTime:r.executedAt?r.executedAt-r.enqueuedAt:e-r.enqueuedAt,executionTime:r.executedAt?e-r.executedAt:0})))}async execute(e){if(Vs.debug(`execute() [name:${e.name}]`),e.executedAt)throw new Error("task already being executed");e.executedAt=Date.now();try{const t=await e.task();e.resolve(t)}catch(t){e.reject(t)}}};var Gs="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:l):e=>(Ks||(Ks=Promise.resolve())).then(e).catch((e=>setTimeout((()=>{throw e}),0))),Qs={};Object.defineProperty(Qs,"__esModule",{value:!0}),Qs.Producer=void 0;const Js=yi,Ys=ir,Zs=new hi.Logger("Producer");class Xs extends Js.EnhancedEventEmitter{constructor({id:e,localId:t,rtpSender:r,track:n,rtpParameters:i,stopTracks:s,disableTrackOnPause:o,zeroRtpOnPause:a,appData:c}){super(),this._closed=!1,this._observer=new Js.EnhancedEventEmitter,Zs.debug("constructor()"),this._id=e,this._localId=t,this._rtpSender=r,this._track=n,this._kind=n.kind,this._rtpParameters=i,this._paused=!!o&&!n.enabled,this._maxSpatialLayer=void 0,this._stopTracks=s,this._disableTrackOnPause=o,this._zeroRtpOnPause=a,this._appData=c??{},this.onTrackEnded=this.onTrackEnded.bind(this),this.handleTrack()}get id(){return this._id}get localId(){return this._localId}get closed(){return this._closed}get kind(){return this._kind}get rtpSender(){return this._rtpSender}get track(){return this._track}get rtpParameters(){return this._rtpParameters}get paused(){return this._paused}get maxSpatialLayer(){return this._maxSpatialLayer}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(Zs.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(Zs.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new Ys.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){Zs.debug("pause()"),this._closed?Zs.error("pause() | Producer closed"):(this._paused=!0,this._track&&this._disableTrackOnPause&&(this._track.enabled=!1),this._zeroRtpOnPause&&new Promise(((e,t)=>{this.safeEmit("@pause",e,t)})).catch((()=>{})),this._observer.safeEmit("pause"))}resume(){Zs.debug("resume()"),this._closed?Zs.error("resume() | Producer closed"):(this._paused=!1,this._track&&this._disableTrackOnPause&&(this._track.enabled=!0),this._zeroRtpOnPause&&new Promise(((e,t)=>{this.safeEmit("@resume",e,t)})).catch((()=>{})),this._observer.safeEmit("resume"))}async replaceTrack({track:e}){if(Zs.debug("replaceTrack() [track:%o]",e),this._closed){if(e&&this._stopTracks)try{e.stop()}catch(e){}throw new Ys.InvalidStateError("closed")}if(e&&"ended"===e.readyState)throw new Ys.InvalidStateError("track ended");e!==this._track?(await new Promise(((t,r)=>{this.safeEmit("@replacetrack",e,t,r)})),this.destroyTrack(),this._track=e,this._track&&this._disableTrackOnPause&&(this._paused?this._paused&&(this._track.enabled=!1):this._track.enabled=!0),this.handleTrack()):Zs.debug("replaceTrack() | same track, ignored")}async setMaxSpatialLayer(e){if(this._closed)throw new Ys.InvalidStateError("closed");if("video"!==this._kind)throw new Ys.UnsupportedError("not a video Producer");if("number"!=typeof e)throw new TypeError("invalid spatialLayer");e!==this._maxSpatialLayer&&(await new Promise(((t,r)=>{this.safeEmit("@setmaxspatiallayer",e,t,r)})).catch((()=>{})),this._maxSpatialLayer=e)}async setRtpEncodingParameters(e){if(this._closed)throw new Ys.InvalidStateError("closed");if("object"!=typeof e)throw new TypeError("invalid params");await new Promise(((t,r)=>{this.safeEmit("@setrtpencodingparameters",e,t,r)}))}onTrackEnded(){Zs.debug('track "ended" event'),this.safeEmit("trackended"),this._observer.safeEmit("trackended")}handleTrack(){this._track&&this._track.addEventListener("ended",this.onTrackEnded)}destroyTrack(){if(this._track)try{this._track.removeEventListener("ended",this.onTrackEnded),this._stopTracks&&this._track.stop()}catch(e){}}}Qs.Producer=Xs;var eo={};Object.defineProperty(eo,"__esModule",{value:!0}),eo.Consumer=void 0;const to=yi,ro=ir,no=new hi.Logger("Consumer");class io extends to.EnhancedEventEmitter{constructor({id:e,localId:t,producerId:r,rtpReceiver:n,track:i,rtpParameters:s,appData:o}){super(),this._closed=!1,this._observer=new to.EnhancedEventEmitter,no.debug("constructor()"),this._id=e,this._localId=t,this._producerId=r,this._rtpReceiver=n,this._track=i,this._rtpParameters=s,this._paused=!i.enabled,this._appData=o??{},this.onTrackEnded=this.onTrackEnded.bind(this),this.handleTrack()}get id(){return this._id}get localId(){return this._localId}get producerId(){return this._producerId}get closed(){return this._closed}get kind(){return this._track.kind}get rtpReceiver(){return this._rtpReceiver}get track(){return this._track}get rtpParameters(){return this._rtpParameters}get paused(){return this._paused}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(no.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(no.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new ro.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){no.debug("pause()"),this._closed?no.error("pause() | Consumer closed"):this._paused?no.debug("pause() | Consumer is already paused"):(this._paused=!0,this._track.enabled=!1,this.emit("@pause"),this._observer.safeEmit("pause"))}resume(){no.debug("resume()"),this._closed?no.error("resume() | Consumer closed"):this._paused?(this._paused=!1,this._track.enabled=!0,this.emit("@resume"),this._observer.safeEmit("resume")):no.debug("resume() | Consumer is already resumed")}onTrackEnded(){no.debug('track "ended" event'),this.safeEmit("trackended"),this._observer.safeEmit("trackended")}handleTrack(){this._track.addEventListener("ended",this.onTrackEnded)}destroyTrack(){try{this._track.removeEventListener("ended",this.onTrackEnded),this._track.stop()}catch(e){}}}eo.Consumer=io;var so={};Object.defineProperty(so,"__esModule",{value:!0}),so.DataProducer=void 0;const oo=yi,ao=ir,co=new hi.Logger("DataProducer");class uo extends oo.EnhancedEventEmitter{constructor({id:e,dataChannel:t,sctpStreamParameters:r,appData:n}){super(),this._closed=!1,this._observer=new oo.EnhancedEventEmitter,co.debug("constructor()"),this._id=e,this._dataChannel=t,this._sctpStreamParameters=r,this._appData=n??{},this.handleDataChannel()}get id(){return this._id}get closed(){return this._closed}get sctpStreamParameters(){return this._sctpStreamParameters}get readyState(){return this._dataChannel.readyState}get label(){return this._dataChannel.label}get protocol(){return this._dataChannel.protocol}get bufferedAmount(){return this._dataChannel.bufferedAmount}get bufferedAmountLowThreshold(){return this._dataChannel.bufferedAmountLowThreshold}set bufferedAmountLowThreshold(e){this._dataChannel.bufferedAmountLowThreshold=e}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(co.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(co.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}send(e){if(co.debug("send()"),this._closed)throw new ao.InvalidStateError("closed");this._dataChannel.send(e)}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(co.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;let{error:t}=e;t||(t=new Error("unknown DataChannel error")),"sctp-failure"===t.errorDetail?co.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):co.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(co.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(()=>{this._closed||co.warn('DataChannel "message" event in a DataProducer, message discarded')})),this._dataChannel.addEventListener("bufferedamountlow",(()=>{this._closed||this.safeEmit("bufferedamountlow")}))}}so.DataProducer=uo;var lo={};Object.defineProperty(lo,"__esModule",{value:!0}),lo.DataConsumer=void 0;const po=yi,ho=new hi.Logger("DataConsumer");class fo extends po.EnhancedEventEmitter{constructor({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:n,appData:i}){super(),this._closed=!1,this._observer=new po.EnhancedEventEmitter,ho.debug("constructor()"),this._id=e,this._dataProducerId=t,this._dataChannel=r,this._sctpStreamParameters=n,this._appData=i??{},this.handleDataChannel()}get id(){return this._id}get dataProducerId(){return this._dataProducerId}get closed(){return this._closed}get sctpStreamParameters(){return this._sctpStreamParameters}get readyState(){return this._dataChannel.readyState}get label(){return this._dataChannel.label}get protocol(){return this._dataChannel.protocol}get binaryType(){return this._dataChannel.binaryType}set binaryType(e){this._dataChannel.binaryType=e}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(ho.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(ho.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(ho.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;let{error:t}=e;t||(t=new Error("unknown DataChannel error")),"sctp-failure"===t.errorDetail?ho.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):ho.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(ho.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(e=>{this._closed||this.safeEmit("message",e.data)}))}}lo.DataConsumer=fo;var mo=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),go=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),vo=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&mo(r,t,n[i]);return go(r,t),r}}(),yo=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ds,"__esModule",{value:!0}),Ds.Transport=void 0;const bo=Is,wo=yo(Gs),_o=hi,So=yi,ko=ir,Co=vo(Fi),Ro=vo(Ni),Po=Qs,To=eo,Eo=so,Do=lo,Io=new _o.Logger("Transport");class Mo{constructor(e){this.consumerOptions=e,this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class xo extends So.EnhancedEventEmitter{constructor({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,proprietaryConstraints:d,appData:u,handlerFactory:l,extendedRtpCapabilities:p,canProduceByKind:h}){super(),this._closed=!1,this._iceGatheringState="new",this._connectionState="new",this._producers=new Map,this._consumers=new Map,this._dataProducers=new Map,this._dataConsumers=new Map,this._probatorConsumerCreated=!1,this._awaitQueue=new bo.AwaitQueue,this._pendingConsumerTasks=[],this._consumerCreationInProgress=!1,this._pendingPauseConsumers=new Map,this._consumerPauseInProgress=!1,this._pendingResumeConsumers=new Map,this._consumerResumeInProgress=!1,this._pendingCloseConsumers=new Map,this._consumerCloseInProgress=!1,this._observer=new So.EnhancedEventEmitter,Io.debug("constructor() [id:%s, direction:%s]",t,e),this._id=t,this._direction=e,this._extendedRtpCapabilities=p,this._canProduceByKind=h,this._maxSctpMessageSize=s?s.maxMessageSize:null;const f=Co.clone(c)??{};delete f.iceServers,delete f.iceTransportPolicy,delete f.bundlePolicy,delete f.rtcpMuxPolicy,delete f.sdpSemantics,this._handler=l(),this._handler.run({direction:e,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:f,proprietaryConstraints:d,extendedRtpCapabilities:p}),this._appData=u??{},this.handleHandler()}get id(){return this._id}get closed(){return this._closed}get direction(){return this._direction}get handler(){return this._handler}get iceGatheringState(){return this._iceGatheringState}get connectionState(){return this._connectionState}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){if(!this._closed){Io.debug("close()"),this._closed=!0,this._awaitQueue.stop(),this._handler.close(),this._connectionState="closed";for(const e of this._producers.values())e.transportClosed();this._producers.clear();for(const e of this._consumers.values())e.transportClosed();this._consumers.clear();for(const e of this._dataProducers.values())e.transportClosed();this._dataProducers.clear();for(const e of this._dataConsumers.values())e.transportClosed();this._dataConsumers.clear(),this._observer.safeEmit("close")}}async getStats(){if(this._closed)throw new ko.InvalidStateError("closed");return this._handler.getTransportStats()}async restartIce({iceParameters:e}){if(Io.debug("restartIce()"),this._closed)throw new ko.InvalidStateError("closed");if(!e)throw new TypeError("missing iceParameters");return this._awaitQueue.push((async()=>await this._handler.restartIce(e)),"transport.restartIce()")}async updateIceServers({iceServers:e}={}){if(Io.debug("updateIceServers()"),this._closed)throw new ko.InvalidStateError("closed");if(!Array.isArray(e))throw new TypeError("missing iceServers");return this._awaitQueue.push((async()=>this._handler.updateIceServers(e)),"transport.updateIceServers()")}async produce({track:e,encodings:t,codecOptions:r,codec:n,stopTracks:i=!0,disableTrackOnPause:s=!0,zeroRtpOnPause:o=!1,onRtpSender:a,appData:c={}}={}){if(Io.debug("produce() [track:%o]",e),this._closed)throw new ko.InvalidStateError("closed");if(!e)throw new TypeError("missing track");if("send"!==this._direction)throw new ko.UnsupportedError("not a sending Transport");if(!this._canProduceByKind[e.kind])throw new ko.UnsupportedError(`cannot produce ${e.kind}`);if("ended"===e.readyState)throw new ko.InvalidStateError("track ended");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(0===this.listenerCount("produce"))throw new TypeError('no "produce" listener set into this transport');if(c&&"object"!=typeof c)throw new TypeError("if given, appData must be an object");return this._awaitQueue.push((async()=>{let d;if(t&&!Array.isArray(t))throw TypeError("encodings must be an array");t&&0===t.length?d=void 0:t&&(d=t.map((e=>{const t={active:!0};return!1===e.active&&(t.active=!1),"boolean"==typeof e.dtx&&(t.dtx=e.dtx),"string"==typeof e.scalabilityMode&&(t.scalabilityMode=e.scalabilityMode),"number"==typeof e.scaleResolutionDownBy&&(t.scaleResolutionDownBy=e.scaleResolutionDownBy),"number"==typeof e.maxBitrate&&(t.maxBitrate=e.maxBitrate),"number"==typeof e.maxFramerate&&(t.maxFramerate=e.maxFramerate),"boolean"==typeof e.adaptivePtime&&(t.adaptivePtime=e.adaptivePtime),"string"==typeof e.priority&&(t.priority=e.priority),"string"==typeof e.networkPriority&&(t.networkPriority=e.networkPriority),t})));const{localId:u,rtpParameters:l,rtpSender:p}=await this._handler.send({track:e,encodings:d,codecOptions:r,codec:n,onRtpSender:a});try{Ro.validateRtpParameters(l);const{id:t}=await new Promise(((t,r)=>{this.safeEmit("produce",{kind:e.kind,rtpParameters:l,appData:c},t,r)})),r=new Po.Producer({id:t,localId:u,rtpSender:p,track:e,rtpParameters:l,stopTracks:i,disableTrackOnPause:s,zeroRtpOnPause:o,appData:c});return this._producers.set(r.id,r),this.handleProducer(r),this._observer.safeEmit("newproducer",r),r}catch(e){throw this._handler.stopSending(u).catch((()=>{})),e}}),"transport.produce()").catch((t=>{if(i)try{e.stop()}catch(e){}throw t}))}async consume({id:e,producerId:t,kind:r,rtpParameters:n,streamId:i,onRtpReceiver:s,appData:o={}}){if(Io.debug("consume()"),this._closed)throw new ko.InvalidStateError("closed");if("recv"!==this._direction)throw new ko.UnsupportedError("not a receiving Transport");if("string"!=typeof e)throw new TypeError("missing id");if("string"!=typeof t)throw new TypeError("missing producerId");if("audio"!==r&&"video"!==r)throw new TypeError(`invalid kind '${r}'`);if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(o&&"object"!=typeof o)throw new TypeError("if given, appData must be an object");const a=Co.clone(n);if(!Ro.canReceive(a,this._extendedRtpCapabilities))throw new ko.UnsupportedError("cannot consume this Producer");const c=new Mo({id:e,producerId:t,kind:r,rtpParameters:a,streamId:i,onRtpReceiver:s,appData:o});return this._pendingConsumerTasks.push(c),(0,wo.default)((()=>{this._closed||!1===this._consumerCreationInProgress&&this.createPendingConsumers()})),c.promise}async produceData({ordered:e=!0,maxPacketLifeTime:t,maxRetransmits:r,label:n="",protocol:i="",appData:s={}}={}){if(Io.debug("produceData()"),this._closed)throw new ko.InvalidStateError("closed");if("send"!==this._direction)throw new ko.UnsupportedError("not a sending Transport");if(!this._maxSctpMessageSize)throw new ko.UnsupportedError("SCTP not enabled by remote Transport");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(0===this.listenerCount("producedata"))throw new TypeError('no "producedata" listener set into this transport');if(s&&"object"!=typeof s)throw new TypeError("if given, appData must be an object");return(t||r)&&(e=!1),this._awaitQueue.push((async()=>{const{dataChannel:o,sctpStreamParameters:a}=await this._handler.sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i});Ro.validateSctpStreamParameters(a);const{id:c}=await new Promise(((e,t)=>{this.safeEmit("producedata",{sctpStreamParameters:a,label:n,protocol:i,appData:s},e,t)})),d=new Eo.DataProducer({id:c,dataChannel:o,sctpStreamParameters:a,appData:s});return this._dataProducers.set(d.id,d),this.handleDataProducer(d),this._observer.safeEmit("newdataproducer",d),d}),"transport.produceData()")}async consumeData({id:e,dataProducerId:t,sctpStreamParameters:r,label:n="",protocol:i="",appData:s={}}){if(Io.debug("consumeData()"),this._closed)throw new ko.InvalidStateError("closed");if("recv"!==this._direction)throw new ko.UnsupportedError("not a receiving Transport");if(!this._maxSctpMessageSize)throw new ko.UnsupportedError("SCTP not enabled by remote Transport");if("string"!=typeof e)throw new TypeError("missing id");if("string"!=typeof t)throw new TypeError("missing dataProducerId");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(s&&"object"!=typeof s)throw new TypeError("if given, appData must be an object");const o=Co.clone(r);return Ro.validateSctpStreamParameters(o),this._awaitQueue.push((async()=>{const{dataChannel:r}=await this._handler.receiveDataChannel({sctpStreamParameters:o,label:n,protocol:i}),a=new Do.DataConsumer({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:o,appData:s});return this._dataConsumers.set(a.id,a),this.handleDataConsumer(a),this._observer.safeEmit("newdataconsumer",a),a}),"transport.consumeData()")}async createPendingConsumers(){this._consumerCreationInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingConsumerTasks.length)return void Io.debug("createPendingConsumers() | there is no Consumer to be created");const e=[...this._pendingConsumerTasks];let t;this._pendingConsumerTasks=[];const r=[];for(const t of e){const{id:e,kind:n,rtpParameters:i,streamId:s,onRtpReceiver:o}=t.consumerOptions;r.push({trackId:e,kind:n,rtpParameters:i,streamId:s,onRtpReceiver:o})}try{const n=await this._handler.receive(r);for(let r=0;r<n.length;++r){const i=e[r],s=n[r],{id:o,producerId:a,kind:c,rtpParameters:d,appData:u}=i.consumerOptions,{localId:l,rtpReceiver:p,track:h}=s,f=new To.Consumer({id:o,localId:l,producerId:a,rtpReceiver:p,track:h,rtpParameters:d,appData:u});this._consumers.set(f.id,f),this.handleConsumer(f),this._probatorConsumerCreated||t||"video"!==c||(t=f),this._observer.safeEmit("newconsumer",f),i.resolve(f)}}catch(t){for(const r of e)r.reject(t)}if(t)try{const e=Ro.generateProbatorRtpParameters(t.rtpParameters);await this._handler.receive([{trackId:"probator",kind:"video",rtpParameters:e}]),Io.debug("createPendingConsumers() | Consumer for RTP probation created"),this._probatorConsumerCreated=!0}catch(e){Io.error("createPendingConsumers() | failed to create Consumer for RTP probation:%o",e)}}),"transport.createPendingConsumers()").then((()=>{this._consumerCreationInProgress=!1,this._pendingConsumerTasks.length>0&&this.createPendingConsumers()})).catch((()=>{}))}pausePendingConsumers(){this._consumerPauseInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingPauseConsumers.size)return void Io.debug("pausePendingConsumers() | there is no Consumer to be paused");const e=Array.from(this._pendingPauseConsumers.values());this._pendingPauseConsumers.clear();try{const t=e.map((e=>e.localId));await this._handler.pauseReceiving(t)}catch(e){Io.error("pausePendingConsumers() | failed to pause Consumers:",e)}}),"transport.pausePendingConsumers").then((()=>{this._consumerPauseInProgress=!1,this._pendingPauseConsumers.size>0&&this.pausePendingConsumers()})).catch((()=>{}))}resumePendingConsumers(){this._consumerResumeInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingResumeConsumers.size)return void Io.debug("resumePendingConsumers() | there is no Consumer to be resumed");const e=Array.from(this._pendingResumeConsumers.values());this._pendingResumeConsumers.clear();try{const t=e.map((e=>e.localId));await this._handler.resumeReceiving(t)}catch(e){Io.error("resumePendingConsumers() | failed to resume Consumers:",e)}}),"transport.resumePendingConsumers").then((()=>{this._consumerResumeInProgress=!1,this._pendingResumeConsumers.size>0&&this.resumePendingConsumers()})).catch((()=>{}))}closePendingConsumers(){this._consumerCloseInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingCloseConsumers.size)return void Io.debug("closePendingConsumers() | there is no Consumer to be closed");const e=Array.from(this._pendingCloseConsumers.values());this._pendingCloseConsumers.clear();try{await this._handler.stopReceiving(e.map((e=>e.localId)))}catch(e){Io.error("closePendingConsumers() | failed to close Consumers:",e)}}),"transport.closePendingConsumers").then((()=>{this._consumerCloseInProgress=!1,this._pendingCloseConsumers.size>0&&this.closePendingConsumers()})).catch((()=>{}))}handleHandler(){const e=this._handler;e.on("@connect",(({dtlsParameters:e},t,r)=>{this._closed?r(new ko.InvalidStateError("closed")):this.safeEmit("connect",{dtlsParameters:e},t,r)})),e.on("@icegatheringstatechange",(e=>{e!==this._iceGatheringState&&(Io.debug("ICE gathering state changed to %s",e),this._iceGatheringState=e,this._closed||this.safeEmit("icegatheringstatechange",e))})),e.on("@connectionstatechange",(e=>{e!==this._connectionState&&(Io.debug("connection state changed to %s",e),this._connectionState=e,this._closed||this.safeEmit("connectionstatechange",e))}))}handleProducer(e){e.on("@close",(()=>{this._producers.delete(e.id),this._closed||this._awaitQueue.push((async()=>await this._handler.stopSending(e.localId)),"producer @close event").catch((e=>Io.warn("producer.close() failed:%o",e)))})),e.on("@pause",((t,r)=>{this._awaitQueue.push((async()=>await this._handler.pauseSending(e.localId)),"producer @pause event").then(t).catch(r)})),e.on("@resume",((t,r)=>{this._awaitQueue.push((async()=>await this._handler.resumeSending(e.localId)),"producer @resume event").then(t).catch(r)})),e.on("@replacetrack",((t,r,n)=>{this._awaitQueue.push((async()=>await this._handler.replaceTrack(e.localId,t)),"producer @replacetrack event").then(r).catch(n)})),e.on("@setmaxspatiallayer",((t,r,n)=>{this._awaitQueue.push((async()=>await this._handler.setMaxSpatialLayer(e.localId,t)),"producer @setmaxspatiallayer event").then(r).catch(n)})),e.on("@setrtpencodingparameters",((t,r,n)=>{this._awaitQueue.push((async()=>await this._handler.setRtpEncodingParameters(e.localId,t)),"producer @setrtpencodingparameters event").then(r).catch(n)})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new ko.InvalidStateError("closed"));this._handler.getSenderStats(e.localId).then(t).catch(r)}))}handleConsumer(e){e.on("@close",(()=>{this._consumers.delete(e.id),this._pendingPauseConsumers.delete(e.id),this._pendingResumeConsumers.delete(e.id),this._closed||(this._pendingCloseConsumers.set(e.id,e),!1===this._consumerCloseInProgress&&this.closePendingConsumers())})),e.on("@pause",(()=>{this._pendingResumeConsumers.has(e.id)&&this._pendingResumeConsumers.delete(e.id),this._pendingPauseConsumers.set(e.id,e),(0,wo.default)((()=>{this._closed||!1===this._consumerPauseInProgress&&this.pausePendingConsumers()}))})),e.on("@resume",(()=>{this._pendingPauseConsumers.has(e.id)&&this._pendingPauseConsumers.delete(e.id),this._pendingResumeConsumers.set(e.id,e),(0,wo.default)((()=>{this._closed||!1===this._consumerResumeInProgress&&this.resumePendingConsumers()}))})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new ko.InvalidStateError("closed"));this._handler.getReceiverStats(e.localId).then(t).catch(r)}))}handleDataProducer(e){e.on("@close",(()=>{this._dataProducers.delete(e.id)}))}handleDataConsumer(e){e.on("@close",(()=>{this._dataConsumers.delete(e.id)}))}}Ds.Transport=xo;var Oo={},Lo={},Ao={},jo={exports:{}},Fo=jo.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(Fo).forEach((function(e){Fo[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var s=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var s=0;s<n.length;s+=1)null!=e[s+1]&&(r[n[s]]=t(e[s+1]))}(n.match(e.reg),s,e.names,e.name),e.push&&r[e.push].push(s)},n=jo.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},s=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(s.push({rtp:[],fmtp:[]}),o=s[s.length-1]);for(var a=0;a<(n[t]||[]).length;a+=1){var c=n[t][a];if(c.reg.test(i))return r(c,o,i)}})),t.media=s,t};var s=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(s,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],n=e.split(" ").map(t),i=0;i<n.length;i+=3)r.push({component:n[i],ip:n[i+1],port:n[i+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(s,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(Ao);var No=jo.exports,Bo=/%[sdv%]/g,Wo=function(e){var t=1,r=arguments,n=r.length;return e.replace(Bo,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},qo=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var s=t.names[i];t.name?n.push(r[t.name][s]):n.push(r[t.names[i]])}else n.push(r[t.name]);return Wo.apply(null,n)},Uo=["v","o","s","i","u","e","p","c","b","t","r","z","a"],zo=["i","c","b","a"],Vo=Ao,Ho=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||Uo,n=t.innerOrder||zo,i=[];return r.forEach((function(t){No[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(qo(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(qo(t,r,e))}))}))})),e.media.forEach((function(e){i.push(qo("m",No.m[0],e)),n.forEach((function(t){No[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(qo(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(qo(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"},$o=jo.exports;Lo.grammar=$o,Lo.write=Ho,Lo.parse=Vo.parse,Lo.parseParams=Vo.parseParams,Lo.parseFmtpConfig=Vo.parseFmtpConfig,Lo.parsePayloads=Vo.parsePayloads,Lo.parseRemoteCandidates=Vo.parseRemoteCandidates,Lo.parseImageAttributes=Vo.parseImageAttributes,Lo.parseSimulcastStreamList=Vo.parseSimulcastStreamList;var Ko={},Go=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Qo=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Jo=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Go(r,t,n[i]);return Qo(r,t),r}}();Object.defineProperty(Ko,"__esModule",{value:!0}),Ko.extractRtpCapabilities=function({sdpObject:e}){const t=new Map,r=[];let n=!1,i=!1;for(const s of e.media){const e=s.type;switch(e){case"audio":if(n)continue;n=!0;break;case"video":if(i)continue;i=!0;break;default:continue}for(const r of s.rtp){const n={kind:e,mimeType:`${e}/${r.codec}`,preferredPayloadType:r.payload,clockRate:r.rate,channels:r.encoding,parameters:{},rtcpFeedback:[]};t.set(n.preferredPayloadType,n)}for(const e of s.fmtp||[]){const r=Yo.parseParams(e.config),n=t.get(e.payload);n&&(r?.hasOwnProperty("profile-level-id")&&(r["profile-level-id"]=String(r["profile-level-id"])),n.parameters=r)}for(const r of s.rtcpFb||[]){const n={type:r.type,parameter:r.subtype};if(n.parameter||delete n.parameter,"*"!==r.payload){const e=t.get(r.payload);if(!e)continue;e.rtcpFeedback.push(n)}else for(const r of t.values())r.kind!==e||/.+\/rtx$/i.test(r.mimeType)||r.rtcpFeedback.push(n)}for(const t of s.ext||[]){if(t["encrypt-uri"])continue;const n={kind:e,uri:t.uri,preferredId:t.value};r.push(n)}}return{codecs:Array.from(t.values()),headerExtensions:r}},Ko.extractDtlsParameters=function({sdpObject:e}){let t,r=e.setup,n=e.fingerprint;if(!r||!n){const t=(e.media||[]).find((e=>0!==e.port));t&&(r??(r=t.setup),n??(n=t.fingerprint))}if(!r)throw new Error("no a=setup found at SDP session or media level");if(!n)throw new Error("no a=fingerprint found at SDP session or media level");switch(r){case"active":t="client";break;case"passive":t="server";break;case"actpass":t="auto"}return{role:t,fingerprints:[{algorithm:n.type,value:n.hash}]}},Ko.getCname=function({offerMediaObject:e}){const t=(e.ssrcs||[]).find((e=>"cname"===e.attribute));if(!t)return"";return t.value},Ko.applyCodecParameters=function({offerRtpParameters:e,answerMediaObject:t}){for(const r of e.codecs){const e=r.mimeType.toLowerCase();if("audio/opus"!==e)continue;const n=(t.rtp||[]).find((e=>e.payload===r.payloadType));if(!n)continue;t.fmtp=t.fmtp||[];let i=t.fmtp.find((e=>e.payload===r.payloadType));i||(i={payload:r.payloadType,config:""},t.fmtp.push(i));const s=Yo.parseParams(i.config);switch(e){case"audio/opus":{const e=r.parameters["sprop-stereo"];void 0!==e&&(s.stereo=Number(e)?1:0);break}}i.config="";for(const e of Object.keys(s))i.config&&(i.config+=";"),i.config+=`${e}=${s[e]}`}};const Yo=Jo(Lo);var Zo={};Object.defineProperty(Zo,"__esModule",{value:!0}),Zo.getRtpEncodings=function({offerMediaObject:e}){const t=new Set;for(const r of e.ssrcs||[]){const e=r.id;t.add(e)}if(0===t.size)throw new Error("no a=ssrc lines found");const r=new Map;for(const n of e.ssrcGroups||[]){if("FID"!==n.semantics)continue;let[e,i]=n.ssrcs.split(/\s+/);e=Number(e),i=Number(i),t.has(e)&&(t.delete(e),t.delete(i),r.set(e,i))}for(const e of t)r.set(e,null);const n=[];for(const[e,t]of r){const r={ssrc:e};t&&(r.rtx={ssrc:t}),n.push(r)}return n},Zo.addLegacySimulcast=function({offerMediaObject:e,numStreams:t}){if(t<=1)throw new TypeError("numStreams must be greater than 1");const r=(e.ssrcs||[]).find((e=>"msid"===e.attribute));if(!r)throw new Error("a=ssrc line with msid information not found");const[n,i]=r.value.split(" "),s=Number(r.id);let o;(e.ssrcGroups||[]).some((e=>{if("FID"!==e.semantics)return!1;const t=e.ssrcs.split(/\s+/);return Number(t[0])===s&&(o=Number(t[1]),!0)}));const a=e.ssrcs.find((e=>"cname"===e.attribute));if(!a)throw new Error("a=ssrc line with cname information not found");const c=a.value,d=[],u=[];for(let e=0;e<t;++e)d.push(s+e),o&&u.push(o+e);e.ssrcGroups=[],e.ssrcs=[],e.ssrcGroups.push({semantics:"SIM",ssrcs:d.join(" ")});for(const t of d)e.ssrcs.push({id:t,attribute:"cname",value:c}),e.ssrcs.push({id:t,attribute:"msid",value:`${n} ${i}`});for(let t=0;t<u.length;++t){const r=d[t],s=u[t];e.ssrcs.push({id:s,attribute:"cname",value:c}),e.ssrcs.push({id:s,attribute:"msid",value:`${n} ${i}`}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${r} ${s}`})}};var Xo={};Object.defineProperty(Xo,"__esModule",{value:!0}),Xo.addNackSuppportForOpus=function(e){for(const t of e.codecs??[])"audio/opus"!==t.mimeType.toLowerCase()&&"audio/multiopus"!==t.mimeType.toLowerCase()||t.rtcpFeedback?.some((e=>"nack"===e.type&&!e.parameter))||(t.rtcpFeedback||(t.rtcpFeedback=[]),t.rtcpFeedback.push({type:"nack"}))};var ea={};Object.defineProperty(ea,"__esModule",{value:!0}),ea.HandlerInterface=void 0;const ta=yi;class ra extends ta.EnhancedEventEmitter{constructor(){super()}}ea.HandlerInterface=ra;var na={},ia={},sa=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),oa=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),aa=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&sa(r,t,n[i]);return oa(r,t),r}}();Object.defineProperty(ia,"__esModule",{value:!0}),ia.OfferMediaSection=ia.AnswerMediaSection=ia.MediaSection=void 0;const ca=aa(Lo),da=aa(Fi);class ua{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:n=!1}){if(this._mediaObject={},this._planB=n,e&&this.setIceParameters(e),t){this._mediaObject.candidates=[];for(const e of t){const t={component:1};t.foundation=e.foundation,t.ip=e.address??e.ip,t.port=e.port,t.priority=e.priority,t.transport=e.protocol,t.type=e.type,e.tcpType&&(t.tcptype=e.tcpType),this._mediaObject.candidates.push(t)}this._mediaObject.endOfCandidates="end-of-candidates",this._mediaObject.iceOptions="renomination"}r&&this.setDtlsRole(r.role)}get mid(){return String(this._mediaObject.mid)}get closed(){return 0===this._mediaObject.port}getObject(){return this._mediaObject}setIceParameters(e){this._mediaObject.iceUfrag=e.usernameFragment,this._mediaObject.icePwd=e.password}pause(){this._mediaObject.direction="inactive"}disable(){this.pause(),delete this._mediaObject.ext,delete this._mediaObject.ssrcs,delete this._mediaObject.ssrcGroups,delete this._mediaObject.simulcast,delete this._mediaObject.simulcast_03,delete this._mediaObject.rids,delete this._mediaObject.extmapAllowMixed}close(){this.disable(),this._mediaObject.port=0}}ia.MediaSection=ua;ia.AnswerMediaSection=class extends ua{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,planB:s=!1,offerMediaObject:o,offerRtpParameters:a,answerRtpParameters:c,codecOptions:d,extmapAllowMixed:u=!1}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:s}),this._mediaObject.mid=String(o.mid),this._mediaObject.type=o.type,this._mediaObject.protocol=o.protocol,i?(this._mediaObject.connection={ip:i.ip,version:i.ipVersion},this._mediaObject.port=i.port):(this._mediaObject.connection={ip:"127.0.0.1",version:4},this._mediaObject.port=7),o.type){case"audio":case"video":this._mediaObject.direction="recvonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[];for(const e of c.codecs){const t={payload:e.payloadType,codec:la(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r=da.clone(e.parameters)??{};let n=da.clone(e.rtcpFeedback)??[];if(d){const{opusStereo:t,opusFec:i,opusDtx:s,opusMaxPlaybackRate:o,opusMaxAverageBitrate:c,opusPtime:u,opusNack:l,videoGoogleStartBitrate:p,videoGoogleMaxBitrate:h,videoGoogleMinBitrate:f}=d,m=a.codecs.find((t=>t.payloadType===e.payloadType));switch(e.mimeType.toLowerCase()){case"audio/opus":case"audio/multiopus":void 0!==t&&(m.parameters["sprop-stereo"]=t?1:0,r.stereo=t?1:0),void 0!==i&&(m.parameters.useinbandfec=i?1:0,r.useinbandfec=i?1:0),void 0!==s&&(m.parameters.usedtx=s?1:0,r.usedtx=s?1:0),void 0!==o&&(r.maxplaybackrate=o),void 0!==c&&(r.maxaveragebitrate=c),void 0!==u&&(m.parameters.ptime=u,r.ptime=u),l||(m.rtcpFeedback=m.rtcpFeedback.filter((e=>"nack"!==e.type||e.parameter)),n=n.filter((e=>"nack"!==e.type||e.parameter)));break;case"video/vp8":case"video/vp9":case"video/h264":case"video/h265":void 0!==p&&(r["x-google-start-bitrate"]=p),void 0!==h&&(r["x-google-max-bitrate"]=h),void 0!==f&&(r["x-google-min-bitrate"]=f)}}const i={payload:e.payloadType,config:""};for(const e of Object.keys(r))i.config&&(i.config+=";"),i.config+=`${e}=${r[e]}`;i.config&&this._mediaObject.fmtp.push(i);for(const t of n)this._mediaObject.rtcpFb.push({payload:e.payloadType,type:t.type,subtype:t.parameter})}this._mediaObject.payloads=c.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of c.headerExtensions){(o.ext??[]).some((t=>t.uri===e.uri))&&this._mediaObject.ext.push({uri:e.uri,value:e.id})}if(u&&"extmap-allow-mixed"===o.extmapAllowMixed&&(this._mediaObject.extmapAllowMixed="extmap-allow-mixed"),o.simulcast){this._mediaObject.simulcast={dir1:"recv",list1:o.simulcast.list1},this._mediaObject.rids=[];for(const e of o.rids??[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}else if(o.simulcast_03){this._mediaObject.simulcast_03={value:o.simulcast_03.value.replace(/send/g,"recv")},this._mediaObject.rids=[];for(const e of o.rids??[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize",this._planB&&"video"===this._mediaObject.type&&(this._mediaObject.xGoogleFlag="conference");break;case"application":"number"==typeof o.sctpPort?(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=n.port,this._mediaObject.maxMessageSize=n.maxMessageSize):o.sctpmap&&(this._mediaObject.payloads=n.port,this._mediaObject.sctpmap={app:"webrtc-datachannel",sctpmapNumber:n.port,maxMessageSize:n.maxMessageSize})}}setDtlsRole(e){switch(e){case"client":this._mediaObject.setup="active";break;case"server":this._mediaObject.setup="passive";break;case"auto":this._mediaObject.setup="actpass"}}resume(){this._mediaObject.direction="recvonly"}muxSimulcastStreams(e){if(!this._mediaObject.simulcast?.list1)return;const t={};for(const r of e)r.rid&&(t[r.rid]=r);const r=this._mediaObject.simulcast.list1,n=ca.parseSimulcastStreamList(r);for(const e of n)for(const r of e)r.paused=!t[r.scid]?.active;this._mediaObject.simulcast.list1=n.map((e=>e.map((e=>`${e.paused?"~":""}${e.scid}`)).join(","))).join(";")}};function la(e){const t=new RegExp("^(audio|video)/(.+)","i").exec(e.mimeType);if(!t)throw new TypeError("invalid codec.mimeType");return t[2]}ia.OfferMediaSection=class extends ua{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,planB:s=!1,mid:o,kind:a,offerRtpParameters:c,streamId:d,trackId:u,oldDataChannelSpec:l=!1}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:s}),this._mediaObject.mid=String(o),this._mediaObject.type=a,i?(this._mediaObject.connection={ip:i.ip,version:i.ipVersion},this._mediaObject.protocol="RTP/AVP",this._mediaObject.port=i.port):(this._mediaObject.connection={ip:"127.0.0.1",version:4},this._mediaObject.protocol=n?"UDP/DTLS/SCTP":"UDP/TLS/RTP/SAVPF",this._mediaObject.port=7),a){case"audio":case"video":{this._mediaObject.direction="sendonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[],this._planB||(this._mediaObject.msid=`${d??"-"} ${u}`);for(const e of c.codecs){const t={payload:e.payloadType,codec:la(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r={payload:e.payloadType,config:""};for(const t of Object.keys(e.parameters))r.config&&(r.config+=";"),r.config+=`${t}=${e.parameters[t]}`;r.config&&this._mediaObject.fmtp.push(r);for(const t of e.rtcpFeedback)this._mediaObject.rtcpFb.push({payload:e.payloadType,type:t.type,subtype:t.parameter})}this._mediaObject.payloads=c.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of c.headerExtensions)this._mediaObject.ext.push({uri:e.uri,value:e.id});this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize";const e=c.encodings[0],t=e.ssrc,r=e.rtx?.ssrc;this._mediaObject.ssrcs=[],this._mediaObject.ssrcGroups=[],c.rtcp.cname&&this._mediaObject.ssrcs.push({id:t,attribute:"cname",value:c.rtcp.cname}),this._planB&&this._mediaObject.ssrcs.push({id:t,attribute:"msid",value:`${d??"-"} ${u}`}),r&&(c.rtcp.cname&&this._mediaObject.ssrcs.push({id:r,attribute:"cname",value:c.rtcp.cname}),this._planB&&this._mediaObject.ssrcs.push({id:r,attribute:"msid",value:`${d??"-"} ${u}`}),this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}));break}case"application":l?(this._mediaObject.payloads=n.port,this._mediaObject.sctpmap={app:"webrtc-datachannel",sctpmapNumber:n.port,maxMessageSize:n.maxMessageSize}):(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=n.port,this._mediaObject.maxMessageSize=n.maxMessageSize)}}setDtlsRole(e){this._mediaObject.setup="actpass"}resume(){this._mediaObject.direction="sendonly"}planBReceive({offerRtpParameters:e,streamId:t,trackId:r}){const n=e.encodings[0],i=n.ssrc,s=n.rtx?.ssrc,o=this._mediaObject.payloads.split(" ");for(const t of e.codecs){if(o.includes(String(t.payloadType)))continue;const e={payload:t.payloadType,codec:la(t),rate:t.clockRate};t.channels>1&&(e.encoding=t.channels),this._mediaObject.rtp.push(e);const r={payload:t.payloadType,config:""};for(const e of Object.keys(t.parameters))r.config&&(r.config+=";"),r.config+=`${e}=${t.parameters[e]}`;r.config&&this._mediaObject.fmtp.push(r);for(const e of t.rtcpFeedback)this._mediaObject.rtcpFb.push({payload:t.payloadType,type:e.type,subtype:e.parameter})}this._mediaObject.payloads+=` ${e.codecs.filter((e=>!this._mediaObject.payloads.includes(e.payloadType))).map((e=>e.payloadType)).join(" ")}`,this._mediaObject.payloads=this._mediaObject.payloads.trim(),e.rtcp.cname&&this._mediaObject.ssrcs.push({id:i,attribute:"cname",value:e.rtcp.cname}),this._mediaObject.ssrcs.push({id:i,attribute:"msid",value:`${t??"-"} ${r}`}),s&&(e.rtcp.cname&&this._mediaObject.ssrcs.push({id:s,attribute:"cname",value:e.rtcp.cname}),this._mediaObject.ssrcs.push({id:s,attribute:"msid",value:`${t??"-"} ${r}`}),this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${i} ${s}`}))}planBStopReceiving({offerRtpParameters:e}){const t=e.encodings[0],r=t.ssrc,n=t.rtx?.ssrc;this._mediaObject.ssrcs=this._mediaObject.ssrcs.filter((e=>e.id!==r&&e.id!==n)),n&&(this._mediaObject.ssrcGroups=this._mediaObject.ssrcGroups.filter((e=>e.ssrcs!==`${r} ${n}`)))}};var pa=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),ha=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),fa=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&pa(r,t,n[i]);return ha(r,t),r}}();Object.defineProperty(na,"__esModule",{value:!0}),na.RemoteSdp=void 0;const ma=fa(Lo),ga=ia,va=new hi.Logger("RemoteSdp");na.RemoteSdp=class{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,planB:s=!1}){if(this._mediaSections=[],this._midToIndex=new Map,this._iceParameters=e,this._iceCandidates=t,this._dtlsParameters=r,this._sctpParameters=n,this._plainRtpParameters=i,this._planB=s,this._sdpObject={version:0,origin:{address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:1e4,sessionVersion:0,username:"mediasoup-client"},name:"-",timing:{start:0,stop:0},media:[]},e?.iceLite&&(this._sdpObject.icelite="ice-lite"),r){this._sdpObject.msidSemantic={semantic:"WMS",token:"*"};const e=this._dtlsParameters.fingerprints.length;this._sdpObject.fingerprint={type:r.fingerprints[e-1].algorithm,hash:r.fingerprints[e-1].value},this._sdpObject.groups=[{type:"BUNDLE",mids:""}]}i&&(this._sdpObject.origin.address=i.ip,this._sdpObject.origin.ipVer=i.ipVersion)}updateIceParameters(e){va.debug("updateIceParameters() [iceParameters:%o]",e),this._iceParameters=e,this._sdpObject.icelite=e.iceLite?"ice-lite":void 0;for(const t of this._mediaSections)t.setIceParameters(e)}updateDtlsRole(e){va.debug("updateDtlsRole() [role:%s]",e),this._dtlsParameters.role=e;for(const t of this._mediaSections)t.setDtlsRole(e)}getNextMediaSectionIdx(){for(let e=0;e<this._mediaSections.length;++e){const t=this._mediaSections[e];if(t.closed)return{idx:e,reuseMid:t.mid}}return{idx:this._mediaSections.length}}send({offerMediaObject:e,reuseMid:t,offerRtpParameters:r,answerRtpParameters:n,codecOptions:i,extmapAllowMixed:s=!1}){const o=new ga.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,planB:this._planB,offerMediaObject:e,offerRtpParameters:r,answerRtpParameters:n,codecOptions:i,extmapAllowMixed:s});t?this._replaceMediaSection(o,t):this._midToIndex.has(o.mid)?this._replaceMediaSection(o):this._addMediaSection(o)}receive({mid:e,kind:t,offerRtpParameters:r,streamId:n,trackId:i}){const s=this._midToIndex.get(e);let o;if(void 0!==s&&(o=this._mediaSections[s]),o)o.planBReceive({offerRtpParameters:r,streamId:n,trackId:i}),this._replaceMediaSection(o);else{o=new ga.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,planB:this._planB,mid:e,kind:t,offerRtpParameters:r,streamId:n,trackId:i});const s=this._mediaSections.find((e=>e.closed));s?this._replaceMediaSection(o,s.mid):this._addMediaSection(o)}}pauseMediaSection(e){this._findMediaSection(e).pause()}resumeSendingMediaSection(e){this._findMediaSection(e).resume()}resumeReceivingMediaSection(e){this._findMediaSection(e).resume()}disableMediaSection(e){this._findMediaSection(e).disable()}closeMediaSection(e){const t=this._findMediaSection(e);return e===this._firstMid?(va.debug("closeMediaSection() | cannot close first media section, disabling it instead [mid:%s]",e),this.disableMediaSection(e),!1):(t.close(),this._regenerateBundleMids(),!0)}muxMediaSectionSimulcast(e,t){const r=this._findMediaSection(e);r.muxSimulcastStreams(t),this._replaceMediaSection(r)}planBStopReceiving({mid:e,offerRtpParameters:t}){const r=this._findMediaSection(e);r.planBStopReceiving({offerRtpParameters:t}),this._replaceMediaSection(r)}sendSctpAssociation({offerMediaObject:e}){const t=new ga.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,offerMediaObject:e});this._addMediaSection(t)}receiveSctpAssociation({oldDataChannelSpec:e=!1}={}){const t=new ga.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,mid:"datachannel",kind:"application",oldDataChannelSpec:e});this._addMediaSection(t)}getSdp(){return this._sdpObject.origin.sessionVersion++,ma.write(this._sdpObject)}_addMediaSection(e){this._firstMid||(this._firstMid=e.mid),this._mediaSections.push(e),this._midToIndex.set(e.mid,this._mediaSections.length-1),this._sdpObject.media.push(e.getObject()),this._regenerateBundleMids()}_replaceMediaSection(e,t){if("string"==typeof t){const r=this._midToIndex.get(t);if(void 0===r)throw new Error(`no media section found for reuseMid '${t}'`);const n=this._mediaSections[r];this._mediaSections[r]=e,this._midToIndex.delete(n.mid),this._midToIndex.set(e.mid,r),this._sdpObject.media[r]=e.getObject(),this._regenerateBundleMids()}else{const t=this._midToIndex.get(e.mid);if(void 0===t)throw new Error(`no media section found with mid '${e.mid}'`);this._mediaSections[t]=e,this._sdpObject.media[t]=e.getObject()}}_findMediaSection(e){const t=this._midToIndex.get(e);if(void 0===t)throw new Error(`no media section found with mid '${e}'`);return this._mediaSections[t]}_regenerateBundleMids(){this._dtlsParameters&&(this._sdpObject.groups[0].mids=this._mediaSections.filter((e=>!e.closed)).map((e=>e.mid)).join(" "))}};var ya={};Object.defineProperty(ya,"__esModule",{value:!0}),ya.parse=function(e){const t=ba.exec(e??"");return t?{spatialLayers:Number(t[1]),temporalLayers:Number(t[2])}:{spatialLayers:1,temporalLayers:1}};const ba=new RegExp("^[LS]([1-9]\\d{0,1})T([1-9]\\d{0,1})");var wa=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),_a=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Sa=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&wa(r,t,n[i]);return _a(r,t),r}}();Object.defineProperty(Oo,"__esModule",{value:!0}),Oo.Chrome111=void 0;const ka=Sa(Lo),Ca=hi,Ra=Sa(Fi),Pa=Sa(Ni),Ta=Sa(Ko),Ea=Sa(Zo),Da=Sa(Xo),Ia=ir,Ma=ea,xa=na,Oa=ya,La=new Ca.Logger("Chrome111"),Aa={OS:1024,MIS:1024};class ja extends Ma.HandlerInterface{static createFactory(){return()=>new ja}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome111"}close(){if(La.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){La.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=ka.parse(t.sdp),n=Ta.extractRtpCapabilities({sdpObject:r});return Da.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return La.debug("getNativeSctpCapabilities()"),{numStreams:Aa}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),La.debug("run()"),this._direction=e,this._remoteSdp=new xa.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Pa.getSendingRtpParameters("audio",d),video:Pa.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Pa.getSendingRemoteRtpParameters("audio",d),video:Pa.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):(La.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})))}async updateIceServers(e){this.assertNotClosed(),La.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),La.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});La.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};La.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};La.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();La.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){if(this.assertNotClosed(),this.assertSendDirection(),La.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1){let e=1;for(const r of t){const t=r.scalabilityMode?(0,Oa.parse)(r.scalabilityMode).temporalLayers:3;t>e&&(e=t)}t.forEach(((t,r)=>{t.rid=`r${r}`,t.scalabilityMode=`L1T${e}`}))}const s=Ra.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Pa.reduceCodecs(s.codecs,n);const o=Ra.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Pa.reduceCodecs(o.codecs,n);const a=this._remoteSdp.getNextMediaSectionIdx(),c=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(c.sender);const d=await this._pc.createOffer();let u=ka.parse(d.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u}),La.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d);const l=c.mid;s.mid=l,u=ka.parse(this._pc.localDescription.sdp);const p=u.media[a.idx];if(s.rtcp.cname=Ta.getCname({offerMediaObject:p}),t)if(1===t.length){const e=Ea.getRtpEncodings({offerMediaObject:p});Object.assign(e[0],t[0]),s.encodings=e}else s.encodings=t;else s.encodings=Ea.getRtpEncodings({offerMediaObject:p});this._remoteSdp.send({offerMediaObject:p,reuseMid:a.reuseMid,offerRtpParameters:s,answerRtpParameters:o,codecOptions:r,extmapAllowMixed:!0});const h={type:"answer",sdp:this._remoteSdp.getSdp()};return La.debug("send() | calling pc.setRemoteDescription() [answer:%o]",h),await this._pc.setRemoteDescription(h),this._mapMidTransceiver.set(l,c),{localId:l,rtpParameters:s,rtpSender:c.sender}}async stopSending(e){if(this.assertSendDirection(),La.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();La.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};La.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),La.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();La.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};La.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),La.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();La.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};La.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?La.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):La.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),La.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();La.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};La.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),La.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();La.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};La.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};La.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Aa.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=ka.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),La.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};La.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;La.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};La.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=ka.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Ta.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:ka.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),La.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){La.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};La.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();La.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){La.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};La.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();La.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){La.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};La.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();La.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};La.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};La.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=ka.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}La.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=ka.parse(this._pc.localDescription.sdp));const r=Ta.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new Ia.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Oo.Chrome111=ja;var Fa={},Na=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Ba=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Wa=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Na(r,t,n[i]);return Ba(r,t),r}}();Object.defineProperty(Fa,"__esModule",{value:!0}),Fa.Chrome74=void 0;const qa=Wa(Lo),Ua=hi,za=Wa(Fi),Va=Wa(Ni),Ha=Wa(Ko),$a=Wa(Zo),Ka=Wa(Xo),Ga=ir,Qa=ea,Ja=na,Ya=ya,Za=new Ua.Logger("Chrome74"),Xa={OS:1024,MIS:1024};class ec extends Qa.HandlerInterface{static createFactory(){return()=>new ec}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome74"}close(){if(Za.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){Za.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=qa.parse(t.sdp),n=Ha.extractRtpCapabilities({sdpObject:r});return Ka.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Za.debug("getNativeSctpCapabilities()"),{numStreams:Xa}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Za.debug("run()"),this._direction=e,this._remoteSdp=new Ja.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Va.getSendingRtpParameters("audio",d),video:Va.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Va.getSendingRemoteRtpParameters("audio",d),video:Va.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):(Za.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})))}async updateIceServers(e){this.assertNotClosed(),Za.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Za.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Za.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Za.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Za.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Za.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertNotClosed(),this.assertSendDirection(),Za.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const i=za.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=Va.reduceCodecs(i.codecs,n);const s=za.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=Va.reduceCodecs(s.codecs,n);const o=this._remoteSdp.getNextMediaSectionIdx(),a=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});let c,d=await this._pc.createOffer(),u=qa.parse(d.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u});let l=!1;const p=(0,Ya.parse)((t??[{}])[0].scalabilityMode);t&&1===t.length&&p.spatialLayers>1&&"video/vp9"===i.codecs[0].mimeType.toLowerCase()&&(Za.debug("send() | enabling legacy simulcast for VP9 SVC"),l=!0,u=qa.parse(d.sdp),c=u.media[o.idx],$a.addLegacySimulcast({offerMediaObject:c,numStreams:p.spatialLayers}),d={type:"offer",sdp:qa.write(u)}),Za.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d);const h=a.mid;if(i.mid=h,u=qa.parse(this._pc.localDescription.sdp),c=u.media[o.idx],i.rtcp.cname=Ha.getCname({offerMediaObject:c}),t)if(1===t.length){let e=$a.getRtpEncodings({offerMediaObject:c});Object.assign(e[0],t[0]),l&&(e=[e[0]]),i.encodings=e}else i.encodings=t;else i.encodings=$a.getRtpEncodings({offerMediaObject:c});if(i.encodings.length>1&&("video/vp8"===i.codecs[0].mimeType.toLowerCase()||"video/h264"===i.codecs[0].mimeType.toLowerCase()))for(const e of i.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${p.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:c,reuseMid:o.reuseMid,offerRtpParameters:i,answerRtpParameters:s,codecOptions:r,extmapAllowMixed:!0});const f={type:"answer",sdp:this._remoteSdp.getSdp()};return Za.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f),this._mapMidTransceiver.set(h,a),{localId:h,rtpParameters:i,rtpSender:a.sender}}async stopSending(e){if(this.assertSendDirection(),Za.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();Za.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Za.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Za.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();Za.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Za.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Za.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();Za.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Za.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Za.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Za.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),Za.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Za.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Za.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Za.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Za.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Za.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};Za.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Xa.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=qa.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Za.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Za.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;Za.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};Za.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=qa.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Ha.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:qa.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Za.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){Za.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Za.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Za.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Za.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Za.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Za.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Za.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Za.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Za.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};Za.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};Za.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=qa.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Za.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=qa.parse(this._pc.localDescription.sdp));const r=Ha.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new Ga.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Fa.Chrome74=ec;var tc={},rc=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),nc=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ic=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&rc(r,t,n[i]);return nc(r,t),r}}();Object.defineProperty(tc,"__esModule",{value:!0}),tc.Chrome70=void 0;const sc=ic(Lo),oc=hi,ac=ic(Fi),cc=ic(Ni),dc=ic(Ko),uc=ic(Zo),lc=ea,pc=na,hc=ya,fc=new oc.Logger("Chrome70"),mc={OS:1024,MIS:1024};class gc extends lc.HandlerInterface{static createFactory(){return()=>new gc}constructor(){super(),this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome70"}close(){if(fc.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){fc.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=sc.parse(t.sdp);return dc.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return fc.debug("getNativeSctpCapabilities()"),{numStreams:mc}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){fc.debug("run()"),this._direction=e,this._remoteSdp=new pc.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:cc.getSendingRtpParameters("audio",d),video:cc.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:cc.getSendingRemoteRtpParameters("audio",d),video:cc.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(fc.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){fc.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(fc.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});fc.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};fc.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};fc.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();fc.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),fc.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const i=ac.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=cc.reduceCodecs(i.codecs,n);const s=ac.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=cc.reduceCodecs(s.codecs,n);const o=this._remoteSdp.getNextMediaSectionIdx(),a=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});let c,d=await this._pc.createOffer(),u=sc.parse(d.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u}),t&&t.length>1&&(fc.debug("send() | enabling legacy simulcast"),u=sc.parse(d.sdp),c=u.media[o.idx],uc.addLegacySimulcast({offerMediaObject:c,numStreams:t.length}),d={type:"offer",sdp:sc.write(u)});let l=!1;const p=(0,hc.parse)((t??[{}])[0].scalabilityMode);if(t&&1===t.length&&p.spatialLayers>1&&"video/vp9"===i.codecs[0].mimeType.toLowerCase()&&(fc.debug("send() | enabling legacy simulcast for VP9 SVC"),l=!0,u=sc.parse(d.sdp),c=u.media[o.idx],uc.addLegacySimulcast({offerMediaObject:c,numStreams:p.spatialLayers}),d={type:"offer",sdp:sc.write(u)}),fc.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d),t){fc.debug("send() | applying given encodings");const e=a.sender.getParameters();for(let r=0;r<(e.encodings??[]).length;++r){const n=e.encodings[r],i=t[r];if(!i)break;e.encodings[r]=Object.assign(n,i)}await a.sender.setParameters(e)}const h=a.mid;if(i.mid=h,u=sc.parse(this._pc.localDescription.sdp),c=u.media[o.idx],i.rtcp.cname=dc.getCname({offerMediaObject:c}),i.encodings=uc.getRtpEncodings({offerMediaObject:c}),t)for(let e=0;e<i.encodings.length;++e)t[e]&&Object.assign(i.encodings[e],t[e]);if(l&&(i.encodings=[i.encodings[0]]),i.encodings.length>1&&("video/vp8"===i.codecs[0].mimeType.toLowerCase()||"video/h264"===i.codecs[0].mimeType.toLowerCase()))for(const e of i.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:c,reuseMid:o.reuseMid,offerRtpParameters:i,answerRtpParameters:s,codecOptions:r});const f={type:"answer",sdp:this._remoteSdp.getSdp()};return fc.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f),this._mapMidTransceiver.set(h,a),{localId:h,rtpParameters:i,rtpSender:a.sender}}async stopSending(e){this.assertSendDirection(),fc.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();fc.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};fc.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?fc.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):fc.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),fc.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();fc.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};fc.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),fc.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();fc.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};fc.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:i};fc.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%mc.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=sc.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),fc.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};fc.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;fc.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};fc.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=sc.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));dc.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:sc.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),fc.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){fc.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};fc.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();fc.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmitTime:s,maxRetransmits:o,protocol:r};fc.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};fc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=sc.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}fc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=sc.parse(this._pc.localDescription.sdp));const r=dc.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}tc.Chrome70=gc;var vc={},yc={};Object.defineProperty(yc,"__esModule",{value:!0}),yc.getRtpEncodings=function({offerMediaObject:e,track:t}){const r=new Set;for(const n of e.ssrcs||[]){if("msid"!==n.attribute)continue;if(n.value.split(" ")[1]===t.id){const e=n.id;r.add(e)}}if(0===r.size)throw new Error(`a=ssrc line with msid information not found [track.id:${t.id}]`);const n=new Map;for(const t of e.ssrcGroups||[]){if("FID"!==t.semantics)continue;let[e,i]=t.ssrcs.split(/\s+/);e=Number(e),i=Number(i),r.has(e)&&(r.delete(e),r.delete(i),n.set(e,i))}for(const e of r)n.set(e,null);const i=[];for(const[e,t]of n){const r={ssrc:e};t&&(r.rtx={ssrc:t}),i.push(r)}return i},yc.addLegacySimulcast=function({offerMediaObject:e,track:t,numStreams:r}){if(r<=1)throw new TypeError("numStreams must be greater than 1");let n,i,s;if(!(e.ssrcs||[]).find((e=>{if("msid"!==e.attribute)return!1;return e.value.split(" ")[1]===t.id&&(n=e.id,s=e.value.split(" ")[0],!0)})))throw new Error(`a=ssrc line with msid information not found [track.id:${t.id}]`);(e.ssrcGroups||[]).some((e=>{if("FID"!==e.semantics)return!1;const t=e.ssrcs.split(/\s+/);return Number(t[0])===n&&(i=Number(t[1]),!0)}));const o=e.ssrcs.find((e=>"cname"===e.attribute&&e.id===n));if(!o)throw new Error(`a=ssrc line with cname information not found [track.id:${t.id}]`);const a=o.value,c=[],d=[];for(let e=0;e<r;++e)c.push(n+e),i&&d.push(i+e);e.ssrcGroups=e.ssrcGroups||[],e.ssrcs=e.ssrcs||[],e.ssrcGroups.push({semantics:"SIM",ssrcs:c.join(" ")});for(const r of c)e.ssrcs.push({id:r,attribute:"cname",value:a}),e.ssrcs.push({id:r,attribute:"msid",value:`${s} ${t.id}`});for(let r=0;r<d.length;++r){const n=c[r],i=d[r];e.ssrcs.push({id:i,attribute:"cname",value:a}),e.ssrcs.push({id:i,attribute:"msid",value:`${s} ${t.id}`}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${n} ${i}`})}};var bc=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),wc=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),_c=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&bc(r,t,n[i]);return wc(r,t),r}}();Object.defineProperty(vc,"__esModule",{value:!0}),vc.Chrome67=void 0;const Sc=_c(Lo),kc=hi,Cc=_c(Fi),Rc=_c(Ni),Pc=_c(Ko),Tc=_c(yc),Ec=ea,Dc=na,Ic=new kc.Logger("Chrome67"),Mc={OS:1024,MIS:1024};class xc extends Ec.HandlerInterface{static createFactory(){return()=>new xc}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdRtpSender=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome67"}close(){if(Ic.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){Ic.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=Sc.parse(t.sdp);return Pc.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Ic.debug("getNativeSctpCapabilities()"),{numStreams:Mc}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Ic.debug("run()"),this._direction=e,this._remoteSdp=new Dc.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:Rc.getSendingRtpParameters("audio",d),video:Rc.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Rc.getSendingRemoteRtpParameters("audio",d),video:Rc.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(Ic.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){Ic.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(Ic.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Ic.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Ic.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ic.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Ic.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),Ic.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&Ic.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addTrack(e,this._sendStream);let i,s=await this._pc.createOffer(),o=Sc.parse(s.sdp);const a=Cc.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=Rc.reduceCodecs(a.codecs);const c=Cc.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=Rc.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(Ic.debug("send() | enabling simulcast"),o=Sc.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),Tc.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Sc.write(o)}),Ic.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Sc.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=Pc.getCname({offerMediaObject:i}),a.encodings=Tc.getRtpEncodings({offerMediaObject:i,track:e}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&"video/vp8"===a.codecs[0].mimeType.toLowerCase())for(const e of a.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:i,offerRtpParameters:a,answerRtpParameters:c,codecOptions:r});const d={type:"answer",sdp:this._remoteSdp.getSdp()};Ic.debug("send() | calling pc.setRemoteDescription() [answer:%o]",d),await this._pc.setRemoteDescription(d);const u=String(this._nextSendLocalId);this._nextSendLocalId++;const l=this._pc.getSenders().find((t=>t.track===e));return this._mapSendLocalIdRtpSender.set(u,l),{localId:u,rtpParameters:a,rtpSender:l}}async stopSending(e){this.assertSendDirection(),Ic.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");this._pc.removeTrack(t),t.track&&this._sendStream.removeTrack(t.track),this._mapSendLocalIdRtpSender.delete(e);const r=await this._pc.createOffer();Ic.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void Ic.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ic.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?Ic.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Ic.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.track;await r.replaceTrack(t),n&&this._sendStream.removeTrack(n),t&&this._sendStream.addTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),Ic.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(n)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),Ic.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.setParameters(n)}async getSenderStats(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");return t.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:i};Ic.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Mc.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Sc.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Ic.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ic.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const t of e){const{trackId:e,kind:r,rtpParameters:n,streamId:i}=t;Ic.debug("receive() [trackId:%s, kind:%s]",e,r);const s=r;this._remoteSdp.receive({mid:s,kind:r,offerRtpParameters:n,streamId:i??n.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};Ic.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=Sc.parse(n.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,n=e,s=i.media.find((e=>String(e.mid)===n));Pc.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:Sc.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),Ic.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const r of e){const{kind:e,trackId:n,rtpParameters:i}=r,s=n,o=e,a=this._pc.getReceivers().find((e=>e.track&&e.track.id===s));if(!a)throw new Error("new RTCRtpReceiver not");this._mapRecvLocalIdInfo.set(s,{mid:o,rtpParameters:i,rtpReceiver:a}),t.push({localId:s,track:a.track,rtpReceiver:a})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){Ic.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)??{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Ic.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ic.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){this.assertRecvDirection();const{rtpReceiver:t}=this._mapRecvLocalIdInfo.get(e)??{};if(!t)throw new Error("associated RTCRtpReceiver not found");return t.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmitTime:s,maxRetransmits:o,protocol:r};Ic.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ic.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Sc.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Ic.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Sc.parse(this._pc.localDescription.sdp));const r=Pc.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}vc.Chrome67=xc;var Oc={},Lc=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Ac=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),jc=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Lc(r,t,n[i]);return Ac(r,t),r}}();Object.defineProperty(Oc,"__esModule",{value:!0}),Oc.Chrome55=void 0;const Fc=jc(Lo),Nc=hi,Bc=ir,Wc=jc(Fi),qc=jc(Ni),Uc=jc(Ko),zc=jc(yc),Vc=ea,Hc=na,$c=new Nc.Logger("Chrome55"),Kc={OS:1024,MIS:1024};class Gc extends Vc.HandlerInterface{static createFactory(){return()=>new Gc}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdTrack=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome55"}close(){if($c.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){$c.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=Fc.parse(t.sdp);return Uc.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return $c.debug("getNativeSctpCapabilities()"),{numStreams:Kc}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){$c.debug("run()"),this._direction=e,this._remoteSdp=new Hc.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:qc.getSendingRtpParameters("audio",d),video:qc.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:qc.getSendingRemoteRtpParameters("audio",d),video:qc.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch($c.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){$c.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if($c.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});$c.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};$c.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};$c.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();$c.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),$c.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&$c.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addStream(this._sendStream);let i,s=await this._pc.createOffer(),o=Fc.parse(s.sdp);const a=Wc.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=qc.reduceCodecs(a.codecs);const c=Wc.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=qc.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&($c.debug("send() | enabling simulcast"),o=Fc.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),zc.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Fc.write(o)}),$c.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Fc.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=Uc.getCname({offerMediaObject:i}),a.encodings=zc.getRtpEncodings({offerMediaObject:i,track:e}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&"video/vp8"===a.codecs[0].mimeType.toLowerCase())for(const e of a.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:i,offerRtpParameters:a,answerRtpParameters:c,codecOptions:r});const d={type:"answer",sdp:this._remoteSdp.getSdp()};$c.debug("send() | calling pc.setRemoteDescription() [answer:%o]",d),await this._pc.setRemoteDescription(d);const u=String(this._nextSendLocalId);return this._nextSendLocalId++,this._mapSendLocalIdTrack.set(u,e),{localId:u,rtpParameters:a}}async stopSending(e){this.assertSendDirection(),$c.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdTrack.get(e);if(!t)throw new Error("track not found");this._mapSendLocalIdTrack.delete(e),this._sendStream.removeTrack(t),this._pc.addStream(this._sendStream);const r=await this._pc.createOffer();$c.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void $c.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const n={type:"answer",sdp:this._remoteSdp.getSdp()};$c.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){throw new Bc.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new Bc.UnsupportedError(" not implemented")}async setRtpEncodingParameters(e,t){throw new Bc.UnsupportedError("not supported")}async getSenderStats(e){throw new Bc.UnsupportedError("not implemented")}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:i};$c.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Kc.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Fc.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),$c.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};$c.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const t of e){const{trackId:e,kind:r,rtpParameters:n,streamId:i}=t;$c.debug("receive() [trackId:%s, kind:%s]",e,r);const s=r;this._remoteSdp.receive({mid:s,kind:r,offerRtpParameters:n,streamId:i??n.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};$c.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=Fc.parse(n.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,n=e,s=i.media.find((e=>String(e.mid)===n));Uc.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:Fc.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),$c.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const r of e){const{kind:e,trackId:n,rtpParameters:i}=r,s=e,o=n,a=r.streamId??i.rtcp.cname,c=this._pc.getRemoteStreams().find((e=>e.id===a)),d=c.getTrackById(o);if(!d)throw new Error("remote track not found");this._mapRecvLocalIdInfo.set(o,{mid:s,rtpParameters:i}),t.push({localId:o,track:d})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){$c.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)??{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};$c.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();$c.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new Bc.UnsupportedError("not implemented")}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmitTime:s,maxRetransmits:o,protocol:r};$c.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};$c.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Fc.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}$c.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Fc.parse(this._pc.localDescription.sdp));const r=Uc.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Oc.Chrome55=Gc;var Qc={},Jc=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Yc=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Zc=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Jc(r,t,n[i]);return Yc(r,t),r}}();Object.defineProperty(Qc,"__esModule",{value:!0}),Qc.Firefox120=void 0;const Xc=Zc(Lo),ed=hi,td=ir,rd=Zc(Fi),nd=Zc(Ni),id=Zc(Ko),sd=Zc(Zo),od=ea,ad=na,cd=ya,dd=new ed.Logger("Firefox120"),ud={OS:16,MIS:2048};class ld extends od.HandlerInterface{static createFactory(){return()=>new ld}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Firefox120"}close(){if(dd.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){dd.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"}),t=document.createElement("canvas");t.getContext("2d");const r=t.captureStream().getVideoTracks()[0];try{e.addTransceiver("audio",{direction:"sendrecv"}),e.addTransceiver(r,{direction:"sendrecv",sendEncodings:[{rid:"r0",maxBitrate:1e5},{rid:"r1",maxBitrate:5e5}]});const n=await e.createOffer();try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}const i=Xc.parse(n.sdp);return id.extractRtpCapabilities({sdpObject:i})}catch(n){try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}throw n}}async getNativeSctpCapabilities(){return dd.debug("getNativeSctpCapabilities()"),{numStreams:ud}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),dd.debug("run()"),this._direction=e,this._remoteSdp=new ad.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:nd.getSendingRtpParameters("audio",d),video:nd.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:nd.getSendingRemoteRtpParameters("audio",d),video:nd.getSendingRemoteRtpParameters("video",d)},this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(dd.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){throw this.assertNotClosed(),new td.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),dd.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});dd.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};dd.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};dd.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();dd.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){this.assertNotClosed(),this.assertSendDirection(),dd.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const s=rd.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=nd.reduceCodecs(s.codecs,n);const o=rd.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=nd.reduceCodecs(o.codecs,n);const a=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(a.sender);const c=await this._pc.createOffer();let d=Xc.parse(c.sdp);this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:d});const u=(0,cd.parse)((t??[{}])[0].scalabilityMode);dd.debug("send() | calling pc.setLocalDescription() [offer:%o]",c),await this._pc.setLocalDescription(c);const l=a.mid;s.mid=l,d=Xc.parse(this._pc.localDescription.sdp);const p=d.media[d.media.length-1];if(s.rtcp.cname=id.getCname({offerMediaObject:p}),t)if(1===t.length){const e=sd.getRtpEncodings({offerMediaObject:p});Object.assign(e[0],t[0]),s.encodings=e}else s.encodings=t;else s.encodings=sd.getRtpEncodings({offerMediaObject:p});if(s.encodings.length>1&&("video/vp8"===s.codecs[0].mimeType.toLowerCase()||"video/h264"===s.codecs[0].mimeType.toLowerCase()))for(const e of s.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${u.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:p,offerRtpParameters:s,answerRtpParameters:o,codecOptions:r,extmapAllowMixed:!0});const h={type:"answer",sdp:this._remoteSdp.getSdp()};return dd.debug("send() | calling pc.setRemoteDescription() [answer:%o]",h),await this._pc.setRemoteDescription(h),this._mapMidTransceiver.set(l,a),{localId:l,rtpParameters:s,rtpSender:a.sender}}async stopSending(e){if(this.assertSendDirection(),dd.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated transceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.disableMediaSection(t.mid);const r=await this._pc.createOffer();dd.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};dd.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),dd.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();dd.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};dd.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),dd.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();dd.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};dd.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?dd.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):dd.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),dd.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated transceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();dd.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};dd.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),dd.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();dd.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};dd.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};dd.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%ud.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Xc.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),dd.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};dd.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;dd.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};dd.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=Xc.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,o=r.get(e),a=s.media.find((e=>String(e.mid)===o));id.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:Xc.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),dd.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){dd.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};dd.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();dd.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){dd.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};dd.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();dd.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){dd.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};dd.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();dd.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};dd.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};dd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Xc.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}dd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Xc.parse(this._pc.localDescription.sdp));const r=id.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new td.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Qc.Firefox120=ld;var pd={},hd=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),fd=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),md=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&hd(r,t,n[i]);return fd(r,t),r}}();Object.defineProperty(pd,"__esModule",{value:!0}),pd.Firefox60=void 0;const gd=md(Lo),vd=hi,yd=ir,bd=md(Fi),wd=md(Ni),_d=md(Ko),Sd=md(Zo),kd=ea,Cd=na,Rd=ya,Pd=new vd.Logger("Firefox60"),Td={OS:16,MIS:2048};class Ed extends kd.HandlerInterface{static createFactory(){return()=>new Ed}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Firefox60"}close(){if(Pd.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){Pd.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"}),t=document.createElement("canvas");t.getContext("2d");const r=t.captureStream().getVideoTracks()[0];try{e.addTransceiver("audio",{direction:"sendrecv"});const n=e.addTransceiver(r,{direction:"sendrecv"}),i=n.sender.getParameters(),s=[{rid:"r0",maxBitrate:1e5},{rid:"r1",maxBitrate:5e5}];i.encodings=s,await n.sender.setParameters(i);const o=await e.createOffer();try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}const a=gd.parse(o.sdp);return _d.extractRtpCapabilities({sdpObject:a})}catch(n){try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}throw n}}async getNativeSctpCapabilities(){return Pd.debug("getNativeSctpCapabilities()"),{numStreams:Td}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),Pd.debug("run()"),this._direction=e,this._remoteSdp=new Cd.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:wd.getSendingRtpParameters("audio",d),video:wd.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:wd.getSendingRemoteRtpParameters("audio",d),video:wd.getSendingRemoteRtpParameters("video",d)},this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(Pd.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){throw this.assertNotClosed(),new yd.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),Pd.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Pd.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Pd.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Pd.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Pd.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertNotClosed(),this.assertSendDirection(),Pd.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&((t=bd.clone(t)).forEach(((e,t)=>{e.rid=`r${t}`})),t.reverse());const i=bd.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=wd.reduceCodecs(i.codecs,n);const s=bd.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=wd.reduceCodecs(s.codecs,n);const o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});if(t){const e=o.sender.getParameters();e.encodings=t,await o.sender.setParameters(e)}const a=await this._pc.createOffer();let c=gd.parse(a.sdp);this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:c});const d=(0,Rd.parse)((t??[{}])[0].scalabilityMode);Pd.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);const u=o.mid;i.mid=u,c=gd.parse(this._pc.localDescription.sdp);const l=c.media[c.media.length-1];if(i.rtcp.cname=_d.getCname({offerMediaObject:l}),t)if(1===t.length){const e=Sd.getRtpEncodings({offerMediaObject:l});Object.assign(e[0],t[0]),i.encodings=e}else i.encodings=t.reverse();else i.encodings=Sd.getRtpEncodings({offerMediaObject:l});if(i.encodings.length>1&&("video/vp8"===i.codecs[0].mimeType.toLowerCase()||"video/h264"===i.codecs[0].mimeType.toLowerCase()))for(const e of i.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${d.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:l,offerRtpParameters:i,answerRtpParameters:s,codecOptions:r,extmapAllowMixed:!0});const p={type:"answer",sdp:this._remoteSdp.getSdp()};return Pd.debug("send() | calling pc.setRemoteDescription() [answer:%o]",p),await this._pc.setRemoteDescription(p),this._mapMidTransceiver.set(u,o),{localId:u,rtpParameters:i,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),Pd.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated transceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.disableMediaSection(t.mid);const r=await this._pc.createOffer();Pd.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Pd.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Pd.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();Pd.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Pd.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Pd.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();Pd.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Pd.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Pd.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Pd.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),Pd.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated transceiver not found");const n=r.sender.getParameters();t=n.encodings.length-1-t,n.encodings.forEach(((e,r)=>{e.active=r>=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Pd.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Pd.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Pd.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Pd.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Pd.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};Pd.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Td.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=gd.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),Pd.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Pd.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;Pd.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};Pd.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=gd.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,o=r.get(e),a=s.media.find((e=>String(e.mid)===o));_d.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:gd.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),Pd.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){Pd.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Pd.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Pd.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Pd.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Pd.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Pd.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Pd.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Pd.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Pd.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};Pd.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};Pd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=gd.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}Pd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=gd.parse(this._pc.localDescription.sdp));const r=_d.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new yd.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}pd.Firefox60=Ed;var Dd={},Id=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Md=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),xd=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Id(r,t,n[i]);return Md(r,t),r}}();Object.defineProperty(Dd,"__esModule",{value:!0}),Dd.Safari12=void 0;const Od=xd(Lo),Ld=hi,Ad=xd(Fi),jd=xd(Ni),Fd=xd(Ko),Nd=xd(Zo),Bd=xd(Xo),Wd=ir,qd=ea,Ud=na,zd=ya,Vd=new Ld.Logger("Safari12"),Hd={OS:1024,MIS:1024};class $d extends qd.HandlerInterface{static createFactory(){return()=>new $d}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Safari12"}close(){if(Vd.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){Vd.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=Od.parse(t.sdp),n=Fd.extractRtpCapabilities({sdpObject:r});return Bd.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Vd.debug("getNativeSctpCapabilities()"),{numStreams:Hd}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),Vd.debug("run()"),this._direction=e,this._remoteSdp=new Ud.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:jd.getSendingRtpParameters("audio",d),video:jd.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:jd.getSendingRemoteRtpParameters("audio",d),video:jd.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(Vd.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){this.assertNotClosed(),Vd.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Vd.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Vd.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Vd.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Vd.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Vd.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){this.assertNotClosed(),this.assertSendDirection(),Vd.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const s=Ad.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=jd.reduceCodecs(s.codecs,n);const o=Ad.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=jd.reduceCodecs(o.codecs,n);const a=this._remoteSdp.getNextMediaSectionIdx(),c=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});i&&i(c.sender);let d,u=await this._pc.createOffer(),l=Od.parse(u.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:l});const p=(0,zd.parse)((t??[{}])[0].scalabilityMode);t&&t.length>1&&(Vd.debug("send() | enabling legacy simulcast"),l=Od.parse(u.sdp),d=l.media[a.idx],Nd.addLegacySimulcast({offerMediaObject:d,numStreams:t.length}),u={type:"offer",sdp:Od.write(l)}),Vd.debug("send() | calling pc.setLocalDescription() [offer:%o]",u),await this._pc.setLocalDescription(u);const h=c.mid;if(s.mid=h,l=Od.parse(this._pc.localDescription.sdp),d=l.media[a.idx],s.rtcp.cname=Fd.getCname({offerMediaObject:d}),s.encodings=Nd.getRtpEncodings({offerMediaObject:d}),t)for(let e=0;e<s.encodings.length;++e)t[e]&&Object.assign(s.encodings[e],t[e]);if(s.encodings.length>1&&("video/vp8"===s.codecs[0].mimeType.toLowerCase()||"video/h264"===s.codecs[0].mimeType.toLowerCase()))for(const e of s.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${p.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:d,reuseMid:a.reuseMid,offerRtpParameters:s,answerRtpParameters:o,codecOptions:r});const f={type:"answer",sdp:this._remoteSdp.getSdp()};return Vd.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f),this._mapMidTransceiver.set(h,c),{localId:h,rtpParameters:s,rtpSender:c.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;Vd.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();Vd.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Vd.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Vd.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();Vd.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Vd.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Vd.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();Vd.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Vd.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Vd.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Vd.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),Vd.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Vd.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Vd.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Vd.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Vd.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Vd.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};Vd.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Hd.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Od.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Vd.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Vd.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;Vd.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};Vd.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=Od.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Fd.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Od.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Vd.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){Vd.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Vd.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Vd.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Vd.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Vd.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Vd.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Vd.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Vd.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Vd.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};Vd.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};Vd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Od.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Vd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Od.parse(this._pc.localDescription.sdp));const r=Fd.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new Wd.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Dd.Safari12=$d;var Kd={},Gd=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Qd=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Jd=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Gd(r,t,n[i]);return Qd(r,t),r}}();Object.defineProperty(Kd,"__esModule",{value:!0}),Kd.Safari11=void 0;const Yd=Jd(Lo),Zd=hi,Xd=Jd(Fi),eu=Jd(Ni),tu=Jd(Ko),ru=Jd(yc),nu=ea,iu=na,su=new Zd.Logger("Safari11"),ou={OS:1024,MIS:1024};class au extends nu.HandlerInterface{static createFactory(){return()=>new au}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdRtpSender=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Safari11"}close(){if(su.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){su.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=Yd.parse(t.sdp);return tu.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return su.debug("getNativeSctpCapabilities()"),{numStreams:ou}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){su.debug("run()"),this._direction=e,this._remoteSdp=new iu.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:eu.getSendingRtpParameters("audio",d),video:eu.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:eu.getSendingRemoteRtpParameters("audio",d),video:eu.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(su.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){su.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(su.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});su.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};su.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};su.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();su.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),su.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&su.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addTrack(e,this._sendStream);let i,s=await this._pc.createOffer(),o=Yd.parse(s.sdp);const a=Xd.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=eu.reduceCodecs(a.codecs);const c=Xd.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=eu.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(su.debug("send() | enabling simulcast"),o=Yd.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),ru.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Yd.write(o)}),su.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Yd.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=tu.getCname({offerMediaObject:i}),a.encodings=ru.getRtpEncodings({offerMediaObject:i,track:e}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&"video/vp8"===a.codecs[0].mimeType.toLowerCase())for(const e of a.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:i,offerRtpParameters:a,answerRtpParameters:c,codecOptions:r});const d={type:"answer",sdp:this._remoteSdp.getSdp()};su.debug("send() | calling pc.setRemoteDescription() [answer:%o]",d),await this._pc.setRemoteDescription(d);const u=String(this._nextSendLocalId);this._nextSendLocalId++;const l=this._pc.getSenders().find((t=>t.track===e));return this._mapSendLocalIdRtpSender.set(u,l),{localId:u,rtpParameters:a,rtpSender:l}}async stopSending(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");t.track&&this._sendStream.removeTrack(t.track),this._mapSendLocalIdRtpSender.delete(e);const r=await this._pc.createOffer();su.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void su.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const n={type:"answer",sdp:this._remoteSdp.getSdp()};su.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?su.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):su.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.track;await r.replaceTrack(t),n&&this._sendStream.removeTrack(n),t&&this._sendStream.addTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),su.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(n)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),su.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.setParameters(n)}async getSenderStats(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");return t.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};su.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%ou.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Yd.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),su.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};su.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const t of e){const{trackId:e,kind:r,rtpParameters:n,streamId:i}=t;su.debug("receive() [trackId:%s, kind:%s]",e,r);const s=r;this._remoteSdp.receive({mid:s,kind:r,offerRtpParameters:n,streamId:i??n.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};su.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=Yd.parse(n.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,n=e,s=i.media.find((e=>String(e.mid)===n));tu.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:Yd.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),su.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const r of e){const{kind:e,trackId:n,rtpParameters:i}=r,s=e,o=n,a=this._pc.getReceivers().find((e=>e.track&&e.track.id===o));if(!a)throw new Error("new RTCRtpReceiver not");this._mapRecvLocalIdInfo.set(o,{mid:s,rtpParameters:i,rtpReceiver:a}),t.push({localId:o,track:a.track,rtpReceiver:a})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){su.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)??{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};su.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();su.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const{rtpReceiver:t}=this._mapRecvLocalIdInfo.get(e)??{};if(!t)throw new Error("associated RTCRtpReceiver not found");return t.getStats()}async pauseReceiving(e){}async resumeReceiving(e){}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};su.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};su.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Yd.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}su.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Yd.parse(this._pc.localDescription.sdp));const r=tu.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Kd.Safari11=au;var cu={},du={},uu=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),lu=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),pu=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&uu(r,t,n[i]);return lu(r,t),r}}();Object.defineProperty(du,"__esModule",{value:!0}),du.getCapabilities=function(){const e=RTCRtpReceiver.getCapabilities(),t=hu.clone(e);for(const e of t.codecs??[]){if(e.channels=e.numChannels,delete e.numChannels,e.mimeType=e.mimeType??`${e.kind}/${e.name}`,e.parameters){const t=e.parameters;t.apt&&(t.apt=Number(t.apt)),t["packetization-mode"]&&(t["packetization-mode"]=Number(t["packetization-mode"]))}for(const t of e.rtcpFeedback??[])t.parameter||(t.parameter="")}return t},du.mangleRtpParameters=function(e){const t=hu.clone(e);t.mid&&(t.muxId=t.mid,delete t.mid);for(const e of t.codecs)e.channels&&(e.numChannels=e.channels,delete e.channels),e.mimeType&&!e.name&&(e.name=e.mimeType.split("/")[1]),delete e.mimeType;return t};const hu=pu(Fi);var fu=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),mu=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),gu=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&fu(r,t,n[i]);return mu(r,t),r}}();Object.defineProperty(cu,"__esModule",{value:!0}),cu.Edge11=void 0;const vu=hi,yu=ir,bu=gu(Fi),wu=gu(Ni),_u=gu(du),Su=ea,ku=new vu.Logger("Edge11");class Cu extends Su.HandlerInterface{static createFactory(){return()=>new Cu}constructor(){super(),this._rtpSenders=new Map,this._rtpReceivers=new Map,this._nextSendLocalId=0,this._transportReady=!1}get name(){return"Edge11"}close(){ku.debug("close()");try{this._iceGatherer.close()}catch(e){}try{this._iceTransport.stop()}catch(e){}try{this._dtlsTransport.stop()}catch(e){}for(const e of this._rtpSenders.values())try{e.stop()}catch(e){}for(const e of this._rtpReceivers.values())try{e.stop()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){return ku.debug("getNativeRtpCapabilities()"),_u.getCapabilities()}async getNativeSctpCapabilities(){return ku.debug("getNativeSctpCapabilities()"),{numStreams:{OS:0,MIS:0}}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){ku.debug("run()"),this._sendingRtpParametersByKind={audio:wu.getSendingRtpParameters("audio",d),video:wu.getSendingRtpParameters("video",d)},this._remoteIceParameters=t,this._remoteIceCandidates=r,this._remoteDtlsParameters=n,this._cname=`CNAME-${bu.generateRandomNumber()}`,this.setIceGatherer({iceServers:s,iceTransportPolicy:o}),this.setIceTransport(),this.setDtlsTransport()}async updateIceServers(e){throw new yu.UnsupportedError("not supported")}async restartIce(e){if(ku.debug("restartIce()"),this._remoteIceParameters=e,this._transportReady){ku.debug("restartIce() | calling iceTransport.start()"),this._iceTransport.start(this._iceGatherer,e,"controlling");for(const e of this._remoteIceCandidates)this._iceTransport.addRemoteCandidate(e);this._iceTransport.addRemoteCandidate({})}}async getTransportStats(){return this._iceTransport.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){ku.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),this._transportReady||await this.setupTransport({localDtlsRole:"server"}),ku.debug("send() | calling new RTCRtpSender()");const i=new RTCRtpSender(e,this._dtlsTransport),s=bu.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=wu.reduceCodecs(s.codecs,n);const o=s.codecs.some((e=>/.+\/rtx$/i.test(e.mimeType)));t||(t=[{}]);for(const e of t)e.ssrc=bu.generateRandomNumber(),o&&(e.rtx={ssrc:bu.generateRandomNumber()});s.encodings=t,s.rtcp={cname:this._cname,reducedSize:!0,mux:!0};const a=_u.mangleRtpParameters(s);ku.debug("send() | calling rtpSender.send() [params:%o]",a),await i.send(a);const c=String(this._nextSendLocalId);return this._nextSendLocalId++,this._rtpSenders.set(c,i),{localId:c,rtpParameters:s,rtpSender:i}}async stopSending(e){ku.debug("stopSending() [localId:%s]",e);const t=this._rtpSenders.get(e);if(!t)throw new Error("RTCRtpSender not found");this._rtpSenders.delete(e);try{ku.debug("stopSending() | calling rtpSender.stop()"),t.stop()}catch(e){throw ku.warn("stopSending() | rtpSender.stop() failed:%o",e),e}}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){t?ku.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):ku.debug("replaceTrack() [localId:%s, no track]",e);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");r.setTrack(t)}async setMaxSpatialLayer(e,t){ku.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(n)}async setRtpEncodingParameters(e,t){ku.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.setParameters(n)}async getSenderStats(e){const t=this._rtpSenders.get(e);if(!t)throw new Error("RTCRtpSender not found");return t.getStats()}async sendDataChannel(e){throw new yu.UnsupportedError("not implemented")}async receive(e){const t=[];for(const t of e){const{trackId:e,kind:r}=t;ku.debug("receive() [trackId:%s, kind:%s]",e,r)}this._transportReady||await this.setupTransport({localDtlsRole:"server"});for(const r of e){const{trackId:e,kind:n,rtpParameters:i}=r;ku.debug("receive() | calling new RTCRtpReceiver()");const s=new RTCRtpReceiver(this._dtlsTransport,n);s.addEventListener("error",(e=>{ku.error('rtpReceiver "error" event [event:%o]',e)}));const o=_u.mangleRtpParameters(i);ku.debug("receive() | calling rtpReceiver.receive() [params:%o]",o),await s.receive(o);const a=e;this._rtpReceivers.set(a,s),t.push({localId:a,track:s.track,rtpReceiver:s})}return t}async stopReceiving(e){for(const t of e){ku.debug("stopReceiving() [localId:%s]",t);const e=this._rtpReceivers.get(t);if(!e)throw new Error("RTCRtpReceiver not found");this._rtpReceivers.delete(t);try{ku.debug("stopReceiving() | calling rtpReceiver.stop()"),e.stop()}catch(e){ku.warn("stopReceiving() | rtpReceiver.stop() failed:%o",e)}}}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){const t=this._rtpReceivers.get(e);if(!t)throw new Error("RTCRtpReceiver not found");return t.getStats()}async receiveDataChannel(e){throw new yu.UnsupportedError("not implemented")}setIceGatherer({iceServers:e,iceTransportPolicy:t}){const r=new RTCIceGatherer({iceServers:e??[],gatherPolicy:t??"all"});r.addEventListener("error",(e=>{ku.error('iceGatherer "error" event [event:%o]',e)}));try{r.gather()}catch(e){ku.debug("setIceGatherer() | iceGatherer.gather() failed: %s",e.toString())}this._iceGatherer=r}setIceTransport(){const e=new RTCIceTransport(this._iceGatherer);e.addEventListener("statechange",(()=>{switch(e.state){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})),e.addEventListener("icestatechange",(()=>{switch(e.state){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})),e.addEventListener("candidatepairchange",(e=>{ku.debug('iceTransport "candidatepairchange" event [pair:%o]',e.pair)})),this._iceTransport=e}setDtlsTransport(){const e=new RTCDtlsTransport(this._iceTransport);e.addEventListener("statechange",(()=>{ku.debug('dtlsTransport "statechange" event [state:%s]',e.state)})),e.addEventListener("dtlsstatechange",(()=>{ku.debug('dtlsTransport "dtlsstatechange" event [state:%s]',e.state),"closed"===e.state&&this.emit("@connectionstatechange","closed")})),e.addEventListener("error",(e=>{ku.error('dtlsTransport "error" event [event:%o]',e)})),this._dtlsTransport=e}async setupTransport({localDtlsRole:e}){ku.debug("setupTransport()");const t=this._dtlsTransport.getLocalParameters();t.role=e,await new Promise(((e,r)=>{this.safeEmit("@connect",{dtlsParameters:t},e,r)})),this._iceTransport.start(this._iceGatherer,this._remoteIceParameters,"controlling");for(const e of this._remoteIceCandidates)this._iceTransport.addRemoteCandidate(e);this._iceTransport.addRemoteCandidate({}),this._remoteDtlsParameters.fingerprints=this._remoteDtlsParameters.fingerprints.filter((e=>"sha-256"===e.algorithm||"sha-384"===e.algorithm||"sha-512"===e.algorithm)),this._dtlsTransport.start(this._remoteDtlsParameters),this._transportReady=!0}}cu.Edge11=Cu;var Ru={},Pu=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Tu=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Eu=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Pu(r,t,n[i]);return Tu(r,t),r}}();Object.defineProperty(Ru,"__esModule",{value:!0}),Ru.ReactNativeUnifiedPlan=void 0;const Du=Eu(Lo),Iu=hi,Mu=Eu(Fi),xu=Eu(Ni),Ou=Eu(Ko),Lu=Eu(Zo),Au=Eu(Xo),ju=ir,Fu=ea,Nu=na,Bu=ya,Wu=new Iu.Logger("ReactNativeUnifiedPlan"),qu={OS:1024,MIS:1024};class Uu extends Fu.HandlerInterface{static createFactory(){return()=>new Uu}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"ReactNativeUnifiedPlan"}close(){if(Wu.debug("close()"),!this._closed){if(this._closed=!0,this._sendStream.release(!1),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){Wu.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=Du.parse(t.sdp),n=Ou.extractRtpCapabilities({sdpObject:r});return Au.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Wu.debug("getNativeSctpCapabilities()"),{numStreams:qu}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),Wu.debug("run()"),this._direction=e,this._remoteSdp=new Nu.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:xu.getSendingRtpParameters("audio",d),video:xu.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:xu.getSendingRemoteRtpParameters("audio",d),video:xu.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(Wu.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){this.assertNotClosed(),Wu.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Wu.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Wu.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Wu.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Wu.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Wu.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){this.assertNotClosed(),this.assertSendDirection(),Wu.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const s=Mu.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=xu.reduceCodecs(s.codecs,n);const o=Mu.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=xu.reduceCodecs(o.codecs,n);const a=this._remoteSdp.getNextMediaSectionIdx(),c=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(c.sender);let d,u=await this._pc.createOffer(),l=Du.parse(u.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:l});let p=!1;const h=(0,Bu.parse)((t??[{}])[0].scalabilityMode);t&&1===t.length&&h.spatialLayers>1&&"video/vp9"===s.codecs[0].mimeType.toLowerCase()&&(Wu.debug("send() | enabling legacy simulcast for VP9 SVC"),p=!0,l=Du.parse(u.sdp),d=l.media[a.idx],Lu.addLegacySimulcast({offerMediaObject:d,numStreams:h.spatialLayers}),u={type:"offer",sdp:Du.write(l)}),Wu.debug("send() | calling pc.setLocalDescription() [offer:%o]",u),await this._pc.setLocalDescription(u);let f=c.mid??void 0;if(f||Wu.warn("send() | missing transceiver.mid (bug in react-native-webrtc, using a workaround"),s.mid=f,l=Du.parse(this._pc.localDescription.sdp),d=l.media[a.idx],s.rtcp.cname=Ou.getCname({offerMediaObject:d}),t)if(1===t.length){let e=Lu.getRtpEncodings({offerMediaObject:d});Object.assign(e[0],t[0]),p&&(e=[e[0]]),s.encodings=e}else s.encodings=t;else s.encodings=Lu.getRtpEncodings({offerMediaObject:d});if(s.encodings.length>1&&("video/vp8"===s.codecs[0].mimeType.toLowerCase()||"video/h264"===s.codecs[0].mimeType.toLowerCase()))for(const e of s.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${h.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:d,reuseMid:a.reuseMid,offerRtpParameters:s,answerRtpParameters:o,codecOptions:r,extmapAllowMixed:!0});const m={type:"answer",sdp:this._remoteSdp.getSdp()};return Wu.debug("send() | calling pc.setRemoteDescription() [answer:%o]",m),await this._pc.setRemoteDescription(m),f||(f=c.mid,s.mid=f),this._mapMidTransceiver.set(f,c),{localId:f,rtpParameters:s,rtpSender:c.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;Wu.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();Wu.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Wu.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Wu.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();Wu.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Wu.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Wu.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();Wu.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Wu.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Wu.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Wu.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),Wu.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Wu.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Wu.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Wu.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Wu.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Wu.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};Wu.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%qu.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Du.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Wu.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Wu.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;Wu.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};Wu.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=Du.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Ou.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Du.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Wu.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){Wu.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Wu.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Wu.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Wu.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Wu.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Wu.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Wu.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Wu.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Wu.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};Wu.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};Wu.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Du.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Wu.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Du.parse(this._pc.localDescription.sdp));const r=Ou.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new ju.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Ru.ReactNativeUnifiedPlan=Uu;var zu={},Vu=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Hu=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),$u=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Vu(r,t,n[i]);return Hu(r,t),r}}();Object.defineProperty(zu,"__esModule",{value:!0}),zu.ReactNative=void 0;const Ku=$u(Lo),Gu=hi,Qu=ir,Ju=$u(Fi),Yu=$u(Ni),Zu=$u(Ko),Xu=$u(yc),el=ea,tl=na,rl=new Gu.Logger("ReactNative"),nl={OS:1024,MIS:1024};class il extends el.HandlerInterface{static createFactory(){return()=>new il}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdTrack=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"ReactNative"}close(){if(rl.debug("close()"),this._sendStream.release(!1),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){rl.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=Ku.parse(t.sdp);return Zu.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return rl.debug("getNativeSctpCapabilities()"),{numStreams:nl}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){rl.debug("run()"),this._direction=e,this._remoteSdp=new tl.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:Yu.getSendingRtpParameters("audio",d),video:Yu.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Yu.getSendingRemoteRtpParameters("audio",d),video:Yu.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(rl.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){rl.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(rl.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});rl.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};rl.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};rl.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();rl.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),rl.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&rl.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addStream(this._sendStream);let i,s=await this._pc.createOffer(),o=Ku.parse(s.sdp);const a=Ju.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=Yu.reduceCodecs(a.codecs);const c=Ju.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=Yu.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(rl.debug("send() | enabling simulcast"),o=Ku.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),Xu.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Ku.write(o)}),rl.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Ku.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=Zu.getCname({offerMediaObject:i}),a.encodings=Xu.getRtpEncodings({offerMediaObject:i,track:e}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&("video/vp8"===a.codecs[0].mimeType.toLowerCase()||"video/h264"===a.codecs[0].mimeType.toLowerCase()))for(const e of a.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:i,offerRtpParameters:a,answerRtpParameters:c,codecOptions:r});const d={type:"answer",sdp:this._remoteSdp.getSdp()};rl.debug("send() | calling pc.setRemoteDescription() [answer:%o]",d),await this._pc.setRemoteDescription(d);const u=String(this._nextSendLocalId);return this._nextSendLocalId++,this._mapSendLocalIdTrack.set(u,e),{localId:u,rtpParameters:a}}async stopSending(e){this.assertSendDirection(),rl.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdTrack.get(e);if(!t)throw new Error("track not found");this._mapSendLocalIdTrack.delete(e),this._sendStream.removeTrack(t),this._pc.addStream(this._sendStream);const r=await this._pc.createOffer();rl.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void rl.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const n={type:"answer",sdp:this._remoteSdp.getSdp()};rl.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){throw new Qu.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new Qu.UnsupportedError("not implemented")}async setRtpEncodingParameters(e,t){throw new Qu.UnsupportedError("not implemented")}async getSenderStats(e){throw new Qu.UnsupportedError("not implemented")}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:i};rl.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%nl.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Ku.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),rl.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};rl.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i}=t;rl.debug("receive() [trackId:%s, kind:%s]",e,n);const s=n;let o=t.streamId??i.rtcp.cname;rl.debug("receive() | forcing a random remote streamId to avoid well known bug in react-native-webrtc"),o+=`-hack-${Ju.generateRandomNumber()}`,r.set(e,o),this._remoteSdp.receive({mid:s,kind:n,offerRtpParameters:i,streamId:o,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};rl.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=Ku.parse(i.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,n=e,i=s.media.find((e=>String(e.mid)===n));Zu.applyCodecParameters({offerRtpParameters:r,answerMediaObject:i})}i={type:"answer",sdp:Ku.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),rl.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{kind:e,trackId:i,rtpParameters:s}=n,o=i,a=e,c=r.get(i),d=this._pc.getRemoteStreams().find((e=>e.id===c)),u=d.getTrackById(o);if(!u)throw new Error("remote track not found");this._mapRecvLocalIdInfo.set(o,{mid:a,rtpParameters:s}),t.push({localId:o,track:u})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){rl.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)??{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};rl.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();rl.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new Qu.UnsupportedError("not implemented")}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmitTime:s,maxRetransmits:o,protocol:r};rl.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};rl.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Ku.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}rl.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Ku.parse(this._pc.localDescription.sdp));const r=Zu.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}zu.ReactNative=il;var sl=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),ol=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),al=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&sl(r,t,n[i]);return ol(r,t),r}}();Object.defineProperty(li,"__esModule",{value:!0}),li.Device=void 0,li.detectDevice=El;const cl=pi.exports,dl=hi,ul=yi,ll=ir,pl=al(Fi),hl=al(Ni),fl=Ds,ml=Oo,gl=Fa,vl=tc,yl=vc,bl=Oc,wl=Qc,_l=pd,Sl=Dd,kl=Kd,Cl=cu,Rl=Ru,Pl=zu,Tl=new dl.Logger("Device");function El(e){if(!e&&"object"==typeof navigator&&"ReactNative"===navigator.product)return Tl.debug("detectDevice() | React-Native detected"),"undefined"==typeof RTCPeerConnection?void Tl.warn("detectDevice() | unsupported react-native-webrtc without RTCPeerConnection, forgot to call registerGlobals()?"):"undefined"!=typeof RTCRtpTransceiver?(Tl.debug("detectDevice() | ReactNative UnifiedPlan handler chosen"),"ReactNativeUnifiedPlan"):(Tl.debug("detectDevice() | ReactNative PlanB handler chosen"),"ReactNative");if(e||"object"==typeof navigator&&"string"==typeof navigator.userAgent){e??(e=navigator.userAgent);const t=new cl.UAParser(e);Tl.debug("detectDevice() | browser detected [userAgent:%s, parsed:%o]",e,t.getResult());const r=t.getBrowser(),n=r.name?.toLowerCase(),i=parseInt(r.major??"0"),s=t.getEngine().name?.toLowerCase(),o=t.getOS(),a=o.name?.toLowerCase(),c=parseFloat(o.version??"0"),d=t.getDevice().model?.toLowerCase(),u="ios"===a||"ipad"===d,l=n&&["chrome","chromium","mobile chrome","chrome webview","chrome headless"].includes(n),p=n&&["firefox","mobile firefox","mobile focus"].includes(n),h=n&&["safari","mobile safari"].includes(n),f=n&&["edge"].includes(n);if((l||f)&&!u&&i>=111)return"Chrome111";if(l&&!u&&i>=74||f&&!u&&i>=88)return"Chrome74";if(l&&!u&&i>=70)return"Chrome70";if(l&&!u&&i>=67)return"Chrome67";if(l&&!u&&i>=55)return"Chrome55";if(p&&!u&&i>=120)return"Firefox120";if(p&&!u&&i>=60)return"Firefox60";if(p&&u&&c>=14.3)return"Safari12";if(h&&i>=12&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(h&&i>=11)return"Safari11";if(f&&!u&&i>=11&&i<=18)return"Edge11";if("webkit"===s&&u&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if("blink"===s){const t=e.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);if(t){const e=Number(t[1]);return e>=111?"Chrome111":e>=74?"Chrome74":e>=70?"Chrome70":e>=67?"Chrome67":"Chrome55"}return"Chrome111"}Tl.warn("detectDevice() | browser not supported [name:%s, version:%s]",n,i)}else Tl.warn("detectDevice() | unknown device")}li.Device=class{constructor({handlerName:e,handlerFactory:t}={}){if(this._loaded=!1,this._observer=new ul.EnhancedEventEmitter,Tl.debug("constructor()"),e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(t)this._handlerFactory=t;else{if(e)Tl.debug("constructor() | handler given: %s",e);else{if(!(e=El()))throw new ll.UnsupportedError("device not supported");Tl.debug("constructor() | detected handler: %s",e)}switch(e){case"Chrome111":this._handlerFactory=ml.Chrome111.createFactory();break;case"Chrome74":this._handlerFactory=gl.Chrome74.createFactory();break;case"Chrome70":this._handlerFactory=vl.Chrome70.createFactory();break;case"Chrome67":this._handlerFactory=yl.Chrome67.createFactory();break;case"Chrome55":this._handlerFactory=bl.Chrome55.createFactory();break;case"Firefox120":this._handlerFactory=wl.Firefox120.createFactory();break;case"Firefox60":this._handlerFactory=_l.Firefox60.createFactory();break;case"Safari12":this._handlerFactory=Sl.Safari12.createFactory();break;case"Safari11":this._handlerFactory=kl.Safari11.createFactory();break;case"Edge11":this._handlerFactory=Cl.Edge11.createFactory();break;case"ReactNativeUnifiedPlan":this._handlerFactory=Rl.ReactNativeUnifiedPlan.createFactory();break;case"ReactNative":this._handlerFactory=Pl.ReactNative.createFactory();break;default:throw new TypeError(`unknown handlerName "${e}"`)}}const r=this._handlerFactory();this._handlerName=r.name,r.close(),this._extendedRtpCapabilities=void 0,this._recvRtpCapabilities=void 0,this._canProduceByKind={audio:!1,video:!1},this._sctpCapabilities=void 0}get handlerName(){return this._handlerName}get loaded(){return this._loaded}get rtpCapabilities(){if(!this._loaded)throw new ll.InvalidStateError("not loaded");return this._recvRtpCapabilities}get sctpCapabilities(){if(!this._loaded)throw new ll.InvalidStateError("not loaded");return this._sctpCapabilities}get observer(){return this._observer}async load({routerRtpCapabilities:e}){let t;Tl.debug("load() [routerRtpCapabilities:%o]",e);try{if(this._loaded)throw new ll.InvalidStateError("already loaded");const r=pl.clone(e);hl.validateRtpCapabilities(r),t=this._handlerFactory();const n=await t.getNativeRtpCapabilities();Tl.debug("load() | got native RTP capabilities:%o",n);const i=pl.clone(n);hl.validateRtpCapabilities(i),this._extendedRtpCapabilities=hl.getExtendedRtpCapabilities(i,r),Tl.debug("load() | got extended RTP capabilities:%o",this._extendedRtpCapabilities),this._canProduceByKind.audio=hl.canSend("audio",this._extendedRtpCapabilities),this._canProduceByKind.video=hl.canSend("video",this._extendedRtpCapabilities),this._recvRtpCapabilities=hl.getRecvRtpCapabilities(this._extendedRtpCapabilities),hl.validateRtpCapabilities(this._recvRtpCapabilities),Tl.debug("load() | got receiving RTP capabilities:%o",this._recvRtpCapabilities),this._sctpCapabilities=await t.getNativeSctpCapabilities(),Tl.debug("load() | got native SCTP capabilities:%o",this._sctpCapabilities),hl.validateSctpCapabilities(this._sctpCapabilities),Tl.debug("load() succeeded"),this._loaded=!0,t.close()}catch(e){throw t&&t.close(),e}}canProduce(e){if(!this._loaded)throw new ll.InvalidStateError("not loaded");if("audio"!==e&&"video"!==e)throw new TypeError(`invalid kind "${e}"`);return this._canProduceByKind[e]}createSendTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,appData:d}){return Tl.debug("createSendTransport()"),this.createTransport({direction:"send",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,appData:d})}createRecvTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,appData:d}){return Tl.debug("createRecvTransport()"),this.createTransport({direction:"recv",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,appData:d})}createTransport({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,proprietaryConstraints:d,appData:u}){if(!this._loaded)throw new ll.InvalidStateError("not loaded");if("string"!=typeof t)throw new TypeError("missing id");if("object"!=typeof r)throw new TypeError("missing iceParameters");if(!Array.isArray(n))throw new TypeError("missing iceCandidates");if("object"!=typeof i)throw new TypeError("missing dtlsParameters");if(s&&"object"!=typeof s)throw new TypeError("wrong sctpParameters");if(u&&"object"!=typeof u)throw new TypeError("if given, appData must be an object");const l=new fl.Transport({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,proprietaryConstraints:d,appData:u,handlerFactory:this._handlerFactory,extendedRtpCapabilities:this._extendedRtpCapabilities,canProduceByKind:this._canProduceByKind});return this._observer.safeEmit("newtransport",l),l}};var Dl={},Il={};Object.defineProperty(Il,"__esModule",{value:!0});var Ml={};Object.defineProperty(Ml,"__esModule",{value:!0}),function(e){var t=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=l&&l.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(li,e),r(Ds,e),r(Qs,e),r(eo,e),r(so,e),r(lo,e),r(Il,e),r(Ml,e),r(ea,e),r(ir,e)}(Dl),function(e){var t=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(n){if(n&&n.__esModule)return n;var i={};if(null!=n)for(var s=e(n),o=0;o<s.length;o++)"default"!==s[o]&&t(i,n,s[o]);return r(i,n),i}}(),i=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.debug=e.parseScalabilityMode=e.detectDevice=e.Device=e.version=e.types=void 0;const s=i(ti.exports);e.debug=s.default;const o=li;Object.defineProperty(e,"Device",{enumerable:!0,get:function(){return o.Device}}),Object.defineProperty(e,"detectDevice",{enumerable:!0,get:function(){return o.detectDevice}});const a=n(Dl);e.types=a,e.version="3.7.18";var c=ya;Object.defineProperty(e,"parseScalabilityMode",{enumerable:!0,get:function(){return c.parse}})}(ei);const xl=[{scaleResolutionDownBy:4,maxBitrate:15e4,maxFramerate:12},{scaleResolutionDownBy:2,maxBitrate:35e4,maxFramerate:18},{scaleResolutionDownBy:1,maxBitrate:9e5,maxFramerate:24}],Ol=[{maxBitrate:1e6,dtx:!0}],Ll=[{maxBitrate:4e4,dtx:!0}],Al={width:1280,height:720};function jl(e,t){e.onload=function(){this.onerror=this.onload=null,t(null,e)},e.onerror=function(){this.onerror=this.onload=null,t(new Error("Failed to load "+this.src),e)}}function Fl(e,t){e.onreadystatechange=function(){"complete"!=this.readyState&&"loaded"!=this.readyState||(this.onreadystatechange=null,t(null,e))}}const Nl=new $n,Bl=e=>new Promise(((t,r)=>{!function(e,t,r){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("script");"function"==typeof t&&(r=t,t={}),t=t||{},r=r||function(){},i.type=t.type||"text/javascript",i.charset=t.charset||"utf8",i.async=!("async"in t)||!!t.async,i.src=e,t.attrs&&function(e,t){for(var r in t)e.setAttribute(r,t[r])}(i,t.attrs),t.text&&(i.text=""+t.text),("onload"in i?jl:Fl)(i,r),i.onload||jl(i,r),n.appendChild(i)}(e,((e,n)=>{e?r(e):t(n)}))})),Wl=(e,t=3,r=500)=>a(void 0,void 0,void 0,(function*(){let n=0;for(;n<t;)try{return void(yield Bl(e))}catch(e){if(n+=1,!(n<t))throw e;yield Nl.sleepMs(r)}}));var ql;let Ul=class{constructor(){ql.set(this,new Map)}add(e,t,r){const n=this.getKey(e,t);if(c(this,ql,"f").has(n))throw new Error("Attempt to rewrite cached track processor");c(this,ql,"f").set(n,r)}get(e,t){return c(this,ql,"f").get(this.getKey(e,t))}has(e,t){return c(this,ql,"f").has(this.getKey(e,t))}getKey(e,t){return`${e}:${t}`}reset(){return a(this,void 0,void 0,(function*(){for(const e of c(this,ql,"f").values())yield e.stopProcessing();c(this,ql,"f").clear()}))}};var zl,Vl;ql=new WeakMap,Ul=i([at()],Ul);let Hl=class{constructor(e,t,r,n){this.config=e,this.processorsCache=t,this.audioTrackProcessorFactory=r,zl.set(this,new Map),Vl.set(this,void 0),d(this,Vl,n("IntegrationsService"),"f")}init(){const e=this.config.get("denoiser");if("asdk"===e){c(this,Vl,"f").info("Start integration of ASDK",{denoiser:e});const t={integrated:!1,initPromise:this.integrateASDK()};c(this,zl,"f").set("asdk",t)}else if("rnnoise"===e){c(this,Vl,"f").info("Start integration of RNNoise",{denoiser:e});const t={integrated:!1,initPromise:this.integrateRNNoise()};c(this,zl,"f").set("rnnoise",t)}}integrateASDK(){var e;return a(this,void 0,void 0,(function*(){const t=this.config.get("asdk"),r=this.config.get("staticFilesPath");if(!window.atsvb){const s=`https://effectssdk.ai/sdk/audio/dev/${t.version}/atsvb-web.js`,o=null!==(e=t.localDir)&&void 0!==e?e:`${r}/${t.version}/atsvb-web.js`;yield(n=s,i=o,a(void 0,void 0,void 0,(function*(){try{yield Wl(n)}catch(e){if(!i)throw e;yield Wl(i)}})))}var n,i;if(!window.atsvb)throw c(this,Vl,"f").info("Audio Effects SDK is not loaded, skipping initialization",{case:"initAudioSDK"}),new Error("windows.atsvb is still missing");const s=this.audioTrackProcessorFactory({trackLabel:Jn.Microphone});yield s.init(),this.processorsCache.add("asdk",Jn.Microphone,s);const o=c(this,zl,"f").get("asdk");if(!o)throw Error("IntegrationContext is missing for ASDK");o.integrated=!0}))}get audio(){return"asdk"===this.config.get("denoiser")?this.getASDKState():this.getRNNoiseState()}getASDKState(){var e,t;const r=c(this,zl,"f").get("asdk");return{type:"asdk",enabled:Boolean(r),isInitialized:null!==(e=null==r?void 0:r.integrated)&&void 0!==e&&e,waitForInitialization:null!==(t=null==r?void 0:r.initPromise)&&void 0!==t?t:Promise.resolve()}}getRNNoiseState(){var e,t;const r=c(this,zl,"f").get("rnnoise");return{type:"rnnoise",enabled:Boolean(r),isInitialized:null!==(e=null==r?void 0:r.integrated)&&void 0!==e&&e,waitForInitialization:null!==(t=null==r?void 0:r.initPromise)&&void 0!==t?t:Promise.resolve()}}integrateRNNoise(){return a(this,void 0,void 0,(function*(){const e=yield class{static compileModule(e){return a(this,void 0,void 0,(function*(){if(!window.WebAssembly)throw new Error("Webassembly not supported");const t=yield fetch(`${e}/rnnoise-processor.wasm`);return WebAssembly.instantiate(yield t.arrayBuffer())}))}}.compileModule(this.config.get("staticFilesPath")),t=this.audioTrackProcessorFactory({trackLabel:Jn.Microphone,noiseSuppressor:e});this.processorsCache.add("rnnoise",Jn.Microphone,t);const r=c(this,zl,"f").get("rnnoise");if(!r)throw Error("IntegrationContext is missing for RNNoise");r.integrated=!0}))}reset(){c(this,zl,"f").clear()}};var $l,Kl,Gl,Ql,Jl,Yl,Zl,Xl,ep;zl=new WeakMap,Vl=new WeakMap,Hl=i([at(),s(0,dt(Qn.Config)),s(1,dt(Qn.ProcessorsCache)),s(2,dt(Qn.AudioTrackProcessorFactory)),s(3,dt(Qn.LoggerFactory)),o("design:paramtypes",[Ct,Ul,Function,Function])],Hl);class tp{constructor(e){$l.set(this,void 0),Kl.set(this,void 0),Gl.set(this,{lowLighter:!1,colorCorrector:!1,faceDetector:!1,segmentation:!1}),Ql.set(this,null),Jl.set(this,void 0),Yl.set(this,!1),Zl.set(this,void 0);const{loggerFactory:t}=e;d(this,Kl,t("EffectsSDKTrackProcessor"),"f"),d(this,Zl,e.onModelsLoaded,"f"),d(this,$l,new window.tsvb(e.customerId),"f"),c(this,$l,"f").onError(this.tsvbErrorHandler.bind(this)),c(this,$l,"f").onReady=this.onReady.bind(this);c(this,$l,"f").config({preset:"balanced",provider:"wasm"})}init(){return a(this,void 0,void 0,(function*(){yield c(this,$l,"f").preload(),yield c(this,$l,"f").cache(),d(this,Yl,!0,"f")}))}awaitReady(){return a(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const r=Date.now(),n=setInterval((()=>{if(this.isModelsLoaded)return clearInterval(n),void e();Date.now()-r>6e4&&(clearInterval(n),t(new Error("ESDK init timeout")))}),100)}))}))}tsvbErrorHandler(e){var t;const{emitter:r,type:i,cause:s}=e,o=n(e,["emitter","type","cause"]),a=null!=r?r:"N/A emitter";"error"===i&&c(this,Kl,"f").error(a,Object.assign({error:hr(e)},o)),"warning"===i&&c(this,Kl,"f").warn(a,Object.assign({},o)),"info"===i&&c(this,Kl,"f").info(a,Object.assign({},o)),"ml_inference"===r&&(o.message.toLocaleLowerCase().includes("init lowlighter")&&(c(this,Gl,"f").lowLighter=!0),o.message.toLocaleLowerCase().includes("init colorcorrector")&&(c(this,Gl,"f").colorCorrector=!0),o.message.toLocaleLowerCase().includes("init facedetector")&&(c(this,Gl,"f").faceDetector=!0),o.message.toLocaleLowerCase().includes("init segmentation")&&(c(this,Gl,"f").segmentation=!0),this.isModelsLoaded&&(null===(t=c(this,Zl,"f"))||void 0===t||t.call(this)))}get isModelsLoaded(){return c(this,Gl,"f").colorCorrector&&c(this,Gl,"f").faceDetector&&c(this,Gl,"f").lowLighter&&c(this,Gl,"f").segmentation}get modelsLoadProgress(){return Object.values(c(this,Gl,"f")).filter(Boolean).length/Object.keys(c(this,Gl,"f")).length}get isReady(){return c(this,Yl,"f")}setOnLoadModels(e){d(this,Zl,e,"f"),this.isModelsLoaded&&c(this,Zl,"f").call(this)}onReady(){d(this,Yl,!0,"f"),c(this,Kl,"f").debug("onReady()",{description:"ESDK is ready"}),this.updateEffects(c(this,Jl,"f"))}processTrack(e){var t,r;return a(this,void 0,void 0,(function*(){if(c(this,Ql,"f")===e||"ended"===e.readyState)return(null===(t=c(this,$l,"f").getStream())||void 0===t?void 0:t.getVideoTracks()[0])||e;this.stopProcessing();try{c(this,$l,"f").useStream(new MediaStream([e]));const t=null===(r=c(this,$l,"f").getStream())||void 0===r?void 0:r.getVideoTracks()[0];return t?(d(this,Ql,e,"f"),t):e}catch(t){throw c(this,Kl,"f").error("processTrack()",{error:t,track:e}),new Error("Can not process this track")}}))}stopProcessing(){try{c(this,$l,"f").clear(),c(this,$l,"f").stop()}catch(e){c(this,Kl,"f").error("stopProcessing()",{error:e})}finally{d(this,Ql,null,"f")}}updateEffects(e){var t,r,n,i,s,o,a,u,l,p,h,f,m,g,v,y,b,w,_,S,k;if(d(this,Jl,e,"f"),!c(this,Yl,"f"))return void c(this,Kl,"f").warn("updateEffects()",{description:"Esdk not ready"});if(!c(this,Jl,"f")||0===Object.keys(c(this,Jl,"f")).length)return void c(this,$l,"f").stop();let C=0;if((null===(t=c(this,Jl,"f"))||void 0===t?void 0:t.blur)&&!(null===(r=c(this,Jl,"f"))||void 0===r?void 0:r.backgroundColor)?(c(this,$l,"f").setBlur(c(this,Jl,"f").blur),C+=1):c(this,$l,"f").clearBlur(),void 0!==(null===(n=c(this,Jl,"f"))||void 0===n?void 0:n.background)?(c(this,$l,"f").setBackground(c(this,Jl,"f").background),C+=1):void 0!==(null===(i=c(this,Jl,"f"))||void 0===i?void 0:i.backgroundColor)?(c(this,$l,"f").setBackgroundColor(null===(s=c(this,Jl,"f"))||void 0===s?void 0:s.backgroundColor),c(this,$l,"f").setBackground("color"),C+=1):c(this,$l,"f").clearBackground(),(null===(o=c(this,Jl,"f"))||void 0===o?void 0:o.beautification)?(c(this,$l,"f").enableBeautification(),c(this,$l,"f").setBeautificationLevel(c(this,Jl,"f").beautification),C+=1):c(this,$l,"f").disableBeautification(),(null===(a=c(this,Jl,"f"))||void 0===a?void 0:a.lowLightEffect)?(c(this,$l,"f").enableLowLightEffect(),c(this,$l,"f").setLowLightEffectPower(c(this,Jl,"f").lowLightEffect),C+=1):c(this,$l,"f").disableLowLightEffect(),(null===(u=c(this,Jl,"f"))||void 0===u?void 0:u.colorCorrector)?(c(this,$l,"f").enableColorCorrector(),c(this,$l,"f").setColorCorrectorPower(c(this,Jl,"f").colorCorrector),C+=1):c(this,$l,"f").disableColorCorrector(),(null===(l=c(this,Jl,"f"))||void 0===l?void 0:l.smartZoom)?(c(this,$l,"f").enableSmartZoom(),c(this,$l,"f").setFaceArea(c(this,Jl,"f").smartZoom),C+=1):c(this,$l,"f").disableSmartZoom(),(null===(p=c(this,Jl,"f"))||void 0===p?void 0:p.layout)?(c(this,$l,"f").setLayout(c(this,Jl,"f").layout),C+=1):c(this,$l,"f").setLayout("center"),(null===(h=c(this,Jl,"f"))||void 0===h?void 0:h.colorFilter)&&(null===(f=c(this,Jl,"f"))||void 0===f?void 0:f.colorFilter.power)&&(null===(m=c(this,Jl,"f"))||void 0===m?void 0:m.colorFilter.url)?(c(this,$l,"f").setColorFilterConfig({lut:c(this,Jl,"f").colorFilter.url,power:c(this,Jl,"f").colorFilter.power}),c(this,$l,"f").enableColorFilter(),C+=1):c(this,$l,"f").disableColorFilter(),null===(g=c(this,Jl,"f"))||void 0===g?void 0:g.lowerThird){const e=c(this,$l,"f").createComponent({component:c(this,Jl,"f").lowerThird.type,options:c(this,Jl,"f").lowerThird.options||{}});null===(b=null===(y=null===(v=c(this,$l,"f").components)||void 0===v?void 0:v.lowerThird)||void 0===y?void 0:y.hideLowerThird)||void 0===b||b.call(y),c(this,$l,"f").addComponent(e,"lowerThird"),c(this,$l,"f").components.lowerThird.showLowerThird(),C+=1}else null===(S=null===(_=null===(w=c(this,$l,"f").components)||void 0===w?void 0:w.lowerThird)||void 0===_?void 0:_.hideLowerThird)||void 0===S||S.call(_);(null===(k=c(this,Jl,"f"))||void 0===k?void 0:k.sharpness)?(c(this,$l,"f").setSharpnessEffectConfig(c(this,Jl,"f").sharpness),C+=1):c(this,$l,"f").disableSharpnessEffect(),C>2?c(this,$l,"f").enableFrameSkipping():c(this,$l,"f").disableFrameSkipping(),c(this,$l,"f").run()}}$l=new WeakMap,Kl=new WeakMap,Gl=new WeakMap,Ql=new WeakMap,Jl=new WeakMap,Yl=new WeakMap,Zl=new WeakMap;let rp=ep=class{constructor(e){Xl.set(this,void 0),d(this,Xl,e("MediaStreamTrackManager"),"f")}createMediaStreamTrack({label:e,constraints:t}){return a(this,void 0,void 0,(function*(){if(ep.isDisplayMedia(e)){const[e]=yield this.createDisplayMediaTracks(t);return e}const[r]=yield this.createUserMediaTracks(t);return r}))}static isDisplayMedia(e){return[Jn.ScreenVideo,Jn.ScreenAudio].includes(e)}createUserMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getUserMedia(e);return c(this,Xl,"f").debug("createUserMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}createDisplayMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getDisplayMedia(e);return c(this,Xl,"f").debug("getDisplayMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}};Xl=new WeakMap,rp=ep=i([at(),s(0,dt(Qn.LoggerFactory)),o("design:paramtypes",[Function])],rp);var np,ip,sp,op,ap,cp,dp,up=rp;let lp=class{constructor(e,t,r,n,i,s,o,a){this.config=e,this.loggerFactory=t,this.audioTrackFactory=r,this.clientEventEmitter=n,this.integrationsService=i,this.processorsCache=s,this.videoTrackFactory=o,this.mediaStreamTrackManager=a,this.isDeviceLoaded=!1,this.tracks=new Map,np.set(this,void 0),ip.set(this,null),sp.set(this,!1),op.set(this,new Map),ap.set(this,!1),cp.set(this,!1),dp.set(this,void 0);const c=this.config.get("effectsSDKParams");d(this,dp,this.config.get("denoiser"),"f"),d(this,np,this.loggerFactory("Media"),"f"),d(this,ip,c||null,"f")}get mediasoupDevice(){return this.device||(this.device=this.createDevice()),this.device}get effectsSDKInitialized(){return c(this,sp,"f")}get effectsSDKParams(){return c(this,ip,"f")}getTrack(e){return this.tracks.get(e)}loadDevice(e){return a(this,void 0,void 0,(function*(){this.isDeviceLoaded||(yield this.mediasoupDevice.load({routerRtpCapabilities:e}),this.isDeviceLoaded=!0)}))}getTrackCodec(e){const{rtpCapabilities:t,rtpCapabilities:{codecs:r}}=this.mediasoupDevice;if(r)return r.find((t=>t.mimeType.toLowerCase()===`${e.kind}/${e.getPreferredCodec()}`));c(this,np,"f").error("getTrackCodec()",{label:e.getLabel,rtpCapabilities:t})}createTracks({constraints:e,mediaStreamTracks:t}){return t.map((t=>{const r={mediaStreamTrack:t,constraints:e};let n;return n="audio"===t.kind?this.audioTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"AudioTrack"})):this.videoTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"VideoTrack"})),c(this,np,"f").debug("createTrack() track created",{trackId:n.id,kind:n.kind}),n}))}createUserMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createUserMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}createDisplayMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createDisplayMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}deleteTrack(e){return a(this,void 0,void 0,(function*(){const t={trackId:e.id,label:e.getLabel(),producerId:e.producerId};try{"disableNoiseSuppression"in e&&(yield e.disableNoiseSuppression()),"disableEffects"in e&&(yield e.disableEffects())}catch(e){c(this,np,"f").warn("deleteTrack()",Object.assign({error:e},t))}try{this.tracks.delete(e.getLabel()),e.stopMediaStreamTrack(),yield e.closeProducer()}catch(e){c(this,np,"f").error("deleteTrack()",{error:e})}finally{c(this,np,"f").debug("deleteTrack()",t)}}))}getAllTracks(){return Array.from(this.tracks.values())}publishedTracks(){return this.getAllTracks().filter((e=>e.isPublished))}clearTracks(){return a(this,void 0,void 0,(function*(){try{this.getAllTracks().map((e=>e.stopMediaStreamTrack()))}catch(e){c(this,np,"f").warn("clearTracks()",{error:e})}finally{this.tracks.clear()}}))}unpublishTracks(){return a(this,void 0,void 0,(function*(){try{yield Promise.all(this.publishedTracks().map((e=>e.unpublish(!1))))}catch(e){c(this,np,"f").warn("unpublishTracks()",{error:e})}}))}setTrack(e){this.tracks.set(e.getLabel(),e)}initEffectsSDK(){return a(this,void 0,void 0,(function*(){if(c(this,sp,"f"))return!0;if(!c(this,ip,"f"))throw c(this,np,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Error("Effects SDK config not provided");const e=(e,t)=>a(this,void 0,void 0,(function*(){if(!window.tsvb)return c(this,np,"f").info("Effects SDK not loaded, skipping initialization",{case:"initEffectsSDK"}),void e(!1);c(this,np,"f").info("Effects SDK initializing",{case:"initEffectsSDK"});try{c(this,op,"f").set(Jn.Camera,yield this.createEffectsSDKTrackProcessor(Jn.Camera)),c(this,op,"f").set(Jn.CameraPreview,yield this.createEffectsSDKTrackProcessor(Jn.CameraPreview)),d(this,sp,!0,"f"),c(this,np,"f").info("Effects SDK initialized",{case:"initEffectsSDK"}),e(!0)}catch(e){c(this,np,"f").error("Failed to initialize Effects SDK",{error:e,case:"initEffectsSDK"}),t(e)}}));return new Promise(((t,r)=>{if(!window.tsvb)return c(this,np,"f").info("Effects SDK tsvb-web.js is not ready, waiting",{case:"initEffectsSDK"}),void window.addEventListener("load",(()=>e(t,r)));e(t,r)}))}))}initDenoiser(e,t){return a(this,void 0,void 0,(function*(){if(!c(this,ap,"f"))try{d(this,ap,!0,"f"),this.clientEventEmitter.emit(Yr,!0),yield this.integrationsService.audio.waitForInitialization,c(this,np,"f").debug("Denoiser initialized, activating",{case:"Denoiser",type:this.integrationsService.audio.type,trackLabel:e.getLabel()});const r=e,n=this.processorsCache.get(c(this,dp,"f"),Jn.Microphone);if(!n)return void c(this,np,"f").error("No cached trackProcessor found",{case:"Denoiser",trackLabel:e.getLabel(),type:this.integrationsService.audio.type});"asdk"===c(this,dp,"f")&&n.setOnError((()=>{this.clientEventEmitter.emit(Yr,!0),this.fallbackToRNoise(e,t).catch((t=>{c(this,np,"f").error("Failed to fallback to RNNoise through onError",{case:"Denoiser",type:c(this,dp,"f"),error:hr(t),label:e.getLabel()})})).then((()=>{this.clientEventEmitter.emit(Yr,!1)}))})),r.prepareTrackProcessor(n),c(this,np,"f").debug("Denoiser trackProcessor set, check if activation is needed",{case:"Denoiser",type:c(this,dp,"f"),shouldEnableDenoiser:null==t?void 0:t.noiseSuppression,trackLabel:e.getLabel()}),(null==t?void 0:t.noiseSuppression)&&(yield e.enableNoiseSuppression())}catch(r){if(c(this,np,"f").warn("Failed to start noise suppression, featured original track",{case:"Denoiser",type:c(this,dp,"f"),error:hr(r),label:e.getLabel()}),"asdk"===c(this,dp,"f"))try{c(this,np,"f").warn("Fallback to RNNoise",{error:hr(r)}),yield this.fallbackToRNoise(e,t)}catch(t){c(this,np,"f").error("Failed to fallback to RNNoise through catch",{case:"Denoiser",type:c(this,dp,"f"),error:hr(t),label:e.getLabel()})}}finally{this.clientEventEmitter.emit(Yr,!1),d(this,ap,!1,"f")}}))}fallbackToRNoise(e,t){return a(this,void 0,void 0,(function*(){c(this,np,"f").debug("Fallback to RNNoise denoiser",{case:"Denoiser"});const r=e;yield r.disableNoiseSuppression(),r.unsetTrackProcessor(),d(this,dp,"rnnoise","f"),this.config.set("denoiser",c(this,dp,"f")),c(this,np,"f").debug("Set config to rnnoise denoiser",{case:"Denoiser",type:this.config.get("denoiser")}),this.integrationsService.init(),yield this.integrationsService.audio.waitForInitialization;const n=this.processorsCache.get(c(this,dp,"f"),Jn.Microphone);n?(r.prepareTrackProcessor(n),(null==t?void 0:t.noiseSuppression)&&(yield r.enableNoiseSuppression())):c(this,np,"f").error("No cached trackProcessor found",{case:"Denoiser",trackLabel:e.getLabel(),type:this.integrationsService.audio.type})}))}createEffectsSDKTrackProcessor(e){return a(this,void 0,void 0,(function*(){if(e){const t=c(this,op,"f").get(e);if(t)return t}if(!c(this,ip,"f"))throw c(this,np,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Error("Effects SDK config not provided");const t=new tp({loggerFactory:this.loggerFactory,customerId:c(this,ip,"f").customerId});return yield t.init(),c(this,np,"f").info("Track effects processor initialized",{trackLabel:e}),t}))}static getVideoTrackTransformParams(e){const t=e.getSettings();return{width:t.width||Al.width,height:t.height||Al.height}}static getScreenVideoTrackParams(e){var t;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:20},width:{max:Al.width},height:{max:Al.height}},encoderConfig:(null==e?void 0:e.videoEncoderConfig)||{encodings:Ol}}}static getCameraVideoTrackParams(e){var t;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:24},width:{max:Al.width},height:{max:Al.height}},encoderConfig:(null==e?void 0:e.encoderConfig)||{encodings:xl}}}createDevice(){const e=(e=>{const t=null!=e?e:null===navigator||void 0===navigator?void 0:navigator.userAgent;if(!t)return;const r=zn.getParser(t);return r.satisfies({"yandex browser":">=23.7"})?"Chrome111":r.satisfies({"yandex browser":">=22"})?"Chrome74":void 0})();return c(this,np,"f").debug("Creating a media device",{handlerName:null!=e?e:"not specified"}),new ei.Device({handlerName:e})}};np=new WeakMap,ip=new WeakMap,sp=new WeakMap,op=new WeakMap,ap=new WeakMap,cp=new WeakMap,dp=new WeakMap,lp=i([at(),s(0,dt(Qn.Config)),s(1,dt(Qn.LoggerFactory)),s(2,dt(Qn.AudioTrackFactory)),s(3,dt(Qn.ClientEventEmitter)),s(4,dt(Qn.IntegrationsService)),s(5,dt(Qn.ProcessorsCache)),s(6,dt(Qn.VideoTrackFactory)),s(7,dt(Qn.MediaStreamTrackManager)),o("design:paramtypes",[Ct,Function,Function,Rt,Hl,Ul,Function,up])],lp);var pp=lp;let hp=class{get(){return this.peer}set(e){this.peer=e}delete(){this.peer=void 0}get canPublish(){var e;return"host"===(null===(e=this.peer)||void 0===e?void 0:e.role)}};hp=i([at()],hp);class fp extends Bn{constructor(e,t,r){super(e,null!=t?t:"something_went_wrong",r)}}const mp=Object.create(null);mp.open="0",mp.close="1",mp.ping="2",mp.pong="3",mp.message="4",mp.upgrade="5",mp.noop="6";const gp=Object.create(null);Object.keys(mp).forEach((e=>{gp[mp[e]]=e}));const vp={type:"error",data:"parser error"},yp="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),bp="function"==typeof ArrayBuffer,wp=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,_p=({type:e,data:t},r,n)=>yp&&t instanceof Blob?r?n(t):Sp(t,n):bp&&(t instanceof ArrayBuffer||wp(t))?r?n(t):Sp(new Blob([t]),n):n(mp[e]+(t||"")),Sp=(e,t)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(",")[1];t("b"+(e||""))},r.readAsDataURL(e)};function kp(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Cp;const Rp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Pp="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<Rp.length;e++)Pp[Rp.charCodeAt(e)]=e;const Tp="function"==typeof ArrayBuffer,Ep=(e,t)=>{if("string"!=typeof e)return{type:"message",data:Ip(e,t)};const r=e.charAt(0);if("b"===r)return{type:"message",data:Dp(e.substring(1),t)};return gp[r]?e.length>1?{type:gp[r],data:e.substring(1)}:{type:gp[r]}:vp},Dp=(e,t)=>{if(Tp){const r=(e=>{let t,r,n,i,s,o=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);const d=new ArrayBuffer(o),u=new Uint8Array(d);for(t=0;t<a;t+=4)r=Pp[e.charCodeAt(t)],n=Pp[e.charCodeAt(t+1)],i=Pp[e.charCodeAt(t+2)],s=Pp[e.charCodeAt(t+3)],u[c++]=r<<2|n>>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&s;return d})(e);return Ip(r,t)}return{base64:!0,data:e}},Ip=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,Mp=String.fromCharCode(30);function xp(){return new TransformStream({transform(e,t){!function(e,t){yp&&e.data instanceof Blob?e.data.arrayBuffer().then(kp).then(t):bp&&(e.data instanceof ArrayBuffer||wp(e.data))?t(kp(e.data)):_p(e,!1,(e=>{Cp||(Cp=new TextEncoder),t(Cp.encode(e))}))}(e,(r=>{const n=r.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,n)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(n))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(r)}))}})}let Op;function Lp(e){return e.reduce(((e,t)=>e+t.length),0)}function Ap(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let n=0;for(let i=0;i<t;i++)r[i]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),r}function jp(e){if(e)return function(e){for(var t in jp.prototype)e[t]=jp.prototype[t];return e}(e)}jp.prototype.on=jp.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},jp.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},jp.prototype.off=jp.prototype.removeListener=jp.prototype.removeAllListeners=jp.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<n.length;i++)if((r=n[i])===t||r.fn===t){n.splice(i,1);break}return 0===n.length&&delete this._callbacks["$"+e],this},jp.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){n=0;for(var i=(r=r.slice(0)).length;n<i;++n)r[n].apply(this,t)}return this},jp.prototype.emitReserved=jp.prototype.emit,jp.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},jp.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Fp="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function Np(e,...t){return t.reduce(((t,r)=>(e.hasOwnProperty(r)&&(t[r]=e[r]),t)),{})}const Bp=Fp.setTimeout,Wp=Fp.clearTimeout;function qp(e,t){t.useNativeTimers?(e.setTimeoutFn=Bp.bind(Fp),e.clearTimeoutFn=Wp.bind(Fp)):(e.setTimeoutFn=Fp.setTimeout.bind(Fp),e.clearTimeoutFn=Fp.clearTimeout.bind(Fp))}class Up extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class zp extends jp{constructor(e){super(),this.writable=!1,qp(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Up(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=Ep(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}(e);return t.length?"?"+t:""}}const Vp="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Hp={};let $p,Kp=0,Gp=0;function Qp(e){let t="";do{t=Vp[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function Jp(){const e=Qp(+new Date);return e!==$p?(Kp=0,$p=e):e+"."+Qp(Kp++)}for(;Gp<64;Gp++)Hp[Vp[Gp]]=Gp;let Yp=!1;try{Yp="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(jb){}const Zp=Yp;function Xp(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||Zp))return new XMLHttpRequest}catch(e){}if(!t)try{return new(Fp[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function eh(){}const th=null!=new Xp({xdomain:!1}).responseType;class rh extends jp{constructor(e,t){super(),qp(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=Np(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const r=this.xhr=new Xp(t);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{r.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var e;3===r.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(r)),4===r.readyState&&(200===r.status||1223===r.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof r.status?r.status:0)}),0))},r.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=rh.requestsCount++,rh.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=eh,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete rh.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(rh.requestsCount=0,rh.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",nh);else if("function"==typeof addEventListener){addEventListener("onpagehide"in Fp?"pagehide":"unload",nh,!1)}function nh(){for(let e in rh.requests)rh.requests.hasOwnProperty(e)&&rh.requests[e].abort()}const ih="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),sh=Fp.WebSocket||Fp.MozWebSocket,oh="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const ah={websocket:class extends zp{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,r=oh?{}:Np(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=oh?new sh(e,t,r):t?new sh(e,t):new sh(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],n=t===e.length-1;_p(r,this.supportsBinary,(e=>{try{this.ws.send(e)}catch(e){}n&&ih((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Jp()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!sh}},webtransport:class extends zp{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((e=>{this.onError("webtransport error",e)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((e=>{const t=function(e,t){Op||(Op=new TextDecoder);const r=[];let n=0,i=-1,s=!1;return new TransformStream({transform(o,a){for(r.push(o);;){if(0===n){if(Lp(r)<1)break;const e=Ap(r,1);s=128==(128&e[0]),i=127&e[0],n=i<126?3:126===i?1:2}else if(1===n){if(Lp(r)<2)break;const e=Ap(r,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),n=3}else if(2===n){if(Lp(r)<8)break;const e=Ap(r,8),t=new DataView(e.buffer,e.byteOffset,e.length),s=t.getUint32(0);if(s>Math.pow(2,21)-1){a.enqueue(vp);break}i=s*Math.pow(2,32)+t.getUint32(4),n=3}else{if(Lp(r)<i)break;const e=Ap(r,i);a.enqueue(Ep(s?e:Op.decode(e),t)),n=0}if(0===i||i>e){a.enqueue(vp);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=xp();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();const i=()=>{r.read().then((({done:e,value:t})=>{e||(this.onPacket(t),i())})).catch((e=>{}))};i();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this.writer.write(s).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],n=t===e.length-1;this.writer.write(r).then((()=>{n&&ih((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends zp{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let r=location.port;r||(r=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||r!==e.port}const t=e&&e.forceBase64;this.supportsBinary=th&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const r=e.split(Mp),n=[];for(let e=0;e<r.length;e++){const i=Ep(r[e],t);if(n.push(i),"error"===i.type)break}return n})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const r=e.length,n=new Array(r);let i=0;e.forEach(((e,s)=>{_p(e,!1,(e=>{n[s]=e,++i===r&&t(n.join(Mp))}))}))})(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Jp()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new rh(this.uri(),e)}doWrite(e,t){const r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}},ch=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,dh=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function uh(e){const t=e,r=e.indexOf("["),n=e.indexOf("]");-1!=r&&-1!=n&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let i=ch.exec(e||""),s={},o=14;for(;o--;)s[dh[o]]=i[o]||"";return-1!=r&&-1!=n&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=function(e,t){const r=/\/{2,9}/g,n=t.replace(r,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1);"/"==t.slice(-1)&&n.splice(n.length-1,1);return n}(0,s.path),s.queryKey=function(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,n){t&&(r[t]=n)})),r}(0,s.query),s}class lh extends jp{constructor(e,t={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=uh(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=uh(t.host).host),qp(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},r=e.split("&");for(let e=0,n=r.length;e<n;e++){let n=r[e].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new ah[e](r)}open(){let e;if(this.opts.rememberUpgrade&&lh.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(e){let t=this.createTransport(e),r=!1;lh.priorWebsocketSuccess=!1;const n=()=>{r||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!r)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;lh.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{r||"closed"!==this.readyState&&(d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function i(){r||(r=!0,d(),t.close(),t=null)}const s=e=>{const r=new Error("probe error: "+e);r.transport=t.name,i(),this.emitReserved("upgradeError",r)};function o(){s("transport closed")}function a(){s("socket closed")}function c(e){t&&e.name!==t.name&&i()}const d=()=>{t.removeListener("open",n),t.removeListener("error",s),t.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};t.once("open",n),t.once("error",s),t.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{r||t.open()}),200):t.open()}onOpen(){if(this.readyState="open",lh.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let r=0;r<this.writeBuffer.length;r++){const n=this.writeBuffer[r].data;if(n&&(e+="string"==typeof(t=n)?function(e){let t=0,r=0;for(let n=0,i=e.length;n<i;n++)t=e.charCodeAt(n),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(n++,r+=4);return r}(t):Math.ceil(1.33*(t.byteLength||t.size))),r>0&&e>this.maxPayload)return this.writeBuffer.slice(0,r);e+=2}var t;return this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,n){if("function"==typeof t&&(n=t,t=void 0),"function"==typeof r&&(n=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const i={type:e,data:t,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),n&&this.once("flush",n),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?r():e()})):this.upgrading?r():e()),this}onError(e){lh.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let r=0;const n=e.length;for(;r<n;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}}lh.protocol=4;const ph="function"==typeof ArrayBuffer,hh=Object.prototype.toString,fh="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===hh.call(Blob),mh="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===hh.call(File);function gh(e){return ph&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||fh&&e instanceof Blob||mh&&e instanceof File}function vh(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(vh(e[t]))return!0;return!1}if(gh(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return vh(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&vh(e[t]))return!0;return!1}function yh(e){const t=[],r=e.data,n=e;return n.data=bh(r,t),n.attachments=t.length,{packet:n,buffers:t}}function bh(e,t){if(!e)return e;if(gh(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}if(Array.isArray(e)){const r=new Array(e.length);for(let n=0;n<e.length;n++)r[n]=bh(e[n],t);return r}if("object"==typeof e&&!(e instanceof Date)){const r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=bh(e[n],t));return r}return e}function wh(e,t){return e.data=_h(e.data,t),delete e.attachments,e}function _h(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=_h(e[r],t);else if("object"==typeof e)for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=_h(e[r],t));return e}const Sh=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var kh;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(kh||(kh={}));function Ch(e){return"[object Object]"===Object.prototype.toString.call(e)}class Rh extends jp{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const r=t.type===kh.BINARY_EVENT;r||t.type===kh.BINARY_ACK?(t.type=r?kh.EVENT:kh.ACK,this.reconstructor=new Ph(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!gh(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const r={type:Number(e.charAt(0))};if(void 0===kh[r.type])throw new Error("unknown packet type "+r.type);if(r.type===kh.BINARY_EVENT||r.type===kh.BINARY_ACK){const n=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(n,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");r.attachments=Number(i)}if("/"===e.charAt(t+1)){const n=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}r.nsp=e.substring(n,t)}else r.nsp="/";const n=e.charAt(t+1);if(""!==n&&Number(n)==n){const n=t+1;for(;++t;){const r=e.charAt(t);if(null==r||Number(r)!=r){--t;break}if(t===e.length)break}r.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){const n=this.tryParse(e.substr(t));if(!Rh.isPayloadValid(r.type,n))throw new Error("invalid payload");r.data=n}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case kh.CONNECT:return Ch(t);case kh.DISCONNECT:return void 0===t;case kh.CONNECT_ERROR:return"string"==typeof t||Ch(t);case kh.EVENT:case kh.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===Sh.indexOf(t[0]));case kh.ACK:case kh.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Ph{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=wh(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var Th=Object.freeze({__proto__:null,protocol:5,get PacketType(){return kh},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==kh.EVENT&&e.type!==kh.ACK||!vh(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===kh.EVENT?kh.BINARY_EVENT:kh.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==kh.BINARY_EVENT&&e.type!==kh.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=yh(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}},Decoder:Rh});function Eh(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const Dh=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Ih extends jp{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Eh(e,"open",this.onopen.bind(this)),Eh(e,"packet",this.onpacket.bind(this)),Eh(e,"error",this.onerror.bind(this)),Eh(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(Dh.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const r={type:kh.EVENT,data:t,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,n=t.pop();this._registerAckCallback(e,n),r.id=e}const n=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!n||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,t){var r;const n=null!==(r=this.flags.timeout)&&void 0!==r?r:this._opts.ackTimeout;if(void 0===n)return void(this.acks[e]=t);const i=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),n);this.acks[e]=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,[null,...e])}}emitWithAck(e,...t){const r=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((n,i)=>{t.push(((e,t)=>r?e?i(e):n(t):n(e))),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...n)=>{if(r!==this._queue[0])return;return null!==e?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...n)),r.pending=!1,this._drainQueue()})),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:kh.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case kh.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case kh.EVENT:case kh.BINARY_EVENT:this.onevent(e);break;case kh.ACK:case kh.BINARY_ACK:this.onack(e);break;case kh.DISCONNECT:this.ondisconnect();break;case kh.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let r=!1;return function(...n){r||(r=!0,t.packet({type:kh.ACK,id:e,data:n}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:kh.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const r of t)r.apply(this,e.data)}}}function Mh(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Mh.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-r:e+r}return 0|Math.min(e,this.max)},Mh.prototype.reset=function(){this.attempts=0},Mh.prototype.setMin=function(e){this.ms=e},Mh.prototype.setMax=function(e){this.max=e},Mh.prototype.setJitter=function(e){this.jitter=e};class xh extends jp{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,qp(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(r=t.randomizationFactor)&&void 0!==r?r:.5),this.backoff=new Mh({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const n=t.parser||Th;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new lh(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const n=Eh(t,"open",(function(){r.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},s=Eh(t,"error",i);if(!1!==this._timeout){const e=this._timeout,r=this.setTimeoutFn((()=>{n(),i(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}return this.subs.push(n),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Eh(e,"ping",this.onping.bind(this)),Eh(e,"data",this.ondata.bind(this)),Eh(e,"error",this.onerror.bind(this)),Eh(e,"close",this.onclose.bind(this)),Eh(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){ih((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new Ih(this,e,t),this.nsps[e]=r),r}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){this.subs.forEach((e=>e())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn((()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Oh={};function Lh(e,t){"object"==typeof e&&(t=e,e=void 0);const r=function(e,t="",r){let n=e;r=r||"undefined"!=typeof location&&location,null==e&&(e=r.protocol+"//"+r.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?r.protocol+e:r.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==r?r.protocol+"//"+e:"https://"+e),n=uh(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const i=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+t,n.href=n.protocol+"://"+i+(r&&r.port===n.port?"":":"+n.port),n}(e,(t=t||{}).path||"/socket.io"),n=r.source,i=r.id,s=r.path,o=Oh[i]&&s in Oh[i].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?a=new xh(n,t):(Oh[i]||(Oh[i]=new xh(n,t)),a=Oh[i]),r.query&&!t.query&&(t.query=r.queryKey),a.socket(r.path,t)}var Ah,jh,Fh,Nh;Object.assign(Lh,{Manager:xh,Socket:Ih,io:Lh,connect:Lh});let Bh=class{constructor(e){this.reconnectingAttempt=0,this.isConnected=!1,this._observer=new Rt,Ah.set(this,void 0),this.knownDisconnectReasonsCodes={"io server disconnect":"server.disconnect","io client disconnect":"client.disconnect","ping timeout":"ping.timeout","transport close":"transport.close","transport error":"transport.error"},jh.set(this,100),Fh.set(this,!1),Nh.set(this,8e3),d(this,Ah,e("Socket"),"f")}get observer(){return this._observer}get id(){var e;return null===(e=this.connection)||void 0===e?void 0:e.id}connect(e,t){const r=Lh(e,{multiplex:!0,randomizationFactor:.2,reconnectionDelay:1e3,reconnection:!0,transports:["polling","websocket"],upgrade:!0,rememberUpgrade:!1,auth:{token:t,apiVersion:4}});this.connection=r,this.serverUrl=e,r.on(Zn.Connect,(()=>{const e=this.reconnectingAttempt?Zn.Reconnected:Zn.Connected;this.isConnected=!0,this.setReconnectingAttempt(0),c(this,Ah,"f").debug(`connection.on('${Zn.Connect}')`,{connectionId:r.id,recovered:r.recovered}),this.observer.safeEmit(Zn.State,{state:e})})),r.on(Zn.ConnectError,(e=>{this.connectionError=e,c(this,Ah,"f").error(`connection.on('${Zn.ConnectError}')`,{error:e}),this.observer.safeEmit(Zn.State,{state:Zn.Error,error:e}),this.reconnectingAttempt>c(this,jh,"f")&&(r.disconnect(),this.observer.safeEmit(Zn.State,{state:Zn.Disconnected,code:"server.disconnect"}))})),r.on(Zn.Disconnect,(e=>{this.isConnected=!1,this.setReconnectingAttempt(0),this.disconnectReason=e,c(this,Ah,"f").info(`connection.on('${Zn.Disconnect}')`,{reason:e});const t=this.getDisconnectReasonCode(e);"server.disconnect"===t&&r.disconnect(),this.observer.safeEmit(Zn.State,{state:Zn.Disconnected,code:t})})),r.io.on(Zn.ReconnectAttempt,(e=>{this.setReconnectingAttempt(e),c(this,Ah,"f").info(`connection.on('${Zn.ReconnectAttempt}')`,{attempt:e}),this.observer.safeEmit(Zn.State,{state:Zn.Reconnecting})})),r.io.on(Zn.Reconnect,(()=>{c(this,Ah,"f").debug(`connection.on('${Zn.Reconnect}')`,{connectionId:r.id}),this.observer.safeEmit(Zn.State,{state:Zn.Reconnect})}))}disconnect(){this.connection&&(this.connection.offAny(),this.connection.volatile.offAny(),this.connection.disconnect(),this.connection.io.removeAllListeners(),this.setReconnectingAttempt(0))}request(e,t={}){return new Promise(((r,n)=>{this.connection?this.connection.timeout(c(this,Nh,"f")).emit(e,t,((t,i)=>{if(t){const r=jn.includes(e);return"operation has timed out"===(null==t?void 0:t.message)&&!c(this,Fh,"f")&&r&&(d(this,Fh,!0,"f"),this.observer.safeEmit(Zn.State,{state:Zn.BufferingStart})),void n(t)}i&&i.error?("Need join to channel first"===i.error&&this.observer.safeEmit(Zn.State,{code:Zn.NeedToJoinFirst}),n(new fp(i.error,i.errorCode,Object.assign({},i)))):(c(this,Fh,"f")&&(d(this,Fh,!1,"f"),this.observer.safeEmit(Zn.State,{state:Zn.BufferingEnd})),r(i))})):n(new Error("Socket request: Socket connection is not initialized"))}))}getServerUrl(){return this.serverUrl}getDisconnectReasonCode(e){const t=String(e).toLowerCase();return this.knownDisconnectReasonsCodes[t]||t}setReconnectingAttempt(e){this.reconnectingAttempt=e}};Ah=new WeakMap,jh=new WeakMap,Fh=new WeakMap,Nh=new WeakMap,Bh=i([at(),s(0,dt(Qn.LoggerFactory)),o("design:paramtypes",[Function])],Bh);var Wh,qh,Uh,zh=Bh;let Vh=class{constructor(e,t,r,n){this.state=e,this.myPeer=t,this.socket=n,Wh.set(this,{send:void 0,recv:void 0}),qh.set(this,void 0),Uh.set(this,void 0),d(this,Uh,r("Network"),"f"),d(this,qh,new Rt,"f"),this.socket.observer.on(Zn.State,(e=>{c(this,qh,"f").safeEmit(Fn,e)}))}get isNetworkActive(){var e,t,r,n,i;return!!(null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&["connected","new"].includes(null!==(r=null===(t=this.receiveTransport)||void 0===t?void 0:t.connectionState)&&void 0!==r?r:"")&&["connected","new"].includes(null!==(i=null===(n=this.sendTransport)||void 0===n?void 0:n.connectionState)&&void 0!==i?i:"")}get observer(){return c(this,qh,"f")}get isSocketConnectionActive(){try{return this.checkSocketConnectionActivity(),!0}catch(e){return!1}}checkSocketConnectionActivity(){var e;if(!this.state.channelId||this.state.isChannelJoining)throw new Error("Connect to the channel first");if(!(null===(e=this.socket.connection)||void 0===e?void 0:e.active))throw new Error("Socket is inactive");if(!this.socket.connection.connected)throw new Error("Socket disconnected")}removeEventListeners(){const{sendTransport:e,receiveTransport:t}=this;if(e){["connect","produce","connectionstatechange"].forEach((t=>e.removeAllListeners(t)))}if(t){["connect","produce","connectionstatechange"].forEach((e=>t.removeAllListeners(e)))}}reset(){return a(this,void 0,void 0,(function*(){this.stopRestartIceAtempts(),this.removeEventListeners()}))}closeRemoteProducer(e){return a(this,void 0,void 0,(function*(){yield this.socket.request(fn,{peerId:this.myPeer.id,producerId:e})}))}closeSendTransport(){var e;return a(this,void 0,void 0,(function*(){this.sendTransport?((null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&(yield this.closeTransport(this.sendTransport)),this.sendTransport.close(),this.sendTransport=void 0):c(this,Uh,"f").warn("closeSendTransport()",{message:"No available send transport"})}))}closeReceiveTransport(){var e;return a(this,void 0,void 0,(function*(){this.receiveTransport?((null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&(yield this.closeTransport(this.receiveTransport)),this.receiveTransport.close(),this.receiveTransport=void 0):c(this,Uh,"f").warn("closeReceiveTransport()",{message:"No available receive transport"})}))}closeTransport(e){return a(this,void 0,void 0,(function*(){try{e.close(),c(this,Uh,"f").debug("closeTransport()",{transportId:e.id,direction:e.direction})}catch(t){c(this,Uh,"f").error("closeTransport()",{error:t,transportId:e.id,direction:e.direction})}}))}createSendTransport(e){return a(this,void 0,void 0,(function*(){if(this.sendTransport)throw c(this,Uh,"f").warn("createSendTransport()",{message:"Send transport already exists"}),new Bn("Send transport already exists","already_exists");const t=yield this.socket.request(In,{sctpCapabilities:e.sctpCapabilities,localDirection:"send"}),r=e.createSendTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return c(this,Uh,"f").debug("createSendTransport()",{transportId:r.id,direction:r.direction}),this.sendTransport=r,this.subscribeCommonTransportEvents(r),r}))}createRecvTransport(e){return a(this,void 0,void 0,(function*(){if(this.receiveTransport)throw c(this,Uh,"f").warn("createReceiveTransport()",{message:"Receive transport already exists"}),new Bn("Receive transport already exists","already_exists");const t=yield this.socket.request(In,{localDirection:"receive"}),r=e.createRecvTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return c(this,Uh,"f").debug("createReceiveTransport()",{transportId:r.id,direction:r.direction}),this.receiveTransport=r,this.subscribeCommonTransportEvents(r),r}))}getIceParameters(e){return a(this,void 0,void 0,(function*(){const t=yield this.socket.request(An,{transportId:e.id}),{error:r}=t;if(r)throw new Error(r);const{iceParameters:n}=t;return c(this,Uh,"f").debug("getIceParameters()",{iceParameters:n}),n}))}restartIce(e){return a(this,void 0,void 0,(function*(){try{const t=yield this.getIceParameters(e);yield e.restartIce({iceParameters:t}),c(this,Uh,"f").info("restartIce completed",{iceParameters:t})}catch(e){c(this,Uh,"f").error("restartIce error",{error:e})}}))}createConsumer({producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i}){var s;return a(this,void 0,void 0,(function*(){const o=this.receiveTransport;if(!o)throw c(this,Uh,"f").error("createConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer");let a;c(this,Uh,"f").debug("createConsumer()",{producerId:e});try{a=yield this.socket.request(Sn,{producerId:e,transportId:o.id,rtpCapabilities:t,appData:{peerId:this.myPeer.id,appId:r,channelId:n},producerPeerId:i})}catch(o){if(!(o instanceof fp&&(null===(s=o.meta)||void 0===s?void 0:s.existedConsumer)))throw c(this,Uh,"f").error("Failed to get consumer options",{producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i,error:hr(o)}),new Error("Failed to create consumer");a=o.meta.existedConsumer}const d=yield o.consume(a),{producerPaused:u}=a;return u&&d.pause(),c(this,Uh,"f").debug("Consumer created",{consumerId:d.id,label:d.appData.label,isProducerPaused:u}),{consumer:d,isProducerPaused:u}}))}createDataConsumer({producerId:e,appId:t,channelId:r,ordered:n}){return a(this,void 0,void 0,(function*(){const i=this.receiveTransport;if(!i)throw c(this,Uh,"f").error("createDataConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer");c(this,Uh,"f").debug("createDataConsumer()",{producerId:e});const s=yield this.socket.request(kn,{ordered:n,dataProducerId:e,transportId:i.id,appData:{peerId:this.myPeer.id,producerId:e,appId:t,channelId:r}}),o=yield i.consumeData(s);return c(this,Uh,"f").debug("Data consumer created",{consumerId:o.id}),o}))}closeRemoteConsumer(e){return a(this,void 0,void 0,(function*(){return this.socket.request(Cn,{peerId:this.myPeer.id,consumerId:e})}))}resumeRemoteConsumer(e){return a(this,void 0,void 0,(function*(){return this.socket.request(Pn,{consumerId:e})}))}pauseRemoteProducer(e){return a(this,void 0,void 0,(function*(){return this.socket.request(mn,{producerId:e})}))}pauseRemoteConsumer(e){return a(this,void 0,void 0,(function*(){return this.socket.request(Rn,{consumerId:e})}))}updatePeerAppData({peerId:e,appData:t}){return a(this,void 0,void 0,(function*(){return this.socket.request(br,{peerId:e,appData:t})}))}getAudioObserverProducer(){return a(this,void 0,void 0,(function*(){return this.socket.request(Cr)}))}getGeneralDataProducer(){return a(this,void 0,void 0,(function*(){return this.socket.request(Rr)}))}getChannelStateSyncDataProducer(){return a(this,void 0,void 0,(function*(){return this.socket.request(Pr)}))}createDataProducer(e){var t;return a(this,void 0,void 0,(function*(){return this.socket.request(On,{transportId:null===(t=this.sendTransport)||void 0===t?void 0:t.id,label:e})}))}getTransportsStateInfo(){return a(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([this.getParsedTransportStats(this.receiveTransport),this.getParsedTransportStats(this.sendTransport)]);return{receive:e,send:t}}))}setPreferRelay(e){this.preferRelay=e}getPreferRelay(){var e;return null!==(e=this.preferRelay)&&void 0!==e&&e}getChannelPeers(e){return a(this,void 0,void 0,(function*(){return this.socket.request(vr,{role:e})}))}getParsedTransportStats(e){return a(this,void 0,void 0,(function*(){if(e)try{const t=Array.from((yield e.getStats()).values()),r=t.find((e=>"local-candidate"===e.type)),n=t.find((e=>"remote-candidate"===e.type)),i=t.find((e=>"transport"===e.type));return{dtlsState:null==i?void 0:i.dtlsState,iceState:null==i?void 0:i.iceState,dtlsRole:null==i?void 0:i.dtlsRole,iceRole:null==i?void 0:i.iceRole,selectedCandidatePairChanges:null==i?void 0:i.selectedCandidatePairChanges,tlsVersion:null==i?void 0:i.tlsVersion,localCandidateState:{ip:null==r?void 0:r.ip,address:null==r?void 0:r.address,port:null==r?void 0:r.port,protocol:null==r?void 0:r.protocol,candidateType:null==r?void 0:r.candidateType},remoteCandidateState:{ip:null==n?void 0:n.ip,address:null==n?void 0:n.address,port:null==n?void 0:n.port,protocol:null==n?void 0:n.protocol,candidateType:null==n?void 0:n.candidateType}}}catch(e){return void c(this,Uh,"f").warn("getParsedTransportStats()",{error:e})}else c(this,Uh,"f").debug("getParsedTransportStats()",{message:"Transport is missing"})}))}logTransportDetails(e){var t,r;return a(this,void 0,void 0,(function*(){let n;try{n=yield e.getStats()}catch(t){return void c(this,Uh,"f").error("Failed to log detailed WebRTC transport stats",{error:hr(t),transportId:e.id,reason:"failed to parse getStats"})}try{const i=[...n],[,s]=null!==(t=i.find((([,e])=>"transport"===(null==e?void 0:e.type))))&&void 0!==t?t:[],[,o]=null!==(r=i.find((([,e])=>"candidate-pair"===e.type&&"succeeded"===e.state&&e.nominated)))&&void 0!==r?r:[],a=n.get(String((null==o?void 0:o.localCandidateId)||"-")),d=n.get(String((null==o?void 0:o.remoteCandidateId)||"-")),u={hasNominatedPair:!!o,transportId:e.id,iceRole:null==s?void 0:s.iceRole,iceState:null==s?void 0:s.iceState,dtlsRole:null==s?void 0:s.dtlsRole,dtlsState:null==s?void 0:s.dtlsState,local:{address:null==a?void 0:a.address,candidateType:null==a?void 0:a.candidateType,foundation:null==a?void 0:a.foundation,networkType:null==a?void 0:a.networkType,isRemote:null==a?void 0:a.isRemote,port:null==a?void 0:a.port,protocol:null==a?void 0:a.protocol,relatedAddress:null==a?void 0:a.relatedAddress,relatedPort:null==a?void 0:a.relatedPort,transportId:null==a?void 0:a.transportId,relayProtocol:null==a?void 0:a.relayProtocol,url:null==a?void 0:a.url},remote:{address:null==d?void 0:d.address,candidateType:null==d?void 0:d.candidateType,foundation:null==d?void 0:d.foundation,isRemote:null==d?void 0:d.isRemote,port:null==d?void 0:d.port,protocol:null==d?void 0:d.protocol,transportId:null==d?void 0:d.transportId}};(null==o?void 0:o.totalRoundTripTime)&&(null==o?void 0:o.responsesReceived)&&(u.pairRoundTripTime=Math.round(o.totalRoundTripTime/o.responsesReceived*1e3)),c(this,Uh,"f").info("Detailed WebRTC transport stats",u)}catch(t){c(this,Uh,"f").error("Failed to log detailed WebRTC transport stats",{error:hr(t),transportId:e.id,reason:"-"})}}))}stopRestartIceAtempts(){clearInterval(c(this,Wh,"f").send),clearInterval(c(this,Wh,"f").recv)}subscribeCommonTransportEvents(e){e.on("connect",(({dtlsParameters:t},r,n)=>a(this,void 0,void 0,(function*(){try{yield this.socket.request(Mn,{transportId:e.id,dtlsParameters:t}),r(),c(this,Uh,"f").debug(`${e.direction}Transport.connect()`,{transportId:e.id,dtlsRole:t.role}),setTimeout((()=>this.logTransportDetails(e)),1500)}catch(t){c(this,Uh,"f").error(`${e.direction}Transport.on('connect')`,{error:t}),n(t)}})))),e.on("produce",((t,r,n)=>a(this,void 0,void 0,(function*(){try{const{id:n}=yield this.socket.request(xn,{transportId:e.id,kind:t.kind,rtpParameters:t.rtpParameters,appData:t.appData});r({id:n}),c(this,Uh,"f").debug(`${e.direction}Transport.produce()`,{producerId:n,transportId:e.id,kind:t.kind})}catch(r){c(this,Uh,"f").error(`${e.direction}Transport.produce()`,{error:r,transportId:e.id,kind:t.kind}),n(r)}})))),e.on("connectionstatechange",(t=>{if(c(this,Uh,"f").info(`${e.direction}Transport.state`,{state:t}),["closed","connected"].includes(t))return c(this,qh,"f").safeEmit(Nn,{state:t,direction:e.direction}),c(this,Wh,"f")[e.direction]&&(c(this,Uh,"f").debug("Stop receiveTransport.restartIce() retries",{recvTransportId:e.id}),clearInterval(c(this,Wh,"f")[e.direction]),c(this,Wh,"f")[e.direction]=void 0,"connected"===t&&c(this,qh,"f").safeEmit(Nn,{state:"reconnected",direction:e.direction})),void("connected"===t&&setTimeout((()=>this.logTransportDetails(e)),1500));if(c(this,qh,"f").safeEmit(Nn,{state:t,direction:e.direction}),["disconnected","failed"].includes(t)){if(c(this,Wh,"f")[e.direction])return;"failed"===t&&(c(this,Uh,"f").debug(`${e.direction}Transport.restartIce()`,{recvTransportId:e.id}),this.restartIce(e)),c(this,Wh,"f")[e.direction]=setInterval((()=>{this.restartIce(e),c(this,Uh,"f").debug(`${e.direction}Transport.restartIce() attempt`,{recvTransportId:e.id})}),5e3)}})),e.on("icegatheringstatechange",(t=>{c(this,Uh,"f").info("icegatheringstatechange",{state:t,transportId:e.id,transportDirection:e.direction})}))}};Wh=new WeakMap,qh=new WeakMap,Uh=new WeakMap,Vh=i([at(),s(0,dt(Qn.CallState)),s(1,dt(Qn.MyPeer)),s(2,dt(Qn.LoggerFactory)),s(3,dt(Qn.SocketIO)),o("design:paramtypes",[Xn,hp,Function,zh])],Vh);var Hh=Vh;let $h=class{constructor(e,t,r,n){this.myPeer=e,this.network=t,this.peerFactory=r,this.clientEventEmitter=n,this.peersStorage=new Map}has(e){return this.peersStorage.has(e)}set(e,t){e===this.myPeer.id&&this.myPeer.set(t),this.peersStorage.set(e,t)}get(e){return this.peersStorage.get(e)}delete(e){return e===this.myPeer.id&&this.myPeer.delete(),this.peersStorage.delete(e)}remove(e){return a(this,void 0,void 0,(function*(){const t=this.get(e);t&&(yield t.reset(),this.delete(e),this.clientEventEmitter.safeEmit(jr,e))}))}all(){return Array.from(this.peersStorage.values())}hosts(){return this.all().filter((e=>"host"===e.role))}audience(){return this.all().filter((e=>"audience"===e.role))}reset(){return a(this,void 0,void 0,(function*(){yield Promise.all(Array.from(this.peersStorage.values()).map((e=>e.reset()))),this.peersStorage.clear()}))}load(e){return a(this,void 0,void 0,(function*(){const{peers:t}=yield this.network.getChannelPeers(e);t.filter((e=>!this.has(e.id))).forEach((e=>this.add(e,!1)))}))}add(e,t=!0){const r=this.get(e.id);if(r)return r;const n=this.peerFactory(e);return this.set(n.id,n),t&&this.clientEventEmitter.safeEmit(Ar,n),n}isModerator(e){if(void 0===e)return!1;const t=this.get(e);return!!t&&t.isModerator}setActiveSpeaker(e){this.activePeerId!==(null==e?void 0:e.id)&&(this.activePeerId=null==e?void 0:e.id,this.clientEventEmitter.safeEmit(Hr,{peer:e}))}};$h=i([at(),s(0,dt(Qn.MyPeer)),s(1,dt(Qn.Network)),s(2,dt(Qn.PeerFactory)),s(3,dt(Qn.ClientEventEmitter)),o("design:paramtypes",[hp,Hh,Function,Rt])],$h);const Kh=e=>null!==e&&"object"==typeof e,Gh=(e,t)=>{const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;let i=!0;return r.forEach((r=>{const n=e[r],s=t[r],o=Kh(n)&&Kh(s);(o&&!Gh(n,s)||!o&&n!==s)&&(i=!1)})),i};var Qh,Jh,Yh,Zh;let Xh=class{constructor(){Qh.set(this,[]),Jh.set(this,new Map),Yh.set(this,new Set),Zh.set(this,!1)}subscribeToSocket(e){c(this,Yh,"f").has(e)||(e.onAny(((e,...t)=>{this.push(e,t)})),c(this,Yh,"f").add(e))}subscribeToDataChannel(e){e.on("message",((...e)=>{this.push("message",e)}))}on(e,t){var r;c(this,Jh,"f").has(e)?null===(r=c(this,Jh,"f").get(e))||void 0===r||r.push(t):c(this,Jh,"f").set(e,[t])}removeListener(e){c(this,Jh,"f").delete(e)}removeAllListeners(e,t){t&&c(this,Yh,"f").has(t)&&(t.offAny(),c(this,Yh,"f").delete(t)),e.forEach((e=>{c(this,Jh,"f").delete(e)}))}push(e,t){c(this,Qh,"f").push({event:e,args:t}),this.process()}process(){if(!c(this,Zh,"f"))for(;c(this,Qh,"f").length>0;){const e=c(this,Qh,"f").shift();this.emit(e.event,e.args)}}emit(e,t){(c(this,Jh,"f").get(e)||[]).forEach((e=>{e(...t)}))}pause(){d(this,Zh,!0,"f")}size(){return c(this,Qh,"f").length}resume(){d(this,Zh,!1,"f"),this.process()}};Qh=new WeakMap,Jh=new WeakMap,Yh=new WeakMap,Zh=new WeakMap,Xh=i([at()],Xh);var ef,tf=Xh;let rf=class{constructor(e,t,r,n,i,s,o){this.network=e,this.media=t,this.myPeer=r,this.eventsQueue=n,this.clientEventEmitter=i,this.peers=s,ef.set(this,void 0),d(this,ef,o("ChannelStateSyncEventHandler"),"f"),this.debouncedRestoreState=function(e,t,r=!1){let n;return function(...i){const s=this,o=r&&!n;"number"==typeof n&&clearTimeout(n),n=setTimeout((()=>{n=null,r||e.apply(s,i)}),t),o&&e.apply(s,i)}}(this.restoreState.bind(this),3e3),this.watchNetworkState()}watchNetworkState(){this.clientEventEmitter.on(Gr,(()=>a(this,void 0,void 0,(function*(){yield this.debouncedRestoreState()}))))}restoreState(){return a(this,void 0,void 0,(function*(){const e={missingPeers:[],removedPeers:[],missingProducers:[],removedProducers:[],fixedProducersState:[],fixedConsumersState:[],restoredAppDataPeers:[]};try{if(!this.network.isSocketConnectionActive)return c(this,ef,"f").info("Connection inactive, skipping restore local state",{case:"restoreLocalState"}),e;this.eventsQueue.pause(),c(this,ef,"f").info("Restoring local state",{case:"restoreLocalState"});const t=this.peers.hosts().map((e=>e.shortData)),{peers:r}=yield this.network.getChannelPeers("host"),{removedProducers:n,fixedProducersState:i}=yield this.restoreRemoteProducersState(r);e.removedProducers.push(...i),e.removedProducers.push(...n),e.removedPeers.push(...this.removeUnnecessaryPeers(t,r)),e.missingPeers.push(...this.setMissingPeers(t,r));const s=this.restoreLocalPeersState(r);return e.missingProducers.push(...s.missingProducers),e.removedProducers.push(...s.removedProducers),e.restoredAppDataPeers.push(...s.restoredAppDataPeers),e.fixedProducersState.push(...s.fixedProducersState),e.fixedConsumersState.push(...s.fixedConsumersState),e}catch(t){return c(this,ef,"f").info("Failed to restore local state",{case:"restoreLocalState",error:hr(t)}),e}finally{c(this,ef,"f").info("Resume events after re-syncing local peers",{case:"restoreLocalState",accumulatedEventsAmount:this.eventsQueue.size()}),this.eventsQueue.resume()}}))}restoreRemoteProducersState(e){return a(this,void 0,void 0,(function*(){const t={removedProducers:[],fixedProducersState:[]},r=this.myPeer.get(),n=e.find((e=>e.id===this.myPeer.id));if(!r||!n)return t;const i=this.media.getAllTracks(),s=n.producers.filter((e=>!i.map((e=>e.producerId)).some((t=>e.id===t))));yield Promise.all(s.map((e=>a(this,void 0,void 0,(function*(){yield this.network.closeRemoteProducer(e.id),r.producers.delete(e.id),t.removedProducers.push(e.id),c(this,ef,"f").info("Unnecessary local producer closed",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId})})))));const o=n.producers.filter((e=>!!i.find((t=>t.isPaused&&t.isPaused!==e.paused))));return yield Promise.all(o.map((e=>a(this,void 0,void 0,(function*(){yield this.network.pauseRemoteProducer(e.id),t.fixedProducersState.push(e.id),c(this,ef,"f").info("Remote producer state repaired",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId})}))))),t}))}removeUnnecessaryPeers(e,t){const r=[];return e.filter((e=>!t.find((t=>t.id===e.id)))).forEach((e=>{this.peers.remove(e.id),r.push(e.id),c(this,ef,"f").info("Unnecessary peer removed",{case:"restoreLocalState",removedPeerId:e.id})})),r}setMissingPeers(e,t){const r=[];return t.forEach((t=>{if(e.find((e=>e.id===t.id)))return;const n=this.peers.add(t);r.push(n.id),c(this,ef,"f").info("Missing peer added to storage",{case:"restoreLocalState",peerId:t.id})})),r}restoreLocalPeersState(e){const t=new Map(e.map((e=>[e.id,e]))),r=this.peers.hosts(),n={removedProducers:[],missingProducers:[],restoredAppDataPeers:[],fixedConsumersState:[],fixedProducersState:[]};return r.forEach((e=>{const r=t.get(e.id);if(!r)return void c(this,ef,"f").warn("Found new local peer, skip restoring state",{case:"restoreLocalState",newPeerId:e.id});n.removedProducers.push(...this.removeUnnecessaryProducers(e,r));this.restoreAppData(e,r)&&n.restoredAppDataPeers.push(e.id);const{fixedProducersState:i,fixedConsumersState:s,missingProducers:o}=this.restoreTracksState(e,r);n.fixedProducersState.push(...i),n.fixedConsumersState.push(...s),n.missingProducers.push(...o)})),c(this,ef,"f").info("Peers state restored",{case:"restoreLocalState"}),n}removeUnnecessaryProducers(e,t){const r=[];return e.getProducers().filter((e=>!t.producers.find((t=>t.id===e.id)))).forEach((t=>{e.observer.safeEmit(fn,t),r.push(t.id),c(this,ef,"f").info("Unnecessary producer removed",{case:"restoreLocalState",removedProducerId:t.id,removedProducerPeerId:t.peerId})})),r}restoreTracksState(e,t){const r={missingProducers:[],fixedProducersState:[],fixedConsumersState:[]};return t.producers.forEach((t=>{var n;const i=e.producers.get(t.id);if(!i)return e.observer.safeEmit(hn,t),r.missingProducers.push(t.id),void c(this,ef,"f").info("Missing producer added to storage",{case:"restoreLocalState",producerId:t.id,producerPeerId:t.peerId});if(i.paused!==t.paused){i.paused=t.paused;const n=i.paused?rn:nn;e.observer.safeEmit(n,{producerId:i.id,kind:i.kind,label:i.label,paused:i.paused}),r.fixedProducersState.push(t.id),c(this,ef,"f").info("Producer state fixed",{case:"restoreLocalState",producerId:t.id,producerPeerId:t.peerId})}const s=e.tracks.get(i.label);if(s&&s.consumerId&&(null===(n=s.consumer)||void 0===n?void 0:n.paused)!==t.paused){const{consumerId:n}=s,o=i.paused?Rn:Pn;e.observer.safeEmit(o,n),r.fixedConsumersState.push(n),c(this,ef,"f").info("Consumer state fixed",{case:"restoreLocalState",consumerId:n,consumerProducerId:t.id,consumerProducerPeerId:t.peerId})}})),r}restoreAppData(e,t){return!Gh(e.appData,t.appData)&&(e.observer.emit(br,t.appData),c(this,ef,"f").info("Application data restored",{case:"restoreLocalState",peerId:e.id,appData:t.appData}),!0)}};ef=new WeakMap,rf=i([at(),s(0,dt(Qn.Network)),s(1,dt(Qn.Media)),s(2,dt(Qn.MyPeer)),s(3,dt(Qn.EventsQueue)),s(4,dt(Qn.ClientEventEmitter)),s(5,dt(Qn.Peers)),s(6,dt(Qn.LoggerFactory)),o("design:paramtypes",[Hh,pp,hp,tf,Rt,$h,Function])],rf);var nf,sf=rf;function of(e){return{id:e.id,appId:e.appId,role:e.role,groups:e.groups,producePermissions:e.producePermissions}}let af=class{constructor(e,t,r,n,i,s){this.eventsQueue=e,this.network=t,this.socket=r,this.peers=n,this.clientEventEmitter=i,nf.set(this,void 0),d(this,nf,s("ChannelEvents"),"f")}handleDataChannelEvent(e){try{const{event:t,data:r}=JSON.parse(e);this.doHandleDataChannelEvent(t,r)}catch(t){c(this,nf,"f").error("Failed to handle data channel event",{error:t,payload:e})}}doHandleDataChannelEvent(e,t){e===br&&this.handlePeerAppDataUpdate(t)}subscribeToEvents(){const{connection:e}=this.socket;if(!e)throw c(this,nf,"f").error("subscribeToEvents()",{error:"Socket connection not initialized"}),new Error("Socket connection not initialized");this.eventsQueue.subscribeToSocket(e),this.eventsQueue.on(mr,(e=>{this.clientEventEmitter.safeEmit(Lr,e),c(this,nf,"f").debug("New channel event",{event:e})})),this.eventsQueue.on(gr,(e=>{const t=this.peers.add(e);c(this,nf,"f").debug("Peer joined to the channel",{peer:of(t)})})),this.eventsQueue.on(yr,(e=>{this.peers.remove(e),c(this,nf,"f").debug("Peer left the channel",{peerId:e})})),this.eventsQueue.on(Sr,(e=>{this.clientEventEmitter.safeEmit(Fr,e),c(this,nf,"f").info("Notify the channel that activity confirmation is required",e)})),this.eventsQueue.on(kr,(e=>{this.clientEventEmitter.safeEmit(Br,e),c(this,nf,"f").info("Notify the channel that it has disconnected due to the activity confirmation expiring",e)})),this.eventsQueue.on(_r,(e=>{this.clientEventEmitter.safeEmit(Nr,e),c(this,nf,"f").info("Notify the channel that the activity has been acquired.",e)})),this.eventsQueue.on(Tr,(e=>{const{producePermissions:t,groups:r,changedProducePermissions:n}=e;this.peers.all().filter((e=>e.groups.some((e=>r.includes(e))))).forEach((e=>{const r=Array.from(new Set([...e.producePermissions,...n])).filter((e=>!n.includes(e)||t.includes(e)));e.handleProducePermissionsChange(r)})),c(this,nf,"f").info("Peers changed produce permissions",{groups:r,producePermissions:t})})),this.eventsQueue.on(Dr,(e=>{const{peerId:t,producePermissions:r}=e,n=this.peers.get(t);n&&n.handleProducePermissionsChange(r)})),this.eventsQueue.on(Er,(e=>{const{producePermissions:t,groups:r}=e;this.peers.all().filter((e=>e.groups.some((e=>r.includes(e))))).forEach((e=>{const r=e.producePermissions.filter((e=>!t.includes(e)));e.handleProducePermissionsChange(r)})),c(this,nf,"f").info("Peers deleted produce permissions",{groups:r,producePermissions:t})})),this.eventsQueue.on(xr,(e=>{const{peerId:t,groups:r}=e,n=this.peers.get(t);n&&n.handleGroupsChange(r)}))}removeEventListeners(){if(!this.eventsQueue)return;const e=[mr,gr,yr,Sr,kr,_r,br,Tr],{connection:t}=this.socket;this.eventsQueue.removeAllListeners(e,t)}handlePeerAppDataUpdate({peerId:e,appData:t}){const r=this.peers.get(e);r&&r.observer.emit(br,t)}reset(){this.removeEventListeners()}};nf=new WeakMap,af=i([at(),s(0,dt(Qn.EventsQueue)),s(1,dt(Qn.Network)),s(2,dt(Qn.SocketIO)),s(3,dt(Qn.Peers)),s(4,dt(Qn.ClientEventEmitter)),s(5,dt(Qn.LoggerFactory)),o("design:paramtypes",[tf,Hh,zh,$h,Rt,Function])],af);var cf=af,df={},uf=l&&l.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(df,"__esModule",{value:!0});var lf=df.AwaitQueue=class{constructor({ClosedErrorClass:e=Error,StoppedErrorClass:t=Error,RemovedTaskErrorClass:r=Error}={ClosedErrorClass:Error,StoppedErrorClass:Error,RemovedTaskErrorClass:Error}){this.closed=!1,this.pendingTasks=[],this.ClosedErrorClass=Error,this.StoppedErrorClass=Error,this.RemovedTaskErrorClass=Error,this.ClosedErrorClass=e,this.StoppedErrorClass=t,this.RemovedTaskErrorClass=r}get size(){return this.pendingTasks.length}close(){if(!this.closed){this.closed=!0;for(const e of this.pendingTasks)e.stopped=!0,e.reject(new this.ClosedErrorClass("AwaitQueue closed"));this.pendingTasks.length=0}}push(e,t){return uf(this,void 0,void 0,(function*(){if(this.closed)throw new this.ClosedErrorClass("AwaitQueue closed");if("function"!=typeof e)throw new TypeError("given task is not a function");if(!e.name&&t)try{Object.defineProperty(e,"name",{value:t})}catch(e){}return new Promise(((r,n)=>{const i={task:e,name:t,resolve:r,reject:n,stopped:!1,enqueuedAt:new Date,executedAt:void 0};this.pendingTasks.push(i),1===this.pendingTasks.length&&this.next()}))}))}removeTask(e){if(0===e)throw new TypeError("cannot remove task with index 0");const t=this.pendingTasks[e];t&&(this.pendingTasks.splice(e,1),t.reject(new this.RemovedTaskErrorClass("task removed from the queue")))}stop(){if(!this.closed){for(const e of this.pendingTasks)e.stopped=!0,e.reject(new this.StoppedErrorClass("AwaitQueue stopped"));this.pendingTasks.length=0}}dump(){const e=new Date;let t=0;return this.pendingTasks.map((r=>({idx:t++,task:r.task,name:r.name,enqueuedTime:r.executedAt?r.executedAt.getTime()-r.enqueuedAt.getTime():e.getTime()-r.enqueuedAt.getTime(),executingTime:r.executedAt?e.getTime()-r.executedAt.getTime():0})))}next(){return uf(this,void 0,void 0,(function*(){const e=this.pendingTasks[0];e&&(yield this.executeTask(e),this.pendingTasks.shift(),this.next())}))}executeTask(e){return uf(this,void 0,void 0,(function*(){if(!e.stopped){e.executedAt=new Date;try{const t=yield e.task();if(e.stopped)return;e.resolve(t)}catch(t){if(e.stopped)return;e.reject(t)}}}))}};const pf=new Error("request for lock canceled");var hf=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))};class ff{constructor(e,t=pf){if(this._maxConcurrency=e,this._cancelError=t,this._queue=[],this._waiters=[],e<=0)throw new Error("semaphore must be initialized to a positive value");this._value=e}acquire(){const e=this.isLocked(),t=new Promise(((e,t)=>this._queue.push({resolve:e,reject:t})));return e||this._dispatch(),t}runExclusive(e){return hf(this,void 0,void 0,(function*(){const[t,r]=yield this.acquire();try{return yield e(t)}finally{r()}}))}waitForUnlock(){return hf(this,void 0,void 0,(function*(){if(!this.isLocked())return Promise.resolve();const e=new Promise((e=>this._waiters.push({resolve:e})));return e}))}isLocked(){return this._value<=0}release(){if(this._maxConcurrency>1)throw new Error("this method is unavailable on semaphores with concurrency > 1; use the scoped release returned by acquire instead");if(this._currentReleaser){const e=this._currentReleaser;this._currentReleaser=void 0,e()}}cancel(){this._queue.forEach((e=>e.reject(this._cancelError))),this._queue=[]}_dispatch(){const e=this._queue.shift();if(!e)return;let t=!1;this._currentReleaser=()=>{t||(t=!0,this._value++,this._resolveWaiters(),this._dispatch())},e.resolve([this._value--,this._currentReleaser])}_resolveWaiters(){this._waiters.forEach((e=>e.resolve())),this._waiters=[]}}var mf=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))};class gf{constructor(e){this._semaphore=new ff(1,e)}acquire(){return mf(this,void 0,void 0,(function*(){const[,e]=yield this._semaphore.acquire();return e}))}runExclusive(e){return this._semaphore.runExclusive((()=>e()))}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const vf=e=>"rtx"!==e.mimeType;var yf,bf,wf,_f,Sf,kf,Cf,Rf,Pf,Tf,Ef,Df,If,Mf,xf,Of,Lf,Af,jf,Ff,Nf,Bf,Wf;class qf{constructor({track:e,statsHandler:t}){yf.set(this,void 0),bf.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return c(this,yf,"f")}get audioWebRTCStats(){return c(this,bf,"f")}handleWebRTCStats(e,t){e.addEventListener("ended",(()=>{t.removeInboundVideoHandler(e.id),t.removeInboundAudioHandler(e.id)}),{once:!0}),"video"!==e.kind?t.addOutboundAudioHandler(e.id,this.setAudioWebRTCStats.bind(this)):t.addOutboundVideoHandler(e.id,this.setVideoWebRTCStats.bind(this))}setVideoWebRTCStats(e){d(this,yf,e,"f")}setAudioWebRTCStats(e){d(this,bf,e,"f")}}yf=new WeakMap,bf=new WeakMap;class Uf{constructor(e){wf.set(this,void 0),_f.set(this,void 0),this.encoderConfig={},this.label=Jn.Unknown,Sf.set(this,void 0),kf.set(this,void 0),Cf.set(this,void 0),Rf.set(this,void 0),Pf.set(this,void 0),Tf.set(this,!1),Ef.set(this,void 0),Df.set(this,void 0),If.set(this,void 0),Mf.set(this,!0),xf.set(this,new gf),Of.set(this,void 0),Lf.set(this,void 0);const{mediaStreamTrack:t,internalEventEmitter:r,constraints:n,mediaStreamTrackManager:i,media:s,myPeer:o,network:a,socket:c,loggerFactory:u,loggerNamespace:l,statsHandler:p}=e;d(this,wf,t,"f"),d(this,Pf,r,"f"),d(this,Ef,n,"f"),d(this,Df,i,"f"),d(this,If,new Rt,"f"),this.logger=u(l),d(this,kf,s,"f"),d(this,Sf,o,"f"),d(this,Cf,a,"f"),d(this,Rf,c,"f"),d(this,Lf,p,"f"),d(this,Of,new qf({track:t,statsHandler:p}),"f")}get videoWebRTCStats(){return c(this,Of,"f").videoWebRTCStats}get audioWebRTCStats(){return c(this,Of,"f").audioWebRTCStats}get logCtx(){return{label:this.getLabel(),id:this.id,kind:this.kind,producerId:this.producerId,paused:this.isPaused,published:this.isPublished}}get observer(){return c(this,If,"f")}get mediaStreamTrack(){return c(this,wf,"f")}get originalTrack(){return c(this,_f,"f")}get id(){return this.mediaStreamTrack.id}get kind(){return this.mediaStreamTrack.kind}get producerId(){var e;return null===(e=this.producer)||void 0===e?void 0:e.id}get isPublished(){return!!this.producer&&!this.producer.closed}get isPaused(){var e,t;return null!==(t=null===(e=this.producer)||void 0===e?void 0:e.paused)&&void 0!==t&&t}get internalEventEmitter(){return c(this,Pf,"f")}getLabel(){return this.label}setLabel(e){this.label=e}setEncoderConfig(e){this.encoderConfig=e}getEncoderConfig(){return this.encoderConfig}setProducer(e){this.producer=e}setStopTrackOnPause(e){this.isPublished||d(this,Mf,e,"f")}getProducer(){return this.producer}setOriginalTrack(){d(this,_f,this.mediaStreamTrack,"f")}closeProducer(e=!0){return a(this,void 0,void 0,(function*(){if(this.producer){try{yield c(this,Cf,"f").closeRemoteProducer(this.producer.id)}catch(e){this.logger.warn("closeProducer()",{label:this.getLabel(),producerId:this.producerId})}this.producer.close(),this.producer=void 0,e&&this.stopMediaStreamTrack()}}))}setPriority(e){return a(this,void 0,void 0,(function*(){this.producer?(yield this.producer.setRtpEncodingParameters({priority:e}),this.logger.debug("setPriority()",{label:this.getLabel(),priority:e})):this.logger.warn("setPriority()",{priority:e,reason:"Not published yet"})}))}stopMediaStreamTrack(){this.mediaStreamTrack.stop(),this.mediaStreamTrack.dispatchEvent(new Event("ended")),this.stopOriginalTrack()}stopOriginalTrack(){c(this,_f,"f")&&(c(this,_f,"f").stop(),d(this,_f,void 0,"f"))}produce({encodings:e,codecOptions:t,preferredCodec:r,transformParams:n,keyFrameRequestDelay:i}){var s,o,d,u,l;return a(this,void 0,void 0,(function*(){if(!c(this,Sf,"f").canPublish)throw this.logger.error("produce()",{message:"Not enough access to produce"}),new Error("Not enough access to produce");if(this.producer)throw new Error("Track already produced");try{yield c(this,Rf,"f").request(Or);const{rtpCapabilities:{codecs:a}}=c(this,kf,"f").mediasoupDevice,p=null==a?void 0:a.find((e=>e.mimeType.toLowerCase()===`${this.kind}/${r}`)),h=0,f=this.prepareProducerEncodings({codec:p,encodings:null!=e?e:[],maxSpatialLayer:(null!=e?e:[]).length-1}),m={trackTransformParams:n,peerId:String(c(this,Sf,"f").id),label:this.getLabel(),maxSpatialLayer:h,encodings:f,codecOptions:t,preferredCodec:r,codec:p,keyFrameRequestDelay:i},g=yield null===(s=c(this,Cf,"f").sendTransport)||void 0===s?void 0:s.produce({track:this.mediaStreamTrack,encodings:f,codecOptions:t,codec:p,stopTracks:!1,disableTrackOnPause:!0,zeroRtpOnPause:!0,appData:m});if(!g)return;const v=g.rtpSender,y=()=>/Safari/i.test(navigator.userAgent);if(e&&v&&y()){const t=v.getParameters();e.forEach((({maxBitrate:e,scaleResolutionDownBy:r},n)=>{t.encodings[n]&&(t.encodings[n].maxBitrate=e,t.encodings[n].scaleResolutionDownBy=r)})),yield v.setParameters(t)}this.setProducer(g),(null===(d=null===(o=this.producer)||void 0===o?void 0:o.track)||void 0===d?void 0:d.id)!==c(this,wf,"f").id&&(this.logger.info("Producer initialized with old track, updating",{oldTrackId:null===(l=null===(u=this.producer)||void 0===u?void 0:u.track)||void 0===l?void 0:l.id,newTrackId:c(this,wf,"f").id}),yield this.replaceTrack(c(this,wf,"f"))),"video"===this.kind&&(e&&v&&p&&Hn(p.mimeType)&&!y()?yield v.setParameters(Object.assign(Object.assign({},v.getParameters()),{encodings:this.prepareProducerEncodings({encodings:e,codec:p,maxSpatialLayer:h})})):yield g.setMaxSpatialLayer(h),yield c(this,Rf,"f").request(wn,{producerId:g.id,maxSpatialLayer:h})),"audio"===this.kind&&(yield this.setPriority("high")),this.logger.debug("produce()",{track:this.logCtx,encodings:e,codecOptions:t})}catch(e){throw this.logger.error("produce()",{error:e,track:this.logCtx}),new Error("Publish track failed")}}))}publish(){return a(this,void 0,void 0,(function*(){yield this.produce({}),this.internalEventEmitter.emit(Xr.trackProduced,this)}))}unpublish(e=!0){return a(this,void 0,void 0,(function*(){try{e&&this.stopMediaStreamTrack(),this.internalEventEmitter.emit(Xr.trackUnproduced,this),this.producer&&(yield this.closeProducer()),d(this,Tf,!0,"f"),this.logger.debug("unpublish()",{track:this.logCtx})}catch(e){this.logger.error("unpublish()",{error:e})}}))}pauseRemoteProducer(e){return a(this,void 0,void 0,(function*(){return c(this,Rf,"f").request(mn,{producerId:e})}))}resumeRemoteProducer(e){return a(this,void 0,void 0,(function*(){return c(this,Rf,"f").request(gn,{producerId:e})}))}mute(e){return a(this,void 0,void 0,(function*(){yield c(this,xf,"f").waitForUnlock();const t=yield c(this,xf,"f").acquire();if(this.producer)try{if(this.producer.pause(),this.logger.debug("pause()",{track:this.logCtx}),c(this,Mf,"f"))return null==e||e(),c(this,wf,"f").stop(),this.stopOriginalTrack(),this.internalEventEmitter.emit(Xr.trackClosed,this),void(yield this.pauseRemoteProducer(this.producer.id));yield this.pauseRemoteProducer(this.producer.id),this.internalEventEmitter.emit(Xr.trackPaused,this)}catch(e){throw this.logger.error("pause()",{error:e,track:this.logCtx}),yield c(this,kf,"f").deleteTrack(this),this.internalEventEmitter.emit(Xr.trackFailed,this),new Error("Can`t pause track, removing")}finally{t()}else this.logger.warn("pause()",{message:"Track is not published",track:this.logCtx})}))}resume(){return a(this,void 0,void 0,(function*(){yield c(this,xf,"f").waitForUnlock();const e=yield c(this,xf,"f").acquire();if(this.producer)try{if(this.logger.debug("resume()",{track:this.logCtx}),c(this,Mf,"f"))return yield this.reopenMediaStreamTrack(),yield this.resumeProducer(),void this.internalEventEmitter.emit(Xr.trackReopened,this);yield this.resumeProducer(),this.internalEventEmitter.emit(Xr.trackResumed,this)}catch(e){throw this.logger.error("resume()",{error:e,track:this.logCtx}),new Error("Can`t resume track")}finally{e()}else this.logger.warn("resume()",{message:"Track is not published",track:this.logCtx})}))}getInfo(){return a(this,void 0,void 0,(function*(){const{width:e,height:t,frameRate:r,aspectRatio:n}=c(this,wf,"f").getSettings();return{trackId:c(this,wf,"f").id,readyState:c(this,wf,"f").readyState,kind:this.kind,label:this.label,width:e,height:t,frameRate:r,aspectRatio:n,paused:this.isPaused,trackOutboundStats:yield this.getStats()}}))}getStats(){var e,t,r,n,i;return a(this,void 0,void 0,(function*(){try{return{producerId:null===(e=this.producer)||void 0===e?void 0:e.id,codec:null===(t=this.producer)||void 0===t?void 0:t.rtpParameters.codecs.find((e=>vf(e))),dtlsState:null===(i=null===(n=null===(r=this.producer)||void 0===r?void 0:r.rtpSender)||void 0===n?void 0:n.transport)||void 0===i?void 0:i.state,rtcStats:yield this.getOutboundRTPStreamStats()}}catch(e){return void this.logger.debug("getStats()",{error:e})}}))}replaceTrack(e){var t;return a(this,void 0,void 0,(function*(){try{d(this,wf,e,"f"),this.internalEventEmitter.emit(Xr.trackReopened,this),this.observer.safeEmit("track-changed",{track:e}),yield null===(t=this.producer)||void 0===t?void 0:t.replaceTrack({track:e}),d(this,Of,new qf({track:e,statsHandler:c(this,Lf,"f")}),"f")}catch(e){this.logger.warn("replaceTrack()",{error:e})}}))}resumeProducer(){return a(this,void 0,void 0,(function*(){this.producer?(yield this.resumeRemoteProducer(this.producer.id),this.producer.resume()):this.logger.debug("resumeProducer()",{message:"Track not produced yet",track:this.logCtx})}))}reopenMediaStreamTrack(){var e;return a(this,void 0,void 0,(function*(){const t=yield c(this,Df,"f").createMediaStreamTrack({label:this.label,constraints:c(this,Ef,"f")});d(this,wf,t,"f"),yield null===(e=this.producer)||void 0===e?void 0:e.replaceTrack({track:t})}))}prepareProducerEncodings(e){const{encodings:t,codec:r,maxSpatialLayer:n}=e;return t&&t.length>1&&r&&Hn(r.mimeType)?[t[n]||t[0]]:t}getOutboundRTPStreamStats(){return new Promise(((e,t)=>{const r=(n=0)=>a(this,void 0,void 0,(function*(){if(!this.producer)throw new Error("Producer is missed");try{const i=yield this.producer.getStats(),s=Array.from(i.values()).find((e=>"outbound-rtp"===e.type));if(!s&&n<5)return void setTimeout((()=>r(n+1)),150);n>=5&&!s&&t(new Error("OutboundRTPStreamStat not exist")),e(s)}catch(e){t(new Error("Can not get RTCStatsReport")),this.logger.debug("getOutboundRTPStreamStats()",{error:e})}}));r()}))}}wf=new WeakMap,_f=new WeakMap,Sf=new WeakMap,kf=new WeakMap,Cf=new WeakMap,Rf=new WeakMap,Pf=new WeakMap,Tf=new WeakMap,Ef=new WeakMap,Df=new WeakMap,If=new WeakMap,Mf=new WeakMap,xf=new WeakMap,Of=new WeakMap,Lf=new WeakMap;class zf extends Uf{constructor(e){super(e),this.transformParams={},Af.set(this,void 0),jf.set(this,void 0),Ff.set(this,!1),Nf.set(this,(()=>{})),d(this,jf,e,"f")}get logCtx(){return{label:this.getLabel(),id:this.id,kind:this.kind,producerId:this.producerId,paused:this.isPaused,published:this.isPublished,isEffectsProcessing:this.isEffectsProcessing}}get isEffectsProcessing(){return Boolean(c(this,Af,"f"))}getEncoderConfig(){return this.encoderConfig}getCodecOptions(){return{videoGoogleStartBitrate:this.getEncoderConfig().videoGoogleStartBitrate||1e3}}getPreferredCodec(){const{preferredCodec:e}=this.getEncoderConfig();return e||(this.getLabel()===Jn.ScreenVideo?"vp8":"h264")}getEncodings(){return this.getEncoderConfig().encodings||xl}setTransformParams(e){this.transformParams=e}setMaxSpatialLayer(e){return a(this,void 0,void 0,(function*(){const t=this.getProducer();t?(yield t.setMaxSpatialLayer(e),this.logger.debug("setMaxSpatialLayer()",{label:this.getLabel(),spatialLayer:e})):this.logger.warn("setMaxSpatialLayer()",{message:"Not produced yet"})}))}getMaxSpatialLayer(){const e=this.getProducer();if(e)return e.maxSpatialLayer;this.logger.warn("getMaxSpatialLayer()",{message:"Not produced yet"})}enableEffects(){return a(this,void 0,void 0,(function*(){if(!c(this,Ff,"f")){d(this,Ff,!0,"f");try{if(c(this,Af,"f"))return this.logger.debug("enableEffects()",{description:"Track is already processed"}),void d(this,Ff,!1,"f");if("ended"===this.mediaStreamTrack.readyState)return void this.logger.warn("Track already ended",{case:"enableEffects"});const{media:e}=c(this,jf,"f");if(!e.effectsSDKInitialized)return void this.logger.warn("Effects SDK not initialized",{case:"enableEffects"});const t=Date.now();d(this,Af,yield e.createEffectsSDKTrackProcessor(this.getLabel()),"f"),this.setOriginalTrack();const r=yield c(this,Af,"f").processTrack(this.mediaStreamTrack),n=Date.now();this.logger.info("enableEffects() time",{time:(n-t)/1e3}),yield this.replaceTrack(r),this.logger.info("enableEffects()",{track:this.logCtx})}catch(e){this.logger.warn("enableEffects()",{track:this.logCtx,error:hr(e)}),this.disableEffects().catch((e=>{this.logger.warn("Failed to this.disableEffects() in catch{}",{track:this.logCtx,error:hr(e)})})),c(this,Nf,"f").call(this,e)}finally{d(this,Ff,!1,"f")}}}))}disableEffects(){var e;return a(this,void 0,void 0,(function*(){try{if(!c(this,Af,"f"))return void this.logger.debug("disableEffects()",{description:"Track is not processed"});this.originalTrack?yield this.replaceTrack(this.originalTrack):this.logger.warn("disableEffects()",{description:"Original track missing"}),null===(e=c(this,Af,"f"))||void 0===e||e.stopProcessing(),d(this,Af,void 0,"f"),this.logger.info("disableEffects()",{track:this.logCtx})}catch(e){this.logger.warn("disableEffects()",{track:this.logCtx,error:e})}}))}publish(e={}){var t;return a(this,void 0,void 0,(function*(){yield this.produce({encodings:this.getEncodings(),preferredCodec:this.getPreferredCodec(),transformParams:this.transformParams,codecOptions:this.getCodecOptions(),keyFrameRequestDelay:null!==(t=e.keyFrameRequestDelay)&&void 0!==t?t:0}),this.internalEventEmitter.emit(Xr.trackProduced,this)}))}adjustEncodingPresetToCurrentMaxSpatialLayer(e){return a(this,void 0,void 0,(function*(){if(!Hn(this.getPreferredCodec()))return;const{rtpSender:t}=this.getProducer()||{};if(!t)return void this.logger.warn("No rtpSender found in producer to change encodings",{maxSpatialLayer:e,trackId:this.id,producerId:this.producerId});const{encodings:r=[]}=this.getEncoderConfig(),n=r[e];if(!n)return void this.logger.warn("Skipping RTPSender params update. No target encoding found",{initialEncodings:r});this.logger.debug("Adjusting encoding parameters to max spatial layer",{targetEncoding:n,maxSpatialLayer:e});const i=t.getParameters();yield t.setParameters(Object.assign(Object.assign({},i),{encodings:[Object.assign(Object.assign({},i.encodings[0]),n)]}))}))}applyEffects(e){var t;return a(this,void 0,void 0,(function*(){try{!this.isEffectsProcessing&&Object.keys(e).length>0&&(yield this.enableEffects()),null===(t=c(this,Af,"f"))||void 0===t||t.updateEffects(e)}catch(e){c(this,Nf,"f").call(this,e)}}))}resetEffects(){var e;return a(this,void 0,void 0,(function*(){null===(e=c(this,Af,"f"))||void 0===e||e.updateEffects({})}))}setOnLoadModels(e){var t;null===(t=c(this,Af,"f"))||void 0===t||t.setOnLoadModels(e)}get modelsLoadProgress(){var e;return(null===(e=c(this,Af,"f"))||void 0===e?void 0:e.modelsLoadProgress)||0}pause(){return a(this,void 0,void 0,(function*(){yield this.mute((()=>{var e;c(this,Af,"f")&&(null===(e=c(this,Af,"f"))||void 0===e||e.stopProcessing(),d(this,Af,void 0,"f"))}))}))}setOnEffectError(e){d(this,Nf,e,"f")}}Af=new WeakMap,jf=new WeakMap,Ff=new WeakMap,Nf=new WeakMap;let Vf=class{constructor(e,t,r,n,i,s,o,a,c){this.eventsQueue=e,this.media=t,this.network=r,this.socket=n,this.myPeer=i,this.internalEventEmitter=s,this.peers=o,this.clientEventEmitter=a,Bf.set(this,void 0),Wf.set(this,new lf),d(this,Bf,c("MediasoupEvents"),"f")}subscribeToEvents(){const{connection:e}=this.socket;if(!e)throw c(this,Bf,"f").error("subscribeToEvents()",{error:"Socket connection not initialized"}),new Error("Socket connection not initialized");this.eventsQueue.subscribeToSocket(e),this.eventsQueue.on(fn,(e=>{const t=this.peers.get(e.peerId);t&&t.observer.safeEmit(fn,e)})),this.eventsQueue.on(hn,(e=>{const t=this.peers.get(e.peerId);t&&t.observer.safeEmit(hn,e)})),this.eventsQueue.on(Cn,((e,t)=>{const r=this.peers.get(t);r&&r.observer.safeEmit(Cn,e)})),this.eventsQueue.on(Pn,((e,t)=>{const r=this.peers.get(t);r&&!r.isMe&&r.observer.safeEmit(Pn,e)})),this.eventsQueue.on(Rn,((e,t)=>{const r=this.peers.get(t);r&&!r.isMe&&r.observer.safeEmit(Rn,e)})),this.eventsQueue.on(En,(({peerId:e,spatialLayer:t,temporalLayer:r,consumerId:n})=>{const i=this.peers.get(e);i&&!i.isMe&&i.observer.safeEmit(En,{consumerId:n,spatialLayer:t,temporalLayer:r})})),this.eventsQueue.on(_n,(({producerId:e,spatialLayer:t})=>a(this,void 0,void 0,(function*(){yield c(this,Wf,"f").push((()=>a(this,void 0,void 0,(function*(){yield this.handleProducerSetMaxSpatialLayer({producerId:e,spatialLayer:t})}))),_n)})))),this.eventsQueue.on(wn,(({peerId:e,producerId:t,spatialLayer:r})=>a(this,void 0,void 0,(function*(){const n=this.peers.get(e);n&&!n.isMe&&n.observer.safeEmit(wn,{peerId:e,producerId:t,spatialLayer:r})})))),this.eventsQueue.on(Ln,(({reason:e,transportId:t,direction:r,timeout:n})=>a(this,void 0,void 0,(function*(){const i=[this.network.receiveTransport,this.network.sendTransport].find((e=>(null==e?void 0:e.id)===t));i&&"connected"!==i.connectionState&&(c(this,Bf,"f").warn(Ln,{reason:e,transportId:t,direction:r,timeout:n}),this.clientEventEmitter.emit(Ur,{direction:r,reason:e}))})))),this.eventsQueue.on(vn,(({peerId:e,producerId:t})=>{const r=this.peers.get(e),n=null==r?void 0:r.producers.get(t);r&&n&&(n.paused=!0,r.observer.safeEmit(rn,{producerId:n.id,kind:n.kind,label:n.label,paused:n.paused}))})),this.eventsQueue.on(yn,(({peerId:e,producerId:t})=>{const r=this.peers.get(e),n=null==r?void 0:r.producers.get(t);r&&n&&(n.paused=!1,r.observer.safeEmit(nn,{producerId:n.id,kind:n.kind,label:n.label,paused:n.paused}))})),this.eventsQueue.on(bn,(({label:e})=>a(this,void 0,void 0,(function*(){const t=this.media.getTrack(e);t&&(t.stopMediaStreamTrack(),this.internalEventEmitter.safeEmit(Xr.trackClosed,t),this.clientEventEmitter.emit(zr,{label:e}),yield this.media.deleteTrack(t))}))))}handleConsumerScoreEvent(e){try{const{peerId:t,consumerId:r,score:n}=JSON.parse(e),i=this.peers.get(t);if(!i)return;i.observer.safeEmit(Tn,{consumerId:r,score:n})}catch(t){c(this,Bf,"f").error("Failed to handle consumer score event",{error:t,payload:e})}}removeEventListeners(){if(!this.eventsQueue)return;const e=[fn,hn,Cn,Pn,Rn,En,_n,wn,Ln,vn,yn,bn],{connection:t}=this.socket;this.eventsQueue.removeAllListeners(e,t)}reset(){this.removeEventListeners()}handleProducerSetMaxSpatialLayer({producerId:e,spatialLayer:t}){return a(this,void 0,void 0,(function*(){const r=this.media.getAllTracks().find((t=>{var r;return(null===(r=t.getProducer())||void 0===r?void 0:r.id)===e}));if(!r)return void c(this,Bf,"f").warn("producerRequestMaxSpatialLayer()",{message:"Producer not found"});if(!(r instanceof zf))return void c(this,Bf,"f").warn("producerRequestMaxSpatialLayer()",{message:"Wrong producer kind"});const n=t||0,i=r.getMaxSpatialLayer();i!==n?(r.getEncodings().length>1&&(yield r.setMaxSpatialLayer(n)),yield this.socket.request(wn,{producerId:e,maxSpatialLayer:n}),yield r.adjustEncodingPresetToCurrentMaxSpatialLayer(n)):c(this,Bf,"f").debug("producerRequestMaxSpatialLayer()",{message:"Skip set max spatial layer",requestedSpatialLayer:n,currentMaxSpatialLayer:i})}))}};Bf=new WeakMap,Wf=new WeakMap,Vf=i([at(),s(0,dt(Qn.EventsQueue)),s(1,dt(Qn.Media)),s(2,dt(Qn.Network)),s(3,dt(Qn.SocketIO)),s(4,dt(Qn.Network)),s(5,dt(Qn.InternalEventEmitter)),s(6,dt(Qn.Peers)),s(7,dt(Qn.ClientEventEmitter)),s(8,dt(Qn.LoggerFactory)),o("design:paramtypes",[tf,pp,Hh,zh,hp,Rt,$h,Rt,Function])],Vf);var Hf=Vf,$f={exports:{}},Kf=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},Gf=Kf,Qf=Object.prototype.toString;function Jf(e){return"[object Array]"===Qf.call(e)}function Yf(e){return void 0===e}function Zf(e){return null!==e&&"object"==typeof e}function Xf(e){if("[object Object]"!==Qf.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function em(e){return"[object Function]"===Qf.call(e)}function tm(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),Jf(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}var rm={isArray:Jf,isArrayBuffer:function(e){return"[object ArrayBuffer]"===Qf.call(e)},isBuffer:function(e){return null!==e&&!Yf(e)&&null!==e.constructor&&!Yf(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:Zf,isPlainObject:Xf,isUndefined:Yf,isDate:function(e){return"[object Date]"===Qf.call(e)},isFile:function(e){return"[object File]"===Qf.call(e)},isBlob:function(e){return"[object Blob]"===Qf.call(e)},isFunction:em,isStream:function(e){return Zf(e)&&em(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:tm,merge:function e(){var t={};function r(r,n){Xf(t[n])&&Xf(r)?t[n]=e(t[n],r):Xf(r)?t[n]=e({},r):Jf(r)?t[n]=r.slice():t[n]=r}for(var n=0,i=arguments.length;n<i;n++)tm(arguments[n],r);return t},extend:function(e,t,r){return tm(t,(function(t,n){e[n]=r&&"function"==typeof t?Gf(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}},nm=rm;function im(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var sm=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(nm.isURLSearchParams(t))n=t.toString();else{var i=[];nm.forEach(t,(function(e,t){null!=e&&(nm.isArray(e)?t+="[]":e=[e],nm.forEach(e,(function(e){nm.isDate(e)?e=e.toISOString():nm.isObject(e)&&(e=JSON.stringify(e)),i.push(im(t)+"="+im(e))})))})),n=i.join("&")}if(n){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e},om=rm;function am(){this.handlers=[]}am.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},am.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},am.prototype.forEach=function(e){om.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var cm=am,dm=rm,um=function(e,t,r,n,i){return e.config=t,r&&(e.code=r),e.request=n,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},lm=um,pm=function(e,t,r,n,i){var s=new Error(e);return lm(s,t,r,n,i)},hm=pm,fm=rm,mm=fm.isStandardBrowserEnv()?{write:function(e,t,r,n,i,s){var o=[];o.push(e+"="+encodeURIComponent(t)),fm.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),fm.isString(n)&&o.push("path="+n),fm.isString(i)&&o.push("domain="+i),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},gm=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},vm=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},ym=rm,bm=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],wm=rm,_m=wm.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=wm.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0},Sm=rm,km=function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(hm("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)},Cm=mm,Rm=sm,Pm=function(e,t){return e&&!gm(t)?vm(e,t):t},Tm=function(e){var t,r,n,i={};return e?(ym.forEach(e.split("\n"),(function(e){if(n=e.indexOf(":"),t=ym.trim(e.substr(0,n)).toLowerCase(),r=ym.trim(e.substr(n+1)),t){if(i[t]&&bm.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([r]):i[t]?i[t]+", "+r:r}})),i):i},Em=_m,Dm=pm,Im=function(e){return new Promise((function(t,r){var n=e.data,i=e.headers,s=e.responseType;Sm.isFormData(n)&&delete i["Content-Type"];var o=new XMLHttpRequest;if(e.auth){var a=e.auth.username||"",c=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.Authorization="Basic "+btoa(a+":"+c)}var d=Pm(e.baseURL,e.url);function u(){if(o){var n="getAllResponseHeaders"in o?Tm(o.getAllResponseHeaders()):null,i={data:s&&"text"!==s&&"json"!==s?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:n,config:e,request:o};km(t,r,i),o=null}}if(o.open(e.method.toUpperCase(),Rm(d,e.params,e.paramsSerializer),!0),o.timeout=e.timeout,"onloadend"in o?o.onloadend=u:o.onreadystatechange=function(){o&&4===o.readyState&&(0!==o.status||o.responseURL&&0===o.responseURL.indexOf("file:"))&&setTimeout(u)},o.onabort=function(){o&&(r(Dm("Request aborted",e,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(Dm("Network Error",e,null,o)),o=null},o.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(Dm(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",o)),o=null},Sm.isStandardBrowserEnv()){var l=(e.withCredentials||Em(d))&&e.xsrfCookieName?Cm.read(e.xsrfCookieName):void 0;l&&(i[e.xsrfHeaderName]=l)}"setRequestHeader"in o&&Sm.forEach(i,(function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete i[t]:o.setRequestHeader(t,e)})),Sm.isUndefined(e.withCredentials)||(o.withCredentials=!!e.withCredentials),s&&"json"!==s&&(o.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&o.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){o&&(o.abort(),r(e),o=null)})),n||(n=null),o.send(n)}))},Mm=rm,xm=function(e,t){dm.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},Om=um,Lm={"Content-Type":"application/x-www-form-urlencoded"};function Am(e,t){!Mm.isUndefined(e)&&Mm.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var jm,Fm={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(jm=Im),jm),transformRequest:[function(e,t){return xm(t,"Accept"),xm(t,"Content-Type"),Mm.isFormData(e)||Mm.isArrayBuffer(e)||Mm.isBuffer(e)||Mm.isStream(e)||Mm.isFile(e)||Mm.isBlob(e)?e:Mm.isArrayBufferView(e)?e.buffer:Mm.isURLSearchParams(e)?(Am(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):Mm.isObject(e)||t&&"application/json"===t["Content-Type"]?(Am(t,"application/json"),function(e,t,r){if(Mm.isString(e))try{return(t||JSON.parse)(e),Mm.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||n&&Mm.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw Om(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};Fm.headers={common:{Accept:"application/json, text/plain, */*"}},Mm.forEach(["delete","get","head"],(function(e){Fm.headers[e]={}})),Mm.forEach(["post","put","patch"],(function(e){Fm.headers[e]=Mm.merge(Lm)}));var Nm=Fm,Bm=rm,Wm=Nm,qm=function(e){return!(!e||!e.__CANCEL__)},Um=rm,zm=function(e,t,r){var n=this||Wm;return Bm.forEach(r,(function(r){e=r.call(n,e,t)})),e},Vm=qm,Hm=Nm;function $m(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var Km=rm,Gm=function(e,t){t=t||{};var r={},n=["url","method","data"],i=["headers","auth","proxy","params"],s=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],o=["validateStatus"];function a(e,t){return Km.isPlainObject(e)&&Km.isPlainObject(t)?Km.merge(e,t):Km.isPlainObject(t)?Km.merge({},t):Km.isArray(t)?t.slice():t}function c(n){Km.isUndefined(t[n])?Km.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(e[n],t[n])}Km.forEach(n,(function(e){Km.isUndefined(t[e])||(r[e]=a(void 0,t[e]))})),Km.forEach(i,c),Km.forEach(s,(function(n){Km.isUndefined(t[n])?Km.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(void 0,t[n])})),Km.forEach(o,(function(n){n in t?r[n]=a(e[n],t[n]):n in e&&(r[n]=a(void 0,e[n]))}));var d=n.concat(i).concat(s).concat(o),u=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===d.indexOf(e)}));return Km.forEach(u,c),r},Qm={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}]},Jm={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){Jm[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var Ym={},Zm=Qm.version.split(".");function Xm(e,t){for(var r=t?t.split("."):Zm,n=e.split("."),i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}Jm.transitional=function(e,t,r){var n=t&&Xm(t);function i(e,t){return"[Axios v"+Qm.version+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,s,o){if(!1===e)throw new Error(i(s," has been removed in "+t));return n&&!Ym[s]&&(Ym[s]=!0,console.warn(i(s," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,s,o)}};var eg={isOlderVersion:Xm,assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),i=n.length;i-- >0;){var s=n[i],o=t[s];if(o){var a=e[s],c=void 0===a||o(a,s,e);if(!0!==c)throw new TypeError("option "+s+" must be "+c)}else if(!0!==r)throw Error("Unknown option "+s)}},validators:Jm},tg=rm,rg=sm,ng=cm,ig=function(e){return $m(e),e.headers=e.headers||{},e.data=zm.call(e,e.data,e.headers,e.transformRequest),e.headers=Um.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Um.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||Hm.adapter)(e).then((function(t){return $m(e),t.data=zm.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return Vm(t)||($m(e),t&&t.response&&(t.response.data=zm.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},sg=Gm,og=eg,ag=og.validators;function cg(e){this.defaults=e,this.interceptors={request:new ng,response:new ng}}cg.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=sg(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&og.assertOptions(t,{silentJSONParsing:ag.transitional(ag.boolean,"1.0.0"),forcedJSONParsing:ag.transitional(ag.boolean,"1.0.0"),clarifyTimeoutError:ag.transitional(ag.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var i,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!n){var o=[ig,void 0];for(Array.prototype.unshift.apply(o,r),o=o.concat(s),i=Promise.resolve(e);o.length;)i=i.then(o.shift(),o.shift());return i}for(var a=e;r.length;){var c=r.shift(),d=r.shift();try{a=c(a)}catch(e){d(e);break}}try{i=ig(a)}catch(e){return Promise.reject(e)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},cg.prototype.getUri=function(e){return e=sg(this.defaults,e),rg(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},tg.forEach(["delete","get","head","options"],(function(e){cg.prototype[e]=function(t,r){return this.request(sg(r||{},{method:e,url:t,data:(r||{}).data}))}})),tg.forEach(["post","put","patch"],(function(e){cg.prototype[e]=function(t,r,n){return this.request(sg(n||{},{method:e,url:t,data:r}))}}));var dg=cg;function ug(e){this.message=e}ug.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},ug.prototype.__CANCEL__=!0;var lg=ug,pg=lg;function hg(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new pg(e),t(r.reason))}))}hg.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},hg.source=function(){var e,t=new hg((function(t){e=t}));return{token:t,cancel:e}};var fg=hg,mg=rm,gg=Kf,vg=dg,yg=Gm;function bg(e){var t=new vg(e),r=gg(vg.prototype.request,t);return mg.extend(r,vg.prototype,t),mg.extend(r,t),r}var wg=bg(Nm);wg.Axios=vg,wg.create=function(e){return bg(yg(wg.defaults,e))},wg.Cancel=lg,wg.CancelToken=fg,wg.isCancel=qm,wg.all=function(e){return Promise.all(e)},wg.spread=function(e){return function(t){return e.apply(null,t)}},wg.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},$f.exports=wg,$f.exports.default=wg;var _g=$f.exports,Sg="undefined"!=typeof Symbol&&Symbol,kg=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0},Cg="Function.prototype.bind called on incompatible ",Rg=Array.prototype.slice,Pg=Object.prototype.toString,Tg=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==Pg.call(t))throw new TypeError(Cg+t);for(var r,n=Rg.call(arguments,1),i=function(){if(this instanceof r){var i=t.apply(this,n.concat(Rg.call(arguments)));return Object(i)===i?i:this}return t.apply(e,n.concat(Rg.call(arguments)))},s=Math.max(0,t.length-n.length),o=[],a=0;a<s;a++)o.push("$"+a);if(r=Function("binder","return function ("+o.join(",")+"){ return binder.apply(this,arguments); }")(i),t.prototype){var c=function(){};c.prototype=t.prototype,r.prototype=new c,c.prototype=null}return r},Eg=Function.prototype.bind||Tg,Dg=Eg.call(Function.call,Object.prototype.hasOwnProperty),Ig=SyntaxError,Mg=Function,xg=TypeError,Og=function(e){try{return Mg('"use strict"; return ('+e+").constructor;")()}catch(e){}},Lg=Object.getOwnPropertyDescriptor;if(Lg)try{Lg({},"")}catch(_t){Lg=null}var Ag=function(){throw new xg},jg=Lg?function(){try{return Ag}catch(e){try{return Lg(arguments,"callee").get}catch(e){return Ag}}}():Ag,Fg="function"==typeof Sg&&"function"==typeof Symbol&&"symbol"==typeof Sg("foo")&&"symbol"==typeof Symbol("bar")&&kg(),Ng=Object.getPrototypeOf||function(e){return e.__proto__},Bg={},Wg="undefined"==typeof Uint8Array?undefined:Ng(Uint8Array),qg={"%AggregateError%":"undefined"==typeof AggregateError?undefined:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?undefined:ArrayBuffer,"%ArrayIteratorPrototype%":Fg?Ng([][Symbol.iterator]()):undefined,"%AsyncFromSyncIteratorPrototype%":undefined,"%AsyncFunction%":Bg,"%AsyncGenerator%":Bg,"%AsyncGeneratorFunction%":Bg,"%AsyncIteratorPrototype%":Bg,"%Atomics%":"undefined"==typeof Atomics?undefined:Atomics,"%BigInt%":"undefined"==typeof BigInt?undefined:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?undefined:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?undefined:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?undefined:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?undefined:FinalizationRegistry,"%Function%":Mg,"%GeneratorFunction%":Bg,"%Int8Array%":"undefined"==typeof Int8Array?undefined:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?undefined:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?undefined:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Fg?Ng(Ng([][Symbol.iterator]())):undefined,"%JSON%":"object"==typeof JSON?JSON:undefined,"%Map%":"undefined"==typeof Map?undefined:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&Fg?Ng((new Map)[Symbol.iterator]()):undefined,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?undefined:Promise,"%Proxy%":"undefined"==typeof Proxy?undefined:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?undefined:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?undefined:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&Fg?Ng((new Set)[Symbol.iterator]()):undefined,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?undefined:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Fg?Ng(""[Symbol.iterator]()):undefined,"%Symbol%":Fg?Symbol:undefined,"%SyntaxError%":Ig,"%ThrowTypeError%":jg,"%TypedArray%":Wg,"%TypeError%":xg,"%Uint8Array%":"undefined"==typeof Uint8Array?undefined:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?undefined:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?undefined:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?undefined:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?undefined:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?undefined:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?undefined:WeakSet},Ug=function e(t){var r;if("%AsyncFunction%"===t)r=Og("async function () {}");else if("%GeneratorFunction%"===t)r=Og("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=Og("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&(r=Ng(i.prototype))}return qg[t]=r,r},zg={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},Vg=Eg,Hg=Dg,$g=Vg.call(Function.call,Array.prototype.concat),Kg=Vg.call(Function.apply,Array.prototype.splice),Gg=Vg.call(Function.call,String.prototype.replace),Qg=Vg.call(Function.call,String.prototype.slice),Jg=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Yg=/\\(\\)?/g,Zg=function(e){var t=Qg(e,0,1),r=Qg(e,-1);if("%"===t&&"%"!==r)throw new Ig("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new Ig("invalid intrinsic syntax, expected opening `%`");var n=[];return Gg(e,Jg,(function(e,t,r,i){n[n.length]=r?Gg(i,Yg,"$1"):t||e})),n},Xg=function(e,t){var r,n=e;if(Hg(zg,n)&&(n="%"+(r=zg[n])[0]+"%"),Hg(qg,n)){var i=qg[n];if(i===Bg&&(i=Ug(n)),void 0===i&&!t)throw new xg("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new Ig("intrinsic "+e+" does not exist!")},ev=function(e,t){if("string"!=typeof e||0===e.length)throw new xg("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new xg('"allowMissing" argument must be a boolean');var r=Zg(e),n=r.length>0?r[0]:"",i=Xg("%"+n+"%",t),s=i.name,o=i.value,a=!1,c=i.alias;c&&(n=c[0],Kg(r,$g([0,1],c)));for(var d=1,u=!0;d<r.length;d+=1){var l=r[d],p=Qg(l,0,1),h=Qg(l,-1);if(('"'===p||"'"===p||"`"===p||'"'===h||"'"===h||"`"===h)&&p!==h)throw new Ig("property names with quotes must have matching quotes");if("constructor"!==l&&u||(a=!0),Hg(qg,s="%"+(n+="."+l)+"%"))o=qg[s];else if(null!=o){if(!(l in o)){if(!t)throw new xg("base intrinsic for "+e+" exists, but the property is not available.");return}if(Lg&&d+1>=r.length){var f=Lg(o,l);o=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:o[l]}else u=Hg(o,l),o=o[l];u&&!a&&(qg[s]=o)}}return o},tv={exports:{}};!function(e){var t=Eg,r=ev,n=r("%Function.prototype.apply%"),i=r("%Function.prototype.call%"),s=r("%Reflect.apply%",!0)||t.call(i,n),o=r("%Object.getOwnPropertyDescriptor%",!0),a=r("%Object.defineProperty%",!0),c=r("%Math.max%");if(a)try{a({},"a",{value:1})}catch(e){a=null}e.exports=function(e){var r=s(t,i,arguments);if(o&&a){var n=o(r,"length");n.configurable&&a(r,"length",{value:1+c(0,e.length-(arguments.length-1))})}return r};var d=function(){return s(t,n,arguments)};a?a(e.exports,"apply",{value:d}):e.exports.apply=d}(tv);var rv=ev,nv=tv.exports,iv=nv(rv("String.prototype.indexOf")),sv=h(Object.freeze({__proto__:null,default:{}})),ov="function"==typeof Map&&Map.prototype,av=Object.getOwnPropertyDescriptor&&ov?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,cv=ov&&av&&"function"==typeof av.get?av.get:null,dv=ov&&Map.prototype.forEach,uv="function"==typeof Set&&Set.prototype,lv=Object.getOwnPropertyDescriptor&&uv?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,pv=uv&&lv&&"function"==typeof lv.get?lv.get:null,hv=uv&&Set.prototype.forEach,fv="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,mv="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,gv="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,vv=Boolean.prototype.valueOf,yv=Object.prototype.toString,bv=Function.prototype.toString,wv=String.prototype.match,_v="function"==typeof BigInt?BigInt.prototype.valueOf:null,Sv=Object.getOwnPropertySymbols,kv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,Cv="function"==typeof Symbol&&"object"==typeof Symbol.iterator,Rv=Object.prototype.propertyIsEnumerable,Pv=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null),Tv=sv.custom,Ev=Tv&&Ov(Tv)?Tv:null,Dv="function"==typeof Symbol&&void 0!==Symbol.toStringTag?Symbol.toStringTag:null;function Iv(e,t,r){var n="double"===(r.quoteStyle||t)?'"':"'";return n+e+n}function Mv(e){return String(e).replace(/"/g,""")}function xv(e){return!("[object Array]"!==jv(e)||Dv&&"object"==typeof e&&Dv in e)}function Ov(e){if(Cv)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!kv)return!1;try{return kv.call(e),!0}catch(e){}return!1}var Lv=Object.prototype.hasOwnProperty||function(e){return e in this};function Av(e,t){return Lv.call(e,t)}function jv(e){return yv.call(e)}function Fv(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}function Nv(e,t){if(e.length>t.maxStringLength){var r=e.length-t.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return Nv(e.slice(0,t.maxStringLength),t)+n}return Iv(e.replace(/(['\\])/g,"\\$1").replace(/[\x00-\x1f]/g,Bv),"single",t)}function Bv(e){var t=e.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return r?"\\"+r:"\\x"+(t<16?"0":"")+t.toString(16).toUpperCase()}function Wv(e){return"Object("+e+")"}function qv(e){return e+" { ? }"}function Uv(e,t,r,n){return e+" ("+t+") {"+(n?zv(r,n):r.join(", "))+"}"}function zv(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+e.join(","+r)+"\n"+t.prev}function Vv(e,t){var r=xv(e),n=[];if(r){n.length=e.length;for(var i=0;i<e.length;i++)n[i]=Av(e,i)?t(e[i],e):""}var s,o="function"==typeof Sv?Sv(e):[];if(Cv){s={};for(var a=0;a<o.length;a++)s["$"+o[a]]=o[a]}for(var c in e)Av(e,c)&&(r&&String(Number(c))===c&&c<e.length||Cv&&s["$"+c]instanceof Symbol||(/[^\w$]/.test(c)?n.push(t(c,e)+": "+t(e[c],e)):n.push(c+": "+t(e[c],e))));if("function"==typeof Sv)for(var d=0;d<o.length;d++)Rv.call(e,o[d])&&n.push("["+t(o[d])+"]: "+t(e[o[d]],e));return n}var Hv=ev,$v=function(e,t){var r=rv(e,!!t);return"function"==typeof r&&iv(e,".prototype.")>-1?nv(r):r},Kv=function e(t,r,n,i){var s=r||{};if(Av(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Av(s,"maxStringLength")&&("number"==typeof s.maxStringLength?s.maxStringLength<0&&s.maxStringLength!==1/0:null!==s.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=!Av(s,"customInspect")||s.customInspect;if("boolean"!=typeof o&&"symbol"!==o)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Av(s,"indent")&&null!==s.indent&&"\t"!==s.indent&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('options "indent" must be "\\t", an integer > 0, or `null`');if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return Nv(t,s);if("number"==typeof t)return 0===t?1/0/t>0?"0":"-0":String(t);if("bigint"==typeof t)return String(t)+"n";var a=void 0===s.depth?5:s.depth;if(void 0===n&&(n=0),n>=a&&a>0&&"object"==typeof t)return xv(t)?"[Array]":"[Object]";var c=function(e,t){var r;if("\t"===e.indent)r="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;r=Array(e.indent+1).join(" ")}return{base:r,prev:Array(t+1).join(r)}}(s,n);if(void 0===i)i=[];else if(Fv(i,t)>=0)return"[Circular]";function d(t,r,o){if(r&&(i=i.slice()).push(r),o){var a={depth:s.depth};return Av(s,"quoteStyle")&&(a.quoteStyle=s.quoteStyle),e(t,a,n+1,i)}return e(t,s,n+1,i)}if("function"==typeof t){var u=function(e){if(e.name)return e.name;var t=wv.call(bv.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),l=Vv(t,d);return"[Function"+(u?": "+u:" (anonymous)")+"]"+(l.length>0?" { "+l.join(", ")+" }":"")}if(Ov(t)){var p=Cv?String(t).replace(/^(Symbol\(.*\))_[^)]*$/,"$1"):kv.call(t);return"object"!=typeof t||Cv?p:Wv(p)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var h="<"+String(t.nodeName).toLowerCase(),f=t.attributes||[],m=0;m<f.length;m++)h+=" "+f[m].name+"="+Iv(Mv(f[m].value),"double",s);return h+=">",t.childNodes&&t.childNodes.length&&(h+="..."),h+="</"+String(t.nodeName).toLowerCase()+">"}if(xv(t)){if(0===t.length)return"[]";var g=Vv(t,d);return c&&!function(e){for(var t=0;t<e.length;t++)if(Fv(e[t],"\n")>=0)return!1;return!0}(g)?"["+zv(g,c)+"]":"[ "+g.join(", ")+" ]"}if(function(e){return!("[object Error]"!==jv(e)||Dv&&"object"==typeof e&&Dv in e)}(t)){var v=Vv(t,d);return 0===v.length?"["+String(t)+"]":"{ ["+String(t)+"] "+v.join(", ")+" }"}if("object"==typeof t&&o){if(Ev&&"function"==typeof t[Ev])return t[Ev]();if("symbol"!==o&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!cv||!e||"object"!=typeof e)return!1;try{cv.call(e);try{pv.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var y=[];return dv.call(t,(function(e,r){y.push(d(r,t,!0)+" => "+d(e,t))})),Uv("Map",cv.call(t),y,c)}if(function(e){if(!pv||!e||"object"!=typeof e)return!1;try{pv.call(e);try{cv.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var b=[];return hv.call(t,(function(e){b.push(d(e,t))})),Uv("Set",pv.call(t),b,c)}if(function(e){if(!fv||!e||"object"!=typeof e)return!1;try{fv.call(e,fv);try{mv.call(e,mv)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return qv("WeakMap");if(function(e){if(!mv||!e||"object"!=typeof e)return!1;try{mv.call(e,mv);try{fv.call(e,fv)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return qv("WeakSet");if(function(e){if(!gv||!e||"object"!=typeof e)return!1;try{return gv.call(e),!0}catch(e){}return!1}(t))return qv("WeakRef");if(function(e){return!("[object Number]"!==jv(e)||Dv&&"object"==typeof e&&Dv in e)}(t))return Wv(d(Number(t)));if(function(e){if(!e||"object"!=typeof e||!_v)return!1;try{return _v.call(e),!0}catch(e){}return!1}(t))return Wv(d(_v.call(t)));if(function(e){return!("[object Boolean]"!==jv(e)||Dv&&"object"==typeof e&&Dv in e)}(t))return Wv(vv.call(t));if(function(e){return!("[object String]"!==jv(e)||Dv&&"object"==typeof e&&Dv in e)}(t))return Wv(d(String(t)));if(!function(e){return!("[object Date]"!==jv(e)||Dv&&"object"==typeof e&&Dv in e)}(t)&&!function(e){return!("[object RegExp]"!==jv(e)||Dv&&"object"==typeof e&&Dv in e)}(t)){var w=Vv(t,d),_=Pv?Pv(t)===Object.prototype:t instanceof Object||t.constructor===Object,S=t instanceof Object?"":"null prototype",k=!_&&Dv&&Object(t)===t&&Dv in t?jv(t).slice(8,-1):S?"Object":"",C=(_||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(k||S?"["+[].concat(k||[],S||[]).join(": ")+"] ":"");return 0===w.length?C+"{}":c?C+"{"+zv(w,c)+"}":C+"{ "+w.join(", ")+" }"}return String(t)},Gv=Hv("%TypeError%"),Qv=Hv("%WeakMap%",!0),Jv=Hv("%Map%",!0),Yv=$v("WeakMap.prototype.get",!0),Zv=$v("WeakMap.prototype.set",!0),Xv=$v("WeakMap.prototype.has",!0),ey=$v("Map.prototype.get",!0),ty=$v("Map.prototype.set",!0),ry=$v("Map.prototype.has",!0),ny=function(e,t){for(var r,n=e;null!==(r=n.next);n=r)if(r.key===t)return n.next=r.next,r.next=e.next,e.next=r,r},iy=String.prototype.replace,sy=/%20/g,oy="RFC3986",ay={default:oy,formatters:{RFC1738:function(e){return iy.call(e,sy,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:oy},cy=ay,dy=Object.prototype.hasOwnProperty,uy=Array.isArray,ly=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),py=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},n=0;n<e.length;++n)void 0!==e[n]&&(r[n]=e[n]);return r},hy={arrayToObject:py,assign:function(e,t){return Object.keys(t).reduce((function(e,r){return e[r]=t[r],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],n=0;n<t.length;++n)for(var i=t[n],s=i.obj[i.prop],o=Object.keys(s),a=0;a<o.length;++a){var c=o[a],d=s[c];"object"==typeof d&&null!==d&&-1===r.indexOf(d)&&(t.push({obj:s,prop:c}),r.push(d))}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(uy(r)){for(var n=[],i=0;i<r.length;++i)void 0!==r[i]&&n.push(r[i]);t.obj[t.prop]=n}}}(t),e},decode:function(e,t,r){var n=e.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(e){return n}},encode:function(e,t,r,n,i){if(0===e.length)return e;var s=e;if("symbol"==typeof e?s=Symbol.prototype.toString.call(e):"string"!=typeof e&&(s=String(e)),"iso-8859-1"===r)return escape(s).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var o="",a=0;a<s.length;++a){var c=s.charCodeAt(a);45===c||46===c||95===c||126===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||i===cy.RFC1738&&(40===c||41===c)?o+=s.charAt(a):c<128?o+=ly[c]:c<2048?o+=ly[192|c>>6]+ly[128|63&c]:c<55296||c>=57344?o+=ly[224|c>>12]+ly[128|c>>6&63]+ly[128|63&c]:(a+=1,c=65536+((1023&c)<<10|1023&s.charCodeAt(a)),o+=ly[240|c>>18]+ly[128|c>>12&63]+ly[128|c>>6&63]+ly[128|63&c])}return o},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(uy(e)){for(var r=[],n=0;n<e.length;n+=1)r.push(t(e[n]));return r}return t(e)},merge:function e(t,r,n){if(!r)return t;if("object"!=typeof r){if(uy(t))t.push(r);else{if(!t||"object"!=typeof t)return[t,r];(n&&(n.plainObjects||n.allowPrototypes)||!dy.call(Object.prototype,r))&&(t[r]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(r);var i=t;return uy(t)&&!uy(r)&&(i=py(t,n)),uy(t)&&uy(r)?(r.forEach((function(r,i){if(dy.call(t,i)){var s=t[i];s&&"object"==typeof s&&r&&"object"==typeof r?t[i]=e(s,r,n):t.push(r)}else t[i]=r})),t):Object.keys(r).reduce((function(t,i){var s=r[i];return dy.call(t,i)?t[i]=e(t[i],s,n):t[i]=s,t}),i)}},fy=function(){var e,t,r,n={assert:function(e){if(!n.has(e))throw new Gv("Side channel does not contain "+Kv(e))},get:function(n){if(Qv&&n&&("object"==typeof n||"function"==typeof n)){if(e)return Yv(e,n)}else if(Jv){if(t)return ey(t,n)}else if(r)return function(e,t){var r=ny(e,t);return r&&r.value}(r,n)},has:function(n){if(Qv&&n&&("object"==typeof n||"function"==typeof n)){if(e)return Xv(e,n)}else if(Jv){if(t)return ry(t,n)}else if(r)return function(e,t){return!!ny(e,t)}(r,n);return!1},set:function(n,i){Qv&&n&&("object"==typeof n||"function"==typeof n)?(e||(e=new Qv),Zv(e,n,i)):Jv?(t||(t=new Jv),ty(t,n,i)):(r||(r={key:{},next:null}),function(e,t,r){var n=ny(e,t);n?n.value=r:e.next={key:t,next:e.next,value:r}}(r,n,i))}};return n},my=hy,gy=ay,vy=Object.prototype.hasOwnProperty,yy={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},by=Array.isArray,wy=String.prototype.split,_y=Array.prototype.push,Sy=function(e,t){_y.apply(e,by(t)?t:[t])},ky=Date.prototype.toISOString,Cy=gy.default,Ry={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:my.encode,encodeValuesOnly:!1,format:Cy,formatter:gy.formatters[Cy],indices:!1,serializeDate:function(e){return ky.call(e)},skipNulls:!1,strictNullHandling:!1},Py={},Ty=function e(t,r,n,i,s,o,a,c,d,u,l,p,h,f,m,g){for(var v=t,y=g,b=0,w=!1;void 0!==(y=y.get(Py))&&!w;){var _=y.get(t);if(b+=1,void 0!==_){if(_===b)throw new RangeError("Cyclic object value");w=!0}void 0===y.get(Py)&&(b=0)}if("function"==typeof c?v=c(r,v):v instanceof Date?v=l(v):"comma"===n&&by(v)&&(v=my.maybeMap(v,(function(e){return e instanceof Date?l(e):e}))),null===v){if(s)return a&&!f?a(r,Ry.encoder,m,"key",p):r;v=""}if(function(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||"symbol"==typeof e||"bigint"==typeof e}(v)||my.isBuffer(v)){if(a){var S=f?r:a(r,Ry.encoder,m,"key",p);if("comma"===n&&f){for(var k=wy.call(String(v),","),C="",R=0;R<k.length;++R)C+=(0===R?"":",")+h(a(k[R],Ry.encoder,m,"value",p));return[h(S)+(i&&by(v)&&1===k.length?"[]":"")+"="+C]}return[h(S)+"="+h(a(v,Ry.encoder,m,"value",p))]}return[h(r)+"="+h(String(v))]}var P,T=[];if(void 0===v)return T;if("comma"===n&&by(v))P=[{value:v.length>0?v.join(",")||null:void 0}];else if(by(c))P=c;else{var E=Object.keys(v);P=d?E.sort(d):E}for(var D=i&&by(v)&&1===v.length?r+"[]":r,I=0;I<P.length;++I){var M=P[I],x="object"==typeof M&&void 0!==M.value?M.value:v[M];if(!o||null!==x){var O=by(v)?"function"==typeof n?n(D,M):D:D+(u?"."+M:"["+M+"]");g.set(t,b);var L=fy();L.set(Py,g),Sy(T,e(x,O,n,i,s,o,a,c,d,u,l,p,h,f,m,L))}}return T},Ey=hy,Dy=Object.prototype.hasOwnProperty,Iy=Array.isArray,My={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Ey.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},xy=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},Oy=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},Ly=function(e,t,r,n){if(e){var i=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,s=/(\[[^[\]]*])/g,o=r.depth>0&&/(\[[^[\]]*])/.exec(i),a=o?i.slice(0,o.index):i,c=[];if(a){if(!r.plainObjects&&Dy.call(Object.prototype,a)&&!r.allowPrototypes)return;c.push(a)}for(var d=0;r.depth>0&&null!==(o=s.exec(i))&&d<r.depth;){if(d+=1,!r.plainObjects&&Dy.call(Object.prototype,o[1].slice(1,-1))&&!r.allowPrototypes)return;c.push(o[1])}return o&&c.push("["+i.slice(o.index)+"]"),function(e,t,r,n){for(var i=n?t:Oy(t,r),s=e.length-1;s>=0;--s){var o,a=e[s];if("[]"===a&&r.parseArrays)o=[].concat(i);else{o=r.plainObjects?Object.create(null):{};var c="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,d=parseInt(c,10);r.parseArrays||""!==c?!isNaN(d)&&a!==c&&String(d)===c&&d>=0&&r.parseArrays&&d<=r.arrayLimit?(o=[])[d]=i:"__proto__"!==c&&(o[c]=i):o={0:i}}i=o}return i}(c,t,r,n)}},Ay=function(e,t){var r,n=e,i=function(e){if(!e)return Ry;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Ry.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=gy.default;if(void 0!==e.format){if(!vy.call(gy.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n=gy.formatters[r],i=Ry.filter;return("function"==typeof e.filter||by(e.filter))&&(i=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Ry.addQueryPrefix,allowDots:void 0===e.allowDots?Ry.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Ry.charsetSentinel,delimiter:void 0===e.delimiter?Ry.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Ry.encode,encoder:"function"==typeof e.encoder?e.encoder:Ry.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Ry.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Ry.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Ry.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Ry.strictNullHandling}}(t);"function"==typeof i.filter?n=(0,i.filter)("",n):by(i.filter)&&(r=i.filter);var s,o=[];if("object"!=typeof n||null===n)return"";s=t&&t.arrayFormat in yy?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var a=yy[s];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var c="comma"===a&&t&&t.commaRoundTrip;r||(r=Object.keys(n)),i.sort&&r.sort(i.sort);for(var d=fy(),u=0;u<r.length;++u){var l=r[u];i.skipNulls&&null===n[l]||Sy(o,Ty(n[l],l,a,c,i.strictNullHandling,i.skipNulls,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,d))}var p=o.join(i.delimiter),h=!0===i.addQueryPrefix?"?":"";return i.charsetSentinel&&("iso-8859-1"===i.charset?h+="utf8=%26%2310003%3B&":h+="utf8=%E2%9C%93&"),p.length>0?h+p:""},jy=function(e,t){var r=function(e){if(!e)return My;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?My.charset:e.charset;return{allowDots:void 0===e.allowDots?My.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:My.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:My.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:My.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:My.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:My.comma,decoder:"function"==typeof e.decoder?e.decoder:My.decoder,delimiter:"string"==typeof e.delimiter||Ey.isRegExp(e.delimiter)?e.delimiter:My.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:My.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:My.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:My.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:My.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:My.strictNullHandling}}(t);if(""===e||null==e)return r.plainObjects?Object.create(null):{};for(var n="string"==typeof e?function(e,t){var r,n={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,s=t.parameterLimit===1/0?void 0:t.parameterLimit,o=i.split(t.delimiter,s),a=-1,c=t.charset;if(t.charsetSentinel)for(r=0;r<o.length;++r)0===o[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===o[r]?c="utf-8":"utf8=%26%2310003%3B"===o[r]&&(c="iso-8859-1"),a=r,r=o.length);for(r=0;r<o.length;++r)if(r!==a){var d,u,l=o[r],p=l.indexOf("]="),h=-1===p?l.indexOf("="):p+1;-1===h?(d=t.decoder(l,My.decoder,c,"key"),u=t.strictNullHandling?null:""):(d=t.decoder(l.slice(0,h),My.decoder,c,"key"),u=Ey.maybeMap(Oy(l.slice(h+1),t),(function(e){return t.decoder(e,My.decoder,c,"value")}))),u&&t.interpretNumericEntities&&"iso-8859-1"===c&&(u=xy(u)),l.indexOf("[]=")>-1&&(u=Iy(u)?[u]:u),Dy.call(n,d)?n[d]=Ey.combine(n[d],u):n[d]=u}return n}(e,r):e,i=r.plainObjects?Object.create(null):{},s=Object.keys(n),o=0;o<s.length;++o){var a=s[o],c=Ly(a,n[a],r,"string"==typeof e);i=Ey.merge(i,c,r)}return!0===r.allowSparse?i:Ey.compact(i)},Fy={formats:ay,parse:jy,stringify:Ay};let Ny=class{constructor(e){this.config=e;const t=this.config.get("loadbalancer"),{baseURL:r,timeout:n,customNode:i}=t;this.api=_g.create({baseURL:r||"https://lb.livedigital.space/v1",timeout:n||5e3,withCredentials:!1,paramsSerializer:e=>Fy.stringify(e)}),this.customNode=i}getNode(e){return a(this,void 0,void 0,(function*(){if(this.customNode)return this.customNode;const{data:t}=yield this.api.get("/nodes/best",{params:e});return t}))}checkServiceAvailability(e=2e3){return a(this,void 0,void 0,(function*(){try{const{status:t}=yield this.api.options("/nodes/best",{timeout:e});return[200,204].includes(t)}catch(e){return!1}}))}};Ny=i([at(),s(0,dt(Qn.Config)),o("design:paramtypes",[Ct])],Ny);var By,Wy=Ny;let qy=class{constructor(e,t){this.clientEventEmitter=e,this.isEnableVideoDevicesLock=!1,this.isEnableAudioDevicesLock=!1,this.isDevicesDetected=!1,this.availableVideoDevices=[],this.availableAudioDevices=[],By.set(this,void 0),d(this,By,t("System"),"f"),this.deviceChangeHandler=this.deviceChangeHandler.bind(this),this.listenDevices()}setIsEnableVideoDevicesLock(e){this.isEnableVideoDevicesLock=e}setIsEnableAudioDevicesLock(e){this.isEnableAudioDevicesLock=e}setAvailableVideoDevices(e){this.availableVideoDevices=e}setAvailableAudioDevices(e){this.availableAudioDevices=e}requestMediaDevicesAccess(e={video:!0,audio:!0}){return a(this,void 0,void 0,(function*(){try{return(yield navigator.mediaDevices.getUserMedia(e)).getTracks()}catch(t){if(c(this,By,"f").error("getUserMedia()",{error:t,constraints:e}),"NotAllowedError"===t.name)throw new Error(Yn.NotAllowedError);if("NotReadableError"===t.name)throw new Error(Yn.DeviceIsBusy);if("NotFoundError"===t.name)throw new Error(Yn.NotFoundError);throw new Error(Yn.RequestDevicesUnknownError)}}))}hasAvailableMediaDevicesList(){return a(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices();if(0===e.length)return!0;return e.every((e=>e.deviceId&&e.label))}))}refreshAvailableMediaDevicesList(){return a(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices(),t=[],r=[];e.forEach((e=>{""!==e.deviceId&&("videoinput"===e.kind&&t.push(e),"audioinput"===e.kind&&r.push(e))})),this.setAvailableVideoDevices(t),this.setAvailableAudioDevices(r);const n=({label:e,kind:t})=>({label:e,kind:t});return c(this,By,"f").debug("Devices list updated",{videoDevices:t.map(n),audioDevices:r.map(n)}),e}))}detectDevices(e){return a(this,void 0,void 0,(function*(){if(this.isDevicesDetected&&!e)return;(yield this.hasAvailableMediaDevicesList())||(yield this.tryToAccessDevices()),this.isDevicesDetected=!0;const t=yield this.refreshAvailableMediaDevicesList(),r=t.some((e=>"audioinput"===e.kind)),n=t.some((e=>"videoinput"===e.kind));if(!r&&!n)throw new Error(Yn.NoDevices)}))}deviceChangeHandler(){return a(this,void 0,void 0,(function*(){this.isDevicesDetected&&(yield this.refreshAvailableMediaDevicesList(),this.clientEventEmitter.safeEmit(qr,{audio:this.availableAudioDevices,video:this.availableVideoDevices}))}))}listenDevices(){navigator.mediaDevices.addEventListener("devicechange",this.deviceChangeHandler)}assertHasAccessToMediaDevices(e={video:!0,audio:!0}){return a(this,void 0,void 0,(function*(){(yield this.requestMediaDevicesAccess(e)).forEach((e=>e.stop()))}))}tryToAccessDevices(){return a(this,void 0,void 0,(function*(){try{(yield this.requestMediaDevicesAccess()).forEach((e=>e.stop()))}catch(t){if(e=t.message,![Yn.NotFoundError,Yn.NotAllowedError,Yn.DeviceIsBusy].includes(e))throw t;t.message!==Yn.DeviceIsBusy&&(yield this.assertHasAccessToMediaDevices({audio:!0}),yield this.assertHasAccessToMediaDevices({video:!0}))}var e}))}};By=new WeakMap,qy=i([at(),s(0,dt(Qn.ClientEventEmitter)),s(1,dt(Qn.LoggerFactory)),o("design:paramtypes",[Rt,Function])],qy);var Uy,zy,Vy,Hy,$y,Ky,Gy,Qy,Jy,Yy,Zy=qy;class Xy{constructor({sendTransportConnectionManager:e,receiveTransportConnectionManager:t,media:r,peers:n}){Uy.set(this,void 0),zy.set(this,void 0),Vy.set(this,void 0),Hy.set(this,void 0),d(this,Uy,e,"f"),d(this,zy,t,"f"),d(this,Vy,r,"f"),d(this,Hy,n,"f")}getStats(){var e,t;return Object.assign(Object.assign({},(null===(e=c(this,Uy,"f").connectionStats)||void 0===e?void 0:e.id)?{outbound:Object.assign(Object.assign({},c(this,Uy,"f").connectionStats),{bitrate:this.calculateOutboundTracksBitrate()})}:{}),(null===(t=c(this,zy,"f").connectionStats)||void 0===t?void 0:t.id)?{inbound:Object.assign(Object.assign({},c(this,zy,"f").connectionStats),{bitrate:this.calculateInboundTracksBitrate()})}:{})}calculateInboundTracksBitrate(){return c(this,Hy,"f").hosts().reduce(((e,t)=>{if(t.isMe)return e;const r=Array.from(t.tracks.values()).reduce(((e,t)=>{var r,n;const i="video"===t.kind?null===(r=t.videoWebRTCStats)||void 0===r?void 0:r.bitrate:null===(n=t.audioWebRTCStats)||void 0===n?void 0:n.bitrate;return e+(null!=i?i:0)}),0);return e+r}),0)}calculateOutboundTracksBitrate(){return c(this,Vy,"f").getAllTracks().reduce(((e,t)=>{var r,n;if(!t.isPublished)return e;const i="video"===t.kind?null===(r=t.videoWebRTCStats)||void 0===r?void 0:r.bitrate:null===(n=t.audioWebRTCStats)||void 0===n?void 0:n.bitrate;return e+(null!=i?i:0)}),0)}}Uy=new WeakMap,zy=new WeakMap,Vy=new WeakMap,Hy=new WeakMap;class eb{constructor({transport:e,statsHandler:t}){$y.set(this,void 0),this.handleWebRTCStats(e,t)}get connectionStats(){return c(this,$y,"f")}handleWebRTCStats(e,t){t.addConnectionHandler(e.id,this.setConnectionStats.bind(this)),e.observer.once("close",(()=>{t.removeConnectionHandler(e.id)}))}setConnectionStats(e){d(this,$y,e,"f")}}$y=new WeakMap;let tb=class{constructor(){Ky.set(this,new Map),Gy.set(this,new Map),Qy.set(this,new Map),Jy.set(this,new Map),Yy.set(this,new Map)}handle(e){e.forEach((({id:e,stats:t})=>{var r;null===(r=c(this,Ky,"f").get(e))||void 0===r||r(t.connection),t.video.inbound.forEach((e=>{var t;return null===(t=c(this,Gy,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.inbound.forEach((e=>{var t;return null===(t=c(this,Qy,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.video.outbound.forEach((e=>{var t;return null===(t=c(this,Jy,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.outbound.forEach((e=>{var t;return null===(t=c(this,Yy,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)}))}))}addConnectionHandler(e,t){c(this,Ky,"f").set(e,t)}addInboundVideoHandler(e,t){c(this,Gy,"f").set(e,t)}addInboundAudioHandler(e,t){c(this,Qy,"f").set(e,t)}addOutboundVideoHandler(e,t){c(this,Jy,"f").set(e,t)}addOutboundAudioHandler(e,t){c(this,Yy,"f").set(e,t)}removeConnectionHandler(e){c(this,Ky,"f").delete(e)}removeInboundVideoHandler(e){c(this,Gy,"f").delete(e)}removeInboundAudioHandler(e){c(this,Jy,"f").delete(e)}removeOutboundVideoHandler(e){c(this,Yy,"f").delete(e)}removeOutboundAudioHandler(e){c(this,Yy,"f").delete(e)}clear(){c(this,Ky,"f").clear(),c(this,Gy,"f").clear(),c(this,Qy,"f").clear(),c(this,Jy,"f").clear(),c(this,Yy,"f").clear()}};Ky=new WeakMap,Gy=new WeakMap,Qy=new WeakMap,Jy=new WeakMap,Yy=new WeakMap,tb=i([at()],tb);var rb,nb,ib,sb,ob,ab=tb;class cb extends Bn{constructor(e,t){super(e,null!=t?t:"invalid_payload")}}!function(e){e.DominantSpeaker="dominant-speaker",e.PeersVolumes="peers-volumes",e.Silence="silence"}(rb||(rb={}));let db=ob=class{constructor(e,t,r){this.peers=e,this.clientEventEmitter=t,nb.set(this,void 0),ib.set(this,void 0),sb.set(this,void 0),d(this,nb,r("ChannelAudioObserverEventHandler"),"f"),this.watchPeersLeave()}handle(e){try{const t=JSON.parse(e);switch(ob.validateEventPayload(t),t.event){case rb.DominantSpeaker:this.handleDominantSpeaker(t);break;case rb.PeersVolumes:this.handlePeerVolumes(t);break;case rb.Silence:this.handleSilence()}}catch(t){c(this,nb,"f").warn("Failed to handle audio observer event",{error:hr(t),eventData:e})}}handleDominantSpeaker(e){const{peerId:t}=e.data,r=this.peers.get(t);d(this,ib,r,"f"),d(this,sb,r,"f"),this.peers.setActiveSpeaker(r)}handlePeerVolumes(e){e.volumes.forEach((e=>{var t;const{peerId:r,trackLabel:n,value:i}=e,s=this.peers.get(r);if(!s)return;i>0&&!c(this,ib,"f")&&s.id===(null===(t=c(this,sb,"f"))||void 0===t?void 0:t.id)&&(d(this,ib,s,"f"),this.peers.setActiveSpeaker(s));const o=null==s?void 0:s.tracks.get(n);o&&o.setVolume(i)}))}handleSilence(){this.peers.all().flatMap((e=>Array.from(e.tracks.values()))).forEach((e=>e.setVolume(0))),d(this,ib,void 0,"f"),this.peers.setActiveSpeaker(void 0)}watchPeersLeave(){this.clientEventEmitter.on(jr,(e=>{var t;e===(null===(t=c(this,ib,"f"))||void 0===t?void 0:t.id)&&this.peers.setActiveSpeaker(void 0)}))}static validateEventPayload(e){switch(e.event){case rb.Silence:break;case rb.DominantSpeaker:{e.data||ob.throwInvalidPayload();const{peerId:t,producerId:r,trackLabel:n}=e.data;"string"==typeof t&&"string"==typeof r&&n===Jn.Microphone||ob.throwInvalidPayload();break}case rb.PeersVolumes:Array.isArray(e.volumes)||ob.throwInvalidPayload(),e.volumes.forEach((e=>{const{peerId:t,producerId:r,value:n,trackLabel:i}=e;"string"==typeof t&&"string"==typeof r&&"number"==typeof n&&i===Jn.Microphone||ob.throwInvalidPayload()}));break;default:ob.throwInvalidPayload()}}static throwInvalidPayload(){throw new cb("Invalid channel audio observer event handler payload")}};nb=new WeakMap,ib=new WeakMap,sb=new WeakMap,db=ob=i([at(),s(0,dt(Qn.Peers)),s(1,dt(Qn.ClientEventEmitter)),s(2,dt(Qn.LoggerFactory)),o("design:paramtypes",[$h,Rt,Function])],db);var ub=db,lb=Uint8Array,pb=Uint16Array,hb=Int32Array,fb=new lb([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),mb=new lb([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),gb=new lb([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),vb=function(e,t){for(var r=new pb(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];var i=new hb(r[30]);for(n=1;n<30;++n)for(var s=r[n];s<r[n+1];++s)i[s]=s-r[n]<<5|n;return{b:r,r:i}},yb=vb(fb,2),bb=yb.b,wb=yb.r;bb[28]=258,wb[258]=28;for(var _b=vb(mb,0).b,Sb=new pb(32768),kb=0;kb<32768;++kb){var Cb=(43690&kb)>>1|(21845&kb)<<1;Cb=(61680&(Cb=(52428&Cb)>>2|(13107&Cb)<<2))>>4|(3855&Cb)<<4,Sb[kb]=((65280&Cb)>>8|(255&Cb)<<8)>>1}var Rb=function(e,t,r){for(var n=e.length,i=0,s=new pb(t);i<n;++i)e[i]&&++s[e[i]-1];var o,a=new pb(t);for(i=1;i<t;++i)a[i]=a[i-1]+s[i-1]<<1;if(r){o=new pb(1<<t);var c=15-t;for(i=0;i<n;++i)if(e[i])for(var d=i<<4|e[i],u=t-e[i],l=a[e[i]-1]++<<u,p=l|(1<<u)-1;l<=p;++l)o[Sb[l]>>c]=d}else for(o=new pb(n),i=0;i<n;++i)e[i]&&(o[i]=Sb[a[e[i]-1]++]>>15-e[i]);return o},Pb=new lb(288);for(kb=0;kb<144;++kb)Pb[kb]=8;for(kb=144;kb<256;++kb)Pb[kb]=9;for(kb=256;kb<280;++kb)Pb[kb]=7;for(kb=280;kb<288;++kb)Pb[kb]=8;var Tb=new lb(32);for(kb=0;kb<32;++kb)Tb[kb]=5;var Eb=Rb(Pb,9,1),Db=Rb(Tb,5,1),Ib=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},Mb=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&r},xb=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},Ob=function(e){return(e+7)/8|0},Lb=function(e,t,r){return(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length),new lb(e.subarray(t,r))},Ab=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],jb=function(e,t,r){var n=new Error(t||Ab[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,jb),!r)throw n;return n},Fb=function(e,t,r,n){var i=e.length,s=n?n.length:0;if(!i||t.f&&!t.l)return r||new lb(0);var o=!r,a=o||2!=t.i,c=t.i;o&&(r=new lb(3*i));var d=function(e){var t=r.length;if(e>t){var n=new lb(Math.max(2*t,e));n.set(r),r=n}},u=t.f||0,l=t.p||0,p=t.b||0,h=t.l,f=t.d,m=t.m,g=t.n,v=8*i;do{if(!h){u=Mb(e,l,1);var y=Mb(e,l+1,3);if(l+=3,!y){var b=e[(I=Ob(l)+4)-4]|e[I-3]<<8,w=I+b;if(w>i){c&&jb(0);break}a&&d(p+b),r.set(e.subarray(I,w),p),t.b=p+=b,t.p=l=8*w,t.f=u;continue}if(1==y)h=Eb,f=Db,m=9,g=5;else if(2==y){var _=Mb(e,l,31)+257,S=Mb(e,l+10,15)+4,k=_+Mb(e,l+5,31)+1;l+=14;for(var C=new lb(k),R=new lb(19),P=0;P<S;++P)R[gb[P]]=Mb(e,l+3*P,7);l+=3*S;var T=Ib(R),E=(1<<T)-1,D=Rb(R,T,1);for(P=0;P<k;){var I,M=D[Mb(e,l,E)];if(l+=15&M,(I=M>>4)<16)C[P++]=I;else{var x=0,O=0;for(16==I?(O=3+Mb(e,l,3),l+=2,x=C[P-1]):17==I?(O=3+Mb(e,l,7),l+=3):18==I&&(O=11+Mb(e,l,127),l+=7);O--;)C[P++]=x}}var L=C.subarray(0,_),A=C.subarray(_);m=Ib(L),g=Ib(A),h=Rb(L,m,1),f=Rb(A,g,1)}else jb(1);if(l>v){c&&jb(0);break}}a&&d(p+131072);for(var j=(1<<m)-1,F=(1<<g)-1,N=l;;N=l){var B=(x=h[xb(e,l)&j])>>4;if((l+=15&x)>v){c&&jb(0);break}if(x||jb(2),B<256)r[p++]=B;else{if(256==B){N=l,h=null;break}var W=B-254;if(B>264){var q=fb[P=B-257];W=Mb(e,l,(1<<q)-1)+bb[P],l+=q}var U=f[xb(e,l)&F],z=U>>4;U||jb(3),l+=15&U;A=_b[z];if(z>3){q=mb[z];A+=xb(e,l)&(1<<q)-1,l+=q}if(l>v){c&&jb(0);break}a&&d(p+131072);var V=p+W;if(p<A){var H=s-A,$=Math.min(A,V);for(H+p<0&&jb(3);p<$;++p)r[p]=n[H+p]}for(;p<V;++p)r[p]=r[p-A]}}t.l=h,t.p=N,t.b=p,t.f=u,h&&(u=1,t.m=m,t.d=f,t.n=g)}while(!u);return p!=r.length&&o?Lb(r,0,p):r.subarray(0,p)},Nb=new lb(0);function Bb(e,t){var r=function(e){31==e[0]&&139==e[1]&&8==e[2]||jb(6,"invalid gzip data");var t=e[3],r=10;4&t&&(r+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[r++]);return r+(2&t)}(e);return r+8>e.length&&jb(6,"invalid gzip data"),Fb(e.subarray(r,-8),{i:2},t&&t.out||new lb(function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}(e)),t&&t.dictionary)}function Wb(e,t){return Fb(e.subarray(function(e,t){return(8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31)&&jb(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&jb(6,"invalid zlib data: "+(32&e[1]?"need":"unexpected")+" dictionary"),2+(e[1]>>3&4)}(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}function qb(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?Bb(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?function(e,t){return Fb(e,{i:2},t&&t.out,t&&t.dictionary)}(e,t):Wb(e,t)}var Ub="undefined"!=typeof TextDecoder&&new TextDecoder;try{Ub.decode(Nb,{stream:!0}),1}catch(_t){}function zb(e,t){if(t){for(var r="",n=0;n<e.length;n+=16384)r+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return r}if(Ub)return Ub.decode(e);var i=function(e){for(var t="",r=0;;){var n=e[r++],i=(n>127)+(n>223)+(n>239);if(r+i>e.length)return{s:t,r:Lb(e,r-1)};i?3==i?(n=((15&n)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,t+=String.fromCharCode(55296|n>>10,56320|1023&n)):t+=1&i?String.fromCharCode((31&n)<<6|63&e[r++]):String.fromCharCode((15&n)<<12|(63&e[r++])<<6|63&e[r++]):t+=String.fromCharCode(n)}}(e),s=i.s;return(r=i.r).length&&jb(8),s}function Vb(e,t){var r,n;if(0===t.length)return e;for(r=0,n=t.length;r<n;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e<0?-2*e:e}function Hb(e,t,r,n){var i=Vb(Vb(Vb(e,r),function(e){return Object.prototype.toString.call(e)}(t)),typeof t);if(null===t)return Vb(i,"null");if(void 0===t)return Vb(i,"undefined");if("object"==typeof t||"function"==typeof t){if(-1!==n.indexOf(t))return Vb(i,"[Circular]"+r);n.push(t);var s=function(e,t,r){return Object.keys(t).sort().reduce((function(e,n){return Hb(e,t[n],n,r)}),e)}(i,t,n);if(!("valueOf"in t)||"function"!=typeof t.valueOf)return s;try{return Vb(s,String(t.valueOf()))}catch(e){return Vb(s,"[valueOf exception]"+(e.stack||e.message))}}return Vb(i,t.toString())}var $b=function(e){return function(e,t){for(;e.length<t;)e="0"+e;return e}(Hb(0,e,"",[]).toString(16),8)};class Kb{constructor(e){this.missingPeers=e.missingPeers,this.missingProducers=e.missingProducers,this.consumersWithInconsistentState=e.consumersWithInconsistentState,this.producersWithInconsistentState=e.producersWithInconsistentState,this.peersWithInconsistentAppData=e.peersWithInconsistentAppData}hasInconsistencyCases(){return this.missingPeers.length>0||this.missingProducers.length>0||this.consumersWithInconsistentState.length>0||this.producersWithInconsistentState.length>0||this.peersWithInconsistentAppData.length>0}}class Gb{constructor(e){this.missingPeers=[],this.missingProducers=[],this.consumersWithInconsistentState=[],this.producersWithInconsistentState=[],this.peersWithInconsistentAppData=[],this.localState=e.localState,this.remoteState=e.remoteState}check(){return this.resetPreviousCheckResults(),this.remoteState.peers.forEach((e=>{const t=this.findLocalPeerById(e.id);if(!t)return void this.missingPeers.push(e.id);t.appDataHash!==e.appDataHash&&this.peersWithInconsistentAppData.push(e.id),e.producers.forEach((e=>{const r=this.findLocalConsumerByProducerId(t,e.id);r&&r.paused!==e.paused&&this.consumersWithInconsistentState.push(r.id);const n=this.findLocalProducerById(t,e.id);if(n||this.missingProducers.push(e.id),!n)return;n.paused!==e.paused&&this.producersWithInconsistentState.push(e.id)}))})),new Kb({missingPeers:this.missingPeers,missingProducers:this.missingProducers,consumersWithInconsistentState:this.consumersWithInconsistentState,producersWithInconsistentState:this.producersWithInconsistentState,peersWithInconsistentAppData:this.peersWithInconsistentAppData})}getMissingPeers(){return this.missingPeers}getMissingProducers(){return this.missingProducers}getConsumersWithInconsistentState(){return this.consumersWithInconsistentState}getProducersWithInconsistentState(){return this.producersWithInconsistentState}getPeersWithInconsistentAppData(){return this.peersWithInconsistentAppData}findLocalPeerById(e){return this.localState.peers.find((t=>t.id===e))}findLocalConsumerByProducerId(e,t){var r;return null===(r=e.consumers)||void 0===r?void 0:r.find((e=>e.producerId===t))}findLocalProducerById(e,t){return e.producers.find((e=>e.id===t))}resetPreviousCheckResults(){this.missingPeers=[],this.missingProducers=[],this.consumersWithInconsistentState=[],this.producersWithInconsistentState=[],this.peersWithInconsistentAppData=[]}}var Qb,Jb,Yb,Zb,Xb,ew,tw;!function(e){e.MissingPeer="missing-peer",e.MissingProducer="missing-producer",e.IncorrectProducerState="incorrect-producer-state",e.IncorrectConsumerState="incorrect-consumer-state",e.IncorrectAppData="incorrect-app-data"}(Qb||(Qb={}));let rw=class{constructor(e,t,r,n,i,s,o,a){var c;this.channelStateSynchronizer=e,this.network=r,this.callState=n,this.socket=i,this.peers=s,this.clientEventEmitter=o,this.webRtcIssueDetector=a,Jb.set(this,void 0),Yb.set(this,void 0),Zb.set(this,[]),Xb.set(this,!1),ew.set(this,{inbound:4.3,outbound:4.3}),tw.set(this,(new Date).getTime()-15e3),d(this,Yb,null===(c=this.webRtcIssueDetector)||void 0===c?void 0:c.eventEmitter,"f"),d(this,Jb,t("ChannelStateSyncEventHandler"),"f"),this.listenNetworkScoresUpdatedEvents()}handle(e){return a(this,void 0,void 0,(function*(){try{const{event:t,data:r}=yield this.parseChannelStateSyncEventPayload(e);"channel-state"!==t||c(this,Xb,"f")||(yield this.handleChannelStateEvent(r))}catch(e){c(this,Jb,"f").error("handleChannelStateSyncEvent()",{error:hr(e)})}}))}handleChannelStateEvent(e){return a(this,void 0,void 0,(function*(){d(this,Xb,!0,"f");try{yield this.collectProbableInconsistencyCases(e);const t=this.getConfirmedInconsistencyResult();if(!(null==t?void 0:t.hasInconsistencyCases()))return;if(this.isRestoreStateRequestToEarly())return void c(this,Jb,"f").info("Inconsistency detected, but restore skipped",Object.assign({},t));this.handleConfirmedInconsistencyResult(t)}finally{d(this,Xb,!1,"f")}}))}getLastInconsistencyCheckResult(){return c(this,Zb,"f")[c(this,Zb,"f").length-1]}handleConfirmedInconsistencyResult(e){e.missingPeers.forEach((e=>{this.clientEventEmitter.safeEmit($r,{peerId:e,type:Qb.MissingPeer})})),e.missingProducers.forEach((e=>{this.clientEventEmitter.safeEmit($r,{producerId:e,type:Qb.MissingProducer})})),e.producersWithInconsistentState.forEach((e=>{this.clientEventEmitter.safeEmit($r,{producerId:e,type:Qb.IncorrectProducerState})})),e.peersWithInconsistentAppData.forEach((e=>{this.clientEventEmitter.safeEmit($r,{peerId:e,type:Qb.IncorrectAppData})}))}getConfirmedInconsistencyResult(){const e=this.getLastInconsistencyCheckResult();if(!e)return;return new Kb({missingPeers:this.getConfirmedMissingPeers(e.missingPeers),missingProducers:this.getConfirmedMissingProducers(e.missingProducers),consumersWithInconsistentState:this.getConfirmedConsumersWithInconsistencState(e.consumersWithInconsistentState),producersWithInconsistentState:this.getConfirmedProducersWithInconsistencState(e.producersWithInconsistentState),peersWithInconsistentAppData:this.getConfirmedPeersWithInconsistentAppData(e.missingPeers)})}collectProbableInconsistencyCases(e){return a(this,void 0,void 0,(function*(){const t=new Gb({remoteState:e,localState:this.getLocalState()}).check();if(this.rotateLastProbableInconsistencyCheckResults(t),!t.hasInconsistencyCases())return;if(this.isBadNetworkScore())return void this.resetLastProbableInconsistencyCheckResults();(yield this.getIsConnectionActive())&&this.callState.isJoined&&this.network.isNetworkActive||this.resetLastProbableInconsistencyCheckResults()}))}resetLastProbableInconsistencyCheckResults(){d(this,Zb,[],"f")}rotateLastProbableInconsistencyCheckResults(e){4===c(this,Zb,"f").length&&c(this,Zb,"f").shift(),c(this,Zb,"f").push(e)}isReachedMaxCheckRetries(e,t,r=4){let n=0;return c(this,Zb,"f").forEach((r=>{r[e].includes(t)&&(n+=1)})),n>=r}getConfirmedMissingPeers(e){return e.filter((e=>this.isReachedMaxCheckRetries("missingPeers",e)))}getConfirmedMissingProducers(e){return e.filter((e=>this.isReachedMaxCheckRetries("missingProducers",e)))}getConfirmedConsumersWithInconsistencState(e){return e.filter((e=>this.isReachedMaxCheckRetries("consumersWithInconsistentState",e,1)))}getConfirmedProducersWithInconsistencState(e){return e.filter((e=>this.isReachedMaxCheckRetries("producersWithInconsistentState",e)))}getConfirmedPeersWithInconsistentAppData(e){return e.filter((e=>this.isReachedMaxCheckRetries("peersWithInconsistentAppData",e)))}parseChannelStateSyncEventPayload(e){return a(this,void 0,void 0,(function*(){const t=qb("arrayBuffer"in e?new Uint8Array(yield e.arrayBuffer()):new Uint8Array(e));return JSON.parse(zb(t))}))}getLocalState(){return{peers:this.peers.hosts().map((e=>({id:e.id,appDataHash:$b(e.appData),producers:e.getProducers().map((e=>({id:e.id,paused:e.paused}))),consumers:e.getConsumersState()})))}}getIsConnectionActive(){var e;return a(this,void 0,void 0,(function*(){try{return this.network.checkSocketConnectionActivity(),yield null===(e=this.socket.connection)||void 0===e?void 0:e.timeout(1e3).emitWithAck("peer.ping",{}),!0}catch(e){return!1}}))}listenNetworkScoresUpdatedEvents(){c(this,Yb,"f")&&c(this,Yb,"f").on(wt.NetworkScoresUpdated,(e=>{e.inbound&&(c(this,ew,"f").inbound=e.inbound),e.outbound&&(c(this,ew,"f").outbound=e.outbound)}))}isBadNetworkScore(){const{inbound:e,outbound:t}=c(this,ew,"f");return e<=2.6||t<=2.6}compareCheckedAndRestoredResults(e,t){return new Kb({missingPeers:e.missingPeers.filter((e=>!t.missingPeers.includes(e))),missingProducers:e.missingProducers.filter((e=>!t.missingProducers.includes(e))),consumersWithInconsistentState:e.consumersWithInconsistentState.filter((e=>!t.fixedConsumersState.includes(e))),producersWithInconsistentState:e.producersWithInconsistentState.filter((e=>!t.fixedProducersState.includes(e))),peersWithInconsistentAppData:e.peersWithInconsistentAppData.filter((e=>!t.restoredAppDataPeers.includes(e)))})}isRestoreStateRequestToEarly(){return(new Date).getTime()-c(this,tw,"f")<=15e3}};Jb=new WeakMap,Yb=new WeakMap,Zb=new WeakMap,Xb=new WeakMap,ew=new WeakMap,tw=new WeakMap,rw=i([at(),s(0,dt(Qn.ChannelStateSynchronizer)),s(1,dt(Qn.LoggerFactory)),s(2,dt(Qn.Network)),s(3,dt(Qn.CallState)),s(4,dt(Qn.SocketIO)),s(5,dt(Qn.Peers)),s(6,dt(Qn.ClientEventEmitter)),s(7,dt(Qn.WebRTCIssueDetector)),o("design:paramtypes",[sf,Function,Hh,Xn,zh,$h,Rt,nr])],rw);var nw,iw,sw,ow,aw,cw,dw,uw,lw,pw=rw;let hw=class{constructor(e,t,r,n,i,s,o,c,u,l){this.state=e,this.myPeer=r,this.network=n,this.channelEventsHandler=i,this.eventsQueue=s,this.peers=o,this.mediaSoupEventsHandler=c,this.channelAudioObserverEventHandler=u,this.channelStateSyncEventHandler=l,nw.set(this,void 0),iw.set(this,void 0),sw.set(this,void 0),ow.set(this,void 0),aw.set(this,void 0),cw.set(this,void 0),dw.set(this,void 0),uw.set(this,void 0),lw.set(this,void 0),d(this,nw,t("DataChannels"),"f"),d(this,cw,(e=>{this.channelAudioObserverEventHandler.handle(e)}),"f"),d(this,dw,(e=>{this.channelEventsHandler.handleDataChannelEvent(e)}),"f"),d(this,uw,(e=>a(this,void 0,void 0,(function*(){yield this.channelStateSyncEventHandler.handle(e)}))),"f"),d(this,lw,(e=>{this.mediaSoupEventsHandler.handleConsumerScoreEvent(e)}),"f")}createAllDataChannels(){return a(this,void 0,void 0,(function*(){yield Promise.all([this.createAudioObserver(),this.createGeneralDataConsumer(),this.createChannelStateSyncDataConsumer(),this.createConsumersScoresDataConsumer()])}))}closeAllDataChannels(){var e,t,r,n,i,s,o,a;null===(e=c(this,iw,"f"))||void 0===e||e.removeListener("message",c(this,cw,"f")),null===(t=c(this,iw,"f"))||void 0===t||t.close(),null===(r=c(this,sw,"f"))||void 0===r||r.removeListener("message",c(this,dw,"f")),null===(n=c(this,sw,"f"))||void 0===n||n.close(),null===(i=c(this,ow,"f"))||void 0===i||i.removeListener("message",c(this,uw,"f")),null===(s=c(this,ow,"f"))||void 0===s||s.close(),null===(o=c(this,aw,"f"))||void 0===o||o.removeListener("message",c(this,lw,"f")),null===(a=c(this,aw,"f"))||void 0===a||a.close()}createAudioObserver(){var e;return a(this,void 0,void 0,(function*(){const t={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(e=this.myPeer)||void 0===e?void 0:e.id};try{const{producerId:e}=yield this.network.getAudioObserverProducer(),r=yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId});r.on("message",c(this,cw,"f")),d(this,iw,r,"f"),c(this,nw,"f").debug("Successfully create audio observer",t)}catch(e){c(this,nw,"f").error("Failed to create audio observer",t)}}))}createGeneralDataConsumer(){var e;return a(this,void 0,void 0,(function*(){const t={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(e=this.myPeer)||void 0===e?void 0:e.id};try{const{producerId:e}=yield this.network.getGeneralDataProducer();d(this,sw,yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId,ordered:!0}),"f"),this.eventsQueue.subscribeToDataChannel(c(this,sw,"f")),this.eventsQueue.on("message",c(this,dw,"f")),c(this,nw,"f").debug("Successfully created general data consumer",Object.assign(Object.assign({},t),{producerId:e}))}catch(e){c(this,nw,"f").error("Failed to create general data consumer",Object.assign(Object.assign({},t),{error:e}))}}))}createChannelStateSyncDataConsumer(){var e;return a(this,void 0,void 0,(function*(){const t={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(e=this.myPeer)||void 0===e?void 0:e.id};try{const{producerId:e}=yield this.network.getChannelStateSyncDataProducer();if(d(this,ow,yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId}),"f"),!c(this,ow,"f"))throw new Error("Failed to create ChannelStateSyncDataConsumer");c(this,ow,"f").on("message",c(this,uw,"f")),c(this,nw,"f").debug("Successfully created ChannelStateSyncDataConsumer",t)}catch(e){c(this,nw,"f").error("Failed to create ChannelStateSyncDataConsumer",Object.assign(Object.assign({},t),{error:e}))}}))}createConsumersScoresDataConsumer(){var e;return a(this,void 0,void 0,(function*(){const t={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(e=this.myPeer)||void 0===e?void 0:e.id};try{const{id:e}=yield this.network.createDataProducer("consumers-scores");if(d(this,aw,yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId}),"f"),!c(this,aw,"f"))throw new Error("Failed to create consumers scores data consumer");c(this,aw,"f").on("message",c(this,lw,"f")),c(this,nw,"f").debug("Successfully create consumers scores data consumer",t)}catch(e){c(this,nw,"f").error("Failed to create consumers scores data consumer",t)}}))}};nw=new WeakMap,iw=new WeakMap,sw=new WeakMap,ow=new WeakMap,aw=new WeakMap,cw=new WeakMap,dw=new WeakMap,uw=new WeakMap,lw=new WeakMap,hw=i([at(),s(0,dt(Qn.CallState)),s(1,dt(Qn.LoggerFactory)),s(2,dt(Qn.MyPeer)),s(3,dt(Qn.Network)),s(4,dt(Qn.ChannelEventHandler)),s(5,dt(Qn.EventsQueue)),s(6,dt(Qn.Peers)),s(7,dt(Qn.MediaSoupEventHandler)),s(8,dt(Qn.ChannelAudioObserverEventHandler)),s(9,dt(Qn.ChannelStateSyncEventHandler)),o("design:paramtypes",[Xn,Function,hp,Hh,cf,tf,Object,Hf,ub,pw])],hw);var fw,mw,gw,vw,yw,bw=hw;let ww=class{constructor(e,t,r,n,i,s,o,a,c,u,l,p,h,f,m,g,v,y,b,w,_,S){this.config=e,this.state=t,this.myPeer=r,this.integrationsService=i,this.processorsCache=s,this.mediaSoupEventsHandler=o,this.channelEventsHandler=a,this.channelStateSynchronizer=c,this.peerTrackFactory=u,this.peers=l,this.system=p,this.media=h,this.network=f,this.loadBalancerClient=m,this.socket=g,this.eventsQueue=v,this.clientEventEmitter=y,this.internalEventEmitter=b,this.statsHandler=w,this.dataChannelsManager=_,this.webRtcIssueDetector=S,fw.set(this,void 0),mw.set(this,void 0),this.rejoinRequested=!1,this.isReleasing=!1,gw.set(this,!1),vw.set(this,!1),yw.set(this,void 0),d(this,fw,n("Engine"),"f"),d(this,mw,n,"f"),this.watchNetworkState(),this.watchDocumentUnload()}get isChannelJoined(){return this.state.isJoined}initialize(){var e,t,r,n;return a(this,void 0,void 0,(function*(){try{const{rtpCapabilities:i}=yield this.socket.request("router.getRtpCapabilities");this.integrationsService.init(),yield this.media.loadDevice(i),c(this,fw,"f").info("Supported capabilities",{codecs:Vn(this.media.mediasoupDevice)});const[s,o]=yield Promise.all([this.network.createSendTransport(this.media.mediasoupDevice),this.network.createRecvTransport(this.media.mediasoupDevice)]);null===(e=this.webRtcIssueDetector)||void 0===e||e.handleNewPeerConnection(s.handler._pc,s.id),null===(t=this.webRtcIssueDetector)||void 0===t||t.handleNewPeerConnection(o.handler._pc,o.id),d(this,yw,new Xy({media:this.media,peers:this.peers,receiveTransportConnectionManager:new eb({transport:o,statsHandler:this.statsHandler}),sendTransportConnectionManager:new eb({transport:s,statsHandler:this.statsHandler})}),"f"),c(this,fw,"f").debug("initialize()",{sendTransportId:null===(r=this.network.sendTransport)||void 0===r?void 0:r.id,recvTransportId:null===(n=this.network.receiveTransport)||void 0===n?void 0:n.id})}catch(e){c(this,fw,"f").error("initialize()",{error:e});const t=e instanceof or&&"device not supported"===e.message,r=e instanceof Error&&"RTCPeerConnection is not defined"===e.message;if(t||r)throw new Wn("Device not supported",Wn.UNSUPPORTED_DEVICE_CODE);throw new Error("Error initialize engine")}}))}release(e){var t;return a(this,void 0,void 0,(function*(){if(!this.isReleasing){this.isReleasing=!0;try{this.state.isJoined=!1,this.state.reset(),this.myPeer.delete(),null===(t=this.webRtcIssueDetector)||void 0===t||t.stopWatchingNewPeerConnections(),yield this.peers.reset(),yield this.network.closeSendTransport(),yield this.network.closeReceiveTransport(),yield this.media.unpublishTracks(),e||(yield this.media.clearTracks()),yield this.processorsCache.reset(),this.integrationsService.reset(),this.eventsQueue.removeListener("message"),this.dataChannelsManager.closeAllDataChannels(),this.channelEventsHandler.reset(),this.mediaSoupEventsHandler.reset(),this.removeClientEventEmitterListeners(),yield this.network.reset(),this.socket.disconnect(),fr.clear(),d(this,yw,void 0,"f"),this.statsHandler.clear(),c(this,fw,"f").debug("release()",{socketId:this.myPeerId})}catch(e){throw c(this,fw,"f").error("release()",{error:e}),new Error("Error release engine")}finally{this.isReleasing=!1}}}))}removeClientEventEmitterListeners(){Array.from(Object.values(Xr)).forEach((e=>this.internalEventEmitter.removeAllListeners(e)))}getPeers(){return this.peers.all()}get myPeerId(){return this.myPeer.id}confirmActivity(){return a(this,void 0,void 0,(function*(){this.network.checkSocketConnectionActivity(),yield this.socket.request(wr)}))}join(e){return a(this,void 0,void 0,(function*(){const t=()=>a(this,void 0,void 0,(function*(){this.watchClientEvents(),yield this.connectToSocketServerWithRetry(e),yield this.performJoin({appData:e.appData})}));try{c(this,fw,"f").debug("join()",{params:e}),this.state.isChannelJoining=!0,yield Gn(t,{maxRetries:4,minBackoffDelayMs:150,maxBackoffDelayMs:5e3,actionName:"joinWithRetry",logger:c(this,mw,"f").call(this,"RetryJoinNode"),onError:()=>a(this,void 0,void 0,(function*(){yield this.release(!0)}))})}catch(e){throw c(this,fw,"f").error("join()",{error:e}),e}finally{this.state.isChannelJoining=!1,this.rejoinRequested=!1}}))}loadPeers(e){return a(this,void 0,void 0,(function*(){yield this.peers.load(e)}))}setPeer(e,t=!0){return this.peers.add(e,t)}removePeer(e){return a(this,void 0,void 0,(function*(){return this.peers.remove(e)}))}updateAppData(e){return a(this,void 0,void 0,(function*(){const t=this.myPeer.get();if(!t)throw new Error("Need join to channel first");try{qn(e),yield this.network.updatePeerAppData({peerId:t.id,appData:e})}catch(e){throw c(this,fw,"f").error("updateAppData()",{error:e}),new Error("Can not update peer appData")}}))}createCameraVideoTrack(e){return a(this,void 0,void 0,(function*(){const t=pp.getCameraVideoTrackParams(e);try{const[r]=yield this.media.createUserMediaTracks({audio:!1,video:t.videoTrackOptions});return r.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),r instanceof zf&&(r.setLabel((null==e?void 0:e.isPreview)?Jn.CameraPreview:Jn.Camera),r.setEncoderConfig(t.encoderConfig),r.setTransformParams(pp.getVideoTrackTransformParams(r.mediaStreamTrack))),this.media.setTrack(r),c(this,fw,"f").debug("createCameraVideoTrack()",{trackParams:t}),r}catch(e){throw c(this,fw,"f").error("createCameraVideoTrack()",{error:e,trackParams:t}),new Error(`Can not create camera track: ${e.message}`)}}))}createMicrophoneAudioTrack(e){return a(this,void 0,void 0,(function*(){try{const[t]=yield this.media.createUserMediaTracks({video:!1,audio:null==e?void 0:e.audio}),r=(null==e?void 0:e.isPreview)?Jn.MicrophonePreview:Jn.Microphone;return t.setLabel(r),t.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),(null==e?void 0:e.encoderConfig)&&t.setEncoderConfig(e.encoderConfig),"audio"!==t.kind||t.getLabel()!==Jn.Microphone||c(this,vw,"f")||this.media.initDenoiser(t,e),this.media.setTrack(t),c(this,fw,"f").debug("createMicrophoneAudioTrack()",{options:e,trackLabel:t.getLabel()}),t}catch(t){throw c(this,fw,"f").error("createMicrophoneAudioTrack()",{error:t,options:e}),new Error(`Can not create microphone track: ${t.message}`)}}))}createScreenMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=pp.getScreenVideoTrackParams(e);try{const r=yield this.media.createDisplayMediaTracks({audio:null==e?void 0:e.audio,video:null==e?void 0:e.video});return r.forEach((r=>{if(r.mediaStreamTrack.addEventListener("ended",(()=>{r.unpublish().catch((e=>{c(this,fw,"f").error("Failed to unpublish media track",{track:r,error:hr(e)})}))}),{once:!0}),r.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),r instanceof zf){r.setLabel(Jn.ScreenVideo),r.setEncoderConfig(t.encoderConfig);const e=pp.getVideoTrackTransformParams(r.mediaStreamTrack);return r.setTransformParams(e),this.media.setTrack(r),void c(this,fw,"f").debug("createScreenMediaTrack()",{trackParams:t,transformParams:e,label:r.logCtx})}r.setLabel(Jn.ScreenAudio),(null==e?void 0:e.audioEncoderConfig)&&r.setEncoderConfig(e.audioEncoderConfig),this.media.setTrack(r),c(this,fw,"f").debug("createScreenMediaTrack()",{trackParams:null==e?void 0:e.audio,encoderConfig:null==e?void 0:e.audioEncoderConfig})})),r}catch(e){throw c(this,fw,"f").error("createScreenMediaTrack()",{error:e,trackParams:t}),new Error(`Can not create screen media tracks: ${e.message}`)}}))}deleteTrack(e){return this.media.deleteTrack(e)}getNodeActiveStreamsStat(){const e=this.socket.getServerUrl(),t=this.peers.hosts().filter((e=>{var t;return e.id!==(null===(t=this.myPeer)||void 0===t?void 0:t.id)})).reduce(((e,t)=>e+t.getActiveTracksCount()),0),r=this.myPeer.get();return{node:e,inboundActiveStreams:t,outboundActiveStreams:(null==r?void 0:r.getActivePublishersCount())||0}}transportsStats(){var e;return null===(e=c(this,yw,"f"))||void 0===e?void 0:e.getStats()}connectToSocketServerWithRetry(e){return a(this,void 0,void 0,(function*(){return Gn((()=>a(this,void 0,void 0,(function*(){return this.connectToSocketServer(e)}))),{maxRetries:15,minBackoffDelayMs:150,maxBackoffDelayMs:5e3,actionName:"connectToSocketServer",logger:c(this,mw,"f").call(this,"RetrySocketConnect"),abortOnError:e=>{var t;return"unauthorized"===(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.errorCode)}})}))}connectToSocketServer(e){return a(this,void 0,void 0,(function*(){const{webSocketUrl:t}=yield this.getAvailableNode({channelId:e.channelId,role:e.role});this.socket.connect(t,e.token);try{yield this.waitForSocketConnection()}catch(r){throw c(this,fw,"f").error("Failed to connect to socket server",{error:r,role:e.role,channelId:e.channelId,webSocketUrl:t}),this.socket.disconnect(),r}}))}getAvailableNode(e){return a(this,void 0,void 0,(function*(){try{return{webSocketUrl:(yield this.loadBalancerClient.getNode(e)).webSocketUrl}}catch(e){throw c(this,fw,"f").error("getAvailableNode()",{error:"No available nodes"}),e}}))}waitForSocketConnection(){return new Promise(((e,t)=>{const r=n=>a(this,void 0,void 0,(function*(){const{error:i,state:s}=n,o=()=>this.socket.observer.removeListener(Zn.State,r),a=[Zn.Disconnected,Zn.Reconnecting].includes(s);return i?(o(),void t(i)):this.state.isChannelJoining&&a?(o(),void t(new Error(`Not expected socket state for new connection: ${s}`))):void(this.state.isChannelJoining&&[Zn.Connected,Zn.Reconnected].includes(s)&&(o(),e()))}));this.socket.observer.on(Zn.State,r)}))}performJoin(e){return a(this,void 0,void 0,(function*(){try{const{appId:t,channelId:r,peerId:n}=yield this.sendJoinChannelRequestWithRetry(e);this.myPeer.id=n,this.state.appId=t,this.state.channelId=r,yield this.initialize(),this.channelEventsHandler.subscribeToEvents(),this.mediaSoupEventsHandler.subscribeToEvents(),this.state.isJoined=!0,c(this,fw,"f").debug("Successfully joined channel",{channelId:r}),yield this.dataChannelsManager.createAllDataChannels(),fr.setPeerId(n),fr.setChannelId(r),fr.setAppId(t)}catch(e){throw c(this,fw,"f").error("performJoin()",{error:e}),e}}))}sendJoinChannelRequestWithRetry(e){return a(this,void 0,void 0,(function*(){return Gn((()=>a(this,void 0,void 0,(function*(){return this.sendJoinChannelRequest(e)}))),{maxRetries:3,minBackoffDelayMs:300,actionName:"sendJoinChannelRequest",logger:c(this,mw,"f").call(this,"RetryJoin")})}))}sendJoinChannelRequest(e){return a(this,void 0,void 0,(function*(){return this.socket.request(gr,e)}))}watchClientEvents(){this.internalEventEmitter.on(Xr.trackProduced,(e=>a(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(Xr.trackUnproduced,(e=>a(this,void 0,void 0,(function*(){var t;const r=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null==r||r.close(),yield this.media.deleteTrack(e)})))),this.internalEventEmitter.on(Xr.trackPaused,(e=>{var t;const r=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null==r||r.pause()})),this.internalEventEmitter.on(Xr.trackResumed,(e=>{var t;const r=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null==r||r.resume()})),this.internalEventEmitter.on(Xr.trackClosed,(e=>{var t;const r=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null==r||r.close()})),this.internalEventEmitter.on(Xr.trackReopened,(e=>a(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(Xr.trackFailed,(e=>a(this,void 0,void 0,(function*(){this.clientEventEmitter.safeEmit(Vr,{label:e.getLabel()})}))))}createSelfPeerTrack(e){var t;return a(this,void 0,void 0,(function*(){const r=this.peers.get(this.myPeer.id);if(!r)return;yield null===(t=r.tracks.get(e.getLabel()))||void 0===t?void 0:t.close();const n=this.peerTrackFactory({label:e.getLabel(),mediaStreamTrack:e.mediaStreamTrack,muted:!1,paused:e.isPaused,onClose:()=>{},peerEventEmitter:r.observer});r.tracks.set(n.label,n)}))}triggerRejoinEventIfAppropriate(e){this.rejoinRequested&&!this.state.isChannelJoining||(c(this,fw,"f").debug("Triggering channel rejoin required event",{reason:e}),this.rejoinRequested=!0,this.clientEventEmitter.emit(Wr))}watchNetworkState(){this.network.observer.on(Fn,(e=>a(this,void 0,void 0,(function*(){var t;if(this.isReleasing)return;const{code:r,error:n,state:i}=e,s="unauthorized"===(null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.errorCode)&&this.isChannelJoined,o=r===Zn.NeedToJoinFirst&&this.isChannelJoined;if(s&&this.clientEventEmitter.safeEmit(Jr),"server.disconnect"!==r||c(this,gw,"f")){if(o||s){const e=s?"unauthorized error":"invalid channel state";this.triggerRejoinEventIfAppropriate(e)}i===Zn.Disconnected&&this.isChannelJoined&&!c(this,gw,"f")&&c(this,fw,"f").info("connection lost",{channel:"socket"}),i===Zn.Reconnected&&this.isChannelJoined&&c(this,fw,"f").info("connection restored",{channel:"socket"}),i===Zn.BufferingStart&&(d(this,gw,!0,"f"),this.clientEventEmitter.safeEmit(Kr),this.waitForReconnectOrTriggerRejoinEventIfAppropriate()),[Zn.BufferingEnd,Zn.Reconnected].includes(i)&&this.network.isNetworkActive&&(d(this,gw,!1,"f"),this.clientEventEmitter.safeEmit(Gr))}else this.clientEventEmitter.safeEmit(Qr)})))),this.network.observer.on(Nn,(({state:e,direction:t})=>a(this,void 0,void 0,(function*(){if(!this.isReleasing&&(["disconnected","failed"].includes(e)&&this.isChannelJoined&&!c(this,gw,"f")&&(d(this,gw,!0,"f"),c(this,fw,"f").info("connection lost",{channel:"webrtc-transport",direction:t}),this.clientEventEmitter.safeEmit(Kr),this.waitForReconnectOrTriggerRejoinEventIfAppropriate()),"reconnected"===e&&this.isChannelJoined&&c(this,fw,"f").info("connection restored",{channel:"webrtc-transport",direction:t}),"reconnected"===e&&this.isChannelJoined&&c(this,gw,"f"))){if(![this.network.receiveTransport,this.network.sendTransport].every((e=>"connected"===(null==e?void 0:e.connectionState)||"new"===(null==e?void 0:e.connectionState))))return;d(this,gw,!1,"f"),this.clientEventEmitter.safeEmit(Gr)}}))))}getAvgTracksScore(e){const t=this.peers.all().map((e=>Array.from(e.tracks.values()))).flat().filter((t=>t.kind===e&&!1===t.isPaused&&void 0!==t.score));if(0!==t.length)return t.reduce(((e,t)=>e+(t.score||0)),0)/t.length}watchDocumentUnload(){try{window.addEventListener("unload",(()=>{var e,t;null===(e=this.network.sendTransport)||void 0===e||e.close(),null===(t=this.network.receiveTransport)||void 0===t||t.close()}))}catch(e){c(this,fw,"f").error("Failed to add watchDocumentUnload listener",{channelId:this.state.channelId})}}waitForReconnectOrTriggerRejoinEventIfAppropriate(){c(this,fw,"f").info("Start waiting for seamless reconnect and check loadbalancer availability",{case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"});let e=0;const t=setInterval((()=>a(this,void 0,void 0,(function*(){try{if(!c(this,gw,"f"))return void clearInterval(t);if(!(yield this.loadBalancerClient.checkServiceAvailability(2e3)))return void(e=0);e+=1,e>4&&(clearInterval(t),this.triggerRejoinEventIfAppropriate("loadbalancer available"))}catch(e){c(this,fw,"f").error("Check failed",{error:hr(e),case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"})}}))),3e3)}};fw=new WeakMap,mw=new WeakMap,gw=new WeakMap,vw=new WeakMap,yw=new WeakMap,ww=i([at(),s(0,dt(Qn.Config)),s(1,dt(Qn.CallState)),s(2,dt(Qn.MyPeer)),s(3,dt(Qn.LoggerFactory)),s(4,dt(Qn.IntegrationsService)),s(5,dt(Qn.ProcessorsCache)),s(6,dt(Qn.MediaSoupEventHandler)),s(7,dt(Qn.ChannelEventHandler)),s(8,dt(Qn.ChannelStateSynchronizer)),s(9,dt(Qn.PeerTrackFactory)),s(10,dt(Qn.Peers)),s(11,dt(Qn.System)),s(12,dt(Qn.Media)),s(13,dt(Qn.Network)),s(14,dt(Qn.LoadBalancerApiClient)),s(15,dt(Qn.SocketIO)),s(16,dt(Qn.EventsQueue)),s(17,dt(Qn.ClientEventEmitter)),s(18,dt(Qn.InternalEventEmitter)),s(19,dt(Qn.StatsHandler)),s(20,dt(Qn.DataChannelsManager)),s(21,dt(Qn.WebRTCIssueDetector)),o("design:paramtypes",[Ct,Xn,hp,Function,Hl,Ul,Hf,cf,sf,Function,Object,Zy,pp,Hh,Wy,zh,tf,Rt,Rt,ab,bw,nr])],ww);var _w=ww,Sw={},kw={},Cw={},Rw={exports:{}};
|
|
31
|
+
let Qs;xs.AwaitQueue=class{constructor(){this.pendingTasks=new Map,this.nextTaskId=0,this.stopping=!1}get size(){return this.pendingTasks.size}async push(e,t){if(t=t??e.name,$s.debug(`push() [name:${t}]`),"function"!=typeof e)throw new TypeError("given task is not a function");if(t)try{Object.defineProperty(e,"name",{value:t})}catch(e){}return new Promise(((r,n)=>{const i={id:this.nextTaskId++,task:e,name:t,enqueuedAt:Date.now(),executedAt:void 0,completed:!1,resolve:e=>{if(i.completed)return;i.completed=!0,this.pendingTasks.delete(i.id),$s.debug(`resolving task [name:${i.name}]`),r(e);const[t]=this.pendingTasks.values();t&&!t.executedAt&&this.execute(t)},reject:e=>{if(!i.completed&&(i.completed=!0,this.pendingTasks.delete(i.id),$s.debug(`rejecting task [name:${i.name}]: %s`,String(e)),n(e),!this.stopping)){const[e]=this.pendingTasks.values();e&&!e.executedAt&&this.execute(e)}}};this.pendingTasks.set(i.id,i),1===this.pendingTasks.size&&this.execute(i)}))}stop(){$s.debug("stop()"),this.stopping=!0;for(const e of this.pendingTasks.values())$s.debug(`stop() | stopping task [name:${e.name}]`),e.reject(new Ks);this.stopping=!1}remove(e){$s.debug(`remove() [taskIdx:${e}]`);const t=Array.from(this.pendingTasks.values())[e];t?t.reject(new Gs):$s.debug(`stop() | no task with given idx [taskIdx:${e}]`)}dump(){const e=Date.now();let t=0;return Array.from(this.pendingTasks.values()).map((r=>({idx:t++,task:r.task,name:r.name,enqueuedTime:r.executedAt?r.executedAt-r.enqueuedAt:e-r.enqueuedAt,executionTime:r.executedAt?e-r.executedAt:0})))}async execute(e){if($s.debug(`execute() [name:${e.name}]`),e.executedAt)throw new Error("task already being executed");e.executedAt=Date.now();try{const t=await e.task();e.resolve(t)}catch(t){e.reject(t)}}};var Js="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:l):e=>(Qs||(Qs=Promise.resolve())).then(e).catch((e=>setTimeout((()=>{throw e}),0))),Ys={};Object.defineProperty(Ys,"__esModule",{value:!0}),Ys.Producer=void 0;const Zs=wi,Xs=or,eo=new mi.Logger("Producer");class to extends Zs.EnhancedEventEmitter{constructor({id:e,localId:t,rtpSender:r,track:n,rtpParameters:i,stopTracks:s,disableTrackOnPause:o,zeroRtpOnPause:a,appData:c}){super(),this._closed=!1,this._observer=new Zs.EnhancedEventEmitter,eo.debug("constructor()"),this._id=e,this._localId=t,this._rtpSender=r,this._track=n,this._kind=n.kind,this._rtpParameters=i,this._paused=!!o&&!n.enabled,this._maxSpatialLayer=void 0,this._stopTracks=s,this._disableTrackOnPause=o,this._zeroRtpOnPause=a,this._appData=c??{},this.onTrackEnded=this.onTrackEnded.bind(this),this.handleTrack()}get id(){return this._id}get localId(){return this._localId}get closed(){return this._closed}get kind(){return this._kind}get rtpSender(){return this._rtpSender}get track(){return this._track}get rtpParameters(){return this._rtpParameters}get paused(){return this._paused}get maxSpatialLayer(){return this._maxSpatialLayer}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(eo.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(eo.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new Xs.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){eo.debug("pause()"),this._closed?eo.error("pause() | Producer closed"):(this._paused=!0,this._track&&this._disableTrackOnPause&&(this._track.enabled=!1),this._zeroRtpOnPause&&new Promise(((e,t)=>{this.safeEmit("@pause",e,t)})).catch((()=>{})),this._observer.safeEmit("pause"))}resume(){eo.debug("resume()"),this._closed?eo.error("resume() | Producer closed"):(this._paused=!1,this._track&&this._disableTrackOnPause&&(this._track.enabled=!0),this._zeroRtpOnPause&&new Promise(((e,t)=>{this.safeEmit("@resume",e,t)})).catch((()=>{})),this._observer.safeEmit("resume"))}async replaceTrack({track:e}){if(eo.debug("replaceTrack() [track:%o]",e),this._closed){if(e&&this._stopTracks)try{e.stop()}catch(e){}throw new Xs.InvalidStateError("closed")}if(e&&"ended"===e.readyState)throw new Xs.InvalidStateError("track ended");e!==this._track?(await new Promise(((t,r)=>{this.safeEmit("@replacetrack",e,t,r)})),this.destroyTrack(),this._track=e,this._track&&this._disableTrackOnPause&&(this._paused?this._paused&&(this._track.enabled=!1):this._track.enabled=!0),this.handleTrack()):eo.debug("replaceTrack() | same track, ignored")}async setMaxSpatialLayer(e){if(this._closed)throw new Xs.InvalidStateError("closed");if("video"!==this._kind)throw new Xs.UnsupportedError("not a video Producer");if("number"!=typeof e)throw new TypeError("invalid spatialLayer");e!==this._maxSpatialLayer&&(await new Promise(((t,r)=>{this.safeEmit("@setmaxspatiallayer",e,t,r)})).catch((()=>{})),this._maxSpatialLayer=e)}async setRtpEncodingParameters(e){if(this._closed)throw new Xs.InvalidStateError("closed");if("object"!=typeof e)throw new TypeError("invalid params");await new Promise(((t,r)=>{this.safeEmit("@setrtpencodingparameters",e,t,r)}))}onTrackEnded(){eo.debug('track "ended" event'),this.safeEmit("trackended"),this._observer.safeEmit("trackended")}handleTrack(){this._track&&this._track.addEventListener("ended",this.onTrackEnded)}destroyTrack(){if(this._track)try{this._track.removeEventListener("ended",this.onTrackEnded),this._stopTracks&&this._track.stop()}catch(e){}}}Ys.Producer=to;var ro={};Object.defineProperty(ro,"__esModule",{value:!0}),ro.Consumer=void 0;const no=wi,io=or,so=new mi.Logger("Consumer");class oo extends no.EnhancedEventEmitter{constructor({id:e,localId:t,producerId:r,rtpReceiver:n,track:i,rtpParameters:s,appData:o}){super(),this._closed=!1,this._observer=new no.EnhancedEventEmitter,so.debug("constructor()"),this._id=e,this._localId=t,this._producerId=r,this._rtpReceiver=n,this._track=i,this._rtpParameters=s,this._paused=!i.enabled,this._appData=o??{},this.onTrackEnded=this.onTrackEnded.bind(this),this.handleTrack()}get id(){return this._id}get localId(){return this._localId}get producerId(){return this._producerId}get closed(){return this._closed}get kind(){return this._track.kind}get rtpReceiver(){return this._rtpReceiver}get track(){return this._track}get rtpParameters(){return this._rtpParameters}get paused(){return this._paused}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(so.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(so.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new io.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){so.debug("pause()"),this._closed?so.error("pause() | Consumer closed"):this._paused?so.debug("pause() | Consumer is already paused"):(this._paused=!0,this._track.enabled=!1,this.emit("@pause"),this._observer.safeEmit("pause"))}resume(){so.debug("resume()"),this._closed?so.error("resume() | Consumer closed"):this._paused?(this._paused=!1,this._track.enabled=!0,this.emit("@resume"),this._observer.safeEmit("resume")):so.debug("resume() | Consumer is already resumed")}onTrackEnded(){so.debug('track "ended" event'),this.safeEmit("trackended"),this._observer.safeEmit("trackended")}handleTrack(){this._track.addEventListener("ended",this.onTrackEnded)}destroyTrack(){try{this._track.removeEventListener("ended",this.onTrackEnded),this._track.stop()}catch(e){}}}ro.Consumer=oo;var ao={};Object.defineProperty(ao,"__esModule",{value:!0}),ao.DataProducer=void 0;const co=wi,uo=or,lo=new mi.Logger("DataProducer");class po extends co.EnhancedEventEmitter{constructor({id:e,dataChannel:t,sctpStreamParameters:r,appData:n}){super(),this._closed=!1,this._observer=new co.EnhancedEventEmitter,lo.debug("constructor()"),this._id=e,this._dataChannel=t,this._sctpStreamParameters=r,this._appData=n??{},this.handleDataChannel()}get id(){return this._id}get closed(){return this._closed}get sctpStreamParameters(){return this._sctpStreamParameters}get readyState(){return this._dataChannel.readyState}get label(){return this._dataChannel.label}get protocol(){return this._dataChannel.protocol}get bufferedAmount(){return this._dataChannel.bufferedAmount}get bufferedAmountLowThreshold(){return this._dataChannel.bufferedAmountLowThreshold}set bufferedAmountLowThreshold(e){this._dataChannel.bufferedAmountLowThreshold=e}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(lo.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(lo.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}send(e){if(lo.debug("send()"),this._closed)throw new uo.InvalidStateError("closed");this._dataChannel.send(e)}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(lo.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;let{error:t}=e;t||(t=new Error("unknown DataChannel error")),"sctp-failure"===t.errorDetail?lo.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):lo.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(lo.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(()=>{this._closed||lo.warn('DataChannel "message" event in a DataProducer, message discarded')})),this._dataChannel.addEventListener("bufferedamountlow",(()=>{this._closed||this.safeEmit("bufferedamountlow")}))}}ao.DataProducer=po;var ho={};Object.defineProperty(ho,"__esModule",{value:!0}),ho.DataConsumer=void 0;const fo=wi,mo=new mi.Logger("DataConsumer");class go extends fo.EnhancedEventEmitter{constructor({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:n,appData:i}){super(),this._closed=!1,this._observer=new fo.EnhancedEventEmitter,mo.debug("constructor()"),this._id=e,this._dataProducerId=t,this._dataChannel=r,this._sctpStreamParameters=n,this._appData=i??{},this.handleDataChannel()}get id(){return this._id}get dataProducerId(){return this._dataProducerId}get closed(){return this._closed}get sctpStreamParameters(){return this._sctpStreamParameters}get readyState(){return this._dataChannel.readyState}get label(){return this._dataChannel.label}get protocol(){return this._dataChannel.protocol}get binaryType(){return this._dataChannel.binaryType}set binaryType(e){this._dataChannel.binaryType=e}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){this._closed||(mo.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(mo.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(mo.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;let{error:t}=e;t||(t=new Error("unknown DataChannel error")),"sctp-failure"===t.errorDetail?mo.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):mo.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(mo.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(e=>{this._closed||this.safeEmit("message",e.data)}))}}ho.DataConsumer=go;var vo=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),yo=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),bo=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&vo(r,t,n[i]);return yo(r,t),r}}(),wo=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Is,"__esModule",{value:!0}),Is.Transport=void 0;const _o=xs,So=wo(Js),ko=mi,Co=wi,Ro=or,Po=bo(Bi),To=bo(Wi),Eo=Ys,Do=ro,Mo=ao,Io=ho,xo=new ko.Logger("Transport");class Oo{constructor(e){this.consumerOptions=e,this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class Lo extends Co.EnhancedEventEmitter{constructor({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,proprietaryConstraints:d,appData:u,handlerFactory:l,extendedRtpCapabilities:p,canProduceByKind:h}){super(),this._closed=!1,this._iceGatheringState="new",this._connectionState="new",this._producers=new Map,this._consumers=new Map,this._dataProducers=new Map,this._dataConsumers=new Map,this._probatorConsumerCreated=!1,this._awaitQueue=new _o.AwaitQueue,this._pendingConsumerTasks=[],this._consumerCreationInProgress=!1,this._pendingPauseConsumers=new Map,this._consumerPauseInProgress=!1,this._pendingResumeConsumers=new Map,this._consumerResumeInProgress=!1,this._pendingCloseConsumers=new Map,this._consumerCloseInProgress=!1,this._observer=new Co.EnhancedEventEmitter,xo.debug("constructor() [id:%s, direction:%s]",t,e),this._id=t,this._direction=e,this._extendedRtpCapabilities=p,this._canProduceByKind=h,this._maxSctpMessageSize=s?s.maxMessageSize:null;const f=Po.clone(c)??{};delete f.iceServers,delete f.iceTransportPolicy,delete f.bundlePolicy,delete f.rtcpMuxPolicy,delete f.sdpSemantics,this._handler=l(),this._handler.run({direction:e,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:f,proprietaryConstraints:d,extendedRtpCapabilities:p}),this._appData=u??{},this.handleHandler()}get id(){return this._id}get closed(){return this._closed}get direction(){return this._direction}get handler(){return this._handler}get iceGatheringState(){return this._iceGatheringState}get connectionState(){return this._connectionState}get appData(){return this._appData}set appData(e){this._appData=e}get observer(){return this._observer}close(){if(!this._closed){xo.debug("close()"),this._closed=!0,this._awaitQueue.stop(),this._handler.close(),this._connectionState="closed";for(const e of this._producers.values())e.transportClosed();this._producers.clear();for(const e of this._consumers.values())e.transportClosed();this._consumers.clear();for(const e of this._dataProducers.values())e.transportClosed();this._dataProducers.clear();for(const e of this._dataConsumers.values())e.transportClosed();this._dataConsumers.clear(),this._observer.safeEmit("close")}}async getStats(){if(this._closed)throw new Ro.InvalidStateError("closed");return this._handler.getTransportStats()}async restartIce({iceParameters:e}){if(xo.debug("restartIce()"),this._closed)throw new Ro.InvalidStateError("closed");if(!e)throw new TypeError("missing iceParameters");return this._awaitQueue.push((async()=>await this._handler.restartIce(e)),"transport.restartIce()")}async updateIceServers({iceServers:e}={}){if(xo.debug("updateIceServers()"),this._closed)throw new Ro.InvalidStateError("closed");if(!Array.isArray(e))throw new TypeError("missing iceServers");return this._awaitQueue.push((async()=>this._handler.updateIceServers(e)),"transport.updateIceServers()")}async produce({track:e,encodings:t,codecOptions:r,codec:n,stopTracks:i=!0,disableTrackOnPause:s=!0,zeroRtpOnPause:o=!1,onRtpSender:a,appData:c={}}={}){if(xo.debug("produce() [track:%o]",e),this._closed)throw new Ro.InvalidStateError("closed");if(!e)throw new TypeError("missing track");if("send"!==this._direction)throw new Ro.UnsupportedError("not a sending Transport");if(!this._canProduceByKind[e.kind])throw new Ro.UnsupportedError(`cannot produce ${e.kind}`);if("ended"===e.readyState)throw new Ro.InvalidStateError("track ended");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(0===this.listenerCount("produce"))throw new TypeError('no "produce" listener set into this transport');if(c&&"object"!=typeof c)throw new TypeError("if given, appData must be an object");return this._awaitQueue.push((async()=>{let d;if(t&&!Array.isArray(t))throw TypeError("encodings must be an array");t&&0===t.length?d=void 0:t&&(d=t.map((e=>{const t={active:!0};return!1===e.active&&(t.active=!1),"boolean"==typeof e.dtx&&(t.dtx=e.dtx),"string"==typeof e.scalabilityMode&&(t.scalabilityMode=e.scalabilityMode),"number"==typeof e.scaleResolutionDownBy&&(t.scaleResolutionDownBy=e.scaleResolutionDownBy),"number"==typeof e.maxBitrate&&(t.maxBitrate=e.maxBitrate),"number"==typeof e.maxFramerate&&(t.maxFramerate=e.maxFramerate),"boolean"==typeof e.adaptivePtime&&(t.adaptivePtime=e.adaptivePtime),"string"==typeof e.priority&&(t.priority=e.priority),"string"==typeof e.networkPriority&&(t.networkPriority=e.networkPriority),t})));const{localId:u,rtpParameters:l,rtpSender:p}=await this._handler.send({track:e,encodings:d,codecOptions:r,codec:n,onRtpSender:a});try{To.validateRtpParameters(l);const{id:t}=await new Promise(((t,r)=>{this.safeEmit("produce",{kind:e.kind,rtpParameters:l,appData:c},t,r)})),r=new Eo.Producer({id:t,localId:u,rtpSender:p,track:e,rtpParameters:l,stopTracks:i,disableTrackOnPause:s,zeroRtpOnPause:o,appData:c});return this._producers.set(r.id,r),this.handleProducer(r),this._observer.safeEmit("newproducer",r),r}catch(e){throw this._handler.stopSending(u).catch((()=>{})),e}}),"transport.produce()").catch((t=>{if(i)try{e.stop()}catch(e){}throw t}))}async consume({id:e,producerId:t,kind:r,rtpParameters:n,streamId:i,onRtpReceiver:s,appData:o={}}){if(xo.debug("consume()"),this._closed)throw new Ro.InvalidStateError("closed");if("recv"!==this._direction)throw new Ro.UnsupportedError("not a receiving Transport");if("string"!=typeof e)throw new TypeError("missing id");if("string"!=typeof t)throw new TypeError("missing producerId");if("audio"!==r&&"video"!==r)throw new TypeError(`invalid kind '${r}'`);if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(o&&"object"!=typeof o)throw new TypeError("if given, appData must be an object");const a=Po.clone(n);if(!To.canReceive(a,this._extendedRtpCapabilities))throw new Ro.UnsupportedError("cannot consume this Producer");const c=new Oo({id:e,producerId:t,kind:r,rtpParameters:a,streamId:i,onRtpReceiver:s,appData:o});return this._pendingConsumerTasks.push(c),(0,So.default)((()=>{this._closed||!1===this._consumerCreationInProgress&&this.createPendingConsumers()})),c.promise}async produceData({ordered:e=!0,maxPacketLifeTime:t,maxRetransmits:r,label:n="",protocol:i="",appData:s={}}={}){if(xo.debug("produceData()"),this._closed)throw new Ro.InvalidStateError("closed");if("send"!==this._direction)throw new Ro.UnsupportedError("not a sending Transport");if(!this._maxSctpMessageSize)throw new Ro.UnsupportedError("SCTP not enabled by remote Transport");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(0===this.listenerCount("producedata"))throw new TypeError('no "producedata" listener set into this transport');if(s&&"object"!=typeof s)throw new TypeError("if given, appData must be an object");return(t||r)&&(e=!1),this._awaitQueue.push((async()=>{const{dataChannel:o,sctpStreamParameters:a}=await this._handler.sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i});To.validateSctpStreamParameters(a);const{id:c}=await new Promise(((e,t)=>{this.safeEmit("producedata",{sctpStreamParameters:a,label:n,protocol:i,appData:s},e,t)})),d=new Mo.DataProducer({id:c,dataChannel:o,sctpStreamParameters:a,appData:s});return this._dataProducers.set(d.id,d),this.handleDataProducer(d),this._observer.safeEmit("newdataproducer",d),d}),"transport.produceData()")}async consumeData({id:e,dataProducerId:t,sctpStreamParameters:r,label:n="",protocol:i="",appData:s={}}){if(xo.debug("consumeData()"),this._closed)throw new Ro.InvalidStateError("closed");if("recv"!==this._direction)throw new Ro.UnsupportedError("not a receiving Transport");if(!this._maxSctpMessageSize)throw new Ro.UnsupportedError("SCTP not enabled by remote Transport");if("string"!=typeof e)throw new TypeError("missing id");if("string"!=typeof t)throw new TypeError("missing dataProducerId");if(0===this.listenerCount("connect")&&"new"===this._connectionState)throw new TypeError('no "connect" listener set into this transport');if(s&&"object"!=typeof s)throw new TypeError("if given, appData must be an object");const o=Po.clone(r);return To.validateSctpStreamParameters(o),this._awaitQueue.push((async()=>{const{dataChannel:r}=await this._handler.receiveDataChannel({sctpStreamParameters:o,label:n,protocol:i}),a=new Io.DataConsumer({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:o,appData:s});return this._dataConsumers.set(a.id,a),this.handleDataConsumer(a),this._observer.safeEmit("newdataconsumer",a),a}),"transport.consumeData()")}async createPendingConsumers(){this._consumerCreationInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingConsumerTasks.length)return void xo.debug("createPendingConsumers() | there is no Consumer to be created");const e=[...this._pendingConsumerTasks];let t;this._pendingConsumerTasks=[];const r=[];for(const t of e){const{id:e,kind:n,rtpParameters:i,streamId:s,onRtpReceiver:o}=t.consumerOptions;r.push({trackId:e,kind:n,rtpParameters:i,streamId:s,onRtpReceiver:o})}try{const n=await this._handler.receive(r);for(let r=0;r<n.length;++r){const i=e[r],s=n[r],{id:o,producerId:a,kind:c,rtpParameters:d,appData:u}=i.consumerOptions,{localId:l,rtpReceiver:p,track:h}=s,f=new Do.Consumer({id:o,localId:l,producerId:a,rtpReceiver:p,track:h,rtpParameters:d,appData:u});this._consumers.set(f.id,f),this.handleConsumer(f),this._probatorConsumerCreated||t||"video"!==c||(t=f),this._observer.safeEmit("newconsumer",f),i.resolve(f)}}catch(t){for(const r of e)r.reject(t)}if(t)try{const e=To.generateProbatorRtpParameters(t.rtpParameters);await this._handler.receive([{trackId:"probator",kind:"video",rtpParameters:e}]),xo.debug("createPendingConsumers() | Consumer for RTP probation created"),this._probatorConsumerCreated=!0}catch(e){xo.error("createPendingConsumers() | failed to create Consumer for RTP probation:%o",e)}}),"transport.createPendingConsumers()").then((()=>{this._consumerCreationInProgress=!1,this._pendingConsumerTasks.length>0&&this.createPendingConsumers()})).catch((()=>{}))}pausePendingConsumers(){this._consumerPauseInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingPauseConsumers.size)return void xo.debug("pausePendingConsumers() | there is no Consumer to be paused");const e=Array.from(this._pendingPauseConsumers.values());this._pendingPauseConsumers.clear();try{const t=e.map((e=>e.localId));await this._handler.pauseReceiving(t)}catch(e){xo.error("pausePendingConsumers() | failed to pause Consumers:",e)}}),"transport.pausePendingConsumers").then((()=>{this._consumerPauseInProgress=!1,this._pendingPauseConsumers.size>0&&this.pausePendingConsumers()})).catch((()=>{}))}resumePendingConsumers(){this._consumerResumeInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingResumeConsumers.size)return void xo.debug("resumePendingConsumers() | there is no Consumer to be resumed");const e=Array.from(this._pendingResumeConsumers.values());this._pendingResumeConsumers.clear();try{const t=e.map((e=>e.localId));await this._handler.resumeReceiving(t)}catch(e){xo.error("resumePendingConsumers() | failed to resume Consumers:",e)}}),"transport.resumePendingConsumers").then((()=>{this._consumerResumeInProgress=!1,this._pendingResumeConsumers.size>0&&this.resumePendingConsumers()})).catch((()=>{}))}closePendingConsumers(){this._consumerCloseInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingCloseConsumers.size)return void xo.debug("closePendingConsumers() | there is no Consumer to be closed");const e=Array.from(this._pendingCloseConsumers.values());this._pendingCloseConsumers.clear();try{await this._handler.stopReceiving(e.map((e=>e.localId)))}catch(e){xo.error("closePendingConsumers() | failed to close Consumers:",e)}}),"transport.closePendingConsumers").then((()=>{this._consumerCloseInProgress=!1,this._pendingCloseConsumers.size>0&&this.closePendingConsumers()})).catch((()=>{}))}handleHandler(){const e=this._handler;e.on("@connect",(({dtlsParameters:e},t,r)=>{this._closed?r(new Ro.InvalidStateError("closed")):this.safeEmit("connect",{dtlsParameters:e},t,r)})),e.on("@icegatheringstatechange",(e=>{e!==this._iceGatheringState&&(xo.debug("ICE gathering state changed to %s",e),this._iceGatheringState=e,this._closed||this.safeEmit("icegatheringstatechange",e))})),e.on("@connectionstatechange",(e=>{e!==this._connectionState&&(xo.debug("connection state changed to %s",e),this._connectionState=e,this._closed||this.safeEmit("connectionstatechange",e))}))}handleProducer(e){e.on("@close",(()=>{this._producers.delete(e.id),this._closed||this._awaitQueue.push((async()=>await this._handler.stopSending(e.localId)),"producer @close event").catch((e=>xo.warn("producer.close() failed:%o",e)))})),e.on("@pause",((t,r)=>{this._awaitQueue.push((async()=>await this._handler.pauseSending(e.localId)),"producer @pause event").then(t).catch(r)})),e.on("@resume",((t,r)=>{this._awaitQueue.push((async()=>await this._handler.resumeSending(e.localId)),"producer @resume event").then(t).catch(r)})),e.on("@replacetrack",((t,r,n)=>{this._awaitQueue.push((async()=>await this._handler.replaceTrack(e.localId,t)),"producer @replacetrack event").then(r).catch(n)})),e.on("@setmaxspatiallayer",((t,r,n)=>{this._awaitQueue.push((async()=>await this._handler.setMaxSpatialLayer(e.localId,t)),"producer @setmaxspatiallayer event").then(r).catch(n)})),e.on("@setrtpencodingparameters",((t,r,n)=>{this._awaitQueue.push((async()=>await this._handler.setRtpEncodingParameters(e.localId,t)),"producer @setrtpencodingparameters event").then(r).catch(n)})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new Ro.InvalidStateError("closed"));this._handler.getSenderStats(e.localId).then(t).catch(r)}))}handleConsumer(e){e.on("@close",(()=>{this._consumers.delete(e.id),this._pendingPauseConsumers.delete(e.id),this._pendingResumeConsumers.delete(e.id),this._closed||(this._pendingCloseConsumers.set(e.id,e),!1===this._consumerCloseInProgress&&this.closePendingConsumers())})),e.on("@pause",(()=>{this._pendingResumeConsumers.has(e.id)&&this._pendingResumeConsumers.delete(e.id),this._pendingPauseConsumers.set(e.id,e),(0,So.default)((()=>{this._closed||!1===this._consumerPauseInProgress&&this.pausePendingConsumers()}))})),e.on("@resume",(()=>{this._pendingPauseConsumers.has(e.id)&&this._pendingPauseConsumers.delete(e.id),this._pendingResumeConsumers.set(e.id,e),(0,So.default)((()=>{this._closed||!1===this._consumerResumeInProgress&&this.resumePendingConsumers()}))})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new Ro.InvalidStateError("closed"));this._handler.getReceiverStats(e.localId).then(t).catch(r)}))}handleDataProducer(e){e.on("@close",(()=>{this._dataProducers.delete(e.id)}))}handleDataConsumer(e){e.on("@close",(()=>{this._dataConsumers.delete(e.id)}))}}Is.Transport=Lo;var Ao={},jo={},Fo={},No={exports:{}},Bo=No.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(Bo).forEach((function(e){Bo[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var s=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var s=0;s<n.length;s+=1)null!=e[s+1]&&(r[n[s]]=t(e[s+1]))}(n.match(e.reg),s,e.names,e.name),e.push&&r[e.push].push(s)},n=No.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},s=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(s.push({rtp:[],fmtp:[]}),o=s[s.length-1]);for(var a=0;a<(n[t]||[]).length;a+=1){var c=n[t][a];if(c.reg.test(i))return r(c,o,i)}})),t.media=s,t};var s=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(s,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],n=e.split(" ").map(t),i=0;i<n.length;i+=3)r.push({component:n[i],ip:n[i+1],port:n[i+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(s,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(Fo);var Wo=No.exports,qo=/%[sdv%]/g,Uo=function(e){var t=1,r=arguments,n=r.length;return e.replace(qo,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},zo=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var s=t.names[i];t.name?n.push(r[t.name][s]):n.push(r[t.names[i]])}else n.push(r[t.name]);return Uo.apply(null,n)},Vo=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Ho=["i","c","b","a"],$o=Fo,Ko=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||Vo,n=t.innerOrder||Ho,i=[];return r.forEach((function(t){Wo[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(zo(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(zo(t,r,e))}))}))})),e.media.forEach((function(e){i.push(zo("m",Wo.m[0],e)),n.forEach((function(t){Wo[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(zo(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(zo(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"},Go=No.exports;jo.grammar=Go,jo.write=Ko,jo.parse=$o.parse,jo.parseParams=$o.parseParams,jo.parseFmtpConfig=$o.parseFmtpConfig,jo.parsePayloads=$o.parsePayloads,jo.parseRemoteCandidates=$o.parseRemoteCandidates,jo.parseImageAttributes=$o.parseImageAttributes,jo.parseSimulcastStreamList=$o.parseSimulcastStreamList;var Qo={},Jo=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Yo=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Zo=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Jo(r,t,n[i]);return Yo(r,t),r}}();Object.defineProperty(Qo,"__esModule",{value:!0}),Qo.extractRtpCapabilities=function({sdpObject:e}){const t=new Map,r=[];let n=!1,i=!1;for(const s of e.media){const e=s.type;switch(e){case"audio":if(n)continue;n=!0;break;case"video":if(i)continue;i=!0;break;default:continue}for(const r of s.rtp){const n={kind:e,mimeType:`${e}/${r.codec}`,preferredPayloadType:r.payload,clockRate:r.rate,channels:r.encoding,parameters:{},rtcpFeedback:[]};t.set(n.preferredPayloadType,n)}for(const e of s.fmtp||[]){const r=Xo.parseParams(e.config),n=t.get(e.payload);n&&(r?.hasOwnProperty("profile-level-id")&&(r["profile-level-id"]=String(r["profile-level-id"])),n.parameters=r)}for(const r of s.rtcpFb||[]){const n={type:r.type,parameter:r.subtype};if(n.parameter||delete n.parameter,"*"!==r.payload){const e=t.get(r.payload);if(!e)continue;e.rtcpFeedback.push(n)}else for(const r of t.values())r.kind!==e||/.+\/rtx$/i.test(r.mimeType)||r.rtcpFeedback.push(n)}for(const t of s.ext||[]){if(t["encrypt-uri"])continue;const n={kind:e,uri:t.uri,preferredId:t.value};r.push(n)}}return{codecs:Array.from(t.values()),headerExtensions:r}},Qo.extractDtlsParameters=function({sdpObject:e}){let t,r=e.setup,n=e.fingerprint;if(!r||!n){const t=(e.media||[]).find((e=>0!==e.port));t&&(r??(r=t.setup),n??(n=t.fingerprint))}if(!r)throw new Error("no a=setup found at SDP session or media level");if(!n)throw new Error("no a=fingerprint found at SDP session or media level");switch(r){case"active":t="client";break;case"passive":t="server";break;case"actpass":t="auto"}return{role:t,fingerprints:[{algorithm:n.type,value:n.hash}]}},Qo.getCname=function({offerMediaObject:e}){const t=(e.ssrcs||[]).find((e=>"cname"===e.attribute));if(!t)return"";return t.value},Qo.applyCodecParameters=function({offerRtpParameters:e,answerMediaObject:t}){for(const r of e.codecs){const e=r.mimeType.toLowerCase();if("audio/opus"!==e)continue;const n=(t.rtp||[]).find((e=>e.payload===r.payloadType));if(!n)continue;t.fmtp=t.fmtp||[];let i=t.fmtp.find((e=>e.payload===r.payloadType));i||(i={payload:r.payloadType,config:""},t.fmtp.push(i));const s=Xo.parseParams(i.config);switch(e){case"audio/opus":{const e=r.parameters["sprop-stereo"];void 0!==e&&(s.stereo=Number(e)?1:0);break}}i.config="";for(const e of Object.keys(s))i.config&&(i.config+=";"),i.config+=`${e}=${s[e]}`}};const Xo=Zo(jo);var ea={};Object.defineProperty(ea,"__esModule",{value:!0}),ea.getRtpEncodings=function({offerMediaObject:e}){const t=new Set;for(const r of e.ssrcs||[]){const e=r.id;t.add(e)}if(0===t.size)throw new Error("no a=ssrc lines found");const r=new Map;for(const n of e.ssrcGroups||[]){if("FID"!==n.semantics)continue;let[e,i]=n.ssrcs.split(/\s+/);e=Number(e),i=Number(i),t.has(e)&&(t.delete(e),t.delete(i),r.set(e,i))}for(const e of t)r.set(e,null);const n=[];for(const[e,t]of r){const r={ssrc:e};t&&(r.rtx={ssrc:t}),n.push(r)}return n},ea.addLegacySimulcast=function({offerMediaObject:e,numStreams:t}){if(t<=1)throw new TypeError("numStreams must be greater than 1");const r=(e.ssrcs||[]).find((e=>"msid"===e.attribute));if(!r)throw new Error("a=ssrc line with msid information not found");const[n,i]=r.value.split(" "),s=Number(r.id);let o;(e.ssrcGroups||[]).some((e=>{if("FID"!==e.semantics)return!1;const t=e.ssrcs.split(/\s+/);return Number(t[0])===s&&(o=Number(t[1]),!0)}));const a=e.ssrcs.find((e=>"cname"===e.attribute));if(!a)throw new Error("a=ssrc line with cname information not found");const c=a.value,d=[],u=[];for(let e=0;e<t;++e)d.push(s+e),o&&u.push(o+e);e.ssrcGroups=[],e.ssrcs=[],e.ssrcGroups.push({semantics:"SIM",ssrcs:d.join(" ")});for(const t of d)e.ssrcs.push({id:t,attribute:"cname",value:c}),e.ssrcs.push({id:t,attribute:"msid",value:`${n} ${i}`});for(let t=0;t<u.length;++t){const r=d[t],s=u[t];e.ssrcs.push({id:s,attribute:"cname",value:c}),e.ssrcs.push({id:s,attribute:"msid",value:`${n} ${i}`}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${r} ${s}`})}};var ta={};Object.defineProperty(ta,"__esModule",{value:!0}),ta.addNackSuppportForOpus=function(e){for(const t of e.codecs??[])"audio/opus"!==t.mimeType.toLowerCase()&&"audio/multiopus"!==t.mimeType.toLowerCase()||t.rtcpFeedback?.some((e=>"nack"===e.type&&!e.parameter))||(t.rtcpFeedback||(t.rtcpFeedback=[]),t.rtcpFeedback.push({type:"nack"}))};var ra={};Object.defineProperty(ra,"__esModule",{value:!0}),ra.HandlerInterface=void 0;const na=wi;class ia extends na.EnhancedEventEmitter{constructor(){super()}}ra.HandlerInterface=ia;var sa={},oa={},aa=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),ca=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),da=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&aa(r,t,n[i]);return ca(r,t),r}}();Object.defineProperty(oa,"__esModule",{value:!0}),oa.OfferMediaSection=oa.AnswerMediaSection=oa.MediaSection=void 0;const ua=da(jo),la=da(Bi);class pa{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:n=!1}){if(this._mediaObject={},this._planB=n,e&&this.setIceParameters(e),t){this._mediaObject.candidates=[];for(const e of t){const t={component:1};t.foundation=e.foundation,t.ip=e.address??e.ip,t.port=e.port,t.priority=e.priority,t.transport=e.protocol,t.type=e.type,e.tcpType&&(t.tcptype=e.tcpType),this._mediaObject.candidates.push(t)}this._mediaObject.endOfCandidates="end-of-candidates",this._mediaObject.iceOptions="renomination"}r&&this.setDtlsRole(r.role)}get mid(){return String(this._mediaObject.mid)}get closed(){return 0===this._mediaObject.port}getObject(){return this._mediaObject}setIceParameters(e){this._mediaObject.iceUfrag=e.usernameFragment,this._mediaObject.icePwd=e.password}pause(){this._mediaObject.direction="inactive"}disable(){this.pause(),delete this._mediaObject.ext,delete this._mediaObject.ssrcs,delete this._mediaObject.ssrcGroups,delete this._mediaObject.simulcast,delete this._mediaObject.simulcast_03,delete this._mediaObject.rids,delete this._mediaObject.extmapAllowMixed}close(){this.disable(),this._mediaObject.port=0}}oa.MediaSection=pa;oa.AnswerMediaSection=class extends pa{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,planB:s=!1,offerMediaObject:o,offerRtpParameters:a,answerRtpParameters:c,codecOptions:d,extmapAllowMixed:u=!1}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:s}),this._mediaObject.mid=String(o.mid),this._mediaObject.type=o.type,this._mediaObject.protocol=o.protocol,i?(this._mediaObject.connection={ip:i.ip,version:i.ipVersion},this._mediaObject.port=i.port):(this._mediaObject.connection={ip:"127.0.0.1",version:4},this._mediaObject.port=7),o.type){case"audio":case"video":this._mediaObject.direction="recvonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[];for(const e of c.codecs){const t={payload:e.payloadType,codec:ha(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r=la.clone(e.parameters)??{};let n=la.clone(e.rtcpFeedback)??[];if(d){const{opusStereo:t,opusFec:i,opusDtx:s,opusMaxPlaybackRate:o,opusMaxAverageBitrate:c,opusPtime:u,opusNack:l,videoGoogleStartBitrate:p,videoGoogleMaxBitrate:h,videoGoogleMinBitrate:f}=d,m=a.codecs.find((t=>t.payloadType===e.payloadType));switch(e.mimeType.toLowerCase()){case"audio/opus":case"audio/multiopus":void 0!==t&&(m.parameters["sprop-stereo"]=t?1:0,r.stereo=t?1:0),void 0!==i&&(m.parameters.useinbandfec=i?1:0,r.useinbandfec=i?1:0),void 0!==s&&(m.parameters.usedtx=s?1:0,r.usedtx=s?1:0),void 0!==o&&(r.maxplaybackrate=o),void 0!==c&&(r.maxaveragebitrate=c),void 0!==u&&(m.parameters.ptime=u,r.ptime=u),l||(m.rtcpFeedback=m.rtcpFeedback.filter((e=>"nack"!==e.type||e.parameter)),n=n.filter((e=>"nack"!==e.type||e.parameter)));break;case"video/vp8":case"video/vp9":case"video/h264":case"video/h265":void 0!==p&&(r["x-google-start-bitrate"]=p),void 0!==h&&(r["x-google-max-bitrate"]=h),void 0!==f&&(r["x-google-min-bitrate"]=f)}}const i={payload:e.payloadType,config:""};for(const e of Object.keys(r))i.config&&(i.config+=";"),i.config+=`${e}=${r[e]}`;i.config&&this._mediaObject.fmtp.push(i);for(const t of n)this._mediaObject.rtcpFb.push({payload:e.payloadType,type:t.type,subtype:t.parameter})}this._mediaObject.payloads=c.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of c.headerExtensions){(o.ext??[]).some((t=>t.uri===e.uri))&&this._mediaObject.ext.push({uri:e.uri,value:e.id})}if(u&&"extmap-allow-mixed"===o.extmapAllowMixed&&(this._mediaObject.extmapAllowMixed="extmap-allow-mixed"),o.simulcast){this._mediaObject.simulcast={dir1:"recv",list1:o.simulcast.list1},this._mediaObject.rids=[];for(const e of o.rids??[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}else if(o.simulcast_03){this._mediaObject.simulcast_03={value:o.simulcast_03.value.replace(/send/g,"recv")},this._mediaObject.rids=[];for(const e of o.rids??[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize",this._planB&&"video"===this._mediaObject.type&&(this._mediaObject.xGoogleFlag="conference");break;case"application":"number"==typeof o.sctpPort?(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=n.port,this._mediaObject.maxMessageSize=n.maxMessageSize):o.sctpmap&&(this._mediaObject.payloads=n.port,this._mediaObject.sctpmap={app:"webrtc-datachannel",sctpmapNumber:n.port,maxMessageSize:n.maxMessageSize})}}setDtlsRole(e){switch(e){case"client":this._mediaObject.setup="active";break;case"server":this._mediaObject.setup="passive";break;case"auto":this._mediaObject.setup="actpass"}}resume(){this._mediaObject.direction="recvonly"}muxSimulcastStreams(e){if(!this._mediaObject.simulcast?.list1)return;const t={};for(const r of e)r.rid&&(t[r.rid]=r);const r=this._mediaObject.simulcast.list1,n=ua.parseSimulcastStreamList(r);for(const e of n)for(const r of e)r.paused=!t[r.scid]?.active;this._mediaObject.simulcast.list1=n.map((e=>e.map((e=>`${e.paused?"~":""}${e.scid}`)).join(","))).join(";")}};function ha(e){const t=new RegExp("^(audio|video)/(.+)","i").exec(e.mimeType);if(!t)throw new TypeError("invalid codec.mimeType");return t[2]}oa.OfferMediaSection=class extends pa{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,planB:s=!1,mid:o,kind:a,offerRtpParameters:c,streamId:d,trackId:u,oldDataChannelSpec:l=!1}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r,planB:s}),this._mediaObject.mid=String(o),this._mediaObject.type=a,i?(this._mediaObject.connection={ip:i.ip,version:i.ipVersion},this._mediaObject.protocol="RTP/AVP",this._mediaObject.port=i.port):(this._mediaObject.connection={ip:"127.0.0.1",version:4},this._mediaObject.protocol=n?"UDP/DTLS/SCTP":"UDP/TLS/RTP/SAVPF",this._mediaObject.port=7),a){case"audio":case"video":{this._mediaObject.direction="sendonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[],this._planB||(this._mediaObject.msid=`${d??"-"} ${u}`);for(const e of c.codecs){const t={payload:e.payloadType,codec:ha(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r={payload:e.payloadType,config:""};for(const t of Object.keys(e.parameters))r.config&&(r.config+=";"),r.config+=`${t}=${e.parameters[t]}`;r.config&&this._mediaObject.fmtp.push(r);for(const t of e.rtcpFeedback)this._mediaObject.rtcpFb.push({payload:e.payloadType,type:t.type,subtype:t.parameter})}this._mediaObject.payloads=c.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of c.headerExtensions)this._mediaObject.ext.push({uri:e.uri,value:e.id});this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize";const e=c.encodings[0],t=e.ssrc,r=e.rtx?.ssrc;this._mediaObject.ssrcs=[],this._mediaObject.ssrcGroups=[],c.rtcp.cname&&this._mediaObject.ssrcs.push({id:t,attribute:"cname",value:c.rtcp.cname}),this._planB&&this._mediaObject.ssrcs.push({id:t,attribute:"msid",value:`${d??"-"} ${u}`}),r&&(c.rtcp.cname&&this._mediaObject.ssrcs.push({id:r,attribute:"cname",value:c.rtcp.cname}),this._planB&&this._mediaObject.ssrcs.push({id:r,attribute:"msid",value:`${d??"-"} ${u}`}),this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}));break}case"application":l?(this._mediaObject.payloads=n.port,this._mediaObject.sctpmap={app:"webrtc-datachannel",sctpmapNumber:n.port,maxMessageSize:n.maxMessageSize}):(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=n.port,this._mediaObject.maxMessageSize=n.maxMessageSize)}}setDtlsRole(e){this._mediaObject.setup="actpass"}resume(){this._mediaObject.direction="sendonly"}planBReceive({offerRtpParameters:e,streamId:t,trackId:r}){const n=e.encodings[0],i=n.ssrc,s=n.rtx?.ssrc,o=this._mediaObject.payloads.split(" ");for(const t of e.codecs){if(o.includes(String(t.payloadType)))continue;const e={payload:t.payloadType,codec:ha(t),rate:t.clockRate};t.channels>1&&(e.encoding=t.channels),this._mediaObject.rtp.push(e);const r={payload:t.payloadType,config:""};for(const e of Object.keys(t.parameters))r.config&&(r.config+=";"),r.config+=`${e}=${t.parameters[e]}`;r.config&&this._mediaObject.fmtp.push(r);for(const e of t.rtcpFeedback)this._mediaObject.rtcpFb.push({payload:t.payloadType,type:e.type,subtype:e.parameter})}this._mediaObject.payloads+=` ${e.codecs.filter((e=>!this._mediaObject.payloads.includes(e.payloadType))).map((e=>e.payloadType)).join(" ")}`,this._mediaObject.payloads=this._mediaObject.payloads.trim(),e.rtcp.cname&&this._mediaObject.ssrcs.push({id:i,attribute:"cname",value:e.rtcp.cname}),this._mediaObject.ssrcs.push({id:i,attribute:"msid",value:`${t??"-"} ${r}`}),s&&(e.rtcp.cname&&this._mediaObject.ssrcs.push({id:s,attribute:"cname",value:e.rtcp.cname}),this._mediaObject.ssrcs.push({id:s,attribute:"msid",value:`${t??"-"} ${r}`}),this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${i} ${s}`}))}planBStopReceiving({offerRtpParameters:e}){const t=e.encodings[0],r=t.ssrc,n=t.rtx?.ssrc;this._mediaObject.ssrcs=this._mediaObject.ssrcs.filter((e=>e.id!==r&&e.id!==n)),n&&(this._mediaObject.ssrcGroups=this._mediaObject.ssrcGroups.filter((e=>e.ssrcs!==`${r} ${n}`)))}};var fa=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),ma=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ga=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&fa(r,t,n[i]);return ma(r,t),r}}();Object.defineProperty(sa,"__esModule",{value:!0}),sa.RemoteSdp=void 0;const va=ga(jo),ya=oa,ba=new mi.Logger("RemoteSdp");sa.RemoteSdp=class{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,planB:s=!1}){if(this._mediaSections=[],this._midToIndex=new Map,this._iceParameters=e,this._iceCandidates=t,this._dtlsParameters=r,this._sctpParameters=n,this._plainRtpParameters=i,this._planB=s,this._sdpObject={version:0,origin:{address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:1e4,sessionVersion:0,username:"mediasoup-client"},name:"-",timing:{start:0,stop:0},media:[]},e?.iceLite&&(this._sdpObject.icelite="ice-lite"),r){this._sdpObject.msidSemantic={semantic:"WMS",token:"*"};const e=this._dtlsParameters.fingerprints.length;this._sdpObject.fingerprint={type:r.fingerprints[e-1].algorithm,hash:r.fingerprints[e-1].value},this._sdpObject.groups=[{type:"BUNDLE",mids:""}]}i&&(this._sdpObject.origin.address=i.ip,this._sdpObject.origin.ipVer=i.ipVersion)}updateIceParameters(e){ba.debug("updateIceParameters() [iceParameters:%o]",e),this._iceParameters=e,this._sdpObject.icelite=e.iceLite?"ice-lite":void 0;for(const t of this._mediaSections)t.setIceParameters(e)}updateDtlsRole(e){ba.debug("updateDtlsRole() [role:%s]",e),this._dtlsParameters.role=e;for(const t of this._mediaSections)t.setDtlsRole(e)}getNextMediaSectionIdx(){for(let e=0;e<this._mediaSections.length;++e){const t=this._mediaSections[e];if(t.closed)return{idx:e,reuseMid:t.mid}}return{idx:this._mediaSections.length}}send({offerMediaObject:e,reuseMid:t,offerRtpParameters:r,answerRtpParameters:n,codecOptions:i,extmapAllowMixed:s=!1}){const o=new ya.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,planB:this._planB,offerMediaObject:e,offerRtpParameters:r,answerRtpParameters:n,codecOptions:i,extmapAllowMixed:s});t?this._replaceMediaSection(o,t):this._midToIndex.has(o.mid)?this._replaceMediaSection(o):this._addMediaSection(o)}receive({mid:e,kind:t,offerRtpParameters:r,streamId:n,trackId:i}){const s=this._midToIndex.get(e);let o;if(void 0!==s&&(o=this._mediaSections[s]),o)o.planBReceive({offerRtpParameters:r,streamId:n,trackId:i}),this._replaceMediaSection(o);else{o=new ya.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,planB:this._planB,mid:e,kind:t,offerRtpParameters:r,streamId:n,trackId:i});const s=this._mediaSections.find((e=>e.closed));s?this._replaceMediaSection(o,s.mid):this._addMediaSection(o)}}pauseMediaSection(e){this._findMediaSection(e).pause()}resumeSendingMediaSection(e){this._findMediaSection(e).resume()}resumeReceivingMediaSection(e){this._findMediaSection(e).resume()}disableMediaSection(e){this._findMediaSection(e).disable()}closeMediaSection(e){const t=this._findMediaSection(e);return e===this._firstMid?(ba.debug("closeMediaSection() | cannot close first media section, disabling it instead [mid:%s]",e),this.disableMediaSection(e),!1):(t.close(),this._regenerateBundleMids(),!0)}muxMediaSectionSimulcast(e,t){const r=this._findMediaSection(e);r.muxSimulcastStreams(t),this._replaceMediaSection(r)}planBStopReceiving({mid:e,offerRtpParameters:t}){const r=this._findMediaSection(e);r.planBStopReceiving({offerRtpParameters:t}),this._replaceMediaSection(r)}sendSctpAssociation({offerMediaObject:e}){const t=new ya.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,offerMediaObject:e});this._addMediaSection(t)}receiveSctpAssociation({oldDataChannelSpec:e=!1}={}){const t=new ya.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,mid:"datachannel",kind:"application",oldDataChannelSpec:e});this._addMediaSection(t)}getSdp(){return this._sdpObject.origin.sessionVersion++,va.write(this._sdpObject)}_addMediaSection(e){this._firstMid||(this._firstMid=e.mid),this._mediaSections.push(e),this._midToIndex.set(e.mid,this._mediaSections.length-1),this._sdpObject.media.push(e.getObject()),this._regenerateBundleMids()}_replaceMediaSection(e,t){if("string"==typeof t){const r=this._midToIndex.get(t);if(void 0===r)throw new Error(`no media section found for reuseMid '${t}'`);const n=this._mediaSections[r];this._mediaSections[r]=e,this._midToIndex.delete(n.mid),this._midToIndex.set(e.mid,r),this._sdpObject.media[r]=e.getObject(),this._regenerateBundleMids()}else{const t=this._midToIndex.get(e.mid);if(void 0===t)throw new Error(`no media section found with mid '${e.mid}'`);this._mediaSections[t]=e,this._sdpObject.media[t]=e.getObject()}}_findMediaSection(e){const t=this._midToIndex.get(e);if(void 0===t)throw new Error(`no media section found with mid '${e}'`);return this._mediaSections[t]}_regenerateBundleMids(){this._dtlsParameters&&(this._sdpObject.groups[0].mids=this._mediaSections.filter((e=>!e.closed)).map((e=>e.mid)).join(" "))}};var wa={};Object.defineProperty(wa,"__esModule",{value:!0}),wa.parse=function(e){const t=_a.exec(e??"");return t?{spatialLayers:Number(t[1]),temporalLayers:Number(t[2])}:{spatialLayers:1,temporalLayers:1}};const _a=new RegExp("^[LS]([1-9]\\d{0,1})T([1-9]\\d{0,1})");var Sa=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),ka=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ca=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Sa(r,t,n[i]);return ka(r,t),r}}();Object.defineProperty(Ao,"__esModule",{value:!0}),Ao.Chrome111=void 0;const Ra=Ca(jo),Pa=mi,Ta=Ca(Bi),Ea=Ca(Wi),Da=Ca(Qo),Ma=Ca(ea),Ia=Ca(ta),xa=or,Oa=ra,La=sa,Aa=wa,ja=new Pa.Logger("Chrome111"),Fa={OS:1024,MIS:1024};class Na extends Oa.HandlerInterface{static createFactory(){return()=>new Na}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome111"}close(){if(ja.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){ja.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=Ra.parse(t.sdp),n=Da.extractRtpCapabilities({sdpObject:r});return Ia.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return ja.debug("getNativeSctpCapabilities()"),{numStreams:Fa}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),ja.debug("run()"),this._direction=e,this._remoteSdp=new La.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Ea.getSendingRtpParameters("audio",d),video:Ea.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Ea.getSendingRemoteRtpParameters("audio",d),video:Ea.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):(ja.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})))}async updateIceServers(e){this.assertNotClosed(),ja.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),ja.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});ja.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};ja.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};ja.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();ja.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){if(this.assertNotClosed(),this.assertSendDirection(),ja.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1){let e=1;for(const r of t){const t=r.scalabilityMode?(0,Aa.parse)(r.scalabilityMode).temporalLayers:3;t>e&&(e=t)}t.forEach(((t,r)=>{t.rid=`r${r}`,t.scalabilityMode=`L1T${e}`}))}const s=Ta.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Ea.reduceCodecs(s.codecs,n);const o=Ta.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Ea.reduceCodecs(o.codecs,n);const a=this._remoteSdp.getNextMediaSectionIdx(),c=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(c.sender);const d=await this._pc.createOffer();let u=Ra.parse(d.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u}),ja.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d);const l=c.mid;s.mid=l,u=Ra.parse(this._pc.localDescription.sdp);const p=u.media[a.idx];if(s.rtcp.cname=Da.getCname({offerMediaObject:p}),t)if(1===t.length){const e=Ma.getRtpEncodings({offerMediaObject:p});Object.assign(e[0],t[0]),s.encodings=e}else s.encodings=t;else s.encodings=Ma.getRtpEncodings({offerMediaObject:p});this._remoteSdp.send({offerMediaObject:p,reuseMid:a.reuseMid,offerRtpParameters:s,answerRtpParameters:o,codecOptions:r,extmapAllowMixed:!0});const h={type:"answer",sdp:this._remoteSdp.getSdp()};return ja.debug("send() | calling pc.setRemoteDescription() [answer:%o]",h),await this._pc.setRemoteDescription(h),this._mapMidTransceiver.set(l,c),{localId:l,rtpParameters:s,rtpSender:c.sender}}async stopSending(e){if(this.assertSendDirection(),ja.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();ja.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ja.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),ja.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();ja.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ja.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),ja.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();ja.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ja.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?ja.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):ja.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),ja.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();ja.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};ja.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),ja.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();ja.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};ja.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};ja.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Fa.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Ra.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),ja.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};ja.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;ja.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};ja.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=Ra.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Da.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Ra.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),ja.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){ja.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};ja.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ja.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){ja.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};ja.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ja.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){ja.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};ja.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ja.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};ja.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};ja.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Ra.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}ja.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Ra.parse(this._pc.localDescription.sdp));const r=Da.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new xa.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Ao.Chrome111=Na;var Ba={},Wa=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),qa=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ua=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Wa(r,t,n[i]);return qa(r,t),r}}();Object.defineProperty(Ba,"__esModule",{value:!0}),Ba.Chrome74=void 0;const za=Ua(jo),Va=mi,Ha=Ua(Bi),$a=Ua(Wi),Ka=Ua(Qo),Ga=Ua(ea),Qa=Ua(ta),Ja=or,Ya=ra,Za=sa,Xa=wa,ec=new Va.Logger("Chrome74"),tc={OS:1024,MIS:1024};class rc extends Ya.HandlerInterface{static createFactory(){return()=>new rc}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome74"}close(){if(ec.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){ec.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=za.parse(t.sdp),n=Ka.extractRtpCapabilities({sdpObject:r});return Qa.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return ec.debug("getNativeSctpCapabilities()"),{numStreams:tc}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){ec.debug("run()"),this._direction=e,this._remoteSdp=new Za.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:$a.getSendingRtpParameters("audio",d),video:$a.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:$a.getSendingRemoteRtpParameters("audio",d),video:$a.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):(ec.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})))}async updateIceServers(e){this.assertNotClosed(),ec.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),ec.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});ec.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};ec.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};ec.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();ec.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertNotClosed(),this.assertSendDirection(),ec.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const i=Ha.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=$a.reduceCodecs(i.codecs,n);const s=Ha.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=$a.reduceCodecs(s.codecs,n);const o=this._remoteSdp.getNextMediaSectionIdx(),a=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});let c,d=await this._pc.createOffer(),u=za.parse(d.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u});let l=!1;const p=(0,Xa.parse)((t??[{}])[0].scalabilityMode);t&&1===t.length&&p.spatialLayers>1&&"video/vp9"===i.codecs[0].mimeType.toLowerCase()&&(ec.debug("send() | enabling legacy simulcast for VP9 SVC"),l=!0,u=za.parse(d.sdp),c=u.media[o.idx],Ga.addLegacySimulcast({offerMediaObject:c,numStreams:p.spatialLayers}),d={type:"offer",sdp:za.write(u)}),ec.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d);const h=a.mid;if(i.mid=h,u=za.parse(this._pc.localDescription.sdp),c=u.media[o.idx],i.rtcp.cname=Ka.getCname({offerMediaObject:c}),t)if(1===t.length){let e=Ga.getRtpEncodings({offerMediaObject:c});Object.assign(e[0],t[0]),l&&(e=[e[0]]),i.encodings=e}else i.encodings=t;else i.encodings=Ga.getRtpEncodings({offerMediaObject:c});if(i.encodings.length>1&&("video/vp8"===i.codecs[0].mimeType.toLowerCase()||"video/h264"===i.codecs[0].mimeType.toLowerCase()))for(const e of i.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${p.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:c,reuseMid:o.reuseMid,offerRtpParameters:i,answerRtpParameters:s,codecOptions:r,extmapAllowMixed:!0});const f={type:"answer",sdp:this._remoteSdp.getSdp()};return ec.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f),this._mapMidTransceiver.set(h,a),{localId:h,rtpParameters:i,rtpSender:a.sender}}async stopSending(e){if(this.assertSendDirection(),ec.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();ec.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ec.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),ec.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();ec.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ec.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),ec.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();ec.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ec.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?ec.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):ec.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),ec.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();ec.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};ec.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),ec.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();ec.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};ec.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};ec.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%tc.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=za.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),ec.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};ec.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;ec.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};ec.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=za.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Ka.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:za.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),ec.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){ec.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};ec.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ec.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){ec.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};ec.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ec.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){ec.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};ec.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ec.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};ec.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};ec.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=za.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}ec.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=za.parse(this._pc.localDescription.sdp));const r=Ka.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new Ja.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Ba.Chrome74=rc;var nc={},ic=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),sc=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),oc=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&ic(r,t,n[i]);return sc(r,t),r}}();Object.defineProperty(nc,"__esModule",{value:!0}),nc.Chrome70=void 0;const ac=oc(jo),cc=mi,dc=oc(Bi),uc=oc(Wi),lc=oc(Qo),pc=oc(ea),hc=ra,fc=sa,mc=wa,gc=new cc.Logger("Chrome70"),vc={OS:1024,MIS:1024};class yc extends hc.HandlerInterface{static createFactory(){return()=>new yc}constructor(){super(),this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome70"}close(){if(gc.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){gc.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=ac.parse(t.sdp);return lc.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return gc.debug("getNativeSctpCapabilities()"),{numStreams:vc}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){gc.debug("run()"),this._direction=e,this._remoteSdp=new fc.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:uc.getSendingRtpParameters("audio",d),video:uc.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:uc.getSendingRemoteRtpParameters("audio",d),video:uc.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(gc.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){gc.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(gc.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});gc.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};gc.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};gc.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();gc.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),gc.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const i=dc.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=uc.reduceCodecs(i.codecs,n);const s=dc.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=uc.reduceCodecs(s.codecs,n);const o=this._remoteSdp.getNextMediaSectionIdx(),a=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});let c,d=await this._pc.createOffer(),u=ac.parse(d.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u}),t&&t.length>1&&(gc.debug("send() | enabling legacy simulcast"),u=ac.parse(d.sdp),c=u.media[o.idx],pc.addLegacySimulcast({offerMediaObject:c,numStreams:t.length}),d={type:"offer",sdp:ac.write(u)});let l=!1;const p=(0,mc.parse)((t??[{}])[0].scalabilityMode);if(t&&1===t.length&&p.spatialLayers>1&&"video/vp9"===i.codecs[0].mimeType.toLowerCase()&&(gc.debug("send() | enabling legacy simulcast for VP9 SVC"),l=!0,u=ac.parse(d.sdp),c=u.media[o.idx],pc.addLegacySimulcast({offerMediaObject:c,numStreams:p.spatialLayers}),d={type:"offer",sdp:ac.write(u)}),gc.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d),t){gc.debug("send() | applying given encodings");const e=a.sender.getParameters();for(let r=0;r<(e.encodings??[]).length;++r){const n=e.encodings[r],i=t[r];if(!i)break;e.encodings[r]=Object.assign(n,i)}await a.sender.setParameters(e)}const h=a.mid;if(i.mid=h,u=ac.parse(this._pc.localDescription.sdp),c=u.media[o.idx],i.rtcp.cname=lc.getCname({offerMediaObject:c}),i.encodings=pc.getRtpEncodings({offerMediaObject:c}),t)for(let e=0;e<i.encodings.length;++e)t[e]&&Object.assign(i.encodings[e],t[e]);if(l&&(i.encodings=[i.encodings[0]]),i.encodings.length>1&&("video/vp8"===i.codecs[0].mimeType.toLowerCase()||"video/h264"===i.codecs[0].mimeType.toLowerCase()))for(const e of i.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:c,reuseMid:o.reuseMid,offerRtpParameters:i,answerRtpParameters:s,codecOptions:r});const f={type:"answer",sdp:this._remoteSdp.getSdp()};return gc.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f),this._mapMidTransceiver.set(h,a),{localId:h,rtpParameters:i,rtpSender:a.sender}}async stopSending(e){this.assertSendDirection(),gc.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();gc.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};gc.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?gc.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):gc.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),gc.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();gc.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};gc.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),gc.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();gc.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};gc.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:i};gc.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%vc.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=ac.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),gc.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};gc.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;gc.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};gc.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=ac.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));lc.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:ac.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),gc.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){gc.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};gc.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();gc.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmitTime:s,maxRetransmits:o,protocol:r};gc.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};gc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=ac.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}gc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=ac.parse(this._pc.localDescription.sdp));const r=lc.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}nc.Chrome70=yc;var bc={},wc={};Object.defineProperty(wc,"__esModule",{value:!0}),wc.getRtpEncodings=function({offerMediaObject:e,track:t}){const r=new Set;for(const n of e.ssrcs||[]){if("msid"!==n.attribute)continue;if(n.value.split(" ")[1]===t.id){const e=n.id;r.add(e)}}if(0===r.size)throw new Error(`a=ssrc line with msid information not found [track.id:${t.id}]`);const n=new Map;for(const t of e.ssrcGroups||[]){if("FID"!==t.semantics)continue;let[e,i]=t.ssrcs.split(/\s+/);e=Number(e),i=Number(i),r.has(e)&&(r.delete(e),r.delete(i),n.set(e,i))}for(const e of r)n.set(e,null);const i=[];for(const[e,t]of n){const r={ssrc:e};t&&(r.rtx={ssrc:t}),i.push(r)}return i},wc.addLegacySimulcast=function({offerMediaObject:e,track:t,numStreams:r}){if(r<=1)throw new TypeError("numStreams must be greater than 1");let n,i,s;if(!(e.ssrcs||[]).find((e=>{if("msid"!==e.attribute)return!1;return e.value.split(" ")[1]===t.id&&(n=e.id,s=e.value.split(" ")[0],!0)})))throw new Error(`a=ssrc line with msid information not found [track.id:${t.id}]`);(e.ssrcGroups||[]).some((e=>{if("FID"!==e.semantics)return!1;const t=e.ssrcs.split(/\s+/);return Number(t[0])===n&&(i=Number(t[1]),!0)}));const o=e.ssrcs.find((e=>"cname"===e.attribute&&e.id===n));if(!o)throw new Error(`a=ssrc line with cname information not found [track.id:${t.id}]`);const a=o.value,c=[],d=[];for(let e=0;e<r;++e)c.push(n+e),i&&d.push(i+e);e.ssrcGroups=e.ssrcGroups||[],e.ssrcs=e.ssrcs||[],e.ssrcGroups.push({semantics:"SIM",ssrcs:c.join(" ")});for(const r of c)e.ssrcs.push({id:r,attribute:"cname",value:a}),e.ssrcs.push({id:r,attribute:"msid",value:`${s} ${t.id}`});for(let r=0;r<d.length;++r){const n=c[r],i=d[r];e.ssrcs.push({id:i,attribute:"cname",value:a}),e.ssrcs.push({id:i,attribute:"msid",value:`${s} ${t.id}`}),e.ssrcGroups.push({semantics:"FID",ssrcs:`${n} ${i}`})}};var _c=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Sc=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),kc=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&_c(r,t,n[i]);return Sc(r,t),r}}();Object.defineProperty(bc,"__esModule",{value:!0}),bc.Chrome67=void 0;const Cc=kc(jo),Rc=mi,Pc=kc(Bi),Tc=kc(Wi),Ec=kc(Qo),Dc=kc(wc),Mc=ra,Ic=sa,xc=new Rc.Logger("Chrome67"),Oc={OS:1024,MIS:1024};class Lc extends Mc.HandlerInterface{static createFactory(){return()=>new Lc}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdRtpSender=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome67"}close(){if(xc.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){xc.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=Cc.parse(t.sdp);return Ec.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return xc.debug("getNativeSctpCapabilities()"),{numStreams:Oc}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){xc.debug("run()"),this._direction=e,this._remoteSdp=new Ic.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:Tc.getSendingRtpParameters("audio",d),video:Tc.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Tc.getSendingRemoteRtpParameters("audio",d),video:Tc.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(xc.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){xc.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(xc.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});xc.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};xc.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};xc.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();xc.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),xc.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&xc.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addTrack(e,this._sendStream);let i,s=await this._pc.createOffer(),o=Cc.parse(s.sdp);const a=Pc.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=Tc.reduceCodecs(a.codecs);const c=Pc.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=Tc.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(xc.debug("send() | enabling simulcast"),o=Cc.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),Dc.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Cc.write(o)}),xc.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Cc.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=Ec.getCname({offerMediaObject:i}),a.encodings=Dc.getRtpEncodings({offerMediaObject:i,track:e}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&"video/vp8"===a.codecs[0].mimeType.toLowerCase())for(const e of a.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:i,offerRtpParameters:a,answerRtpParameters:c,codecOptions:r});const d={type:"answer",sdp:this._remoteSdp.getSdp()};xc.debug("send() | calling pc.setRemoteDescription() [answer:%o]",d),await this._pc.setRemoteDescription(d);const u=String(this._nextSendLocalId);this._nextSendLocalId++;const l=this._pc.getSenders().find((t=>t.track===e));return this._mapSendLocalIdRtpSender.set(u,l),{localId:u,rtpParameters:a,rtpSender:l}}async stopSending(e){this.assertSendDirection(),xc.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");this._pc.removeTrack(t),t.track&&this._sendStream.removeTrack(t.track),this._mapSendLocalIdRtpSender.delete(e);const r=await this._pc.createOffer();xc.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void xc.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const n={type:"answer",sdp:this._remoteSdp.getSdp()};xc.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?xc.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):xc.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.track;await r.replaceTrack(t),n&&this._sendStream.removeTrack(n),t&&this._sendStream.addTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),xc.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(n)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),xc.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.setParameters(n)}async getSenderStats(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");return t.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:i};xc.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Oc.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Cc.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),xc.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};xc.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const t of e){const{trackId:e,kind:r,rtpParameters:n,streamId:i}=t;xc.debug("receive() [trackId:%s, kind:%s]",e,r);const s=r;this._remoteSdp.receive({mid:s,kind:r,offerRtpParameters:n,streamId:i??n.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};xc.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=Cc.parse(n.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,n=e,s=i.media.find((e=>String(e.mid)===n));Ec.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:Cc.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),xc.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const r of e){const{kind:e,trackId:n,rtpParameters:i}=r,s=n,o=e,a=this._pc.getReceivers().find((e=>e.track&&e.track.id===s));if(!a)throw new Error("new RTCRtpReceiver not");this._mapRecvLocalIdInfo.set(s,{mid:o,rtpParameters:i,rtpReceiver:a}),t.push({localId:s,track:a.track,rtpReceiver:a})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){xc.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)??{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};xc.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();xc.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){this.assertRecvDirection();const{rtpReceiver:t}=this._mapRecvLocalIdInfo.get(e)??{};if(!t)throw new Error("associated RTCRtpReceiver not found");return t.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmitTime:s,maxRetransmits:o,protocol:r};xc.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};xc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Cc.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}xc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Cc.parse(this._pc.localDescription.sdp));const r=Ec.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}bc.Chrome67=Lc;var Ac={},jc=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Fc=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Nc=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&jc(r,t,n[i]);return Fc(r,t),r}}();Object.defineProperty(Ac,"__esModule",{value:!0}),Ac.Chrome55=void 0;const Bc=Nc(jo),Wc=mi,qc=or,Uc=Nc(Bi),zc=Nc(Wi),Vc=Nc(Qo),Hc=Nc(wc),$c=ra,Kc=sa,Gc=new Wc.Logger("Chrome55"),Qc={OS:1024,MIS:1024};class Jc extends $c.HandlerInterface{static createFactory(){return()=>new Jc}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdTrack=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Chrome55"}close(){if(Gc.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){Gc.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=Bc.parse(t.sdp);return Vc.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Gc.debug("getNativeSctpCapabilities()"),{numStreams:Qc}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Gc.debug("run()"),this._direction=e,this._remoteSdp=new Kc.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:zc.getSendingRtpParameters("audio",d),video:zc.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:zc.getSendingRemoteRtpParameters("audio",d),video:zc.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(Gc.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){Gc.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(Gc.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Gc.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Gc.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Gc.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Gc.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),Gc.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&Gc.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addStream(this._sendStream);let i,s=await this._pc.createOffer(),o=Bc.parse(s.sdp);const a=Uc.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=zc.reduceCodecs(a.codecs);const c=Uc.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=zc.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(Gc.debug("send() | enabling simulcast"),o=Bc.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),Hc.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Bc.write(o)}),Gc.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Bc.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=Vc.getCname({offerMediaObject:i}),a.encodings=Hc.getRtpEncodings({offerMediaObject:i,track:e}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&"video/vp8"===a.codecs[0].mimeType.toLowerCase())for(const e of a.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:i,offerRtpParameters:a,answerRtpParameters:c,codecOptions:r});const d={type:"answer",sdp:this._remoteSdp.getSdp()};Gc.debug("send() | calling pc.setRemoteDescription() [answer:%o]",d),await this._pc.setRemoteDescription(d);const u=String(this._nextSendLocalId);return this._nextSendLocalId++,this._mapSendLocalIdTrack.set(u,e),{localId:u,rtpParameters:a}}async stopSending(e){this.assertSendDirection(),Gc.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdTrack.get(e);if(!t)throw new Error("track not found");this._mapSendLocalIdTrack.delete(e),this._sendStream.removeTrack(t),this._pc.addStream(this._sendStream);const r=await this._pc.createOffer();Gc.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void Gc.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const n={type:"answer",sdp:this._remoteSdp.getSdp()};Gc.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){throw new qc.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new qc.UnsupportedError(" not implemented")}async setRtpEncodingParameters(e,t){throw new qc.UnsupportedError("not supported")}async getSenderStats(e){throw new qc.UnsupportedError("not implemented")}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:i};Gc.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Qc.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Bc.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Gc.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Gc.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const t of e){const{trackId:e,kind:r,rtpParameters:n,streamId:i}=t;Gc.debug("receive() [trackId:%s, kind:%s]",e,r);const s=r;this._remoteSdp.receive({mid:s,kind:r,offerRtpParameters:n,streamId:i??n.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};Gc.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=Bc.parse(n.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,n=e,s=i.media.find((e=>String(e.mid)===n));Vc.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:Bc.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),Gc.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const r of e){const{kind:e,trackId:n,rtpParameters:i}=r,s=e,o=n,a=r.streamId??i.rtcp.cname,c=this._pc.getRemoteStreams().find((e=>e.id===a)),d=c.getTrackById(o);if(!d)throw new Error("remote track not found");this._mapRecvLocalIdInfo.set(o,{mid:s,rtpParameters:i}),t.push({localId:o,track:d})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){Gc.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)??{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Gc.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Gc.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new qc.UnsupportedError("not implemented")}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmitTime:s,maxRetransmits:o,protocol:r};Gc.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};Gc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Bc.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Gc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Bc.parse(this._pc.localDescription.sdp));const r=Vc.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Ac.Chrome55=Jc;var Yc={},Zc=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Xc=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ed=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Zc(r,t,n[i]);return Xc(r,t),r}}();Object.defineProperty(Yc,"__esModule",{value:!0}),Yc.Firefox120=void 0;const td=ed(jo),rd=mi,nd=or,id=ed(Bi),sd=ed(Wi),od=ed(Qo),ad=ed(ea),cd=ra,dd=sa,ud=wa,ld=new rd.Logger("Firefox120"),pd={OS:16,MIS:2048};class hd extends cd.HandlerInterface{static createFactory(){return()=>new hd}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Firefox120"}close(){if(ld.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){ld.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"}),t=document.createElement("canvas");t.getContext("2d");const r=t.captureStream().getVideoTracks()[0];try{e.addTransceiver("audio",{direction:"sendrecv"}),e.addTransceiver(r,{direction:"sendrecv",sendEncodings:[{rid:"r0",maxBitrate:1e5},{rid:"r1",maxBitrate:5e5}]});const n=await e.createOffer();try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}const i=td.parse(n.sdp);return od.extractRtpCapabilities({sdpObject:i})}catch(n){try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}throw n}}async getNativeSctpCapabilities(){return ld.debug("getNativeSctpCapabilities()"),{numStreams:pd}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),ld.debug("run()"),this._direction=e,this._remoteSdp=new dd.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:sd.getSendingRtpParameters("audio",d),video:sd.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:sd.getSendingRemoteRtpParameters("audio",d),video:sd.getSendingRemoteRtpParameters("video",d)},this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(ld.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){throw this.assertNotClosed(),new nd.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),ld.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});ld.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};ld.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};ld.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();ld.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){this.assertNotClosed(),this.assertSendDirection(),ld.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const s=id.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=sd.reduceCodecs(s.codecs,n);const o=id.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=sd.reduceCodecs(o.codecs,n);const a=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(a.sender);const c=await this._pc.createOffer();let d=td.parse(c.sdp);this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:d});const u=(0,ud.parse)((t??[{}])[0].scalabilityMode);ld.debug("send() | calling pc.setLocalDescription() [offer:%o]",c),await this._pc.setLocalDescription(c);const l=a.mid;s.mid=l,d=td.parse(this._pc.localDescription.sdp);const p=d.media[d.media.length-1];if(s.rtcp.cname=od.getCname({offerMediaObject:p}),t)if(1===t.length){const e=ad.getRtpEncodings({offerMediaObject:p});Object.assign(e[0],t[0]),s.encodings=e}else s.encodings=t;else s.encodings=ad.getRtpEncodings({offerMediaObject:p});if(s.encodings.length>1&&("video/vp8"===s.codecs[0].mimeType.toLowerCase()||"video/h264"===s.codecs[0].mimeType.toLowerCase()))for(const e of s.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${u.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:p,offerRtpParameters:s,answerRtpParameters:o,codecOptions:r,extmapAllowMixed:!0});const h={type:"answer",sdp:this._remoteSdp.getSdp()};return ld.debug("send() | calling pc.setRemoteDescription() [answer:%o]",h),await this._pc.setRemoteDescription(h),this._mapMidTransceiver.set(l,a),{localId:l,rtpParameters:s,rtpSender:a.sender}}async stopSending(e){if(this.assertSendDirection(),ld.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated transceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.disableMediaSection(t.mid);const r=await this._pc.createOffer();ld.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ld.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),ld.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();ld.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ld.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),ld.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();ld.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ld.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?ld.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):ld.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),ld.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated transceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();ld.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};ld.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),ld.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();ld.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};ld.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};ld.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%pd.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=td.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),ld.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};ld.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;ld.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};ld.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=td.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,o=r.get(e),a=s.media.find((e=>String(e.mid)===o));od.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:td.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),ld.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){ld.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};ld.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ld.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){ld.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};ld.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ld.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){ld.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};ld.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ld.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};ld.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};ld.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=td.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}ld.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=td.parse(this._pc.localDescription.sdp));const r=od.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new nd.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Yc.Firefox120=hd;var fd={},md=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),gd=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),vd=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&md(r,t,n[i]);return gd(r,t),r}}();Object.defineProperty(fd,"__esModule",{value:!0}),fd.Firefox60=void 0;const yd=vd(jo),bd=mi,wd=or,_d=vd(Bi),Sd=vd(Wi),kd=vd(Qo),Cd=vd(ea),Rd=ra,Pd=sa,Td=wa,Ed=new bd.Logger("Firefox60"),Dd={OS:16,MIS:2048};class Md extends Rd.HandlerInterface{static createFactory(){return()=>new Md}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Firefox60"}close(){if(Ed.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){Ed.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"}),t=document.createElement("canvas");t.getContext("2d");const r=t.captureStream().getVideoTracks()[0];try{e.addTransceiver("audio",{direction:"sendrecv"});const n=e.addTransceiver(r,{direction:"sendrecv"}),i=n.sender.getParameters(),s=[{rid:"r0",maxBitrate:1e5},{rid:"r1",maxBitrate:5e5}];i.encodings=s,await n.sender.setParameters(i);const o=await e.createOffer();try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}const a=yd.parse(o.sdp);return kd.extractRtpCapabilities({sdpObject:a})}catch(n){try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e.close()}catch(e){}throw n}}async getNativeSctpCapabilities(){return Ed.debug("getNativeSctpCapabilities()"),{numStreams:Dd}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),Ed.debug("run()"),this._direction=e,this._remoteSdp=new Pd.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Sd.getSendingRtpParameters("audio",d),video:Sd.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Sd.getSendingRemoteRtpParameters("audio",d),video:Sd.getSendingRemoteRtpParameters("video",d)},this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(Ed.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){throw this.assertNotClosed(),new wd.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),Ed.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Ed.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Ed.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ed.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Ed.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertNotClosed(),this.assertSendDirection(),Ed.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&((t=_d.clone(t)).forEach(((e,t)=>{e.rid=`r${t}`})),t.reverse());const i=_d.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=Sd.reduceCodecs(i.codecs,n);const s=_d.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=Sd.reduceCodecs(s.codecs,n);const o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});if(t){const e=o.sender.getParameters();e.encodings=t,await o.sender.setParameters(e)}const a=await this._pc.createOffer();let c=yd.parse(a.sdp);this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:c});const d=(0,Td.parse)((t??[{}])[0].scalabilityMode);Ed.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);const u=o.mid;i.mid=u,c=yd.parse(this._pc.localDescription.sdp);const l=c.media[c.media.length-1];if(i.rtcp.cname=kd.getCname({offerMediaObject:l}),t)if(1===t.length){const e=Cd.getRtpEncodings({offerMediaObject:l});Object.assign(e[0],t[0]),i.encodings=e}else i.encodings=t.reverse();else i.encodings=Cd.getRtpEncodings({offerMediaObject:l});if(i.encodings.length>1&&("video/vp8"===i.codecs[0].mimeType.toLowerCase()||"video/h264"===i.codecs[0].mimeType.toLowerCase()))for(const e of i.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${d.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:l,offerRtpParameters:i,answerRtpParameters:s,codecOptions:r,extmapAllowMixed:!0});const p={type:"answer",sdp:this._remoteSdp.getSdp()};return Ed.debug("send() | calling pc.setRemoteDescription() [answer:%o]",p),await this._pc.setRemoteDescription(p),this._mapMidTransceiver.set(u,o),{localId:u,rtpParameters:i,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),Ed.debug("stopSending() [localId:%s]",e),this._closed)return;const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated transceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender),this._remoteSdp.disableMediaSection(t.mid);const r=await this._pc.createOffer();Ed.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ed.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Ed.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();Ed.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ed.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Ed.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();Ed.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ed.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Ed.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Ed.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),Ed.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated transceiver not found");const n=r.sender.getParameters();t=n.encodings.length-1-t,n.encodings.forEach(((e,r)=>{e.active=r>=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Ed.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ed.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Ed.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Ed.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ed.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};Ed.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Dd.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=yd.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),Ed.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ed.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;Ed.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};Ed.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=yd.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,o=r.get(e),a=s.media.find((e=>String(e.mid)===o));kd.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:yd.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),Ed.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){Ed.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Ed.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ed.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Ed.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Ed.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ed.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Ed.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Ed.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ed.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};Ed.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ed.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=yd.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}Ed.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=yd.parse(this._pc.localDescription.sdp));const r=kd.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new wd.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}fd.Firefox60=Md;var Id={},xd=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Od=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ld=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&xd(r,t,n[i]);return Od(r,t),r}}();Object.defineProperty(Id,"__esModule",{value:!0}),Id.Safari12=void 0;const Ad=Ld(jo),jd=mi,Fd=Ld(Bi),Nd=Ld(Wi),Bd=Ld(Qo),Wd=Ld(ea),qd=Ld(ta),Ud=or,zd=ra,Vd=sa,Hd=wa,$d=new jd.Logger("Safari12"),Kd={OS:1024,MIS:1024};class Gd extends zd.HandlerInterface{static createFactory(){return()=>new Gd}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Safari12"}close(){if($d.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){$d.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=Ad.parse(t.sdp),n=Bd.extractRtpCapabilities({sdpObject:r});return qd.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return $d.debug("getNativeSctpCapabilities()"),{numStreams:Kd}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),$d.debug("run()"),this._direction=e,this._remoteSdp=new Vd.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Nd.getSendingRtpParameters("audio",d),video:Nd.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Nd.getSendingRemoteRtpParameters("audio",d),video:Nd.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch($d.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){this.assertNotClosed(),$d.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),$d.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});$d.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};$d.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};$d.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();$d.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){this.assertNotClosed(),this.assertSendDirection(),$d.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const s=Fd.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Nd.reduceCodecs(s.codecs,n);const o=Fd.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Nd.reduceCodecs(o.codecs,n);const a=this._remoteSdp.getNextMediaSectionIdx(),c=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});i&&i(c.sender);let d,u=await this._pc.createOffer(),l=Ad.parse(u.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:l});const p=(0,Hd.parse)((t??[{}])[0].scalabilityMode);t&&t.length>1&&($d.debug("send() | enabling legacy simulcast"),l=Ad.parse(u.sdp),d=l.media[a.idx],Wd.addLegacySimulcast({offerMediaObject:d,numStreams:t.length}),u={type:"offer",sdp:Ad.write(l)}),$d.debug("send() | calling pc.setLocalDescription() [offer:%o]",u),await this._pc.setLocalDescription(u);const h=c.mid;if(s.mid=h,l=Ad.parse(this._pc.localDescription.sdp),d=l.media[a.idx],s.rtcp.cname=Bd.getCname({offerMediaObject:d}),s.encodings=Wd.getRtpEncodings({offerMediaObject:d}),t)for(let e=0;e<s.encodings.length;++e)t[e]&&Object.assign(s.encodings[e],t[e]);if(s.encodings.length>1&&("video/vp8"===s.codecs[0].mimeType.toLowerCase()||"video/h264"===s.codecs[0].mimeType.toLowerCase()))for(const e of s.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${p.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:d,reuseMid:a.reuseMid,offerRtpParameters:s,answerRtpParameters:o,codecOptions:r});const f={type:"answer",sdp:this._remoteSdp.getSdp()};return $d.debug("send() | calling pc.setRemoteDescription() [answer:%o]",f),await this._pc.setRemoteDescription(f),this._mapMidTransceiver.set(h,c),{localId:h,rtpParameters:s,rtpSender:c.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;$d.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();$d.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};$d.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),$d.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();$d.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};$d.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),$d.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly",this._remoteSdp.resumeSendingMediaSection(e);const r=await this._pc.createOffer();$d.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};$d.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?$d.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):$d.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),$d.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();$d.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};$d.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),$d.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();$d.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};$d.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};$d.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Kd.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Ad.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),$d.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};$d.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;$d.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};$d.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=Ad.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Bd.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Ad.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),$d.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){$d.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};$d.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();$d.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){$d.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};$d.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();$d.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){$d.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};$d.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();$d.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};$d.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};$d.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Ad.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}$d.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Ad.parse(this._pc.localDescription.sdp));const r=Bd.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new Ud.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Id.Safari12=Gd;var Qd={},Jd=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Yd=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Zd=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Jd(r,t,n[i]);return Yd(r,t),r}}();Object.defineProperty(Qd,"__esModule",{value:!0}),Qd.Safari11=void 0;const Xd=Zd(jo),eu=mi,tu=Zd(Bi),ru=Zd(Wi),nu=Zd(Qo),iu=Zd(wc),su=ra,ou=sa,au=new eu.Logger("Safari11"),cu={OS:1024,MIS:1024};class du extends su.HandlerInterface{static createFactory(){return()=>new du}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdRtpSender=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"Safari11"}close(){if(au.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){au.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=Xd.parse(t.sdp);return nu.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return au.debug("getNativeSctpCapabilities()"),{numStreams:cu}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){au.debug("run()"),this._direction=e,this._remoteSdp=new ou.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:ru.getSendingRtpParameters("audio",d),video:ru.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:ru.getSendingRemoteRtpParameters("audio",d),video:ru.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(au.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){au.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(au.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});au.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};au.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};au.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();au.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),au.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&au.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addTrack(e,this._sendStream);let i,s=await this._pc.createOffer(),o=Xd.parse(s.sdp);const a=tu.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=ru.reduceCodecs(a.codecs);const c=tu.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=ru.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(au.debug("send() | enabling simulcast"),o=Xd.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),iu.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Xd.write(o)}),au.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Xd.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=nu.getCname({offerMediaObject:i}),a.encodings=iu.getRtpEncodings({offerMediaObject:i,track:e}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&"video/vp8"===a.codecs[0].mimeType.toLowerCase())for(const e of a.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:i,offerRtpParameters:a,answerRtpParameters:c,codecOptions:r});const d={type:"answer",sdp:this._remoteSdp.getSdp()};au.debug("send() | calling pc.setRemoteDescription() [answer:%o]",d),await this._pc.setRemoteDescription(d);const u=String(this._nextSendLocalId);this._nextSendLocalId++;const l=this._pc.getSenders().find((t=>t.track===e));return this._mapSendLocalIdRtpSender.set(u,l),{localId:u,rtpParameters:a,rtpSender:l}}async stopSending(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");t.track&&this._sendStream.removeTrack(t.track),this._mapSendLocalIdRtpSender.delete(e);const r=await this._pc.createOffer();au.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void au.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const n={type:"answer",sdp:this._remoteSdp.getSdp()};au.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){this.assertSendDirection(),t?au.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):au.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.track;await r.replaceTrack(t),n&&this._sendStream.removeTrack(n),t&&this._sendStream.addTrack(t)}async setMaxSpatialLayer(e,t){this.assertSendDirection(),au.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(n)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),au.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapSendLocalIdRtpSender.get(e);if(!r)throw new Error("associated RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.setParameters(n)}async getSenderStats(e){this.assertSendDirection();const t=this._mapSendLocalIdRtpSender.get(e);if(!t)throw new Error("associated RTCRtpSender not found");return t.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};au.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%cu.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Xd.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),au.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};au.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[];for(const t of e){const{trackId:e,kind:r,rtpParameters:n,streamId:i}=t;au.debug("receive() [trackId:%s, kind:%s]",e,r);const s=r;this._remoteSdp.receive({mid:s,kind:r,offerRtpParameters:n,streamId:i??n.rtcp.cname,trackId:e})}const r={type:"offer",sdp:this._remoteSdp.getSdp()};au.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=Xd.parse(n.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,n=e,s=i.media.find((e=>String(e.mid)===n));nu.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:Xd.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),au.debug("receive() | calling pc.setLocalDescription() [answer:%o]",n),await this._pc.setLocalDescription(n);for(const r of e){const{kind:e,trackId:n,rtpParameters:i}=r,s=e,o=n,a=this._pc.getReceivers().find((e=>e.track&&e.track.id===o));if(!a)throw new Error("new RTCRtpReceiver not");this._mapRecvLocalIdInfo.set(o,{mid:s,rtpParameters:i,rtpReceiver:a}),t.push({localId:o,track:a.track,rtpReceiver:a})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){au.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)??{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};au.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();au.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertRecvDirection();const{rtpReceiver:t}=this._mapRecvLocalIdInfo.get(e)??{};if(!t)throw new Error("associated RTCRtpReceiver not found");return t.getStats()}async pauseReceiving(e){}async resumeReceiving(e){}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};au.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};au.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Xd.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}au.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Xd.parse(this._pc.localDescription.sdp));const r=nu.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Qd.Safari11=du;var uu={},lu={},pu=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),hu=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),fu=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&pu(r,t,n[i]);return hu(r,t),r}}();Object.defineProperty(lu,"__esModule",{value:!0}),lu.getCapabilities=function(){const e=RTCRtpReceiver.getCapabilities(),t=mu.clone(e);for(const e of t.codecs??[]){if(e.channels=e.numChannels,delete e.numChannels,e.mimeType=e.mimeType??`${e.kind}/${e.name}`,e.parameters){const t=e.parameters;t.apt&&(t.apt=Number(t.apt)),t["packetization-mode"]&&(t["packetization-mode"]=Number(t["packetization-mode"]))}for(const t of e.rtcpFeedback??[])t.parameter||(t.parameter="")}return t},lu.mangleRtpParameters=function(e){const t=mu.clone(e);t.mid&&(t.muxId=t.mid,delete t.mid);for(const e of t.codecs)e.channels&&(e.numChannels=e.channels,delete e.channels),e.mimeType&&!e.name&&(e.name=e.mimeType.split("/")[1]),delete e.mimeType;return t};const mu=fu(Bi);var gu=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),vu=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),yu=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&gu(r,t,n[i]);return vu(r,t),r}}();Object.defineProperty(uu,"__esModule",{value:!0}),uu.Edge11=void 0;const bu=mi,wu=or,_u=yu(Bi),Su=yu(Wi),ku=yu(lu),Cu=ra,Ru=new bu.Logger("Edge11");class Pu extends Cu.HandlerInterface{static createFactory(){return()=>new Pu}constructor(){super(),this._rtpSenders=new Map,this._rtpReceivers=new Map,this._nextSendLocalId=0,this._transportReady=!1}get name(){return"Edge11"}close(){Ru.debug("close()");try{this._iceGatherer.close()}catch(e){}try{this._iceTransport.stop()}catch(e){}try{this._dtlsTransport.stop()}catch(e){}for(const e of this._rtpSenders.values())try{e.stop()}catch(e){}for(const e of this._rtpReceivers.values())try{e.stop()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){return Ru.debug("getNativeRtpCapabilities()"),ku.getCapabilities()}async getNativeSctpCapabilities(){return Ru.debug("getNativeSctpCapabilities()"),{numStreams:{OS:0,MIS:0}}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Ru.debug("run()"),this._sendingRtpParametersByKind={audio:Su.getSendingRtpParameters("audio",d),video:Su.getSendingRtpParameters("video",d)},this._remoteIceParameters=t,this._remoteIceCandidates=r,this._remoteDtlsParameters=n,this._cname=`CNAME-${_u.generateRandomNumber()}`,this.setIceGatherer({iceServers:s,iceTransportPolicy:o}),this.setIceTransport(),this.setDtlsTransport()}async updateIceServers(e){throw new wu.UnsupportedError("not supported")}async restartIce(e){if(Ru.debug("restartIce()"),this._remoteIceParameters=e,this._transportReady){Ru.debug("restartIce() | calling iceTransport.start()"),this._iceTransport.start(this._iceGatherer,e,"controlling");for(const e of this._remoteIceCandidates)this._iceTransport.addRemoteCandidate(e);this._iceTransport.addRemoteCandidate({})}}async getTransportStats(){return this._iceTransport.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){Ru.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),this._transportReady||await this.setupTransport({localDtlsRole:"server"}),Ru.debug("send() | calling new RTCRtpSender()");const i=new RTCRtpSender(e,this._dtlsTransport),s=_u.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Su.reduceCodecs(s.codecs,n);const o=s.codecs.some((e=>/.+\/rtx$/i.test(e.mimeType)));t||(t=[{}]);for(const e of t)e.ssrc=_u.generateRandomNumber(),o&&(e.rtx={ssrc:_u.generateRandomNumber()});s.encodings=t,s.rtcp={cname:this._cname,reducedSize:!0,mux:!0};const a=ku.mangleRtpParameters(s);Ru.debug("send() | calling rtpSender.send() [params:%o]",a),await i.send(a);const c=String(this._nextSendLocalId);return this._nextSendLocalId++,this._rtpSenders.set(c,i),{localId:c,rtpParameters:s,rtpSender:i}}async stopSending(e){Ru.debug("stopSending() [localId:%s]",e);const t=this._rtpSenders.get(e);if(!t)throw new Error("RTCRtpSender not found");this._rtpSenders.delete(e);try{Ru.debug("stopSending() | calling rtpSender.stop()"),t.stop()}catch(e){throw Ru.warn("stopSending() | rtpSender.stop() failed:%o",e),e}}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){t?Ru.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Ru.debug("replaceTrack() [localId:%s, no track]",e);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");r.setTrack(t)}async setMaxSpatialLayer(e,t){Ru.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.setParameters(n)}async setRtpEncodingParameters(e,t){Ru.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._rtpSenders.get(e);if(!r)throw new Error("RTCRtpSender not found");const n=r.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.setParameters(n)}async getSenderStats(e){const t=this._rtpSenders.get(e);if(!t)throw new Error("RTCRtpSender not found");return t.getStats()}async sendDataChannel(e){throw new wu.UnsupportedError("not implemented")}async receive(e){const t=[];for(const t of e){const{trackId:e,kind:r}=t;Ru.debug("receive() [trackId:%s, kind:%s]",e,r)}this._transportReady||await this.setupTransport({localDtlsRole:"server"});for(const r of e){const{trackId:e,kind:n,rtpParameters:i}=r;Ru.debug("receive() | calling new RTCRtpReceiver()");const s=new RTCRtpReceiver(this._dtlsTransport,n);s.addEventListener("error",(e=>{Ru.error('rtpReceiver "error" event [event:%o]',e)}));const o=ku.mangleRtpParameters(i);Ru.debug("receive() | calling rtpReceiver.receive() [params:%o]",o),await s.receive(o);const a=e;this._rtpReceivers.set(a,s),t.push({localId:a,track:s.track,rtpReceiver:s})}return t}async stopReceiving(e){for(const t of e){Ru.debug("stopReceiving() [localId:%s]",t);const e=this._rtpReceivers.get(t);if(!e)throw new Error("RTCRtpReceiver not found");this._rtpReceivers.delete(t);try{Ru.debug("stopReceiving() | calling rtpReceiver.stop()"),e.stop()}catch(e){Ru.warn("stopReceiving() | rtpReceiver.stop() failed:%o",e)}}}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){const t=this._rtpReceivers.get(e);if(!t)throw new Error("RTCRtpReceiver not found");return t.getStats()}async receiveDataChannel(e){throw new wu.UnsupportedError("not implemented")}setIceGatherer({iceServers:e,iceTransportPolicy:t}){const r=new RTCIceGatherer({iceServers:e??[],gatherPolicy:t??"all"});r.addEventListener("error",(e=>{Ru.error('iceGatherer "error" event [event:%o]',e)}));try{r.gather()}catch(e){Ru.debug("setIceGatherer() | iceGatherer.gather() failed: %s",e.toString())}this._iceGatherer=r}setIceTransport(){const e=new RTCIceTransport(this._iceGatherer);e.addEventListener("statechange",(()=>{switch(e.state){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})),e.addEventListener("icestatechange",(()=>{switch(e.state){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}})),e.addEventListener("candidatepairchange",(e=>{Ru.debug('iceTransport "candidatepairchange" event [pair:%o]',e.pair)})),this._iceTransport=e}setDtlsTransport(){const e=new RTCDtlsTransport(this._iceTransport);e.addEventListener("statechange",(()=>{Ru.debug('dtlsTransport "statechange" event [state:%s]',e.state)})),e.addEventListener("dtlsstatechange",(()=>{Ru.debug('dtlsTransport "dtlsstatechange" event [state:%s]',e.state),"closed"===e.state&&this.emit("@connectionstatechange","closed")})),e.addEventListener("error",(e=>{Ru.error('dtlsTransport "error" event [event:%o]',e)})),this._dtlsTransport=e}async setupTransport({localDtlsRole:e}){Ru.debug("setupTransport()");const t=this._dtlsTransport.getLocalParameters();t.role=e,await new Promise(((e,r)=>{this.safeEmit("@connect",{dtlsParameters:t},e,r)})),this._iceTransport.start(this._iceGatherer,this._remoteIceParameters,"controlling");for(const e of this._remoteIceCandidates)this._iceTransport.addRemoteCandidate(e);this._iceTransport.addRemoteCandidate({}),this._remoteDtlsParameters.fingerprints=this._remoteDtlsParameters.fingerprints.filter((e=>"sha-256"===e.algorithm||"sha-384"===e.algorithm||"sha-512"===e.algorithm)),this._dtlsTransport.start(this._remoteDtlsParameters),this._transportReady=!0}}uu.Edge11=Pu;var Tu={},Eu=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Du=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Mu=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&Eu(r,t,n[i]);return Du(r,t),r}}();Object.defineProperty(Tu,"__esModule",{value:!0}),Tu.ReactNativeUnifiedPlan=void 0;const Iu=Mu(jo),xu=mi,Ou=Mu(Bi),Lu=Mu(Wi),Au=Mu(Qo),ju=Mu(ea),Fu=Mu(ta),Nu=or,Bu=ra,Wu=sa,qu=wa,Uu=new xu.Logger("ReactNativeUnifiedPlan"),zu={OS:1024,MIS:1024};class Vu extends Bu.HandlerInterface{static createFactory(){return()=>new Vu}constructor(){super(),this._closed=!1,this._mapMidTransceiver=new Map,this._sendStream=new MediaStream,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"ReactNativeUnifiedPlan"}close(){if(Uu.debug("close()"),!this._closed){if(this._closed=!0,this._sendStream.release(!1),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){Uu.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"});try{e.addTransceiver("audio"),e.addTransceiver("video");const t=await e.createOffer();try{e.close()}catch(e){}const r=Iu.parse(t.sdp),n=Au.extractRtpCapabilities({sdpObject:r});return Fu.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Uu.debug("getNativeSctpCapabilities()"),{numStreams:zu}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),Uu.debug("run()"),this._direction=e,this._remoteSdp=new Wu.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Lu.getSendingRtpParameters("audio",d),video:Lu.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Lu.getSendingRemoteRtpParameters("audio",d),video:Lu.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(Uu.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){this.assertNotClosed(),Uu.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Uu.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Uu.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Uu.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Uu.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Uu.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this.assertNotClosed(),this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n,onRtpSender:i}){this.assertNotClosed(),this.assertSendDirection(),Uu.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&t.length>1&&t.forEach(((e,t)=>{e.rid=`r${t}`}));const s=Ou.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Lu.reduceCodecs(s.codecs,n);const o=Ou.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Lu.reduceCodecs(o.codecs,n);const a=this._remoteSdp.getNextMediaSectionIdx(),c=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(c.sender);let d,u=await this._pc.createOffer(),l=Iu.parse(u.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:l});let p=!1;const h=(0,qu.parse)((t??[{}])[0].scalabilityMode);t&&1===t.length&&h.spatialLayers>1&&"video/vp9"===s.codecs[0].mimeType.toLowerCase()&&(Uu.debug("send() | enabling legacy simulcast for VP9 SVC"),p=!0,l=Iu.parse(u.sdp),d=l.media[a.idx],ju.addLegacySimulcast({offerMediaObject:d,numStreams:h.spatialLayers}),u={type:"offer",sdp:Iu.write(l)}),Uu.debug("send() | calling pc.setLocalDescription() [offer:%o]",u),await this._pc.setLocalDescription(u);let f=c.mid??void 0;if(f||Uu.warn("send() | missing transceiver.mid (bug in react-native-webrtc, using a workaround"),s.mid=f,l=Iu.parse(this._pc.localDescription.sdp),d=l.media[a.idx],s.rtcp.cname=Au.getCname({offerMediaObject:d}),t)if(1===t.length){let e=ju.getRtpEncodings({offerMediaObject:d});Object.assign(e[0],t[0]),p&&(e=[e[0]]),s.encodings=e}else s.encodings=t;else s.encodings=ju.getRtpEncodings({offerMediaObject:d});if(s.encodings.length>1&&("video/vp8"===s.codecs[0].mimeType.toLowerCase()||"video/h264"===s.codecs[0].mimeType.toLowerCase()))for(const e of s.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${h.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:d,reuseMid:a.reuseMid,offerRtpParameters:s,answerRtpParameters:o,codecOptions:r,extmapAllowMixed:!0});const m={type:"answer",sdp:this._remoteSdp.getSdp()};return Uu.debug("send() | calling pc.setRemoteDescription() [answer:%o]",m),await this._pc.setRemoteDescription(m),f||(f=c.mid,s.mid=f),this._mapMidTransceiver.set(f,c),{localId:f,rtpParameters:s,rtpSender:c.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;Uu.debug("stopSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.sender.replaceTrack(null),this._pc.removeTrack(t.sender);if(this._remoteSdp.closeMediaSection(t.mid))try{t.stop()}catch(e){}const r=await this._pc.createOffer();Uu.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Uu.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Uu.debug("pauseSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="inactive",this._remoteSdp.pauseMediaSection(e);const r=await this._pc.createOffer();Uu.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Uu.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Uu.debug("resumeSending() [localId:%s]",e);const t=this._mapMidTransceiver.get(e);if(this._remoteSdp.resumeSendingMediaSection(e),!t)throw new Error("associated RTCRtpTransceiver not found");t.direction="sendonly";const r=await this._pc.createOffer();Uu.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Uu.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Uu.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Uu.debug("replaceTrack() [localId:%s, no track]",e);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");await r.sender.replaceTrack(t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),this.assertSendDirection(),Uu.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{e.active=r<=t})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Uu.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Uu.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Uu.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t);const r=this._mapMidTransceiver.get(e);if(!r)throw new Error("associated RTCRtpTransceiver not found");const n=r.sender.getParameters();n.encodings.forEach(((e,r)=>{n.encodings[r]={...e,...t}})),await r.sender.setParameters(n),this._remoteSdp.muxMediaSectionSimulcast(e,n.encodings);const i=await this._pc.createOffer();Uu.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Uu.debug("setRtpEncodingParameters() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async getSenderStats(e){this.assertNotClosed(),this.assertSendDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.sender.getStats()}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,protocol:i};Uu.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%zu.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Iu.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Uu.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};Uu.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertNotClosed(),this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i,streamId:s}=t;Uu.debug("receive() [trackId:%s, kind:%s]",e,n);const o=i.mid??String(this._mapMidTransceiver.size);r.set(e,o),this._remoteSdp.receive({mid:o,kind:n,offerRtpParameters:i,streamId:s??i.rtcp.cname,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};Uu.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);for(const t of e){const{trackId:e,onRtpReceiver:n}=t;if(n){const t=r.get(e),i=this._pc.getTransceivers().find((e=>e.mid===t));if(!i)throw new Error("transceiver not found");n(i.receiver)}}let i=await this._pc.createAnswer();const s=Iu.parse(i.sdp);for(const t of e){const{trackId:e,rtpParameters:n}=t,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Au.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Iu.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Uu.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{trackId:e}=n,i=r.get(e),s=this._pc.getTransceivers().find((e=>e.mid===i));if(!s)throw new Error("new RTCRtpTransceiver not found");this._mapMidTransceiver.set(i,s),t.push({localId:i,track:s.receiver.track,rtpReceiver:s.receiver})}return t}async stopReceiving(e){if(this.assertRecvDirection(),this._closed)return;for(const t of e){Uu.debug("stopReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");this._remoteSdp.closeMediaSection(e.mid)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Uu.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Uu.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r);for(const t of e)this._mapMidTransceiver.delete(t)}async pauseReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Uu.debug("pauseReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="inactive",this._remoteSdp.pauseMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Uu.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Uu.debug("pauseReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async resumeReceiving(e){this.assertNotClosed(),this.assertRecvDirection();for(const t of e){Uu.debug("resumeReceiving() [localId:%s]",t);const e=this._mapMidTransceiver.get(t);if(!e)throw new Error("associated RTCRtpTransceiver not found");e.direction="recvonly",this._remoteSdp.resumeReceivingMediaSection(t)}const t={type:"offer",sdp:this._remoteSdp.getSdp()};Uu.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Uu.debug("resumeReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async getReceiverStats(e){this.assertNotClosed(),this.assertRecvDirection();const t=this._mapMidTransceiver.get(e);if(!t)throw new Error("associated RTCRtpTransceiver not found");return t.receiver.getStats()}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o,protocol:r};Uu.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation();const e={type:"offer",sdp:this._remoteSdp.getSdp()};Uu.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Iu.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Uu.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Iu.parse(this._pc.localDescription.sdp));const r=Au.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new Nu.InvalidStateError("method called in a closed handler")}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Tu.ReactNativeUnifiedPlan=Vu;var Hu={},$u=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),Ku=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Gu=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&$u(r,t,n[i]);return Ku(r,t),r}}();Object.defineProperty(Hu,"__esModule",{value:!0}),Hu.ReactNative=void 0;const Qu=Gu(jo),Ju=mi,Yu=or,Zu=Gu(Bi),Xu=Gu(Wi),el=Gu(Qo),tl=Gu(wc),rl=ra,nl=sa,il=new Ju.Logger("ReactNative"),sl={OS:1024,MIS:1024};class ol extends rl.HandlerInterface{static createFactory(){return()=>new ol}constructor(){super(),this._sendStream=new MediaStream,this._mapSendLocalIdTrack=new Map,this._nextSendLocalId=0,this._mapRecvLocalIdInfo=new Map,this._hasDataChannelMediaSection=!1,this._nextSendSctpStreamId=0,this._transportReady=!1}get name(){return"ReactNative"}close(){if(il.debug("close()"),this._sendStream.release(!1),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){il.debug("getNativeRtpCapabilities()");const e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b"});try{const t=await e.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});try{e.close()}catch(e){}const r=Qu.parse(t.sdp);return el.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return il.debug("getNativeSctpCapabilities()"),{numStreams:sl}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){il.debug("run()"),this._direction=e,this._remoteSdp=new nl.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:Xu.getSendingRtpParameters("audio",d),video:Xu.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Xu.getSendingRemoteRtpParameters("audio",d),video:Xu.getSendingRemoteRtpParameters("video",d)},n.role&&"auto"!==n.role&&(this._forcedLocalDtlsRole="server"===n.role?"client":"server"),this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"plan-b",...a},c),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",(()=>{this.emit("@connectionstatechange",this._pc.connectionState)})):this._pc.addEventListener("iceconnectionstatechange",(()=>{switch(il.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.iceConnectionState){case"checking":this.emit("@connectionstatechange","connecting");break;case"connected":case"completed":this.emit("@connectionstatechange","connected");break;case"failed":this.emit("@connectionstatechange","failed");break;case"disconnected":this.emit("@connectionstatechange","disconnected");break;case"closed":this.emit("@connectionstatechange","closed")}}))}async updateIceServers(e){il.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(il.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});il.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};il.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};il.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();il.debug("restartIce() | calling pc.setLocalDescription() [answer:%o]",t),await this._pc.setLocalDescription(t)}}async getTransportStats(){return this._pc.getStats()}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertSendDirection(),il.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&il.warn("send() | codec selection is not available in %s handler",this.name),this._sendStream.addTrack(e),this._pc.addStream(this._sendStream);let i,s=await this._pc.createOffer(),o=Qu.parse(s.sdp);const a=Zu.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=Xu.reduceCodecs(a.codecs);const c=Zu.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=Xu.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(il.debug("send() | enabling simulcast"),o=Qu.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),tl.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Qu.write(o)}),il.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Qu.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=el.getCname({offerMediaObject:i}),a.encodings=tl.getRtpEncodings({offerMediaObject:i,track:e}),t)for(let e=0;e<a.encodings.length;++e)t[e]&&Object.assign(a.encodings[e],t[e]);if(a.encodings.length>1&&("video/vp8"===a.codecs[0].mimeType.toLowerCase()||"video/h264"===a.codecs[0].mimeType.toLowerCase()))for(const e of a.encodings)e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:i,offerRtpParameters:a,answerRtpParameters:c,codecOptions:r});const d={type:"answer",sdp:this._remoteSdp.getSdp()};il.debug("send() | calling pc.setRemoteDescription() [answer:%o]",d),await this._pc.setRemoteDescription(d);const u=String(this._nextSendLocalId);return this._nextSendLocalId++,this._mapSendLocalIdTrack.set(u,e),{localId:u,rtpParameters:a}}async stopSending(e){this.assertSendDirection(),il.debug("stopSending() [localId:%s]",e);const t=this._mapSendLocalIdTrack.get(e);if(!t)throw new Error("track not found");this._mapSendLocalIdTrack.delete(e),this._sendStream.removeTrack(t),this._pc.addStream(this._sendStream);const r=await this._pc.createOffer();il.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void il.warn("stopSending() | ignoring expected error due no sending tracks: %s",e.toString());throw e}if("stable"===this._pc.signalingState)return;const n={type:"answer",sdp:this._remoteSdp.getSdp()};il.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){throw new Yu.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new Yu.UnsupportedError("not implemented")}async setRtpEncodingParameters(e,t){throw new Yu.UnsupportedError("not implemented")}async getSenderStats(e){throw new Yu.UnsupportedError("not implemented")}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertSendDirection();const s={negotiated:!0,id:this._nextSendSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmitTime:t,maxRetransmits:r,protocol:i};il.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%sl.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Qu.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),il.debug("sendDataChannel() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e),this._remoteSdp.sendSctpAssociation({offerMediaObject:r});const n={type:"answer",sdp:this._remoteSdp.getSdp()};il.debug("sendDataChannel() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._hasDataChannelMediaSection=!0}return{dataChannel:o,sctpStreamParameters:{streamId:s.id,ordered:s.ordered,maxPacketLifeTime:s.maxPacketLifeTime,maxRetransmits:s.maxRetransmits}}}async receive(e){this.assertRecvDirection();const t=[],r=new Map;for(const t of e){const{trackId:e,kind:n,rtpParameters:i}=t;il.debug("receive() [trackId:%s, kind:%s]",e,n);const s=n;let o=t.streamId??i.rtcp.cname;il.debug("receive() | forcing a random remote streamId to avoid well known bug in react-native-webrtc"),o+=`-hack-${Zu.generateRandomNumber()}`,r.set(e,o),this._remoteSdp.receive({mid:s,kind:n,offerRtpParameters:i,streamId:o,trackId:e})}const n={type:"offer",sdp:this._remoteSdp.getSdp()};il.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=Qu.parse(i.sdp);for(const t of e){const{kind:e,rtpParameters:r}=t,n=e,i=s.media.find((e=>String(e.mid)===n));el.applyCodecParameters({offerRtpParameters:r,answerMediaObject:i})}i={type:"answer",sdp:Qu.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),il.debug("receive() | calling pc.setLocalDescription() [answer:%o]",i),await this._pc.setLocalDescription(i);for(const n of e){const{kind:e,trackId:i,rtpParameters:s}=n,o=i,a=e,c=r.get(i),d=this._pc.getRemoteStreams().find((e=>e.id===c)),u=d.getTrackById(o);if(!u)throw new Error("remote track not found");this._mapRecvLocalIdInfo.set(o,{mid:a,rtpParameters:s}),t.push({localId:o,track:u})}return t}async stopReceiving(e){this.assertRecvDirection();for(const t of e){il.debug("stopReceiving() [localId:%s]",t);const{mid:e,rtpParameters:r}=this._mapRecvLocalIdInfo.get(t)??{};this._mapRecvLocalIdInfo.delete(t),this._remoteSdp.planBStopReceiving({mid:e,offerRtpParameters:r})}const t={type:"offer",sdp:this._remoteSdp.getSdp()};il.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();il.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new Yu.UnsupportedError("not implemented")}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertRecvDirection();const{streamId:n,ordered:i,maxPacketLifeTime:s,maxRetransmits:o}=e,a={negotiated:!0,id:n,ordered:i,maxPacketLifeTime:s,maxRetransmitTime:s,maxRetransmits:o,protocol:r};il.debug("receiveDataChannel() [options:%o]",a);const c=this._pc.createDataChannel(t,a);if(!this._hasDataChannelMediaSection){this._remoteSdp.receiveSctpAssociation({oldDataChannelSpec:!0});const e={type:"offer",sdp:this._remoteSdp.getSdp()};il.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Qu.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}il.debug("receiveDataChannel() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setLocalDescription(t),this._hasDataChannelMediaSection=!0}return{dataChannel:c}}async setupTransport({localDtlsRole:e,localSdpObject:t}){t||(t=Qu.parse(this._pc.localDescription.sdp));const r=el.extractDtlsParameters({sdpObject:t});r.role=e,this._remoteSdp.updateDtlsRole("client"===e?"server":"client"),await new Promise(((e,t)=>{this.safeEmit("@connect",{dtlsParameters:r},e,t)})),this._transportReady=!0}assertSendDirection(){if("send"!==this._direction)throw new Error('method can just be called for handlers with "send" direction')}assertRecvDirection(){if("recv"!==this._direction)throw new Error('method can just be called for handlers with "recv" direction')}}Hu.ReactNative=ol;var al=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),cl=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),dl=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var n=e(t),i=0;i<n.length;i++)"default"!==n[i]&&al(r,t,n[i]);return cl(r,t),r}}();Object.defineProperty(hi,"__esModule",{value:!0}),hi.Device=void 0,hi.detectDevice=Ml;const ul=fi.exports,ll=mi,pl=wi,hl=or,fl=dl(Bi),ml=dl(Wi),gl=Is,vl=Ao,yl=Ba,bl=nc,wl=bc,_l=Ac,Sl=Yc,kl=fd,Cl=Id,Rl=Qd,Pl=uu,Tl=Tu,El=Hu,Dl=new ll.Logger("Device");function Ml(e){if(!e&&"object"==typeof navigator&&"ReactNative"===navigator.product)return Dl.debug("detectDevice() | React-Native detected"),"undefined"==typeof RTCPeerConnection?void Dl.warn("detectDevice() | unsupported react-native-webrtc without RTCPeerConnection, forgot to call registerGlobals()?"):"undefined"!=typeof RTCRtpTransceiver?(Dl.debug("detectDevice() | ReactNative UnifiedPlan handler chosen"),"ReactNativeUnifiedPlan"):(Dl.debug("detectDevice() | ReactNative PlanB handler chosen"),"ReactNative");if(e||"object"==typeof navigator&&"string"==typeof navigator.userAgent){e??(e=navigator.userAgent);const t=new ul.UAParser(e);Dl.debug("detectDevice() | browser detected [userAgent:%s, parsed:%o]",e,t.getResult());const r=t.getBrowser(),n=r.name?.toLowerCase(),i=parseInt(r.major??"0"),s=t.getEngine().name?.toLowerCase(),o=t.getOS(),a=o.name?.toLowerCase(),c=parseFloat(o.version??"0"),d=t.getDevice().model?.toLowerCase(),u="ios"===a||"ipad"===d,l=n&&["chrome","chromium","mobile chrome","chrome webview","chrome headless"].includes(n),p=n&&["firefox","mobile firefox","mobile focus"].includes(n),h=n&&["safari","mobile safari"].includes(n),f=n&&["edge"].includes(n);if((l||f)&&!u&&i>=111)return"Chrome111";if(l&&!u&&i>=74||f&&!u&&i>=88)return"Chrome74";if(l&&!u&&i>=70)return"Chrome70";if(l&&!u&&i>=67)return"Chrome67";if(l&&!u&&i>=55)return"Chrome55";if(p&&!u&&i>=120)return"Firefox120";if(p&&!u&&i>=60)return"Firefox60";if(p&&u&&c>=14.3)return"Safari12";if(h&&i>=12&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(h&&i>=11)return"Safari11";if(f&&!u&&i>=11&&i<=18)return"Edge11";if("webkit"===s&&u&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if("blink"===s){const t=e.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);if(t){const e=Number(t[1]);return e>=111?"Chrome111":e>=74?"Chrome74":e>=70?"Chrome70":e>=67?"Chrome67":"Chrome55"}return"Chrome111"}Dl.warn("detectDevice() | browser not supported [name:%s, version:%s]",n,i)}else Dl.warn("detectDevice() | unknown device")}hi.Device=class{constructor({handlerName:e,handlerFactory:t}={}){if(this._loaded=!1,this._observer=new pl.EnhancedEventEmitter,Dl.debug("constructor()"),e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(t)this._handlerFactory=t;else{if(e)Dl.debug("constructor() | handler given: %s",e);else{if(!(e=Ml()))throw new hl.UnsupportedError("device not supported");Dl.debug("constructor() | detected handler: %s",e)}switch(e){case"Chrome111":this._handlerFactory=vl.Chrome111.createFactory();break;case"Chrome74":this._handlerFactory=yl.Chrome74.createFactory();break;case"Chrome70":this._handlerFactory=bl.Chrome70.createFactory();break;case"Chrome67":this._handlerFactory=wl.Chrome67.createFactory();break;case"Chrome55":this._handlerFactory=_l.Chrome55.createFactory();break;case"Firefox120":this._handlerFactory=Sl.Firefox120.createFactory();break;case"Firefox60":this._handlerFactory=kl.Firefox60.createFactory();break;case"Safari12":this._handlerFactory=Cl.Safari12.createFactory();break;case"Safari11":this._handlerFactory=Rl.Safari11.createFactory();break;case"Edge11":this._handlerFactory=Pl.Edge11.createFactory();break;case"ReactNativeUnifiedPlan":this._handlerFactory=Tl.ReactNativeUnifiedPlan.createFactory();break;case"ReactNative":this._handlerFactory=El.ReactNative.createFactory();break;default:throw new TypeError(`unknown handlerName "${e}"`)}}const r=this._handlerFactory();this._handlerName=r.name,r.close(),this._extendedRtpCapabilities=void 0,this._recvRtpCapabilities=void 0,this._canProduceByKind={audio:!1,video:!1},this._sctpCapabilities=void 0}get handlerName(){return this._handlerName}get loaded(){return this._loaded}get rtpCapabilities(){if(!this._loaded)throw new hl.InvalidStateError("not loaded");return this._recvRtpCapabilities}get sctpCapabilities(){if(!this._loaded)throw new hl.InvalidStateError("not loaded");return this._sctpCapabilities}get observer(){return this._observer}async load({routerRtpCapabilities:e}){let t;Dl.debug("load() [routerRtpCapabilities:%o]",e);try{if(this._loaded)throw new hl.InvalidStateError("already loaded");const r=fl.clone(e);ml.validateRtpCapabilities(r),t=this._handlerFactory();const n=await t.getNativeRtpCapabilities();Dl.debug("load() | got native RTP capabilities:%o",n);const i=fl.clone(n);ml.validateRtpCapabilities(i),this._extendedRtpCapabilities=ml.getExtendedRtpCapabilities(i,r),Dl.debug("load() | got extended RTP capabilities:%o",this._extendedRtpCapabilities),this._canProduceByKind.audio=ml.canSend("audio",this._extendedRtpCapabilities),this._canProduceByKind.video=ml.canSend("video",this._extendedRtpCapabilities),this._recvRtpCapabilities=ml.getRecvRtpCapabilities(this._extendedRtpCapabilities),ml.validateRtpCapabilities(this._recvRtpCapabilities),Dl.debug("load() | got receiving RTP capabilities:%o",this._recvRtpCapabilities),this._sctpCapabilities=await t.getNativeSctpCapabilities(),Dl.debug("load() | got native SCTP capabilities:%o",this._sctpCapabilities),ml.validateSctpCapabilities(this._sctpCapabilities),Dl.debug("load() succeeded"),this._loaded=!0,t.close()}catch(e){throw t&&t.close(),e}}canProduce(e){if(!this._loaded)throw new hl.InvalidStateError("not loaded");if("audio"!==e&&"video"!==e)throw new TypeError(`invalid kind "${e}"`);return this._canProduceByKind[e]}createSendTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,appData:d}){return Dl.debug("createSendTransport()"),this.createTransport({direction:"send",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,appData:d})}createRecvTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,appData:d}){return Dl.debug("createRecvTransport()"),this.createTransport({direction:"recv",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,appData:d})}createTransport({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,proprietaryConstraints:d,appData:u}){if(!this._loaded)throw new hl.InvalidStateError("not loaded");if("string"!=typeof t)throw new TypeError("missing id");if("object"!=typeof r)throw new TypeError("missing iceParameters");if(!Array.isArray(n))throw new TypeError("missing iceCandidates");if("object"!=typeof i)throw new TypeError("missing dtlsParameters");if(s&&"object"!=typeof s)throw new TypeError("wrong sctpParameters");if(u&&"object"!=typeof u)throw new TypeError("if given, appData must be an object");const l=new gl.Transport({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,proprietaryConstraints:d,appData:u,handlerFactory:this._handlerFactory,extendedRtpCapabilities:this._extendedRtpCapabilities,canProduceByKind:this._canProduceByKind});return this._observer.safeEmit("newtransport",l),l}};var Il={},xl={};Object.defineProperty(xl,"__esModule",{value:!0});var Ol={};Object.defineProperty(Ol,"__esModule",{value:!0}),function(e){var t=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=l&&l.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(hi,e),r(Is,e),r(Ys,e),r(ro,e),r(ao,e),r(ho,e),r(xl,e),r(Ol,e),r(ra,e),r(or,e)}(Il),function(e){var t=l&&l.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=l&&l.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=l&&l.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},e(t)};return function(n){if(n&&n.__esModule)return n;var i={};if(null!=n)for(var s=e(n),o=0;o<s.length;o++)"default"!==s[o]&&t(i,n,s[o]);return r(i,n),i}}(),i=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.debug=e.parseScalabilityMode=e.detectDevice=e.Device=e.version=e.types=void 0;const s=i(ni.exports);e.debug=s.default;const o=hi;Object.defineProperty(e,"Device",{enumerable:!0,get:function(){return o.Device}}),Object.defineProperty(e,"detectDevice",{enumerable:!0,get:function(){return o.detectDevice}});const a=n(Il);e.types=a,e.version="3.7.18";var c=wa;Object.defineProperty(e,"parseScalabilityMode",{enumerable:!0,get:function(){return c.parse}})}(ri);const Ll=[{scaleResolutionDownBy:4,maxBitrate:15e4,maxFramerate:12},{scaleResolutionDownBy:2,maxBitrate:35e4,maxFramerate:18},{scaleResolutionDownBy:1,maxBitrate:9e5,maxFramerate:24}],Al=[{maxBitrate:1e6,dtx:!0}],jl=[{maxBitrate:4e4,dtx:!0}],Fl={width:1280,height:720};function Nl(e,t){e.onload=function(){this.onerror=this.onload=null,t(null,e)},e.onerror=function(){this.onerror=this.onload=null,t(new Error("Failed to load "+this.src),e)}}function Bl(e,t){e.onreadystatechange=function(){"complete"!=this.readyState&&"loaded"!=this.readyState||(this.onreadystatechange=null,t(null,e))}}const Wl=new Gn,ql=e=>new Promise(((t,r)=>{!function(e,t,r){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("script");"function"==typeof t&&(r=t,t={}),t=t||{},r=r||function(){},i.type=t.type||"text/javascript",i.charset=t.charset||"utf8",i.async=!("async"in t)||!!t.async,i.src=e,t.attrs&&function(e,t){for(var r in t)e.setAttribute(r,t[r])}(i,t.attrs),t.text&&(i.text=""+t.text),("onload"in i?Nl:Bl)(i,r),i.onload||Nl(i,r),n.appendChild(i)}(e,((e,n)=>{e?r(e):t(n)}))})),Ul=(e,t=3,r=500)=>a(void 0,void 0,void 0,(function*(){let n=0;for(;n<t;)try{return void(yield ql(e))}catch(e){if(n+=1,!(n<t))throw e;yield Wl.sleepMs(r)}}));var zl;let Vl=class{constructor(){zl.set(this,new Map)}add(e,t,r){const n=this.getKey(e,t);if(c(this,zl,"f").has(n))throw new Error("Attempt to rewrite cached track processor");c(this,zl,"f").set(n,r)}get(e,t){return c(this,zl,"f").get(this.getKey(e,t))}has(e,t){return c(this,zl,"f").has(this.getKey(e,t))}getKey(e,t){return`${e}:${t}`}reset(){return a(this,void 0,void 0,(function*(){for(const e of c(this,zl,"f").values())yield e.stopProcessing();c(this,zl,"f").clear()}))}};var Hl,$l;zl=new WeakMap,Vl=i([at()],Vl);let Kl=class{constructor(e,t,r,n){this.config=e,this.processorsCache=t,this.audioTrackProcessorFactory=r,Hl.set(this,new Map),$l.set(this,void 0),d(this,$l,n("IntegrationsService"),"f")}init(){const e=this.config.get("denoiser");if("asdk"===e){c(this,$l,"f").info("Start integration of ASDK",{denoiser:e});const t={integrated:!1,initPromise:this.integrateASDK()};c(this,Hl,"f").set("asdk",t)}else if("rnnoise"===e){c(this,$l,"f").info("Start integration of RNNoise",{denoiser:e});const t={integrated:!1,initPromise:this.integrateRNNoise()};c(this,Hl,"f").set("rnnoise",t)}}integrateASDK(){var e;return a(this,void 0,void 0,(function*(){const t=this.config.get("asdk"),r=this.config.get("staticFilesPath");if(!window.atsvb){const s=`https://effectssdk.ai/sdk/audio/dev/${t.version}/atsvb-web.js`,o=null!==(e=t.localDir)&&void 0!==e?e:`${r}/${t.version}/atsvb-web.js`;yield(n=s,i=o,a(void 0,void 0,void 0,(function*(){try{yield Ul(n)}catch(e){if(!i)throw e;yield Ul(i)}})))}var n,i;if(!window.atsvb)throw c(this,$l,"f").info("Audio Effects SDK is not loaded, skipping initialization",{case:"initAudioSDK"}),new Error("windows.atsvb is still missing");const s=this.audioTrackProcessorFactory({trackLabel:Zn.Microphone});yield s.init(),this.processorsCache.add("asdk",Zn.Microphone,s);const o=c(this,Hl,"f").get("asdk");if(!o)throw Error("IntegrationContext is missing for ASDK");o.integrated=!0}))}get audio(){return"asdk"===this.config.get("denoiser")?this.getASDKState():this.getRNNoiseState()}getASDKState(){var e,t;const r=c(this,Hl,"f").get("asdk");return{type:"asdk",enabled:Boolean(r),isInitialized:null!==(e=null==r?void 0:r.integrated)&&void 0!==e&&e,waitForInitialization:null!==(t=null==r?void 0:r.initPromise)&&void 0!==t?t:Promise.resolve()}}getRNNoiseState(){var e,t;const r=c(this,Hl,"f").get("rnnoise");return{type:"rnnoise",enabled:Boolean(r),isInitialized:null!==(e=null==r?void 0:r.integrated)&&void 0!==e&&e,waitForInitialization:null!==(t=null==r?void 0:r.initPromise)&&void 0!==t?t:Promise.resolve()}}integrateRNNoise(){return a(this,void 0,void 0,(function*(){const e=yield class{static compileModule(e){return a(this,void 0,void 0,(function*(){if(!window.WebAssembly)throw new Error("Webassembly not supported");const t=yield fetch(`${e}/rnnoise-processor.wasm`);return WebAssembly.instantiate(yield t.arrayBuffer())}))}}.compileModule(this.config.get("staticFilesPath")),t=this.audioTrackProcessorFactory({trackLabel:Zn.Microphone,noiseSuppressor:e});this.processorsCache.add("rnnoise",Zn.Microphone,t);const r=c(this,Hl,"f").get("rnnoise");if(!r)throw Error("IntegrationContext is missing for RNNoise");r.integrated=!0}))}reset(){c(this,Hl,"f").clear()}};var Gl,Ql,Jl,Yl,Zl,Xl,ep,tp,rp;Hl=new WeakMap,$l=new WeakMap,Kl=i([at(),s(0,dt(Yn.Config)),s(1,dt(Yn.ProcessorsCache)),s(2,dt(Yn.AudioTrackProcessorFactory)),s(3,dt(Yn.LoggerFactory)),o("design:paramtypes",[Ct,Vl,Function,Function])],Kl);class np{constructor(e){Gl.set(this,void 0),Ql.set(this,void 0),Jl.set(this,{lowLighter:!1,colorCorrector:!1,faceDetector:!1,segmentation:!1}),Yl.set(this,null),Zl.set(this,void 0),Xl.set(this,!1),ep.set(this,void 0);const{loggerFactory:t}=e;d(this,Ql,t("EffectsSDKTrackProcessor"),"f"),d(this,ep,e.onModelsLoaded,"f"),d(this,Gl,new window.tsvb(e.customerId),"f"),c(this,Gl,"f").onError(this.tsvbErrorHandler.bind(this)),c(this,Gl,"f").onReady=this.onReady.bind(this);c(this,Gl,"f").config({preset:"balanced",provider:"wasm"})}init(){return a(this,void 0,void 0,(function*(){yield c(this,Gl,"f").preload(),yield c(this,Gl,"f").cache(),d(this,Xl,!0,"f")}))}awaitReady(){return a(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const r=Date.now(),n=setInterval((()=>{if(this.isModelsLoaded)return clearInterval(n),void e();Date.now()-r>6e4&&(clearInterval(n),t(new Error("ESDK init timeout")))}),100)}))}))}tsvbErrorHandler(e){var t;const{emitter:r,type:i,cause:s}=e,o=n(e,["emitter","type","cause"]),a=null!=r?r:"N/A emitter";"error"===i&&c(this,Ql,"f").error(a,Object.assign({error:mr(e)},o)),"warning"===i&&c(this,Ql,"f").warn(a,Object.assign({},o)),"info"===i&&c(this,Ql,"f").info(a,Object.assign({},o)),"ml_inference"===r&&(o.message.toLocaleLowerCase().includes("init lowlighter")&&(c(this,Jl,"f").lowLighter=!0),o.message.toLocaleLowerCase().includes("init colorcorrector")&&(c(this,Jl,"f").colorCorrector=!0),o.message.toLocaleLowerCase().includes("init facedetector")&&(c(this,Jl,"f").faceDetector=!0),o.message.toLocaleLowerCase().includes("init segmentation")&&(c(this,Jl,"f").segmentation=!0),this.isModelsLoaded&&(null===(t=c(this,ep,"f"))||void 0===t||t.call(this)))}get isModelsLoaded(){return c(this,Jl,"f").colorCorrector&&c(this,Jl,"f").faceDetector&&c(this,Jl,"f").lowLighter&&c(this,Jl,"f").segmentation}get modelsLoadProgress(){return Object.values(c(this,Jl,"f")).filter(Boolean).length/Object.keys(c(this,Jl,"f")).length}get isReady(){return c(this,Xl,"f")}setOnLoadModels(e){d(this,ep,e,"f"),this.isModelsLoaded&&c(this,ep,"f").call(this)}onReady(){d(this,Xl,!0,"f"),c(this,Ql,"f").debug("onReady()",{description:"ESDK is ready"}),this.updateEffects(c(this,Zl,"f"))}processTrack(e){var t,r;return a(this,void 0,void 0,(function*(){if(c(this,Yl,"f")===e||"ended"===e.readyState)return(null===(t=c(this,Gl,"f").getStream())||void 0===t?void 0:t.getVideoTracks()[0])||e;this.stopProcessing();try{c(this,Gl,"f").useStream(new MediaStream([e]));const t=null===(r=c(this,Gl,"f").getStream())||void 0===r?void 0:r.getVideoTracks()[0];return t?(d(this,Yl,e,"f"),t):e}catch(t){throw c(this,Ql,"f").error("processTrack()",{error:t,track:e}),new Error("Can not process this track")}}))}stopProcessing(){try{c(this,Gl,"f").clear(),c(this,Gl,"f").stop()}catch(e){c(this,Ql,"f").error("stopProcessing()",{error:e})}finally{d(this,Yl,null,"f")}}updateEffects(e){var t,r,n,i,s,o,a,u,l,p,h,f,m,g,v,y,b,w,_,S,k;if(d(this,Zl,e,"f"),!c(this,Xl,"f"))return void c(this,Ql,"f").warn("updateEffects()",{description:"Esdk not ready"});if(!c(this,Zl,"f")||0===Object.keys(c(this,Zl,"f")).length)return void c(this,Gl,"f").stop();let C=0;if((null===(t=c(this,Zl,"f"))||void 0===t?void 0:t.blur)&&!(null===(r=c(this,Zl,"f"))||void 0===r?void 0:r.backgroundColor)?(c(this,Gl,"f").setBlur(c(this,Zl,"f").blur),C+=1):c(this,Gl,"f").clearBlur(),void 0!==(null===(n=c(this,Zl,"f"))||void 0===n?void 0:n.background)?(c(this,Gl,"f").setBackground(c(this,Zl,"f").background),C+=1):void 0!==(null===(i=c(this,Zl,"f"))||void 0===i?void 0:i.backgroundColor)?(c(this,Gl,"f").setBackgroundColor(null===(s=c(this,Zl,"f"))||void 0===s?void 0:s.backgroundColor),c(this,Gl,"f").setBackground("color"),C+=1):c(this,Gl,"f").clearBackground(),(null===(o=c(this,Zl,"f"))||void 0===o?void 0:o.beautification)?(c(this,Gl,"f").enableBeautification(),c(this,Gl,"f").setBeautificationLevel(c(this,Zl,"f").beautification),C+=1):c(this,Gl,"f").disableBeautification(),(null===(a=c(this,Zl,"f"))||void 0===a?void 0:a.lowLightEffect)?(c(this,Gl,"f").enableLowLightEffect(),c(this,Gl,"f").setLowLightEffectPower(c(this,Zl,"f").lowLightEffect),C+=1):c(this,Gl,"f").disableLowLightEffect(),(null===(u=c(this,Zl,"f"))||void 0===u?void 0:u.colorCorrector)?(c(this,Gl,"f").enableColorCorrector(),c(this,Gl,"f").setColorCorrectorPower(c(this,Zl,"f").colorCorrector),C+=1):c(this,Gl,"f").disableColorCorrector(),(null===(l=c(this,Zl,"f"))||void 0===l?void 0:l.smartZoom)?(c(this,Gl,"f").enableSmartZoom(),c(this,Gl,"f").setFaceArea(c(this,Zl,"f").smartZoom),C+=1):c(this,Gl,"f").disableSmartZoom(),(null===(p=c(this,Zl,"f"))||void 0===p?void 0:p.layout)?(c(this,Gl,"f").setLayout(c(this,Zl,"f").layout),C+=1):c(this,Gl,"f").setLayout("center"),(null===(h=c(this,Zl,"f"))||void 0===h?void 0:h.colorFilter)&&(null===(f=c(this,Zl,"f"))||void 0===f?void 0:f.colorFilter.power)&&(null===(m=c(this,Zl,"f"))||void 0===m?void 0:m.colorFilter.url)?(c(this,Gl,"f").setColorFilterConfig({lut:c(this,Zl,"f").colorFilter.url,power:c(this,Zl,"f").colorFilter.power}),c(this,Gl,"f").enableColorFilter(),C+=1):c(this,Gl,"f").disableColorFilter(),null===(g=c(this,Zl,"f"))||void 0===g?void 0:g.lowerThird){const e=c(this,Gl,"f").createComponent({component:c(this,Zl,"f").lowerThird.type,options:c(this,Zl,"f").lowerThird.options||{}});null===(b=null===(y=null===(v=c(this,Gl,"f").components)||void 0===v?void 0:v.lowerThird)||void 0===y?void 0:y.hideLowerThird)||void 0===b||b.call(y),c(this,Gl,"f").addComponent(e,"lowerThird"),c(this,Gl,"f").components.lowerThird.showLowerThird(),C+=1}else null===(S=null===(_=null===(w=c(this,Gl,"f").components)||void 0===w?void 0:w.lowerThird)||void 0===_?void 0:_.hideLowerThird)||void 0===S||S.call(_);(null===(k=c(this,Zl,"f"))||void 0===k?void 0:k.sharpness)?(c(this,Gl,"f").setSharpnessEffectConfig(c(this,Zl,"f").sharpness),C+=1):c(this,Gl,"f").disableSharpnessEffect(),C>2?c(this,Gl,"f").enableFrameSkipping():c(this,Gl,"f").disableFrameSkipping(),c(this,Gl,"f").run()}}Gl=new WeakMap,Ql=new WeakMap,Jl=new WeakMap,Yl=new WeakMap,Zl=new WeakMap,Xl=new WeakMap,ep=new WeakMap;let ip=rp=class{constructor(e){tp.set(this,void 0),d(this,tp,e("MediaStreamTrackManager"),"f")}createMediaStreamTrack({label:e,constraints:t}){return a(this,void 0,void 0,(function*(){if(rp.isDisplayMedia(e)){const[e]=yield this.createDisplayMediaTracks(t);return e}const[r]=yield this.createUserMediaTracks(t);return r}))}static isDisplayMedia(e){return[Zn.ScreenVideo,Zn.ScreenAudio].includes(e)}createUserMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getUserMedia(e);return c(this,tp,"f").debug("createUserMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}createDisplayMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getDisplayMedia(e);return c(this,tp,"f").debug("getDisplayMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}};tp=new WeakMap,ip=rp=i([at(),s(0,dt(Yn.LoggerFactory)),o("design:paramtypes",[Function])],ip);var sp,op,ap,cp,dp,up,lp,pp=ip;let hp=class{constructor(e,t,r,n,i,s,o,a){this.config=e,this.loggerFactory=t,this.audioTrackFactory=r,this.clientEventEmitter=n,this.integrationsService=i,this.processorsCache=s,this.videoTrackFactory=o,this.mediaStreamTrackManager=a,this.isDeviceLoaded=!1,this.tracks=new Map,sp.set(this,void 0),op.set(this,null),ap.set(this,!1),cp.set(this,new Map),dp.set(this,!1),up.set(this,!1),lp.set(this,void 0);const c=this.config.get("effectsSDKParams");d(this,lp,this.config.get("denoiser"),"f"),d(this,sp,this.loggerFactory("Media"),"f"),d(this,op,c||null,"f")}get mediasoupDevice(){return this.device||(this.device=this.createDevice()),this.device}get effectsSDKInitialized(){return c(this,ap,"f")}get effectsSDKParams(){return c(this,op,"f")}getTrack(e){return this.tracks.get(e)}loadDevice(e){return a(this,void 0,void 0,(function*(){this.isDeviceLoaded||(yield this.mediasoupDevice.load({routerRtpCapabilities:e}),this.isDeviceLoaded=!0)}))}getTrackCodec(e){const{rtpCapabilities:t,rtpCapabilities:{codecs:r}}=this.mediasoupDevice;if(r)return r.find((t=>t.mimeType.toLowerCase()===`${e.kind}/${e.getPreferredCodec()}`));c(this,sp,"f").error("getTrackCodec()",{label:e.getLabel,rtpCapabilities:t})}createTracks({constraints:e,mediaStreamTracks:t}){return t.map((t=>{const r={mediaStreamTrack:t,constraints:e};let n;return n="audio"===t.kind?this.audioTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"AudioTrack"})):this.videoTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"VideoTrack"})),c(this,sp,"f").debug("createTrack() track created",{trackId:n.id,kind:n.kind}),n}))}createUserMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createUserMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}createDisplayMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createDisplayMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}deleteTrack(e){return a(this,void 0,void 0,(function*(){const t={trackId:e.id,label:e.getLabel(),producerId:e.producerId};try{"disableNoiseSuppression"in e&&(yield e.disableNoiseSuppression()),"disableEffects"in e&&(yield e.disableEffects())}catch(e){c(this,sp,"f").warn("deleteTrack()",Object.assign({error:e},t))}try{this.tracks.delete(e.getLabel()),e.stopMediaStreamTrack(),yield e.closeProducer()}catch(e){c(this,sp,"f").error("deleteTrack()",{error:e})}finally{c(this,sp,"f").debug("deleteTrack()",t)}}))}getAllTracks(){return Array.from(this.tracks.values())}publishedTracks(){return this.getAllTracks().filter((e=>e.isPublished))}clearTracks(){return a(this,void 0,void 0,(function*(){try{this.getAllTracks().map((e=>e.stopMediaStreamTrack()))}catch(e){c(this,sp,"f").warn("clearTracks()",{error:e})}finally{this.tracks.clear()}}))}unpublishTracks(){return a(this,void 0,void 0,(function*(){try{yield Promise.all(this.publishedTracks().map((e=>e.unpublish(!1))))}catch(e){c(this,sp,"f").warn("unpublishTracks()",{error:e})}}))}setTrack(e){this.tracks.set(e.getLabel(),e)}initEffectsSDK(){return a(this,void 0,void 0,(function*(){if(c(this,ap,"f"))return!0;if(!c(this,op,"f"))throw c(this,sp,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Error("Effects SDK config not provided");const e=(e,t)=>a(this,void 0,void 0,(function*(){if(!window.tsvb)return c(this,sp,"f").info("Effects SDK not loaded, skipping initialization",{case:"initEffectsSDK"}),void e(!1);c(this,sp,"f").info("Effects SDK initializing",{case:"initEffectsSDK"});try{c(this,cp,"f").set(Zn.Camera,yield this.createEffectsSDKTrackProcessor(Zn.Camera)),c(this,cp,"f").set(Zn.CameraPreview,yield this.createEffectsSDKTrackProcessor(Zn.CameraPreview)),d(this,ap,!0,"f"),c(this,sp,"f").info("Effects SDK initialized",{case:"initEffectsSDK"}),e(!0)}catch(e){c(this,sp,"f").error("Failed to initialize Effects SDK",{error:e,case:"initEffectsSDK"}),t(e)}}));return new Promise(((t,r)=>{if(!window.tsvb)return c(this,sp,"f").info("Effects SDK tsvb-web.js is not ready, waiting",{case:"initEffectsSDK"}),void window.addEventListener("load",(()=>e(t,r)));e(t,r)}))}))}initDenoiser(e,t){return a(this,void 0,void 0,(function*(){if(!c(this,dp,"f"))try{d(this,dp,!0,"f"),this.clientEventEmitter.emit(Xr,!0),yield this.integrationsService.audio.waitForInitialization,c(this,sp,"f").debug("Denoiser initialized, activating",{case:"Denoiser",type:this.integrationsService.audio.type,trackLabel:e.getLabel()});const r=e,n=this.processorsCache.get(c(this,lp,"f"),Zn.Microphone);if(!n)return void c(this,sp,"f").error("No cached trackProcessor found",{case:"Denoiser",trackLabel:e.getLabel(),type:this.integrationsService.audio.type});"asdk"===c(this,lp,"f")&&n.setOnError((()=>{this.clientEventEmitter.emit(Xr,!0),this.fallbackToRNoise(e,t).catch((t=>{c(this,sp,"f").error("Failed to fallback to RNNoise through onError",{case:"Denoiser",type:c(this,lp,"f"),error:mr(t),label:e.getLabel()})})).then((()=>{this.clientEventEmitter.emit(Xr,!1)}))})),r.prepareTrackProcessor(n),c(this,sp,"f").debug("Denoiser trackProcessor set, check if activation is needed",{case:"Denoiser",type:c(this,lp,"f"),shouldEnableDenoiser:null==t?void 0:t.noiseSuppression,trackLabel:e.getLabel()}),(null==t?void 0:t.noiseSuppression)&&(yield e.enableNoiseSuppression())}catch(r){if(c(this,sp,"f").warn("Failed to start noise suppression, featured original track",{case:"Denoiser",type:c(this,lp,"f"),error:mr(r),label:e.getLabel()}),"asdk"===c(this,lp,"f"))try{c(this,sp,"f").warn("Fallback to RNNoise",{error:mr(r)}),yield this.fallbackToRNoise(e,t)}catch(t){c(this,sp,"f").error("Failed to fallback to RNNoise through catch",{case:"Denoiser",type:c(this,lp,"f"),error:mr(t),label:e.getLabel()})}}finally{this.clientEventEmitter.emit(Xr,!1),d(this,dp,!1,"f")}}))}fallbackToRNoise(e,t){return a(this,void 0,void 0,(function*(){c(this,sp,"f").debug("Fallback to RNNoise denoiser",{case:"Denoiser"});const r=e;yield r.disableNoiseSuppression(),r.unsetTrackProcessor(),d(this,lp,"rnnoise","f"),this.config.set("denoiser",c(this,lp,"f")),c(this,sp,"f").debug("Set config to rnnoise denoiser",{case:"Denoiser",type:this.config.get("denoiser")}),this.integrationsService.init(),yield this.integrationsService.audio.waitForInitialization;const n=this.processorsCache.get(c(this,lp,"f"),Zn.Microphone);n?(r.prepareTrackProcessor(n),(null==t?void 0:t.noiseSuppression)&&(yield r.enableNoiseSuppression())):c(this,sp,"f").error("No cached trackProcessor found",{case:"Denoiser",trackLabel:e.getLabel(),type:this.integrationsService.audio.type})}))}createEffectsSDKTrackProcessor(e){return a(this,void 0,void 0,(function*(){if(e){const t=c(this,cp,"f").get(e);if(t)return t}if(!c(this,op,"f"))throw c(this,sp,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Error("Effects SDK config not provided");const t=new np({loggerFactory:this.loggerFactory,customerId:c(this,op,"f").customerId});return yield t.init(),c(this,sp,"f").info("Track effects processor initialized",{trackLabel:e}),t}))}static getVideoTrackTransformParams(e){const t=e.getSettings();return{width:t.width||Fl.width,height:t.height||Fl.height}}static getScreenVideoTrackParams(e){var t;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:20},width:{max:Fl.width},height:{max:Fl.height}},encoderConfig:(null==e?void 0:e.videoEncoderConfig)||{encodings:Al}}}static getCameraVideoTrackParams(e){var t;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:24},width:{max:Fl.width},height:{max:Fl.height}},encoderConfig:(null==e?void 0:e.encoderConfig)||{encodings:Ll}}}createDevice(){const e=(e=>{const t=null!=e?e:null===navigator||void 0===navigator?void 0:navigator.userAgent;if(!t)return;const r=Hn.getParser(t);return r.satisfies({"yandex browser":">=23.7"})?"Chrome111":r.satisfies({"yandex browser":">=22"})?"Chrome74":void 0})();return c(this,sp,"f").debug("Creating a media device",{handlerName:null!=e?e:"not specified"}),new ri.Device({handlerName:e})}};sp=new WeakMap,op=new WeakMap,ap=new WeakMap,cp=new WeakMap,dp=new WeakMap,up=new WeakMap,lp=new WeakMap,hp=i([at(),s(0,dt(Yn.Config)),s(1,dt(Yn.LoggerFactory)),s(2,dt(Yn.AudioTrackFactory)),s(3,dt(Yn.ClientEventEmitter)),s(4,dt(Yn.IntegrationsService)),s(5,dt(Yn.ProcessorsCache)),s(6,dt(Yn.VideoTrackFactory)),s(7,dt(Yn.MediaStreamTrackManager)),o("design:paramtypes",[Ct,Function,Function,Rt,Kl,Vl,Function,pp])],hp);var fp=hp;let mp=class{get(){return this.peer}set(e){this.peer=e}delete(){this.peer=void 0}get canPublish(){var e;return"host"===(null===(e=this.peer)||void 0===e?void 0:e.role)}};mp=i([at()],mp);class gp extends qn{constructor(e,t,r){super(e,null!=t?t:"something_went_wrong",r)}}const vp=Object.create(null);vp.open="0",vp.close="1",vp.ping="2",vp.pong="3",vp.message="4",vp.upgrade="5",vp.noop="6";const yp=Object.create(null);Object.keys(vp).forEach((e=>{yp[vp[e]]=e}));const bp={type:"error",data:"parser error"},wp="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),_p="function"==typeof ArrayBuffer,Sp=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,kp=({type:e,data:t},r,n)=>wp&&t instanceof Blob?r?n(t):Cp(t,n):_p&&(t instanceof ArrayBuffer||Sp(t))?r?n(t):Cp(new Blob([t]),n):n(vp[e]+(t||"")),Cp=(e,t)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(",")[1];t("b"+(e||""))},r.readAsDataURL(e)};function Rp(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Pp;const Tp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ep="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<Tp.length;e++)Ep[Tp.charCodeAt(e)]=e;const Dp="function"==typeof ArrayBuffer,Mp=(e,t)=>{if("string"!=typeof e)return{type:"message",data:xp(e,t)};const r=e.charAt(0);if("b"===r)return{type:"message",data:Ip(e.substring(1),t)};return yp[r]?e.length>1?{type:yp[r],data:e.substring(1)}:{type:yp[r]}:bp},Ip=(e,t)=>{if(Dp){const r=(e=>{let t,r,n,i,s,o=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);const d=new ArrayBuffer(o),u=new Uint8Array(d);for(t=0;t<a;t+=4)r=Ep[e.charCodeAt(t)],n=Ep[e.charCodeAt(t+1)],i=Ep[e.charCodeAt(t+2)],s=Ep[e.charCodeAt(t+3)],u[c++]=r<<2|n>>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&s;return d})(e);return xp(r,t)}return{base64:!0,data:e}},xp=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,Op=String.fromCharCode(30);function Lp(){return new TransformStream({transform(e,t){!function(e,t){wp&&e.data instanceof Blob?e.data.arrayBuffer().then(Rp).then(t):_p&&(e.data instanceof ArrayBuffer||Sp(e.data))?t(Rp(e.data)):kp(e,!1,(e=>{Pp||(Pp=new TextEncoder),t(Pp.encode(e))}))}(e,(r=>{const n=r.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,n)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(n))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(r)}))}})}let Ap;function jp(e){return e.reduce(((e,t)=>e+t.length),0)}function Fp(e,t){if(e[0].length===t)return e.shift();const r=new Uint8Array(t);let n=0;for(let i=0;i<t;i++)r[i]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),r}function Np(e){if(e)return function(e){for(var t in Np.prototype)e[t]=Np.prototype[t];return e}(e)}Np.prototype.on=Np.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},Np.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},Np.prototype.off=Np.prototype.removeListener=Np.prototype.removeAllListeners=Np.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<n.length;i++)if((r=n[i])===t||r.fn===t){n.splice(i,1);break}return 0===n.length&&delete this._callbacks["$"+e],this},Np.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks["$"+e],n=1;n<arguments.length;n++)t[n-1]=arguments[n];if(r){n=0;for(var i=(r=r.slice(0)).length;n<i;++n)r[n].apply(this,t)}return this},Np.prototype.emitReserved=Np.prototype.emit,Np.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},Np.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Bp="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function Wp(e,...t){return t.reduce(((t,r)=>(e.hasOwnProperty(r)&&(t[r]=e[r]),t)),{})}const qp=Bp.setTimeout,Up=Bp.clearTimeout;function zp(e,t){t.useNativeTimers?(e.setTimeoutFn=qp.bind(Bp),e.clearTimeoutFn=Up.bind(Bp)):(e.setTimeoutFn=Bp.setTimeout.bind(Bp),e.clearTimeoutFn=Bp.clearTimeout.bind(Bp))}class Vp extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class Hp extends Np{constructor(e){super(),this.writable=!1,zp(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Vp(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=Mp(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(e[r]));return t}(e);return t.length?"?"+t:""}}const $p="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Kp={};let Gp,Qp=0,Jp=0;function Yp(e){let t="";do{t=$p[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function Zp(){const e=Yp(+new Date);return e!==Gp?(Qp=0,Gp=e):e+"."+Yp(Qp++)}for(;Jp<64;Jp++)Kp[$p[Jp]]=Jp;let Xp=!1;try{Xp="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(Nb){}const eh=Xp;function th(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||eh))return new XMLHttpRequest}catch(e){}if(!t)try{return new(Bp[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function rh(){}const nh=null!=new th({xdomain:!1}).responseType;class ih extends Np{constructor(e,t){super(),zp(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=Wp(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const r=this.xhr=new th(t);try{r.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{r.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(r),"withCredentials"in r&&(r.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(r.timeout=this.opts.requestTimeout),r.onreadystatechange=()=>{var e;3===r.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(r)),4===r.readyState&&(200===r.status||1223===r.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof r.status?r.status:0)}),0))},r.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=ih.requestsCount++,ih.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=rh,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete ih.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(ih.requestsCount=0,ih.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",sh);else if("function"==typeof addEventListener){addEventListener("onpagehide"in Bp?"pagehide":"unload",sh,!1)}function sh(){for(let e in ih.requests)ih.requests.hasOwnProperty(e)&&ih.requests[e].abort()}const oh="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),ah=Bp.WebSocket||Bp.MozWebSocket,ch="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const dh={websocket:class extends Hp{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,r=ch?{}:Wp(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=ch?new ah(e,t,r):t?new ah(e,t):new ah(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],n=t===e.length-1;kp(r,this.supportsBinary,(e=>{try{this.ws.send(e)}catch(e){}n&&oh((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=Zp()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!ah}},webtransport:class extends Hp{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((e=>{this.onError("webtransport error",e)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((e=>{const t=function(e,t){Ap||(Ap=new TextDecoder);const r=[];let n=0,i=-1,s=!1;return new TransformStream({transform(o,a){for(r.push(o);;){if(0===n){if(jp(r)<1)break;const e=Fp(r,1);s=128==(128&e[0]),i=127&e[0],n=i<126?3:126===i?1:2}else if(1===n){if(jp(r)<2)break;const e=Fp(r,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),n=3}else if(2===n){if(jp(r)<8)break;const e=Fp(r,8),t=new DataView(e.buffer,e.byteOffset,e.length),s=t.getUint32(0);if(s>Math.pow(2,21)-1){a.enqueue(bp);break}i=s*Math.pow(2,32)+t.getUint32(4),n=3}else{if(jp(r)<i)break;const e=Fp(r,i);a.enqueue(Mp(s?e:Ap.decode(e),t)),n=0}if(0===i||i>e){a.enqueue(bp);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=Lp();n.readable.pipeTo(e.writable),this.writer=n.writable.getWriter();const i=()=>{r.read().then((({done:e,value:t})=>{e||(this.onPacket(t),i())})).catch((e=>{}))};i();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this.writer.write(s).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const r=e[t],n=t===e.length-1;this.writer.write(r).then((()=>{n&&oh((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends Hp{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let r=location.port;r||(r=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||r!==e.port}const t=e&&e.forceBase64;this.supportsBinary=nh&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const r=e.split(Op),n=[];for(let e=0;e<r.length;e++){const i=Mp(r[e],t);if(n.push(i),"error"===i.type)break}return n})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const r=e.length,n=new Array(r);let i=0;e.forEach(((e,s)=>{kp(e,!1,(e=>{n[s]=e,++i===r&&t(n.join(Op))}))}))})(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=Zp()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new ih(this.uri(),e)}doWrite(e,t){const r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}},uh=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,lh=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ph(e){const t=e,r=e.indexOf("["),n=e.indexOf("]");-1!=r&&-1!=n&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let i=uh.exec(e||""),s={},o=14;for(;o--;)s[lh[o]]=i[o]||"";return-1!=r&&-1!=n&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=function(e,t){const r=/\/{2,9}/g,n=t.replace(r,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||n.splice(0,1);"/"==t.slice(-1)&&n.splice(n.length-1,1);return n}(0,s.path),s.queryKey=function(e,t){const r={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,n){t&&(r[t]=n)})),r}(0,s.query),s}class hh extends Np{constructor(e,t={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=ph(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=ph(t.host).host),zp(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},r=e.split("&");for(let e=0,n=r.length;e<n;e++){let n=r[e].split("=");t[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return t}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new dh[e](r)}open(){let e;if(this.opts.rememberUpgrade&&hh.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(e){let t=this.createTransport(e),r=!1;hh.priorWebsocketSuccess=!1;const n=()=>{r||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!r)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;hh.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{r||"closed"!==this.readyState&&(d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function i(){r||(r=!0,d(),t.close(),t=null)}const s=e=>{const r=new Error("probe error: "+e);r.transport=t.name,i(),this.emitReserved("upgradeError",r)};function o(){s("transport closed")}function a(){s("socket closed")}function c(e){t&&e.name!==t.name&&i()}const d=()=>{t.removeListener("open",n),t.removeListener("error",s),t.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};t.once("open",n),t.once("error",s),t.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{r||t.open()}),200):t.open()}onOpen(){if(this.readyState="open",hh.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let r=0;r<this.writeBuffer.length;r++){const n=this.writeBuffer[r].data;if(n&&(e+="string"==typeof(t=n)?function(e){let t=0,r=0;for(let n=0,i=e.length;n<i;n++)t=e.charCodeAt(n),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(n++,r+=4);return r}(t):Math.ceil(1.33*(t.byteLength||t.size))),r>0&&e>this.maxPayload)return this.writeBuffer.slice(0,r);e+=2}var t;return this.writeBuffer}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,n){if("function"==typeof t&&(n=t,t=void 0),"function"==typeof r&&(n=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const i={type:e,data:t,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),n&&this.once("flush",n),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?r():e()})):this.upgrading?r():e()),this}onError(e){hh.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let r=0;const n=e.length;for(;r<n;r++)~this.transports.indexOf(e[r])&&t.push(e[r]);return t}}hh.protocol=4;const fh="function"==typeof ArrayBuffer,mh=Object.prototype.toString,gh="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===mh.call(Blob),vh="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===mh.call(File);function yh(e){return fh&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||gh&&e instanceof Blob||vh&&e instanceof File}function bh(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(bh(e[t]))return!0;return!1}if(yh(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return bh(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&bh(e[t]))return!0;return!1}function wh(e){const t=[],r=e.data,n=e;return n.data=_h(r,t),n.attachments=t.length,{packet:n,buffers:t}}function _h(e,t){if(!e)return e;if(yh(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}if(Array.isArray(e)){const r=new Array(e.length);for(let n=0;n<e.length;n++)r[n]=_h(e[n],t);return r}if("object"==typeof e&&!(e instanceof Date)){const r={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=_h(e[n],t));return r}return e}function Sh(e,t){return e.data=kh(e.data,t),delete e.attachments,e}function kh(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]=kh(e[r],t);else if("object"==typeof e)for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=kh(e[r],t));return e}const Ch=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var Rh;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(Rh||(Rh={}));function Ph(e){return"[object Object]"===Object.prototype.toString.call(e)}class Th extends Np{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const r=t.type===Rh.BINARY_EVENT;r||t.type===Rh.BINARY_ACK?(t.type=r?Rh.EVENT:Rh.ACK,this.reconstructor=new Eh(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!yh(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const r={type:Number(e.charAt(0))};if(void 0===Rh[r.type])throw new Error("unknown packet type "+r.type);if(r.type===Rh.BINARY_EVENT||r.type===Rh.BINARY_ACK){const n=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(n,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");r.attachments=Number(i)}if("/"===e.charAt(t+1)){const n=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}r.nsp=e.substring(n,t)}else r.nsp="/";const n=e.charAt(t+1);if(""!==n&&Number(n)==n){const n=t+1;for(;++t;){const r=e.charAt(t);if(null==r||Number(r)!=r){--t;break}if(t===e.length)break}r.id=Number(e.substring(n,t+1))}if(e.charAt(++t)){const n=this.tryParse(e.substr(t));if(!Th.isPayloadValid(r.type,n))throw new Error("invalid payload");r.data=n}return r}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case Rh.CONNECT:return Ph(t);case Rh.DISCONNECT:return void 0===t;case Rh.CONNECT_ERROR:return"string"==typeof t||Ph(t);case Rh.EVENT:case Rh.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===Ch.indexOf(t[0]));case Rh.ACK:case Rh.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Eh{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=Sh(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var Dh=Object.freeze({__proto__:null,protocol:5,get PacketType(){return Rh},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==Rh.EVENT&&e.type!==Rh.ACK||!bh(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===Rh.EVENT?Rh.BINARY_EVENT:Rh.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==Rh.BINARY_EVENT&&e.type!==Rh.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=wh(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}},Decoder:Th});function Mh(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const Ih=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class xh extends Np{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Mh(e,"open",this.onopen.bind(this)),Mh(e,"packet",this.onpacket.bind(this)),Mh(e,"error",this.onerror.bind(this)),Mh(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(Ih.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const r={type:Rh.EVENT,data:t,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,n=t.pop();this._registerAckCallback(e,n),r.id=e}const n=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!n||!this.connected)||(this.connected?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,t){var r;const n=null!==(r=this.flags.timeout)&&void 0!==r?r:this._opts.ackTimeout;if(void 0===n)return void(this.acks[e]=t);const i=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),n);this.acks[e]=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,[null,...e])}}emitWithAck(e,...t){const r=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((n,i)=>{t.push(((e,t)=>r?e?i(e):n(t):n(e))),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...n)=>{if(r!==this._queue[0])return;return null!==e?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...n)),r.pending=!1,this._drainQueue()})),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Rh.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Rh.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Rh.EVENT:case Rh.BINARY_EVENT:this.onevent(e);break;case Rh.ACK:case Rh.BINARY_ACK:this.onack(e);break;case Rh.DISCONNECT:this.ondisconnect();break;case Rh.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let r=!1;return function(...n){r||(r=!0,t.packet({type:Rh.ACK,id:e,data:n}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Rh.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===t[r])return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const r of t)r.apply(this,e.data)}}}function Oh(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Oh.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-r:e+r}return 0|Math.min(e,this.max)},Oh.prototype.reset=function(){this.attempts=0},Oh.prototype.setMin=function(e){this.ms=e},Oh.prototype.setMax=function(e){this.max=e},Oh.prototype.setJitter=function(e){this.jitter=e};class Lh extends Np{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,zp(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(r=t.randomizationFactor)&&void 0!==r?r:.5),this.backoff=new Oh({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const n=t.parser||Dh;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new hh(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const n=Mh(t,"open",(function(){r.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},s=Mh(t,"error",i);if(!1!==this._timeout){const e=this._timeout,r=this.setTimeoutFn((()=>{n(),i(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}return this.subs.push(n),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Mh(e,"ping",this.onping.bind(this)),Mh(e,"data",this.ondata.bind(this)),Mh(e,"error",this.onerror.bind(this)),Mh(e,"close",this.onclose.bind(this)),Mh(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){oh((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r?this._autoConnect&&!r.active&&r.connect():(r=new xh(this,e,t),this.nsps[e]=r),r}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(t[r],e.options)}cleanup(){this.subs.forEach((e=>e())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn((()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&r.unref(),this.subs.push((()=>{this.clearTimeoutFn(r)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Ah={};function jh(e,t){"object"==typeof e&&(t=e,e=void 0);const r=function(e,t="",r){let n=e;r=r||"undefined"!=typeof location&&location,null==e&&(e=r.protocol+"//"+r.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?r.protocol+e:r.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==r?r.protocol+"//"+e:"https://"+e),n=ph(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const i=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+t,n.href=n.protocol+"://"+i+(r&&r.port===n.port?"":":"+n.port),n}(e,(t=t||{}).path||"/socket.io"),n=r.source,i=r.id,s=r.path,o=Ah[i]&&s in Ah[i].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?a=new Lh(n,t):(Ah[i]||(Ah[i]=new Lh(n,t)),a=Ah[i]),r.query&&!t.query&&(t.query=r.queryKey),a.socket(r.path,t)}var Fh,Nh,Bh,Wh;Object.assign(jh,{Manager:Lh,Socket:xh,io:jh,connect:jh});let qh=class{constructor(e){this.reconnectingAttempt=0,this.isConnected=!1,this._observer=new Rt,Fh.set(this,void 0),this.knownDisconnectReasonsCodes={"io server disconnect":"server.disconnect","io client disconnect":"client.disconnect","ping timeout":"ping.timeout","transport close":"transport.close","transport error":"transport.error"},Nh.set(this,100),Bh.set(this,!1),Wh.set(this,8e3),d(this,Fh,e("Socket"),"f")}get observer(){return this._observer}get id(){var e;return null===(e=this.connection)||void 0===e?void 0:e.id}connect(e,t){const r=jh(e,{multiplex:!0,randomizationFactor:.2,reconnectionDelay:1e3,reconnection:!0,transports:["polling","websocket"],upgrade:!0,rememberUpgrade:!1,auth:{token:t,apiVersion:4}});this.connection=r,this.serverUrl=e,r.on(ei.Connect,(()=>{const e=this.reconnectingAttempt?ei.Reconnected:ei.Connected;this.isConnected=!0,this.setReconnectingAttempt(0),c(this,Fh,"f").debug(`connection.on('${ei.Connect}')`,{connectionId:r.id,recovered:r.recovered}),this.observer.safeEmit(ei.State,{state:e})})),r.on(ei.ConnectError,(e=>{this.connectionError=e,c(this,Fh,"f").error(`connection.on('${ei.ConnectError}')`,{error:e}),this.observer.safeEmit(ei.State,{state:ei.Error,error:e}),this.reconnectingAttempt>c(this,Nh,"f")&&(r.disconnect(),this.observer.safeEmit(ei.State,{state:ei.Disconnected,code:"server.disconnect"}))})),r.on(ei.Disconnect,(e=>{this.isConnected=!1,this.setReconnectingAttempt(0),this.disconnectReason=e,c(this,Fh,"f").info(`connection.on('${ei.Disconnect}')`,{reason:e});const t=this.getDisconnectReasonCode(e);"server.disconnect"===t&&r.disconnect(),this.observer.safeEmit(ei.State,{state:ei.Disconnected,code:t})})),r.io.on(ei.ReconnectAttempt,(e=>{this.setReconnectingAttempt(e),c(this,Fh,"f").info(`connection.on('${ei.ReconnectAttempt}')`,{attempt:e}),this.observer.safeEmit(ei.State,{state:ei.Reconnecting})})),r.io.on(ei.Reconnect,(()=>{c(this,Fh,"f").debug(`connection.on('${ei.Reconnect}')`,{connectionId:r.id}),this.observer.safeEmit(ei.State,{state:ei.Reconnect})}))}disconnect(){this.connection&&(this.connection.offAny(),this.connection.volatile.offAny(),this.connection.disconnect(),this.connection.io.removeAllListeners(),this.setReconnectingAttempt(0))}request(e,t={}){return new Promise(((r,n)=>{this.connection?this.connection.timeout(c(this,Wh,"f")).emit(e,t,((t,i)=>{if(t){const r=Nn.includes(e);return"operation has timed out"===(null==t?void 0:t.message)&&!c(this,Bh,"f")&&r&&(d(this,Bh,!0,"f"),this.observer.safeEmit(ei.State,{state:ei.BufferingStart})),void n(t)}i&&i.error?("Need join to channel first"===i.error&&this.observer.safeEmit(ei.State,{code:ei.NeedToJoinFirst}),n(new gp(i.error,i.errorCode,Object.assign({},i)))):(c(this,Bh,"f")&&(d(this,Bh,!1,"f"),this.observer.safeEmit(ei.State,{state:ei.BufferingEnd})),r(i))})):n(new Error("Socket request: Socket connection is not initialized"))}))}getServerUrl(){return this.serverUrl}getDisconnectReasonCode(e){const t=String(e).toLowerCase();return this.knownDisconnectReasonsCodes[t]||t}setReconnectingAttempt(e){this.reconnectingAttempt=e}};Fh=new WeakMap,Nh=new WeakMap,Bh=new WeakMap,Wh=new WeakMap,qh=i([at(),s(0,dt(Yn.LoggerFactory)),o("design:paramtypes",[Function])],qh);var Uh,zh,Vh,Hh=qh;let $h=class{constructor(e,t,r,n){this.state=e,this.myPeer=t,this.socket=n,Uh.set(this,{send:void 0,recv:void 0}),zh.set(this,void 0),Vh.set(this,void 0),d(this,Vh,r("Network"),"f"),d(this,zh,new Rt,"f"),this.socket.observer.on(ei.State,(e=>{c(this,zh,"f").safeEmit(Bn,e)}))}get isNetworkActive(){var e,t,r,n,i;return!!(null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&["connected","new"].includes(null!==(r=null===(t=this.receiveTransport)||void 0===t?void 0:t.connectionState)&&void 0!==r?r:"")&&["connected","new"].includes(null!==(i=null===(n=this.sendTransport)||void 0===n?void 0:n.connectionState)&&void 0!==i?i:"")}get observer(){return c(this,zh,"f")}get isSocketConnectionActive(){try{return this.checkSocketConnectionActivity(),!0}catch(e){return!1}}checkSocketConnectionActivity(){var e;if(!this.state.channelId||this.state.isChannelJoining)throw new Error("Connect to the channel first");if(!(null===(e=this.socket.connection)||void 0===e?void 0:e.active))throw new Error("Socket is inactive");if(!this.socket.connection.connected)throw new Error("Socket disconnected")}removeEventListeners(){const{sendTransport:e,receiveTransport:t}=this;if(e){["connect","produce","connectionstatechange"].forEach((t=>e.removeAllListeners(t)))}if(t){["connect","produce","connectionstatechange"].forEach((e=>t.removeAllListeners(e)))}}reset(){return a(this,void 0,void 0,(function*(){this.stopRestartIceAtempts(),this.removeEventListeners()}))}closeRemoteProducer(e){return a(this,void 0,void 0,(function*(){yield this.socket.request(gn,{peerId:this.myPeer.id,producerId:e})}))}closeSendTransport(){var e;return a(this,void 0,void 0,(function*(){this.sendTransport?((null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&(yield this.closeTransport(this.sendTransport)),this.sendTransport.close(),this.sendTransport=void 0):c(this,Vh,"f").warn("closeSendTransport()",{message:"No available send transport"})}))}closeReceiveTransport(){var e;return a(this,void 0,void 0,(function*(){this.receiveTransport?((null===(e=this.socket.connection)||void 0===e?void 0:e.connected)&&(yield this.closeTransport(this.receiveTransport)),this.receiveTransport.close(),this.receiveTransport=void 0):c(this,Vh,"f").warn("closeReceiveTransport()",{message:"No available receive transport"})}))}closeTransport(e){return a(this,void 0,void 0,(function*(){try{e.close(),c(this,Vh,"f").debug("closeTransport()",{transportId:e.id,direction:e.direction})}catch(t){c(this,Vh,"f").error("closeTransport()",{error:t,transportId:e.id,direction:e.direction})}}))}createSendTransport(e){return a(this,void 0,void 0,(function*(){if(this.sendTransport)throw c(this,Vh,"f").warn("createSendTransport()",{message:"Send transport already exists"}),new qn("Send transport already exists","already_exists");const t=yield this.socket.request(xn,{sctpCapabilities:e.sctpCapabilities,localDirection:"send"}),r=e.createSendTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return c(this,Vh,"f").debug("createSendTransport()",{transportId:r.id,direction:r.direction}),this.sendTransport=r,this.subscribeCommonTransportEvents(r),r}))}createRecvTransport(e){return a(this,void 0,void 0,(function*(){if(this.receiveTransport)throw c(this,Vh,"f").warn("createReceiveTransport()",{message:"Receive transport already exists"}),new qn("Receive transport already exists","already_exists");const t=yield this.socket.request(xn,{localDirection:"receive"}),r=e.createRecvTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return c(this,Vh,"f").debug("createReceiveTransport()",{transportId:r.id,direction:r.direction}),this.receiveTransport=r,this.subscribeCommonTransportEvents(r),r}))}getIceParameters(e){return a(this,void 0,void 0,(function*(){const t=yield this.socket.request(Fn,{transportId:e.id}),{error:r}=t;if(r)throw new Error(r);const{iceParameters:n}=t;return c(this,Vh,"f").debug("getIceParameters()",{iceParameters:n}),n}))}restartIce(e){return a(this,void 0,void 0,(function*(){try{const t=yield this.getIceParameters(e);yield e.restartIce({iceParameters:t}),c(this,Vh,"f").info("restartIce completed",{iceParameters:t})}catch(e){c(this,Vh,"f").error("restartIce error",{error:e})}}))}createConsumer({producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i}){var s;return a(this,void 0,void 0,(function*(){const o=this.receiveTransport;if(!o)throw c(this,Vh,"f").error("createConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer");let a;c(this,Vh,"f").debug("createConsumer()",{producerId:e});try{a=yield this.socket.request(Cn,{producerId:e,transportId:o.id,rtpCapabilities:t,appData:{peerId:this.myPeer.id,appId:r,channelId:n},producerPeerId:i})}catch(o){if(!(o instanceof gp&&(null===(s=o.meta)||void 0===s?void 0:s.existedConsumer)))throw c(this,Vh,"f").error("Failed to get consumer options",{producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i,error:mr(o)}),new Error("Failed to create consumer");a=o.meta.existedConsumer}const d=yield o.consume(a),{producerPaused:u}=a;return u&&d.pause(),c(this,Vh,"f").debug("Consumer created",{consumerId:d.id,label:d.appData.label,isProducerPaused:u}),{consumer:d,isProducerPaused:u}}))}createDataConsumer({producerId:e,appId:t,channelId:r,ordered:n}){return a(this,void 0,void 0,(function*(){const i=this.receiveTransport;if(!i)throw c(this,Vh,"f").error("createDataConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer");c(this,Vh,"f").debug("createDataConsumer()",{producerId:e});const s=yield this.socket.request(Rn,{ordered:n,dataProducerId:e,transportId:i.id,appData:{peerId:this.myPeer.id,producerId:e,appId:t,channelId:r}}),o=yield i.consumeData(s);return c(this,Vh,"f").debug("Data consumer created",{consumerId:o.id}),o}))}closeRemoteConsumer(e){return a(this,void 0,void 0,(function*(){return this.socket.request(Pn,{peerId:this.myPeer.id,consumerId:e})}))}resumeRemoteConsumer(e){return a(this,void 0,void 0,(function*(){return this.socket.request(En,{consumerId:e})}))}pauseRemoteProducer(e){return a(this,void 0,void 0,(function*(){return this.socket.request(vn,{producerId:e})}))}pauseRemoteConsumer(e){return a(this,void 0,void 0,(function*(){return this.socket.request(Tn,{consumerId:e})}))}updatePeerAppData({peerId:e,appData:t}){return a(this,void 0,void 0,(function*(){return this.socket.request(_r,{peerId:e,appData:t})}))}getAudioObserverProducer(){return a(this,void 0,void 0,(function*(){return this.socket.request(Pr)}))}getGeneralDataProducer(){return a(this,void 0,void 0,(function*(){return this.socket.request(Tr)}))}getChannelStateSyncDataProducer(){return a(this,void 0,void 0,(function*(){return this.socket.request(Er)}))}createDataProducer(e){var t;return a(this,void 0,void 0,(function*(){return this.socket.request(An,{transportId:null===(t=this.sendTransport)||void 0===t?void 0:t.id,label:e})}))}getTransportsStateInfo(){return a(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([this.getParsedTransportStats(this.receiveTransport),this.getParsedTransportStats(this.sendTransport)]);return{receive:e,send:t}}))}setPreferRelay(e){this.preferRelay=e}getPreferRelay(){var e;return null!==(e=this.preferRelay)&&void 0!==e&&e}getChannelPeers(e){return a(this,void 0,void 0,(function*(){return this.socket.request(br,{role:e})}))}getParsedTransportStats(e){return a(this,void 0,void 0,(function*(){if(e)try{const t=Array.from((yield e.getStats()).values()),r=t.find((e=>"local-candidate"===e.type)),n=t.find((e=>"remote-candidate"===e.type)),i=t.find((e=>"transport"===e.type));return{dtlsState:null==i?void 0:i.dtlsState,iceState:null==i?void 0:i.iceState,dtlsRole:null==i?void 0:i.dtlsRole,iceRole:null==i?void 0:i.iceRole,selectedCandidatePairChanges:null==i?void 0:i.selectedCandidatePairChanges,tlsVersion:null==i?void 0:i.tlsVersion,localCandidateState:{ip:null==r?void 0:r.ip,address:null==r?void 0:r.address,port:null==r?void 0:r.port,protocol:null==r?void 0:r.protocol,candidateType:null==r?void 0:r.candidateType},remoteCandidateState:{ip:null==n?void 0:n.ip,address:null==n?void 0:n.address,port:null==n?void 0:n.port,protocol:null==n?void 0:n.protocol,candidateType:null==n?void 0:n.candidateType}}}catch(e){return void c(this,Vh,"f").warn("getParsedTransportStats()",{error:e})}else c(this,Vh,"f").debug("getParsedTransportStats()",{message:"Transport is missing"})}))}logTransportDetails(e){var t,r;return a(this,void 0,void 0,(function*(){let n;try{n=yield e.getStats()}catch(t){return void c(this,Vh,"f").error("Failed to log detailed WebRTC transport stats",{error:mr(t),transportId:e.id,reason:"failed to parse getStats"})}try{const i=[...n],[,s]=null!==(t=i.find((([,e])=>"transport"===(null==e?void 0:e.type))))&&void 0!==t?t:[],[,o]=null!==(r=i.find((([,e])=>"candidate-pair"===e.type&&"succeeded"===e.state&&e.nominated)))&&void 0!==r?r:[],a=n.get(String((null==o?void 0:o.localCandidateId)||"-")),d=n.get(String((null==o?void 0:o.remoteCandidateId)||"-")),u={hasNominatedPair:!!o,transportId:e.id,iceRole:null==s?void 0:s.iceRole,iceState:null==s?void 0:s.iceState,dtlsRole:null==s?void 0:s.dtlsRole,dtlsState:null==s?void 0:s.dtlsState,local:{address:null==a?void 0:a.address,candidateType:null==a?void 0:a.candidateType,foundation:null==a?void 0:a.foundation,networkType:null==a?void 0:a.networkType,isRemote:null==a?void 0:a.isRemote,port:null==a?void 0:a.port,protocol:null==a?void 0:a.protocol,relatedAddress:null==a?void 0:a.relatedAddress,relatedPort:null==a?void 0:a.relatedPort,transportId:null==a?void 0:a.transportId,relayProtocol:null==a?void 0:a.relayProtocol,url:null==a?void 0:a.url},remote:{address:null==d?void 0:d.address,candidateType:null==d?void 0:d.candidateType,foundation:null==d?void 0:d.foundation,isRemote:null==d?void 0:d.isRemote,port:null==d?void 0:d.port,protocol:null==d?void 0:d.protocol,transportId:null==d?void 0:d.transportId}};(null==o?void 0:o.totalRoundTripTime)&&(null==o?void 0:o.responsesReceived)&&(u.pairRoundTripTime=Math.round(o.totalRoundTripTime/o.responsesReceived*1e3)),c(this,Vh,"f").info("Detailed WebRTC transport stats",u)}catch(t){c(this,Vh,"f").error("Failed to log detailed WebRTC transport stats",{error:mr(t),transportId:e.id,reason:"-"})}}))}stopRestartIceAtempts(){clearInterval(c(this,Uh,"f").send),clearInterval(c(this,Uh,"f").recv)}subscribeCommonTransportEvents(e){e.on("connect",(({dtlsParameters:t},r,n)=>a(this,void 0,void 0,(function*(){try{yield this.socket.request(On,{transportId:e.id,dtlsParameters:t}),r(),c(this,Vh,"f").debug(`${e.direction}Transport.connect()`,{transportId:e.id,dtlsRole:t.role}),setTimeout((()=>this.logTransportDetails(e)),1500)}catch(t){c(this,Vh,"f").error(`${e.direction}Transport.on('connect')`,{error:t}),n(t)}})))),e.on("produce",((t,r,n)=>a(this,void 0,void 0,(function*(){try{const{id:n}=yield this.socket.request(Ln,{transportId:e.id,kind:t.kind,rtpParameters:t.rtpParameters,appData:t.appData});r({id:n}),c(this,Vh,"f").debug(`${e.direction}Transport.produce()`,{producerId:n,transportId:e.id,kind:t.kind})}catch(r){c(this,Vh,"f").error(`${e.direction}Transport.produce()`,{error:r,transportId:e.id,kind:t.kind}),n(r)}})))),e.on("connectionstatechange",(t=>{if(c(this,Vh,"f").info(`${e.direction}Transport.state`,{state:t}),["closed","connected"].includes(t))return c(this,zh,"f").safeEmit(Wn,{state:t,direction:e.direction}),c(this,Uh,"f")[e.direction]&&(c(this,Vh,"f").debug("Stop receiveTransport.restartIce() retries",{recvTransportId:e.id}),clearInterval(c(this,Uh,"f")[e.direction]),c(this,Uh,"f")[e.direction]=void 0,"connected"===t&&c(this,zh,"f").safeEmit(Wn,{state:"reconnected",direction:e.direction})),void("connected"===t&&setTimeout((()=>this.logTransportDetails(e)),1500));if(c(this,zh,"f").safeEmit(Wn,{state:t,direction:e.direction}),["disconnected","failed"].includes(t)){if(c(this,Uh,"f")[e.direction])return;"failed"===t&&(c(this,Vh,"f").debug(`${e.direction}Transport.restartIce()`,{recvTransportId:e.id}),this.restartIce(e)),c(this,Uh,"f")[e.direction]=setInterval((()=>{this.restartIce(e),c(this,Vh,"f").debug(`${e.direction}Transport.restartIce() attempt`,{recvTransportId:e.id})}),5e3)}})),e.on("icegatheringstatechange",(t=>{c(this,Vh,"f").info("icegatheringstatechange",{state:t,transportId:e.id,transportDirection:e.direction})}))}};Uh=new WeakMap,zh=new WeakMap,Vh=new WeakMap,$h=i([at(),s(0,dt(Yn.CallState)),s(1,dt(Yn.MyPeer)),s(2,dt(Yn.LoggerFactory)),s(3,dt(Yn.SocketIO)),o("design:paramtypes",[ti,mp,Function,Hh])],$h);var Kh=$h;let Gh=class{constructor(e,t,r,n){this.myPeer=e,this.network=t,this.peerFactory=r,this.clientEventEmitter=n,this.peersStorage=new Map}has(e){return this.peersStorage.has(e)}set(e,t){e===this.myPeer.id&&this.myPeer.set(t),this.peersStorage.set(e,t)}get(e){return this.peersStorage.get(e)}delete(e){return e===this.myPeer.id&&this.myPeer.delete(),this.peersStorage.delete(e)}remove(e){return a(this,void 0,void 0,(function*(){const t=this.get(e);t&&(yield t.reset(),this.delete(e),this.clientEventEmitter.safeEmit(Nr,e))}))}all(){return Array.from(this.peersStorage.values())}hosts(){return this.all().filter((e=>"host"===e.role))}audience(){return this.all().filter((e=>"audience"===e.role))}reset(){return a(this,void 0,void 0,(function*(){yield Promise.all(Array.from(this.peersStorage.values()).map((e=>e.reset()))),this.peersStorage.clear()}))}load(e){return a(this,void 0,void 0,(function*(){const{peers:t}=yield this.network.getChannelPeers(e);t.filter((e=>!this.has(e.id))).forEach((e=>this.add(e,!1)))}))}add(e,t=!0){const r=this.get(e.id);if(r)return r;const n=this.peerFactory(e);return this.set(n.id,n),t&&this.clientEventEmitter.safeEmit(Fr,n),n}isModerator(e){if(void 0===e)return!1;const t=this.get(e);return!!t&&t.isModerator}setActiveSpeaker(e){this.activePeerId!==(null==e?void 0:e.id)&&(this.activePeerId=null==e?void 0:e.id,this.clientEventEmitter.safeEmit(Kr,{peer:e}))}};Gh=i([at(),s(0,dt(Yn.MyPeer)),s(1,dt(Yn.Network)),s(2,dt(Yn.PeerFactory)),s(3,dt(Yn.ClientEventEmitter)),o("design:paramtypes",[mp,Kh,Function,Rt])],Gh);const Qh=e=>null!==e&&"object"==typeof e,Jh=(e,t)=>{const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;let i=!0;return r.forEach((r=>{const n=e[r],s=t[r],o=Qh(n)&&Qh(s);(o&&!Jh(n,s)||!o&&n!==s)&&(i=!1)})),i};var Yh,Zh,Xh,ef;let tf=class{constructor(){Yh.set(this,[]),Zh.set(this,new Map),Xh.set(this,new Set),ef.set(this,!1)}subscribeToSocket(e){c(this,Xh,"f").has(e)||(e.onAny(((e,...t)=>{this.push(e,t)})),c(this,Xh,"f").add(e))}subscribeToDataChannel(e){e.on("message",((...e)=>{this.push("message",e)}))}on(e,t){var r;c(this,Zh,"f").has(e)?null===(r=c(this,Zh,"f").get(e))||void 0===r||r.push(t):c(this,Zh,"f").set(e,[t])}removeListener(e){c(this,Zh,"f").delete(e)}removeAllListeners(e,t){t&&c(this,Xh,"f").has(t)&&(t.offAny(),c(this,Xh,"f").delete(t)),e.forEach((e=>{c(this,Zh,"f").delete(e)}))}push(e,t){c(this,Yh,"f").push({event:e,args:t}),this.process()}process(){if(!c(this,ef,"f"))for(;c(this,Yh,"f").length>0;){const e=c(this,Yh,"f").shift();this.emit(e.event,e.args)}}emit(e,t){(c(this,Zh,"f").get(e)||[]).forEach((e=>{e(...t)}))}pause(){d(this,ef,!0,"f")}size(){return c(this,Yh,"f").length}resume(){d(this,ef,!1,"f"),this.process()}};Yh=new WeakMap,Zh=new WeakMap,Xh=new WeakMap,ef=new WeakMap,tf=i([at()],tf);var rf,nf=tf;let sf=class{constructor(e,t,r,n,i,s,o){this.network=e,this.media=t,this.myPeer=r,this.eventsQueue=n,this.clientEventEmitter=i,this.peers=s,rf.set(this,void 0),d(this,rf,o("ChannelStateSyncEventHandler"),"f"),this.debouncedRestoreState=function(e,t,r=!1){let n;return function(...i){const s=this,o=r&&!n;"number"==typeof n&&clearTimeout(n),n=setTimeout((()=>{n=null,r||e.apply(s,i)}),t),o&&e.apply(s,i)}}(this.restoreState.bind(this),3e3),this.watchNetworkState()}watchNetworkState(){this.clientEventEmitter.on(Jr,(()=>a(this,void 0,void 0,(function*(){yield this.debouncedRestoreState()}))))}restoreState(){return a(this,void 0,void 0,(function*(){const e={missingPeers:[],removedPeers:[],missingProducers:[],removedProducers:[],fixedProducersState:[],fixedConsumersState:[],restoredAppDataPeers:[]};try{if(!this.network.isSocketConnectionActive)return c(this,rf,"f").info("Connection inactive, skipping restore local state",{case:"restoreLocalState"}),e;this.eventsQueue.pause(),c(this,rf,"f").info("Restoring local state",{case:"restoreLocalState"});const t=this.peers.hosts().map((e=>e.shortData)),{peers:r}=yield this.network.getChannelPeers("host"),{removedProducers:n,fixedProducersState:i}=yield this.restoreRemoteProducersState(r);e.removedProducers.push(...i),e.removedProducers.push(...n),e.removedPeers.push(...this.removeUnnecessaryPeers(t,r)),e.missingPeers.push(...this.setMissingPeers(t,r));const s=this.restoreLocalPeersState(r);return e.missingProducers.push(...s.missingProducers),e.removedProducers.push(...s.removedProducers),e.restoredAppDataPeers.push(...s.restoredAppDataPeers),e.fixedProducersState.push(...s.fixedProducersState),e.fixedConsumersState.push(...s.fixedConsumersState),e}catch(t){return c(this,rf,"f").info("Failed to restore local state",{case:"restoreLocalState",error:mr(t)}),e}finally{c(this,rf,"f").info("Resume events after re-syncing local peers",{case:"restoreLocalState",accumulatedEventsAmount:this.eventsQueue.size()}),this.eventsQueue.resume()}}))}restoreRemoteProducersState(e){return a(this,void 0,void 0,(function*(){const t={removedProducers:[],fixedProducersState:[]},r=this.myPeer.get(),n=e.find((e=>e.id===this.myPeer.id));if(!r||!n)return t;const i=this.media.getAllTracks(),s=n.producers.filter((e=>!i.map((e=>e.producerId)).some((t=>e.id===t))));yield Promise.all(s.map((e=>a(this,void 0,void 0,(function*(){yield this.network.closeRemoteProducer(e.id),r.producers.delete(e.id),t.removedProducers.push(e.id),c(this,rf,"f").info("Unnecessary local producer closed",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId})})))));const o=n.producers.filter((e=>!!i.find((t=>t.isPaused&&t.isPaused!==e.paused))));return yield Promise.all(o.map((e=>a(this,void 0,void 0,(function*(){yield this.network.pauseRemoteProducer(e.id),t.fixedProducersState.push(e.id),c(this,rf,"f").info("Remote producer state repaired",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId})}))))),t}))}removeUnnecessaryPeers(e,t){const r=[];return e.filter((e=>!t.find((t=>t.id===e.id)))).forEach((e=>{this.peers.remove(e.id),r.push(e.id),c(this,rf,"f").info("Unnecessary peer removed",{case:"restoreLocalState",removedPeerId:e.id})})),r}setMissingPeers(e,t){const r=[];return t.forEach((t=>{if(e.find((e=>e.id===t.id)))return;const n=this.peers.add(t);r.push(n.id),c(this,rf,"f").info("Missing peer added to storage",{case:"restoreLocalState",peerId:t.id})})),r}restoreLocalPeersState(e){const t=new Map(e.map((e=>[e.id,e]))),r=this.peers.hosts(),n={removedProducers:[],missingProducers:[],restoredAppDataPeers:[],fixedConsumersState:[],fixedProducersState:[]};return r.forEach((e=>{const r=t.get(e.id);if(!r)return void c(this,rf,"f").warn("Found new local peer, skip restoring state",{case:"restoreLocalState",newPeerId:e.id});n.removedProducers.push(...this.removeUnnecessaryProducers(e,r));this.restoreAppData(e,r)&&n.restoredAppDataPeers.push(e.id);const{fixedProducersState:i,fixedConsumersState:s,missingProducers:o}=this.restoreTracksState(e,r);n.fixedProducersState.push(...i),n.fixedConsumersState.push(...s),n.missingProducers.push(...o)})),c(this,rf,"f").info("Peers state restored",{case:"restoreLocalState"}),n}removeUnnecessaryProducers(e,t){const r=[];return e.getProducers().filter((e=>!t.producers.find((t=>t.id===e.id)))).forEach((t=>{e.observer.safeEmit(gn,t),r.push(t.id),c(this,rf,"f").info("Unnecessary producer removed",{case:"restoreLocalState",removedProducerId:t.id,removedProducerPeerId:t.peerId})})),r}restoreTracksState(e,t){const r={missingProducers:[],fixedProducersState:[],fixedConsumersState:[]};return t.producers.forEach((t=>{var n;const i=e.producers.get(t.id);if(!i)return e.observer.safeEmit(mn,t),r.missingProducers.push(t.id),void c(this,rf,"f").info("Missing producer added to storage",{case:"restoreLocalState",producerId:t.id,producerPeerId:t.peerId});if(i.paused!==t.paused){i.paused=t.paused;const n=i.paused?sn:on;e.observer.safeEmit(n,{producerId:i.id,kind:i.kind,label:i.label,paused:i.paused}),r.fixedProducersState.push(t.id),c(this,rf,"f").info("Producer state fixed",{case:"restoreLocalState",producerId:t.id,producerPeerId:t.peerId})}const s=e.tracks.get(i.label);if(s&&s.consumerId&&(null===(n=s.consumer)||void 0===n?void 0:n.paused)!==t.paused){const{consumerId:n}=s,o=i.paused?Tn:En;e.observer.safeEmit(o,n),r.fixedConsumersState.push(n),c(this,rf,"f").info("Consumer state fixed",{case:"restoreLocalState",consumerId:n,consumerProducerId:t.id,consumerProducerPeerId:t.peerId})}})),r}restoreAppData(e,t){return!Jh(e.appData,t.appData)&&(e.observer.emit(_r,t.appData),c(this,rf,"f").info("Application data restored",{case:"restoreLocalState",peerId:e.id,appData:t.appData}),!0)}};rf=new WeakMap,sf=i([at(),s(0,dt(Yn.Network)),s(1,dt(Yn.Media)),s(2,dt(Yn.MyPeer)),s(3,dt(Yn.EventsQueue)),s(4,dt(Yn.ClientEventEmitter)),s(5,dt(Yn.Peers)),s(6,dt(Yn.LoggerFactory)),o("design:paramtypes",[Kh,fp,mp,nf,Rt,Gh,Function])],sf);var of,af=sf;function cf(e){return{id:e.id,appId:e.appId,role:e.role,groups:e.groups,producePermissions:e.producePermissions}}let df=class{constructor(e,t,r,n,i,s){this.eventsQueue=e,this.network=t,this.socket=r,this.peers=n,this.clientEventEmitter=i,of.set(this,void 0),d(this,of,s("ChannelEvents"),"f")}handleDataChannelEvent(e){try{const{event:t,data:r}=JSON.parse(e);this.doHandleDataChannelEvent(t,r)}catch(t){c(this,of,"f").error("Failed to handle data channel event",{error:t,payload:e})}}doHandleDataChannelEvent(e,t){e===_r&&this.handlePeerAppDataUpdate(t)}subscribeToEvents(){const{connection:e}=this.socket;if(!e)throw c(this,of,"f").error("subscribeToEvents()",{error:"Socket connection not initialized"}),new Error("Socket connection not initialized");this.eventsQueue.subscribeToSocket(e),this.eventsQueue.on(vr,(e=>{this.clientEventEmitter.safeEmit(jr,e),c(this,of,"f").debug("New channel event",{event:e})})),this.eventsQueue.on(yr,(e=>{const t=this.peers.add(e);c(this,of,"f").debug("Peer joined to the channel",{peer:cf(t)})})),this.eventsQueue.on(wr,(e=>{this.peers.remove(e),c(this,of,"f").debug("Peer left the channel",{peerId:e})})),this.eventsQueue.on(Cr,(e=>{this.clientEventEmitter.safeEmit(Br,e),c(this,of,"f").info("Notify the channel that activity confirmation is required",e)})),this.eventsQueue.on(Rr,(e=>{this.clientEventEmitter.safeEmit(qr,e),c(this,of,"f").info("Notify the channel that it has disconnected due to the activity confirmation expiring",e)})),this.eventsQueue.on(kr,(e=>{this.clientEventEmitter.safeEmit(Wr,e),c(this,of,"f").info("Notify the channel that the activity has been acquired.",e)})),this.eventsQueue.on(Dr,(e=>{const{producePermissions:t,groups:r,changedProducePermissions:n}=e;this.peers.all().filter((e=>e.groups.some((e=>r.includes(e))))).forEach((e=>{const r=Array.from(new Set([...e.producePermissions,...n])).filter((e=>!n.includes(e)||t.includes(e)));e.handleProducePermissionsChange(r)})),c(this,of,"f").info("Peers changed produce permissions",{groups:r,producePermissions:t})})),this.eventsQueue.on(Ir,(e=>{const{peerId:t,producePermissions:r}=e,n=this.peers.get(t);n&&n.handleProducePermissionsChange(r)})),this.eventsQueue.on(Mr,(e=>{const{producePermissions:t,groups:r}=e;this.peers.all().filter((e=>e.groups.some((e=>r.includes(e))))).forEach((e=>{const r=e.producePermissions.filter((e=>!t.includes(e)));e.handleProducePermissionsChange(r)})),c(this,of,"f").info("Peers deleted produce permissions",{groups:r,producePermissions:t})})),this.eventsQueue.on(Lr,(e=>{const{peerId:t,groups:r}=e,n=this.peers.get(t);n&&n.handleGroupsChange(r)}))}removeEventListeners(){if(!this.eventsQueue)return;const e=[vr,yr,wr,Cr,Rr,kr,_r,Dr],{connection:t}=this.socket;this.eventsQueue.removeAllListeners(e,t)}handlePeerAppDataUpdate({peerId:e,appData:t}){const r=this.peers.get(e);r&&r.observer.emit(_r,t)}reset(){this.removeEventListeners()}};of=new WeakMap,df=i([at(),s(0,dt(Yn.EventsQueue)),s(1,dt(Yn.Network)),s(2,dt(Yn.SocketIO)),s(3,dt(Yn.Peers)),s(4,dt(Yn.ClientEventEmitter)),s(5,dt(Yn.LoggerFactory)),o("design:paramtypes",[nf,Kh,Hh,Gh,Rt,Function])],df);var uf=df,lf={},pf=l&&l.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(lf,"__esModule",{value:!0});var hf=lf.AwaitQueue=class{constructor({ClosedErrorClass:e=Error,StoppedErrorClass:t=Error,RemovedTaskErrorClass:r=Error}={ClosedErrorClass:Error,StoppedErrorClass:Error,RemovedTaskErrorClass:Error}){this.closed=!1,this.pendingTasks=[],this.ClosedErrorClass=Error,this.StoppedErrorClass=Error,this.RemovedTaskErrorClass=Error,this.ClosedErrorClass=e,this.StoppedErrorClass=t,this.RemovedTaskErrorClass=r}get size(){return this.pendingTasks.length}close(){if(!this.closed){this.closed=!0;for(const e of this.pendingTasks)e.stopped=!0,e.reject(new this.ClosedErrorClass("AwaitQueue closed"));this.pendingTasks.length=0}}push(e,t){return pf(this,void 0,void 0,(function*(){if(this.closed)throw new this.ClosedErrorClass("AwaitQueue closed");if("function"!=typeof e)throw new TypeError("given task is not a function");if(!e.name&&t)try{Object.defineProperty(e,"name",{value:t})}catch(e){}return new Promise(((r,n)=>{const i={task:e,name:t,resolve:r,reject:n,stopped:!1,enqueuedAt:new Date,executedAt:void 0};this.pendingTasks.push(i),1===this.pendingTasks.length&&this.next()}))}))}removeTask(e){if(0===e)throw new TypeError("cannot remove task with index 0");const t=this.pendingTasks[e];t&&(this.pendingTasks.splice(e,1),t.reject(new this.RemovedTaskErrorClass("task removed from the queue")))}stop(){if(!this.closed){for(const e of this.pendingTasks)e.stopped=!0,e.reject(new this.StoppedErrorClass("AwaitQueue stopped"));this.pendingTasks.length=0}}dump(){const e=new Date;let t=0;return this.pendingTasks.map((r=>({idx:t++,task:r.task,name:r.name,enqueuedTime:r.executedAt?r.executedAt.getTime()-r.enqueuedAt.getTime():e.getTime()-r.enqueuedAt.getTime(),executingTime:r.executedAt?e.getTime()-r.executedAt.getTime():0})))}next(){return pf(this,void 0,void 0,(function*(){const e=this.pendingTasks[0];e&&(yield this.executeTask(e),this.pendingTasks.shift(),this.next())}))}executeTask(e){return pf(this,void 0,void 0,(function*(){if(!e.stopped){e.executedAt=new Date;try{const t=yield e.task();if(e.stopped)return;e.resolve(t)}catch(t){if(e.stopped)return;e.reject(t)}}}))}};const ff=new Error("request for lock canceled");var mf=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))};class gf{constructor(e,t=ff){if(this._maxConcurrency=e,this._cancelError=t,this._queue=[],this._waiters=[],e<=0)throw new Error("semaphore must be initialized to a positive value");this._value=e}acquire(){const e=this.isLocked(),t=new Promise(((e,t)=>this._queue.push({resolve:e,reject:t})));return e||this._dispatch(),t}runExclusive(e){return mf(this,void 0,void 0,(function*(){const[t,r]=yield this.acquire();try{return yield e(t)}finally{r()}}))}waitForUnlock(){return mf(this,void 0,void 0,(function*(){if(!this.isLocked())return Promise.resolve();const e=new Promise((e=>this._waiters.push({resolve:e})));return e}))}isLocked(){return this._value<=0}release(){if(this._maxConcurrency>1)throw new Error("this method is unavailable on semaphores with concurrency > 1; use the scoped release returned by acquire instead");if(this._currentReleaser){const e=this._currentReleaser;this._currentReleaser=void 0,e()}}cancel(){this._queue.forEach((e=>e.reject(this._cancelError))),this._queue=[]}_dispatch(){const e=this._queue.shift();if(!e)return;let t=!1;this._currentReleaser=()=>{t||(t=!0,this._value++,this._resolveWaiters(),this._dispatch())},e.resolve([this._value--,this._currentReleaser])}_resolveWaiters(){this._waiters.forEach((e=>e.resolve())),this._waiters=[]}}var vf=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(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){e.done?i(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(o,a)}c((n=n.apply(e,t||[])).next())}))};class yf{constructor(e){this._semaphore=new gf(1,e)}acquire(){return vf(this,void 0,void 0,(function*(){const[,e]=yield this._semaphore.acquire();return e}))}runExclusive(e){return this._semaphore.runExclusive((()=>e()))}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const bf=e=>"rtx"!==e.mimeType;var wf,_f,Sf,kf,Cf,Rf,Pf,Tf,Ef,Df,Mf,If,xf,Of,Lf,Af,jf,Ff,Nf,Bf,Wf,qf,Uf;class zf{constructor({track:e,statsHandler:t}){wf.set(this,void 0),_f.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return c(this,wf,"f")}get audioWebRTCStats(){return c(this,_f,"f")}handleWebRTCStats(e,t){e.addEventListener("ended",(()=>{t.removeInboundVideoHandler(e.id),t.removeInboundAudioHandler(e.id)}),{once:!0}),"video"!==e.kind?t.addOutboundAudioHandler(e.id,this.setAudioWebRTCStats.bind(this)):t.addOutboundVideoHandler(e.id,this.setVideoWebRTCStats.bind(this))}setVideoWebRTCStats(e){d(this,wf,e,"f")}setAudioWebRTCStats(e){d(this,_f,e,"f")}}wf=new WeakMap,_f=new WeakMap;class Vf{constructor(e){Sf.set(this,void 0),kf.set(this,void 0),this.encoderConfig={},this.label=Zn.Unknown,Cf.set(this,void 0),Rf.set(this,void 0),Pf.set(this,void 0),Tf.set(this,void 0),Ef.set(this,void 0),Df.set(this,!1),Mf.set(this,void 0),If.set(this,void 0),xf.set(this,void 0),Of.set(this,!0),Lf.set(this,new yf),Af.set(this,void 0),jf.set(this,void 0);const{mediaStreamTrack:t,internalEventEmitter:r,constraints:n,mediaStreamTrackManager:i,media:s,myPeer:o,network:a,socket:c,loggerFactory:u,loggerNamespace:l,statsHandler:p}=e;d(this,Sf,t,"f"),d(this,Ef,r,"f"),d(this,Mf,n,"f"),d(this,If,i,"f"),d(this,xf,new Rt,"f"),this.logger=u(l),d(this,Rf,s,"f"),d(this,Cf,o,"f"),d(this,Pf,a,"f"),d(this,Tf,c,"f"),d(this,jf,p,"f"),d(this,Af,new zf({track:t,statsHandler:p}),"f")}get videoWebRTCStats(){return c(this,Af,"f").videoWebRTCStats}get audioWebRTCStats(){return c(this,Af,"f").audioWebRTCStats}get logCtx(){return{label:this.getLabel(),id:this.id,kind:this.kind,producerId:this.producerId,paused:this.isPaused,published:this.isPublished}}get observer(){return c(this,xf,"f")}get mediaStreamTrack(){return c(this,Sf,"f")}get originalTrack(){return c(this,kf,"f")}get id(){return this.mediaStreamTrack.id}get kind(){return this.mediaStreamTrack.kind}get producerId(){var e;return null===(e=this.producer)||void 0===e?void 0:e.id}get isPublished(){return!!this.producer&&!this.producer.closed}get isPaused(){var e,t;return null!==(t=null===(e=this.producer)||void 0===e?void 0:e.paused)&&void 0!==t&&t}get internalEventEmitter(){return c(this,Ef,"f")}getLabel(){return this.label}setLabel(e){this.label=e}setEncoderConfig(e){this.encoderConfig=e}getEncoderConfig(){return this.encoderConfig}setProducer(e){this.producer=e}setStopTrackOnPause(e){this.isPublished||d(this,Of,e,"f")}getProducer(){return this.producer}setOriginalTrack(){d(this,kf,this.mediaStreamTrack,"f")}closeProducer(e=!0){return a(this,void 0,void 0,(function*(){if(this.producer){try{yield c(this,Pf,"f").closeRemoteProducer(this.producer.id)}catch(e){this.logger.warn("closeProducer()",{label:this.getLabel(),producerId:this.producerId})}this.producer.close(),this.producer=void 0,e&&this.stopMediaStreamTrack()}}))}setPriority(e){return a(this,void 0,void 0,(function*(){this.producer?(yield this.producer.setRtpEncodingParameters({priority:e}),this.logger.debug("setPriority()",{label:this.getLabel(),priority:e})):this.logger.warn("setPriority()",{priority:e,reason:"Not published yet"})}))}stopMediaStreamTrack(){this.mediaStreamTrack.stop(),this.mediaStreamTrack.dispatchEvent(new Event("ended")),this.stopOriginalTrack()}stopOriginalTrack(){c(this,kf,"f")&&(c(this,kf,"f").stop(),d(this,kf,void 0,"f"))}produce({encodings:e,codecOptions:t,preferredCodec:r,transformParams:n,keyFrameRequestDelay:i}){var s,o,d,u,l;return a(this,void 0,void 0,(function*(){if(!c(this,Cf,"f").canPublish)throw this.logger.error("produce()",{message:"Not enough access to produce"}),new Error("Not enough access to produce");if(this.producer)throw new Error("Track already produced");try{yield c(this,Tf,"f").request(Ar);const{rtpCapabilities:{codecs:a}}=c(this,Rf,"f").mediasoupDevice,p=null==a?void 0:a.find((e=>e.mimeType.toLowerCase()===`${this.kind}/${r}`)),h=0,f=this.prepareProducerEncodings({codec:p,encodings:null!=e?e:[],maxSpatialLayer:(null!=e?e:[]).length-1}),m={trackTransformParams:n,peerId:String(c(this,Cf,"f").id),label:this.getLabel(),maxSpatialLayer:h,encodings:f,codecOptions:t,preferredCodec:r,codec:p,keyFrameRequestDelay:i},g=yield null===(s=c(this,Pf,"f").sendTransport)||void 0===s?void 0:s.produce({track:this.mediaStreamTrack,encodings:f,codecOptions:t,codec:p,stopTracks:!1,disableTrackOnPause:!0,zeroRtpOnPause:!0,appData:m});if(!g)return;const v=g.rtpSender,y=()=>/Safari/i.test(navigator.userAgent);if(e&&v&&y()){const t=v.getParameters();e.forEach((({maxBitrate:e,scaleResolutionDownBy:r},n)=>{t.encodings[n]&&(t.encodings[n].maxBitrate=e,t.encodings[n].scaleResolutionDownBy=r)})),yield v.setParameters(t)}this.setProducer(g),(null===(d=null===(o=this.producer)||void 0===o?void 0:o.track)||void 0===d?void 0:d.id)!==c(this,Sf,"f").id&&(this.logger.info("Producer initialized with old track, updating",{oldTrackId:null===(l=null===(u=this.producer)||void 0===u?void 0:u.track)||void 0===l?void 0:l.id,newTrackId:c(this,Sf,"f").id}),yield this.replaceTrack(c(this,Sf,"f"))),"video"===this.kind&&(e&&v&&p&&Kn(p.mimeType)&&!y()?yield v.setParameters(Object.assign(Object.assign({},v.getParameters()),{encodings:this.prepareProducerEncodings({encodings:e,codec:p,maxSpatialLayer:h})})):yield g.setMaxSpatialLayer(h),yield c(this,Tf,"f").request(Sn,{producerId:g.id,maxSpatialLayer:h})),"audio"===this.kind&&(yield this.setPriority("high")),this.logger.debug("produce()",{track:this.logCtx,encodings:e,codecOptions:t})}catch(e){throw this.logger.error("produce()",{error:e,track:this.logCtx}),new Error("Publish track failed")}}))}publish(){return a(this,void 0,void 0,(function*(){yield this.produce({}),this.internalEventEmitter.emit(tn.trackProduced,this)}))}unpublish(e=!0){return a(this,void 0,void 0,(function*(){try{e&&this.stopMediaStreamTrack(),this.internalEventEmitter.emit(tn.trackUnproduced,this),this.producer&&(yield this.closeProducer()),d(this,Df,!0,"f"),this.logger.debug("unpublish()",{track:this.logCtx})}catch(e){this.logger.error("unpublish()",{error:e})}}))}pauseRemoteProducer(e){return a(this,void 0,void 0,(function*(){return c(this,Tf,"f").request(vn,{producerId:e})}))}resumeRemoteProducer(e){return a(this,void 0,void 0,(function*(){return c(this,Tf,"f").request(yn,{producerId:e})}))}mute(e){return a(this,void 0,void 0,(function*(){yield c(this,Lf,"f").waitForUnlock();const t=yield c(this,Lf,"f").acquire();if(this.producer)try{if(this.producer.pause(),this.logger.debug("pause()",{track:this.logCtx}),c(this,Of,"f"))return null==e||e(),c(this,Sf,"f").stop(),this.stopOriginalTrack(),this.internalEventEmitter.emit(tn.trackClosed,this),void(yield this.pauseRemoteProducer(this.producer.id));yield this.pauseRemoteProducer(this.producer.id),this.internalEventEmitter.emit(tn.trackPaused,this)}catch(e){throw this.logger.error("pause()",{error:e,track:this.logCtx}),yield c(this,Rf,"f").deleteTrack(this),this.internalEventEmitter.emit(tn.trackFailed,this),new Error("Can`t pause track, removing")}finally{t()}else this.logger.warn("pause()",{message:"Track is not published",track:this.logCtx})}))}resume(){return a(this,void 0,void 0,(function*(){yield c(this,Lf,"f").waitForUnlock();const e=yield c(this,Lf,"f").acquire();if(this.producer)try{if(this.logger.debug("resume()",{track:this.logCtx}),c(this,Of,"f"))return yield this.reopenMediaStreamTrack(),yield this.resumeProducer(),void this.internalEventEmitter.emit(tn.trackReopened,this);yield this.resumeProducer(),this.internalEventEmitter.emit(tn.trackResumed,this)}catch(e){throw this.logger.error("resume()",{error:e,track:this.logCtx}),new Error("Can`t resume track")}finally{e()}else this.logger.warn("resume()",{message:"Track is not published",track:this.logCtx})}))}getInfo(){return a(this,void 0,void 0,(function*(){const{width:e,height:t,frameRate:r,aspectRatio:n}=c(this,Sf,"f").getSettings();return{trackId:c(this,Sf,"f").id,readyState:c(this,Sf,"f").readyState,kind:this.kind,label:this.label,width:e,height:t,frameRate:r,aspectRatio:n,paused:this.isPaused,trackOutboundStats:yield this.getStats()}}))}getStats(){var e,t,r,n,i;return a(this,void 0,void 0,(function*(){try{return{producerId:null===(e=this.producer)||void 0===e?void 0:e.id,codec:null===(t=this.producer)||void 0===t?void 0:t.rtpParameters.codecs.find((e=>bf(e))),dtlsState:null===(i=null===(n=null===(r=this.producer)||void 0===r?void 0:r.rtpSender)||void 0===n?void 0:n.transport)||void 0===i?void 0:i.state,rtcStats:yield this.getOutboundRTPStreamStats()}}catch(e){return void this.logger.debug("getStats()",{error:e})}}))}replaceTrack(e){var t;return a(this,void 0,void 0,(function*(){try{d(this,Sf,e,"f"),this.internalEventEmitter.emit(tn.trackReopened,this),this.observer.safeEmit("track-changed",{track:e}),yield null===(t=this.producer)||void 0===t?void 0:t.replaceTrack({track:e}),d(this,Af,new zf({track:e,statsHandler:c(this,jf,"f")}),"f")}catch(e){this.logger.warn("replaceTrack()",{error:e})}}))}resumeProducer(){return a(this,void 0,void 0,(function*(){this.producer?(yield this.resumeRemoteProducer(this.producer.id),this.producer.resume()):this.logger.debug("resumeProducer()",{message:"Track not produced yet",track:this.logCtx})}))}reopenMediaStreamTrack(){var e;return a(this,void 0,void 0,(function*(){const t=yield c(this,If,"f").createMediaStreamTrack({label:this.label,constraints:c(this,Mf,"f")});d(this,Sf,t,"f"),yield null===(e=this.producer)||void 0===e?void 0:e.replaceTrack({track:t})}))}prepareProducerEncodings(e){const{encodings:t,codec:r,maxSpatialLayer:n}=e;return t&&t.length>1&&r&&Kn(r.mimeType)?[t[n]||t[0]]:t}getOutboundRTPStreamStats(){return new Promise(((e,t)=>{const r=(n=0)=>a(this,void 0,void 0,(function*(){if(!this.producer)throw new Error("Producer is missed");try{const i=yield this.producer.getStats(),s=Array.from(i.values()).find((e=>"outbound-rtp"===e.type));if(!s&&n<5)return void setTimeout((()=>r(n+1)),150);n>=5&&!s&&t(new Error("OutboundRTPStreamStat not exist")),e(s)}catch(e){t(new Error("Can not get RTCStatsReport")),this.logger.debug("getOutboundRTPStreamStats()",{error:e})}}));r()}))}}Sf=new WeakMap,kf=new WeakMap,Cf=new WeakMap,Rf=new WeakMap,Pf=new WeakMap,Tf=new WeakMap,Ef=new WeakMap,Df=new WeakMap,Mf=new WeakMap,If=new WeakMap,xf=new WeakMap,Of=new WeakMap,Lf=new WeakMap,Af=new WeakMap,jf=new WeakMap;class Hf extends Vf{constructor(e){super(e),this.transformParams={},Ff.set(this,void 0),Nf.set(this,void 0),Bf.set(this,!1),Wf.set(this,(()=>{})),d(this,Nf,e,"f")}get logCtx(){return{label:this.getLabel(),id:this.id,kind:this.kind,producerId:this.producerId,paused:this.isPaused,published:this.isPublished,isEffectsProcessing:this.isEffectsProcessing}}get isEffectsProcessing(){return Boolean(c(this,Ff,"f"))}getEncoderConfig(){return this.encoderConfig}getCodecOptions(){return{videoGoogleStartBitrate:this.getEncoderConfig().videoGoogleStartBitrate||1e3}}getPreferredCodec(){const{preferredCodec:e}=this.getEncoderConfig();return e||(this.getLabel()===Zn.ScreenVideo?"vp8":"h264")}getEncodings(){return this.getEncoderConfig().encodings||Ll}setTransformParams(e){this.transformParams=e}setMaxSpatialLayer(e){return a(this,void 0,void 0,(function*(){const t=this.getProducer();t?(yield t.setMaxSpatialLayer(e),this.logger.debug("setMaxSpatialLayer()",{label:this.getLabel(),spatialLayer:e})):this.logger.warn("setMaxSpatialLayer()",{message:"Not produced yet"})}))}getMaxSpatialLayer(){const e=this.getProducer();if(e)return e.maxSpatialLayer;this.logger.warn("getMaxSpatialLayer()",{message:"Not produced yet"})}enableEffects(){return a(this,void 0,void 0,(function*(){if(!c(this,Bf,"f")){d(this,Bf,!0,"f");try{if(c(this,Ff,"f"))return this.logger.debug("enableEffects()",{description:"Track is already processed"}),void d(this,Bf,!1,"f");if("ended"===this.mediaStreamTrack.readyState)return void this.logger.warn("Track already ended",{case:"enableEffects"});const{media:e}=c(this,Nf,"f");if(!e.effectsSDKInitialized)return void this.logger.warn("Effects SDK not initialized",{case:"enableEffects"});const t=Date.now();d(this,Ff,yield e.createEffectsSDKTrackProcessor(this.getLabel()),"f"),this.setOriginalTrack();const r=yield c(this,Ff,"f").processTrack(this.mediaStreamTrack),n=Date.now();this.logger.info("enableEffects() time",{time:(n-t)/1e3}),yield this.replaceTrack(r),this.logger.info("enableEffects()",{track:this.logCtx})}catch(e){this.logger.warn("enableEffects()",{track:this.logCtx,error:mr(e)}),this.disableEffects().catch((e=>{this.logger.warn("Failed to this.disableEffects() in catch{}",{track:this.logCtx,error:mr(e)})})),c(this,Wf,"f").call(this,e)}finally{d(this,Bf,!1,"f")}}}))}disableEffects(){var e;return a(this,void 0,void 0,(function*(){try{if(!c(this,Ff,"f"))return void this.logger.debug("disableEffects()",{description:"Track is not processed"});this.originalTrack?yield this.replaceTrack(this.originalTrack):this.logger.warn("disableEffects()",{description:"Original track missing"}),null===(e=c(this,Ff,"f"))||void 0===e||e.stopProcessing(),d(this,Ff,void 0,"f"),this.logger.info("disableEffects()",{track:this.logCtx})}catch(e){this.logger.warn("disableEffects()",{track:this.logCtx,error:e})}}))}publish(e={}){var t;return a(this,void 0,void 0,(function*(){yield this.produce({encodings:this.getEncodings(),preferredCodec:this.getPreferredCodec(),transformParams:this.transformParams,codecOptions:this.getCodecOptions(),keyFrameRequestDelay:null!==(t=e.keyFrameRequestDelay)&&void 0!==t?t:0}),this.internalEventEmitter.emit(tn.trackProduced,this)}))}adjustEncodingPresetToCurrentMaxSpatialLayer(e){return a(this,void 0,void 0,(function*(){if(!Kn(this.getPreferredCodec()))return;const{rtpSender:t}=this.getProducer()||{};if(!t)return void this.logger.warn("No rtpSender found in producer to change encodings",{maxSpatialLayer:e,trackId:this.id,producerId:this.producerId});const{encodings:r=[]}=this.getEncoderConfig(),n=r[e];if(!n)return void this.logger.warn("Skipping RTPSender params update. No target encoding found",{initialEncodings:r});this.logger.debug("Adjusting encoding parameters to max spatial layer",{targetEncoding:n,maxSpatialLayer:e});const i=t.getParameters();yield t.setParameters(Object.assign(Object.assign({},i),{encodings:[Object.assign(Object.assign({},i.encodings[0]),n)]}))}))}applyEffects(e){var t;return a(this,void 0,void 0,(function*(){try{!this.isEffectsProcessing&&Object.keys(e).length>0&&(yield this.enableEffects()),null===(t=c(this,Ff,"f"))||void 0===t||t.updateEffects(e)}catch(e){c(this,Wf,"f").call(this,e)}}))}resetEffects(){var e;return a(this,void 0,void 0,(function*(){null===(e=c(this,Ff,"f"))||void 0===e||e.updateEffects({})}))}setOnLoadModels(e){var t;null===(t=c(this,Ff,"f"))||void 0===t||t.setOnLoadModels(e)}get modelsLoadProgress(){var e;return(null===(e=c(this,Ff,"f"))||void 0===e?void 0:e.modelsLoadProgress)||0}pause(){return a(this,void 0,void 0,(function*(){yield this.mute((()=>{var e;c(this,Ff,"f")&&(null===(e=c(this,Ff,"f"))||void 0===e||e.stopProcessing(),d(this,Ff,void 0,"f"))}))}))}setOnEffectError(e){d(this,Wf,e,"f")}}Ff=new WeakMap,Nf=new WeakMap,Bf=new WeakMap,Wf=new WeakMap;let $f=class{constructor(e,t,r,n,i,s,o,a,c){this.eventsQueue=e,this.media=t,this.network=r,this.socket=n,this.myPeer=i,this.internalEventEmitter=s,this.peers=o,this.clientEventEmitter=a,qf.set(this,void 0),Uf.set(this,new hf),d(this,qf,c("MediasoupEvents"),"f")}subscribeToEvents(){const{connection:e}=this.socket;if(!e)throw c(this,qf,"f").error("subscribeToEvents()",{error:"Socket connection not initialized"}),new Error("Socket connection not initialized");this.eventsQueue.subscribeToSocket(e),this.eventsQueue.on(gn,(e=>{const t=this.peers.get(e.peerId);t&&t.observer.safeEmit(gn,e)})),this.eventsQueue.on(mn,(e=>{const t=this.peers.get(e.peerId);t&&t.observer.safeEmit(mn,e)})),this.eventsQueue.on(Pn,((e,t)=>{const r=this.peers.get(t);r&&r.observer.safeEmit(Pn,e)})),this.eventsQueue.on(En,((e,t)=>{const r=this.peers.get(t);r&&!r.isMe&&r.observer.safeEmit(En,e)})),this.eventsQueue.on(Tn,((e,t)=>{const r=this.peers.get(t);r&&!r.isMe&&r.observer.safeEmit(Tn,e)})),this.eventsQueue.on(Mn,(({peerId:e,spatialLayer:t,temporalLayer:r,consumerId:n})=>{const i=this.peers.get(e);i&&!i.isMe&&i.observer.safeEmit(Mn,{consumerId:n,spatialLayer:t,temporalLayer:r})})),this.eventsQueue.on(kn,(({producerId:e,spatialLayer:t})=>a(this,void 0,void 0,(function*(){yield c(this,Uf,"f").push((()=>a(this,void 0,void 0,(function*(){yield this.handleProducerSetMaxSpatialLayer({producerId:e,spatialLayer:t})}))),kn)})))),this.eventsQueue.on(Sn,(({peerId:e,producerId:t,spatialLayer:r})=>a(this,void 0,void 0,(function*(){const n=this.peers.get(e);n&&!n.isMe&&n.observer.safeEmit(Sn,{peerId:e,producerId:t,spatialLayer:r})})))),this.eventsQueue.on(jn,(({reason:e,transportId:t,direction:r,timeout:n})=>a(this,void 0,void 0,(function*(){const i=[this.network.receiveTransport,this.network.sendTransport].find((e=>(null==e?void 0:e.id)===t));i&&"connected"!==i.connectionState&&(c(this,qf,"f").warn(jn,{reason:e,transportId:t,direction:r,timeout:n}),this.clientEventEmitter.emit(Vr,{direction:r,reason:e}))})))),this.eventsQueue.on(bn,(({peerId:e,producerId:t})=>{const r=this.peers.get(e),n=null==r?void 0:r.producers.get(t);r&&n&&(n.paused=!0,r.observer.safeEmit(sn,{producerId:n.id,kind:n.kind,label:n.label,paused:n.paused}))})),this.eventsQueue.on(wn,(({peerId:e,producerId:t})=>{const r=this.peers.get(e),n=null==r?void 0:r.producers.get(t);r&&n&&(n.paused=!1,r.observer.safeEmit(on,{producerId:n.id,kind:n.kind,label:n.label,paused:n.paused}))})),this.eventsQueue.on(_n,(({label:e})=>a(this,void 0,void 0,(function*(){const t=this.media.getTrack(e);t&&(t.stopMediaStreamTrack(),this.internalEventEmitter.safeEmit(tn.trackClosed,t),this.clientEventEmitter.emit(Hr,{label:e}),yield this.media.deleteTrack(t))}))))}handleConsumerScoreEvent(e){try{const{peerId:t,consumerId:r,score:n}=JSON.parse(e),i=this.peers.get(t);if(!i)return;i.observer.safeEmit(Dn,{consumerId:r,score:n})}catch(t){c(this,qf,"f").error("Failed to handle consumer score event",{error:t,payload:e})}}removeEventListeners(){if(!this.eventsQueue)return;const e=[gn,mn,Pn,En,Tn,Mn,kn,Sn,jn,bn,wn,_n],{connection:t}=this.socket;this.eventsQueue.removeAllListeners(e,t)}reset(){this.removeEventListeners()}handleProducerSetMaxSpatialLayer({producerId:e,spatialLayer:t}){return a(this,void 0,void 0,(function*(){const r=this.media.getAllTracks().find((t=>{var r;return(null===(r=t.getProducer())||void 0===r?void 0:r.id)===e}));if(!r)return void c(this,qf,"f").warn("producerRequestMaxSpatialLayer()",{message:"Producer not found"});if(!(r instanceof Hf))return void c(this,qf,"f").warn("producerRequestMaxSpatialLayer()",{message:"Wrong producer kind"});const n=t||0,i=r.getMaxSpatialLayer();i!==n?(r.getEncodings().length>1&&(yield r.setMaxSpatialLayer(n)),yield this.socket.request(Sn,{producerId:e,maxSpatialLayer:n}),yield r.adjustEncodingPresetToCurrentMaxSpatialLayer(n)):c(this,qf,"f").debug("producerRequestMaxSpatialLayer()",{message:"Skip set max spatial layer",requestedSpatialLayer:n,currentMaxSpatialLayer:i})}))}};qf=new WeakMap,Uf=new WeakMap,$f=i([at(),s(0,dt(Yn.EventsQueue)),s(1,dt(Yn.Media)),s(2,dt(Yn.Network)),s(3,dt(Yn.SocketIO)),s(4,dt(Yn.Network)),s(5,dt(Yn.InternalEventEmitter)),s(6,dt(Yn.Peers)),s(7,dt(Yn.ClientEventEmitter)),s(8,dt(Yn.LoggerFactory)),o("design:paramtypes",[nf,fp,Kh,Hh,mp,Rt,Gh,Rt,Function])],$f);var Kf=$f,Gf={exports:{}},Qf=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},Jf=Qf,Yf=Object.prototype.toString;function Zf(e){return"[object Array]"===Yf.call(e)}function Xf(e){return void 0===e}function em(e){return null!==e&&"object"==typeof e}function tm(e){if("[object Object]"!==Yf.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function rm(e){return"[object Function]"===Yf.call(e)}function nm(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),Zf(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}var im={isArray:Zf,isArrayBuffer:function(e){return"[object ArrayBuffer]"===Yf.call(e)},isBuffer:function(e){return null!==e&&!Xf(e)&&null!==e.constructor&&!Xf(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:em,isPlainObject:tm,isUndefined:Xf,isDate:function(e){return"[object Date]"===Yf.call(e)},isFile:function(e){return"[object File]"===Yf.call(e)},isBlob:function(e){return"[object Blob]"===Yf.call(e)},isFunction:rm,isStream:function(e){return em(e)&&rm(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:nm,merge:function e(){var t={};function r(r,n){tm(t[n])&&tm(r)?t[n]=e(t[n],r):tm(r)?t[n]=e({},r):Zf(r)?t[n]=r.slice():t[n]=r}for(var n=0,i=arguments.length;n<i;n++)nm(arguments[n],r);return t},extend:function(e,t,r){return nm(t,(function(t,n){e[n]=r&&"function"==typeof t?Jf(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}},sm=im;function om(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var am=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(sm.isURLSearchParams(t))n=t.toString();else{var i=[];sm.forEach(t,(function(e,t){null!=e&&(sm.isArray(e)?t+="[]":e=[e],sm.forEach(e,(function(e){sm.isDate(e)?e=e.toISOString():sm.isObject(e)&&(e=JSON.stringify(e)),i.push(om(t)+"="+om(e))})))})),n=i.join("&")}if(n){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e},cm=im;function dm(){this.handlers=[]}dm.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},dm.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},dm.prototype.forEach=function(e){cm.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var um=dm,lm=im,pm=function(e,t,r,n,i){return e.config=t,r&&(e.code=r),e.request=n,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e},hm=pm,fm=function(e,t,r,n,i){var s=new Error(e);return hm(s,t,r,n,i)},mm=fm,gm=im,vm=gm.isStandardBrowserEnv()?{write:function(e,t,r,n,i,s){var o=[];o.push(e+"="+encodeURIComponent(t)),gm.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),gm.isString(n)&&o.push("path="+n),gm.isString(i)&&o.push("domain="+i),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},ym=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},bm=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},wm=im,_m=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],Sm=im,km=Sm.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=Sm.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0},Cm=im,Rm=function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(mm("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)},Pm=vm,Tm=am,Em=function(e,t){return e&&!ym(t)?bm(e,t):t},Dm=function(e){var t,r,n,i={};return e?(wm.forEach(e.split("\n"),(function(e){if(n=e.indexOf(":"),t=wm.trim(e.substr(0,n)).toLowerCase(),r=wm.trim(e.substr(n+1)),t){if(i[t]&&_m.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([r]):i[t]?i[t]+", "+r:r}})),i):i},Mm=km,Im=fm,xm=function(e){return new Promise((function(t,r){var n=e.data,i=e.headers,s=e.responseType;Cm.isFormData(n)&&delete i["Content-Type"];var o=new XMLHttpRequest;if(e.auth){var a=e.auth.username||"",c=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.Authorization="Basic "+btoa(a+":"+c)}var d=Em(e.baseURL,e.url);function u(){if(o){var n="getAllResponseHeaders"in o?Dm(o.getAllResponseHeaders()):null,i={data:s&&"text"!==s&&"json"!==s?o.response:o.responseText,status:o.status,statusText:o.statusText,headers:n,config:e,request:o};Rm(t,r,i),o=null}}if(o.open(e.method.toUpperCase(),Tm(d,e.params,e.paramsSerializer),!0),o.timeout=e.timeout,"onloadend"in o?o.onloadend=u:o.onreadystatechange=function(){o&&4===o.readyState&&(0!==o.status||o.responseURL&&0===o.responseURL.indexOf("file:"))&&setTimeout(u)},o.onabort=function(){o&&(r(Im("Request aborted",e,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(Im("Network Error",e,null,o)),o=null},o.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(Im(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",o)),o=null},Cm.isStandardBrowserEnv()){var l=(e.withCredentials||Mm(d))&&e.xsrfCookieName?Pm.read(e.xsrfCookieName):void 0;l&&(i[e.xsrfHeaderName]=l)}"setRequestHeader"in o&&Cm.forEach(i,(function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete i[t]:o.setRequestHeader(t,e)})),Cm.isUndefined(e.withCredentials)||(o.withCredentials=!!e.withCredentials),s&&"json"!==s&&(o.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&o.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&o.upload&&o.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){o&&(o.abort(),r(e),o=null)})),n||(n=null),o.send(n)}))},Om=im,Lm=function(e,t){lm.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},Am=pm,jm={"Content-Type":"application/x-www-form-urlencoded"};function Fm(e,t){!Om.isUndefined(e)&&Om.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var Nm,Bm={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(Nm=xm),Nm),transformRequest:[function(e,t){return Lm(t,"Accept"),Lm(t,"Content-Type"),Om.isFormData(e)||Om.isArrayBuffer(e)||Om.isBuffer(e)||Om.isStream(e)||Om.isFile(e)||Om.isBlob(e)?e:Om.isArrayBufferView(e)?e.buffer:Om.isURLSearchParams(e)?(Fm(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):Om.isObject(e)||t&&"application/json"===t["Content-Type"]?(Fm(t,"application/json"),function(e,t,r){if(Om.isString(e))try{return(t||JSON.parse)(e),Om.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||n&&Om.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw Am(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};Bm.headers={common:{Accept:"application/json, text/plain, */*"}},Om.forEach(["delete","get","head"],(function(e){Bm.headers[e]={}})),Om.forEach(["post","put","patch"],(function(e){Bm.headers[e]=Om.merge(jm)}));var Wm=Bm,qm=im,Um=Wm,zm=function(e){return!(!e||!e.__CANCEL__)},Vm=im,Hm=function(e,t,r){var n=this||Um;return qm.forEach(r,(function(r){e=r.call(n,e,t)})),e},$m=zm,Km=Wm;function Gm(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var Qm=im,Jm=function(e,t){t=t||{};var r={},n=["url","method","data"],i=["headers","auth","proxy","params"],s=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],o=["validateStatus"];function a(e,t){return Qm.isPlainObject(e)&&Qm.isPlainObject(t)?Qm.merge(e,t):Qm.isPlainObject(t)?Qm.merge({},t):Qm.isArray(t)?t.slice():t}function c(n){Qm.isUndefined(t[n])?Qm.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(e[n],t[n])}Qm.forEach(n,(function(e){Qm.isUndefined(t[e])||(r[e]=a(void 0,t[e]))})),Qm.forEach(i,c),Qm.forEach(s,(function(n){Qm.isUndefined(t[n])?Qm.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(void 0,t[n])})),Qm.forEach(o,(function(n){n in t?r[n]=a(e[n],t[n]):n in e&&(r[n]=a(void 0,e[n]))}));var d=n.concat(i).concat(s).concat(o),u=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===d.indexOf(e)}));return Qm.forEach(u,c),r},Ym={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}]},Zm={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){Zm[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var Xm={},eg=Ym.version.split(".");function tg(e,t){for(var r=t?t.split("."):eg,n=e.split("."),i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}Zm.transitional=function(e,t,r){var n=t&&tg(t);function i(e,t){return"[Axios v"+Ym.version+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,s,o){if(!1===e)throw new Error(i(s," has been removed in "+t));return n&&!Xm[s]&&(Xm[s]=!0,console.warn(i(s," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,s,o)}};var rg={isOlderVersion:tg,assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),i=n.length;i-- >0;){var s=n[i],o=t[s];if(o){var a=e[s],c=void 0===a||o(a,s,e);if(!0!==c)throw new TypeError("option "+s+" must be "+c)}else if(!0!==r)throw Error("Unknown option "+s)}},validators:Zm},ng=im,ig=am,sg=um,og=function(e){return Gm(e),e.headers=e.headers||{},e.data=Hm.call(e,e.data,e.headers,e.transformRequest),e.headers=Vm.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Vm.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||Km.adapter)(e).then((function(t){return Gm(e),t.data=Hm.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return $m(t)||(Gm(e),t&&t.response&&(t.response.data=Hm.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},ag=Jm,cg=rg,dg=cg.validators;function ug(e){this.defaults=e,this.interceptors={request:new sg,response:new sg}}ug.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=ag(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&cg.assertOptions(t,{silentJSONParsing:dg.transitional(dg.boolean,"1.0.0"),forcedJSONParsing:dg.transitional(dg.boolean,"1.0.0"),clarifyTimeoutError:dg.transitional(dg.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var i,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!n){var o=[og,void 0];for(Array.prototype.unshift.apply(o,r),o=o.concat(s),i=Promise.resolve(e);o.length;)i=i.then(o.shift(),o.shift());return i}for(var a=e;r.length;){var c=r.shift(),d=r.shift();try{a=c(a)}catch(e){d(e);break}}try{i=og(a)}catch(e){return Promise.reject(e)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},ug.prototype.getUri=function(e){return e=ag(this.defaults,e),ig(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},ng.forEach(["delete","get","head","options"],(function(e){ug.prototype[e]=function(t,r){return this.request(ag(r||{},{method:e,url:t,data:(r||{}).data}))}})),ng.forEach(["post","put","patch"],(function(e){ug.prototype[e]=function(t,r,n){return this.request(ag(n||{},{method:e,url:t,data:r}))}}));var lg=ug;function pg(e){this.message=e}pg.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},pg.prototype.__CANCEL__=!0;var hg=pg,fg=hg;function mg(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new fg(e),t(r.reason))}))}mg.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},mg.source=function(){var e,t=new mg((function(t){e=t}));return{token:t,cancel:e}};var gg=mg,vg=im,yg=Qf,bg=lg,wg=Jm;function _g(e){var t=new bg(e),r=yg(bg.prototype.request,t);return vg.extend(r,bg.prototype,t),vg.extend(r,t),r}var Sg=_g(Wm);Sg.Axios=bg,Sg.create=function(e){return _g(wg(Sg.defaults,e))},Sg.Cancel=hg,Sg.CancelToken=gg,Sg.isCancel=zm,Sg.all=function(e){return Promise.all(e)},Sg.spread=function(e){return function(t){return e.apply(null,t)}},Sg.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},Gf.exports=Sg,Gf.exports.default=Sg;var kg=Gf.exports,Cg="undefined"!=typeof Symbol&&Symbol,Rg=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(e,t);if(42!==i.value||!0!==i.enumerable)return!1}return!0},Pg="Function.prototype.bind called on incompatible ",Tg=Array.prototype.slice,Eg=Object.prototype.toString,Dg=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==Eg.call(t))throw new TypeError(Pg+t);for(var r,n=Tg.call(arguments,1),i=function(){if(this instanceof r){var i=t.apply(this,n.concat(Tg.call(arguments)));return Object(i)===i?i:this}return t.apply(e,n.concat(Tg.call(arguments)))},s=Math.max(0,t.length-n.length),o=[],a=0;a<s;a++)o.push("$"+a);if(r=Function("binder","return function ("+o.join(",")+"){ return binder.apply(this,arguments); }")(i),t.prototype){var c=function(){};c.prototype=t.prototype,r.prototype=new c,c.prototype=null}return r},Mg=Function.prototype.bind||Dg,Ig=Mg.call(Function.call,Object.prototype.hasOwnProperty),xg=SyntaxError,Og=Function,Lg=TypeError,Ag=function(e){try{return Og('"use strict"; return ('+e+").constructor;")()}catch(e){}},jg=Object.getOwnPropertyDescriptor;if(jg)try{jg({},"")}catch(_t){jg=null}var Fg=function(){throw new Lg},Ng=jg?function(){try{return Fg}catch(e){try{return jg(arguments,"callee").get}catch(e){return Fg}}}():Fg,Bg="function"==typeof Cg&&"function"==typeof Symbol&&"symbol"==typeof Cg("foo")&&"symbol"==typeof Symbol("bar")&&Rg(),Wg=Object.getPrototypeOf||function(e){return e.__proto__},qg={},Ug="undefined"==typeof Uint8Array?undefined:Wg(Uint8Array),zg={"%AggregateError%":"undefined"==typeof AggregateError?undefined:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?undefined:ArrayBuffer,"%ArrayIteratorPrototype%":Bg?Wg([][Symbol.iterator]()):undefined,"%AsyncFromSyncIteratorPrototype%":undefined,"%AsyncFunction%":qg,"%AsyncGenerator%":qg,"%AsyncGeneratorFunction%":qg,"%AsyncIteratorPrototype%":qg,"%Atomics%":"undefined"==typeof Atomics?undefined:Atomics,"%BigInt%":"undefined"==typeof BigInt?undefined:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?undefined:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?undefined:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?undefined:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?undefined:FinalizationRegistry,"%Function%":Og,"%GeneratorFunction%":qg,"%Int8Array%":"undefined"==typeof Int8Array?undefined:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?undefined:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?undefined:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Bg?Wg(Wg([][Symbol.iterator]())):undefined,"%JSON%":"object"==typeof JSON?JSON:undefined,"%Map%":"undefined"==typeof Map?undefined:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&Bg?Wg((new Map)[Symbol.iterator]()):undefined,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?undefined:Promise,"%Proxy%":"undefined"==typeof Proxy?undefined:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?undefined:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?undefined:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&Bg?Wg((new Set)[Symbol.iterator]()):undefined,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?undefined:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Bg?Wg(""[Symbol.iterator]()):undefined,"%Symbol%":Bg?Symbol:undefined,"%SyntaxError%":xg,"%ThrowTypeError%":Ng,"%TypedArray%":Ug,"%TypeError%":Lg,"%Uint8Array%":"undefined"==typeof Uint8Array?undefined:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?undefined:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?undefined:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?undefined:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?undefined:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?undefined:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?undefined:WeakSet},Vg=function e(t){var r;if("%AsyncFunction%"===t)r=Ag("async function () {}");else if("%GeneratorFunction%"===t)r=Ag("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=Ag("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&(r=Wg(i.prototype))}return zg[t]=r,r},Hg={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},$g=Mg,Kg=Ig,Gg=$g.call(Function.call,Array.prototype.concat),Qg=$g.call(Function.apply,Array.prototype.splice),Jg=$g.call(Function.call,String.prototype.replace),Yg=$g.call(Function.call,String.prototype.slice),Zg=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Xg=/\\(\\)?/g,ev=function(e){var t=Yg(e,0,1),r=Yg(e,-1);if("%"===t&&"%"!==r)throw new xg("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new xg("invalid intrinsic syntax, expected opening `%`");var n=[];return Jg(e,Zg,(function(e,t,r,i){n[n.length]=r?Jg(i,Xg,"$1"):t||e})),n},tv=function(e,t){var r,n=e;if(Kg(Hg,n)&&(n="%"+(r=Hg[n])[0]+"%"),Kg(zg,n)){var i=zg[n];if(i===qg&&(i=Vg(n)),void 0===i&&!t)throw new Lg("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new xg("intrinsic "+e+" does not exist!")},rv=function(e,t){if("string"!=typeof e||0===e.length)throw new Lg("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new Lg('"allowMissing" argument must be a boolean');var r=ev(e),n=r.length>0?r[0]:"",i=tv("%"+n+"%",t),s=i.name,o=i.value,a=!1,c=i.alias;c&&(n=c[0],Qg(r,Gg([0,1],c)));for(var d=1,u=!0;d<r.length;d+=1){var l=r[d],p=Yg(l,0,1),h=Yg(l,-1);if(('"'===p||"'"===p||"`"===p||'"'===h||"'"===h||"`"===h)&&p!==h)throw new xg("property names with quotes must have matching quotes");if("constructor"!==l&&u||(a=!0),Kg(zg,s="%"+(n+="."+l)+"%"))o=zg[s];else if(null!=o){if(!(l in o)){if(!t)throw new Lg("base intrinsic for "+e+" exists, but the property is not available.");return}if(jg&&d+1>=r.length){var f=jg(o,l);o=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:o[l]}else u=Kg(o,l),o=o[l];u&&!a&&(zg[s]=o)}}return o},nv={exports:{}};!function(e){var t=Mg,r=rv,n=r("%Function.prototype.apply%"),i=r("%Function.prototype.call%"),s=r("%Reflect.apply%",!0)||t.call(i,n),o=r("%Object.getOwnPropertyDescriptor%",!0),a=r("%Object.defineProperty%",!0),c=r("%Math.max%");if(a)try{a({},"a",{value:1})}catch(e){a=null}e.exports=function(e){var r=s(t,i,arguments);if(o&&a){var n=o(r,"length");n.configurable&&a(r,"length",{value:1+c(0,e.length-(arguments.length-1))})}return r};var d=function(){return s(t,n,arguments)};a?a(e.exports,"apply",{value:d}):e.exports.apply=d}(nv);var iv=rv,sv=nv.exports,ov=sv(iv("String.prototype.indexOf")),av=h(Object.freeze({__proto__:null,default:{}})),cv="function"==typeof Map&&Map.prototype,dv=Object.getOwnPropertyDescriptor&&cv?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,uv=cv&&dv&&"function"==typeof dv.get?dv.get:null,lv=cv&&Map.prototype.forEach,pv="function"==typeof Set&&Set.prototype,hv=Object.getOwnPropertyDescriptor&&pv?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,fv=pv&&hv&&"function"==typeof hv.get?hv.get:null,mv=pv&&Set.prototype.forEach,gv="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,vv="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,yv="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,bv=Boolean.prototype.valueOf,wv=Object.prototype.toString,_v=Function.prototype.toString,Sv=String.prototype.match,kv="function"==typeof BigInt?BigInt.prototype.valueOf:null,Cv=Object.getOwnPropertySymbols,Rv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,Pv="function"==typeof Symbol&&"object"==typeof Symbol.iterator,Tv=Object.prototype.propertyIsEnumerable,Ev=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null),Dv=av.custom,Mv=Dv&&Av(Dv)?Dv:null,Iv="function"==typeof Symbol&&void 0!==Symbol.toStringTag?Symbol.toStringTag:null;function xv(e,t,r){var n="double"===(r.quoteStyle||t)?'"':"'";return n+e+n}function Ov(e){return String(e).replace(/"/g,""")}function Lv(e){return!("[object Array]"!==Nv(e)||Iv&&"object"==typeof e&&Iv in e)}function Av(e){if(Pv)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Rv)return!1;try{return Rv.call(e),!0}catch(e){}return!1}var jv=Object.prototype.hasOwnProperty||function(e){return e in this};function Fv(e,t){return jv.call(e,t)}function Nv(e){return wv.call(e)}function Bv(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;r<n;r++)if(e[r]===t)return r;return-1}function Wv(e,t){if(e.length>t.maxStringLength){var r=e.length-t.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return Wv(e.slice(0,t.maxStringLength),t)+n}return xv(e.replace(/(['\\])/g,"\\$1").replace(/[\x00-\x1f]/g,qv),"single",t)}function qv(e){var t=e.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return r?"\\"+r:"\\x"+(t<16?"0":"")+t.toString(16).toUpperCase()}function Uv(e){return"Object("+e+")"}function zv(e){return e+" { ? }"}function Vv(e,t,r,n){return e+" ("+t+") {"+(n?Hv(r,n):r.join(", "))+"}"}function Hv(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+e.join(","+r)+"\n"+t.prev}function $v(e,t){var r=Lv(e),n=[];if(r){n.length=e.length;for(var i=0;i<e.length;i++)n[i]=Fv(e,i)?t(e[i],e):""}var s,o="function"==typeof Cv?Cv(e):[];if(Pv){s={};for(var a=0;a<o.length;a++)s["$"+o[a]]=o[a]}for(var c in e)Fv(e,c)&&(r&&String(Number(c))===c&&c<e.length||Pv&&s["$"+c]instanceof Symbol||(/[^\w$]/.test(c)?n.push(t(c,e)+": "+t(e[c],e)):n.push(c+": "+t(e[c],e))));if("function"==typeof Cv)for(var d=0;d<o.length;d++)Tv.call(e,o[d])&&n.push("["+t(o[d])+"]: "+t(e[o[d]],e));return n}var Kv=rv,Gv=function(e,t){var r=iv(e,!!t);return"function"==typeof r&&ov(e,".prototype.")>-1?sv(r):r},Qv=function e(t,r,n,i){var s=r||{};if(Fv(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Fv(s,"maxStringLength")&&("number"==typeof s.maxStringLength?s.maxStringLength<0&&s.maxStringLength!==1/0:null!==s.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=!Fv(s,"customInspect")||s.customInspect;if("boolean"!=typeof o&&"symbol"!==o)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Fv(s,"indent")&&null!==s.indent&&"\t"!==s.indent&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('options "indent" must be "\\t", an integer > 0, or `null`');if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return Wv(t,s);if("number"==typeof t)return 0===t?1/0/t>0?"0":"-0":String(t);if("bigint"==typeof t)return String(t)+"n";var a=void 0===s.depth?5:s.depth;if(void 0===n&&(n=0),n>=a&&a>0&&"object"==typeof t)return Lv(t)?"[Array]":"[Object]";var c=function(e,t){var r;if("\t"===e.indent)r="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;r=Array(e.indent+1).join(" ")}return{base:r,prev:Array(t+1).join(r)}}(s,n);if(void 0===i)i=[];else if(Bv(i,t)>=0)return"[Circular]";function d(t,r,o){if(r&&(i=i.slice()).push(r),o){var a={depth:s.depth};return Fv(s,"quoteStyle")&&(a.quoteStyle=s.quoteStyle),e(t,a,n+1,i)}return e(t,s,n+1,i)}if("function"==typeof t){var u=function(e){if(e.name)return e.name;var t=Sv.call(_v.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),l=$v(t,d);return"[Function"+(u?": "+u:" (anonymous)")+"]"+(l.length>0?" { "+l.join(", ")+" }":"")}if(Av(t)){var p=Pv?String(t).replace(/^(Symbol\(.*\))_[^)]*$/,"$1"):Rv.call(t);return"object"!=typeof t||Pv?p:Uv(p)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var h="<"+String(t.nodeName).toLowerCase(),f=t.attributes||[],m=0;m<f.length;m++)h+=" "+f[m].name+"="+xv(Ov(f[m].value),"double",s);return h+=">",t.childNodes&&t.childNodes.length&&(h+="..."),h+="</"+String(t.nodeName).toLowerCase()+">"}if(Lv(t)){if(0===t.length)return"[]";var g=$v(t,d);return c&&!function(e){for(var t=0;t<e.length;t++)if(Bv(e[t],"\n")>=0)return!1;return!0}(g)?"["+Hv(g,c)+"]":"[ "+g.join(", ")+" ]"}if(function(e){return!("[object Error]"!==Nv(e)||Iv&&"object"==typeof e&&Iv in e)}(t)){var v=$v(t,d);return 0===v.length?"["+String(t)+"]":"{ ["+String(t)+"] "+v.join(", ")+" }"}if("object"==typeof t&&o){if(Mv&&"function"==typeof t[Mv])return t[Mv]();if("symbol"!==o&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!uv||!e||"object"!=typeof e)return!1;try{uv.call(e);try{fv.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var y=[];return lv.call(t,(function(e,r){y.push(d(r,t,!0)+" => "+d(e,t))})),Vv("Map",uv.call(t),y,c)}if(function(e){if(!fv||!e||"object"!=typeof e)return!1;try{fv.call(e);try{uv.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var b=[];return mv.call(t,(function(e){b.push(d(e,t))})),Vv("Set",fv.call(t),b,c)}if(function(e){if(!gv||!e||"object"!=typeof e)return!1;try{gv.call(e,gv);try{vv.call(e,vv)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return zv("WeakMap");if(function(e){if(!vv||!e||"object"!=typeof e)return!1;try{vv.call(e,vv);try{gv.call(e,gv)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return zv("WeakSet");if(function(e){if(!yv||!e||"object"!=typeof e)return!1;try{return yv.call(e),!0}catch(e){}return!1}(t))return zv("WeakRef");if(function(e){return!("[object Number]"!==Nv(e)||Iv&&"object"==typeof e&&Iv in e)}(t))return Uv(d(Number(t)));if(function(e){if(!e||"object"!=typeof e||!kv)return!1;try{return kv.call(e),!0}catch(e){}return!1}(t))return Uv(d(kv.call(t)));if(function(e){return!("[object Boolean]"!==Nv(e)||Iv&&"object"==typeof e&&Iv in e)}(t))return Uv(bv.call(t));if(function(e){return!("[object String]"!==Nv(e)||Iv&&"object"==typeof e&&Iv in e)}(t))return Uv(d(String(t)));if(!function(e){return!("[object Date]"!==Nv(e)||Iv&&"object"==typeof e&&Iv in e)}(t)&&!function(e){return!("[object RegExp]"!==Nv(e)||Iv&&"object"==typeof e&&Iv in e)}(t)){var w=$v(t,d),_=Ev?Ev(t)===Object.prototype:t instanceof Object||t.constructor===Object,S=t instanceof Object?"":"null prototype",k=!_&&Iv&&Object(t)===t&&Iv in t?Nv(t).slice(8,-1):S?"Object":"",C=(_||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(k||S?"["+[].concat(k||[],S||[]).join(": ")+"] ":"");return 0===w.length?C+"{}":c?C+"{"+Hv(w,c)+"}":C+"{ "+w.join(", ")+" }"}return String(t)},Jv=Kv("%TypeError%"),Yv=Kv("%WeakMap%",!0),Zv=Kv("%Map%",!0),Xv=Gv("WeakMap.prototype.get",!0),ey=Gv("WeakMap.prototype.set",!0),ty=Gv("WeakMap.prototype.has",!0),ry=Gv("Map.prototype.get",!0),ny=Gv("Map.prototype.set",!0),iy=Gv("Map.prototype.has",!0),sy=function(e,t){for(var r,n=e;null!==(r=n.next);n=r)if(r.key===t)return n.next=r.next,r.next=e.next,e.next=r,r},oy=String.prototype.replace,ay=/%20/g,cy="RFC3986",dy={default:cy,formatters:{RFC1738:function(e){return oy.call(e,ay,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:cy},uy=dy,ly=Object.prototype.hasOwnProperty,py=Array.isArray,hy=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),fy=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},n=0;n<e.length;++n)void 0!==e[n]&&(r[n]=e[n]);return r},my={arrayToObject:fy,assign:function(e,t){return Object.keys(t).reduce((function(e,r){return e[r]=t[r],e}),e)},combine:function(e,t){return[].concat(e,t)},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],n=0;n<t.length;++n)for(var i=t[n],s=i.obj[i.prop],o=Object.keys(s),a=0;a<o.length;++a){var c=o[a],d=s[c];"object"==typeof d&&null!==d&&-1===r.indexOf(d)&&(t.push({obj:s,prop:c}),r.push(d))}return function(e){for(;e.length>1;){var t=e.pop(),r=t.obj[t.prop];if(py(r)){for(var n=[],i=0;i<r.length;++i)void 0!==r[i]&&n.push(r[i]);t.obj[t.prop]=n}}}(t),e},decode:function(e,t,r){var n=e.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(e){return n}},encode:function(e,t,r,n,i){if(0===e.length)return e;var s=e;if("symbol"==typeof e?s=Symbol.prototype.toString.call(e):"string"!=typeof e&&(s=String(e)),"iso-8859-1"===r)return escape(s).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));for(var o="",a=0;a<s.length;++a){var c=s.charCodeAt(a);45===c||46===c||95===c||126===c||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||i===uy.RFC1738&&(40===c||41===c)?o+=s.charAt(a):c<128?o+=hy[c]:c<2048?o+=hy[192|c>>6]+hy[128|63&c]:c<55296||c>=57344?o+=hy[224|c>>12]+hy[128|c>>6&63]+hy[128|63&c]:(a+=1,c=65536+((1023&c)<<10|1023&s.charCodeAt(a)),o+=hy[240|c>>18]+hy[128|c>>12&63]+hy[128|c>>6&63]+hy[128|63&c])}return o},isBuffer:function(e){return!(!e||"object"!=typeof e)&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(py(e)){for(var r=[],n=0;n<e.length;n+=1)r.push(t(e[n]));return r}return t(e)},merge:function e(t,r,n){if(!r)return t;if("object"!=typeof r){if(py(t))t.push(r);else{if(!t||"object"!=typeof t)return[t,r];(n&&(n.plainObjects||n.allowPrototypes)||!ly.call(Object.prototype,r))&&(t[r]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(r);var i=t;return py(t)&&!py(r)&&(i=fy(t,n)),py(t)&&py(r)?(r.forEach((function(r,i){if(ly.call(t,i)){var s=t[i];s&&"object"==typeof s&&r&&"object"==typeof r?t[i]=e(s,r,n):t.push(r)}else t[i]=r})),t):Object.keys(r).reduce((function(t,i){var s=r[i];return ly.call(t,i)?t[i]=e(t[i],s,n):t[i]=s,t}),i)}},gy=function(){var e,t,r,n={assert:function(e){if(!n.has(e))throw new Jv("Side channel does not contain "+Qv(e))},get:function(n){if(Yv&&n&&("object"==typeof n||"function"==typeof n)){if(e)return Xv(e,n)}else if(Zv){if(t)return ry(t,n)}else if(r)return function(e,t){var r=sy(e,t);return r&&r.value}(r,n)},has:function(n){if(Yv&&n&&("object"==typeof n||"function"==typeof n)){if(e)return ty(e,n)}else if(Zv){if(t)return iy(t,n)}else if(r)return function(e,t){return!!sy(e,t)}(r,n);return!1},set:function(n,i){Yv&&n&&("object"==typeof n||"function"==typeof n)?(e||(e=new Yv),ey(e,n,i)):Zv?(t||(t=new Zv),ny(t,n,i)):(r||(r={key:{},next:null}),function(e,t,r){var n=sy(e,t);n?n.value=r:e.next={key:t,next:e.next,value:r}}(r,n,i))}};return n},vy=my,yy=dy,by=Object.prototype.hasOwnProperty,wy={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},_y=Array.isArray,Sy=String.prototype.split,ky=Array.prototype.push,Cy=function(e,t){ky.apply(e,_y(t)?t:[t])},Ry=Date.prototype.toISOString,Py=yy.default,Ty={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:vy.encode,encodeValuesOnly:!1,format:Py,formatter:yy.formatters[Py],indices:!1,serializeDate:function(e){return Ry.call(e)},skipNulls:!1,strictNullHandling:!1},Ey={},Dy=function e(t,r,n,i,s,o,a,c,d,u,l,p,h,f,m,g){for(var v=t,y=g,b=0,w=!1;void 0!==(y=y.get(Ey))&&!w;){var _=y.get(t);if(b+=1,void 0!==_){if(_===b)throw new RangeError("Cyclic object value");w=!0}void 0===y.get(Ey)&&(b=0)}if("function"==typeof c?v=c(r,v):v instanceof Date?v=l(v):"comma"===n&&_y(v)&&(v=vy.maybeMap(v,(function(e){return e instanceof Date?l(e):e}))),null===v){if(s)return a&&!f?a(r,Ty.encoder,m,"key",p):r;v=""}if(function(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||"symbol"==typeof e||"bigint"==typeof e}(v)||vy.isBuffer(v)){if(a){var S=f?r:a(r,Ty.encoder,m,"key",p);if("comma"===n&&f){for(var k=Sy.call(String(v),","),C="",R=0;R<k.length;++R)C+=(0===R?"":",")+h(a(k[R],Ty.encoder,m,"value",p));return[h(S)+(i&&_y(v)&&1===k.length?"[]":"")+"="+C]}return[h(S)+"="+h(a(v,Ty.encoder,m,"value",p))]}return[h(r)+"="+h(String(v))]}var P,T=[];if(void 0===v)return T;if("comma"===n&&_y(v))P=[{value:v.length>0?v.join(",")||null:void 0}];else if(_y(c))P=c;else{var E=Object.keys(v);P=d?E.sort(d):E}for(var D=i&&_y(v)&&1===v.length?r+"[]":r,M=0;M<P.length;++M){var I=P[M],x="object"==typeof I&&void 0!==I.value?I.value:v[I];if(!o||null!==x){var O=_y(v)?"function"==typeof n?n(D,I):D:D+(u?"."+I:"["+I+"]");g.set(t,b);var L=gy();L.set(Ey,g),Cy(T,e(x,O,n,i,s,o,a,c,d,u,l,p,h,f,m,L))}}return T},My=my,Iy=Object.prototype.hasOwnProperty,xy=Array.isArray,Oy={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:My.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},Ly=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},Ay=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},jy=function(e,t,r,n){if(e){var i=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,s=/(\[[^[\]]*])/g,o=r.depth>0&&/(\[[^[\]]*])/.exec(i),a=o?i.slice(0,o.index):i,c=[];if(a){if(!r.plainObjects&&Iy.call(Object.prototype,a)&&!r.allowPrototypes)return;c.push(a)}for(var d=0;r.depth>0&&null!==(o=s.exec(i))&&d<r.depth;){if(d+=1,!r.plainObjects&&Iy.call(Object.prototype,o[1].slice(1,-1))&&!r.allowPrototypes)return;c.push(o[1])}return o&&c.push("["+i.slice(o.index)+"]"),function(e,t,r,n){for(var i=n?t:Ay(t,r),s=e.length-1;s>=0;--s){var o,a=e[s];if("[]"===a&&r.parseArrays)o=[].concat(i);else{o=r.plainObjects?Object.create(null):{};var c="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,d=parseInt(c,10);r.parseArrays||""!==c?!isNaN(d)&&a!==c&&String(d)===c&&d>=0&&r.parseArrays&&d<=r.arrayLimit?(o=[])[d]=i:"__proto__"!==c&&(o[c]=i):o={0:i}}i=o}return i}(c,t,r,n)}},Fy=function(e,t){var r,n=e,i=function(e){if(!e)return Ty;if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");var t=e.charset||Ty.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=yy.default;if(void 0!==e.format){if(!by.call(yy.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n=yy.formatters[r],i=Ty.filter;return("function"==typeof e.filter||_y(e.filter))&&(i=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:Ty.addQueryPrefix,allowDots:void 0===e.allowDots?Ty.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Ty.charsetSentinel,delimiter:void 0===e.delimiter?Ty.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:Ty.encode,encoder:"function"==typeof e.encoder?e.encoder:Ty.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:Ty.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:Ty.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:Ty.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Ty.strictNullHandling}}(t);"function"==typeof i.filter?n=(0,i.filter)("",n):_y(i.filter)&&(r=i.filter);var s,o=[];if("object"!=typeof n||null===n)return"";s=t&&t.arrayFormat in wy?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var a=wy[s];if(t&&"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var c="comma"===a&&t&&t.commaRoundTrip;r||(r=Object.keys(n)),i.sort&&r.sort(i.sort);for(var d=gy(),u=0;u<r.length;++u){var l=r[u];i.skipNulls&&null===n[l]||Cy(o,Dy(n[l],l,a,c,i.strictNullHandling,i.skipNulls,i.encode?i.encoder:null,i.filter,i.sort,i.allowDots,i.serializeDate,i.format,i.formatter,i.encodeValuesOnly,i.charset,d))}var p=o.join(i.delimiter),h=!0===i.addQueryPrefix?"?":"";return i.charsetSentinel&&("iso-8859-1"===i.charset?h+="utf8=%26%2310003%3B&":h+="utf8=%E2%9C%93&"),p.length>0?h+p:""},Ny=function(e,t){var r=function(e){if(!e)return Oy;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?Oy.charset:e.charset;return{allowDots:void 0===e.allowDots?Oy.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:Oy.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:Oy.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:Oy.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:Oy.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:Oy.comma,decoder:"function"==typeof e.decoder?e.decoder:Oy.decoder,delimiter:"string"==typeof e.delimiter||My.isRegExp(e.delimiter)?e.delimiter:Oy.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:Oy.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:Oy.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:Oy.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:Oy.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:Oy.strictNullHandling}}(t);if(""===e||null==e)return r.plainObjects?Object.create(null):{};for(var n="string"==typeof e?function(e,t){var r,n={},i=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,s=t.parameterLimit===1/0?void 0:t.parameterLimit,o=i.split(t.delimiter,s),a=-1,c=t.charset;if(t.charsetSentinel)for(r=0;r<o.length;++r)0===o[r].indexOf("utf8=")&&("utf8=%E2%9C%93"===o[r]?c="utf-8":"utf8=%26%2310003%3B"===o[r]&&(c="iso-8859-1"),a=r,r=o.length);for(r=0;r<o.length;++r)if(r!==a){var d,u,l=o[r],p=l.indexOf("]="),h=-1===p?l.indexOf("="):p+1;-1===h?(d=t.decoder(l,Oy.decoder,c,"key"),u=t.strictNullHandling?null:""):(d=t.decoder(l.slice(0,h),Oy.decoder,c,"key"),u=My.maybeMap(Ay(l.slice(h+1),t),(function(e){return t.decoder(e,Oy.decoder,c,"value")}))),u&&t.interpretNumericEntities&&"iso-8859-1"===c&&(u=Ly(u)),l.indexOf("[]=")>-1&&(u=xy(u)?[u]:u),Iy.call(n,d)?n[d]=My.combine(n[d],u):n[d]=u}return n}(e,r):e,i=r.plainObjects?Object.create(null):{},s=Object.keys(n),o=0;o<s.length;++o){var a=s[o],c=jy(a,n[a],r,"string"==typeof e);i=My.merge(i,c,r)}return!0===r.allowSparse?i:My.compact(i)},By={formats:dy,parse:Ny,stringify:Fy};let Wy=class{constructor(e){this.config=e;const t=this.config.get("loadbalancer"),{baseURL:r,timeout:n,customNode:i}=t;this.api=kg.create({baseURL:r||"https://lb.livedigital.space/v1",timeout:n||5e3,withCredentials:!1,paramsSerializer:e=>By.stringify(e)}),this.customNode=i}getNode(e){return a(this,void 0,void 0,(function*(){if(this.customNode)return this.customNode;const{data:t}=yield this.api.get("/nodes/best",{params:e});return t}))}checkServiceAvailability(e=2e3){return a(this,void 0,void 0,(function*(){try{const{status:t}=yield this.api.options("/nodes/best",{timeout:e});return[200,204].includes(t)}catch(e){return!1}}))}};Wy=i([at(),s(0,dt(Yn.Config)),o("design:paramtypes",[Ct])],Wy);var qy,Uy=Wy;let zy=class{constructor(e,t){this.clientEventEmitter=e,this.isEnableVideoDevicesLock=!1,this.isEnableAudioDevicesLock=!1,this.isDevicesDetected=!1,this.availableVideoDevices=[],this.availableAudioDevices=[],qy.set(this,void 0),d(this,qy,t("System"),"f"),this.deviceChangeHandler=this.deviceChangeHandler.bind(this),this.listenDevices()}setIsEnableVideoDevicesLock(e){this.isEnableVideoDevicesLock=e}setIsEnableAudioDevicesLock(e){this.isEnableAudioDevicesLock=e}setAvailableVideoDevices(e){this.availableVideoDevices=e}setAvailableAudioDevices(e){this.availableAudioDevices=e}requestMediaDevicesAccess(e={video:!0,audio:!0}){return a(this,void 0,void 0,(function*(){try{return(yield navigator.mediaDevices.getUserMedia(e)).getTracks()}catch(t){if(c(this,qy,"f").error("getUserMedia()",{error:t,constraints:e}),"NotAllowedError"===t.name)throw new Error(Xn.NotAllowedError);if("NotReadableError"===t.name)throw new Error(Xn.DeviceIsBusy);if("NotFoundError"===t.name)throw new Error(Xn.NotFoundError);throw new Error(Xn.RequestDevicesUnknownError)}}))}hasAvailableMediaDevicesList(){return a(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices();if(0===e.length)return!0;return e.every((e=>e.deviceId&&e.label))}))}refreshAvailableMediaDevicesList(){return a(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices(),t=[],r=[];e.forEach((e=>{""!==e.deviceId&&("videoinput"===e.kind&&t.push(e),"audioinput"===e.kind&&r.push(e))})),this.setAvailableVideoDevices(t),this.setAvailableAudioDevices(r);const n=({label:e,kind:t})=>({label:e,kind:t});return c(this,qy,"f").debug("Devices list updated",{videoDevices:t.map(n),audioDevices:r.map(n)}),e}))}detectDevices(e){return a(this,void 0,void 0,(function*(){if(this.isDevicesDetected&&!e)return;(yield this.hasAvailableMediaDevicesList())||(yield this.tryToAccessDevices()),this.isDevicesDetected=!0;const t=yield this.refreshAvailableMediaDevicesList(),r=t.some((e=>"audioinput"===e.kind)),n=t.some((e=>"videoinput"===e.kind));if(!r&&!n)throw new Error(Xn.NoDevices)}))}deviceChangeHandler(){return a(this,void 0,void 0,(function*(){this.isDevicesDetected&&(yield this.refreshAvailableMediaDevicesList(),this.clientEventEmitter.safeEmit(zr,{audio:this.availableAudioDevices,video:this.availableVideoDevices}))}))}listenDevices(){navigator.mediaDevices.addEventListener("devicechange",this.deviceChangeHandler)}assertHasAccessToMediaDevices(e={video:!0,audio:!0}){return a(this,void 0,void 0,(function*(){(yield this.requestMediaDevicesAccess(e)).forEach((e=>e.stop()))}))}tryToAccessDevices(){return a(this,void 0,void 0,(function*(){try{(yield this.requestMediaDevicesAccess()).forEach((e=>e.stop()))}catch(t){if(e=t.message,![Xn.NotFoundError,Xn.NotAllowedError,Xn.DeviceIsBusy].includes(e))throw t;t.message!==Xn.DeviceIsBusy&&(yield this.assertHasAccessToMediaDevices({audio:!0}),yield this.assertHasAccessToMediaDevices({video:!0}))}var e}))}};qy=new WeakMap,zy=i([at(),s(0,dt(Yn.ClientEventEmitter)),s(1,dt(Yn.LoggerFactory)),o("design:paramtypes",[Rt,Function])],zy);var Vy,Hy,$y,Ky,Gy,Qy,Jy,Yy,Zy,Xy,eb=zy;class tb{constructor({sendTransportConnectionManager:e,receiveTransportConnectionManager:t,media:r,peers:n}){Vy.set(this,void 0),Hy.set(this,void 0),$y.set(this,void 0),Ky.set(this,void 0),d(this,Vy,e,"f"),d(this,Hy,t,"f"),d(this,$y,r,"f"),d(this,Ky,n,"f")}getStats(){var e,t;return Object.assign(Object.assign({},(null===(e=c(this,Vy,"f").connectionStats)||void 0===e?void 0:e.id)?{outbound:Object.assign(Object.assign({},c(this,Vy,"f").connectionStats),{bitrate:this.calculateOutboundTracksBitrate()})}:{}),(null===(t=c(this,Hy,"f").connectionStats)||void 0===t?void 0:t.id)?{inbound:Object.assign(Object.assign({},c(this,Hy,"f").connectionStats),{bitrate:this.calculateInboundTracksBitrate()})}:{})}calculateInboundTracksBitrate(){return c(this,Ky,"f").hosts().reduce(((e,t)=>{if(t.isMe)return e;const r=Array.from(t.tracks.values()).reduce(((e,t)=>{var r,n;const i="video"===t.kind?null===(r=t.videoWebRTCStats)||void 0===r?void 0:r.bitrate:null===(n=t.audioWebRTCStats)||void 0===n?void 0:n.bitrate;return e+(null!=i?i:0)}),0);return e+r}),0)}calculateOutboundTracksBitrate(){return c(this,$y,"f").getAllTracks().reduce(((e,t)=>{var r,n;if(!t.isPublished)return e;const i="video"===t.kind?null===(r=t.videoWebRTCStats)||void 0===r?void 0:r.bitrate:null===(n=t.audioWebRTCStats)||void 0===n?void 0:n.bitrate;return e+(null!=i?i:0)}),0)}}Vy=new WeakMap,Hy=new WeakMap,$y=new WeakMap,Ky=new WeakMap;class rb{constructor({transport:e,statsHandler:t}){Gy.set(this,void 0),this.handleWebRTCStats(e,t)}get connectionStats(){return c(this,Gy,"f")}handleWebRTCStats(e,t){t.addConnectionHandler(e.id,this.setConnectionStats.bind(this)),e.observer.once("close",(()=>{t.removeConnectionHandler(e.id)}))}setConnectionStats(e){d(this,Gy,e,"f")}}Gy=new WeakMap;let nb=class{constructor(){Qy.set(this,new Map),Jy.set(this,new Map),Yy.set(this,new Map),Zy.set(this,new Map),Xy.set(this,new Map)}handle(e){e.forEach((({id:e,stats:t})=>{var r;null===(r=c(this,Qy,"f").get(e))||void 0===r||r(t.connection),t.video.inbound.forEach((e=>{var t;return null===(t=c(this,Jy,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.inbound.forEach((e=>{var t;return null===(t=c(this,Yy,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.video.outbound.forEach((e=>{var t;return null===(t=c(this,Zy,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.outbound.forEach((e=>{var t;return null===(t=c(this,Xy,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)}))}))}addConnectionHandler(e,t){c(this,Qy,"f").set(e,t)}addInboundVideoHandler(e,t){c(this,Jy,"f").set(e,t)}addInboundAudioHandler(e,t){c(this,Yy,"f").set(e,t)}addOutboundVideoHandler(e,t){c(this,Zy,"f").set(e,t)}addOutboundAudioHandler(e,t){c(this,Xy,"f").set(e,t)}removeConnectionHandler(e){c(this,Qy,"f").delete(e)}removeInboundVideoHandler(e){c(this,Jy,"f").delete(e)}removeInboundAudioHandler(e){c(this,Zy,"f").delete(e)}removeOutboundVideoHandler(e){c(this,Xy,"f").delete(e)}removeOutboundAudioHandler(e){c(this,Xy,"f").delete(e)}clear(){c(this,Qy,"f").clear(),c(this,Jy,"f").clear(),c(this,Yy,"f").clear(),c(this,Zy,"f").clear(),c(this,Xy,"f").clear()}};Qy=new WeakMap,Jy=new WeakMap,Yy=new WeakMap,Zy=new WeakMap,Xy=new WeakMap,nb=i([at()],nb);var ib,sb,ob,ab,cb,db=nb;class ub extends qn{constructor(e,t){super(e,null!=t?t:"invalid_payload")}}!function(e){e.DominantSpeaker="dominant-speaker",e.PeersVolumes="peers-volumes",e.Silence="silence"}(ib||(ib={}));let lb=cb=class{constructor(e,t,r){this.peers=e,this.clientEventEmitter=t,sb.set(this,void 0),ob.set(this,void 0),ab.set(this,void 0),d(this,sb,r("ChannelAudioObserverEventHandler"),"f"),this.watchPeersLeave()}handle(e){try{const t=JSON.parse(e);switch(cb.validateEventPayload(t),t.event){case ib.DominantSpeaker:this.handleDominantSpeaker(t);break;case ib.PeersVolumes:this.handlePeerVolumes(t);break;case ib.Silence:this.handleSilence()}}catch(t){c(this,sb,"f").warn("Failed to handle audio observer event",{error:mr(t),eventData:e})}}handleDominantSpeaker(e){const{peerId:t}=e.data,r=this.peers.get(t);d(this,ob,r,"f"),d(this,ab,r,"f"),this.peers.setActiveSpeaker(r)}handlePeerVolumes(e){e.volumes.forEach((e=>{var t;const{peerId:r,trackLabel:n,value:i}=e,s=this.peers.get(r);if(!s)return;i>0&&!c(this,ob,"f")&&s.id===(null===(t=c(this,ab,"f"))||void 0===t?void 0:t.id)&&(d(this,ob,s,"f"),this.peers.setActiveSpeaker(s));const o=null==s?void 0:s.tracks.get(n);o&&o.setVolume(i)}))}handleSilence(){this.peers.all().flatMap((e=>Array.from(e.tracks.values()))).forEach((e=>e.setVolume(0))),d(this,ob,void 0,"f"),this.peers.setActiveSpeaker(void 0)}watchPeersLeave(){this.clientEventEmitter.on(Nr,(e=>{var t;e===(null===(t=c(this,ob,"f"))||void 0===t?void 0:t.id)&&this.peers.setActiveSpeaker(void 0)}))}static validateEventPayload(e){switch(e.event){case ib.Silence:break;case ib.DominantSpeaker:{e.data||cb.throwInvalidPayload();const{peerId:t,producerId:r,trackLabel:n}=e.data;"string"==typeof t&&"string"==typeof r&&n===Zn.Microphone||cb.throwInvalidPayload();break}case ib.PeersVolumes:Array.isArray(e.volumes)||cb.throwInvalidPayload(),e.volumes.forEach((e=>{const{peerId:t,producerId:r,value:n,trackLabel:i}=e;"string"==typeof t&&"string"==typeof r&&"number"==typeof n&&i===Zn.Microphone||cb.throwInvalidPayload()}));break;default:cb.throwInvalidPayload()}}static throwInvalidPayload(){throw new ub("Invalid channel audio observer event handler payload")}};sb=new WeakMap,ob=new WeakMap,ab=new WeakMap,lb=cb=i([at(),s(0,dt(Yn.Peers)),s(1,dt(Yn.ClientEventEmitter)),s(2,dt(Yn.LoggerFactory)),o("design:paramtypes",[Gh,Rt,Function])],lb);var pb=lb,hb=Uint8Array,fb=Uint16Array,mb=Int32Array,gb=new hb([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),vb=new hb([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),yb=new hb([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bb=function(e,t){for(var r=new fb(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];var i=new mb(r[30]);for(n=1;n<30;++n)for(var s=r[n];s<r[n+1];++s)i[s]=s-r[n]<<5|n;return{b:r,r:i}},wb=bb(gb,2),_b=wb.b,Sb=wb.r;_b[28]=258,Sb[258]=28;for(var kb=bb(vb,0).b,Cb=new fb(32768),Rb=0;Rb<32768;++Rb){var Pb=(43690&Rb)>>1|(21845&Rb)<<1;Pb=(61680&(Pb=(52428&Pb)>>2|(13107&Pb)<<2))>>4|(3855&Pb)<<4,Cb[Rb]=((65280&Pb)>>8|(255&Pb)<<8)>>1}var Tb=function(e,t,r){for(var n=e.length,i=0,s=new fb(t);i<n;++i)e[i]&&++s[e[i]-1];var o,a=new fb(t);for(i=1;i<t;++i)a[i]=a[i-1]+s[i-1]<<1;if(r){o=new fb(1<<t);var c=15-t;for(i=0;i<n;++i)if(e[i])for(var d=i<<4|e[i],u=t-e[i],l=a[e[i]-1]++<<u,p=l|(1<<u)-1;l<=p;++l)o[Cb[l]>>c]=d}else for(o=new fb(n),i=0;i<n;++i)e[i]&&(o[i]=Cb[a[e[i]-1]++]>>15-e[i]);return o},Eb=new hb(288);for(Rb=0;Rb<144;++Rb)Eb[Rb]=8;for(Rb=144;Rb<256;++Rb)Eb[Rb]=9;for(Rb=256;Rb<280;++Rb)Eb[Rb]=7;for(Rb=280;Rb<288;++Rb)Eb[Rb]=8;var Db=new hb(32);for(Rb=0;Rb<32;++Rb)Db[Rb]=5;var Mb=Tb(Eb,9,1),Ib=Tb(Db,5,1),xb=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},Ob=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&r},Lb=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},Ab=function(e){return(e+7)/8|0},jb=function(e,t,r){return(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length),new hb(e.subarray(t,r))},Fb=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Nb=function(e,t,r){var n=new Error(t||Fb[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,Nb),!r)throw n;return n},Bb=function(e,t,r,n){var i=e.length,s=n?n.length:0;if(!i||t.f&&!t.l)return r||new hb(0);var o=!r,a=o||2!=t.i,c=t.i;o&&(r=new hb(3*i));var d=function(e){var t=r.length;if(e>t){var n=new hb(Math.max(2*t,e));n.set(r),r=n}},u=t.f||0,l=t.p||0,p=t.b||0,h=t.l,f=t.d,m=t.m,g=t.n,v=8*i;do{if(!h){u=Ob(e,l,1);var y=Ob(e,l+1,3);if(l+=3,!y){var b=e[(M=Ab(l)+4)-4]|e[M-3]<<8,w=M+b;if(w>i){c&&Nb(0);break}a&&d(p+b),r.set(e.subarray(M,w),p),t.b=p+=b,t.p=l=8*w,t.f=u;continue}if(1==y)h=Mb,f=Ib,m=9,g=5;else if(2==y){var _=Ob(e,l,31)+257,S=Ob(e,l+10,15)+4,k=_+Ob(e,l+5,31)+1;l+=14;for(var C=new hb(k),R=new hb(19),P=0;P<S;++P)R[yb[P]]=Ob(e,l+3*P,7);l+=3*S;var T=xb(R),E=(1<<T)-1,D=Tb(R,T,1);for(P=0;P<k;){var M,I=D[Ob(e,l,E)];if(l+=15&I,(M=I>>4)<16)C[P++]=M;else{var x=0,O=0;for(16==M?(O=3+Ob(e,l,3),l+=2,x=C[P-1]):17==M?(O=3+Ob(e,l,7),l+=3):18==M&&(O=11+Ob(e,l,127),l+=7);O--;)C[P++]=x}}var L=C.subarray(0,_),A=C.subarray(_);m=xb(L),g=xb(A),h=Tb(L,m,1),f=Tb(A,g,1)}else Nb(1);if(l>v){c&&Nb(0);break}}a&&d(p+131072);for(var j=(1<<m)-1,F=(1<<g)-1,N=l;;N=l){var B=(x=h[Lb(e,l)&j])>>4;if((l+=15&x)>v){c&&Nb(0);break}if(x||Nb(2),B<256)r[p++]=B;else{if(256==B){N=l,h=null;break}var W=B-254;if(B>264){var q=gb[P=B-257];W=Ob(e,l,(1<<q)-1)+_b[P],l+=q}var U=f[Lb(e,l)&F],z=U>>4;U||Nb(3),l+=15&U;A=kb[z];if(z>3){q=vb[z];A+=Lb(e,l)&(1<<q)-1,l+=q}if(l>v){c&&Nb(0);break}a&&d(p+131072);var V=p+W;if(p<A){var H=s-A,$=Math.min(A,V);for(H+p<0&&Nb(3);p<$;++p)r[p]=n[H+p]}for(;p<V;++p)r[p]=r[p-A]}}t.l=h,t.p=N,t.b=p,t.f=u,h&&(u=1,t.m=m,t.d=f,t.n=g)}while(!u);return p!=r.length&&o?jb(r,0,p):r.subarray(0,p)},Wb=new hb(0);function qb(e,t){var r=function(e){31==e[0]&&139==e[1]&&8==e[2]||Nb(6,"invalid gzip data");var t=e[3],r=10;4&t&&(r+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[r++]);return r+(2&t)}(e);return r+8>e.length&&Nb(6,"invalid gzip data"),Bb(e.subarray(r,-8),{i:2},t&&t.out||new hb(function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}(e)),t&&t.dictionary)}function Ub(e,t){return Bb(e.subarray(function(e,t){return(8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Nb(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&Nb(6,"invalid zlib data: "+(32&e[1]?"need":"unexpected")+" dictionary"),2+(e[1]>>3&4)}(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}function zb(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?qb(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?function(e,t){return Bb(e,{i:2},t&&t.out,t&&t.dictionary)}(e,t):Ub(e,t)}var Vb="undefined"!=typeof TextDecoder&&new TextDecoder;try{Vb.decode(Wb,{stream:!0}),1}catch(_t){}function Hb(e,t){if(t){for(var r="",n=0;n<e.length;n+=16384)r+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return r}if(Vb)return Vb.decode(e);var i=function(e){for(var t="",r=0;;){var n=e[r++],i=(n>127)+(n>223)+(n>239);if(r+i>e.length)return{s:t,r:jb(e,r-1)};i?3==i?(n=((15&n)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,t+=String.fromCharCode(55296|n>>10,56320|1023&n)):t+=1&i?String.fromCharCode((31&n)<<6|63&e[r++]):String.fromCharCode((15&n)<<12|(63&e[r++])<<6|63&e[r++]):t+=String.fromCharCode(n)}}(e),s=i.s;return(r=i.r).length&&Nb(8),s}function $b(e,t){var r,n;if(0===t.length)return e;for(r=0,n=t.length;r<n;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e<0?-2*e:e}function Kb(e,t,r,n){var i=$b($b($b(e,r),function(e){return Object.prototype.toString.call(e)}(t)),typeof t);if(null===t)return $b(i,"null");if(void 0===t)return $b(i,"undefined");if("object"==typeof t||"function"==typeof t){if(-1!==n.indexOf(t))return $b(i,"[Circular]"+r);n.push(t);var s=function(e,t,r){return Object.keys(t).sort().reduce((function(e,n){return Kb(e,t[n],n,r)}),e)}(i,t,n);if(!("valueOf"in t)||"function"!=typeof t.valueOf)return s;try{return $b(s,String(t.valueOf()))}catch(e){return $b(s,"[valueOf exception]"+(e.stack||e.message))}}return $b(i,t.toString())}var Gb=function(e){return function(e,t){for(;e.length<t;)e="0"+e;return e}(Kb(0,e,"",[]).toString(16),8)};class Qb{constructor(e){this.missingPeers=e.missingPeers,this.missingProducers=e.missingProducers,this.consumersWithInconsistentState=e.consumersWithInconsistentState,this.producersWithInconsistentState=e.producersWithInconsistentState,this.peersWithInconsistentAppData=e.peersWithInconsistentAppData}hasInconsistencyCases(){return this.missingPeers.length>0||this.missingProducers.length>0||this.consumersWithInconsistentState.length>0||this.producersWithInconsistentState.length>0||this.peersWithInconsistentAppData.length>0}}class Jb{constructor(e){this.missingPeers=[],this.missingProducers=[],this.consumersWithInconsistentState=[],this.producersWithInconsistentState=[],this.peersWithInconsistentAppData=[],this.localState=e.localState,this.remoteState=e.remoteState}check(){return this.resetPreviousCheckResults(),this.remoteState.peers.forEach((e=>{const t=this.findLocalPeerById(e.id);if(!t)return void this.missingPeers.push(e.id);t.appDataHash!==e.appDataHash&&this.peersWithInconsistentAppData.push(e.id),e.producers.forEach((e=>{const r=this.findLocalConsumerByProducerId(t,e.id);r&&r.paused!==e.paused&&this.consumersWithInconsistentState.push(r.id);const n=this.findLocalProducerById(t,e.id);if(n||this.missingProducers.push(e.id),!n)return;n.paused!==e.paused&&this.producersWithInconsistentState.push(e.id)}))})),new Qb({missingPeers:this.missingPeers,missingProducers:this.missingProducers,consumersWithInconsistentState:this.consumersWithInconsistentState,producersWithInconsistentState:this.producersWithInconsistentState,peersWithInconsistentAppData:this.peersWithInconsistentAppData})}getMissingPeers(){return this.missingPeers}getMissingProducers(){return this.missingProducers}getConsumersWithInconsistentState(){return this.consumersWithInconsistentState}getProducersWithInconsistentState(){return this.producersWithInconsistentState}getPeersWithInconsistentAppData(){return this.peersWithInconsistentAppData}findLocalPeerById(e){return this.localState.peers.find((t=>t.id===e))}findLocalConsumerByProducerId(e,t){var r;return null===(r=e.consumers)||void 0===r?void 0:r.find((e=>e.producerId===t))}findLocalProducerById(e,t){return e.producers.find((e=>e.id===t))}resetPreviousCheckResults(){this.missingPeers=[],this.missingProducers=[],this.consumersWithInconsistentState=[],this.producersWithInconsistentState=[],this.peersWithInconsistentAppData=[]}}var Yb,Zb,Xb,ew,tw,rw,nw;!function(e){e.MissingPeer="missing-peer",e.MissingProducer="missing-producer",e.IncorrectProducerState="incorrect-producer-state",e.IncorrectConsumerState="incorrect-consumer-state",e.IncorrectAppData="incorrect-app-data"}(Yb||(Yb={}));let iw=class{constructor(e,t,r,n,i,s,o,a){var c;this.channelStateSynchronizer=e,this.network=r,this.callState=n,this.socket=i,this.peers=s,this.clientEventEmitter=o,this.webRtcIssueDetector=a,Zb.set(this,void 0),Xb.set(this,void 0),ew.set(this,[]),tw.set(this,!1),rw.set(this,{inbound:4.3,outbound:4.3}),nw.set(this,(new Date).getTime()-15e3),d(this,Xb,null===(c=this.webRtcIssueDetector)||void 0===c?void 0:c.eventEmitter,"f"),d(this,Zb,t("ChannelStateSyncEventHandler"),"f"),this.listenNetworkScoresUpdatedEvents()}handle(e){return a(this,void 0,void 0,(function*(){try{const{event:t,data:r}=yield this.parseChannelStateSyncEventPayload(e);"channel-state"!==t||c(this,tw,"f")||(yield this.handleChannelStateEvent(r))}catch(e){c(this,Zb,"f").error("handleChannelStateSyncEvent()",{error:mr(e)})}}))}handleChannelStateEvent(e){return a(this,void 0,void 0,(function*(){d(this,tw,!0,"f");try{yield this.collectProbableInconsistencyCases(e);const t=this.getConfirmedInconsistencyResult();if(!(null==t?void 0:t.hasInconsistencyCases()))return;if(this.isRestoreStateRequestToEarly())return void c(this,Zb,"f").info("Inconsistency detected, but restore skipped",Object.assign({},t));this.handleConfirmedInconsistencyResult(t)}finally{d(this,tw,!1,"f")}}))}getLastInconsistencyCheckResult(){return c(this,ew,"f")[c(this,ew,"f").length-1]}handleConfirmedInconsistencyResult(e){e.missingPeers.forEach((e=>{this.clientEventEmitter.safeEmit(Gr,{peerId:e,type:Yb.MissingPeer})})),e.missingProducers.forEach((e=>{this.clientEventEmitter.safeEmit(Gr,{producerId:e,type:Yb.MissingProducer})})),e.producersWithInconsistentState.forEach((e=>{this.clientEventEmitter.safeEmit(Gr,{producerId:e,type:Yb.IncorrectProducerState})})),e.peersWithInconsistentAppData.forEach((e=>{this.clientEventEmitter.safeEmit(Gr,{peerId:e,type:Yb.IncorrectAppData})}))}getConfirmedInconsistencyResult(){const e=this.getLastInconsistencyCheckResult();if(!e)return;return new Qb({missingPeers:this.getConfirmedMissingPeers(e.missingPeers),missingProducers:this.getConfirmedMissingProducers(e.missingProducers),consumersWithInconsistentState:this.getConfirmedConsumersWithInconsistencState(e.consumersWithInconsistentState),producersWithInconsistentState:this.getConfirmedProducersWithInconsistencState(e.producersWithInconsistentState),peersWithInconsistentAppData:this.getConfirmedPeersWithInconsistentAppData(e.missingPeers)})}collectProbableInconsistencyCases(e){return a(this,void 0,void 0,(function*(){const t=new Jb({remoteState:e,localState:this.getLocalState()}).check();if(this.rotateLastProbableInconsistencyCheckResults(t),!t.hasInconsistencyCases())return;if(this.isBadNetworkScore())return void this.resetLastProbableInconsistencyCheckResults();(yield this.getIsConnectionActive())&&this.callState.isJoined&&this.network.isNetworkActive||this.resetLastProbableInconsistencyCheckResults()}))}resetLastProbableInconsistencyCheckResults(){d(this,ew,[],"f")}rotateLastProbableInconsistencyCheckResults(e){4===c(this,ew,"f").length&&c(this,ew,"f").shift(),c(this,ew,"f").push(e)}isReachedMaxCheckRetries(e,t,r=4){let n=0;return c(this,ew,"f").forEach((r=>{r[e].includes(t)&&(n+=1)})),n>=r}getConfirmedMissingPeers(e){return e.filter((e=>this.isReachedMaxCheckRetries("missingPeers",e)))}getConfirmedMissingProducers(e){return e.filter((e=>this.isReachedMaxCheckRetries("missingProducers",e)))}getConfirmedConsumersWithInconsistencState(e){return e.filter((e=>this.isReachedMaxCheckRetries("consumersWithInconsistentState",e,1)))}getConfirmedProducersWithInconsistencState(e){return e.filter((e=>this.isReachedMaxCheckRetries("producersWithInconsistentState",e)))}getConfirmedPeersWithInconsistentAppData(e){return e.filter((e=>this.isReachedMaxCheckRetries("peersWithInconsistentAppData",e)))}parseChannelStateSyncEventPayload(e){return a(this,void 0,void 0,(function*(){const t=zb("arrayBuffer"in e?new Uint8Array(yield e.arrayBuffer()):new Uint8Array(e));return JSON.parse(Hb(t))}))}getLocalState(){return{peers:this.peers.hosts().map((e=>({id:e.id,appDataHash:Gb(e.appData),producers:e.getProducers().map((e=>({id:e.id,paused:e.paused}))),consumers:e.getConsumersState()})))}}getIsConnectionActive(){var e;return a(this,void 0,void 0,(function*(){try{return this.network.checkSocketConnectionActivity(),yield null===(e=this.socket.connection)||void 0===e?void 0:e.timeout(1e3).emitWithAck("peer.ping",{}),!0}catch(e){return!1}}))}listenNetworkScoresUpdatedEvents(){c(this,Xb,"f")&&c(this,Xb,"f").on(wt.NetworkScoresUpdated,(e=>{e.inbound&&(c(this,rw,"f").inbound=e.inbound),e.outbound&&(c(this,rw,"f").outbound=e.outbound)}))}isBadNetworkScore(){const{inbound:e,outbound:t}=c(this,rw,"f");return e<=2.6||t<=2.6}compareCheckedAndRestoredResults(e,t){return new Qb({missingPeers:e.missingPeers.filter((e=>!t.missingPeers.includes(e))),missingProducers:e.missingProducers.filter((e=>!t.missingProducers.includes(e))),consumersWithInconsistentState:e.consumersWithInconsistentState.filter((e=>!t.fixedConsumersState.includes(e))),producersWithInconsistentState:e.producersWithInconsistentState.filter((e=>!t.fixedProducersState.includes(e))),peersWithInconsistentAppData:e.peersWithInconsistentAppData.filter((e=>!t.restoredAppDataPeers.includes(e)))})}isRestoreStateRequestToEarly(){return(new Date).getTime()-c(this,nw,"f")<=15e3}};Zb=new WeakMap,Xb=new WeakMap,ew=new WeakMap,tw=new WeakMap,rw=new WeakMap,nw=new WeakMap,iw=i([at(),s(0,dt(Yn.ChannelStateSynchronizer)),s(1,dt(Yn.LoggerFactory)),s(2,dt(Yn.Network)),s(3,dt(Yn.CallState)),s(4,dt(Yn.SocketIO)),s(5,dt(Yn.Peers)),s(6,dt(Yn.ClientEventEmitter)),s(7,dt(Yn.WebRTCIssueDetector)),o("design:paramtypes",[af,Function,Kh,ti,Hh,Gh,Rt,sr])],iw);var sw,ow,aw,cw,dw,uw,lw,pw,hw,fw=iw;let mw=class{constructor(e,t,r,n,i,s,o,c,u,l){this.state=e,this.myPeer=r,this.network=n,this.channelEventsHandler=i,this.eventsQueue=s,this.peers=o,this.mediaSoupEventsHandler=c,this.channelAudioObserverEventHandler=u,this.channelStateSyncEventHandler=l,sw.set(this,void 0),ow.set(this,void 0),aw.set(this,void 0),cw.set(this,void 0),dw.set(this,void 0),uw.set(this,void 0),lw.set(this,void 0),pw.set(this,void 0),hw.set(this,void 0),d(this,sw,t("DataChannels"),"f"),d(this,uw,(e=>{this.channelAudioObserverEventHandler.handle(e)}),"f"),d(this,lw,(e=>{this.channelEventsHandler.handleDataChannelEvent(e)}),"f"),d(this,pw,(e=>a(this,void 0,void 0,(function*(){yield this.channelStateSyncEventHandler.handle(e)}))),"f"),d(this,hw,(e=>{this.mediaSoupEventsHandler.handleConsumerScoreEvent(e)}),"f")}createAllDataChannels(){return a(this,void 0,void 0,(function*(){yield Promise.all([this.createAudioObserver(),this.createGeneralDataConsumer(),this.createChannelStateSyncDataConsumer(),this.createConsumersScoresDataConsumer()])}))}closeAllDataChannels(){var e,t,r,n,i,s,o,a;null===(e=c(this,ow,"f"))||void 0===e||e.removeListener("message",c(this,uw,"f")),null===(t=c(this,ow,"f"))||void 0===t||t.close(),null===(r=c(this,aw,"f"))||void 0===r||r.removeListener("message",c(this,lw,"f")),null===(n=c(this,aw,"f"))||void 0===n||n.close(),null===(i=c(this,cw,"f"))||void 0===i||i.removeListener("message",c(this,pw,"f")),null===(s=c(this,cw,"f"))||void 0===s||s.close(),null===(o=c(this,dw,"f"))||void 0===o||o.removeListener("message",c(this,hw,"f")),null===(a=c(this,dw,"f"))||void 0===a||a.close()}createAudioObserver(){var e;return a(this,void 0,void 0,(function*(){const t={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(e=this.myPeer)||void 0===e?void 0:e.id};try{const{producerId:e}=yield this.network.getAudioObserverProducer(),r=yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId});r.on("message",c(this,uw,"f")),d(this,ow,r,"f"),c(this,sw,"f").debug("Successfully create audio observer",t)}catch(e){c(this,sw,"f").error("Failed to create audio observer",t)}}))}createGeneralDataConsumer(){var e;return a(this,void 0,void 0,(function*(){const t={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(e=this.myPeer)||void 0===e?void 0:e.id};try{const{producerId:e}=yield this.network.getGeneralDataProducer();d(this,aw,yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId,ordered:!0}),"f"),this.eventsQueue.subscribeToDataChannel(c(this,aw,"f")),this.eventsQueue.on("message",c(this,lw,"f")),c(this,sw,"f").debug("Successfully created general data consumer",Object.assign(Object.assign({},t),{producerId:e}))}catch(e){c(this,sw,"f").error("Failed to create general data consumer",Object.assign(Object.assign({},t),{error:e}))}}))}createChannelStateSyncDataConsumer(){var e;return a(this,void 0,void 0,(function*(){const t={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(e=this.myPeer)||void 0===e?void 0:e.id};try{const{producerId:e}=yield this.network.getChannelStateSyncDataProducer();if(d(this,cw,yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId}),"f"),!c(this,cw,"f"))throw new Error("Failed to create ChannelStateSyncDataConsumer");c(this,cw,"f").on("message",c(this,pw,"f")),c(this,sw,"f").debug("Successfully created ChannelStateSyncDataConsumer",t)}catch(e){c(this,sw,"f").error("Failed to create ChannelStateSyncDataConsumer",Object.assign(Object.assign({},t),{error:e}))}}))}createConsumersScoresDataConsumer(){var e;return a(this,void 0,void 0,(function*(){const t={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(e=this.myPeer)||void 0===e?void 0:e.id};try{const{id:e}=yield this.network.createDataProducer("consumers-scores");if(d(this,dw,yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId}),"f"),!c(this,dw,"f"))throw new Error("Failed to create consumers scores data consumer");c(this,dw,"f").on("message",c(this,hw,"f")),c(this,sw,"f").debug("Successfully create consumers scores data consumer",t)}catch(e){c(this,sw,"f").error("Failed to create consumers scores data consumer",t)}}))}};sw=new WeakMap,ow=new WeakMap,aw=new WeakMap,cw=new WeakMap,dw=new WeakMap,uw=new WeakMap,lw=new WeakMap,pw=new WeakMap,hw=new WeakMap,mw=i([at(),s(0,dt(Yn.CallState)),s(1,dt(Yn.LoggerFactory)),s(2,dt(Yn.MyPeer)),s(3,dt(Yn.Network)),s(4,dt(Yn.ChannelEventHandler)),s(5,dt(Yn.EventsQueue)),s(6,dt(Yn.Peers)),s(7,dt(Yn.MediaSoupEventHandler)),s(8,dt(Yn.ChannelAudioObserverEventHandler)),s(9,dt(Yn.ChannelStateSyncEventHandler)),o("design:paramtypes",[ti,Function,mp,Kh,uf,nf,Object,Kf,pb,fw])],mw);var gw,vw,yw,bw,ww,_w=mw;let Sw=class{constructor(e,t,r,n,i,s,o,a,c,u,l,p,h,f,m,g,v,y,b,w,_,S){this.config=e,this.state=t,this.myPeer=r,this.integrationsService=i,this.processorsCache=s,this.mediaSoupEventsHandler=o,this.channelEventsHandler=a,this.channelStateSynchronizer=c,this.peerTrackFactory=u,this.peers=l,this.system=p,this.media=h,this.network=f,this.loadBalancerClient=m,this.socket=g,this.eventsQueue=v,this.clientEventEmitter=y,this.internalEventEmitter=b,this.statsHandler=w,this.dataChannelsManager=_,this.webRtcIssueDetector=S,gw.set(this,void 0),vw.set(this,void 0),this.rejoinRequested=!1,this.isReleasing=!1,yw.set(this,!1),bw.set(this,!1),ww.set(this,void 0),d(this,gw,n("Engine"),"f"),d(this,vw,n,"f"),this.watchNetworkState(),this.watchDocumentUnload()}get isChannelJoined(){return this.state.isJoined}initialize(){var e,t,r,n;return a(this,void 0,void 0,(function*(){try{const{rtpCapabilities:i}=yield this.socket.request("router.getRtpCapabilities");this.integrationsService.init(),yield this.media.loadDevice(i),c(this,gw,"f").info("Supported capabilities",{codecs:$n(this.media.mediasoupDevice)});const[s,o]=yield Promise.all([this.network.createSendTransport(this.media.mediasoupDevice),this.network.createRecvTransport(this.media.mediasoupDevice)]);null===(e=this.webRtcIssueDetector)||void 0===e||e.handleNewPeerConnection(s.handler._pc,s.id),null===(t=this.webRtcIssueDetector)||void 0===t||t.handleNewPeerConnection(o.handler._pc,o.id),d(this,ww,new tb({media:this.media,peers:this.peers,receiveTransportConnectionManager:new rb({transport:o,statsHandler:this.statsHandler}),sendTransportConnectionManager:new rb({transport:s,statsHandler:this.statsHandler})}),"f"),c(this,gw,"f").debug("initialize()",{sendTransportId:null===(r=this.network.sendTransport)||void 0===r?void 0:r.id,recvTransportId:null===(n=this.network.receiveTransport)||void 0===n?void 0:n.id})}catch(e){c(this,gw,"f").error("initialize()",{error:e});const t=e instanceof cr&&"device not supported"===e.message,r=e instanceof Error&&"RTCPeerConnection is not defined"===e.message;if(t||r)throw new Un("Device not supported",Un.UNSUPPORTED_DEVICE_CODE);throw new Error("Error initialize engine")}}))}release(e){var t;return a(this,void 0,void 0,(function*(){if(!this.isReleasing){this.isReleasing=!0;try{this.state.isJoined=!1,this.state.reset(),this.myPeer.delete(),null===(t=this.webRtcIssueDetector)||void 0===t||t.stopWatchingNewPeerConnections(),yield this.peers.reset(),yield this.network.closeSendTransport(),yield this.network.closeReceiveTransport(),yield this.media.unpublishTracks(),e||(yield this.media.clearTracks()),yield this.processorsCache.reset(),this.integrationsService.reset(),this.eventsQueue.removeListener("message"),this.dataChannelsManager.closeAllDataChannels(),this.channelEventsHandler.reset(),this.mediaSoupEventsHandler.reset(),this.removeClientEventEmitterListeners(),yield this.network.reset(),this.socket.disconnect(),gr.clear(),d(this,ww,void 0,"f"),this.statsHandler.clear(),c(this,gw,"f").debug("release()",{socketId:this.myPeerId})}catch(e){throw c(this,gw,"f").error("release()",{error:e}),new Error("Error release engine")}finally{this.isReleasing=!1}}}))}removeClientEventEmitterListeners(){Array.from(Object.values(tn)).forEach((e=>this.internalEventEmitter.removeAllListeners(e)))}getPeers(){return this.peers.all()}get myPeerId(){return this.myPeer.id}confirmActivity(){return a(this,void 0,void 0,(function*(){this.network.checkSocketConnectionActivity(),yield this.socket.request(Sr)}))}join(e){return a(this,void 0,void 0,(function*(){const t=()=>a(this,void 0,void 0,(function*(){this.watchClientEvents(),yield this.connectToSocketServerWithRetry(e),yield this.performJoin({appData:e.appData})}));try{c(this,gw,"f").debug("join()",{params:e}),this.state.isChannelJoining=!0,yield Jn(t,{maxRetries:4,minBackoffDelayMs:150,maxBackoffDelayMs:5e3,actionName:"joinWithRetry",logger:c(this,vw,"f").call(this,"RetryJoinNode"),onError:()=>a(this,void 0,void 0,(function*(){yield this.release(!0)}))})}catch(e){throw c(this,gw,"f").error("join()",{error:e}),e}finally{this.state.isChannelJoining=!1,this.rejoinRequested=!1}}))}loadPeers(e){return a(this,void 0,void 0,(function*(){yield this.peers.load(e)}))}setPeer(e,t=!0){return this.peers.add(e,t)}removePeer(e){return a(this,void 0,void 0,(function*(){return this.peers.remove(e)}))}updateAppData(e){return a(this,void 0,void 0,(function*(){const t=this.myPeer.get();if(!t)throw new Error("Need join to channel first");try{zn(e),yield this.network.updatePeerAppData({peerId:t.id,appData:e})}catch(e){throw c(this,gw,"f").error("updateAppData()",{error:e}),new Error("Can not update peer appData")}}))}createCameraVideoTrack(e){return a(this,void 0,void 0,(function*(){const t=fp.getCameraVideoTrackParams(e);try{const[r]=yield this.media.createUserMediaTracks({audio:!1,video:t.videoTrackOptions});return r.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),r instanceof Hf&&(r.setLabel((null==e?void 0:e.isPreview)?Zn.CameraPreview:Zn.Camera),r.setEncoderConfig(t.encoderConfig),r.setTransformParams(fp.getVideoTrackTransformParams(r.mediaStreamTrack))),this.media.setTrack(r),c(this,gw,"f").debug("createCameraVideoTrack()",{trackParams:t}),r}catch(e){throw c(this,gw,"f").error("createCameraVideoTrack()",{error:e,trackParams:t}),new Error(`Can not create camera track: ${e.message}`)}}))}createMicrophoneAudioTrack(e){return a(this,void 0,void 0,(function*(){try{const[t]=yield this.media.createUserMediaTracks({video:!1,audio:null==e?void 0:e.audio}),r=(null==e?void 0:e.isPreview)?Zn.MicrophonePreview:Zn.Microphone;return t.setLabel(r),t.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),(null==e?void 0:e.encoderConfig)&&t.setEncoderConfig(e.encoderConfig),"audio"!==t.kind||t.getLabel()!==Zn.Microphone||c(this,bw,"f")||this.media.initDenoiser(t,e),this.media.setTrack(t),c(this,gw,"f").debug("createMicrophoneAudioTrack()",{options:e,trackLabel:t.getLabel()}),t}catch(t){throw c(this,gw,"f").error("createMicrophoneAudioTrack()",{error:t,options:e}),new Error(`Can not create microphone track: ${t.message}`)}}))}createScreenMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=fp.getScreenVideoTrackParams(e);try{const r=yield this.media.createDisplayMediaTracks({audio:null==e?void 0:e.audio,video:null==e?void 0:e.video});return r.forEach((r=>{if(r.mediaStreamTrack.addEventListener("ended",(()=>{r.unpublish().catch((e=>{c(this,gw,"f").error("Failed to unpublish media track",{track:r,error:mr(e)})}))}),{once:!0}),r.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),r instanceof Hf){r.setLabel(Zn.ScreenVideo),r.setEncoderConfig(t.encoderConfig);const e=fp.getVideoTrackTransformParams(r.mediaStreamTrack);return r.setTransformParams(e),this.media.setTrack(r),void c(this,gw,"f").debug("createScreenMediaTrack()",{trackParams:t,transformParams:e,label:r.logCtx})}r.setLabel(Zn.ScreenAudio),(null==e?void 0:e.audioEncoderConfig)&&r.setEncoderConfig(e.audioEncoderConfig),this.media.setTrack(r),c(this,gw,"f").debug("createScreenMediaTrack()",{trackParams:null==e?void 0:e.audio,encoderConfig:null==e?void 0:e.audioEncoderConfig})})),r}catch(e){throw c(this,gw,"f").error("createScreenMediaTrack()",{error:e,trackParams:t}),new Error(`Can not create screen media tracks: ${e.message}`)}}))}deleteTrack(e){return this.media.deleteTrack(e)}getNodeActiveStreamsStat(){const e=this.socket.getServerUrl(),t=this.peers.hosts().filter((e=>{var t;return e.id!==(null===(t=this.myPeer)||void 0===t?void 0:t.id)})).reduce(((e,t)=>e+t.getActiveTracksCount()),0),r=this.myPeer.get();return{node:e,inboundActiveStreams:t,outboundActiveStreams:(null==r?void 0:r.getActivePublishersCount())||0}}transportsStats(){var e;return null===(e=c(this,ww,"f"))||void 0===e?void 0:e.getStats()}connectToSocketServerWithRetry(e){return a(this,void 0,void 0,(function*(){return Jn((()=>a(this,void 0,void 0,(function*(){return this.connectToSocketServer(e)}))),{maxRetries:15,minBackoffDelayMs:150,maxBackoffDelayMs:5e3,actionName:"connectToSocketServer",logger:c(this,vw,"f").call(this,"RetrySocketConnect"),abortOnError:e=>{var t;return"unauthorized"===(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.errorCode)}})}))}connectToSocketServer(e){return a(this,void 0,void 0,(function*(){const{webSocketUrl:t}=yield this.getAvailableNode({channelId:e.channelId,role:e.role});this.socket.connect(t,e.token);try{yield this.waitForSocketConnection()}catch(r){throw c(this,gw,"f").error("Failed to connect to socket server",{error:r,role:e.role,channelId:e.channelId,webSocketUrl:t}),this.socket.disconnect(),r}}))}getAvailableNode(e){return a(this,void 0,void 0,(function*(){try{return{webSocketUrl:(yield this.loadBalancerClient.getNode(e)).webSocketUrl}}catch(e){throw c(this,gw,"f").error("getAvailableNode()",{error:"No available nodes"}),e}}))}waitForSocketConnection(){return new Promise(((e,t)=>{const r=n=>a(this,void 0,void 0,(function*(){const{error:i,state:s}=n,o=()=>this.socket.observer.removeListener(ei.State,r),a=[ei.Disconnected,ei.Reconnecting].includes(s);return i?(o(),void t(i)):this.state.isChannelJoining&&a?(o(),void t(new Error(`Not expected socket state for new connection: ${s}`))):void(this.state.isChannelJoining&&[ei.Connected,ei.Reconnected].includes(s)&&(o(),e()))}));this.socket.observer.on(ei.State,r)}))}performJoin(e){return a(this,void 0,void 0,(function*(){try{const{appId:t,channelId:r,peerId:n}=yield this.sendJoinChannelRequestWithRetry(e);this.myPeer.id=n,this.state.appId=t,this.state.channelId=r,yield this.initialize(),this.channelEventsHandler.subscribeToEvents(),this.mediaSoupEventsHandler.subscribeToEvents(),this.state.isJoined=!0,c(this,gw,"f").debug("Successfully joined channel",{channelId:r}),yield this.dataChannelsManager.createAllDataChannels(),gr.setPeerId(n),gr.setChannelId(r),gr.setAppId(t)}catch(e){throw c(this,gw,"f").error("performJoin()",{error:e}),e}}))}sendJoinChannelRequestWithRetry(e){return a(this,void 0,void 0,(function*(){return Jn((()=>a(this,void 0,void 0,(function*(){return this.sendJoinChannelRequest(e)}))),{maxRetries:3,minBackoffDelayMs:300,actionName:"sendJoinChannelRequest",logger:c(this,vw,"f").call(this,"RetryJoin")})}))}sendJoinChannelRequest(e){return a(this,void 0,void 0,(function*(){return this.socket.request(yr,e)}))}watchClientEvents(){this.internalEventEmitter.on(tn.trackProduced,(e=>a(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(tn.trackUnproduced,(e=>a(this,void 0,void 0,(function*(){var t;const r=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null==r||r.close(),yield this.media.deleteTrack(e)})))),this.internalEventEmitter.on(tn.trackPaused,(e=>{var t;const r=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null==r||r.pause()})),this.internalEventEmitter.on(tn.trackResumed,(e=>{var t;const r=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null==r||r.resume()})),this.internalEventEmitter.on(tn.trackClosed,(e=>{var t;const r=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null==r||r.close()})),this.internalEventEmitter.on(tn.trackReopened,(e=>a(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(tn.trackFailed,(e=>a(this,void 0,void 0,(function*(){this.clientEventEmitter.safeEmit($r,{label:e.getLabel()})}))))}createSelfPeerTrack(e){var t;return a(this,void 0,void 0,(function*(){const r=this.peers.get(this.myPeer.id);if(!r)return;yield null===(t=r.tracks.get(e.getLabel()))||void 0===t?void 0:t.close();const n=this.peerTrackFactory({label:e.getLabel(),mediaStreamTrack:e.mediaStreamTrack,muted:!1,paused:e.isPaused,onClose:()=>{},peerEventEmitter:r.observer});r.tracks.set(n.label,n)}))}triggerRejoinEventIfAppropriate(e){this.rejoinRequested&&!this.state.isChannelJoining||(c(this,gw,"f").debug("Triggering channel rejoin required event",{reason:e}),this.rejoinRequested=!0,this.clientEventEmitter.emit(Ur))}watchNetworkState(){this.network.observer.on(Bn,(e=>a(this,void 0,void 0,(function*(){var t;if(this.isReleasing)return;const{code:r,error:n,state:i}=e,s="unauthorized"===(null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.errorCode)&&this.isChannelJoined,o=r===ei.NeedToJoinFirst&&this.isChannelJoined;if(s&&this.clientEventEmitter.safeEmit(Zr),"server.disconnect"!==r||c(this,yw,"f")){if(o||s){const e=s?"unauthorized error":"invalid channel state";this.triggerRejoinEventIfAppropriate(e)}i===ei.Disconnected&&this.isChannelJoined&&!c(this,yw,"f")&&c(this,gw,"f").info("connection lost",{channel:"socket"}),i===ei.Reconnected&&this.isChannelJoined&&c(this,gw,"f").info("connection restored",{channel:"socket"}),i===ei.BufferingStart&&(d(this,yw,!0,"f"),this.clientEventEmitter.safeEmit(Qr),this.waitForReconnectOrTriggerRejoinEventIfAppropriate()),[ei.BufferingEnd,ei.Reconnected].includes(i)&&this.network.isNetworkActive&&(d(this,yw,!1,"f"),this.clientEventEmitter.safeEmit(Jr))}else this.clientEventEmitter.safeEmit(Yr)})))),this.network.observer.on(Wn,(({state:e,direction:t})=>a(this,void 0,void 0,(function*(){if(!this.isReleasing&&(["disconnected","failed"].includes(e)&&this.isChannelJoined&&!c(this,yw,"f")&&(d(this,yw,!0,"f"),c(this,gw,"f").info("connection lost",{channel:"webrtc-transport",direction:t}),this.clientEventEmitter.safeEmit(Qr),this.waitForReconnectOrTriggerRejoinEventIfAppropriate()),"reconnected"===e&&this.isChannelJoined&&c(this,gw,"f").info("connection restored",{channel:"webrtc-transport",direction:t}),"reconnected"===e&&this.isChannelJoined&&c(this,yw,"f"))){if(![this.network.receiveTransport,this.network.sendTransport].every((e=>"connected"===(null==e?void 0:e.connectionState)||"new"===(null==e?void 0:e.connectionState))))return;d(this,yw,!1,"f"),this.clientEventEmitter.safeEmit(Jr)}}))))}getAvgTracksScore(e){const t=this.peers.all().map((e=>Array.from(e.tracks.values()))).flat().filter((t=>t.kind===e&&!1===t.isPaused&&void 0!==t.score));if(0!==t.length)return t.reduce(((e,t)=>e+(t.score||0)),0)/t.length}watchDocumentUnload(){try{window.addEventListener("unload",(()=>{var e,t;null===(e=this.network.sendTransport)||void 0===e||e.close(),null===(t=this.network.receiveTransport)||void 0===t||t.close()}))}catch(e){c(this,gw,"f").error("Failed to add watchDocumentUnload listener",{channelId:this.state.channelId})}}waitForReconnectOrTriggerRejoinEventIfAppropriate(){c(this,gw,"f").info("Start waiting for seamless reconnect and check loadbalancer availability",{case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"});let e=0;const t=setInterval((()=>a(this,void 0,void 0,(function*(){try{if(!c(this,yw,"f"))return void clearInterval(t);if(!(yield this.loadBalancerClient.checkServiceAvailability(2e3)))return void(e=0);e+=1,e>4&&(clearInterval(t),this.triggerRejoinEventIfAppropriate("loadbalancer available"))}catch(e){c(this,gw,"f").error("Check failed",{error:mr(e),case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"})}}))),3e3)}};gw=new WeakMap,vw=new WeakMap,yw=new WeakMap,bw=new WeakMap,ww=new WeakMap,Sw=i([at(),s(0,dt(Yn.Config)),s(1,dt(Yn.CallState)),s(2,dt(Yn.MyPeer)),s(3,dt(Yn.LoggerFactory)),s(4,dt(Yn.IntegrationsService)),s(5,dt(Yn.ProcessorsCache)),s(6,dt(Yn.MediaSoupEventHandler)),s(7,dt(Yn.ChannelEventHandler)),s(8,dt(Yn.ChannelStateSynchronizer)),s(9,dt(Yn.PeerTrackFactory)),s(10,dt(Yn.Peers)),s(11,dt(Yn.System)),s(12,dt(Yn.Media)),s(13,dt(Yn.Network)),s(14,dt(Yn.LoadBalancerApiClient)),s(15,dt(Yn.SocketIO)),s(16,dt(Yn.EventsQueue)),s(17,dt(Yn.ClientEventEmitter)),s(18,dt(Yn.InternalEventEmitter)),s(19,dt(Yn.StatsHandler)),s(20,dt(Yn.DataChannelsManager)),s(21,dt(Yn.WebRTCIssueDetector)),o("design:paramtypes",[Ct,ti,mp,Function,Kl,Vl,Kf,uf,af,Function,Object,eb,fp,Kh,Uy,Hh,nf,Rt,Rt,db,_w,sr])],Sw);var kw=Sw,Cw={},Rw={},Pw={},Tw={exports:{}};
|
|
32
32
|
/**
|
|
33
33
|
* @license
|
|
34
34
|
* Lodash <https://lodash.com/>
|
|
@@ -37,4 +37,4 @@ let Ks;Is.AwaitQueue=class{constructor(){this.pendingTasks=new Map,this.nextTask
|
|
|
37
37
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
38
38
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
39
39
|
*/
|
|
40
|
-
!function(e,t){(function(){var r,n="Expected a function",i="__lodash_hash_undefined__",s="__lodash_placeholder__",o=16,a=32,c=64,d=128,u=256,p=1/0,h=9007199254740991,f=NaN,m=4294967295,g=[["ary",d],["bind",1],["bindKey",2],["curry",8],["curryRight",o],["flip",512],["partial",a],["partialRight",c],["rearg",u]],v="[object Arguments]",y="[object Array]",b="[object Boolean]",w="[object Date]",_="[object Error]",S="[object Function]",k="[object GeneratorFunction]",C="[object Map]",R="[object Number]",P="[object Object]",T="[object Promise]",E="[object RegExp]",D="[object Set]",I="[object String]",M="[object Symbol]",x="[object WeakMap]",O="[object ArrayBuffer]",L="[object DataView]",A="[object Float32Array]",j="[object Float64Array]",F="[object Int8Array]",N="[object Int16Array]",B="[object Int32Array]",W="[object Uint8Array]",q="[object Uint8ClampedArray]",U="[object Uint16Array]",z="[object Uint32Array]",V=/\b__p \+= '';/g,H=/\b(__p \+=) '' \+/g,$=/(__e\(.*?\)|\b__t\)) \+\n'';/g,K=/&(?:amp|lt|gt|quot|#39);/g,G=/[&<>"']/g,Q=RegExp(K.source),J=RegExp(G.source),Y=/<%-([\s\S]+?)%>/g,Z=/<%([\s\S]+?)%>/g,X=/<%=([\s\S]+?)%>/g,ee=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,te=/^\w*$/,re=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ne=/[\\^$.*+?()[\]{}|]/g,ie=RegExp(ne.source),se=/^\s+/,oe=/\s/,ae=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ce=/\{\n\/\* \[wrapped with (.+)\] \*/,de=/,? & /,ue=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,le=/[()=,{}\[\]\/\s]/,pe=/\\(\\)?/g,he=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,fe=/\w*$/,me=/^[-+]0x[0-9a-f]+$/i,ge=/^0b[01]+$/i,ve=/^\[object .+?Constructor\]$/,ye=/^0o[0-7]+$/i,be=/^(?:0|[1-9]\d*)$/,we=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,_e=/($^)/,Se=/['\n\r\u2028\u2029\\]/g,ke="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ce="\\u2700-\\u27bf",Re="a-z\\xdf-\\xf6\\xf8-\\xff",Pe="A-Z\\xc0-\\xd6\\xd8-\\xde",Te="\\ufe0e\\ufe0f",Ee="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",De="['’]",Ie="[\\ud800-\\udfff]",Me="["+Ee+"]",xe="["+ke+"]",Oe="\\d+",Le="[\\u2700-\\u27bf]",Ae="["+Re+"]",je="[^\\ud800-\\udfff"+Ee+Oe+Ce+Re+Pe+"]",Fe="\\ud83c[\\udffb-\\udfff]",Ne="[^\\ud800-\\udfff]",Be="(?:\\ud83c[\\udde6-\\uddff]){2}",We="[\\ud800-\\udbff][\\udc00-\\udfff]",qe="["+Pe+"]",Ue="(?:"+Ae+"|"+je+")",ze="(?:"+qe+"|"+je+")",Ve="(?:['’](?:d|ll|m|re|s|t|ve))?",He="(?:['’](?:D|LL|M|RE|S|T|VE))?",$e="(?:"+xe+"|"+Fe+")"+"?",Ke="[\\ufe0e\\ufe0f]?",Ge=Ke+$e+("(?:\\u200d(?:"+[Ne,Be,We].join("|")+")"+Ke+$e+")*"),Qe="(?:"+[Le,Be,We].join("|")+")"+Ge,Je="(?:"+[Ne+xe+"?",xe,Be,We,Ie].join("|")+")",Ye=RegExp(De,"g"),Ze=RegExp(xe,"g"),Xe=RegExp(Fe+"(?="+Fe+")|"+Je+Ge,"g"),et=RegExp([qe+"?"+Ae+"+"+Ve+"(?="+[Me,qe,"$"].join("|")+")",ze+"+"+He+"(?="+[Me,qe+Ue,"$"].join("|")+")",qe+"?"+Ue+"+"+Ve,qe+"+"+He,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Oe,Qe].join("|"),"g"),tt=RegExp("[\\u200d\\ud800-\\udfff"+ke+Te+"]"),rt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],it=-1,st={};st[A]=st[j]=st[F]=st[N]=st[B]=st[W]=st[q]=st[U]=st[z]=!0,st[v]=st[y]=st[O]=st[b]=st[L]=st[w]=st[_]=st[S]=st[C]=st[R]=st[P]=st[E]=st[D]=st[I]=st[x]=!1;var ot={};ot[v]=ot[y]=ot[O]=ot[L]=ot[b]=ot[w]=ot[A]=ot[j]=ot[F]=ot[N]=ot[B]=ot[C]=ot[R]=ot[P]=ot[E]=ot[D]=ot[I]=ot[M]=ot[W]=ot[q]=ot[U]=ot[z]=!0,ot[_]=ot[S]=ot[x]=!1;var at={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ct=parseFloat,dt=parseInt,ut="object"==typeof l&&l&&l.Object===Object&&l,lt="object"==typeof self&&self&&self.Object===Object&&self,pt=ut||lt||Function("return this")(),ht=t&&!t.nodeType&&t,ft=ht&&e&&!e.nodeType&&e,mt=ft&&ft.exports===ht,gt=mt&&ut.process,vt=function(){try{var e=ft&&ft.require&&ft.require("util").types;return e||gt&>.binding&>.binding("util")}catch(e){}}(),yt=vt&&vt.isArrayBuffer,bt=vt&&vt.isDate,wt=vt&&vt.isMap,_t=vt&&vt.isRegExp,St=vt&&vt.isSet,kt=vt&&vt.isTypedArray;function Ct(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function Rt(e,t,r,n){for(var i=-1,s=null==e?0:e.length;++i<s;){var o=e[i];t(n,o,r(o),e)}return n}function Pt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}function Tt(e,t){for(var r=null==e?0:e.length;r--&&!1!==t(e[r],r,e););return e}function Et(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(!t(e[r],r,e))return!1;return!0}function Dt(e,t){for(var r=-1,n=null==e?0:e.length,i=0,s=[];++r<n;){var o=e[r];t(o,r,e)&&(s[i++]=o)}return s}function It(e,t){return!!(null==e?0:e.length)&&Wt(e,t,0)>-1}function Mt(e,t,r){for(var n=-1,i=null==e?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1}function xt(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}function Ot(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}function Lt(e,t,r,n){var i=-1,s=null==e?0:e.length;for(n&&s&&(r=e[++i]);++i<s;)r=t(r,e[i],i,e);return r}function At(e,t,r,n){var i=null==e?0:e.length;for(n&&i&&(r=e[--i]);i--;)r=t(r,e[i],i,e);return r}function jt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var Ft=Vt("length");function Nt(e,t,r){var n;return r(e,(function(e,r,i){if(t(e,r,i))return n=r,!1})),n}function Bt(e,t,r,n){for(var i=e.length,s=r+(n?1:-1);n?s--:++s<i;)if(t(e[s],s,e))return s;return-1}function Wt(e,t,r){return t==t?function(e,t,r){var n=r-1,i=e.length;for(;++n<i;)if(e[n]===t)return n;return-1}(e,t,r):Bt(e,Ut,r)}function qt(e,t,r,n){for(var i=r-1,s=e.length;++i<s;)if(n(e[i],t))return i;return-1}function Ut(e){return e!=e}function zt(e,t){var r=null==e?0:e.length;return r?Kt(e,t)/r:f}function Vt(e){return function(t){return null==t?r:t[e]}}function Ht(e){return function(t){return null==e?r:e[t]}}function $t(e,t,r,n,i){return i(e,(function(e,i,s){r=n?(n=!1,e):t(r,e,i,s)})),r}function Kt(e,t){for(var n,i=-1,s=e.length;++i<s;){var o=t(e[i]);o!==r&&(n=n===r?o:n+o)}return n}function Gt(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function Qt(e){return e?e.slice(0,hr(e)+1).replace(se,""):e}function Jt(e){return function(t){return e(t)}}function Yt(e,t){return xt(t,(function(t){return e[t]}))}function Zt(e,t){return e.has(t)}function Xt(e,t){for(var r=-1,n=e.length;++r<n&&Wt(t,e[r],0)>-1;);return r}function er(e,t){for(var r=e.length;r--&&Wt(t,e[r],0)>-1;);return r}function tr(e,t){for(var r=e.length,n=0;r--;)e[r]===t&&++n;return n}var rr=Ht({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),nr=Ht({"&":"&","<":"<",">":">",'"':""","'":"'"});function ir(e){return"\\"+at[e]}function sr(e){return tt.test(e)}function or(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function ar(e,t){return function(r){return e(t(r))}}function cr(e,t){for(var r=-1,n=e.length,i=0,o=[];++r<n;){var a=e[r];a!==t&&a!==s||(e[r]=s,o[i++]=r)}return o}function dr(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}function ur(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=[e,e]})),r}function lr(e){return sr(e)?function(e){var t=Xe.lastIndex=0;for(;Xe.test(e);)++t;return t}(e):Ft(e)}function pr(e){return sr(e)?function(e){return e.match(Xe)||[]}(e):function(e){return e.split("")}(e)}function hr(e){for(var t=e.length;t--&&oe.test(e.charAt(t)););return t}var fr=Ht({"&":"&","<":"<",">":">",""":'"',"'":"'"});var mr=function e(t){var l,oe=(t=null==t?pt:mr.defaults(pt.Object(),t,mr.pick(pt,nt))).Array,ke=t.Date,Ce=t.Error,Re=t.Function,Pe=t.Math,Te=t.Object,Ee=t.RegExp,De=t.String,Ie=t.TypeError,Me=oe.prototype,xe=Re.prototype,Oe=Te.prototype,Le=t["__core-js_shared__"],Ae=xe.toString,je=Oe.hasOwnProperty,Fe=0,Ne=(l=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||""))?"Symbol(src)_1."+l:"",Be=Oe.toString,We=Ae.call(Te),qe=pt._,Ue=Ee("^"+Ae.call(je).replace(ne,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ze=mt?t.Buffer:r,Ve=t.Symbol,He=t.Uint8Array,$e=ze?ze.allocUnsafe:r,Ke=ar(Te.getPrototypeOf,Te),Ge=Te.create,Qe=Oe.propertyIsEnumerable,Je=Me.splice,Xe=Ve?Ve.isConcatSpreadable:r,tt=Ve?Ve.iterator:r,at=Ve?Ve.toStringTag:r,ut=function(){try{var e=hs(Te,"defineProperty");return e({},"",{}),e}catch(e){}}(),lt=t.clearTimeout!==pt.clearTimeout&&t.clearTimeout,ht=ke&&ke.now!==pt.Date.now&&ke.now,ft=t.setTimeout!==pt.setTimeout&&t.setTimeout,gt=Pe.ceil,vt=Pe.floor,Ft=Te.getOwnPropertySymbols,Ht=ze?ze.isBuffer:r,gr=t.isFinite,vr=Me.join,yr=ar(Te.keys,Te),br=Pe.max,wr=Pe.min,_r=ke.now,Sr=t.parseInt,kr=Pe.random,Cr=Me.reverse,Rr=hs(t,"DataView"),Pr=hs(t,"Map"),Tr=hs(t,"Promise"),Er=hs(t,"Set"),Dr=hs(t,"WeakMap"),Ir=hs(Te,"create"),Mr=Dr&&new Dr,xr={},Or=Ws(Rr),Lr=Ws(Pr),Ar=Ws(Tr),jr=Ws(Er),Fr=Ws(Dr),Nr=Ve?Ve.prototype:r,Br=Nr?Nr.valueOf:r,Wr=Nr?Nr.toString:r;function qr(e){if(ia(e)&&!Ko(e)&&!(e instanceof Hr)){if(e instanceof Vr)return e;if(je.call(e,"__wrapped__"))return qs(e)}return new Vr(e)}var Ur=function(){function e(){}return function(t){if(!na(t))return{};if(Ge)return Ge(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function zr(){}function Vr(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}function Hr(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=m,this.__views__=[]}function $r(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Kr(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Gr(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Qr(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Gr;++t<r;)this.add(e[t])}function Jr(e){var t=this.__data__=new Kr(e);this.size=t.size}function Yr(e,t){var r=Ko(e),n=!r&&$o(e),i=!r&&!n&&Yo(e),s=!r&&!n&&!i&&pa(e),o=r||n||i||s,a=o?Gt(e.length,De):[],c=a.length;for(var d in e)!t&&!je.call(e,d)||o&&("length"==d||i&&("offset"==d||"parent"==d)||s&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||ws(d,c))||a.push(d);return a}function Zr(e){var t=e.length;return t?e[Jn(0,t-1)]:r}function Xr(e,t){return Fs(Mi(e),dn(t,0,e.length))}function en(e){return Fs(Mi(e))}function tn(e,t,n){(n!==r&&!zo(e[t],n)||n===r&&!(t in e))&&an(e,t,n)}function rn(e,t,n){var i=e[t];je.call(e,t)&&zo(i,n)&&(n!==r||t in e)||an(e,t,n)}function nn(e,t){for(var r=e.length;r--;)if(zo(e[r][0],t))return r;return-1}function sn(e,t,r,n){return fn(e,(function(e,i,s){t(n,e,r(e),s)})),n}function on(e,t){return e&&xi(t,La(t),e)}function an(e,t,r){"__proto__"==t&&ut?ut(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function cn(e,t){for(var n=-1,i=t.length,s=oe(i),o=null==e;++n<i;)s[n]=o?r:Da(e,t[n]);return s}function dn(e,t,n){return e==e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function un(e,t,n,i,s,o){var a,c=1&t,d=2&t,u=4&t;if(n&&(a=s?n(e,i,s,o):n(e)),a!==r)return a;if(!na(e))return e;var l=Ko(e);if(l){if(a=function(e){var t=e.length,r=new e.constructor(t);t&&"string"==typeof e[0]&&je.call(e,"index")&&(r.index=e.index,r.input=e.input);return r}(e),!c)return Mi(e,a)}else{var p=gs(e),h=p==S||p==k;if(Yo(e))return Ri(e,c);if(p==P||p==v||h&&!s){if(a=d||h?{}:ys(e),!c)return d?function(e,t){return xi(e,ms(e),t)}(e,function(e,t){return e&&xi(t,Aa(t),e)}(a,e)):function(e,t){return xi(e,fs(e),t)}(e,on(a,e))}else{if(!ot[p])return s?e:{};a=function(e,t,r){var n=e.constructor;switch(t){case O:return Pi(e);case b:case w:return new n(+e);case L:return function(e,t){var r=t?Pi(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case A:case j:case F:case N:case B:case W:case q:case U:case z:return Ti(e,r);case C:case D:return new n;case R:case I:return new n(e);case E:return function(e){var t=new e.constructor(e.source,fe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case M:return i=e,Br?Te(Br.call(i)):{}}var i}(e,p,c)}}o||(o=new Jr);var f=o.get(e);if(f)return f;o.set(e,a),da(e)?e.forEach((function(r){a.add(un(r,t,n,r,e,o))})):sa(e)&&e.forEach((function(r,i){a.set(i,un(r,t,n,i,e,o))}));var m=l?r:(u?d?os:ss:d?Aa:La)(e);return Pt(m||e,(function(r,i){m&&(r=e[i=r]),rn(a,i,un(r,t,n,i,e,o))})),a}function ln(e,t,n){var i=n.length;if(null==e)return!i;for(e=Te(e);i--;){var s=n[i],o=t[s],a=e[s];if(a===r&&!(s in e)||!o(a))return!1}return!0}function pn(e,t,i){if("function"!=typeof e)throw new Ie(n);return Os((function(){e.apply(r,i)}),t)}function hn(e,t,r,n){var i=-1,s=It,o=!0,a=e.length,c=[],d=t.length;if(!a)return c;r&&(t=xt(t,Jt(r))),n?(s=Mt,o=!1):t.length>=200&&(s=Zt,o=!1,t=new Qr(t));e:for(;++i<a;){var u=e[i],l=null==r?u:r(u);if(u=n||0!==u?u:0,o&&l==l){for(var p=d;p--;)if(t[p]===l)continue e;c.push(u)}else s(t,l,n)||c.push(u)}return c}qr.templateSettings={escape:Y,evaluate:Z,interpolate:X,variable:"",imports:{_:qr}},qr.prototype=zr.prototype,qr.prototype.constructor=qr,Vr.prototype=Ur(zr.prototype),Vr.prototype.constructor=Vr,Hr.prototype=Ur(zr.prototype),Hr.prototype.constructor=Hr,$r.prototype.clear=function(){this.__data__=Ir?Ir(null):{},this.size=0},$r.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},$r.prototype.get=function(e){var t=this.__data__;if(Ir){var n=t[e];return n===i?r:n}return je.call(t,e)?t[e]:r},$r.prototype.has=function(e){var t=this.__data__;return Ir?t[e]!==r:je.call(t,e)},$r.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Ir&&t===r?i:t,this},Kr.prototype.clear=function(){this.__data__=[],this.size=0},Kr.prototype.delete=function(e){var t=this.__data__,r=nn(t,e);return!(r<0)&&(r==t.length-1?t.pop():Je.call(t,r,1),--this.size,!0)},Kr.prototype.get=function(e){var t=this.__data__,n=nn(t,e);return n<0?r:t[n][1]},Kr.prototype.has=function(e){return nn(this.__data__,e)>-1},Kr.prototype.set=function(e,t){var r=this.__data__,n=nn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},Gr.prototype.clear=function(){this.size=0,this.__data__={hash:new $r,map:new(Pr||Kr),string:new $r}},Gr.prototype.delete=function(e){var t=ls(this,e).delete(e);return this.size-=t?1:0,t},Gr.prototype.get=function(e){return ls(this,e).get(e)},Gr.prototype.has=function(e){return ls(this,e).has(e)},Gr.prototype.set=function(e,t){var r=ls(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Qr.prototype.add=Qr.prototype.push=function(e){return this.__data__.set(e,i),this},Qr.prototype.has=function(e){return this.__data__.has(e)},Jr.prototype.clear=function(){this.__data__=new Kr,this.size=0},Jr.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Jr.prototype.get=function(e){return this.__data__.get(e)},Jr.prototype.has=function(e){return this.__data__.has(e)},Jr.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Kr){var n=r.__data__;if(!Pr||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Gr(n)}return r.set(e,t),this.size=r.size,this};var fn=Ai(Sn),mn=Ai(kn,!0);function gn(e,t){var r=!0;return fn(e,(function(e,n,i){return r=!!t(e,n,i)})),r}function vn(e,t,n){for(var i=-1,s=e.length;++i<s;){var o=e[i],a=t(o);if(null!=a&&(c===r?a==a&&!la(a):n(a,c)))var c=a,d=o}return d}function yn(e,t){var r=[];return fn(e,(function(e,n,i){t(e,n,i)&&r.push(e)})),r}function bn(e,t,r,n,i){var s=-1,o=e.length;for(r||(r=bs),i||(i=[]);++s<o;){var a=e[s];t>0&&r(a)?t>1?bn(a,t-1,r,n,i):Ot(i,a):n||(i[i.length]=a)}return i}var wn=ji(),_n=ji(!0);function Sn(e,t){return e&&wn(e,t,La)}function kn(e,t){return e&&_n(e,t,La)}function Cn(e,t){return Dt(t,(function(t){return ea(e[t])}))}function Rn(e,t){for(var n=0,i=(t=_i(t,e)).length;null!=e&&n<i;)e=e[Bs(t[n++])];return n&&n==i?e:r}function Pn(e,t,r){var n=t(e);return Ko(e)?n:Ot(n,r(e))}function Tn(e){return null==e?e===r?"[object Undefined]":"[object Null]":at&&at in Te(e)?function(e){var t=je.call(e,at),n=e[at];try{e[at]=r;var i=!0}catch(e){}var s=Be.call(e);i&&(t?e[at]=n:delete e[at]);return s}(e):function(e){return Be.call(e)}(e)}function En(e,t){return e>t}function Dn(e,t){return null!=e&&je.call(e,t)}function In(e,t){return null!=e&&t in Te(e)}function Mn(e,t,n){for(var i=n?Mt:It,s=e[0].length,o=e.length,a=o,c=oe(o),d=1/0,u=[];a--;){var l=e[a];a&&t&&(l=xt(l,Jt(t))),d=wr(l.length,d),c[a]=!n&&(t||s>=120&&l.length>=120)?new Qr(a&&l):r}l=e[0];var p=-1,h=c[0];e:for(;++p<s&&u.length<d;){var f=l[p],m=t?t(f):f;if(f=n||0!==f?f:0,!(h?Zt(h,m):i(u,m,n))){for(a=o;--a;){var g=c[a];if(!(g?Zt(g,m):i(e[a],m,n)))continue e}h&&h.push(m),u.push(f)}}return u}function xn(e,t,n){var i=null==(e=Ds(e,t=_i(t,e)))?e:e[Bs(Zs(t))];return null==i?r:Ct(i,e,n)}function On(e){return ia(e)&&Tn(e)==v}function Ln(e,t,n,i,s){return e===t||(null==e||null==t||!ia(e)&&!ia(t)?e!=e&&t!=t:function(e,t,n,i,s,o){var a=Ko(e),c=Ko(t),d=a?y:gs(e),u=c?y:gs(t),l=(d=d==v?P:d)==P,p=(u=u==v?P:u)==P,h=d==u;if(h&&Yo(e)){if(!Yo(t))return!1;a=!0,l=!1}if(h&&!l)return o||(o=new Jr),a||pa(e)?ns(e,t,n,i,s,o):function(e,t,r,n,i,s,o){switch(r){case L:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case O:return!(e.byteLength!=t.byteLength||!s(new He(e),new He(t)));case b:case w:case R:return zo(+e,+t);case _:return e.name==t.name&&e.message==t.message;case E:case I:return e==t+"";case C:var a=or;case D:var c=1&n;if(a||(a=dr),e.size!=t.size&&!c)return!1;var d=o.get(e);if(d)return d==t;n|=2,o.set(e,t);var u=ns(a(e),a(t),n,i,s,o);return o.delete(e),u;case M:if(Br)return Br.call(e)==Br.call(t)}return!1}(e,t,d,n,i,s,o);if(!(1&n)){var f=l&&je.call(e,"__wrapped__"),m=p&&je.call(t,"__wrapped__");if(f||m){var g=f?e.value():e,S=m?t.value():t;return o||(o=new Jr),s(g,S,n,i,o)}}if(!h)return!1;return o||(o=new Jr),function(e,t,n,i,s,o){var a=1&n,c=ss(e),d=c.length,u=ss(t).length;if(d!=u&&!a)return!1;var l=d;for(;l--;){var p=c[l];if(!(a?p in t:je.call(t,p)))return!1}var h=o.get(e),f=o.get(t);if(h&&f)return h==t&&f==e;var m=!0;o.set(e,t),o.set(t,e);var g=a;for(;++l<d;){var v=e[p=c[l]],y=t[p];if(i)var b=a?i(y,v,p,t,e,o):i(v,y,p,e,t,o);if(!(b===r?v===y||s(v,y,n,i,o):b)){m=!1;break}g||(g="constructor"==p)}if(m&&!g){var w=e.constructor,_=t.constructor;w==_||!("constructor"in e)||!("constructor"in t)||"function"==typeof w&&w instanceof w&&"function"==typeof _&&_ instanceof _||(m=!1)}return o.delete(e),o.delete(t),m}(e,t,n,i,s,o)}(e,t,n,i,Ln,s))}function An(e,t,n,i){var s=n.length,o=s,a=!i;if(null==e)return!o;for(e=Te(e);s--;){var c=n[s];if(a&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++s<o;){var d=(c=n[s])[0],u=e[d],l=c[1];if(a&&c[2]){if(u===r&&!(d in e))return!1}else{var p=new Jr;if(i)var h=i(u,l,d,e,t,p);if(!(h===r?Ln(l,u,3,i,p):h))return!1}}return!0}function jn(e){return!(!na(e)||(t=e,Ne&&Ne in t))&&(ea(e)?Ue:ve).test(Ws(e));var t}function Fn(e){return"function"==typeof e?e:null==e?oc:"object"==typeof e?Ko(e)?zn(e[0],e[1]):Un(e):mc(e)}function Nn(e){if(!Rs(e))return yr(e);var t=[];for(var r in Te(e))je.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Bn(e){if(!na(e))return function(e){var t=[];if(null!=e)for(var r in Te(e))t.push(r);return t}(e);var t=Rs(e),r=[];for(var n in e)("constructor"!=n||!t&&je.call(e,n))&&r.push(n);return r}function Wn(e,t){return e<t}function qn(e,t){var r=-1,n=Qo(e)?oe(e.length):[];return fn(e,(function(e,i,s){n[++r]=t(e,i,s)})),n}function Un(e){var t=ps(e);return 1==t.length&&t[0][2]?Ts(t[0][0],t[0][1]):function(r){return r===e||An(r,e,t)}}function zn(e,t){return Ss(e)&&Ps(t)?Ts(Bs(e),t):function(n){var i=Da(n,e);return i===r&&i===t?Ia(n,e):Ln(t,i,3)}}function Vn(e,t,n,i,s){e!==t&&wn(t,(function(o,a){if(s||(s=new Jr),na(o))!function(e,t,n,i,s,o,a){var c=Ms(e,n),d=Ms(t,n),u=a.get(d);if(u)return void tn(e,n,u);var l=o?o(c,d,n+"",e,t,a):r,p=l===r;if(p){var h=Ko(d),f=!h&&Yo(d),m=!h&&!f&&pa(d);l=d,h||f||m?Ko(c)?l=c:Jo(c)?l=Mi(c):f?(p=!1,l=Ri(d,!0)):m?(p=!1,l=Ti(d,!0)):l=[]:aa(d)||$o(d)?(l=c,$o(c)?l=wa(c):na(c)&&!ea(c)||(l=ys(d))):p=!1}p&&(a.set(d,l),s(l,d,i,o,a),a.delete(d));tn(e,n,l)}(e,t,a,n,Vn,i,s);else{var c=i?i(Ms(e,a),o,a+"",e,t,s):r;c===r&&(c=o),tn(e,a,c)}}),Aa)}function Hn(e,t){var n=e.length;if(n)return ws(t+=t<0?n:0,n)?e[t]:r}function $n(e,t,r){t=t.length?xt(t,(function(e){return Ko(e)?function(t){return Rn(t,1===e.length?e[0]:e)}:e})):[oc];var n=-1;t=xt(t,Jt(us()));var i=qn(e,(function(e,r,i){var s=xt(t,(function(t){return t(e)}));return{criteria:s,index:++n,value:e}}));return function(e,t){var r=e.length;for(e.sort(t);r--;)e[r]=e[r].value;return e}(i,(function(e,t){return function(e,t,r){var n=-1,i=e.criteria,s=t.criteria,o=i.length,a=r.length;for(;++n<o;){var c=Ei(i[n],s[n]);if(c)return n>=a?c:c*("desc"==r[n]?-1:1)}return e.index-t.index}(e,t,r)}))}function Kn(e,t,r){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=Rn(e,o);r(a,o)&&ti(s,_i(o,e),a)}return s}function Gn(e,t,r,n){var i=n?qt:Wt,s=-1,o=t.length,a=e;for(e===t&&(t=Mi(t)),r&&(a=xt(e,Jt(r)));++s<o;)for(var c=0,d=t[s],u=r?r(d):d;(c=i(a,u,c,n))>-1;)a!==e&&Je.call(a,c,1),Je.call(e,c,1);return e}function Qn(e,t){for(var r=e?t.length:0,n=r-1;r--;){var i=t[r];if(r==n||i!==s){var s=i;ws(i)?Je.call(e,i,1):hi(e,i)}}return e}function Jn(e,t){return e+vt(kr()*(t-e+1))}function Yn(e,t){var r="";if(!e||t<1||t>h)return r;do{t%2&&(r+=e),(t=vt(t/2))&&(e+=e)}while(t);return r}function Zn(e,t){return Ls(Es(e,t,oc),e+"")}function Xn(e){return Zr(za(e))}function ei(e,t){var r=za(e);return Fs(r,dn(t,0,r.length))}function ti(e,t,n,i){if(!na(e))return e;for(var s=-1,o=(t=_i(t,e)).length,a=o-1,c=e;null!=c&&++s<o;){var d=Bs(t[s]),u=n;if("__proto__"===d||"constructor"===d||"prototype"===d)return e;if(s!=a){var l=c[d];(u=i?i(l,d,c):r)===r&&(u=na(l)?l:ws(t[s+1])?[]:{})}rn(c,d,u),c=c[d]}return e}var ri=Mr?function(e,t){return Mr.set(e,t),e}:oc,ni=ut?function(e,t){return ut(e,"toString",{configurable:!0,enumerable:!1,value:nc(t),writable:!0})}:oc;function ii(e){return Fs(za(e))}function si(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var s=oe(i);++n<i;)s[n]=e[n+t];return s}function oi(e,t){var r;return fn(e,(function(e,n,i){return!(r=t(e,n,i))})),!!r}function ai(e,t,r){var n=0,i=null==e?n:e.length;if("number"==typeof t&&t==t&&i<=2147483647){for(;n<i;){var s=n+i>>>1,o=e[s];null!==o&&!la(o)&&(r?o<=t:o<t)?n=s+1:i=s}return i}return ci(e,t,oc,r)}function ci(e,t,n,i){var s=0,o=null==e?0:e.length;if(0===o)return 0;for(var a=(t=n(t))!=t,c=null===t,d=la(t),u=t===r;s<o;){var l=vt((s+o)/2),p=n(e[l]),h=p!==r,f=null===p,m=p==p,g=la(p);if(a)var v=i||m;else v=u?m&&(i||h):c?m&&h&&(i||!f):d?m&&h&&!f&&(i||!g):!f&&!g&&(i?p<=t:p<t);v?s=l+1:o=l}return wr(o,4294967294)}function di(e,t){for(var r=-1,n=e.length,i=0,s=[];++r<n;){var o=e[r],a=t?t(o):o;if(!r||!zo(a,c)){var c=a;s[i++]=0===o?0:o}}return s}function ui(e){return"number"==typeof e?e:la(e)?f:+e}function li(e){if("string"==typeof e)return e;if(Ko(e))return xt(e,li)+"";if(la(e))return Wr?Wr.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function pi(e,t,r){var n=-1,i=It,s=e.length,o=!0,a=[],c=a;if(r)o=!1,i=Mt;else if(s>=200){var d=t?null:Yi(e);if(d)return dr(d);o=!1,i=Zt,c=new Qr}else c=t?[]:a;e:for(;++n<s;){var u=e[n],l=t?t(u):u;if(u=r||0!==u?u:0,o&&l==l){for(var p=c.length;p--;)if(c[p]===l)continue e;t&&c.push(l),a.push(u)}else i(c,l,r)||(c!==a&&c.push(l),a.push(u))}return a}function hi(e,t){return null==(e=Ds(e,t=_i(t,e)))||delete e[Bs(Zs(t))]}function fi(e,t,r,n){return ti(e,t,r(Rn(e,t)),n)}function mi(e,t,r,n){for(var i=e.length,s=n?i:-1;(n?s--:++s<i)&&t(e[s],s,e););return r?si(e,n?0:s,n?s+1:i):si(e,n?s+1:0,n?i:s)}function gi(e,t){var r=e;return r instanceof Hr&&(r=r.value()),Lt(t,(function(e,t){return t.func.apply(t.thisArg,Ot([e],t.args))}),r)}function vi(e,t,r){var n=e.length;if(n<2)return n?pi(e[0]):[];for(var i=-1,s=oe(n);++i<n;)for(var o=e[i],a=-1;++a<n;)a!=i&&(s[i]=hn(s[i]||o,e[a],t,r));return pi(bn(s,1),t,r)}function yi(e,t,n){for(var i=-1,s=e.length,o=t.length,a={};++i<s;){var c=i<o?t[i]:r;n(a,e[i],c)}return a}function bi(e){return Jo(e)?e:[]}function wi(e){return"function"==typeof e?e:oc}function _i(e,t){return Ko(e)?e:Ss(e,t)?[e]:Ns(_a(e))}var Si=Zn;function ki(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:si(e,t,n)}var Ci=lt||function(e){return pt.clearTimeout(e)};function Ri(e,t){if(t)return e.slice();var r=e.length,n=$e?$e(r):new e.constructor(r);return e.copy(n),n}function Pi(e){var t=new e.constructor(e.byteLength);return new He(t).set(new He(e)),t}function Ti(e,t){var r=t?Pi(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Ei(e,t){if(e!==t){var n=e!==r,i=null===e,s=e==e,o=la(e),a=t!==r,c=null===t,d=t==t,u=la(t);if(!c&&!u&&!o&&e>t||o&&a&&d&&!c&&!u||i&&a&&d||!n&&d||!s)return 1;if(!i&&!o&&!u&&e<t||u&&n&&s&&!i&&!o||c&&n&&s||!a&&s||!d)return-1}return 0}function Di(e,t,r,n){for(var i=-1,s=e.length,o=r.length,a=-1,c=t.length,d=br(s-o,0),u=oe(c+d),l=!n;++a<c;)u[a]=t[a];for(;++i<o;)(l||i<s)&&(u[r[i]]=e[i]);for(;d--;)u[a++]=e[i++];return u}function Ii(e,t,r,n){for(var i=-1,s=e.length,o=-1,a=r.length,c=-1,d=t.length,u=br(s-a,0),l=oe(u+d),p=!n;++i<u;)l[i]=e[i];for(var h=i;++c<d;)l[h+c]=t[c];for(;++o<a;)(p||i<s)&&(l[h+r[o]]=e[i++]);return l}function Mi(e,t){var r=-1,n=e.length;for(t||(t=oe(n));++r<n;)t[r]=e[r];return t}function xi(e,t,n,i){var s=!n;n||(n={});for(var o=-1,a=t.length;++o<a;){var c=t[o],d=i?i(n[c],e[c],c,n,e):r;d===r&&(d=e[c]),s?an(n,c,d):rn(n,c,d)}return n}function Oi(e,t){return function(r,n){var i=Ko(r)?Rt:sn,s=t?t():{};return i(r,e,us(n,2),s)}}function Li(e){return Zn((function(t,n){var i=-1,s=n.length,o=s>1?n[s-1]:r,a=s>2?n[2]:r;for(o=e.length>3&&"function"==typeof o?(s--,o):r,a&&_s(n[0],n[1],a)&&(o=s<3?r:o,s=1),t=Te(t);++i<s;){var c=n[i];c&&e(t,c,i,o)}return t}))}function Ai(e,t){return function(r,n){if(null==r)return r;if(!Qo(r))return e(r,n);for(var i=r.length,s=t?i:-1,o=Te(r);(t?s--:++s<i)&&!1!==n(o[s],s,o););return r}}function ji(e){return function(t,r,n){for(var i=-1,s=Te(t),o=n(t),a=o.length;a--;){var c=o[e?a:++i];if(!1===r(s[c],c,s))break}return t}}function Fi(e){return function(t){var n=sr(t=_a(t))?pr(t):r,i=n?n[0]:t.charAt(0),s=n?ki(n,1).join(""):t.slice(1);return i[e]()+s}}function Ni(e){return function(t){return Lt(ec($a(t).replace(Ye,"")),e,"")}}function Bi(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=Ur(e.prototype),n=e.apply(r,t);return na(n)?n:r}}function Wi(e){return function(t,n,i){var s=Te(t);if(!Qo(t)){var o=us(n,3);t=La(t),n=function(e){return o(s[e],e,s)}}var a=e(t,n,i);return a>-1?s[o?t[a]:a]:r}}function qi(e){return is((function(t){var i=t.length,s=i,o=Vr.prototype.thru;for(e&&t.reverse();s--;){var a=t[s];if("function"!=typeof a)throw new Ie(n);if(o&&!c&&"wrapper"==cs(a))var c=new Vr([],!0)}for(s=c?s:i;++s<i;){var d=cs(a=t[s]),u="wrapper"==d?as(a):r;c=u&&ks(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?c[cs(u[0])].apply(c,u[3]):1==a.length&&ks(a)?c[d]():c.thru(a)}return function(){var e=arguments,r=e[0];if(c&&1==e.length&&Ko(r))return c.plant(r).value();for(var n=0,s=i?t[n].apply(this,e):r;++n<i;)s=t[n].call(this,s);return s}}))}function Ui(e,t,n,i,s,o,a,c,u,l){var p=t&d,h=1&t,f=2&t,m=24&t,g=512&t,v=f?r:Bi(e);return function r(){for(var d=arguments.length,y=oe(d),b=d;b--;)y[b]=arguments[b];if(m)var w=ds(r),_=tr(y,w);if(i&&(y=Di(y,i,s,m)),o&&(y=Ii(y,o,a,m)),d-=_,m&&d<l){var S=cr(y,w);return Qi(e,t,Ui,r.placeholder,n,y,S,c,u,l-d)}var k=h?n:this,C=f?k[e]:e;return d=y.length,c?y=Is(y,c):g&&d>1&&y.reverse(),p&&u<d&&(y.length=u),this&&this!==pt&&this instanceof r&&(C=v||Bi(C)),C.apply(k,y)}}function zi(e,t){return function(r,n){return function(e,t,r,n){return Sn(e,(function(e,i,s){t(n,r(e),i,s)})),n}(r,e,t(n),{})}}function Vi(e,t){return function(n,i){var s;if(n===r&&i===r)return t;if(n!==r&&(s=n),i!==r){if(s===r)return i;"string"==typeof n||"string"==typeof i?(n=li(n),i=li(i)):(n=ui(n),i=ui(i)),s=e(n,i)}return s}}function Hi(e){return is((function(t){return t=xt(t,Jt(us())),Zn((function(r){var n=this;return e(t,(function(e){return Ct(e,n,r)}))}))}))}function $i(e,t){var n=(t=t===r?" ":li(t)).length;if(n<2)return n?Yn(t,e):t;var i=Yn(t,gt(e/lr(t)));return sr(t)?ki(pr(i),0,e).join(""):i.slice(0,e)}function Ki(e){return function(t,n,i){return i&&"number"!=typeof i&&_s(t,n,i)&&(n=i=r),t=ga(t),n===r?(n=t,t=0):n=ga(n),function(e,t,r,n){for(var i=-1,s=br(gt((t-e)/(r||1)),0),o=oe(s);s--;)o[n?s:++i]=e,e+=r;return o}(t,n,i=i===r?t<n?1:-1:ga(i),e)}}function Gi(e){return function(t,r){return"string"==typeof t&&"string"==typeof r||(t=ba(t),r=ba(r)),e(t,r)}}function Qi(e,t,n,i,s,o,d,u,l,p){var h=8&t;t|=h?a:c,4&(t&=~(h?c:a))||(t&=-4);var f=[e,t,s,h?o:r,h?d:r,h?r:o,h?r:d,u,l,p],m=n.apply(r,f);return ks(e)&&xs(m,f),m.placeholder=i,As(m,e,t)}function Ji(e){var t=Pe[e];return function(e,r){if(e=ba(e),(r=null==r?0:wr(va(r),292))&&gr(e)){var n=(_a(e)+"e").split("e");return+((n=(_a(t(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return t(e)}}var Yi=Er&&1/dr(new Er([,-0]))[1]==p?function(e){return new Er(e)}:lc;function Zi(e){return function(t){var r=gs(t);return r==C?or(t):r==D?ur(t):function(e,t){return xt(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Xi(e,t,i,l,p,h,f,m){var g=2&t;if(!g&&"function"!=typeof e)throw new Ie(n);var v=l?l.length:0;if(v||(t&=-97,l=p=r),f=f===r?f:br(va(f),0),m=m===r?m:va(m),v-=p?p.length:0,t&c){var y=l,b=p;l=p=r}var w=g?r:as(e),_=[e,t,i,l,p,y,b,h,f,m];if(w&&function(e,t){var r=e[1],n=t[1],i=r|n,o=i<131,a=n==d&&8==r||n==d&&r==u&&e[7].length<=t[8]||384==n&&t[7].length<=t[8]&&8==r;if(!o&&!a)return e;1&n&&(e[2]=t[2],i|=1&r?0:4);var c=t[3];if(c){var l=e[3];e[3]=l?Di(l,c,t[4]):c,e[4]=l?cr(e[3],s):t[4]}(c=t[5])&&(l=e[5],e[5]=l?Ii(l,c,t[6]):c,e[6]=l?cr(e[5],s):t[6]);(c=t[7])&&(e[7]=c);n&d&&(e[8]=null==e[8]?t[8]:wr(e[8],t[8]));null==e[9]&&(e[9]=t[9]);e[0]=t[0],e[1]=i}(_,w),e=_[0],t=_[1],i=_[2],l=_[3],p=_[4],!(m=_[9]=_[9]===r?g?0:e.length:br(_[9]-v,0))&&24&t&&(t&=-25),t&&1!=t)S=8==t||t==o?function(e,t,n){var i=Bi(e);return function s(){for(var o=arguments.length,a=oe(o),c=o,d=ds(s);c--;)a[c]=arguments[c];var u=o<3&&a[0]!==d&&a[o-1]!==d?[]:cr(a,d);return(o-=u.length)<n?Qi(e,t,Ui,s.placeholder,r,a,u,r,r,n-o):Ct(this&&this!==pt&&this instanceof s?i:e,this,a)}}(e,t,m):t!=a&&33!=t||p.length?Ui.apply(r,_):function(e,t,r,n){var i=1&t,s=Bi(e);return function t(){for(var o=-1,a=arguments.length,c=-1,d=n.length,u=oe(d+a),l=this&&this!==pt&&this instanceof t?s:e;++c<d;)u[c]=n[c];for(;a--;)u[c++]=arguments[++o];return Ct(l,i?r:this,u)}}(e,t,i,l);else var S=function(e,t,r){var n=1&t,i=Bi(e);return function t(){return(this&&this!==pt&&this instanceof t?i:e).apply(n?r:this,arguments)}}(e,t,i);return As((w?ri:xs)(S,_),e,t)}function es(e,t,n,i){return e===r||zo(e,Oe[n])&&!je.call(i,n)?t:e}function ts(e,t,n,i,s,o){return na(e)&&na(t)&&(o.set(t,e),Vn(e,t,r,ts,o),o.delete(t)),e}function rs(e){return aa(e)?r:e}function ns(e,t,n,i,s,o){var a=1&n,c=e.length,d=t.length;if(c!=d&&!(a&&d>c))return!1;var u=o.get(e),l=o.get(t);if(u&&l)return u==t&&l==e;var p=-1,h=!0,f=2&n?new Qr:r;for(o.set(e,t),o.set(t,e);++p<c;){var m=e[p],g=t[p];if(i)var v=a?i(g,m,p,t,e,o):i(m,g,p,e,t,o);if(v!==r){if(v)continue;h=!1;break}if(f){if(!jt(t,(function(e,t){if(!Zt(f,t)&&(m===e||s(m,e,n,i,o)))return f.push(t)}))){h=!1;break}}else if(m!==g&&!s(m,g,n,i,o)){h=!1;break}}return o.delete(e),o.delete(t),h}function is(e){return Ls(Es(e,r,Ks),e+"")}function ss(e){return Pn(e,La,fs)}function os(e){return Pn(e,Aa,ms)}var as=Mr?function(e){return Mr.get(e)}:lc;function cs(e){for(var t=e.name+"",r=xr[t],n=je.call(xr,t)?r.length:0;n--;){var i=r[n],s=i.func;if(null==s||s==e)return i.name}return t}function ds(e){return(je.call(qr,"placeholder")?qr:e).placeholder}function us(){var e=qr.iteratee||ac;return e=e===ac?Fn:e,arguments.length?e(arguments[0],arguments[1]):e}function ls(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function ps(e){for(var t=La(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Ps(i)]}return t}function hs(e,t){var n=function(e,t){return null==e?r:e[t]}(e,t);return jn(n)?n:r}var fs=Ft?function(e){return null==e?[]:(e=Te(e),Dt(Ft(e),(function(t){return Qe.call(e,t)})))}:yc,ms=Ft?function(e){for(var t=[];e;)Ot(t,fs(e)),e=Ke(e);return t}:yc,gs=Tn;function vs(e,t,r){for(var n=-1,i=(t=_i(t,e)).length,s=!1;++n<i;){var o=Bs(t[n]);if(!(s=null!=e&&r(e,o)))break;e=e[o]}return s||++n!=i?s:!!(i=null==e?0:e.length)&&ra(i)&&ws(o,i)&&(Ko(e)||$o(e))}function ys(e){return"function"!=typeof e.constructor||Rs(e)?{}:Ur(Ke(e))}function bs(e){return Ko(e)||$o(e)||!!(Xe&&e&&e[Xe])}function ws(e,t){var r=typeof e;return!!(t=null==t?h:t)&&("number"==r||"symbol"!=r&&be.test(e))&&e>-1&&e%1==0&&e<t}function _s(e,t,r){if(!na(r))return!1;var n=typeof t;return!!("number"==n?Qo(r)&&ws(t,r.length):"string"==n&&t in r)&&zo(r[t],e)}function Ss(e,t){if(Ko(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!la(e))||(te.test(e)||!ee.test(e)||null!=t&&e in Te(t))}function ks(e){var t=cs(e),r=qr[t];if("function"!=typeof r||!(t in Hr.prototype))return!1;if(e===r)return!0;var n=as(r);return!!n&&e===n[0]}(Rr&&gs(new Rr(new ArrayBuffer(1)))!=L||Pr&&gs(new Pr)!=C||Tr&&gs(Tr.resolve())!=T||Er&&gs(new Er)!=D||Dr&&gs(new Dr)!=x)&&(gs=function(e){var t=Tn(e),n=t==P?e.constructor:r,i=n?Ws(n):"";if(i)switch(i){case Or:return L;case Lr:return C;case Ar:return T;case jr:return D;case Fr:return x}return t});var Cs=Le?ea:bc;function Rs(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Oe)}function Ps(e){return e==e&&!na(e)}function Ts(e,t){return function(n){return null!=n&&(n[e]===t&&(t!==r||e in Te(n)))}}function Es(e,t,n){return t=br(t===r?e.length-1:t,0),function(){for(var r=arguments,i=-1,s=br(r.length-t,0),o=oe(s);++i<s;)o[i]=r[t+i];i=-1;for(var a=oe(t+1);++i<t;)a[i]=r[i];return a[t]=n(o),Ct(e,this,a)}}function Ds(e,t){return t.length<2?e:Rn(e,si(t,0,-1))}function Is(e,t){for(var n=e.length,i=wr(t.length,n),s=Mi(e);i--;){var o=t[i];e[i]=ws(o,n)?s[o]:r}return e}function Ms(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var xs=js(ri),Os=ft||function(e,t){return pt.setTimeout(e,t)},Ls=js(ni);function As(e,t,r){var n=t+"";return Ls(e,function(e,t){var r=t.length;if(!r)return e;var n=r-1;return t[n]=(r>1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(ae,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return Pt(g,(function(r){var n="_."+r[0];t&r[1]&&!It(e,n)&&e.push(n)})),e.sort()}(function(e){var t=e.match(ce);return t?t[1].split(de):[]}(n),r)))}function js(e){var t=0,n=0;return function(){var i=_r(),s=16-(i-n);if(n=i,s>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Fs(e,t){var n=-1,i=e.length,s=i-1;for(t=t===r?i:t;++n<t;){var o=Jn(n,s),a=e[o];e[o]=e[n],e[n]=a}return e.length=t,e}var Ns=function(e){var t=Fo(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(re,(function(e,r,n,i){t.push(n?i.replace(pe,"$1"):r||e)})),t}));function Bs(e){if("string"==typeof e||la(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Ws(e){if(null!=e){try{return Ae.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function qs(e){if(e instanceof Hr)return e.clone();var t=new Vr(e.__wrapped__,e.__chain__);return t.__actions__=Mi(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var Us=Zn((function(e,t){return Jo(e)?hn(e,bn(t,1,Jo,!0)):[]})),zs=Zn((function(e,t){var n=Zs(t);return Jo(n)&&(n=r),Jo(e)?hn(e,bn(t,1,Jo,!0),us(n,2)):[]})),Vs=Zn((function(e,t){var n=Zs(t);return Jo(n)&&(n=r),Jo(e)?hn(e,bn(t,1,Jo,!0),r,n):[]}));function Hs(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:va(r);return i<0&&(i=br(n+i,0)),Bt(e,us(t,3),i)}function $s(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var s=i-1;return n!==r&&(s=va(n),s=n<0?br(i+s,0):wr(s,i-1)),Bt(e,us(t,3),s,!0)}function Ks(e){return(null==e?0:e.length)?bn(e,1):[]}function Gs(e){return e&&e.length?e[0]:r}var Qs=Zn((function(e){var t=xt(e,bi);return t.length&&t[0]===e[0]?Mn(t):[]})),Js=Zn((function(e){var t=Zs(e),n=xt(e,bi);return t===Zs(n)?t=r:n.pop(),n.length&&n[0]===e[0]?Mn(n,us(t,2)):[]})),Ys=Zn((function(e){var t=Zs(e),n=xt(e,bi);return(t="function"==typeof t?t:r)&&n.pop(),n.length&&n[0]===e[0]?Mn(n,r,t):[]}));function Zs(e){var t=null==e?0:e.length;return t?e[t-1]:r}var Xs=Zn(eo);function eo(e,t){return e&&e.length&&t&&t.length?Gn(e,t):e}var to=is((function(e,t){var r=null==e?0:e.length,n=cn(e,t);return Qn(e,xt(t,(function(e){return ws(e,r)?+e:e})).sort(Ei)),n}));function ro(e){return null==e?e:Cr.call(e)}var no=Zn((function(e){return pi(bn(e,1,Jo,!0))})),io=Zn((function(e){var t=Zs(e);return Jo(t)&&(t=r),pi(bn(e,1,Jo,!0),us(t,2))})),so=Zn((function(e){var t=Zs(e);return t="function"==typeof t?t:r,pi(bn(e,1,Jo,!0),r,t)}));function oo(e){if(!e||!e.length)return[];var t=0;return e=Dt(e,(function(e){if(Jo(e))return t=br(e.length,t),!0})),Gt(t,(function(t){return xt(e,Vt(t))}))}function ao(e,t){if(!e||!e.length)return[];var n=oo(e);return null==t?n:xt(n,(function(e){return Ct(t,r,e)}))}var co=Zn((function(e,t){return Jo(e)?hn(e,t):[]})),uo=Zn((function(e){return vi(Dt(e,Jo))})),lo=Zn((function(e){var t=Zs(e);return Jo(t)&&(t=r),vi(Dt(e,Jo),us(t,2))})),po=Zn((function(e){var t=Zs(e);return t="function"==typeof t?t:r,vi(Dt(e,Jo),r,t)})),ho=Zn(oo);var fo=Zn((function(e){var t=e.length,n=t>1?e[t-1]:r;return n="function"==typeof n?(e.pop(),n):r,ao(e,n)}));function mo(e){var t=qr(e);return t.__chain__=!0,t}function go(e,t){return t(e)}var vo=is((function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,s=function(t){return cn(t,e)};return!(t>1||this.__actions__.length)&&i instanceof Hr&&ws(n)?((i=i.slice(n,+n+(t?1:0))).__actions__.push({func:go,args:[s],thisArg:r}),new Vr(i,this.__chain__).thru((function(e){return t&&!e.length&&e.push(r),e}))):this.thru(s)}));var yo=Oi((function(e,t,r){je.call(e,r)?++e[r]:an(e,r,1)}));var bo=Wi(Hs),wo=Wi($s);function _o(e,t){return(Ko(e)?Pt:fn)(e,us(t,3))}function So(e,t){return(Ko(e)?Tt:mn)(e,us(t,3))}var ko=Oi((function(e,t,r){je.call(e,r)?e[r].push(t):an(e,r,[t])}));var Co=Zn((function(e,t,r){var n=-1,i="function"==typeof t,s=Qo(e)?oe(e.length):[];return fn(e,(function(e){s[++n]=i?Ct(t,e,r):xn(e,t,r)})),s})),Ro=Oi((function(e,t,r){an(e,r,t)}));function Po(e,t){return(Ko(e)?xt:qn)(e,us(t,3))}var To=Oi((function(e,t,r){e[r?0:1].push(t)}),(function(){return[[],[]]}));var Eo=Zn((function(e,t){if(null==e)return[];var r=t.length;return r>1&&_s(e,t[0],t[1])?t=[]:r>2&&_s(t[0],t[1],t[2])&&(t=[t[0]]),$n(e,bn(t,1),[])})),Do=ht||function(){return pt.Date.now()};function Io(e,t,n){return t=n?r:t,t=e&&null==t?e.length:t,Xi(e,d,r,r,r,r,t)}function Mo(e,t){var i;if("function"!=typeof t)throw new Ie(n);return e=va(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=r),i}}var xo=Zn((function(e,t,r){var n=1;if(r.length){var i=cr(r,ds(xo));n|=a}return Xi(e,n,t,r,i)})),Oo=Zn((function(e,t,r){var n=3;if(r.length){var i=cr(r,ds(Oo));n|=a}return Xi(t,n,e,r,i)}));function Lo(e,t,i){var s,o,a,c,d,u,l=0,p=!1,h=!1,f=!0;if("function"!=typeof e)throw new Ie(n);function m(t){var n=s,i=o;return s=o=r,l=t,c=e.apply(i,n)}function g(e){return l=e,d=Os(y,t),p?m(e):c}function v(e){var n=e-u;return u===r||n>=t||n<0||h&&e-l>=a}function y(){var e=Do();if(v(e))return b(e);d=Os(y,function(e){var r=t-(e-u);return h?wr(r,a-(e-l)):r}(e))}function b(e){return d=r,f&&s?m(e):(s=o=r,c)}function w(){var e=Do(),n=v(e);if(s=arguments,o=this,u=e,n){if(d===r)return g(u);if(h)return Ci(d),d=Os(y,t),m(u)}return d===r&&(d=Os(y,t)),c}return t=ba(t)||0,na(i)&&(p=!!i.leading,a=(h="maxWait"in i)?br(ba(i.maxWait)||0,t):a,f="trailing"in i?!!i.trailing:f),w.cancel=function(){d!==r&&Ci(d),l=0,s=u=o=d=r},w.flush=function(){return d===r?c:b(Do())},w}var Ao=Zn((function(e,t){return pn(e,1,t)})),jo=Zn((function(e,t,r){return pn(e,ba(t)||0,r)}));function Fo(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ie(n);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=e.apply(this,n);return r.cache=s.set(i,o)||s,o};return r.cache=new(Fo.Cache||Gr),r}function No(e){if("function"!=typeof e)throw new Ie(n);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Fo.Cache=Gr;var Bo=Si((function(e,t){var r=(t=1==t.length&&Ko(t[0])?xt(t[0],Jt(us())):xt(bn(t,1),Jt(us()))).length;return Zn((function(n){for(var i=-1,s=wr(n.length,r);++i<s;)n[i]=t[i].call(this,n[i]);return Ct(e,this,n)}))})),Wo=Zn((function(e,t){var n=cr(t,ds(Wo));return Xi(e,a,r,t,n)})),qo=Zn((function(e,t){var n=cr(t,ds(qo));return Xi(e,c,r,t,n)})),Uo=is((function(e,t){return Xi(e,u,r,r,r,t)}));function zo(e,t){return e===t||e!=e&&t!=t}var Vo=Gi(En),Ho=Gi((function(e,t){return e>=t})),$o=On(function(){return arguments}())?On:function(e){return ia(e)&&je.call(e,"callee")&&!Qe.call(e,"callee")},Ko=oe.isArray,Go=yt?Jt(yt):function(e){return ia(e)&&Tn(e)==O};function Qo(e){return null!=e&&ra(e.length)&&!ea(e)}function Jo(e){return ia(e)&&Qo(e)}var Yo=Ht||bc,Zo=bt?Jt(bt):function(e){return ia(e)&&Tn(e)==w};function Xo(e){if(!ia(e))return!1;var t=Tn(e);return t==_||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!aa(e)}function ea(e){if(!na(e))return!1;var t=Tn(e);return t==S||t==k||"[object AsyncFunction]"==t||"[object Proxy]"==t}function ta(e){return"number"==typeof e&&e==va(e)}function ra(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function na(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ia(e){return null!=e&&"object"==typeof e}var sa=wt?Jt(wt):function(e){return ia(e)&&gs(e)==C};function oa(e){return"number"==typeof e||ia(e)&&Tn(e)==R}function aa(e){if(!ia(e)||Tn(e)!=P)return!1;var t=Ke(e);if(null===t)return!0;var r=je.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Ae.call(r)==We}var ca=_t?Jt(_t):function(e){return ia(e)&&Tn(e)==E};var da=St?Jt(St):function(e){return ia(e)&&gs(e)==D};function ua(e){return"string"==typeof e||!Ko(e)&&ia(e)&&Tn(e)==I}function la(e){return"symbol"==typeof e||ia(e)&&Tn(e)==M}var pa=kt?Jt(kt):function(e){return ia(e)&&ra(e.length)&&!!st[Tn(e)]};var ha=Gi(Wn),fa=Gi((function(e,t){return e<=t}));function ma(e){if(!e)return[];if(Qo(e))return ua(e)?pr(e):Mi(e);if(tt&&e[tt])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[tt]());var t=gs(e);return(t==C?or:t==D?dr:za)(e)}function ga(e){return e?(e=ba(e))===p||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function va(e){var t=ga(e),r=t%1;return t==t?r?t-r:t:0}function ya(e){return e?dn(va(e),0,m):0}function ba(e){if("number"==typeof e)return e;if(la(e))return f;if(na(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=na(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Qt(e);var r=ge.test(e);return r||ye.test(e)?dt(e.slice(2),r?2:8):me.test(e)?f:+e}function wa(e){return xi(e,Aa(e))}function _a(e){return null==e?"":li(e)}var Sa=Li((function(e,t){if(Rs(t)||Qo(t))xi(t,La(t),e);else for(var r in t)je.call(t,r)&&rn(e,r,t[r])})),ka=Li((function(e,t){xi(t,Aa(t),e)})),Ca=Li((function(e,t,r,n){xi(t,Aa(t),e,n)})),Ra=Li((function(e,t,r,n){xi(t,La(t),e,n)})),Pa=is(cn);var Ta=Zn((function(e,t){e=Te(e);var n=-1,i=t.length,s=i>2?t[2]:r;for(s&&_s(t[0],t[1],s)&&(i=1);++n<i;)for(var o=t[n],a=Aa(o),c=-1,d=a.length;++c<d;){var u=a[c],l=e[u];(l===r||zo(l,Oe[u])&&!je.call(e,u))&&(e[u]=o[u])}return e})),Ea=Zn((function(e){return e.push(r,ts),Ct(Fa,r,e)}));function Da(e,t,n){var i=null==e?r:Rn(e,t);return i===r?n:i}function Ia(e,t){return null!=e&&vs(e,t,In)}var Ma=zi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=Be.call(t)),e[t]=r}),nc(oc)),xa=zi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=Be.call(t)),je.call(e,t)?e[t].push(r):e[t]=[r]}),us),Oa=Zn(xn);function La(e){return Qo(e)?Yr(e):Nn(e)}function Aa(e){return Qo(e)?Yr(e,!0):Bn(e)}var ja=Li((function(e,t,r){Vn(e,t,r)})),Fa=Li((function(e,t,r,n){Vn(e,t,r,n)})),Na=is((function(e,t){var r={};if(null==e)return r;var n=!1;t=xt(t,(function(t){return t=_i(t,e),n||(n=t.length>1),t})),xi(e,os(e),r),n&&(r=un(r,7,rs));for(var i=t.length;i--;)hi(r,t[i]);return r}));var Ba=is((function(e,t){return null==e?{}:function(e,t){return Kn(e,t,(function(t,r){return Ia(e,r)}))}(e,t)}));function Wa(e,t){if(null==e)return{};var r=xt(os(e),(function(e){return[e]}));return t=us(t),Kn(e,r,(function(e,r){return t(e,r[0])}))}var qa=Zi(La),Ua=Zi(Aa);function za(e){return null==e?[]:Yt(e,La(e))}var Va=Ni((function(e,t,r){return t=t.toLowerCase(),e+(r?Ha(t):t)}));function Ha(e){return Xa(_a(e).toLowerCase())}function $a(e){return(e=_a(e))&&e.replace(we,rr).replace(Ze,"")}var Ka=Ni((function(e,t,r){return e+(r?"-":"")+t.toLowerCase()})),Ga=Ni((function(e,t,r){return e+(r?" ":"")+t.toLowerCase()})),Qa=Fi("toLowerCase");var Ja=Ni((function(e,t,r){return e+(r?"_":"")+t.toLowerCase()}));var Ya=Ni((function(e,t,r){return e+(r?" ":"")+Xa(t)}));var Za=Ni((function(e,t,r){return e+(r?" ":"")+t.toUpperCase()})),Xa=Fi("toUpperCase");function ec(e,t,n){return e=_a(e),(t=n?r:t)===r?function(e){return rt.test(e)}(e)?function(e){return e.match(et)||[]}(e):function(e){return e.match(ue)||[]}(e):e.match(t)||[]}var tc=Zn((function(e,t){try{return Ct(e,r,t)}catch(e){return Xo(e)?e:new Ce(e)}})),rc=is((function(e,t){return Pt(t,(function(t){t=Bs(t),an(e,t,xo(e[t],e))})),e}));function nc(e){return function(){return e}}var ic=qi(),sc=qi(!0);function oc(e){return e}function ac(e){return Fn("function"==typeof e?e:un(e,1))}var cc=Zn((function(e,t){return function(r){return xn(r,e,t)}})),dc=Zn((function(e,t){return function(r){return xn(e,r,t)}}));function uc(e,t,r){var n=La(t),i=Cn(t,n);null!=r||na(t)&&(i.length||!n.length)||(r=t,t=e,e=this,i=Cn(t,La(t)));var s=!(na(r)&&"chain"in r&&!r.chain),o=ea(e);return Pt(i,(function(r){var n=t[r];e[r]=n,o&&(e.prototype[r]=function(){var t=this.__chain__;if(s||t){var r=e(this.__wrapped__),i=r.__actions__=Mi(this.__actions__);return i.push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,Ot([this.value()],arguments))})})),e}function lc(){}var pc=Hi(xt),hc=Hi(Et),fc=Hi(jt);function mc(e){return Ss(e)?Vt(Bs(e)):function(e){return function(t){return Rn(t,e)}}(e)}var gc=Ki(),vc=Ki(!0);function yc(){return[]}function bc(){return!1}var wc=Vi((function(e,t){return e+t}),0),_c=Ji("ceil"),Sc=Vi((function(e,t){return e/t}),1),kc=Ji("floor");var Cc,Rc=Vi((function(e,t){return e*t}),1),Pc=Ji("round"),Tc=Vi((function(e,t){return e-t}),0);return qr.after=function(e,t){if("function"!=typeof t)throw new Ie(n);return e=va(e),function(){if(--e<1)return t.apply(this,arguments)}},qr.ary=Io,qr.assign=Sa,qr.assignIn=ka,qr.assignInWith=Ca,qr.assignWith=Ra,qr.at=Pa,qr.before=Mo,qr.bind=xo,qr.bindAll=rc,qr.bindKey=Oo,qr.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Ko(e)?e:[e]},qr.chain=mo,qr.chunk=function(e,t,n){t=(n?_s(e,t,n):t===r)?1:br(va(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,o=0,a=oe(gt(i/t));s<i;)a[o++]=si(e,s,s+=t);return a},qr.compact=function(e){for(var t=-1,r=null==e?0:e.length,n=0,i=[];++t<r;){var s=e[t];s&&(i[n++]=s)}return i},qr.concat=function(){var e=arguments.length;if(!e)return[];for(var t=oe(e-1),r=arguments[0],n=e;n--;)t[n-1]=arguments[n];return Ot(Ko(r)?Mi(r):[r],bn(t,1))},qr.cond=function(e){var t=null==e?0:e.length,r=us();return e=t?xt(e,(function(e){if("function"!=typeof e[1])throw new Ie(n);return[r(e[0]),e[1]]})):[],Zn((function(r){for(var n=-1;++n<t;){var i=e[n];if(Ct(i[0],this,r))return Ct(i[1],this,r)}}))},qr.conforms=function(e){return function(e){var t=La(e);return function(r){return ln(r,e,t)}}(un(e,1))},qr.constant=nc,qr.countBy=yo,qr.create=function(e,t){var r=Ur(e);return null==t?r:on(r,t)},qr.curry=function e(t,n,i){var s=Xi(t,8,r,r,r,r,r,n=i?r:n);return s.placeholder=e.placeholder,s},qr.curryRight=function e(t,n,i){var s=Xi(t,o,r,r,r,r,r,n=i?r:n);return s.placeholder=e.placeholder,s},qr.debounce=Lo,qr.defaults=Ta,qr.defaultsDeep=Ea,qr.defer=Ao,qr.delay=jo,qr.difference=Us,qr.differenceBy=zs,qr.differenceWith=Vs,qr.drop=function(e,t,n){var i=null==e?0:e.length;return i?si(e,(t=n||t===r?1:va(t))<0?0:t,i):[]},qr.dropRight=function(e,t,n){var i=null==e?0:e.length;return i?si(e,0,(t=i-(t=n||t===r?1:va(t)))<0?0:t):[]},qr.dropRightWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!0,!0):[]},qr.dropWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!0):[]},qr.fill=function(e,t,n,i){var s=null==e?0:e.length;return s?(n&&"number"!=typeof n&&_s(e,t,n)&&(n=0,i=s),function(e,t,n,i){var s=e.length;for((n=va(n))<0&&(n=-n>s?0:s+n),(i=i===r||i>s?s:va(i))<0&&(i+=s),i=n>i?0:ya(i);n<i;)e[n++]=t;return e}(e,t,n,i)):[]},qr.filter=function(e,t){return(Ko(e)?Dt:yn)(e,us(t,3))},qr.flatMap=function(e,t){return bn(Po(e,t),1)},qr.flatMapDeep=function(e,t){return bn(Po(e,t),p)},qr.flatMapDepth=function(e,t,n){return n=n===r?1:va(n),bn(Po(e,t),n)},qr.flatten=Ks,qr.flattenDeep=function(e){return(null==e?0:e.length)?bn(e,p):[]},qr.flattenDepth=function(e,t){return(null==e?0:e.length)?bn(e,t=t===r?1:va(t)):[]},qr.flip=function(e){return Xi(e,512)},qr.flow=ic,qr.flowRight=sc,qr.fromPairs=function(e){for(var t=-1,r=null==e?0:e.length,n={};++t<r;){var i=e[t];n[i[0]]=i[1]}return n},qr.functions=function(e){return null==e?[]:Cn(e,La(e))},qr.functionsIn=function(e){return null==e?[]:Cn(e,Aa(e))},qr.groupBy=ko,qr.initial=function(e){return(null==e?0:e.length)?si(e,0,-1):[]},qr.intersection=Qs,qr.intersectionBy=Js,qr.intersectionWith=Ys,qr.invert=Ma,qr.invertBy=xa,qr.invokeMap=Co,qr.iteratee=ac,qr.keyBy=Ro,qr.keys=La,qr.keysIn=Aa,qr.map=Po,qr.mapKeys=function(e,t){var r={};return t=us(t,3),Sn(e,(function(e,n,i){an(r,t(e,n,i),e)})),r},qr.mapValues=function(e,t){var r={};return t=us(t,3),Sn(e,(function(e,n,i){an(r,n,t(e,n,i))})),r},qr.matches=function(e){return Un(un(e,1))},qr.matchesProperty=function(e,t){return zn(e,un(t,1))},qr.memoize=Fo,qr.merge=ja,qr.mergeWith=Fa,qr.method=cc,qr.methodOf=dc,qr.mixin=uc,qr.negate=No,qr.nthArg=function(e){return e=va(e),Zn((function(t){return Hn(t,e)}))},qr.omit=Na,qr.omitBy=function(e,t){return Wa(e,No(us(t)))},qr.once=function(e){return Mo(2,e)},qr.orderBy=function(e,t,n,i){return null==e?[]:(Ko(t)||(t=null==t?[]:[t]),Ko(n=i?r:n)||(n=null==n?[]:[n]),$n(e,t,n))},qr.over=pc,qr.overArgs=Bo,qr.overEvery=hc,qr.overSome=fc,qr.partial=Wo,qr.partialRight=qo,qr.partition=To,qr.pick=Ba,qr.pickBy=Wa,qr.property=mc,qr.propertyOf=function(e){return function(t){return null==e?r:Rn(e,t)}},qr.pull=Xs,qr.pullAll=eo,qr.pullAllBy=function(e,t,r){return e&&e.length&&t&&t.length?Gn(e,t,us(r,2)):e},qr.pullAllWith=function(e,t,n){return e&&e.length&&t&&t.length?Gn(e,t,r,n):e},qr.pullAt=to,qr.range=gc,qr.rangeRight=vc,qr.rearg=Uo,qr.reject=function(e,t){return(Ko(e)?Dt:yn)(e,No(us(t,3)))},qr.remove=function(e,t){var r=[];if(!e||!e.length)return r;var n=-1,i=[],s=e.length;for(t=us(t,3);++n<s;){var o=e[n];t(o,n,e)&&(r.push(o),i.push(n))}return Qn(e,i),r},qr.rest=function(e,t){if("function"!=typeof e)throw new Ie(n);return Zn(e,t=t===r?t:va(t))},qr.reverse=ro,qr.sampleSize=function(e,t,n){return t=(n?_s(e,t,n):t===r)?1:va(t),(Ko(e)?Xr:ei)(e,t)},qr.set=function(e,t,r){return null==e?e:ti(e,t,r)},qr.setWith=function(e,t,n,i){return i="function"==typeof i?i:r,null==e?e:ti(e,t,n,i)},qr.shuffle=function(e){return(Ko(e)?en:ii)(e)},qr.slice=function(e,t,n){var i=null==e?0:e.length;return i?(n&&"number"!=typeof n&&_s(e,t,n)?(t=0,n=i):(t=null==t?0:va(t),n=n===r?i:va(n)),si(e,t,n)):[]},qr.sortBy=Eo,qr.sortedUniq=function(e){return e&&e.length?di(e):[]},qr.sortedUniqBy=function(e,t){return e&&e.length?di(e,us(t,2)):[]},qr.split=function(e,t,n){return n&&"number"!=typeof n&&_s(e,t,n)&&(t=n=r),(n=n===r?m:n>>>0)?(e=_a(e))&&("string"==typeof t||null!=t&&!ca(t))&&!(t=li(t))&&sr(e)?ki(pr(e),0,n):e.split(t,n):[]},qr.spread=function(e,t){if("function"!=typeof e)throw new Ie(n);return t=null==t?0:br(va(t),0),Zn((function(r){var n=r[t],i=ki(r,0,t);return n&&Ot(i,n),Ct(e,this,i)}))},qr.tail=function(e){var t=null==e?0:e.length;return t?si(e,1,t):[]},qr.take=function(e,t,n){return e&&e.length?si(e,0,(t=n||t===r?1:va(t))<0?0:t):[]},qr.takeRight=function(e,t,n){var i=null==e?0:e.length;return i?si(e,(t=i-(t=n||t===r?1:va(t)))<0?0:t,i):[]},qr.takeRightWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!1,!0):[]},qr.takeWhile=function(e,t){return e&&e.length?mi(e,us(t,3)):[]},qr.tap=function(e,t){return t(e),e},qr.throttle=function(e,t,r){var i=!0,s=!0;if("function"!=typeof e)throw new Ie(n);return na(r)&&(i="leading"in r?!!r.leading:i,s="trailing"in r?!!r.trailing:s),Lo(e,t,{leading:i,maxWait:t,trailing:s})},qr.thru=go,qr.toArray=ma,qr.toPairs=qa,qr.toPairsIn=Ua,qr.toPath=function(e){return Ko(e)?xt(e,Bs):la(e)?[e]:Mi(Ns(_a(e)))},qr.toPlainObject=wa,qr.transform=function(e,t,r){var n=Ko(e),i=n||Yo(e)||pa(e);if(t=us(t,4),null==r){var s=e&&e.constructor;r=i?n?new s:[]:na(e)&&ea(s)?Ur(Ke(e)):{}}return(i?Pt:Sn)(e,(function(e,n,i){return t(r,e,n,i)})),r},qr.unary=function(e){return Io(e,1)},qr.union=no,qr.unionBy=io,qr.unionWith=so,qr.uniq=function(e){return e&&e.length?pi(e):[]},qr.uniqBy=function(e,t){return e&&e.length?pi(e,us(t,2)):[]},qr.uniqWith=function(e,t){return t="function"==typeof t?t:r,e&&e.length?pi(e,r,t):[]},qr.unset=function(e,t){return null==e||hi(e,t)},qr.unzip=oo,qr.unzipWith=ao,qr.update=function(e,t,r){return null==e?e:fi(e,t,wi(r))},qr.updateWith=function(e,t,n,i){return i="function"==typeof i?i:r,null==e?e:fi(e,t,wi(n),i)},qr.values=za,qr.valuesIn=function(e){return null==e?[]:Yt(e,Aa(e))},qr.without=co,qr.words=ec,qr.wrap=function(e,t){return Wo(wi(t),e)},qr.xor=uo,qr.xorBy=lo,qr.xorWith=po,qr.zip=ho,qr.zipObject=function(e,t){return yi(e||[],t||[],rn)},qr.zipObjectDeep=function(e,t){return yi(e||[],t||[],ti)},qr.zipWith=fo,qr.entries=qa,qr.entriesIn=Ua,qr.extend=ka,qr.extendWith=Ca,uc(qr,qr),qr.add=wc,qr.attempt=tc,qr.camelCase=Va,qr.capitalize=Ha,qr.ceil=_c,qr.clamp=function(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=(n=ba(n))==n?n:0),t!==r&&(t=(t=ba(t))==t?t:0),dn(ba(e),t,n)},qr.clone=function(e){return un(e,4)},qr.cloneDeep=function(e){return un(e,5)},qr.cloneDeepWith=function(e,t){return un(e,5,t="function"==typeof t?t:r)},qr.cloneWith=function(e,t){return un(e,4,t="function"==typeof t?t:r)},qr.conformsTo=function(e,t){return null==t||ln(e,t,La(t))},qr.deburr=$a,qr.defaultTo=function(e,t){return null==e||e!=e?t:e},qr.divide=Sc,qr.endsWith=function(e,t,n){e=_a(e),t=li(t);var i=e.length,s=n=n===r?i:dn(va(n),0,i);return(n-=t.length)>=0&&e.slice(n,s)==t},qr.eq=zo,qr.escape=function(e){return(e=_a(e))&&J.test(e)?e.replace(G,nr):e},qr.escapeRegExp=function(e){return(e=_a(e))&&ie.test(e)?e.replace(ne,"\\$&"):e},qr.every=function(e,t,n){var i=Ko(e)?Et:gn;return n&&_s(e,t,n)&&(t=r),i(e,us(t,3))},qr.find=bo,qr.findIndex=Hs,qr.findKey=function(e,t){return Nt(e,us(t,3),Sn)},qr.findLast=wo,qr.findLastIndex=$s,qr.findLastKey=function(e,t){return Nt(e,us(t,3),kn)},qr.floor=kc,qr.forEach=_o,qr.forEachRight=So,qr.forIn=function(e,t){return null==e?e:wn(e,us(t,3),Aa)},qr.forInRight=function(e,t){return null==e?e:_n(e,us(t,3),Aa)},qr.forOwn=function(e,t){return e&&Sn(e,us(t,3))},qr.forOwnRight=function(e,t){return e&&kn(e,us(t,3))},qr.get=Da,qr.gt=Vo,qr.gte=Ho,qr.has=function(e,t){return null!=e&&vs(e,t,Dn)},qr.hasIn=Ia,qr.head=Gs,qr.identity=oc,qr.includes=function(e,t,r,n){e=Qo(e)?e:za(e),r=r&&!n?va(r):0;var i=e.length;return r<0&&(r=br(i+r,0)),ua(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&Wt(e,t,r)>-1},qr.indexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:va(r);return i<0&&(i=br(n+i,0)),Wt(e,t,i)},qr.inRange=function(e,t,n){return t=ga(t),n===r?(n=t,t=0):n=ga(n),function(e,t,r){return e>=wr(t,r)&&e<br(t,r)}(e=ba(e),t,n)},qr.invoke=Oa,qr.isArguments=$o,qr.isArray=Ko,qr.isArrayBuffer=Go,qr.isArrayLike=Qo,qr.isArrayLikeObject=Jo,qr.isBoolean=function(e){return!0===e||!1===e||ia(e)&&Tn(e)==b},qr.isBuffer=Yo,qr.isDate=Zo,qr.isElement=function(e){return ia(e)&&1===e.nodeType&&!aa(e)},qr.isEmpty=function(e){if(null==e)return!0;if(Qo(e)&&(Ko(e)||"string"==typeof e||"function"==typeof e.splice||Yo(e)||pa(e)||$o(e)))return!e.length;var t=gs(e);if(t==C||t==D)return!e.size;if(Rs(e))return!Nn(e).length;for(var r in e)if(je.call(e,r))return!1;return!0},qr.isEqual=function(e,t){return Ln(e,t)},qr.isEqualWith=function(e,t,n){var i=(n="function"==typeof n?n:r)?n(e,t):r;return i===r?Ln(e,t,r,n):!!i},qr.isError=Xo,qr.isFinite=function(e){return"number"==typeof e&&gr(e)},qr.isFunction=ea,qr.isInteger=ta,qr.isLength=ra,qr.isMap=sa,qr.isMatch=function(e,t){return e===t||An(e,t,ps(t))},qr.isMatchWith=function(e,t,n){return n="function"==typeof n?n:r,An(e,t,ps(t),n)},qr.isNaN=function(e){return oa(e)&&e!=+e},qr.isNative=function(e){if(Cs(e))throw new Ce("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return jn(e)},qr.isNil=function(e){return null==e},qr.isNull=function(e){return null===e},qr.isNumber=oa,qr.isObject=na,qr.isObjectLike=ia,qr.isPlainObject=aa,qr.isRegExp=ca,qr.isSafeInteger=function(e){return ta(e)&&e>=-9007199254740991&&e<=h},qr.isSet=da,qr.isString=ua,qr.isSymbol=la,qr.isTypedArray=pa,qr.isUndefined=function(e){return e===r},qr.isWeakMap=function(e){return ia(e)&&gs(e)==x},qr.isWeakSet=function(e){return ia(e)&&"[object WeakSet]"==Tn(e)},qr.join=function(e,t){return null==e?"":vr.call(e,t)},qr.kebabCase=Ka,qr.last=Zs,qr.lastIndexOf=function(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var s=i;return n!==r&&(s=(s=va(n))<0?br(i+s,0):wr(s,i-1)),t==t?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(e,t,s):Bt(e,Ut,s,!0)},qr.lowerCase=Ga,qr.lowerFirst=Qa,qr.lt=ha,qr.lte=fa,qr.max=function(e){return e&&e.length?vn(e,oc,En):r},qr.maxBy=function(e,t){return e&&e.length?vn(e,us(t,2),En):r},qr.mean=function(e){return zt(e,oc)},qr.meanBy=function(e,t){return zt(e,us(t,2))},qr.min=function(e){return e&&e.length?vn(e,oc,Wn):r},qr.minBy=function(e,t){return e&&e.length?vn(e,us(t,2),Wn):r},qr.stubArray=yc,qr.stubFalse=bc,qr.stubObject=function(){return{}},qr.stubString=function(){return""},qr.stubTrue=function(){return!0},qr.multiply=Rc,qr.nth=function(e,t){return e&&e.length?Hn(e,va(t)):r},qr.noConflict=function(){return pt._===this&&(pt._=qe),this},qr.noop=lc,qr.now=Do,qr.pad=function(e,t,r){e=_a(e);var n=(t=va(t))?lr(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return $i(vt(i),r)+e+$i(gt(i),r)},qr.padEnd=function(e,t,r){e=_a(e);var n=(t=va(t))?lr(e):0;return t&&n<t?e+$i(t-n,r):e},qr.padStart=function(e,t,r){e=_a(e);var n=(t=va(t))?lr(e):0;return t&&n<t?$i(t-n,r)+e:e},qr.parseInt=function(e,t,r){return r||null==t?t=0:t&&(t=+t),Sr(_a(e).replace(se,""),t||0)},qr.random=function(e,t,n){if(n&&"boolean"!=typeof n&&_s(e,t,n)&&(t=n=r),n===r&&("boolean"==typeof t?(n=t,t=r):"boolean"==typeof e&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=ga(e),t===r?(t=e,e=0):t=ga(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var s=kr();return wr(e+s*(t-e+ct("1e-"+((s+"").length-1))),t)}return Jn(e,t)},qr.reduce=function(e,t,r){var n=Ko(e)?Lt:$t,i=arguments.length<3;return n(e,us(t,4),r,i,fn)},qr.reduceRight=function(e,t,r){var n=Ko(e)?At:$t,i=arguments.length<3;return n(e,us(t,4),r,i,mn)},qr.repeat=function(e,t,n){return t=(n?_s(e,t,n):t===r)?1:va(t),Yn(_a(e),t)},qr.replace=function(){var e=arguments,t=_a(e[0]);return e.length<3?t:t.replace(e[1],e[2])},qr.result=function(e,t,n){var i=-1,s=(t=_i(t,e)).length;for(s||(s=1,e=r);++i<s;){var o=null==e?r:e[Bs(t[i])];o===r&&(i=s,o=n),e=ea(o)?o.call(e):o}return e},qr.round=Pc,qr.runInContext=e,qr.sample=function(e){return(Ko(e)?Zr:Xn)(e)},qr.size=function(e){if(null==e)return 0;if(Qo(e))return ua(e)?lr(e):e.length;var t=gs(e);return t==C||t==D?e.size:Nn(e).length},qr.snakeCase=Ja,qr.some=function(e,t,n){var i=Ko(e)?jt:oi;return n&&_s(e,t,n)&&(t=r),i(e,us(t,3))},qr.sortedIndex=function(e,t){return ai(e,t)},qr.sortedIndexBy=function(e,t,r){return ci(e,t,us(r,2))},qr.sortedIndexOf=function(e,t){var r=null==e?0:e.length;if(r){var n=ai(e,t);if(n<r&&zo(e[n],t))return n}return-1},qr.sortedLastIndex=function(e,t){return ai(e,t,!0)},qr.sortedLastIndexBy=function(e,t,r){return ci(e,t,us(r,2),!0)},qr.sortedLastIndexOf=function(e,t){if(null==e?0:e.length){var r=ai(e,t,!0)-1;if(zo(e[r],t))return r}return-1},qr.startCase=Ya,qr.startsWith=function(e,t,r){return e=_a(e),r=null==r?0:dn(va(r),0,e.length),t=li(t),e.slice(r,r+t.length)==t},qr.subtract=Tc,qr.sum=function(e){return e&&e.length?Kt(e,oc):0},qr.sumBy=function(e,t){return e&&e.length?Kt(e,us(t,2)):0},qr.template=function(e,t,n){var i=qr.templateSettings;n&&_s(e,t,n)&&(t=r),e=_a(e),t=Ca({},t,i,es);var s,o,a=Ca({},t.imports,i.imports,es),c=La(a),d=Yt(a,c),u=0,l=t.interpolate||_e,p="__p += '",h=Ee((t.escape||_e).source+"|"+l.source+"|"+(l===X?he:_e).source+"|"+(t.evaluate||_e).source+"|$","g"),f="//# sourceURL="+(je.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++it+"]")+"\n";e.replace(h,(function(t,r,n,i,a,c){return n||(n=i),p+=e.slice(u,c).replace(Se,ir),r&&(s=!0,p+="' +\n__e("+r+") +\n'"),a&&(o=!0,p+="';\n"+a+";\n__p += '"),n&&(p+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+t.length,t})),p+="';\n";var m=je.call(t,"variable")&&t.variable;if(m){if(le.test(m))throw new Ce("Invalid `variable` option passed into `_.template`")}else p="with (obj) {\n"+p+"\n}\n";p=(o?p.replace(V,""):p).replace(H,"$1").replace($,"$1;"),p="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(s?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";var g=tc((function(){return Re(c,f+"return "+p).apply(r,d)}));if(g.source=p,Xo(g))throw g;return g},qr.times=function(e,t){if((e=va(e))<1||e>h)return[];var r=m,n=wr(e,m);t=us(t),e-=m;for(var i=Gt(n,t);++r<e;)t(r);return i},qr.toFinite=ga,qr.toInteger=va,qr.toLength=ya,qr.toLower=function(e){return _a(e).toLowerCase()},qr.toNumber=ba,qr.toSafeInteger=function(e){return e?dn(va(e),-9007199254740991,h):0===e?e:0},qr.toString=_a,qr.toUpper=function(e){return _a(e).toUpperCase()},qr.trim=function(e,t,n){if((e=_a(e))&&(n||t===r))return Qt(e);if(!e||!(t=li(t)))return e;var i=pr(e),s=pr(t);return ki(i,Xt(i,s),er(i,s)+1).join("")},qr.trimEnd=function(e,t,n){if((e=_a(e))&&(n||t===r))return e.slice(0,hr(e)+1);if(!e||!(t=li(t)))return e;var i=pr(e);return ki(i,0,er(i,pr(t))+1).join("")},qr.trimStart=function(e,t,n){if((e=_a(e))&&(n||t===r))return e.replace(se,"");if(!e||!(t=li(t)))return e;var i=pr(e);return ki(i,Xt(i,pr(t))).join("")},qr.truncate=function(e,t){var n=30,i="...";if(na(t)){var s="separator"in t?t.separator:s;n="length"in t?va(t.length):n,i="omission"in t?li(t.omission):i}var o=(e=_a(e)).length;if(sr(e)){var a=pr(e);o=a.length}if(n>=o)return e;var c=n-lr(i);if(c<1)return i;var d=a?ki(a,0,c).join(""):e.slice(0,c);if(s===r)return d+i;if(a&&(c+=d.length-c),ca(s)){if(e.slice(c).search(s)){var u,l=d;for(s.global||(s=Ee(s.source,_a(fe.exec(s))+"g")),s.lastIndex=0;u=s.exec(l);)var p=u.index;d=d.slice(0,p===r?c:p)}}else if(e.indexOf(li(s),c)!=c){var h=d.lastIndexOf(s);h>-1&&(d=d.slice(0,h))}return d+i},qr.unescape=function(e){return(e=_a(e))&&Q.test(e)?e.replace(K,fr):e},qr.uniqueId=function(e){var t=++Fe;return _a(e)+t},qr.upperCase=Za,qr.upperFirst=Xa,qr.each=_o,qr.eachRight=So,qr.first=Gs,uc(qr,(Cc={},Sn(qr,(function(e,t){je.call(qr.prototype,t)||(Cc[t]=e)})),Cc),{chain:!1}),qr.VERSION="4.17.21",Pt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){qr[e].placeholder=qr})),Pt(["drop","take"],(function(e,t){Hr.prototype[e]=function(n){n=n===r?1:br(va(n),0);var i=this.__filtered__&&!t?new Hr(this):this.clone();return i.__filtered__?i.__takeCount__=wr(n,i.__takeCount__):i.__views__.push({size:wr(n,m),type:e+(i.__dir__<0?"Right":"")}),i},Hr.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Pt(["filter","map","takeWhile"],(function(e,t){var r=t+1,n=1==r||3==r;Hr.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:us(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}})),Pt(["head","last"],(function(e,t){var r="take"+(t?"Right":"");Hr.prototype[e]=function(){return this[r](1).value()[0]}})),Pt(["initial","tail"],(function(e,t){var r="drop"+(t?"":"Right");Hr.prototype[e]=function(){return this.__filtered__?new Hr(this):this[r](1)}})),Hr.prototype.compact=function(){return this.filter(oc)},Hr.prototype.find=function(e){return this.filter(e).head()},Hr.prototype.findLast=function(e){return this.reverse().find(e)},Hr.prototype.invokeMap=Zn((function(e,t){return"function"==typeof e?new Hr(this):this.map((function(r){return xn(r,e,t)}))})),Hr.prototype.reject=function(e){return this.filter(No(us(e)))},Hr.prototype.slice=function(e,t){e=va(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Hr(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(n=(t=va(t))<0?n.dropRight(-t):n.take(t-e)),n)},Hr.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hr.prototype.toArray=function(){return this.take(m)},Sn(Hr.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),s=qr[i?"take"+("last"==t?"Right":""):t],o=i||/^find/.test(t);s&&(qr.prototype[t]=function(){var t=this.__wrapped__,a=i?[1]:arguments,c=t instanceof Hr,d=a[0],u=c||Ko(t),l=function(e){var t=s.apply(qr,Ot([e],a));return i&&p?t[0]:t};u&&n&&"function"==typeof d&&1!=d.length&&(c=u=!1);var p=this.__chain__,h=!!this.__actions__.length,f=o&&!p,m=c&&!h;if(!o&&u){t=m?t:new Hr(this);var g=e.apply(t,a);return g.__actions__.push({func:go,args:[l],thisArg:r}),new Vr(g,p)}return f&&m?e.apply(this,a):(g=this.thru(l),f?i?g.value()[0]:g.value():g)})})),Pt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Me[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);qr.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(Ko(i)?i:[],e)}return this[r]((function(r){return t.apply(Ko(r)?r:[],e)}))}})),Sn(Hr.prototype,(function(e,t){var r=qr[t];if(r){var n=r.name+"";je.call(xr,n)||(xr[n]=[]),xr[n].push({name:t,func:r})}})),xr[Ui(r,2).name]=[{name:"wrapper",func:r}],Hr.prototype.clone=function(){var e=new Hr(this.__wrapped__);return e.__actions__=Mi(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Mi(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Mi(this.__views__),e},Hr.prototype.reverse=function(){if(this.__filtered__){var e=new Hr(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hr.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=Ko(e),n=t<0,i=r?e.length:0,s=function(e,t,r){var n=-1,i=r.length;for(;++n<i;){var s=r[n],o=s.size;switch(s.type){case"drop":e+=o;break;case"dropRight":t-=o;break;case"take":t=wr(t,e+o);break;case"takeRight":e=br(e,t-o)}}return{start:e,end:t}}(0,i,this.__views__),o=s.start,a=s.end,c=a-o,d=n?a:o-1,u=this.__iteratees__,l=u.length,p=0,h=wr(c,this.__takeCount__);if(!r||!n&&i==c&&h==c)return gi(e,this.__actions__);var f=[];e:for(;c--&&p<h;){for(var m=-1,g=e[d+=t];++m<l;){var v=u[m],y=v.iteratee,b=v.type,w=y(g);if(2==b)g=w;else if(!w){if(1==b)continue e;break e}}f[p++]=g}return f},qr.prototype.at=vo,qr.prototype.chain=function(){return mo(this)},qr.prototype.commit=function(){return new Vr(this.value(),this.__chain__)},qr.prototype.next=function(){this.__values__===r&&(this.__values__=ma(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?r:this.__values__[this.__index__++]}},qr.prototype.plant=function(e){for(var t,n=this;n instanceof zr;){var i=qs(n);i.__index__=0,i.__values__=r,t?s.__wrapped__=i:t=i;var s=i;n=n.__wrapped__}return s.__wrapped__=e,t},qr.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hr){var t=e;return this.__actions__.length&&(t=new Hr(this)),(t=t.reverse()).__actions__.push({func:go,args:[ro],thisArg:r}),new Vr(t,this.__chain__)}return this.thru(ro)},qr.prototype.toJSON=qr.prototype.valueOf=qr.prototype.value=function(){return gi(this.__wrapped__,this.__actions__)},qr.prototype.first=qr.prototype.head,tt&&(qr.prototype[tt]=function(){return this}),qr}();ft?((ft.exports=mr)._=mr,ht._=mr):pt._=mr}).call(l)}(Rw,Rw.exports);var Pw,Tw=l&&l.__extends||(Pw=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}Pw(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(Cw,"__esModule",{value:!0});var Ew=Rw.exports,Dw=["MaxBatchSize","MaxDelay","MinDelay"],Iw=function(e){function t(t){var r=e.call(this)||this;return r.fifo=[],r.firstBatch=!0,function(e){if(Dw.forEach((function(t){if(!e.hasOwnProperty(t))throw new Error("Missing required MessageBatcher option: "+t)})),isNaN(e.MaxBatchSize))throw new Error("MessageBatcher MaxBatchSize option must be a number");if(!isFinite(e.MaxBatchSize))throw new Error("MessageBatcher MaxBatchSize option must be a finite number");if(e.MaxBatchSize<1)throw new Error("MessageBatcher MaxBatchSize option cannot be less than 1");if(isNaN(e.MaxDelay))throw new Error("MessageBatcher MaxDelay option must be a number");if(!isFinite(e.MaxDelay))throw new Error("MessageBatcher MaxDelay option must be a finite number");if(e.MaxDelay<0)throw new Error("MessageBatcher MaxDelay option cannot be less than 0");if(isNaN(e.MinDelay))throw new Error("MessageBatcher MinDelay option must be a number");if(!isFinite(e.MinDelay))throw new Error("MessageBatcher MinDelay option must be a finite number");if(e.MinDelay<0)throw new Error("MessageBatcher MinDelay option cannot be less than 0");if(e.MinDelay>e.MaxDelay)throw new Error("MessageBatcher MinDelay option cannot be greater than MaxDelay")}(t),r.options=t,r.releaseBatchDebouncedMax=Ew.debounce(r.releaseBatch.bind(r),r.options.MaxDelay,{maxWait:r.options.MaxDelay}),r.releaseBatchDebouncedMin=Ew.debounce(r.releaseBatch.bind(r),r.options.MinDelay,{maxWait:r.options.MinDelay}),r}return Tw(t,e),t.prototype.Queue=function(e){var t=this;(e=[].concat(e)).forEach((function(e){t.fifo.push(e),t.debounce(t.fifo,t.options.MaxBatchSize)}),this)},t.prototype.debounce=function(e,t){e.length>0&&(e.length>=t?this.firstBatch?(this.firstBatch=!1,this.releaseBatchDebouncedMax.flush()):(this.releaseBatchDebouncedMax.cancel(),this.releaseBatchDebouncedMin(e,t)):(this.releaseBatchDebouncedMin.cancel(),this.releaseBatchDebouncedMax(e,t)))},t.prototype.releaseBatch=function(e,t){var r=this.drainFIFO(e,t);r&&r.length&&(this.emit("batch",r),this.debounce(e,t))},t.prototype.drainFIFO=function(e,t){return e.length>0?e.splice(0,t):e},t}(e.EventEmitter);Cw.MessageBatcher=Iw,function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(Cw)}(kw),function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(kw)}(Sw);let Mw,xw=!1;const Ow=()=>{try{return xw?null:window.localStorage}catch(e){return console.error("Get local storage error",{error:hr(e)}),e instanceof Error&&"SecurityError"===e.name&&(xw=!0),null}};function Lw(e){const t=Ow();if(!t)return null;try{return JSON.parse(t.getItem(e))}catch(e){return null}}const Aw=()=>{if(Mw)return Mw;const e=Lw("sdk_clientUniqueId");if(e)return Mw=e,e;const t=r.randomBytes(12).toString("hex");return Mw=t,function(e,t){const r=Ow();if(r)try{r.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}}("sdk_clientUniqueId",t),t},jw=()=>{const e=Lw("sdk_clientUniqueId");return e||(null!=Mw?Mw:Aw())},Fw=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);function Nw(e){return!e.response&&(!!e.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(e.code)&&(e=>!Fw.has(e&&e.code))(e)))}const Bw=["get","head","options"],Ww=Bw.concat(["put","delete"]);function qw(e){return"ECONNABORTED"!==e.code&&(!e.response||429===e.response.status||e.response.status>=500&&e.response.status<=599)}function Uw(e){return!!e.config?.method&&(qw(e)&&-1!==Ww.indexOf(e.config.method))}function zw(e){return Nw(e)||Uw(e)}function Vw(e){const t=e?.response?.headers["retry-after"];if(!t)return 0;let r=1e3*(Number(t)||0);return 0===r&&(r=(new Date(t).valueOf()||0)-Date.now()),Math.max(0,r)}const Hw={retries:3,retryCondition:zw,retryDelay:function(e=0,t){return Math.max(0,Vw(t))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function $w(e,t,r=!1){const n=function(e,t){return{...Hw,...t,...e["axios-retry"]}}(e,t||{});return n.retryCount=n.retryCount||0,n.lastRequestTime&&!r||(n.lastRequestTime=Date.now()),e["axios-retry"]=n,n}const Kw=(e,t)=>{const r=e.interceptors.request.use((e=>($w(e,t,!0),e["axios-retry"]?.validateResponse&&(e.validateStatus=()=>!1),e))),n=e.interceptors.response.use(null,(async r=>{const{config:n}=r;if(!n)return Promise.reject(r);const i=$w(n,t);return r.response&&i.validateResponse?.(r.response)?r.response:await async function(e,t){const{retries:r,retryCondition:n}=e,i=(e.retryCount||0)<r&&n(t);if("object"==typeof i)try{return!1!==await i}catch(e){return!1}return i}(i,r)?async function(e,t,r,n){t.retryCount+=1;const{retryDelay:i,shouldResetTimeout:s,onRetry:o}=t,a=i(t.retryCount,r);if(function(e,t){e.defaults.agent===t.agent&&delete t.agent,e.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,e.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}(e,n),!s&&n.timeout&&t.lastRequestTime){const e=Date.now()-t.lastRequestTime,i=n.timeout-e-a;if(i<=0)return Promise.reject(r);n.timeout=i}return n.transformRequest=[e=>e],await o(t.retryCount,r,n),n.signal?.aborted?Promise.resolve(e(n)):new Promise((t=>{const r=()=>{clearTimeout(i),t(e(n))},i=setTimeout((()=>{t(e(n)),n.signal?.removeEventListener&&n.signal.removeEventListener("abort",r)}),a);n.signal?.addEventListener&&n.signal.addEventListener("abort",r,{once:!0})}))}(e,i,r,n):(await async function(e,t){e.retryCount>=e.retries&&await e.onMaxRetryTimesExceeded(t,e.retryCount)}(i,r),Promise.reject(r))}));return{requestInterceptorId:r,responseInterceptorId:n}};Kw.isNetworkError=Nw,Kw.isSafeRequestError=function(e){return!!e.config?.method&&(qw(e)&&-1!==Bw.indexOf(e.config.method))},Kw.isIdempotentRequestError=Uw,Kw.isNetworkOrIdempotentRequestError=zw,Kw.exponentialDelay=function(e=0,t,r=100){const n=2**e*r,i=Math.max(n,Vw(t));return i+.2*i*Math.random()},Kw.linearDelay=function(e=100){return(t=0,r)=>{const n=t*e;return Math.max(n,Vw(r))}},Kw.isRetryableError=qw;class Gw{constructor(e){this.api=e,Kw(this.api,{retries:2,shouldResetTimeout:!0,retryDelay:e=>1500*e,retryCondition:e=>{var t,r;return/^\/?log\//.test(null!==(r=null===(t=e.config)||void 0===t?void 0:t.url)&&void 0!==r?r:"")||!1}})}batch(e){return a(this,void 0,void 0,(function*(){return this.api.post("/log/batch",e)}))}}class Qw{constructor(){this.api=_g.create({baseURL:"https://moodhood-analytics.livedigital.space/v1",timeout:1e4,withCredentials:!0,paramsSerializer:e=>Fy.stringify(e),headers:{"x-cl-id":jw()}}),this.api.defaults.headers.common["Cache-Control"]="no-cache",this.api.defaults.headers.common.Pragma="no-cache",this.api.defaults.headers.common.Expires="0",this.logApi=new Gw(this.api)}get log(){return this.logApi}}var Jw,Yw,Zw,Xw,e_,t_,r_,n_;class i_{constructor(e){Jw.add(this),Yw.set(this,void 0),Zw.set(this,void 0),Xw.set(this,void 0),e_.set(this,void 0),t_.set(this,void 0);const{logLevel:t,namespace:r,onLogMessage:n}=e;d(this,Yw,r,"f"),d(this,Zw,t,"f"),this.onLogMessage=n,d(this,e_,new Qw,"f"),d(this,Xw,new Sw.MessageBatcher({MaxBatchSize:50,MaxDelay:1e3,MinDelay:500}),"f"),d(this,t_,e.sendAnalytics,"f"),c(this,Xw,"f").on("batch",(e=>a(this,void 0,void 0,(function*(){yield this.logToApi(e)})))),this._debug=Qi("LiveDigital").extend("debug").extend(c(this,Yw,"f")),this._info=Qi("LiveDigital").extend("info").extend(c(this,Yw,"f")),this._warn=Qi("LiveDigital").extend("warn").extend(c(this,Yw,"f")),this._error=Qi("LiveDigital").extend("error").extend(c(this,Yw,"f")),this._debug.log=console.info.bind(console),this._info.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}debug(e,t){this._debug(e,t),c(this,t_,"f")&&c(this,Xw,"f").Queue({level:"debug",message:e,meta:t}),c(this,Zw,"f")>=ht&&c(this,Jw,"m",r_).call(this,"debug",e,t)}info(e,t){this._info(e,t),c(this,t_,"f")&&c(this,Xw,"f").Queue({level:"info",message:e,meta:t}),c(this,Zw,"f")>=pt&&c(this,Jw,"m",r_).call(this,"info",e,t)}warn(e,t){this._warn(e,t),c(this,t_,"f")&&c(this,Xw,"f").Queue({level:"warn",message:e,meta:t}),c(this,Zw,"f")>=lt&&c(this,Jw,"m",r_).call(this,"warn",e,t)}error(e,t){this._error(e,t),c(this,t_,"f")&&c(this,Xw,"f").Queue({level:"error",message:e,meta:t}),c(this,Zw,"f")>=ut&&c(this,Jw,"m",r_).call(this,"error",e,t)}logToApi(e){return a(this,void 0,void 0,(function*(){try{yield c(this,e_,"f").log.batch({logs:e.map((e=>c(this,Jw,"m",n_).call(this,Object.assign(Object.assign({},e),{meta:this.prepareRecordMeta(e.meta)})))),clientMeta:this.getClientMeta()})}catch(e){this._debug("Log request was not successful",{error:e})}}))}getClientMeta(){return Object.assign(Object.assign({},fr.meta),{clUId:jw()})}prepareRecordMeta(e){const t=e||{},{error:r}=t;return Object.assign(Object.assign(Object.assign({},t),{clientTimestamp:(new Date).toISOString(),from_sdk:!0}),r&&"object"==typeof r?{error:hr(r)}:{})}}Yw=new WeakMap,Zw=new WeakMap,Xw=new WeakMap,e_=new WeakMap,t_=new WeakMap,Jw=new WeakSet,r_=function(e,t,...r){"function"==typeof this.onLogMessage&&this.onLogMessage(t,...c(this,Jw,"m",n_).call(this,r),e)},n_=function(e){const t=new WeakMap;return function e(r,n=[]){if(!Kh(r))return r;const i=t.get(r);if(i)return`[Circular *${i.join(".")}]`;t.set(r,n);const s=Array.isArray(r)?[]:{};return Object.entries(r).forEach((([t,r])=>{s[t]=e(r,[...n,t])})),t.delete(r),s}(e)};let s_=class{constructor(e){this.peerTrackFactory=e,this.tracksByConsumerId=new Map}register(e,t){this.tracksByConsumerId.set(e,t)}get(e){return this.tracksByConsumerId.get(e)}delete(e){return this.tracksByConsumerId.delete(e)}reset(){this.tracksByConsumerId.clear()}create(e){const{consumer:t,label:r,muted:n=!1,mediaStreamTrack:i,paused:s,peerEventEmitter:o}=e,a=this.peerTrackFactory({consumer:t,label:r,mediaStreamTrack:i,paused:s,peerEventEmitter:o,muted:n,onClose:()=>{void 0!==a.consumerId&&this.delete(a.consumerId)}});return void 0!==a.consumerId&&this.register(a.consumerId,a),a}};var o_,a_,c_,d_,u_,l_,p_;s_=i([at(),s(0,dt(Qn.PeerTrackFactory)),o("design:paramtypes",[Function])],s_);const h_=()=>{};class f_{constructor(e){o_.set(this,void 0),a_.set(this,void 0),c_.set(this,null),d_.set(this,"speed"),u_.set(this,16e3),l_.set(this,void 0),this.type="asdk",p_.set(this,void 0);const{loggerFactory:t}=e;d(this,a_,t("ASDKTrackProcessor"),"f"),d(this,p_,"function"==typeof e.onError?e.onError:h_,"f"),d(this,o_,new window.atsvb(e.asdkCustomerId),"f"),c(this,o_,"f").config({preset:c(this,d_,"f"),sample_rate:c(this,u_,"f"),sdk_url:"https://effectssdk.ai/sdk/audio/",wasmPaths:{"ort-wasm.wasm":"https://effectssdk.ai/sdk/audio/dev/2.4.2/ort-wasm.wasm","ort-wasm-simd.wasm":"https://effectssdk.ai/sdk/audio/dev/2.4.2/ort-wasm-simd.wasm"}}),c(this,o_,"f").onError((e=>{const{message:t,type:r,cause:i}=e,s=n(e,["message","type","cause"]);"error"===r&&(c(this,a_,"f").error(t,Object.assign(Object.assign({error:hr(i),cause:i},s),{type:this.type,case:"Denoiser"})),c(this,p_,"f").call(this),d(this,p_,h_,"f")),"warning"===r&&c(this,a_,"f").warn(t,Object.assign(Object.assign({},s),{type:this.type,case:"Denoiser"})),"info"===r&&c(this,a_,"f").info(t,Object.assign(Object.assign({},s),{type:this.type,case:"Denoiser"}))}))}setOnError(e){d(this,p_,e,"f")}init(){return a(this,void 0,void 0,(function*(){yield c(this,o_,"f").preload()}))}get isProcessing(){return!!c(this,l_,"f")}processTrack(e){var t;return a(this,void 0,void 0,(function*(){if(c(this,c_,"f")===e||"ended"===e.readyState)return(null===(t=c(this,o_,"f").getStream())||void 0===t?void 0:t.getAudioTracks()[0])||e;yield this.stopProcessing();try{const t=new Promise(((t,r)=>{c(this,o_,"f").onReady=()=>{try{const r=c(this,o_,"f").getStream(),n=null==r?void 0:r.getAudioTracks()[0];if(!n)return void t(e);d(this,c_,e,"f"),d(this,l_,n,"f"),t(n),c(this,o_,"f").run()}catch(e){r(e)}finally{c(this,o_,"f").onReady=void 0}}}));c(this,o_,"f").useStream(new MediaStream([e]));return yield t}catch(t){throw c(this,a_,"f").error("processTrack()",{error:hr(t),type:this.type,case:"Denoiser",track:e}),c(this,p_,"f").call(this),d(this,p_,h_,"f"),new Error("Can not process this track")}}))}stopProcessing(){return a(this,void 0,void 0,(function*(){try{c(this,o_,"f").stop()}catch(e){c(this,a_,"f").error("stopProcessing()",{type:this.type,case:"Denoiser",error:hr(e)})}finally{d(this,c_,null,"f")}}))}}o_=new WeakMap,a_=new WeakMap,c_=new WeakMap,d_=new WeakMap,u_=new WeakMap,l_=new WeakMap,p_=new WeakMap;class m_ extends AudioWorkletNode{constructor(e){super(e.context,"rnnoise",{channelCountMode:"explicit",channelCount:1,channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{module:e.noiseSuppressor.module}}),this.port.onmessage=({data:e})=>{const t=Object.assign(new Event("status"),e);this.dispatchEvent(t)}}update(e){this.port.postMessage(e)}static register(e){return a(this,void 0,void 0,(function*(){const t=gS.get(Qn.Config);yield e.audioWorklet.addModule(`${t.get("staticFilesPath")}/noiseSuppressionWorklet.js`)}))}}var g_,v_,y_,b_,w_,__;class S_{constructor(e){g_.set(this,void 0),v_.set(this,void 0),y_.set(this,void 0),b_.set(this,void 0),w_.set(this,void 0),__.set(this,!0),d(this,g_,e.noiseSuppressor.instance.exports,"f"),d(this,v_,e.context,"f"),d(this,y_,new Float32Array(c(this,g_,"f").memory.buffer),"f"),d(this,b_,c(this,g_,"f").newState(),"f"),d(this,w_,c(this,v_,"f").createScriptProcessor(),"f"),this.setOnAudioProcess()}get noiseSuppressionScriptProcessorNode(){return c(this,w_,"f")}update(e){e||(d(this,__,!1,"f"),c(this,g_,"f").deleteState(c(this,b_,"f")));const t=Object.assign(new Event("status"),{vadProb:c(this,g_,"f").getVadProb(c(this,b_,"f"))});c(this,w_,"f").dispatchEvent(t)}setOnAudioProcess(){c(this,w_,"f").addEventListener("audioprocess",(({inputBuffer:e,outputBuffer:t})=>{if(!c(this,__,"f"))return;c(this,y_,"f").set(e.getChannelData(0),c(this,g_,"f").getInput(c(this,b_,"f"))/4);const r=t.getChannelData(0),n=c(this,g_,"f").pipe(c(this,b_,"f"),r.length)/4;n&&r.set(c(this,y_,"f").subarray(n,n+r.length))}))}}g_=new WeakMap,v_=new WeakMap,y_=new WeakMap,b_=new WeakMap,w_=new WeakMap,__=new WeakMap;var k_,C_,R_,P_,T_,E_,D_,I_,M_,x_,O_,L_,A_,j_,F_,N_,B_,W_,q_,U_,z_,V_,H_,$_,K_,G_,Q_,J_,Y_,Z_,X_,eS,tS,rS,nS,iS,sS,oS,aS;class cS{constructor({context:e,noiseSuppressor:t}){k_.set(this,void 0),C_.set(this,void 0),R_.set(this,void 0),d(this,k_,e,"f"),d(this,C_,t,"f")}createNoiseSuppressionNode(){return a(this,void 0,void 0,(function*(){return/apple/i.test(navigator.vendor)?this.createScriptProcessorNode():this.createAudioWorkletNode()}))}stop(){var e;null===(e=c(this,R_,"f"))||void 0===e||e.update(!1)}createAudioWorkletNode(){return a(this,void 0,void 0,(function*(){return yield m_.register(c(this,k_,"f")),d(this,R_,new m_({context:c(this,k_,"f"),noiseSuppressor:c(this,C_,"f")}),"f"),c(this,R_,"f")}))}createScriptProcessorNode(){return d(this,R_,new S_({context:c(this,k_,"f"),noiseSuppressor:c(this,C_,"f")}),"f"),c(this,R_,"f").noiseSuppressionScriptProcessorNode}}k_=new WeakMap,C_=new WeakMap,R_=new WeakMap;class dS{constructor(e){P_.set(this,void 0),T_.set(this,void 0),E_.set(this,void 0),D_.set(this,void 0),this.type="rnnoise",d(this,P_,e.noiseSuppressor,"f"),d(this,E_,e.loggerFactory("TrackProcessor"),"f")}get isProcessing(){return!!c(this,D_,"f")}processTrack(e){return a(this,void 0,void 0,(function*(){const t=(e=>{const t=window.AudioContext||window.webkitAudioContext||!1;return t?new t(e):null})();if(!t)throw new Error("AudioContext is not available");const r=new MediaStreamAudioDestinationNode(t,{channelCountMode:"explicit",channelCount:1,channelInterpretation:"speakers"});yield m_.register(t);const n=t.createMediaStreamSource(new MediaStream([e])),i=new cS({context:t,noiseSuppressor:c(this,P_,"f")}),s=yield i.createNoiseSuppressionNode();s.connect(r),n.connect(s);const[o]=r.stream.getTracks();return d(this,T_,{audioContext:t,streamDestination:r,noiseSuppressionNode:s,noiseSuppressionProvider:i},"f"),d(this,D_,o,"f"),c(this,E_,"f").info("processTrack()",{case:"Denoiser",type:this.type,track:e.id}),o}))}stopProcessing(){var e;return a(this,void 0,void 0,(function*(){if(this.isProcessing)if(c(this,T_,"f"))try{c(this,T_,"f").noiseSuppressionProvider.stop(),c(this,T_,"f").noiseSuppressionNode.disconnect(),c(this,T_,"f").streamDestination.disconnect(),yield c(this,T_,"f").audioContext.close(),null===(e=c(this,D_,"f"))||void 0===e||e.stop(),d(this,D_,void 0,"f"),c(this,E_,"f").info("stopProcessing()",{success:!0,case:"Denoiser",type:this.type})}catch(e){c(this,E_,"f").error("stopProcessing()",{success:!1,error:hr(e),case:"Denoiser",type:this.type})}else c(this,E_,"f").warn("stopProcessing()",{success:!1,description:"Processing context is not available",case:"Denoiser",type:this.type});else c(this,E_,"f").debug("stopProcessing()",{description:"Track is not processed",case:"Denoiser",type:this.type})}))}}P_=new WeakMap,T_=new WeakMap,E_=new WeakMap,D_=new WeakMap;class uS extends Uf{constructor(){super(...arguments),I_.set(this,!1),M_.set(this,void 0),x_.set(this,void 0)}get isDenoiserRequireActivation(){var e;return!(null===(e=c(this,M_,"f"))||void 0===e?void 0:e.isProcessing)&&c(this,I_,"f")}prepareTrackProcessor(e){this.logger.debug("Setting trackProcessor to AudioTrack",{case:"Denoiser",type:e.type}),d(this,M_,e,"f")}unsetTrackProcessor(){d(this,M_,void 0,"f")}get isEffectsProcessing(){var e;return Boolean(null===(e=c(this,M_,"f"))||void 0===e?void 0:e.isProcessing)}getEncoderConfig(){return this.encoderConfig}getEncodings(){var e;return null!==(e=this.getEncoderConfig().encodings)&&void 0!==e?e:Ll}getCodecOptions(){var e,t;return{opusFec:null===(e=this.getEncoderConfig().enableFec)||void 0===e||e,opusDtx:null===(t=this.getEncoderConfig().enableDtx)||void 0===t||t}}getPreferredCodec(){const{preferredCodec:e}=this.getEncoderConfig();return e||"opus"}enableNoiseSuppression(){var e,t;return a(this,void 0,void 0,(function*(){if(d(this,I_,!0,"f"),c(this,M_,"f"))try{const r=yield null===(e=c(this,M_,"f"))||void 0===e?void 0:e.processTrack(this.mediaStreamTrack);d(this,x_,this.mediaStreamTrack,"f"),yield this.replaceTrack(r),this.logger.debug("Denoiser activated",{case:"Denoiser",type:(null===(t=c(this,M_,"f"))||void 0===t?void 0:t.type)||"none"})}catch(e){throw this.logger.warn("enableNoiseSuppression()",{description:"Can not enable noise suppression",track:this.logCtx,error:hr(e)}),new Error("Can not enable noise suppression")}else this.logger.warn("enableNoiseSuppression()",{description:"Track suppressor is not defined"})}))}disableNoiseSuppression(){var e,t,r;return a(this,void 0,void 0,(function*(){d(this,I_,!1,"f");try{if(!(null===(e=c(this,M_,"f"))||void 0===e?void 0:e.isProcessing))return void this.logger.debug("stopProcessing()",{description:"Track is not processed"});if(!c(this,x_,"f"))return void this.logger.warn("disableNoiseSuppression()",{description:"Original track missing"});this.isPublished&&(yield this.replaceTrack(c(this,x_,"f"))),yield null===(t=c(this,M_,"f"))||void 0===t?void 0:t.stopProcessing(),this.logger.debug("Denoiser deactivated",{case:"Denoiser",type:(null===(r=c(this,M_,"f"))||void 0===r?void 0:r.type)||"none"})}catch(e){throw this.logger.warn("disableNoiseSuppression()",{description:"Can not disable noise suppression",track:this.logCtx,error:hr(e)}),new Error("Can not disable noise suppression")}}))}publish(){return a(this,void 0,void 0,(function*(){yield this.produce({encodings:this.getEncodings(),preferredCodec:this.getPreferredCodec(),codecOptions:this.getCodecOptions()}),this.internalEventEmitter.emit(Xr.trackProduced,this)}))}pause(){return a(this,void 0,void 0,(function*(){yield this.mute()}))}}I_=new WeakMap,M_=new WeakMap,x_=new WeakMap;class lS{constructor({track:e,statsHandler:t}){O_.set(this,void 0),L_.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return c(this,O_,"f")}get audioWebRTCStats(){return c(this,L_,"f")}handleWebRTCStats(e,t){e.addEventListener("ended",(()=>{t.removeInboundVideoHandler(e.id),t.removeInboundAudioHandler(e.id)}),{once:!0}),"video"!==e.kind?t.addInboundAudioHandler(e.id,this.setAudioWebRTCStats.bind(this)):t.addInboundVideoHandler(e.id,this.setVideoWebRTCStats.bind(this))}setVideoWebRTCStats(e){d(this,O_,e,"f")}setAudioWebRTCStats(e){d(this,L_,e,"f")}}O_=new WeakMap,L_=new WeakMap;class pS{constructor(e){this.label=Jn.Unknown,A_.set(this,void 0),j_.set(this,void 0),F_.set(this,void 0),N_.set(this,void 0),B_.set(this,void 0),W_.set(this,void 0),q_.set(this,void 0),U_.set(this,void 0),z_.set(this,void 0),V_.set(this,void 0),H_.set(this,!1),$_.set(this,void 0),K_.set(this,!1),G_.set(this,new lf),Q_.set(this,!1),J_.set(this,0),Y_.set(this,void 0),this.observer=new Rt,d(this,z_,e.mediaStreamTrack,"f"),this.label=e.label,this.consumer=e.consumer,d(this,B_,e.peerConsumerFactory,"f"),d(this,q_,e.loggerFactory("PeerTrack"),"f"),d(this,U_,e.peerEventEmitter,"f"),d(this,Q_,e.muted,"f"),d(this,V_,e.paused,"f"),d(this,A_,e.network,"f"),d(this,j_,e.socket,"f"),d(this,F_,e.media,"f"),d(this,W_,e.callState,"f"),d(this,N_,e.onClose,"f"),d(this,Y_,new lS({track:e.mediaStreamTrack,statsHandler:e.statsHandler}),"f")}get videoWebRTCStats(){return c(this,Y_,"f").videoWebRTCStats}get audioWebRTCStats(){return c(this,Y_,"f").audioWebRTCStats}get logCtx(){var e,t;return{id:c(this,z_,"f").id,label:this.label,consumerId:null===(e=this.consumer)||void 0===e?void 0:e.id,producerId:null===(t=this.consumer)||void 0===t?void 0:t.producerId,muted:c(this,Q_,"f"),paused:c(this,V_,"f"),closed:c(this,K_,"f")}}get volume(){return c(this,J_,"f")}get isRemote(){return!!this.consumer}get mediaStreamTrack(){return c(this,z_,"f")}get kind(){return this.mediaStreamTrack.kind}get isPaused(){return c(this,V_,"f")}get isMuted(){return c(this,Q_,"f")}get consumerId(){var e;return null===(e=this.consumer)||void 0===e?void 0:e.id}get currentSpatialLayer(){var e;return(null===(e=this.consumer)||void 0===e?void 0:e.currentSpatialLayer)||0}get score(){var e;return null===(e=this.consumer)||void 0===e?void 0:e.score}close(){return a(this,void 0,void 0,(function*(){c(this,U_,"f").safeEmit(on,this),d(this,K_,!0,"f"),c(this,N_,"f").call(this),this.consumer&&(yield this.closeConsumer(),this.clearCheckStateTimeout())}))}mute(){return a(this,void 0,void 0,(function*(){yield c(this,G_,"f").push((()=>a(this,void 0,void 0,(function*(){c(this,q_,"f").debug("mute()",{track:this.logCtx}),yield this.pauseConsumer(),d(this,Q_,!0,"f")}))))}))}unmute(){return a(this,void 0,void 0,(function*(){yield c(this,G_,"f").push((()=>a(this,void 0,void 0,(function*(){c(this,q_,"f").debug("unmute()",{track:this.logCtx}),yield this.resumeConsumer(),d(this,Q_,!1,"f")}))))}))}pause(e=!0){return a(this,void 0,void 0,(function*(){yield c(this,G_,"f").push((()=>a(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return d(this,V_,!0,"f"),c(this,U_,"f").safeEmit(an,this),void c(this,q_,"f").debug("pause()",{track:this.logCtx});yield this.pauseConsumer(e),d(this,V_,!0,"f"),c(this,U_,"f").safeEmit(an,this)}))))}))}resume(e=!0){return a(this,void 0,void 0,(function*(){yield c(this,G_,"f").push((()=>a(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return d(this,V_,!1,"f"),c(this,U_,"f").safeEmit(cn,this),void c(this,q_,"f").debug("resume()",{track:this.logCtx});yield this.resumeConsumer(e),d(this,V_,!1,"f"),c(this,U_,"f").safeEmit(cn,this)}))))}))}resumeConsumer(e=!0){return a(this,void 0,void 0,(function*(){if(this.consumer)try{this.consumer.resume(),e&&(yield c(this,A_,"f").resumeRemoteConsumer(this.consumer.id)),this.checkConsumerState().catch((e=>{c(this,q_,"f").warn("Failed to checkConsumerState()",{track:this.logCtx,error:hr(e)})})),c(this,q_,"f").debug("resumeConsumer()",{track:this.logCtx})}catch(e){c(this,q_,"f").warn("resumeConsumer()",{error:e})}}))}pauseConsumer(e=!0){return a(this,void 0,void 0,(function*(){if(this.consumer)try{this.clearCheckStateTimeout(),e&&(yield c(this,A_,"f").pauseRemoteConsumer(this.consumer.id)),this.consumer.pause(),d(this,H_,!1,"f"),c(this,q_,"f").debug("pauseConsumer()",{track:this.logCtx})}catch(e){c(this,q_,"f").warn("pauseConsumer()",{error:e})}}))}requestVideoPreferredLayers({spatialLayer:e,temporalLayer:t}){return a(this,void 0,void 0,(function*(){if(this.consumer)try{if(this.consumer.isAudio)return void c(this,q_,"f").warn("Only video consumers support layers",{case:"requestVideoPreferredLayers"});if(e===this.consumer.currentSpatialLayer)return;if(e>this.consumer.spatialLayers)return void c(this,q_,"f").warn("Invalid spatial layer",{spatialLayer:e,consumerSpatialLayers:this.consumer.spatialLayers,case:"requestVideoPreferredLayers"});if(e>this.consumer.currentMaxSpatialLayer)return void(yield this.requestMaxSpatialLayer(this.consumer.id,e));yield c(this,j_,"f").request(En,{consumerId:this.consumer.id,spatialLayer:e,temporalLayer:t}),c(this,q_,"f").debug("requestVideoPreferredLayers()",{track:this.logCtx,consumer:this.consumer,spatialLayer:e,temporalLayer:t})}catch(e){throw c(this,q_,"f").error("Failed to request preferred layers",{case:"requestVideoPreferredLayers",track:{id:this.mediaStreamTrack.id,kind:this.mediaStreamTrack.kind,label:this.mediaStreamTrack.label},consumerId:this.consumer.id,spatialLayers:this.consumer.spatialLayers,temporalLayers:this.consumer.temporalLayers,error:e}),new Error("Error request preferred layers")}}))}requestKeyFrame(){return a(this,void 0,void 0,(function*(){if(this.consumerId){c(this,q_,"f").debug("requestKeyFrame()",{track:this.logCtx});try{yield c(this,j_,"f").request(Dn,{consumerId:this.consumerId})}catch(e){throw c(this,q_,"f").error("requestKeyFrame()",{error:e,track:this.logCtx,consumerId:this.consumerId}),new Error("Failed to request key frame")}}}))}getVideoAvailableLayers(){if(this.consumer){if(!this.consumer.isAudio)return this.consumer.availableSpatialLayers;c(this,q_,"f").warn("Only video consumers support layers",{case:"getVideoAvailableLayers"})}}getInfo(){var e;return a(this,void 0,void 0,(function*(){const{width:t,height:r,frameRate:n,aspectRatio:i}=c(this,z_,"f").getSettings();return{trackId:c(this,z_,"f").id,readyState:c(this,z_,"f").readyState,isRemote:this.isRemote,kind:this.kind,label:this.label,width:t,height:r,frameRate:n,aspectRatio:i,paused:c(this,V_,"f"),trackInboundStats:yield null===(e=this.consumer)||void 0===e?void 0:e.getStats(),trackOutboundStats:yield this.getOutboundStats()}}))}getOutboundStats(){return a(this,void 0,void 0,(function*(){if(this.isRemote)return;const e=c(this,F_,"f").getAllTracks().find((e=>e.getLabel()===this.label));return e?e.getStats():void 0}))}requestMaxSpatialLayer(e,t){return a(this,void 0,void 0,(function*(){try{if(!this.consumer)return;if(this.consumer.isAudio||0===this.consumer.spatialLayers||this.consumer.currentMaxSpatialLayer===t||t<this.consumer.currentMaxSpatialLayer)return void c(this,q_,"f").warn("Can`t request this spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t});this.consumer.setRequestedSpatialLayer(t),yield c(this,j_,"f").request(_n,{producerId:this.consumer.producerId,spatialLayer:t}),c(this,q_,"f").debug("requestMaxSpatialLayer()",{consumerId:e,spatialLayer:t})}catch(r){c(this,q_,"f").warn("Failed to request max spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t,error:r})}}))}checkConsumerState(){return a(this,void 0,void 0,(function*(){try{if(c(this,K_,"f")||"audio"===this.kind)return;c(this,q_,"f").debug("checkConsumerState()",{track:this.logCtx});if((yield this.isInboundRTPStreamActive())||c(this,K_,"f"))return;yield this.requestKeyFrame();if((yield this.isInboundRTPStreamActive())||c(this,K_,"f"))return;if(c(this,H_,"f"))return c(this,U_,"f").emit(dn,this),void c(this,q_,"f").debug("trackFail()",{track:this.logCtx});yield this.restartConsumer()}catch(e){c(this,q_,"f").warn("checkConsumerState()",{track:this,error:e})}}))}setVolume(e){c(this,J_,"f")!==e&&(d(this,J_,e,"f"),this.observer.safeEmit(Zr,{value:e}))}closeConsumer(){return a(this,void 0,void 0,(function*(){try{if(!this.consumer)return;this.consumer.close(),yield c(this,A_,"f").closeRemoteConsumer(this.consumer.id)}catch(e){c(this,q_,"f").debug("closeConsumer()",{track:this,error:e})}}))}restartConsumer(){return a(this,void 0,void 0,(function*(){try{if(!this.consumer||c(this,K_,"f"))return;c(this,q_,"f").debug("restartConsumer()",{track:this.logCtx}),c(this,U_,"f").emit(on,this),d(this,V_,!0,"f"),yield this.closeConsumer();const{consumer:e}=yield c(this,A_,"f").createConsumer({producerId:this.consumer.producerId,rtpCapabilities:c(this,F_,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.consumer.appData.producerData.peerId,appId:c(this,W_,"f").appId,channelId:c(this,W_,"f").channelId});d(this,H_,!0,"f"),this.consumer=c(this,B_,"f").call(this,{consumer:e}),d(this,z_,e.track,"f"),yield this.resume(),c(this,U_,"f").emit(sn,this)}catch(e){d(this,H_,!0,"f"),c(this,q_,"f").warn("restartConsumer()",{track:this,error:e})}}))}isInboundRTPStreamActive(){return a(this,void 0,void 0,(function*(){if(!this.consumer||c(this,K_,"f"))return!1;const{framesDecoded:e}=yield this.consumer.getInboundRTPStreamStats();return new Promise((t=>{d(this,$_,setTimeout((()=>a(this,void 0,void 0,(function*(){try{if(!this.consumer)return void t(!1);const{framesDecoded:r}=yield this.consumer.getInboundRTPStreamStats();if(e===r&&!this.isPaused)return void t(!1);t(!0)}catch(e){c(this,q_,"f").debug("isInboundRTPStreamActive()",{error:e,track:this.logCtx}),t(!1)}}))),4500),"f")}))}))}clearCheckStateTimeout(){c(this,$_,"f")||clearTimeout(c(this,$_,"f"))}}A_=new WeakMap,j_=new WeakMap,F_=new WeakMap,N_=new WeakMap,B_=new WeakMap,W_=new WeakMap,q_=new WeakMap,U_=new WeakMap,z_=new WeakMap,V_=new WeakMap,H_=new WeakMap,$_=new WeakMap,K_=new WeakMap,G_=new WeakMap,Q_=new WeakMap,J_=new WeakMap,Y_=new WeakMap;class hS{constructor(e){this.score=10;const{id:t,kind:r,peerId:n,label:i,paused:s}=e;this.id=t,this.kind=r,this.peerId=n,this.label=i,this.paused=s,this.encodings=e.encodings,this.trackTransformParams=e.trackTransformParams,this.maxSpatialLayer=e.maxSpatialLayer}}class fS{constructor({id:e,channelIds:t,groups:r,producePermissions:n,appId:i,loginDate:s,producers:o=[],appData:a,uid:c,role:u,loggerFactory:l,myPeer:p,callState:h,peers:f,remotePeerTracks:m,media:g,network:v,socket:y,peerConsumerFactory:b}){this.producers=new Map,this.tracks=new Map,Z_.set(this,void 0),X_.set(this,void 0),eS.set(this,void 0),tS.set(this,void 0),rS.set(this,void 0),nS.set(this,void 0),iS.set(this,void 0),sS.set(this,void 0),oS.set(this,void 0),this._observer=new Rt,this.id=e,this.channelIds=t,this.groups=r,this.producePermissions=n,this.appId=i,this.loginDate=s,this.applicationData=a||{},this.uid=c,this.role=u,d(this,nS,p,"f"),d(this,iS,h,"f"),d(this,Z_,f,"f"),d(this,X_,m,"f"),d(this,tS,y,"f"),d(this,sS,b,"f"),d(this,eS,v,"f"),d(this,rS,g,"f"),d(this,oS,l("Peer"),"f"),o.forEach(this.handleNewProducer.bind(this)),this.handlePeerEvents()}get appData(){return this.applicationData}get observer(){return this._observer}get isMe(){return this.id===c(this,nS,"f").id}get isModerator(){return this.groups.includes("moderator")}get isUser(){return this.groups.includes("user")}get publishedMedia(){return Array.from(this.producers.values()).map((e=>({producerId:e.id,kind:e.kind,label:e.label,paused:e.paused})))}get shortData(){return{id:this.id,producers:Array.from(this.producers.values()).map((e=>({id:e.id,paused:e.paused}))),appData:this.appData}}hasPermission(e){return this.producePermissions.includes(e)}hasGroup(e){return this.groups.includes(e)}subscribe({producerId:e,muted:t=!1}){return a(this,void 0,void 0,(function*(){try{const r=this.producers.get(e);if(!r)return void c(this,oS,"f").warn("subscribe()",{message:"Peer does not have a producer",peer:of(this),producerId:e});if(this.getAllConsumers().find((t=>t.producerId===e)))return void c(this,oS,"f").debug("subscribe()",{message:"Already subscribed to producer",peer:of(this),producerId:e});const{consumer:n,isProducerPaused:i}=yield c(this,eS,"f").createConsumer({producerId:r.id,rtpCapabilities:c(this,rS,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.id,appId:c(this,iS,"f").appId,channelId:c(this,iS,"f").channelId});if(!this.producePermissions.includes(r.label)&&Object.values(Jn).includes(r.label))return void c(this,oS,"f").debug("subscribe()",{message:"Producer is not allowed anymore",peer:of(this),producerId:e});const s=c(this,X_,"f").create({mediaStreamTrack:n.track,label:r.label,consumer:c(this,sS,"f").call(this,{consumer:n}),muted:t,paused:i,peerEventEmitter:this.observer});t||(yield s.unmute()),this.tracks.set(s.label,s),c(this,oS,"f").debug(`Subscribed for ${r.kind}`,{peer:of(this)})}catch(t){throw c(this,oS,"f").error("subscribe()",{producerId:e,error:t,peer:of(this)}),new Error("Error subscribe media")}}))}unsubscribe(e){return a(this,void 0,void 0,(function*(){try{const t=this.getConsumerByProducerId(e);if(!t)return;const r=this.getTrackByConsumerId(t.id);if(!r)return;yield r.close(),this.tracks.delete(r.label),c(this,oS,"f").debug(`Unsubscribed consumer ${t.kind}`,{peer:of(this)})}catch(t){throw c(this,oS,"f").error("unsubscribe()",{producerId:e,error:t}),new Error("Error unsubscribe media")}}))}setProducePermissions(e){return a(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield c(this,tS,"f").request(Dr,{peerId:this.id,producePermissions:e}),c(this,oS,"f").debug("Produce permissions changed",{peerId:this.id,producePermissions:e})}))}addProducePermission(e){return a(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield c(this,tS,"f").request(Ir,{peerId:this.id,label:e}),c(this,oS,"f").debug("Add produce permission requested",{peerId:this.id,label:e})}))}removeProducePermission(e){return a(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield c(this,tS,"f").request(Mr,{peerId:this.id,label:e}),c(this,oS,"f").debug("Remove produce permission requested",{peerId:this.id,label:e})}))}getInfo(){return a(this,void 0,void 0,(function*(){try{return{id:this.id,appData:this.appData,role:this.role,channelIds:this.channelIds,appId:this.appId,uid:this.uid,loginDate:this.loginDate,tracks:yield Promise.all(Array.from(this.tracks.values()).map((e=>e.getInfo())))}}catch(e){throw c(this,oS,"f").error("getInfo()",{peer:of(this),error:e}),new Error("Error get info")}}))}getProducers(){return Array.from(this.producers.values())}getConsumersState(){return this.getAllConsumers().map((e=>({id:e.id,paused:e.paused,producerId:e.producerId})))}handleNewProducer(e){if(this.producers.get(e.id))return;const t=new hS(e);this.producers.set(t.id,t),c(this,oS,"f").debug("Peer published media:",{peer:of(this),producer:t}),this.observer.safeEmit(en,{producerId:t.id,kind:t.kind,label:t.label,paused:t.paused})}handlePeerEvents(){this.observer.on(hn,this.handleNewProducer.bind(this)),this.observer.on(fn,(e=>a(this,void 0,void 0,(function*(){this.producers.delete(e.id),c(this,oS,"f").debug("Peer unpublished media:",{peer:of(this),producer:e}),this.observer.safeEmit(tn,{producerId:e.id,kind:e.kind,label:e.label,paused:e.paused});const t=this.tracks.get(e.label);if(t)try{yield t.close()}catch(e){c(this,oS,"f").warn("Failed to close peer track due to producer closed",{label:t.label,peerId:this.id})}})))),this.observer.on(Cn,(e=>a(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.close(),this.tracks.delete(t.label),c(this,oS,"f").debug("Peer video track was ended:",{peer:of(this),track:t.logCtx}))})))),this.observer.on(Rn,(e=>a(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.pause(!1))})))),this.observer.on(Pn,(e=>a(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.resume(!1))})))),this.observer.on(En,(e=>{const t=this.getConsumerById(e.consumerId);(null==t?void 0:t.isVideo)&&(t.setCurrentTemporalLayer(e.temporalLayer),t.setCurrentSpatialLayer(e.spatialLayer),e.spatialLayer===t.requestedSpatialLayer&&t.setRequestedSpatialLayer(void 0),c(this,oS,"f").debug("consumerChangePreferredLayers()",Object.assign({},e)))})),this.observer.on(Tn,(e=>{const t=this.getConsumerById(e.consumerId);t&&(t.score=e.score)})),this.observer.on(wn,(e=>a(this,void 0,void 0,(function*(){const{producerId:t,spatialLayer:r}=e,n=this.getConsumerByProducerId(t);n?(n.setCurrentMaxSpatialLayer(r),c(this,oS,"f").debug("producerSetMaxSpatialLayer()",{producerId:t,consumerId:n.id,spatialLayer:r}),n.requestedSpatialLayer===r?(yield c(this,tS,"f").request(En,{consumerId:n.id,spatialLayer:r}),c(this,oS,"f").debug("requestVideoPreferredLayers()",{producerId:t,consumerId:n.id,spatialLayer:r})):c(this,oS,"f").debug("producerSetMaxSpatialLayer()",{message:"No need to request new preferred layer",currentMaxSpatialLayer:r,requestedMaxSpatialLayer:n.requestedSpatialLayer})):c(this,oS,"f").debug("producerSetMaxSpatialLayer()",{message:"Consumer for producer not created, ignore MaxSpatialLayer change"})})))),this.observer.on(br,(e=>{try{qn(e),this.setAppData(e),this.observer.emit(un,e),c(this,oS,"f").debug("updatePeerAppData",{peer:of(this),appData:e})}catch(t){c(this,oS,"f").error("updatePeerAppData",{peer:of(this),appData:e,error:t})}}))}reset(){return a(this,void 0,void 0,(function*(){this.producers.clear(),yield Promise.all(Array.from(this.tracks.values()).map((e=>e.close()))),this.tracks.clear();[hn,fn,Cn,Rn,Pn,Tn,En,wn,br].forEach((e=>this.observer.removeAllListeners(e)))}))}getActiveTracksCount(){return Array.from(this.tracks.values()).map((e=>e.consumer)).filter((e=>!(null==e?void 0:e.paused))).length}getActivePublishersCount(){return Array.from(this.producers.values()).filter((e=>!e.paused)).length}handleProducePermissionsChange(e){this.producePermissions=e,Object.values(Jn).filter((e=>!this.producePermissions.includes(e))).forEach((e=>{const t=this.tracks.get(e);t&&(this.tracks.delete(t.label),t.close())})),this.observer.safeEmit(ln,{labels:this.producePermissions})}handleGroupsChange(e){this.groups=e,this.observer.safeEmit(pn,{groups:e})}getAllConsumers(){return Array.from(this.tracks.values()).map((e=>e.consumer)).filter((e=>!!e))}getConsumerByProducerId(e){return this.getAllConsumers().find((t=>t.producerId===e))}getConsumerById(e){return this.getAllConsumers().find((t=>t.id===e))}getTrackByConsumerId(e){return Array.from(this.tracks.values()).find((t=>t.consumerId===e))}setAppData(e){this.applicationData=e}throwIfIamNotModerator(){if(!c(this,Z_,"f").isModerator(c(this,nS,"f").id))throw new Error("Not enough access")}}Z_=new WeakMap,X_=new WeakMap,eS=new WeakMap,tS=new WeakMap,rS=new WeakMap,nS=new WeakMap,iS=new WeakMap,sS=new WeakMap,oS=new WeakMap;class mS{constructor(e){this.score=10,this.spatialLayers=0,this.temporalLayers=0,this.currentSpatialLayer=0,this.currentTemporalLayer=0,this.availableSpatialLayers=[],aS.set(this,void 0);const{consumer:t,loggerFactory:r}=e;this.id=t.id,this.kind=t.kind,this.producerId=t.producerId,this.appData=t.appData,this.consumer=t,d(this,aS,r("PeerConsumer"),"f"),this.currentMaxSpatialLayer=this.appData.producerData.maxSpatialLayer,this.parseScalabilityMode(),this.initAvailableSpatialLayers(),this.setCurrentSpatialLayerParams()}get paused(){return this.consumer.paused}pause(){return this.consumer.pause()}resume(){return this.consumer.resume()}close(){return this.consumer.close()}get isVideo(){return"video"===this.kind}get isAudio(){return"audio"===this.kind}parseScalabilityMode(){if(this.consumer.rtpParameters.encodings){const{scalabilityMode:e}=this.consumer.rtpParameters.encodings[0],{spatialLayers:t,temporalLayers:r}=ei.parseScalabilityMode(e);this.spatialLayers=t,this.temporalLayers=r,c(this,aS,"f").debug("parseScalabilityMode()",{scalabilityMode:e,spatialLayers:t,temporalLayers:r})}}initAvailableSpatialLayers(){const{encodings:e,trackTransformParams:t}=this.appData.producerData;if(!e)return;if(this.availableSpatialLayers=e.map((e=>this.tryPrepareSpatialLayerParams(e))),!t||this.availableSpatialLayers.length>1||this.spatialLayers<2)return void c(this,aS,"f").debug("Using available spatial layers",{case:"initAvailableSpatialLayers"});c(this,aS,"f").debug("Pre-generating encodings with spatial layer params",{case:"initAvailableSpatialLayers"});const r=[],n=e[e.length-1];for(let e=this.spatialLayers-1;e>=0;e-=1)r.push(this.tryPrepareSpatialLayerParams(Object.assign(Object.assign({},n),{scaleResolutionDownBy:Math.pow(2,e)})));this.availableSpatialLayers=r}setCurrentSpatialLayerParams(){const{encodings:e}=this.appData.producerData;e&&e[this.currentSpatialLayer]&&(this.currentSpatialLayerParams=this.tryPrepareSpatialLayerParams(e[this.currentSpatialLayer]),c(this,aS,"f").debug("setCurrentSpatialLayerParams()",{currentSpatialLayerParams:this.currentSpatialLayerParams}))}tryPrepareSpatialLayerParams(e){const{trackTransformParams:t}=this.appData.producerData;if(!t)return e;const{width:r,height:n}=t,i=e.scaleResolutionDownBy||1;return r&&n?Object.assign({width:r/i,height:n/i},e):e}setCurrentSpatialLayer(e){if(!this.isVideo)throw new Error("setCurrentSpatialLayer applies to video consumers only");this.currentSpatialLayer=e,c(this,aS,"f").debug("setCurrentSpatialLayer()",{currentSpatialLayer:e}),this.setCurrentSpatialLayerParams()}setCurrentTemporalLayer(e){if(!this.isVideo)throw new Error("setCurrentTemporalLayer applies to video consumers only");this.currentTemporalLayer=e,c(this,aS,"f").debug("setCurrentTemporalLayer()",{currentTemporalLayer:e})}setRequestedSpatialLayer(e){this.requestedSpatialLayer=e}setCurrentMaxSpatialLayer(e){this.currentMaxSpatialLayer=e}getStats(){var e,t;return a(this,void 0,void 0,(function*(){try{return{consumerId:this.consumer.id,codec:this.consumer.rtpParameters.codecs.find((e=>vf(e))),score:this.score,dtlsState:null===(t=null===(e=this.consumer.rtpReceiver)||void 0===e?void 0:e.transport)||void 0===t?void 0:t.state,availableSpatialLayers:this.availableSpatialLayers,currentSpatialLayerParams:this.currentSpatialLayerParams,requestedSpatialLayer:this.requestedSpatialLayer,rtcStats:yield this.getInboundRTPStreamStats()}}catch(e){return void c(this,aS,"f").debug("getStats()",{error:e})}}))}getInboundRTPStreamStats(){return a(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const r=(n=0)=>a(this,void 0,void 0,(function*(){try{const i=yield this.consumer.getStats(),s=Array.from(i.values()).find((e=>"inbound-rtp"===e.type));if(!s&&n<5)return void setTimeout((()=>r(n+1)),150);n>=5&&!s&&t(new Error("InboundRTPStreamStat not exist")),e(s)}catch(e){t(new Error("Can not get RTCStatsReport")),c(this,aS,"f").debug("getInboundRTPStreamStats()",{error:e})}}));r()}))}))}}aS=new WeakMap;const gS=new rt({autoBindInjectable:!0});var vS;gS.bind(Qn.CallState).to(Xn).inSingletonScope(),gS.bind(Qn.MyPeer).to(hp).inSingletonScope(),gS.bind(Qn.LoggerFactory).toFactory((e=>{const t=e.container.get(Qn.Config),r=t.get("logLevel"),n=t.get("sendAnalytics"),i=t.get("onLogMessage");return e=>new i_({logLevel:r,namespace:e,onLogMessage:i,sendAnalytics:n})})),gS.bind(Qn.System).to(Zy).inSingletonScope(),gS.bind(Qn.ProcessorsCache).to(Ul).inSingletonScope(),gS.bind(Qn.IntegrationsService).to(Hl).inSingletonScope(),gS.bind(Qn.MediaStreamTrackManager).to(up).inSingletonScope(),gS.bind(Qn.Media).to(pp).inSingletonScope(),gS.bind(Qn.SocketIO).to(zh).inSingletonScope(),gS.bind(Qn.LoadBalancerApiClient).to(Wy).inSingletonScope(),gS.bind(Qn.Network).to(Hh).inSingletonScope(),gS.bind(Qn.RemotePeerTracks).to(s_).inSingletonScope(),gS.bind(Qn.Peers).to($h).inSingletonScope(),gS.bind(Qn.MediaSoupEventHandler).to(Hf).inSingletonScope(),gS.bind(Qn.ChannelEventHandler).to(cf).inSingletonScope(),gS.bind(Qn.ChannelAudioObserverEventHandler).to(ub).inSingletonScope(),gS.bind(Qn.EventsQueue).to(tf).inSingletonScope(),gS.bind(Qn.ChannelStateSynchronizer).to(sf).inSingletonScope(),gS.bind(Qn.ChannelStateSyncEventHandler).to(pw).inSingletonScope(),gS.bind(Qn.StatsHandler).to(ab).inSingletonScope(),gS.bind(Qn.WebRTCIssueDetector).toDynamicValue((e=>{const t=e.container.get(Qn.Config);if(t.get("disableWid"))return;const r=e.container.get(Qn.StatsHandler),n=t.get("onIssues"),i=t.get("onNetworkScoresUpdated"),s=[1234],o=e.container.get(Qn.LoggerFactory)("WID"),a=new er({statsParser:new tr({ignoreSSRCList:s,logger:o})});return new nr({onIssues:n,issueEmitter:new Nt,networkScoresCalculator:new qt,detectors:[new Kt,new Vt,new $t,new Ht,new zt,new Gt,new Jt,new Yt],statsReporter:new Bt({compositeStatsParser:a,getStatsInterval:5e3}),onNetworkScoresUpdated:i,onStats:r.handle.bind(r),ignoreSSRCList:s,compositeStatsParser:a,logger:o,autoAddPeerConnections:!1})})).inSingletonScope(),gS.bind(Qn.Engine).to(_w).inSingletonScope(),gS.bind(Qn.PeerTrackFactory).toFactory((function(e){const t=e.container.get(Qn.LoggerFactory),r=e.container.get(Qn.CallState),n=e.container.get(Qn.StatsHandler);return i=>{const s={callState:r,loggerFactory:t,media:e.container.get(Qn.Media),network:e.container.get(Qn.Network),peerConsumerFactory:e.container.get(Qn.PeerConsumerFactory),socket:e.container.get(Qn.SocketIO)},{peerEventEmitter:o}=i,a=new pS(Object.assign(Object.assign(Object.assign({},i),s),{statsHandler:n}));return o.safeEmit(sn,a),a}})),gS.bind(Qn.PeerFactory).toFactory((function(e){const t=e.container.get(Qn.LoggerFactory),r=e.container.get(Qn.CallState);return n=>{const i={callState:r,loggerFactory:t,media:e.container.get(Qn.Media),myPeer:e.container.get(Qn.MyPeer),network:e.container.get(Qn.Network),peers:e.container.get(Qn.Peers),remotePeerTracks:e.container.get(Qn.RemotePeerTracks),socket:e.container.get(Qn.SocketIO),peerConsumerFactory:e.container.get(Qn.PeerConsumerFactory)};return new fS(Object.assign(Object.assign({},i),n))}})),gS.bind(Qn.PeerConsumerFactory).toFactory((function(e){const t=e.container.get(Qn.LoggerFactory);return e=>{const r={loggerFactory:t};return new mS(Object.assign(Object.assign({},r),e))}})),gS.bind(Qn.AudioTrackFactory).toFactory((function(e){const t=e.container.get(Qn.LoggerFactory),r=e.container.get(Qn.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(Qn.InternalEventEmitter),loggerFactory:t,media:e.container.get(Qn.Media),mediaStreamTrackManager:e.container.get(Qn.MediaStreamTrackManager),myPeer:e.container.get(Qn.MyPeer),network:e.container.get(Qn.Network),socket:e.container.get(Qn.SocketIO),processorFactory:e.container.get(Qn.AudioTrackProcessorFactory),clientEventEmitter:e.container.get(Qn.ClientEventEmitter),statsHandler:r};return new uS(Object.assign(Object.assign({},i),n))}})),gS.bind(Qn.VideoTrackFactory).toFactory((function(e){const t=e.container.get(Qn.LoggerFactory),r=e.container.get(Qn.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(Qn.InternalEventEmitter),loggerFactory:t,media:e.container.get(Qn.Media),mediaStreamTrackManager:e.container.get(Qn.MediaStreamTrackManager),myPeer:e.container.get(Qn.MyPeer),network:e.container.get(Qn.Network),socket:e.container.get(Qn.SocketIO),statsHandler:r};return new zf(Object.assign(Object.assign({},i),n))}})),gS.bind(Qn.AudioTrackProcessorFactory).toFactory((function(e){const t=e.container.get(Qn.LoggerFactory),r=e.container.get(Qn.Config),n=e.container.get(Qn.ProcessorsCache),i=r.get("asdk");return e=>{const s=r.get("denoiser");if(n.has(s,e.trackLabel))throw new Error(`Track processor for type:${s}, label:${e.trackLabel} already created`);let o;if("rnnoise"===s&&e.noiseSuppressor&&(o=new dS({noiseSuppressor:e.noiseSuppressor,loggerFactory:t})),"asdk"===s&&(null==i?void 0:i.customerId)&&(o=new f_({asdkCustomerId:i.customerId,loggerFactory:t})),!o)throw new TypeError("Incorrect parameters passed to AudioTrackProcessorFactory");return o}})),gS.bind(Qn.DataChannelsManager).to(bw).inSingletonScope();class yS{constructor(e){vS.set(this,void 0);const{clientEventEmitter:t,internalEventEmitter:r}=e;gS.bind(Qn.Config).toDynamicValue((()=>new Ct(e))).inSingletonScope(),gS.bind(Qn.InternalEventEmitter).toDynamicValue((()=>null!=r?r:new Rt)).inSingletonScope(),gS.bind(Qn.ClientEventEmitter).toDynamicValue((()=>null!=t?t:new Rt)).inSingletonScope(),gS.get(Qn.IntegrationsService),this.clientEventEmitter=gS.get(Qn.ClientEventEmitter),d(this,vS,gS.get(Qn.Engine),"f")}get observer(){return this.clientEventEmitter}get id(){return c(this,vS,"f").myPeerId}get peers(){return c(this,vS,"f").getPeers()}get availableVideoDevices(){return c(this,vS,"f").system.availableVideoDevices}get availableAudioDevices(){return c(this,vS,"f").system.availableAudioDevices}get canUseNoiseSuppression(){return!0}get effectsSDKInitialized(){return c(this,vS,"f").media.effectsSDKInitialized}detectDevices(e){return a(this,void 0,void 0,(function*(){return yield c(this,vS,"f").system.detectDevices(e),{video:c(this,vS,"f").system.availableVideoDevices,audio:c(this,vS,"f").system.availableAudioDevices}}))}initEffectsSDK(){return c(this,vS,"f").media.initEffectsSDK()}join(e){return c(this,vS,"f").join(e)}leave(e){return c(this,vS,"f").release(e)}confirmActivity(){return c(this,vS,"f").confirmActivity()}createCameraVideoTrack(e){return c(this,vS,"f").createCameraVideoTrack(e)}createMicrophoneAudioTrack(e){return c(this,vS,"f").createMicrophoneAudioTrack(e)}createScreenMediaTracks(e){return c(this,vS,"f").createScreenMediaTracks(e)}deleteTrack(e){return c(this,vS,"f").deleteTrack(e)}loadPeers(e){return c(this,vS,"f").loadPeers(e)}updateAppData(e){return c(this,vS,"f").updateAppData(e)}getTransportsInfo(){return a(this,void 0,void 0,(function*(){return c(this,vS,"f").network.getTransportsStateInfo()}))}getNodeActiveStreamsStat(){return c(this,vS,"f").getNodeActiveStreamsStat()}setPreferRelay(e){c(this,vS,"f").network.setPreferRelay(e)}getPreferRelay(){return c(this,vS,"f").network.getPreferRelay()}transportsStats(){return c(this,vS,"f").transportsStats()}getAvgTracksScore(e){return c(this,vS,"f").getAvgTracksScore(e)}}vS=new WeakMap;export{yS as default};
|
|
40
|
+
!function(e,t){(function(){var r,n="Expected a function",i="__lodash_hash_undefined__",s="__lodash_placeholder__",o=16,a=32,c=64,d=128,u=256,p=1/0,h=9007199254740991,f=NaN,m=4294967295,g=[["ary",d],["bind",1],["bindKey",2],["curry",8],["curryRight",o],["flip",512],["partial",a],["partialRight",c],["rearg",u]],v="[object Arguments]",y="[object Array]",b="[object Boolean]",w="[object Date]",_="[object Error]",S="[object Function]",k="[object GeneratorFunction]",C="[object Map]",R="[object Number]",P="[object Object]",T="[object Promise]",E="[object RegExp]",D="[object Set]",M="[object String]",I="[object Symbol]",x="[object WeakMap]",O="[object ArrayBuffer]",L="[object DataView]",A="[object Float32Array]",j="[object Float64Array]",F="[object Int8Array]",N="[object Int16Array]",B="[object Int32Array]",W="[object Uint8Array]",q="[object Uint8ClampedArray]",U="[object Uint16Array]",z="[object Uint32Array]",V=/\b__p \+= '';/g,H=/\b(__p \+=) '' \+/g,$=/(__e\(.*?\)|\b__t\)) \+\n'';/g,K=/&(?:amp|lt|gt|quot|#39);/g,G=/[&<>"']/g,Q=RegExp(K.source),J=RegExp(G.source),Y=/<%-([\s\S]+?)%>/g,Z=/<%([\s\S]+?)%>/g,X=/<%=([\s\S]+?)%>/g,ee=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,te=/^\w*$/,re=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ne=/[\\^$.*+?()[\]{}|]/g,ie=RegExp(ne.source),se=/^\s+/,oe=/\s/,ae=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ce=/\{\n\/\* \[wrapped with (.+)\] \*/,de=/,? & /,ue=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,le=/[()=,{}\[\]\/\s]/,pe=/\\(\\)?/g,he=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,fe=/\w*$/,me=/^[-+]0x[0-9a-f]+$/i,ge=/^0b[01]+$/i,ve=/^\[object .+?Constructor\]$/,ye=/^0o[0-7]+$/i,be=/^(?:0|[1-9]\d*)$/,we=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,_e=/($^)/,Se=/['\n\r\u2028\u2029\\]/g,ke="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ce="\\u2700-\\u27bf",Re="a-z\\xdf-\\xf6\\xf8-\\xff",Pe="A-Z\\xc0-\\xd6\\xd8-\\xde",Te="\\ufe0e\\ufe0f",Ee="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",De="['’]",Me="[\\ud800-\\udfff]",Ie="["+Ee+"]",xe="["+ke+"]",Oe="\\d+",Le="[\\u2700-\\u27bf]",Ae="["+Re+"]",je="[^\\ud800-\\udfff"+Ee+Oe+Ce+Re+Pe+"]",Fe="\\ud83c[\\udffb-\\udfff]",Ne="[^\\ud800-\\udfff]",Be="(?:\\ud83c[\\udde6-\\uddff]){2}",We="[\\ud800-\\udbff][\\udc00-\\udfff]",qe="["+Pe+"]",Ue="(?:"+Ae+"|"+je+")",ze="(?:"+qe+"|"+je+")",Ve="(?:['’](?:d|ll|m|re|s|t|ve))?",He="(?:['’](?:D|LL|M|RE|S|T|VE))?",$e="(?:"+xe+"|"+Fe+")"+"?",Ke="[\\ufe0e\\ufe0f]?",Ge=Ke+$e+("(?:\\u200d(?:"+[Ne,Be,We].join("|")+")"+Ke+$e+")*"),Qe="(?:"+[Le,Be,We].join("|")+")"+Ge,Je="(?:"+[Ne+xe+"?",xe,Be,We,Me].join("|")+")",Ye=RegExp(De,"g"),Ze=RegExp(xe,"g"),Xe=RegExp(Fe+"(?="+Fe+")|"+Je+Ge,"g"),et=RegExp([qe+"?"+Ae+"+"+Ve+"(?="+[Ie,qe,"$"].join("|")+")",ze+"+"+He+"(?="+[Ie,qe+Ue,"$"].join("|")+")",qe+"?"+Ue+"+"+Ve,qe+"+"+He,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Oe,Qe].join("|"),"g"),tt=RegExp("[\\u200d\\ud800-\\udfff"+ke+Te+"]"),rt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],it=-1,st={};st[A]=st[j]=st[F]=st[N]=st[B]=st[W]=st[q]=st[U]=st[z]=!0,st[v]=st[y]=st[O]=st[b]=st[L]=st[w]=st[_]=st[S]=st[C]=st[R]=st[P]=st[E]=st[D]=st[M]=st[x]=!1;var ot={};ot[v]=ot[y]=ot[O]=ot[L]=ot[b]=ot[w]=ot[A]=ot[j]=ot[F]=ot[N]=ot[B]=ot[C]=ot[R]=ot[P]=ot[E]=ot[D]=ot[M]=ot[I]=ot[W]=ot[q]=ot[U]=ot[z]=!0,ot[_]=ot[S]=ot[x]=!1;var at={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ct=parseFloat,dt=parseInt,ut="object"==typeof l&&l&&l.Object===Object&&l,lt="object"==typeof self&&self&&self.Object===Object&&self,pt=ut||lt||Function("return this")(),ht=t&&!t.nodeType&&t,ft=ht&&e&&!e.nodeType&&e,mt=ft&&ft.exports===ht,gt=mt&&ut.process,vt=function(){try{var e=ft&&ft.require&&ft.require("util").types;return e||gt&>.binding&>.binding("util")}catch(e){}}(),yt=vt&&vt.isArrayBuffer,bt=vt&&vt.isDate,wt=vt&&vt.isMap,_t=vt&&vt.isRegExp,St=vt&&vt.isSet,kt=vt&&vt.isTypedArray;function Ct(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function Rt(e,t,r,n){for(var i=-1,s=null==e?0:e.length;++i<s;){var o=e[i];t(n,o,r(o),e)}return n}function Pt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}function Tt(e,t){for(var r=null==e?0:e.length;r--&&!1!==t(e[r],r,e););return e}function Et(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(!t(e[r],r,e))return!1;return!0}function Dt(e,t){for(var r=-1,n=null==e?0:e.length,i=0,s=[];++r<n;){var o=e[r];t(o,r,e)&&(s[i++]=o)}return s}function Mt(e,t){return!!(null==e?0:e.length)&&Wt(e,t,0)>-1}function It(e,t,r){for(var n=-1,i=null==e?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1}function xt(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}function Ot(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}function Lt(e,t,r,n){var i=-1,s=null==e?0:e.length;for(n&&s&&(r=e[++i]);++i<s;)r=t(r,e[i],i,e);return r}function At(e,t,r,n){var i=null==e?0:e.length;for(n&&i&&(r=e[--i]);i--;)r=t(r,e[i],i,e);return r}function jt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var Ft=Vt("length");function Nt(e,t,r){var n;return r(e,(function(e,r,i){if(t(e,r,i))return n=r,!1})),n}function Bt(e,t,r,n){for(var i=e.length,s=r+(n?1:-1);n?s--:++s<i;)if(t(e[s],s,e))return s;return-1}function Wt(e,t,r){return t==t?function(e,t,r){var n=r-1,i=e.length;for(;++n<i;)if(e[n]===t)return n;return-1}(e,t,r):Bt(e,Ut,r)}function qt(e,t,r,n){for(var i=r-1,s=e.length;++i<s;)if(n(e[i],t))return i;return-1}function Ut(e){return e!=e}function zt(e,t){var r=null==e?0:e.length;return r?Kt(e,t)/r:f}function Vt(e){return function(t){return null==t?r:t[e]}}function Ht(e){return function(t){return null==e?r:e[t]}}function $t(e,t,r,n,i){return i(e,(function(e,i,s){r=n?(n=!1,e):t(r,e,i,s)})),r}function Kt(e,t){for(var n,i=-1,s=e.length;++i<s;){var o=t(e[i]);o!==r&&(n=n===r?o:n+o)}return n}function Gt(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function Qt(e){return e?e.slice(0,hr(e)+1).replace(se,""):e}function Jt(e){return function(t){return e(t)}}function Yt(e,t){return xt(t,(function(t){return e[t]}))}function Zt(e,t){return e.has(t)}function Xt(e,t){for(var r=-1,n=e.length;++r<n&&Wt(t,e[r],0)>-1;);return r}function er(e,t){for(var r=e.length;r--&&Wt(t,e[r],0)>-1;);return r}function tr(e,t){for(var r=e.length,n=0;r--;)e[r]===t&&++n;return n}var rr=Ht({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),nr=Ht({"&":"&","<":"<",">":">",'"':""","'":"'"});function ir(e){return"\\"+at[e]}function sr(e){return tt.test(e)}function or(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function ar(e,t){return function(r){return e(t(r))}}function cr(e,t){for(var r=-1,n=e.length,i=0,o=[];++r<n;){var a=e[r];a!==t&&a!==s||(e[r]=s,o[i++]=r)}return o}function dr(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}function ur(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=[e,e]})),r}function lr(e){return sr(e)?function(e){var t=Xe.lastIndex=0;for(;Xe.test(e);)++t;return t}(e):Ft(e)}function pr(e){return sr(e)?function(e){return e.match(Xe)||[]}(e):function(e){return e.split("")}(e)}function hr(e){for(var t=e.length;t--&&oe.test(e.charAt(t)););return t}var fr=Ht({"&":"&","<":"<",">":">",""":'"',"'":"'"});var mr=function e(t){var l,oe=(t=null==t?pt:mr.defaults(pt.Object(),t,mr.pick(pt,nt))).Array,ke=t.Date,Ce=t.Error,Re=t.Function,Pe=t.Math,Te=t.Object,Ee=t.RegExp,De=t.String,Me=t.TypeError,Ie=oe.prototype,xe=Re.prototype,Oe=Te.prototype,Le=t["__core-js_shared__"],Ae=xe.toString,je=Oe.hasOwnProperty,Fe=0,Ne=(l=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||""))?"Symbol(src)_1."+l:"",Be=Oe.toString,We=Ae.call(Te),qe=pt._,Ue=Ee("^"+Ae.call(je).replace(ne,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ze=mt?t.Buffer:r,Ve=t.Symbol,He=t.Uint8Array,$e=ze?ze.allocUnsafe:r,Ke=ar(Te.getPrototypeOf,Te),Ge=Te.create,Qe=Oe.propertyIsEnumerable,Je=Ie.splice,Xe=Ve?Ve.isConcatSpreadable:r,tt=Ve?Ve.iterator:r,at=Ve?Ve.toStringTag:r,ut=function(){try{var e=hs(Te,"defineProperty");return e({},"",{}),e}catch(e){}}(),lt=t.clearTimeout!==pt.clearTimeout&&t.clearTimeout,ht=ke&&ke.now!==pt.Date.now&&ke.now,ft=t.setTimeout!==pt.setTimeout&&t.setTimeout,gt=Pe.ceil,vt=Pe.floor,Ft=Te.getOwnPropertySymbols,Ht=ze?ze.isBuffer:r,gr=t.isFinite,vr=Ie.join,yr=ar(Te.keys,Te),br=Pe.max,wr=Pe.min,_r=ke.now,Sr=t.parseInt,kr=Pe.random,Cr=Ie.reverse,Rr=hs(t,"DataView"),Pr=hs(t,"Map"),Tr=hs(t,"Promise"),Er=hs(t,"Set"),Dr=hs(t,"WeakMap"),Mr=hs(Te,"create"),Ir=Dr&&new Dr,xr={},Or=Ws(Rr),Lr=Ws(Pr),Ar=Ws(Tr),jr=Ws(Er),Fr=Ws(Dr),Nr=Ve?Ve.prototype:r,Br=Nr?Nr.valueOf:r,Wr=Nr?Nr.toString:r;function qr(e){if(ia(e)&&!Ko(e)&&!(e instanceof Hr)){if(e instanceof Vr)return e;if(je.call(e,"__wrapped__"))return qs(e)}return new Vr(e)}var Ur=function(){function e(){}return function(t){if(!na(t))return{};if(Ge)return Ge(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function zr(){}function Vr(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}function Hr(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=m,this.__views__=[]}function $r(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Kr(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Gr(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Qr(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Gr;++t<r;)this.add(e[t])}function Jr(e){var t=this.__data__=new Kr(e);this.size=t.size}function Yr(e,t){var r=Ko(e),n=!r&&$o(e),i=!r&&!n&&Yo(e),s=!r&&!n&&!i&&pa(e),o=r||n||i||s,a=o?Gt(e.length,De):[],c=a.length;for(var d in e)!t&&!je.call(e,d)||o&&("length"==d||i&&("offset"==d||"parent"==d)||s&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||ws(d,c))||a.push(d);return a}function Zr(e){var t=e.length;return t?e[Jn(0,t-1)]:r}function Xr(e,t){return Fs(Ii(e),dn(t,0,e.length))}function en(e){return Fs(Ii(e))}function tn(e,t,n){(n!==r&&!zo(e[t],n)||n===r&&!(t in e))&&an(e,t,n)}function rn(e,t,n){var i=e[t];je.call(e,t)&&zo(i,n)&&(n!==r||t in e)||an(e,t,n)}function nn(e,t){for(var r=e.length;r--;)if(zo(e[r][0],t))return r;return-1}function sn(e,t,r,n){return fn(e,(function(e,i,s){t(n,e,r(e),s)})),n}function on(e,t){return e&&xi(t,La(t),e)}function an(e,t,r){"__proto__"==t&&ut?ut(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function cn(e,t){for(var n=-1,i=t.length,s=oe(i),o=null==e;++n<i;)s[n]=o?r:Da(e,t[n]);return s}function dn(e,t,n){return e==e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function un(e,t,n,i,s,o){var a,c=1&t,d=2&t,u=4&t;if(n&&(a=s?n(e,i,s,o):n(e)),a!==r)return a;if(!na(e))return e;var l=Ko(e);if(l){if(a=function(e){var t=e.length,r=new e.constructor(t);t&&"string"==typeof e[0]&&je.call(e,"index")&&(r.index=e.index,r.input=e.input);return r}(e),!c)return Ii(e,a)}else{var p=gs(e),h=p==S||p==k;if(Yo(e))return Ri(e,c);if(p==P||p==v||h&&!s){if(a=d||h?{}:ys(e),!c)return d?function(e,t){return xi(e,ms(e),t)}(e,function(e,t){return e&&xi(t,Aa(t),e)}(a,e)):function(e,t){return xi(e,fs(e),t)}(e,on(a,e))}else{if(!ot[p])return s?e:{};a=function(e,t,r){var n=e.constructor;switch(t){case O:return Pi(e);case b:case w:return new n(+e);case L:return function(e,t){var r=t?Pi(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case A:case j:case F:case N:case B:case W:case q:case U:case z:return Ti(e,r);case C:case D:return new n;case R:case M:return new n(e);case E:return function(e){var t=new e.constructor(e.source,fe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case I:return i=e,Br?Te(Br.call(i)):{}}var i}(e,p,c)}}o||(o=new Jr);var f=o.get(e);if(f)return f;o.set(e,a),da(e)?e.forEach((function(r){a.add(un(r,t,n,r,e,o))})):sa(e)&&e.forEach((function(r,i){a.set(i,un(r,t,n,i,e,o))}));var m=l?r:(u?d?os:ss:d?Aa:La)(e);return Pt(m||e,(function(r,i){m&&(r=e[i=r]),rn(a,i,un(r,t,n,i,e,o))})),a}function ln(e,t,n){var i=n.length;if(null==e)return!i;for(e=Te(e);i--;){var s=n[i],o=t[s],a=e[s];if(a===r&&!(s in e)||!o(a))return!1}return!0}function pn(e,t,i){if("function"!=typeof e)throw new Me(n);return Os((function(){e.apply(r,i)}),t)}function hn(e,t,r,n){var i=-1,s=Mt,o=!0,a=e.length,c=[],d=t.length;if(!a)return c;r&&(t=xt(t,Jt(r))),n?(s=It,o=!1):t.length>=200&&(s=Zt,o=!1,t=new Qr(t));e:for(;++i<a;){var u=e[i],l=null==r?u:r(u);if(u=n||0!==u?u:0,o&&l==l){for(var p=d;p--;)if(t[p]===l)continue e;c.push(u)}else s(t,l,n)||c.push(u)}return c}qr.templateSettings={escape:Y,evaluate:Z,interpolate:X,variable:"",imports:{_:qr}},qr.prototype=zr.prototype,qr.prototype.constructor=qr,Vr.prototype=Ur(zr.prototype),Vr.prototype.constructor=Vr,Hr.prototype=Ur(zr.prototype),Hr.prototype.constructor=Hr,$r.prototype.clear=function(){this.__data__=Mr?Mr(null):{},this.size=0},$r.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},$r.prototype.get=function(e){var t=this.__data__;if(Mr){var n=t[e];return n===i?r:n}return je.call(t,e)?t[e]:r},$r.prototype.has=function(e){var t=this.__data__;return Mr?t[e]!==r:je.call(t,e)},$r.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Mr&&t===r?i:t,this},Kr.prototype.clear=function(){this.__data__=[],this.size=0},Kr.prototype.delete=function(e){var t=this.__data__,r=nn(t,e);return!(r<0)&&(r==t.length-1?t.pop():Je.call(t,r,1),--this.size,!0)},Kr.prototype.get=function(e){var t=this.__data__,n=nn(t,e);return n<0?r:t[n][1]},Kr.prototype.has=function(e){return nn(this.__data__,e)>-1},Kr.prototype.set=function(e,t){var r=this.__data__,n=nn(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},Gr.prototype.clear=function(){this.size=0,this.__data__={hash:new $r,map:new(Pr||Kr),string:new $r}},Gr.prototype.delete=function(e){var t=ls(this,e).delete(e);return this.size-=t?1:0,t},Gr.prototype.get=function(e){return ls(this,e).get(e)},Gr.prototype.has=function(e){return ls(this,e).has(e)},Gr.prototype.set=function(e,t){var r=ls(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Qr.prototype.add=Qr.prototype.push=function(e){return this.__data__.set(e,i),this},Qr.prototype.has=function(e){return this.__data__.has(e)},Jr.prototype.clear=function(){this.__data__=new Kr,this.size=0},Jr.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Jr.prototype.get=function(e){return this.__data__.get(e)},Jr.prototype.has=function(e){return this.__data__.has(e)},Jr.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Kr){var n=r.__data__;if(!Pr||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Gr(n)}return r.set(e,t),this.size=r.size,this};var fn=Ai(Sn),mn=Ai(kn,!0);function gn(e,t){var r=!0;return fn(e,(function(e,n,i){return r=!!t(e,n,i)})),r}function vn(e,t,n){for(var i=-1,s=e.length;++i<s;){var o=e[i],a=t(o);if(null!=a&&(c===r?a==a&&!la(a):n(a,c)))var c=a,d=o}return d}function yn(e,t){var r=[];return fn(e,(function(e,n,i){t(e,n,i)&&r.push(e)})),r}function bn(e,t,r,n,i){var s=-1,o=e.length;for(r||(r=bs),i||(i=[]);++s<o;){var a=e[s];t>0&&r(a)?t>1?bn(a,t-1,r,n,i):Ot(i,a):n||(i[i.length]=a)}return i}var wn=ji(),_n=ji(!0);function Sn(e,t){return e&&wn(e,t,La)}function kn(e,t){return e&&_n(e,t,La)}function Cn(e,t){return Dt(t,(function(t){return ea(e[t])}))}function Rn(e,t){for(var n=0,i=(t=_i(t,e)).length;null!=e&&n<i;)e=e[Bs(t[n++])];return n&&n==i?e:r}function Pn(e,t,r){var n=t(e);return Ko(e)?n:Ot(n,r(e))}function Tn(e){return null==e?e===r?"[object Undefined]":"[object Null]":at&&at in Te(e)?function(e){var t=je.call(e,at),n=e[at];try{e[at]=r;var i=!0}catch(e){}var s=Be.call(e);i&&(t?e[at]=n:delete e[at]);return s}(e):function(e){return Be.call(e)}(e)}function En(e,t){return e>t}function Dn(e,t){return null!=e&&je.call(e,t)}function Mn(e,t){return null!=e&&t in Te(e)}function In(e,t,n){for(var i=n?It:Mt,s=e[0].length,o=e.length,a=o,c=oe(o),d=1/0,u=[];a--;){var l=e[a];a&&t&&(l=xt(l,Jt(t))),d=wr(l.length,d),c[a]=!n&&(t||s>=120&&l.length>=120)?new Qr(a&&l):r}l=e[0];var p=-1,h=c[0];e:for(;++p<s&&u.length<d;){var f=l[p],m=t?t(f):f;if(f=n||0!==f?f:0,!(h?Zt(h,m):i(u,m,n))){for(a=o;--a;){var g=c[a];if(!(g?Zt(g,m):i(e[a],m,n)))continue e}h&&h.push(m),u.push(f)}}return u}function xn(e,t,n){var i=null==(e=Ds(e,t=_i(t,e)))?e:e[Bs(Zs(t))];return null==i?r:Ct(i,e,n)}function On(e){return ia(e)&&Tn(e)==v}function Ln(e,t,n,i,s){return e===t||(null==e||null==t||!ia(e)&&!ia(t)?e!=e&&t!=t:function(e,t,n,i,s,o){var a=Ko(e),c=Ko(t),d=a?y:gs(e),u=c?y:gs(t),l=(d=d==v?P:d)==P,p=(u=u==v?P:u)==P,h=d==u;if(h&&Yo(e)){if(!Yo(t))return!1;a=!0,l=!1}if(h&&!l)return o||(o=new Jr),a||pa(e)?ns(e,t,n,i,s,o):function(e,t,r,n,i,s,o){switch(r){case L:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case O:return!(e.byteLength!=t.byteLength||!s(new He(e),new He(t)));case b:case w:case R:return zo(+e,+t);case _:return e.name==t.name&&e.message==t.message;case E:case M:return e==t+"";case C:var a=or;case D:var c=1&n;if(a||(a=dr),e.size!=t.size&&!c)return!1;var d=o.get(e);if(d)return d==t;n|=2,o.set(e,t);var u=ns(a(e),a(t),n,i,s,o);return o.delete(e),u;case I:if(Br)return Br.call(e)==Br.call(t)}return!1}(e,t,d,n,i,s,o);if(!(1&n)){var f=l&&je.call(e,"__wrapped__"),m=p&&je.call(t,"__wrapped__");if(f||m){var g=f?e.value():e,S=m?t.value():t;return o||(o=new Jr),s(g,S,n,i,o)}}if(!h)return!1;return o||(o=new Jr),function(e,t,n,i,s,o){var a=1&n,c=ss(e),d=c.length,u=ss(t).length;if(d!=u&&!a)return!1;var l=d;for(;l--;){var p=c[l];if(!(a?p in t:je.call(t,p)))return!1}var h=o.get(e),f=o.get(t);if(h&&f)return h==t&&f==e;var m=!0;o.set(e,t),o.set(t,e);var g=a;for(;++l<d;){var v=e[p=c[l]],y=t[p];if(i)var b=a?i(y,v,p,t,e,o):i(v,y,p,e,t,o);if(!(b===r?v===y||s(v,y,n,i,o):b)){m=!1;break}g||(g="constructor"==p)}if(m&&!g){var w=e.constructor,_=t.constructor;w==_||!("constructor"in e)||!("constructor"in t)||"function"==typeof w&&w instanceof w&&"function"==typeof _&&_ instanceof _||(m=!1)}return o.delete(e),o.delete(t),m}(e,t,n,i,s,o)}(e,t,n,i,Ln,s))}function An(e,t,n,i){var s=n.length,o=s,a=!i;if(null==e)return!o;for(e=Te(e);s--;){var c=n[s];if(a&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++s<o;){var d=(c=n[s])[0],u=e[d],l=c[1];if(a&&c[2]){if(u===r&&!(d in e))return!1}else{var p=new Jr;if(i)var h=i(u,l,d,e,t,p);if(!(h===r?Ln(l,u,3,i,p):h))return!1}}return!0}function jn(e){return!(!na(e)||(t=e,Ne&&Ne in t))&&(ea(e)?Ue:ve).test(Ws(e));var t}function Fn(e){return"function"==typeof e?e:null==e?oc:"object"==typeof e?Ko(e)?zn(e[0],e[1]):Un(e):mc(e)}function Nn(e){if(!Rs(e))return yr(e);var t=[];for(var r in Te(e))je.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Bn(e){if(!na(e))return function(e){var t=[];if(null!=e)for(var r in Te(e))t.push(r);return t}(e);var t=Rs(e),r=[];for(var n in e)("constructor"!=n||!t&&je.call(e,n))&&r.push(n);return r}function Wn(e,t){return e<t}function qn(e,t){var r=-1,n=Qo(e)?oe(e.length):[];return fn(e,(function(e,i,s){n[++r]=t(e,i,s)})),n}function Un(e){var t=ps(e);return 1==t.length&&t[0][2]?Ts(t[0][0],t[0][1]):function(r){return r===e||An(r,e,t)}}function zn(e,t){return Ss(e)&&Ps(t)?Ts(Bs(e),t):function(n){var i=Da(n,e);return i===r&&i===t?Ma(n,e):Ln(t,i,3)}}function Vn(e,t,n,i,s){e!==t&&wn(t,(function(o,a){if(s||(s=new Jr),na(o))!function(e,t,n,i,s,o,a){var c=Is(e,n),d=Is(t,n),u=a.get(d);if(u)return void tn(e,n,u);var l=o?o(c,d,n+"",e,t,a):r,p=l===r;if(p){var h=Ko(d),f=!h&&Yo(d),m=!h&&!f&&pa(d);l=d,h||f||m?Ko(c)?l=c:Jo(c)?l=Ii(c):f?(p=!1,l=Ri(d,!0)):m?(p=!1,l=Ti(d,!0)):l=[]:aa(d)||$o(d)?(l=c,$o(c)?l=wa(c):na(c)&&!ea(c)||(l=ys(d))):p=!1}p&&(a.set(d,l),s(l,d,i,o,a),a.delete(d));tn(e,n,l)}(e,t,a,n,Vn,i,s);else{var c=i?i(Is(e,a),o,a+"",e,t,s):r;c===r&&(c=o),tn(e,a,c)}}),Aa)}function Hn(e,t){var n=e.length;if(n)return ws(t+=t<0?n:0,n)?e[t]:r}function $n(e,t,r){t=t.length?xt(t,(function(e){return Ko(e)?function(t){return Rn(t,1===e.length?e[0]:e)}:e})):[oc];var n=-1;t=xt(t,Jt(us()));var i=qn(e,(function(e,r,i){var s=xt(t,(function(t){return t(e)}));return{criteria:s,index:++n,value:e}}));return function(e,t){var r=e.length;for(e.sort(t);r--;)e[r]=e[r].value;return e}(i,(function(e,t){return function(e,t,r){var n=-1,i=e.criteria,s=t.criteria,o=i.length,a=r.length;for(;++n<o;){var c=Ei(i[n],s[n]);if(c)return n>=a?c:c*("desc"==r[n]?-1:1)}return e.index-t.index}(e,t,r)}))}function Kn(e,t,r){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=Rn(e,o);r(a,o)&&ti(s,_i(o,e),a)}return s}function Gn(e,t,r,n){var i=n?qt:Wt,s=-1,o=t.length,a=e;for(e===t&&(t=Ii(t)),r&&(a=xt(e,Jt(r)));++s<o;)for(var c=0,d=t[s],u=r?r(d):d;(c=i(a,u,c,n))>-1;)a!==e&&Je.call(a,c,1),Je.call(e,c,1);return e}function Qn(e,t){for(var r=e?t.length:0,n=r-1;r--;){var i=t[r];if(r==n||i!==s){var s=i;ws(i)?Je.call(e,i,1):hi(e,i)}}return e}function Jn(e,t){return e+vt(kr()*(t-e+1))}function Yn(e,t){var r="";if(!e||t<1||t>h)return r;do{t%2&&(r+=e),(t=vt(t/2))&&(e+=e)}while(t);return r}function Zn(e,t){return Ls(Es(e,t,oc),e+"")}function Xn(e){return Zr(za(e))}function ei(e,t){var r=za(e);return Fs(r,dn(t,0,r.length))}function ti(e,t,n,i){if(!na(e))return e;for(var s=-1,o=(t=_i(t,e)).length,a=o-1,c=e;null!=c&&++s<o;){var d=Bs(t[s]),u=n;if("__proto__"===d||"constructor"===d||"prototype"===d)return e;if(s!=a){var l=c[d];(u=i?i(l,d,c):r)===r&&(u=na(l)?l:ws(t[s+1])?[]:{})}rn(c,d,u),c=c[d]}return e}var ri=Ir?function(e,t){return Ir.set(e,t),e}:oc,ni=ut?function(e,t){return ut(e,"toString",{configurable:!0,enumerable:!1,value:nc(t),writable:!0})}:oc;function ii(e){return Fs(za(e))}function si(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var s=oe(i);++n<i;)s[n]=e[n+t];return s}function oi(e,t){var r;return fn(e,(function(e,n,i){return!(r=t(e,n,i))})),!!r}function ai(e,t,r){var n=0,i=null==e?n:e.length;if("number"==typeof t&&t==t&&i<=2147483647){for(;n<i;){var s=n+i>>>1,o=e[s];null!==o&&!la(o)&&(r?o<=t:o<t)?n=s+1:i=s}return i}return ci(e,t,oc,r)}function ci(e,t,n,i){var s=0,o=null==e?0:e.length;if(0===o)return 0;for(var a=(t=n(t))!=t,c=null===t,d=la(t),u=t===r;s<o;){var l=vt((s+o)/2),p=n(e[l]),h=p!==r,f=null===p,m=p==p,g=la(p);if(a)var v=i||m;else v=u?m&&(i||h):c?m&&h&&(i||!f):d?m&&h&&!f&&(i||!g):!f&&!g&&(i?p<=t:p<t);v?s=l+1:o=l}return wr(o,4294967294)}function di(e,t){for(var r=-1,n=e.length,i=0,s=[];++r<n;){var o=e[r],a=t?t(o):o;if(!r||!zo(a,c)){var c=a;s[i++]=0===o?0:o}}return s}function ui(e){return"number"==typeof e?e:la(e)?f:+e}function li(e){if("string"==typeof e)return e;if(Ko(e))return xt(e,li)+"";if(la(e))return Wr?Wr.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function pi(e,t,r){var n=-1,i=Mt,s=e.length,o=!0,a=[],c=a;if(r)o=!1,i=It;else if(s>=200){var d=t?null:Yi(e);if(d)return dr(d);o=!1,i=Zt,c=new Qr}else c=t?[]:a;e:for(;++n<s;){var u=e[n],l=t?t(u):u;if(u=r||0!==u?u:0,o&&l==l){for(var p=c.length;p--;)if(c[p]===l)continue e;t&&c.push(l),a.push(u)}else i(c,l,r)||(c!==a&&c.push(l),a.push(u))}return a}function hi(e,t){return null==(e=Ds(e,t=_i(t,e)))||delete e[Bs(Zs(t))]}function fi(e,t,r,n){return ti(e,t,r(Rn(e,t)),n)}function mi(e,t,r,n){for(var i=e.length,s=n?i:-1;(n?s--:++s<i)&&t(e[s],s,e););return r?si(e,n?0:s,n?s+1:i):si(e,n?s+1:0,n?i:s)}function gi(e,t){var r=e;return r instanceof Hr&&(r=r.value()),Lt(t,(function(e,t){return t.func.apply(t.thisArg,Ot([e],t.args))}),r)}function vi(e,t,r){var n=e.length;if(n<2)return n?pi(e[0]):[];for(var i=-1,s=oe(n);++i<n;)for(var o=e[i],a=-1;++a<n;)a!=i&&(s[i]=hn(s[i]||o,e[a],t,r));return pi(bn(s,1),t,r)}function yi(e,t,n){for(var i=-1,s=e.length,o=t.length,a={};++i<s;){var c=i<o?t[i]:r;n(a,e[i],c)}return a}function bi(e){return Jo(e)?e:[]}function wi(e){return"function"==typeof e?e:oc}function _i(e,t){return Ko(e)?e:Ss(e,t)?[e]:Ns(_a(e))}var Si=Zn;function ki(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:si(e,t,n)}var Ci=lt||function(e){return pt.clearTimeout(e)};function Ri(e,t){if(t)return e.slice();var r=e.length,n=$e?$e(r):new e.constructor(r);return e.copy(n),n}function Pi(e){var t=new e.constructor(e.byteLength);return new He(t).set(new He(e)),t}function Ti(e,t){var r=t?Pi(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Ei(e,t){if(e!==t){var n=e!==r,i=null===e,s=e==e,o=la(e),a=t!==r,c=null===t,d=t==t,u=la(t);if(!c&&!u&&!o&&e>t||o&&a&&d&&!c&&!u||i&&a&&d||!n&&d||!s)return 1;if(!i&&!o&&!u&&e<t||u&&n&&s&&!i&&!o||c&&n&&s||!a&&s||!d)return-1}return 0}function Di(e,t,r,n){for(var i=-1,s=e.length,o=r.length,a=-1,c=t.length,d=br(s-o,0),u=oe(c+d),l=!n;++a<c;)u[a]=t[a];for(;++i<o;)(l||i<s)&&(u[r[i]]=e[i]);for(;d--;)u[a++]=e[i++];return u}function Mi(e,t,r,n){for(var i=-1,s=e.length,o=-1,a=r.length,c=-1,d=t.length,u=br(s-a,0),l=oe(u+d),p=!n;++i<u;)l[i]=e[i];for(var h=i;++c<d;)l[h+c]=t[c];for(;++o<a;)(p||i<s)&&(l[h+r[o]]=e[i++]);return l}function Ii(e,t){var r=-1,n=e.length;for(t||(t=oe(n));++r<n;)t[r]=e[r];return t}function xi(e,t,n,i){var s=!n;n||(n={});for(var o=-1,a=t.length;++o<a;){var c=t[o],d=i?i(n[c],e[c],c,n,e):r;d===r&&(d=e[c]),s?an(n,c,d):rn(n,c,d)}return n}function Oi(e,t){return function(r,n){var i=Ko(r)?Rt:sn,s=t?t():{};return i(r,e,us(n,2),s)}}function Li(e){return Zn((function(t,n){var i=-1,s=n.length,o=s>1?n[s-1]:r,a=s>2?n[2]:r;for(o=e.length>3&&"function"==typeof o?(s--,o):r,a&&_s(n[0],n[1],a)&&(o=s<3?r:o,s=1),t=Te(t);++i<s;){var c=n[i];c&&e(t,c,i,o)}return t}))}function Ai(e,t){return function(r,n){if(null==r)return r;if(!Qo(r))return e(r,n);for(var i=r.length,s=t?i:-1,o=Te(r);(t?s--:++s<i)&&!1!==n(o[s],s,o););return r}}function ji(e){return function(t,r,n){for(var i=-1,s=Te(t),o=n(t),a=o.length;a--;){var c=o[e?a:++i];if(!1===r(s[c],c,s))break}return t}}function Fi(e){return function(t){var n=sr(t=_a(t))?pr(t):r,i=n?n[0]:t.charAt(0),s=n?ki(n,1).join(""):t.slice(1);return i[e]()+s}}function Ni(e){return function(t){return Lt(ec($a(t).replace(Ye,"")),e,"")}}function Bi(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=Ur(e.prototype),n=e.apply(r,t);return na(n)?n:r}}function Wi(e){return function(t,n,i){var s=Te(t);if(!Qo(t)){var o=us(n,3);t=La(t),n=function(e){return o(s[e],e,s)}}var a=e(t,n,i);return a>-1?s[o?t[a]:a]:r}}function qi(e){return is((function(t){var i=t.length,s=i,o=Vr.prototype.thru;for(e&&t.reverse();s--;){var a=t[s];if("function"!=typeof a)throw new Me(n);if(o&&!c&&"wrapper"==cs(a))var c=new Vr([],!0)}for(s=c?s:i;++s<i;){var d=cs(a=t[s]),u="wrapper"==d?as(a):r;c=u&&ks(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?c[cs(u[0])].apply(c,u[3]):1==a.length&&ks(a)?c[d]():c.thru(a)}return function(){var e=arguments,r=e[0];if(c&&1==e.length&&Ko(r))return c.plant(r).value();for(var n=0,s=i?t[n].apply(this,e):r;++n<i;)s=t[n].call(this,s);return s}}))}function Ui(e,t,n,i,s,o,a,c,u,l){var p=t&d,h=1&t,f=2&t,m=24&t,g=512&t,v=f?r:Bi(e);return function r(){for(var d=arguments.length,y=oe(d),b=d;b--;)y[b]=arguments[b];if(m)var w=ds(r),_=tr(y,w);if(i&&(y=Di(y,i,s,m)),o&&(y=Mi(y,o,a,m)),d-=_,m&&d<l){var S=cr(y,w);return Qi(e,t,Ui,r.placeholder,n,y,S,c,u,l-d)}var k=h?n:this,C=f?k[e]:e;return d=y.length,c?y=Ms(y,c):g&&d>1&&y.reverse(),p&&u<d&&(y.length=u),this&&this!==pt&&this instanceof r&&(C=v||Bi(C)),C.apply(k,y)}}function zi(e,t){return function(r,n){return function(e,t,r,n){return Sn(e,(function(e,i,s){t(n,r(e),i,s)})),n}(r,e,t(n),{})}}function Vi(e,t){return function(n,i){var s;if(n===r&&i===r)return t;if(n!==r&&(s=n),i!==r){if(s===r)return i;"string"==typeof n||"string"==typeof i?(n=li(n),i=li(i)):(n=ui(n),i=ui(i)),s=e(n,i)}return s}}function Hi(e){return is((function(t){return t=xt(t,Jt(us())),Zn((function(r){var n=this;return e(t,(function(e){return Ct(e,n,r)}))}))}))}function $i(e,t){var n=(t=t===r?" ":li(t)).length;if(n<2)return n?Yn(t,e):t;var i=Yn(t,gt(e/lr(t)));return sr(t)?ki(pr(i),0,e).join(""):i.slice(0,e)}function Ki(e){return function(t,n,i){return i&&"number"!=typeof i&&_s(t,n,i)&&(n=i=r),t=ga(t),n===r?(n=t,t=0):n=ga(n),function(e,t,r,n){for(var i=-1,s=br(gt((t-e)/(r||1)),0),o=oe(s);s--;)o[n?s:++i]=e,e+=r;return o}(t,n,i=i===r?t<n?1:-1:ga(i),e)}}function Gi(e){return function(t,r){return"string"==typeof t&&"string"==typeof r||(t=ba(t),r=ba(r)),e(t,r)}}function Qi(e,t,n,i,s,o,d,u,l,p){var h=8&t;t|=h?a:c,4&(t&=~(h?c:a))||(t&=-4);var f=[e,t,s,h?o:r,h?d:r,h?r:o,h?r:d,u,l,p],m=n.apply(r,f);return ks(e)&&xs(m,f),m.placeholder=i,As(m,e,t)}function Ji(e){var t=Pe[e];return function(e,r){if(e=ba(e),(r=null==r?0:wr(va(r),292))&&gr(e)){var n=(_a(e)+"e").split("e");return+((n=(_a(t(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return t(e)}}var Yi=Er&&1/dr(new Er([,-0]))[1]==p?function(e){return new Er(e)}:lc;function Zi(e){return function(t){var r=gs(t);return r==C?or(t):r==D?ur(t):function(e,t){return xt(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Xi(e,t,i,l,p,h,f,m){var g=2&t;if(!g&&"function"!=typeof e)throw new Me(n);var v=l?l.length:0;if(v||(t&=-97,l=p=r),f=f===r?f:br(va(f),0),m=m===r?m:va(m),v-=p?p.length:0,t&c){var y=l,b=p;l=p=r}var w=g?r:as(e),_=[e,t,i,l,p,y,b,h,f,m];if(w&&function(e,t){var r=e[1],n=t[1],i=r|n,o=i<131,a=n==d&&8==r||n==d&&r==u&&e[7].length<=t[8]||384==n&&t[7].length<=t[8]&&8==r;if(!o&&!a)return e;1&n&&(e[2]=t[2],i|=1&r?0:4);var c=t[3];if(c){var l=e[3];e[3]=l?Di(l,c,t[4]):c,e[4]=l?cr(e[3],s):t[4]}(c=t[5])&&(l=e[5],e[5]=l?Mi(l,c,t[6]):c,e[6]=l?cr(e[5],s):t[6]);(c=t[7])&&(e[7]=c);n&d&&(e[8]=null==e[8]?t[8]:wr(e[8],t[8]));null==e[9]&&(e[9]=t[9]);e[0]=t[0],e[1]=i}(_,w),e=_[0],t=_[1],i=_[2],l=_[3],p=_[4],!(m=_[9]=_[9]===r?g?0:e.length:br(_[9]-v,0))&&24&t&&(t&=-25),t&&1!=t)S=8==t||t==o?function(e,t,n){var i=Bi(e);return function s(){for(var o=arguments.length,a=oe(o),c=o,d=ds(s);c--;)a[c]=arguments[c];var u=o<3&&a[0]!==d&&a[o-1]!==d?[]:cr(a,d);return(o-=u.length)<n?Qi(e,t,Ui,s.placeholder,r,a,u,r,r,n-o):Ct(this&&this!==pt&&this instanceof s?i:e,this,a)}}(e,t,m):t!=a&&33!=t||p.length?Ui.apply(r,_):function(e,t,r,n){var i=1&t,s=Bi(e);return function t(){for(var o=-1,a=arguments.length,c=-1,d=n.length,u=oe(d+a),l=this&&this!==pt&&this instanceof t?s:e;++c<d;)u[c]=n[c];for(;a--;)u[c++]=arguments[++o];return Ct(l,i?r:this,u)}}(e,t,i,l);else var S=function(e,t,r){var n=1&t,i=Bi(e);return function t(){return(this&&this!==pt&&this instanceof t?i:e).apply(n?r:this,arguments)}}(e,t,i);return As((w?ri:xs)(S,_),e,t)}function es(e,t,n,i){return e===r||zo(e,Oe[n])&&!je.call(i,n)?t:e}function ts(e,t,n,i,s,o){return na(e)&&na(t)&&(o.set(t,e),Vn(e,t,r,ts,o),o.delete(t)),e}function rs(e){return aa(e)?r:e}function ns(e,t,n,i,s,o){var a=1&n,c=e.length,d=t.length;if(c!=d&&!(a&&d>c))return!1;var u=o.get(e),l=o.get(t);if(u&&l)return u==t&&l==e;var p=-1,h=!0,f=2&n?new Qr:r;for(o.set(e,t),o.set(t,e);++p<c;){var m=e[p],g=t[p];if(i)var v=a?i(g,m,p,t,e,o):i(m,g,p,e,t,o);if(v!==r){if(v)continue;h=!1;break}if(f){if(!jt(t,(function(e,t){if(!Zt(f,t)&&(m===e||s(m,e,n,i,o)))return f.push(t)}))){h=!1;break}}else if(m!==g&&!s(m,g,n,i,o)){h=!1;break}}return o.delete(e),o.delete(t),h}function is(e){return Ls(Es(e,r,Ks),e+"")}function ss(e){return Pn(e,La,fs)}function os(e){return Pn(e,Aa,ms)}var as=Ir?function(e){return Ir.get(e)}:lc;function cs(e){for(var t=e.name+"",r=xr[t],n=je.call(xr,t)?r.length:0;n--;){var i=r[n],s=i.func;if(null==s||s==e)return i.name}return t}function ds(e){return(je.call(qr,"placeholder")?qr:e).placeholder}function us(){var e=qr.iteratee||ac;return e=e===ac?Fn:e,arguments.length?e(arguments[0],arguments[1]):e}function ls(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function ps(e){for(var t=La(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Ps(i)]}return t}function hs(e,t){var n=function(e,t){return null==e?r:e[t]}(e,t);return jn(n)?n:r}var fs=Ft?function(e){return null==e?[]:(e=Te(e),Dt(Ft(e),(function(t){return Qe.call(e,t)})))}:yc,ms=Ft?function(e){for(var t=[];e;)Ot(t,fs(e)),e=Ke(e);return t}:yc,gs=Tn;function vs(e,t,r){for(var n=-1,i=(t=_i(t,e)).length,s=!1;++n<i;){var o=Bs(t[n]);if(!(s=null!=e&&r(e,o)))break;e=e[o]}return s||++n!=i?s:!!(i=null==e?0:e.length)&&ra(i)&&ws(o,i)&&(Ko(e)||$o(e))}function ys(e){return"function"!=typeof e.constructor||Rs(e)?{}:Ur(Ke(e))}function bs(e){return Ko(e)||$o(e)||!!(Xe&&e&&e[Xe])}function ws(e,t){var r=typeof e;return!!(t=null==t?h:t)&&("number"==r||"symbol"!=r&&be.test(e))&&e>-1&&e%1==0&&e<t}function _s(e,t,r){if(!na(r))return!1;var n=typeof t;return!!("number"==n?Qo(r)&&ws(t,r.length):"string"==n&&t in r)&&zo(r[t],e)}function Ss(e,t){if(Ko(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!la(e))||(te.test(e)||!ee.test(e)||null!=t&&e in Te(t))}function ks(e){var t=cs(e),r=qr[t];if("function"!=typeof r||!(t in Hr.prototype))return!1;if(e===r)return!0;var n=as(r);return!!n&&e===n[0]}(Rr&&gs(new Rr(new ArrayBuffer(1)))!=L||Pr&&gs(new Pr)!=C||Tr&&gs(Tr.resolve())!=T||Er&&gs(new Er)!=D||Dr&&gs(new Dr)!=x)&&(gs=function(e){var t=Tn(e),n=t==P?e.constructor:r,i=n?Ws(n):"";if(i)switch(i){case Or:return L;case Lr:return C;case Ar:return T;case jr:return D;case Fr:return x}return t});var Cs=Le?ea:bc;function Rs(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Oe)}function Ps(e){return e==e&&!na(e)}function Ts(e,t){return function(n){return null!=n&&(n[e]===t&&(t!==r||e in Te(n)))}}function Es(e,t,n){return t=br(t===r?e.length-1:t,0),function(){for(var r=arguments,i=-1,s=br(r.length-t,0),o=oe(s);++i<s;)o[i]=r[t+i];i=-1;for(var a=oe(t+1);++i<t;)a[i]=r[i];return a[t]=n(o),Ct(e,this,a)}}function Ds(e,t){return t.length<2?e:Rn(e,si(t,0,-1))}function Ms(e,t){for(var n=e.length,i=wr(t.length,n),s=Ii(e);i--;){var o=t[i];e[i]=ws(o,n)?s[o]:r}return e}function Is(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var xs=js(ri),Os=ft||function(e,t){return pt.setTimeout(e,t)},Ls=js(ni);function As(e,t,r){var n=t+"";return Ls(e,function(e,t){var r=t.length;if(!r)return e;var n=r-1;return t[n]=(r>1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(ae,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return Pt(g,(function(r){var n="_."+r[0];t&r[1]&&!Mt(e,n)&&e.push(n)})),e.sort()}(function(e){var t=e.match(ce);return t?t[1].split(de):[]}(n),r)))}function js(e){var t=0,n=0;return function(){var i=_r(),s=16-(i-n);if(n=i,s>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Fs(e,t){var n=-1,i=e.length,s=i-1;for(t=t===r?i:t;++n<t;){var o=Jn(n,s),a=e[o];e[o]=e[n],e[n]=a}return e.length=t,e}var Ns=function(e){var t=Fo(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(re,(function(e,r,n,i){t.push(n?i.replace(pe,"$1"):r||e)})),t}));function Bs(e){if("string"==typeof e||la(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Ws(e){if(null!=e){try{return Ae.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function qs(e){if(e instanceof Hr)return e.clone();var t=new Vr(e.__wrapped__,e.__chain__);return t.__actions__=Ii(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var Us=Zn((function(e,t){return Jo(e)?hn(e,bn(t,1,Jo,!0)):[]})),zs=Zn((function(e,t){var n=Zs(t);return Jo(n)&&(n=r),Jo(e)?hn(e,bn(t,1,Jo,!0),us(n,2)):[]})),Vs=Zn((function(e,t){var n=Zs(t);return Jo(n)&&(n=r),Jo(e)?hn(e,bn(t,1,Jo,!0),r,n):[]}));function Hs(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:va(r);return i<0&&(i=br(n+i,0)),Bt(e,us(t,3),i)}function $s(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var s=i-1;return n!==r&&(s=va(n),s=n<0?br(i+s,0):wr(s,i-1)),Bt(e,us(t,3),s,!0)}function Ks(e){return(null==e?0:e.length)?bn(e,1):[]}function Gs(e){return e&&e.length?e[0]:r}var Qs=Zn((function(e){var t=xt(e,bi);return t.length&&t[0]===e[0]?In(t):[]})),Js=Zn((function(e){var t=Zs(e),n=xt(e,bi);return t===Zs(n)?t=r:n.pop(),n.length&&n[0]===e[0]?In(n,us(t,2)):[]})),Ys=Zn((function(e){var t=Zs(e),n=xt(e,bi);return(t="function"==typeof t?t:r)&&n.pop(),n.length&&n[0]===e[0]?In(n,r,t):[]}));function Zs(e){var t=null==e?0:e.length;return t?e[t-1]:r}var Xs=Zn(eo);function eo(e,t){return e&&e.length&&t&&t.length?Gn(e,t):e}var to=is((function(e,t){var r=null==e?0:e.length,n=cn(e,t);return Qn(e,xt(t,(function(e){return ws(e,r)?+e:e})).sort(Ei)),n}));function ro(e){return null==e?e:Cr.call(e)}var no=Zn((function(e){return pi(bn(e,1,Jo,!0))})),io=Zn((function(e){var t=Zs(e);return Jo(t)&&(t=r),pi(bn(e,1,Jo,!0),us(t,2))})),so=Zn((function(e){var t=Zs(e);return t="function"==typeof t?t:r,pi(bn(e,1,Jo,!0),r,t)}));function oo(e){if(!e||!e.length)return[];var t=0;return e=Dt(e,(function(e){if(Jo(e))return t=br(e.length,t),!0})),Gt(t,(function(t){return xt(e,Vt(t))}))}function ao(e,t){if(!e||!e.length)return[];var n=oo(e);return null==t?n:xt(n,(function(e){return Ct(t,r,e)}))}var co=Zn((function(e,t){return Jo(e)?hn(e,t):[]})),uo=Zn((function(e){return vi(Dt(e,Jo))})),lo=Zn((function(e){var t=Zs(e);return Jo(t)&&(t=r),vi(Dt(e,Jo),us(t,2))})),po=Zn((function(e){var t=Zs(e);return t="function"==typeof t?t:r,vi(Dt(e,Jo),r,t)})),ho=Zn(oo);var fo=Zn((function(e){var t=e.length,n=t>1?e[t-1]:r;return n="function"==typeof n?(e.pop(),n):r,ao(e,n)}));function mo(e){var t=qr(e);return t.__chain__=!0,t}function go(e,t){return t(e)}var vo=is((function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,s=function(t){return cn(t,e)};return!(t>1||this.__actions__.length)&&i instanceof Hr&&ws(n)?((i=i.slice(n,+n+(t?1:0))).__actions__.push({func:go,args:[s],thisArg:r}),new Vr(i,this.__chain__).thru((function(e){return t&&!e.length&&e.push(r),e}))):this.thru(s)}));var yo=Oi((function(e,t,r){je.call(e,r)?++e[r]:an(e,r,1)}));var bo=Wi(Hs),wo=Wi($s);function _o(e,t){return(Ko(e)?Pt:fn)(e,us(t,3))}function So(e,t){return(Ko(e)?Tt:mn)(e,us(t,3))}var ko=Oi((function(e,t,r){je.call(e,r)?e[r].push(t):an(e,r,[t])}));var Co=Zn((function(e,t,r){var n=-1,i="function"==typeof t,s=Qo(e)?oe(e.length):[];return fn(e,(function(e){s[++n]=i?Ct(t,e,r):xn(e,t,r)})),s})),Ro=Oi((function(e,t,r){an(e,r,t)}));function Po(e,t){return(Ko(e)?xt:qn)(e,us(t,3))}var To=Oi((function(e,t,r){e[r?0:1].push(t)}),(function(){return[[],[]]}));var Eo=Zn((function(e,t){if(null==e)return[];var r=t.length;return r>1&&_s(e,t[0],t[1])?t=[]:r>2&&_s(t[0],t[1],t[2])&&(t=[t[0]]),$n(e,bn(t,1),[])})),Do=ht||function(){return pt.Date.now()};function Mo(e,t,n){return t=n?r:t,t=e&&null==t?e.length:t,Xi(e,d,r,r,r,r,t)}function Io(e,t){var i;if("function"!=typeof t)throw new Me(n);return e=va(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=r),i}}var xo=Zn((function(e,t,r){var n=1;if(r.length){var i=cr(r,ds(xo));n|=a}return Xi(e,n,t,r,i)})),Oo=Zn((function(e,t,r){var n=3;if(r.length){var i=cr(r,ds(Oo));n|=a}return Xi(t,n,e,r,i)}));function Lo(e,t,i){var s,o,a,c,d,u,l=0,p=!1,h=!1,f=!0;if("function"!=typeof e)throw new Me(n);function m(t){var n=s,i=o;return s=o=r,l=t,c=e.apply(i,n)}function g(e){return l=e,d=Os(y,t),p?m(e):c}function v(e){var n=e-u;return u===r||n>=t||n<0||h&&e-l>=a}function y(){var e=Do();if(v(e))return b(e);d=Os(y,function(e){var r=t-(e-u);return h?wr(r,a-(e-l)):r}(e))}function b(e){return d=r,f&&s?m(e):(s=o=r,c)}function w(){var e=Do(),n=v(e);if(s=arguments,o=this,u=e,n){if(d===r)return g(u);if(h)return Ci(d),d=Os(y,t),m(u)}return d===r&&(d=Os(y,t)),c}return t=ba(t)||0,na(i)&&(p=!!i.leading,a=(h="maxWait"in i)?br(ba(i.maxWait)||0,t):a,f="trailing"in i?!!i.trailing:f),w.cancel=function(){d!==r&&Ci(d),l=0,s=u=o=d=r},w.flush=function(){return d===r?c:b(Do())},w}var Ao=Zn((function(e,t){return pn(e,1,t)})),jo=Zn((function(e,t,r){return pn(e,ba(t)||0,r)}));function Fo(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Me(n);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=e.apply(this,n);return r.cache=s.set(i,o)||s,o};return r.cache=new(Fo.Cache||Gr),r}function No(e){if("function"!=typeof e)throw new Me(n);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Fo.Cache=Gr;var Bo=Si((function(e,t){var r=(t=1==t.length&&Ko(t[0])?xt(t[0],Jt(us())):xt(bn(t,1),Jt(us()))).length;return Zn((function(n){for(var i=-1,s=wr(n.length,r);++i<s;)n[i]=t[i].call(this,n[i]);return Ct(e,this,n)}))})),Wo=Zn((function(e,t){var n=cr(t,ds(Wo));return Xi(e,a,r,t,n)})),qo=Zn((function(e,t){var n=cr(t,ds(qo));return Xi(e,c,r,t,n)})),Uo=is((function(e,t){return Xi(e,u,r,r,r,t)}));function zo(e,t){return e===t||e!=e&&t!=t}var Vo=Gi(En),Ho=Gi((function(e,t){return e>=t})),$o=On(function(){return arguments}())?On:function(e){return ia(e)&&je.call(e,"callee")&&!Qe.call(e,"callee")},Ko=oe.isArray,Go=yt?Jt(yt):function(e){return ia(e)&&Tn(e)==O};function Qo(e){return null!=e&&ra(e.length)&&!ea(e)}function Jo(e){return ia(e)&&Qo(e)}var Yo=Ht||bc,Zo=bt?Jt(bt):function(e){return ia(e)&&Tn(e)==w};function Xo(e){if(!ia(e))return!1;var t=Tn(e);return t==_||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!aa(e)}function ea(e){if(!na(e))return!1;var t=Tn(e);return t==S||t==k||"[object AsyncFunction]"==t||"[object Proxy]"==t}function ta(e){return"number"==typeof e&&e==va(e)}function ra(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function na(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ia(e){return null!=e&&"object"==typeof e}var sa=wt?Jt(wt):function(e){return ia(e)&&gs(e)==C};function oa(e){return"number"==typeof e||ia(e)&&Tn(e)==R}function aa(e){if(!ia(e)||Tn(e)!=P)return!1;var t=Ke(e);if(null===t)return!0;var r=je.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Ae.call(r)==We}var ca=_t?Jt(_t):function(e){return ia(e)&&Tn(e)==E};var da=St?Jt(St):function(e){return ia(e)&&gs(e)==D};function ua(e){return"string"==typeof e||!Ko(e)&&ia(e)&&Tn(e)==M}function la(e){return"symbol"==typeof e||ia(e)&&Tn(e)==I}var pa=kt?Jt(kt):function(e){return ia(e)&&ra(e.length)&&!!st[Tn(e)]};var ha=Gi(Wn),fa=Gi((function(e,t){return e<=t}));function ma(e){if(!e)return[];if(Qo(e))return ua(e)?pr(e):Ii(e);if(tt&&e[tt])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[tt]());var t=gs(e);return(t==C?or:t==D?dr:za)(e)}function ga(e){return e?(e=ba(e))===p||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function va(e){var t=ga(e),r=t%1;return t==t?r?t-r:t:0}function ya(e){return e?dn(va(e),0,m):0}function ba(e){if("number"==typeof e)return e;if(la(e))return f;if(na(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=na(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Qt(e);var r=ge.test(e);return r||ye.test(e)?dt(e.slice(2),r?2:8):me.test(e)?f:+e}function wa(e){return xi(e,Aa(e))}function _a(e){return null==e?"":li(e)}var Sa=Li((function(e,t){if(Rs(t)||Qo(t))xi(t,La(t),e);else for(var r in t)je.call(t,r)&&rn(e,r,t[r])})),ka=Li((function(e,t){xi(t,Aa(t),e)})),Ca=Li((function(e,t,r,n){xi(t,Aa(t),e,n)})),Ra=Li((function(e,t,r,n){xi(t,La(t),e,n)})),Pa=is(cn);var Ta=Zn((function(e,t){e=Te(e);var n=-1,i=t.length,s=i>2?t[2]:r;for(s&&_s(t[0],t[1],s)&&(i=1);++n<i;)for(var o=t[n],a=Aa(o),c=-1,d=a.length;++c<d;){var u=a[c],l=e[u];(l===r||zo(l,Oe[u])&&!je.call(e,u))&&(e[u]=o[u])}return e})),Ea=Zn((function(e){return e.push(r,ts),Ct(Fa,r,e)}));function Da(e,t,n){var i=null==e?r:Rn(e,t);return i===r?n:i}function Ma(e,t){return null!=e&&vs(e,t,Mn)}var Ia=zi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=Be.call(t)),e[t]=r}),nc(oc)),xa=zi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=Be.call(t)),je.call(e,t)?e[t].push(r):e[t]=[r]}),us),Oa=Zn(xn);function La(e){return Qo(e)?Yr(e):Nn(e)}function Aa(e){return Qo(e)?Yr(e,!0):Bn(e)}var ja=Li((function(e,t,r){Vn(e,t,r)})),Fa=Li((function(e,t,r,n){Vn(e,t,r,n)})),Na=is((function(e,t){var r={};if(null==e)return r;var n=!1;t=xt(t,(function(t){return t=_i(t,e),n||(n=t.length>1),t})),xi(e,os(e),r),n&&(r=un(r,7,rs));for(var i=t.length;i--;)hi(r,t[i]);return r}));var Ba=is((function(e,t){return null==e?{}:function(e,t){return Kn(e,t,(function(t,r){return Ma(e,r)}))}(e,t)}));function Wa(e,t){if(null==e)return{};var r=xt(os(e),(function(e){return[e]}));return t=us(t),Kn(e,r,(function(e,r){return t(e,r[0])}))}var qa=Zi(La),Ua=Zi(Aa);function za(e){return null==e?[]:Yt(e,La(e))}var Va=Ni((function(e,t,r){return t=t.toLowerCase(),e+(r?Ha(t):t)}));function Ha(e){return Xa(_a(e).toLowerCase())}function $a(e){return(e=_a(e))&&e.replace(we,rr).replace(Ze,"")}var Ka=Ni((function(e,t,r){return e+(r?"-":"")+t.toLowerCase()})),Ga=Ni((function(e,t,r){return e+(r?" ":"")+t.toLowerCase()})),Qa=Fi("toLowerCase");var Ja=Ni((function(e,t,r){return e+(r?"_":"")+t.toLowerCase()}));var Ya=Ni((function(e,t,r){return e+(r?" ":"")+Xa(t)}));var Za=Ni((function(e,t,r){return e+(r?" ":"")+t.toUpperCase()})),Xa=Fi("toUpperCase");function ec(e,t,n){return e=_a(e),(t=n?r:t)===r?function(e){return rt.test(e)}(e)?function(e){return e.match(et)||[]}(e):function(e){return e.match(ue)||[]}(e):e.match(t)||[]}var tc=Zn((function(e,t){try{return Ct(e,r,t)}catch(e){return Xo(e)?e:new Ce(e)}})),rc=is((function(e,t){return Pt(t,(function(t){t=Bs(t),an(e,t,xo(e[t],e))})),e}));function nc(e){return function(){return e}}var ic=qi(),sc=qi(!0);function oc(e){return e}function ac(e){return Fn("function"==typeof e?e:un(e,1))}var cc=Zn((function(e,t){return function(r){return xn(r,e,t)}})),dc=Zn((function(e,t){return function(r){return xn(e,r,t)}}));function uc(e,t,r){var n=La(t),i=Cn(t,n);null!=r||na(t)&&(i.length||!n.length)||(r=t,t=e,e=this,i=Cn(t,La(t)));var s=!(na(r)&&"chain"in r&&!r.chain),o=ea(e);return Pt(i,(function(r){var n=t[r];e[r]=n,o&&(e.prototype[r]=function(){var t=this.__chain__;if(s||t){var r=e(this.__wrapped__),i=r.__actions__=Ii(this.__actions__);return i.push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,Ot([this.value()],arguments))})})),e}function lc(){}var pc=Hi(xt),hc=Hi(Et),fc=Hi(jt);function mc(e){return Ss(e)?Vt(Bs(e)):function(e){return function(t){return Rn(t,e)}}(e)}var gc=Ki(),vc=Ki(!0);function yc(){return[]}function bc(){return!1}var wc=Vi((function(e,t){return e+t}),0),_c=Ji("ceil"),Sc=Vi((function(e,t){return e/t}),1),kc=Ji("floor");var Cc,Rc=Vi((function(e,t){return e*t}),1),Pc=Ji("round"),Tc=Vi((function(e,t){return e-t}),0);return qr.after=function(e,t){if("function"!=typeof t)throw new Me(n);return e=va(e),function(){if(--e<1)return t.apply(this,arguments)}},qr.ary=Mo,qr.assign=Sa,qr.assignIn=ka,qr.assignInWith=Ca,qr.assignWith=Ra,qr.at=Pa,qr.before=Io,qr.bind=xo,qr.bindAll=rc,qr.bindKey=Oo,qr.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Ko(e)?e:[e]},qr.chain=mo,qr.chunk=function(e,t,n){t=(n?_s(e,t,n):t===r)?1:br(va(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,o=0,a=oe(gt(i/t));s<i;)a[o++]=si(e,s,s+=t);return a},qr.compact=function(e){for(var t=-1,r=null==e?0:e.length,n=0,i=[];++t<r;){var s=e[t];s&&(i[n++]=s)}return i},qr.concat=function(){var e=arguments.length;if(!e)return[];for(var t=oe(e-1),r=arguments[0],n=e;n--;)t[n-1]=arguments[n];return Ot(Ko(r)?Ii(r):[r],bn(t,1))},qr.cond=function(e){var t=null==e?0:e.length,r=us();return e=t?xt(e,(function(e){if("function"!=typeof e[1])throw new Me(n);return[r(e[0]),e[1]]})):[],Zn((function(r){for(var n=-1;++n<t;){var i=e[n];if(Ct(i[0],this,r))return Ct(i[1],this,r)}}))},qr.conforms=function(e){return function(e){var t=La(e);return function(r){return ln(r,e,t)}}(un(e,1))},qr.constant=nc,qr.countBy=yo,qr.create=function(e,t){var r=Ur(e);return null==t?r:on(r,t)},qr.curry=function e(t,n,i){var s=Xi(t,8,r,r,r,r,r,n=i?r:n);return s.placeholder=e.placeholder,s},qr.curryRight=function e(t,n,i){var s=Xi(t,o,r,r,r,r,r,n=i?r:n);return s.placeholder=e.placeholder,s},qr.debounce=Lo,qr.defaults=Ta,qr.defaultsDeep=Ea,qr.defer=Ao,qr.delay=jo,qr.difference=Us,qr.differenceBy=zs,qr.differenceWith=Vs,qr.drop=function(e,t,n){var i=null==e?0:e.length;return i?si(e,(t=n||t===r?1:va(t))<0?0:t,i):[]},qr.dropRight=function(e,t,n){var i=null==e?0:e.length;return i?si(e,0,(t=i-(t=n||t===r?1:va(t)))<0?0:t):[]},qr.dropRightWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!0,!0):[]},qr.dropWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!0):[]},qr.fill=function(e,t,n,i){var s=null==e?0:e.length;return s?(n&&"number"!=typeof n&&_s(e,t,n)&&(n=0,i=s),function(e,t,n,i){var s=e.length;for((n=va(n))<0&&(n=-n>s?0:s+n),(i=i===r||i>s?s:va(i))<0&&(i+=s),i=n>i?0:ya(i);n<i;)e[n++]=t;return e}(e,t,n,i)):[]},qr.filter=function(e,t){return(Ko(e)?Dt:yn)(e,us(t,3))},qr.flatMap=function(e,t){return bn(Po(e,t),1)},qr.flatMapDeep=function(e,t){return bn(Po(e,t),p)},qr.flatMapDepth=function(e,t,n){return n=n===r?1:va(n),bn(Po(e,t),n)},qr.flatten=Ks,qr.flattenDeep=function(e){return(null==e?0:e.length)?bn(e,p):[]},qr.flattenDepth=function(e,t){return(null==e?0:e.length)?bn(e,t=t===r?1:va(t)):[]},qr.flip=function(e){return Xi(e,512)},qr.flow=ic,qr.flowRight=sc,qr.fromPairs=function(e){for(var t=-1,r=null==e?0:e.length,n={};++t<r;){var i=e[t];n[i[0]]=i[1]}return n},qr.functions=function(e){return null==e?[]:Cn(e,La(e))},qr.functionsIn=function(e){return null==e?[]:Cn(e,Aa(e))},qr.groupBy=ko,qr.initial=function(e){return(null==e?0:e.length)?si(e,0,-1):[]},qr.intersection=Qs,qr.intersectionBy=Js,qr.intersectionWith=Ys,qr.invert=Ia,qr.invertBy=xa,qr.invokeMap=Co,qr.iteratee=ac,qr.keyBy=Ro,qr.keys=La,qr.keysIn=Aa,qr.map=Po,qr.mapKeys=function(e,t){var r={};return t=us(t,3),Sn(e,(function(e,n,i){an(r,t(e,n,i),e)})),r},qr.mapValues=function(e,t){var r={};return t=us(t,3),Sn(e,(function(e,n,i){an(r,n,t(e,n,i))})),r},qr.matches=function(e){return Un(un(e,1))},qr.matchesProperty=function(e,t){return zn(e,un(t,1))},qr.memoize=Fo,qr.merge=ja,qr.mergeWith=Fa,qr.method=cc,qr.methodOf=dc,qr.mixin=uc,qr.negate=No,qr.nthArg=function(e){return e=va(e),Zn((function(t){return Hn(t,e)}))},qr.omit=Na,qr.omitBy=function(e,t){return Wa(e,No(us(t)))},qr.once=function(e){return Io(2,e)},qr.orderBy=function(e,t,n,i){return null==e?[]:(Ko(t)||(t=null==t?[]:[t]),Ko(n=i?r:n)||(n=null==n?[]:[n]),$n(e,t,n))},qr.over=pc,qr.overArgs=Bo,qr.overEvery=hc,qr.overSome=fc,qr.partial=Wo,qr.partialRight=qo,qr.partition=To,qr.pick=Ba,qr.pickBy=Wa,qr.property=mc,qr.propertyOf=function(e){return function(t){return null==e?r:Rn(e,t)}},qr.pull=Xs,qr.pullAll=eo,qr.pullAllBy=function(e,t,r){return e&&e.length&&t&&t.length?Gn(e,t,us(r,2)):e},qr.pullAllWith=function(e,t,n){return e&&e.length&&t&&t.length?Gn(e,t,r,n):e},qr.pullAt=to,qr.range=gc,qr.rangeRight=vc,qr.rearg=Uo,qr.reject=function(e,t){return(Ko(e)?Dt:yn)(e,No(us(t,3)))},qr.remove=function(e,t){var r=[];if(!e||!e.length)return r;var n=-1,i=[],s=e.length;for(t=us(t,3);++n<s;){var o=e[n];t(o,n,e)&&(r.push(o),i.push(n))}return Qn(e,i),r},qr.rest=function(e,t){if("function"!=typeof e)throw new Me(n);return Zn(e,t=t===r?t:va(t))},qr.reverse=ro,qr.sampleSize=function(e,t,n){return t=(n?_s(e,t,n):t===r)?1:va(t),(Ko(e)?Xr:ei)(e,t)},qr.set=function(e,t,r){return null==e?e:ti(e,t,r)},qr.setWith=function(e,t,n,i){return i="function"==typeof i?i:r,null==e?e:ti(e,t,n,i)},qr.shuffle=function(e){return(Ko(e)?en:ii)(e)},qr.slice=function(e,t,n){var i=null==e?0:e.length;return i?(n&&"number"!=typeof n&&_s(e,t,n)?(t=0,n=i):(t=null==t?0:va(t),n=n===r?i:va(n)),si(e,t,n)):[]},qr.sortBy=Eo,qr.sortedUniq=function(e){return e&&e.length?di(e):[]},qr.sortedUniqBy=function(e,t){return e&&e.length?di(e,us(t,2)):[]},qr.split=function(e,t,n){return n&&"number"!=typeof n&&_s(e,t,n)&&(t=n=r),(n=n===r?m:n>>>0)?(e=_a(e))&&("string"==typeof t||null!=t&&!ca(t))&&!(t=li(t))&&sr(e)?ki(pr(e),0,n):e.split(t,n):[]},qr.spread=function(e,t){if("function"!=typeof e)throw new Me(n);return t=null==t?0:br(va(t),0),Zn((function(r){var n=r[t],i=ki(r,0,t);return n&&Ot(i,n),Ct(e,this,i)}))},qr.tail=function(e){var t=null==e?0:e.length;return t?si(e,1,t):[]},qr.take=function(e,t,n){return e&&e.length?si(e,0,(t=n||t===r?1:va(t))<0?0:t):[]},qr.takeRight=function(e,t,n){var i=null==e?0:e.length;return i?si(e,(t=i-(t=n||t===r?1:va(t)))<0?0:t,i):[]},qr.takeRightWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!1,!0):[]},qr.takeWhile=function(e,t){return e&&e.length?mi(e,us(t,3)):[]},qr.tap=function(e,t){return t(e),e},qr.throttle=function(e,t,r){var i=!0,s=!0;if("function"!=typeof e)throw new Me(n);return na(r)&&(i="leading"in r?!!r.leading:i,s="trailing"in r?!!r.trailing:s),Lo(e,t,{leading:i,maxWait:t,trailing:s})},qr.thru=go,qr.toArray=ma,qr.toPairs=qa,qr.toPairsIn=Ua,qr.toPath=function(e){return Ko(e)?xt(e,Bs):la(e)?[e]:Ii(Ns(_a(e)))},qr.toPlainObject=wa,qr.transform=function(e,t,r){var n=Ko(e),i=n||Yo(e)||pa(e);if(t=us(t,4),null==r){var s=e&&e.constructor;r=i?n?new s:[]:na(e)&&ea(s)?Ur(Ke(e)):{}}return(i?Pt:Sn)(e,(function(e,n,i){return t(r,e,n,i)})),r},qr.unary=function(e){return Mo(e,1)},qr.union=no,qr.unionBy=io,qr.unionWith=so,qr.uniq=function(e){return e&&e.length?pi(e):[]},qr.uniqBy=function(e,t){return e&&e.length?pi(e,us(t,2)):[]},qr.uniqWith=function(e,t){return t="function"==typeof t?t:r,e&&e.length?pi(e,r,t):[]},qr.unset=function(e,t){return null==e||hi(e,t)},qr.unzip=oo,qr.unzipWith=ao,qr.update=function(e,t,r){return null==e?e:fi(e,t,wi(r))},qr.updateWith=function(e,t,n,i){return i="function"==typeof i?i:r,null==e?e:fi(e,t,wi(n),i)},qr.values=za,qr.valuesIn=function(e){return null==e?[]:Yt(e,Aa(e))},qr.without=co,qr.words=ec,qr.wrap=function(e,t){return Wo(wi(t),e)},qr.xor=uo,qr.xorBy=lo,qr.xorWith=po,qr.zip=ho,qr.zipObject=function(e,t){return yi(e||[],t||[],rn)},qr.zipObjectDeep=function(e,t){return yi(e||[],t||[],ti)},qr.zipWith=fo,qr.entries=qa,qr.entriesIn=Ua,qr.extend=ka,qr.extendWith=Ca,uc(qr,qr),qr.add=wc,qr.attempt=tc,qr.camelCase=Va,qr.capitalize=Ha,qr.ceil=_c,qr.clamp=function(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=(n=ba(n))==n?n:0),t!==r&&(t=(t=ba(t))==t?t:0),dn(ba(e),t,n)},qr.clone=function(e){return un(e,4)},qr.cloneDeep=function(e){return un(e,5)},qr.cloneDeepWith=function(e,t){return un(e,5,t="function"==typeof t?t:r)},qr.cloneWith=function(e,t){return un(e,4,t="function"==typeof t?t:r)},qr.conformsTo=function(e,t){return null==t||ln(e,t,La(t))},qr.deburr=$a,qr.defaultTo=function(e,t){return null==e||e!=e?t:e},qr.divide=Sc,qr.endsWith=function(e,t,n){e=_a(e),t=li(t);var i=e.length,s=n=n===r?i:dn(va(n),0,i);return(n-=t.length)>=0&&e.slice(n,s)==t},qr.eq=zo,qr.escape=function(e){return(e=_a(e))&&J.test(e)?e.replace(G,nr):e},qr.escapeRegExp=function(e){return(e=_a(e))&&ie.test(e)?e.replace(ne,"\\$&"):e},qr.every=function(e,t,n){var i=Ko(e)?Et:gn;return n&&_s(e,t,n)&&(t=r),i(e,us(t,3))},qr.find=bo,qr.findIndex=Hs,qr.findKey=function(e,t){return Nt(e,us(t,3),Sn)},qr.findLast=wo,qr.findLastIndex=$s,qr.findLastKey=function(e,t){return Nt(e,us(t,3),kn)},qr.floor=kc,qr.forEach=_o,qr.forEachRight=So,qr.forIn=function(e,t){return null==e?e:wn(e,us(t,3),Aa)},qr.forInRight=function(e,t){return null==e?e:_n(e,us(t,3),Aa)},qr.forOwn=function(e,t){return e&&Sn(e,us(t,3))},qr.forOwnRight=function(e,t){return e&&kn(e,us(t,3))},qr.get=Da,qr.gt=Vo,qr.gte=Ho,qr.has=function(e,t){return null!=e&&vs(e,t,Dn)},qr.hasIn=Ma,qr.head=Gs,qr.identity=oc,qr.includes=function(e,t,r,n){e=Qo(e)?e:za(e),r=r&&!n?va(r):0;var i=e.length;return r<0&&(r=br(i+r,0)),ua(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&Wt(e,t,r)>-1},qr.indexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:va(r);return i<0&&(i=br(n+i,0)),Wt(e,t,i)},qr.inRange=function(e,t,n){return t=ga(t),n===r?(n=t,t=0):n=ga(n),function(e,t,r){return e>=wr(t,r)&&e<br(t,r)}(e=ba(e),t,n)},qr.invoke=Oa,qr.isArguments=$o,qr.isArray=Ko,qr.isArrayBuffer=Go,qr.isArrayLike=Qo,qr.isArrayLikeObject=Jo,qr.isBoolean=function(e){return!0===e||!1===e||ia(e)&&Tn(e)==b},qr.isBuffer=Yo,qr.isDate=Zo,qr.isElement=function(e){return ia(e)&&1===e.nodeType&&!aa(e)},qr.isEmpty=function(e){if(null==e)return!0;if(Qo(e)&&(Ko(e)||"string"==typeof e||"function"==typeof e.splice||Yo(e)||pa(e)||$o(e)))return!e.length;var t=gs(e);if(t==C||t==D)return!e.size;if(Rs(e))return!Nn(e).length;for(var r in e)if(je.call(e,r))return!1;return!0},qr.isEqual=function(e,t){return Ln(e,t)},qr.isEqualWith=function(e,t,n){var i=(n="function"==typeof n?n:r)?n(e,t):r;return i===r?Ln(e,t,r,n):!!i},qr.isError=Xo,qr.isFinite=function(e){return"number"==typeof e&&gr(e)},qr.isFunction=ea,qr.isInteger=ta,qr.isLength=ra,qr.isMap=sa,qr.isMatch=function(e,t){return e===t||An(e,t,ps(t))},qr.isMatchWith=function(e,t,n){return n="function"==typeof n?n:r,An(e,t,ps(t),n)},qr.isNaN=function(e){return oa(e)&&e!=+e},qr.isNative=function(e){if(Cs(e))throw new Ce("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return jn(e)},qr.isNil=function(e){return null==e},qr.isNull=function(e){return null===e},qr.isNumber=oa,qr.isObject=na,qr.isObjectLike=ia,qr.isPlainObject=aa,qr.isRegExp=ca,qr.isSafeInteger=function(e){return ta(e)&&e>=-9007199254740991&&e<=h},qr.isSet=da,qr.isString=ua,qr.isSymbol=la,qr.isTypedArray=pa,qr.isUndefined=function(e){return e===r},qr.isWeakMap=function(e){return ia(e)&&gs(e)==x},qr.isWeakSet=function(e){return ia(e)&&"[object WeakSet]"==Tn(e)},qr.join=function(e,t){return null==e?"":vr.call(e,t)},qr.kebabCase=Ka,qr.last=Zs,qr.lastIndexOf=function(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var s=i;return n!==r&&(s=(s=va(n))<0?br(i+s,0):wr(s,i-1)),t==t?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(e,t,s):Bt(e,Ut,s,!0)},qr.lowerCase=Ga,qr.lowerFirst=Qa,qr.lt=ha,qr.lte=fa,qr.max=function(e){return e&&e.length?vn(e,oc,En):r},qr.maxBy=function(e,t){return e&&e.length?vn(e,us(t,2),En):r},qr.mean=function(e){return zt(e,oc)},qr.meanBy=function(e,t){return zt(e,us(t,2))},qr.min=function(e){return e&&e.length?vn(e,oc,Wn):r},qr.minBy=function(e,t){return e&&e.length?vn(e,us(t,2),Wn):r},qr.stubArray=yc,qr.stubFalse=bc,qr.stubObject=function(){return{}},qr.stubString=function(){return""},qr.stubTrue=function(){return!0},qr.multiply=Rc,qr.nth=function(e,t){return e&&e.length?Hn(e,va(t)):r},qr.noConflict=function(){return pt._===this&&(pt._=qe),this},qr.noop=lc,qr.now=Do,qr.pad=function(e,t,r){e=_a(e);var n=(t=va(t))?lr(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return $i(vt(i),r)+e+$i(gt(i),r)},qr.padEnd=function(e,t,r){e=_a(e);var n=(t=va(t))?lr(e):0;return t&&n<t?e+$i(t-n,r):e},qr.padStart=function(e,t,r){e=_a(e);var n=(t=va(t))?lr(e):0;return t&&n<t?$i(t-n,r)+e:e},qr.parseInt=function(e,t,r){return r||null==t?t=0:t&&(t=+t),Sr(_a(e).replace(se,""),t||0)},qr.random=function(e,t,n){if(n&&"boolean"!=typeof n&&_s(e,t,n)&&(t=n=r),n===r&&("boolean"==typeof t?(n=t,t=r):"boolean"==typeof e&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=ga(e),t===r?(t=e,e=0):t=ga(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var s=kr();return wr(e+s*(t-e+ct("1e-"+((s+"").length-1))),t)}return Jn(e,t)},qr.reduce=function(e,t,r){var n=Ko(e)?Lt:$t,i=arguments.length<3;return n(e,us(t,4),r,i,fn)},qr.reduceRight=function(e,t,r){var n=Ko(e)?At:$t,i=arguments.length<3;return n(e,us(t,4),r,i,mn)},qr.repeat=function(e,t,n){return t=(n?_s(e,t,n):t===r)?1:va(t),Yn(_a(e),t)},qr.replace=function(){var e=arguments,t=_a(e[0]);return e.length<3?t:t.replace(e[1],e[2])},qr.result=function(e,t,n){var i=-1,s=(t=_i(t,e)).length;for(s||(s=1,e=r);++i<s;){var o=null==e?r:e[Bs(t[i])];o===r&&(i=s,o=n),e=ea(o)?o.call(e):o}return e},qr.round=Pc,qr.runInContext=e,qr.sample=function(e){return(Ko(e)?Zr:Xn)(e)},qr.size=function(e){if(null==e)return 0;if(Qo(e))return ua(e)?lr(e):e.length;var t=gs(e);return t==C||t==D?e.size:Nn(e).length},qr.snakeCase=Ja,qr.some=function(e,t,n){var i=Ko(e)?jt:oi;return n&&_s(e,t,n)&&(t=r),i(e,us(t,3))},qr.sortedIndex=function(e,t){return ai(e,t)},qr.sortedIndexBy=function(e,t,r){return ci(e,t,us(r,2))},qr.sortedIndexOf=function(e,t){var r=null==e?0:e.length;if(r){var n=ai(e,t);if(n<r&&zo(e[n],t))return n}return-1},qr.sortedLastIndex=function(e,t){return ai(e,t,!0)},qr.sortedLastIndexBy=function(e,t,r){return ci(e,t,us(r,2),!0)},qr.sortedLastIndexOf=function(e,t){if(null==e?0:e.length){var r=ai(e,t,!0)-1;if(zo(e[r],t))return r}return-1},qr.startCase=Ya,qr.startsWith=function(e,t,r){return e=_a(e),r=null==r?0:dn(va(r),0,e.length),t=li(t),e.slice(r,r+t.length)==t},qr.subtract=Tc,qr.sum=function(e){return e&&e.length?Kt(e,oc):0},qr.sumBy=function(e,t){return e&&e.length?Kt(e,us(t,2)):0},qr.template=function(e,t,n){var i=qr.templateSettings;n&&_s(e,t,n)&&(t=r),e=_a(e),t=Ca({},t,i,es);var s,o,a=Ca({},t.imports,i.imports,es),c=La(a),d=Yt(a,c),u=0,l=t.interpolate||_e,p="__p += '",h=Ee((t.escape||_e).source+"|"+l.source+"|"+(l===X?he:_e).source+"|"+(t.evaluate||_e).source+"|$","g"),f="//# sourceURL="+(je.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++it+"]")+"\n";e.replace(h,(function(t,r,n,i,a,c){return n||(n=i),p+=e.slice(u,c).replace(Se,ir),r&&(s=!0,p+="' +\n__e("+r+") +\n'"),a&&(o=!0,p+="';\n"+a+";\n__p += '"),n&&(p+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),u=c+t.length,t})),p+="';\n";var m=je.call(t,"variable")&&t.variable;if(m){if(le.test(m))throw new Ce("Invalid `variable` option passed into `_.template`")}else p="with (obj) {\n"+p+"\n}\n";p=(o?p.replace(V,""):p).replace(H,"$1").replace($,"$1;"),p="function("+(m||"obj")+") {\n"+(m?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(s?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+p+"return __p\n}";var g=tc((function(){return Re(c,f+"return "+p).apply(r,d)}));if(g.source=p,Xo(g))throw g;return g},qr.times=function(e,t){if((e=va(e))<1||e>h)return[];var r=m,n=wr(e,m);t=us(t),e-=m;for(var i=Gt(n,t);++r<e;)t(r);return i},qr.toFinite=ga,qr.toInteger=va,qr.toLength=ya,qr.toLower=function(e){return _a(e).toLowerCase()},qr.toNumber=ba,qr.toSafeInteger=function(e){return e?dn(va(e),-9007199254740991,h):0===e?e:0},qr.toString=_a,qr.toUpper=function(e){return _a(e).toUpperCase()},qr.trim=function(e,t,n){if((e=_a(e))&&(n||t===r))return Qt(e);if(!e||!(t=li(t)))return e;var i=pr(e),s=pr(t);return ki(i,Xt(i,s),er(i,s)+1).join("")},qr.trimEnd=function(e,t,n){if((e=_a(e))&&(n||t===r))return e.slice(0,hr(e)+1);if(!e||!(t=li(t)))return e;var i=pr(e);return ki(i,0,er(i,pr(t))+1).join("")},qr.trimStart=function(e,t,n){if((e=_a(e))&&(n||t===r))return e.replace(se,"");if(!e||!(t=li(t)))return e;var i=pr(e);return ki(i,Xt(i,pr(t))).join("")},qr.truncate=function(e,t){var n=30,i="...";if(na(t)){var s="separator"in t?t.separator:s;n="length"in t?va(t.length):n,i="omission"in t?li(t.omission):i}var o=(e=_a(e)).length;if(sr(e)){var a=pr(e);o=a.length}if(n>=o)return e;var c=n-lr(i);if(c<1)return i;var d=a?ki(a,0,c).join(""):e.slice(0,c);if(s===r)return d+i;if(a&&(c+=d.length-c),ca(s)){if(e.slice(c).search(s)){var u,l=d;for(s.global||(s=Ee(s.source,_a(fe.exec(s))+"g")),s.lastIndex=0;u=s.exec(l);)var p=u.index;d=d.slice(0,p===r?c:p)}}else if(e.indexOf(li(s),c)!=c){var h=d.lastIndexOf(s);h>-1&&(d=d.slice(0,h))}return d+i},qr.unescape=function(e){return(e=_a(e))&&Q.test(e)?e.replace(K,fr):e},qr.uniqueId=function(e){var t=++Fe;return _a(e)+t},qr.upperCase=Za,qr.upperFirst=Xa,qr.each=_o,qr.eachRight=So,qr.first=Gs,uc(qr,(Cc={},Sn(qr,(function(e,t){je.call(qr.prototype,t)||(Cc[t]=e)})),Cc),{chain:!1}),qr.VERSION="4.17.21",Pt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){qr[e].placeholder=qr})),Pt(["drop","take"],(function(e,t){Hr.prototype[e]=function(n){n=n===r?1:br(va(n),0);var i=this.__filtered__&&!t?new Hr(this):this.clone();return i.__filtered__?i.__takeCount__=wr(n,i.__takeCount__):i.__views__.push({size:wr(n,m),type:e+(i.__dir__<0?"Right":"")}),i},Hr.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Pt(["filter","map","takeWhile"],(function(e,t){var r=t+1,n=1==r||3==r;Hr.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:us(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}})),Pt(["head","last"],(function(e,t){var r="take"+(t?"Right":"");Hr.prototype[e]=function(){return this[r](1).value()[0]}})),Pt(["initial","tail"],(function(e,t){var r="drop"+(t?"":"Right");Hr.prototype[e]=function(){return this.__filtered__?new Hr(this):this[r](1)}})),Hr.prototype.compact=function(){return this.filter(oc)},Hr.prototype.find=function(e){return this.filter(e).head()},Hr.prototype.findLast=function(e){return this.reverse().find(e)},Hr.prototype.invokeMap=Zn((function(e,t){return"function"==typeof e?new Hr(this):this.map((function(r){return xn(r,e,t)}))})),Hr.prototype.reject=function(e){return this.filter(No(us(e)))},Hr.prototype.slice=function(e,t){e=va(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Hr(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(n=(t=va(t))<0?n.dropRight(-t):n.take(t-e)),n)},Hr.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hr.prototype.toArray=function(){return this.take(m)},Sn(Hr.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),s=qr[i?"take"+("last"==t?"Right":""):t],o=i||/^find/.test(t);s&&(qr.prototype[t]=function(){var t=this.__wrapped__,a=i?[1]:arguments,c=t instanceof Hr,d=a[0],u=c||Ko(t),l=function(e){var t=s.apply(qr,Ot([e],a));return i&&p?t[0]:t};u&&n&&"function"==typeof d&&1!=d.length&&(c=u=!1);var p=this.__chain__,h=!!this.__actions__.length,f=o&&!p,m=c&&!h;if(!o&&u){t=m?t:new Hr(this);var g=e.apply(t,a);return g.__actions__.push({func:go,args:[l],thisArg:r}),new Vr(g,p)}return f&&m?e.apply(this,a):(g=this.thru(l),f?i?g.value()[0]:g.value():g)})})),Pt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ie[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);qr.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(Ko(i)?i:[],e)}return this[r]((function(r){return t.apply(Ko(r)?r:[],e)}))}})),Sn(Hr.prototype,(function(e,t){var r=qr[t];if(r){var n=r.name+"";je.call(xr,n)||(xr[n]=[]),xr[n].push({name:t,func:r})}})),xr[Ui(r,2).name]=[{name:"wrapper",func:r}],Hr.prototype.clone=function(){var e=new Hr(this.__wrapped__);return e.__actions__=Ii(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ii(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ii(this.__views__),e},Hr.prototype.reverse=function(){if(this.__filtered__){var e=new Hr(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hr.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=Ko(e),n=t<0,i=r?e.length:0,s=function(e,t,r){var n=-1,i=r.length;for(;++n<i;){var s=r[n],o=s.size;switch(s.type){case"drop":e+=o;break;case"dropRight":t-=o;break;case"take":t=wr(t,e+o);break;case"takeRight":e=br(e,t-o)}}return{start:e,end:t}}(0,i,this.__views__),o=s.start,a=s.end,c=a-o,d=n?a:o-1,u=this.__iteratees__,l=u.length,p=0,h=wr(c,this.__takeCount__);if(!r||!n&&i==c&&h==c)return gi(e,this.__actions__);var f=[];e:for(;c--&&p<h;){for(var m=-1,g=e[d+=t];++m<l;){var v=u[m],y=v.iteratee,b=v.type,w=y(g);if(2==b)g=w;else if(!w){if(1==b)continue e;break e}}f[p++]=g}return f},qr.prototype.at=vo,qr.prototype.chain=function(){return mo(this)},qr.prototype.commit=function(){return new Vr(this.value(),this.__chain__)},qr.prototype.next=function(){this.__values__===r&&(this.__values__=ma(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?r:this.__values__[this.__index__++]}},qr.prototype.plant=function(e){for(var t,n=this;n instanceof zr;){var i=qs(n);i.__index__=0,i.__values__=r,t?s.__wrapped__=i:t=i;var s=i;n=n.__wrapped__}return s.__wrapped__=e,t},qr.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hr){var t=e;return this.__actions__.length&&(t=new Hr(this)),(t=t.reverse()).__actions__.push({func:go,args:[ro],thisArg:r}),new Vr(t,this.__chain__)}return this.thru(ro)},qr.prototype.toJSON=qr.prototype.valueOf=qr.prototype.value=function(){return gi(this.__wrapped__,this.__actions__)},qr.prototype.first=qr.prototype.head,tt&&(qr.prototype[tt]=function(){return this}),qr}();ft?((ft.exports=mr)._=mr,ht._=mr):pt._=mr}).call(l)}(Tw,Tw.exports);var Ew,Dw=l&&l.__extends||(Ew=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}Ew(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(Pw,"__esModule",{value:!0});var Mw=Tw.exports,Iw=["MaxBatchSize","MaxDelay","MinDelay"],xw=function(e){function t(t){var r=e.call(this)||this;return r.fifo=[],r.firstBatch=!0,function(e){if(Iw.forEach((function(t){if(!e.hasOwnProperty(t))throw new Error("Missing required MessageBatcher option: "+t)})),isNaN(e.MaxBatchSize))throw new Error("MessageBatcher MaxBatchSize option must be a number");if(!isFinite(e.MaxBatchSize))throw new Error("MessageBatcher MaxBatchSize option must be a finite number");if(e.MaxBatchSize<1)throw new Error("MessageBatcher MaxBatchSize option cannot be less than 1");if(isNaN(e.MaxDelay))throw new Error("MessageBatcher MaxDelay option must be a number");if(!isFinite(e.MaxDelay))throw new Error("MessageBatcher MaxDelay option must be a finite number");if(e.MaxDelay<0)throw new Error("MessageBatcher MaxDelay option cannot be less than 0");if(isNaN(e.MinDelay))throw new Error("MessageBatcher MinDelay option must be a number");if(!isFinite(e.MinDelay))throw new Error("MessageBatcher MinDelay option must be a finite number");if(e.MinDelay<0)throw new Error("MessageBatcher MinDelay option cannot be less than 0");if(e.MinDelay>e.MaxDelay)throw new Error("MessageBatcher MinDelay option cannot be greater than MaxDelay")}(t),r.options=t,r.releaseBatchDebouncedMax=Mw.debounce(r.releaseBatch.bind(r),r.options.MaxDelay,{maxWait:r.options.MaxDelay}),r.releaseBatchDebouncedMin=Mw.debounce(r.releaseBatch.bind(r),r.options.MinDelay,{maxWait:r.options.MinDelay}),r}return Dw(t,e),t.prototype.Queue=function(e){var t=this;(e=[].concat(e)).forEach((function(e){t.fifo.push(e),t.debounce(t.fifo,t.options.MaxBatchSize)}),this)},t.prototype.debounce=function(e,t){e.length>0&&(e.length>=t?this.firstBatch?(this.firstBatch=!1,this.releaseBatchDebouncedMax.flush()):(this.releaseBatchDebouncedMax.cancel(),this.releaseBatchDebouncedMin(e,t)):(this.releaseBatchDebouncedMin.cancel(),this.releaseBatchDebouncedMax(e,t)))},t.prototype.releaseBatch=function(e,t){var r=this.drainFIFO(e,t);r&&r.length&&(this.emit("batch",r),this.debounce(e,t))},t.prototype.drainFIFO=function(e,t){return e.length>0?e.splice(0,t):e},t}(e.EventEmitter);Pw.MessageBatcher=xw,function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(Pw)}(Rw),function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(Rw)}(Cw);let Ow,Lw=!1;const Aw=()=>{try{return Lw?null:window.localStorage}catch(e){return console.error("Get local storage error",{error:mr(e)}),e instanceof Error&&"SecurityError"===e.name&&(Lw=!0),null}};function jw(e){const t=Aw();if(!t)return null;try{return JSON.parse(t.getItem(e))}catch(e){return null}}const Fw=()=>{if(Ow)return Ow;const e=jw("sdk_clientUniqueId");if(e)return Ow=e,e;const t=r.randomBytes(12).toString("hex");return Ow=t,function(e,t){const r=Aw();if(r)try{r.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}}("sdk_clientUniqueId",t),t},Nw=()=>{const e=jw("sdk_clientUniqueId");return e||(null!=Ow?Ow:Fw())},Bw=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);function Ww(e){return!e.response&&(!!e.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(e.code)&&(e=>!Bw.has(e&&e.code))(e)))}const qw=["get","head","options"],Uw=qw.concat(["put","delete"]);function zw(e){return"ECONNABORTED"!==e.code&&(!e.response||429===e.response.status||e.response.status>=500&&e.response.status<=599)}function Vw(e){return!!e.config?.method&&(zw(e)&&-1!==Uw.indexOf(e.config.method))}function Hw(e){return Ww(e)||Vw(e)}function $w(e){const t=e?.response?.headers["retry-after"];if(!t)return 0;let r=1e3*(Number(t)||0);return 0===r&&(r=(new Date(t).valueOf()||0)-Date.now()),Math.max(0,r)}const Kw={retries:3,retryCondition:Hw,retryDelay:function(e=0,t){return Math.max(0,$w(t))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function Gw(e,t,r=!1){const n=function(e,t){return{...Kw,...t,...e["axios-retry"]}}(e,t||{});return n.retryCount=n.retryCount||0,n.lastRequestTime&&!r||(n.lastRequestTime=Date.now()),e["axios-retry"]=n,n}const Qw=(e,t)=>{const r=e.interceptors.request.use((e=>(Gw(e,t,!0),e["axios-retry"]?.validateResponse&&(e.validateStatus=()=>!1),e))),n=e.interceptors.response.use(null,(async r=>{const{config:n}=r;if(!n)return Promise.reject(r);const i=Gw(n,t);return r.response&&i.validateResponse?.(r.response)?r.response:await async function(e,t){const{retries:r,retryCondition:n}=e,i=(e.retryCount||0)<r&&n(t);if("object"==typeof i)try{return!1!==await i}catch(e){return!1}return i}(i,r)?async function(e,t,r,n){t.retryCount+=1;const{retryDelay:i,shouldResetTimeout:s,onRetry:o}=t,a=i(t.retryCount,r);if(function(e,t){e.defaults.agent===t.agent&&delete t.agent,e.defaults.httpAgent===t.httpAgent&&delete t.httpAgent,e.defaults.httpsAgent===t.httpsAgent&&delete t.httpsAgent}(e,n),!s&&n.timeout&&t.lastRequestTime){const e=Date.now()-t.lastRequestTime,i=n.timeout-e-a;if(i<=0)return Promise.reject(r);n.timeout=i}return n.transformRequest=[e=>e],await o(t.retryCount,r,n),n.signal?.aborted?Promise.resolve(e(n)):new Promise((t=>{const r=()=>{clearTimeout(i),t(e(n))},i=setTimeout((()=>{t(e(n)),n.signal?.removeEventListener&&n.signal.removeEventListener("abort",r)}),a);n.signal?.addEventListener&&n.signal.addEventListener("abort",r,{once:!0})}))}(e,i,r,n):(await async function(e,t){e.retryCount>=e.retries&&await e.onMaxRetryTimesExceeded(t,e.retryCount)}(i,r),Promise.reject(r))}));return{requestInterceptorId:r,responseInterceptorId:n}};Qw.isNetworkError=Ww,Qw.isSafeRequestError=function(e){return!!e.config?.method&&(zw(e)&&-1!==qw.indexOf(e.config.method))},Qw.isIdempotentRequestError=Vw,Qw.isNetworkOrIdempotentRequestError=Hw,Qw.exponentialDelay=function(e=0,t,r=100){const n=2**e*r,i=Math.max(n,$w(t));return i+.2*i*Math.random()},Qw.linearDelay=function(e=100){return(t=0,r)=>{const n=t*e;return Math.max(n,$w(r))}},Qw.isRetryableError=zw;class Jw{constructor(e){this.api=e,Qw(this.api,{retries:2,shouldResetTimeout:!0,retryDelay:e=>1500*e,retryCondition:e=>{var t,r;return/^\/?log\//.test(null!==(r=null===(t=e.config)||void 0===t?void 0:t.url)&&void 0!==r?r:"")||!1}})}batch(e){return a(this,void 0,void 0,(function*(){return this.api.post("/log/batch",e)}))}}class Yw{constructor(){this.api=kg.create({baseURL:"https://moodhood-analytics.livedigital.space/v1",timeout:1e4,withCredentials:!0,paramsSerializer:e=>By.stringify(e),headers:{"x-cl-id":Nw()}}),this.api.defaults.headers.common["Cache-Control"]="no-cache",this.api.defaults.headers.common.Pragma="no-cache",this.api.defaults.headers.common.Expires="0",this.logApi=new Jw(this.api)}get log(){return this.logApi}}var Zw,Xw,e_,t_,r_,n_,i_,s_;class o_{constructor(e){Zw.add(this),Xw.set(this,void 0),e_.set(this,void 0),t_.set(this,void 0),r_.set(this,void 0),n_.set(this,void 0);const{logLevel:t,namespace:r,onLogMessage:n}=e;d(this,Xw,r,"f"),d(this,e_,t,"f"),this.onLogMessage=n,d(this,r_,new Yw,"f"),d(this,t_,new Cw.MessageBatcher({MaxBatchSize:50,MaxDelay:1e3,MinDelay:500}),"f"),d(this,n_,e.sendAnalytics,"f"),c(this,t_,"f").on("batch",(e=>a(this,void 0,void 0,(function*(){yield this.logToApi(e)})))),this._debug=Yi("LiveDigital").extend("debug").extend(c(this,Xw,"f")),this._info=Yi("LiveDigital").extend("info").extend(c(this,Xw,"f")),this._warn=Yi("LiveDigital").extend("warn").extend(c(this,Xw,"f")),this._error=Yi("LiveDigital").extend("error").extend(c(this,Xw,"f")),this._debug.log=console.info.bind(console),this._info.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}debug(e,t){this._debug(e,t),c(this,n_,"f")&&c(this,t_,"f").Queue({level:"debug",message:e,meta:t}),c(this,e_,"f")>=ht&&c(this,Zw,"m",i_).call(this,"debug",e,t)}info(e,t){this._info(e,t),c(this,n_,"f")&&c(this,t_,"f").Queue({level:"info",message:e,meta:t}),c(this,e_,"f")>=pt&&c(this,Zw,"m",i_).call(this,"info",e,t)}warn(e,t){this._warn(e,t),c(this,n_,"f")&&c(this,t_,"f").Queue({level:"warn",message:e,meta:t}),c(this,e_,"f")>=lt&&c(this,Zw,"m",i_).call(this,"warn",e,t)}error(e,t){this._error(e,t),c(this,n_,"f")&&c(this,t_,"f").Queue({level:"error",message:e,meta:t}),c(this,e_,"f")>=ut&&c(this,Zw,"m",i_).call(this,"error",e,t)}logToApi(e){return a(this,void 0,void 0,(function*(){try{yield c(this,r_,"f").log.batch({logs:e.map((e=>c(this,Zw,"m",s_).call(this,Object.assign(Object.assign({},e),{meta:this.prepareRecordMeta(e.meta)})))),clientMeta:this.getClientMeta()})}catch(e){this._debug("Log request was not successful",{error:e})}}))}getClientMeta(){return Object.assign(Object.assign({},gr.meta),{clUId:Nw()})}prepareRecordMeta(e){const t=e||{},{error:r}=t;return Object.assign(Object.assign(Object.assign({},t),{clientTimestamp:(new Date).toISOString(),from_sdk:!0}),r&&"object"==typeof r?{error:mr(r)}:{})}}Xw=new WeakMap,e_=new WeakMap,t_=new WeakMap,r_=new WeakMap,n_=new WeakMap,Zw=new WeakSet,i_=function(e,t,...r){"function"==typeof this.onLogMessage&&this.onLogMessage(t,...c(this,Zw,"m",s_).call(this,r),e)},s_=function(e){const t=new WeakMap;return function e(r,n=[]){if(!Qh(r))return r;const i=t.get(r);if(i)return`[Circular *${i.join(".")}]`;t.set(r,n);const s=Array.isArray(r)?[]:{};return Object.entries(r).forEach((([t,r])=>{s[t]=e(r,[...n,t])})),t.delete(r),s}(e)};let a_=class{constructor(e){this.peerTrackFactory=e,this.tracksByConsumerId=new Map}register(e,t){this.tracksByConsumerId.set(e,t)}get(e){return this.tracksByConsumerId.get(e)}delete(e){return this.tracksByConsumerId.delete(e)}reset(){this.tracksByConsumerId.clear()}create(e){const{consumer:t,label:r,muted:n=!1,mediaStreamTrack:i,paused:s,peerEventEmitter:o}=e,a=this.peerTrackFactory({consumer:t,label:r,mediaStreamTrack:i,paused:s,peerEventEmitter:o,muted:n,onClose:()=>{void 0!==a.consumerId&&this.delete(a.consumerId)}});return void 0!==a.consumerId&&this.register(a.consumerId,a),a}};var c_,d_,u_,l_,p_,h_,f_;a_=i([at(),s(0,dt(Yn.PeerTrackFactory)),o("design:paramtypes",[Function])],a_);const m_=()=>{};class g_{constructor(e){c_.set(this,void 0),d_.set(this,void 0),u_.set(this,null),l_.set(this,"speed"),p_.set(this,16e3),h_.set(this,void 0),this.type="asdk",f_.set(this,void 0);const{loggerFactory:t}=e;d(this,d_,t("ASDKTrackProcessor"),"f"),d(this,f_,"function"==typeof e.onError?e.onError:m_,"f"),d(this,c_,new window.atsvb(e.asdkCustomerId),"f"),c(this,c_,"f").config({preset:c(this,l_,"f"),sample_rate:c(this,p_,"f"),sdk_url:"https://effectssdk.ai/sdk/audio/",wasmPaths:{"ort-wasm.wasm":"https://effectssdk.ai/sdk/audio/dev/2.4.2/ort-wasm.wasm","ort-wasm-simd.wasm":"https://effectssdk.ai/sdk/audio/dev/2.4.2/ort-wasm-simd.wasm"}}),c(this,c_,"f").onError((e=>{const{message:t,type:r,cause:i}=e,s=n(e,["message","type","cause"]);"error"===r&&(c(this,d_,"f").error(t,Object.assign(Object.assign({error:mr(i),cause:i},s),{type:this.type,case:"Denoiser"})),c(this,f_,"f").call(this),d(this,f_,m_,"f")),"warning"===r&&c(this,d_,"f").warn(t,Object.assign(Object.assign({},s),{type:this.type,case:"Denoiser"})),"info"===r&&c(this,d_,"f").info(t,Object.assign(Object.assign({},s),{type:this.type,case:"Denoiser"}))}))}setOnError(e){d(this,f_,e,"f")}init(){return a(this,void 0,void 0,(function*(){yield c(this,c_,"f").preload()}))}get isProcessing(){return!!c(this,h_,"f")}processTrack(e){var t;return a(this,void 0,void 0,(function*(){if(c(this,u_,"f")===e||"ended"===e.readyState)return(null===(t=c(this,c_,"f").getStream())||void 0===t?void 0:t.getAudioTracks()[0])||e;yield this.stopProcessing();try{const t=new Promise(((t,r)=>{c(this,c_,"f").onReady=()=>{try{const r=c(this,c_,"f").getStream(),n=null==r?void 0:r.getAudioTracks()[0];if(!n)return void t(e);d(this,u_,e,"f"),d(this,h_,n,"f"),t(n),c(this,c_,"f").run()}catch(e){r(e)}finally{c(this,c_,"f").onReady=void 0}}}));c(this,c_,"f").useStream(new MediaStream([e]));return yield t}catch(t){throw c(this,d_,"f").error("processTrack()",{error:mr(t),type:this.type,case:"Denoiser",track:e}),c(this,f_,"f").call(this),d(this,f_,m_,"f"),new Error("Can not process this track")}}))}stopProcessing(){return a(this,void 0,void 0,(function*(){try{c(this,c_,"f").stop()}catch(e){c(this,d_,"f").error("stopProcessing()",{type:this.type,case:"Denoiser",error:mr(e)})}finally{d(this,u_,null,"f")}}))}}c_=new WeakMap,d_=new WeakMap,u_=new WeakMap,l_=new WeakMap,p_=new WeakMap,h_=new WeakMap,f_=new WeakMap;class v_ extends AudioWorkletNode{constructor(e){super(e.context,"rnnoise",{channelCountMode:"explicit",channelCount:1,channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{module:e.noiseSuppressor.module}}),this.port.onmessage=({data:e})=>{const t=Object.assign(new Event("status"),e);this.dispatchEvent(t)}}update(e){this.port.postMessage(e)}static register(e){return a(this,void 0,void 0,(function*(){const t=yS.get(Yn.Config);yield e.audioWorklet.addModule(`${t.get("staticFilesPath")}/noiseSuppressionWorklet.js`)}))}}var y_,b_,w_,__,S_,k_;class C_{constructor(e){y_.set(this,void 0),b_.set(this,void 0),w_.set(this,void 0),__.set(this,void 0),S_.set(this,void 0),k_.set(this,!0),d(this,y_,e.noiseSuppressor.instance.exports,"f"),d(this,b_,e.context,"f"),d(this,w_,new Float32Array(c(this,y_,"f").memory.buffer),"f"),d(this,__,c(this,y_,"f").newState(),"f"),d(this,S_,c(this,b_,"f").createScriptProcessor(),"f"),this.setOnAudioProcess()}get noiseSuppressionScriptProcessorNode(){return c(this,S_,"f")}update(e){e||(d(this,k_,!1,"f"),c(this,y_,"f").deleteState(c(this,__,"f")));const t=Object.assign(new Event("status"),{vadProb:c(this,y_,"f").getVadProb(c(this,__,"f"))});c(this,S_,"f").dispatchEvent(t)}setOnAudioProcess(){c(this,S_,"f").addEventListener("audioprocess",(({inputBuffer:e,outputBuffer:t})=>{if(!c(this,k_,"f"))return;c(this,w_,"f").set(e.getChannelData(0),c(this,y_,"f").getInput(c(this,__,"f"))/4);const r=t.getChannelData(0),n=c(this,y_,"f").pipe(c(this,__,"f"),r.length)/4;n&&r.set(c(this,w_,"f").subarray(n,n+r.length))}))}}y_=new WeakMap,b_=new WeakMap,w_=new WeakMap,__=new WeakMap,S_=new WeakMap,k_=new WeakMap;var R_,P_,T_,E_,D_,M_,I_,x_,O_,L_,A_,j_,F_,N_,B_,W_,q_,U_,z_,V_,H_,$_,K_,G_,Q_,J_,Y_,Z_,X_,eS,tS,rS,nS,iS,sS,oS,aS,cS,dS;class uS{constructor({context:e,noiseSuppressor:t}){R_.set(this,void 0),P_.set(this,void 0),T_.set(this,void 0),d(this,R_,e,"f"),d(this,P_,t,"f")}createNoiseSuppressionNode(){return a(this,void 0,void 0,(function*(){return/apple/i.test(navigator.vendor)?this.createScriptProcessorNode():this.createAudioWorkletNode()}))}stop(){var e;null===(e=c(this,T_,"f"))||void 0===e||e.update(!1)}createAudioWorkletNode(){return a(this,void 0,void 0,(function*(){return yield v_.register(c(this,R_,"f")),d(this,T_,new v_({context:c(this,R_,"f"),noiseSuppressor:c(this,P_,"f")}),"f"),c(this,T_,"f")}))}createScriptProcessorNode(){return d(this,T_,new C_({context:c(this,R_,"f"),noiseSuppressor:c(this,P_,"f")}),"f"),c(this,T_,"f").noiseSuppressionScriptProcessorNode}}R_=new WeakMap,P_=new WeakMap,T_=new WeakMap;class lS{constructor(e){E_.set(this,void 0),D_.set(this,void 0),M_.set(this,void 0),I_.set(this,void 0),this.type="rnnoise",d(this,E_,e.noiseSuppressor,"f"),d(this,M_,e.loggerFactory("TrackProcessor"),"f")}get isProcessing(){return!!c(this,I_,"f")}processTrack(e){return a(this,void 0,void 0,(function*(){const t=(e=>{const t=window.AudioContext||window.webkitAudioContext||!1;return t?new t(e):null})();if(!t)throw new Error("AudioContext is not available");const r=new MediaStreamAudioDestinationNode(t,{channelCountMode:"explicit",channelCount:1,channelInterpretation:"speakers"});yield v_.register(t);const n=t.createMediaStreamSource(new MediaStream([e])),i=new uS({context:t,noiseSuppressor:c(this,E_,"f")}),s=yield i.createNoiseSuppressionNode();s.connect(r),n.connect(s);const[o]=r.stream.getTracks();return d(this,D_,{audioContext:t,streamDestination:r,noiseSuppressionNode:s,noiseSuppressionProvider:i},"f"),d(this,I_,o,"f"),c(this,M_,"f").info("processTrack()",{case:"Denoiser",type:this.type,track:e.id}),o}))}stopProcessing(){var e;return a(this,void 0,void 0,(function*(){if(this.isProcessing)if(c(this,D_,"f"))try{c(this,D_,"f").noiseSuppressionProvider.stop(),c(this,D_,"f").noiseSuppressionNode.disconnect(),c(this,D_,"f").streamDestination.disconnect(),yield c(this,D_,"f").audioContext.close(),null===(e=c(this,I_,"f"))||void 0===e||e.stop(),d(this,I_,void 0,"f"),c(this,M_,"f").info("stopProcessing()",{success:!0,case:"Denoiser",type:this.type})}catch(e){c(this,M_,"f").error("stopProcessing()",{success:!1,error:mr(e),case:"Denoiser",type:this.type})}else c(this,M_,"f").warn("stopProcessing()",{success:!1,description:"Processing context is not available",case:"Denoiser",type:this.type});else c(this,M_,"f").debug("stopProcessing()",{description:"Track is not processed",case:"Denoiser",type:this.type})}))}}E_=new WeakMap,D_=new WeakMap,M_=new WeakMap,I_=new WeakMap;class pS extends Vf{constructor(){super(...arguments),x_.set(this,!1),O_.set(this,void 0),L_.set(this,void 0)}get isDenoiserRequireActivation(){var e;return!(null===(e=c(this,O_,"f"))||void 0===e?void 0:e.isProcessing)&&c(this,x_,"f")}prepareTrackProcessor(e){this.logger.debug("Setting trackProcessor to AudioTrack",{case:"Denoiser",type:e.type}),d(this,O_,e,"f")}unsetTrackProcessor(){d(this,O_,void 0,"f")}get isEffectsProcessing(){var e;return Boolean(null===(e=c(this,O_,"f"))||void 0===e?void 0:e.isProcessing)}getEncoderConfig(){return this.encoderConfig}getEncodings(){var e;return null!==(e=this.getEncoderConfig().encodings)&&void 0!==e?e:jl}getCodecOptions(){var e,t;return{opusFec:null===(e=this.getEncoderConfig().enableFec)||void 0===e||e,opusDtx:null===(t=this.getEncoderConfig().enableDtx)||void 0===t||t}}getPreferredCodec(){const{preferredCodec:e}=this.getEncoderConfig();return e||"opus"}enableNoiseSuppression(){var e,t;return a(this,void 0,void 0,(function*(){if(d(this,x_,!0,"f"),c(this,O_,"f"))try{const r=yield null===(e=c(this,O_,"f"))||void 0===e?void 0:e.processTrack(this.mediaStreamTrack);d(this,L_,this.mediaStreamTrack,"f"),yield this.replaceTrack(r),this.logger.debug("Denoiser activated",{case:"Denoiser",type:(null===(t=c(this,O_,"f"))||void 0===t?void 0:t.type)||"none"})}catch(e){throw this.logger.warn("enableNoiseSuppression()",{description:"Can not enable noise suppression",track:this.logCtx,error:mr(e)}),new Error("Can not enable noise suppression")}else this.logger.warn("enableNoiseSuppression()",{description:"Track suppressor is not defined"})}))}disableNoiseSuppression(){var e,t,r;return a(this,void 0,void 0,(function*(){d(this,x_,!1,"f");try{if(!(null===(e=c(this,O_,"f"))||void 0===e?void 0:e.isProcessing))return void this.logger.debug("stopProcessing()",{description:"Track is not processed"});if(!c(this,L_,"f"))return void this.logger.warn("disableNoiseSuppression()",{description:"Original track missing"});this.isPublished&&(yield this.replaceTrack(c(this,L_,"f"))),yield null===(t=c(this,O_,"f"))||void 0===t?void 0:t.stopProcessing(),this.logger.debug("Denoiser deactivated",{case:"Denoiser",type:(null===(r=c(this,O_,"f"))||void 0===r?void 0:r.type)||"none"})}catch(e){throw this.logger.warn("disableNoiseSuppression()",{description:"Can not disable noise suppression",track:this.logCtx,error:mr(e)}),new Error("Can not disable noise suppression")}}))}publish(){return a(this,void 0,void 0,(function*(){yield this.produce({encodings:this.getEncodings(),preferredCodec:this.getPreferredCodec(),codecOptions:this.getCodecOptions()}),this.internalEventEmitter.emit(tn.trackProduced,this)}))}pause(){return a(this,void 0,void 0,(function*(){yield this.mute()}))}}x_=new WeakMap,O_=new WeakMap,L_=new WeakMap;class hS{constructor({track:e,statsHandler:t}){A_.set(this,void 0),j_.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return c(this,A_,"f")}get audioWebRTCStats(){return c(this,j_,"f")}handleWebRTCStats(e,t){e.addEventListener("ended",(()=>{t.removeInboundVideoHandler(e.id),t.removeInboundAudioHandler(e.id)}),{once:!0}),"video"!==e.kind?t.addInboundAudioHandler(e.id,this.setAudioWebRTCStats.bind(this)):t.addInboundVideoHandler(e.id,this.setVideoWebRTCStats.bind(this))}setVideoWebRTCStats(e){d(this,A_,e,"f")}setAudioWebRTCStats(e){d(this,j_,e,"f")}}A_=new WeakMap,j_=new WeakMap;class fS{constructor(e){this.label=Zn.Unknown,F_.set(this,void 0),N_.set(this,void 0),B_.set(this,void 0),W_.set(this,void 0),q_.set(this,void 0),U_.set(this,void 0),z_.set(this,void 0),V_.set(this,void 0),H_.set(this,void 0),$_.set(this,void 0),K_.set(this,!1),G_.set(this,void 0),Q_.set(this,!1),J_.set(this,new hf),Y_.set(this,!1),Z_.set(this,0),X_.set(this,void 0),this.observer=new Rt,d(this,H_,e.mediaStreamTrack,"f"),this.label=e.label,this.consumer=e.consumer,d(this,q_,e.peerConsumerFactory,"f"),d(this,z_,e.loggerFactory("PeerTrack"),"f"),d(this,V_,e.peerEventEmitter,"f"),d(this,Y_,e.muted,"f"),d(this,$_,e.paused,"f"),d(this,F_,e.network,"f"),d(this,N_,e.socket,"f"),d(this,B_,e.media,"f"),d(this,U_,e.callState,"f"),d(this,W_,e.onClose,"f"),d(this,X_,new hS({track:e.mediaStreamTrack,statsHandler:e.statsHandler}),"f")}get videoWebRTCStats(){return c(this,X_,"f").videoWebRTCStats}get audioWebRTCStats(){return c(this,X_,"f").audioWebRTCStats}get logCtx(){var e,t;return{id:c(this,H_,"f").id,label:this.label,consumerId:null===(e=this.consumer)||void 0===e?void 0:e.id,producerId:null===(t=this.consumer)||void 0===t?void 0:t.producerId,muted:c(this,Y_,"f"),paused:c(this,$_,"f"),closed:c(this,Q_,"f")}}get volume(){return c(this,Z_,"f")}get isRemote(){return!!this.consumer}get mediaStreamTrack(){return c(this,H_,"f")}get kind(){return this.mediaStreamTrack.kind}get isPaused(){return c(this,$_,"f")}get isMuted(){return c(this,Y_,"f")}get consumerId(){var e;return null===(e=this.consumer)||void 0===e?void 0:e.id}get currentSpatialLayer(){var e;return(null===(e=this.consumer)||void 0===e?void 0:e.currentSpatialLayer)||0}get score(){var e;return null===(e=this.consumer)||void 0===e?void 0:e.score}close(){return a(this,void 0,void 0,(function*(){c(this,V_,"f").safeEmit(cn,this),d(this,Q_,!0,"f"),c(this,W_,"f").call(this),this.consumer&&(yield this.closeConsumer(),this.clearCheckStateTimeout())}))}mute(){return a(this,void 0,void 0,(function*(){yield c(this,J_,"f").push((()=>a(this,void 0,void 0,(function*(){c(this,z_,"f").debug("mute()",{track:this.logCtx}),yield this.pauseConsumer(),d(this,Y_,!0,"f")}))))}))}unmute(){return a(this,void 0,void 0,(function*(){yield c(this,J_,"f").push((()=>a(this,void 0,void 0,(function*(){c(this,z_,"f").debug("unmute()",{track:this.logCtx}),yield this.resumeConsumer(),d(this,Y_,!1,"f")}))))}))}pause(e=!0){return a(this,void 0,void 0,(function*(){yield c(this,J_,"f").push((()=>a(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return d(this,$_,!0,"f"),c(this,V_,"f").safeEmit(dn,this),void c(this,z_,"f").debug("pause()",{track:this.logCtx});yield this.pauseConsumer(e),d(this,$_,!0,"f"),c(this,V_,"f").safeEmit(dn,this)}))))}))}resume(e=!0){return a(this,void 0,void 0,(function*(){yield c(this,J_,"f").push((()=>a(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return d(this,$_,!1,"f"),c(this,V_,"f").safeEmit(un,this),void c(this,z_,"f").debug("resume()",{track:this.logCtx});yield this.resumeConsumer(e),d(this,$_,!1,"f"),c(this,V_,"f").safeEmit(un,this)}))))}))}resumeConsumer(e=!0){return a(this,void 0,void 0,(function*(){if(this.consumer)try{this.consumer.resume(),e&&(yield c(this,F_,"f").resumeRemoteConsumer(this.consumer.id)),this.checkConsumerState().catch((e=>{c(this,z_,"f").warn("Failed to checkConsumerState()",{track:this.logCtx,error:mr(e)})})),c(this,z_,"f").debug("resumeConsumer()",{track:this.logCtx})}catch(e){c(this,z_,"f").warn("resumeConsumer()",{error:e})}}))}pauseConsumer(e=!0){return a(this,void 0,void 0,(function*(){if(this.consumer)try{this.clearCheckStateTimeout(),e&&(yield c(this,F_,"f").pauseRemoteConsumer(this.consumer.id)),this.consumer.pause(),d(this,K_,!1,"f"),c(this,z_,"f").debug("pauseConsumer()",{track:this.logCtx})}catch(e){c(this,z_,"f").warn("pauseConsumer()",{error:e})}}))}requestVideoPreferredLayers({spatialLayer:e,temporalLayer:t}){return a(this,void 0,void 0,(function*(){if(this.consumer)try{if(this.consumer.isAudio)return void c(this,z_,"f").warn("Only video consumers support layers",{case:"requestVideoPreferredLayers"});if(e===this.consumer.currentSpatialLayer)return;if(e>this.consumer.spatialLayers)return void c(this,z_,"f").warn("Invalid spatial layer",{spatialLayer:e,consumerSpatialLayers:this.consumer.spatialLayers,case:"requestVideoPreferredLayers"});if(e>this.consumer.currentMaxSpatialLayer)return void(yield this.requestMaxSpatialLayer(this.consumer.id,e));yield c(this,N_,"f").request(Mn,{consumerId:this.consumer.id,spatialLayer:e,temporalLayer:t}),c(this,z_,"f").debug("requestVideoPreferredLayers()",{track:this.logCtx,consumer:this.consumer,spatialLayer:e,temporalLayer:t})}catch(e){throw c(this,z_,"f").error("Failed to request preferred layers",{case:"requestVideoPreferredLayers",track:{id:this.mediaStreamTrack.id,kind:this.mediaStreamTrack.kind,label:this.mediaStreamTrack.label},consumerId:this.consumer.id,spatialLayers:this.consumer.spatialLayers,temporalLayers:this.consumer.temporalLayers,error:e}),new Error("Error request preferred layers")}}))}requestKeyFrame(){return a(this,void 0,void 0,(function*(){if(this.consumerId){c(this,z_,"f").debug("requestKeyFrame()",{track:this.logCtx});try{yield c(this,N_,"f").request(In,{consumerId:this.consumerId})}catch(e){throw c(this,z_,"f").error("requestKeyFrame()",{error:e,track:this.logCtx,consumerId:this.consumerId}),new Error("Failed to request key frame")}}}))}getVideoAvailableLayers(){if(this.consumer){if(!this.consumer.isAudio)return this.consumer.availableSpatialLayers;c(this,z_,"f").warn("Only video consumers support layers",{case:"getVideoAvailableLayers"})}}getInfo(){var e;return a(this,void 0,void 0,(function*(){const{width:t,height:r,frameRate:n,aspectRatio:i}=c(this,H_,"f").getSettings();return{trackId:c(this,H_,"f").id,readyState:c(this,H_,"f").readyState,isRemote:this.isRemote,kind:this.kind,label:this.label,width:t,height:r,frameRate:n,aspectRatio:i,paused:c(this,$_,"f"),trackInboundStats:yield null===(e=this.consumer)||void 0===e?void 0:e.getStats(),trackOutboundStats:yield this.getOutboundStats()}}))}getOutboundStats(){return a(this,void 0,void 0,(function*(){if(this.isRemote)return;const e=c(this,B_,"f").getAllTracks().find((e=>e.getLabel()===this.label));return e?e.getStats():void 0}))}requestMaxSpatialLayer(e,t){return a(this,void 0,void 0,(function*(){try{if(!this.consumer)return;if(this.consumer.isAudio||0===this.consumer.spatialLayers||this.consumer.currentMaxSpatialLayer===t||t<this.consumer.currentMaxSpatialLayer)return void c(this,z_,"f").warn("Can`t request this spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t});this.consumer.setRequestedSpatialLayer(t),yield c(this,N_,"f").request(kn,{producerId:this.consumer.producerId,spatialLayer:t}),c(this,z_,"f").debug("requestMaxSpatialLayer()",{consumerId:e,spatialLayer:t})}catch(r){c(this,z_,"f").warn("Failed to request max spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t,error:r})}}))}checkConsumerState(){return a(this,void 0,void 0,(function*(){try{if(c(this,Q_,"f")||"audio"===this.kind)return;c(this,z_,"f").debug("checkConsumerState()",{track:this.logCtx});if((yield this.isInboundRTPStreamActive())||c(this,Q_,"f"))return;yield this.requestKeyFrame();if((yield this.isInboundRTPStreamActive())||c(this,Q_,"f"))return;if(c(this,K_,"f"))return c(this,V_,"f").emit(ln,this),void c(this,z_,"f").debug("trackFail()",{track:this.logCtx});yield this.restartConsumer()}catch(e){c(this,z_,"f").warn("checkConsumerState()",{track:this,error:e})}}))}setVolume(e){c(this,Z_,"f")!==e&&(d(this,Z_,e,"f"),this.observer.safeEmit(en,{value:e}))}closeConsumer(){return a(this,void 0,void 0,(function*(){try{if(!this.consumer)return;this.consumer.close(),yield c(this,F_,"f").closeRemoteConsumer(this.consumer.id)}catch(e){c(this,z_,"f").debug("closeConsumer()",{track:this,error:e})}}))}restartConsumer(){return a(this,void 0,void 0,(function*(){try{if(!this.consumer||c(this,Q_,"f"))return;c(this,z_,"f").debug("restartConsumer()",{track:this.logCtx}),c(this,V_,"f").emit(cn,this),d(this,$_,!0,"f"),yield this.closeConsumer();const{consumer:e}=yield c(this,F_,"f").createConsumer({producerId:this.consumer.producerId,rtpCapabilities:c(this,B_,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.consumer.appData.producerData.peerId,appId:c(this,U_,"f").appId,channelId:c(this,U_,"f").channelId});d(this,K_,!0,"f"),this.consumer=c(this,q_,"f").call(this,{consumer:e}),d(this,H_,e.track,"f"),yield this.resume(),c(this,V_,"f").emit(an,this)}catch(e){d(this,K_,!0,"f"),c(this,z_,"f").warn("restartConsumer()",{track:this,error:e})}}))}isInboundRTPStreamActive(){return a(this,void 0,void 0,(function*(){if(!this.consumer||c(this,Q_,"f"))return!1;const{framesDecoded:e}=yield this.consumer.getInboundRTPStreamStats();return new Promise((t=>{d(this,G_,setTimeout((()=>a(this,void 0,void 0,(function*(){try{if(!this.consumer)return void t(!1);const{framesDecoded:r}=yield this.consumer.getInboundRTPStreamStats();if(e===r&&!this.isPaused)return void t(!1);t(!0)}catch(e){c(this,z_,"f").debug("isInboundRTPStreamActive()",{error:e,track:this.logCtx}),t(!1)}}))),4500),"f")}))}))}clearCheckStateTimeout(){c(this,G_,"f")||clearTimeout(c(this,G_,"f"))}}F_=new WeakMap,N_=new WeakMap,B_=new WeakMap,W_=new WeakMap,q_=new WeakMap,U_=new WeakMap,z_=new WeakMap,V_=new WeakMap,H_=new WeakMap,$_=new WeakMap,K_=new WeakMap,G_=new WeakMap,Q_=new WeakMap,J_=new WeakMap,Y_=new WeakMap,Z_=new WeakMap,X_=new WeakMap;class mS{constructor(e){this.score=10;const{id:t,kind:r,peerId:n,label:i,paused:s}=e;this.id=t,this.kind=r,this.peerId=n,this.label=i,this.paused=s,this.encodings=e.encodings,this.trackTransformParams=e.trackTransformParams,this.maxSpatialLayer=e.maxSpatialLayer}}class gS{constructor({id:e,channelIds:t,groups:r,producePermissions:n,appId:i,loginDate:s,producers:o=[],appData:a,uid:c,role:u,loggerFactory:l,myPeer:p,callState:h,peers:f,remotePeerTracks:m,media:g,network:v,socket:y,peerConsumerFactory:b}){this.producers=new Map,this.tracks=new Map,eS.set(this,void 0),tS.set(this,void 0),rS.set(this,void 0),nS.set(this,void 0),iS.set(this,void 0),sS.set(this,void 0),oS.set(this,void 0),aS.set(this,void 0),cS.set(this,void 0),this._observer=new Rt,this.id=e,this.channelIds=t,this.groups=r,this.producePermissions=n,this.appId=i,this.loginDate=s,this.applicationData=a||{},this.uid=c,this.role=u,d(this,sS,p,"f"),d(this,oS,h,"f"),d(this,eS,f,"f"),d(this,tS,m,"f"),d(this,nS,y,"f"),d(this,aS,b,"f"),d(this,rS,v,"f"),d(this,iS,g,"f"),d(this,cS,l("Peer"),"f"),o.forEach(this.handleNewProducer.bind(this)),this.handlePeerEvents()}get appData(){return this.applicationData}get observer(){return this._observer}get isMe(){return this.id===c(this,sS,"f").id}get isModerator(){return this.groups.includes("moderator")}get isUser(){return this.groups.includes("user")}get publishedMedia(){return Array.from(this.producers.values()).map((e=>({producerId:e.id,kind:e.kind,label:e.label,paused:e.paused})))}get shortData(){return{id:this.id,producers:Array.from(this.producers.values()).map((e=>({id:e.id,paused:e.paused}))),appData:this.appData}}hasPermission(e){return this.producePermissions.includes(e)}hasGroup(e){return this.groups.includes(e)}subscribe({producerId:e,muted:t=!1}){return a(this,void 0,void 0,(function*(){try{const r=this.producers.get(e);if(!r)return void c(this,cS,"f").warn("subscribe()",{message:"Peer does not have a producer",peer:cf(this),producerId:e});if(this.getAllConsumers().find((t=>t.producerId===e)))return void c(this,cS,"f").debug("subscribe()",{message:"Already subscribed to producer",peer:cf(this),producerId:e});const{consumer:n,isProducerPaused:i}=yield c(this,rS,"f").createConsumer({producerId:r.id,rtpCapabilities:c(this,iS,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.id,appId:c(this,oS,"f").appId,channelId:c(this,oS,"f").channelId});if(!this.producePermissions.includes(r.label)&&Object.values(Zn).includes(r.label))return void c(this,cS,"f").debug("subscribe()",{message:"Producer is not allowed anymore",peer:cf(this),producerId:e});const s=c(this,tS,"f").create({mediaStreamTrack:n.track,label:r.label,consumer:c(this,aS,"f").call(this,{consumer:n}),muted:t,paused:i,peerEventEmitter:this.observer});t||(yield s.unmute()),this.tracks.set(s.label,s),c(this,cS,"f").debug(`Subscribed for ${r.kind}`,{peer:cf(this)})}catch(t){throw c(this,cS,"f").error("subscribe()",{producerId:e,error:t,peer:cf(this)}),new Error("Error subscribe media")}}))}unsubscribe(e){return a(this,void 0,void 0,(function*(){try{const t=this.getConsumerByProducerId(e);if(!t)return;const r=this.getTrackByConsumerId(t.id);if(!r)return;yield r.close(),this.tracks.delete(r.label),c(this,cS,"f").debug(`Unsubscribed consumer ${t.kind}`,{peer:cf(this)})}catch(t){throw c(this,cS,"f").error("unsubscribe()",{producerId:e,error:t}),new Error("Error unsubscribe media")}}))}setProducePermissions(e){return a(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield c(this,nS,"f").request(Ir,{peerId:this.id,producePermissions:e}),c(this,cS,"f").debug("Produce permissions changed",{peerId:this.id,producePermissions:e})}))}addProducePermission(e){return a(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield c(this,nS,"f").request(xr,{peerId:this.id,label:e}),c(this,cS,"f").debug("Add produce permission requested",{peerId:this.id,label:e})}))}removeProducePermission(e){return a(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield c(this,nS,"f").request(Or,{peerId:this.id,label:e}),c(this,cS,"f").debug("Remove produce permission requested",{peerId:this.id,label:e})}))}getInfo(){return a(this,void 0,void 0,(function*(){try{return{id:this.id,appData:this.appData,role:this.role,channelIds:this.channelIds,appId:this.appId,uid:this.uid,loginDate:this.loginDate,tracks:yield Promise.all(Array.from(this.tracks.values()).map((e=>e.getInfo())))}}catch(e){throw c(this,cS,"f").error("getInfo()",{peer:cf(this),error:e}),new Error("Error get info")}}))}getProducers(){return Array.from(this.producers.values())}getConsumersState(){return this.getAllConsumers().map((e=>({id:e.id,paused:e.paused,producerId:e.producerId})))}handleNewProducer(e){if(this.producers.get(e.id))return;const t=new mS(e);this.producers.set(t.id,t),c(this,cS,"f").debug("Peer published media:",{peer:cf(this),producer:t}),this.observer.safeEmit(rn,{producerId:t.id,kind:t.kind,label:t.label,paused:t.paused})}handlePeerEvents(){this.observer.on(mn,this.handleNewProducer.bind(this)),this.observer.on(gn,(e=>a(this,void 0,void 0,(function*(){this.producers.delete(e.id),c(this,cS,"f").debug("Peer unpublished media:",{peer:cf(this),producer:e}),this.observer.safeEmit(nn,{producerId:e.id,kind:e.kind,label:e.label,paused:e.paused});const t=this.tracks.get(e.label);if(t)try{yield t.close()}catch(e){c(this,cS,"f").warn("Failed to close peer track due to producer closed",{label:t.label,peerId:this.id})}})))),this.observer.on(Pn,(e=>a(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.close(),this.tracks.delete(t.label),c(this,cS,"f").debug("Peer video track was ended:",{peer:cf(this),track:t.logCtx}))})))),this.observer.on(Tn,(e=>a(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.pause(!1))})))),this.observer.on(En,(e=>a(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.resume(!1))})))),this.observer.on(Mn,(e=>{const t=this.getConsumerById(e.consumerId);(null==t?void 0:t.isVideo)&&(t.setCurrentTemporalLayer(e.temporalLayer),t.setCurrentSpatialLayer(e.spatialLayer),e.spatialLayer===t.requestedSpatialLayer&&t.setRequestedSpatialLayer(void 0),c(this,cS,"f").debug("consumerChangePreferredLayers()",Object.assign({},e)))})),this.observer.on(Dn,(e=>{const t=this.getConsumerById(e.consumerId);t&&(t.score=e.score)})),this.observer.on(Sn,(e=>a(this,void 0,void 0,(function*(){const{producerId:t,spatialLayer:r}=e,n=this.getConsumerByProducerId(t);n?(n.setCurrentMaxSpatialLayer(r),c(this,cS,"f").debug("producerSetMaxSpatialLayer()",{producerId:t,consumerId:n.id,spatialLayer:r}),n.requestedSpatialLayer===r?(yield c(this,nS,"f").request(Mn,{consumerId:n.id,spatialLayer:r}),c(this,cS,"f").debug("requestVideoPreferredLayers()",{producerId:t,consumerId:n.id,spatialLayer:r})):c(this,cS,"f").debug("producerSetMaxSpatialLayer()",{message:"No need to request new preferred layer",currentMaxSpatialLayer:r,requestedMaxSpatialLayer:n.requestedSpatialLayer})):c(this,cS,"f").debug("producerSetMaxSpatialLayer()",{message:"Consumer for producer not created, ignore MaxSpatialLayer change"})})))),this.observer.on(_r,(e=>{try{zn(e),this.setAppData(e),this.observer.emit(pn,e),c(this,cS,"f").debug("updatePeerAppData",{peer:cf(this),appData:e})}catch(t){c(this,cS,"f").error("updatePeerAppData",{peer:cf(this),appData:e,error:t})}}))}reset(){return a(this,void 0,void 0,(function*(){this.producers.clear(),yield Promise.all(Array.from(this.tracks.values()).map((e=>e.close()))),this.tracks.clear();[mn,gn,Pn,Tn,En,Dn,Mn,Sn,_r].forEach((e=>this.observer.removeAllListeners(e)))}))}getActiveTracksCount(){return Array.from(this.tracks.values()).map((e=>e.consumer)).filter((e=>!(null==e?void 0:e.paused))).length}getActivePublishersCount(){return Array.from(this.producers.values()).filter((e=>!e.paused)).length}handleProducePermissionsChange(e){this.producePermissions=e,Object.values(Zn).filter((e=>!this.producePermissions.includes(e))).forEach((e=>{const t=this.tracks.get(e);t&&(this.tracks.delete(t.label),t.close())})),this.observer.safeEmit(hn,{labels:this.producePermissions})}handleGroupsChange(e){this.groups=e,this.observer.safeEmit(fn,{groups:e})}getAllConsumers(){return Array.from(this.tracks.values()).map((e=>e.consumer)).filter((e=>!!e))}getConsumerByProducerId(e){return this.getAllConsumers().find((t=>t.producerId===e))}getConsumerById(e){return this.getAllConsumers().find((t=>t.id===e))}getTrackByConsumerId(e){return Array.from(this.tracks.values()).find((t=>t.consumerId===e))}setAppData(e){this.applicationData=e}throwIfIamNotModerator(){if(!c(this,eS,"f").isModerator(c(this,sS,"f").id))throw new Error("Not enough access")}}eS=new WeakMap,tS=new WeakMap,rS=new WeakMap,nS=new WeakMap,iS=new WeakMap,sS=new WeakMap,oS=new WeakMap,aS=new WeakMap,cS=new WeakMap;class vS{constructor(e){this.score=10,this.spatialLayers=0,this.temporalLayers=0,this.currentSpatialLayer=0,this.currentTemporalLayer=0,this.availableSpatialLayers=[],dS.set(this,void 0);const{consumer:t,loggerFactory:r}=e;this.id=t.id,this.kind=t.kind,this.producerId=t.producerId,this.appData=t.appData,this.consumer=t,d(this,dS,r("PeerConsumer"),"f"),this.currentMaxSpatialLayer=this.appData.producerData.maxSpatialLayer,this.parseScalabilityMode(),this.initAvailableSpatialLayers(),this.setCurrentSpatialLayerParams()}get paused(){return this.consumer.paused}pause(){return this.consumer.pause()}resume(){return this.consumer.resume()}close(){return this.consumer.close()}get isVideo(){return"video"===this.kind}get isAudio(){return"audio"===this.kind}parseScalabilityMode(){if(this.consumer.rtpParameters.encodings){const{scalabilityMode:e}=this.consumer.rtpParameters.encodings[0],{spatialLayers:t,temporalLayers:r}=ri.parseScalabilityMode(e);this.spatialLayers=t,this.temporalLayers=r,c(this,dS,"f").debug("parseScalabilityMode()",{scalabilityMode:e,spatialLayers:t,temporalLayers:r})}}initAvailableSpatialLayers(){const{encodings:e,trackTransformParams:t}=this.appData.producerData;if(!e)return;if(this.availableSpatialLayers=e.map((e=>this.tryPrepareSpatialLayerParams(e))),!t||this.availableSpatialLayers.length>1||this.spatialLayers<2)return void c(this,dS,"f").debug("Using available spatial layers",{case:"initAvailableSpatialLayers"});c(this,dS,"f").debug("Pre-generating encodings with spatial layer params",{case:"initAvailableSpatialLayers"});const r=[],n=e[e.length-1];for(let e=this.spatialLayers-1;e>=0;e-=1)r.push(this.tryPrepareSpatialLayerParams(Object.assign(Object.assign({},n),{scaleResolutionDownBy:Math.pow(2,e)})));this.availableSpatialLayers=r}setCurrentSpatialLayerParams(){const{encodings:e}=this.appData.producerData;e&&e[this.currentSpatialLayer]&&(this.currentSpatialLayerParams=this.tryPrepareSpatialLayerParams(e[this.currentSpatialLayer]),c(this,dS,"f").debug("setCurrentSpatialLayerParams()",{currentSpatialLayerParams:this.currentSpatialLayerParams}))}tryPrepareSpatialLayerParams(e){const{trackTransformParams:t}=this.appData.producerData;if(!t)return e;const{width:r,height:n}=t,i=e.scaleResolutionDownBy||1;return r&&n?Object.assign({width:r/i,height:n/i},e):e}setCurrentSpatialLayer(e){if(!this.isVideo)throw new Error("setCurrentSpatialLayer applies to video consumers only");this.currentSpatialLayer=e,c(this,dS,"f").debug("setCurrentSpatialLayer()",{currentSpatialLayer:e}),this.setCurrentSpatialLayerParams()}setCurrentTemporalLayer(e){if(!this.isVideo)throw new Error("setCurrentTemporalLayer applies to video consumers only");this.currentTemporalLayer=e,c(this,dS,"f").debug("setCurrentTemporalLayer()",{currentTemporalLayer:e})}setRequestedSpatialLayer(e){this.requestedSpatialLayer=e}setCurrentMaxSpatialLayer(e){this.currentMaxSpatialLayer=e}getStats(){var e,t;return a(this,void 0,void 0,(function*(){try{return{consumerId:this.consumer.id,codec:this.consumer.rtpParameters.codecs.find((e=>bf(e))),score:this.score,dtlsState:null===(t=null===(e=this.consumer.rtpReceiver)||void 0===e?void 0:e.transport)||void 0===t?void 0:t.state,availableSpatialLayers:this.availableSpatialLayers,currentSpatialLayerParams:this.currentSpatialLayerParams,requestedSpatialLayer:this.requestedSpatialLayer,rtcStats:yield this.getInboundRTPStreamStats()}}catch(e){return void c(this,dS,"f").debug("getStats()",{error:e})}}))}getInboundRTPStreamStats(){return a(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const r=(n=0)=>a(this,void 0,void 0,(function*(){try{const i=yield this.consumer.getStats(),s=Array.from(i.values()).find((e=>"inbound-rtp"===e.type));if(!s&&n<5)return void setTimeout((()=>r(n+1)),150);n>=5&&!s&&t(new Error("InboundRTPStreamStat not exist")),e(s)}catch(e){t(new Error("Can not get RTCStatsReport")),c(this,dS,"f").debug("getInboundRTPStreamStats()",{error:e})}}));r()}))}))}}dS=new WeakMap;const yS=new rt({autoBindInjectable:!0});var bS;yS.bind(Yn.CallState).to(ti).inSingletonScope(),yS.bind(Yn.MyPeer).to(mp).inSingletonScope(),yS.bind(Yn.LoggerFactory).toFactory((e=>{const t=e.container.get(Yn.Config),r=t.get("logLevel"),n=t.get("sendAnalytics"),i=t.get("onLogMessage");return e=>new o_({logLevel:r,namespace:e,onLogMessage:i,sendAnalytics:n})})),yS.bind(Yn.System).to(eb).inSingletonScope(),yS.bind(Yn.ProcessorsCache).to(Vl).inSingletonScope(),yS.bind(Yn.IntegrationsService).to(Kl).inSingletonScope(),yS.bind(Yn.MediaStreamTrackManager).to(pp).inSingletonScope(),yS.bind(Yn.Media).to(fp).inSingletonScope(),yS.bind(Yn.SocketIO).to(Hh).inSingletonScope(),yS.bind(Yn.LoadBalancerApiClient).to(Uy).inSingletonScope(),yS.bind(Yn.Network).to(Kh).inSingletonScope(),yS.bind(Yn.RemotePeerTracks).to(a_).inSingletonScope(),yS.bind(Yn.Peers).to(Gh).inSingletonScope(),yS.bind(Yn.MediaSoupEventHandler).to(Kf).inSingletonScope(),yS.bind(Yn.ChannelEventHandler).to(uf).inSingletonScope(),yS.bind(Yn.ChannelAudioObserverEventHandler).to(pb).inSingletonScope(),yS.bind(Yn.EventsQueue).to(nf).inSingletonScope(),yS.bind(Yn.ChannelStateSynchronizer).to(af).inSingletonScope(),yS.bind(Yn.ChannelStateSyncEventHandler).to(fw).inSingletonScope(),yS.bind(Yn.StatsHandler).to(db).inSingletonScope(),yS.bind(Yn.WebRTCIssueDetector).toDynamicValue((e=>{const t=e.container.get(Yn.Config);if(t.get("disableWid"))return;const r=e.container.get(Yn.StatsHandler),n=t.get("onIssues"),i=t.get("onNetworkScoresUpdated"),s=[1234],o=e.container.get(Yn.LoggerFactory)("WID"),a=new rr({statsParser:new nr({ignoreSSRCList:s,logger:o})});return new sr({onIssues:n,issueEmitter:new Nt,networkScoresCalculator:new qt,detectors:[new Kt,new Vt,new $t,new Ht,new zt,new Gt,new Zt,new Xt],statsReporter:new Bt({compositeStatsParser:a,getStatsInterval:5e3}),onNetworkScoresUpdated:i,onStats:r.handle.bind(r),ignoreSSRCList:s,compositeStatsParser:a,logger:o,autoAddPeerConnections:!1})})).inSingletonScope(),yS.bind(Yn.Engine).to(kw).inSingletonScope(),yS.bind(Yn.PeerTrackFactory).toFactory((function(e){const t=e.container.get(Yn.LoggerFactory),r=e.container.get(Yn.CallState),n=e.container.get(Yn.StatsHandler);return i=>{const s={callState:r,loggerFactory:t,media:e.container.get(Yn.Media),network:e.container.get(Yn.Network),peerConsumerFactory:e.container.get(Yn.PeerConsumerFactory),socket:e.container.get(Yn.SocketIO)},{peerEventEmitter:o}=i,a=new fS(Object.assign(Object.assign(Object.assign({},i),s),{statsHandler:n}));return o.safeEmit(an,a),a}})),yS.bind(Yn.PeerFactory).toFactory((function(e){const t=e.container.get(Yn.LoggerFactory),r=e.container.get(Yn.CallState);return n=>{const i={callState:r,loggerFactory:t,media:e.container.get(Yn.Media),myPeer:e.container.get(Yn.MyPeer),network:e.container.get(Yn.Network),peers:e.container.get(Yn.Peers),remotePeerTracks:e.container.get(Yn.RemotePeerTracks),socket:e.container.get(Yn.SocketIO),peerConsumerFactory:e.container.get(Yn.PeerConsumerFactory)};return new gS(Object.assign(Object.assign({},i),n))}})),yS.bind(Yn.PeerConsumerFactory).toFactory((function(e){const t=e.container.get(Yn.LoggerFactory);return e=>{const r={loggerFactory:t};return new vS(Object.assign(Object.assign({},r),e))}})),yS.bind(Yn.AudioTrackFactory).toFactory((function(e){const t=e.container.get(Yn.LoggerFactory),r=e.container.get(Yn.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(Yn.InternalEventEmitter),loggerFactory:t,media:e.container.get(Yn.Media),mediaStreamTrackManager:e.container.get(Yn.MediaStreamTrackManager),myPeer:e.container.get(Yn.MyPeer),network:e.container.get(Yn.Network),socket:e.container.get(Yn.SocketIO),processorFactory:e.container.get(Yn.AudioTrackProcessorFactory),clientEventEmitter:e.container.get(Yn.ClientEventEmitter),statsHandler:r};return new pS(Object.assign(Object.assign({},i),n))}})),yS.bind(Yn.VideoTrackFactory).toFactory((function(e){const t=e.container.get(Yn.LoggerFactory),r=e.container.get(Yn.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(Yn.InternalEventEmitter),loggerFactory:t,media:e.container.get(Yn.Media),mediaStreamTrackManager:e.container.get(Yn.MediaStreamTrackManager),myPeer:e.container.get(Yn.MyPeer),network:e.container.get(Yn.Network),socket:e.container.get(Yn.SocketIO),statsHandler:r};return new Hf(Object.assign(Object.assign({},i),n))}})),yS.bind(Yn.AudioTrackProcessorFactory).toFactory((function(e){const t=e.container.get(Yn.LoggerFactory),r=e.container.get(Yn.Config),n=e.container.get(Yn.ProcessorsCache),i=r.get("asdk");return e=>{const s=r.get("denoiser");if(n.has(s,e.trackLabel))throw new Error(`Track processor for type:${s}, label:${e.trackLabel} already created`);let o;if("rnnoise"===s&&e.noiseSuppressor&&(o=new lS({noiseSuppressor:e.noiseSuppressor,loggerFactory:t})),"asdk"===s&&(null==i?void 0:i.customerId)&&(o=new g_({asdkCustomerId:i.customerId,loggerFactory:t})),!o)throw new TypeError("Incorrect parameters passed to AudioTrackProcessorFactory");return o}})),yS.bind(Yn.DataChannelsManager).to(_w).inSingletonScope();class wS{constructor(e){bS.set(this,void 0);const{clientEventEmitter:t,internalEventEmitter:r}=e;yS.bind(Yn.Config).toDynamicValue((()=>new Ct(e))).inSingletonScope(),yS.bind(Yn.InternalEventEmitter).toDynamicValue((()=>null!=r?r:new Rt)).inSingletonScope(),yS.bind(Yn.ClientEventEmitter).toDynamicValue((()=>null!=t?t:new Rt)).inSingletonScope(),yS.get(Yn.IntegrationsService),this.clientEventEmitter=yS.get(Yn.ClientEventEmitter),d(this,bS,yS.get(Yn.Engine),"f")}get observer(){return this.clientEventEmitter}get id(){return c(this,bS,"f").myPeerId}get peers(){return c(this,bS,"f").getPeers()}get availableVideoDevices(){return c(this,bS,"f").system.availableVideoDevices}get availableAudioDevices(){return c(this,bS,"f").system.availableAudioDevices}get canUseNoiseSuppression(){return!0}get effectsSDKInitialized(){return c(this,bS,"f").media.effectsSDKInitialized}detectDevices(e){return a(this,void 0,void 0,(function*(){return yield c(this,bS,"f").system.detectDevices(e),{video:c(this,bS,"f").system.availableVideoDevices,audio:c(this,bS,"f").system.availableAudioDevices}}))}initEffectsSDK(){return c(this,bS,"f").media.initEffectsSDK()}join(e){return c(this,bS,"f").join(e)}leave(e){return c(this,bS,"f").release(e)}confirmActivity(){return c(this,bS,"f").confirmActivity()}createCameraVideoTrack(e){return c(this,bS,"f").createCameraVideoTrack(e)}createMicrophoneAudioTrack(e){return c(this,bS,"f").createMicrophoneAudioTrack(e)}createScreenMediaTracks(e){return c(this,bS,"f").createScreenMediaTracks(e)}deleteTrack(e){return c(this,bS,"f").deleteTrack(e)}loadPeers(e){return c(this,bS,"f").loadPeers(e)}updateAppData(e){return c(this,bS,"f").updateAppData(e)}getTransportsInfo(){return a(this,void 0,void 0,(function*(){return c(this,bS,"f").network.getTransportsStateInfo()}))}getNodeActiveStreamsStat(){return c(this,bS,"f").getNodeActiveStreamsStat()}setPreferRelay(e){c(this,bS,"f").network.setPreferRelay(e)}getPreferRelay(){return c(this,bS,"f").network.getPreferRelay()}transportsStats(){return c(this,bS,"f").transportsStats()}getAvgTracksScore(e){return c(this,bS,"f").getAvgTracksScore(e)}}bS=new WeakMap;export{wS as default};
|