@livedigital/client 3.28.0 → 3.28.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/constants/events.d.ts +0 -1
- package/dist/constants/events.ts +0 -1
- package/dist/engine/media/tracks/PeerTrack.d.ts +0 -2
- package/dist/index.es.js +3 -3
- package/dist/index.js +4 -4
- package/dist/types/common.d.ts +0 -4
- package/package.json +1 -1
- package/src/constants/events.ts +0 -1
- package/src/engine/media/tracks/PeerTrack.ts +0 -19
- package/src/types/common.ts +0 -5
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 u?u:"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)&&!J(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 J(e){switch(j(e)){case 3:case 4:return!0;default:return!1}}function Q(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--,Q(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(!Q(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(Q(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)}()}(d||(d={}));var h=["inject","multi_inject","name","unmanaged","named","optional"],f="Request",m="Singleton",g="Transient",v="ConstantValue",y="Constructor",b="DynamicValue",w="Factory",_="Function",S="Instance",k="Invalid",C="Provider",R="ClassProperty",P="ConstructorArgument",T="Variable",E=0;function D(){return E++}var I=function(){function e(e,t){this.id=D(),this.activated=!1,this.serviceIdentifier=e,this.scope=t,this.type=k,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===m&&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}(),M="No matching bindings found for serviceIdentifier:",x="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.",O=function(e,t){return"onDeactivation() error in class "+e+": "+t},L=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}(),A=0,j=1;function F(e){return e instanceof RangeError||"Maximum call stack size exceeded"===e.message}function N(e){return"function"==typeof e?e.name:"symbol"==typeof e?e.toString():e}function B(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=U(e.implementationType)),n=n+"\n "+t,e.constraint.metaData&&(n=n+" - "+e.constraint.metaData)}))),n}function W(e,t){return null!==e.parentRequest&&(e.parentRequest.serviceIdentifier===t||W(e.parentRequest,t))}function q(e){e.childRequests.forEach((function(e){if(W(e,e.serviceIdentifier)){var t=function(e){return function e(t,r){void 0===r&&(r=[]);var n=N(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)}q(e)}))}function U(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 z=function(){function e(e){this.id=D(),this.container=e}return e.prototype.addPlan=function(e){this.plan=e},e.prototype.setCurrentRequest=function(e){this.currentRequest=e},e}(),V=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}(),H=function(e,t){this.parentContext=e,this.rootRequest=t},$=function(){function e(e){this._cb=e}return e.prototype.unwrap=function(){return this._cb()},e}(),K=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}(),G=function(){function e(e,t,r,n){this.id=D(),this.type=e,this.serviceIdentifier=r;var i="symbol"==typeof t?t.toString().slice(7,-1):t;this.name=new K(i||""),this.identifier=t,this.metadata=new Array;var s=null;"string"==typeof n?s=new V("named",n):n instanceof V&&(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 h.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 h.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 Q(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=Y(o,e,t,r,n);null!==a&&s.push(a)}return s}(n,t,s,o,c||d?a.length:r.length),l=X(e,r,t);return J(J([],u,!0),l,!0)}function Y(e,t,r,n,i){var s=i[e.toString()]||[],o=te(s),a=!0!==o.unmanaged,c=n[e],d=o.inject||o.multiInject;if((c=d||c)instanceof $&&(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 G(P,o.targetName,c);return u.metadata=s,u}return null}function Z(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 X(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=te(d),l=u.targetName||c,p=Z(u.inject,u.multiInject,c,r),h=new G(R,l,p);h.metadata=d,i.push(h)}var f=Object.getPrototypeOf(t.prototype).constructor;if(f!==Object){var m=X(e,f,r);i=J(J([],i,!0),m,!0)}return i}function ee(e,t){var r=Object.getPrototypeOf(t.prototype).constructor;if(r!==Object){var n=Q(e,U(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:ee(e,r)}return 0}function te(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 re=function(){function e(e,t,r,n,i){this.id=D(),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 ne(e){return e._bindingDictionary}function ie(e,t,r,n,i){var s=oe(r.container,i.serviceIdentifier),o=[];return s.length===A&&r.container.options.autoBindInjectable&&"function"==typeof i.serviceIdentifier&&e.getConstructorMetadata(i.serviceIdentifier).compilerGeneratedMetadata&&(r.container.bind(i.serviceIdentifier).toSelf(),s=oe(r.container,i.serviceIdentifier)),o=t?s:s.filter((function(e){var t=new re(e.serviceIdentifier,r,n,e,i);return e.constraint(t)})),function(e,t,r,n){switch(t.length){case A:if(r.isOptional())return t;var i=N(e),s=M;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+=B(n,i,oe),new Error(s);case j:return t;default:if(r.isArray())return t;s="Ambiguous match found for serviceIdentifier: "+(i=N(e));throw s+=B(n,i,oe),new Error(s)}}(i.serviceIdentifier,o,i,r.container),o}function se(e,t,r,n,i,s){var o,a;if(null===i){o=ie(e,t,n,null,s),a=new re(r,n,null,o,s);var c=new H(n,a);n.addPlan(c)}else o=ie(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===S&&null!==t.implementationType){var i=function(e,t){return Q(e,U(t),t,!1)}(e,t.implementationType);if(!n.container.options.skipBaseClassChecks){var o=ee(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."}(U(t.implementationType));throw new Error(c)}}i.forEach((function(t){se(e,!1,t.serviceIdentifier,n,r,t)}))}}))}function oe(e,t){var r=[],n=ne(e);return n.hasKey(t)?r=n.get(t):null!==e.parent&&(r=oe(e.parent,t)),r}function ae(e,t,r,n,i,s,o,a){void 0===a&&(a=!1);var c=new z(t),d=function(e,t,r,n,i,s){var o=new V(e?"multi_inject":"inject",r),a=new G(t,n,r,o);if(void 0!==i){var c=new V(i,s);a.metadata.push(c)}return a}(r,n,i,"",s,o);try{return se(e,a,i,c,null,d),c}catch(e){throw F(e)&&q(c.plan.rootRequest),e}}function ce(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then}function de(e){return!!ce(e)||Array.isArray(e)&&e.some(ce)}var ue,le=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())}))},pe=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])}}},he=function(e,t,r){e.has(t.id)||e.set(t.id,r)},fe=function(e,t){e.cache=t,e.activated=!0,ce(t)&&me(e,t)},me=function(e,t){return le(void 0,void 0,void 0,(function(){var r,n;return pe(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"}(ue||(ue={}));var ge=function(){return ge=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},ge.apply(this,arguments)},ve=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())}))},ye=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])}}},be=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 we(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===P?e.constructorInjections.push(n):(e.propertyRequests.push(r),e.propertyInjections.push(n)),e.isAsync||(e.isAsync=de(n)),e}),{constructorInjections:[],propertyInjections:[],propertyRequests:[],isAsync:!1})}(t,r),s=ge(ge({},i),{constr:e});n=i.isAsync?function(e){return ve(this,void 0,void 0,(function(){var t,r;return ye(this,(function(n){switch(n.label){case 0:return[4,Se(e.constructorInjections)];case 1:return t=n.sent(),[4,Se(e.propertyInjections)];case 2:return r=n.sent(),[2,_e(ge(ge({},e),{constructorInjections:t,propertyInjections:r}))]}}))}))}(s):_e(s)}else n=new e;return n}function _e(e){var t,r=new((t=e.constr).bind.apply(t,be([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 Se(e){return ve(this,void 0,void 0,(function(){var t,r,n,i;return ye(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 ke(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 ce(r)?r.then((function(){return t})):t}function Ce(e,t){e.scope!==m&&function(e,t){var r="Class cannot be instantiated in "+(e.scope===f?"request":"transient")+" scope.";if("function"==typeof e.onDeactivation)throw new Error(O(t.name,r));if(Reflect.hasMetadata("pre_destroy",t))throw new Error("@preDestroy error in class "+t.name+": "+r)}(e,t)}var Re=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())}))},Pe=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])}}},Te=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 Te(e)(t)}));if(!t.target.isOptional()||0!==r.length){var o=r[0];return Me(e,t,o)}}},Ee=function(e,t){var r=function(e){switch(e.type){case w:return{factory:e.factory,factoryType:ue.Factory};case C:return{factory:e.provider,factoryType:ue.Provider};case b:return{factory:e.dynamicValue,factoryType:ue.DynamicValue};default:throw new Error("Unexpected factory type "+e.type)}}(e);return function(e,t){try{return e()}catch(e){throw F(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}))},De=function(e,t,r){var n,i=t.childRequests;switch(function(e){var t=null;switch(e.type){case v:case _:t=e.cache;break;case y:case S:t=e.implementationType;break;case b:t=e.dynamicValue;break;case C:t=e.provider;break;case w:t=e.factory}if(null===t){var r=N(e.serviceIdentifier);throw new Error("Invalid binding type: "+r)}}(r),r.type){case v:case _:n=r.cache;break;case y:n=r.implementationType;break;case S:n=function(e,t,r,n){Ce(e,t);var i=we(t,r,n);return ce(i)?i.then((function(e){return ke(t,e)})):ke(t,i)}(r,r.implementationType,i,Te(e));break;default:n=Ee(r,t.parentContext)}return n},Ie=function(e,t,r){var n=function(e,t){return t.scope===m&&t.activated?t.cache:t.scope===f&&e.has(t.id)?e.get(t.id):null}(e,t);return null!==n||function(e,t,r){t.scope===m&&fe(t,r),t.scope===f&&he(e,t,r)}(e,t,n=r()),n},Me=function(e,t,r){return Ie(e,r,(function(){var n=De(e,t,r);return n=ce(n)?n.then((function(e){return xe(t,r,e)})):xe(t,r,n)}))};function xe(e,t,r){var n,i=Oe(e.parentContext,t,r),s=Fe(e.parentContext.container),o=s.next();do{n=o.value;var a=e.parentContext,c=e.serviceIdentifier,d=je(n,c);i=ce(i)?Ae(d,a,i):Le(d,a,i),o=s.next()}while(!0!==o.done&&!ne(n).hasKey(e.serviceIdentifier));return i}var Oe=function(e,t,r){return"function"==typeof t.onActivation?t.onActivation(e,r):r},Le=function(e,t,r){for(var n=e.next();!n.done;){if(ce(r=n.value(t,r)))return Ae(e,t,r);n=e.next()}return r},Ae=function(e,t,r){return Re(void 0,void 0,void 0,(function(){var n,i;return Pe(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]}}))}))},je=function(e,t){var r=e._activations;return r.hasKey(t)?r.get(t).values():[].values()},Fe=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 Ne=function(e,t){var r=e.parentRequest;return null!==r&&(!!t(r)||Ne(r,t))},Be=function(e){return function(t){var r=function(r){return null!==r&&null!==r.target&&r.target.matchesTag(e)(t)};return r.metaData=new V(e,t),r}},We=Be("named"),qe=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}},Ue=function(){function e(e){this._binding=e}return e.prototype.when=function(e){return this._binding.constraint=e,new ze(this._binding)},e.prototype.whenTargetNamed=function(e){return this._binding.constraint=We(e),new ze(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 ze(this._binding)},e.prototype.whenTargetTagged=function(e,t){return this._binding.constraint=Be(e)(t),new ze(this._binding)},e.prototype.whenInjectedInto=function(e){return this._binding.constraint=function(t){return null!==t&&qe(e)(t.parentRequest)},new ze(this._binding)},e.prototype.whenParentNamed=function(e){return this._binding.constraint=function(t){return null!==t&&We(e)(t.parentRequest)},new ze(this._binding)},e.prototype.whenParentTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&Be(e)(t)(r.parentRequest)},new ze(this._binding)},e.prototype.whenAnyAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&Ne(t,qe(e))},new ze(this._binding)},e.prototype.whenNoAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&!Ne(t,qe(e))},new ze(this._binding)},e.prototype.whenAnyAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&Ne(t,We(e))},new ze(this._binding)},e.prototype.whenNoAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&!Ne(t,We(e))},new ze(this._binding)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&Ne(r,Be(e)(t))},new ze(this._binding)},e.prototype.whenNoAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&!Ne(r,Be(e)(t))},new ze(this._binding)},e.prototype.whenAnyAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&Ne(t,e)},new ze(this._binding)},e.prototype.whenNoAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&!Ne(t,e)},new ze(this._binding)},e}(),ze=function(){function e(e){this._binding=e}return e.prototype.onActivation=function(e){return this._binding.onActivation=e,new Ue(this._binding)},e.prototype.onDeactivation=function(e){return this._binding.onDeactivation=e,new Ue(this._binding)},e}(),Ve=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new Ue(this._binding),this._bindingOnSyntax=new ze(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}(),He=function(){function e(e){this._binding=e}return e.prototype.inRequestScope=function(){return this._binding.scope=f,new Ve(this._binding)},e.prototype.inSingletonScope=function(){return this._binding.scope=m,new Ve(this._binding)},e.prototype.inTransientScope=function(){return this._binding.scope=g,new Ve(this._binding)},e}(),$e=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new Ue(this._binding),this._bindingOnSyntax=new ze(this._binding),this._bindingInSyntax=new He(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}(),Ke=function(){function e(e){this._binding=e}return e.prototype.to=function(e){return this._binding.type=S,this._binding.implementationType=e,new $e(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=v,this._binding.cache=e,this._binding.dynamicValue=null,this._binding.implementationType=null,this._binding.scope=m,new Ve(this._binding)},e.prototype.toDynamicValue=function(e){return this._binding.type=b,this._binding.cache=null,this._binding.dynamicValue=e,this._binding.implementationType=null,new $e(this._binding)},e.prototype.toConstructor=function(e){return this._binding.type=y,this._binding.implementationType=e,this._binding.scope=m,new Ve(this._binding)},e.prototype.toFactory=function(e){return this._binding.type=w,this._binding.factory=e,this._binding.scope=m,new Ve(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=_,this._binding.scope=m,t},e.prototype.toAutoFactory=function(e){return this._binding.type=w,this._binding.factory=function(t){return function(){return t.container.get(e)}},this._binding.scope=m,new Ve(this._binding)},e.prototype.toAutoNamedFactory=function(e){return this._binding.type=w,this._binding.factory=function(t){return function(r){return t.container.getNamed(e,r)}},new Ve(this._binding)},e.prototype.toProvider=function(e){return this._binding.type=C,this._binding.provider=e,this._binding.scope=m,new Ve(this._binding)},e.prototype.toService=function(e){this.toDynamicValue((function(t){return t.container.get(e)}))},e}(),Ge=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}(),Qe=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}(),Ye=function(){return Ye=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},Ye.apply(this,arguments)},Ze=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())}))},Xe=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])}}},et=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))},tt=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=g;else if(t.defaultScope!==m&&t.defaultScope!==g&&t.defaultScope!==f)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=D(),this._bindingDictionary=new Je,this._snapshots=[],this._middleware=null,this._activations=new Je,this._deactivations=new Je,this.parent=null,this._metadataReader=new L,this._moduleActivationStore=new Qe}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=et([t,r],n,!0).map((function(e){return ne(e)})),a=ne(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 Ze(this,void 0,void 0,(function(){var t,r,n,i,s;return Xe(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 Ze(this,void 0,void 0,(function(){var t,r,n,i;return Xe(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||g,r=new I(e,t);return this._bindingDictionary.add(e,r),new Ke(r)},e.prototype.rebind=function(e){return this.unbind(e),this.bind(e)},e.prototype.rebindAsync=function(e){return Ze(this,void 0,void 0,(function(){return Xe(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 Ze(this,void 0,void 0,(function(){var t;return Xe(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 Ze(this,void 0,void 0,(function(){var e,t=this;return Xe(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 G(T,"",t,new V(r,n)),s=new z(e);return new re(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(Ge.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 Ze(this,void 0,void 0,(function(){var t;return Xe(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 Ze(this,void 0,void 0,(function(){var n;return Xe(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(ce(i))return this._handleDeactivationError(i.then((function(){return r._propagateContainerDeactivationThenBindingAndPreDestroyAsync(e,t,n)})),n)}var s=this._propagateContainerDeactivationThenBindingAndPreDestroy(e,t,n);if(ce(s))return this._handleDeactivationError(s,n)}catch(e){if(e instanceof Error)throw new Error(O(n.name,e.message))}},e.prototype._handleDeactivationError=function(e,t){return Ze(this,void 0,void 0,(function(){var r;return Xe(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(O(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(ce(i))return i.then((function(){return r._deactivateContainerAsync(e,t)}));n=t.next()}},e.prototype._deactivateContainerAsync=function(e,t){return Ze(this,void 0,void 0,(function(){var r;return Xe(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=Ye(Ye({},e),{contextInterceptor:function(e){return e},targetType:T});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(de(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=ae(e._metadataReader,e,t.isMultiInject,t.targetType,t.serviceIdentifier,t.key,t.value,t.avoidConstraints);return function(e){return Te(e.plan.rootRequest.requestScope)(e.plan.rootRequest)}(r=t.contextInterceptor(r))}},e.prototype._deactivateIfSingleton=function(e){var t=this;if(e.activated)return ce(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(ce(this._deactivateIfSingleton(n)))throw new Error("Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)")}},e.prototype._deactivateSingletonsAsync=function(e){return Ze(this,void 0,void 0,(function(){var t=this;return Xe(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 Ze(this,void 0,void 0,(function(){return Xe(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: "+N(e))}},e.prototype._bindingDeactivationAndPreDestroy=function(e,t,r){var n=this;if("function"==typeof e.onDeactivation){var i=e.onDeactivation(t);if(ce(i))return i.then((function(){return n._preDestroy(r,t)}))}return this._preDestroy(r,t)},e.prototype._bindingDeactivationAndPreDestroyAsync=function(e,t,r){return Ze(this,void 0,void 0,(function(){return Xe(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 rt(e,t,r,n){!function(e){if(void 0!==e)throw new Error(x)}(t),it("inversify:tagged",e,r.toString(),n)}function nt(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 it(e,t,r,n){var i=nt(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 st(e){return function(t,r,n){"number"==typeof n?rt(t,r,n,e):function(e,t,r){if(void 0!==e.prototype)throw new Error(x);it("inversify:tagged_props",e.constructor,t,r)}(t,r,e)}}function ot(){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 at,ct=(at="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 st(new V(at,e))(t,r,n)}});const dt=3,ut=4,lt=6,pt=7;var ht;const ft={baseURL:"https://lb.livedigital.space/v1",timeout:5e3},mt=()=>{};let gt=class{constructor(e){var t,r,n,i,s;ht.set(this,void 0),c(this,ht,{loadbalancer:Object.assign(ft,(null===(t=e.network)||void 0===t?void 0:t.loadbalancer)||{}),logLevel:null!==(r=e.logLevel)&&void 0!==r?r:dt,sendAnalytics:null!==(n=e.sendAnalytics)&&void 0!==n&&n,onLogMessage:e.onLogMessage||mt,onIssues:e.onIssues||mt,disableWid:null!==(i=e.disableWid)&&void 0!==i&&i,effectsSDKParams:e.effectsSDKParams,onNetworkScoresUpdated:e.onNetworkScoresUpdated||mt,staticFilesPath:null!==(s=e.staticFilesPath)&&void 0!==s?s:window.location.origin},"f")}get(e){return a(this,ht,"f")[e]}};ht=new WeakMap,gt=n([ot(),s("design:paramtypes",[Object])],gt);var vt,yt,bt,wt=gt;class _t 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 St(){}function kt(){kt.init.call(this)}function Ct(e){return void 0===e._maxListeners?kt.defaultMaxListeners:e._maxListeners}function Rt(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Ot(e,n),s=0;s<n;++s)i[s].call(r)}function Pt(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,s=Ot(e,i),o=0;o<i;++o)s[o].call(r,n)}function Tt(e,t,r,n,i){if(t)e.call(r,n,i);else for(var s=e.length,o=Ot(e,s),a=0;a<s;++a)o[a].call(r,n,i)}function Et(e,t,r,n,i,s){if(t)e.call(r,n,i,s);else for(var o=e.length,a=Ot(e,o),c=0;c<o;++c)a[c].call(r,n,i,s)}function Dt(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,s=Ot(e,i),o=0;o<i;++o)s[o].apply(r,n)}function It(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 St,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=Ct(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 Mt(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 xt(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 Ot(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}St.prototype=Object.create(null),kt.EventEmitter=kt,kt.usingDomains=!1,kt.prototype.domain=void 0,kt.prototype._events=void 0,kt.prototype._maxListeners=void 0,kt.defaultMaxListeners=10,kt.init=function(){this.domain=null,kt.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new St,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},kt.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},kt.prototype.getMaxListeners=function(){return Ct(this)},kt.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:Rt(r,u,this);break;case 2:Pt(r,u,this,arguments[1]);break;case 3:Tt(r,u,this,arguments[1],arguments[2]);break;case 4:Et(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];Dt(r,u,this,i)}return!0},kt.prototype.addListener=function(e,t){return It(this,e,t,!1)},kt.prototype.on=kt.prototype.addListener,kt.prototype.prependListener=function(e,t){return It(this,e,t,!0)},kt.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Mt(this,e,t)),this},kt.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Mt(this,e,t)),this},kt.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 St:(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 St,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},kt.prototype.off=function(e,t){return this.removeListener(e,t)},kt.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new St,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new St: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 St,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},kt.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):[]},kt.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):xt.call(e,t)},kt.prototype.listenerCount=xt,kt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};class Lt extends kt{}!function(e){e.Issue="issue",e.NetworkScoresUpdated="network-scores-updated",e.StatsParsingFinished="stats-parsing-finished"}(vt||(vt={})),function(e){e.Network="network",e.CPU="cpu",e.Server="server",e.Stream="stream"}(yt||(yt={})),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"}(bt||(bt={}));class At extends kt{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(At.STATS_REPORTS_PARSED,{timeTaken:r,reportItems:t}),t.forEach((e=>{this.emit(At.STATS_REPORT_READY_EVENT,e)}))}}const jt=(()=>{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 Ft{#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,jt({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 Nt{#e;#t;constructor(e={}){this.#e=new Map,this.#t=e.statsCleanupTtlMs??35e3}detect(e){const t=this.performDetection(e);return this.performPrevStatsCleanup({connectionId:e.connection.id}),t}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;this.#e.has(t)&&jt({taskId:t,delayMs:this.#t,callback:()=>{this.deleteLastProcessedStats(t),"function"==typeof r&&r()}})}setLastProcessedStats(e,t){this.#e.set(e,t)}getLastProcessedStats(e){return this.#e.get(e)}deleteLastProcessedStats(e){this.#e.delete(e)}}class Bt extends Nt{#r;constructor(e={}){super(e),this.#r=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.#r?(t.push({statsSample:s,type:yt.Network,reason:bt.OutboundNetworkThroughput}),t):t}}class Wt extends Nt{#n;constructor(e={}){super(e),this.#n=e.framesDroppedThreshold??.5}performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}processData(e){const t=e.video.inbound.filter((e=>e.framesDropped>0)),r=[],n=this.getLastProcessedStats(e.connection.id)?.video.inbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;if(e.framesDropped===t.framesDropped)return;const i=e.framesReceived-t.framesReceived,s=e.framesDecoded-t.framesDecoded,o=e.framesDropped-t.framesDropped,a=o/i;if(0===i||0===s)return;const c={deltaFramesDropped:o,deltaFramesReceived:i,deltaFramesDecoded:s,framesDroppedPct:Math.round(100*a)};a>=this.#n&&r.push({statsSample:c,type:yt.CPU,reason:bt.DecoderCPUThrottling,ssrc:e.ssrc})})),r):r}}class qt extends Nt{#i;constructor(e={}){super(e),this.#i=e.missedFramesThreshold??.15}performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}processData(e){const t=e.video.outbound.filter((e=>e.framesEncoded>0)),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;if(e.framesEncoded===t.framesEncoded)return;const i=e.framesEncoded-t.framesEncoded,s=e.framesSent-t.framesSent,o=1-s/i;if(0===i)return;if(i===s)return;const a={deltaFramesSent:s,deltaFramesEncoded:i,missedFramesPct:Math.round(100*o)};o>=this.#i&&r.push({statsSample:a,type:yt.Network,reason:bt.OutboundNetworkThroughput,ssrc:e.ssrc})})),r):r}}class Ut extends Nt{#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){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}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:yt.Network,reason:bt.InboundNetworkQuality,iceCandidate:e.connection.local.id}),w&&t.push({statsSample:k,type:yt.Server,reason:bt.ServerIssue,iceCandidate:e.connection.remote.id}),_&&t.push({statsSample:k,type:yt.Network,reason:bt.InboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),S&&t.push({statsSample:k,type:yt.Network,reason:bt.NetworkMediaSyncFailure,iceCandidate:e.connection.local.id}),t}}class zt extends Nt{#d;constructor(e={}){super(),this.#d=e.correctedSamplesThresholdPct??5}performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}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:yt.Network,reason:bt.NetworkMediaSyncFailure,ssrc:e.ssrc})})),r):r}}class Vt extends Nt{#s;#o;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200}performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}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:yt.Network,reason:bt.OutboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),g&&t.push({statsSample:v,type:yt.Network,reason:bt.OutboundNetworkQuality,iceCandidate:e.connection.local.id}),t}}class Ht extends Nt{performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}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:yt.CPU,reason:bt.EncoderCPUThrottling,ssrc:e.ssrc}),"bandwidth"===e.qualityLimitationReason&&r.push({statsSample:i,type:yt.Network,reason:bt.OutboundNetworkThroughput,ssrc:e.ssrc}))})),r):r}}class $t extends Nt{UNKNOWN_DECODER="unknown";#u={};performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}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:yt.Stream,reason:bt.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}}class Kt extends Nt{#l=new Map;#p;#n;constructor(e={}){super(),this.#p=e.timeoutMs??1e4,this.#n=e.framesDroppedThreshold??.5}performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}processData(e){const{connection:{id:t}}=e,r=this.getLastProcessedStats(t),n=[];if(!r)return n;const{video:{inbound:i}}=e,{video:{inbound:s}}=r,o=e=>new Map(e.map((e=>[e.track.trackIdentifier,e]))),a=o(i),c=o(s),d=new Set(this.#l.keys());return Array.from(a.entries()).forEach((([e,t])=>{d.delete(e);const r=c.get(e);if(!r)return;const i=t.framesReceived-r.framesReceived,s=t.framesDropped-r.framesDropped,o=t.framesDecoded-r.framesDecoded;if(0===i)return;if(s/i>=this.#n)return;if(o>0)return void this.removeMarkIssue(e);if(!this.markIssue(e))return;const a={framesReceived:t.framesReceived,framesDropped:t.framesDropped,framesDecoded:t.framesDecoded,deltaFramesReceived:i,deltaFramesDropped:s,deltaFramesDecoded:o};n.push({statsSample:a,type:yt.Stream,reason:bt.FrozenVideoTrack,trackIdentifier:e})})),d.forEach((e=>{this.removeMarkIssue(e)})),n}markIssue(e){const t=Date.now(),r=this.#l.get(e);return r?!(t-r<this.#p):(this.#l.set(e,t),!1)}removeMarkIssue(e){this.#l.delete(e)}}const Gt=e=>"closed"===e.iceConnectionState||"closed"===e.connectionState,Jt=(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 Qt{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(!Gt(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 Yt{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(!Gt(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()}),jt({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=Jt(e,r,"bytesReceived"),e.packetRate=Jt(e,r,"packetsReceived")})),e.audio.outbound.forEach((e=>{const r=t.audio.outbound.find((({id:t})=>t===e.id));e.bitrate=Jt(e,r,"bytesSent"),e.packetRate=Jt(e,r,"packetsSent")})),e.video.inbound.forEach((e=>{const r=t.video.inbound.find((({id:t})=>t===e.id));e.bitrate=Jt(e,r,"bytesReceived"),e.packetRate=Jt(e,r,"packetsReceived")})),e.video.outbound.forEach((e=>{const r=t.video.outbound.find((({id:t})=>t===e.id));e.bitrate=Jt(e,r,"bytesSent"),e.packetRate=Jt(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 Zt{eventEmitter;#h=!1;detectors=[];networkScoresCalculator;statsReporter;compositeStatsParser;logger;autoAddPeerConnections;constructor(e){this.logger=e.logger??{debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},this.eventEmitter=e.issueEmitter??new Lt,e.onIssues&&this.eventEmitter.on(vt.Issue,e.onIssues),e.onNetworkScoresUpdated&&this.eventEmitter.on(vt.NetworkScoresUpdated,e.onNetworkScoresUpdated),this.detectors=e.detectors??[new Ht,new Wt,new qt,new Ut,new Vt,new zt,new Bt,new $t,new Kt],this.networkScoresCalculator=e.networkScoresCalculator??new Ft,this.compositeStatsParser=e.compositeStatsParser??new Qt({statsParser:new Yt({ignoreSSRCList:e.ignoreSSRCList,logger:this.logger})}),this.statsReporter=e.statsReporter??new At({compositeStatsParser:this.compositeStatsParser,getStatsInterval:e.getStatsInterval??5e3}),window.wid=this,this.autoAddPeerConnections=e.autoAddPeerConnections??!0,this.autoAddPeerConnections&&this.wrapRTCPeerConnection(),this.statsReporter.on(At.STATS_REPORT_READY_EVENT,(e=>{this.detectIssues({data:e.stats}),this.calculateNetworkScores(e.stats)})),this.statsReporter.on(At.STATS_REPORTS_PARSED,(t=>{const r={timeTaken:t.timeTaken,ts:Date.now()};e.onStats&&e.onStats(t.reportItems),this.eventEmitter.emit(vt.StatsParsingFinished,r)}))}watchNewPeerConnections(){if(!this.autoAddPeerConnections)throw new Error("Auto add peer connections was disabled in the constructor.");this.#h?this.logger.warn("WebRTCIssueDetector is already started. Skip processing"):(this.logger.info("Start watching peer connections"),this.#h=!0,this.statsReporter.startReporting())}stopWatchingNewPeerConnections(){this.#h?(this.logger.info("Stop watching peer connections"),this.#h=!1,this.statsReporter.stopReporting()):this.logger.warn("WebRTCIssueDetector is already stopped. Skip processing")}handleNewPeerConnection(e,t){this.#h||!this.autoAddPeerConnections?(this.#h||!1!==this.autoAddPeerConnections||(this.logger.info("Starting stats reporting for new peer connection"),this.#h=!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(vt.Issue,e)}detectIssues({data:e}){const t=this.detectors.reduce(((t,r)=>[...t,...r.detect(e)]),[]);t.length>0&&this.emitIssues(t)}calculateNetworkScores(e){const t=this.networkScoresCalculator.calculate(e);this.eventEmitter.emit(vt.NetworkScoresUpdated,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 Xt={};Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.InvalidStateError=Xt.UnsupportedError=void 0;class er extends Error{constructor(e){super(e),this.name="UnsupportedError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,er):this.stack=new Error(e).stack}}var tr=Xt.UnsupportedError=er;class rr extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,rr):this.stack=new Error(e).stack}}Xt.InvalidStateError=rr;Error;const nr=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],ir=({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]=ir({from:e[r],seen:t.slice(),forceEnumerable:n}):i[r]=s);for(const{property:t,enumerable:r}of nr)"string"==typeof e[t]&&Object.defineProperty(i,t,{value:e[t],enumerable:!!n||r,configurable:!0,writable:!0});return i};var sr,or,ar,cr=e=>"object"==typeof e&&null!==e?ir({from:e,seen:[],forceEnumerable:!0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e;sr=new WeakMap,or=new WeakMap,ar=new WeakMap;var dr=new class{constructor(){sr.set(this,void 0),or.set(this,void 0),ar.set(this,void 0)}get meta(){return{peerId:a(this,sr,"f"),channelId:a(this,or,"f"),appId:a(this,ar,"f")}}setPeerId(e){c(this,sr,e,"f")}setChannelId(e){c(this,or,e,"f")}setAppId(e){c(this,ar,e,"f")}clear(){c(this,sr,void 0,"f"),c(this,or,void 0,"f"),c(this,ar,void 0,"f")}};const ur="channel.event",lr="channel.join",pr="channel.getPeers",hr="peer.disconnected",fr="peer.updateAppData",mr="channel.confirmActivity",gr="channel.activityConfirmationAcquired",vr="channel.activityConfirmationRequired",yr="channel.activityConfirmationExpired",br="channel.getAudioObserverProducer",wr="channel.getGeneralDataProducer",_r="channel.getChannelStateSyncDataProducer",Sr="channel.changeProducePermissions",kr="channel.deleteProducePermissions",Cr="peer.changeProducePermissions",Rr="peer.addProducePermissions",Pr="peer.removeProducePermissions",Tr="peer.groupsChanged",Er="peer.ping",Dr="channel-event",Ir="peer-joined",Mr="peer-left",xr="channel-activity-confirmation-required",Or="channel-activity-confirmation-acquired",Lr="channel-activity-confirmation-expired",Ar="channel-rejoin-required",jr="devices-list-updated",Fr="transport-connection-timeout",Nr="track-force-closed",Br="track-failed",Wr="active-speaker-changed",qr="channel-state-inconsistent",Ur="connection-lost",zr="connection-restored",Vr="forced-disconnect",Hr="reject-unauthorized",$r="volume-changed",Kr={trackProduced:"track-produced",trackUnproduced:"track-unproduced",trackPaused:"track-paused",trackResumed:"track-resumed",trackClosed:"track-closed",trackReopened:"track-reopened",trackFailed:"track-failed"},Gr="media-published",Jr="media-unpublished",Qr="publisher-paused",Yr="publisher-resumed",Zr="track-start",Xr="track-end",en="track-paused",tn="track-resumed",rn="track-failed",nn="app-data-updated",sn="produce-permissions-changed",on="groups-changed",an="peer.newProducer",cn="producer.close",dn="producer.pause",un="producer.resume",ln="producer.paused",pn="producer.resumed",hn="producer.forceClosed",fn="producer.setMaxSpatialLayer",mn="producer.requestMaxSpatialLayer",gn="consumer.create",vn="dataConsumer.create",yn="consumer.close",bn="consumer.pause",wn="consumer.resume",_n="consumer.score",Sn="consumer.changeConsumerPreferredLayers",kn="consumer.requestKeyFrame",Cn="consumer.setConsumerPriority",Rn="transport.create",Pn="transport.connect",Tn="transport.produce",En="transport.produceData",Dn="transport.connectionTimeout",In="transport.getIceParameters",Mn=[Rn,Pn,Tn,En,In,cn,dn,un,bn,wn,gn,yn,Er],xn="socket-state",On="transport-state";class Ln extends Error{constructor(e,t,r){super(e),this.errorCode=null!=t?t:"unknown_error",this.meta=r}}class An extends Ln{constructor(e,t){super(e,null!=t?t:"unsupported_error")}}An.UNSUPPORTED_DEVICE_CODE="unsupported_device_error",An.UNSUPPORTED_OPERATION_CODE="unsupported_operation_error";const jn=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 Fn={exports:{}},Nn=l(Fn.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 Bn=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}),[]))||[]},Wn=e=>["video/vp9","vp9"].includes(e.toLowerCase());const qn=new class{sleepMs(e){return o(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}now(){return new Date(Date.now())}},Un=(e,t={})=>o(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 zn,Vn,Hn,$n;!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.StatsHandler="StatsHandler",e.DataChannelsManager="DataChannelsManager"}(zn||(zn={})),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"}(Vn||(Vn={})),function(e){e.NotFoundError="NotFoundError",e.NoDevices="NoDevices",e.DeviceIsBusy="DeviceIsBusy",e.NotAllowedError="NotAllowedError",e.RequestDevicesUnknownError="RequestDevicesUnknownError"}(Hn||(Hn={})),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"}($n||($n={}));let Kn=class{constructor(){this.isJoined=!1,this.isChannelJoining=!1}reset(){this.appId=void 0,this.channelId=void 0}};Kn=n([ot()],Kn);var Gn={},Jn={exports:{}},Qn=1e3,Yn=6e4,Zn=60*Yn,Xn=24*Zn,ei=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*Xn;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Zn;case"minutes":case"minute":case"mins":case"min":case"m":return r*Yn;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>=Xn)return ti(e,t,Xn,"day");if(t>=Zn)return ti(e,t,Zn,"hour");if(t>=Yn)return ti(e,t,Yn,"minute");if(t>=1e3)return ti(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=Xn)return Math.round(e/Xn)+"d";if(t>=Zn)return Math.round(e/Zn)+"h";if(t>=Yn)return Math.round(e/Yn)+"m";if(t>=Qn)return Math.round(e/Qn)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ti(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var ri=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=ei,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=ri(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Jn,Jn.exports);var ni,ii,si={},oi={exports:{}};ni=oi,ii=oi.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",J="Samsung",Q="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,J],[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,J],[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,Q],[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,J],[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,Q],[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,J],[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]),ni.exports&&(ii=ni.exports=Te),ii.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:u);var ai={},ci=u&&u.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ai,"__esModule",{value:!0}),ai.Logger=void 0;const di=ci(Jn.exports),ui="mediasoup-client";ai.Logger=class{constructor(e){e?(this._debug=(0,di.default)(`${ui}:${e}`),this._warn=(0,di.default)(`${ui}:WARN:${e}`),this._error=(0,di.default)(`${ui}:ERROR:${e}`)):(this._debug=(0,di.default)(ui),this._warn=(0,di.default)(`${ui}:WARN`),this._error=(0,di.default)(`${ui}: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 li,pi={},hi={exports:{}},fi="object"==typeof Reflect?Reflect:null,mi=fi&&"function"==typeof fi.apply?fi.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};li=fi&&"function"==typeof fi.ownKeys?fi.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var gi=Number.isNaN||function(e){return e!=e};function vi(){vi.init.call(this)}hi.exports=vi,hi.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))}Ti(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&Ti(e,"error",t,r)}(e,i,{once:!0})}))},vi.EventEmitter=vi,vi.prototype._events=void 0,vi.prototype._eventsCount=0,vi.prototype._maxListeners=void 0;var yi=10;function bi(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function wi(e){return void 0===e._maxListeners?vi.defaultMaxListeners:e._maxListeners}function _i(e,t,r,n){var i,s,o,a;if(bi(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=wi(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 Si(){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 ki(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=Si.bind(n);return i.listener=r,n.wrapFn=i,i}function Ci(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):Pi(i,i.length)}function Ri(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 Pi(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function Ti(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(vi,"defaultMaxListeners",{enumerable:!0,get:function(){return yi},set:function(e){if("number"!=typeof e||e<0||gi(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");yi=e}}),vi.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},vi.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||gi(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},vi.prototype.getMaxListeners=function(){return wi(this)},vi.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)mi(a,this,t);else{var c=a.length,d=Pi(a,c);for(r=0;r<c;++r)mi(d[r],this,t)}return!0},vi.prototype.addListener=function(e,t){return _i(this,e,t,!1)},vi.prototype.on=vi.prototype.addListener,vi.prototype.prependListener=function(e,t){return _i(this,e,t,!0)},vi.prototype.once=function(e,t){return bi(t),this.on(e,ki(this,e,t)),this},vi.prototype.prependOnceListener=function(e,t){return bi(t),this.prependListener(e,ki(this,e,t)),this},vi.prototype.removeListener=function(e,t){var r,n,i,s,o;if(bi(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},vi.prototype.off=vi.prototype.removeListener,vi.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},vi.prototype.listeners=function(e){return Ci(this,e,!0)},vi.prototype.rawListeners=function(e){return Ci(this,e,!1)},vi.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ri.call(e,t)},vi.prototype.listenerCount=Ri,vi.prototype.eventNames=function(){return this._eventsCount>0?li(this._events):[]},Object.defineProperty(pi,"__esModule",{value:!0}),pi.EnhancedEventEmitter=void 0;const Ei=hi.exports,Di=new ai.Logger("EnhancedEventEmitter");class Ii extends Ei.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){Di.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)}}pi.EnhancedEventEmitter=Ii;var Mi={};Object.defineProperty(Mi,"__esModule",{value:!0}),Mi.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},Mi.generateRandomNumber=function(){return Math.round(1e7*Math.random())},Mi.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 xi={},Oi={},Li={},Ai={exports:{}},ji=1e3,Fi=6e4,Ni=60*Fi,Bi=24*Ni,Wi=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*Bi;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Ni;case"minutes":case"minute":case"mins":case"min":case"m":return r*Fi;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>=Bi)return qi(e,t,Bi,"day");if(t>=Ni)return qi(e,t,Ni,"hour");if(t>=Fi)return qi(e,t,Fi,"minute");if(t>=1e3)return qi(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=Bi)return Math.round(e/Bi)+"d";if(t>=Ni)return Math.round(e/Ni)+"h";if(t>=Fi)return Math.round(e/Fi)+"m";if(t>=ji)return Math.round(e/ji)+"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 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=Wi,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=Ui(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Ai,Ai.exports);var zi=Ai.exports,Vi=u&&u.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Li,"__esModule",{value:!0}),Li.Logger=void 0;const Hi=Vi(Ai.exports),$i="h264-profile-level-id";Li.Logger=class{constructor(e){e?(this._debug=(0,Hi.default)(`${$i}:${e}`),this._warn=(0,Hi.default)(`${$i}:WARN:${e}`),this._error=(0,Hi.default)(`${$i}:ERROR:${e}`)):(this._debug=(0,Hi.default)($i),this._warn=(0,Hi.default)(`${$i}:WARN`),this._error=(0,Hi.default)(`${$i}: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(Oi,"__esModule",{value:!0}),Oi.generateProfileLevelIdStringForAnswer=Oi.isSameProfile=Oi.parseSdpProfileLevelId=Oi.levelToString=Oi.profileToString=Oi.profileLevelIdToString=Oi.parseProfileLevelId=Oi.ProfileLevelId=Oi.Level=Oi.Profile=void 0;const Ki=new Li.Logger;var Gi,Ji;!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"}(Gi||(Oi.Profile=Gi={})),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"}(Ji||(Oi.Level=Ji={}));class Qi{constructor(e,t){this.profile=e,this.level=t}}Oi.ProfileLevelId=Qi;const Yi=new Qi(Gi.ConstrainedBaseline,Ji.L3_1);class Zi{constructor(e){this.mask=~is("x",e),this.masked_value=is("1",e)}isMatch(e){return this.masked_value===(e&this.mask)}}class Xi{constructor(e,t,r){this.profile_idc=e,this.profile_iop=t,this.profile=r}}const es=[new Xi(66,new Zi("x1xx0000"),Gi.ConstrainedBaseline),new Xi(77,new Zi("1xxx0000"),Gi.ConstrainedBaseline),new Xi(88,new Zi("11xx0000"),Gi.ConstrainedBaseline),new Xi(66,new Zi("x0xx0000"),Gi.Baseline),new Xi(88,new Zi("10xx0000"),Gi.Baseline),new Xi(77,new Zi("0x0x0000"),Gi.Main),new Xi(100,new Zi("00000000"),Gi.High),new Xi(100,new Zi("00001100"),Gi.ConstrainedHigh),new Xi(244,new Zi("00000000"),Gi.PredictiveHigh444)];function ts(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 Ji.L1_1:s=0!=(16&n)?Ji.L1_b:Ji.L1_1;break;case Ji.L1:case Ji.L1_2:case Ji.L1_3:case Ji.L2:case Ji.L2_1:case Ji.L2_2:case Ji.L3:case Ji.L3_1:case Ji.L3_2:case Ji.L4:case Ji.L4_1:case Ji.L4_2:case Ji.L5:case Ji.L5_1:case Ji.L5_2:s=r;break;default:return void Ki.warn(`parseProfileLevelId() | unrecognized level_idc [str:${e}, level_idc:${r}]`)}for(const e of es)if(i===e.profile_idc&&e.profile_iop.isMatch(n))return new Qi(e.profile,s);Ki.warn(`parseProfileLevelId() | unrecognized profile_idc/profile_iop combination [str:${e}, profile_idc:${i}, profile_iop:${n}]`)}function rs(e){if(e.level==Ji.L1_b)switch(e.profile){case Gi.ConstrainedBaseline:return"42f00b";case Gi.Baseline:return"42100b";case Gi.Main:return"4d100b";default:return void Ki.warn(`profileLevelIdToString() | Level 1_b not is allowed for profile ${e.profile}`)}let t;switch(e.profile){case Gi.ConstrainedBaseline:t="42e0";break;case Gi.Baseline:t="4200";break;case Gi.Main:t="4d00";break;case Gi.ConstrainedHigh:t="640c";break;case Gi.High:t="6400";break;case Gi.PredictiveHigh444:t="f400";break;default:return void Ki.warn(`profileLevelIdToString() | unrecognized profile ${e.profile}`)}let r=e.level.toString(16);return 1===r.length&&(r=`0${r}`),`${t}${r}`}function ns(e={}){const t=e["profile-level-id"];return t?ts(t):Yi}function is(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 ss(e={}){const t=e["level-asymmetry-allowed"];return!0===t||1===t||"1"===t}Oi.parseProfileLevelId=ts,Oi.profileLevelIdToString=rs,Oi.profileToString=function(e){switch(e){case Gi.ConstrainedBaseline:return"ConstrainedBaseline";case Gi.Baseline:return"Baseline";case Gi.Main:return"Main";case Gi.ConstrainedHigh:return"ConstrainedHigh";case Gi.High:return"High";case Gi.PredictiveHigh444:return"PredictiveHigh444";default:return void Ki.warn(`profileToString() | unrecognized profile ${e}`)}},Oi.levelToString=function(e){switch(e){case Ji.L1_b:return"1b";case Ji.L1:return"1";case Ji.L1_1:return"1.1";case Ji.L1_2:return"1.2";case Ji.L1_3:return"1.3";case Ji.L2:return"2";case Ji.L2_1:return"2.1";case Ji.L2_2:return"2.2";case Ji.L3:return"3";case Ji.L3_1:return"3.1";case Ji.L3_2:return"3.2";case Ji.L4:return"4";case Ji.L4_1:return"4.1";case Ji.L4_2:return"4.2";case Ji.L5:return"5";case Ji.L5_1:return"5.1";case Ji.L5_2:return"5.2";default:return void Ki.warn(`levelToString() | unrecognized level ${e}`)}},Oi.parseSdpProfileLevelId=ns,Oi.isSameProfile=function(e={},t={}){const r=ns(e),n=ns(t);return Boolean(r&&n&&r.profile===n.profile)},Oi.generateProfileLevelIdStringForAnswer=function(e={},t={}){if(!e["profile-level-id"]&&!t["profile-level-id"])return void Ki.warn("generateProfileLevelIdStringForAnswer() | profile-level-id missing in local and remote params");const r=ns(e),n=ns(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=ss(e)&&ss(t),s=r.level,o=function(e,t){return function(e,t){if(e===Ji.L1_b)return t!==Ji.L1&&t!==Ji.L1_b;if(t===Ji.L1_b)return e!==Ji.L1;return e<t}(e,t)?e:t}(s,n.level),a=i?s:o;return Ki.debug(`generateProfileLevelIdStringForAnswer() | result [profile:${r.profile}, level:${a}]`),rs(new Qi(r.profile,a))};var os,as=u&&u.__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]}),cs=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ds=u&&u.__importStar||(os=function(e){return os=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},os(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=os(e),n=0;n<r.length;n++)"default"!==r[n]&&as(t,e,r[n]);return cs(t,e),t});Object.defineProperty(xi,"__esModule",{value:!0}),xi.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)hs(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)ms(t)},xi.validateRtpParameters=ps,xi.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")},xi.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)},xi.getExtendedRtpCapabilities=function(e,t){const r={codecs:[],headerExtensions:[]};for(const n of t.codecs??[]){if(bs(n))continue;const t=(e.codecs??[]).find((e=>ws(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:Ss(t,n)};r.codecs.push(i)}for(const n of r.codecs){const r=e.codecs.find((e=>bs(e)&&e.parameters.apt===n.localPayloadType)),i=t.codecs.find((e=>bs(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=>_s(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},xi.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},xi.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},xi.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},xi.reduceCodecs=function(e,t){const r=[];if(t){for(let n=0;n<e.length;++n)if(ws(e[n],t,{strict:!0})){r.push(e[n]),bs(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]),bs(e[1])&&r.push(e[1]);return r},xi.generateProbatorRtpParameters=function(e){ps(e=ls.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},xi.canSend=function(e,t){return t.codecs.some((t=>t.kind===e))},xi.canReceive=function(e,t){if(ps(e),0===e.codecs.length)return!1;const r=e.codecs[0];return t.codecs.some((e=>e.remotePayloadType===r.payloadType))};const us=ds(Oi),ls=ds(Mi);function ps(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)gs(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)vs(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)ys(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 hs(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)fs(t)}function fs(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 ms(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 gs(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)fs(t)}function vs(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 ys(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 bs(e){return!!e&&/.+\/rtx$/i.test(e.mimeType)}function ws(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(!us.isSameProfile(e.parameters,t.parameters))return!1;let r;try{r=us.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 _s(e,t){return(!e.kind||!t.kind||e.kind===t.kind)&&e.uri===t.uri}function Ss(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 ks={},Cs={},Rs={},Ps={exports:{}},Ts=1e3,Es=60*Ts,Ds=60*Es,Is=24*Ds,Ms=7*Is,xs=365.25*Is,Os=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*xs;case"weeks":case"week":case"w":return r*Ms;case"days":case"day":case"d":return r*Is;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Ds;case"minutes":case"minute":case"mins":case"min":case"m":return r*Es;case"seconds":case"second":case"secs":case"sec":case"s":return r*Ts;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>=Is)return Ls(e,t,Is,"day");if(t>=Ds)return Ls(e,t,Ds,"hour");if(t>=Es)return Ls(e,t,Es,"minute");if(t>=Ts)return Ls(e,t,Ts,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=Is)return Math.round(e/Is)+"d";if(t>=Ds)return Math.round(e/Ds)+"h";if(t>=Es)return Math.round(e/Es)+"m";if(t>=Ts)return Math.round(e/Ts)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ls(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var As=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=Os,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=As(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Ps,Ps.exports),Object.defineProperty(Rs,"__esModule",{value:!0}),Rs.Logger=void 0;const js=Ps.exports,Fs="awaitqueue";Rs.Logger=class{constructor(e){e?(this._debug=(0,js.default)(`awaitqueue:${e}`),this._warn=(0,js.default)(`awaitqueue:WARN:${e}`),this._error=(0,js.default)(`awaitqueue:ERROR:${e}`)):(this._debug=(0,js.default)(Fs),this._warn=(0,js.default)("awaitqueue:WARN"),this._error=(0,js.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(Cs,"__esModule",{value:!0}),Cs.AwaitQueue=Cs.AwaitQueueRemovedTaskError=Cs.AwaitQueueStoppedError=void 0;const Ns=new Rs.Logger;class Bs extends Error{constructor(e){super(e??"AwaitQueue stopped"),this.name="AwaitQueueStoppedError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Bs)}}Cs.AwaitQueueStoppedError=Bs;class Ws extends Error{constructor(e){super(e??"AwaitQueue task removed"),this.name="AwaitQueueRemovedTaskError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Ws)}}Cs.AwaitQueueRemovedTaskError=Ws;
|
|
29
|
+
***************************************************************************** */!function(e){!function(t){var r="object"==typeof globalThis?globalThis:"object"==typeof u?u:"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)&&!J(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 J(e){switch(j(e)){case 3:case 4:return!0;default:return!1}}function Q(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--,Q(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(!Q(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(Q(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)}()}(d||(d={}));var h=["inject","multi_inject","name","unmanaged","named","optional"],f="Request",m="Singleton",g="Transient",v="ConstantValue",y="Constructor",b="DynamicValue",w="Factory",_="Function",S="Instance",k="Invalid",C="Provider",R="ClassProperty",P="ConstructorArgument",T="Variable",E=0;function D(){return E++}var I=function(){function e(e,t){this.id=D(),this.activated=!1,this.serviceIdentifier=e,this.scope=t,this.type=k,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===m&&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}(),M="No matching bindings found for serviceIdentifier:",x="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.",O=function(e,t){return"onDeactivation() error in class "+e+": "+t},L=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}(),A=0,j=1;function F(e){return e instanceof RangeError||"Maximum call stack size exceeded"===e.message}function N(e){return"function"==typeof e?e.name:"symbol"==typeof e?e.toString():e}function B(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=U(e.implementationType)),n=n+"\n "+t,e.constraint.metaData&&(n=n+" - "+e.constraint.metaData)}))),n}function W(e,t){return null!==e.parentRequest&&(e.parentRequest.serviceIdentifier===t||W(e.parentRequest,t))}function q(e){e.childRequests.forEach((function(e){if(W(e,e.serviceIdentifier)){var t=function(e){return function e(t,r){void 0===r&&(r=[]);var n=N(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)}q(e)}))}function U(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 z=function(){function e(e){this.id=D(),this.container=e}return e.prototype.addPlan=function(e){this.plan=e},e.prototype.setCurrentRequest=function(e){this.currentRequest=e},e}(),V=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}(),H=function(e,t){this.parentContext=e,this.rootRequest=t},$=function(){function e(e){this._cb=e}return e.prototype.unwrap=function(){return this._cb()},e}(),K=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}(),G=function(){function e(e,t,r,n){this.id=D(),this.type=e,this.serviceIdentifier=r;var i="symbol"==typeof t?t.toString().slice(7,-1):t;this.name=new K(i||""),this.identifier=t,this.metadata=new Array;var s=null;"string"==typeof n?s=new V("named",n):n instanceof V&&(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 h.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 h.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 Q(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=Y(o,e,t,r,n);null!==a&&s.push(a)}return s}(n,t,s,o,c||d?a.length:r.length),l=X(e,r,t);return J(J([],u,!0),l,!0)}function Y(e,t,r,n,i){var s=i[e.toString()]||[],o=te(s),a=!0!==o.unmanaged,c=n[e],d=o.inject||o.multiInject;if((c=d||c)instanceof $&&(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 G(P,o.targetName,c);return u.metadata=s,u}return null}function Z(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 X(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=te(d),l=u.targetName||c,p=Z(u.inject,u.multiInject,c,r),h=new G(R,l,p);h.metadata=d,i.push(h)}var f=Object.getPrototypeOf(t.prototype).constructor;if(f!==Object){var m=X(e,f,r);i=J(J([],i,!0),m,!0)}return i}function ee(e,t){var r=Object.getPrototypeOf(t.prototype).constructor;if(r!==Object){var n=Q(e,U(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:ee(e,r)}return 0}function te(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 re=function(){function e(e,t,r,n,i){this.id=D(),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 ne(e){return e._bindingDictionary}function ie(e,t,r,n,i){var s=oe(r.container,i.serviceIdentifier),o=[];return s.length===A&&r.container.options.autoBindInjectable&&"function"==typeof i.serviceIdentifier&&e.getConstructorMetadata(i.serviceIdentifier).compilerGeneratedMetadata&&(r.container.bind(i.serviceIdentifier).toSelf(),s=oe(r.container,i.serviceIdentifier)),o=t?s:s.filter((function(e){var t=new re(e.serviceIdentifier,r,n,e,i);return e.constraint(t)})),function(e,t,r,n){switch(t.length){case A:if(r.isOptional())return t;var i=N(e),s=M;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+=B(n,i,oe),new Error(s);case j:return t;default:if(r.isArray())return t;s="Ambiguous match found for serviceIdentifier: "+(i=N(e));throw s+=B(n,i,oe),new Error(s)}}(i.serviceIdentifier,o,i,r.container),o}function se(e,t,r,n,i,s){var o,a;if(null===i){o=ie(e,t,n,null,s),a=new re(r,n,null,o,s);var c=new H(n,a);n.addPlan(c)}else o=ie(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===S&&null!==t.implementationType){var i=function(e,t){return Q(e,U(t),t,!1)}(e,t.implementationType);if(!n.container.options.skipBaseClassChecks){var o=ee(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."}(U(t.implementationType));throw new Error(c)}}i.forEach((function(t){se(e,!1,t.serviceIdentifier,n,r,t)}))}}))}function oe(e,t){var r=[],n=ne(e);return n.hasKey(t)?r=n.get(t):null!==e.parent&&(r=oe(e.parent,t)),r}function ae(e,t,r,n,i,s,o,a){void 0===a&&(a=!1);var c=new z(t),d=function(e,t,r,n,i,s){var o=new V(e?"multi_inject":"inject",r),a=new G(t,n,r,o);if(void 0!==i){var c=new V(i,s);a.metadata.push(c)}return a}(r,n,i,"",s,o);try{return se(e,a,i,c,null,d),c}catch(e){throw F(e)&&q(c.plan.rootRequest),e}}function ce(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then}function de(e){return!!ce(e)||Array.isArray(e)&&e.some(ce)}var ue,le=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())}))},pe=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])}}},he=function(e,t,r){e.has(t.id)||e.set(t.id,r)},fe=function(e,t){e.cache=t,e.activated=!0,ce(t)&&me(e,t)},me=function(e,t){return le(void 0,void 0,void 0,(function(){var r,n;return pe(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"}(ue||(ue={}));var ge=function(){return ge=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},ge.apply(this,arguments)},ve=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())}))},ye=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])}}},be=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 we(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===P?e.constructorInjections.push(n):(e.propertyRequests.push(r),e.propertyInjections.push(n)),e.isAsync||(e.isAsync=de(n)),e}),{constructorInjections:[],propertyInjections:[],propertyRequests:[],isAsync:!1})}(t,r),s=ge(ge({},i),{constr:e});n=i.isAsync?function(e){return ve(this,void 0,void 0,(function(){var t,r;return ye(this,(function(n){switch(n.label){case 0:return[4,Se(e.constructorInjections)];case 1:return t=n.sent(),[4,Se(e.propertyInjections)];case 2:return r=n.sent(),[2,_e(ge(ge({},e),{constructorInjections:t,propertyInjections:r}))]}}))}))}(s):_e(s)}else n=new e;return n}function _e(e){var t,r=new((t=e.constr).bind.apply(t,be([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 Se(e){return ve(this,void 0,void 0,(function(){var t,r,n,i;return ye(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 ke(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 ce(r)?r.then((function(){return t})):t}function Ce(e,t){e.scope!==m&&function(e,t){var r="Class cannot be instantiated in "+(e.scope===f?"request":"transient")+" scope.";if("function"==typeof e.onDeactivation)throw new Error(O(t.name,r));if(Reflect.hasMetadata("pre_destroy",t))throw new Error("@preDestroy error in class "+t.name+": "+r)}(e,t)}var Re=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())}))},Pe=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])}}},Te=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 Te(e)(t)}));if(!t.target.isOptional()||0!==r.length){var o=r[0];return Me(e,t,o)}}},Ee=function(e,t){var r=function(e){switch(e.type){case w:return{factory:e.factory,factoryType:ue.Factory};case C:return{factory:e.provider,factoryType:ue.Provider};case b:return{factory:e.dynamicValue,factoryType:ue.DynamicValue};default:throw new Error("Unexpected factory type "+e.type)}}(e);return function(e,t){try{return e()}catch(e){throw F(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}))},De=function(e,t,r){var n,i=t.childRequests;switch(function(e){var t=null;switch(e.type){case v:case _:t=e.cache;break;case y:case S:t=e.implementationType;break;case b:t=e.dynamicValue;break;case C:t=e.provider;break;case w:t=e.factory}if(null===t){var r=N(e.serviceIdentifier);throw new Error("Invalid binding type: "+r)}}(r),r.type){case v:case _:n=r.cache;break;case y:n=r.implementationType;break;case S:n=function(e,t,r,n){Ce(e,t);var i=we(t,r,n);return ce(i)?i.then((function(e){return ke(t,e)})):ke(t,i)}(r,r.implementationType,i,Te(e));break;default:n=Ee(r,t.parentContext)}return n},Ie=function(e,t,r){var n=function(e,t){return t.scope===m&&t.activated?t.cache:t.scope===f&&e.has(t.id)?e.get(t.id):null}(e,t);return null!==n||function(e,t,r){t.scope===m&&fe(t,r),t.scope===f&&he(e,t,r)}(e,t,n=r()),n},Me=function(e,t,r){return Ie(e,r,(function(){var n=De(e,t,r);return n=ce(n)?n.then((function(e){return xe(t,r,e)})):xe(t,r,n)}))};function xe(e,t,r){var n,i=Oe(e.parentContext,t,r),s=Fe(e.parentContext.container),o=s.next();do{n=o.value;var a=e.parentContext,c=e.serviceIdentifier,d=je(n,c);i=ce(i)?Ae(d,a,i):Le(d,a,i),o=s.next()}while(!0!==o.done&&!ne(n).hasKey(e.serviceIdentifier));return i}var Oe=function(e,t,r){return"function"==typeof t.onActivation?t.onActivation(e,r):r},Le=function(e,t,r){for(var n=e.next();!n.done;){if(ce(r=n.value(t,r)))return Ae(e,t,r);n=e.next()}return r},Ae=function(e,t,r){return Re(void 0,void 0,void 0,(function(){var n,i;return Pe(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]}}))}))},je=function(e,t){var r=e._activations;return r.hasKey(t)?r.get(t).values():[].values()},Fe=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 Ne=function(e,t){var r=e.parentRequest;return null!==r&&(!!t(r)||Ne(r,t))},Be=function(e){return function(t){var r=function(r){return null!==r&&null!==r.target&&r.target.matchesTag(e)(t)};return r.metaData=new V(e,t),r}},We=Be("named"),qe=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}},Ue=function(){function e(e){this._binding=e}return e.prototype.when=function(e){return this._binding.constraint=e,new ze(this._binding)},e.prototype.whenTargetNamed=function(e){return this._binding.constraint=We(e),new ze(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 ze(this._binding)},e.prototype.whenTargetTagged=function(e,t){return this._binding.constraint=Be(e)(t),new ze(this._binding)},e.prototype.whenInjectedInto=function(e){return this._binding.constraint=function(t){return null!==t&&qe(e)(t.parentRequest)},new ze(this._binding)},e.prototype.whenParentNamed=function(e){return this._binding.constraint=function(t){return null!==t&&We(e)(t.parentRequest)},new ze(this._binding)},e.prototype.whenParentTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&Be(e)(t)(r.parentRequest)},new ze(this._binding)},e.prototype.whenAnyAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&Ne(t,qe(e))},new ze(this._binding)},e.prototype.whenNoAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&!Ne(t,qe(e))},new ze(this._binding)},e.prototype.whenAnyAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&Ne(t,We(e))},new ze(this._binding)},e.prototype.whenNoAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&!Ne(t,We(e))},new ze(this._binding)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&Ne(r,Be(e)(t))},new ze(this._binding)},e.prototype.whenNoAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&!Ne(r,Be(e)(t))},new ze(this._binding)},e.prototype.whenAnyAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&Ne(t,e)},new ze(this._binding)},e.prototype.whenNoAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&!Ne(t,e)},new ze(this._binding)},e}(),ze=function(){function e(e){this._binding=e}return e.prototype.onActivation=function(e){return this._binding.onActivation=e,new Ue(this._binding)},e.prototype.onDeactivation=function(e){return this._binding.onDeactivation=e,new Ue(this._binding)},e}(),Ve=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new Ue(this._binding),this._bindingOnSyntax=new ze(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}(),He=function(){function e(e){this._binding=e}return e.prototype.inRequestScope=function(){return this._binding.scope=f,new Ve(this._binding)},e.prototype.inSingletonScope=function(){return this._binding.scope=m,new Ve(this._binding)},e.prototype.inTransientScope=function(){return this._binding.scope=g,new Ve(this._binding)},e}(),$e=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new Ue(this._binding),this._bindingOnSyntax=new ze(this._binding),this._bindingInSyntax=new He(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}(),Ke=function(){function e(e){this._binding=e}return e.prototype.to=function(e){return this._binding.type=S,this._binding.implementationType=e,new $e(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=v,this._binding.cache=e,this._binding.dynamicValue=null,this._binding.implementationType=null,this._binding.scope=m,new Ve(this._binding)},e.prototype.toDynamicValue=function(e){return this._binding.type=b,this._binding.cache=null,this._binding.dynamicValue=e,this._binding.implementationType=null,new $e(this._binding)},e.prototype.toConstructor=function(e){return this._binding.type=y,this._binding.implementationType=e,this._binding.scope=m,new Ve(this._binding)},e.prototype.toFactory=function(e){return this._binding.type=w,this._binding.factory=e,this._binding.scope=m,new Ve(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=_,this._binding.scope=m,t},e.prototype.toAutoFactory=function(e){return this._binding.type=w,this._binding.factory=function(t){return function(){return t.container.get(e)}},this._binding.scope=m,new Ve(this._binding)},e.prototype.toAutoNamedFactory=function(e){return this._binding.type=w,this._binding.factory=function(t){return function(r){return t.container.getNamed(e,r)}},new Ve(this._binding)},e.prototype.toProvider=function(e){return this._binding.type=C,this._binding.provider=e,this._binding.scope=m,new Ve(this._binding)},e.prototype.toService=function(e){this.toDynamicValue((function(t){return t.container.get(e)}))},e}(),Ge=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}(),Qe=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}(),Ye=function(){return Ye=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},Ye.apply(this,arguments)},Ze=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())}))},Xe=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])}}},et=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))},tt=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=g;else if(t.defaultScope!==m&&t.defaultScope!==g&&t.defaultScope!==f)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=D(),this._bindingDictionary=new Je,this._snapshots=[],this._middleware=null,this._activations=new Je,this._deactivations=new Je,this.parent=null,this._metadataReader=new L,this._moduleActivationStore=new Qe}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=et([t,r],n,!0).map((function(e){return ne(e)})),a=ne(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 Ze(this,void 0,void 0,(function(){var t,r,n,i,s;return Xe(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 Ze(this,void 0,void 0,(function(){var t,r,n,i;return Xe(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||g,r=new I(e,t);return this._bindingDictionary.add(e,r),new Ke(r)},e.prototype.rebind=function(e){return this.unbind(e),this.bind(e)},e.prototype.rebindAsync=function(e){return Ze(this,void 0,void 0,(function(){return Xe(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 Ze(this,void 0,void 0,(function(){var t;return Xe(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 Ze(this,void 0,void 0,(function(){var e,t=this;return Xe(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 G(T,"",t,new V(r,n)),s=new z(e);return new re(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(Ge.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 Ze(this,void 0,void 0,(function(){var t;return Xe(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 Ze(this,void 0,void 0,(function(){var n;return Xe(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(ce(i))return this._handleDeactivationError(i.then((function(){return r._propagateContainerDeactivationThenBindingAndPreDestroyAsync(e,t,n)})),n)}var s=this._propagateContainerDeactivationThenBindingAndPreDestroy(e,t,n);if(ce(s))return this._handleDeactivationError(s,n)}catch(e){if(e instanceof Error)throw new Error(O(n.name,e.message))}},e.prototype._handleDeactivationError=function(e,t){return Ze(this,void 0,void 0,(function(){var r;return Xe(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(O(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(ce(i))return i.then((function(){return r._deactivateContainerAsync(e,t)}));n=t.next()}},e.prototype._deactivateContainerAsync=function(e,t){return Ze(this,void 0,void 0,(function(){var r;return Xe(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=Ye(Ye({},e),{contextInterceptor:function(e){return e},targetType:T});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(de(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=ae(e._metadataReader,e,t.isMultiInject,t.targetType,t.serviceIdentifier,t.key,t.value,t.avoidConstraints);return function(e){return Te(e.plan.rootRequest.requestScope)(e.plan.rootRequest)}(r=t.contextInterceptor(r))}},e.prototype._deactivateIfSingleton=function(e){var t=this;if(e.activated)return ce(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(ce(this._deactivateIfSingleton(n)))throw new Error("Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)")}},e.prototype._deactivateSingletonsAsync=function(e){return Ze(this,void 0,void 0,(function(){var t=this;return Xe(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 Ze(this,void 0,void 0,(function(){return Xe(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: "+N(e))}},e.prototype._bindingDeactivationAndPreDestroy=function(e,t,r){var n=this;if("function"==typeof e.onDeactivation){var i=e.onDeactivation(t);if(ce(i))return i.then((function(){return n._preDestroy(r,t)}))}return this._preDestroy(r,t)},e.prototype._bindingDeactivationAndPreDestroyAsync=function(e,t,r){return Ze(this,void 0,void 0,(function(){return Xe(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 rt(e,t,r,n){!function(e){if(void 0!==e)throw new Error(x)}(t),it("inversify:tagged",e,r.toString(),n)}function nt(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 it(e,t,r,n){var i=nt(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 st(e){return function(t,r,n){"number"==typeof n?rt(t,r,n,e):function(e,t,r){if(void 0!==e.prototype)throw new Error(x);it("inversify:tagged_props",e.constructor,t,r)}(t,r,e)}}function ot(){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 at,ct=(at="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 st(new V(at,e))(t,r,n)}});const dt=3,ut=4,lt=6,pt=7;var ht;const ft={baseURL:"https://lb.livedigital.space/v1",timeout:5e3},mt=()=>{};let gt=class{constructor(e){var t,r,n,i,s;ht.set(this,void 0),c(this,ht,{loadbalancer:Object.assign(ft,(null===(t=e.network)||void 0===t?void 0:t.loadbalancer)||{}),logLevel:null!==(r=e.logLevel)&&void 0!==r?r:dt,sendAnalytics:null!==(n=e.sendAnalytics)&&void 0!==n&&n,onLogMessage:e.onLogMessage||mt,onIssues:e.onIssues||mt,disableWid:null!==(i=e.disableWid)&&void 0!==i&&i,effectsSDKParams:e.effectsSDKParams,onNetworkScoresUpdated:e.onNetworkScoresUpdated||mt,staticFilesPath:null!==(s=e.staticFilesPath)&&void 0!==s?s:window.location.origin},"f")}get(e){return a(this,ht,"f")[e]}};ht=new WeakMap,gt=n([ot(),s("design:paramtypes",[Object])],gt);var vt,yt,bt,wt=gt;class _t 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 St(){}function kt(){kt.init.call(this)}function Ct(e){return void 0===e._maxListeners?kt.defaultMaxListeners:e._maxListeners}function Rt(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Ot(e,n),s=0;s<n;++s)i[s].call(r)}function Pt(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,s=Ot(e,i),o=0;o<i;++o)s[o].call(r,n)}function Tt(e,t,r,n,i){if(t)e.call(r,n,i);else for(var s=e.length,o=Ot(e,s),a=0;a<s;++a)o[a].call(r,n,i)}function Et(e,t,r,n,i,s){if(t)e.call(r,n,i,s);else for(var o=e.length,a=Ot(e,o),c=0;c<o;++c)a[c].call(r,n,i,s)}function Dt(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,s=Ot(e,i),o=0;o<i;++o)s[o].apply(r,n)}function It(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 St,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=Ct(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 Mt(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 xt(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 Ot(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}St.prototype=Object.create(null),kt.EventEmitter=kt,kt.usingDomains=!1,kt.prototype.domain=void 0,kt.prototype._events=void 0,kt.prototype._maxListeners=void 0,kt.defaultMaxListeners=10,kt.init=function(){this.domain=null,kt.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new St,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},kt.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},kt.prototype.getMaxListeners=function(){return Ct(this)},kt.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:Rt(r,u,this);break;case 2:Pt(r,u,this,arguments[1]);break;case 3:Tt(r,u,this,arguments[1],arguments[2]);break;case 4:Et(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];Dt(r,u,this,i)}return!0},kt.prototype.addListener=function(e,t){return It(this,e,t,!1)},kt.prototype.on=kt.prototype.addListener,kt.prototype.prependListener=function(e,t){return It(this,e,t,!0)},kt.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Mt(this,e,t)),this},kt.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Mt(this,e,t)),this},kt.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 St:(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 St,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},kt.prototype.off=function(e,t){return this.removeListener(e,t)},kt.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new St,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new St: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 St,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},kt.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):[]},kt.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):xt.call(e,t)},kt.prototype.listenerCount=xt,kt.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};class Lt extends kt{}!function(e){e.Issue="issue",e.NetworkScoresUpdated="network-scores-updated",e.StatsParsingFinished="stats-parsing-finished"}(vt||(vt={})),function(e){e.Network="network",e.CPU="cpu",e.Server="server",e.Stream="stream"}(yt||(yt={})),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"}(bt||(bt={}));class At extends kt{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(At.STATS_REPORTS_PARSED,{timeTaken:r,reportItems:t}),t.forEach((e=>{this.emit(At.STATS_REPORT_READY_EVENT,e)}))}}const jt=(()=>{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 Ft{#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,jt({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 Nt{#e;#t;constructor(e={}){this.#e=new Map,this.#t=e.statsCleanupTtlMs??35e3}detect(e){const t=this.performDetection(e);return this.performPrevStatsCleanup({connectionId:e.connection.id}),t}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;this.#e.has(t)&&jt({taskId:t,delayMs:this.#t,callback:()=>{this.deleteLastProcessedStats(t),"function"==typeof r&&r()}})}setLastProcessedStats(e,t){this.#e.set(e,t)}getLastProcessedStats(e){return this.#e.get(e)}deleteLastProcessedStats(e){this.#e.delete(e)}}class Bt extends Nt{#r;constructor(e={}){super(e),this.#r=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.#r?(t.push({statsSample:s,type:yt.Network,reason:bt.OutboundNetworkThroughput}),t):t}}class Wt extends Nt{#n;constructor(e={}){super(e),this.#n=e.framesDroppedThreshold??.5}performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}processData(e){const t=e.video.inbound.filter((e=>e.framesDropped>0)),r=[],n=this.getLastProcessedStats(e.connection.id)?.video.inbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;if(e.framesDropped===t.framesDropped)return;const i=e.framesReceived-t.framesReceived,s=e.framesDecoded-t.framesDecoded,o=e.framesDropped-t.framesDropped,a=o/i;if(0===i||0===s)return;const c={deltaFramesDropped:o,deltaFramesReceived:i,deltaFramesDecoded:s,framesDroppedPct:Math.round(100*a)};a>=this.#n&&r.push({statsSample:c,type:yt.CPU,reason:bt.DecoderCPUThrottling,ssrc:e.ssrc})})),r):r}}class qt extends Nt{#i;constructor(e={}){super(e),this.#i=e.missedFramesThreshold??.15}performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}processData(e){const t=e.video.outbound.filter((e=>e.framesEncoded>0)),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;if(e.framesEncoded===t.framesEncoded)return;const i=e.framesEncoded-t.framesEncoded,s=e.framesSent-t.framesSent,o=1-s/i;if(0===i)return;if(i===s)return;const a={deltaFramesSent:s,deltaFramesEncoded:i,missedFramesPct:Math.round(100*o)};o>=this.#i&&r.push({statsSample:a,type:yt.Network,reason:bt.OutboundNetworkThroughput,ssrc:e.ssrc})})),r):r}}class Ut extends Nt{#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){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}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:yt.Network,reason:bt.InboundNetworkQuality,iceCandidate:e.connection.local.id}),w&&t.push({statsSample:k,type:yt.Server,reason:bt.ServerIssue,iceCandidate:e.connection.remote.id}),_&&t.push({statsSample:k,type:yt.Network,reason:bt.InboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),S&&t.push({statsSample:k,type:yt.Network,reason:bt.NetworkMediaSyncFailure,iceCandidate:e.connection.local.id}),t}}class zt extends Nt{#d;constructor(e={}){super(),this.#d=e.correctedSamplesThresholdPct??5}performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}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:yt.Network,reason:bt.NetworkMediaSyncFailure,ssrc:e.ssrc})})),r):r}}class Vt extends Nt{#s;#o;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200}performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}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:yt.Network,reason:bt.OutboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),g&&t.push({statsSample:v,type:yt.Network,reason:bt.OutboundNetworkQuality,iceCandidate:e.connection.local.id}),t}}class Ht extends Nt{performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}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:yt.CPU,reason:bt.EncoderCPUThrottling,ssrc:e.ssrc}),"bandwidth"===e.qualityLimitationReason&&r.push({statsSample:i,type:yt.Network,reason:bt.OutboundNetworkThroughput,ssrc:e.ssrc}))})),r):r}}class $t extends Nt{UNKNOWN_DECODER="unknown";#u={};performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}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:yt.Stream,reason:bt.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}}class Kt extends Nt{#l=new Map;#p;#n;constructor(e={}){super(),this.#p=e.timeoutMs??1e4,this.#n=e.framesDroppedThreshold??.5}performDetection(e){const{connection:{id:t}}=e,r=this.processData(e);return this.setLastProcessedStats(t,e),r}processData(e){const{connection:{id:t}}=e,r=this.getLastProcessedStats(t),n=[];if(!r)return n;const{video:{inbound:i}}=e,{video:{inbound:s}}=r,o=e=>new Map(e.map((e=>[e.track.trackIdentifier,e]))),a=o(i),c=o(s),d=new Set(this.#l.keys());return Array.from(a.entries()).forEach((([e,t])=>{d.delete(e);const r=c.get(e);if(!r)return;const i=t.framesReceived-r.framesReceived,s=t.framesDropped-r.framesDropped,o=t.framesDecoded-r.framesDecoded;if(0===i)return;if(s/i>=this.#n)return;if(o>0)return void this.removeMarkIssue(e);if(!this.markIssue(e))return;const a={framesReceived:t.framesReceived,framesDropped:t.framesDropped,framesDecoded:t.framesDecoded,deltaFramesReceived:i,deltaFramesDropped:s,deltaFramesDecoded:o};n.push({statsSample:a,type:yt.Stream,reason:bt.FrozenVideoTrack,trackIdentifier:e})})),d.forEach((e=>{this.removeMarkIssue(e)})),n}markIssue(e){const t=Date.now(),r=this.#l.get(e);return r?!(t-r<this.#p):(this.#l.set(e,t),!1)}removeMarkIssue(e){this.#l.delete(e)}}const Gt=e=>"closed"===e.iceConnectionState||"closed"===e.connectionState,Jt=(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 Qt{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(!Gt(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 Yt{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(!Gt(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()}),jt({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=Jt(e,r,"bytesReceived"),e.packetRate=Jt(e,r,"packetsReceived")})),e.audio.outbound.forEach((e=>{const r=t.audio.outbound.find((({id:t})=>t===e.id));e.bitrate=Jt(e,r,"bytesSent"),e.packetRate=Jt(e,r,"packetsSent")})),e.video.inbound.forEach((e=>{const r=t.video.inbound.find((({id:t})=>t===e.id));e.bitrate=Jt(e,r,"bytesReceived"),e.packetRate=Jt(e,r,"packetsReceived")})),e.video.outbound.forEach((e=>{const r=t.video.outbound.find((({id:t})=>t===e.id));e.bitrate=Jt(e,r,"bytesSent"),e.packetRate=Jt(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 Zt{eventEmitter;#h=!1;detectors=[];networkScoresCalculator;statsReporter;compositeStatsParser;logger;autoAddPeerConnections;constructor(e){this.logger=e.logger??{debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},this.eventEmitter=e.issueEmitter??new Lt,e.onIssues&&this.eventEmitter.on(vt.Issue,e.onIssues),e.onNetworkScoresUpdated&&this.eventEmitter.on(vt.NetworkScoresUpdated,e.onNetworkScoresUpdated),this.detectors=e.detectors??[new Ht,new Wt,new qt,new Ut,new Vt,new zt,new Bt,new $t,new Kt],this.networkScoresCalculator=e.networkScoresCalculator??new Ft,this.compositeStatsParser=e.compositeStatsParser??new Qt({statsParser:new Yt({ignoreSSRCList:e.ignoreSSRCList,logger:this.logger})}),this.statsReporter=e.statsReporter??new At({compositeStatsParser:this.compositeStatsParser,getStatsInterval:e.getStatsInterval??5e3}),window.wid=this,this.autoAddPeerConnections=e.autoAddPeerConnections??!0,this.autoAddPeerConnections&&this.wrapRTCPeerConnection(),this.statsReporter.on(At.STATS_REPORT_READY_EVENT,(e=>{this.detectIssues({data:e.stats}),this.calculateNetworkScores(e.stats)})),this.statsReporter.on(At.STATS_REPORTS_PARSED,(t=>{const r={timeTaken:t.timeTaken,ts:Date.now()};e.onStats&&e.onStats(t.reportItems),this.eventEmitter.emit(vt.StatsParsingFinished,r)}))}watchNewPeerConnections(){if(!this.autoAddPeerConnections)throw new Error("Auto add peer connections was disabled in the constructor.");this.#h?this.logger.warn("WebRTCIssueDetector is already started. Skip processing"):(this.logger.info("Start watching peer connections"),this.#h=!0,this.statsReporter.startReporting())}stopWatchingNewPeerConnections(){this.#h?(this.logger.info("Stop watching peer connections"),this.#h=!1,this.statsReporter.stopReporting()):this.logger.warn("WebRTCIssueDetector is already stopped. Skip processing")}handleNewPeerConnection(e,t){this.#h||!this.autoAddPeerConnections?(this.#h||!1!==this.autoAddPeerConnections||(this.logger.info("Starting stats reporting for new peer connection"),this.#h=!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(vt.Issue,e)}detectIssues({data:e}){const t=this.detectors.reduce(((t,r)=>[...t,...r.detect(e)]),[]);t.length>0&&this.emitIssues(t)}calculateNetworkScores(e){const t=this.networkScoresCalculator.calculate(e);this.eventEmitter.emit(vt.NetworkScoresUpdated,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 Xt={};Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.InvalidStateError=Xt.UnsupportedError=void 0;class er extends Error{constructor(e){super(e),this.name="UnsupportedError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,er):this.stack=new Error(e).stack}}var tr=Xt.UnsupportedError=er;class rr extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,rr):this.stack=new Error(e).stack}}Xt.InvalidStateError=rr;Error;const nr=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],ir=({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]=ir({from:e[r],seen:t.slice(),forceEnumerable:n}):i[r]=s);for(const{property:t,enumerable:r}of nr)"string"==typeof e[t]&&Object.defineProperty(i,t,{value:e[t],enumerable:!!n||r,configurable:!0,writable:!0});return i};var sr,or,ar,cr=e=>"object"==typeof e&&null!==e?ir({from:e,seen:[],forceEnumerable:!0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e;sr=new WeakMap,or=new WeakMap,ar=new WeakMap;var dr=new class{constructor(){sr.set(this,void 0),or.set(this,void 0),ar.set(this,void 0)}get meta(){return{peerId:a(this,sr,"f"),channelId:a(this,or,"f"),appId:a(this,ar,"f")}}setPeerId(e){c(this,sr,e,"f")}setChannelId(e){c(this,or,e,"f")}setAppId(e){c(this,ar,e,"f")}clear(){c(this,sr,void 0,"f"),c(this,or,void 0,"f"),c(this,ar,void 0,"f")}};const ur="channel.event",lr="channel.join",pr="channel.getPeers",hr="peer.disconnected",fr="peer.updateAppData",mr="channel.confirmActivity",gr="channel.activityConfirmationAcquired",vr="channel.activityConfirmationRequired",yr="channel.activityConfirmationExpired",br="channel.getAudioObserverProducer",wr="channel.getGeneralDataProducer",_r="channel.getChannelStateSyncDataProducer",Sr="channel.changeProducePermissions",kr="channel.deleteProducePermissions",Cr="peer.changeProducePermissions",Rr="peer.addProducePermissions",Pr="peer.removeProducePermissions",Tr="peer.groupsChanged",Er="peer.ping",Dr="channel-event",Ir="peer-joined",Mr="peer-left",xr="channel-activity-confirmation-required",Or="channel-activity-confirmation-acquired",Lr="channel-activity-confirmation-expired",Ar="channel-rejoin-required",jr="devices-list-updated",Fr="transport-connection-timeout",Nr="track-force-closed",Br="track-failed",Wr="active-speaker-changed",qr="channel-state-inconsistent",Ur="connection-lost",zr="connection-restored",Vr="forced-disconnect",Hr="reject-unauthorized",$r="volume-changed",Kr={trackProduced:"track-produced",trackUnproduced:"track-unproduced",trackPaused:"track-paused",trackResumed:"track-resumed",trackClosed:"track-closed",trackReopened:"track-reopened",trackFailed:"track-failed"},Gr="media-published",Jr="media-unpublished",Qr="publisher-paused",Yr="publisher-resumed",Zr="track-start",Xr="track-end",en="track-paused",tn="track-resumed",rn="track-failed",nn="app-data-updated",sn="produce-permissions-changed",on="groups-changed",an="peer.newProducer",cn="producer.close",dn="producer.pause",un="producer.resume",ln="producer.paused",pn="producer.resumed",hn="producer.forceClosed",fn="producer.setMaxSpatialLayer",mn="producer.requestMaxSpatialLayer",gn="consumer.create",vn="dataConsumer.create",yn="consumer.close",bn="consumer.pause",wn="consumer.resume",_n="consumer.score",Sn="consumer.changeConsumerPreferredLayers",kn="consumer.requestKeyFrame",Cn="transport.create",Rn="transport.connect",Pn="transport.produce",Tn="transport.produceData",En="transport.connectionTimeout",Dn="transport.getIceParameters",In=[Cn,Rn,Pn,Tn,Dn,cn,dn,un,bn,wn,gn,yn,Er],Mn="socket-state",xn="transport-state";class On extends Error{constructor(e,t,r){super(e),this.errorCode=null!=t?t:"unknown_error",this.meta=r}}class Ln extends On{constructor(e,t){super(e,null!=t?t:"unsupported_error")}}Ln.UNSUPPORTED_DEVICE_CODE="unsupported_device_error",Ln.UNSUPPORTED_OPERATION_CODE="unsupported_operation_error";const An=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 jn={exports:{}},Fn=l(jn.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 Nn=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}),[]))||[]},Bn=e=>["video/vp9","vp9"].includes(e.toLowerCase());const Wn=new class{sleepMs(e){return o(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}now(){return new Date(Date.now())}},qn=(e,t={})=>o(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 Wn.sleepMs(Math.min(e,null!==(r=t.maxBackoffDelayMs)&&void 0!==r?r:e))}}}throw s}));var Un,zn,Vn,Hn;!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.StatsHandler="StatsHandler",e.DataChannelsManager="DataChannelsManager"}(Un||(Un={})),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"}(Vn||(Vn={})),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"}(Hn||(Hn={}));let $n=class{constructor(){this.isJoined=!1,this.isChannelJoining=!1}reset(){this.appId=void 0,this.channelId=void 0}};$n=n([ot()],$n);var Kn={},Gn={exports:{}},Jn=1e3,Qn=6e4,Yn=60*Qn,Zn=24*Yn,Xn=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*Zn;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Yn;case"minutes":case"minute":case"mins":case"min":case"m":return r*Qn;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>=Zn)return ei(e,t,Zn,"day");if(t>=Yn)return ei(e,t,Yn,"hour");if(t>=Qn)return ei(e,t,Qn,"minute");if(t>=1e3)return ei(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=Zn)return Math.round(e/Zn)+"d";if(t>=Yn)return Math.round(e/Yn)+"h";if(t>=Qn)return Math.round(e/Qn)+"m";if(t>=Jn)return Math.round(e/Jn)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ei(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var ti=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=Xn,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=ti(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Gn,Gn.exports);var ri,ni,ii={},si={exports:{}};ri=si,ni=si.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",J="Samsung",Q="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,J],[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,J],[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,Q],[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,J],[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,Q],[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,J],[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]),ri.exports&&(ni=ri.exports=Te),ni.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:u);var oi={},ai=u&&u.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(oi,"__esModule",{value:!0}),oi.Logger=void 0;const ci=ai(Gn.exports),di="mediasoup-client";oi.Logger=class{constructor(e){e?(this._debug=(0,ci.default)(`${di}:${e}`),this._warn=(0,ci.default)(`${di}:WARN:${e}`),this._error=(0,ci.default)(`${di}:ERROR:${e}`)):(this._debug=(0,ci.default)(di),this._warn=(0,ci.default)(`${di}:WARN`),this._error=(0,ci.default)(`${di}: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 ui,li={},pi={exports:{}},hi="object"==typeof Reflect?Reflect:null,fi=hi&&"function"==typeof hi.apply?hi.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};ui=hi&&"function"==typeof hi.ownKeys?hi.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var mi=Number.isNaN||function(e){return e!=e};function gi(){gi.init.call(this)}pi.exports=gi,pi.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))}Pi(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&Pi(e,"error",t,r)}(e,i,{once:!0})}))},gi.EventEmitter=gi,gi.prototype._events=void 0,gi.prototype._eventsCount=0,gi.prototype._maxListeners=void 0;var vi=10;function yi(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function bi(e){return void 0===e._maxListeners?gi.defaultMaxListeners:e._maxListeners}function wi(e,t,r,n){var i,s,o,a;if(yi(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=bi(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 _i(){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 Si(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=_i.bind(n);return i.listener=r,n.wrapFn=i,i}function ki(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):Ri(i,i.length)}function Ci(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 Ri(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function Pi(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(gi,"defaultMaxListeners",{enumerable:!0,get:function(){return vi},set:function(e){if("number"!=typeof e||e<0||mi(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");vi=e}}),gi.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},gi.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||mi(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},gi.prototype.getMaxListeners=function(){return bi(this)},gi.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)fi(a,this,t);else{var c=a.length,d=Ri(a,c);for(r=0;r<c;++r)fi(d[r],this,t)}return!0},gi.prototype.addListener=function(e,t){return wi(this,e,t,!1)},gi.prototype.on=gi.prototype.addListener,gi.prototype.prependListener=function(e,t){return wi(this,e,t,!0)},gi.prototype.once=function(e,t){return yi(t),this.on(e,Si(this,e,t)),this},gi.prototype.prependOnceListener=function(e,t){return yi(t),this.prependListener(e,Si(this,e,t)),this},gi.prototype.removeListener=function(e,t){var r,n,i,s,o;if(yi(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},gi.prototype.off=gi.prototype.removeListener,gi.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},gi.prototype.listeners=function(e){return ki(this,e,!0)},gi.prototype.rawListeners=function(e){return ki(this,e,!1)},gi.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ci.call(e,t)},gi.prototype.listenerCount=Ci,gi.prototype.eventNames=function(){return this._eventsCount>0?ui(this._events):[]},Object.defineProperty(li,"__esModule",{value:!0}),li.EnhancedEventEmitter=void 0;const Ti=pi.exports,Ei=new oi.Logger("EnhancedEventEmitter");class Di extends Ti.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){Ei.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)}}li.EnhancedEventEmitter=Di;var Ii={};Object.defineProperty(Ii,"__esModule",{value:!0}),Ii.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},Ii.generateRandomNumber=function(){return Math.round(1e7*Math.random())},Ii.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 Mi={},xi={},Oi={},Li={exports:{}},Ai=1e3,ji=6e4,Fi=60*ji,Ni=24*Fi,Bi=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*Ni;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Fi;case"minutes":case"minute":case"mins":case"min":case"m":return r*ji;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>=Ni)return Wi(e,t,Ni,"day");if(t>=Fi)return Wi(e,t,Fi,"hour");if(t>=ji)return Wi(e,t,ji,"minute");if(t>=1e3)return Wi(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=Ni)return Math.round(e/Ni)+"d";if(t>=Fi)return Math.round(e/Fi)+"h";if(t>=ji)return Math.round(e/ji)+"m";if(t>=Ai)return Math.round(e/Ai)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Wi(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var qi=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=Bi,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=qi(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Li,Li.exports);var Ui=Li.exports,zi=u&&u.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Oi,"__esModule",{value:!0}),Oi.Logger=void 0;const Vi=zi(Li.exports),Hi="h264-profile-level-id";Oi.Logger=class{constructor(e){e?(this._debug=(0,Vi.default)(`${Hi}:${e}`),this._warn=(0,Vi.default)(`${Hi}:WARN:${e}`),this._error=(0,Vi.default)(`${Hi}:ERROR:${e}`)):(this._debug=(0,Vi.default)(Hi),this._warn=(0,Vi.default)(`${Hi}:WARN`),this._error=(0,Vi.default)(`${Hi}: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(xi,"__esModule",{value:!0}),xi.generateProfileLevelIdStringForAnswer=xi.isSameProfile=xi.parseSdpProfileLevelId=xi.levelToString=xi.profileToString=xi.profileLevelIdToString=xi.parseProfileLevelId=xi.ProfileLevelId=xi.Level=xi.Profile=void 0;const $i=new Oi.Logger;var Ki,Gi;!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"}(Ki||(xi.Profile=Ki={})),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"}(Gi||(xi.Level=Gi={}));class Ji{constructor(e,t){this.profile=e,this.level=t}}xi.ProfileLevelId=Ji;const Qi=new Ji(Ki.ConstrainedBaseline,Gi.L3_1);class Yi{constructor(e){this.mask=~ns("x",e),this.masked_value=ns("1",e)}isMatch(e){return this.masked_value===(e&this.mask)}}class Zi{constructor(e,t,r){this.profile_idc=e,this.profile_iop=t,this.profile=r}}const Xi=[new Zi(66,new Yi("x1xx0000"),Ki.ConstrainedBaseline),new Zi(77,new Yi("1xxx0000"),Ki.ConstrainedBaseline),new Zi(88,new Yi("11xx0000"),Ki.ConstrainedBaseline),new Zi(66,new Yi("x0xx0000"),Ki.Baseline),new Zi(88,new Yi("10xx0000"),Ki.Baseline),new Zi(77,new Yi("0x0x0000"),Ki.Main),new Zi(100,new Yi("00000000"),Ki.High),new Zi(100,new Yi("00001100"),Ki.ConstrainedHigh),new Zi(244,new Yi("00000000"),Ki.PredictiveHigh444)];function es(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 Gi.L1_1:s=0!=(16&n)?Gi.L1_b:Gi.L1_1;break;case Gi.L1:case Gi.L1_2:case Gi.L1_3:case Gi.L2:case Gi.L2_1:case Gi.L2_2:case Gi.L3:case Gi.L3_1:case Gi.L3_2:case Gi.L4:case Gi.L4_1:case Gi.L4_2:case Gi.L5:case Gi.L5_1:case Gi.L5_2:s=r;break;default:return void $i.warn(`parseProfileLevelId() | unrecognized level_idc [str:${e}, level_idc:${r}]`)}for(const e of Xi)if(i===e.profile_idc&&e.profile_iop.isMatch(n))return new Ji(e.profile,s);$i.warn(`parseProfileLevelId() | unrecognized profile_idc/profile_iop combination [str:${e}, profile_idc:${i}, profile_iop:${n}]`)}function ts(e){if(e.level==Gi.L1_b)switch(e.profile){case Ki.ConstrainedBaseline:return"42f00b";case Ki.Baseline:return"42100b";case Ki.Main:return"4d100b";default:return void $i.warn(`profileLevelIdToString() | Level 1_b not is allowed for profile ${e.profile}`)}let t;switch(e.profile){case Ki.ConstrainedBaseline:t="42e0";break;case Ki.Baseline:t="4200";break;case Ki.Main:t="4d00";break;case Ki.ConstrainedHigh:t="640c";break;case Ki.High:t="6400";break;case Ki.PredictiveHigh444:t="f400";break;default:return void $i.warn(`profileLevelIdToString() | unrecognized profile ${e.profile}`)}let r=e.level.toString(16);return 1===r.length&&(r=`0${r}`),`${t}${r}`}function rs(e={}){const t=e["profile-level-id"];return t?es(t):Qi}function ns(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 is(e={}){const t=e["level-asymmetry-allowed"];return!0===t||1===t||"1"===t}xi.parseProfileLevelId=es,xi.profileLevelIdToString=ts,xi.profileToString=function(e){switch(e){case Ki.ConstrainedBaseline:return"ConstrainedBaseline";case Ki.Baseline:return"Baseline";case Ki.Main:return"Main";case Ki.ConstrainedHigh:return"ConstrainedHigh";case Ki.High:return"High";case Ki.PredictiveHigh444:return"PredictiveHigh444";default:return void $i.warn(`profileToString() | unrecognized profile ${e}`)}},xi.levelToString=function(e){switch(e){case Gi.L1_b:return"1b";case Gi.L1:return"1";case Gi.L1_1:return"1.1";case Gi.L1_2:return"1.2";case Gi.L1_3:return"1.3";case Gi.L2:return"2";case Gi.L2_1:return"2.1";case Gi.L2_2:return"2.2";case Gi.L3:return"3";case Gi.L3_1:return"3.1";case Gi.L3_2:return"3.2";case Gi.L4:return"4";case Gi.L4_1:return"4.1";case Gi.L4_2:return"4.2";case Gi.L5:return"5";case Gi.L5_1:return"5.1";case Gi.L5_2:return"5.2";default:return void $i.warn(`levelToString() | unrecognized level ${e}`)}},xi.parseSdpProfileLevelId=rs,xi.isSameProfile=function(e={},t={}){const r=rs(e),n=rs(t);return Boolean(r&&n&&r.profile===n.profile)},xi.generateProfileLevelIdStringForAnswer=function(e={},t={}){if(!e["profile-level-id"]&&!t["profile-level-id"])return void $i.warn("generateProfileLevelIdStringForAnswer() | profile-level-id missing in local and remote params");const r=rs(e),n=rs(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=is(e)&&is(t),s=r.level,o=function(e,t){return function(e,t){if(e===Gi.L1_b)return t!==Gi.L1&&t!==Gi.L1_b;if(t===Gi.L1_b)return e!==Gi.L1;return e<t}(e,t)?e:t}(s,n.level),a=i?s:o;return $i.debug(`generateProfileLevelIdStringForAnswer() | result [profile:${r.profile}, level:${a}]`),ts(new Ji(r.profile,a))};var ss,os=u&&u.__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]}),as=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),cs=u&&u.__importStar||(ss=function(e){return ss=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},ss(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=ss(e),n=0;n<r.length;n++)"default"!==r[n]&&os(t,e,r[n]);return as(t,e),t});Object.defineProperty(Mi,"__esModule",{value:!0}),Mi.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)ps(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)fs(t)},Mi.validateRtpParameters=ls,Mi.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")},Mi.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)},Mi.getExtendedRtpCapabilities=function(e,t){const r={codecs:[],headerExtensions:[]};for(const n of t.codecs??[]){if(ys(n))continue;const t=(e.codecs??[]).find((e=>bs(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:_s(t,n)};r.codecs.push(i)}for(const n of r.codecs){const r=e.codecs.find((e=>ys(e)&&e.parameters.apt===n.localPayloadType)),i=t.codecs.find((e=>ys(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=>ws(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},Mi.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},Mi.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},Mi.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},Mi.reduceCodecs=function(e,t){const r=[];if(t){for(let n=0;n<e.length;++n)if(bs(e[n],t,{strict:!0})){r.push(e[n]),ys(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]),ys(e[1])&&r.push(e[1]);return r},Mi.generateProbatorRtpParameters=function(e){ls(e=us.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},Mi.canSend=function(e,t){return t.codecs.some((t=>t.kind===e))},Mi.canReceive=function(e,t){if(ls(e),0===e.codecs.length)return!1;const r=e.codecs[0];return t.codecs.some((e=>e.remotePayloadType===r.payloadType))};const ds=cs(xi),us=cs(Ii);function ls(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)ms(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)gs(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)vs(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 ps(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)hs(t)}function hs(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 fs(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 ms(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)hs(t)}function gs(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 vs(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 ys(e){return!!e&&/.+\/rtx$/i.test(e.mimeType)}function bs(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(!ds.isSameProfile(e.parameters,t.parameters))return!1;let r;try{r=ds.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 ws(e,t){return(!e.kind||!t.kind||e.kind===t.kind)&&e.uri===t.uri}function _s(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 Ss={},ks={},Cs={},Rs={exports:{}},Ps=1e3,Ts=60*Ps,Es=60*Ts,Ds=24*Es,Is=7*Ds,Ms=365.25*Ds,xs=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*Ms;case"weeks":case"week":case"w":return r*Is;case"days":case"day":case"d":return r*Ds;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Es;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ts;case"seconds":case"second":case"secs":case"sec":case"s":return r*Ps;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>=Ds)return Os(e,t,Ds,"day");if(t>=Es)return Os(e,t,Es,"hour");if(t>=Ts)return Os(e,t,Ts,"minute");if(t>=Ps)return Os(e,t,Ps,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=Ds)return Math.round(e/Ds)+"d";if(t>=Es)return Math.round(e/Es)+"h";if(t>=Ts)return Math.round(e/Ts)+"m";if(t>=Ps)return Math.round(e/Ps)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Os(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var Ls=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=xs,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=Ls(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Rs,Rs.exports),Object.defineProperty(Cs,"__esModule",{value:!0}),Cs.Logger=void 0;const As=Rs.exports,js="awaitqueue";Cs.Logger=class{constructor(e){e?(this._debug=(0,As.default)(`awaitqueue:${e}`),this._warn=(0,As.default)(`awaitqueue:WARN:${e}`),this._error=(0,As.default)(`awaitqueue:ERROR:${e}`)):(this._debug=(0,As.default)(js),this._warn=(0,As.default)("awaitqueue:WARN"),this._error=(0,As.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(ks,"__esModule",{value:!0}),ks.AwaitQueue=ks.AwaitQueueRemovedTaskError=ks.AwaitQueueStoppedError=void 0;const Fs=new Cs.Logger;class Ns extends Error{constructor(e){super(e??"AwaitQueue stopped"),this.name="AwaitQueueStoppedError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Ns)}}ks.AwaitQueueStoppedError=Ns;class Bs extends Error{constructor(e){super(e??"AwaitQueue task removed"),this.name="AwaitQueueRemovedTaskError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Bs)}}ks.AwaitQueueRemovedTaskError=Bs;
|
|
30
30
|
/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
31
|
-
let qs;Cs.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,Ns.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),Ns.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),Ns.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(){Ns.debug("stop()"),this.stopping=!0;for(const e of this.pendingTasks.values())Ns.debug(`stop() | stopping task [name:${e.name}]`),e.reject(new Bs);this.stopping=!1}remove(e){Ns.debug(`remove() [taskIdx:${e}]`);const t=Array.from(this.pendingTasks.values())[e];t?t.reject(new Ws):Ns.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(Ns.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 Us="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:u):e=>(qs||(qs=Promise.resolve())).then(e).catch((e=>setTimeout((()=>{throw e}),0))),zs={};Object.defineProperty(zs,"__esModule",{value:!0}),zs.Producer=void 0;const Vs=pi,Hs=Xt,$s=new ai.Logger("Producer");class Ks extends Vs.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 Vs.EnhancedEventEmitter,$s.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||($s.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||($s.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new Hs.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){$s.debug("pause()"),this._closed?$s.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(){$s.debug("resume()"),this._closed?$s.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($s.debug("replaceTrack() [track:%o]",e),this._closed){if(e&&this._stopTracks)try{e.stop()}catch(e){}throw new Hs.InvalidStateError("closed")}if(e&&"ended"===e.readyState)throw new Hs.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()):$s.debug("replaceTrack() | same track, ignored")}async setMaxSpatialLayer(e){if(this._closed)throw new Hs.InvalidStateError("closed");if("video"!==this._kind)throw new Hs.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 Hs.InvalidStateError("closed");if("object"!=typeof e)throw new TypeError("invalid params");await new Promise(((t,r)=>{this.safeEmit("@setrtpencodingparameters",e,t,r)}))}onTrackEnded(){$s.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){}}}zs.Producer=Ks;var Gs={};Object.defineProperty(Gs,"__esModule",{value:!0}),Gs.Consumer=void 0;const Js=pi,Qs=Xt,Ys=new ai.Logger("Consumer");class Zs extends Js.EnhancedEventEmitter{constructor({id:e,localId:t,producerId:r,rtpReceiver:n,track:i,rtpParameters:s,appData:o}){super(),this._closed=!1,this._observer=new Js.EnhancedEventEmitter,Ys.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||(Ys.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(Ys.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new Qs.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){Ys.debug("pause()"),this._closed?Ys.error("pause() | Consumer closed"):this._paused?Ys.debug("pause() | Consumer is already paused"):(this._paused=!0,this._track.enabled=!1,this.emit("@pause"),this._observer.safeEmit("pause"))}resume(){Ys.debug("resume()"),this._closed?Ys.error("resume() | Consumer closed"):this._paused?(this._paused=!1,this._track.enabled=!0,this.emit("@resume"),this._observer.safeEmit("resume")):Ys.debug("resume() | Consumer is already resumed")}onTrackEnded(){Ys.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){}}}Gs.Consumer=Zs;var Xs={};Object.defineProperty(Xs,"__esModule",{value:!0}),Xs.DataProducer=void 0;const eo=pi,to=Xt,ro=new ai.Logger("DataProducer");class no extends eo.EnhancedEventEmitter{constructor({id:e,dataChannel:t,sctpStreamParameters:r,appData:n}){super(),this._closed=!1,this._observer=new eo.EnhancedEventEmitter,ro.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||(ro.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(ro.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}send(e){if(ro.debug("send()"),this._closed)throw new to.InvalidStateError("closed");this._dataChannel.send(e)}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(ro.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?ro.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):ro.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(ro.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(()=>{this._closed||ro.warn('DataChannel "message" event in a DataProducer, message discarded')})),this._dataChannel.addEventListener("bufferedamountlow",(()=>{this._closed||this.safeEmit("bufferedamountlow")}))}}Xs.DataProducer=no;var io={};Object.defineProperty(io,"__esModule",{value:!0}),io.DataConsumer=void 0;const so=pi,oo=new ai.Logger("DataConsumer");class ao extends so.EnhancedEventEmitter{constructor({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:n,appData:i}){super(),this._closed=!1,this._observer=new so.EnhancedEventEmitter,oo.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||(oo.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(oo.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(oo.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?oo.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):oo.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(oo.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)}))}}io.DataConsumer=ao;var co=u&&u.__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]}),uo=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),lo=u&&u.__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]&&co(r,t,n[i]);return uo(r,t),r}}(),po=u&&u.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ks,"__esModule",{value:!0}),ks.Transport=void 0;const ho=Cs,fo=po(Us),mo=ai,go=pi,vo=Xt,yo=lo(Mi),bo=lo(xi),wo=zs,_o=Gs,So=Xs,ko=io,Co=new mo.Logger("Transport");class Ro{constructor(e){this.consumerOptions=e,this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class Po extends go.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 ho.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 go.EnhancedEventEmitter,Co.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=yo.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){Co.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 vo.InvalidStateError("closed");return this._handler.getTransportStats()}async restartIce({iceParameters:e}){if(Co.debug("restartIce()"),this._closed)throw new vo.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(Co.debug("updateIceServers()"),this._closed)throw new vo.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(Co.debug("produce() [track:%o]",e),this._closed)throw new vo.InvalidStateError("closed");if(!e)throw new TypeError("missing track");if("send"!==this._direction)throw new vo.UnsupportedError("not a sending Transport");if(!this._canProduceByKind[e.kind])throw new vo.UnsupportedError(`cannot produce ${e.kind}`);if("ended"===e.readyState)throw new vo.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{bo.validateRtpParameters(l);const{id:t}=await new Promise(((t,r)=>{this.safeEmit("produce",{kind:e.kind,rtpParameters:l,appData:c},t,r)})),r=new wo.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(Co.debug("consume()"),this._closed)throw new vo.InvalidStateError("closed");if("recv"!==this._direction)throw new vo.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=yo.clone(n);if(!bo.canReceive(a,this._extendedRtpCapabilities))throw new vo.UnsupportedError("cannot consume this Producer");const c=new Ro({id:e,producerId:t,kind:r,rtpParameters:a,streamId:i,onRtpReceiver:s,appData:o});return this._pendingConsumerTasks.push(c),(0,fo.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(Co.debug("produceData()"),this._closed)throw new vo.InvalidStateError("closed");if("send"!==this._direction)throw new vo.UnsupportedError("not a sending Transport");if(!this._maxSctpMessageSize)throw new vo.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});bo.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 So.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(Co.debug("consumeData()"),this._closed)throw new vo.InvalidStateError("closed");if("recv"!==this._direction)throw new vo.UnsupportedError("not a receiving Transport");if(!this._maxSctpMessageSize)throw new vo.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=yo.clone(r);return bo.validateSctpStreamParameters(o),this._awaitQueue.push((async()=>{const{dataChannel:r}=await this._handler.receiveDataChannel({sctpStreamParameters:o,label:n,protocol:i}),a=new ko.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 Co.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 _o.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=bo.generateProbatorRtpParameters(t.rtpParameters);await this._handler.receive([{trackId:"probator",kind:"video",rtpParameters:e}]),Co.debug("createPendingConsumers() | Consumer for RTP probation created"),this._probatorConsumerCreated=!0}catch(e){Co.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 Co.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){Co.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 Co.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){Co.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 Co.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){Co.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 vo.InvalidStateError("closed")):this.safeEmit("connect",{dtlsParameters:e},t,r)})),e.on("@icegatheringstatechange",(e=>{e!==this._iceGatheringState&&(Co.debug("ICE gathering state changed to %s",e),this._iceGatheringState=e,this._closed||this.safeEmit("icegatheringstatechange",e))})),e.on("@connectionstatechange",(e=>{e!==this._connectionState&&(Co.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=>Co.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 vo.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,fo.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,fo.default)((()=>{this._closed||!1===this._consumerResumeInProgress&&this.resumePendingConsumers()}))})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new vo.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)}))}}ks.Transport=Po;var To={},Eo={},Do={},Io={exports:{}},Mo=Io.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(Mo).forEach((function(e){Mo[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=Io.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}}))}))}}(Do);var xo=Io.exports,Oo=/%[sdv%]/g,Lo=function(e){var t=1,r=arguments,n=r.length;return e.replace(Oo,(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""}}))},Ao=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 Lo.apply(null,n)},jo=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Fo=["i","c","b","a"],No=Do,Bo=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||jo,n=t.innerOrder||Fo,i=[];return r.forEach((function(t){xo[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(Ao(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(Ao(t,r,e))}))}))})),e.media.forEach((function(e){i.push(Ao("m",xo.m[0],e)),n.forEach((function(t){xo[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(Ao(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(Ao(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"},Wo=Io.exports;Eo.grammar=Wo,Eo.write=Bo,Eo.parse=No.parse,Eo.parseParams=No.parseParams,Eo.parseFmtpConfig=No.parseFmtpConfig,Eo.parsePayloads=No.parsePayloads,Eo.parseRemoteCandidates=No.parseRemoteCandidates,Eo.parseImageAttributes=No.parseImageAttributes,Eo.parseSimulcastStreamList=No.parseSimulcastStreamList;var qo={},Uo=u&&u.__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]}),zo=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Vo=u&&u.__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]&&Uo(r,t,n[i]);return zo(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=Ho.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=Ho.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 Ho=Vo(Eo);var $o={};Object.defineProperty($o,"__esModule",{value:!0}),$o.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},$o.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 Ko={};Object.defineProperty(Ko,"__esModule",{value:!0}),Ko.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 Go={};Object.defineProperty(Go,"__esModule",{value:!0}),Go.HandlerInterface=void 0;const Jo=pi;class Qo extends Jo.EnhancedEventEmitter{constructor(){super()}}Go.HandlerInterface=Qo;var Yo={},Zo={},Xo=u&&u.__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]}),ea=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ta=u&&u.__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]&&Xo(r,t,n[i]);return ea(r,t),r}}();Object.defineProperty(Zo,"__esModule",{value:!0}),Zo.OfferMediaSection=Zo.AnswerMediaSection=Zo.MediaSection=void 0;const ra=ta(Eo),na=ta(Mi);class ia{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}}Zo.MediaSection=ia;Zo.AnswerMediaSection=class extends ia{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:sa(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r=na.clone(e.parameters)??{};let n=na.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=ra.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 sa(e){const t=new RegExp("^(audio|video)/(.+)","i").exec(e.mimeType);if(!t)throw new TypeError("invalid codec.mimeType");return t[2]}Zo.OfferMediaSection=class extends ia{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:sa(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:sa(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 oa=u&&u.__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]}),aa=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ca=u&&u.__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]&&oa(r,t,n[i]);return aa(r,t),r}}();Object.defineProperty(Yo,"__esModule",{value:!0}),Yo.RemoteSdp=void 0;const da=ca(Eo),ua=Zo,la=new ai.Logger("RemoteSdp");Yo.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){la.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){la.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 ua.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 ua.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?(la.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 ua.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 ua.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++,da.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 pa={};Object.defineProperty(pa,"__esModule",{value:!0}),pa.parse=function(e){const t=ha.exec(e??"");return t?{spatialLayers:Number(t[1]),temporalLayers:Number(t[2])}:{spatialLayers:1,temporalLayers:1}};const ha=new RegExp("^[LS]([1-9]\\d{0,1})T([1-9]\\d{0,1})");var fa=u&&u.__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=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ga=u&&u.__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(To,"__esModule",{value:!0}),To.Chrome111=void 0;const va=ga(Eo),ya=ai,ba=ga(Mi),wa=ga(xi),_a=ga(qo),Sa=ga($o),ka=ga(Ko),Ca=Xt,Ra=Go,Pa=Yo,Ta=pa,Ea=new ya.Logger("Chrome111"),Da={OS:1024,MIS:1024};class Ia extends Ra.HandlerInterface{static createFactory(){return()=>new Ia}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(Ea.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){Ea.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=va.parse(t.sdp),n=_a.extractRtpCapabilities({sdpObject:r});return ka.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Ea.debug("getNativeSctpCapabilities()"),{numStreams:Da}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),Ea.debug("run()"),this._direction=e,this._remoteSdp=new Pa.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:wa.getSendingRtpParameters("audio",d),video:wa.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:wa.getSendingRemoteRtpParameters("audio",d),video:wa.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)})):(Ea.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(),Ea.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Ea.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Ea.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Ea.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ea.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Ea.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(),Ea.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,Ta.parse)(r.scalabilityMode).temporalLayers:3;t>e&&(e=t)}t.forEach(((t,r)=>{t.rid=`r${r}`,t.scalabilityMode=`L1T${e}`}))}const s=ba.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=wa.reduceCodecs(s.codecs,n);const o=ba.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=wa.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=va.parse(d.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u}),Ea.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d);const l=c.mid;s.mid=l,u=va.parse(this._pc.localDescription.sdp);const p=u.media[a.idx];if(s.rtcp.cname=_a.getCname({offerMediaObject:p}),t)if(1===t.length){const e=Sa.getRtpEncodings({offerMediaObject:p});Object.assign(e[0],t[0]),s.encodings=e}else s.encodings=t;else s.encodings=Sa.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 Ea.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(),Ea.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();Ea.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ea.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Ea.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();Ea.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ea.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Ea.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();Ea.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ea.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Ea.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Ea.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(),Ea.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();Ea.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ea.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Ea.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();Ea.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ea.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};Ea.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Da.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=va.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Ea.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()};Ea.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;Ea.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()};Ea.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=va.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));_a.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:va.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Ea.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){Ea.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()};Ea.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ea.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){Ea.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()};Ea.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ea.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){Ea.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()};Ea.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ea.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};Ea.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()};Ea.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=va.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Ea.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=va.parse(this._pc.localDescription.sdp));const r=_a.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 Ca.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')}}To.Chrome111=Ia;var Ma={},xa=u&&u.__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=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),La=u&&u.__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]&&xa(r,t,n[i]);return Oa(r,t),r}}();Object.defineProperty(Ma,"__esModule",{value:!0}),Ma.Chrome74=void 0;const Aa=La(Eo),ja=ai,Fa=La(Mi),Na=La(xi),Ba=La(qo),Wa=La($o),qa=La(Ko),Ua=Xt,za=Go,Va=Yo,Ha=pa,$a=new ja.Logger("Chrome74"),Ka={OS:1024,MIS:1024};class Ga extends za.HandlerInterface{static createFactory(){return()=>new Ga}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($a.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){$a.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=Aa.parse(t.sdp),n=Ba.extractRtpCapabilities({sdpObject:r});return qa.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return $a.debug("getNativeSctpCapabilities()"),{numStreams:Ka}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){$a.debug("run()"),this._direction=e,this._remoteSdp=new Va.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Na.getSendingRtpParameters("audio",d),video:Na.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Na.getSendingRemoteRtpParameters("audio",d),video:Na.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)})):($a.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(),$a.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),$a.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});$a.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};$a.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};$a.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();$a.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(),$a.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=Fa.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=Na.reduceCodecs(i.codecs,n);const s=Fa.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=Na.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=Aa.parse(d.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u});let l=!1;const p=(0,Ha.parse)((t??[{}])[0].scalabilityMode);t&&1===t.length&&p.spatialLayers>1&&"video/vp9"===i.codecs[0].mimeType.toLowerCase()&&($a.debug("send() | enabling legacy simulcast for VP9 SVC"),l=!0,u=Aa.parse(d.sdp),c=u.media[o.idx],Wa.addLegacySimulcast({offerMediaObject:c,numStreams:p.spatialLayers}),d={type:"offer",sdp:Aa.write(u)}),$a.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d);const h=a.mid;if(i.mid=h,u=Aa.parse(this._pc.localDescription.sdp),c=u.media[o.idx],i.rtcp.cname=Ba.getCname({offerMediaObject:c}),t)if(1===t.length){let e=Wa.getRtpEncodings({offerMediaObject:c});Object.assign(e[0],t[0]),l&&(e=[e[0]]),i.encodings=e}else i.encodings=t;else i.encodings=Wa.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 $a.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(),$a.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();$a.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};$a.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),$a.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();$a.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};$a.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),$a.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();$a.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};$a.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?$a.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):$a.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(),$a.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();$a.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};$a.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),$a.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();$a.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};$a.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};$a.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Ka.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Aa.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),$a.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()};$a.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;$a.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()};$a.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=Aa.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));Ba.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Aa.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),$a.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){$a.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()};$a.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();$a.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){$a.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()};$a.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();$a.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){$a.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()};$a.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();$a.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};$a.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()};$a.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Aa.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}$a.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=Aa.parse(this._pc.localDescription.sdp));const r=Ba.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 Ua.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')}}Ma.Chrome74=Ga;var Ja={},Qa=u&&u.__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]}),Ya=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Za=u&&u.__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]&&Qa(r,t,n[i]);return Ya(r,t),r}}();Object.defineProperty(Ja,"__esModule",{value:!0}),Ja.Chrome70=void 0;const Xa=Za(Eo),ec=ai,tc=Za(Mi),rc=Za(xi),nc=Za(qo),ic=Za($o),sc=Go,oc=Yo,ac=pa,cc=new ec.Logger("Chrome70"),dc={OS:1024,MIS:1024};class uc extends sc.HandlerInterface{static createFactory(){return()=>new uc}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(cc.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){cc.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=Xa.parse(t.sdp);return nc.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return cc.debug("getNativeSctpCapabilities()"),{numStreams:dc}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){cc.debug("run()"),this._direction=e,this._remoteSdp=new oc.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),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:"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(cc.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){cc.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(cc.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});cc.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};cc.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};cc.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();cc.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(),cc.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const i=tc.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=rc.reduceCodecs(i.codecs,n);const s=tc.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=rc.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=Xa.parse(d.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u}),t&&t.length>1&&(cc.debug("send() | enabling legacy simulcast"),u=Xa.parse(d.sdp),c=u.media[o.idx],ic.addLegacySimulcast({offerMediaObject:c,numStreams:t.length}),d={type:"offer",sdp:Xa.write(u)});let l=!1;const p=(0,ac.parse)((t??[{}])[0].scalabilityMode);if(t&&1===t.length&&p.spatialLayers>1&&"video/vp9"===i.codecs[0].mimeType.toLowerCase()&&(cc.debug("send() | enabling legacy simulcast for VP9 SVC"),l=!0,u=Xa.parse(d.sdp),c=u.media[o.idx],ic.addLegacySimulcast({offerMediaObject:c,numStreams:p.spatialLayers}),d={type:"offer",sdp:Xa.write(u)}),cc.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d),t){cc.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=Xa.parse(this._pc.localDescription.sdp),c=u.media[o.idx],i.rtcp.cname=nc.getCname({offerMediaObject:c}),i.encodings=ic.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 cc.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(),cc.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();cc.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};cc.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?cc.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):cc.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(),cc.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();cc.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};cc.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),cc.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();cc.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};cc.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};cc.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%dc.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Xa.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),cc.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()};cc.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;cc.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()};cc.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=Xa.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));nc.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Xa.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),cc.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){cc.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()};cc.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();cc.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};cc.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()};cc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Xa.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}cc.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=Xa.parse(this._pc.localDescription.sdp));const r=nc.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')}}Ja.Chrome70=uc;var lc={},pc={};Object.defineProperty(pc,"__esModule",{value:!0}),pc.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},pc.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 hc=u&&u.__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=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),mc=u&&u.__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]&&hc(r,t,n[i]);return fc(r,t),r}}();Object.defineProperty(lc,"__esModule",{value:!0}),lc.Chrome67=void 0;const gc=mc(Eo),vc=ai,yc=mc(Mi),bc=mc(xi),wc=mc(qo),_c=mc(pc),Sc=Go,kc=Yo,Cc=new vc.Logger("Chrome67"),Rc={OS:1024,MIS:1024};class Pc extends Sc.HandlerInterface{static createFactory(){return()=>new Pc}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(Cc.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){Cc.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=gc.parse(t.sdp);return wc.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Cc.debug("getNativeSctpCapabilities()"),{numStreams:Rc}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Cc.debug("run()"),this._direction=e,this._remoteSdp=new kc.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:bc.getSendingRtpParameters("audio",d),video:bc.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:bc.getSendingRemoteRtpParameters("audio",d),video:bc.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(Cc.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){Cc.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(Cc.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Cc.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Cc.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Cc.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Cc.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(),Cc.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&Cc.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=gc.parse(s.sdp);const a=yc.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=bc.reduceCodecs(a.codecs);const c=yc.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=bc.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(Cc.debug("send() | enabling simulcast"),o=gc.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),_c.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:gc.write(o)}),Cc.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=gc.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=wc.getCname({offerMediaObject:i}),a.encodings=_c.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()};Cc.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(),Cc.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();Cc.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void Cc.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()};Cc.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?Cc.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Cc.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(),Cc.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(),Cc.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};Cc.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Rc.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=gc.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Cc.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()};Cc.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;Cc.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()};Cc.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=gc.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));wc.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:gc.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),Cc.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){Cc.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()};Cc.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Cc.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};Cc.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()};Cc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=gc.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Cc.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=gc.parse(this._pc.localDescription.sdp));const r=wc.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')}}lc.Chrome67=Pc;var Tc={},Ec=u&&u.__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]}),Dc=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ic=u&&u.__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]&&Ec(r,t,n[i]);return Dc(r,t),r}}();Object.defineProperty(Tc,"__esModule",{value:!0}),Tc.Chrome55=void 0;const Mc=Ic(Eo),xc=ai,Oc=Xt,Lc=Ic(Mi),Ac=Ic(xi),jc=Ic(qo),Fc=Ic(pc),Nc=Go,Bc=Yo,Wc=new xc.Logger("Chrome55"),qc={OS:1024,MIS:1024};class Uc extends Nc.HandlerInterface{static createFactory(){return()=>new Uc}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(Wc.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){Wc.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=Mc.parse(t.sdp);return jc.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Wc.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}){Wc.debug("run()"),this._direction=e,this._remoteSdp=new Bc.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:Ac.getSendingRtpParameters("audio",d),video:Ac.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Ac.getSendingRemoteRtpParameters("audio",d),video:Ac.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(Wc.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){Wc.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(Wc.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Wc.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Wc.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Wc.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Wc.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(),Wc.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&Wc.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=Mc.parse(s.sdp);const a=Lc.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=Ac.reduceCodecs(a.codecs);const c=Lc.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=Ac.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(Wc.debug("send() | enabling simulcast"),o=Mc.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),Fc.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Mc.write(o)}),Wc.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Mc.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=jc.getCname({offerMediaObject:i}),a.encodings=Fc.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()};Wc.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(),Wc.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();Wc.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void Wc.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()};Wc.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 Oc.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new Oc.UnsupportedError(" not implemented")}async setRtpEncodingParameters(e,t){throw new Oc.UnsupportedError("not supported")}async getSenderStats(e){throw new Oc.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};Wc.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=Mc.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Wc.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()};Wc.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;Wc.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()};Wc.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=Mc.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));jc.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:Mc.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),Wc.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){Wc.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()};Wc.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Wc.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new Oc.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};Wc.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()};Wc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Mc.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Wc.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=Mc.parse(this._pc.localDescription.sdp));const r=jc.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.Chrome55=Uc;var zc={},Vc=u&&u.__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]}),Hc=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),$c=u&&u.__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]&&Vc(r,t,n[i]);return Hc(r,t),r}}();Object.defineProperty(zc,"__esModule",{value:!0}),zc.Firefox120=void 0;const Kc=$c(Eo),Gc=ai,Jc=Xt,Qc=$c(Mi),Yc=$c(xi),Zc=$c(qo),Xc=$c($o),ed=Go,td=Yo,rd=pa,nd=new Gc.Logger("Firefox120"),id={OS:16,MIS:2048};class sd extends ed.HandlerInterface{static createFactory(){return()=>new sd}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(nd.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){nd.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=Kc.parse(n.sdp);return Zc.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 nd.debug("getNativeSctpCapabilities()"),{numStreams:id}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),nd.debug("run()"),this._direction=e,this._remoteSdp=new td.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Yc.getSendingRtpParameters("audio",d),video:Yc.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Yc.getSendingRemoteRtpParameters("audio",d),video:Yc.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(nd.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 Jc.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),nd.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});nd.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};nd.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};nd.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();nd.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(),nd.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=Qc.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Yc.reduceCodecs(s.codecs,n);const o=Qc.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Yc.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=Kc.parse(c.sdp);this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:d});const u=(0,rd.parse)((t??[{}])[0].scalabilityMode);nd.debug("send() | calling pc.setLocalDescription() [offer:%o]",c),await this._pc.setLocalDescription(c);const l=a.mid;s.mid=l,d=Kc.parse(this._pc.localDescription.sdp);const p=d.media[d.media.length-1];if(s.rtcp.cname=Zc.getCname({offerMediaObject:p}),t)if(1===t.length){const e=Xc.getRtpEncodings({offerMediaObject:p});Object.assign(e[0],t[0]),s.encodings=e}else s.encodings=t;else s.encodings=Xc.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 nd.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(),nd.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();nd.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};nd.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),nd.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();nd.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};nd.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),nd.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();nd.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};nd.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?nd.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):nd.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(),nd.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();nd.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};nd.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),nd.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();nd.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};nd.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};nd.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%id.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Kc.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),nd.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()};nd.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;nd.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()};nd.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=Kc.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));Zc.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:Kc.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),nd.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){nd.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()};nd.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();nd.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){nd.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()};nd.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();nd.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){nd.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()};nd.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();nd.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};nd.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()};nd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Kc.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}nd.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=Kc.parse(this._pc.localDescription.sdp));const r=Zc.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 Jc.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')}}zc.Firefox120=sd;var od={},ad=u&&u.__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]}),cd=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),dd=u&&u.__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]&&ad(r,t,n[i]);return cd(r,t),r}}();Object.defineProperty(od,"__esModule",{value:!0}),od.Firefox60=void 0;const ud=dd(Eo),ld=ai,pd=Xt,hd=dd(Mi),fd=dd(xi),md=dd(qo),gd=dd($o),vd=Go,yd=Yo,bd=pa,wd=new ld.Logger("Firefox60"),_d={OS:16,MIS:2048};class Sd extends vd.HandlerInterface{static createFactory(){return()=>new Sd}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(wd.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){wd.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=ud.parse(o.sdp);return md.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 wd.debug("getNativeSctpCapabilities()"),{numStreams:_d}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),wd.debug("run()"),this._direction=e,this._remoteSdp=new yd.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:fd.getSendingRtpParameters("audio",d),video:fd.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:fd.getSendingRemoteRtpParameters("audio",d),video:fd.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(wd.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 pd.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),wd.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});wd.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};wd.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};wd.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();wd.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(),wd.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&((t=hd.clone(t)).forEach(((e,t)=>{e.rid=`r${t}`})),t.reverse());const i=hd.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=fd.reduceCodecs(i.codecs,n);const s=hd.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=fd.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=ud.parse(a.sdp);this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:c});const d=(0,bd.parse)((t??[{}])[0].scalabilityMode);wd.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);const u=o.mid;i.mid=u,c=ud.parse(this._pc.localDescription.sdp);const l=c.media[c.media.length-1];if(i.rtcp.cname=md.getCname({offerMediaObject:l}),t)if(1===t.length){const e=gd.getRtpEncodings({offerMediaObject:l});Object.assign(e[0],t[0]),i.encodings=e}else i.encodings=t.reverse();else i.encodings=gd.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 wd.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(),wd.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();wd.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};wd.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),wd.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();wd.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};wd.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),wd.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();wd.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};wd.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?wd.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):wd.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(),wd.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();wd.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};wd.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),wd.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();wd.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};wd.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};wd.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%_d.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=ud.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),wd.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()};wd.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;wd.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()};wd.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=ud.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));md.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:ud.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),wd.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){wd.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()};wd.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();wd.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){wd.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()};wd.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();wd.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){wd.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()};wd.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();wd.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};wd.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()};wd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=ud.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}wd.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=ud.parse(this._pc.localDescription.sdp));const r=md.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 pd.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')}}od.Firefox60=Sd;var kd={},Cd=u&&u.__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]}),Rd=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Pd=u&&u.__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]&&Cd(r,t,n[i]);return Rd(r,t),r}}();Object.defineProperty(kd,"__esModule",{value:!0}),kd.Safari12=void 0;const Td=Pd(Eo),Ed=ai,Dd=Pd(Mi),Id=Pd(xi),Md=Pd(qo),xd=Pd($o),Od=Pd(Ko),Ld=Xt,Ad=Go,jd=Yo,Fd=pa,Nd=new Ed.Logger("Safari12"),Bd={OS:1024,MIS:1024};class Wd extends Ad.HandlerInterface{static createFactory(){return()=>new Wd}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(Nd.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){Nd.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=Td.parse(t.sdp),n=Md.extractRtpCapabilities({sdpObject:r});return Od.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Nd.debug("getNativeSctpCapabilities()"),{numStreams:Bd}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),Nd.debug("run()"),this._direction=e,this._remoteSdp=new jd.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Id.getSendingRtpParameters("audio",d),video:Id.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Id.getSendingRemoteRtpParameters("audio",d),video:Id.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(Nd.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(),Nd.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Nd.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Nd.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Nd.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Nd.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Nd.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(),Nd.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const s=Dd.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Id.reduceCodecs(s.codecs,n);const o=Dd.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Id.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=Td.parse(u.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:l});const p=(0,Fd.parse)((t??[{}])[0].scalabilityMode);t&&t.length>1&&(Nd.debug("send() | enabling legacy simulcast"),l=Td.parse(u.sdp),d=l.media[a.idx],xd.addLegacySimulcast({offerMediaObject:d,numStreams:t.length}),u={type:"offer",sdp:Td.write(l)}),Nd.debug("send() | calling pc.setLocalDescription() [offer:%o]",u),await this._pc.setLocalDescription(u);const h=c.mid;if(s.mid=h,l=Td.parse(this._pc.localDescription.sdp),d=l.media[a.idx],s.rtcp.cname=Md.getCname({offerMediaObject:d}),s.encodings=xd.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 Nd.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;Nd.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();Nd.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Nd.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Nd.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();Nd.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Nd.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Nd.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();Nd.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Nd.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Nd.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Nd.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(),Nd.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();Nd.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Nd.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Nd.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();Nd.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Nd.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};Nd.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Bd.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:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Nd.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()};Nd.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;Nd.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()};Nd.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,i=r.get(e),o=s.media.find((e=>String(e.mid)===i));Md.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Td.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Nd.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){Nd.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()};Nd.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Nd.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){Nd.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()};Nd.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Nd.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){Nd.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()};Nd.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Nd.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};Nd.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()};Nd.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:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Nd.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=Md.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 Ld.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')}}kd.Safari12=Wd;var qd={},Ud=u&&u.__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]}),zd=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Vd=u&&u.__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]&&Ud(r,t,n[i]);return zd(r,t),r}}();Object.defineProperty(qd,"__esModule",{value:!0}),qd.Safari11=void 0;const Hd=Vd(Eo),$d=ai,Kd=Vd(Mi),Gd=Vd(xi),Jd=Vd(qo),Qd=Vd(pc),Yd=Go,Zd=Yo,Xd=new $d.Logger("Safari11"),eu={OS:1024,MIS:1024};class tu extends Yd.HandlerInterface{static createFactory(){return()=>new tu}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(Xd.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){Xd.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=Hd.parse(t.sdp);return Jd.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Xd.debug("getNativeSctpCapabilities()"),{numStreams:eu}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Xd.debug("run()"),this._direction=e,this._remoteSdp=new Zd.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:Gd.getSendingRtpParameters("audio",d),video:Gd.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Gd.getSendingRemoteRtpParameters("audio",d),video:Gd.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(Xd.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){Xd.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(Xd.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Xd.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Xd.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Xd.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Xd.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(),Xd.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&Xd.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=Hd.parse(s.sdp);const a=Kd.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=Gd.reduceCodecs(a.codecs);const c=Kd.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=Gd.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(Xd.debug("send() | enabling simulcast"),o=Hd.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),Qd.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Hd.write(o)}),Xd.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Hd.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=Jd.getCname({offerMediaObject:i}),a.encodings=Qd.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()};Xd.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();Xd.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void Xd.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()};Xd.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?Xd.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Xd.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(),Xd.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(),Xd.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};Xd.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%eu.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Hd.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Xd.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()};Xd.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;Xd.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()};Xd.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=Hd.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));Jd.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:Hd.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),Xd.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){Xd.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()};Xd.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Xd.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};Xd.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()};Xd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Hd.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Xd.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=Hd.parse(this._pc.localDescription.sdp));const r=Jd.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=tu;var ru={},nu={},iu=u&&u.__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]}),su=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ou=u&&u.__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]&&iu(r,t,n[i]);return su(r,t),r}}();Object.defineProperty(nu,"__esModule",{value:!0}),nu.getCapabilities=function(){const e=RTCRtpReceiver.getCapabilities(),t=au.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},nu.mangleRtpParameters=function(e){const t=au.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 au=ou(Mi);var cu=u&&u.__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=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),uu=u&&u.__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]&&cu(r,t,n[i]);return du(r,t),r}}();Object.defineProperty(ru,"__esModule",{value:!0}),ru.Edge11=void 0;const lu=ai,pu=Xt,hu=uu(Mi),fu=uu(xi),mu=uu(nu),gu=Go,vu=new lu.Logger("Edge11");class yu extends gu.HandlerInterface{static createFactory(){return()=>new yu}constructor(){super(),this._rtpSenders=new Map,this._rtpReceivers=new Map,this._nextSendLocalId=0,this._transportReady=!1}get name(){return"Edge11"}close(){vu.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 vu.debug("getNativeRtpCapabilities()"),mu.getCapabilities()}async getNativeSctpCapabilities(){return vu.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}){vu.debug("run()"),this._sendingRtpParametersByKind={audio:fu.getSendingRtpParameters("audio",d),video:fu.getSendingRtpParameters("video",d)},this._remoteIceParameters=t,this._remoteIceCandidates=r,this._remoteDtlsParameters=n,this._cname=`CNAME-${hu.generateRandomNumber()}`,this.setIceGatherer({iceServers:s,iceTransportPolicy:o}),this.setIceTransport(),this.setDtlsTransport()}async updateIceServers(e){throw new pu.UnsupportedError("not supported")}async restartIce(e){if(vu.debug("restartIce()"),this._remoteIceParameters=e,this._transportReady){vu.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}){vu.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),this._transportReady||await this.setupTransport({localDtlsRole:"server"}),vu.debug("send() | calling new RTCRtpSender()");const i=new RTCRtpSender(e,this._dtlsTransport),s=hu.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=fu.reduceCodecs(s.codecs,n);const o=s.codecs.some((e=>/.+\/rtx$/i.test(e.mimeType)));t||(t=[{}]);for(const e of t)e.ssrc=hu.generateRandomNumber(),o&&(e.rtx={ssrc:hu.generateRandomNumber()});s.encodings=t,s.rtcp={cname:this._cname,reducedSize:!0,mux:!0};const a=mu.mangleRtpParameters(s);vu.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){vu.debug("stopSending() [localId:%s]",e);const t=this._rtpSenders.get(e);if(!t)throw new Error("RTCRtpSender not found");this._rtpSenders.delete(e);try{vu.debug("stopSending() | calling rtpSender.stop()"),t.stop()}catch(e){throw vu.warn("stopSending() | rtpSender.stop() failed:%o",e),e}}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){t?vu.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):vu.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){vu.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){vu.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 pu.UnsupportedError("not implemented")}async receive(e){const t=[];for(const t of e){const{trackId:e,kind:r}=t;vu.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;vu.debug("receive() | calling new RTCRtpReceiver()");const s=new RTCRtpReceiver(this._dtlsTransport,n);s.addEventListener("error",(e=>{vu.error('rtpReceiver "error" event [event:%o]',e)}));const o=mu.mangleRtpParameters(i);vu.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){vu.debug("stopReceiving() [localId:%s]",t);const e=this._rtpReceivers.get(t);if(!e)throw new Error("RTCRtpReceiver not found");this._rtpReceivers.delete(t);try{vu.debug("stopReceiving() | calling rtpReceiver.stop()"),e.stop()}catch(e){vu.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 pu.UnsupportedError("not implemented")}setIceGatherer({iceServers:e,iceTransportPolicy:t}){const r=new RTCIceGatherer({iceServers:e??[],gatherPolicy:t??"all"});r.addEventListener("error",(e=>{vu.error('iceGatherer "error" event [event:%o]',e)}));try{r.gather()}catch(e){vu.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=>{vu.debug('iceTransport "candidatepairchange" event [pair:%o]',e.pair)})),this._iceTransport=e}setDtlsTransport(){const e=new RTCDtlsTransport(this._iceTransport);e.addEventListener("statechange",(()=>{vu.debug('dtlsTransport "statechange" event [state:%s]',e.state)})),e.addEventListener("dtlsstatechange",(()=>{vu.debug('dtlsTransport "dtlsstatechange" event [state:%s]',e.state),"closed"===e.state&&this.emit("@connectionstatechange","closed")})),e.addEventListener("error",(e=>{vu.error('dtlsTransport "error" event [event:%o]',e)})),this._dtlsTransport=e}async setupTransport({localDtlsRole:e}){vu.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}}ru.Edge11=yu;var bu={},wu=u&&u.__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]}),_u=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Su=u&&u.__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]&&wu(r,t,n[i]);return _u(r,t),r}}();Object.defineProperty(bu,"__esModule",{value:!0}),bu.ReactNativeUnifiedPlan=void 0;const ku=Su(Eo),Cu=ai,Ru=Su(Mi),Pu=Su(xi),Tu=Su(qo),Eu=Su($o),Du=Su(Ko),Iu=Xt,Mu=Go,xu=Yo,Ou=pa,Lu=new Cu.Logger("ReactNativeUnifiedPlan"),Au={OS:1024,MIS:1024};class ju extends Mu.HandlerInterface{static createFactory(){return()=>new ju}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(Lu.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(){Lu.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=ku.parse(t.sdp),n=Tu.extractRtpCapabilities({sdpObject:r});return Du.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Lu.debug("getNativeSctpCapabilities()"),{numStreams:Au}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),Lu.debug("run()"),this._direction=e,this._remoteSdp=new xu.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Pu.getSendingRtpParameters("audio",d),video:Pu.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Pu.getSendingRemoteRtpParameters("audio",d),video:Pu.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(Lu.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(),Lu.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Lu.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Lu.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Lu.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Lu.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Lu.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(),Lu.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=Ru.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Pu.reduceCodecs(s.codecs,n);const o=Ru.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Pu.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=ku.parse(u.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:l});let p=!1;const h=(0,Ou.parse)((t??[{}])[0].scalabilityMode);t&&1===t.length&&h.spatialLayers>1&&"video/vp9"===s.codecs[0].mimeType.toLowerCase()&&(Lu.debug("send() | enabling legacy simulcast for VP9 SVC"),p=!0,l=ku.parse(u.sdp),d=l.media[a.idx],Eu.addLegacySimulcast({offerMediaObject:d,numStreams:h.spatialLayers}),u={type:"offer",sdp:ku.write(l)}),Lu.debug("send() | calling pc.setLocalDescription() [offer:%o]",u),await this._pc.setLocalDescription(u);let f=c.mid??void 0;if(f||Lu.warn("send() | missing transceiver.mid (bug in react-native-webrtc, using a workaround"),s.mid=f,l=ku.parse(this._pc.localDescription.sdp),d=l.media[a.idx],s.rtcp.cname=Tu.getCname({offerMediaObject:d}),t)if(1===t.length){let e=Eu.getRtpEncodings({offerMediaObject:d});Object.assign(e[0],t[0]),p&&(e=[e[0]]),s.encodings=e}else s.encodings=t;else s.encodings=Eu.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 Lu.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;Lu.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();Lu.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Lu.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Lu.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();Lu.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Lu.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Lu.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();Lu.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Lu.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Lu.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Lu.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(),Lu.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();Lu.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Lu.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Lu.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();Lu.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Lu.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};Lu.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Au.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}),Lu.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()};Lu.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;Lu.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()};Lu.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=ku.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));Tu.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:ku.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Lu.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){Lu.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()};Lu.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Lu.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){Lu.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()};Lu.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Lu.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){Lu.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()};Lu.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Lu.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};Lu.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()};Lu.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})}Lu.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=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}assertNotClosed(){if(this._closed)throw new Iu.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')}}bu.ReactNativeUnifiedPlan=ju;var Fu={},Nu=u&&u.__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]}),Bu=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Wu=u&&u.__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]&&Nu(r,t,n[i]);return Bu(r,t),r}}();Object.defineProperty(Fu,"__esModule",{value:!0}),Fu.ReactNative=void 0;const qu=Wu(Eo),Uu=ai,zu=Xt,Vu=Wu(Mi),Hu=Wu(xi),$u=Wu(qo),Ku=Wu(pc),Gu=Go,Ju=Yo,Qu=new Uu.Logger("ReactNative"),Yu={OS:1024,MIS:1024};class Zu extends Gu.HandlerInterface{static createFactory(){return()=>new Zu}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(Qu.debug("close()"),this._sendStream.release(!1),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){Qu.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 $u.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Qu.debug("getNativeSctpCapabilities()"),{numStreams:Yu}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Qu.debug("run()"),this._direction=e,this._remoteSdp=new Ju.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:Hu.getSendingRtpParameters("audio",d),video:Hu.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Hu.getSendingRemoteRtpParameters("audio",d),video:Hu.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(Qu.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){Qu.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(Qu.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Qu.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Qu.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Qu.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Qu.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(),Qu.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&Qu.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=Vu.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=Hu.reduceCodecs(a.codecs);const c=Vu.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=Hu.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(Qu.debug("send() | enabling simulcast"),o=qu.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),Ku.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:qu.write(o)}),Qu.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=$u.getCname({offerMediaObject:i}),a.encodings=Ku.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()};Qu.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(),Qu.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();Qu.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void Qu.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()};Qu.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 zu.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new zu.UnsupportedError("not implemented")}async setRtpEncodingParameters(e,t){throw new zu.UnsupportedError("not implemented")}async getSenderStats(e){throw new zu.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};Qu.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Yu.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}),Qu.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()};Qu.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;Qu.debug("receive() [trackId:%s, kind:%s]",e,n);const s=n;let o=t.streamId??i.rtcp.cname;Qu.debug("receive() | forcing a random remote streamId to avoid well known bug in react-native-webrtc"),o+=`-hack-${Vu.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()};Qu.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));$u.applyCodecParameters({offerRtpParameters:r,answerMediaObject:i})}i={type:"answer",sdp:qu.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Qu.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){Qu.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()};Qu.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Qu.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new zu.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};Qu.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()};Qu.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})}Qu.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=$u.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')}}Fu.ReactNative=Zu;var Xu=u&&u.__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]}),el=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),tl=u&&u.__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]&&Xu(r,t,n[i]);return el(r,t),r}}();Object.defineProperty(si,"__esModule",{value:!0}),si.Device=void 0,si.detectDevice=Sl;const rl=oi.exports,nl=ai,il=pi,sl=Xt,ol=tl(Mi),al=tl(xi),cl=ks,dl=To,ul=Ma,ll=Ja,pl=lc,hl=Tc,fl=zc,ml=od,gl=kd,vl=qd,yl=ru,bl=bu,wl=Fu,_l=new nl.Logger("Device");function Sl(e){if(!e&&"object"==typeof navigator&&"ReactNative"===navigator.product)return _l.debug("detectDevice() | React-Native detected"),"undefined"==typeof RTCPeerConnection?void _l.warn("detectDevice() | unsupported react-native-webrtc without RTCPeerConnection, forgot to call registerGlobals()?"):"undefined"!=typeof RTCRtpTransceiver?(_l.debug("detectDevice() | ReactNative UnifiedPlan handler chosen"),"ReactNativeUnifiedPlan"):(_l.debug("detectDevice() | ReactNative PlanB handler chosen"),"ReactNative");if(e||"object"==typeof navigator&&"string"==typeof navigator.userAgent){e??(e=navigator.userAgent);const t=new rl.UAParser(e);_l.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"}_l.warn("detectDevice() | browser not supported [name:%s, version:%s]",n,i)}else _l.warn("detectDevice() | unknown device")}si.Device=class{constructor({handlerName:e,handlerFactory:t}={}){if(this._loaded=!1,this._observer=new il.EnhancedEventEmitter,_l.debug("constructor()"),e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(t)this._handlerFactory=t;else{if(e)_l.debug("constructor() | handler given: %s",e);else{if(!(e=Sl()))throw new sl.UnsupportedError("device not supported");_l.debug("constructor() | detected handler: %s",e)}switch(e){case"Chrome111":this._handlerFactory=dl.Chrome111.createFactory();break;case"Chrome74":this._handlerFactory=ul.Chrome74.createFactory();break;case"Chrome70":this._handlerFactory=ll.Chrome70.createFactory();break;case"Chrome67":this._handlerFactory=pl.Chrome67.createFactory();break;case"Chrome55":this._handlerFactory=hl.Chrome55.createFactory();break;case"Firefox120":this._handlerFactory=fl.Firefox120.createFactory();break;case"Firefox60":this._handlerFactory=ml.Firefox60.createFactory();break;case"Safari12":this._handlerFactory=gl.Safari12.createFactory();break;case"Safari11":this._handlerFactory=vl.Safari11.createFactory();break;case"Edge11":this._handlerFactory=yl.Edge11.createFactory();break;case"ReactNativeUnifiedPlan":this._handlerFactory=bl.ReactNativeUnifiedPlan.createFactory();break;case"ReactNative":this._handlerFactory=wl.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 sl.InvalidStateError("not loaded");return this._recvRtpCapabilities}get sctpCapabilities(){if(!this._loaded)throw new sl.InvalidStateError("not loaded");return this._sctpCapabilities}get observer(){return this._observer}async load({routerRtpCapabilities:e}){let t;_l.debug("load() [routerRtpCapabilities:%o]",e);try{if(this._loaded)throw new sl.InvalidStateError("already loaded");const r=ol.clone(e);al.validateRtpCapabilities(r),t=this._handlerFactory();const n=await t.getNativeRtpCapabilities();_l.debug("load() | got native RTP capabilities:%o",n);const i=ol.clone(n);al.validateRtpCapabilities(i),this._extendedRtpCapabilities=al.getExtendedRtpCapabilities(i,r),_l.debug("load() | got extended RTP capabilities:%o",this._extendedRtpCapabilities),this._canProduceByKind.audio=al.canSend("audio",this._extendedRtpCapabilities),this._canProduceByKind.video=al.canSend("video",this._extendedRtpCapabilities),this._recvRtpCapabilities=al.getRecvRtpCapabilities(this._extendedRtpCapabilities),al.validateRtpCapabilities(this._recvRtpCapabilities),_l.debug("load() | got receiving RTP capabilities:%o",this._recvRtpCapabilities),this._sctpCapabilities=await t.getNativeSctpCapabilities(),_l.debug("load() | got native SCTP capabilities:%o",this._sctpCapabilities),al.validateSctpCapabilities(this._sctpCapabilities),_l.debug("load() succeeded"),this._loaded=!0,t.close()}catch(e){throw t&&t.close(),e}}canProduce(e){if(!this._loaded)throw new sl.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 _l.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 _l.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 sl.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 cl.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 kl={},Cl={};Object.defineProperty(Cl,"__esModule",{value:!0});var Rl={};Object.defineProperty(Rl,"__esModule",{value:!0}),function(e){var t=u&&u.__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=u&&u.__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(si,e),r(ks,e),r(zs,e),r(Gs,e),r(Xs,e),r(io,e),r(Cl,e),r(Rl,e),r(Go,e),r(Xt,e)}(kl),function(e){var t=u&&u.__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=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=u&&u.__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=u&&u.__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(Jn.exports);e.debug=s.default;const o=si;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(kl);e.types=a,e.version="3.7.18";var c=pa;Object.defineProperty(e,"parseScalabilityMode",{enumerable:!0,get:function(){return c.parse}})}(Gn);const Pl=[{scaleResolutionDownBy:4,maxBitrate:15e4,maxFramerate:12},{scaleResolutionDownBy:2,maxBitrate:35e4,maxFramerate:18},{scaleResolutionDownBy:1,maxBitrate:9e5,maxFramerate:24}],Tl=[{maxBitrate:1e6,dtx:!0}],El=[{maxBitrate:4e4,dtx:!0}],Dl={width:1280,height:720};var Il,Ml,xl,Ol,Ll,Al,jl,Fl,Nl;class Bl{constructor(e){Il.set(this,void 0),Ml.set(this,void 0),xl.set(this,{lowLighter:!1,colorCorrector:!1,faceDetector:!1,segmentation:!1}),Ol.set(this,null),Ll.set(this,void 0),Al.set(this,!1),jl.set(this,void 0);const{loggerFactory:t}=e;c(this,Ml,t("EffectsSDKTrackProcessor"),"f"),c(this,jl,e.onModelsLoaded,"f"),c(this,Il,new window.tsvb(e.customerId),"f"),a(this,Il,"f").onError(this.tsvbErrorHandler.bind(this)),a(this,Il,"f").onReady=this.onReady.bind(this);a(this,Il,"f").config({preset:"balanced",provider:"wasm"})}init(){return o(this,void 0,void 0,(function*(){yield a(this,Il,"f").preload(),yield a(this,Il,"f").cache(),c(this,Al,!0,"f")}))}awaitReady(){return o(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:n}=e,i=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(e,["emitter","type"]),s=null!=r?r:"N/A emitter";"error"===n&&a(this,Ml,"f").error(s,Object.assign({},i)),"warning"===n&&a(this,Ml,"f").warn(s,Object.assign({},i)),"info"===n&&a(this,Ml,"f").info(s,Object.assign({},i)),"ml_inference"===r&&(i.message.toLocaleLowerCase().includes("init lowlighter")&&(a(this,xl,"f").lowLighter=!0),i.message.toLocaleLowerCase().includes("init colorcorrector")&&(a(this,xl,"f").colorCorrector=!0),i.message.toLocaleLowerCase().includes("init facedetector")&&(a(this,xl,"f").faceDetector=!0),i.message.toLocaleLowerCase().includes("init segmentation")&&(a(this,xl,"f").segmentation=!0),this.isModelsLoaded&&(null===(t=a(this,jl,"f"))||void 0===t||t.call(this)))}get isModelsLoaded(){return a(this,xl,"f").colorCorrector&&a(this,xl,"f").faceDetector&&a(this,xl,"f").lowLighter&&a(this,xl,"f").segmentation}get modelsLoadProgress(){return Object.values(a(this,xl,"f")).filter(Boolean).length/Object.keys(a(this,xl,"f")).length}get isReady(){return a(this,Al,"f")}setOnLoadModels(e){c(this,jl,e,"f"),this.isModelsLoaded&&a(this,jl,"f").call(this)}onReady(){c(this,Al,!0,"f"),a(this,Ml,"f").debug("onReady()",{description:"ESDK is ready"}),this.updateEffects(a(this,Ll,"f"))}processTrack(e){var t,r;return o(this,void 0,void 0,(function*(){if(a(this,Ol,"f")===e||"ended"===e.readyState)return(null===(t=a(this,Il,"f").getStream())||void 0===t?void 0:t.getVideoTracks()[0])||e;this.stopProcessing();try{a(this,Il,"f").useStream(new MediaStream([e]));const t=null===(r=a(this,Il,"f").getStream())||void 0===r?void 0:r.getVideoTracks()[0];return t?(c(this,Ol,e,"f"),t):e}catch(t){throw a(this,Ml,"f").error("processTrack()",{error:t,track:e}),new Error("Can not process this track")}}))}stopProcessing(){try{a(this,Il,"f").clear(),a(this,Il,"f").stop()}catch(e){a(this,Ml,"f").error("stopProcessing()",{error:e})}finally{c(this,Ol,null,"f")}}updateEffects(e){var t,r,n,i,s,o,d,u,l,p,h,f,m,g,v,y,b,w,_,S,k;if(c(this,Ll,e,"f"),!a(this,Al,"f"))return void a(this,Ml,"f").warn("updateEffects()",{description:"Esdk not ready"});if(!a(this,Ll,"f")||0===Object.keys(a(this,Ll,"f")).length)return void a(this,Il,"f").stop();let C=0;if((null===(t=a(this,Ll,"f"))||void 0===t?void 0:t.blur)&&!(null===(r=a(this,Ll,"f"))||void 0===r?void 0:r.backgroundColor)?(a(this,Il,"f").setBlur(a(this,Ll,"f").blur),C+=1):a(this,Il,"f").clearBlur(),void 0!==(null===(n=a(this,Ll,"f"))||void 0===n?void 0:n.background)?(a(this,Il,"f").setBackground(a(this,Ll,"f").background),C+=1):void 0!==(null===(i=a(this,Ll,"f"))||void 0===i?void 0:i.backgroundColor)?(a(this,Il,"f").setBackgroundColor(null===(s=a(this,Ll,"f"))||void 0===s?void 0:s.backgroundColor),a(this,Il,"f").setBackground("color"),C+=1):a(this,Il,"f").clearBackground(),(null===(o=a(this,Ll,"f"))||void 0===o?void 0:o.beautification)?(a(this,Il,"f").enableBeautification(),a(this,Il,"f").setBeautificationLevel(a(this,Ll,"f").beautification),C+=1):a(this,Il,"f").disableBeautification(),(null===(d=a(this,Ll,"f"))||void 0===d?void 0:d.lowLightEffect)?(a(this,Il,"f").enableLowLightEffect(),a(this,Il,"f").setLowLightEffectPower(a(this,Ll,"f").lowLightEffect),C+=1):a(this,Il,"f").disableLowLightEffect(),(null===(u=a(this,Ll,"f"))||void 0===u?void 0:u.colorCorrector)?(a(this,Il,"f").enableColorCorrector(),a(this,Il,"f").setColorCorrectorPower(a(this,Ll,"f").colorCorrector),C+=1):a(this,Il,"f").disableColorCorrector(),(null===(l=a(this,Ll,"f"))||void 0===l?void 0:l.smartZoom)?(a(this,Il,"f").enableSmartZoom(),a(this,Il,"f").setFaceArea(a(this,Ll,"f").smartZoom),C+=1):a(this,Il,"f").disableSmartZoom(),(null===(p=a(this,Ll,"f"))||void 0===p?void 0:p.layout)?(a(this,Il,"f").setLayout(a(this,Ll,"f").layout),C+=1):a(this,Il,"f").setLayout("center"),(null===(h=a(this,Ll,"f"))||void 0===h?void 0:h.colorFilter)&&(null===(f=a(this,Ll,"f"))||void 0===f?void 0:f.colorFilter.power)&&(null===(m=a(this,Ll,"f"))||void 0===m?void 0:m.colorFilter.url)?(a(this,Il,"f").setColorFilterConfig({lut:a(this,Ll,"f").colorFilter.url,power:a(this,Ll,"f").colorFilter.power}),a(this,Il,"f").enableColorFilter(),C+=1):a(this,Il,"f").disableColorFilter(),null===(g=a(this,Ll,"f"))||void 0===g?void 0:g.lowerThird){const e=a(this,Il,"f").createComponent({component:a(this,Ll,"f").lowerThird.type,options:a(this,Ll,"f").lowerThird.options||{}});null===(b=null===(y=null===(v=a(this,Il,"f").components)||void 0===v?void 0:v.lowerThird)||void 0===y?void 0:y.hideLowerThird)||void 0===b||b.call(y),a(this,Il,"f").addComponent(e,"lowerThird"),a(this,Il,"f").components.lowerThird.showLowerThird(),C+=1}else null===(S=null===(_=null===(w=a(this,Il,"f").components)||void 0===w?void 0:w.lowerThird)||void 0===_?void 0:_.hideLowerThird)||void 0===S||S.call(_);(null===(k=a(this,Ll,"f"))||void 0===k?void 0:k.sharpness)?(a(this,Il,"f").setSharpnessEffectConfig(a(this,Ll,"f").sharpness),C+=1):a(this,Il,"f").disableSharpnessEffect(),C>2?a(this,Il,"f").enableFrameSkipping():a(this,Il,"f").disableFrameSkipping(),a(this,Il,"f").run()}}Il=new WeakMap,Ml=new WeakMap,xl=new WeakMap,Ol=new WeakMap,Ll=new WeakMap,Al=new WeakMap,jl=new WeakMap;let Wl=Nl=class{constructor(e){Fl.set(this,void 0),c(this,Fl,e("MediaStreamTrackManager"),"f")}createMediaStreamTrack({label:e,constraints:t}){return o(this,void 0,void 0,(function*(){if(Nl.isDisplayMedia(e)){const[e]=yield this.createDisplayMediaTracks(t);return e}const[r]=yield this.createUserMediaTracks(t);return r}))}static isDisplayMedia(e){return[Vn.ScreenVideo,Vn.ScreenAudio].includes(e)}createUserMediaTracks(e){return o(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getUserMedia(e);return a(this,Fl,"f").debug("createUserMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}createDisplayMediaTracks(e){return o(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getDisplayMedia(e);return a(this,Fl,"f").debug("getDisplayMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}};Fl=new WeakMap,Wl=Nl=n([ot(),i(0,ct(zn.LoggerFactory)),s("design:paramtypes",[Function])],Wl);var ql,Ul,zl,Vl,Hl,$l=Wl;let Kl=class{constructor(e,t,r,n,i){this.config=e,this.loggerFactory=t,this.audioTrackFactory=r,this.videoTrackFactory=n,this.mediaStreamTrackManager=i,this.isDeviceLoaded=!1,this.tracks=new Map,ql.set(this,void 0),Ul.set(this,null),zl.set(this,void 0),Vl.set(this,!1),Hl.set(this,new Map);const s=this.config.get("effectsSDKParams");c(this,ql,this.loggerFactory("Media"),"f"),c(this,Ul,s||null,"f")}get mediasoupDevice(){return this.device||(this.device=this.createDevice()),this.device}get isNoiseSuppressorLoaded(){return!!a(this,zl,"f")}get effectsSDKInitialized(){return a(this,Vl,"f")}get effectsSDKParams(){return a(this,Ul,"f")}getTrack(e){return this.tracks.get(e)}loadDevice(e){return o(this,void 0,void 0,(function*(){this.isDeviceLoaded||(yield this.mediasoupDevice.load({routerRtpCapabilities:e}),this.isDeviceLoaded=!0)}))}createNoiseSuppressor(){return o(this,void 0,void 0,(function*(){try{if(a(this,zl,"f"))return void a(this,ql,"f").warn("createNoiseSuppressor()",{message:"Noise suppression module already created"});c(this,zl,yield class{static compileModule(e){return o(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")),"f")}catch(e){a(this,ql,"f").warn("createNoiseSuppressor()",{message:"Can not load wasm module",error:e})}}))}getTrackCodec(e){const{rtpCapabilities:t,rtpCapabilities:{codecs:r}}=this.mediasoupDevice;if(r)return r.find((t=>t.mimeType.toLowerCase()===`${e.kind}/${e.getPreferredCodec()}`));a(this,ql,"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),{noiseSuppressor:a(this,zl,"f"),loggerNamespace:"AudioTrack"})):this.videoTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"VideoTrack"})),a(this,ql,"f").debug("createTrack() track created",{trackId:n.id,kind:n.kind}),n}))}createUserMediaTracks(e){return o(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createUserMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}createDisplayMediaTracks(e){return o(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createDisplayMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}deleteTrack(e){return o(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){a(this,ql,"f").warn("deleteTrack()",Object.assign({error:e},t))}try{this.tracks.delete(e.getLabel()),e.stopMediaStreamTrack(),yield e.closeProducer()}catch(e){a(this,ql,"f").error("deleteTrack()",{error:e})}finally{a(this,ql,"f").debug("deleteTrack()",t)}}))}getAllTracks(){return Array.from(this.tracks.values())}publishedTracks(){return this.getAllTracks().filter((e=>e.isPublished))}clearTracks(){return o(this,void 0,void 0,(function*(){try{this.getAllTracks().map((e=>e.stopMediaStreamTrack()))}catch(e){a(this,ql,"f").warn("clearTracks()",{error:e})}finally{this.tracks.clear()}}))}unpublishTracks(){return o(this,void 0,void 0,(function*(){try{yield Promise.all(this.publishedTracks().map((e=>e.unpublish(!1))))}catch(e){a(this,ql,"f").warn("unpublishTracks()",{error:e})}}))}setTrack(e){this.tracks.set(e.getLabel(),e)}initEffectsSDK(){if(a(this,Vl,"f"))return Promise.resolve(!0);if(!a(this,Ul,"f"))throw a(this,ql,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Error("Effects SDK config not provided");const e=(e,t)=>o(this,void 0,void 0,(function*(){if(!window.tsvb)return a(this,ql,"f").info("Effects SDK not loaded, skipping initialization",{case:"initEffectsSDK"}),void e(!1);a(this,ql,"f").info("Effects SDK initializing",{case:"initEffectsSDK"});try{a(this,Hl,"f").set(Vn.Camera,yield this.createEffectsSDKTrackProcessor(Vn.Camera)),a(this,Hl,"f").set(Vn.CameraPreview,yield this.createEffectsSDKTrackProcessor(Vn.CameraPreview)),c(this,Vl,!0,"f"),a(this,ql,"f").info("Effects SDK initialized",{case:"initEffectsSDK"}),e(!0)}catch(e){a(this,ql,"f").error("Failed to initilize Effects SDK",{error:e,case:"initEffectsSDK"}),t(e)}}));return new Promise(((t,r)=>{if(!window.tsvb)return a(this,ql,"f").info("Effects SDK tsvb-web.js is not ready, waiting",{case:"initEffectsSDK"}),void window.addEventListener("load",(()=>e(t,r)));e(t,r)}))}createEffectsSDKTrackProcessor(e){return o(this,void 0,void 0,(function*(){if(e){const t=a(this,Hl,"f").get(e);if(t)return t}if(!a(this,Ul,"f"))throw a(this,ql,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Error("Effects SDK config not provided");const t=new Bl({loggerFactory:this.loggerFactory,customerId:a(this,Ul,"f").customerId});return yield t.init(),a(this,ql,"f").info("Track effects processor initialized",{trackLabel:e}),t}))}static getVideoTrackTransformParams(e){const t=e.getSettings();return{width:t.width||Dl.width,height:t.height||Dl.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:Dl.width},height:{max:Dl.height}},encoderConfig:(null==e?void 0:e.videoEncoderConfig)||{encodings:Tl}}}static getCameraVideoTrackParams(e){var t;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:24},width:{max:Dl.width},height:{max:Dl.height}},encoderConfig:(null==e?void 0:e.encoderConfig)||{encodings:Pl}}}createDevice(){const e=(e=>{const t=null!=e?e:null===navigator||void 0===navigator?void 0:navigator.userAgent;if(!t)return;const r=Nn.getParser(t);return r.satisfies({"yandex browser":">=23.7"})?"Chrome111":r.satisfies({"yandex browser":">=22"})?"Chrome74":void 0})();return a(this,ql,"f").debug("Creating a media device",{handlerName:null!=e?e:"not specified"}),new Gn.Device({handlerName:e})}};ql=new WeakMap,Ul=new WeakMap,zl=new WeakMap,Vl=new WeakMap,Hl=new WeakMap,Kl=n([ot(),i(0,ct(zn.Config)),i(1,ct(zn.LoggerFactory)),i(2,ct(zn.AudioTrackFactory)),i(3,ct(zn.VideoTrackFactory)),i(4,ct(zn.MediaStreamTrackManager)),s("design:paramtypes",[wt,Function,Function,Function,$l])],Kl);var Gl=Kl;let Jl=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)}};Jl=n([ot()],Jl);class Ql extends Ln{constructor(e,t,r){super(e,null!=t?t:"something_went_wrong",r)}}const Yl=Object.create(null);Yl.open="0",Yl.close="1",Yl.ping="2",Yl.pong="3",Yl.message="4",Yl.upgrade="5",Yl.noop="6";const Zl=Object.create(null);Object.keys(Yl).forEach((e=>{Zl[Yl[e]]=e}));const Xl={type:"error",data:"parser error"},ep="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),tp="function"==typeof ArrayBuffer,rp=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,np=({type:e,data:t},r,n)=>ep&&t instanceof Blob?r?n(t):ip(t,n):tp&&(t instanceof ArrayBuffer||rp(t))?r?n(t):ip(new Blob([t]),n):n(Yl[e]+(t||"")),ip=(e,t)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(",")[1];t("b"+(e||""))},r.readAsDataURL(e)};function sp(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let op;const ap="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",cp="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<ap.length;e++)cp[ap.charCodeAt(e)]=e;const dp="function"==typeof ArrayBuffer,up=(e,t)=>{if("string"!=typeof e)return{type:"message",data:pp(e,t)};const r=e.charAt(0);if("b"===r)return{type:"message",data:lp(e.substring(1),t)};return Zl[r]?e.length>1?{type:Zl[r],data:e.substring(1)}:{type:Zl[r]}:Xl},lp=(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=cp[e.charCodeAt(t)],n=cp[e.charCodeAt(t+1)],i=cp[e.charCodeAt(t+2)],s=cp[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 pp(r,t)}return{base64:!0,data:e}},pp=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,hp=String.fromCharCode(30);function fp(){return new TransformStream({transform(e,t){!function(e,t){ep&&e.data instanceof Blob?e.data.arrayBuffer().then(sp).then(t):tp&&(e.data instanceof ArrayBuffer||rp(e.data))?t(sp(e.data)):np(e,!1,(e=>{op||(op=new TextEncoder),t(op.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 mp;function gp(e){return e.reduce(((e,t)=>e+t.length),0)}function vp(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 yp(e){if(e)return function(e){for(var t in yp.prototype)e[t]=yp.prototype[t];return e}(e)}yp.prototype.on=yp.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},yp.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},yp.prototype.off=yp.prototype.removeListener=yp.prototype.removeAllListeners=yp.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},yp.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},yp.prototype.emitReserved=yp.prototype.emit,yp.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},yp.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 _p=bp.setTimeout,Sp=bp.clearTimeout;function kp(e,t){t.useNativeTimers?(e.setTimeoutFn=_p.bind(bp),e.clearTimeoutFn=Sp.bind(bp)):(e.setTimeoutFn=bp.setTimeout.bind(bp),e.clearTimeoutFn=bp.clearTimeout.bind(bp))}class Cp extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class Rp extends yp{constructor(e){super(),this.writable=!1,kp(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new Cp(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=up(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 Pp="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Tp={};let Ep,Dp=0,Ip=0;function Mp(e){let t="";do{t=Pp[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function xp(){const e=Mp(+new Date);return e!==Ep?(Dp=0,Ep=e):e+"."+Mp(Dp++)}for(;Ip<64;Ip++)Tp[Pp[Ip]]=Ip;let Op=!1;try{Op="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(yb){}const Lp=Op;function Ap(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||Lp))return new XMLHttpRequest}catch(e){}if(!t)try{return new(bp[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function jp(){}const Fp=null!=new Ap({xdomain:!1}).responseType;class Np extends yp{constructor(e,t){super(),kp(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 Ap(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=Np.requestsCount++,Np.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=jp,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete Np.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(Np.requestsCount=0,Np.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Bp);else if("function"==typeof addEventListener){addEventListener("onpagehide"in bp?"pagehide":"unload",Bp,!1)}function Bp(){for(let e in Np.requests)Np.requests.hasOwnProperty(e)&&Np.requests[e].abort()}const Wp="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),qp=bp.WebSocket||bp.MozWebSocket,Up="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const zp={websocket:class extends Rp{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=Up?{}: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=Up?new qp(e,t,r):t?new qp(e,t):new qp(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;np(r,this.supportsBinary,(e=>{try{this.ws.send(e)}catch(e){}n&&Wp((()=>{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]=xp()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!qp}},webtransport:class extends Rp{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){mp||(mp=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(gp(r)<1)break;const e=vp(r,1);s=128==(128&e[0]),i=127&e[0],n=i<126?3:126===i?1:2}else if(1===n){if(gp(r)<2)break;const e=vp(r,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),n=3}else if(2===n){if(gp(r)<8)break;const e=vp(r,8),t=new DataView(e.buffer,e.byteOffset,e.length),s=t.getUint32(0);if(s>Math.pow(2,21)-1){a.enqueue(Xl);break}i=s*Math.pow(2,32)+t.getUint32(4),n=3}else{if(gp(r)<i)break;const e=vp(r,i);a.enqueue(up(s?e:mp.decode(e),t)),n=0}if(0===i||i>e){a.enqueue(Xl);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=fp();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&&Wp((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends Rp{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=Fp&&!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(hp),n=[];for(let e=0;e<r.length;e++){const i=up(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)=>{np(e,!1,(e=>{n[s]=e,++i===r&&t(n.join(hp))}))}))})(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]=xp()),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 Np(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}}},Vp=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Hp=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function $p(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=Vp.exec(e||""),s={},o=14;for(;o--;)s[Hp[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 Kp extends yp{constructor(e,t={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=$p(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=$p(t.host).host),kp(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 zp[e](r)}open(){let e;if(this.opts.rememberUpgrade&&Kp.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;Kp.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;Kp.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",Kp.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){Kp.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}}Kp.protocol=4;const Gp="function"==typeof ArrayBuffer,Jp=Object.prototype.toString,Qp="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Jp.call(Blob),Yp="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Jp.call(File);function Zp(e){return Gp&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||Qp&&e instanceof Blob||Yp&&e instanceof File}function Xp(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(Xp(e[t]))return!0;return!1}if(Zp(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return Xp(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&Xp(e[t]))return!0;return!1}function eh(e){const t=[],r=e.data,n=e;return n.data=th(r,t),n.attachments=t.length,{packet:n,buffers:t}}function th(e,t){if(!e)return e;if(Zp(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]=th(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]=th(e[n],t));return r}return e}function rh(e,t){return e.data=nh(e.data,t),delete e.attachments,e}function nh(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]=nh(e[r],t);else if("object"==typeof e)for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=nh(e[r],t));return e}const ih=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var sh;!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"}(sh||(sh={}));function oh(e){return"[object Object]"===Object.prototype.toString.call(e)}class ah extends yp{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===sh.BINARY_EVENT;r||t.type===sh.BINARY_ACK?(t.type=r?sh.EVENT:sh.ACK,this.reconstructor=new ch(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!Zp(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===sh[r.type])throw new Error("unknown packet type "+r.type);if(r.type===sh.BINARY_EVENT||r.type===sh.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(!ah.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 sh.CONNECT:return oh(t);case sh.DISCONNECT:return void 0===t;case sh.CONNECT_ERROR:return"string"==typeof t||oh(t);case sh.EVENT:case sh.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===ih.indexOf(t[0]));case sh.ACK:case sh.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ch{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=rh(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 sh},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==sh.EVENT&&e.type!==sh.ACK||!Xp(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===sh.EVENT?sh.BINARY_EVENT:sh.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==sh.BINARY_EVENT&&e.type!==sh.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=eh(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}},Decoder:ah});function uh(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const lh=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class ph extends yp{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=[uh(e,"open",this.onopen.bind(this)),uh(e,"packet",this.onpacket.bind(this)),uh(e,"error",this.onerror.bind(this)),uh(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(lh.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:sh.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:sh.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 sh.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 sh.EVENT:case sh.BINARY_EVENT:this.onevent(e);break;case sh.ACK:case sh.BINARY_ACK:this.onack(e);break;case sh.DISCONNECT:this.ondisconnect();break;case sh.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:sh.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:sh.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 hh(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}hh.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)},hh.prototype.reset=function(){this.attempts=0},hh.prototype.setMin=function(e){this.ms=e},hh.prototype.setMax=function(e){this.max=e},hh.prototype.setJitter=function(e){this.jitter=e};class fh extends yp{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,kp(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 hh({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 Kp(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const n=uh(t,"open",(function(){r.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},s=uh(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(uh(e,"ping",this.onping.bind(this)),uh(e,"data",this.ondata.bind(this)),uh(e,"error",this.onerror.bind(this)),uh(e,"close",this.onclose.bind(this)),uh(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){Wp((()=>{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 ph(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 mh={};function gh(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=$p(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=mh[i]&&s in mh[i].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?a=new fh(n,t):(mh[i]||(mh[i]=new fh(n,t)),a=mh[i]),r.query&&!t.query&&(t.query=r.queryKey),a.socket(r.path,t)}var vh,yh,bh,wh;Object.assign(gh,{Manager:fh,Socket:ph,io:gh,connect:gh});let _h=class{constructor(e){this.reconnectingAttempt=0,this.isConnected=!1,this._observer=new _t,vh.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"},yh.set(this,100),bh.set(this,!1),wh.set(this,8e3),c(this,vh,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=gh(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($n.Connect,(()=>{const e=this.reconnectingAttempt?$n.Reconnected:$n.Connected;this.isConnected=!0,this.setReconnectingAttempt(0),a(this,vh,"f").debug(`connection.on('${$n.Connect}')`,{connectionId:r.id,recovered:r.recovered}),this.observer.safeEmit($n.State,{state:e})})),r.on($n.ConnectError,(e=>{this.connectionError=e,a(this,vh,"f").error(`connection.on('${$n.ConnectError}')`,{error:e}),this.observer.safeEmit($n.State,{state:$n.Error,error:e}),this.reconnectingAttempt>a(this,yh,"f")&&(r.disconnect(),this.observer.safeEmit($n.State,{state:$n.Disconnected,code:"server.disconnect"}))})),r.on($n.Disconnect,(e=>{this.isConnected=!1,this.setReconnectingAttempt(0),this.disconnectReason=e,a(this,vh,"f").info(`connection.on('${$n.Disconnect}')`,{reason:e});const t=this.getDisconnectReasonCode(e);"server.disconnect"===t&&r.disconnect(),this.observer.safeEmit($n.State,{state:$n.Disconnected,code:t})})),r.io.on($n.ReconnectAttempt,(e=>{this.setReconnectingAttempt(e),a(this,vh,"f").info(`connection.on('${$n.ReconnectAttempt}')`,{attempt:e}),this.observer.safeEmit($n.State,{state:$n.Reconnecting})})),r.io.on($n.Reconnect,(()=>{a(this,vh,"f").debug(`connection.on('${$n.Reconnect}')`,{connectionId:r.id}),this.observer.safeEmit($n.State,{state:$n.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(a(this,wh,"f")).emit(e,t,((t,i)=>{if(t){const r=Mn.includes(e);return"operation has timed out"===(null==t?void 0:t.message)&&!a(this,bh,"f")&&r&&(c(this,bh,!0,"f"),this.observer.safeEmit($n.State,{state:$n.BufferingStart})),void n(t)}i&&i.error?("Need join to channel first"===i.error&&this.observer.safeEmit($n.State,{code:$n.NeedToJoinFirst}),n(new Ql(i.error,i.errorCode,Object.assign({},i)))):(a(this,bh,"f")&&(c(this,bh,!1,"f"),this.observer.safeEmit($n.State,{state:$n.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}};vh=new WeakMap,yh=new WeakMap,bh=new WeakMap,wh=new WeakMap,_h=n([ot(),i(0,ct(zn.LoggerFactory)),s("design:paramtypes",[Function])],_h);var Sh,kh,Ch,Rh=_h;let Ph=class{constructor(e,t,r,n){this.state=e,this.myPeer=t,this.socket=n,Sh.set(this,{send:void 0,recv:void 0}),kh.set(this,void 0),Ch.set(this,void 0),c(this,Ch,r("Network"),"f"),c(this,kh,new _t,"f"),this.socket.observer.on($n.State,(e=>{a(this,kh,"f").safeEmit(xn,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 a(this,kh,"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 o(this,void 0,void 0,(function*(){this.stopRestartIceAtempts(),this.removeEventListeners()}))}closeRemoteProducer(e){return o(this,void 0,void 0,(function*(){yield this.socket.request(cn,{peerId:this.myPeer.id,producerId:e})}))}closeSendTransport(){var e;return o(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):a(this,Ch,"f").warn("closeSendTransport()",{message:"No available send transport"})}))}closeReceiveTransport(){var e;return o(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):a(this,Ch,"f").warn("closeReceiveTransport()",{message:"No available receive transport"})}))}closeTransport(e){return o(this,void 0,void 0,(function*(){try{e.close(),a(this,Ch,"f").debug("closeTransport()",{transportId:e.id,direction:e.direction})}catch(t){a(this,Ch,"f").error("closeTransport()",{error:t,transportId:e.id,direction:e.direction})}}))}createSendTransport(e){return o(this,void 0,void 0,(function*(){if(this.sendTransport)throw a(this,Ch,"f").warn("createSendTransport()",{message:"Send transport already exists"}),new Ln("Send transport already exists","already_exists");const t=yield this.socket.request(Rn,{sctpCapabilities:e.sctpCapabilities,localDirection:"send"}),r=e.createSendTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return a(this,Ch,"f").debug("createSendTransport()",{transportId:r.id,direction:r.direction}),this.sendTransport=r,this.subscribeCommonTransportEvents(r),r}))}createRecvTransport(e){return o(this,void 0,void 0,(function*(){if(this.receiveTransport)throw a(this,Ch,"f").warn("createReceiveTransport()",{message:"Receive transport already exists"}),new Ln("Receive transport already exists","already_exists");const t=yield this.socket.request(Rn,{localDirection:"receive"}),r=e.createRecvTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return a(this,Ch,"f").debug("createReceiveTransport()",{transportId:r.id,direction:r.direction}),this.receiveTransport=r,this.subscribeCommonTransportEvents(r),r}))}getIceParameters(e){return o(this,void 0,void 0,(function*(){const t=yield this.socket.request(In,{transportId:e.id}),{error:r}=t;if(r)throw new Error(r);const{iceParameters:n}=t;return a(this,Ch,"f").debug("getIceParameters()",{iceParameters:n}),n}))}restartIce(e){return o(this,void 0,void 0,(function*(){try{const t=yield this.getIceParameters(e);yield e.restartIce({iceParameters:t}),a(this,Ch,"f").info("restartIce completed",{iceParameters:t})}catch(e){a(this,Ch,"f").error("restartIce error",{error:e})}}))}createConsumer({producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i}){var s;return o(this,void 0,void 0,(function*(){const o=this.receiveTransport;if(!o)throw a(this,Ch,"f").error("createConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer");let c;a(this,Ch,"f").debug("createConsumer()",{producerId:e});try{c=yield this.socket.request(gn,{producerId:e,transportId:o.id,rtpCapabilities:t,appData:{peerId:this.myPeer.id,appId:r,channelId:n},producerPeerId:i})}catch(o){if(!(o instanceof Ql&&(null===(s=o.meta)||void 0===s?void 0:s.existedConsumer)))throw a(this,Ch,"f").error("Failed to get consumer options",{producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i,error:cr(o)}),new Error("Failed to create consumer");c=o.meta.existedConsumer}const d=yield o.consume(c),{producerPaused:u}=c;return u&&d.pause(),a(this,Ch,"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 o(this,void 0,void 0,(function*(){const i=this.receiveTransport;if(!i)throw a(this,Ch,"f").error("createDataConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer");a(this,Ch,"f").debug("createDataConsumer()",{producerId:e});const s=yield this.socket.request(vn,{ordered:n,dataProducerId:e,transportId:i.id,appData:{peerId:this.myPeer.id,producerId:e,appId:t,channelId:r}}),o=yield i.consumeData(s);return a(this,Ch,"f").debug("Data consumer created",{consumerId:o.id}),o}))}closeRemoteConsumer(e){return o(this,void 0,void 0,(function*(){return this.socket.request(yn,{peerId:this.myPeer.id,consumerId:e})}))}resumeRemoteConsumer(e){return o(this,void 0,void 0,(function*(){return this.socket.request(wn,{consumerId:e})}))}pauseRemoteProducer(e){return o(this,void 0,void 0,(function*(){return this.socket.request(dn,{producerId:e})}))}pauseRemoteConsumer(e){return o(this,void 0,void 0,(function*(){return this.socket.request(bn,{consumerId:e})}))}updatePeerAppData({peerId:e,appData:t}){return o(this,void 0,void 0,(function*(){return this.socket.request(fr,{peerId:e,appData:t})}))}getAudioObserverProducer(){return o(this,void 0,void 0,(function*(){return this.socket.request(br)}))}getGeneralDataProducer(){return o(this,void 0,void 0,(function*(){return this.socket.request(wr)}))}getChannelStateSyncDataProducer(){return o(this,void 0,void 0,(function*(){return this.socket.request(_r)}))}createDataProducer(e){var t;return o(this,void 0,void 0,(function*(){return this.socket.request(En,{transportId:null===(t=this.sendTransport)||void 0===t?void 0:t.id,label:e})}))}getTransportsStateInfo(){return o(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 o(this,void 0,void 0,(function*(){return this.socket.request(pr,{role:e})}))}getParsedTransportStats(e){return o(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 a(this,Ch,"f").warn("getParsedTransportStats()",{error:e})}else a(this,Ch,"f").debug("getParsedTransportStats()",{message:"Transport is missing"})}))}logTransportDetails(e){var t,r;return o(this,void 0,void 0,(function*(){let n;try{n=yield e.getStats()}catch(t){return void a(this,Ch,"f").error("Failed to log detailed WebRTC transport stats",{error:cr(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:[],c=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==c?void 0:c.address,candidateType:null==c?void 0:c.candidateType,foundation:null==c?void 0:c.foundation,networkType:null==c?void 0:c.networkType,isRemote:null==c?void 0:c.isRemote,port:null==c?void 0:c.port,protocol:null==c?void 0:c.protocol,relatedAddress:null==c?void 0:c.relatedAddress,relatedPort:null==c?void 0:c.relatedPort,transportId:null==c?void 0:c.transportId,relayProtocol:null==c?void 0:c.relayProtocol,url:null==c?void 0:c.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)),a(this,Ch,"f").info("Detailed WebRTC transport stats",u)}catch(t){a(this,Ch,"f").error("Failed to log detailed WebRTC transport stats",{error:cr(t),transportId:e.id,reason:"-"})}}))}stopRestartIceAtempts(){clearInterval(a(this,Sh,"f").send),clearInterval(a(this,Sh,"f").recv)}subscribeCommonTransportEvents(e){e.on("connect",(({dtlsParameters:t},r,n)=>o(this,void 0,void 0,(function*(){try{yield this.socket.request(Pn,{transportId:e.id,dtlsParameters:t}),r(),a(this,Ch,"f").debug(`${e.direction}Transport.connect()`,{transportId:e.id,dtlsRole:t.role}),setTimeout((()=>this.logTransportDetails(e)),1500)}catch(t){a(this,Ch,"f").error(`${e.direction}Transport.on('connect')`,{error:t}),n(t)}})))),e.on("produce",((t,r,n)=>o(this,void 0,void 0,(function*(){try{const{id:n}=yield this.socket.request(Tn,{transportId:e.id,kind:t.kind,rtpParameters:t.rtpParameters,appData:t.appData});r({id:n}),a(this,Ch,"f").debug(`${e.direction}Transport.produce()`,{producerId:n,transportId:e.id,kind:t.kind})}catch(r){a(this,Ch,"f").error(`${e.direction}Transport.produce()`,{error:r,transportId:e.id,kind:t.kind}),n(r)}})))),e.on("connectionstatechange",(t=>{if(a(this,Ch,"f").info(`${e.direction}Transport.state`,{state:t}),["closed","connected"].includes(t))return a(this,kh,"f").safeEmit(On,{state:t,direction:e.direction}),a(this,Sh,"f")[e.direction]&&(a(this,Ch,"f").debug("Stop receiveTransport.restartIce() retries",{recvTransportId:e.id}),clearInterval(a(this,Sh,"f")[e.direction]),a(this,Sh,"f")[e.direction]=void 0,"connected"===t&&a(this,kh,"f").safeEmit(On,{state:"reconnected",direction:e.direction})),void("connected"===t&&setTimeout((()=>this.logTransportDetails(e)),1500));if(a(this,kh,"f").safeEmit(On,{state:t,direction:e.direction}),["disconnected","failed"].includes(t)){if(a(this,Sh,"f")[e.direction])return;"failed"===t&&(a(this,Ch,"f").debug(`${e.direction}Transport.restartIce()`,{recvTransportId:e.id}),this.restartIce(e)),a(this,Sh,"f")[e.direction]=setInterval((()=>{this.restartIce(e),a(this,Ch,"f").debug(`${e.direction}Transport.restartIce() attempt`,{recvTransportId:e.id})}),5e3)}})),e.on("icegatheringstatechange",(t=>{a(this,Ch,"f").info("icegatheringstatechange",{state:t,transportId:e.id,transportDirection:e.direction})}))}};Sh=new WeakMap,kh=new WeakMap,Ch=new WeakMap,Ph=n([ot(),i(0,ct(zn.CallState)),i(1,ct(zn.MyPeer)),i(2,ct(zn.LoggerFactory)),i(3,ct(zn.SocketIO)),s("design:paramtypes",[Kn,Jl,Function,Rh])],Ph);var Th=Ph;let Eh=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){const t=this.get(e);t&&(t.tracks.forEach((e=>e.close())),t.reset(),this.delete(e),this.clientEventEmitter.safeEmit(Mr,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(){this.peersStorage.forEach((e=>e.reset())),this.peersStorage.clear()}load(e){return o(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(Ir,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(Wr,{peer:e}))}};Eh=n([ot(),i(0,ct(zn.MyPeer)),i(1,ct(zn.Network)),i(2,ct(zn.PeerFactory)),i(3,ct(zn.ClientEventEmitter)),s("design:paramtypes",[Jl,Th,Function,_t])],Eh);const Dh=e=>null!==e&&"object"==typeof e,Ih=(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=Dh(n)&&Dh(s);(o&&!Ih(n,s)||!o&&n!==s)&&(i=!1)})),i};var Mh,xh,Oh,Lh;let Ah=class{constructor(){Mh.set(this,[]),xh.set(this,new Map),Oh.set(this,new Set),Lh.set(this,!1)}subscribeToSocket(e){a(this,Oh,"f").has(e)||(e.onAny(((e,...t)=>{this.push(e,t)})),a(this,Oh,"f").add(e))}subscribeToDataChannel(e){e.on("message",((...e)=>{this.push("message",e)}))}on(e,t){var r;a(this,xh,"f").has(e)?null===(r=a(this,xh,"f").get(e))||void 0===r||r.push(t):a(this,xh,"f").set(e,[t])}removeListener(e){a(this,xh,"f").delete(e)}removeAllListeners(e,t){t&&a(this,Oh,"f").has(t)&&(t.offAny(),a(this,Oh,"f").delete(t)),e.forEach((e=>{a(this,xh,"f").delete(e)}))}push(e,t){a(this,Mh,"f").push({event:e,args:t}),this.process()}process(){if(!a(this,Lh,"f"))for(;a(this,Mh,"f").length>0;){const e=a(this,Mh,"f").shift();this.emit(e.event,e.args)}}emit(e,t){(a(this,xh,"f").get(e)||[]).forEach((e=>{e(...t)}))}pause(){c(this,Lh,!0,"f")}size(){return a(this,Mh,"f").length}resume(){c(this,Lh,!1,"f"),this.process()}};Mh=new WeakMap,xh=new WeakMap,Oh=new WeakMap,Lh=new WeakMap,Ah=n([ot()],Ah);var jh,Fh=Ah;let Nh=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,jh.set(this,void 0),c(this,jh,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(zr,(()=>o(this,void 0,void 0,(function*(){yield this.debouncedRestoreState()}))))}restoreState(){return o(this,void 0,void 0,(function*(){const e={missingPeers:[],removedPeers:[],missingProducers:[],removedProducers:[],fixedProducersState:[],fixedConsumersState:[],restoredAppDataPeers:[]};try{if(!this.network.isSocketConnectionActive)return a(this,jh,"f").info("Connection inactive, skipping restore local state",{case:"restoreLocalState"}),e;this.eventsQueue.pause(),a(this,jh,"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 a(this,jh,"f").info("Failed to restore local state",{case:"restoreLocalState",error:cr(t)}),e}finally{a(this,jh,"f").info("Resume events after re-syncing local peers",{case:"restoreLocalState",accumulatedEventsAmount:this.eventsQueue.size()}),this.eventsQueue.resume()}}))}restoreRemoteProducersState(e){return o(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=>o(this,void 0,void 0,(function*(){yield this.network.closeRemoteProducer(e.id),r.producers.delete(e.id),t.removedProducers.push(e.id),a(this,jh,"f").info("Unnecessary local producer closed",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId})})))));const c=n.producers.filter((e=>!!i.find((t=>t.isPaused&&t.isPaused!==e.paused))));return yield Promise.all(c.map((e=>o(this,void 0,void 0,(function*(){yield this.network.pauseRemoteProducer(e.id),t.fixedProducersState.push(e.id),a(this,jh,"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),a(this,jh,"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),a(this,jh,"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 a(this,jh,"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)})),a(this,jh,"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(cn,t),r.push(t.id),a(this,jh,"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(an,t),r.missingProducers.push(t.id),void a(this,jh,"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?Qr:Yr;e.observer.safeEmit(n,{producerId:i.id,kind:i.kind,label:i.label,paused:i.paused}),r.fixedProducersState.push(t.id),a(this,jh,"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?bn:wn;e.observer.safeEmit(o,n),r.fixedConsumersState.push(n),a(this,jh,"f").info("Consumer state fixed",{case:"restoreLocalState",consumerId:n,consumerProducerId:t.id,consumerProducerPeerId:t.peerId})}})),r}restoreAppData(e,t){return!Ih(e.appData,t.appData)&&(e.observer.emit(fr,t.appData),a(this,jh,"f").info("Application data restored",{case:"restoreLocalState",peerId:e.id,appData:t.appData}),!0)}};jh=new WeakMap,Nh=n([ot(),i(0,ct(zn.Network)),i(1,ct(zn.Media)),i(2,ct(zn.MyPeer)),i(3,ct(zn.EventsQueue)),i(4,ct(zn.ClientEventEmitter)),i(5,ct(zn.Peers)),i(6,ct(zn.LoggerFactory)),s("design:paramtypes",[Th,Gl,Jl,Fh,_t,Eh,Function])],Nh);var Bh,Wh=Nh;function qh(e){return{id:e.id,appId:e.appId,role:e.role,groups:e.groups,producePermissions:e.producePermissions}}let Uh=class{constructor(e,t,r,n,i,s){this.eventsQueue=e,this.network=t,this.socket=r,this.peers=n,this.clientEventEmitter=i,Bh.set(this,void 0),c(this,Bh,s("ChannelEvents"),"f")}handleDataChannelEvent(e){try{const{event:t,data:r}=JSON.parse(e);this.doHandleDataChannelEvent(t,r)}catch(t){a(this,Bh,"f").error("Failed to handle data channel event",{error:t,payload:e})}}doHandleDataChannelEvent(e,t){e===fr&&this.handlePeerAppDataUpdate(t)}subscribeToEvents(){const{connection:e}=this.socket;if(!e)throw a(this,Bh,"f").error("subscribeToEvents()",{error:"Socket connection not initialized"}),new Error("Socket connection not initialized");this.eventsQueue.subscribeToSocket(e),this.eventsQueue.on(ur,(e=>{this.clientEventEmitter.safeEmit(Dr,e),a(this,Bh,"f").debug("New channel event",{event:e})})),this.eventsQueue.on(lr,(e=>{const t=this.peers.add(e);a(this,Bh,"f").debug("Peer joined to the channel",{peer:qh(t)})})),this.eventsQueue.on(hr,(e=>{this.peers.remove(e),a(this,Bh,"f").debug("Peer left the channel",{peerId:e})})),this.eventsQueue.on(vr,(e=>{this.clientEventEmitter.safeEmit(xr,e),a(this,Bh,"f").info("Notify the channel that activity confirmation is required",e)})),this.eventsQueue.on(yr,(e=>{this.clientEventEmitter.safeEmit(Lr,e),a(this,Bh,"f").info("Notify the channel that it has disconnected due to the activity confirmation expiring",e)})),this.eventsQueue.on(gr,(e=>{this.clientEventEmitter.safeEmit(Or,e),a(this,Bh,"f").info("Notify the channel that the activity has been acquired.",e)})),this.eventsQueue.on(Sr,(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)})),a(this,Bh,"f").info("Peers changed produce permissions",{groups:r,producePermissions:t})})),this.eventsQueue.on(Cr,(e=>{const{peerId:t,producePermissions:r}=e,n=this.peers.get(t);n&&n.handleProducePermissionsChange(r)})),this.eventsQueue.on(kr,(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)})),a(this,Bh,"f").info("Peers deleted produce permissions",{groups:r,producePermissions:t})})),this.eventsQueue.on(Tr,(e=>{const{peerId:t,groups:r}=e,n=this.peers.get(t);n&&n.handleGroupsChange(r)}))}removeEventListeners(){if(!this.eventsQueue)return;const e=[ur,lr,hr,vr,yr,gr,fr,Sr],{connection:t}=this.socket;this.eventsQueue.removeAllListeners(e,t)}handlePeerAppDataUpdate({peerId:e,appData:t}){const r=this.peers.get(e);r&&r.observer.emit(fr,t)}reset(){this.removeEventListeners()}};Bh=new WeakMap,Uh=n([ot(),i(0,ct(zn.EventsQueue)),i(1,ct(zn.Network)),i(2,ct(zn.SocketIO)),i(3,ct(zn.Peers)),i(4,ct(zn.ClientEventEmitter)),i(5,ct(zn.LoggerFactory)),s("design:paramtypes",[Fh,Th,Rh,Eh,_t,Function])],Uh);var zh=Uh,Vh={},Hh=u&&u.__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(Vh,"__esModule",{value:!0});var $h=Vh.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 Hh(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 Hh(this,void 0,void 0,(function*(){const e=this.pendingTasks[0];e&&(yield this.executeTask(e),this.pendingTasks.shift(),this.next())}))}executeTask(e){return Hh(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 Kh=new Error("request for lock canceled");var Gh=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 Jh{constructor(e,t=Kh){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 Gh(this,void 0,void 0,(function*(){const[t,r]=yield this.acquire();try{return yield e(t)}finally{r()}}))}waitForUnlock(){return Gh(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 Qh=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 Yh{constructor(e){this._semaphore=new Jh(1,e)}acquire(){return Qh(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 Zh=e=>"rtx"!==e.mimeType;var Xh,ef,tf,rf,nf,sf,of,af,cf,df,uf,lf,pf,hf,ff,mf,gf,vf,yf,bf,wf,_f,Sf;class kf{constructor({track:e,statsHandler:t}){Xh.set(this,void 0),ef.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return a(this,Xh,"f")}get audioWebRTCStats(){return a(this,ef,"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){c(this,Xh,e,"f")}setAudioWebRTCStats(e){c(this,ef,e,"f")}}Xh=new WeakMap,ef=new WeakMap;class Cf{constructor(e){tf.set(this,void 0),rf.set(this,void 0),this.encoderConfig={},this.label=Vn.Unknown,nf.set(this,void 0),sf.set(this,void 0),of.set(this,void 0),af.set(this,void 0),cf.set(this,void 0),df.set(this,!1),uf.set(this,void 0),lf.set(this,void 0),pf.set(this,void 0),hf.set(this,!0),ff.set(this,new Yh),mf.set(this,void 0),gf.set(this,void 0);const{mediaStreamTrack:t,internalEventEmitter:r,constraints:n,mediaStreamTrackManager:i,media:s,myPeer:o,network:a,socket:d,loggerFactory:u,loggerNamespace:l,statsHandler:p}=e;c(this,tf,t,"f"),c(this,cf,r,"f"),c(this,uf,n,"f"),c(this,lf,i,"f"),c(this,pf,new _t,"f"),this.logger=u(l),c(this,sf,s,"f"),c(this,nf,o,"f"),c(this,of,a,"f"),c(this,af,d,"f"),c(this,gf,p,"f"),c(this,mf,new kf({track:t,statsHandler:p}),"f")}get videoWebRTCStats(){return a(this,mf,"f").videoWebRTCStats}get audioWebRTCStats(){return a(this,mf,"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 a(this,pf,"f")}get mediaStreamTrack(){return a(this,tf,"f")}get originalTrack(){return a(this,rf,"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 a(this,cf,"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||c(this,hf,e,"f")}getProducer(){return this.producer}setOriginalTrack(){c(this,rf,this.mediaStreamTrack,"f")}closeProducer(e=!0){return o(this,void 0,void 0,(function*(){if(this.producer){try{yield a(this,of,"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 o(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(){a(this,rf,"f")&&(a(this,rf,"f").stop(),c(this,rf,void 0,"f"))}produce({encodings:e,codecOptions:t,preferredCodec:r,transformParams:n,keyFrameRequestDelay:i}){var s;return o(this,void 0,void 0,(function*(){if(!a(this,nf,"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 a(this,af,"f").request(Er);const{rtpCapabilities:{codecs:o}}=a(this,sf,"f").mediasoupDevice,c=null==o?void 0:o.find((e=>e.mimeType.toLowerCase()===`${this.kind}/${r}`)),d=0,u=this.prepareProducerEncodings({codec:c,encodings:null!=e?e:[],maxSpatialLayer:(null!=e?e:[]).length-1}),l={trackTransformParams:n,peerId:String(a(this,nf,"f").id),label:this.getLabel(),maxSpatialLayer:d,encodings:u,codecOptions:t,preferredCodec:r,codec:c,keyFrameRequestDelay:i},p=yield null===(s=a(this,of,"f").sendTransport)||void 0===s?void 0:s.produce({track:this.mediaStreamTrack,encodings:u,codecOptions:t,codec:c,stopTracks:!1,disableTrackOnPause:!0,zeroRtpOnPause:!0,appData:l});if(!p)return;const h=p.rtpSender,f=()=>/Safari/i.test(navigator.userAgent);if(e&&h&&f()){const t=h.getParameters();e.forEach((({maxBitrate:e,scaleResolutionDownBy:r},n)=>{t.encodings[n]&&(t.encodings[n].maxBitrate=e,t.encodings[n].scaleResolutionDownBy=r)})),yield h.setParameters(t)}this.setProducer(p),"video"===this.kind&&(e&&h&&c&&Wn(c.mimeType)&&!f()?yield h.setParameters(Object.assign(Object.assign({},h.getParameters()),{encodings:this.prepareProducerEncodings({encodings:e,codec:c,maxSpatialLayer:d})})):yield p.setMaxSpatialLayer(d),yield a(this,af,"f").request(fn,{producerId:p.id,maxSpatialLayer:d})),"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 o(this,void 0,void 0,(function*(){yield this.produce({}),this.internalEventEmitter.emit(Kr.trackProduced,this)}))}unpublish(e=!0){return o(this,void 0,void 0,(function*(){try{e&&this.stopMediaStreamTrack(),this.internalEventEmitter.emit(Kr.trackUnproduced,this),this.producer&&(yield this.closeProducer()),c(this,df,!0,"f"),this.logger.debug("unpublish()",{track:this.logCtx})}catch(e){this.logger.error("unpublish()",{error:e})}}))}pauseRemoteProducer(e){return o(this,void 0,void 0,(function*(){return a(this,af,"f").request(dn,{producerId:e})}))}resumeRemoteProducer(e){return o(this,void 0,void 0,(function*(){return a(this,af,"f").request(un,{producerId:e})}))}mute(e){return o(this,void 0,void 0,(function*(){yield a(this,ff,"f").waitForUnlock();const t=yield a(this,ff,"f").acquire();if(this.producer)try{if(this.producer.pause(),this.logger.debug("pause()",{track:this.logCtx}),a(this,hf,"f"))return null==e||e(),a(this,tf,"f").stop(),this.stopOriginalTrack(),this.internalEventEmitter.emit(Kr.trackClosed,this),void(yield this.pauseRemoteProducer(this.producer.id));yield this.pauseRemoteProducer(this.producer.id),this.internalEventEmitter.emit(Kr.trackPaused,this)}catch(e){throw this.logger.error("pause()",{error:e,track:this.logCtx}),yield a(this,sf,"f").deleteTrack(this),this.internalEventEmitter.emit(Kr.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 o(this,void 0,void 0,(function*(){yield a(this,ff,"f").waitForUnlock();const e=yield a(this,ff,"f").acquire();if(this.producer)try{if(this.logger.debug("resume()",{track:this.logCtx}),a(this,hf,"f"))return yield this.reopenMediaStreamTrack(),yield this.resumeProducer(),void this.internalEventEmitter.emit(Kr.trackReopened,this);yield this.resumeProducer(),this.internalEventEmitter.emit(Kr.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 o(this,void 0,void 0,(function*(){const{width:e,height:t,frameRate:r,aspectRatio:n}=a(this,tf,"f").getSettings();return{trackId:a(this,tf,"f").id,readyState:a(this,tf,"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 o(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=>Zh(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 o(this,void 0,void 0,(function*(){try{c(this,tf,e,"f"),this.internalEventEmitter.emit(Kr.trackReopened,this),this.observer.safeEmit("track-changed",{track:e}),yield null===(t=this.producer)||void 0===t?void 0:t.replaceTrack({track:e}),c(this,mf,new kf({track:e,statsHandler:a(this,gf,"f")}),"f")}catch(e){this.logger.warn("replaceTrack()",{error:e})}}))}resumeProducer(){return o(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 o(this,void 0,void 0,(function*(){const t=yield a(this,lf,"f").createMediaStreamTrack({label:this.label,constraints:a(this,uf,"f")});c(this,tf,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&&Wn(r.mimeType)?[t[n]||t[0]]:t}getOutboundRTPStreamStats(){return new Promise(((e,t)=>{const r=(n=0)=>o(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()}))}}tf=new WeakMap,rf=new WeakMap,nf=new WeakMap,sf=new WeakMap,of=new WeakMap,af=new WeakMap,cf=new WeakMap,df=new WeakMap,uf=new WeakMap,lf=new WeakMap,pf=new WeakMap,hf=new WeakMap,ff=new WeakMap,mf=new WeakMap,gf=new WeakMap;class Rf extends Cf{constructor(e){super(e),this.transformParams={},vf.set(this,void 0),yf.set(this,void 0),bf.set(this,!1),wf.set(this,(()=>{})),c(this,yf,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(a(this,vf,"f"))}getEncoderConfig(){return this.encoderConfig}getCodecOptions(){return{videoGoogleStartBitrate:this.getEncoderConfig().videoGoogleStartBitrate||1e3}}getPreferredCodec(){const{preferredCodec:e}=this.getEncoderConfig();return e||(this.getLabel()===Vn.ScreenVideo?"vp8":"h264")}getEncodings(){return this.getEncoderConfig().encodings||Pl}setTransformParams(e){this.transformParams=e}setMaxSpatialLayer(e){return o(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 o(this,void 0,void 0,(function*(){if(!a(this,bf,"f")){c(this,bf,!0,"f");try{if(a(this,vf,"f"))return this.logger.debug("enableEffects()",{description:"Track is already processed"}),void c(this,bf,!1,"f");if("ended"===this.mediaStreamTrack.readyState)return void this.logger.warn("Track already ended",{case:"enableEffects"});const{media:e}=a(this,yf,"f");if(!e.effectsSDKInitialized)return void this.logger.warn("Effects SDK not initialized",{case:"enableEffects"});const t=Date.now();c(this,vf,yield e.createEffectsSDKTrackProcessor(this.getLabel()),"f"),this.setOriginalTrack();const r=yield a(this,vf,"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:cr(e)}),this.disableEffects().catch((e=>{this.logger.warn("Failed to this.disableEffects() in catch{}",{track:this.logCtx,error:cr(e)})})),a(this,wf,"f").call(this,e)}finally{c(this,bf,!1,"f")}}}))}disableEffects(){var e;return o(this,void 0,void 0,(function*(){try{if(!a(this,vf,"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=a(this,vf,"f"))||void 0===e||e.stopProcessing(),c(this,vf,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 o(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(Kr.trackProduced,this)}))}adjustEncodingPresetToCurrentMaxSpatialLayer(e){return o(this,void 0,void 0,(function*(){if(!Wn(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 o(this,void 0,void 0,(function*(){try{!this.isEffectsProcessing&&Object.keys(e).length>0&&(yield this.enableEffects()),null===(t=a(this,vf,"f"))||void 0===t||t.updateEffects(e)}catch(e){a(this,wf,"f").call(this,e)}}))}resetEffects(){var e;return o(this,void 0,void 0,(function*(){null===(e=a(this,vf,"f"))||void 0===e||e.updateEffects({})}))}setOnLoadModels(e){var t;null===(t=a(this,vf,"f"))||void 0===t||t.setOnLoadModels(e)}get modelsLoadProgress(){var e;return(null===(e=a(this,vf,"f"))||void 0===e?void 0:e.modelsLoadProgress)||0}pause(){return o(this,void 0,void 0,(function*(){yield this.mute((()=>{var e;a(this,vf,"f")&&(null===(e=a(this,vf,"f"))||void 0===e||e.stopProcessing(),c(this,vf,void 0,"f"))}))}))}setOnEffectError(e){c(this,wf,e,"f")}}vf=new WeakMap,yf=new WeakMap,bf=new WeakMap,wf=new WeakMap;let Pf=class{constructor(e,t,r,n,i,s,o,a,d){this.eventsQueue=e,this.media=t,this.network=r,this.socket=n,this.myPeer=i,this.internalEventEmitter=s,this.peers=o,this.clientEventEmitter=a,_f.set(this,void 0),Sf.set(this,new $h),c(this,_f,d("MediasoupEvents"),"f")}subscribeToEvents(){const{connection:e}=this.socket;if(!e)throw a(this,_f,"f").error("subscribeToEvents()",{error:"Socket connection not initialized"}),new Error("Socket connection not initialized");this.eventsQueue.subscribeToSocket(e),this.eventsQueue.on(cn,(e=>{const t=this.peers.get(e.peerId);t&&t.observer.safeEmit(cn,e)})),this.eventsQueue.on(an,(e=>{const t=this.peers.get(e.peerId);t&&t.observer.safeEmit(an,e)})),this.eventsQueue.on(yn,((e,t)=>{const r=this.peers.get(t);r&&r.observer.safeEmit(yn,e)})),this.eventsQueue.on(wn,((e,t)=>{const r=this.peers.get(t);r&&!r.isMe&&r.observer.safeEmit(wn,e)})),this.eventsQueue.on(bn,((e,t)=>{const r=this.peers.get(t);r&&!r.isMe&&r.observer.safeEmit(bn,e)})),this.eventsQueue.on(Sn,(({peerId:e,spatialLayer:t,temporalLayer:r,consumerId:n})=>{const i=this.peers.get(e);i&&!i.isMe&&i.observer.safeEmit(Sn,{consumerId:n,spatialLayer:t,temporalLayer:r})})),this.eventsQueue.on(mn,(({producerId:e,spatialLayer:t})=>o(this,void 0,void 0,(function*(){yield a(this,Sf,"f").push((()=>o(this,void 0,void 0,(function*(){yield this.handleProducerSetMaxSpatialLayer({producerId:e,spatialLayer:t})}))),mn)})))),this.eventsQueue.on(fn,(({peerId:e,producerId:t,spatialLayer:r})=>o(this,void 0,void 0,(function*(){const n=this.peers.get(e);n&&!n.isMe&&n.observer.safeEmit(fn,{peerId:e,producerId:t,spatialLayer:r})})))),this.eventsQueue.on(Dn,(({reason:e,transportId:t,direction:r,timeout:n})=>o(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&&(a(this,_f,"f").warn(Dn,{reason:e,transportId:t,direction:r,timeout:n}),this.clientEventEmitter.emit(Fr,{direction:r,reason:e}))})))),this.eventsQueue.on(ln,(({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(Qr,{producerId:n.id,kind:n.kind,label:n.label,paused:n.paused}))})),this.eventsQueue.on(pn,(({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(Yr,{producerId:n.id,kind:n.kind,label:n.label,paused:n.paused}))})),this.eventsQueue.on(hn,(({label:e})=>o(this,void 0,void 0,(function*(){const t=this.media.getTrack(e);t&&(t.stopMediaStreamTrack(),this.internalEventEmitter.safeEmit(Kr.trackClosed,t),this.clientEventEmitter.emit(Nr,{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(_n,{consumerId:r,score:n})}catch(t){a(this,_f,"f").error("Failed to handle consumer score event",{error:t,payload:e})}}removeEventListeners(){if(!this.eventsQueue)return;const e=[cn,an,yn,wn,bn,Sn,mn,fn,Dn,ln,pn,hn],{connection:t}=this.socket;this.eventsQueue.removeAllListeners(e,t)}reset(){this.removeEventListeners()}handleProducerSetMaxSpatialLayer({producerId:e,spatialLayer:t}){return o(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 a(this,_f,"f").warn("producerRequestMaxSpatialLayer()",{message:"Producer not found"});if(!(r instanceof Rf))return void a(this,_f,"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(fn,{producerId:e,maxSpatialLayer:n}),yield r.adjustEncodingPresetToCurrentMaxSpatialLayer(n)):a(this,_f,"f").debug("producerRequestMaxSpatialLayer()",{message:"Skip set max spatial layer",requestedSpatialLayer:n,currentMaxSpatialLayer:i})}))}};_f=new WeakMap,Sf=new WeakMap,Pf=n([ot(),i(0,ct(zn.EventsQueue)),i(1,ct(zn.Media)),i(2,ct(zn.Network)),i(3,ct(zn.SocketIO)),i(4,ct(zn.Network)),i(5,ct(zn.InternalEventEmitter)),i(6,ct(zn.Peers)),i(7,ct(zn.ClientEventEmitter)),i(8,ct(zn.LoggerFactory)),s("design:paramtypes",[Fh,Gl,Th,Rh,Jl,_t,Eh,_t,Function])],Pf);var Tf=Pf,Ef={exports:{}},Df=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)}},If=Df,Mf=Object.prototype.toString;function xf(e){return"[object Array]"===Mf.call(e)}function Of(e){return void 0===e}function Lf(e){return null!==e&&"object"==typeof e}function Af(e){if("[object Object]"!==Mf.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function jf(e){return"[object Function]"===Mf.call(e)}function Ff(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),xf(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 Nf={isArray:xf,isArrayBuffer:function(e){return"[object ArrayBuffer]"===Mf.call(e)},isBuffer:function(e){return null!==e&&!Of(e)&&null!==e.constructor&&!Of(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:Lf,isPlainObject:Af,isUndefined:Of,isDate:function(e){return"[object Date]"===Mf.call(e)},isFile:function(e){return"[object File]"===Mf.call(e)},isBlob:function(e){return"[object Blob]"===Mf.call(e)},isFunction:jf,isStream:function(e){return Lf(e)&&jf(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:Ff,merge:function e(){var t={};function r(r,n){Af(t[n])&&Af(r)?t[n]=e(t[n],r):Af(r)?t[n]=e({},r):xf(r)?t[n]=r.slice():t[n]=r}for(var n=0,i=arguments.length;n<i;n++)Ff(arguments[n],r);return t},extend:function(e,t,r){return Ff(t,(function(t,n){e[n]=r&&"function"==typeof t?If(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}},Bf=Nf;function Wf(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var qf=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(Bf.isURLSearchParams(t))n=t.toString();else{var i=[];Bf.forEach(t,(function(e,t){null!=e&&(Bf.isArray(e)?t+="[]":e=[e],Bf.forEach(e,(function(e){Bf.isDate(e)?e=e.toISOString():Bf.isObject(e)&&(e=JSON.stringify(e)),i.push(Wf(t)+"="+Wf(e))})))})),n=i.join("&")}if(n){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e},Uf=Nf;function zf(){this.handlers=[]}zf.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},zf.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},zf.prototype.forEach=function(e){Uf.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var Vf=zf,Hf=Nf,$f=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},Kf=$f,Gf=function(e,t,r,n,i){var s=new Error(e);return Kf(s,t,r,n,i)},Jf=Gf,Qf=Nf,Yf=Qf.isStandardBrowserEnv()?{write:function(e,t,r,n,i,s){var o=[];o.push(e+"="+encodeURIComponent(t)),Qf.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Qf.isString(n)&&o.push("path="+n),Qf.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(){}},Zf=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Xf=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},em=Nf,tm=["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"],rm=Nf,nm=rm.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=rm.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0},im=Nf,sm=function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(Jf("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)},om=Yf,am=qf,cm=function(e,t){return e&&!Zf(t)?Xf(e,t):t},dm=function(e){var t,r,n,i={};return e?(em.forEach(e.split("\n"),(function(e){if(n=e.indexOf(":"),t=em.trim(e.substr(0,n)).toLowerCase(),r=em.trim(e.substr(n+1)),t){if(i[t]&&tm.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([r]):i[t]?i[t]+", "+r:r}})),i):i},um=nm,lm=Gf,pm=function(e){return new Promise((function(t,r){var n=e.data,i=e.headers,s=e.responseType;im.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=cm(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};sm(t,r,i),o=null}}if(o.open(e.method.toUpperCase(),am(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(lm("Request aborted",e,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(lm("Network Error",e,null,o)),o=null},o.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(lm(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",o)),o=null},im.isStandardBrowserEnv()){var l=(e.withCredentials||um(d))&&e.xsrfCookieName?om.read(e.xsrfCookieName):void 0;l&&(i[e.xsrfHeaderName]=l)}"setRequestHeader"in o&&im.forEach(i,(function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete i[t]:o.setRequestHeader(t,e)})),im.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)}))},hm=Nf,fm=function(e,t){Hf.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},mm=$f,gm={"Content-Type":"application/x-www-form-urlencoded"};function vm(e,t){!hm.isUndefined(e)&&hm.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var ym,bm={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(ym=pm),ym),transformRequest:[function(e,t){return fm(t,"Accept"),fm(t,"Content-Type"),hm.isFormData(e)||hm.isArrayBuffer(e)||hm.isBuffer(e)||hm.isStream(e)||hm.isFile(e)||hm.isBlob(e)?e:hm.isArrayBufferView(e)?e.buffer:hm.isURLSearchParams(e)?(vm(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):hm.isObject(e)||t&&"application/json"===t["Content-Type"]?(vm(t,"application/json"),function(e,t,r){if(hm.isString(e))try{return(t||JSON.parse)(e),hm.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&&hm.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw mm(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, */*"}},hm.forEach(["delete","get","head"],(function(e){bm.headers[e]={}})),hm.forEach(["post","put","patch"],(function(e){bm.headers[e]=hm.merge(gm)}));var wm=bm,_m=Nf,Sm=wm,km=function(e){return!(!e||!e.__CANCEL__)},Cm=Nf,Rm=function(e,t,r){var n=this||Sm;return _m.forEach(r,(function(r){e=r.call(n,e,t)})),e},Pm=km,Tm=wm;function Em(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var Dm=Nf,Im=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 Dm.isPlainObject(e)&&Dm.isPlainObject(t)?Dm.merge(e,t):Dm.isPlainObject(t)?Dm.merge({},t):Dm.isArray(t)?t.slice():t}function c(n){Dm.isUndefined(t[n])?Dm.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(e[n],t[n])}Dm.forEach(n,(function(e){Dm.isUndefined(t[e])||(r[e]=a(void 0,t[e]))})),Dm.forEach(i,c),Dm.forEach(s,(function(n){Dm.isUndefined(t[n])?Dm.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(void 0,t[n])})),Dm.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 Dm.forEach(u,c),r},Mm={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"}]},xm={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){xm[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var Om={},Lm=Mm.version.split(".");function Am(e,t){for(var r=t?t.split("."):Lm,n=e.split("."),i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}xm.transitional=function(e,t,r){var n=t&&Am(t);function i(e,t){return"[Axios v"+Mm.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&&!Om[s]&&(Om[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 jm={isOlderVersion:Am,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:xm},Fm=Nf,Nm=qf,Bm=Vf,Wm=function(e){return Em(e),e.headers=e.headers||{},e.data=Rm.call(e,e.data,e.headers,e.transformRequest),e.headers=Cm.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Cm.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||Tm.adapter)(e).then((function(t){return Em(e),t.data=Rm.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return Pm(t)||(Em(e),t&&t.response&&(t.response.data=Rm.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},qm=Im,Um=jm,zm=Um.validators;function Vm(e){this.defaults=e,this.interceptors={request:new Bm,response:new Bm}}Vm.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=qm(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&&Um.assertOptions(t,{silentJSONParsing:zm.transitional(zm.boolean,"1.0.0"),forcedJSONParsing:zm.transitional(zm.boolean,"1.0.0"),clarifyTimeoutError:zm.transitional(zm.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=[Wm,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=Wm(a)}catch(e){return Promise.reject(e)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},Vm.prototype.getUri=function(e){return e=qm(this.defaults,e),Nm(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},Fm.forEach(["delete","get","head","options"],(function(e){Vm.prototype[e]=function(t,r){return this.request(qm(r||{},{method:e,url:t,data:(r||{}).data}))}})),Fm.forEach(["post","put","patch"],(function(e){Vm.prototype[e]=function(t,r,n){return this.request(qm(n||{},{method:e,url:t,data:r}))}}));var Hm=Vm;function $m(e){this.message=e}$m.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},$m.prototype.__CANCEL__=!0;var Km=$m,Gm=Km;function Jm(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 Gm(e),t(r.reason))}))}Jm.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Jm.source=function(){var e,t=new Jm((function(t){e=t}));return{token:t,cancel:e}};var Qm=Jm,Ym=Nf,Zm=Df,Xm=Hm,eg=Im;function tg(e){var t=new Xm(e),r=Zm(Xm.prototype.request,t);return Ym.extend(r,Xm.prototype,t),Ym.extend(r,t),r}var rg=tg(wm);rg.Axios=Xm,rg.create=function(e){return tg(eg(rg.defaults,e))},rg.Cancel=Km,rg.CancelToken=Qm,rg.isCancel=km,rg.all=function(e){return Promise.all(e)},rg.spread=function(e){return function(t){return e.apply(null,t)}},rg.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},Ef.exports=rg,Ef.exports.default=rg;var ng=Ef.exports,ig="undefined"!=typeof Symbol&&Symbol,sg=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},og="Function.prototype.bind called on incompatible ",ag=Array.prototype.slice,cg=Object.prototype.toString,dg=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==cg.call(t))throw new TypeError(og+t);for(var r,n=ag.call(arguments,1),i=function(){if(this instanceof r){var i=t.apply(this,n.concat(ag.call(arguments)));return Object(i)===i?i:this}return t.apply(e,n.concat(ag.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},ug=Function.prototype.bind||dg,lg=ug.call(Function.call,Object.prototype.hasOwnProperty),pg=SyntaxError,hg=Function,fg=TypeError,mg=function(e){try{return hg('"use strict"; return ('+e+").constructor;")()}catch(e){}},gg=Object.getOwnPropertyDescriptor;if(gg)try{gg({},"")}catch(yt){gg=null}var vg=function(){throw new fg},yg=gg?function(){try{return vg}catch(e){try{return gg(arguments,"callee").get}catch(e){return vg}}}():vg,bg="function"==typeof ig&&"function"==typeof Symbol&&"symbol"==typeof ig("foo")&&"symbol"==typeof Symbol("bar")&&sg(),wg=Object.getPrototypeOf||function(e){return e.__proto__},_g={},Sg="undefined"==typeof Uint8Array?undefined:wg(Uint8Array),kg={"%AggregateError%":"undefined"==typeof AggregateError?undefined:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?undefined:ArrayBuffer,"%ArrayIteratorPrototype%":bg?wg([][Symbol.iterator]()):undefined,"%AsyncFromSyncIteratorPrototype%":undefined,"%AsyncFunction%":_g,"%AsyncGenerator%":_g,"%AsyncGeneratorFunction%":_g,"%AsyncIteratorPrototype%":_g,"%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%":hg,"%GeneratorFunction%":_g,"%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%":pg,"%ThrowTypeError%":yg,"%TypedArray%":Sg,"%TypeError%":fg,"%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},Cg=function e(t){var r;if("%AsyncFunction%"===t)r=mg("async function () {}");else if("%GeneratorFunction%"===t)r=mg("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=mg("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 kg[t]=r,r},Rg={"%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"]},Pg=ug,Tg=lg,Eg=Pg.call(Function.call,Array.prototype.concat),Dg=Pg.call(Function.apply,Array.prototype.splice),Ig=Pg.call(Function.call,String.prototype.replace),Mg=Pg.call(Function.call,String.prototype.slice),xg=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Og=/\\(\\)?/g,Lg=function(e){var t=Mg(e,0,1),r=Mg(e,-1);if("%"===t&&"%"!==r)throw new pg("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new pg("invalid intrinsic syntax, expected opening `%`");var n=[];return Ig(e,xg,(function(e,t,r,i){n[n.length]=r?Ig(i,Og,"$1"):t||e})),n},Ag=function(e,t){var r,n=e;if(Tg(Rg,n)&&(n="%"+(r=Rg[n])[0]+"%"),Tg(kg,n)){var i=kg[n];if(i===_g&&(i=Cg(n)),void 0===i&&!t)throw new fg("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new pg("intrinsic "+e+" does not exist!")},jg=function(e,t){if("string"!=typeof e||0===e.length)throw new fg("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new fg('"allowMissing" argument must be a boolean');var r=Lg(e),n=r.length>0?r[0]:"",i=Ag("%"+n+"%",t),s=i.name,o=i.value,a=!1,c=i.alias;c&&(n=c[0],Dg(r,Eg([0,1],c)));for(var d=1,u=!0;d<r.length;d+=1){var l=r[d],p=Mg(l,0,1),h=Mg(l,-1);if(('"'===p||"'"===p||"`"===p||'"'===h||"'"===h||"`"===h)&&p!==h)throw new pg("property names with quotes must have matching quotes");if("constructor"!==l&&u||(a=!0),Tg(kg,s="%"+(n+="."+l)+"%"))o=kg[s];else if(null!=o){if(!(l in o)){if(!t)throw new fg("base intrinsic for "+e+" exists, but the property is not available.");return}if(gg&&d+1>=r.length){var f=gg(o,l);o=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:o[l]}else u=Tg(o,l),o=o[l];u&&!a&&(kg[s]=o)}}return o},Fg={exports:{}};!function(e){var t=ug,r=jg,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}(Fg);var Ng=jg,Bg=Fg.exports,Wg=Bg(Ng("String.prototype.indexOf")),qg=p(Object.freeze({__proto__:null,default:{}})),Ug="function"==typeof Map&&Map.prototype,zg=Object.getOwnPropertyDescriptor&&Ug?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Vg=Ug&&zg&&"function"==typeof zg.get?zg.get:null,Hg=Ug&&Map.prototype.forEach,$g="function"==typeof Set&&Set.prototype,Kg=Object.getOwnPropertyDescriptor&&$g?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Gg=$g&&Kg&&"function"==typeof Kg.get?Kg.get:null,Jg=$g&&Set.prototype.forEach,Qg="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Yg="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Zg="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Xg=Boolean.prototype.valueOf,ev=Object.prototype.toString,tv=Function.prototype.toString,rv=String.prototype.match,nv="function"==typeof BigInt?BigInt.prototype.valueOf:null,iv=Object.getOwnPropertySymbols,sv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,ov="function"==typeof Symbol&&"object"==typeof Symbol.iterator,av=Object.prototype.propertyIsEnumerable,cv=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null),dv=qg.custom,uv=dv&&mv(dv)?dv:null,lv="function"==typeof Symbol&&void 0!==Symbol.toStringTag?Symbol.toStringTag:null;function pv(e,t,r){var n="double"===(r.quoteStyle||t)?'"':"'";return n+e+n}function hv(e){return String(e).replace(/"/g,""")}function fv(e){return!("[object Array]"!==yv(e)||lv&&"object"==typeof e&&lv in e)}function mv(e){if(ov)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!sv)return!1;try{return sv.call(e),!0}catch(e){}return!1}var gv=Object.prototype.hasOwnProperty||function(e){return e in this};function vv(e,t){return gv.call(e,t)}function yv(e){return ev.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 pv(e.replace(/(['\\])/g,"\\$1").replace(/[\x00-\x1f]/g,_v),"single",t)}function _v(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 Sv(e){return"Object("+e+")"}function kv(e){return e+" { ? }"}function Cv(e,t,r,n){return e+" ("+t+") {"+(n?Rv(r,n):r.join(", "))+"}"}function Rv(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+e.join(","+r)+"\n"+t.prev}function Pv(e,t){var r=fv(e),n=[];if(r){n.length=e.length;for(var i=0;i<e.length;i++)n[i]=vv(e,i)?t(e[i],e):""}var s,o="function"==typeof iv?iv(e):[];if(ov){s={};for(var a=0;a<o.length;a++)s["$"+o[a]]=o[a]}for(var c in e)vv(e,c)&&(r&&String(Number(c))===c&&c<e.length||ov&&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 iv)for(var d=0;d<o.length;d++)av.call(e,o[d])&&n.push("["+t(o[d])+"]: "+t(e[o[d]],e));return n}var Tv=jg,Ev=function(e,t){var r=Ng(e,!!t);return"function"==typeof r&&Wg(e,".prototype.")>-1?Bg(r):r},Dv=function e(t,r,n,i){var s=r||{};if(vv(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(vv(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=!vv(s,"customInspect")||s.customInspect;if("boolean"!=typeof o&&"symbol"!==o)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(vv(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 fv(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 vv(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=rv.call(tv.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),l=Pv(t,d);return"[Function"+(u?": "+u:" (anonymous)")+"]"+(l.length>0?" { "+l.join(", ")+" }":"")}if(mv(t)){var p=ov?String(t).replace(/^(Symbol\(.*\))_[^)]*$/,"$1"):sv.call(t);return"object"!=typeof t||ov?p:Sv(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+"="+pv(hv(f[m].value),"double",s);return h+=">",t.childNodes&&t.childNodes.length&&(h+="..."),h+="</"+String(t.nodeName).toLowerCase()+">"}if(fv(t)){if(0===t.length)return"[]";var g=Pv(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)?"["+Rv(g,c)+"]":"[ "+g.join(", ")+" ]"}if(function(e){return!("[object Error]"!==yv(e)||lv&&"object"==typeof e&&lv in e)}(t)){var v=Pv(t,d);return 0===v.length?"["+String(t)+"]":"{ ["+String(t)+"] "+v.join(", ")+" }"}if("object"==typeof t&&o){if(uv&&"function"==typeof t[uv])return t[uv]();if("symbol"!==o&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!Vg||!e||"object"!=typeof e)return!1;try{Vg.call(e);try{Gg.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var y=[];return Hg.call(t,(function(e,r){y.push(d(r,t,!0)+" => "+d(e,t))})),Cv("Map",Vg.call(t),y,c)}if(function(e){if(!Gg||!e||"object"!=typeof e)return!1;try{Gg.call(e);try{Vg.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var b=[];return Jg.call(t,(function(e){b.push(d(e,t))})),Cv("Set",Gg.call(t),b,c)}if(function(e){if(!Qg||!e||"object"!=typeof e)return!1;try{Qg.call(e,Qg);try{Yg.call(e,Yg)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return kv("WeakMap");if(function(e){if(!Yg||!e||"object"!=typeof e)return!1;try{Yg.call(e,Yg);try{Qg.call(e,Qg)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return kv("WeakSet");if(function(e){if(!Zg||!e||"object"!=typeof e)return!1;try{return Zg.call(e),!0}catch(e){}return!1}(t))return kv("WeakRef");if(function(e){return!("[object Number]"!==yv(e)||lv&&"object"==typeof e&&lv in e)}(t))return Sv(d(Number(t)));if(function(e){if(!e||"object"!=typeof e||!nv)return!1;try{return nv.call(e),!0}catch(e){}return!1}(t))return Sv(d(nv.call(t)));if(function(e){return!("[object Boolean]"!==yv(e)||lv&&"object"==typeof e&&lv in e)}(t))return Sv(Xg.call(t));if(function(e){return!("[object String]"!==yv(e)||lv&&"object"==typeof e&&lv in e)}(t))return Sv(d(String(t)));if(!function(e){return!("[object Date]"!==yv(e)||lv&&"object"==typeof e&&lv in e)}(t)&&!function(e){return!("[object RegExp]"!==yv(e)||lv&&"object"==typeof e&&lv in e)}(t)){var w=Pv(t,d),_=cv?cv(t)===Object.prototype:t instanceof Object||t.constructor===Object,S=t instanceof Object?"":"null prototype",k=!_&&lv&&Object(t)===t&&lv in t?yv(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+"{"+Rv(w,c)+"}":C+"{ "+w.join(", ")+" }"}return String(t)},Iv=Tv("%TypeError%"),Mv=Tv("%WeakMap%",!0),xv=Tv("%Map%",!0),Ov=Ev("WeakMap.prototype.get",!0),Lv=Ev("WeakMap.prototype.set",!0),Av=Ev("WeakMap.prototype.has",!0),jv=Ev("Map.prototype.get",!0),Fv=Ev("Map.prototype.set",!0),Nv=Ev("Map.prototype.has",!0),Bv=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},Wv=String.prototype.replace,qv=/%20/g,Uv="RFC3986",zv={default:Uv,formatters:{RFC1738:function(e){return Wv.call(e,qv,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:Uv},Vv=zv,Hv=Object.prototype.hasOwnProperty,$v=Array.isArray,Kv=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Gv=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},Jv={arrayToObject:Gv,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($v(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===Vv.RFC1738&&(40===c||41===c)?o+=s.charAt(a):c<128?o+=Kv[c]:c<2048?o+=Kv[192|c>>6]+Kv[128|63&c]:c<55296||c>=57344?o+=Kv[224|c>>12]+Kv[128|c>>6&63]+Kv[128|63&c]:(a+=1,c=65536+((1023&c)<<10|1023&s.charCodeAt(a)),o+=Kv[240|c>>18]+Kv[128|c>>12&63]+Kv[128|c>>6&63]+Kv[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($v(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($v(t))t.push(r);else{if(!t||"object"!=typeof t)return[t,r];(n&&(n.plainObjects||n.allowPrototypes)||!Hv.call(Object.prototype,r))&&(t[r]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(r);var i=t;return $v(t)&&!$v(r)&&(i=Gv(t,n)),$v(t)&&$v(r)?(r.forEach((function(r,i){if(Hv.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 Hv.call(t,i)?t[i]=e(t[i],s,n):t[i]=s,t}),i)}},Qv=function(){var e,t,r,n={assert:function(e){if(!n.has(e))throw new Iv("Side channel does not contain "+Dv(e))},get:function(n){if(Mv&&n&&("object"==typeof n||"function"==typeof n)){if(e)return Ov(e,n)}else if(xv){if(t)return jv(t,n)}else if(r)return function(e,t){var r=Bv(e,t);return r&&r.value}(r,n)},has:function(n){if(Mv&&n&&("object"==typeof n||"function"==typeof n)){if(e)return Av(e,n)}else if(xv){if(t)return Nv(t,n)}else if(r)return function(e,t){return!!Bv(e,t)}(r,n);return!1},set:function(n,i){Mv&&n&&("object"==typeof n||"function"==typeof n)?(e||(e=new Mv),Lv(e,n,i)):xv?(t||(t=new xv),Fv(t,n,i)):(r||(r={key:{},next:null}),function(e,t,r){var n=Bv(e,t);n?n.value=r:e.next={key:t,next:e.next,value:r}}(r,n,i))}};return n},Yv=Jv,Zv=zv,Xv=Object.prototype.hasOwnProperty,ey={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},ty=Array.isArray,ry=String.prototype.split,ny=Array.prototype.push,iy=function(e,t){ny.apply(e,ty(t)?t:[t])},sy=Date.prototype.toISOString,oy=Zv.default,ay={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:Yv.encode,encodeValuesOnly:!1,format:oy,formatter:Zv.formatters[oy],indices:!1,serializeDate:function(e){return sy.call(e)},skipNulls:!1,strictNullHandling:!1},cy={},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(cy))&&!w;){var _=y.get(t);if(b+=1,void 0!==_){if(_===b)throw new RangeError("Cyclic object value");w=!0}void 0===y.get(cy)&&(b=0)}if("function"==typeof c?v=c(r,v):v instanceof Date?v=l(v):"comma"===n&&ty(v)&&(v=Yv.maybeMap(v,(function(e){return e instanceof Date?l(e):e}))),null===v){if(s)return a&&!f?a(r,ay.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)||Yv.isBuffer(v)){if(a){var S=f?r:a(r,ay.encoder,m,"key",p);if("comma"===n&&f){for(var k=ry.call(String(v),","),C="",R=0;R<k.length;++R)C+=(0===R?"":",")+h(a(k[R],ay.encoder,m,"value",p));return[h(S)+(i&&ty(v)&&1===k.length?"[]":"")+"="+C]}return[h(S)+"="+h(a(v,ay.encoder,m,"value",p))]}return[h(r)+"="+h(String(v))]}var P,T=[];if(void 0===v)return T;if("comma"===n&&ty(v))P=[{value:v.length>0?v.join(",")||null:void 0}];else if(ty(c))P=c;else{var E=Object.keys(v);P=d?E.sort(d):E}for(var D=i&&ty(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=ty(v)?"function"==typeof n?n(D,M):D:D+(u?"."+M:"["+M+"]");g.set(t,b);var L=Qv();L.set(cy,g),iy(T,e(x,O,n,i,s,o,a,c,d,u,l,p,h,f,m,L))}}return T},uy=Jv,ly=Object.prototype.hasOwnProperty,py=Array.isArray,hy={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:uy.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},fy=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},my=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},gy=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&&ly.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&&ly.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:my(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)}},vy=function(e,t){var r,n=e,i=function(e){if(!e)return ay;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||ay.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=Zv.default;if(void 0!==e.format){if(!Xv.call(Zv.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n=Zv.formatters[r],i=ay.filter;return("function"==typeof e.filter||ty(e.filter))&&(i=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:ay.addQueryPrefix,allowDots:void 0===e.allowDots?ay.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:ay.charsetSentinel,delimiter:void 0===e.delimiter?ay.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:ay.encode,encoder:"function"==typeof e.encoder?e.encoder:ay.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:ay.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:ay.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:ay.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:ay.strictNullHandling}}(t);"function"==typeof i.filter?n=(0,i.filter)("",n):ty(i.filter)&&(r=i.filter);var s,o=[];if("object"!=typeof n||null===n)return"";s=t&&t.arrayFormat in ey?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var a=ey[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=Qv(),u=0;u<r.length;++u){var l=r[u];i.skipNulls&&null===n[l]||iy(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:""},yy=function(e,t){var r=function(e){if(!e)return hy;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?hy.charset:e.charset;return{allowDots:void 0===e.allowDots?hy.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:hy.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:hy.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:hy.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:hy.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:hy.comma,decoder:"function"==typeof e.decoder?e.decoder:hy.decoder,delimiter:"string"==typeof e.delimiter||uy.isRegExp(e.delimiter)?e.delimiter:hy.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:hy.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:hy.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:hy.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:hy.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:hy.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,hy.decoder,c,"key"),u=t.strictNullHandling?null:""):(d=t.decoder(l.slice(0,h),hy.decoder,c,"key"),u=uy.maybeMap(my(l.slice(h+1),t),(function(e){return t.decoder(e,hy.decoder,c,"value")}))),u&&t.interpretNumericEntities&&"iso-8859-1"===c&&(u=fy(u)),l.indexOf("[]=")>-1&&(u=py(u)?[u]:u),ly.call(n,d)?n[d]=uy.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=gy(a,n[a],r,"string"==typeof e);i=uy.merge(i,c,r)}return!0===r.allowSparse?i:uy.compact(i)},by={formats:zv,parse:yy,stringify:vy};let wy=class{constructor(e){this.config=e;const t=this.config.get("loadbalancer"),{baseURL:r,timeout:n,customNode:i}=t;this.api=ng.create({baseURL:r||"https://lb.livedigital.space/v1",timeout:n||5e3,withCredentials:!1,paramsSerializer:e=>by.stringify(e)}),this.customNode=i}getNode(e){return o(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 o(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=n([ot(),i(0,ct(zn.Config)),s("design:paramtypes",[wt])],wy);var _y,Sy=wy;let ky=class{constructor(e,t){this.clientEventEmitter=e,this.isEnableVideoDevicesLock=!1,this.isEnableAudioDevicesLock=!1,this.isDevicesDetected=!1,this.availableVideoDevices=[],this.availableAudioDevices=[],_y.set(this,void 0),c(this,_y,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 o(this,void 0,void 0,(function*(){try{return(yield navigator.mediaDevices.getUserMedia(e)).getTracks()}catch(t){if(a(this,_y,"f").error("getUserMedia()",{error:t,constraints:e}),"NotAllowedError"===t.name)throw new Error(Hn.NotAllowedError);if("NotReadableError"===t.name)throw new Error(Hn.DeviceIsBusy);if("NotFoundError"===t.name)throw new Error(Hn.NotFoundError);throw new Error(Hn.RequestDevicesUnknownError)}}))}hasAvailableMediaDevicesList(){return o(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 o(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 a(this,_y,"f").debug("Devices list updated",{videoDevices:t.map(n),audioDevices:r.map(n)}),e}))}detectDevices(e){return o(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(Hn.NoDevices)}))}deviceChangeHandler(){return o(this,void 0,void 0,(function*(){this.isDevicesDetected&&(yield this.refreshAvailableMediaDevicesList(),this.clientEventEmitter.safeEmit(jr,{audio:this.availableAudioDevices,video:this.availableVideoDevices}))}))}listenDevices(){navigator.mediaDevices.addEventListener("devicechange",this.deviceChangeHandler)}assertHasAccessToMediaDevices(e={video:!0,audio:!0}){return o(this,void 0,void 0,(function*(){(yield this.requestMediaDevicesAccess(e)).forEach((e=>e.stop()))}))}tryToAccessDevices(){return o(this,void 0,void 0,(function*(){try{(yield this.requestMediaDevicesAccess()).forEach((e=>e.stop()))}catch(t){if(e=t.message,![Hn.NotFoundError,Hn.NotAllowedError,Hn.DeviceIsBusy].includes(e))throw t;t.message!==Hn.DeviceIsBusy&&(yield this.assertHasAccessToMediaDevices({audio:!0}),yield this.assertHasAccessToMediaDevices({video:!0}))}var e}))}};_y=new WeakMap,ky=n([ot(),i(0,ct(zn.ClientEventEmitter)),i(1,ct(zn.LoggerFactory)),s("design:paramtypes",[_t,Function])],ky);var Cy,Ry,Py,Ty,Ey,Dy,Iy,My,xy,Oy,Ly=ky;class Ay{constructor({sendTransportConnectionManager:e,receiveTransportConnectionManager:t,media:r,peers:n}){Cy.set(this,void 0),Ry.set(this,void 0),Py.set(this,void 0),Ty.set(this,void 0),c(this,Cy,e,"f"),c(this,Ry,t,"f"),c(this,Py,r,"f"),c(this,Ty,n,"f")}getStats(){var e,t;return Object.assign(Object.assign({},(null===(e=a(this,Cy,"f").connectionStats)||void 0===e?void 0:e.id)?{outbound:Object.assign(Object.assign({},a(this,Cy,"f").connectionStats),{bitrate:this.calculateOutboundTracksBitrate()})}:{}),(null===(t=a(this,Ry,"f").connectionStats)||void 0===t?void 0:t.id)?{inbound:Object.assign(Object.assign({},a(this,Ry,"f").connectionStats),{bitrate:this.calculateInboundTracksBitrate()})}:{})}calculateInboundTracksBitrate(){return a(this,Ty,"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 a(this,Py,"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)}}Cy=new WeakMap,Ry=new WeakMap,Py=new WeakMap,Ty=new WeakMap;class jy{constructor({transport:e,statsHandler:t}){Ey.set(this,void 0),this.handleWebRTCStats(e,t)}get connectionStats(){return a(this,Ey,"f")}handleWebRTCStats(e,t){t.addConnectionHandler(e.id,this.setConnectionStats.bind(this)),e.observer.once("close",(()=>{t.removeConnectionHandler(e.id)}))}setConnectionStats(e){c(this,Ey,e,"f")}}Ey=new WeakMap;let Fy=class{constructor(){Dy.set(this,new Map),Iy.set(this,new Map),My.set(this,new Map),xy.set(this,new Map),Oy.set(this,new Map)}handle(e){e.forEach((({id:e,stats:t})=>{var r;null===(r=a(this,Dy,"f").get(e))||void 0===r||r(t.connection),t.video.inbound.forEach((e=>{var t;return null===(t=a(this,Iy,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.inbound.forEach((e=>{var t;return null===(t=a(this,My,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.video.outbound.forEach((e=>{var t;return null===(t=a(this,xy,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.outbound.forEach((e=>{var t;return null===(t=a(this,Oy,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)}))}))}addConnectionHandler(e,t){a(this,Dy,"f").set(e,t)}addInboundVideoHandler(e,t){a(this,Iy,"f").set(e,t)}addInboundAudioHandler(e,t){a(this,My,"f").set(e,t)}addOutboundVideoHandler(e,t){a(this,xy,"f").set(e,t)}addOutboundAudioHandler(e,t){a(this,Oy,"f").set(e,t)}removeConnectionHandler(e){a(this,Dy,"f").delete(e)}removeInboundVideoHandler(e){a(this,Iy,"f").delete(e)}removeInboundAudioHandler(e){a(this,xy,"f").delete(e)}removeOutboundVideoHandler(e){a(this,Oy,"f").delete(e)}removeOutboundAudioHandler(e){a(this,Oy,"f").delete(e)}clear(){a(this,Dy,"f").clear(),a(this,Iy,"f").clear(),a(this,My,"f").clear(),a(this,xy,"f").clear(),a(this,Oy,"f").clear()}};Dy=new WeakMap,Iy=new WeakMap,My=new WeakMap,xy=new WeakMap,Oy=new WeakMap,Fy=n([ot()],Fy);var Ny,By,Wy,qy,Uy,zy=Fy;class Vy extends Ln{constructor(e,t){super(e,null!=t?t:"invalid_payload")}}!function(e){e.DominantSpeaker="dominant-speaker",e.PeersVolumes="peers-volumes",e.Silence="silence"}(Ny||(Ny={}));let Hy=Uy=class{constructor(e,t,r){this.peers=e,this.clientEventEmitter=t,By.set(this,void 0),Wy.set(this,void 0),qy.set(this,void 0),c(this,By,r("ChannelAudioObserverEventHandler"),"f"),this.watchPeersLeave()}handle(e){try{const t=JSON.parse(e);switch(Uy.validateEventPayload(t),t.event){case Ny.DominantSpeaker:this.handleDominantSpeaker(t);break;case Ny.PeersVolumes:this.handlePeerVolumes(t);break;case Ny.Silence:this.handleSilence()}}catch(t){a(this,By,"f").warn("Failed to handle audio observer event",{error:cr(t),eventData:e})}}handleDominantSpeaker(e){const{peerId:t}=e.data,r=this.peers.get(t);c(this,Wy,r,"f"),c(this,qy,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&&!a(this,Wy,"f")&&s.id===(null===(t=a(this,qy,"f"))||void 0===t?void 0:t.id)&&(c(this,Wy,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))),c(this,Wy,void 0,"f"),this.peers.setActiveSpeaker(void 0)}watchPeersLeave(){this.clientEventEmitter.on(Mr,(e=>{var t;e===(null===(t=a(this,Wy,"f"))||void 0===t?void 0:t.id)&&this.peers.setActiveSpeaker(void 0)}))}static validateEventPayload(e){switch(e.event){case Ny.Silence:break;case Ny.DominantSpeaker:{e.data||Uy.throwInvalidPayload();const{peerId:t,producerId:r,trackLabel:n}=e.data;"string"==typeof t&&"string"==typeof r&&n===Vn.Microphone||Uy.throwInvalidPayload();break}case Ny.PeersVolumes:Array.isArray(e.volumes)||Uy.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===Vn.Microphone||Uy.throwInvalidPayload()}));break;default:Uy.throwInvalidPayload()}}static throwInvalidPayload(){throw new Vy("Invalid channel audio observer event handler payload")}};By=new WeakMap,Wy=new WeakMap,qy=new WeakMap,Hy=Uy=n([ot(),i(0,ct(zn.Peers)),i(1,ct(zn.ClientEventEmitter)),i(2,ct(zn.LoggerFactory)),s("design:paramtypes",[Eh,_t,Function])],Hy);var $y=Hy,Ky=Uint8Array,Gy=Uint16Array,Jy=Int32Array,Qy=new Ky([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]),Yy=new Ky([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]),Zy=new Ky([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xy=function(e,t){for(var r=new Gy(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];var i=new Jy(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}},eb=Xy(Qy,2),tb=eb.b,rb=eb.r;tb[28]=258,rb[258]=28;for(var nb=Xy(Yy,0).b,ib=new Gy(32768),sb=0;sb<32768;++sb){var ob=(43690&sb)>>1|(21845&sb)<<1;ob=(61680&(ob=(52428&ob)>>2|(13107&ob)<<2))>>4|(3855&ob)<<4,ib[sb]=((65280&ob)>>8|(255&ob)<<8)>>1}var ab=function(e,t,r){for(var n=e.length,i=0,s=new Gy(t);i<n;++i)e[i]&&++s[e[i]-1];var o,a=new Gy(t);for(i=1;i<t;++i)a[i]=a[i-1]+s[i-1]<<1;if(r){o=new Gy(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[ib[l]>>c]=d}else for(o=new Gy(n),i=0;i<n;++i)e[i]&&(o[i]=ib[a[e[i]-1]++]>>15-e[i]);return o},cb=new Ky(288);for(sb=0;sb<144;++sb)cb[sb]=8;for(sb=144;sb<256;++sb)cb[sb]=9;for(sb=256;sb<280;++sb)cb[sb]=7;for(sb=280;sb<288;++sb)cb[sb]=8;var db=new Ky(32);for(sb=0;sb<32;++sb)db[sb]=5;var ub=ab(cb,9,1),lb=ab(db,5,1),pb=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},hb=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&r},fb=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},mb=function(e){return(e+7)/8|0},gb=function(e,t,r){return(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length),new Ky(e.subarray(t,r))},vb=["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"],yb=function(e,t,r){var n=new Error(t||vb[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,yb),!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 Ky(0);var o=!r,a=o||2!=t.i,c=t.i;o&&(r=new Ky(3*i));var d=function(e){var t=r.length;if(e>t){var n=new Ky(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=hb(e,l,1);var y=hb(e,l+1,3);if(l+=3,!y){var b=e[(I=mb(l)+4)-4]|e[I-3]<<8,w=I+b;if(w>i){c&&yb(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=ub,f=lb,m=9,g=5;else if(2==y){var _=hb(e,l,31)+257,S=hb(e,l+10,15)+4,k=_+hb(e,l+5,31)+1;l+=14;for(var C=new Ky(k),R=new Ky(19),P=0;P<S;++P)R[Zy[P]]=hb(e,l+3*P,7);l+=3*S;var T=pb(R),E=(1<<T)-1,D=ab(R,T,1);for(P=0;P<k;){var I,M=D[hb(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+hb(e,l,3),l+=2,x=C[P-1]):17==I?(O=3+hb(e,l,7),l+=3):18==I&&(O=11+hb(e,l,127),l+=7);O--;)C[P++]=x}}var L=C.subarray(0,_),A=C.subarray(_);m=pb(L),g=pb(A),h=ab(L,m,1),f=ab(A,g,1)}else yb(1);if(l>v){c&&yb(0);break}}a&&d(p+131072);for(var j=(1<<m)-1,F=(1<<g)-1,N=l;;N=l){var B=(x=h[fb(e,l)&j])>>4;if((l+=15&x)>v){c&&yb(0);break}if(x||yb(2),B<256)r[p++]=B;else{if(256==B){N=l,h=null;break}var W=B-254;if(B>264){var q=Qy[P=B-257];W=hb(e,l,(1<<q)-1)+tb[P],l+=q}var U=f[fb(e,l)&F],z=U>>4;U||yb(3),l+=15&U;A=nb[z];if(z>3){q=Yy[z];A+=fb(e,l)&(1<<q)-1,l+=q}if(l>v){c&&yb(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&&yb(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?gb(r,0,p):r.subarray(0,p)},wb=new Ky(0);function _b(e,t){var r=function(e){31==e[0]&&139==e[1]&&8==e[2]||yb(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&&yb(6,"invalid gzip data"),bb(e.subarray(r,-8),{i:2},t&&t.out||new Ky(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 Sb(e,t){return bb(e.subarray(function(e,t){return(8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31)&&yb(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&yb(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 kb(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?_b(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):Sb(e,t)}var Cb="undefined"!=typeof TextDecoder&&new TextDecoder;try{Cb.decode(wb,{stream:!0}),1}catch(yt){}function Rb(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(Cb)return Cb.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:gb(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&&yb(8),s}function Pb(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 Tb(e,t,r,n){var i=Pb(Pb(Pb(e,r),function(e){return Object.prototype.toString.call(e)}(t)),typeof t);if(null===t)return Pb(i,"null");if(void 0===t)return Pb(i,"undefined");if("object"==typeof t||"function"==typeof t){if(-1!==n.indexOf(t))return Pb(i,"[Circular]"+r);n.push(t);var s=function(e,t,r){return Object.keys(t).sort().reduce((function(e,n){return Tb(e,t[n],n,r)}),e)}(i,t,n);if(!("valueOf"in t)||"function"!=typeof t.valueOf)return s;try{return Pb(s,String(t.valueOf()))}catch(e){return Pb(s,"[valueOf exception]"+(e.stack||e.message))}}return Pb(i,t.toString())}var Eb=function(e){return function(e,t){for(;e.length<t;)e="0"+e;return e}(Tb(0,e,"",[]).toString(16),8)};class Db{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 Ib{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 Db({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 Mb,xb,Ob,Lb,Ab,jb,Fb;!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"}(Mb||(Mb={}));let Nb=class{constructor(e,t,r,n,i,s,o,a){var d;this.channelStateSynchronizer=e,this.network=r,this.callState=n,this.socket=i,this.peers=s,this.clientEventEmitter=o,this.webRtcIssueDetector=a,xb.set(this,void 0),Ob.set(this,void 0),Lb.set(this,[]),Ab.set(this,!1),jb.set(this,{inbound:4.3,outbound:4.3}),Fb.set(this,(new Date).getTime()-15e3),c(this,Ob,null===(d=this.webRtcIssueDetector)||void 0===d?void 0:d.eventEmitter,"f"),c(this,xb,t("ChannelStateSyncEventHandler"),"f"),this.listenNetworkScoresUpdatedEvents()}handle(e){return o(this,void 0,void 0,(function*(){try{const{event:t,data:r}=yield this.parseChannelStateSyncEventPayload(e);"channel-state"!==t||a(this,Ab,"f")||(yield this.handleChannelStateEvent(r))}catch(e){a(this,xb,"f").error("handleChannelStateSyncEvent()",{error:cr(e)})}}))}handleChannelStateEvent(e){return o(this,void 0,void 0,(function*(){c(this,Ab,!0,"f");try{yield this.collectProbableInconsistencyCases(e);const t=this.getConfirmedInconsistencyResult();if(!(null==t?void 0:t.hasInconsistencyCases()))return;if(this.isRestoreStateRequestToEarly())return void a(this,xb,"f").info("Inconsistency detected, but restore skipped",Object.assign({},t));this.handleConfirmedInconsistencyResult(t)}finally{c(this,Ab,!1,"f")}}))}getLastInconsistencyCheckResult(){return a(this,Lb,"f")[a(this,Lb,"f").length-1]}handleConfirmedInconsistencyResult(e){e.missingPeers.forEach((e=>{this.clientEventEmitter.safeEmit(qr,{peerId:e,type:Mb.MissingPeer})})),e.missingProducers.forEach((e=>{this.clientEventEmitter.safeEmit(qr,{producerId:e,type:Mb.MissingProducer})})),e.producersWithInconsistentState.forEach((e=>{this.clientEventEmitter.safeEmit(qr,{producerId:e,type:Mb.IncorrectProducerState})})),e.peersWithInconsistentAppData.forEach((e=>{this.clientEventEmitter.safeEmit(qr,{peerId:e,type:Mb.IncorrectAppData})}))}getConfirmedInconsistencyResult(){const e=this.getLastInconsistencyCheckResult();if(!e)return;return new Db({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 o(this,void 0,void 0,(function*(){const t=new Ib({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(){c(this,Lb,[],"f")}rotateLastProbableInconsistencyCheckResults(e){4===a(this,Lb,"f").length&&a(this,Lb,"f").shift(),a(this,Lb,"f").push(e)}isReachedMaxCheckRetries(e,t,r=4){let n=0;return a(this,Lb,"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 o(this,void 0,void 0,(function*(){const t=kb("arrayBuffer"in e?new Uint8Array(yield e.arrayBuffer()):new Uint8Array(e));return JSON.parse(Rb(t))}))}getLocalState(){return{peers:this.peers.hosts().map((e=>({id:e.id,appDataHash:Eb(e.appData),producers:e.getProducers().map((e=>({id:e.id,paused:e.paused}))),consumers:e.getConsumersState()})))}}getIsConnectionActive(){var e;return o(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(){a(this,Ob,"f")&&a(this,Ob,"f").on(vt.NetworkScoresUpdated,(e=>{e.inbound&&(a(this,jb,"f").inbound=e.inbound),e.outbound&&(a(this,jb,"f").outbound=e.outbound)}))}isBadNetworkScore(){const{inbound:e,outbound:t}=a(this,jb,"f");return e<=2.6||t<=2.6}compareCheckedAndRestoredResults(e,t){return new Db({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()-a(this,Fb,"f")<=15e3}};xb=new WeakMap,Ob=new WeakMap,Lb=new WeakMap,Ab=new WeakMap,jb=new WeakMap,Fb=new WeakMap,Nb=n([ot(),i(0,ct(zn.ChannelStateSynchronizer)),i(1,ct(zn.LoggerFactory)),i(2,ct(zn.Network)),i(3,ct(zn.CallState)),i(4,ct(zn.SocketIO)),i(5,ct(zn.Peers)),i(6,ct(zn.ClientEventEmitter)),i(7,ct(zn.WebRTCIssueDetector)),s("design:paramtypes",[Wh,Function,Th,Kn,Rh,Eh,_t,Zt])],Nb);var Bb,Wb,qb,Ub,zb,Vb,Hb,$b,Kb,Gb=Nb;let Jb=class{constructor(e,t,r,n,i,s,a,d,u,l){this.state=e,this.myPeer=r,this.network=n,this.channelEventsHandler=i,this.eventsQueue=s,this.peers=a,this.mediaSoupEventsHandler=d,this.channelAudioObserverEventHandler=u,this.channelStateSyncEventHandler=l,Bb.set(this,void 0),Wb.set(this,void 0),qb.set(this,void 0),Ub.set(this,void 0),zb.set(this,void 0),Vb.set(this,void 0),Hb.set(this,void 0),$b.set(this,void 0),Kb.set(this,void 0),c(this,Bb,t("DataChannels"),"f"),c(this,Vb,(e=>{this.channelAudioObserverEventHandler.handle(e)}),"f"),c(this,Hb,(e=>{this.channelEventsHandler.handleDataChannelEvent(e)}),"f"),c(this,$b,(e=>o(this,void 0,void 0,(function*(){yield this.channelStateSyncEventHandler.handle(e)}))),"f"),c(this,Kb,(e=>{this.mediaSoupEventsHandler.handleConsumerScoreEvent(e)}),"f")}createAllDataChannels(){return o(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,c;null===(e=a(this,Wb,"f"))||void 0===e||e.removeListener("message",a(this,Vb,"f")),null===(t=a(this,Wb,"f"))||void 0===t||t.close(),null===(r=a(this,qb,"f"))||void 0===r||r.removeListener("message",a(this,Hb,"f")),null===(n=a(this,qb,"f"))||void 0===n||n.close(),null===(i=a(this,Ub,"f"))||void 0===i||i.removeListener("message",a(this,$b,"f")),null===(s=a(this,Ub,"f"))||void 0===s||s.close(),null===(o=a(this,zb,"f"))||void 0===o||o.removeListener("message",a(this,Kb,"f")),null===(c=a(this,zb,"f"))||void 0===c||c.close()}createAudioObserver(){var e;return o(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",a(this,Vb,"f")),c(this,Wb,r,"f"),a(this,Bb,"f").debug("Successfully create audio observer",t)}catch(e){a(this,Bb,"f").error("Failed to create audio observer",t)}}))}createGeneralDataConsumer(){var e;return o(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();c(this,qb,yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId,ordered:!0}),"f"),this.eventsQueue.subscribeToDataChannel(a(this,qb,"f")),this.eventsQueue.on("message",a(this,Hb,"f")),a(this,Bb,"f").debug("Successfully created general data consumer",Object.assign(Object.assign({},t),{producerId:e}))}catch(e){a(this,Bb,"f").error("Failed to create general data consumer",Object.assign(Object.assign({},t),{error:e}))}}))}createChannelStateSyncDataConsumer(){var e;return o(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(c(this,Ub,yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId}),"f"),!a(this,Ub,"f"))throw new Error("Failed to create ChannelStateSyncDataConsumer");a(this,Ub,"f").on("message",a(this,$b,"f")),a(this,Bb,"f").debug("Successfully created ChannelStateSyncDataConsumer",t)}catch(e){a(this,Bb,"f").error("Failed to create ChannelStateSyncDataConsumer",Object.assign(Object.assign({},t),{error:e}))}}))}createConsumersScoresDataConsumer(){var e;return o(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(c(this,zb,yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId}),"f"),!a(this,zb,"f"))throw new Error("Failed to create consumers scores data consumer");a(this,zb,"f").on("message",a(this,Kb,"f")),a(this,Bb,"f").debug("Successfully create consumers scores data consumer",t)}catch(e){a(this,Bb,"f").error("Failed to create consumers scores data consumer",t)}}))}};Bb=new WeakMap,Wb=new WeakMap,qb=new WeakMap,Ub=new WeakMap,zb=new WeakMap,Vb=new WeakMap,Hb=new WeakMap,$b=new WeakMap,Kb=new WeakMap,Jb=n([ot(),i(0,ct(zn.CallState)),i(1,ct(zn.LoggerFactory)),i(2,ct(zn.MyPeer)),i(3,ct(zn.Network)),i(4,ct(zn.ChannelEventHandler)),i(5,ct(zn.EventsQueue)),i(6,ct(zn.Peers)),i(7,ct(zn.MediaSoupEventHandler)),i(8,ct(zn.ChannelAudioObserverEventHandler)),i(9,ct(zn.ChannelStateSyncEventHandler)),s("design:paramtypes",[Kn,Function,Jl,Th,zh,Fh,Object,Tf,$y,Gb])],Jb);var Qb,Yb,Zb,Xb,ew=Jb;let tw=class{constructor(e,t,r,n,i,s,o,a,d,u,l,p,h,f,m,g,v,y,b){this.state=e,this.myPeer=t,this.mediaSoupEventsHandler=n,this.channelEventsHandler=i,this.channelStateSynchronizer=s,this.peerTrackFactory=o,this.peers=a,this.system=d,this.media=u,this.network=l,this.loadBalancerClient=p,this.socket=h,this.eventsQueue=f,this.clientEventEmitter=m,this.internalEventEmitter=g,this.statsHandler=v,this.dataChannelsManager=y,this.webRtcIssueDetector=b,Qb.set(this,void 0),Yb.set(this,void 0),this.rejoinRequested=!1,this.isReleasing=!1,Zb.set(this,!1),Xb.set(this,void 0),c(this,Qb,r("Engine"),"f"),c(this,Yb,r,"f"),this.watchNetworkState(),this.watchDocumentUnload()}get isChannelJoined(){return this.state.isJoined}initialize(){var e,t,r,n;return o(this,void 0,void 0,(function*(){try{const{rtpCapabilities:i}=yield this.socket.request("router.getRtpCapabilities");yield this.media.createNoiseSuppressor(),yield this.media.loadDevice(i),a(this,Qb,"f").info("Supported capabilities",{codecs:Bn(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),c(this,Xb,new Ay({media:this.media,peers:this.peers,receiveTransportConnectionManager:new jy({transport:o,statsHandler:this.statsHandler}),sendTransportConnectionManager:new jy({transport:s,statsHandler:this.statsHandler})}),"f"),a(this,Qb,"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){a(this,Qb,"f").error("initialize()",{error:e});const t=e instanceof tr&&"device not supported"===e.message,r=e instanceof Error&&"RTCPeerConnection is not defined"===e.message;if(t||r)throw new An("Device not supported",An.UNSUPPORTED_DEVICE_CODE);throw new Error("Error initialize engine")}}))}release(e){var t;return o(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(),this.peers.reset(),yield this.network.closeSendTransport(),yield this.network.closeReceiveTransport(),yield this.media.unpublishTracks(),e||(yield this.media.clearTracks()),this.eventsQueue.removeListener("message"),this.dataChannelsManager.closeAllDataChannels(),this.channelEventsHandler.reset(),this.mediaSoupEventsHandler.reset(),this.removeClientEventEmitterListeners(),yield this.network.reset(),this.socket.disconnect(),dr.clear(),c(this,Xb,void 0,"f"),this.statsHandler.clear(),a(this,Qb,"f").debug("release()",{socketId:this.myPeerId})}catch(e){throw a(this,Qb,"f").error("release()",{error:e}),new Error("Error release engine")}finally{this.isReleasing=!1}}}))}releaseForRejoin(){var e;return o(this,void 0,void 0,(function*(){if(!this.isReleasing){this.isReleasing=!0;try{this.state.isJoined=!1,this.state.reset(),this.myPeer.delete(),null===(e=this.webRtcIssueDetector)||void 0===e||e.stopWatchingNewPeerConnections(),this.peers.reset(),yield this.network.closeSendTransport(),yield this.network.closeReceiveTransport(),this.eventsQueue.removeListener("message"),this.dataChannelsManager.closeAllDataChannels(),this.channelEventsHandler.reset(),this.mediaSoupEventsHandler.reset(),this.removeClientEventEmitterListeners(),yield this.network.reset(),this.socket.disconnect(),dr.clear(),a(this,Qb,"f").debug("release()",{socketId:this.myPeerId})}catch(e){throw a(this,Qb,"f").error("release()",{error:e}),new Error("Error release engine")}finally{this.isReleasing=!1}}}))}removeClientEventEmitterListeners(){Array.from(Object.values(Kr)).forEach((e=>this.internalEventEmitter.removeAllListeners(e)))}getPeers(){return this.peers.all()}get myPeerId(){return this.myPeer.id}confirmActivity(){return o(this,void 0,void 0,(function*(){this.network.checkSocketConnectionActivity(),yield this.socket.request(mr)}))}join(e){return o(this,void 0,void 0,(function*(){const t=()=>o(this,void 0,void 0,(function*(){this.watchClientEvents(),yield this.connectToSocketServerWithRetry(e),yield this.performJoin({appData:e.appData})}));try{a(this,Qb,"f").debug("join()",{params:e}),this.state.isChannelJoining=!0,yield Un(t,{maxRetries:4,minBackoffDelayMs:150,maxBackoffDelayMs:5e3,actionName:"joinWithRetry",logger:a(this,Yb,"f").call(this,"RetryJoinNode"),onError:()=>o(this,void 0,void 0,(function*(){yield this.releaseForRejoin()}))})}catch(e){throw a(this,Qb,"f").error("join()",{error:e}),e}finally{this.state.isChannelJoining=!1,this.rejoinRequested=!1}}))}loadPeers(e){return o(this,void 0,void 0,(function*(){yield this.peers.load(e)}))}setPeer(e,t=!0){return this.peers.add(e,t)}removePeer(e){this.peers.remove(e)}updateAppData(e){return o(this,void 0,void 0,(function*(){const t=this.myPeer.get();if(!t)throw new Error("Need join to channel first");try{jn(e),yield this.network.updatePeerAppData({peerId:t.id,appData:e})}catch(e){throw a(this,Qb,"f").error("updateAppData()",{error:e}),new Error("Can not update peer appData")}}))}createCameraVideoTrack(e){return o(this,void 0,void 0,(function*(){const t=Gl.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 Rf&&(r.setLabel((null==e?void 0:e.isPreview)?Vn.CameraPreview:Vn.Camera),r.setEncoderConfig(t.encoderConfig),r.setTransformParams(Gl.getVideoTrackTransformParams(r.mediaStreamTrack))),this.media.setTrack(r),a(this,Qb,"f").debug("createCameraVideoTrack()",{trackParams:t}),r}catch(e){throw a(this,Qb,"f").error("createCameraVideoTrack()",{error:e,trackParams:t}),new Error(`Can not create camera track: ${e.message}`)}}))}createMicrophoneAudioTrack(e){return o(this,void 0,void 0,(function*(){try{const[t]=yield this.media.createUserMediaTracks({video:!1,audio:null==e?void 0:e.audio});if(t.setLabel((null==e?void 0:e.isPreview)?Vn.MicrophonePreview:Vn.Microphone),t.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),(null==e?void 0:e.encoderConfig)&&t.setEncoderConfig(e.encoderConfig),"audio"===t.kind&&(null==e?void 0:e.noiseSuppression))try{yield t.enableNoiseSuppression()}catch(e){a(this,Qb,"f").warn("Failed to start noise suppression, featured original track",{label:t.getLabel()})}return this.media.setTrack(t),a(this,Qb,"f").debug("createMicrophoneAudioTrack()",{options:e}),t}catch(t){throw a(this,Qb,"f").error("createMicrophoneAudioTrack()",{error:t,options:e}),new Error(`Can not create microphone track: ${t.message}`)}}))}createScreenMediaTracks(e){return o(this,void 0,void 0,(function*(){const t=Gl.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=>{a(this,Qb,"f").error("Failed to unpublish media track",{track:r,error:cr(e)})}))}),{once:!0}),r.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),r instanceof Rf){r.setLabel(Vn.ScreenVideo),r.setEncoderConfig(t.encoderConfig);const e=Gl.getVideoTrackTransformParams(r.mediaStreamTrack);return r.setTransformParams(e),this.media.setTrack(r),void a(this,Qb,"f").debug("createScreenMediaTrack()",{trackParams:t,transformParams:e,label:r.logCtx})}r.setLabel(Vn.ScreenAudio),(null==e?void 0:e.audioEncoderConfig)&&r.setEncoderConfig(e.audioEncoderConfig),this.media.setTrack(r),a(this,Qb,"f").debug("createScreenMediaTrack()",{trackParams:null==e?void 0:e.audio,encoderConfig:null==e?void 0:e.audioEncoderConfig})})),r}catch(e){throw a(this,Qb,"f").error("createScreenMediaTrack()",{error:e,trackParams:t}),new Error(`Can not create screen media tracks: ${e.message}`)}}))}deleteTrack(e){return this.media.deleteTrack(e)}get canUseNoiseSuppression(){return this.media.isNoiseSuppressorLoaded}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=a(this,Xb,"f"))||void 0===e?void 0:e.getStats()}connectToSocketServerWithRetry(e){return o(this,void 0,void 0,(function*(){return Un((()=>o(this,void 0,void 0,(function*(){return this.connectToSocketServer(e)}))),{maxRetries:15,minBackoffDelayMs:150,maxBackoffDelayMs:5e3,actionName:"connectToSocketServer",logger:a(this,Yb,"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 o(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 a(this,Qb,"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 o(this,void 0,void 0,(function*(){try{return{webSocketUrl:(yield this.loadBalancerClient.getNode(e)).webSocketUrl}}catch(e){throw a(this,Qb,"f").error("getAvailableNode()",{error:"No available nodes"}),e}}))}waitForSocketConnection(){return new Promise(((e,t)=>{const r=n=>o(this,void 0,void 0,(function*(){const{error:i,state:s}=n,o=()=>this.socket.observer.removeListener($n.State,r),a=[$n.Disconnected,$n.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&&[$n.Connected,$n.Reconnected].includes(s)&&(o(),e()))}));this.socket.observer.on($n.State,r)}))}performJoin(e){return o(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,a(this,Qb,"f").debug("Successfully joined channel",{channelId:r}),yield this.dataChannelsManager.createAllDataChannels(),dr.setPeerId(n),dr.setChannelId(r),dr.setAppId(t)}catch(e){throw a(this,Qb,"f").error("performJoin()",{error:e}),e}}))}sendJoinChannelRequestWithRetry(e){return o(this,void 0,void 0,(function*(){return Un((()=>o(this,void 0,void 0,(function*(){return this.sendJoinChannelRequest(e)}))),{maxRetries:3,minBackoffDelayMs:300,actionName:"sendJoinChannelRequest",logger:a(this,Yb,"f").call(this,"RetryJoin")})}))}sendJoinChannelRequest(e){return o(this,void 0,void 0,(function*(){return this.socket.request(lr,e)}))}watchClientEvents(){this.internalEventEmitter.on(Kr.trackProduced,(e=>o(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(Kr.trackUnproduced,(e=>o(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(Kr.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(Kr.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(Kr.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(Kr.trackReopened,(e=>o(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(Kr.trackFailed,(e=>o(this,void 0,void 0,(function*(){this.clientEventEmitter.safeEmit(Br,{label:e.getLabel()})}))))}createSelfPeerTrack(e){var t;return o(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||(a(this,Qb,"f").debug("Triggering channel rejoin required event",{reason:e}),this.rejoinRequested=!0,this.clientEventEmitter.emit(Ar))}watchNetworkState(){this.network.observer.on(xn,(e=>o(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===$n.NeedToJoinFirst&&this.isChannelJoined;if(s&&this.clientEventEmitter.safeEmit(Hr),"server.disconnect"!==r||a(this,Zb,"f")){if(o||s){const e=s?"unauthorized error":"invalid channel state";this.triggerRejoinEventIfAppropriate(e)}i===$n.Disconnected&&this.isChannelJoined&&!a(this,Zb,"f")&&a(this,Qb,"f").info("connection lost",{channel:"socket"}),i===$n.Reconnected&&this.isChannelJoined&&a(this,Qb,"f").info("connection restored",{channel:"socket"}),i===$n.BufferingStart&&(c(this,Zb,!0,"f"),this.clientEventEmitter.safeEmit(Ur),this.waitForReconnectOrTriggerRejoinEventIfAppropriate()),[$n.BufferingEnd,$n.Reconnected].includes(i)&&this.network.isNetworkActive&&(c(this,Zb,!1,"f"),this.clientEventEmitter.safeEmit(zr))}else this.clientEventEmitter.safeEmit(Vr)})))),this.network.observer.on(On,(({state:e,direction:t})=>o(this,void 0,void 0,(function*(){if(!this.isReleasing&&(["disconnected","failed"].includes(e)&&this.isChannelJoined&&!a(this,Zb,"f")&&(c(this,Zb,!0,"f"),a(this,Qb,"f").info("connection lost",{channel:"webrtc-transport",direction:t}),this.clientEventEmitter.safeEmit(Ur),this.waitForReconnectOrTriggerRejoinEventIfAppropriate()),"reconnected"===e&&this.isChannelJoined&&a(this,Qb,"f").info("connection restored",{channel:"webrtc-transport",direction:t}),"reconnected"===e&&this.isChannelJoined&&a(this,Zb,"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;c(this,Zb,!1,"f"),this.clientEventEmitter.safeEmit(zr)}}))))}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){a(this,Qb,"f").error("Failed to add watchDocumentUnload listener",{channelId:this.state.channelId})}}waitForReconnectOrTriggerRejoinEventIfAppropriate(){a(this,Qb,"f").info("Start waiting for seamless reconnect and check loadbalancer availability",{case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"});let e=0;const t=setInterval((()=>o(this,void 0,void 0,(function*(){try{if(!a(this,Zb,"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){a(this,Qb,"f").error("Check failed",{error:cr(e),case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"})}}))),3e3)}};Qb=new WeakMap,Yb=new WeakMap,Zb=new WeakMap,Xb=new WeakMap,tw=n([ot(),i(0,ct(zn.CallState)),i(1,ct(zn.MyPeer)),i(2,ct(zn.LoggerFactory)),i(3,ct(zn.MediaSoupEventHandler)),i(4,ct(zn.ChannelEventHandler)),i(5,ct(zn.ChannelStateSynchronizer)),i(6,ct(zn.PeerTrackFactory)),i(7,ct(zn.Peers)),i(8,ct(zn.System)),i(9,ct(zn.Media)),i(10,ct(zn.Network)),i(11,ct(zn.LoadBalancerApiClient)),i(12,ct(zn.SocketIO)),i(13,ct(zn.EventsQueue)),i(14,ct(zn.ClientEventEmitter)),i(15,ct(zn.InternalEventEmitter)),i(16,ct(zn.StatsHandler)),i(17,ct(zn.DataChannelsManager)),i(18,ct(zn.WebRTCIssueDetector)),s("design:paramtypes",[Kn,Jl,Function,Tf,zh,Wh,Function,Object,Ly,Gl,Th,Sy,Rh,Fh,_t,_t,zy,ew,Zt])],tw);var rw=tw,nw={},iw={},sw={},ow={exports:{}};
|
|
31
|
+
let Ws;ks.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,Fs.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),Fs.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),Fs.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(){Fs.debug("stop()"),this.stopping=!0;for(const e of this.pendingTasks.values())Fs.debug(`stop() | stopping task [name:${e.name}]`),e.reject(new Ns);this.stopping=!1}remove(e){Fs.debug(`remove() [taskIdx:${e}]`);const t=Array.from(this.pendingTasks.values())[e];t?t.reject(new Bs):Fs.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(Fs.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 qs="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:u):e=>(Ws||(Ws=Promise.resolve())).then(e).catch((e=>setTimeout((()=>{throw e}),0))),Us={};Object.defineProperty(Us,"__esModule",{value:!0}),Us.Producer=void 0;const zs=li,Vs=Xt,Hs=new oi.Logger("Producer");class $s 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,Hs.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||(Hs.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(Hs.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new Vs.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){Hs.debug("pause()"),this._closed?Hs.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(){Hs.debug("resume()"),this._closed?Hs.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(Hs.debug("replaceTrack() [track:%o]",e),this._closed){if(e&&this._stopTracks)try{e.stop()}catch(e){}throw new Vs.InvalidStateError("closed")}if(e&&"ended"===e.readyState)throw new Vs.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()):Hs.debug("replaceTrack() | same track, ignored")}async setMaxSpatialLayer(e){if(this._closed)throw new Vs.InvalidStateError("closed");if("video"!==this._kind)throw new Vs.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 Vs.InvalidStateError("closed");if("object"!=typeof e)throw new TypeError("invalid params");await new Promise(((t,r)=>{this.safeEmit("@setrtpencodingparameters",e,t,r)}))}onTrackEnded(){Hs.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){}}}Us.Producer=$s;var Ks={};Object.defineProperty(Ks,"__esModule",{value:!0}),Ks.Consumer=void 0;const Gs=li,Js=Xt,Qs=new oi.Logger("Consumer");class Ys extends Gs.EnhancedEventEmitter{constructor({id:e,localId:t,producerId:r,rtpReceiver:n,track:i,rtpParameters:s,appData:o}){super(),this._closed=!1,this._observer=new Gs.EnhancedEventEmitter,Qs.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||(Qs.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(Qs.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new Js.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){Qs.debug("pause()"),this._closed?Qs.error("pause() | Consumer closed"):this._paused?Qs.debug("pause() | Consumer is already paused"):(this._paused=!0,this._track.enabled=!1,this.emit("@pause"),this._observer.safeEmit("pause"))}resume(){Qs.debug("resume()"),this._closed?Qs.error("resume() | Consumer closed"):this._paused?(this._paused=!1,this._track.enabled=!0,this.emit("@resume"),this._observer.safeEmit("resume")):Qs.debug("resume() | Consumer is already resumed")}onTrackEnded(){Qs.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){}}}Ks.Consumer=Ys;var Zs={};Object.defineProperty(Zs,"__esModule",{value:!0}),Zs.DataProducer=void 0;const Xs=li,eo=Xt,to=new oi.Logger("DataProducer");class ro extends Xs.EnhancedEventEmitter{constructor({id:e,dataChannel:t,sctpStreamParameters:r,appData:n}){super(),this._closed=!1,this._observer=new Xs.EnhancedEventEmitter,to.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||(to.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(to.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}send(e){if(to.debug("send()"),this._closed)throw new eo.InvalidStateError("closed");this._dataChannel.send(e)}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(to.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?to.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):to.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(to.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(()=>{this._closed||to.warn('DataChannel "message" event in a DataProducer, message discarded')})),this._dataChannel.addEventListener("bufferedamountlow",(()=>{this._closed||this.safeEmit("bufferedamountlow")}))}}Zs.DataProducer=ro;var no={};Object.defineProperty(no,"__esModule",{value:!0}),no.DataConsumer=void 0;const io=li,so=new oi.Logger("DataConsumer");class oo extends io.EnhancedEventEmitter{constructor({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:n,appData:i}){super(),this._closed=!1,this._observer=new io.EnhancedEventEmitter,so.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||(so.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"))}transportClosed(){this._closed||(so.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(so.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?so.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",t.sctpCauseCode,t.message):so.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(so.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)}))}}no.DataConsumer=oo;var ao=u&&u.__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]}),co=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),uo=u&&u.__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]&&ao(r,t,n[i]);return co(r,t),r}}(),lo=u&&u.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ss,"__esModule",{value:!0}),Ss.Transport=void 0;const po=ks,ho=lo(qs),fo=oi,mo=li,go=Xt,vo=uo(Ii),yo=uo(Mi),bo=Us,wo=Ks,_o=Zs,So=no,ko=new fo.Logger("Transport");class Co{constructor(e){this.consumerOptions=e,this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class Ro extends mo.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 po.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 mo.EnhancedEventEmitter,ko.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=vo.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){ko.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 go.InvalidStateError("closed");return this._handler.getTransportStats()}async restartIce({iceParameters:e}){if(ko.debug("restartIce()"),this._closed)throw new go.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(ko.debug("updateIceServers()"),this._closed)throw new go.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(ko.debug("produce() [track:%o]",e),this._closed)throw new go.InvalidStateError("closed");if(!e)throw new TypeError("missing track");if("send"!==this._direction)throw new go.UnsupportedError("not a sending Transport");if(!this._canProduceByKind[e.kind])throw new go.UnsupportedError(`cannot produce ${e.kind}`);if("ended"===e.readyState)throw new go.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{yo.validateRtpParameters(l);const{id:t}=await new Promise(((t,r)=>{this.safeEmit("produce",{kind:e.kind,rtpParameters:l,appData:c},t,r)})),r=new bo.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(ko.debug("consume()"),this._closed)throw new go.InvalidStateError("closed");if("recv"!==this._direction)throw new go.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=vo.clone(n);if(!yo.canReceive(a,this._extendedRtpCapabilities))throw new go.UnsupportedError("cannot consume this Producer");const c=new Co({id:e,producerId:t,kind:r,rtpParameters:a,streamId:i,onRtpReceiver:s,appData:o});return this._pendingConsumerTasks.push(c),(0,ho.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(ko.debug("produceData()"),this._closed)throw new go.InvalidStateError("closed");if("send"!==this._direction)throw new go.UnsupportedError("not a sending Transport");if(!this._maxSctpMessageSize)throw new go.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});yo.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 _o.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(ko.debug("consumeData()"),this._closed)throw new go.InvalidStateError("closed");if("recv"!==this._direction)throw new go.UnsupportedError("not a receiving Transport");if(!this._maxSctpMessageSize)throw new go.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=vo.clone(r);return yo.validateSctpStreamParameters(o),this._awaitQueue.push((async()=>{const{dataChannel:r}=await this._handler.receiveDataChannel({sctpStreamParameters:o,label:n,protocol:i}),a=new So.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 ko.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 wo.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=yo.generateProbatorRtpParameters(t.rtpParameters);await this._handler.receive([{trackId:"probator",kind:"video",rtpParameters:e}]),ko.debug("createPendingConsumers() | Consumer for RTP probation created"),this._probatorConsumerCreated=!0}catch(e){ko.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 ko.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){ko.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 ko.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){ko.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 ko.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){ko.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 go.InvalidStateError("closed")):this.safeEmit("connect",{dtlsParameters:e},t,r)})),e.on("@icegatheringstatechange",(e=>{e!==this._iceGatheringState&&(ko.debug("ICE gathering state changed to %s",e),this._iceGatheringState=e,this._closed||this.safeEmit("icegatheringstatechange",e))})),e.on("@connectionstatechange",(e=>{e!==this._connectionState&&(ko.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=>ko.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 go.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,ho.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,ho.default)((()=>{this._closed||!1===this._consumerResumeInProgress&&this.resumePendingConsumers()}))})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new go.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)}))}}Ss.Transport=Ro;var Po={},To={},Eo={},Do={exports:{}},Io=Do.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(Io).forEach((function(e){Io[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=Do.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}}))}))}}(Eo);var Mo=Do.exports,xo=/%[sdv%]/g,Oo=function(e){var t=1,r=arguments,n=r.length;return e.replace(xo,(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""}}))},Lo=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 Oo.apply(null,n)},Ao=["v","o","s","i","u","e","p","c","b","t","r","z","a"],jo=["i","c","b","a"],Fo=Eo,No=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||Ao,n=t.innerOrder||jo,i=[];return r.forEach((function(t){Mo[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(Lo(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(Lo(t,r,e))}))}))})),e.media.forEach((function(e){i.push(Lo("m",Mo.m[0],e)),n.forEach((function(t){Mo[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(Lo(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(Lo(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"},Bo=Do.exports;To.grammar=Bo,To.write=No,To.parse=Fo.parse,To.parseParams=Fo.parseParams,To.parseFmtpConfig=Fo.parseFmtpConfig,To.parsePayloads=Fo.parsePayloads,To.parseRemoteCandidates=Fo.parseRemoteCandidates,To.parseImageAttributes=Fo.parseImageAttributes,To.parseSimulcastStreamList=Fo.parseSimulcastStreamList;var Wo={},qo=u&&u.__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]}),Uo=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),zo=u&&u.__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]&&qo(r,t,n[i]);return Uo(r,t),r}}();Object.defineProperty(Wo,"__esModule",{value:!0}),Wo.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=Vo.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}},Wo.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}]}},Wo.getCname=function({offerMediaObject:e}){const t=(e.ssrcs||[]).find((e=>"cname"===e.attribute));if(!t)return"";return t.value},Wo.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=Vo.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 Vo=zo(To);var Ho={};Object.defineProperty(Ho,"__esModule",{value:!0}),Ho.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},Ho.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 $o={};Object.defineProperty($o,"__esModule",{value:!0}),$o.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 Ko={};Object.defineProperty(Ko,"__esModule",{value:!0}),Ko.HandlerInterface=void 0;const Go=li;class Jo extends Go.EnhancedEventEmitter{constructor(){super()}}Ko.HandlerInterface=Jo;var Qo={},Yo={},Zo=u&&u.__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]}),Xo=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ea=u&&u.__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]&&Zo(r,t,n[i]);return Xo(r,t),r}}();Object.defineProperty(Yo,"__esModule",{value:!0}),Yo.OfferMediaSection=Yo.AnswerMediaSection=Yo.MediaSection=void 0;const ta=ea(To),ra=ea(Ii);class na{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}}Yo.MediaSection=na;Yo.AnswerMediaSection=class extends na{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:ia(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r=ra.clone(e.parameters)??{};let n=ra.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=ta.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 ia(e){const t=new RegExp("^(audio|video)/(.+)","i").exec(e.mimeType);if(!t)throw new TypeError("invalid codec.mimeType");return t[2]}Yo.OfferMediaSection=class extends na{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:ia(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:ia(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 sa=u&&u.__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=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),aa=u&&u.__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(Qo,"__esModule",{value:!0}),Qo.RemoteSdp=void 0;const ca=aa(To),da=Yo,ua=new oi.Logger("RemoteSdp");Qo.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){ua.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){ua.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 da.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 da.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?(ua.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 da.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 da.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++,ca.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 la={};Object.defineProperty(la,"__esModule",{value:!0}),la.parse=function(e){const t=pa.exec(e??"");return t?{spatialLayers:Number(t[1]),temporalLayers:Number(t[2])}:{spatialLayers:1,temporalLayers:1}};const pa=new RegExp("^[LS]([1-9]\\d{0,1})T([1-9]\\d{0,1})");var ha=u&&u.__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]}),fa=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),ma=u&&u.__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]&&ha(r,t,n[i]);return fa(r,t),r}}();Object.defineProperty(Po,"__esModule",{value:!0}),Po.Chrome111=void 0;const ga=ma(To),va=oi,ya=ma(Ii),ba=ma(Mi),wa=ma(Wo),_a=ma(Ho),Sa=ma($o),ka=Xt,Ca=Ko,Ra=Qo,Pa=la,Ta=new va.Logger("Chrome111"),Ea={OS:1024,MIS:1024};class Da extends Ca.HandlerInterface{static createFactory(){return()=>new Da}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(Ta.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){Ta.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=ga.parse(t.sdp),n=wa.extractRtpCapabilities({sdpObject:r});return Sa.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Ta.debug("getNativeSctpCapabilities()"),{numStreams:Ea}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),Ta.debug("run()"),this._direction=e,this._remoteSdp=new Ra.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:ba.getSendingRtpParameters("audio",d),video:ba.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:ba.getSendingRemoteRtpParameters("audio",d),video:ba.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)})):(Ta.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(),Ta.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Ta.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Ta.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Ta.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ta.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Ta.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(),Ta.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,Pa.parse)(r.scalabilityMode).temporalLayers:3;t>e&&(e=t)}t.forEach(((t,r)=>{t.rid=`r${r}`,t.scalabilityMode=`L1T${e}`}))}const s=ya.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=ba.reduceCodecs(s.codecs,n);const o=ya.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=ba.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=ga.parse(d.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u}),Ta.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d);const l=c.mid;s.mid=l,u=ga.parse(this._pc.localDescription.sdp);const p=u.media[a.idx];if(s.rtcp.cname=wa.getCname({offerMediaObject:p}),t)if(1===t.length){const e=_a.getRtpEncodings({offerMediaObject:p});Object.assign(e[0],t[0]),s.encodings=e}else s.encodings=t;else s.encodings=_a.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 Ta.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(),Ta.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();Ta.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ta.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Ta.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();Ta.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ta.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Ta.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();Ta.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ta.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Ta.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Ta.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(),Ta.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();Ta.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ta.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Ta.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();Ta.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ta.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};Ta.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Ea.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=ga.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Ta.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()};Ta.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;Ta.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()};Ta.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=ga.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));wa.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:ga.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Ta.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){Ta.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()};Ta.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ta.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){Ta.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()};Ta.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ta.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){Ta.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()};Ta.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ta.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};Ta.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()};Ta.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=ga.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Ta.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=ga.parse(this._pc.localDescription.sdp));const r=wa.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 ka.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')}}Po.Chrome111=Da;var Ia={},Ma=u&&u.__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]}),xa=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Oa=u&&u.__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]&&Ma(r,t,n[i]);return xa(r,t),r}}();Object.defineProperty(Ia,"__esModule",{value:!0}),Ia.Chrome74=void 0;const La=Oa(To),Aa=oi,ja=Oa(Ii),Fa=Oa(Mi),Na=Oa(Wo),Ba=Oa(Ho),Wa=Oa($o),qa=Xt,Ua=Ko,za=Qo,Va=la,Ha=new Aa.Logger("Chrome74"),$a={OS:1024,MIS:1024};class Ka extends Ua.HandlerInterface{static createFactory(){return()=>new Ka}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(Ha.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){Ha.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=La.parse(t.sdp),n=Na.extractRtpCapabilities({sdpObject:r});return Wa.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Ha.debug("getNativeSctpCapabilities()"),{numStreams:$a}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Ha.debug("run()"),this._direction=e,this._remoteSdp=new za.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Fa.getSendingRtpParameters("audio",d),video:Fa.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Fa.getSendingRemoteRtpParameters("audio",d),video:Fa.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)})):(Ha.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(),Ha.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Ha.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Ha.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Ha.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ha.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Ha.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(),Ha.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=ja.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=Fa.reduceCodecs(i.codecs,n);const s=ja.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=Fa.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=La.parse(d.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u});let l=!1;const p=(0,Va.parse)((t??[{}])[0].scalabilityMode);t&&1===t.length&&p.spatialLayers>1&&"video/vp9"===i.codecs[0].mimeType.toLowerCase()&&(Ha.debug("send() | enabling legacy simulcast for VP9 SVC"),l=!0,u=La.parse(d.sdp),c=u.media[o.idx],Ba.addLegacySimulcast({offerMediaObject:c,numStreams:p.spatialLayers}),d={type:"offer",sdp:La.write(u)}),Ha.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d);const h=a.mid;if(i.mid=h,u=La.parse(this._pc.localDescription.sdp),c=u.media[o.idx],i.rtcp.cname=Na.getCname({offerMediaObject:c}),t)if(1===t.length){let e=Ba.getRtpEncodings({offerMediaObject:c});Object.assign(e[0],t[0]),l&&(e=[e[0]]),i.encodings=e}else i.encodings=t;else i.encodings=Ba.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 Ha.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(),Ha.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();Ha.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ha.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Ha.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();Ha.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ha.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Ha.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();Ha.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ha.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Ha.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Ha.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(),Ha.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();Ha.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ha.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Ha.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();Ha.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ha.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};Ha.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%$a.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=La.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Ha.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()};Ha.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;Ha.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()};Ha.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=La.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));Na.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:La.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Ha.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){Ha.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()};Ha.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ha.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){Ha.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()};Ha.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ha.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){Ha.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()};Ha.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ha.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};Ha.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()};Ha.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=La.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Ha.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=La.parse(this._pc.localDescription.sdp));const r=Na.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 qa.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')}}Ia.Chrome74=Ka;var Ga={},Ja=u&&u.__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=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ya=u&&u.__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]&&Ja(r,t,n[i]);return Qa(r,t),r}}();Object.defineProperty(Ga,"__esModule",{value:!0}),Ga.Chrome70=void 0;const Za=Ya(To),Xa=oi,ec=Ya(Ii),tc=Ya(Mi),rc=Ya(Wo),nc=Ya(Ho),ic=Ko,sc=Qo,oc=la,ac=new Xa.Logger("Chrome70"),cc={OS:1024,MIS:1024};class dc extends ic.HandlerInterface{static createFactory(){return()=>new dc}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(ac.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){ac.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);return rc.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return ac.debug("getNativeSctpCapabilities()"),{numStreams:cc}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){ac.debug("run()"),this._direction=e,this._remoteSdp=new sc.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),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:"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(ac.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){ac.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(ac.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});ac.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};ac.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};ac.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();ac.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(),ac.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const i=ec.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=tc.reduceCodecs(i.codecs,n);const s=ec.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=tc.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=Za.parse(d.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:u}),t&&t.length>1&&(ac.debug("send() | enabling legacy simulcast"),u=Za.parse(d.sdp),c=u.media[o.idx],nc.addLegacySimulcast({offerMediaObject:c,numStreams:t.length}),d={type:"offer",sdp:Za.write(u)});let l=!1;const p=(0,oc.parse)((t??[{}])[0].scalabilityMode);if(t&&1===t.length&&p.spatialLayers>1&&"video/vp9"===i.codecs[0].mimeType.toLowerCase()&&(ac.debug("send() | enabling legacy simulcast for VP9 SVC"),l=!0,u=Za.parse(d.sdp),c=u.media[o.idx],nc.addLegacySimulcast({offerMediaObject:c,numStreams:p.spatialLayers}),d={type:"offer",sdp:Za.write(u)}),ac.debug("send() | calling pc.setLocalDescription() [offer:%o]",d),await this._pc.setLocalDescription(d),t){ac.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=Za.parse(this._pc.localDescription.sdp),c=u.media[o.idx],i.rtcp.cname=rc.getCname({offerMediaObject:c}),i.encodings=nc.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 ac.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(),ac.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();ac.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ac.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?ac.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):ac.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(),ac.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();ac.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};ac.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertSendDirection(),ac.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();ac.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};ac.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};ac.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%cc.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}),ac.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()};ac.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;ac.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()};ac.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));rc.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Za.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),ac.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){ac.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()};ac.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ac.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};ac.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()};ac.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})}ac.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=rc.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')}}Ga.Chrome70=dc;var uc={},lc={};Object.defineProperty(lc,"__esModule",{value:!0}),lc.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},lc.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 pc=u&&u.__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]}),hc=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),fc=u&&u.__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]&&pc(r,t,n[i]);return hc(r,t),r}}();Object.defineProperty(uc,"__esModule",{value:!0}),uc.Chrome67=void 0;const mc=fc(To),gc=oi,vc=fc(Ii),yc=fc(Mi),bc=fc(Wo),wc=fc(lc),_c=Ko,Sc=Qo,kc=new gc.Logger("Chrome67"),Cc={OS:1024,MIS:1024};class Rc extends _c.HandlerInterface{static createFactory(){return()=>new Rc}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(kc.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){kc.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=mc.parse(t.sdp);return bc.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return kc.debug("getNativeSctpCapabilities()"),{numStreams:Cc}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){kc.debug("run()"),this._direction=e,this._remoteSdp=new Sc.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:yc.getSendingRtpParameters("audio",d),video:yc.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:yc.getSendingRemoteRtpParameters("audio",d),video:yc.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(kc.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){kc.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(kc.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});kc.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};kc.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};kc.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();kc.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(),kc.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&kc.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=mc.parse(s.sdp);const a=vc.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=yc.reduceCodecs(a.codecs);const c=vc.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=yc.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(kc.debug("send() | enabling simulcast"),o=mc.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),wc.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:mc.write(o)}),kc.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=mc.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=bc.getCname({offerMediaObject:i}),a.encodings=wc.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()};kc.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(),kc.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();kc.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void kc.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()};kc.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?kc.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):kc.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(),kc.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(),kc.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};kc.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Cc.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=mc.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),kc.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()};kc.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;kc.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()};kc.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=mc.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));bc.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:mc.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),kc.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){kc.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()};kc.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();kc.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};kc.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()};kc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=mc.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}kc.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=mc.parse(this._pc.localDescription.sdp));const r=bc.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')}}uc.Chrome67=Rc;var Pc={},Tc=u&&u.__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]}),Ec=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Dc=u&&u.__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]&&Tc(r,t,n[i]);return Ec(r,t),r}}();Object.defineProperty(Pc,"__esModule",{value:!0}),Pc.Chrome55=void 0;const Ic=Dc(To),Mc=oi,xc=Xt,Oc=Dc(Ii),Lc=Dc(Mi),Ac=Dc(Wo),jc=Dc(lc),Fc=Ko,Nc=Qo,Bc=new Mc.Logger("Chrome55"),Wc={OS:1024,MIS:1024};class qc extends Fc.HandlerInterface{static createFactory(){return()=>new qc}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(Bc.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){Bc.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=Ic.parse(t.sdp);return Ac.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Bc.debug("getNativeSctpCapabilities()"),{numStreams:Wc}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Bc.debug("run()"),this._direction=e,this._remoteSdp=new Nc.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:Lc.getSendingRtpParameters("audio",d),video:Lc.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Lc.getSendingRemoteRtpParameters("audio",d),video:Lc.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(Bc.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){Bc.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(Bc.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Bc.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Bc.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Bc.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Bc.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(),Bc.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&Bc.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=Ic.parse(s.sdp);const a=Oc.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=Lc.reduceCodecs(a.codecs);const c=Oc.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=Lc.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(Bc.debug("send() | enabling simulcast"),o=Ic.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),jc.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Ic.write(o)}),Bc.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Ic.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=Ac.getCname({offerMediaObject:i}),a.encodings=jc.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()};Bc.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(),Bc.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();Bc.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void Bc.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()};Bc.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 xc.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new xc.UnsupportedError(" not implemented")}async setRtpEncodingParameters(e,t){throw new xc.UnsupportedError("not supported")}async getSenderStats(e){throw new xc.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};Bc.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Wc.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Ic.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Bc.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()};Bc.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;Bc.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()};Bc.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=Ic.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));Ac.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:Ic.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),Bc.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){Bc.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()};Bc.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Bc.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new xc.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};Bc.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()};Bc.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Ic.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Bc.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=Ic.parse(this._pc.localDescription.sdp));const r=Ac.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')}}Pc.Chrome55=qc;var Uc={},zc=u&&u.__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]}),Vc=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Hc=u&&u.__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 Vc(r,t),r}}();Object.defineProperty(Uc,"__esModule",{value:!0}),Uc.Firefox120=void 0;const $c=Hc(To),Kc=oi,Gc=Xt,Jc=Hc(Ii),Qc=Hc(Mi),Yc=Hc(Wo),Zc=Hc(Ho),Xc=Ko,ed=Qo,td=la,rd=new Kc.Logger("Firefox120"),nd={OS:16,MIS:2048};class id extends Xc.HandlerInterface{static createFactory(){return()=>new id}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(rd.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){rd.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=$c.parse(n.sdp);return Yc.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 rd.debug("getNativeSctpCapabilities()"),{numStreams:nd}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),rd.debug("run()"),this._direction=e,this._remoteSdp=new ed.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Qc.getSendingRtpParameters("audio",d),video:Qc.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Qc.getSendingRemoteRtpParameters("audio",d),video:Qc.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(rd.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 Gc.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),rd.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});rd.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};rd.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};rd.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();rd.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(),rd.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=Jc.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Qc.reduceCodecs(s.codecs,n);const o=Jc.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Qc.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=$c.parse(c.sdp);this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:d});const u=(0,td.parse)((t??[{}])[0].scalabilityMode);rd.debug("send() | calling pc.setLocalDescription() [offer:%o]",c),await this._pc.setLocalDescription(c);const l=a.mid;s.mid=l,d=$c.parse(this._pc.localDescription.sdp);const p=d.media[d.media.length-1];if(s.rtcp.cname=Yc.getCname({offerMediaObject:p}),t)if(1===t.length){const e=Zc.getRtpEncodings({offerMediaObject:p});Object.assign(e[0],t[0]),s.encodings=e}else s.encodings=t;else s.encodings=Zc.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 rd.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(),rd.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();rd.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};rd.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),rd.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();rd.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};rd.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),rd.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();rd.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};rd.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?rd.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):rd.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(),rd.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();rd.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};rd.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),rd.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();rd.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};rd.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};rd.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%nd.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=$c.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),rd.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()};rd.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;rd.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()};rd.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=$c.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));Yc.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:$c.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),rd.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){rd.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()};rd.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();rd.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){rd.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()};rd.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();rd.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){rd.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()};rd.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();rd.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};rd.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()};rd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=$c.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}rd.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=$c.parse(this._pc.localDescription.sdp));const r=Yc.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 Gc.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')}}Uc.Firefox120=id;var sd={},od=u&&u.__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]}),ad=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),cd=u&&u.__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]&&od(r,t,n[i]);return ad(r,t),r}}();Object.defineProperty(sd,"__esModule",{value:!0}),sd.Firefox60=void 0;const dd=cd(To),ud=oi,ld=Xt,pd=cd(Ii),hd=cd(Mi),fd=cd(Wo),md=cd(Ho),gd=Ko,vd=Qo,yd=la,bd=new ud.Logger("Firefox60"),wd={OS:16,MIS:2048};class _d extends gd.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"Firefox60"}close(){if(bd.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){bd.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=dd.parse(o.sdp);return fd.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 bd.debug("getNativeSctpCapabilities()"),{numStreams:wd}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),bd.debug("run()"),this._direction=e,this._remoteSdp=new vd.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:hd.getSendingRtpParameters("audio",d),video:hd.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:hd.getSendingRemoteRtpParameters("audio",d),video:hd.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(bd.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 ld.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),bd.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});bd.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};bd.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};bd.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();bd.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(),bd.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),t&&((t=pd.clone(t)).forEach(((e,t)=>{e.rid=`r${t}`})),t.reverse());const i=pd.clone(this._sendingRtpParametersByKind[e.kind]);i.codecs=hd.reduceCodecs(i.codecs,n);const s=pd.clone(this._sendingRemoteRtpParametersByKind[e.kind]);s.codecs=hd.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=dd.parse(a.sdp);this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:c});const d=(0,yd.parse)((t??[{}])[0].scalabilityMode);bd.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);const u=o.mid;i.mid=u,c=dd.parse(this._pc.localDescription.sdp);const l=c.media[c.media.length-1];if(i.rtcp.cname=fd.getCname({offerMediaObject:l}),t)if(1===t.length){const e=md.getRtpEncodings({offerMediaObject:l});Object.assign(e[0],t[0]),i.encodings=e}else i.encodings=t.reverse();else i.encodings=md.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 bd.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(),bd.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();bd.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};bd.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),bd.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();bd.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};bd.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),bd.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();bd.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};bd.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?bd.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):bd.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(),bd.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();bd.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};bd.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),bd.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();bd.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};bd.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};bd.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%wd.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=dd.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),bd.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()};bd.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;bd.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()};bd.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=dd.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));fd.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:dd.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),bd.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){bd.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()};bd.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();bd.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){bd.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()};bd.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();bd.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){bd.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()};bd.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();bd.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};bd.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()};bd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=dd.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}bd.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=dd.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 ld.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')}}sd.Firefox60=_d;var Sd={},kd=u&&u.__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]}),Cd=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Rd=u&&u.__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]&&kd(r,t,n[i]);return Cd(r,t),r}}();Object.defineProperty(Sd,"__esModule",{value:!0}),Sd.Safari12=void 0;const Pd=Rd(To),Td=oi,Ed=Rd(Ii),Dd=Rd(Mi),Id=Rd(Wo),Md=Rd(Ho),xd=Rd($o),Od=Xt,Ld=Ko,Ad=Qo,jd=la,Fd=new Td.Logger("Safari12"),Nd={OS:1024,MIS:1024};class Bd extends Ld.HandlerInterface{static createFactory(){return()=>new Bd}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(Fd.debug("close()"),!this._closed){if(this._closed=!0,this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}}async getNativeRtpCapabilities(){Fd.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=Pd.parse(t.sdp),n=Id.extractRtpCapabilities({sdpObject:r});return xd.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Fd.debug("getNativeSctpCapabilities()"),{numStreams:Nd}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),Fd.debug("run()"),this._direction=e,this._remoteSdp=new Ad.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._sendingRtpParametersByKind={audio:Dd.getSendingRtpParameters("audio",d),video:Dd.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Dd.getSendingRemoteRtpParameters("audio",d),video:Dd.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(Fd.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(),Fd.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Fd.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Fd.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Fd.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Fd.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Fd.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(),Fd.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const s=Ed.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Dd.reduceCodecs(s.codecs,n);const o=Ed.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Dd.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=Pd.parse(u.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:l});const p=(0,jd.parse)((t??[{}])[0].scalabilityMode);t&&t.length>1&&(Fd.debug("send() | enabling legacy simulcast"),l=Pd.parse(u.sdp),d=l.media[a.idx],Md.addLegacySimulcast({offerMediaObject:d,numStreams:t.length}),u={type:"offer",sdp:Pd.write(l)}),Fd.debug("send() | calling pc.setLocalDescription() [offer:%o]",u),await this._pc.setLocalDescription(u);const h=c.mid;if(s.mid=h,l=Pd.parse(this._pc.localDescription.sdp),d=l.media[a.idx],s.rtcp.cname=Id.getCname({offerMediaObject:d}),s.encodings=Md.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 Fd.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;Fd.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();Fd.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Fd.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Fd.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();Fd.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Fd.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Fd.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();Fd.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Fd.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Fd.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Fd.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(),Fd.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();Fd.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Fd.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Fd.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();Fd.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Fd.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};Fd.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Nd.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Pd.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Fd.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()};Fd.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;Fd.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()};Fd.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=Pd.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));Id.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Pd.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Fd.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){Fd.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()};Fd.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Fd.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){Fd.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()};Fd.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Fd.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){Fd.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()};Fd.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Fd.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};Fd.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()};Fd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Pd.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Fd.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=Pd.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 Od.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')}}Sd.Safari12=Bd;var Wd={},qd=u&&u.__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]}),Ud=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),zd=u&&u.__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]&&qd(r,t,n[i]);return Ud(r,t),r}}();Object.defineProperty(Wd,"__esModule",{value:!0}),Wd.Safari11=void 0;const Vd=zd(To),Hd=oi,$d=zd(Ii),Kd=zd(Mi),Gd=zd(Wo),Jd=zd(lc),Qd=Ko,Yd=Qo,Zd=new Hd.Logger("Safari11"),Xd={OS:1024,MIS:1024};class eu extends Qd.HandlerInterface{static createFactory(){return()=>new eu}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(Zd.debug("close()"),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){Zd.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=Vd.parse(t.sdp);return Gd.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Zd.debug("getNativeSctpCapabilities()"),{numStreams:Xd}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){Zd.debug("run()"),this._direction=e,this._remoteSdp=new Yd.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:Kd.getSendingRtpParameters("audio",d),video:Kd.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Kd.getSendingRemoteRtpParameters("audio",d),video:Kd.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(Zd.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){Zd.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(Zd.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Zd.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Zd.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Zd.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Zd.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(),Zd.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&Zd.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=Vd.parse(s.sdp);const a=$d.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=Kd.reduceCodecs(a.codecs);const c=$d.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=Kd.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(Zd.debug("send() | enabling simulcast"),o=Vd.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),Jd.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Vd.write(o)}),Zd.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Vd.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=Gd.getCname({offerMediaObject:i}),a.encodings=Jd.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()};Zd.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();Zd.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void Zd.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()};Zd.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?Zd.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Zd.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(),Zd.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(),Zd.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};Zd.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Xd.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Vd.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Zd.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()};Zd.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;Zd.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()};Zd.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",r),await this._pc.setRemoteDescription(r);let n=await this._pc.createAnswer();const i=Vd.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));Gd.applyCodecParameters({offerRtpParameters:r,answerMediaObject:s})}n={type:"answer",sdp:Vd.write(i)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:i}),Zd.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){Zd.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()};Zd.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Zd.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};Zd.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()};Zd.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Vd.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Zd.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=Vd.parse(this._pc.localDescription.sdp));const r=Gd.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')}}Wd.Safari11=eu;var tu={},ru={},nu=u&&u.__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]}),iu=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),su=u&&u.__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]&&nu(r,t,n[i]);return iu(r,t),r}}();Object.defineProperty(ru,"__esModule",{value:!0}),ru.getCapabilities=function(){const e=RTCRtpReceiver.getCapabilities(),t=ou.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},ru.mangleRtpParameters=function(e){const t=ou.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 ou=su(Ii);var au=u&&u.__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]}),cu=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),du=u&&u.__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]&&au(r,t,n[i]);return cu(r,t),r}}();Object.defineProperty(tu,"__esModule",{value:!0}),tu.Edge11=void 0;const uu=oi,lu=Xt,pu=du(Ii),hu=du(Mi),fu=du(ru),mu=Ko,gu=new uu.Logger("Edge11");class vu extends mu.HandlerInterface{static createFactory(){return()=>new vu}constructor(){super(),this._rtpSenders=new Map,this._rtpReceivers=new Map,this._nextSendLocalId=0,this._transportReady=!1}get name(){return"Edge11"}close(){gu.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 gu.debug("getNativeRtpCapabilities()"),fu.getCapabilities()}async getNativeSctpCapabilities(){return gu.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}){gu.debug("run()"),this._sendingRtpParametersByKind={audio:hu.getSendingRtpParameters("audio",d),video:hu.getSendingRtpParameters("video",d)},this._remoteIceParameters=t,this._remoteIceCandidates=r,this._remoteDtlsParameters=n,this._cname=`CNAME-${pu.generateRandomNumber()}`,this.setIceGatherer({iceServers:s,iceTransportPolicy:o}),this.setIceTransport(),this.setDtlsTransport()}async updateIceServers(e){throw new lu.UnsupportedError("not supported")}async restartIce(e){if(gu.debug("restartIce()"),this._remoteIceParameters=e,this._transportReady){gu.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}){gu.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),this._transportReady||await this.setupTransport({localDtlsRole:"server"}),gu.debug("send() | calling new RTCRtpSender()");const i=new RTCRtpSender(e,this._dtlsTransport),s=pu.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=hu.reduceCodecs(s.codecs,n);const o=s.codecs.some((e=>/.+\/rtx$/i.test(e.mimeType)));t||(t=[{}]);for(const e of t)e.ssrc=pu.generateRandomNumber(),o&&(e.rtx={ssrc:pu.generateRandomNumber()});s.encodings=t,s.rtcp={cname:this._cname,reducedSize:!0,mux:!0};const a=fu.mangleRtpParameters(s);gu.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){gu.debug("stopSending() [localId:%s]",e);const t=this._rtpSenders.get(e);if(!t)throw new Error("RTCRtpSender not found");this._rtpSenders.delete(e);try{gu.debug("stopSending() | calling rtpSender.stop()"),t.stop()}catch(e){throw gu.warn("stopSending() | rtpSender.stop() failed:%o",e),e}}async pauseSending(e){}async resumeSending(e){}async replaceTrack(e,t){t?gu.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):gu.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){gu.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){gu.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 lu.UnsupportedError("not implemented")}async receive(e){const t=[];for(const t of e){const{trackId:e,kind:r}=t;gu.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;gu.debug("receive() | calling new RTCRtpReceiver()");const s=new RTCRtpReceiver(this._dtlsTransport,n);s.addEventListener("error",(e=>{gu.error('rtpReceiver "error" event [event:%o]',e)}));const o=fu.mangleRtpParameters(i);gu.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){gu.debug("stopReceiving() [localId:%s]",t);const e=this._rtpReceivers.get(t);if(!e)throw new Error("RTCRtpReceiver not found");this._rtpReceivers.delete(t);try{gu.debug("stopReceiving() | calling rtpReceiver.stop()"),e.stop()}catch(e){gu.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 lu.UnsupportedError("not implemented")}setIceGatherer({iceServers:e,iceTransportPolicy:t}){const r=new RTCIceGatherer({iceServers:e??[],gatherPolicy:t??"all"});r.addEventListener("error",(e=>{gu.error('iceGatherer "error" event [event:%o]',e)}));try{r.gather()}catch(e){gu.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=>{gu.debug('iceTransport "candidatepairchange" event [pair:%o]',e.pair)})),this._iceTransport=e}setDtlsTransport(){const e=new RTCDtlsTransport(this._iceTransport);e.addEventListener("statechange",(()=>{gu.debug('dtlsTransport "statechange" event [state:%s]',e.state)})),e.addEventListener("dtlsstatechange",(()=>{gu.debug('dtlsTransport "dtlsstatechange" event [state:%s]',e.state),"closed"===e.state&&this.emit("@connectionstatechange","closed")})),e.addEventListener("error",(e=>{gu.error('dtlsTransport "error" event [event:%o]',e)})),this._dtlsTransport=e}async setupTransport({localDtlsRole:e}){gu.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}}tu.Edge11=vu;var yu={},bu=u&&u.__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]}),wu=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),_u=u&&u.__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]&&bu(r,t,n[i]);return wu(r,t),r}}();Object.defineProperty(yu,"__esModule",{value:!0}),yu.ReactNativeUnifiedPlan=void 0;const Su=_u(To),ku=oi,Cu=_u(Ii),Ru=_u(Mi),Pu=_u(Wo),Tu=_u(Ho),Eu=_u($o),Du=Xt,Iu=Ko,Mu=Qo,xu=la,Ou=new ku.Logger("ReactNativeUnifiedPlan"),Lu={OS:1024,MIS:1024};class Au extends Iu.HandlerInterface{static createFactory(){return()=>new Au}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(Ou.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(){Ou.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=Su.parse(t.sdp),n=Pu.extractRtpCapabilities({sdpObject:r});return Eu.addNackSuppportForOpus(n),n}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Ou.debug("getNativeSctpCapabilities()"),{numStreams:Lu}}run({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,proprietaryConstraints:c,extendedRtpCapabilities:d}){this.assertNotClosed(),Ou.debug("run()"),this._direction=e,this._remoteSdp=new Mu.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),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",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(Ou.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(),Ou.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Ou.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Ou.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Ou.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ou.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Ou.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(),Ou.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=Cu.clone(this._sendingRtpParametersByKind[e.kind]);s.codecs=Ru.reduceCodecs(s.codecs,n);const o=Cu.clone(this._sendingRemoteRtpParametersByKind[e.kind]);o.codecs=Ru.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=Su.parse(u.sdp);this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:l});let p=!1;const h=(0,xu.parse)((t??[{}])[0].scalabilityMode);t&&1===t.length&&h.spatialLayers>1&&"video/vp9"===s.codecs[0].mimeType.toLowerCase()&&(Ou.debug("send() | enabling legacy simulcast for VP9 SVC"),p=!0,l=Su.parse(u.sdp),d=l.media[a.idx],Tu.addLegacySimulcast({offerMediaObject:d,numStreams:h.spatialLayers}),u={type:"offer",sdp:Su.write(l)}),Ou.debug("send() | calling pc.setLocalDescription() [offer:%o]",u),await this._pc.setLocalDescription(u);let f=c.mid??void 0;if(f||Ou.warn("send() | missing transceiver.mid (bug in react-native-webrtc, using a workaround"),s.mid=f,l=Su.parse(this._pc.localDescription.sdp),d=l.media[a.idx],s.rtcp.cname=Pu.getCname({offerMediaObject:d}),t)if(1===t.length){let e=Tu.getRtpEncodings({offerMediaObject:d});Object.assign(e[0],t[0]),p&&(e=[e[0]]),s.encodings=e}else s.encodings=t;else s.encodings=Tu.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 Ou.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;Ou.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();Ou.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ou.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Ou.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();Ou.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ou.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Ou.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();Ou.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Ou.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Ou.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Ou.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(),Ou.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();Ou.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ou.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Ou.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();Ou.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Ou.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};Ou.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Lu.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Su.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Ou.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()};Ou.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;Ou.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()};Ou.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=Su.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));Pu.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:Su.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Ou.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){Ou.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()};Ou.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ou.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){Ou.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()};Ou.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ou.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){Ou.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()};Ou.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ou.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};Ou.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()};Ou.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Su.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Ou.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=Su.parse(this._pc.localDescription.sdp));const r=Pu.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 Du.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')}}yu.ReactNativeUnifiedPlan=Au;var ju={},Fu=u&&u.__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]}),Nu=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Bu=u&&u.__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 Nu(r,t),r}}();Object.defineProperty(ju,"__esModule",{value:!0}),ju.ReactNative=void 0;const Wu=Bu(To),qu=oi,Uu=Xt,zu=Bu(Ii),Vu=Bu(Mi),Hu=Bu(Wo),$u=Bu(lc),Ku=Ko,Gu=Qo,Ju=new qu.Logger("ReactNative"),Qu={OS:1024,MIS:1024};class Yu extends Ku.HandlerInterface{static createFactory(){return()=>new Yu}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(Ju.debug("close()"),this._sendStream.release(!1),this._pc)try{this._pc.close()}catch(e){}this.emit("@close")}async getNativeRtpCapabilities(){Ju.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=Wu.parse(t.sdp);return Hu.extractRtpCapabilities({sdpObject:r})}catch(t){try{e.close()}catch(e){}throw t}}async getNativeSctpCapabilities(){return Ju.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}){Ju.debug("run()"),this._direction=e,this._remoteSdp=new Gu.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,planB:!0}),this._sendingRtpParametersByKind={audio:Vu.getSendingRtpParameters("audio",d),video:Vu.getSendingRtpParameters("video",d)},this._sendingRemoteRtpParametersByKind={audio:Vu.getSendingRemoteRtpParameters("audio",d),video:Vu.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(Ju.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){Ju.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(Ju.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Ju.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Ju.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Ju.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Ju.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(),Ju.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),n&&Ju.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=Wu.parse(s.sdp);const a=zu.clone(this._sendingRtpParametersByKind[e.kind]);a.codecs=Vu.reduceCodecs(a.codecs);const c=zu.clone(this._sendingRemoteRtpParametersByKind[e.kind]);if(c.codecs=Vu.reduceCodecs(c.codecs),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:o}),"video"===e.kind&&t&&t.length>1&&(Ju.debug("send() | enabling simulcast"),o=Wu.parse(s.sdp),i=o.media.find((e=>"video"===e.type)),$u.addLegacySimulcast({offerMediaObject:i,track:e,numStreams:t.length}),s={type:"offer",sdp:Wu.write(o)}),Ju.debug("send() | calling pc.setLocalDescription() [offer:%o]",s),await this._pc.setLocalDescription(s),o=Wu.parse(this._pc.localDescription.sdp),i=o.media.find((t=>t.type===e.kind)),a.rtcp.cname=Hu.getCname({offerMediaObject:i}),a.encodings=$u.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()};Ju.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(),Ju.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();Ju.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r);try{await this._pc.setLocalDescription(r)}catch(e){if(0===this._sendStream.getTracks().length)return void Ju.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()};Ju.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 Uu.UnsupportedError("not implemented")}async setMaxSpatialLayer(e,t){throw new Uu.UnsupportedError("not implemented")}async setRtpEncodingParameters(e,t){throw new Uu.UnsupportedError("not implemented")}async getSenderStats(e){throw new Uu.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};Ju.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=Wu.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Ju.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()};Ju.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;Ju.debug("receive() [trackId:%s, kind:%s]",e,n);const s=n;let o=t.streamId??i.rtcp.cname;Ju.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()};Ju.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=Wu.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));Hu.applyCodecParameters({offerRtpParameters:r,answerMediaObject:i})}i={type:"answer",sdp:Wu.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Ju.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){Ju.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()};Ju.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Ju.debug("stopReceiving() | calling pc.setLocalDescription() [answer:%o]",r),await this._pc.setLocalDescription(r)}async pauseReceiving(e){}async resumeReceiving(e){}async getReceiverStats(e){throw new Uu.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};Ju.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()};Ju.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Wu.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Ju.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=Wu.parse(this._pc.localDescription.sdp));const r=Hu.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')}}ju.ReactNative=Yu;var Zu=u&&u.__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]}),Xu=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),el=u&&u.__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]&&Zu(r,t,n[i]);return Xu(r,t),r}}();Object.defineProperty(ii,"__esModule",{value:!0}),ii.Device=void 0,ii.detectDevice=_l;const tl=si.exports,rl=oi,nl=li,il=Xt,sl=el(Ii),ol=el(Mi),al=Ss,cl=Po,dl=Ia,ul=Ga,ll=uc,pl=Pc,hl=Uc,fl=sd,ml=Sd,gl=Wd,vl=tu,yl=yu,bl=ju,wl=new rl.Logger("Device");function _l(e){if(!e&&"object"==typeof navigator&&"ReactNative"===navigator.product)return wl.debug("detectDevice() | React-Native detected"),"undefined"==typeof RTCPeerConnection?void wl.warn("detectDevice() | unsupported react-native-webrtc without RTCPeerConnection, forgot to call registerGlobals()?"):"undefined"!=typeof RTCRtpTransceiver?(wl.debug("detectDevice() | ReactNative UnifiedPlan handler chosen"),"ReactNativeUnifiedPlan"):(wl.debug("detectDevice() | ReactNative PlanB handler chosen"),"ReactNative");if(e||"object"==typeof navigator&&"string"==typeof navigator.userAgent){e??(e=navigator.userAgent);const t=new tl.UAParser(e);wl.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"}wl.warn("detectDevice() | browser not supported [name:%s, version:%s]",n,i)}else wl.warn("detectDevice() | unknown device")}ii.Device=class{constructor({handlerName:e,handlerFactory:t}={}){if(this._loaded=!1,this._observer=new nl.EnhancedEventEmitter,wl.debug("constructor()"),e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(t)this._handlerFactory=t;else{if(e)wl.debug("constructor() | handler given: %s",e);else{if(!(e=_l()))throw new il.UnsupportedError("device not supported");wl.debug("constructor() | detected handler: %s",e)}switch(e){case"Chrome111":this._handlerFactory=cl.Chrome111.createFactory();break;case"Chrome74":this._handlerFactory=dl.Chrome74.createFactory();break;case"Chrome70":this._handlerFactory=ul.Chrome70.createFactory();break;case"Chrome67":this._handlerFactory=ll.Chrome67.createFactory();break;case"Chrome55":this._handlerFactory=pl.Chrome55.createFactory();break;case"Firefox120":this._handlerFactory=hl.Firefox120.createFactory();break;case"Firefox60":this._handlerFactory=fl.Firefox60.createFactory();break;case"Safari12":this._handlerFactory=ml.Safari12.createFactory();break;case"Safari11":this._handlerFactory=gl.Safari11.createFactory();break;case"Edge11":this._handlerFactory=vl.Edge11.createFactory();break;case"ReactNativeUnifiedPlan":this._handlerFactory=yl.ReactNativeUnifiedPlan.createFactory();break;case"ReactNative":this._handlerFactory=bl.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 il.InvalidStateError("not loaded");return this._recvRtpCapabilities}get sctpCapabilities(){if(!this._loaded)throw new il.InvalidStateError("not loaded");return this._sctpCapabilities}get observer(){return this._observer}async load({routerRtpCapabilities:e}){let t;wl.debug("load() [routerRtpCapabilities:%o]",e);try{if(this._loaded)throw new il.InvalidStateError("already loaded");const r=sl.clone(e);ol.validateRtpCapabilities(r),t=this._handlerFactory();const n=await t.getNativeRtpCapabilities();wl.debug("load() | got native RTP capabilities:%o",n);const i=sl.clone(n);ol.validateRtpCapabilities(i),this._extendedRtpCapabilities=ol.getExtendedRtpCapabilities(i,r),wl.debug("load() | got extended RTP capabilities:%o",this._extendedRtpCapabilities),this._canProduceByKind.audio=ol.canSend("audio",this._extendedRtpCapabilities),this._canProduceByKind.video=ol.canSend("video",this._extendedRtpCapabilities),this._recvRtpCapabilities=ol.getRecvRtpCapabilities(this._extendedRtpCapabilities),ol.validateRtpCapabilities(this._recvRtpCapabilities),wl.debug("load() | got receiving RTP capabilities:%o",this._recvRtpCapabilities),this._sctpCapabilities=await t.getNativeSctpCapabilities(),wl.debug("load() | got native SCTP capabilities:%o",this._sctpCapabilities),ol.validateSctpCapabilities(this._sctpCapabilities),wl.debug("load() succeeded"),this._loaded=!0,t.close()}catch(e){throw t&&t.close(),e}}canProduce(e){if(!this._loaded)throw new il.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 wl.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 wl.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 il.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 al.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 Sl={},kl={};Object.defineProperty(kl,"__esModule",{value:!0});var Cl={};Object.defineProperty(Cl,"__esModule",{value:!0}),function(e){var t=u&&u.__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=u&&u.__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(ii,e),r(Ss,e),r(Us,e),r(Ks,e),r(Zs,e),r(no,e),r(kl,e),r(Cl,e),r(Ko,e),r(Xt,e)}(Sl),function(e){var t=u&&u.__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=u&&u.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=u&&u.__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=u&&u.__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(Gn.exports);e.debug=s.default;const o=ii;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(Sl);e.types=a,e.version="3.7.18";var c=la;Object.defineProperty(e,"parseScalabilityMode",{enumerable:!0,get:function(){return c.parse}})}(Kn);const Rl=[{scaleResolutionDownBy:4,maxBitrate:15e4,maxFramerate:12},{scaleResolutionDownBy:2,maxBitrate:35e4,maxFramerate:18},{scaleResolutionDownBy:1,maxBitrate:9e5,maxFramerate:24}],Pl=[{maxBitrate:1e6,dtx:!0}],Tl=[{maxBitrate:4e4,dtx:!0}],El={width:1280,height:720};var Dl,Il,Ml,xl,Ol,Ll,Al,jl,Fl;class Nl{constructor(e){Dl.set(this,void 0),Il.set(this,void 0),Ml.set(this,{lowLighter:!1,colorCorrector:!1,faceDetector:!1,segmentation:!1}),xl.set(this,null),Ol.set(this,void 0),Ll.set(this,!1),Al.set(this,void 0);const{loggerFactory:t}=e;c(this,Il,t("EffectsSDKTrackProcessor"),"f"),c(this,Al,e.onModelsLoaded,"f"),c(this,Dl,new window.tsvb(e.customerId),"f"),a(this,Dl,"f").onError(this.tsvbErrorHandler.bind(this)),a(this,Dl,"f").onReady=this.onReady.bind(this);a(this,Dl,"f").config({preset:"balanced",provider:"wasm"})}init(){return o(this,void 0,void 0,(function*(){yield a(this,Dl,"f").preload(),yield a(this,Dl,"f").cache(),c(this,Ll,!0,"f")}))}awaitReady(){return o(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:n}=e,i=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(e,["emitter","type"]),s=null!=r?r:"N/A emitter";"error"===n&&a(this,Il,"f").error(s,Object.assign({},i)),"warning"===n&&a(this,Il,"f").warn(s,Object.assign({},i)),"info"===n&&a(this,Il,"f").info(s,Object.assign({},i)),"ml_inference"===r&&(i.message.toLocaleLowerCase().includes("init lowlighter")&&(a(this,Ml,"f").lowLighter=!0),i.message.toLocaleLowerCase().includes("init colorcorrector")&&(a(this,Ml,"f").colorCorrector=!0),i.message.toLocaleLowerCase().includes("init facedetector")&&(a(this,Ml,"f").faceDetector=!0),i.message.toLocaleLowerCase().includes("init segmentation")&&(a(this,Ml,"f").segmentation=!0),this.isModelsLoaded&&(null===(t=a(this,Al,"f"))||void 0===t||t.call(this)))}get isModelsLoaded(){return a(this,Ml,"f").colorCorrector&&a(this,Ml,"f").faceDetector&&a(this,Ml,"f").lowLighter&&a(this,Ml,"f").segmentation}get modelsLoadProgress(){return Object.values(a(this,Ml,"f")).filter(Boolean).length/Object.keys(a(this,Ml,"f")).length}get isReady(){return a(this,Ll,"f")}setOnLoadModels(e){c(this,Al,e,"f"),this.isModelsLoaded&&a(this,Al,"f").call(this)}onReady(){c(this,Ll,!0,"f"),a(this,Il,"f").debug("onReady()",{description:"ESDK is ready"}),this.updateEffects(a(this,Ol,"f"))}processTrack(e){var t,r;return o(this,void 0,void 0,(function*(){if(a(this,xl,"f")===e||"ended"===e.readyState)return(null===(t=a(this,Dl,"f").getStream())||void 0===t?void 0:t.getVideoTracks()[0])||e;this.stopProcessing();try{a(this,Dl,"f").useStream(new MediaStream([e]));const t=null===(r=a(this,Dl,"f").getStream())||void 0===r?void 0:r.getVideoTracks()[0];return t?(c(this,xl,e,"f"),t):e}catch(t){throw a(this,Il,"f").error("processTrack()",{error:t,track:e}),new Error("Can not process this track")}}))}stopProcessing(){try{a(this,Dl,"f").clear(),a(this,Dl,"f").stop()}catch(e){a(this,Il,"f").error("stopProcessing()",{error:e})}finally{c(this,xl,null,"f")}}updateEffects(e){var t,r,n,i,s,o,d,u,l,p,h,f,m,g,v,y,b,w,_,S,k;if(c(this,Ol,e,"f"),!a(this,Ll,"f"))return void a(this,Il,"f").warn("updateEffects()",{description:"Esdk not ready"});if(!a(this,Ol,"f")||0===Object.keys(a(this,Ol,"f")).length)return void a(this,Dl,"f").stop();let C=0;if((null===(t=a(this,Ol,"f"))||void 0===t?void 0:t.blur)&&!(null===(r=a(this,Ol,"f"))||void 0===r?void 0:r.backgroundColor)?(a(this,Dl,"f").setBlur(a(this,Ol,"f").blur),C+=1):a(this,Dl,"f").clearBlur(),void 0!==(null===(n=a(this,Ol,"f"))||void 0===n?void 0:n.background)?(a(this,Dl,"f").setBackground(a(this,Ol,"f").background),C+=1):void 0!==(null===(i=a(this,Ol,"f"))||void 0===i?void 0:i.backgroundColor)?(a(this,Dl,"f").setBackgroundColor(null===(s=a(this,Ol,"f"))||void 0===s?void 0:s.backgroundColor),a(this,Dl,"f").setBackground("color"),C+=1):a(this,Dl,"f").clearBackground(),(null===(o=a(this,Ol,"f"))||void 0===o?void 0:o.beautification)?(a(this,Dl,"f").enableBeautification(),a(this,Dl,"f").setBeautificationLevel(a(this,Ol,"f").beautification),C+=1):a(this,Dl,"f").disableBeautification(),(null===(d=a(this,Ol,"f"))||void 0===d?void 0:d.lowLightEffect)?(a(this,Dl,"f").enableLowLightEffect(),a(this,Dl,"f").setLowLightEffectPower(a(this,Ol,"f").lowLightEffect),C+=1):a(this,Dl,"f").disableLowLightEffect(),(null===(u=a(this,Ol,"f"))||void 0===u?void 0:u.colorCorrector)?(a(this,Dl,"f").enableColorCorrector(),a(this,Dl,"f").setColorCorrectorPower(a(this,Ol,"f").colorCorrector),C+=1):a(this,Dl,"f").disableColorCorrector(),(null===(l=a(this,Ol,"f"))||void 0===l?void 0:l.smartZoom)?(a(this,Dl,"f").enableSmartZoom(),a(this,Dl,"f").setFaceArea(a(this,Ol,"f").smartZoom),C+=1):a(this,Dl,"f").disableSmartZoom(),(null===(p=a(this,Ol,"f"))||void 0===p?void 0:p.layout)?(a(this,Dl,"f").setLayout(a(this,Ol,"f").layout),C+=1):a(this,Dl,"f").setLayout("center"),(null===(h=a(this,Ol,"f"))||void 0===h?void 0:h.colorFilter)&&(null===(f=a(this,Ol,"f"))||void 0===f?void 0:f.colorFilter.power)&&(null===(m=a(this,Ol,"f"))||void 0===m?void 0:m.colorFilter.url)?(a(this,Dl,"f").setColorFilterConfig({lut:a(this,Ol,"f").colorFilter.url,power:a(this,Ol,"f").colorFilter.power}),a(this,Dl,"f").enableColorFilter(),C+=1):a(this,Dl,"f").disableColorFilter(),null===(g=a(this,Ol,"f"))||void 0===g?void 0:g.lowerThird){const e=a(this,Dl,"f").createComponent({component:a(this,Ol,"f").lowerThird.type,options:a(this,Ol,"f").lowerThird.options||{}});null===(b=null===(y=null===(v=a(this,Dl,"f").components)||void 0===v?void 0:v.lowerThird)||void 0===y?void 0:y.hideLowerThird)||void 0===b||b.call(y),a(this,Dl,"f").addComponent(e,"lowerThird"),a(this,Dl,"f").components.lowerThird.showLowerThird(),C+=1}else null===(S=null===(_=null===(w=a(this,Dl,"f").components)||void 0===w?void 0:w.lowerThird)||void 0===_?void 0:_.hideLowerThird)||void 0===S||S.call(_);(null===(k=a(this,Ol,"f"))||void 0===k?void 0:k.sharpness)?(a(this,Dl,"f").setSharpnessEffectConfig(a(this,Ol,"f").sharpness),C+=1):a(this,Dl,"f").disableSharpnessEffect(),C>2?a(this,Dl,"f").enableFrameSkipping():a(this,Dl,"f").disableFrameSkipping(),a(this,Dl,"f").run()}}Dl=new WeakMap,Il=new WeakMap,Ml=new WeakMap,xl=new WeakMap,Ol=new WeakMap,Ll=new WeakMap,Al=new WeakMap;let Bl=Fl=class{constructor(e){jl.set(this,void 0),c(this,jl,e("MediaStreamTrackManager"),"f")}createMediaStreamTrack({label:e,constraints:t}){return o(this,void 0,void 0,(function*(){if(Fl.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 o(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getUserMedia(e);return a(this,jl,"f").debug("createUserMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}createDisplayMediaTracks(e){return o(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getDisplayMedia(e);return a(this,jl,"f").debug("getDisplayMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}};jl=new WeakMap,Bl=Fl=n([ot(),i(0,ct(Un.LoggerFactory)),s("design:paramtypes",[Function])],Bl);var Wl,ql,Ul,zl,Vl,Hl=Bl;let $l=class{constructor(e,t,r,n,i){this.config=e,this.loggerFactory=t,this.audioTrackFactory=r,this.videoTrackFactory=n,this.mediaStreamTrackManager=i,this.isDeviceLoaded=!1,this.tracks=new Map,Wl.set(this,void 0),ql.set(this,null),Ul.set(this,void 0),zl.set(this,!1),Vl.set(this,new Map);const s=this.config.get("effectsSDKParams");c(this,Wl,this.loggerFactory("Media"),"f"),c(this,ql,s||null,"f")}get mediasoupDevice(){return this.device||(this.device=this.createDevice()),this.device}get isNoiseSuppressorLoaded(){return!!a(this,Ul,"f")}get effectsSDKInitialized(){return a(this,zl,"f")}get effectsSDKParams(){return a(this,ql,"f")}getTrack(e){return this.tracks.get(e)}loadDevice(e){return o(this,void 0,void 0,(function*(){this.isDeviceLoaded||(yield this.mediasoupDevice.load({routerRtpCapabilities:e}),this.isDeviceLoaded=!0)}))}createNoiseSuppressor(){return o(this,void 0,void 0,(function*(){try{if(a(this,Ul,"f"))return void a(this,Wl,"f").warn("createNoiseSuppressor()",{message:"Noise suppression module already created"});c(this,Ul,yield class{static compileModule(e){return o(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")),"f")}catch(e){a(this,Wl,"f").warn("createNoiseSuppressor()",{message:"Can not load wasm module",error:e})}}))}getTrackCodec(e){const{rtpCapabilities:t,rtpCapabilities:{codecs:r}}=this.mediasoupDevice;if(r)return r.find((t=>t.mimeType.toLowerCase()===`${e.kind}/${e.getPreferredCodec()}`));a(this,Wl,"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),{noiseSuppressor:a(this,Ul,"f"),loggerNamespace:"AudioTrack"})):this.videoTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"VideoTrack"})),a(this,Wl,"f").debug("createTrack() track created",{trackId:n.id,kind:n.kind}),n}))}createUserMediaTracks(e){return o(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createUserMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}createDisplayMediaTracks(e){return o(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createDisplayMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}deleteTrack(e){return o(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){a(this,Wl,"f").warn("deleteTrack()",Object.assign({error:e},t))}try{this.tracks.delete(e.getLabel()),e.stopMediaStreamTrack(),yield e.closeProducer()}catch(e){a(this,Wl,"f").error("deleteTrack()",{error:e})}finally{a(this,Wl,"f").debug("deleteTrack()",t)}}))}getAllTracks(){return Array.from(this.tracks.values())}publishedTracks(){return this.getAllTracks().filter((e=>e.isPublished))}clearTracks(){return o(this,void 0,void 0,(function*(){try{this.getAllTracks().map((e=>e.stopMediaStreamTrack()))}catch(e){a(this,Wl,"f").warn("clearTracks()",{error:e})}finally{this.tracks.clear()}}))}unpublishTracks(){return o(this,void 0,void 0,(function*(){try{yield Promise.all(this.publishedTracks().map((e=>e.unpublish(!1))))}catch(e){a(this,Wl,"f").warn("unpublishTracks()",{error:e})}}))}setTrack(e){this.tracks.set(e.getLabel(),e)}initEffectsSDK(){if(a(this,zl,"f"))return Promise.resolve(!0);if(!a(this,ql,"f"))throw a(this,Wl,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Error("Effects SDK config not provided");const e=(e,t)=>o(this,void 0,void 0,(function*(){if(!window.tsvb)return a(this,Wl,"f").info("Effects SDK not loaded, skipping initialization",{case:"initEffectsSDK"}),void e(!1);a(this,Wl,"f").info("Effects SDK initializing",{case:"initEffectsSDK"});try{a(this,Vl,"f").set(zn.Camera,yield this.createEffectsSDKTrackProcessor(zn.Camera)),a(this,Vl,"f").set(zn.CameraPreview,yield this.createEffectsSDKTrackProcessor(zn.CameraPreview)),c(this,zl,!0,"f"),a(this,Wl,"f").info("Effects SDK initialized",{case:"initEffectsSDK"}),e(!0)}catch(e){a(this,Wl,"f").error("Failed to initilize Effects SDK",{error:e,case:"initEffectsSDK"}),t(e)}}));return new Promise(((t,r)=>{if(!window.tsvb)return a(this,Wl,"f").info("Effects SDK tsvb-web.js is not ready, waiting",{case:"initEffectsSDK"}),void window.addEventListener("load",(()=>e(t,r)));e(t,r)}))}createEffectsSDKTrackProcessor(e){return o(this,void 0,void 0,(function*(){if(e){const t=a(this,Vl,"f").get(e);if(t)return t}if(!a(this,ql,"f"))throw a(this,Wl,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Error("Effects SDK config not provided");const t=new Nl({loggerFactory:this.loggerFactory,customerId:a(this,ql,"f").customerId});return yield t.init(),a(this,Wl,"f").info("Track effects processor initialized",{trackLabel:e}),t}))}static getVideoTrackTransformParams(e){const t=e.getSettings();return{width:t.width||El.width,height:t.height||El.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:El.width},height:{max:El.height}},encoderConfig:(null==e?void 0:e.videoEncoderConfig)||{encodings:Pl}}}static getCameraVideoTrackParams(e){var t;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:24},width:{max:El.width},height:{max:El.height}},encoderConfig:(null==e?void 0:e.encoderConfig)||{encodings:Rl}}}createDevice(){const e=(e=>{const t=null!=e?e:null===navigator||void 0===navigator?void 0:navigator.userAgent;if(!t)return;const r=Fn.getParser(t);return r.satisfies({"yandex browser":">=23.7"})?"Chrome111":r.satisfies({"yandex browser":">=22"})?"Chrome74":void 0})();return a(this,Wl,"f").debug("Creating a media device",{handlerName:null!=e?e:"not specified"}),new Kn.Device({handlerName:e})}};Wl=new WeakMap,ql=new WeakMap,Ul=new WeakMap,zl=new WeakMap,Vl=new WeakMap,$l=n([ot(),i(0,ct(Un.Config)),i(1,ct(Un.LoggerFactory)),i(2,ct(Un.AudioTrackFactory)),i(3,ct(Un.VideoTrackFactory)),i(4,ct(Un.MediaStreamTrackManager)),s("design:paramtypes",[wt,Function,Function,Function,Hl])],$l);var Kl=$l;let Gl=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)}};Gl=n([ot()],Gl);class Jl extends On{constructor(e,t,r){super(e,null!=t?t:"something_went_wrong",r)}}const Ql=Object.create(null);Ql.open="0",Ql.close="1",Ql.ping="2",Ql.pong="3",Ql.message="4",Ql.upgrade="5",Ql.noop="6";const Yl=Object.create(null);Object.keys(Ql).forEach((e=>{Yl[Ql[e]]=e}));const Zl={type:"error",data:"parser error"},Xl="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),ep="function"==typeof ArrayBuffer,tp=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,rp=({type:e,data:t},r,n)=>Xl&&t instanceof Blob?r?n(t):np(t,n):ep&&(t instanceof ArrayBuffer||tp(t))?r?n(t):np(new Blob([t]),n):n(Ql[e]+(t||"")),np=(e,t)=>{const r=new FileReader;return r.onload=function(){const e=r.result.split(",")[1];t("b"+(e||""))},r.readAsDataURL(e)};function ip(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let sp;const op="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ap="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<op.length;e++)ap[op.charCodeAt(e)]=e;const cp="function"==typeof ArrayBuffer,dp=(e,t)=>{if("string"!=typeof e)return{type:"message",data:lp(e,t)};const r=e.charAt(0);if("b"===r)return{type:"message",data:up(e.substring(1),t)};return Yl[r]?e.length>1?{type:Yl[r],data:e.substring(1)}:{type:Yl[r]}:Zl},up=(e,t)=>{if(cp){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=ap[e.charCodeAt(t)],n=ap[e.charCodeAt(t+1)],i=ap[e.charCodeAt(t+2)],s=ap[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 lp(r,t)}return{base64:!0,data:e}},lp=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,pp=String.fromCharCode(30);function hp(){return new TransformStream({transform(e,t){!function(e,t){Xl&&e.data instanceof Blob?e.data.arrayBuffer().then(ip).then(t):ep&&(e.data instanceof ArrayBuffer||tp(e.data))?t(ip(e.data)):rp(e,!1,(e=>{sp||(sp=new TextEncoder),t(sp.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 fp;function mp(e){return e.reduce(((e,t)=>e+t.length),0)}function gp(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 vp(e){if(e)return function(e){for(var t in vp.prototype)e[t]=vp.prototype[t];return e}(e)}vp.prototype.on=vp.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},vp.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},vp.prototype.off=vp.prototype.removeListener=vp.prototype.removeAllListeners=vp.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},vp.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},vp.prototype.emitReserved=vp.prototype.emit,vp.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},vp.prototype.hasListeners=function(e){return!!this.listeners(e).length};const yp="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function bp(e,...t){return t.reduce(((t,r)=>(e.hasOwnProperty(r)&&(t[r]=e[r]),t)),{})}const wp=yp.setTimeout,_p=yp.clearTimeout;function Sp(e,t){t.useNativeTimers?(e.setTimeoutFn=wp.bind(yp),e.clearTimeoutFn=_p.bind(yp)):(e.setTimeoutFn=yp.setTimeout.bind(yp),e.clearTimeoutFn=yp.clearTimeout.bind(yp))}class kp extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}}class Cp extends vp{constructor(e){super(),this.writable=!1,Sp(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,r){return super.emitReserved("error",new kp(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=dp(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 Rp="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Pp={};let Tp,Ep=0,Dp=0;function Ip(e){let t="";do{t=Rp[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function Mp(){const e=Ip(+new Date);return e!==Tp?(Ep=0,Tp=e):e+"."+Ip(Ep++)}for(;Dp<64;Dp++)Pp[Rp[Dp]]=Dp;let xp=!1;try{xp="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(vb){}const Op=xp;function Lp(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||Op))return new XMLHttpRequest}catch(e){}if(!t)try{return new(yp[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function Ap(){}const jp=null!=new Lp({xdomain:!1}).responseType;class Fp extends vp{constructor(e,t){super(),Sp(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=bp(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const r=this.xhr=new Lp(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=Fp.requestsCount++,Fp.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=Ap,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete Fp.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(Fp.requestsCount=0,Fp.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",Np);else if("function"==typeof addEventListener){addEventListener("onpagehide"in yp?"pagehide":"unload",Np,!1)}function Np(){for(let e in Fp.requests)Fp.requests.hasOwnProperty(e)&&Fp.requests[e].abort()}const Bp="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),Wp=yp.WebSocket||yp.MozWebSocket,qp="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const Up={websocket:class extends Cp{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=qp?{}:bp(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=qp?new Wp(e,t,r):t?new Wp(e,t):new Wp(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;rp(r,this.supportsBinary,(e=>{try{this.ws.send(e)}catch(e){}n&&Bp((()=>{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]=Mp()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!Wp}},webtransport:class extends Cp{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){fp||(fp=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(mp(r)<1)break;const e=gp(r,1);s=128==(128&e[0]),i=127&e[0],n=i<126?3:126===i?1:2}else if(1===n){if(mp(r)<2)break;const e=gp(r,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),n=3}else if(2===n){if(mp(r)<8)break;const e=gp(r,8),t=new DataView(e.buffer,e.byteOffset,e.length),s=t.getUint32(0);if(s>Math.pow(2,21)-1){a.enqueue(Zl);break}i=s*Math.pow(2,32)+t.getUint32(4),n=3}else{if(mp(r)<i)break;const e=gp(r,i);a.enqueue(dp(s?e:fp.decode(e),t)),n=0}if(0===i||i>e){a.enqueue(Zl);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=hp();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&&Bp((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends Cp{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=jp&&!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(pp),n=[];for(let e=0;e<r.length;e++){const i=dp(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)=>{rp(e,!1,(e=>{n[s]=e,++i===r&&t(n.join(pp))}))}))})(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]=Mp()),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 Fp(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}}},zp=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Vp=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Hp(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=zp.exec(e||""),s={},o=14;for(;o--;)s[Vp[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 $p extends vp{constructor(e,t={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=Hp(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=Hp(t.host).host),Sp(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 Up[e](r)}open(){let e;if(this.opts.rememberUpgrade&&$p.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;$p.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;$p.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",$p.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){$p.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}}$p.protocol=4;const Kp="function"==typeof ArrayBuffer,Gp=Object.prototype.toString,Jp="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Gp.call(Blob),Qp="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===Gp.call(File);function Yp(e){return Kp&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||Jp&&e instanceof Blob||Qp&&e instanceof File}function Zp(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++)if(Zp(e[t]))return!0;return!1}if(Yp(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return Zp(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&Zp(e[t]))return!0;return!1}function Xp(e){const t=[],r=e.data,n=e;return n.data=eh(r,t),n.attachments=t.length,{packet:n,buffers:t}}function eh(e,t){if(!e)return e;if(Yp(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]=eh(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]=eh(e[n],t));return r}return e}function th(e,t){return e.data=rh(e.data,t),delete e.attachments,e}function rh(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]=rh(e[r],t);else if("object"==typeof e)for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(e[r]=rh(e[r],t));return e}const nh=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var ih;!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"}(ih||(ih={}));function sh(e){return"[object Object]"===Object.prototype.toString.call(e)}class oh extends vp{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===ih.BINARY_EVENT;r||t.type===ih.BINARY_ACK?(t.type=r?ih.EVENT:ih.ACK,this.reconstructor=new ah(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!Yp(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===ih[r.type])throw new Error("unknown packet type "+r.type);if(r.type===ih.BINARY_EVENT||r.type===ih.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(!oh.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 ih.CONNECT:return sh(t);case ih.DISCONNECT:return void 0===t;case ih.CONNECT_ERROR:return"string"==typeof t||sh(t);case ih.EVENT:case ih.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===nh.indexOf(t[0]));case ih.ACK:case ih.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class ah{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=th(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var ch=Object.freeze({__proto__:null,protocol:5,get PacketType(){return ih},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==ih.EVENT&&e.type!==ih.ACK||!Zp(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===ih.EVENT?ih.BINARY_EVENT:ih.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==ih.BINARY_EVENT&&e.type!==ih.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=Xp(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}},Decoder:oh});function dh(e,t,r){return e.on(t,r),function(){e.off(t,r)}}const uh=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class lh extends vp{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=[dh(e,"open",this.onopen.bind(this)),dh(e,"packet",this.onpacket.bind(this)),dh(e,"error",this.onerror.bind(this)),dh(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(uh.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:ih.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:ih.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 ih.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 ih.EVENT:case ih.BINARY_EVENT:this.onevent(e);break;case ih.ACK:case ih.BINARY_ACK:this.onack(e);break;case ih.DISCONNECT:this.ondisconnect();break;case ih.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:ih.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:ih.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 ph(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}ph.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)},ph.prototype.reset=function(){this.attempts=0},ph.prototype.setMin=function(e){this.ms=e},ph.prototype.setMax=function(e){this.max=e},ph.prototype.setJitter=function(e){this.jitter=e};class hh extends vp{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,Sp(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 ph({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||ch;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 $p(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const n=dh(t,"open",(function(){r.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},s=dh(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(dh(e,"ping",this.onping.bind(this)),dh(e,"data",this.ondata.bind(this)),dh(e,"error",this.onerror.bind(this)),dh(e,"close",this.onclose.bind(this)),dh(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){Bp((()=>{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 lh(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 fh={};function mh(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=Hp(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=fh[i]&&s in fh[i].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?a=new hh(n,t):(fh[i]||(fh[i]=new hh(n,t)),a=fh[i]),r.query&&!t.query&&(t.query=r.queryKey),a.socket(r.path,t)}var gh,vh,yh,bh;Object.assign(mh,{Manager:hh,Socket:lh,io:mh,connect:mh});let wh=class{constructor(e){this.reconnectingAttempt=0,this.isConnected=!1,this._observer=new _t,gh.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"},vh.set(this,100),yh.set(this,!1),bh.set(this,8e3),c(this,gh,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=mh(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(Hn.Connect,(()=>{const e=this.reconnectingAttempt?Hn.Reconnected:Hn.Connected;this.isConnected=!0,this.setReconnectingAttempt(0),a(this,gh,"f").debug(`connection.on('${Hn.Connect}')`,{connectionId:r.id,recovered:r.recovered}),this.observer.safeEmit(Hn.State,{state:e})})),r.on(Hn.ConnectError,(e=>{this.connectionError=e,a(this,gh,"f").error(`connection.on('${Hn.ConnectError}')`,{error:e}),this.observer.safeEmit(Hn.State,{state:Hn.Error,error:e}),this.reconnectingAttempt>a(this,vh,"f")&&(r.disconnect(),this.observer.safeEmit(Hn.State,{state:Hn.Disconnected,code:"server.disconnect"}))})),r.on(Hn.Disconnect,(e=>{this.isConnected=!1,this.setReconnectingAttempt(0),this.disconnectReason=e,a(this,gh,"f").info(`connection.on('${Hn.Disconnect}')`,{reason:e});const t=this.getDisconnectReasonCode(e);"server.disconnect"===t&&r.disconnect(),this.observer.safeEmit(Hn.State,{state:Hn.Disconnected,code:t})})),r.io.on(Hn.ReconnectAttempt,(e=>{this.setReconnectingAttempt(e),a(this,gh,"f").info(`connection.on('${Hn.ReconnectAttempt}')`,{attempt:e}),this.observer.safeEmit(Hn.State,{state:Hn.Reconnecting})})),r.io.on(Hn.Reconnect,(()=>{a(this,gh,"f").debug(`connection.on('${Hn.Reconnect}')`,{connectionId:r.id}),this.observer.safeEmit(Hn.State,{state:Hn.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(a(this,bh,"f")).emit(e,t,((t,i)=>{if(t){const r=In.includes(e);return"operation has timed out"===(null==t?void 0:t.message)&&!a(this,yh,"f")&&r&&(c(this,yh,!0,"f"),this.observer.safeEmit(Hn.State,{state:Hn.BufferingStart})),void n(t)}i&&i.error?("Need join to channel first"===i.error&&this.observer.safeEmit(Hn.State,{code:Hn.NeedToJoinFirst}),n(new Jl(i.error,i.errorCode,Object.assign({},i)))):(a(this,yh,"f")&&(c(this,yh,!1,"f"),this.observer.safeEmit(Hn.State,{state:Hn.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}};gh=new WeakMap,vh=new WeakMap,yh=new WeakMap,bh=new WeakMap,wh=n([ot(),i(0,ct(Un.LoggerFactory)),s("design:paramtypes",[Function])],wh);var _h,Sh,kh,Ch=wh;let Rh=class{constructor(e,t,r,n){this.state=e,this.myPeer=t,this.socket=n,_h.set(this,{send:void 0,recv:void 0}),Sh.set(this,void 0),kh.set(this,void 0),c(this,kh,r("Network"),"f"),c(this,Sh,new _t,"f"),this.socket.observer.on(Hn.State,(e=>{a(this,Sh,"f").safeEmit(Mn,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 a(this,Sh,"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 o(this,void 0,void 0,(function*(){this.stopRestartIceAtempts(),this.removeEventListeners()}))}closeRemoteProducer(e){return o(this,void 0,void 0,(function*(){yield this.socket.request(cn,{peerId:this.myPeer.id,producerId:e})}))}closeSendTransport(){var e;return o(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):a(this,kh,"f").warn("closeSendTransport()",{message:"No available send transport"})}))}closeReceiveTransport(){var e;return o(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):a(this,kh,"f").warn("closeReceiveTransport()",{message:"No available receive transport"})}))}closeTransport(e){return o(this,void 0,void 0,(function*(){try{e.close(),a(this,kh,"f").debug("closeTransport()",{transportId:e.id,direction:e.direction})}catch(t){a(this,kh,"f").error("closeTransport()",{error:t,transportId:e.id,direction:e.direction})}}))}createSendTransport(e){return o(this,void 0,void 0,(function*(){if(this.sendTransport)throw a(this,kh,"f").warn("createSendTransport()",{message:"Send transport already exists"}),new On("Send transport already exists","already_exists");const t=yield this.socket.request(Cn,{sctpCapabilities:e.sctpCapabilities,localDirection:"send"}),r=e.createSendTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return a(this,kh,"f").debug("createSendTransport()",{transportId:r.id,direction:r.direction}),this.sendTransport=r,this.subscribeCommonTransportEvents(r),r}))}createRecvTransport(e){return o(this,void 0,void 0,(function*(){if(this.receiveTransport)throw a(this,kh,"f").warn("createReceiveTransport()",{message:"Receive transport already exists"}),new On("Receive transport already exists","already_exists");const t=yield this.socket.request(Cn,{localDirection:"receive"}),r=e.createRecvTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return a(this,kh,"f").debug("createReceiveTransport()",{transportId:r.id,direction:r.direction}),this.receiveTransport=r,this.subscribeCommonTransportEvents(r),r}))}getIceParameters(e){return o(this,void 0,void 0,(function*(){const t=yield this.socket.request(Dn,{transportId:e.id}),{error:r}=t;if(r)throw new Error(r);const{iceParameters:n}=t;return a(this,kh,"f").debug("getIceParameters()",{iceParameters:n}),n}))}restartIce(e){return o(this,void 0,void 0,(function*(){try{const t=yield this.getIceParameters(e);yield e.restartIce({iceParameters:t}),a(this,kh,"f").info("restartIce completed",{iceParameters:t})}catch(e){a(this,kh,"f").error("restartIce error",{error:e})}}))}createConsumer({producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i}){var s;return o(this,void 0,void 0,(function*(){const o=this.receiveTransport;if(!o)throw a(this,kh,"f").error("createConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer");let c;a(this,kh,"f").debug("createConsumer()",{producerId:e});try{c=yield this.socket.request(gn,{producerId:e,transportId:o.id,rtpCapabilities:t,appData:{peerId:this.myPeer.id,appId:r,channelId:n},producerPeerId:i})}catch(o){if(!(o instanceof Jl&&(null===(s=o.meta)||void 0===s?void 0:s.existedConsumer)))throw a(this,kh,"f").error("Failed to get consumer options",{producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i,error:cr(o)}),new Error("Failed to create consumer");c=o.meta.existedConsumer}const d=yield o.consume(c),{producerPaused:u}=c;return u&&d.pause(),a(this,kh,"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 o(this,void 0,void 0,(function*(){const i=this.receiveTransport;if(!i)throw a(this,kh,"f").error("createDataConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer");a(this,kh,"f").debug("createDataConsumer()",{producerId:e});const s=yield this.socket.request(vn,{ordered:n,dataProducerId:e,transportId:i.id,appData:{peerId:this.myPeer.id,producerId:e,appId:t,channelId:r}}),o=yield i.consumeData(s);return a(this,kh,"f").debug("Data consumer created",{consumerId:o.id}),o}))}closeRemoteConsumer(e){return o(this,void 0,void 0,(function*(){return this.socket.request(yn,{peerId:this.myPeer.id,consumerId:e})}))}resumeRemoteConsumer(e){return o(this,void 0,void 0,(function*(){return this.socket.request(wn,{consumerId:e})}))}pauseRemoteProducer(e){return o(this,void 0,void 0,(function*(){return this.socket.request(dn,{producerId:e})}))}pauseRemoteConsumer(e){return o(this,void 0,void 0,(function*(){return this.socket.request(bn,{consumerId:e})}))}updatePeerAppData({peerId:e,appData:t}){return o(this,void 0,void 0,(function*(){return this.socket.request(fr,{peerId:e,appData:t})}))}getAudioObserverProducer(){return o(this,void 0,void 0,(function*(){return this.socket.request(br)}))}getGeneralDataProducer(){return o(this,void 0,void 0,(function*(){return this.socket.request(wr)}))}getChannelStateSyncDataProducer(){return o(this,void 0,void 0,(function*(){return this.socket.request(_r)}))}createDataProducer(e){var t;return o(this,void 0,void 0,(function*(){return this.socket.request(Tn,{transportId:null===(t=this.sendTransport)||void 0===t?void 0:t.id,label:e})}))}getTransportsStateInfo(){return o(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 o(this,void 0,void 0,(function*(){return this.socket.request(pr,{role:e})}))}getParsedTransportStats(e){return o(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 a(this,kh,"f").warn("getParsedTransportStats()",{error:e})}else a(this,kh,"f").debug("getParsedTransportStats()",{message:"Transport is missing"})}))}logTransportDetails(e){var t,r;return o(this,void 0,void 0,(function*(){let n;try{n=yield e.getStats()}catch(t){return void a(this,kh,"f").error("Failed to log detailed WebRTC transport stats",{error:cr(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:[],c=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==c?void 0:c.address,candidateType:null==c?void 0:c.candidateType,foundation:null==c?void 0:c.foundation,networkType:null==c?void 0:c.networkType,isRemote:null==c?void 0:c.isRemote,port:null==c?void 0:c.port,protocol:null==c?void 0:c.protocol,relatedAddress:null==c?void 0:c.relatedAddress,relatedPort:null==c?void 0:c.relatedPort,transportId:null==c?void 0:c.transportId,relayProtocol:null==c?void 0:c.relayProtocol,url:null==c?void 0:c.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)),a(this,kh,"f").info("Detailed WebRTC transport stats",u)}catch(t){a(this,kh,"f").error("Failed to log detailed WebRTC transport stats",{error:cr(t),transportId:e.id,reason:"-"})}}))}stopRestartIceAtempts(){clearInterval(a(this,_h,"f").send),clearInterval(a(this,_h,"f").recv)}subscribeCommonTransportEvents(e){e.on("connect",(({dtlsParameters:t},r,n)=>o(this,void 0,void 0,(function*(){try{yield this.socket.request(Rn,{transportId:e.id,dtlsParameters:t}),r(),a(this,kh,"f").debug(`${e.direction}Transport.connect()`,{transportId:e.id,dtlsRole:t.role}),setTimeout((()=>this.logTransportDetails(e)),1500)}catch(t){a(this,kh,"f").error(`${e.direction}Transport.on('connect')`,{error:t}),n(t)}})))),e.on("produce",((t,r,n)=>o(this,void 0,void 0,(function*(){try{const{id:n}=yield this.socket.request(Pn,{transportId:e.id,kind:t.kind,rtpParameters:t.rtpParameters,appData:t.appData});r({id:n}),a(this,kh,"f").debug(`${e.direction}Transport.produce()`,{producerId:n,transportId:e.id,kind:t.kind})}catch(r){a(this,kh,"f").error(`${e.direction}Transport.produce()`,{error:r,transportId:e.id,kind:t.kind}),n(r)}})))),e.on("connectionstatechange",(t=>{if(a(this,kh,"f").info(`${e.direction}Transport.state`,{state:t}),["closed","connected"].includes(t))return a(this,Sh,"f").safeEmit(xn,{state:t,direction:e.direction}),a(this,_h,"f")[e.direction]&&(a(this,kh,"f").debug("Stop receiveTransport.restartIce() retries",{recvTransportId:e.id}),clearInterval(a(this,_h,"f")[e.direction]),a(this,_h,"f")[e.direction]=void 0,"connected"===t&&a(this,Sh,"f").safeEmit(xn,{state:"reconnected",direction:e.direction})),void("connected"===t&&setTimeout((()=>this.logTransportDetails(e)),1500));if(a(this,Sh,"f").safeEmit(xn,{state:t,direction:e.direction}),["disconnected","failed"].includes(t)){if(a(this,_h,"f")[e.direction])return;"failed"===t&&(a(this,kh,"f").debug(`${e.direction}Transport.restartIce()`,{recvTransportId:e.id}),this.restartIce(e)),a(this,_h,"f")[e.direction]=setInterval((()=>{this.restartIce(e),a(this,kh,"f").debug(`${e.direction}Transport.restartIce() attempt`,{recvTransportId:e.id})}),5e3)}})),e.on("icegatheringstatechange",(t=>{a(this,kh,"f").info("icegatheringstatechange",{state:t,transportId:e.id,transportDirection:e.direction})}))}};_h=new WeakMap,Sh=new WeakMap,kh=new WeakMap,Rh=n([ot(),i(0,ct(Un.CallState)),i(1,ct(Un.MyPeer)),i(2,ct(Un.LoggerFactory)),i(3,ct(Un.SocketIO)),s("design:paramtypes",[$n,Gl,Function,Ch])],Rh);var Ph=Rh;let Th=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){const t=this.get(e);t&&(t.tracks.forEach((e=>e.close())),t.reset(),this.delete(e),this.clientEventEmitter.safeEmit(Mr,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(){this.peersStorage.forEach((e=>e.reset())),this.peersStorage.clear()}load(e){return o(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(Ir,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(Wr,{peer:e}))}};Th=n([ot(),i(0,ct(Un.MyPeer)),i(1,ct(Un.Network)),i(2,ct(Un.PeerFactory)),i(3,ct(Un.ClientEventEmitter)),s("design:paramtypes",[Gl,Ph,Function,_t])],Th);const Eh=e=>null!==e&&"object"==typeof e,Dh=(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=Eh(n)&&Eh(s);(o&&!Dh(n,s)||!o&&n!==s)&&(i=!1)})),i};var Ih,Mh,xh,Oh;let Lh=class{constructor(){Ih.set(this,[]),Mh.set(this,new Map),xh.set(this,new Set),Oh.set(this,!1)}subscribeToSocket(e){a(this,xh,"f").has(e)||(e.onAny(((e,...t)=>{this.push(e,t)})),a(this,xh,"f").add(e))}subscribeToDataChannel(e){e.on("message",((...e)=>{this.push("message",e)}))}on(e,t){var r;a(this,Mh,"f").has(e)?null===(r=a(this,Mh,"f").get(e))||void 0===r||r.push(t):a(this,Mh,"f").set(e,[t])}removeListener(e){a(this,Mh,"f").delete(e)}removeAllListeners(e,t){t&&a(this,xh,"f").has(t)&&(t.offAny(),a(this,xh,"f").delete(t)),e.forEach((e=>{a(this,Mh,"f").delete(e)}))}push(e,t){a(this,Ih,"f").push({event:e,args:t}),this.process()}process(){if(!a(this,Oh,"f"))for(;a(this,Ih,"f").length>0;){const e=a(this,Ih,"f").shift();this.emit(e.event,e.args)}}emit(e,t){(a(this,Mh,"f").get(e)||[]).forEach((e=>{e(...t)}))}pause(){c(this,Oh,!0,"f")}size(){return a(this,Ih,"f").length}resume(){c(this,Oh,!1,"f"),this.process()}};Ih=new WeakMap,Mh=new WeakMap,xh=new WeakMap,Oh=new WeakMap,Lh=n([ot()],Lh);var Ah,jh=Lh;let Fh=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,Ah.set(this,void 0),c(this,Ah,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(zr,(()=>o(this,void 0,void 0,(function*(){yield this.debouncedRestoreState()}))))}restoreState(){return o(this,void 0,void 0,(function*(){const e={missingPeers:[],removedPeers:[],missingProducers:[],removedProducers:[],fixedProducersState:[],fixedConsumersState:[],restoredAppDataPeers:[]};try{if(!this.network.isSocketConnectionActive)return a(this,Ah,"f").info("Connection inactive, skipping restore local state",{case:"restoreLocalState"}),e;this.eventsQueue.pause(),a(this,Ah,"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 a(this,Ah,"f").info("Failed to restore local state",{case:"restoreLocalState",error:cr(t)}),e}finally{a(this,Ah,"f").info("Resume events after re-syncing local peers",{case:"restoreLocalState",accumulatedEventsAmount:this.eventsQueue.size()}),this.eventsQueue.resume()}}))}restoreRemoteProducersState(e){return o(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=>o(this,void 0,void 0,(function*(){yield this.network.closeRemoteProducer(e.id),r.producers.delete(e.id),t.removedProducers.push(e.id),a(this,Ah,"f").info("Unnecessary local producer closed",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId})})))));const c=n.producers.filter((e=>!!i.find((t=>t.isPaused&&t.isPaused!==e.paused))));return yield Promise.all(c.map((e=>o(this,void 0,void 0,(function*(){yield this.network.pauseRemoteProducer(e.id),t.fixedProducersState.push(e.id),a(this,Ah,"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),a(this,Ah,"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),a(this,Ah,"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 a(this,Ah,"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)})),a(this,Ah,"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(cn,t),r.push(t.id),a(this,Ah,"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(an,t),r.missingProducers.push(t.id),void a(this,Ah,"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?Qr:Yr;e.observer.safeEmit(n,{producerId:i.id,kind:i.kind,label:i.label,paused:i.paused}),r.fixedProducersState.push(t.id),a(this,Ah,"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?bn:wn;e.observer.safeEmit(o,n),r.fixedConsumersState.push(n),a(this,Ah,"f").info("Consumer state fixed",{case:"restoreLocalState",consumerId:n,consumerProducerId:t.id,consumerProducerPeerId:t.peerId})}})),r}restoreAppData(e,t){return!Dh(e.appData,t.appData)&&(e.observer.emit(fr,t.appData),a(this,Ah,"f").info("Application data restored",{case:"restoreLocalState",peerId:e.id,appData:t.appData}),!0)}};Ah=new WeakMap,Fh=n([ot(),i(0,ct(Un.Network)),i(1,ct(Un.Media)),i(2,ct(Un.MyPeer)),i(3,ct(Un.EventsQueue)),i(4,ct(Un.ClientEventEmitter)),i(5,ct(Un.Peers)),i(6,ct(Un.LoggerFactory)),s("design:paramtypes",[Ph,Kl,Gl,jh,_t,Th,Function])],Fh);var Nh,Bh=Fh;function Wh(e){return{id:e.id,appId:e.appId,role:e.role,groups:e.groups,producePermissions:e.producePermissions}}let qh=class{constructor(e,t,r,n,i,s){this.eventsQueue=e,this.network=t,this.socket=r,this.peers=n,this.clientEventEmitter=i,Nh.set(this,void 0),c(this,Nh,s("ChannelEvents"),"f")}handleDataChannelEvent(e){try{const{event:t,data:r}=JSON.parse(e);this.doHandleDataChannelEvent(t,r)}catch(t){a(this,Nh,"f").error("Failed to handle data channel event",{error:t,payload:e})}}doHandleDataChannelEvent(e,t){e===fr&&this.handlePeerAppDataUpdate(t)}subscribeToEvents(){const{connection:e}=this.socket;if(!e)throw a(this,Nh,"f").error("subscribeToEvents()",{error:"Socket connection not initialized"}),new Error("Socket connection not initialized");this.eventsQueue.subscribeToSocket(e),this.eventsQueue.on(ur,(e=>{this.clientEventEmitter.safeEmit(Dr,e),a(this,Nh,"f").debug("New channel event",{event:e})})),this.eventsQueue.on(lr,(e=>{const t=this.peers.add(e);a(this,Nh,"f").debug("Peer joined to the channel",{peer:Wh(t)})})),this.eventsQueue.on(hr,(e=>{this.peers.remove(e),a(this,Nh,"f").debug("Peer left the channel",{peerId:e})})),this.eventsQueue.on(vr,(e=>{this.clientEventEmitter.safeEmit(xr,e),a(this,Nh,"f").info("Notify the channel that activity confirmation is required",e)})),this.eventsQueue.on(yr,(e=>{this.clientEventEmitter.safeEmit(Lr,e),a(this,Nh,"f").info("Notify the channel that it has disconnected due to the activity confirmation expiring",e)})),this.eventsQueue.on(gr,(e=>{this.clientEventEmitter.safeEmit(Or,e),a(this,Nh,"f").info("Notify the channel that the activity has been acquired.",e)})),this.eventsQueue.on(Sr,(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)})),a(this,Nh,"f").info("Peers changed produce permissions",{groups:r,producePermissions:t})})),this.eventsQueue.on(Cr,(e=>{const{peerId:t,producePermissions:r}=e,n=this.peers.get(t);n&&n.handleProducePermissionsChange(r)})),this.eventsQueue.on(kr,(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)})),a(this,Nh,"f").info("Peers deleted produce permissions",{groups:r,producePermissions:t})})),this.eventsQueue.on(Tr,(e=>{const{peerId:t,groups:r}=e,n=this.peers.get(t);n&&n.handleGroupsChange(r)}))}removeEventListeners(){if(!this.eventsQueue)return;const e=[ur,lr,hr,vr,yr,gr,fr,Sr],{connection:t}=this.socket;this.eventsQueue.removeAllListeners(e,t)}handlePeerAppDataUpdate({peerId:e,appData:t}){const r=this.peers.get(e);r&&r.observer.emit(fr,t)}reset(){this.removeEventListeners()}};Nh=new WeakMap,qh=n([ot(),i(0,ct(Un.EventsQueue)),i(1,ct(Un.Network)),i(2,ct(Un.SocketIO)),i(3,ct(Un.Peers)),i(4,ct(Un.ClientEventEmitter)),i(5,ct(Un.LoggerFactory)),s("design:paramtypes",[jh,Ph,Ch,Th,_t,Function])],qh);var Uh=qh,zh={},Vh=u&&u.__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(zh,"__esModule",{value:!0});var Hh=zh.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 Vh(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 Vh(this,void 0,void 0,(function*(){const e=this.pendingTasks[0];e&&(yield this.executeTask(e),this.pendingTasks.shift(),this.next())}))}executeTask(e){return Vh(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 $h=new Error("request for lock canceled");var Kh=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 Gh{constructor(e,t=$h){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 Kh(this,void 0,void 0,(function*(){const[t,r]=yield this.acquire();try{return yield e(t)}finally{r()}}))}waitForUnlock(){return Kh(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 Jh=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 Qh{constructor(e){this._semaphore=new Gh(1,e)}acquire(){return Jh(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 Yh=e=>"rtx"!==e.mimeType;var Zh,Xh,ef,tf,rf,nf,sf,of,af,cf,df,uf,lf,pf,hf,ff,mf,gf,vf,yf,bf,wf,_f;class Sf{constructor({track:e,statsHandler:t}){Zh.set(this,void 0),Xh.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return a(this,Zh,"f")}get audioWebRTCStats(){return a(this,Xh,"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){c(this,Zh,e,"f")}setAudioWebRTCStats(e){c(this,Xh,e,"f")}}Zh=new WeakMap,Xh=new WeakMap;class kf{constructor(e){ef.set(this,void 0),tf.set(this,void 0),this.encoderConfig={},this.label=zn.Unknown,rf.set(this,void 0),nf.set(this,void 0),sf.set(this,void 0),of.set(this,void 0),af.set(this,void 0),cf.set(this,!1),df.set(this,void 0),uf.set(this,void 0),lf.set(this,void 0),pf.set(this,!0),hf.set(this,new Qh),ff.set(this,void 0),mf.set(this,void 0);const{mediaStreamTrack:t,internalEventEmitter:r,constraints:n,mediaStreamTrackManager:i,media:s,myPeer:o,network:a,socket:d,loggerFactory:u,loggerNamespace:l,statsHandler:p}=e;c(this,ef,t,"f"),c(this,af,r,"f"),c(this,df,n,"f"),c(this,uf,i,"f"),c(this,lf,new _t,"f"),this.logger=u(l),c(this,nf,s,"f"),c(this,rf,o,"f"),c(this,sf,a,"f"),c(this,of,d,"f"),c(this,mf,p,"f"),c(this,ff,new Sf({track:t,statsHandler:p}),"f")}get videoWebRTCStats(){return a(this,ff,"f").videoWebRTCStats}get audioWebRTCStats(){return a(this,ff,"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 a(this,lf,"f")}get mediaStreamTrack(){return a(this,ef,"f")}get originalTrack(){return a(this,tf,"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 a(this,af,"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||c(this,pf,e,"f")}getProducer(){return this.producer}setOriginalTrack(){c(this,tf,this.mediaStreamTrack,"f")}closeProducer(e=!0){return o(this,void 0,void 0,(function*(){if(this.producer){try{yield a(this,sf,"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 o(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(){a(this,tf,"f")&&(a(this,tf,"f").stop(),c(this,tf,void 0,"f"))}produce({encodings:e,codecOptions:t,preferredCodec:r,transformParams:n,keyFrameRequestDelay:i}){var s;return o(this,void 0,void 0,(function*(){if(!a(this,rf,"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 a(this,of,"f").request(Er);const{rtpCapabilities:{codecs:o}}=a(this,nf,"f").mediasoupDevice,c=null==o?void 0:o.find((e=>e.mimeType.toLowerCase()===`${this.kind}/${r}`)),d=0,u=this.prepareProducerEncodings({codec:c,encodings:null!=e?e:[],maxSpatialLayer:(null!=e?e:[]).length-1}),l={trackTransformParams:n,peerId:String(a(this,rf,"f").id),label:this.getLabel(),maxSpatialLayer:d,encodings:u,codecOptions:t,preferredCodec:r,codec:c,keyFrameRequestDelay:i},p=yield null===(s=a(this,sf,"f").sendTransport)||void 0===s?void 0:s.produce({track:this.mediaStreamTrack,encodings:u,codecOptions:t,codec:c,stopTracks:!1,disableTrackOnPause:!0,zeroRtpOnPause:!0,appData:l});if(!p)return;const h=p.rtpSender,f=()=>/Safari/i.test(navigator.userAgent);if(e&&h&&f()){const t=h.getParameters();e.forEach((({maxBitrate:e,scaleResolutionDownBy:r},n)=>{t.encodings[n]&&(t.encodings[n].maxBitrate=e,t.encodings[n].scaleResolutionDownBy=r)})),yield h.setParameters(t)}this.setProducer(p),"video"===this.kind&&(e&&h&&c&&Bn(c.mimeType)&&!f()?yield h.setParameters(Object.assign(Object.assign({},h.getParameters()),{encodings:this.prepareProducerEncodings({encodings:e,codec:c,maxSpatialLayer:d})})):yield p.setMaxSpatialLayer(d),yield a(this,of,"f").request(fn,{producerId:p.id,maxSpatialLayer:d})),"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 o(this,void 0,void 0,(function*(){yield this.produce({}),this.internalEventEmitter.emit(Kr.trackProduced,this)}))}unpublish(e=!0){return o(this,void 0,void 0,(function*(){try{e&&this.stopMediaStreamTrack(),this.internalEventEmitter.emit(Kr.trackUnproduced,this),this.producer&&(yield this.closeProducer()),c(this,cf,!0,"f"),this.logger.debug("unpublish()",{track:this.logCtx})}catch(e){this.logger.error("unpublish()",{error:e})}}))}pauseRemoteProducer(e){return o(this,void 0,void 0,(function*(){return a(this,of,"f").request(dn,{producerId:e})}))}resumeRemoteProducer(e){return o(this,void 0,void 0,(function*(){return a(this,of,"f").request(un,{producerId:e})}))}mute(e){return o(this,void 0,void 0,(function*(){yield a(this,hf,"f").waitForUnlock();const t=yield a(this,hf,"f").acquire();if(this.producer)try{if(this.producer.pause(),this.logger.debug("pause()",{track:this.logCtx}),a(this,pf,"f"))return null==e||e(),a(this,ef,"f").stop(),this.stopOriginalTrack(),this.internalEventEmitter.emit(Kr.trackClosed,this),void(yield this.pauseRemoteProducer(this.producer.id));yield this.pauseRemoteProducer(this.producer.id),this.internalEventEmitter.emit(Kr.trackPaused,this)}catch(e){throw this.logger.error("pause()",{error:e,track:this.logCtx}),yield a(this,nf,"f").deleteTrack(this),this.internalEventEmitter.emit(Kr.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 o(this,void 0,void 0,(function*(){yield a(this,hf,"f").waitForUnlock();const e=yield a(this,hf,"f").acquire();if(this.producer)try{if(this.logger.debug("resume()",{track:this.logCtx}),a(this,pf,"f"))return yield this.reopenMediaStreamTrack(),yield this.resumeProducer(),void this.internalEventEmitter.emit(Kr.trackReopened,this);yield this.resumeProducer(),this.internalEventEmitter.emit(Kr.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 o(this,void 0,void 0,(function*(){const{width:e,height:t,frameRate:r,aspectRatio:n}=a(this,ef,"f").getSettings();return{trackId:a(this,ef,"f").id,readyState:a(this,ef,"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 o(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=>Yh(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 o(this,void 0,void 0,(function*(){try{c(this,ef,e,"f"),this.internalEventEmitter.emit(Kr.trackReopened,this),this.observer.safeEmit("track-changed",{track:e}),yield null===(t=this.producer)||void 0===t?void 0:t.replaceTrack({track:e}),c(this,ff,new Sf({track:e,statsHandler:a(this,mf,"f")}),"f")}catch(e){this.logger.warn("replaceTrack()",{error:e})}}))}resumeProducer(){return o(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 o(this,void 0,void 0,(function*(){const t=yield a(this,uf,"f").createMediaStreamTrack({label:this.label,constraints:a(this,df,"f")});c(this,ef,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&&Bn(r.mimeType)?[t[n]||t[0]]:t}getOutboundRTPStreamStats(){return new Promise(((e,t)=>{const r=(n=0)=>o(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()}))}}ef=new WeakMap,tf=new WeakMap,rf=new WeakMap,nf=new WeakMap,sf=new WeakMap,of=new WeakMap,af=new WeakMap,cf=new WeakMap,df=new WeakMap,uf=new WeakMap,lf=new WeakMap,pf=new WeakMap,hf=new WeakMap,ff=new WeakMap,mf=new WeakMap;class Cf extends kf{constructor(e){super(e),this.transformParams={},gf.set(this,void 0),vf.set(this,void 0),yf.set(this,!1),bf.set(this,(()=>{})),c(this,vf,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(a(this,gf,"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||Rl}setTransformParams(e){this.transformParams=e}setMaxSpatialLayer(e){return o(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 o(this,void 0,void 0,(function*(){if(!a(this,yf,"f")){c(this,yf,!0,"f");try{if(a(this,gf,"f"))return this.logger.debug("enableEffects()",{description:"Track is already processed"}),void c(this,yf,!1,"f");if("ended"===this.mediaStreamTrack.readyState)return void this.logger.warn("Track already ended",{case:"enableEffects"});const{media:e}=a(this,vf,"f");if(!e.effectsSDKInitialized)return void this.logger.warn("Effects SDK not initialized",{case:"enableEffects"});const t=Date.now();c(this,gf,yield e.createEffectsSDKTrackProcessor(this.getLabel()),"f"),this.setOriginalTrack();const r=yield a(this,gf,"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:cr(e)}),this.disableEffects().catch((e=>{this.logger.warn("Failed to this.disableEffects() in catch{}",{track:this.logCtx,error:cr(e)})})),a(this,bf,"f").call(this,e)}finally{c(this,yf,!1,"f")}}}))}disableEffects(){var e;return o(this,void 0,void 0,(function*(){try{if(!a(this,gf,"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=a(this,gf,"f"))||void 0===e||e.stopProcessing(),c(this,gf,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 o(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(Kr.trackProduced,this)}))}adjustEncodingPresetToCurrentMaxSpatialLayer(e){return o(this,void 0,void 0,(function*(){if(!Bn(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 o(this,void 0,void 0,(function*(){try{!this.isEffectsProcessing&&Object.keys(e).length>0&&(yield this.enableEffects()),null===(t=a(this,gf,"f"))||void 0===t||t.updateEffects(e)}catch(e){a(this,bf,"f").call(this,e)}}))}resetEffects(){var e;return o(this,void 0,void 0,(function*(){null===(e=a(this,gf,"f"))||void 0===e||e.updateEffects({})}))}setOnLoadModels(e){var t;null===(t=a(this,gf,"f"))||void 0===t||t.setOnLoadModels(e)}get modelsLoadProgress(){var e;return(null===(e=a(this,gf,"f"))||void 0===e?void 0:e.modelsLoadProgress)||0}pause(){return o(this,void 0,void 0,(function*(){yield this.mute((()=>{var e;a(this,gf,"f")&&(null===(e=a(this,gf,"f"))||void 0===e||e.stopProcessing(),c(this,gf,void 0,"f"))}))}))}setOnEffectError(e){c(this,bf,e,"f")}}gf=new WeakMap,vf=new WeakMap,yf=new WeakMap,bf=new WeakMap;let Rf=class{constructor(e,t,r,n,i,s,o,a,d){this.eventsQueue=e,this.media=t,this.network=r,this.socket=n,this.myPeer=i,this.internalEventEmitter=s,this.peers=o,this.clientEventEmitter=a,wf.set(this,void 0),_f.set(this,new Hh),c(this,wf,d("MediasoupEvents"),"f")}subscribeToEvents(){const{connection:e}=this.socket;if(!e)throw a(this,wf,"f").error("subscribeToEvents()",{error:"Socket connection not initialized"}),new Error("Socket connection not initialized");this.eventsQueue.subscribeToSocket(e),this.eventsQueue.on(cn,(e=>{const t=this.peers.get(e.peerId);t&&t.observer.safeEmit(cn,e)})),this.eventsQueue.on(an,(e=>{const t=this.peers.get(e.peerId);t&&t.observer.safeEmit(an,e)})),this.eventsQueue.on(yn,((e,t)=>{const r=this.peers.get(t);r&&r.observer.safeEmit(yn,e)})),this.eventsQueue.on(wn,((e,t)=>{const r=this.peers.get(t);r&&!r.isMe&&r.observer.safeEmit(wn,e)})),this.eventsQueue.on(bn,((e,t)=>{const r=this.peers.get(t);r&&!r.isMe&&r.observer.safeEmit(bn,e)})),this.eventsQueue.on(Sn,(({peerId:e,spatialLayer:t,temporalLayer:r,consumerId:n})=>{const i=this.peers.get(e);i&&!i.isMe&&i.observer.safeEmit(Sn,{consumerId:n,spatialLayer:t,temporalLayer:r})})),this.eventsQueue.on(mn,(({producerId:e,spatialLayer:t})=>o(this,void 0,void 0,(function*(){yield a(this,_f,"f").push((()=>o(this,void 0,void 0,(function*(){yield this.handleProducerSetMaxSpatialLayer({producerId:e,spatialLayer:t})}))),mn)})))),this.eventsQueue.on(fn,(({peerId:e,producerId:t,spatialLayer:r})=>o(this,void 0,void 0,(function*(){const n=this.peers.get(e);n&&!n.isMe&&n.observer.safeEmit(fn,{peerId:e,producerId:t,spatialLayer:r})})))),this.eventsQueue.on(En,(({reason:e,transportId:t,direction:r,timeout:n})=>o(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&&(a(this,wf,"f").warn(En,{reason:e,transportId:t,direction:r,timeout:n}),this.clientEventEmitter.emit(Fr,{direction:r,reason:e}))})))),this.eventsQueue.on(ln,(({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(Qr,{producerId:n.id,kind:n.kind,label:n.label,paused:n.paused}))})),this.eventsQueue.on(pn,(({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(Yr,{producerId:n.id,kind:n.kind,label:n.label,paused:n.paused}))})),this.eventsQueue.on(hn,(({label:e})=>o(this,void 0,void 0,(function*(){const t=this.media.getTrack(e);t&&(t.stopMediaStreamTrack(),this.internalEventEmitter.safeEmit(Kr.trackClosed,t),this.clientEventEmitter.emit(Nr,{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(_n,{consumerId:r,score:n})}catch(t){a(this,wf,"f").error("Failed to handle consumer score event",{error:t,payload:e})}}removeEventListeners(){if(!this.eventsQueue)return;const e=[cn,an,yn,wn,bn,Sn,mn,fn,En,ln,pn,hn],{connection:t}=this.socket;this.eventsQueue.removeAllListeners(e,t)}reset(){this.removeEventListeners()}handleProducerSetMaxSpatialLayer({producerId:e,spatialLayer:t}){return o(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 a(this,wf,"f").warn("producerRequestMaxSpatialLayer()",{message:"Producer not found"});if(!(r instanceof Cf))return void a(this,wf,"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(fn,{producerId:e,maxSpatialLayer:n}),yield r.adjustEncodingPresetToCurrentMaxSpatialLayer(n)):a(this,wf,"f").debug("producerRequestMaxSpatialLayer()",{message:"Skip set max spatial layer",requestedSpatialLayer:n,currentMaxSpatialLayer:i})}))}};wf=new WeakMap,_f=new WeakMap,Rf=n([ot(),i(0,ct(Un.EventsQueue)),i(1,ct(Un.Media)),i(2,ct(Un.Network)),i(3,ct(Un.SocketIO)),i(4,ct(Un.Network)),i(5,ct(Un.InternalEventEmitter)),i(6,ct(Un.Peers)),i(7,ct(Un.ClientEventEmitter)),i(8,ct(Un.LoggerFactory)),s("design:paramtypes",[jh,Kl,Ph,Ch,Gl,_t,Th,_t,Function])],Rf);var Pf=Rf,Tf={exports:{}},Ef=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)}},Df=Ef,If=Object.prototype.toString;function Mf(e){return"[object Array]"===If.call(e)}function xf(e){return void 0===e}function Of(e){return null!==e&&"object"==typeof e}function Lf(e){if("[object Object]"!==If.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function Af(e){return"[object Function]"===If.call(e)}function jf(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),Mf(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 Ff={isArray:Mf,isArrayBuffer:function(e){return"[object ArrayBuffer]"===If.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:Of,isPlainObject:Lf,isUndefined:xf,isDate:function(e){return"[object Date]"===If.call(e)},isFile:function(e){return"[object File]"===If.call(e)},isBlob:function(e){return"[object Blob]"===If.call(e)},isFunction:Af,isStream:function(e){return Of(e)&&Af(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:jf,merge:function e(){var t={};function r(r,n){Lf(t[n])&&Lf(r)?t[n]=e(t[n],r):Lf(r)?t[n]=e({},r):Mf(r)?t[n]=r.slice():t[n]=r}for(var n=0,i=arguments.length;n<i;n++)jf(arguments[n],r);return t},extend:function(e,t,r){return jf(t,(function(t,n){e[n]=r&&"function"==typeof t?Df(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}},Nf=Ff;function Bf(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var Wf=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(Nf.isURLSearchParams(t))n=t.toString();else{var i=[];Nf.forEach(t,(function(e,t){null!=e&&(Nf.isArray(e)?t+="[]":e=[e],Nf.forEach(e,(function(e){Nf.isDate(e)?e=e.toISOString():Nf.isObject(e)&&(e=JSON.stringify(e)),i.push(Bf(t)+"="+Bf(e))})))})),n=i.join("&")}if(n){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e},qf=Ff;function Uf(){this.handlers=[]}Uf.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},Uf.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},Uf.prototype.forEach=function(e){qf.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var zf=Uf,Vf=Ff,Hf=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},$f=Hf,Kf=function(e,t,r,n,i){var s=new Error(e);return $f(s,t,r,n,i)},Gf=Kf,Jf=Ff,Qf=Jf.isStandardBrowserEnv()?{write:function(e,t,r,n,i,s){var o=[];o.push(e+"="+encodeURIComponent(t)),Jf.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Jf.isString(n)&&o.push("path="+n),Jf.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(){}},Yf=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Zf=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},Xf=Ff,em=["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"],tm=Ff,rm=tm.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=tm.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0},nm=Ff,im=function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(Gf("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)},sm=Qf,om=Wf,am=function(e,t){return e&&!Yf(t)?Zf(e,t):t},cm=function(e){var t,r,n,i={};return e?(Xf.forEach(e.split("\n"),(function(e){if(n=e.indexOf(":"),t=Xf.trim(e.substr(0,n)).toLowerCase(),r=Xf.trim(e.substr(n+1)),t){if(i[t]&&em.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([r]):i[t]?i[t]+", "+r:r}})),i):i},dm=rm,um=Kf,lm=function(e){return new Promise((function(t,r){var n=e.data,i=e.headers,s=e.responseType;nm.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=am(e.baseURL,e.url);function u(){if(o){var n="getAllResponseHeaders"in o?cm(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};im(t,r,i),o=null}}if(o.open(e.method.toUpperCase(),om(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(um("Request aborted",e,"ECONNABORTED",o)),o=null)},o.onerror=function(){r(um("Network Error",e,null,o)),o=null},o.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(um(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",o)),o=null},nm.isStandardBrowserEnv()){var l=(e.withCredentials||dm(d))&&e.xsrfCookieName?sm.read(e.xsrfCookieName):void 0;l&&(i[e.xsrfHeaderName]=l)}"setRequestHeader"in o&&nm.forEach(i,(function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete i[t]:o.setRequestHeader(t,e)})),nm.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)}))},pm=Ff,hm=function(e,t){Vf.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))},fm=Hf,mm={"Content-Type":"application/x-www-form-urlencoded"};function gm(e,t){!pm.isUndefined(e)&&pm.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var vm,ym={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(vm=lm),vm),transformRequest:[function(e,t){return hm(t,"Accept"),hm(t,"Content-Type"),pm.isFormData(e)||pm.isArrayBuffer(e)||pm.isBuffer(e)||pm.isStream(e)||pm.isFile(e)||pm.isBlob(e)?e:pm.isArrayBufferView(e)?e.buffer:pm.isURLSearchParams(e)?(gm(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):pm.isObject(e)||t&&"application/json"===t["Content-Type"]?(gm(t,"application/json"),function(e,t,r){if(pm.isString(e))try{return(t||JSON.parse)(e),pm.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&&pm.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw fm(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}};ym.headers={common:{Accept:"application/json, text/plain, */*"}},pm.forEach(["delete","get","head"],(function(e){ym.headers[e]={}})),pm.forEach(["post","put","patch"],(function(e){ym.headers[e]=pm.merge(mm)}));var bm=ym,wm=Ff,_m=bm,Sm=function(e){return!(!e||!e.__CANCEL__)},km=Ff,Cm=function(e,t,r){var n=this||_m;return wm.forEach(r,(function(r){e=r.call(n,e,t)})),e},Rm=Sm,Pm=bm;function Tm(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var Em=Ff,Dm=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 Em.isPlainObject(e)&&Em.isPlainObject(t)?Em.merge(e,t):Em.isPlainObject(t)?Em.merge({},t):Em.isArray(t)?t.slice():t}function c(n){Em.isUndefined(t[n])?Em.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(e[n],t[n])}Em.forEach(n,(function(e){Em.isUndefined(t[e])||(r[e]=a(void 0,t[e]))})),Em.forEach(i,c),Em.forEach(s,(function(n){Em.isUndefined(t[n])?Em.isUndefined(e[n])||(r[n]=a(void 0,e[n])):r[n]=a(void 0,t[n])})),Em.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 Em.forEach(u,c),r},Im={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"}]},Mm={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){Mm[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var xm={},Om=Im.version.split(".");function Lm(e,t){for(var r=t?t.split("."):Om,n=e.split("."),i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}Mm.transitional=function(e,t,r){var n=t&&Lm(t);function i(e,t){return"[Axios v"+Im.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 Am={isOlderVersion:Lm,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:Mm},jm=Ff,Fm=Wf,Nm=zf,Bm=function(e){return Tm(e),e.headers=e.headers||{},e.data=Cm.call(e,e.data,e.headers,e.transformRequest),e.headers=km.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),km.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||Pm.adapter)(e).then((function(t){return Tm(e),t.data=Cm.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return Rm(t)||(Tm(e),t&&t.response&&(t.response.data=Cm.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},Wm=Dm,qm=Am,Um=qm.validators;function zm(e){this.defaults=e,this.interceptors={request:new Nm,response:new Nm}}zm.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=Wm(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&&qm.assertOptions(t,{silentJSONParsing:Um.transitional(Um.boolean,"1.0.0"),forcedJSONParsing:Um.transitional(Um.boolean,"1.0.0"),clarifyTimeoutError:Um.transitional(Um.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=[Bm,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=Bm(a)}catch(e){return Promise.reject(e)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},zm.prototype.getUri=function(e){return e=Wm(this.defaults,e),Fm(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},jm.forEach(["delete","get","head","options"],(function(e){zm.prototype[e]=function(t,r){return this.request(Wm(r||{},{method:e,url:t,data:(r||{}).data}))}})),jm.forEach(["post","put","patch"],(function(e){zm.prototype[e]=function(t,r,n){return this.request(Wm(n||{},{method:e,url:t,data:r}))}}));var Vm=zm;function Hm(e){this.message=e}Hm.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},Hm.prototype.__CANCEL__=!0;var $m=Hm,Km=$m;function Gm(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 Km(e),t(r.reason))}))}Gm.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},Gm.source=function(){var e,t=new Gm((function(t){e=t}));return{token:t,cancel:e}};var Jm=Gm,Qm=Ff,Ym=Ef,Zm=Vm,Xm=Dm;function eg(e){var t=new Zm(e),r=Ym(Zm.prototype.request,t);return Qm.extend(r,Zm.prototype,t),Qm.extend(r,t),r}var tg=eg(bm);tg.Axios=Zm,tg.create=function(e){return eg(Xm(tg.defaults,e))},tg.Cancel=$m,tg.CancelToken=Jm,tg.isCancel=Sm,tg.all=function(e){return Promise.all(e)},tg.spread=function(e){return function(t){return e.apply(null,t)}},tg.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError},Tf.exports=tg,Tf.exports.default=tg;var rg=Tf.exports,ng="undefined"!=typeof Symbol&&Symbol,ig=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},sg="Function.prototype.bind called on incompatible ",og=Array.prototype.slice,ag=Object.prototype.toString,cg=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==ag.call(t))throw new TypeError(sg+t);for(var r,n=og.call(arguments,1),i=function(){if(this instanceof r){var i=t.apply(this,n.concat(og.call(arguments)));return Object(i)===i?i:this}return t.apply(e,n.concat(og.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},dg=Function.prototype.bind||cg,ug=dg.call(Function.call,Object.prototype.hasOwnProperty),lg=SyntaxError,pg=Function,hg=TypeError,fg=function(e){try{return pg('"use strict"; return ('+e+").constructor;")()}catch(e){}},mg=Object.getOwnPropertyDescriptor;if(mg)try{mg({},"")}catch(yt){mg=null}var gg=function(){throw new hg},vg=mg?function(){try{return gg}catch(e){try{return mg(arguments,"callee").get}catch(e){return gg}}}():gg,yg="function"==typeof ng&&"function"==typeof Symbol&&"symbol"==typeof ng("foo")&&"symbol"==typeof Symbol("bar")&&ig(),bg=Object.getPrototypeOf||function(e){return e.__proto__},wg={},_g="undefined"==typeof Uint8Array?undefined:bg(Uint8Array),Sg={"%AggregateError%":"undefined"==typeof AggregateError?undefined:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?undefined:ArrayBuffer,"%ArrayIteratorPrototype%":yg?bg([][Symbol.iterator]()):undefined,"%AsyncFromSyncIteratorPrototype%":undefined,"%AsyncFunction%":wg,"%AsyncGenerator%":wg,"%AsyncGeneratorFunction%":wg,"%AsyncIteratorPrototype%":wg,"%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%":pg,"%GeneratorFunction%":wg,"%Int8Array%":"undefined"==typeof Int8Array?undefined:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?undefined:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?undefined:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":yg?bg(bg([][Symbol.iterator]())):undefined,"%JSON%":"object"==typeof JSON?JSON:undefined,"%Map%":"undefined"==typeof Map?undefined:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&yg?bg((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&&yg?bg((new Set)[Symbol.iterator]()):undefined,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?undefined:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":yg?bg(""[Symbol.iterator]()):undefined,"%Symbol%":yg?Symbol:undefined,"%SyntaxError%":lg,"%ThrowTypeError%":vg,"%TypedArray%":_g,"%TypeError%":hg,"%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},kg=function e(t){var r;if("%AsyncFunction%"===t)r=fg("async function () {}");else if("%GeneratorFunction%"===t)r=fg("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=fg("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&(r=bg(i.prototype))}return Sg[t]=r,r},Cg={"%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"]},Rg=dg,Pg=ug,Tg=Rg.call(Function.call,Array.prototype.concat),Eg=Rg.call(Function.apply,Array.prototype.splice),Dg=Rg.call(Function.call,String.prototype.replace),Ig=Rg.call(Function.call,String.prototype.slice),Mg=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,xg=/\\(\\)?/g,Og=function(e){var t=Ig(e,0,1),r=Ig(e,-1);if("%"===t&&"%"!==r)throw new lg("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new lg("invalid intrinsic syntax, expected opening `%`");var n=[];return Dg(e,Mg,(function(e,t,r,i){n[n.length]=r?Dg(i,xg,"$1"):t||e})),n},Lg=function(e,t){var r,n=e;if(Pg(Cg,n)&&(n="%"+(r=Cg[n])[0]+"%"),Pg(Sg,n)){var i=Sg[n];if(i===wg&&(i=kg(n)),void 0===i&&!t)throw new hg("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new lg("intrinsic "+e+" does not exist!")},Ag=function(e,t){if("string"!=typeof e||0===e.length)throw new hg("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new hg('"allowMissing" argument must be a boolean');var r=Og(e),n=r.length>0?r[0]:"",i=Lg("%"+n+"%",t),s=i.name,o=i.value,a=!1,c=i.alias;c&&(n=c[0],Eg(r,Tg([0,1],c)));for(var d=1,u=!0;d<r.length;d+=1){var l=r[d],p=Ig(l,0,1),h=Ig(l,-1);if(('"'===p||"'"===p||"`"===p||'"'===h||"'"===h||"`"===h)&&p!==h)throw new lg("property names with quotes must have matching quotes");if("constructor"!==l&&u||(a=!0),Pg(Sg,s="%"+(n+="."+l)+"%"))o=Sg[s];else if(null!=o){if(!(l in o)){if(!t)throw new hg("base intrinsic for "+e+" exists, but the property is not available.");return}if(mg&&d+1>=r.length){var f=mg(o,l);o=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:o[l]}else u=Pg(o,l),o=o[l];u&&!a&&(Sg[s]=o)}}return o},jg={exports:{}};!function(e){var t=dg,r=Ag,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}(jg);var Fg=Ag,Ng=jg.exports,Bg=Ng(Fg("String.prototype.indexOf")),Wg=p(Object.freeze({__proto__:null,default:{}})),qg="function"==typeof Map&&Map.prototype,Ug=Object.getOwnPropertyDescriptor&&qg?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,zg=qg&&Ug&&"function"==typeof Ug.get?Ug.get:null,Vg=qg&&Map.prototype.forEach,Hg="function"==typeof Set&&Set.prototype,$g=Object.getOwnPropertyDescriptor&&Hg?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Kg=Hg&&$g&&"function"==typeof $g.get?$g.get:null,Gg=Hg&&Set.prototype.forEach,Jg="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Qg="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Yg="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Zg=Boolean.prototype.valueOf,Xg=Object.prototype.toString,ev=Function.prototype.toString,tv=String.prototype.match,rv="function"==typeof BigInt?BigInt.prototype.valueOf:null,nv=Object.getOwnPropertySymbols,iv="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,sv="function"==typeof Symbol&&"object"==typeof Symbol.iterator,ov=Object.prototype.propertyIsEnumerable,av=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null),cv=Wg.custom,dv=cv&&fv(cv)?cv:null,uv="function"==typeof Symbol&&void 0!==Symbol.toStringTag?Symbol.toStringTag:null;function lv(e,t,r){var n="double"===(r.quoteStyle||t)?'"':"'";return n+e+n}function pv(e){return String(e).replace(/"/g,""")}function hv(e){return!("[object Array]"!==vv(e)||uv&&"object"==typeof e&&uv in e)}function fv(e){if(sv)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!iv)return!1;try{return iv.call(e),!0}catch(e){}return!1}var mv=Object.prototype.hasOwnProperty||function(e){return e in this};function gv(e,t){return mv.call(e,t)}function vv(e){return Xg.call(e)}function yv(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 bv(e,t){if(e.length>t.maxStringLength){var r=e.length-t.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return bv(e.slice(0,t.maxStringLength),t)+n}return lv(e.replace(/(['\\])/g,"\\$1").replace(/[\x00-\x1f]/g,wv),"single",t)}function wv(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 _v(e){return"Object("+e+")"}function Sv(e){return e+" { ? }"}function kv(e,t,r,n){return e+" ("+t+") {"+(n?Cv(r,n):r.join(", "))+"}"}function Cv(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+e.join(","+r)+"\n"+t.prev}function Rv(e,t){var r=hv(e),n=[];if(r){n.length=e.length;for(var i=0;i<e.length;i++)n[i]=gv(e,i)?t(e[i],e):""}var s,o="function"==typeof nv?nv(e):[];if(sv){s={};for(var a=0;a<o.length;a++)s["$"+o[a]]=o[a]}for(var c in e)gv(e,c)&&(r&&String(Number(c))===c&&c<e.length||sv&&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 nv)for(var d=0;d<o.length;d++)ov.call(e,o[d])&&n.push("["+t(o[d])+"]: "+t(e[o[d]],e));return n}var Pv=Ag,Tv=function(e,t){var r=Fg(e,!!t);return"function"==typeof r&&Bg(e,".prototype.")>-1?Ng(r):r},Ev=function e(t,r,n,i){var s=r||{};if(gv(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(gv(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=!gv(s,"customInspect")||s.customInspect;if("boolean"!=typeof o&&"symbol"!==o)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(gv(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 bv(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 hv(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(yv(i,t)>=0)return"[Circular]";function d(t,r,o){if(r&&(i=i.slice()).push(r),o){var a={depth:s.depth};return gv(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=tv.call(ev.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),l=Rv(t,d);return"[Function"+(u?": "+u:" (anonymous)")+"]"+(l.length>0?" { "+l.join(", ")+" }":"")}if(fv(t)){var p=sv?String(t).replace(/^(Symbol\(.*\))_[^)]*$/,"$1"):iv.call(t);return"object"!=typeof t||sv?p:_v(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+"="+lv(pv(f[m].value),"double",s);return h+=">",t.childNodes&&t.childNodes.length&&(h+="..."),h+="</"+String(t.nodeName).toLowerCase()+">"}if(hv(t)){if(0===t.length)return"[]";var g=Rv(t,d);return c&&!function(e){for(var t=0;t<e.length;t++)if(yv(e[t],"\n")>=0)return!1;return!0}(g)?"["+Cv(g,c)+"]":"[ "+g.join(", ")+" ]"}if(function(e){return!("[object Error]"!==vv(e)||uv&&"object"==typeof e&&uv in e)}(t)){var v=Rv(t,d);return 0===v.length?"["+String(t)+"]":"{ ["+String(t)+"] "+v.join(", ")+" }"}if("object"==typeof t&&o){if(dv&&"function"==typeof t[dv])return t[dv]();if("symbol"!==o&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!zg||!e||"object"!=typeof e)return!1;try{zg.call(e);try{Kg.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var y=[];return Vg.call(t,(function(e,r){y.push(d(r,t,!0)+" => "+d(e,t))})),kv("Map",zg.call(t),y,c)}if(function(e){if(!Kg||!e||"object"!=typeof e)return!1;try{Kg.call(e);try{zg.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var b=[];return Gg.call(t,(function(e){b.push(d(e,t))})),kv("Set",Kg.call(t),b,c)}if(function(e){if(!Jg||!e||"object"!=typeof e)return!1;try{Jg.call(e,Jg);try{Qg.call(e,Qg)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return Sv("WeakMap");if(function(e){if(!Qg||!e||"object"!=typeof e)return!1;try{Qg.call(e,Qg);try{Jg.call(e,Jg)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return Sv("WeakSet");if(function(e){if(!Yg||!e||"object"!=typeof e)return!1;try{return Yg.call(e),!0}catch(e){}return!1}(t))return Sv("WeakRef");if(function(e){return!("[object Number]"!==vv(e)||uv&&"object"==typeof e&&uv in e)}(t))return _v(d(Number(t)));if(function(e){if(!e||"object"!=typeof e||!rv)return!1;try{return rv.call(e),!0}catch(e){}return!1}(t))return _v(d(rv.call(t)));if(function(e){return!("[object Boolean]"!==vv(e)||uv&&"object"==typeof e&&uv in e)}(t))return _v(Zg.call(t));if(function(e){return!("[object String]"!==vv(e)||uv&&"object"==typeof e&&uv in e)}(t))return _v(d(String(t)));if(!function(e){return!("[object Date]"!==vv(e)||uv&&"object"==typeof e&&uv in e)}(t)&&!function(e){return!("[object RegExp]"!==vv(e)||uv&&"object"==typeof e&&uv in e)}(t)){var w=Rv(t,d),_=av?av(t)===Object.prototype:t instanceof Object||t.constructor===Object,S=t instanceof Object?"":"null prototype",k=!_&&uv&&Object(t)===t&&uv in t?vv(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+"{"+Cv(w,c)+"}":C+"{ "+w.join(", ")+" }"}return String(t)},Dv=Pv("%TypeError%"),Iv=Pv("%WeakMap%",!0),Mv=Pv("%Map%",!0),xv=Tv("WeakMap.prototype.get",!0),Ov=Tv("WeakMap.prototype.set",!0),Lv=Tv("WeakMap.prototype.has",!0),Av=Tv("Map.prototype.get",!0),jv=Tv("Map.prototype.set",!0),Fv=Tv("Map.prototype.has",!0),Nv=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},Bv=String.prototype.replace,Wv=/%20/g,qv="RFC3986",Uv={default:qv,formatters:{RFC1738:function(e){return Bv.call(e,Wv,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:qv},zv=Uv,Vv=Object.prototype.hasOwnProperty,Hv=Array.isArray,$v=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),Kv=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},Gv={arrayToObject:Kv,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(Hv(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===zv.RFC1738&&(40===c||41===c)?o+=s.charAt(a):c<128?o+=$v[c]:c<2048?o+=$v[192|c>>6]+$v[128|63&c]:c<55296||c>=57344?o+=$v[224|c>>12]+$v[128|c>>6&63]+$v[128|63&c]:(a+=1,c=65536+((1023&c)<<10|1023&s.charCodeAt(a)),o+=$v[240|c>>18]+$v[128|c>>12&63]+$v[128|c>>6&63]+$v[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(Hv(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(Hv(t))t.push(r);else{if(!t||"object"!=typeof t)return[t,r];(n&&(n.plainObjects||n.allowPrototypes)||!Vv.call(Object.prototype,r))&&(t[r]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(r);var i=t;return Hv(t)&&!Hv(r)&&(i=Kv(t,n)),Hv(t)&&Hv(r)?(r.forEach((function(r,i){if(Vv.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 Vv.call(t,i)?t[i]=e(t[i],s,n):t[i]=s,t}),i)}},Jv=function(){var e,t,r,n={assert:function(e){if(!n.has(e))throw new Dv("Side channel does not contain "+Ev(e))},get:function(n){if(Iv&&n&&("object"==typeof n||"function"==typeof n)){if(e)return xv(e,n)}else if(Mv){if(t)return Av(t,n)}else if(r)return function(e,t){var r=Nv(e,t);return r&&r.value}(r,n)},has:function(n){if(Iv&&n&&("object"==typeof n||"function"==typeof n)){if(e)return Lv(e,n)}else if(Mv){if(t)return Fv(t,n)}else if(r)return function(e,t){return!!Nv(e,t)}(r,n);return!1},set:function(n,i){Iv&&n&&("object"==typeof n||"function"==typeof n)?(e||(e=new Iv),Ov(e,n,i)):Mv?(t||(t=new Mv),jv(t,n,i)):(r||(r={key:{},next:null}),function(e,t,r){var n=Nv(e,t);n?n.value=r:e.next={key:t,next:e.next,value:r}}(r,n,i))}};return n},Qv=Gv,Yv=Uv,Zv=Object.prototype.hasOwnProperty,Xv={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},ey=Array.isArray,ty=String.prototype.split,ry=Array.prototype.push,ny=function(e,t){ry.apply(e,ey(t)?t:[t])},iy=Date.prototype.toISOString,sy=Yv.default,oy={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:Qv.encode,encodeValuesOnly:!1,format:sy,formatter:Yv.formatters[sy],indices:!1,serializeDate:function(e){return iy.call(e)},skipNulls:!1,strictNullHandling:!1},ay={},cy=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(ay))&&!w;){var _=y.get(t);if(b+=1,void 0!==_){if(_===b)throw new RangeError("Cyclic object value");w=!0}void 0===y.get(ay)&&(b=0)}if("function"==typeof c?v=c(r,v):v instanceof Date?v=l(v):"comma"===n&&ey(v)&&(v=Qv.maybeMap(v,(function(e){return e instanceof Date?l(e):e}))),null===v){if(s)return a&&!f?a(r,oy.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)||Qv.isBuffer(v)){if(a){var S=f?r:a(r,oy.encoder,m,"key",p);if("comma"===n&&f){for(var k=ty.call(String(v),","),C="",R=0;R<k.length;++R)C+=(0===R?"":",")+h(a(k[R],oy.encoder,m,"value",p));return[h(S)+(i&&ey(v)&&1===k.length?"[]":"")+"="+C]}return[h(S)+"="+h(a(v,oy.encoder,m,"value",p))]}return[h(r)+"="+h(String(v))]}var P,T=[];if(void 0===v)return T;if("comma"===n&&ey(v))P=[{value:v.length>0?v.join(",")||null:void 0}];else if(ey(c))P=c;else{var E=Object.keys(v);P=d?E.sort(d):E}for(var D=i&&ey(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=ey(v)?"function"==typeof n?n(D,M):D:D+(u?"."+M:"["+M+"]");g.set(t,b);var L=Jv();L.set(ay,g),ny(T,e(x,O,n,i,s,o,a,c,d,u,l,p,h,f,m,L))}}return T},dy=Gv,uy=Object.prototype.hasOwnProperty,ly=Array.isArray,py={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:dy.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},hy=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},fy=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},my=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&&uy.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&&uy.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:fy(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)}},gy=function(e,t){var r,n=e,i=function(e){if(!e)return oy;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||oy.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=Yv.default;if(void 0!==e.format){if(!Zv.call(Yv.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n=Yv.formatters[r],i=oy.filter;return("function"==typeof e.filter||ey(e.filter))&&(i=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:oy.addQueryPrefix,allowDots:void 0===e.allowDots?oy.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:oy.charsetSentinel,delimiter:void 0===e.delimiter?oy.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:oy.encode,encoder:"function"==typeof e.encoder?e.encoder:oy.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:oy.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:oy.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:oy.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:oy.strictNullHandling}}(t);"function"==typeof i.filter?n=(0,i.filter)("",n):ey(i.filter)&&(r=i.filter);var s,o=[];if("object"!=typeof n||null===n)return"";s=t&&t.arrayFormat in Xv?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var a=Xv[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=Jv(),u=0;u<r.length;++u){var l=r[u];i.skipNulls&&null===n[l]||ny(o,cy(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:""},vy=function(e,t){var r=function(e){if(!e)return py;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?py.charset:e.charset;return{allowDots:void 0===e.allowDots?py.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:py.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:py.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:py.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:py.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:py.comma,decoder:"function"==typeof e.decoder?e.decoder:py.decoder,delimiter:"string"==typeof e.delimiter||dy.isRegExp(e.delimiter)?e.delimiter:py.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:py.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:py.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:py.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:py.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:py.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,py.decoder,c,"key"),u=t.strictNullHandling?null:""):(d=t.decoder(l.slice(0,h),py.decoder,c,"key"),u=dy.maybeMap(fy(l.slice(h+1),t),(function(e){return t.decoder(e,py.decoder,c,"value")}))),u&&t.interpretNumericEntities&&"iso-8859-1"===c&&(u=hy(u)),l.indexOf("[]=")>-1&&(u=ly(u)?[u]:u),uy.call(n,d)?n[d]=dy.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=my(a,n[a],r,"string"==typeof e);i=dy.merge(i,c,r)}return!0===r.allowSparse?i:dy.compact(i)},yy={formats:Uv,parse:vy,stringify:gy};let by=class{constructor(e){this.config=e;const t=this.config.get("loadbalancer"),{baseURL:r,timeout:n,customNode:i}=t;this.api=rg.create({baseURL:r||"https://lb.livedigital.space/v1",timeout:n||5e3,withCredentials:!1,paramsSerializer:e=>yy.stringify(e)}),this.customNode=i}getNode(e){return o(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 o(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}}))}};by=n([ot(),i(0,ct(Un.Config)),s("design:paramtypes",[wt])],by);var wy,_y=by;let Sy=class{constructor(e,t){this.clientEventEmitter=e,this.isEnableVideoDevicesLock=!1,this.isEnableAudioDevicesLock=!1,this.isDevicesDetected=!1,this.availableVideoDevices=[],this.availableAudioDevices=[],wy.set(this,void 0),c(this,wy,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 o(this,void 0,void 0,(function*(){try{return(yield navigator.mediaDevices.getUserMedia(e)).getTracks()}catch(t){if(a(this,wy,"f").error("getUserMedia()",{error:t,constraints:e}),"NotAllowedError"===t.name)throw new Error(Vn.NotAllowedError);if("NotReadableError"===t.name)throw new Error(Vn.DeviceIsBusy);if("NotFoundError"===t.name)throw new Error(Vn.NotFoundError);throw new Error(Vn.RequestDevicesUnknownError)}}))}hasAvailableMediaDevicesList(){return o(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 o(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 a(this,wy,"f").debug("Devices list updated",{videoDevices:t.map(n),audioDevices:r.map(n)}),e}))}detectDevices(e){return o(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(Vn.NoDevices)}))}deviceChangeHandler(){return o(this,void 0,void 0,(function*(){this.isDevicesDetected&&(yield this.refreshAvailableMediaDevicesList(),this.clientEventEmitter.safeEmit(jr,{audio:this.availableAudioDevices,video:this.availableVideoDevices}))}))}listenDevices(){navigator.mediaDevices.addEventListener("devicechange",this.deviceChangeHandler)}assertHasAccessToMediaDevices(e={video:!0,audio:!0}){return o(this,void 0,void 0,(function*(){(yield this.requestMediaDevicesAccess(e)).forEach((e=>e.stop()))}))}tryToAccessDevices(){return o(this,void 0,void 0,(function*(){try{(yield this.requestMediaDevicesAccess()).forEach((e=>e.stop()))}catch(t){if(e=t.message,![Vn.NotFoundError,Vn.NotAllowedError,Vn.DeviceIsBusy].includes(e))throw t;t.message!==Vn.DeviceIsBusy&&(yield this.assertHasAccessToMediaDevices({audio:!0}),yield this.assertHasAccessToMediaDevices({video:!0}))}var e}))}};wy=new WeakMap,Sy=n([ot(),i(0,ct(Un.ClientEventEmitter)),i(1,ct(Un.LoggerFactory)),s("design:paramtypes",[_t,Function])],Sy);var ky,Cy,Ry,Py,Ty,Ey,Dy,Iy,My,xy,Oy=Sy;class Ly{constructor({sendTransportConnectionManager:e,receiveTransportConnectionManager:t,media:r,peers:n}){ky.set(this,void 0),Cy.set(this,void 0),Ry.set(this,void 0),Py.set(this,void 0),c(this,ky,e,"f"),c(this,Cy,t,"f"),c(this,Ry,r,"f"),c(this,Py,n,"f")}getStats(){var e,t;return Object.assign(Object.assign({},(null===(e=a(this,ky,"f").connectionStats)||void 0===e?void 0:e.id)?{outbound:Object.assign(Object.assign({},a(this,ky,"f").connectionStats),{bitrate:this.calculateOutboundTracksBitrate()})}:{}),(null===(t=a(this,Cy,"f").connectionStats)||void 0===t?void 0:t.id)?{inbound:Object.assign(Object.assign({},a(this,Cy,"f").connectionStats),{bitrate:this.calculateInboundTracksBitrate()})}:{})}calculateInboundTracksBitrate(){return a(this,Py,"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 a(this,Ry,"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)}}ky=new WeakMap,Cy=new WeakMap,Ry=new WeakMap,Py=new WeakMap;class Ay{constructor({transport:e,statsHandler:t}){Ty.set(this,void 0),this.handleWebRTCStats(e,t)}get connectionStats(){return a(this,Ty,"f")}handleWebRTCStats(e,t){t.addConnectionHandler(e.id,this.setConnectionStats.bind(this)),e.observer.once("close",(()=>{t.removeConnectionHandler(e.id)}))}setConnectionStats(e){c(this,Ty,e,"f")}}Ty=new WeakMap;let jy=class{constructor(){Ey.set(this,new Map),Dy.set(this,new Map),Iy.set(this,new Map),My.set(this,new Map),xy.set(this,new Map)}handle(e){e.forEach((({id:e,stats:t})=>{var r;null===(r=a(this,Ey,"f").get(e))||void 0===r||r(t.connection),t.video.inbound.forEach((e=>{var t;return null===(t=a(this,Dy,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.inbound.forEach((e=>{var t;return null===(t=a(this,Iy,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.video.outbound.forEach((e=>{var t;return null===(t=a(this,My,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.outbound.forEach((e=>{var t;return null===(t=a(this,xy,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)}))}))}addConnectionHandler(e,t){a(this,Ey,"f").set(e,t)}addInboundVideoHandler(e,t){a(this,Dy,"f").set(e,t)}addInboundAudioHandler(e,t){a(this,Iy,"f").set(e,t)}addOutboundVideoHandler(e,t){a(this,My,"f").set(e,t)}addOutboundAudioHandler(e,t){a(this,xy,"f").set(e,t)}removeConnectionHandler(e){a(this,Ey,"f").delete(e)}removeInboundVideoHandler(e){a(this,Dy,"f").delete(e)}removeInboundAudioHandler(e){a(this,My,"f").delete(e)}removeOutboundVideoHandler(e){a(this,xy,"f").delete(e)}removeOutboundAudioHandler(e){a(this,xy,"f").delete(e)}clear(){a(this,Ey,"f").clear(),a(this,Dy,"f").clear(),a(this,Iy,"f").clear(),a(this,My,"f").clear(),a(this,xy,"f").clear()}};Ey=new WeakMap,Dy=new WeakMap,Iy=new WeakMap,My=new WeakMap,xy=new WeakMap,jy=n([ot()],jy);var Fy,Ny,By,Wy,qy,Uy=jy;class zy extends On{constructor(e,t){super(e,null!=t?t:"invalid_payload")}}!function(e){e.DominantSpeaker="dominant-speaker",e.PeersVolumes="peers-volumes",e.Silence="silence"}(Fy||(Fy={}));let Vy=qy=class{constructor(e,t,r){this.peers=e,this.clientEventEmitter=t,Ny.set(this,void 0),By.set(this,void 0),Wy.set(this,void 0),c(this,Ny,r("ChannelAudioObserverEventHandler"),"f"),this.watchPeersLeave()}handle(e){try{const t=JSON.parse(e);switch(qy.validateEventPayload(t),t.event){case Fy.DominantSpeaker:this.handleDominantSpeaker(t);break;case Fy.PeersVolumes:this.handlePeerVolumes(t);break;case Fy.Silence:this.handleSilence()}}catch(t){a(this,Ny,"f").warn("Failed to handle audio observer event",{error:cr(t),eventData:e})}}handleDominantSpeaker(e){const{peerId:t}=e.data,r=this.peers.get(t);c(this,By,r,"f"),c(this,Wy,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&&!a(this,By,"f")&&s.id===(null===(t=a(this,Wy,"f"))||void 0===t?void 0:t.id)&&(c(this,By,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))),c(this,By,void 0,"f"),this.peers.setActiveSpeaker(void 0)}watchPeersLeave(){this.clientEventEmitter.on(Mr,(e=>{var t;e===(null===(t=a(this,By,"f"))||void 0===t?void 0:t.id)&&this.peers.setActiveSpeaker(void 0)}))}static validateEventPayload(e){switch(e.event){case Fy.Silence:break;case Fy.DominantSpeaker:{e.data||qy.throwInvalidPayload();const{peerId:t,producerId:r,trackLabel:n}=e.data;"string"==typeof t&&"string"==typeof r&&n===zn.Microphone||qy.throwInvalidPayload();break}case Fy.PeersVolumes:Array.isArray(e.volumes)||qy.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||qy.throwInvalidPayload()}));break;default:qy.throwInvalidPayload()}}static throwInvalidPayload(){throw new zy("Invalid channel audio observer event handler payload")}};Ny=new WeakMap,By=new WeakMap,Wy=new WeakMap,Vy=qy=n([ot(),i(0,ct(Un.Peers)),i(1,ct(Un.ClientEventEmitter)),i(2,ct(Un.LoggerFactory)),s("design:paramtypes",[Th,_t,Function])],Vy);var Hy=Vy,$y=Uint8Array,Ky=Uint16Array,Gy=Int32Array,Jy=new $y([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]),Qy=new $y([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]),Yy=new $y([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zy=function(e,t){for(var r=new Ky(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];var i=new Gy(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}},Xy=Zy(Jy,2),eb=Xy.b,tb=Xy.r;eb[28]=258,tb[258]=28;for(var rb=Zy(Qy,0).b,nb=new Ky(32768),ib=0;ib<32768;++ib){var sb=(43690&ib)>>1|(21845&ib)<<1;sb=(61680&(sb=(52428&sb)>>2|(13107&sb)<<2))>>4|(3855&sb)<<4,nb[ib]=((65280&sb)>>8|(255&sb)<<8)>>1}var ob=function(e,t,r){for(var n=e.length,i=0,s=new Ky(t);i<n;++i)e[i]&&++s[e[i]-1];var o,a=new Ky(t);for(i=1;i<t;++i)a[i]=a[i-1]+s[i-1]<<1;if(r){o=new Ky(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[nb[l]>>c]=d}else for(o=new Ky(n),i=0;i<n;++i)e[i]&&(o[i]=nb[a[e[i]-1]++]>>15-e[i]);return o},ab=new $y(288);for(ib=0;ib<144;++ib)ab[ib]=8;for(ib=144;ib<256;++ib)ab[ib]=9;for(ib=256;ib<280;++ib)ab[ib]=7;for(ib=280;ib<288;++ib)ab[ib]=8;var cb=new $y(32);for(ib=0;ib<32;++ib)cb[ib]=5;var db=ob(ab,9,1),ub=ob(cb,5,1),lb=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},pb=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&r},hb=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},fb=function(e){return(e+7)/8|0},mb=function(e,t,r){return(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length),new $y(e.subarray(t,r))},gb=["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"],vb=function(e,t,r){var n=new Error(t||gb[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,vb),!r)throw n;return n},yb=function(e,t,r,n){var i=e.length,s=n?n.length:0;if(!i||t.f&&!t.l)return r||new $y(0);var o=!r,a=o||2!=t.i,c=t.i;o&&(r=new $y(3*i));var d=function(e){var t=r.length;if(e>t){var n=new $y(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=pb(e,l,1);var y=pb(e,l+1,3);if(l+=3,!y){var b=e[(I=fb(l)+4)-4]|e[I-3]<<8,w=I+b;if(w>i){c&&vb(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=db,f=ub,m=9,g=5;else if(2==y){var _=pb(e,l,31)+257,S=pb(e,l+10,15)+4,k=_+pb(e,l+5,31)+1;l+=14;for(var C=new $y(k),R=new $y(19),P=0;P<S;++P)R[Yy[P]]=pb(e,l+3*P,7);l+=3*S;var T=lb(R),E=(1<<T)-1,D=ob(R,T,1);for(P=0;P<k;){var I,M=D[pb(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+pb(e,l,3),l+=2,x=C[P-1]):17==I?(O=3+pb(e,l,7),l+=3):18==I&&(O=11+pb(e,l,127),l+=7);O--;)C[P++]=x}}var L=C.subarray(0,_),A=C.subarray(_);m=lb(L),g=lb(A),h=ob(L,m,1),f=ob(A,g,1)}else vb(1);if(l>v){c&&vb(0);break}}a&&d(p+131072);for(var j=(1<<m)-1,F=(1<<g)-1,N=l;;N=l){var B=(x=h[hb(e,l)&j])>>4;if((l+=15&x)>v){c&&vb(0);break}if(x||vb(2),B<256)r[p++]=B;else{if(256==B){N=l,h=null;break}var W=B-254;if(B>264){var q=Jy[P=B-257];W=pb(e,l,(1<<q)-1)+eb[P],l+=q}var U=f[hb(e,l)&F],z=U>>4;U||vb(3),l+=15&U;A=rb[z];if(z>3){q=Qy[z];A+=hb(e,l)&(1<<q)-1,l+=q}if(l>v){c&&vb(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&&vb(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?mb(r,0,p):r.subarray(0,p)},bb=new $y(0);function wb(e,t){var r=function(e){31==e[0]&&139==e[1]&&8==e[2]||vb(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&&vb(6,"invalid gzip data"),yb(e.subarray(r,-8),{i:2},t&&t.out||new $y(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 _b(e,t){return yb(e.subarray(function(e,t){return(8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31)&&vb(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&vb(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 Sb(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?wb(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?function(e,t){return yb(e,{i:2},t&&t.out,t&&t.dictionary)}(e,t):_b(e,t)}var kb="undefined"!=typeof TextDecoder&&new TextDecoder;try{kb.decode(bb,{stream:!0}),1}catch(yt){}function Cb(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(kb)return kb.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:mb(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&&vb(8),s}function Rb(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 Pb(e,t,r,n){var i=Rb(Rb(Rb(e,r),function(e){return Object.prototype.toString.call(e)}(t)),typeof t);if(null===t)return Rb(i,"null");if(void 0===t)return Rb(i,"undefined");if("object"==typeof t||"function"==typeof t){if(-1!==n.indexOf(t))return Rb(i,"[Circular]"+r);n.push(t);var s=function(e,t,r){return Object.keys(t).sort().reduce((function(e,n){return Pb(e,t[n],n,r)}),e)}(i,t,n);if(!("valueOf"in t)||"function"!=typeof t.valueOf)return s;try{return Rb(s,String(t.valueOf()))}catch(e){return Rb(s,"[valueOf exception]"+(e.stack||e.message))}}return Rb(i,t.toString())}var Tb=function(e){return function(e,t){for(;e.length<t;)e="0"+e;return e}(Pb(0,e,"",[]).toString(16),8)};class Eb{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 Db{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 Eb({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 Ib,Mb,xb,Ob,Lb,Ab,jb;!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"}(Ib||(Ib={}));let Fb=class{constructor(e,t,r,n,i,s,o,a){var d;this.channelStateSynchronizer=e,this.network=r,this.callState=n,this.socket=i,this.peers=s,this.clientEventEmitter=o,this.webRtcIssueDetector=a,Mb.set(this,void 0),xb.set(this,void 0),Ob.set(this,[]),Lb.set(this,!1),Ab.set(this,{inbound:4.3,outbound:4.3}),jb.set(this,(new Date).getTime()-15e3),c(this,xb,null===(d=this.webRtcIssueDetector)||void 0===d?void 0:d.eventEmitter,"f"),c(this,Mb,t("ChannelStateSyncEventHandler"),"f"),this.listenNetworkScoresUpdatedEvents()}handle(e){return o(this,void 0,void 0,(function*(){try{const{event:t,data:r}=yield this.parseChannelStateSyncEventPayload(e);"channel-state"!==t||a(this,Lb,"f")||(yield this.handleChannelStateEvent(r))}catch(e){a(this,Mb,"f").error("handleChannelStateSyncEvent()",{error:cr(e)})}}))}handleChannelStateEvent(e){return o(this,void 0,void 0,(function*(){c(this,Lb,!0,"f");try{yield this.collectProbableInconsistencyCases(e);const t=this.getConfirmedInconsistencyResult();if(!(null==t?void 0:t.hasInconsistencyCases()))return;if(this.isRestoreStateRequestToEarly())return void a(this,Mb,"f").info("Inconsistency detected, but restore skipped",Object.assign({},t));this.handleConfirmedInconsistencyResult(t)}finally{c(this,Lb,!1,"f")}}))}getLastInconsistencyCheckResult(){return a(this,Ob,"f")[a(this,Ob,"f").length-1]}handleConfirmedInconsistencyResult(e){e.missingPeers.forEach((e=>{this.clientEventEmitter.safeEmit(qr,{peerId:e,type:Ib.MissingPeer})})),e.missingProducers.forEach((e=>{this.clientEventEmitter.safeEmit(qr,{producerId:e,type:Ib.MissingProducer})})),e.producersWithInconsistentState.forEach((e=>{this.clientEventEmitter.safeEmit(qr,{producerId:e,type:Ib.IncorrectProducerState})})),e.peersWithInconsistentAppData.forEach((e=>{this.clientEventEmitter.safeEmit(qr,{peerId:e,type:Ib.IncorrectAppData})}))}getConfirmedInconsistencyResult(){const e=this.getLastInconsistencyCheckResult();if(!e)return;return new Eb({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 o(this,void 0,void 0,(function*(){const t=new Db({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(){c(this,Ob,[],"f")}rotateLastProbableInconsistencyCheckResults(e){4===a(this,Ob,"f").length&&a(this,Ob,"f").shift(),a(this,Ob,"f").push(e)}isReachedMaxCheckRetries(e,t,r=4){let n=0;return a(this,Ob,"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 o(this,void 0,void 0,(function*(){const t=Sb("arrayBuffer"in e?new Uint8Array(yield e.arrayBuffer()):new Uint8Array(e));return JSON.parse(Cb(t))}))}getLocalState(){return{peers:this.peers.hosts().map((e=>({id:e.id,appDataHash:Tb(e.appData),producers:e.getProducers().map((e=>({id:e.id,paused:e.paused}))),consumers:e.getConsumersState()})))}}getIsConnectionActive(){var e;return o(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(){a(this,xb,"f")&&a(this,xb,"f").on(vt.NetworkScoresUpdated,(e=>{e.inbound&&(a(this,Ab,"f").inbound=e.inbound),e.outbound&&(a(this,Ab,"f").outbound=e.outbound)}))}isBadNetworkScore(){const{inbound:e,outbound:t}=a(this,Ab,"f");return e<=2.6||t<=2.6}compareCheckedAndRestoredResults(e,t){return new Eb({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()-a(this,jb,"f")<=15e3}};Mb=new WeakMap,xb=new WeakMap,Ob=new WeakMap,Lb=new WeakMap,Ab=new WeakMap,jb=new WeakMap,Fb=n([ot(),i(0,ct(Un.ChannelStateSynchronizer)),i(1,ct(Un.LoggerFactory)),i(2,ct(Un.Network)),i(3,ct(Un.CallState)),i(4,ct(Un.SocketIO)),i(5,ct(Un.Peers)),i(6,ct(Un.ClientEventEmitter)),i(7,ct(Un.WebRTCIssueDetector)),s("design:paramtypes",[Bh,Function,Ph,$n,Ch,Th,_t,Zt])],Fb);var Nb,Bb,Wb,qb,Ub,zb,Vb,Hb,$b,Kb=Fb;let Gb=class{constructor(e,t,r,n,i,s,a,d,u,l){this.state=e,this.myPeer=r,this.network=n,this.channelEventsHandler=i,this.eventsQueue=s,this.peers=a,this.mediaSoupEventsHandler=d,this.channelAudioObserverEventHandler=u,this.channelStateSyncEventHandler=l,Nb.set(this,void 0),Bb.set(this,void 0),Wb.set(this,void 0),qb.set(this,void 0),Ub.set(this,void 0),zb.set(this,void 0),Vb.set(this,void 0),Hb.set(this,void 0),$b.set(this,void 0),c(this,Nb,t("DataChannels"),"f"),c(this,zb,(e=>{this.channelAudioObserverEventHandler.handle(e)}),"f"),c(this,Vb,(e=>{this.channelEventsHandler.handleDataChannelEvent(e)}),"f"),c(this,Hb,(e=>o(this,void 0,void 0,(function*(){yield this.channelStateSyncEventHandler.handle(e)}))),"f"),c(this,$b,(e=>{this.mediaSoupEventsHandler.handleConsumerScoreEvent(e)}),"f")}createAllDataChannels(){return o(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,c;null===(e=a(this,Bb,"f"))||void 0===e||e.removeListener("message",a(this,zb,"f")),null===(t=a(this,Bb,"f"))||void 0===t||t.close(),null===(r=a(this,Wb,"f"))||void 0===r||r.removeListener("message",a(this,Vb,"f")),null===(n=a(this,Wb,"f"))||void 0===n||n.close(),null===(i=a(this,qb,"f"))||void 0===i||i.removeListener("message",a(this,Hb,"f")),null===(s=a(this,qb,"f"))||void 0===s||s.close(),null===(o=a(this,Ub,"f"))||void 0===o||o.removeListener("message",a(this,$b,"f")),null===(c=a(this,Ub,"f"))||void 0===c||c.close()}createAudioObserver(){var e;return o(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",a(this,zb,"f")),c(this,Bb,r,"f"),a(this,Nb,"f").debug("Successfully create audio observer",t)}catch(e){a(this,Nb,"f").error("Failed to create audio observer",t)}}))}createGeneralDataConsumer(){var e;return o(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();c(this,Wb,yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId,ordered:!0}),"f"),this.eventsQueue.subscribeToDataChannel(a(this,Wb,"f")),this.eventsQueue.on("message",a(this,Vb,"f")),a(this,Nb,"f").debug("Successfully created general data consumer",Object.assign(Object.assign({},t),{producerId:e}))}catch(e){a(this,Nb,"f").error("Failed to create general data consumer",Object.assign(Object.assign({},t),{error:e}))}}))}createChannelStateSyncDataConsumer(){var e;return o(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(c(this,qb,yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId}),"f"),!a(this,qb,"f"))throw new Error("Failed to create ChannelStateSyncDataConsumer");a(this,qb,"f").on("message",a(this,Hb,"f")),a(this,Nb,"f").debug("Successfully created ChannelStateSyncDataConsumer",t)}catch(e){a(this,Nb,"f").error("Failed to create ChannelStateSyncDataConsumer",Object.assign(Object.assign({},t),{error:e}))}}))}createConsumersScoresDataConsumer(){var e;return o(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(c(this,Ub,yield this.network.createDataConsumer({producerId:e,appId:this.state.appId,channelId:this.state.channelId}),"f"),!a(this,Ub,"f"))throw new Error("Failed to create consumers scores data consumer");a(this,Ub,"f").on("message",a(this,$b,"f")),a(this,Nb,"f").debug("Successfully create consumers scores data consumer",t)}catch(e){a(this,Nb,"f").error("Failed to create consumers scores data consumer",t)}}))}};Nb=new WeakMap,Bb=new WeakMap,Wb=new WeakMap,qb=new WeakMap,Ub=new WeakMap,zb=new WeakMap,Vb=new WeakMap,Hb=new WeakMap,$b=new WeakMap,Gb=n([ot(),i(0,ct(Un.CallState)),i(1,ct(Un.LoggerFactory)),i(2,ct(Un.MyPeer)),i(3,ct(Un.Network)),i(4,ct(Un.ChannelEventHandler)),i(5,ct(Un.EventsQueue)),i(6,ct(Un.Peers)),i(7,ct(Un.MediaSoupEventHandler)),i(8,ct(Un.ChannelAudioObserverEventHandler)),i(9,ct(Un.ChannelStateSyncEventHandler)),s("design:paramtypes",[$n,Function,Gl,Ph,Uh,jh,Object,Pf,Hy,Kb])],Gb);var Jb,Qb,Yb,Zb,Xb=Gb;let ew=class{constructor(e,t,r,n,i,s,o,a,d,u,l,p,h,f,m,g,v,y,b){this.state=e,this.myPeer=t,this.mediaSoupEventsHandler=n,this.channelEventsHandler=i,this.channelStateSynchronizer=s,this.peerTrackFactory=o,this.peers=a,this.system=d,this.media=u,this.network=l,this.loadBalancerClient=p,this.socket=h,this.eventsQueue=f,this.clientEventEmitter=m,this.internalEventEmitter=g,this.statsHandler=v,this.dataChannelsManager=y,this.webRtcIssueDetector=b,Jb.set(this,void 0),Qb.set(this,void 0),this.rejoinRequested=!1,this.isReleasing=!1,Yb.set(this,!1),Zb.set(this,void 0),c(this,Jb,r("Engine"),"f"),c(this,Qb,r,"f"),this.watchNetworkState(),this.watchDocumentUnload()}get isChannelJoined(){return this.state.isJoined}initialize(){var e,t,r,n;return o(this,void 0,void 0,(function*(){try{const{rtpCapabilities:i}=yield this.socket.request("router.getRtpCapabilities");yield this.media.createNoiseSuppressor(),yield this.media.loadDevice(i),a(this,Jb,"f").info("Supported capabilities",{codecs:Nn(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),c(this,Zb,new Ly({media:this.media,peers:this.peers,receiveTransportConnectionManager:new Ay({transport:o,statsHandler:this.statsHandler}),sendTransportConnectionManager:new Ay({transport:s,statsHandler:this.statsHandler})}),"f"),a(this,Jb,"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){a(this,Jb,"f").error("initialize()",{error:e});const t=e instanceof tr&&"device not supported"===e.message,r=e instanceof Error&&"RTCPeerConnection is not defined"===e.message;if(t||r)throw new Ln("Device not supported",Ln.UNSUPPORTED_DEVICE_CODE);throw new Error("Error initialize engine")}}))}release(e){var t;return o(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(),this.peers.reset(),yield this.network.closeSendTransport(),yield this.network.closeReceiveTransport(),yield this.media.unpublishTracks(),e||(yield this.media.clearTracks()),this.eventsQueue.removeListener("message"),this.dataChannelsManager.closeAllDataChannels(),this.channelEventsHandler.reset(),this.mediaSoupEventsHandler.reset(),this.removeClientEventEmitterListeners(),yield this.network.reset(),this.socket.disconnect(),dr.clear(),c(this,Zb,void 0,"f"),this.statsHandler.clear(),a(this,Jb,"f").debug("release()",{socketId:this.myPeerId})}catch(e){throw a(this,Jb,"f").error("release()",{error:e}),new Error("Error release engine")}finally{this.isReleasing=!1}}}))}releaseForRejoin(){var e;return o(this,void 0,void 0,(function*(){if(!this.isReleasing){this.isReleasing=!0;try{this.state.isJoined=!1,this.state.reset(),this.myPeer.delete(),null===(e=this.webRtcIssueDetector)||void 0===e||e.stopWatchingNewPeerConnections(),this.peers.reset(),yield this.network.closeSendTransport(),yield this.network.closeReceiveTransport(),this.eventsQueue.removeListener("message"),this.dataChannelsManager.closeAllDataChannels(),this.channelEventsHandler.reset(),this.mediaSoupEventsHandler.reset(),this.removeClientEventEmitterListeners(),yield this.network.reset(),this.socket.disconnect(),dr.clear(),a(this,Jb,"f").debug("release()",{socketId:this.myPeerId})}catch(e){throw a(this,Jb,"f").error("release()",{error:e}),new Error("Error release engine")}finally{this.isReleasing=!1}}}))}removeClientEventEmitterListeners(){Array.from(Object.values(Kr)).forEach((e=>this.internalEventEmitter.removeAllListeners(e)))}getPeers(){return this.peers.all()}get myPeerId(){return this.myPeer.id}confirmActivity(){return o(this,void 0,void 0,(function*(){this.network.checkSocketConnectionActivity(),yield this.socket.request(mr)}))}join(e){return o(this,void 0,void 0,(function*(){const t=()=>o(this,void 0,void 0,(function*(){this.watchClientEvents(),yield this.connectToSocketServerWithRetry(e),yield this.performJoin({appData:e.appData})}));try{a(this,Jb,"f").debug("join()",{params:e}),this.state.isChannelJoining=!0,yield qn(t,{maxRetries:4,minBackoffDelayMs:150,maxBackoffDelayMs:5e3,actionName:"joinWithRetry",logger:a(this,Qb,"f").call(this,"RetryJoinNode"),onError:()=>o(this,void 0,void 0,(function*(){yield this.releaseForRejoin()}))})}catch(e){throw a(this,Jb,"f").error("join()",{error:e}),e}finally{this.state.isChannelJoining=!1,this.rejoinRequested=!1}}))}loadPeers(e){return o(this,void 0,void 0,(function*(){yield this.peers.load(e)}))}setPeer(e,t=!0){return this.peers.add(e,t)}removePeer(e){this.peers.remove(e)}updateAppData(e){return o(this,void 0,void 0,(function*(){const t=this.myPeer.get();if(!t)throw new Error("Need join to channel first");try{An(e),yield this.network.updatePeerAppData({peerId:t.id,appData:e})}catch(e){throw a(this,Jb,"f").error("updateAppData()",{error:e}),new Error("Can not update peer appData")}}))}createCameraVideoTrack(e){return o(this,void 0,void 0,(function*(){const t=Kl.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 Cf&&(r.setLabel((null==e?void 0:e.isPreview)?zn.CameraPreview:zn.Camera),r.setEncoderConfig(t.encoderConfig),r.setTransformParams(Kl.getVideoTrackTransformParams(r.mediaStreamTrack))),this.media.setTrack(r),a(this,Jb,"f").debug("createCameraVideoTrack()",{trackParams:t}),r}catch(e){throw a(this,Jb,"f").error("createCameraVideoTrack()",{error:e,trackParams:t}),new Error(`Can not create camera track: ${e.message}`)}}))}createMicrophoneAudioTrack(e){return o(this,void 0,void 0,(function*(){try{const[t]=yield this.media.createUserMediaTracks({video:!1,audio:null==e?void 0:e.audio});if(t.setLabel((null==e?void 0:e.isPreview)?zn.MicrophonePreview:zn.Microphone),t.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),(null==e?void 0:e.encoderConfig)&&t.setEncoderConfig(e.encoderConfig),"audio"===t.kind&&(null==e?void 0:e.noiseSuppression))try{yield t.enableNoiseSuppression()}catch(e){a(this,Jb,"f").warn("Failed to start noise suppression, featured original track",{label:t.getLabel()})}return this.media.setTrack(t),a(this,Jb,"f").debug("createMicrophoneAudioTrack()",{options:e}),t}catch(t){throw a(this,Jb,"f").error("createMicrophoneAudioTrack()",{error:t,options:e}),new Error(`Can not create microphone track: ${t.message}`)}}))}createScreenMediaTracks(e){return o(this,void 0,void 0,(function*(){const t=Kl.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=>{a(this,Jb,"f").error("Failed to unpublish media track",{track:r,error:cr(e)})}))}),{once:!0}),r.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),r instanceof Cf){r.setLabel(zn.ScreenVideo),r.setEncoderConfig(t.encoderConfig);const e=Kl.getVideoTrackTransformParams(r.mediaStreamTrack);return r.setTransformParams(e),this.media.setTrack(r),void a(this,Jb,"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),a(this,Jb,"f").debug("createScreenMediaTrack()",{trackParams:null==e?void 0:e.audio,encoderConfig:null==e?void 0:e.audioEncoderConfig})})),r}catch(e){throw a(this,Jb,"f").error("createScreenMediaTrack()",{error:e,trackParams:t}),new Error(`Can not create screen media tracks: ${e.message}`)}}))}deleteTrack(e){return this.media.deleteTrack(e)}get canUseNoiseSuppression(){return this.media.isNoiseSuppressorLoaded}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=a(this,Zb,"f"))||void 0===e?void 0:e.getStats()}connectToSocketServerWithRetry(e){return o(this,void 0,void 0,(function*(){return qn((()=>o(this,void 0,void 0,(function*(){return this.connectToSocketServer(e)}))),{maxRetries:15,minBackoffDelayMs:150,maxBackoffDelayMs:5e3,actionName:"connectToSocketServer",logger:a(this,Qb,"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 o(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 a(this,Jb,"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 o(this,void 0,void 0,(function*(){try{return{webSocketUrl:(yield this.loadBalancerClient.getNode(e)).webSocketUrl}}catch(e){throw a(this,Jb,"f").error("getAvailableNode()",{error:"No available nodes"}),e}}))}waitForSocketConnection(){return new Promise(((e,t)=>{const r=n=>o(this,void 0,void 0,(function*(){const{error:i,state:s}=n,o=()=>this.socket.observer.removeListener(Hn.State,r),a=[Hn.Disconnected,Hn.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&&[Hn.Connected,Hn.Reconnected].includes(s)&&(o(),e()))}));this.socket.observer.on(Hn.State,r)}))}performJoin(e){return o(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,a(this,Jb,"f").debug("Successfully joined channel",{channelId:r}),yield this.dataChannelsManager.createAllDataChannels(),dr.setPeerId(n),dr.setChannelId(r),dr.setAppId(t)}catch(e){throw a(this,Jb,"f").error("performJoin()",{error:e}),e}}))}sendJoinChannelRequestWithRetry(e){return o(this,void 0,void 0,(function*(){return qn((()=>o(this,void 0,void 0,(function*(){return this.sendJoinChannelRequest(e)}))),{maxRetries:3,minBackoffDelayMs:300,actionName:"sendJoinChannelRequest",logger:a(this,Qb,"f").call(this,"RetryJoin")})}))}sendJoinChannelRequest(e){return o(this,void 0,void 0,(function*(){return this.socket.request(lr,e)}))}watchClientEvents(){this.internalEventEmitter.on(Kr.trackProduced,(e=>o(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(Kr.trackUnproduced,(e=>o(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(Kr.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(Kr.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(Kr.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(Kr.trackReopened,(e=>o(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(Kr.trackFailed,(e=>o(this,void 0,void 0,(function*(){this.clientEventEmitter.safeEmit(Br,{label:e.getLabel()})}))))}createSelfPeerTrack(e){var t;return o(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||(a(this,Jb,"f").debug("Triggering channel rejoin required event",{reason:e}),this.rejoinRequested=!0,this.clientEventEmitter.emit(Ar))}watchNetworkState(){this.network.observer.on(Mn,(e=>o(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===Hn.NeedToJoinFirst&&this.isChannelJoined;if(s&&this.clientEventEmitter.safeEmit(Hr),"server.disconnect"!==r||a(this,Yb,"f")){if(o||s){const e=s?"unauthorized error":"invalid channel state";this.triggerRejoinEventIfAppropriate(e)}i===Hn.Disconnected&&this.isChannelJoined&&!a(this,Yb,"f")&&a(this,Jb,"f").info("connection lost",{channel:"socket"}),i===Hn.Reconnected&&this.isChannelJoined&&a(this,Jb,"f").info("connection restored",{channel:"socket"}),i===Hn.BufferingStart&&(c(this,Yb,!0,"f"),this.clientEventEmitter.safeEmit(Ur),this.waitForReconnectOrTriggerRejoinEventIfAppropriate()),[Hn.BufferingEnd,Hn.Reconnected].includes(i)&&this.network.isNetworkActive&&(c(this,Yb,!1,"f"),this.clientEventEmitter.safeEmit(zr))}else this.clientEventEmitter.safeEmit(Vr)})))),this.network.observer.on(xn,(({state:e,direction:t})=>o(this,void 0,void 0,(function*(){if(!this.isReleasing&&(["disconnected","failed"].includes(e)&&this.isChannelJoined&&!a(this,Yb,"f")&&(c(this,Yb,!0,"f"),a(this,Jb,"f").info("connection lost",{channel:"webrtc-transport",direction:t}),this.clientEventEmitter.safeEmit(Ur),this.waitForReconnectOrTriggerRejoinEventIfAppropriate()),"reconnected"===e&&this.isChannelJoined&&a(this,Jb,"f").info("connection restored",{channel:"webrtc-transport",direction:t}),"reconnected"===e&&this.isChannelJoined&&a(this,Yb,"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;c(this,Yb,!1,"f"),this.clientEventEmitter.safeEmit(zr)}}))))}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){a(this,Jb,"f").error("Failed to add watchDocumentUnload listener",{channelId:this.state.channelId})}}waitForReconnectOrTriggerRejoinEventIfAppropriate(){a(this,Jb,"f").info("Start waiting for seamless reconnect and check loadbalancer availability",{case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"});let e=0;const t=setInterval((()=>o(this,void 0,void 0,(function*(){try{if(!a(this,Yb,"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){a(this,Jb,"f").error("Check failed",{error:cr(e),case:"waitForReconnectOrTriggerRejoinEventIfAppropriate"})}}))),3e3)}};Jb=new WeakMap,Qb=new WeakMap,Yb=new WeakMap,Zb=new WeakMap,ew=n([ot(),i(0,ct(Un.CallState)),i(1,ct(Un.MyPeer)),i(2,ct(Un.LoggerFactory)),i(3,ct(Un.MediaSoupEventHandler)),i(4,ct(Un.ChannelEventHandler)),i(5,ct(Un.ChannelStateSynchronizer)),i(6,ct(Un.PeerTrackFactory)),i(7,ct(Un.Peers)),i(8,ct(Un.System)),i(9,ct(Un.Media)),i(10,ct(Un.Network)),i(11,ct(Un.LoadBalancerApiClient)),i(12,ct(Un.SocketIO)),i(13,ct(Un.EventsQueue)),i(14,ct(Un.ClientEventEmitter)),i(15,ct(Un.InternalEventEmitter)),i(16,ct(Un.StatsHandler)),i(17,ct(Un.DataChannelsManager)),i(18,ct(Un.WebRTCIssueDetector)),s("design:paramtypes",[$n,Gl,Function,Pf,Uh,Bh,Function,Object,Oy,Kl,Ph,_y,Ch,jh,_t,_t,Uy,Xb,Zt])],ew);var tw=ew,rw={},nw={},iw={},sw={exports:{}};
|
|
32
32
|
/**
|
|
33
33
|
* @license
|
|
34
34
|
* Lodash <https://lodash.com/>
|
|
@@ -37,4 +37,4 @@ let qs;Cs.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,l=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",l]],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,J=RegExp(K.source),Q=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+")*"),Je="(?:"+[Le,Be,We].join("|")+")"+Ge,Qe="(?:"+[Ne+xe+"?",xe,Be,We,Ie].join("|")+")",Ye=RegExp(De,"g"),Ze=RegExp(xe,"g"),Xe=RegExp(Fe+"(?="+Fe+")|"+Qe+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,Je].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 u&&u&&u.Object===Object&&u,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 Jt(e){return e?e.slice(0,hr(e)+1).replace(se,""):e}function Qt(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 u,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=(u=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||""))?"Symbol(src)_1."+u:"",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,Je=Oe.propertyIsEnumerable,Qe=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 Jr(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Gr;++t<r;)this.add(e[t])}function Qr(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[Qn(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 Qr);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,Qt(r))),n?(s=Mt,o=!1):t.length>=200&&(s=Zt,o=!1,t=new Jr(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():Qe.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},Jr.prototype.add=Jr.prototype.push=function(e){return this.__data__.set(e,i),this},Jr.prototype.has=function(e){return this.__data__.has(e)},Qr.prototype.clear=function(){this.__data__=new Kr,this.size=0},Qr.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Qr.prototype.get=function(e){return this.__data__.get(e)},Qr.prototype.has=function(e){return this.__data__.has(e)},Qr.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,Qt(t))),d=wr(l.length,d),c[a]=!n&&(t||s>=120&&l.length>=120)?new Jr(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 Qr),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 Qr),s(g,S,n,i,o)}}if(!h)return!1;return o||(o=new Qr),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 Qr;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=Jo(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 Qr),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:Qo(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,Qt(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,Qt(r)));++s<o;)for(var c=0,d=t[s],u=r?r(d):d;(c=i(a,u,c,n))>-1;)a!==e&&Qe.call(a,c,1),Qe.call(e,c,1);return e}function Jn(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)?Qe.call(e,i,1):hi(e,i)}}return e}function Qn(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 Jr}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 Qo(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(!Jo(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(!Jo(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 Ji(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,Qt(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 Ji(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 Qi(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,u,p,h,f,m){var g=2&t;if(!g&&"function"!=typeof e)throw new Ie(n);var v=u?u.length:0;if(v||(t&=-97,u=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=u,b=p;u=p=r}var w=g?r:as(e),_=[e,t,i,u,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==l&&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 u=e[3];e[3]=u?Di(u,c,t[4]):c,e[4]=u?cr(e[3],s):t[4]}(c=t[5])&&(u=e[5],e[5]=u?Ii(u,c,t[6]):c,e[6]=u?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],u=_[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?Ji(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,u);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 Jr: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 Je.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?Jo(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=Qn(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 Qo(e)?hn(e,bn(t,1,Qo,!0)):[]})),zs=Zn((function(e,t){var n=Zs(t);return Qo(n)&&(n=r),Qo(e)?hn(e,bn(t,1,Qo,!0),us(n,2)):[]})),Vs=Zn((function(e,t){var n=Zs(t);return Qo(n)&&(n=r),Qo(e)?hn(e,bn(t,1,Qo,!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 Js=Zn((function(e){var t=xt(e,bi);return t.length&&t[0]===e[0]?Mn(t):[]})),Qs=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 Jn(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,Qo,!0))})),io=Zn((function(e){var t=Zs(e);return Qo(t)&&(t=r),pi(bn(e,1,Qo,!0),us(t,2))})),so=Zn((function(e){var t=Zs(e);return t="function"==typeof t?t:r,pi(bn(e,1,Qo,!0),r,t)}));function oo(e){if(!e||!e.length)return[];var t=0;return e=Dt(e,(function(e){if(Qo(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 Qo(e)?hn(e,t):[]})),uo=Zn((function(e){return vi(Dt(e,Qo))})),lo=Zn((function(e){var t=Zs(e);return Qo(t)&&(t=r),vi(Dt(e,Qo),us(t,2))})),po=Zn((function(e){var t=Zs(e);return t="function"==typeof t?t:r,vi(Dt(e,Qo),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=Jo(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],Qt(us())):xt(bn(t,1),Qt(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,l,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")&&!Je.call(e,"callee")},Ko=oe.isArray,Go=yt?Qt(yt):function(e){return ia(e)&&Tn(e)==O};function Jo(e){return null!=e&&ra(e.length)&&!ea(e)}function Qo(e){return ia(e)&&Jo(e)}var Yo=Ht||bc,Zo=bt?Qt(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?Qt(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?Qt(_t):function(e){return ia(e)&&Tn(e)==E};var da=St?Qt(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?Qt(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(Jo(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=Jt(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)||Jo(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 Jo(e)?Yr(e):Nn(e)}function Aa(e){return Jo(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()})),Ja=Fi("toLowerCase");var Qa=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=Qi("ceil"),Sc=Vi((function(e,t){return e/t}),1),kc=Qi("floor");var Cc,Rc=Vi((function(e,t){return e*t}),1),Pc=Qi("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=Js,qr.intersectionBy=Qs,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 Jn(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))&&Q.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=Jo(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=Jo,qr.isArrayLikeObject=Qo,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(Jo(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=Ja,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 Qn(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(Jo(e))return ua(e)?lr(e):e.length;var t=gs(e);return t==C||t==D?e.size:Nn(e).length},qr.snakeCase=Qa,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 Jt(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))&&J.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(u)}(ow,ow.exports);var aw,cw=u&&u.__extends||(aw=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}aw(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(sw,"__esModule",{value:!0});var dw=ow.exports,uw=["MaxBatchSize","MaxDelay","MinDelay"],lw=function(e){function t(t){var r=e.call(this)||this;return r.fifo=[],r.firstBatch=!0,function(e){if(uw.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=dw.debounce(r.releaseBatch.bind(r),r.options.MaxDelay,{maxWait:r.options.MaxDelay}),r.releaseBatchDebouncedMin=dw.debounce(r.releaseBatch.bind(r),r.options.MinDelay,{maxWait:r.options.MinDelay}),r}return cw(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);sw.MessageBatcher=lw,function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(sw)}(iw),function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(iw)}(nw);let pw,hw=!1;const fw=()=>{try{return hw?null:window.localStorage}catch(e){return console.error("Get local storage error",{error:cr(e)}),e instanceof Error&&"SecurityError"===e.name&&(hw=!0),null}};function mw(e){const t=fw();if(!t)return null;try{return JSON.parse(t.getItem(e))}catch(e){return null}}const gw=()=>{if(pw)return pw;const e=mw("sdk_clientUniqueId");if(e)return pw=e,e;const t=r.randomBytes(12).toString("hex");return pw=t,function(e,t){const r=fw();if(r)try{r.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}}("sdk_clientUniqueId",t),t},vw=()=>{const e=mw("sdk_clientUniqueId");return e||(null!=pw?pw:gw())},yw=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 bw(e){return!e.response&&(!!e.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(e.code)&&(e=>!yw.has(e&&e.code))(e)))}const ww=["get","head","options"],_w=ww.concat(["put","delete"]);function Sw(e){return"ECONNABORTED"!==e.code&&(!e.response||429===e.response.status||e.response.status>=500&&e.response.status<=599)}function kw(e){return!!e.config?.method&&(Sw(e)&&-1!==_w.indexOf(e.config.method))}function Cw(e){return bw(e)||kw(e)}function Rw(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 Pw={retries:3,retryCondition:Cw,retryDelay:function(e=0,t){return Math.max(0,Rw(t))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function Tw(e,t,r=!1){const n=function(e,t){return{...Pw,...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 Ew=(e,t)=>{const r=e.interceptors.request.use((e=>(Tw(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=Tw(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}};Ew.isNetworkError=bw,Ew.isSafeRequestError=function(e){return!!e.config?.method&&(Sw(e)&&-1!==ww.indexOf(e.config.method))},Ew.isIdempotentRequestError=kw,Ew.isNetworkOrIdempotentRequestError=Cw,Ew.exponentialDelay=function(e=0,t,r=100){const n=2**e*r,i=Math.max(n,Rw(t));return i+.2*i*Math.random()},Ew.linearDelay=function(e=100){return(t=0,r)=>{const n=t*e;return Math.max(n,Rw(r))}},Ew.isRetryableError=Sw;class Dw{constructor(e){this.api=e,Ew(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 o(this,void 0,void 0,(function*(){return this.api.post("/log/batch",e)}))}}class Iw{constructor(){this.api=ng.create({baseURL:"https://moodhood-analytics.livedigital.space/v1",timeout:1e4,withCredentials:!0,paramsSerializer:e=>by.stringify(e),headers:{"x-cl-id":vw()}}),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 Dw(this.api)}get log(){return this.logApi}}var Mw,xw,Ow,Lw,Aw,jw,Fw,Nw;class Bw{constructor(e){Mw.add(this),xw.set(this,void 0),Ow.set(this,void 0),Lw.set(this,void 0),Aw.set(this,void 0),jw.set(this,void 0);const{logLevel:t,namespace:r,onLogMessage:n}=e;c(this,xw,r,"f"),c(this,Ow,t,"f"),this.onLogMessage=n,c(this,Aw,new Iw,"f"),c(this,Lw,new nw.MessageBatcher({MaxBatchSize:50,MaxDelay:1e3,MinDelay:500}),"f"),c(this,jw,e.sendAnalytics,"f"),a(this,Lw,"f").on("batch",(e=>o(this,void 0,void 0,(function*(){yield this.logToApi(e)})))),this._debug=zi("LiveDigital").extend("debug").extend(a(this,xw,"f")),this._info=zi("LiveDigital").extend("info").extend(a(this,xw,"f")),this._warn=zi("LiveDigital").extend("warn").extend(a(this,xw,"f")),this._error=zi("LiveDigital").extend("error").extend(a(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),a(this,jw,"f")&&a(this,Lw,"f").Queue({level:"debug",message:e,meta:t}),a(this,Ow,"f")>=pt&&a(this,Mw,"m",Fw).call(this,"debug",e,t)}info(e,t){this._info(e,t),a(this,jw,"f")&&a(this,Lw,"f").Queue({level:"info",message:e,meta:t}),a(this,Ow,"f")>=lt&&a(this,Mw,"m",Fw).call(this,"info",e,t)}warn(e,t){this._warn(e,t),a(this,jw,"f")&&a(this,Lw,"f").Queue({level:"warn",message:e,meta:t}),a(this,Ow,"f")>=ut&&a(this,Mw,"m",Fw).call(this,"warn",e,t)}error(e,t){this._error(e,t),a(this,jw,"f")&&a(this,Lw,"f").Queue({level:"error",message:e,meta:t}),a(this,Ow,"f")>=dt&&a(this,Mw,"m",Fw).call(this,"error",e,t)}logToApi(e){return o(this,void 0,void 0,(function*(){try{yield a(this,Aw,"f").log.batch({logs:e.map((e=>a(this,Mw,"m",Nw).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({},dr.meta),{clUId:vw()})}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:cr(r)}:{})}}xw=new WeakMap,Ow=new WeakMap,Lw=new WeakMap,Aw=new WeakMap,jw=new WeakMap,Mw=new WeakSet,Fw=function(e,t,...r){"function"==typeof this.onLogMessage&&this.onLogMessage(t,...a(this,Mw,"m",Nw).call(this,r),e)},Nw=function(e){const t=new WeakMap;return function e(r,n=[]){if(!Dh(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 Ww=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}};Ww=n([ot(),i(0,ct(zn.PeerTrackFactory)),s("design:paramtypes",[Function])],Ww);class qw 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 o(this,void 0,void 0,(function*(){const t=q_.get(zn.Config);yield e.audioWorklet.addModule(`${t.get("staticFilesPath")}/noiseSuppressionWorklet.js`)}))}}var Uw,zw,Vw,Hw,$w,Kw;class Gw{constructor(e){Uw.set(this,void 0),zw.set(this,void 0),Vw.set(this,void 0),Hw.set(this,void 0),$w.set(this,void 0),Kw.set(this,!0),c(this,Uw,e.noiseSuppressor.instance.exports,"f"),c(this,zw,e.context,"f"),c(this,Vw,new Float32Array(a(this,Uw,"f").memory.buffer),"f"),c(this,Hw,a(this,Uw,"f").newState(),"f"),c(this,$w,a(this,zw,"f").createScriptProcessor(),"f"),this.setOnAudioProcess()}get noiseSuppressionScriptProcessorNode(){return a(this,$w,"f")}update(e){e||(c(this,Kw,!1,"f"),a(this,Uw,"f").deleteState(a(this,Hw,"f")));const t=Object.assign(new Event("status"),{vadProb:a(this,Uw,"f").getVadProb(a(this,Hw,"f"))});a(this,$w,"f").dispatchEvent(t)}setOnAudioProcess(){a(this,$w,"f").addEventListener("audioprocess",(({inputBuffer:e,outputBuffer:t})=>{if(!a(this,Kw,"f"))return;a(this,Vw,"f").set(e.getChannelData(0),a(this,Uw,"f").getInput(a(this,Hw,"f"))/4);const r=t.getChannelData(0),n=a(this,Uw,"f").pipe(a(this,Hw,"f"),r.length)/4;n&&r.set(a(this,Vw,"f").subarray(n,n+r.length))}))}}Uw=new WeakMap,zw=new WeakMap,Vw=new WeakMap,Hw=new WeakMap,$w=new WeakMap,Kw=new WeakMap;var Jw,Qw,Yw,Zw,Xw,e_,t_,r_,n_,i_,s_,o_,a_,c_,d_,u_,l_,p_,h_,f_,m_,g_,v_,y_,b_,w_,__,S_,k_,C_,R_,P_,T_,E_,D_,I_,M_,x_;class O_{constructor({context:e,noiseSuppressor:t}){Jw.set(this,void 0),Qw.set(this,void 0),Yw.set(this,void 0),c(this,Jw,e,"f"),c(this,Qw,t,"f")}createNoiseSuppressionNode(){return o(this,void 0,void 0,(function*(){return/apple/i.test(navigator.vendor)?this.createScriptProcessorNode():this.createAudioWorkletNode()}))}stop(){var e;null===(e=a(this,Yw,"f"))||void 0===e||e.update(!1)}createAudioWorkletNode(){return o(this,void 0,void 0,(function*(){return yield qw.register(a(this,Jw,"f")),c(this,Yw,new qw({context:a(this,Jw,"f"),noiseSuppressor:a(this,Qw,"f")}),"f"),a(this,Yw,"f")}))}createScriptProcessorNode(){return c(this,Yw,new Gw({context:a(this,Jw,"f"),noiseSuppressor:a(this,Qw,"f")}),"f"),a(this,Yw,"f").noiseSuppressionScriptProcessorNode}}Jw=new WeakMap,Qw=new WeakMap,Yw=new WeakMap;class L_{constructor(e){Zw.set(this,void 0),Xw.set(this,void 0),e_.set(this,void 0),t_.set(this,void 0),c(this,Zw,e.noiseSuppressor,"f"),c(this,e_,e.loggerFactory("TrackProcessor"),"f")}get isProcessing(){return!!a(this,t_,"f")}processTrack(e){return o(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 qw.register(t);const n=t.createMediaStreamSource(new MediaStream([e])),i=new O_({context:t,noiseSuppressor:a(this,Zw,"f")}),s=yield i.createNoiseSuppressionNode();s.connect(r),n.connect(s);const[o]=r.stream.getTracks();return c(this,Xw,{audioContext:t,streamDestination:r,noiseSuppressionNode:s,noiseSuppressionProvider:i},"f"),c(this,t_,o,"f"),a(this,e_,"f").info("processTrack()",{track:e.id}),o}))}stopProcessing(){var e;return o(this,void 0,void 0,(function*(){if(this.isProcessing)if(a(this,Xw,"f"))try{a(this,Xw,"f").noiseSuppressionProvider.stop(),a(this,Xw,"f").noiseSuppressionNode.disconnect(),a(this,Xw,"f").streamDestination.disconnect(),yield a(this,Xw,"f").audioContext.close(),null===(e=a(this,t_,"f"))||void 0===e||e.stop(),c(this,t_,void 0,"f"),a(this,e_,"f").info("stopProcessing()",{success:!0})}catch(e){a(this,e_,"f").error("stopProcessing()",{success:!1,error:e})}else a(this,e_,"f").warn("stopProcessing()",{success:!1,description:"Processing context is not available"});else a(this,e_,"f").debug("stopProcessing()",{description:"Track is not processed"})}))}}Zw=new WeakMap,Xw=new WeakMap,e_=new WeakMap,t_=new WeakMap;class A_ extends Cf{constructor(e){super(e),r_.set(this,void 0),n_.set(this,void 0),e.noiseSuppressor&&c(this,r_,new L_({noiseSuppressor:e.noiseSuppressor,loggerFactory:e.loggerFactory}),"f")}get isEffectsProcessing(){var e;return!!(null===(e=a(this,r_,"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:El}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;return o(this,void 0,void 0,(function*(){if(a(this,r_,"f"))try{const t=yield null===(e=a(this,r_,"f"))||void 0===e?void 0:e.processTrack(this.mediaStreamTrack);c(this,n_,this.mediaStreamTrack,"f"),yield this.replaceTrack(t)}catch(e){throw this.logger.warn("enableNoiseSuppression()",{description:"Can not enable noise suppression",track:this.logCtx,error:e}),new Error("Can not enable noise suppression")}else this.logger.warn("enableNoiseSuppression()",{description:"Track suppressor is not defined"})}))}disableNoiseSuppression(){var e,t;return o(this,void 0,void 0,(function*(){try{if(!(null===(e=a(this,r_,"f"))||void 0===e?void 0:e.isProcessing))return void this.logger.debug("stopProcessing()",{description:"Track is not processed"});if(!a(this,n_,"f"))return void this.logger.warn("disableNoiseSuppression()",{description:"Original track missing"});this.isPublished&&(yield this.replaceTrack(a(this,n_,"f"))),yield null===(t=a(this,r_,"f"))||void 0===t?void 0:t.stopProcessing()}catch(e){throw this.logger.warn("disableNoiseSuppression()",{description:"Can not disable noise suppression",track:this.logCtx,error:e}),new Error("Can not disable noise suppression")}}))}publish(){return o(this,void 0,void 0,(function*(){yield this.produce({encodings:this.getEncodings(),preferredCodec:this.getPreferredCodec(),codecOptions:this.getCodecOptions()}),this.internalEventEmitter.emit(Kr.trackProduced,this)}))}pause(){return o(this,void 0,void 0,(function*(){yield this.mute()}))}}r_=new WeakMap,n_=new WeakMap;class j_{constructor({track:e,statsHandler:t}){i_.set(this,void 0),s_.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return a(this,i_,"f")}get audioWebRTCStats(){return a(this,s_,"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){c(this,i_,e,"f")}setAudioWebRTCStats(e){c(this,s_,e,"f")}}i_=new WeakMap,s_=new WeakMap;class F_{constructor(e){this.label=Vn.Unknown,o_.set(this,void 0),a_.set(this,void 0),c_.set(this,void 0),d_.set(this,void 0),u_.set(this,void 0),l_.set(this,void 0),p_.set(this,void 0),h_.set(this,void 0),f_.set(this,void 0),m_.set(this,void 0),g_.set(this,!1),v_.set(this,void 0),y_.set(this,!1),b_.set(this,new $h),w_.set(this,!1),__.set(this,0),S_.set(this,void 0),this.observer=new _t,c(this,f_,e.mediaStreamTrack,"f"),this.label=e.label,this.consumer=e.consumer,c(this,u_,e.peerConsumerFactory,"f"),c(this,p_,e.loggerFactory("PeerTrack"),"f"),c(this,h_,e.peerEventEmitter,"f"),c(this,w_,e.muted,"f"),c(this,m_,e.paused,"f"),c(this,o_,e.network,"f"),c(this,a_,e.socket,"f"),c(this,c_,e.media,"f"),c(this,l_,e.callState,"f"),c(this,d_,e.onClose,"f"),c(this,S_,new j_({track:e.mediaStreamTrack,statsHandler:e.statsHandler}),"f")}get videoWebRTCStats(){return a(this,S_,"f").videoWebRTCStats}get audioWebRTCStats(){return a(this,S_,"f").audioWebRTCStats}get logCtx(){var e,t;return{id:a(this,f_,"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:a(this,w_,"f"),paused:a(this,m_,"f"),closed:a(this,y_,"f")}}get volume(){return a(this,__,"f")}get isRemote(){return!!this.consumer}get mediaStreamTrack(){return a(this,f_,"f")}get kind(){return this.mediaStreamTrack.kind}get isPaused(){return a(this,m_,"f")}get isMuted(){return a(this,w_,"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 o(this,void 0,void 0,(function*(){a(this,h_,"f").safeEmit(Xr,this),c(this,y_,!0,"f"),a(this,d_,"f").call(this),this.consumer&&(yield this.closeConsumer(),this.clearCheckStateTimeout())}))}mute(){return o(this,void 0,void 0,(function*(){yield a(this,b_,"f").push((()=>o(this,void 0,void 0,(function*(){a(this,p_,"f").debug("mute()",{track:this.logCtx}),yield this.pauseConsumer(),c(this,w_,!0,"f")}))))}))}unmute(){return o(this,void 0,void 0,(function*(){yield a(this,b_,"f").push((()=>o(this,void 0,void 0,(function*(){a(this,p_,"f").debug("unmute()",{track:this.logCtx}),yield this.resumeConsumer(),c(this,w_,!1,"f")}))))}))}pause(e=!0){return o(this,void 0,void 0,(function*(){yield a(this,b_,"f").push((()=>o(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return c(this,m_,!0,"f"),a(this,h_,"f").safeEmit(en,this),void a(this,p_,"f").debug("pause()",{track:this.logCtx});yield this.pauseConsumer(e),c(this,m_,!0,"f"),a(this,h_,"f").safeEmit(en,this)}))))}))}resume(e=!0){return o(this,void 0,void 0,(function*(){yield a(this,b_,"f").push((()=>o(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return c(this,m_,!1,"f"),a(this,h_,"f").safeEmit(tn,this),void a(this,p_,"f").debug("resume()",{track:this.logCtx});yield this.resumeConsumer(e),c(this,m_,!1,"f"),a(this,h_,"f").safeEmit(tn,this)}))))}))}setPriority(e){return o(this,void 0,void 0,(function*(){this.consumer&&(yield this.setConsumerPriority({consumerId:this.consumer.id,priority:e}))}))}resumeConsumer(e=!0){return o(this,void 0,void 0,(function*(){if(this.consumer)try{this.consumer.resume(),e&&(yield a(this,o_,"f").resumeRemoteConsumer(this.consumer.id)),this.checkConsumerState().catch((e=>{a(this,p_,"f").warn("Failed to checkConsumerState()",{track:this.logCtx,error:cr(e)})})),a(this,p_,"f").debug("resumeConsumer()",{track:this.logCtx})}catch(e){a(this,p_,"f").warn("resumeConsumer()",{error:e})}}))}pauseConsumer(e=!0){return o(this,void 0,void 0,(function*(){if(this.consumer)try{this.clearCheckStateTimeout(),e&&(yield a(this,o_,"f").pauseRemoteConsumer(this.consumer.id)),this.consumer.pause(),c(this,g_,!1,"f"),a(this,p_,"f").debug("pauseConsumer()",{track:this.logCtx})}catch(e){a(this,p_,"f").warn("pauseConsumer()",{error:e})}}))}setConsumerPriority(e){return o(this,void 0,void 0,(function*(){try{yield a(this,a_,"f").request(Cn,e),a(this,p_,"f").debug("setConsumerPriority()",{track:this.logCtx,params:e})}catch(t){throw a(this,p_,"f").error("setConsumerPriority()",{track:this.logCtx,params:e}),new Error("Can`t change stream priority")}}))}requestVideoPreferredLayers({spatialLayer:e,temporalLayer:t}){return o(this,void 0,void 0,(function*(){if(this.consumer)try{if(this.consumer.isAudio)return void a(this,p_,"f").warn("Only video consumers support layers",{case:"requestVideoPreferredLayers"});if(e===this.consumer.currentSpatialLayer)return;if(e>this.consumer.spatialLayers)return void a(this,p_,"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 a(this,a_,"f").request(Sn,{consumerId:this.consumer.id,spatialLayer:e,temporalLayer:t}),a(this,p_,"f").debug("requestVideoPreferredLayers()",{track:this.logCtx,consumer:this.consumer,spatialLayer:e,temporalLayer:t})}catch(e){throw a(this,p_,"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 o(this,void 0,void 0,(function*(){if(this.consumerId){a(this,p_,"f").debug("requestKeyFrame()",{track:this.logCtx});try{yield a(this,a_,"f").request(kn,{consumerId:this.consumerId})}catch(e){throw a(this,p_,"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;a(this,p_,"f").warn("Only video consumers support layers",{case:"getVideoAvailableLayers"})}}getInfo(){var e;return o(this,void 0,void 0,(function*(){const{width:t,height:r,frameRate:n,aspectRatio:i}=a(this,f_,"f").getSettings();return{trackId:a(this,f_,"f").id,readyState:a(this,f_,"f").readyState,isRemote:this.isRemote,kind:this.kind,label:this.label,width:t,height:r,frameRate:n,aspectRatio:i,paused:a(this,m_,"f"),trackInboundStats:yield null===(e=this.consumer)||void 0===e?void 0:e.getStats(),trackOutboundStats:yield this.getOutboundStats()}}))}getOutboundStats(){return o(this,void 0,void 0,(function*(){if(this.isRemote)return;const e=a(this,c_,"f").getAllTracks().find((e=>e.getLabel()===this.label));return e?e.getStats():void 0}))}requestMaxSpatialLayer(e,t){return o(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 a(this,p_,"f").warn("Can`t request this spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t});this.consumer.setRequestedSpatialLayer(t),yield a(this,a_,"f").request(mn,{producerId:this.consumer.producerId,spatialLayer:t}),a(this,p_,"f").debug("requestMaxSpatialLayer()",{consumerId:e,spatialLayer:t})}catch(r){a(this,p_,"f").warn("Failed to request max spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t,error:r})}}))}checkConsumerState(){return o(this,void 0,void 0,(function*(){try{if(a(this,y_,"f")||"audio"===this.kind)return;a(this,p_,"f").debug("checkConsumerState()",{track:this.logCtx});if((yield this.isInboundRTPStreamActive())||a(this,y_,"f"))return;yield this.requestKeyFrame();if((yield this.isInboundRTPStreamActive())||a(this,y_,"f"))return;if(a(this,g_,"f"))return a(this,h_,"f").emit(rn,this),void a(this,p_,"f").debug("trackFail()",{track:this.logCtx});yield this.restartConsumer()}catch(e){a(this,p_,"f").warn("checkConsumerState()",{track:this,error:e})}}))}setVolume(e){a(this,__,"f")!==e&&(c(this,__,e,"f"),this.observer.safeEmit($r,{value:e}))}closeConsumer(){return o(this,void 0,void 0,(function*(){try{if(!this.consumer)return;this.consumer.close(),yield a(this,o_,"f").closeRemoteConsumer(this.consumer.id)}catch(e){a(this,p_,"f").debug("closeConsumer()",{track:this,error:e})}}))}restartConsumer(){return o(this,void 0,void 0,(function*(){try{if(!this.consumer||a(this,y_,"f"))return;a(this,p_,"f").debug("restartConsumer()",{track:this.logCtx}),a(this,h_,"f").emit(Xr,this),c(this,m_,!0,"f"),yield this.closeConsumer();const{consumer:e}=yield a(this,o_,"f").createConsumer({producerId:this.consumer.producerId,rtpCapabilities:a(this,c_,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.consumer.appData.producerData.peerId,appId:a(this,l_,"f").appId,channelId:a(this,l_,"f").channelId});c(this,g_,!0,"f"),this.consumer=a(this,u_,"f").call(this,{consumer:e}),c(this,f_,e.track,"f"),yield this.resume(),a(this,h_,"f").emit(Zr,this)}catch(e){c(this,g_,!0,"f"),a(this,p_,"f").warn("restartConsumer()",{track:this,error:e})}}))}isInboundRTPStreamActive(){return o(this,void 0,void 0,(function*(){if(!this.consumer||a(this,y_,"f"))return!1;const{framesDecoded:e}=yield this.consumer.getInboundRTPStreamStats();return new Promise((t=>{c(this,v_,setTimeout((()=>o(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){a(this,p_,"f").debug("isInboundRTPStreamActive()",{error:e,track:this.logCtx}),t(!1)}}))),4500),"f")}))}))}clearCheckStateTimeout(){a(this,v_,"f")||clearTimeout(a(this,v_,"f"))}}o_=new WeakMap,a_=new WeakMap,c_=new WeakMap,d_=new WeakMap,u_=new WeakMap,l_=new WeakMap,p_=new WeakMap,h_=new WeakMap,f_=new WeakMap,m_=new WeakMap,g_=new WeakMap,v_=new WeakMap,y_=new WeakMap,b_=new WeakMap,w_=new WeakMap,__=new WeakMap,S_=new WeakMap;class N_{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 B_{constructor({id:e,channelIds:t,groups:r,producePermissions:n,appId:i,loginDate:s,producers:o=[],appData:a,uid:d,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,k_.set(this,void 0),C_.set(this,void 0),R_.set(this,void 0),P_.set(this,void 0),T_.set(this,void 0),E_.set(this,void 0),D_.set(this,void 0),I_.set(this,void 0),M_.set(this,void 0),this._observer=new _t,this.id=e,this.channelIds=t,this.groups=r,this.producePermissions=n,this.appId=i,this.loginDate=s,this.applicationData=a||{},this.uid=d,this.role=u,c(this,E_,p,"f"),c(this,D_,h,"f"),c(this,k_,f,"f"),c(this,C_,m,"f"),c(this,P_,y,"f"),c(this,I_,b,"f"),c(this,R_,v,"f"),c(this,T_,g,"f"),c(this,M_,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===a(this,E_,"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 o(this,void 0,void 0,(function*(){try{const r=this.producers.get(e);if(!r)return void a(this,M_,"f").warn("subscribe()",{message:"Peer does not have a producer",peer:qh(this),producerId:e});if(this.getAllConsumers().find((t=>t.producerId===e)))return void a(this,M_,"f").debug("subscribe()",{message:"Already subscribed to producer",peer:qh(this),producerId:e});const{consumer:n,isProducerPaused:i}=yield a(this,R_,"f").createConsumer({producerId:r.id,rtpCapabilities:a(this,T_,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.id,appId:a(this,D_,"f").appId,channelId:a(this,D_,"f").channelId});if(!this.producePermissions.includes(r.label)&&Object.values(Vn).includes(r.label))return void a(this,M_,"f").debug("subscribe()",{message:"Producer is not allowed anymore",peer:qh(this),producerId:e});const s=a(this,C_,"f").create({mediaStreamTrack:n.track,label:r.label,consumer:a(this,I_,"f").call(this,{consumer:n}),muted:t,paused:i,peerEventEmitter:this.observer});t||(yield s.unmute()),this.tracks.set(s.label,s),a(this,M_,"f").debug(`Subscribed for ${r.kind}`,{peer:qh(this)})}catch(t){throw a(this,M_,"f").error("subscribe()",{producerId:e,error:t,peer:qh(this)}),new Error("Error subscribe media")}}))}unsubscribe(e){return o(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),a(this,M_,"f").debug(`Unsubscribed consumer ${t.kind}`,{peer:qh(this)})}catch(t){throw a(this,M_,"f").error("unsubscribe()",{producerId:e,error:t}),new Error("Error unsubscribe media")}}))}setProducePermissions(e){return o(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield a(this,P_,"f").request(Cr,{peerId:this.id,producePermissions:e}),a(this,M_,"f").debug("Produce permissions changed",{peerId:this.id,producePermissions:e})}))}addProducePermission(e){return o(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield a(this,P_,"f").request(Rr,{peerId:this.id,label:e}),a(this,M_,"f").debug("Add produce permission requested",{peerId:this.id,label:e})}))}removeProducePermission(e){return o(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield a(this,P_,"f").request(Pr,{peerId:this.id,label:e}),a(this,M_,"f").debug("Remove produce permission requested",{peerId:this.id,label:e})}))}getInfo(){return o(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 a(this,M_,"f").error("getInfo()",{peer:qh(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 N_(e);this.producers.set(t.id,t),a(this,M_,"f").debug("Peer published media:",{peer:qh(this),producer:t}),this.observer.safeEmit(Gr,{producerId:t.id,kind:t.kind,label:t.label,paused:t.paused})}handlePeerEvents(){this.observer.on(an,this.handleNewProducer.bind(this)),this.observer.on(cn,(e=>o(this,void 0,void 0,(function*(){this.producers.delete(e.id),a(this,M_,"f").debug("Peer unpublished media:",{peer:qh(this),producer:e}),this.observer.safeEmit(Jr,{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){a(this,M_,"f").warn("Failed to close peer track due to producer closed",{label:t.label,peerId:this.id})}})))),this.observer.on(yn,(e=>o(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.close(),this.tracks.delete(t.label),a(this,M_,"f").debug("Peer video track was ended:",{peer:qh(this),track:t.logCtx}))})))),this.observer.on(bn,(e=>o(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.pause(!1))})))),this.observer.on(wn,(e=>o(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.resume(!1))})))),this.observer.on(Sn,(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),a(this,M_,"f").debug("consumerChangePreferredLayers()",Object.assign({},e)))})),this.observer.on(_n,(e=>{const t=this.getConsumerById(e.consumerId);t&&(t.score=e.score)})),this.observer.on(fn,(e=>o(this,void 0,void 0,(function*(){const{producerId:t,spatialLayer:r}=e,n=this.getConsumerByProducerId(t);n?(n.setCurrentMaxSpatialLayer(r),a(this,M_,"f").debug("producerSetMaxSpatialLayer()",{producerId:t,consumerId:n.id,spatialLayer:r}),n.requestedSpatialLayer===r?(yield a(this,P_,"f").request(Sn,{consumerId:n.id,spatialLayer:r}),a(this,M_,"f").debug("requestVideoPreferredLayers()",{producerId:t,consumerId:n.id,spatialLayer:r})):a(this,M_,"f").debug("producerSetMaxSpatialLayer()",{message:"No need to request new preferred layer",currentMaxSpatialLayer:r,requestedMaxSpatialLayer:n.requestedSpatialLayer})):a(this,M_,"f").debug("producerSetMaxSpatialLayer()",{message:"Consumer for producer not created, ignore MaxSpatialLayer change"})})))),this.observer.on(fr,(e=>{try{jn(e),this.setAppData(e),this.observer.emit(nn,e),a(this,M_,"f").debug("updatePeerAppData",{peer:qh(this),appData:e})}catch(t){a(this,M_,"f").error("updatePeerAppData",{peer:qh(this),appData:e,error:t})}}))}reset(){this.producers.clear(),this.tracks.forEach((e=>e.close())),this.tracks.clear();[an,cn,yn,bn,wn,_n,Sn,fn,fr].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(Vn).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(sn,{labels:this.producePermissions})}handleGroupsChange(e){this.groups=e,this.observer.safeEmit(on,{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(!a(this,k_,"f").isModerator(a(this,E_,"f").id))throw new Error("Not enough access")}}k_=new WeakMap,C_=new WeakMap,R_=new WeakMap,P_=new WeakMap,T_=new WeakMap,E_=new WeakMap,D_=new WeakMap,I_=new WeakMap,M_=new WeakMap;class W_{constructor(e){this.score=10,this.spatialLayers=0,this.temporalLayers=0,this.currentSpatialLayer=0,this.currentTemporalLayer=0,this.availableSpatialLayers=[],x_.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,c(this,x_,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}=Gn.parseScalabilityMode(e);this.spatialLayers=t,this.temporalLayers=r,a(this,x_,"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 a(this,x_,"f").debug("Using available spatial layers",{case:"initAvailableSpatialLayers"});a(this,x_,"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]),a(this,x_,"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,a(this,x_,"f").debug("setCurrentSpatialLayer()",{currentSpatialLayer:e}),this.setCurrentSpatialLayerParams()}setCurrentTemporalLayer(e){if(!this.isVideo)throw new Error("setCurrentTemporalLayer applies to video consumers only");this.currentTemporalLayer=e,a(this,x_,"f").debug("setCurrentTemporalLayer()",{currentTemporalLayer:e})}setRequestedSpatialLayer(e){this.requestedSpatialLayer=e}setCurrentMaxSpatialLayer(e){this.currentMaxSpatialLayer=e}getStats(){var e,t;return o(this,void 0,void 0,(function*(){try{return{consumerId:this.consumer.id,codec:this.consumer.rtpParameters.codecs.find((e=>Zh(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 a(this,x_,"f").debug("getStats()",{error:e})}}))}getInboundRTPStreamStats(){return o(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const r=(n=0)=>o(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")),a(this,x_,"f").debug("getInboundRTPStreamStats()",{error:e})}}));r()}))}))}}x_=new WeakMap;const q_=new tt({autoBindInjectable:!0});var U_;q_.bind(zn.CallState).to(Kn).inSingletonScope(),q_.bind(zn.MyPeer).to(Jl).inSingletonScope(),q_.bind(zn.LoggerFactory).toFactory((e=>{const t=e.container.get(zn.Config),r=t.get("logLevel"),n=t.get("sendAnalytics"),i=t.get("onLogMessage");return e=>new Bw({logLevel:r,namespace:e,onLogMessage:i,sendAnalytics:n})})),q_.bind(zn.System).to(Ly).inSingletonScope(),q_.bind(zn.MediaStreamTrackManager).to($l).inSingletonScope(),q_.bind(zn.Media).to(Gl).inSingletonScope(),q_.bind(zn.SocketIO).to(Rh).inSingletonScope(),q_.bind(zn.LoadBalancerApiClient).to(Sy).inSingletonScope(),q_.bind(zn.Network).to(Th).inSingletonScope(),q_.bind(zn.RemotePeerTracks).to(Ww).inSingletonScope(),q_.bind(zn.Peers).to(Eh).inSingletonScope(),q_.bind(zn.MediaSoupEventHandler).to(Tf).inSingletonScope(),q_.bind(zn.ChannelEventHandler).to(zh).inSingletonScope(),q_.bind(zn.ChannelAudioObserverEventHandler).to($y).inSingletonScope(),q_.bind(zn.EventsQueue).to(Fh).inSingletonScope(),q_.bind(zn.ChannelStateSynchronizer).to(Wh).inSingletonScope(),q_.bind(zn.ChannelStateSyncEventHandler).to(Gb).inSingletonScope(),q_.bind(zn.StatsHandler).to(zy).inSingletonScope(),q_.bind(zn.WebRTCIssueDetector).toDynamicValue((e=>{const t=e.container.get(zn.Config);if(t.get("disableWid"))return;const r=e.container.get(zn.RemotePeerTracks),n=e.container.get(zn.StatsHandler),i=t.get("onIssues"),s=t.get("onNetworkScoresUpdated"),o=[1234],a=e.container.get(zn.LoggerFactory)("WID"),c=new Qt({statsParser:new Yt({ignoreSSRCList:o,logger:a})});return new Zt({issueEmitter:new Lt,networkScoresCalculator:new Ft,detectors:[new Ht,new Wt,new qt,new Ut,new Vt,new zt,new Bt,new $t,new Kt],statsReporter:new At({compositeStatsParser:c,getStatsInterval:5e3}),onIssues:function(e){const t=e.filter((e=>e.type!==yt.Stream||e.reason!==bt.FrozenVideoTrack||function(e){const{iceCandidate:t}=e,n=t&&r.get(t);return!!n&&!n.isPaused}(e)));i(t)},onNetworkScoresUpdated:s,onStats:n.handle.bind(n),ignoreSSRCList:o,compositeStatsParser:c,logger:a,autoAddPeerConnections:!1})})).inSingletonScope(),q_.bind(zn.Engine).to(rw).inSingletonScope(),q_.bind(zn.PeerTrackFactory).toFactory((function(e){const t=e.container.get(zn.LoggerFactory),r=e.container.get(zn.CallState),n=e.container.get(zn.StatsHandler);return i=>{const s={callState:r,loggerFactory:t,media:e.container.get(zn.Media),network:e.container.get(zn.Network),peerConsumerFactory:e.container.get(zn.PeerConsumerFactory),socket:e.container.get(zn.SocketIO)},{peerEventEmitter:o}=i,a=new F_(Object.assign(Object.assign(Object.assign({},i),s),{statsHandler:n}));return o.safeEmit(Zr,a),a}})),q_.bind(zn.PeerFactory).toFactory((function(e){const t=e.container.get(zn.LoggerFactory),r=e.container.get(zn.CallState);return n=>{const i={callState:r,loggerFactory:t,media:e.container.get(zn.Media),myPeer:e.container.get(zn.MyPeer),network:e.container.get(zn.Network),peers:e.container.get(zn.Peers),remotePeerTracks:e.container.get(zn.RemotePeerTracks),socket:e.container.get(zn.SocketIO),peerConsumerFactory:e.container.get(zn.PeerConsumerFactory)};return new B_(Object.assign(Object.assign({},i),n))}})),q_.bind(zn.PeerConsumerFactory).toFactory((function(e){const t=e.container.get(zn.LoggerFactory);return e=>{const r={loggerFactory:t};return new W_(Object.assign(Object.assign({},r),e))}})),q_.bind(zn.AudioTrackFactory).toFactory((function(e){const t=e.container.get(zn.LoggerFactory),r=e.container.get(zn.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(zn.InternalEventEmitter),loggerFactory:t,media:e.container.get(zn.Media),mediaStreamTrackManager:e.container.get(zn.MediaStreamTrackManager),myPeer:e.container.get(zn.MyPeer),network:e.container.get(zn.Network),socket:e.container.get(zn.SocketIO),statsHandler:r};return new A_(Object.assign(Object.assign({},i),n))}})),q_.bind(zn.VideoTrackFactory).toFactory((function(e){const t=e.container.get(zn.LoggerFactory),r=e.container.get(zn.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(zn.InternalEventEmitter),loggerFactory:t,media:e.container.get(zn.Media),mediaStreamTrackManager:e.container.get(zn.MediaStreamTrackManager),myPeer:e.container.get(zn.MyPeer),network:e.container.get(zn.Network),socket:e.container.get(zn.SocketIO),statsHandler:r};return new Rf(Object.assign(Object.assign({},i),n))}})),q_.bind(zn.DataChannelsManager).to(ew).inSingletonScope();class z_{constructor(e){U_.set(this,void 0);const{clientEventEmitter:t,internalEventEmitter:r}=e;q_.bind(zn.Config).toDynamicValue((()=>new wt(e))).inSingletonScope(),q_.bind(zn.InternalEventEmitter).toDynamicValue((()=>null!=r?r:new _t)).inSingletonScope(),q_.bind(zn.ClientEventEmitter).toDynamicValue((()=>null!=t?t:new _t)).inSingletonScope(),this.clientEventEmitter=q_.get(zn.ClientEventEmitter),c(this,U_,q_.get(zn.Engine),"f")}get observer(){return this.clientEventEmitter}get id(){return a(this,U_,"f").myPeerId}get peers(){return a(this,U_,"f").getPeers()}get availableVideoDevices(){return a(this,U_,"f").system.availableVideoDevices}get availableAudioDevices(){return a(this,U_,"f").system.availableAudioDevices}get canUseNoiseSuppression(){return a(this,U_,"f").canUseNoiseSuppression}get effectsSDKInitialized(){return a(this,U_,"f").media.effectsSDKInitialized}detectDevices(e){return o(this,void 0,void 0,(function*(){return yield a(this,U_,"f").system.detectDevices(e),{video:a(this,U_,"f").system.availableVideoDevices,audio:a(this,U_,"f").system.availableAudioDevices}}))}initEffectsSDK(){return a(this,U_,"f").media.initEffectsSDK()}join(e){return a(this,U_,"f").join(e)}leave(e){return a(this,U_,"f").release(e)}confirmActivity(){return a(this,U_,"f").confirmActivity()}createCameraVideoTrack(e){return a(this,U_,"f").createCameraVideoTrack(e)}createMicrophoneAudioTrack(e){return a(this,U_,"f").createMicrophoneAudioTrack(e)}createScreenMediaTracks(e){return a(this,U_,"f").createScreenMediaTracks(e)}deleteTrack(e){return a(this,U_,"f").deleteTrack(e)}loadPeers(e){return a(this,U_,"f").loadPeers(e)}updateAppData(e){return a(this,U_,"f").updateAppData(e)}getTransportsInfo(){return o(this,void 0,void 0,(function*(){return a(this,U_,"f").network.getTransportsStateInfo()}))}getNodeActiveStreamsStat(){return a(this,U_,"f").getNodeActiveStreamsStat()}setPreferRelay(e){a(this,U_,"f").network.setPreferRelay(e)}getPreferRelay(){return a(this,U_,"f").network.getPreferRelay()}transportsStats(){return a(this,U_,"f").transportsStats()}getAvgTracksScore(e){return a(this,U_,"f").getAvgTracksScore(e)}}U_=new WeakMap;export{z_ 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,l=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",l]],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,J=RegExp(K.source),Q=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+")*"),Je="(?:"+[Le,Be,We].join("|")+")"+Ge,Qe="(?:"+[Ne+xe+"?",xe,Be,We,Ie].join("|")+")",Ye=RegExp(De,"g"),Ze=RegExp(xe,"g"),Xe=RegExp(Fe+"(?="+Fe+")|"+Qe+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,Je].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 u&&u&&u.Object===Object&&u,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 Jt(e){return e?e.slice(0,hr(e)+1).replace(se,""):e}function Qt(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 u,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=(u=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||""))?"Symbol(src)_1."+u:"",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,Je=Oe.propertyIsEnumerable,Qe=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 Jr(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Gr;++t<r;)this.add(e[t])}function Qr(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[Qn(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 Qr);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,Qt(r))),n?(s=Mt,o=!1):t.length>=200&&(s=Zt,o=!1,t=new Jr(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():Qe.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},Jr.prototype.add=Jr.prototype.push=function(e){return this.__data__.set(e,i),this},Jr.prototype.has=function(e){return this.__data__.has(e)},Qr.prototype.clear=function(){this.__data__=new Kr,this.size=0},Qr.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Qr.prototype.get=function(e){return this.__data__.get(e)},Qr.prototype.has=function(e){return this.__data__.has(e)},Qr.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,Qt(t))),d=wr(l.length,d),c[a]=!n&&(t||s>=120&&l.length>=120)?new Jr(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 Qr),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 Qr),s(g,S,n,i,o)}}if(!h)return!1;return o||(o=new Qr),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 Qr;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=Jo(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 Qr),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:Qo(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,Qt(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,Qt(r)));++s<o;)for(var c=0,d=t[s],u=r?r(d):d;(c=i(a,u,c,n))>-1;)a!==e&&Qe.call(a,c,1),Qe.call(e,c,1);return e}function Jn(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)?Qe.call(e,i,1):hi(e,i)}}return e}function Qn(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 Jr}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 Qo(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(!Jo(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(!Jo(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 Ji(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,Qt(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 Ji(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 Qi(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,u,p,h,f,m){var g=2&t;if(!g&&"function"!=typeof e)throw new Ie(n);var v=u?u.length:0;if(v||(t&=-97,u=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=u,b=p;u=p=r}var w=g?r:as(e),_=[e,t,i,u,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==l&&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 u=e[3];e[3]=u?Di(u,c,t[4]):c,e[4]=u?cr(e[3],s):t[4]}(c=t[5])&&(u=e[5],e[5]=u?Ii(u,c,t[6]):c,e[6]=u?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],u=_[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?Ji(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,u);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 Jr: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 Je.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?Jo(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=Qn(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 Qo(e)?hn(e,bn(t,1,Qo,!0)):[]})),zs=Zn((function(e,t){var n=Zs(t);return Qo(n)&&(n=r),Qo(e)?hn(e,bn(t,1,Qo,!0),us(n,2)):[]})),Vs=Zn((function(e,t){var n=Zs(t);return Qo(n)&&(n=r),Qo(e)?hn(e,bn(t,1,Qo,!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 Js=Zn((function(e){var t=xt(e,bi);return t.length&&t[0]===e[0]?Mn(t):[]})),Qs=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 Jn(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,Qo,!0))})),io=Zn((function(e){var t=Zs(e);return Qo(t)&&(t=r),pi(bn(e,1,Qo,!0),us(t,2))})),so=Zn((function(e){var t=Zs(e);return t="function"==typeof t?t:r,pi(bn(e,1,Qo,!0),r,t)}));function oo(e){if(!e||!e.length)return[];var t=0;return e=Dt(e,(function(e){if(Qo(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 Qo(e)?hn(e,t):[]})),uo=Zn((function(e){return vi(Dt(e,Qo))})),lo=Zn((function(e){var t=Zs(e);return Qo(t)&&(t=r),vi(Dt(e,Qo),us(t,2))})),po=Zn((function(e){var t=Zs(e);return t="function"==typeof t?t:r,vi(Dt(e,Qo),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=Jo(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],Qt(us())):xt(bn(t,1),Qt(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,l,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")&&!Je.call(e,"callee")},Ko=oe.isArray,Go=yt?Qt(yt):function(e){return ia(e)&&Tn(e)==O};function Jo(e){return null!=e&&ra(e.length)&&!ea(e)}function Qo(e){return ia(e)&&Jo(e)}var Yo=Ht||bc,Zo=bt?Qt(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?Qt(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?Qt(_t):function(e){return ia(e)&&Tn(e)==E};var da=St?Qt(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?Qt(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(Jo(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=Jt(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)||Jo(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 Jo(e)?Yr(e):Nn(e)}function Aa(e){return Jo(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()})),Ja=Fi("toLowerCase");var Qa=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=Qi("ceil"),Sc=Vi((function(e,t){return e/t}),1),kc=Qi("floor");var Cc,Rc=Vi((function(e,t){return e*t}),1),Pc=Qi("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=Js,qr.intersectionBy=Qs,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 Jn(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))&&Q.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=Jo(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=Jo,qr.isArrayLikeObject=Qo,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(Jo(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=Ja,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 Qn(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(Jo(e))return ua(e)?lr(e):e.length;var t=gs(e);return t==C||t==D?e.size:Nn(e).length},qr.snakeCase=Qa,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 Jt(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))&&J.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(u)}(sw,sw.exports);var ow,aw=u&&u.__extends||(ow=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}ow(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(iw,"__esModule",{value:!0});var cw=sw.exports,dw=["MaxBatchSize","MaxDelay","MinDelay"],uw=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=cw.debounce(r.releaseBatch.bind(r),r.options.MaxDelay,{maxWait:r.options.MaxDelay}),r.releaseBatchDebouncedMin=cw.debounce(r.releaseBatch.bind(r),r.options.MinDelay,{maxWait:r.options.MinDelay}),r}return aw(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);iw.MessageBatcher=uw,function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(iw)}(nw),function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(nw)}(rw);let lw,pw=!1;const hw=()=>{try{return pw?null:window.localStorage}catch(e){return console.error("Get local storage error",{error:cr(e)}),e instanceof Error&&"SecurityError"===e.name&&(pw=!0),null}};function fw(e){const t=hw();if(!t)return null;try{return JSON.parse(t.getItem(e))}catch(e){return null}}const mw=()=>{if(lw)return lw;const e=fw("sdk_clientUniqueId");if(e)return lw=e,e;const t=r.randomBytes(12).toString("hex");return lw=t,function(e,t){const r=hw();if(r)try{r.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}}("sdk_clientUniqueId",t),t},gw=()=>{const e=fw("sdk_clientUniqueId");return e||(null!=lw?lw:mw())},vw=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 yw(e){return!e.response&&(!!e.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(e.code)&&(e=>!vw.has(e&&e.code))(e)))}const bw=["get","head","options"],ww=bw.concat(["put","delete"]);function _w(e){return"ECONNABORTED"!==e.code&&(!e.response||429===e.response.status||e.response.status>=500&&e.response.status<=599)}function Sw(e){return!!e.config?.method&&(_w(e)&&-1!==ww.indexOf(e.config.method))}function kw(e){return yw(e)||Sw(e)}function Cw(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 Rw={retries:3,retryCondition:kw,retryDelay:function(e=0,t){return Math.max(0,Cw(t))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function Pw(e,t,r=!1){const n=function(e,t){return{...Rw,...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 Tw=(e,t)=>{const r=e.interceptors.request.use((e=>(Pw(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=Pw(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}};Tw.isNetworkError=yw,Tw.isSafeRequestError=function(e){return!!e.config?.method&&(_w(e)&&-1!==bw.indexOf(e.config.method))},Tw.isIdempotentRequestError=Sw,Tw.isNetworkOrIdempotentRequestError=kw,Tw.exponentialDelay=function(e=0,t,r=100){const n=2**e*r,i=Math.max(n,Cw(t));return i+.2*i*Math.random()},Tw.linearDelay=function(e=100){return(t=0,r)=>{const n=t*e;return Math.max(n,Cw(r))}},Tw.isRetryableError=_w;class Ew{constructor(e){this.api=e,Tw(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 o(this,void 0,void 0,(function*(){return this.api.post("/log/batch",e)}))}}class Dw{constructor(){this.api=rg.create({baseURL:"https://moodhood-analytics.livedigital.space/v1",timeout:1e4,withCredentials:!0,paramsSerializer:e=>yy.stringify(e),headers:{"x-cl-id":gw()}}),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 Ew(this.api)}get log(){return this.logApi}}var Iw,Mw,xw,Ow,Lw,Aw,jw,Fw;class Nw{constructor(e){Iw.add(this),Mw.set(this,void 0),xw.set(this,void 0),Ow.set(this,void 0),Lw.set(this,void 0),Aw.set(this,void 0);const{logLevel:t,namespace:r,onLogMessage:n}=e;c(this,Mw,r,"f"),c(this,xw,t,"f"),this.onLogMessage=n,c(this,Lw,new Dw,"f"),c(this,Ow,new rw.MessageBatcher({MaxBatchSize:50,MaxDelay:1e3,MinDelay:500}),"f"),c(this,Aw,e.sendAnalytics,"f"),a(this,Ow,"f").on("batch",(e=>o(this,void 0,void 0,(function*(){yield this.logToApi(e)})))),this._debug=Ui("LiveDigital").extend("debug").extend(a(this,Mw,"f")),this._info=Ui("LiveDigital").extend("info").extend(a(this,Mw,"f")),this._warn=Ui("LiveDigital").extend("warn").extend(a(this,Mw,"f")),this._error=Ui("LiveDigital").extend("error").extend(a(this,Mw,"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),a(this,Aw,"f")&&a(this,Ow,"f").Queue({level:"debug",message:e,meta:t}),a(this,xw,"f")>=pt&&a(this,Iw,"m",jw).call(this,"debug",e,t)}info(e,t){this._info(e,t),a(this,Aw,"f")&&a(this,Ow,"f").Queue({level:"info",message:e,meta:t}),a(this,xw,"f")>=lt&&a(this,Iw,"m",jw).call(this,"info",e,t)}warn(e,t){this._warn(e,t),a(this,Aw,"f")&&a(this,Ow,"f").Queue({level:"warn",message:e,meta:t}),a(this,xw,"f")>=ut&&a(this,Iw,"m",jw).call(this,"warn",e,t)}error(e,t){this._error(e,t),a(this,Aw,"f")&&a(this,Ow,"f").Queue({level:"error",message:e,meta:t}),a(this,xw,"f")>=dt&&a(this,Iw,"m",jw).call(this,"error",e,t)}logToApi(e){return o(this,void 0,void 0,(function*(){try{yield a(this,Lw,"f").log.batch({logs:e.map((e=>a(this,Iw,"m",Fw).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({},dr.meta),{clUId:gw()})}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:cr(r)}:{})}}Mw=new WeakMap,xw=new WeakMap,Ow=new WeakMap,Lw=new WeakMap,Aw=new WeakMap,Iw=new WeakSet,jw=function(e,t,...r){"function"==typeof this.onLogMessage&&this.onLogMessage(t,...a(this,Iw,"m",Fw).call(this,r),e)},Fw=function(e){const t=new WeakMap;return function e(r,n=[]){if(!Eh(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 Bw=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}};Bw=n([ot(),i(0,ct(Un.PeerTrackFactory)),s("design:paramtypes",[Function])],Bw);class Ww 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 o(this,void 0,void 0,(function*(){const t=W_.get(Un.Config);yield e.audioWorklet.addModule(`${t.get("staticFilesPath")}/noiseSuppressionWorklet.js`)}))}}var qw,Uw,zw,Vw,Hw,$w;class Kw{constructor(e){qw.set(this,void 0),Uw.set(this,void 0),zw.set(this,void 0),Vw.set(this,void 0),Hw.set(this,void 0),$w.set(this,!0),c(this,qw,e.noiseSuppressor.instance.exports,"f"),c(this,Uw,e.context,"f"),c(this,zw,new Float32Array(a(this,qw,"f").memory.buffer),"f"),c(this,Vw,a(this,qw,"f").newState(),"f"),c(this,Hw,a(this,Uw,"f").createScriptProcessor(),"f"),this.setOnAudioProcess()}get noiseSuppressionScriptProcessorNode(){return a(this,Hw,"f")}update(e){e||(c(this,$w,!1,"f"),a(this,qw,"f").deleteState(a(this,Vw,"f")));const t=Object.assign(new Event("status"),{vadProb:a(this,qw,"f").getVadProb(a(this,Vw,"f"))});a(this,Hw,"f").dispatchEvent(t)}setOnAudioProcess(){a(this,Hw,"f").addEventListener("audioprocess",(({inputBuffer:e,outputBuffer:t})=>{if(!a(this,$w,"f"))return;a(this,zw,"f").set(e.getChannelData(0),a(this,qw,"f").getInput(a(this,Vw,"f"))/4);const r=t.getChannelData(0),n=a(this,qw,"f").pipe(a(this,Vw,"f"),r.length)/4;n&&r.set(a(this,zw,"f").subarray(n,n+r.length))}))}}qw=new WeakMap,Uw=new WeakMap,zw=new WeakMap,Vw=new WeakMap,Hw=new WeakMap,$w=new WeakMap;var Gw,Jw,Qw,Yw,Zw,Xw,e_,t_,r_,n_,i_,s_,o_,a_,c_,d_,u_,l_,p_,h_,f_,m_,g_,v_,y_,b_,w_,__,S_,k_,C_,R_,P_,T_,E_,D_,I_,M_;class x_{constructor({context:e,noiseSuppressor:t}){Gw.set(this,void 0),Jw.set(this,void 0),Qw.set(this,void 0),c(this,Gw,e,"f"),c(this,Jw,t,"f")}createNoiseSuppressionNode(){return o(this,void 0,void 0,(function*(){return/apple/i.test(navigator.vendor)?this.createScriptProcessorNode():this.createAudioWorkletNode()}))}stop(){var e;null===(e=a(this,Qw,"f"))||void 0===e||e.update(!1)}createAudioWorkletNode(){return o(this,void 0,void 0,(function*(){return yield Ww.register(a(this,Gw,"f")),c(this,Qw,new Ww({context:a(this,Gw,"f"),noiseSuppressor:a(this,Jw,"f")}),"f"),a(this,Qw,"f")}))}createScriptProcessorNode(){return c(this,Qw,new Kw({context:a(this,Gw,"f"),noiseSuppressor:a(this,Jw,"f")}),"f"),a(this,Qw,"f").noiseSuppressionScriptProcessorNode}}Gw=new WeakMap,Jw=new WeakMap,Qw=new WeakMap;class O_{constructor(e){Yw.set(this,void 0),Zw.set(this,void 0),Xw.set(this,void 0),e_.set(this,void 0),c(this,Yw,e.noiseSuppressor,"f"),c(this,Xw,e.loggerFactory("TrackProcessor"),"f")}get isProcessing(){return!!a(this,e_,"f")}processTrack(e){return o(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 Ww.register(t);const n=t.createMediaStreamSource(new MediaStream([e])),i=new x_({context:t,noiseSuppressor:a(this,Yw,"f")}),s=yield i.createNoiseSuppressionNode();s.connect(r),n.connect(s);const[o]=r.stream.getTracks();return c(this,Zw,{audioContext:t,streamDestination:r,noiseSuppressionNode:s,noiseSuppressionProvider:i},"f"),c(this,e_,o,"f"),a(this,Xw,"f").info("processTrack()",{track:e.id}),o}))}stopProcessing(){var e;return o(this,void 0,void 0,(function*(){if(this.isProcessing)if(a(this,Zw,"f"))try{a(this,Zw,"f").noiseSuppressionProvider.stop(),a(this,Zw,"f").noiseSuppressionNode.disconnect(),a(this,Zw,"f").streamDestination.disconnect(),yield a(this,Zw,"f").audioContext.close(),null===(e=a(this,e_,"f"))||void 0===e||e.stop(),c(this,e_,void 0,"f"),a(this,Xw,"f").info("stopProcessing()",{success:!0})}catch(e){a(this,Xw,"f").error("stopProcessing()",{success:!1,error:e})}else a(this,Xw,"f").warn("stopProcessing()",{success:!1,description:"Processing context is not available"});else a(this,Xw,"f").debug("stopProcessing()",{description:"Track is not processed"})}))}}Yw=new WeakMap,Zw=new WeakMap,Xw=new WeakMap,e_=new WeakMap;class L_ extends kf{constructor(e){super(e),t_.set(this,void 0),r_.set(this,void 0),e.noiseSuppressor&&c(this,t_,new O_({noiseSuppressor:e.noiseSuppressor,loggerFactory:e.loggerFactory}),"f")}get isEffectsProcessing(){var e;return!!(null===(e=a(this,t_,"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:Tl}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;return o(this,void 0,void 0,(function*(){if(a(this,t_,"f"))try{const t=yield null===(e=a(this,t_,"f"))||void 0===e?void 0:e.processTrack(this.mediaStreamTrack);c(this,r_,this.mediaStreamTrack,"f"),yield this.replaceTrack(t)}catch(e){throw this.logger.warn("enableNoiseSuppression()",{description:"Can not enable noise suppression",track:this.logCtx,error:e}),new Error("Can not enable noise suppression")}else this.logger.warn("enableNoiseSuppression()",{description:"Track suppressor is not defined"})}))}disableNoiseSuppression(){var e,t;return o(this,void 0,void 0,(function*(){try{if(!(null===(e=a(this,t_,"f"))||void 0===e?void 0:e.isProcessing))return void this.logger.debug("stopProcessing()",{description:"Track is not processed"});if(!a(this,r_,"f"))return void this.logger.warn("disableNoiseSuppression()",{description:"Original track missing"});this.isPublished&&(yield this.replaceTrack(a(this,r_,"f"))),yield null===(t=a(this,t_,"f"))||void 0===t?void 0:t.stopProcessing()}catch(e){throw this.logger.warn("disableNoiseSuppression()",{description:"Can not disable noise suppression",track:this.logCtx,error:e}),new Error("Can not disable noise suppression")}}))}publish(){return o(this,void 0,void 0,(function*(){yield this.produce({encodings:this.getEncodings(),preferredCodec:this.getPreferredCodec(),codecOptions:this.getCodecOptions()}),this.internalEventEmitter.emit(Kr.trackProduced,this)}))}pause(){return o(this,void 0,void 0,(function*(){yield this.mute()}))}}t_=new WeakMap,r_=new WeakMap;class A_{constructor({track:e,statsHandler:t}){n_.set(this,void 0),i_.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return a(this,n_,"f")}get audioWebRTCStats(){return a(this,i_,"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){c(this,n_,e,"f")}setAudioWebRTCStats(e){c(this,i_,e,"f")}}n_=new WeakMap,i_=new WeakMap;class j_{constructor(e){this.label=zn.Unknown,s_.set(this,void 0),o_.set(this,void 0),a_.set(this,void 0),c_.set(this,void 0),d_.set(this,void 0),u_.set(this,void 0),l_.set(this,void 0),p_.set(this,void 0),h_.set(this,void 0),f_.set(this,void 0),m_.set(this,!1),g_.set(this,void 0),v_.set(this,!1),y_.set(this,new Hh),b_.set(this,!1),w_.set(this,0),__.set(this,void 0),this.observer=new _t,c(this,h_,e.mediaStreamTrack,"f"),this.label=e.label,this.consumer=e.consumer,c(this,d_,e.peerConsumerFactory,"f"),c(this,l_,e.loggerFactory("PeerTrack"),"f"),c(this,p_,e.peerEventEmitter,"f"),c(this,b_,e.muted,"f"),c(this,f_,e.paused,"f"),c(this,s_,e.network,"f"),c(this,o_,e.socket,"f"),c(this,a_,e.media,"f"),c(this,u_,e.callState,"f"),c(this,c_,e.onClose,"f"),c(this,__,new A_({track:e.mediaStreamTrack,statsHandler:e.statsHandler}),"f")}get videoWebRTCStats(){return a(this,__,"f").videoWebRTCStats}get audioWebRTCStats(){return a(this,__,"f").audioWebRTCStats}get logCtx(){var e,t;return{id:a(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:a(this,b_,"f"),paused:a(this,f_,"f"),closed:a(this,v_,"f")}}get volume(){return a(this,w_,"f")}get isRemote(){return!!this.consumer}get mediaStreamTrack(){return a(this,h_,"f")}get kind(){return this.mediaStreamTrack.kind}get isPaused(){return a(this,f_,"f")}get isMuted(){return a(this,b_,"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 o(this,void 0,void 0,(function*(){a(this,p_,"f").safeEmit(Xr,this),c(this,v_,!0,"f"),a(this,c_,"f").call(this),this.consumer&&(yield this.closeConsumer(),this.clearCheckStateTimeout())}))}mute(){return o(this,void 0,void 0,(function*(){yield a(this,y_,"f").push((()=>o(this,void 0,void 0,(function*(){a(this,l_,"f").debug("mute()",{track:this.logCtx}),yield this.pauseConsumer(),c(this,b_,!0,"f")}))))}))}unmute(){return o(this,void 0,void 0,(function*(){yield a(this,y_,"f").push((()=>o(this,void 0,void 0,(function*(){a(this,l_,"f").debug("unmute()",{track:this.logCtx}),yield this.resumeConsumer(),c(this,b_,!1,"f")}))))}))}pause(e=!0){return o(this,void 0,void 0,(function*(){yield a(this,y_,"f").push((()=>o(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return c(this,f_,!0,"f"),a(this,p_,"f").safeEmit(en,this),void a(this,l_,"f").debug("pause()",{track:this.logCtx});yield this.pauseConsumer(e),c(this,f_,!0,"f"),a(this,p_,"f").safeEmit(en,this)}))))}))}resume(e=!0){return o(this,void 0,void 0,(function*(){yield a(this,y_,"f").push((()=>o(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return c(this,f_,!1,"f"),a(this,p_,"f").safeEmit(tn,this),void a(this,l_,"f").debug("resume()",{track:this.logCtx});yield this.resumeConsumer(e),c(this,f_,!1,"f"),a(this,p_,"f").safeEmit(tn,this)}))))}))}resumeConsumer(e=!0){return o(this,void 0,void 0,(function*(){if(this.consumer)try{this.consumer.resume(),e&&(yield a(this,s_,"f").resumeRemoteConsumer(this.consumer.id)),this.checkConsumerState().catch((e=>{a(this,l_,"f").warn("Failed to checkConsumerState()",{track:this.logCtx,error:cr(e)})})),a(this,l_,"f").debug("resumeConsumer()",{track:this.logCtx})}catch(e){a(this,l_,"f").warn("resumeConsumer()",{error:e})}}))}pauseConsumer(e=!0){return o(this,void 0,void 0,(function*(){if(this.consumer)try{this.clearCheckStateTimeout(),e&&(yield a(this,s_,"f").pauseRemoteConsumer(this.consumer.id)),this.consumer.pause(),c(this,m_,!1,"f"),a(this,l_,"f").debug("pauseConsumer()",{track:this.logCtx})}catch(e){a(this,l_,"f").warn("pauseConsumer()",{error:e})}}))}requestVideoPreferredLayers({spatialLayer:e,temporalLayer:t}){return o(this,void 0,void 0,(function*(){if(this.consumer)try{if(this.consumer.isAudio)return void a(this,l_,"f").warn("Only video consumers support layers",{case:"requestVideoPreferredLayers"});if(e===this.consumer.currentSpatialLayer)return;if(e>this.consumer.spatialLayers)return void a(this,l_,"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 a(this,o_,"f").request(Sn,{consumerId:this.consumer.id,spatialLayer:e,temporalLayer:t}),a(this,l_,"f").debug("requestVideoPreferredLayers()",{track:this.logCtx,consumer:this.consumer,spatialLayer:e,temporalLayer:t})}catch(e){throw a(this,l_,"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 o(this,void 0,void 0,(function*(){if(this.consumerId){a(this,l_,"f").debug("requestKeyFrame()",{track:this.logCtx});try{yield a(this,o_,"f").request(kn,{consumerId:this.consumerId})}catch(e){throw a(this,l_,"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;a(this,l_,"f").warn("Only video consumers support layers",{case:"getVideoAvailableLayers"})}}getInfo(){var e;return o(this,void 0,void 0,(function*(){const{width:t,height:r,frameRate:n,aspectRatio:i}=a(this,h_,"f").getSettings();return{trackId:a(this,h_,"f").id,readyState:a(this,h_,"f").readyState,isRemote:this.isRemote,kind:this.kind,label:this.label,width:t,height:r,frameRate:n,aspectRatio:i,paused:a(this,f_,"f"),trackInboundStats:yield null===(e=this.consumer)||void 0===e?void 0:e.getStats(),trackOutboundStats:yield this.getOutboundStats()}}))}getOutboundStats(){return o(this,void 0,void 0,(function*(){if(this.isRemote)return;const e=a(this,a_,"f").getAllTracks().find((e=>e.getLabel()===this.label));return e?e.getStats():void 0}))}requestMaxSpatialLayer(e,t){return o(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 a(this,l_,"f").warn("Can`t request this spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t});this.consumer.setRequestedSpatialLayer(t),yield a(this,o_,"f").request(mn,{producerId:this.consumer.producerId,spatialLayer:t}),a(this,l_,"f").debug("requestMaxSpatialLayer()",{consumerId:e,spatialLayer:t})}catch(r){a(this,l_,"f").warn("Failed to request max spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t,error:r})}}))}checkConsumerState(){return o(this,void 0,void 0,(function*(){try{if(a(this,v_,"f")||"audio"===this.kind)return;a(this,l_,"f").debug("checkConsumerState()",{track:this.logCtx});if((yield this.isInboundRTPStreamActive())||a(this,v_,"f"))return;yield this.requestKeyFrame();if((yield this.isInboundRTPStreamActive())||a(this,v_,"f"))return;if(a(this,m_,"f"))return a(this,p_,"f").emit(rn,this),void a(this,l_,"f").debug("trackFail()",{track:this.logCtx});yield this.restartConsumer()}catch(e){a(this,l_,"f").warn("checkConsumerState()",{track:this,error:e})}}))}setVolume(e){a(this,w_,"f")!==e&&(c(this,w_,e,"f"),this.observer.safeEmit($r,{value:e}))}closeConsumer(){return o(this,void 0,void 0,(function*(){try{if(!this.consumer)return;this.consumer.close(),yield a(this,s_,"f").closeRemoteConsumer(this.consumer.id)}catch(e){a(this,l_,"f").debug("closeConsumer()",{track:this,error:e})}}))}restartConsumer(){return o(this,void 0,void 0,(function*(){try{if(!this.consumer||a(this,v_,"f"))return;a(this,l_,"f").debug("restartConsumer()",{track:this.logCtx}),a(this,p_,"f").emit(Xr,this),c(this,f_,!0,"f"),yield this.closeConsumer();const{consumer:e}=yield a(this,s_,"f").createConsumer({producerId:this.consumer.producerId,rtpCapabilities:a(this,a_,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.consumer.appData.producerData.peerId,appId:a(this,u_,"f").appId,channelId:a(this,u_,"f").channelId});c(this,m_,!0,"f"),this.consumer=a(this,d_,"f").call(this,{consumer:e}),c(this,h_,e.track,"f"),yield this.resume(),a(this,p_,"f").emit(Zr,this)}catch(e){c(this,m_,!0,"f"),a(this,l_,"f").warn("restartConsumer()",{track:this,error:e})}}))}isInboundRTPStreamActive(){return o(this,void 0,void 0,(function*(){if(!this.consumer||a(this,v_,"f"))return!1;const{framesDecoded:e}=yield this.consumer.getInboundRTPStreamStats();return new Promise((t=>{c(this,g_,setTimeout((()=>o(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){a(this,l_,"f").debug("isInboundRTPStreamActive()",{error:e,track:this.logCtx}),t(!1)}}))),4500),"f")}))}))}clearCheckStateTimeout(){a(this,g_,"f")||clearTimeout(a(this,g_,"f"))}}s_=new WeakMap,o_=new WeakMap,a_=new WeakMap,c_=new WeakMap,d_=new WeakMap,u_=new WeakMap,l_=new WeakMap,p_=new WeakMap,h_=new WeakMap,f_=new WeakMap,m_=new WeakMap,g_=new WeakMap,v_=new WeakMap,y_=new WeakMap,b_=new WeakMap,w_=new WeakMap,__=new WeakMap;class F_{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 N_{constructor({id:e,channelIds:t,groups:r,producePermissions:n,appId:i,loginDate:s,producers:o=[],appData:a,uid:d,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,S_.set(this,void 0),k_.set(this,void 0),C_.set(this,void 0),R_.set(this,void 0),P_.set(this,void 0),T_.set(this,void 0),E_.set(this,void 0),D_.set(this,void 0),I_.set(this,void 0),this._observer=new _t,this.id=e,this.channelIds=t,this.groups=r,this.producePermissions=n,this.appId=i,this.loginDate=s,this.applicationData=a||{},this.uid=d,this.role=u,c(this,T_,p,"f"),c(this,E_,h,"f"),c(this,S_,f,"f"),c(this,k_,m,"f"),c(this,R_,y,"f"),c(this,D_,b,"f"),c(this,C_,v,"f"),c(this,P_,g,"f"),c(this,I_,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===a(this,T_,"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 o(this,void 0,void 0,(function*(){try{const r=this.producers.get(e);if(!r)return void a(this,I_,"f").warn("subscribe()",{message:"Peer does not have a producer",peer:Wh(this),producerId:e});if(this.getAllConsumers().find((t=>t.producerId===e)))return void a(this,I_,"f").debug("subscribe()",{message:"Already subscribed to producer",peer:Wh(this),producerId:e});const{consumer:n,isProducerPaused:i}=yield a(this,C_,"f").createConsumer({producerId:r.id,rtpCapabilities:a(this,P_,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.id,appId:a(this,E_,"f").appId,channelId:a(this,E_,"f").channelId});if(!this.producePermissions.includes(r.label)&&Object.values(zn).includes(r.label))return void a(this,I_,"f").debug("subscribe()",{message:"Producer is not allowed anymore",peer:Wh(this),producerId:e});const s=a(this,k_,"f").create({mediaStreamTrack:n.track,label:r.label,consumer:a(this,D_,"f").call(this,{consumer:n}),muted:t,paused:i,peerEventEmitter:this.observer});t||(yield s.unmute()),this.tracks.set(s.label,s),a(this,I_,"f").debug(`Subscribed for ${r.kind}`,{peer:Wh(this)})}catch(t){throw a(this,I_,"f").error("subscribe()",{producerId:e,error:t,peer:Wh(this)}),new Error("Error subscribe media")}}))}unsubscribe(e){return o(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),a(this,I_,"f").debug(`Unsubscribed consumer ${t.kind}`,{peer:Wh(this)})}catch(t){throw a(this,I_,"f").error("unsubscribe()",{producerId:e,error:t}),new Error("Error unsubscribe media")}}))}setProducePermissions(e){return o(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield a(this,R_,"f").request(Cr,{peerId:this.id,producePermissions:e}),a(this,I_,"f").debug("Produce permissions changed",{peerId:this.id,producePermissions:e})}))}addProducePermission(e){return o(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield a(this,R_,"f").request(Rr,{peerId:this.id,label:e}),a(this,I_,"f").debug("Add produce permission requested",{peerId:this.id,label:e})}))}removeProducePermission(e){return o(this,void 0,void 0,(function*(){this.throwIfIamNotModerator(),yield a(this,R_,"f").request(Pr,{peerId:this.id,label:e}),a(this,I_,"f").debug("Remove produce permission requested",{peerId:this.id,label:e})}))}getInfo(){return o(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 a(this,I_,"f").error("getInfo()",{peer:Wh(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 F_(e);this.producers.set(t.id,t),a(this,I_,"f").debug("Peer published media:",{peer:Wh(this),producer:t}),this.observer.safeEmit(Gr,{producerId:t.id,kind:t.kind,label:t.label,paused:t.paused})}handlePeerEvents(){this.observer.on(an,this.handleNewProducer.bind(this)),this.observer.on(cn,(e=>o(this,void 0,void 0,(function*(){this.producers.delete(e.id),a(this,I_,"f").debug("Peer unpublished media:",{peer:Wh(this),producer:e}),this.observer.safeEmit(Jr,{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){a(this,I_,"f").warn("Failed to close peer track due to producer closed",{label:t.label,peerId:this.id})}})))),this.observer.on(yn,(e=>o(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.close(),this.tracks.delete(t.label),a(this,I_,"f").debug("Peer video track was ended:",{peer:Wh(this),track:t.logCtx}))})))),this.observer.on(bn,(e=>o(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.pause(!1))})))),this.observer.on(wn,(e=>o(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.resume(!1))})))),this.observer.on(Sn,(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),a(this,I_,"f").debug("consumerChangePreferredLayers()",Object.assign({},e)))})),this.observer.on(_n,(e=>{const t=this.getConsumerById(e.consumerId);t&&(t.score=e.score)})),this.observer.on(fn,(e=>o(this,void 0,void 0,(function*(){const{producerId:t,spatialLayer:r}=e,n=this.getConsumerByProducerId(t);n?(n.setCurrentMaxSpatialLayer(r),a(this,I_,"f").debug("producerSetMaxSpatialLayer()",{producerId:t,consumerId:n.id,spatialLayer:r}),n.requestedSpatialLayer===r?(yield a(this,R_,"f").request(Sn,{consumerId:n.id,spatialLayer:r}),a(this,I_,"f").debug("requestVideoPreferredLayers()",{producerId:t,consumerId:n.id,spatialLayer:r})):a(this,I_,"f").debug("producerSetMaxSpatialLayer()",{message:"No need to request new preferred layer",currentMaxSpatialLayer:r,requestedMaxSpatialLayer:n.requestedSpatialLayer})):a(this,I_,"f").debug("producerSetMaxSpatialLayer()",{message:"Consumer for producer not created, ignore MaxSpatialLayer change"})})))),this.observer.on(fr,(e=>{try{An(e),this.setAppData(e),this.observer.emit(nn,e),a(this,I_,"f").debug("updatePeerAppData",{peer:Wh(this),appData:e})}catch(t){a(this,I_,"f").error("updatePeerAppData",{peer:Wh(this),appData:e,error:t})}}))}reset(){this.producers.clear(),this.tracks.forEach((e=>e.close())),this.tracks.clear();[an,cn,yn,bn,wn,_n,Sn,fn,fr].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(sn,{labels:this.producePermissions})}handleGroupsChange(e){this.groups=e,this.observer.safeEmit(on,{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(!a(this,S_,"f").isModerator(a(this,T_,"f").id))throw new Error("Not enough access")}}S_=new WeakMap,k_=new WeakMap,C_=new WeakMap,R_=new WeakMap,P_=new WeakMap,T_=new WeakMap,E_=new WeakMap,D_=new WeakMap,I_=new WeakMap;class B_{constructor(e){this.score=10,this.spatialLayers=0,this.temporalLayers=0,this.currentSpatialLayer=0,this.currentTemporalLayer=0,this.availableSpatialLayers=[],M_.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,c(this,M_,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}=Kn.parseScalabilityMode(e);this.spatialLayers=t,this.temporalLayers=r,a(this,M_,"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 a(this,M_,"f").debug("Using available spatial layers",{case:"initAvailableSpatialLayers"});a(this,M_,"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]),a(this,M_,"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,a(this,M_,"f").debug("setCurrentSpatialLayer()",{currentSpatialLayer:e}),this.setCurrentSpatialLayerParams()}setCurrentTemporalLayer(e){if(!this.isVideo)throw new Error("setCurrentTemporalLayer applies to video consumers only");this.currentTemporalLayer=e,a(this,M_,"f").debug("setCurrentTemporalLayer()",{currentTemporalLayer:e})}setRequestedSpatialLayer(e){this.requestedSpatialLayer=e}setCurrentMaxSpatialLayer(e){this.currentMaxSpatialLayer=e}getStats(){var e,t;return o(this,void 0,void 0,(function*(){try{return{consumerId:this.consumer.id,codec:this.consumer.rtpParameters.codecs.find((e=>Yh(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 a(this,M_,"f").debug("getStats()",{error:e})}}))}getInboundRTPStreamStats(){return o(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const r=(n=0)=>o(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")),a(this,M_,"f").debug("getInboundRTPStreamStats()",{error:e})}}));r()}))}))}}M_=new WeakMap;const W_=new tt({autoBindInjectable:!0});var q_;W_.bind(Un.CallState).to($n).inSingletonScope(),W_.bind(Un.MyPeer).to(Gl).inSingletonScope(),W_.bind(Un.LoggerFactory).toFactory((e=>{const t=e.container.get(Un.Config),r=t.get("logLevel"),n=t.get("sendAnalytics"),i=t.get("onLogMessage");return e=>new Nw({logLevel:r,namespace:e,onLogMessage:i,sendAnalytics:n})})),W_.bind(Un.System).to(Oy).inSingletonScope(),W_.bind(Un.MediaStreamTrackManager).to(Hl).inSingletonScope(),W_.bind(Un.Media).to(Kl).inSingletonScope(),W_.bind(Un.SocketIO).to(Ch).inSingletonScope(),W_.bind(Un.LoadBalancerApiClient).to(_y).inSingletonScope(),W_.bind(Un.Network).to(Ph).inSingletonScope(),W_.bind(Un.RemotePeerTracks).to(Bw).inSingletonScope(),W_.bind(Un.Peers).to(Th).inSingletonScope(),W_.bind(Un.MediaSoupEventHandler).to(Pf).inSingletonScope(),W_.bind(Un.ChannelEventHandler).to(Uh).inSingletonScope(),W_.bind(Un.ChannelAudioObserverEventHandler).to(Hy).inSingletonScope(),W_.bind(Un.EventsQueue).to(jh).inSingletonScope(),W_.bind(Un.ChannelStateSynchronizer).to(Bh).inSingletonScope(),W_.bind(Un.ChannelStateSyncEventHandler).to(Kb).inSingletonScope(),W_.bind(Un.StatsHandler).to(Uy).inSingletonScope(),W_.bind(Un.WebRTCIssueDetector).toDynamicValue((e=>{const t=e.container.get(Un.Config);if(t.get("disableWid"))return;const r=e.container.get(Un.RemotePeerTracks),n=e.container.get(Un.StatsHandler),i=t.get("onIssues"),s=t.get("onNetworkScoresUpdated"),o=[1234],a=e.container.get(Un.LoggerFactory)("WID"),c=new Qt({statsParser:new Yt({ignoreSSRCList:o,logger:a})});return new Zt({issueEmitter:new Lt,networkScoresCalculator:new Ft,detectors:[new Ht,new Wt,new qt,new Ut,new Vt,new zt,new Bt,new $t,new Kt],statsReporter:new At({compositeStatsParser:c,getStatsInterval:5e3}),onIssues:function(e){const t=e.filter((e=>e.type!==yt.Stream||e.reason!==bt.FrozenVideoTrack||function(e){const{iceCandidate:t}=e,n=t&&r.get(t);return!!n&&!n.isPaused}(e)));i(t)},onNetworkScoresUpdated:s,onStats:n.handle.bind(n),ignoreSSRCList:o,compositeStatsParser:c,logger:a,autoAddPeerConnections:!1})})).inSingletonScope(),W_.bind(Un.Engine).to(tw).inSingletonScope(),W_.bind(Un.PeerTrackFactory).toFactory((function(e){const t=e.container.get(Un.LoggerFactory),r=e.container.get(Un.CallState),n=e.container.get(Un.StatsHandler);return i=>{const s={callState:r,loggerFactory:t,media:e.container.get(Un.Media),network:e.container.get(Un.Network),peerConsumerFactory:e.container.get(Un.PeerConsumerFactory),socket:e.container.get(Un.SocketIO)},{peerEventEmitter:o}=i,a=new j_(Object.assign(Object.assign(Object.assign({},i),s),{statsHandler:n}));return o.safeEmit(Zr,a),a}})),W_.bind(Un.PeerFactory).toFactory((function(e){const t=e.container.get(Un.LoggerFactory),r=e.container.get(Un.CallState);return n=>{const i={callState:r,loggerFactory:t,media:e.container.get(Un.Media),myPeer:e.container.get(Un.MyPeer),network:e.container.get(Un.Network),peers:e.container.get(Un.Peers),remotePeerTracks:e.container.get(Un.RemotePeerTracks),socket:e.container.get(Un.SocketIO),peerConsumerFactory:e.container.get(Un.PeerConsumerFactory)};return new N_(Object.assign(Object.assign({},i),n))}})),W_.bind(Un.PeerConsumerFactory).toFactory((function(e){const t=e.container.get(Un.LoggerFactory);return e=>{const r={loggerFactory:t};return new B_(Object.assign(Object.assign({},r),e))}})),W_.bind(Un.AudioTrackFactory).toFactory((function(e){const t=e.container.get(Un.LoggerFactory),r=e.container.get(Un.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(Un.InternalEventEmitter),loggerFactory:t,media:e.container.get(Un.Media),mediaStreamTrackManager:e.container.get(Un.MediaStreamTrackManager),myPeer:e.container.get(Un.MyPeer),network:e.container.get(Un.Network),socket:e.container.get(Un.SocketIO),statsHandler:r};return new L_(Object.assign(Object.assign({},i),n))}})),W_.bind(Un.VideoTrackFactory).toFactory((function(e){const t=e.container.get(Un.LoggerFactory),r=e.container.get(Un.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(Un.InternalEventEmitter),loggerFactory:t,media:e.container.get(Un.Media),mediaStreamTrackManager:e.container.get(Un.MediaStreamTrackManager),myPeer:e.container.get(Un.MyPeer),network:e.container.get(Un.Network),socket:e.container.get(Un.SocketIO),statsHandler:r};return new Cf(Object.assign(Object.assign({},i),n))}})),W_.bind(Un.DataChannelsManager).to(Xb).inSingletonScope();class U_{constructor(e){q_.set(this,void 0);const{clientEventEmitter:t,internalEventEmitter:r}=e;W_.bind(Un.Config).toDynamicValue((()=>new wt(e))).inSingletonScope(),W_.bind(Un.InternalEventEmitter).toDynamicValue((()=>null!=r?r:new _t)).inSingletonScope(),W_.bind(Un.ClientEventEmitter).toDynamicValue((()=>null!=t?t:new _t)).inSingletonScope(),this.clientEventEmitter=W_.get(Un.ClientEventEmitter),c(this,q_,W_.get(Un.Engine),"f")}get observer(){return this.clientEventEmitter}get id(){return a(this,q_,"f").myPeerId}get peers(){return a(this,q_,"f").getPeers()}get availableVideoDevices(){return a(this,q_,"f").system.availableVideoDevices}get availableAudioDevices(){return a(this,q_,"f").system.availableAudioDevices}get canUseNoiseSuppression(){return a(this,q_,"f").canUseNoiseSuppression}get effectsSDKInitialized(){return a(this,q_,"f").media.effectsSDKInitialized}detectDevices(e){return o(this,void 0,void 0,(function*(){return yield a(this,q_,"f").system.detectDevices(e),{video:a(this,q_,"f").system.availableVideoDevices,audio:a(this,q_,"f").system.availableAudioDevices}}))}initEffectsSDK(){return a(this,q_,"f").media.initEffectsSDK()}join(e){return a(this,q_,"f").join(e)}leave(e){return a(this,q_,"f").release(e)}confirmActivity(){return a(this,q_,"f").confirmActivity()}createCameraVideoTrack(e){return a(this,q_,"f").createCameraVideoTrack(e)}createMicrophoneAudioTrack(e){return a(this,q_,"f").createMicrophoneAudioTrack(e)}createScreenMediaTracks(e){return a(this,q_,"f").createScreenMediaTracks(e)}deleteTrack(e){return a(this,q_,"f").deleteTrack(e)}loadPeers(e){return a(this,q_,"f").loadPeers(e)}updateAppData(e){return a(this,q_,"f").updateAppData(e)}getTransportsInfo(){return o(this,void 0,void 0,(function*(){return a(this,q_,"f").network.getTransportsStateInfo()}))}getNodeActiveStreamsStat(){return a(this,q_,"f").getNodeActiveStreamsStat()}setPreferRelay(e){a(this,q_,"f").network.setPreferRelay(e)}getPreferRelay(){return a(this,q_,"f").network.getPreferRelay()}transportsStats(){return a(this,q_,"f").transportsStats()}getAvgTracksScore(e){return a(this,q_,"f").getAvgTracksScore(e)}}q_=new WeakMap;export{U_ as default};
|