@livedigital/client 3.49.3 → 3.49.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
26
26
|
|
|
27
27
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
28
28
|
and limitations under the License.
|
|
29
|
-
***************************************************************************** */!function(e){!function(t){var r="object"==typeof globalThis?globalThis:"object"==typeof l?l:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),n=i(e);function i(e,t){return function(r,n){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0!==r.Reflect&&(n=i(r.Reflect,n)),function(e,t){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,i=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",s=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",o="function"==typeof Object.create,a={__proto__:[]}instanceof Array,c=!o&&!a,d={create:o?function(){return le(Object.create(null))}:a?function(){return le({__proto__:null})}:function(){return le({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),l="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),p="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:de(),h="function"==typeof WeakMap?WeakMap:ue(),f=n?Symbol.for("@reflect-metadata:registry"):void 0,m=ie(),g=se(m);function v(e,t,r,n){if(F(r)){if(!G(e))throw new TypeError;if(!$(t))throw new TypeError;return R(e,t)}if(!G(e))throw new TypeError;if(!V(t))throw new TypeError;if(!V(n)&&!F(n)&&!j(n))throw new TypeError;return j(n)&&(n=void 0),k(e,t,r=z(r),n)}function y(e,t){function r(r,n){if(!V(r))throw new TypeError;if(!F(n)&&!J(n))throw new TypeError;N(e,t,r,n)}return r}function _(e,t,r,n){if(!V(r))throw new TypeError;return F(n)||(n=z(n)),N(e,t,r,n)}function b(e,t,r){if(!V(t))throw new TypeError;return F(r)||(r=z(r)),D(e,t,r)}function E(e,t,r){if(!V(t))throw new TypeError;return F(r)||(r=z(r)),I(e,t,r)}function w(e,t,r){if(!V(t))throw new TypeError;return F(r)||(r=z(r)),A(e,t,r)}function S(e,t,r){if(!V(t))throw new TypeError;return F(r)||(r=z(r)),O(e,t,r)}function C(e,t){if(!V(e))throw new TypeError;return F(t)||(t=z(t)),M(e,t)}function P(e,t){if(!V(e))throw new TypeError;return F(t)||(t=z(t)),L(e,t)}function T(e,t,r){if(!V(t))throw new TypeError;if(F(r)||(r=z(r)),!V(t))throw new TypeError;F(r)||(r=z(r));var n=ae(t,r,!1);return!F(n)&&n.OrdinaryDeleteMetadata(e,t,r)}function R(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!F(n)&&!j(n)){if(!$(n))throw new TypeError;t=n}}return t}function k(e,t,r,n){for(var i=e.length-1;i>=0;--i){var s=(0,e[i])(t,r,n);if(!F(s)&&!j(s)){if(!V(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!j(n)&&D(e,n,r)}function I(e,t,r){var n=ae(t,r,!1);return!F(n)&&H(n.OrdinaryHasOwnMetadata(e,t,r))}function A(e,t,r){if(I(e,t,r))return O(e,t,r);var n=re(t);return j(n)?void 0:A(e,n,r)}function O(e,t,r){var n=ae(t,r,!1);if(!F(n))return n.OrdinaryGetOwnMetadata(e,t,r)}function N(e,t,r,n){ae(r,n,!0).OrdinaryDefineOwnMetadata(e,t,r,n)}function M(e,t){var r=L(e,t),n=re(e);if(null===n)return r;var i=M(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 L(e,t){var r=ae(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function x(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 j(e){return null===e}function U(e){return"symbol"==typeof e}function V(e){return"object"==typeof e?null!==e:"function"==typeof e}function B(e,t){switch(x(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=Q(e,i);if(void 0!==n){var s=n.call(e,r);if(V(s))throw new TypeError;return s}return W(e,"default"===r?"number":r)}function W(e,t){if("string"===t){var r=e.toString;if(Y(r))if(!V(i=r.call(e)))return i;if(Y(n=e.valueOf))if(!V(i=n.call(e)))return i}else{var n;if(Y(n=e.valueOf))if(!V(i=n.call(e)))return i;var i,s=e.toString;if(Y(s))if(!V(i=s.call(e)))return i}throw new TypeError}function H(e){return!!e}function q(e){return""+e}function z(e){var t=B(e,3);return U(t)?t:q(t)}function G(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function Y(e){return"function"==typeof e}function $(e){return"function"==typeof e}function J(e){switch(x(e)){case 3:case 4:return!0;default:return!1}}function K(e,t){return e===t||e!=e&&t!=t}function Q(e,t){var r=e[t];if(null!=r){if(!Y(r))throw new TypeError;return r}}function Z(e){var t=Q(e,s);if(!Y(t))throw new TypeError;var r=t.call(e);if(!V(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)&&V(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[f]),F(e)&&(e=ne()),!F(f)&&V(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)&&H(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--,K(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(!K(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(K(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(){return 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}()}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",_),e("hasMetadata",b),e("hasOwnMetadata",E),e("getMetadata",w),e("getOwnMetadata",S),e("getMetadataKeys",C),e("getOwnMetadataKeys",P),e("deleteMetadata",T)}(n,r),void 0===r.Reflect&&(r.Reflect=e)}()}(u||(u={}));var f=["inject","multi_inject","name","unmanaged","named","optional"],m="Request",g="Singleton",v="Transient",y="ConstantValue",_="Constructor",b="DynamicValue",E="Factory",w="Function",S="Instance",C="Invalid",P="Provider",T="ClassProperty",R="ConstructorArgument",k="Variable",D=0;function I(){return D++}var A=function(){function e(e,t){this.id=I(),this.activated=!1,this.serviceIdentifier=e,this.scope=t,this.type=C,this.constraint=function(e){return!0},this.implementationType=null,this.cache=null,this.factory=null,this.provider=null,this.onActivation=null,this.onDeactivation=null,this.dynamicValue=null}return e.prototype.clone=function(){var t=new e(this.serviceIdentifier,this.scope);return t.activated=t.scope===g&&this.activated,t.implementationType=this.implementationType,t.dynamicValue=this.dynamicValue,t.scope=this.scope,t.type=this.type,t.factory=this.factory,t.provider=this.provider,t.constraint=this.constraint,t.onActivation=this.onActivation,t.onDeactivation=this.onDeactivation,t.cache=this.cache,t},e}(),O="No matching bindings found for serviceIdentifier:",N="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.",M=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}(),x=0,F=1;function j(e){return e instanceof RangeError||"Maximum call stack size exceeded"===e.message}function U(e){return"function"==typeof e?e.name:"symbol"==typeof e?e.toString():e}function V(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=H(e.implementationType)),n=n+"\n "+t,e.constraint.metaData&&(n=n+" - "+e.constraint.metaData)}))),n}function B(e,t){return null!==e.parentRequest&&(e.parentRequest.serviceIdentifier===t||B(e.parentRequest,t))}function W(e){e.childRequests.forEach((function(e){if(B(e,e.serviceIdentifier)){var t=function(e){return function e(t,r){void 0===r&&(r=[]);var n=U(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)}W(e)}))}function H(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 q=function(){function e(e){this.id=I(),this.container=e}return e.prototype.addPlan=function(e){this.plan=e},e.prototype.setCurrentRequest=function(e){this.currentRequest=e},e}(),z=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}(),G=function(e,t){this.parentContext=e,this.rootRequest=t},Y=function(){function e(e){this._cb=e}return e.prototype.unwrap=function(){return this._cb()},e}(),$=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}(),J=function(){function e(e,t,r,n){this.id=I(),this.type=e,this.serviceIdentifier=r;var i="symbol"==typeof t?function(e){return e.toString().slice(7,-1)}(t):t;this.name=new $(i||""),this.identifier=t,this.metadata=new Array;var s=null;"string"==typeof n?s=new z("named",n):n instanceof z&&(s=n),null!==s&&this.metadata.push(s)}return e.prototype.hasTag=function(e){for(var t=0,r=this.metadata;t<r.length;t++){if(r[t].key===e)return!0}return!1},e.prototype.isArray=function(){return this.hasTag("multi_inject")},e.prototype.matchesArray=function(e){return this.matchesTag("multi_inject")(e)},e.prototype.isNamed=function(){return this.hasTag("named")},e.prototype.isTagged=function(){return this.metadata.some((function(e){return f.every((function(t){return e.key!==t}))}))},e.prototype.isOptional=function(){return this.matchesTag("optional")(!0)},e.prototype.getNamedTag=function(){return this.isNamed()?this.metadata.filter((function(e){return"named"===e.key}))[0]:null},e.prototype.getCustomTags=function(){return this.isTagged()?this.metadata.filter((function(e){return f.every((function(t){return e.key!==t}))})):null},e.prototype.matchesNamedTag=function(e){return this.matchesTag("named")(e)},e.prototype.matchesTag=function(e){var t=this;return function(r){for(var n=0,i=t.metadata;n<i.length;n++){var s=i[n];if(s.key===e&&s.value===r)return!0}return!1}},e}(),K=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=Z(o,e,t,r,n);null!==a&&s.push(a)}return s}(n,t,s,o,c||d?a.length:r.length),l=ee(e,r,t);return K(K([],u,!0),l,!0)}function Z(e,t,r,n,i){var s=i[e.toString()]||[],o=re(s),a=!0!==o.unmanaged,c=n[e],d=o.inject||o.multiInject;if((c=d||c)instanceof Y&&(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 J(R,o.targetName,c);return u.metadata=s,u}return null}function X(e,t,r,n){var i=e||t;if(void 0===i){var s="Missing required @injectable annotation in: for property "+String(r)+" in class "+n+".";throw new Error(s)}return i}function ee(e,t,r){for(var n=e.getPropertiesMetadata(t),i=[],s=Object.getOwnPropertySymbols(n),o=0,a=Object.keys(n).concat(s);o<a.length;o++){var c=a[o],d=n[c],u=re(d),l=u.targetName||c,p=X(u.inject,u.multiInject,c,r),h=new J(T,l,p);h.metadata=d,i.push(h)}var f=Object.getPrototypeOf(t.prototype).constructor;if(f!==Object){var m=ee(e,f,r);i=K(K([],i,!0),m,!0)}return i}function te(e,t){var r=Object.getPrototypeOf(t.prototype).constructor;if(r!==Object){var n=Q(e,H(r),r,!0),i=n.map((function(e){return e.metadata.filter((function(e){return"unmanaged"===e.key}))})),s=[].concat.apply([],i).length,o=n.length-s;return o>0?o:te(e,r)}return 0}function re(e){var t={};return e.forEach((function(e){t[e.key.toString()]=e.value})),{inject:t.inject,multiInject:t.multi_inject,targetName:t.name,unmanaged:t.unmanaged}}var ne=function(){function e(e,t,r,n,i){this.id=I(),this.serviceIdentifier=e,this.parentContext=t,this.parentRequest=r,this.target=i,this.childRequests=[],this.bindings=Array.isArray(n)?n:[n],this.requestScope=null===r?new Map:null}return e.prototype.addChildRequest=function(t,r,n){var i=new e(t,this.parentContext,this,r,n);return this.childRequests.push(i),i},e}();function ie(e){return e._bindingDictionary}function se(e,t,r,n,i){var s=ae(r.container,i.serviceIdentifier),o=[];return s.length===x&&r.container.options.autoBindInjectable&&"function"==typeof i.serviceIdentifier&&e.getConstructorMetadata(i.serviceIdentifier).compilerGeneratedMetadata&&(r.container.bind(i.serviceIdentifier).toSelf(),s=ae(r.container,i.serviceIdentifier)),o=t?s:s.filter((function(e){var t=new ne(e.serviceIdentifier,r,n,e,i);return e.constraint(t)})),function(e,t,r,n){switch(t.length){case x:if(r.isOptional())return t;var i=U(e),s=O;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+=V(n,i,ae),new Error(s);case F:return t;default:if(r.isArray())return t;s="Ambiguous match found for serviceIdentifier: "+(i=U(e));throw s+=V(n,i,ae),new Error(s)}}(i.serviceIdentifier,o,i,r.container),o}function oe(e,t,r,n,i,s){var o,a;if(null===i){o=se(e,t,n,null,s),a=new ne(r,n,null,o,s);var c=new G(n,a);n.addPlan(c)}else o=se(e,t,n,i,s),a=i.addChildRequest(s.serviceIdentifier,o,s);o.forEach((function(t){var r=null;if(s.isArray())r=a.addChildRequest(t.serviceIdentifier,t,s);else{if(t.cache)return;r=a}if(t.type===S&&null!==t.implementationType){var i=function(e,t){return Q(e,H(t),t,!1)}(e,t.implementationType);if(!n.container.options.skipBaseClassChecks){var o=te(e,t.implementationType);if(i.length<o){var c=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"The number of constructor arguments in the derived class "+e[0]+" must be >= than the number of constructor arguments of its base class."}(H(t.implementationType));throw new Error(c)}}i.forEach((function(t){oe(e,!1,t.serviceIdentifier,n,r,t)}))}}))}function ae(e,t){var r=[],n=ie(e);return n.hasKey(t)?r=n.get(t):null!==e.parent&&(r=ae(e.parent,t)),r}function ce(e,t,r,n,i,s,o,a){void 0===a&&(a=!1);var c=new q(t),d=function(e,t,r,n,i,s){var o=new z(e?"multi_inject":"inject",r),a=new J(t,n,r,o);if(void 0!==i){var c=new z(i,s);a.metadata.push(c)}return a}(r,n,i,"",s,o);try{return oe(e,a,i,c,null,d),c}catch(e){throw j(e)&&W(c.plan.rootRequest),e}}function de(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then}function ue(e){return!!de(e)||Array.isArray(e)&&e.some(de)}var le,pe=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},he=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},fe=function(e,t,r){e.has(t.id)||e.set(t.id,r)},me=function(e,t){e.cache=t,e.activated=!0,de(t)&&ge(e,t)},ge=function(e,t){return pe(void 0,void 0,void 0,(function(){var r,n;return he(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t];case 1:return r=i.sent(),e.cache=r,[3,3];case 2:throw n=i.sent(),e.cache=null,e.activated=!1,n;case 3:return[2]}}))}))};!function(e){e.DynamicValue="toDynamicValue",e.Factory="toFactory",e.Provider="toProvider"}(le||(le={}));var ve=function(){return ve=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ve.apply(this,arguments)},ye=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},_e=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 Ee(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===R?e.constructorInjections.push(n):(e.propertyRequests.push(r),e.propertyInjections.push(n)),e.isAsync||(e.isAsync=ue(n)),e}),{constructorInjections:[],propertyInjections:[],propertyRequests:[],isAsync:!1})}(t,r),s=ve(ve({},i),{constr:e});n=i.isAsync?function(e){return ye(this,void 0,void 0,(function(){var t,r;return _e(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,we(ve(ve({},e),{constructorInjections:t,propertyInjections:r}))]}}))}))}(s):we(s)}else n=new e;return n}function we(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 ye(this,void 0,void 0,(function(){var t,r,n,i;return _e(this,(function(s){for(t=[],r=0,n=e;r<n.length;r++)i=n[r],Array.isArray(i)?t.push(Promise.all(i)):t.push(i);return[2,Promise.all(t)]}))}))}function Ce(e,t){var r=function(e,t){var r,n;if(Reflect.hasMetadata("post_construct",e)){var i=Reflect.getMetadata("post_construct",e);try{return null===(n=(r=t)[i.value])||void 0===n?void 0:n.call(r)}catch(t){if(t instanceof Error)throw new Error((s=e.name,o=t.message,"@postConstruct error in class "+s+": "+o))}}var s,o}(e,t);return de(r)?r.then((function(){return t})):t}function Pe(e,t){e.scope!==g&&function(e,t){var r="Class cannot be instantiated in "+(e.scope===m?"request":"transient")+" scope.";if("function"==typeof e.onDeactivation)throw new Error(M(t.name,r));if(Reflect.hasMetadata("pre_destroy",t))throw new Error("@preDestroy error in class "+t.name+": "+r)}(e,t)}var Te=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){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},Re=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])}}},ke=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 ke(e)(t)}));if(!t.target.isOptional()||0!==r.length){var o=r[0];return Oe(e,t,o)}}},De=function(e,t){var r=function(e){switch(e.type){case E:return{factory:e.factory,factoryType:le.Factory};case P:return{factory:e.provider,factoryType:le.Provider};case b:return{factory:e.dynamicValue,factoryType:le.DynamicValue};default:throw new Error("Unexpected factory type "+e.type)}}(e);return function(e,t){try{return e()}catch(e){throw j(e)&&(e=t()),e}}((function(){return r.factory.bind(e)(t)}),(function(){return new Error((e=r.factoryType,n=t.currentRequest.serviceIdentifier.toString(),"It looks like there is a circular dependency in one of the '"+e+"' bindings. Please investigate bindings with service identifier '"+n+"'."));var e,n}))},Ie=function(e,t,r){var n,i=t.childRequests;switch(function(e){var t=null;switch(e.type){case y:case w:t=e.cache;break;case _:case S:t=e.implementationType;break;case b:t=e.dynamicValue;break;case P:t=e.provider;break;case E:t=e.factory}if(null===t){var r=U(e.serviceIdentifier);throw new Error("Invalid binding type: "+r)}}(r),r.type){case y:case w:n=r.cache;break;case _:n=r.implementationType;break;case S:n=function(e,t,r,n){Pe(e,t);var i=Ee(t,r,n);return de(i)?i.then((function(e){return Ce(t,e)})):Ce(t,i)}(r,r.implementationType,i,ke(e));break;default:n=De(r,t.parentContext)}return n},Ae=function(e,t,r){var n=function(e,t){return t.scope===g&&t.activated?t.cache:t.scope===m&&e.has(t.id)?e.get(t.id):null}(e,t);return null!==n||function(e,t,r){t.scope===g&&me(t,r),t.scope===m&&fe(e,t,r)}(e,t,n=r()),n},Oe=function(e,t,r){return Ae(e,r,(function(){var n=Ie(e,t,r);return n=de(n)?n.then((function(e){return Ne(t,r,e)})):Ne(t,r,n)}))};function Ne(e,t,r){var n,i=Me(e.parentContext,t,r),s=je(e.parentContext.container),o=s.next();do{n=o.value;var a=e.parentContext,c=e.serviceIdentifier,d=Fe(n,c);i=de(i)?xe(d,a,i):Le(d,a,i),o=s.next()}while(!0!==o.done&&!ie(n).hasKey(e.serviceIdentifier));return i}var Me=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(de(r=n.value(t,r)))return xe(e,t,r);n=e.next()}return r},xe=function(e,t,r){return Te(void 0,void 0,void 0,(function(){var n,i;return Re(this,(function(s){switch(s.label){case 0:return[4,r];case 1:n=s.sent(),i=e.next(),s.label=2;case 2:return i.done?[3,4]:[4,i.value(t,n)];case 3:return n=s.sent(),i=e.next(),[3,2];case 4:return[2,n]}}))}))},Fe=function(e,t){var r=e._activations;return r.hasKey(t)?r.get(t).values():[].values()},je=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 Ue=function(e,t){var r=e.parentRequest;return null!==r&&(!!t(r)||Ue(r,t))},Ve=function(e){return function(t){var r=function(r){return null!==r&&null!==r.target&&r.target.matchesTag(e)(t)};return r.metaData=new z(e,t),r}},Be=Ve("named"),We=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}},He=function(){function e(e){this._binding=e}return e.prototype.when=function(e){return this._binding.constraint=e,new qe(this._binding)},e.prototype.whenTargetNamed=function(e){return this._binding.constraint=Be(e),new qe(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 qe(this._binding)},e.prototype.whenTargetTagged=function(e,t){return this._binding.constraint=Ve(e)(t),new qe(this._binding)},e.prototype.whenInjectedInto=function(e){return this._binding.constraint=function(t){return null!==t&&We(e)(t.parentRequest)},new qe(this._binding)},e.prototype.whenParentNamed=function(e){return this._binding.constraint=function(t){return null!==t&&Be(e)(t.parentRequest)},new qe(this._binding)},e.prototype.whenParentTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&Ve(e)(t)(r.parentRequest)},new qe(this._binding)},e.prototype.whenAnyAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&Ue(t,We(e))},new qe(this._binding)},e.prototype.whenNoAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&!Ue(t,We(e))},new qe(this._binding)},e.prototype.whenAnyAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&Ue(t,Be(e))},new qe(this._binding)},e.prototype.whenNoAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&!Ue(t,Be(e))},new qe(this._binding)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&Ue(r,Ve(e)(t))},new qe(this._binding)},e.prototype.whenNoAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&!Ue(r,Ve(e)(t))},new qe(this._binding)},e.prototype.whenAnyAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&Ue(t,e)},new qe(this._binding)},e.prototype.whenNoAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&!Ue(t,e)},new qe(this._binding)},e}(),qe=function(){function e(e){this._binding=e}return e.prototype.onActivation=function(e){return this._binding.onActivation=e,new He(this._binding)},e.prototype.onDeactivation=function(e){return this._binding.onDeactivation=e,new He(this._binding)},e}(),ze=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new He(this._binding),this._bindingOnSyntax=new qe(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}(),Ge=function(){function e(e){this._binding=e}return e.prototype.inRequestScope=function(){return this._binding.scope=m,new ze(this._binding)},e.prototype.inSingletonScope=function(){return this._binding.scope=g,new ze(this._binding)},e.prototype.inTransientScope=function(){return this._binding.scope=v,new ze(this._binding)},e}(),Ye=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new He(this._binding),this._bindingOnSyntax=new qe(this._binding),this._bindingInSyntax=new Ge(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}(),$e=function(){function e(e){this._binding=e}return e.prototype.to=function(e){return this._binding.type=S,this._binding.implementationType=e,new Ye(this._binding)},e.prototype.toSelf=function(){if("function"!=typeof this._binding.serviceIdentifier)throw new Error("The toSelf function can only be applied when a constructor is used as service identifier");var e=this._binding.serviceIdentifier;return this.to(e)},e.prototype.toConstantValue=function(e){return this._binding.type=y,this._binding.cache=e,this._binding.dynamicValue=null,this._binding.implementationType=null,this._binding.scope=g,new ze(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 Ye(this._binding)},e.prototype.toConstructor=function(e){return this._binding.type=_,this._binding.implementationType=e,this._binding.scope=g,new ze(this._binding)},e.prototype.toFactory=function(e){return this._binding.type=E,this._binding.factory=e,this._binding.scope=g,new ze(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=w,this._binding.scope=g,t},e.prototype.toAutoFactory=function(e){return this._binding.type=E,this._binding.factory=function(t){return function(){return t.container.get(e)}},this._binding.scope=g,new ze(this._binding)},e.prototype.toAutoNamedFactory=function(e){return this._binding.type=E,this._binding.factory=function(t){return function(r){return t.container.getNamed(e,r)}},new ze(this._binding)},e.prototype.toProvider=function(e){return this._binding.type=P,this._binding.provider=e,this._binding.scope=g,new ze(this._binding)},e.prototype.toService=function(e){this.toDynamicValue((function(t){return t.container.get(e)}))},e}(),Je=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 Ke=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 Ke,onDeactivations:new Ke}},e}(),Ze=function(){return Ze=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ze.apply(this,arguments)},Xe=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},et=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},tt=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},rt=function(){function e(e){var t=e||{};if("object"!=typeof t)throw new Error("Invalid Container constructor argument. Container options must be an object.");if(void 0===t.defaultScope)t.defaultScope=v;else if(t.defaultScope!==g&&t.defaultScope!==v&&t.defaultScope!==m)throw new Error('Invalid Container option. Default scope must be a string ("singleton" or "transient").');if(void 0===t.autoBindInjectable)t.autoBindInjectable=!1;else if("boolean"!=typeof t.autoBindInjectable)throw new Error("Invalid Container option. Auto bind injectable must be a boolean");if(void 0===t.skipBaseClassChecks)t.skipBaseClassChecks=!1;else if("boolean"!=typeof t.skipBaseClassChecks)throw new Error("Invalid Container option. Skip base check must be a boolean");this.options={autoBindInjectable:t.autoBindInjectable,defaultScope:t.defaultScope,skipBaseClassChecks:t.skipBaseClassChecks},this.id=I(),this._bindingDictionary=new Ke,this._snapshots=[],this._middleware=null,this._activations=new Ke,this._deactivations=new Ke,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=tt([t,r],n,!0).map((function(e){return ie(e)})),a=ie(s);function c(e,t){e.traverse((function(e,r){r.forEach((function(e){t.add(e.serviceIdentifier,e.clone())}))}))}return o.forEach((function(e){c(e,a)})),s},e.prototype.load=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=this._getContainerModuleHelpersFactory(),n=0,i=e;n<i.length;n++){var s=i[n],o=r(s.id);s.registry(o.bindFunction,o.unbindFunction,o.isboundFunction,o.rebindFunction,o.unbindAsyncFunction,o.onActivationFunction,o.onDeactivationFunction)}},e.prototype.loadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Xe(this,void 0,void 0,(function(){var t,r,n,i,s;return et(this,(function(o){switch(o.label){case 0:t=this._getContainerModuleHelpersFactory(),r=0,n=e,o.label=1;case 1:return r<n.length?(i=n[r],s=t(i.id),[4,i.registry(s.bindFunction,s.unbindFunction,s.isboundFunction,s.rebindFunction,s.unbindAsyncFunction,s.onActivationFunction,s.onDeactivationFunction)]):[3,4];case 2:o.sent(),o.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}))},e.prototype.unload=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];t.forEach((function(t){var r=e._removeModuleBindings(t.id);e._deactivateSingletons(r),e._removeModuleHandlers(t.id)}))},e.prototype.unloadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Xe(this,void 0,void 0,(function(){var t,r,n,i;return et(this,(function(s){switch(s.label){case 0:t=0,r=e,s.label=1;case 1:return t<r.length?(n=r[t],i=this._removeModuleBindings(n.id),[4,this._deactivateSingletonsAsync(i)]):[3,4];case 2:s.sent(),this._removeModuleHandlers(n.id),s.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},e.prototype.bind=function(e){var t=this.options.defaultScope||v,r=new A(e,t);return this._bindingDictionary.add(e,r),new $e(r)},e.prototype.rebind=function(e){return this.unbind(e),this.bind(e)},e.prototype.rebindAsync=function(e){return Xe(this,void 0,void 0,(function(){return et(this,(function(t){switch(t.label){case 0:return[4,this.unbindAsync(e)];case 1:return t.sent(),[2,this.bind(e)]}}))}))},e.prototype.unbind=function(e){if(this._bindingDictionary.hasKey(e)){var t=this._bindingDictionary.get(e);this._deactivateSingletons(t)}this._removeServiceFromDictionary(e)},e.prototype.unbindAsync=function(e){return Xe(this,void 0,void 0,(function(){var t;return et(this,(function(r){switch(r.label){case 0:return this._bindingDictionary.hasKey(e)?(t=this._bindingDictionary.get(e),[4,this._deactivateSingletonsAsync(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return this._removeServiceFromDictionary(e),[2]}}))}))},e.prototype.unbindAll=function(){var e=this;this._bindingDictionary.traverse((function(t,r){e._deactivateSingletons(r)})),this._bindingDictionary=new Ke},e.prototype.unbindAllAsync=function(){return Xe(this,void 0,void 0,(function(){var e,t=this;return et(this,(function(r){switch(r.label){case 0:return e=[],this._bindingDictionary.traverse((function(r,n){e.push(t._deactivateSingletonsAsync(n))})),[4,Promise.all(e)];case 1:return r.sent(),this._bindingDictionary=new Ke,[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 J(k,"",t,new z(r,n)),s=new q(e);return new ne(t,s,null,[],i)}(this,e,t,r);n=i.some((function(e){return e.constraint(s)}))}return!n&&this.parent&&(n=this.parent.isBoundTagged(e,t,r)),n},e.prototype.snapshot=function(){this._snapshots.push(Je.of(this._bindingDictionary.clone(),this._middleware,this._activations.clone(),this._deactivations.clone(),this._moduleActivationStore.clone()))},e.prototype.restore=function(){var e=this._snapshots.pop();if(void 0===e)throw new Error("No snapshot available to restore.");this._bindingDictionary=e.bindings,this._activations=e.activations,this._deactivations=e.deactivations,this._middleware=e.middleware,this._moduleActivationStore=e.moduleActivationStore},e.prototype.createChild=function(t){var r=new e(t||this.options);return r.parent=this,r},e.prototype.applyMiddleware=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=this._middleware?this._middleware:this._planAndResolve();this._middleware=e.reduce((function(e,t){return t(e)}),r)},e.prototype.applyCustomMetadataReader=function(e){this._metadataReader=e},e.prototype.get=function(e){var t=this._getNotAllArgs(e,!1);return this._getButThrowIfAsync(t)},e.prototype.getAsync=function(e){return Xe(this,void 0,void 0,(function(){var t;return et(this,(function(r){return t=this._getNotAllArgs(e,!1),[2,this._get(t)]}))}))},e.prototype.getTagged=function(e,t,r){var n=this._getNotAllArgs(e,!1,t,r);return this._getButThrowIfAsync(n)},e.prototype.getTaggedAsync=function(e,t,r){return Xe(this,void 0,void 0,(function(){var n;return et(this,(function(i){return n=this._getNotAllArgs(e,!1,t,r),[2,this._get(n)]}))}))},e.prototype.getNamed=function(e,t){return this.getTagged(e,"named",t)},e.prototype.getNamedAsync=function(e,t){return this.getTaggedAsync(e,"named",t)},e.prototype.getAll=function(e){var t=this._getAllArgs(e);return this._getButThrowIfAsync(t)},e.prototype.getAllAsync=function(e){var t=this._getAllArgs(e);return this._getAll(t)},e.prototype.getAllTagged=function(e,t,r){var n=this._getNotAllArgs(e,!0,t,r);return this._getButThrowIfAsync(n)},e.prototype.getAllTaggedAsync=function(e,t,r){var n=this._getNotAllArgs(e,!0,t,r);return this._getAll(n)},e.prototype.getAllNamed=function(e,t){return this.getAllTagged(e,"named",t)},e.prototype.getAllNamedAsync=function(e,t){return this.getAllTaggedAsync(e,"named",t)},e.prototype.resolve=function(e){var t=this.isBound(e);t||this.bind(e).toSelf();var r=this.get(e);return t||this.unbind(e),r},e.prototype._preDestroy=function(e,t){var r,n;if(Reflect.hasMetadata("pre_destroy",e))return null===(n=(r=t)[Reflect.getMetadata("pre_destroy",e).value])||void 0===n?void 0:n.call(r)},e.prototype._removeModuleHandlers=function(e){var t=this._moduleActivationStore.remove(e);this._activations.removeIntersection(t.onActivations),this._deactivations.removeIntersection(t.onDeactivations)},e.prototype._removeModuleBindings=function(e){return this._bindingDictionary.removeByCondition((function(t){return t.moduleId===e}))},e.prototype._deactivate=function(e,t){var r=this,n=Object.getPrototypeOf(t).constructor;try{if(this._deactivations.hasKey(e.serviceIdentifier)){var i=this._deactivateContainer(t,this._deactivations.get(e.serviceIdentifier).values());if(de(i))return this._handleDeactivationError(i.then((function(){return r._propagateContainerDeactivationThenBindingAndPreDestroyAsync(e,t,n)})),n)}var s=this._propagateContainerDeactivationThenBindingAndPreDestroy(e,t,n);if(de(s))return this._handleDeactivationError(s,n)}catch(e){if(e instanceof Error)throw new Error(M(n.name,e.message))}},e.prototype._handleDeactivationError=function(e,t){return Xe(this,void 0,void 0,(function(){var r;return et(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e];case 1:return n.sent(),[3,3];case 2:if((r=n.sent())instanceof Error)throw new Error(M(t.name,r.message));return[3,3];case 3:return[2]}}))}))},e.prototype._deactivateContainer=function(e,t){for(var r=this,n=t.next();n.value;){var i=n.value(e);if(de(i))return i.then((function(){return r._deactivateContainerAsync(e,t)}));n=t.next()}},e.prototype._deactivateContainerAsync=function(e,t){return Xe(this,void 0,void 0,(function(){var r;return et(this,(function(n){switch(n.label){case 0:r=t.next(),n.label=1;case 1:return r.value?[4,r.value(e)]:[3,3];case 2:return n.sent(),r=t.next(),[3,1];case 3:return[2]}}))}))},e.prototype._getContainerModuleHelpersFactory=function(){var e=this,t=function(e,t){e._binding.moduleId=t},r=function(r){return function(n){var i=e.rebind(n);return t(i,r),i}},n=function(t){return function(r,n){e._moduleActivationStore.addActivation(t,r,n),e.onActivation(r,n)}},i=function(t){return function(r,n){e._moduleActivationStore.addDeactivation(t,r,n),e.onDeactivation(r,n)}};return function(s){return{bindFunction:(o=s,function(r){var n=e.bind(r);return t(n,o),n}),isboundFunction:function(t){return e.isBound(t)},onActivationFunction:n(s),onDeactivationFunction:i(s),rebindFunction:r(s),unbindFunction:function(t){return e.unbind(t)},unbindAsyncFunction:function(t){return e.unbindAsync(t)}};var o}},e.prototype._getAll=function(e){return Promise.all(this._get(e))},e.prototype._get=function(e){var t=Ze(Ze({},e),{contextInterceptor:function(e){return e},targetType:k});if(this._middleware){var r=this._middleware(t);if(null==r)throw new Error("Invalid return type in middleware. Middleware must return!");return r}return this._planAndResolve()(t)},e.prototype._getButThrowIfAsync=function(e){var t=this._get(e);if(ue(t))throw new Error("You are attempting to construct '"+e.serviceIdentifier+"' in a synchronous way\n but it has asynchronous dependencies.");return t},e.prototype._getAllArgs=function(e){return{avoidConstraints:!0,isMultiInject:!0,serviceIdentifier:e}},e.prototype._getNotAllArgs=function(e,t,r,n){return{avoidConstraints:!1,isMultiInject:t,serviceIdentifier:e,key:r,value:n}},e.prototype._planAndResolve=function(){var e=this;return function(t){var r=ce(e._metadataReader,e,t.isMultiInject,t.targetType,t.serviceIdentifier,t.key,t.value,t.avoidConstraints);return function(e){return ke(e.plan.rootRequest.requestScope)(e.plan.rootRequest)}(r=t.contextInterceptor(r))}},e.prototype._deactivateIfSingleton=function(e){var t=this;if(e.activated)return de(e.cache)?e.cache.then((function(r){return t._deactivate(e,r)})):this._deactivate(e,e.cache)},e.prototype._deactivateSingletons=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(de(this._deactivateIfSingleton(n)))throw new Error("Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)")}},e.prototype._deactivateSingletonsAsync=function(e){return Xe(this,void 0,void 0,(function(){var t=this;return et(this,(function(r){switch(r.label){case 0:return[4,Promise.all(e.map((function(e){return t._deactivateIfSingleton(e)})))];case 1:return r.sent(),[2]}}))}))},e.prototype._propagateContainerDeactivationThenBindingAndPreDestroy=function(e,t,r){return this.parent?this._deactivate.bind(this.parent)(e,t):this._bindingDeactivationAndPreDestroy(e,t,r)},e.prototype._propagateContainerDeactivationThenBindingAndPreDestroyAsync=function(e,t,r){return Xe(this,void 0,void 0,(function(){return et(this,(function(n){switch(n.label){case 0:return this.parent?[4,this._deactivate.bind(this.parent)(e,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,this._bindingDeactivationAndPreDestroyAsync(e,t,r)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},e.prototype._removeServiceFromDictionary=function(e){try{this._bindingDictionary.remove(e)}catch(t){throw new Error("Could not unbind serviceIdentifier: "+U(e))}},e.prototype._bindingDeactivationAndPreDestroy=function(e,t,r){var n=this;if("function"==typeof e.onDeactivation){var i=e.onDeactivation(t);if(de(i))return i.then((function(){return n._preDestroy(r,t)}))}return this._preDestroy(r,t)},e.prototype._bindingDeactivationAndPreDestroyAsync=function(e,t,r){return Xe(this,void 0,void 0,(function(){return et(this,(function(n){switch(n.label){case 0:return"function"!=typeof e.onDeactivation?[3,2]:[4,e.onDeactivation(t)];case 1:n.sent(),n.label=2;case 2:return[4,this._preDestroy(r,t)];case 3:return n.sent(),[2]}}))}))},e}();function nt(e,t,r,n){!function(e){if(void 0!==e)throw new Error(N)}(t),st("inversify:tagged",e,r.toString(),n)}function it(e){var t=[];if(Array.isArray(e)){var r=function(e){for(var t=new Set,r=0,n=e;r<n.length;r++){var i=n[r];if(t.has(i))return i;t.add(i)}}((t=e).map((function(e){return e.key})));if(void 0!==r)throw new Error("Metadata key was used more than once in a parameter: "+r.toString())}else t=[e];return t}function st(e,t,r,n){var i=it(n),s={};Reflect.hasOwnMetadata(e,t)&&(s=Reflect.getMetadata(e,t));var o=s[r];if(void 0===o)o=[];else for(var a=function(e){if(i.some((function(t){return t.key===e.key})))throw new Error("Metadata key was used more than once in a parameter: "+e.key.toString())},c=0,d=o;c<d.length;c++){a(d[c])}o.push.apply(o,i),s[r]=o,Reflect.defineMetadata(e,s,t)}function ot(e){return function(t,r,n){"number"==typeof n?nt(t,r,n,e):function(e,t,r){if(void 0!==e.prototype)throw new Error(N);st("inversify:tagged_props",e.constructor,t,r)}(t,r,e)}}function at(){return function(e){if(Reflect.hasOwnMetadata("inversify:paramtypes",e))throw new Error("Cannot apply @injectable decorator multiple times.");var t=Reflect.getMetadata("design:paramtypes",e)||[];return Reflect.defineMetadata("inversify:paramtypes",t,e),e}}var ct,dt=(ct="inject",function(e){return function(t,r,n){if(void 0===e){var i="function"==typeof t?t.name:t.constructor.name;throw new Error("@inject called with undefined this could mean that the class "+i+" has a circular dependency problem. You can use a LazyServiceIdentifier to overcome this limitation.")}return ot(new z(ct,e))(t,r,n)}});const ut=3,lt=4,pt=6,ht=7;var ft;!function(e){e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.OK=200]="OK",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.TooManyRequests=429]="TooManyRequests",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout"}(ft||(ft={}));var mt;const gt={customerId:String("b149fa74b11d989a60fb08e98e6a82883de0b468"),sdk_url:String("https://effectssdk.ai/sdk/audio/"),api_url:String("https://effectssdk.ai/sdk/session/"),version:"2.3.5"},vt={customerId:String("89c41ecf3b3f46fef5dfa9f96842014c21d4901c"),sdk_url:String("https://effectssdk.ai/sdk/"),api_url:String("https://effectssdk.ai/sdk/session/")},yt=()=>{};let _t=class{constructor(e){var t,r,n,i,s,o,a,c,u;mt.set(this,void 0),d(this,mt,{denoiser:null!==(t=e.denoiser)&&void 0!==t?t:"rnnoise",asdk:Object.assign(Object.assign({},gt),e.asdk),signalingServerUrl:null!==(r=e.signalingServerUrl)&&void 0!==r?r:String("https://signaling-api.livedigital.space/v1"),logLevel:null!==(n=e.logLevel)&&void 0!==n?n:ut,sendAnalytics:null!==(i=e.sendAnalytics)&&void 0!==i&&i,onLogMessage:null!==(s=e.onLogMessage)&&void 0!==s?s:yt,onIssues:null!==(o=e.onIssues)&&void 0!==o?o:yt,disableWid:null!==(a=e.disableWid)&&void 0!==a&&a,effectsSDKParams:Object.assign(Object.assign({},vt),e.effectsSDKParams),onNetworkScoresUpdated:null!==(c=e.onNetworkScoresUpdated)&&void 0!==c?c:yt,getStatsInterval:null!==(u=e.getStatsInterval)&&void 0!==u?u:5e3,staticFilesPath:e.staticFilesPath||window.location.origin},"f")}get(e){return c(this,mt,"f")[e]}set(e,t){c(this,mt,"f")[e]=t}};mt=new WeakMap,_t=i([at(),o("design:paramtypes",[Object])],_t);var bt=_t;class Et extends t{constructor(){super(),this.addListener=(e,t)=>this.on(e,t),this.removeListener=(e,t)=>this.off(e,t),this.prependListener=(e,t)=>(super.prependListener(e,t),this),this.prependOnceListener=(e,t)=>(super.prependOnceListener(e,t),this),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!!super.listenerCount(e)}}on(e,t){return super.on(e,t)}off(e,t){return super.off(e,t)}once(e,t){return super.once(e,t)}removeAllListeners(e){return super.removeAllListeners(e),this}}Error;const wt=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],St=({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]=St({from:e[r],seen:t.slice(),forceEnumerable:n}):i[r]=s);for(const{property:t,enumerable:r}of wt)"string"==typeof e[t]&&Object.defineProperty(i,t,{value:e[t],enumerable:!!n||r,configurable:!0,writable:!0});return i};var Ct=e=>"object"==typeof e&&null!==e?St({from:e,seen:[],forceEnumerable:!0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e;class Pt extends Error{constructor(e,t){var r;if(t instanceof Pt)return super(t.message),Object.setPrototypeOf(this,new.target.prototype),this.name=new.target.name,this.errorCode=t.errorCode,void(this.cause=t.cause);const n=Ct(t),i=null!==(r=(e=>{if("string"==typeof e)return e;if(e instanceof Error)return e.message;if(e&&"object"==typeof e&&"message"in e){const t=e.message;return"string"==typeof t?t:void 0}})(n))&&void 0!==r?r:"Operation failed";super(i),Object.setPrototypeOf(this,new.target.prototype),this.name=new.target.name,this.errorCode=e,this.cause=Ct(n)}}var Tt,Rt,kt,Dt;function It(){}function At(){At.init.call(this)}function Ot(e){return void 0===e._maxListeners?At.defaultMaxListeners:e._maxListeners}function Nt(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Bt(e,n),s=0;s<n;++s)i[s].call(r)}function Mt(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,s=Bt(e,i),o=0;o<i;++o)s[o].call(r,n)}function Lt(e,t,r,n,i){if(t)e.call(r,n,i);else for(var s=e.length,o=Bt(e,s),a=0;a<s;++a)o[a].call(r,n,i)}function xt(e,t,r,n,i,s){if(t)e.call(r,n,i,s);else for(var o=e.length,a=Bt(e,o),c=0;c<o;++c)a[c].call(r,n,i,s)}function Ft(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,s=Bt(e,i),o=0;o<i;++o)s[o].apply(r,n)}function jt(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 It,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=Ot(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 Ut(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 Vt(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 Bt(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}It.prototype=Object.create(null),At.EventEmitter=At,At.usingDomains=!1,At.prototype.domain=void 0,At.prototype._events=void 0,At.prototype._maxListeners=void 0,At.defaultMaxListeners=10,At.init=function(){this.domain=null,At.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new It,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},At.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},At.prototype.getMaxListeners=function(){return Ot(this)},At.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:Nt(r,u,this);break;case 2:Mt(r,u,this,arguments[1]);break;case 3:Lt(r,u,this,arguments[1],arguments[2]);break;case 4:xt(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),s=1;s<n;s++)i[s-1]=arguments[s];Ft(r,u,this,i)}return!0},At.prototype.addListener=function(e,t){return jt(this,e,t,!1)},At.prototype.on=At.prototype.addListener,At.prototype.prependListener=function(e,t){return jt(this,e,t,!0)},At.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Ut(this,e,t)),this},At.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Ut(this,e,t)),this},At.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 It:(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 It,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},At.prototype.off=function(e,t){return this.removeListener(e,t)},At.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new It,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new It: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 It,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},At.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):[]},At.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Vt.call(e,t)},At.prototype.listenerCount=Vt,At.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};class Wt extends At{}!function(e){e.Issue="issue",e.NetworkScoresUpdated="network-scores-updated",e.StatsParsingFinished="stats-parsing-finished"}(Tt||(Tt={})),function(e){e.Network="network",e.CPU="cpu",e.Server="server",e.Stream="stream"}(Rt||(Rt={})),function(e){e.OutboundNetworkQuality="outbound-network-quality",e.InboundNetworkQuality="inbound-network-quality",e.OutboundNetworkMediaLatency="outbound-network-media-latency",e.InboundNetworkMediaLatency="inbound-network-media-latency",e.NetworkMediaSyncFailure="network-media-sync-failure",e.OutboundNetworkThroughput="outbound-network-throughput",e.InboundNetworkThroughput="inbound-network-throughput",e.EncoderCPUThrottling="encoder-cpu-throttling",e.DecoderCPUThrottling="decoder-cpu-throttling",e.ServerIssue="server-issue",e.UnknownVideoDecoderIssue="unknown-video-decoder",e.LowInboundMOS="low-inbound-mean-opinion-score",e.LowOutboundMOS="low-outbound-mean-opinion-score",e.FrozenVideoTrack="frozen-video-track",e.MissingVideoStreamData="missing-video-stream-data",e.MissingAudioStreamData="missing-audio-stream-data"}(kt||(kt={})),function(e){e[e.BAD=2.1]="BAD",e[e.POOR=2.6]="POOR",e[e.FAIR=3.1]="FAIR",e[e.GOOD=3.8]="GOOD",e[e.EXCELLENT=4.3]="EXCELLENT"}(Dt||(Dt={}));class Ht extends At{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(Ht.STATS_REPORTS_PARSED,{timeTaken:r,reportItems:t}),t.forEach((e=>{this.emit(Ht.STATS_REPORT_READY_EVENT,e)}))}}const qt=(()=>{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 zt{#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,qt({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=1e3*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=1e3*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;i-=2.5*r;const s=1+.035*i+7e-6*i*(i-60)*(100-i);return Math.max(0,Math.min(5,s))}}class Gt{#t=new Map;#r;#n;constructor(e={}){this.#r=e.statsCleanupTtlMs??35e3,this.#n=e.maxParsedStatsStorageSize??5}detect(e,t){const r={...e,networkScores:{...t,statsSamples:t?.statsSamples||{}}},n=this.performDetection(r);return this.setLastProcessedStats(e.connection.id,r),this.performPrevStatsCleanup({connectionId:e.connection.id}),n}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;this.#t.has(t)&&qt({taskId:t,delayMs:this.#r,callback:()=>{this.deleteLastProcessedStats(t),"function"==typeof r&&r()}})}setLastProcessedStats(e,t){if(!e||t.connection.id!==e)return;const r=this.#t.get(e)??[];r.push(t),r.length>this.#n&&r.shift(),this.#t.set(e,r)}getLastProcessedStats(e){const t=this.#t.get(e);return t?.[t.length-1]}getAllLastProcessedStats(e){return this.#t.get(e)??[]}deleteLastProcessedStats(e){this.#t.delete(e)}}class Yt extends Gt{#i;constructor(e={}){super(e),this.#i=e.availableOutgoingBitrateThreshold??1e5}performDetection(e){const t=[],{availableOutgoingBitrate:r}=e.connection;if(void 0===r)return t;const n=e.audio.outbound.reduce(((e,t)=>e+t.targetBitrate),0),i=e.video.outbound.reduce(((e,t)=>e+t.bitrate),0);if(!n&&!i)return t;const s={availableOutgoingBitrate:r,videoStreamsTotalBitrate:i,audioStreamsTotalTargetBitrate:n};return n>r||i>0&&r<this.#i?(t.push({statsSample:s,type:Rt.Network,reason:kt.OutboundNetworkThroughput}),t):t}}class $t extends Gt{#s;#o;#a;#c;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200,this.#a=e.highJitterBufferDelayThresholdMs??500,this.#c=e.highRttThresholdMs??250}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...e.audio?.inbound,...e.video?.inbound];if(!r.length)return t;const n=this.getLastProcessedStats(e.connection.id);if(!n)return t;const i=[...n.video?.inbound,...n.audio?.inbound],{packetsReceived:s}=e.connection,o=n.connection.packetsReceived,a=r.reduce(((e,t)=>{const r=i.find((e=>e.ssrc===t.ssrc)),n=r?.jitterBufferDelay||0,s=r?.jitterBufferEmittedCount||0,o=t.jitterBufferDelay-n,a=t.jitterBufferEmittedCount-s,c=o&&a?1e3*o/a:0;return{sumJitter:e.sumJitter+t.jitter,sumJitterBufferDelayMs:e.sumJitterBufferDelayMs+c,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,sumJitterBufferDelayMs:0,packetsLost:0,lastPacketsLost:0}),c=1e3*e.connection.currentRoundTripTime||0,{sumJitter:d,sumJitterBufferDelayMs:u}=a,l=1e3*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,_=p>this.#a,b=y&&!v&&!g,E=g&&v,w=v&&_,S={rtt:c,packetLossPct:m,avgJitter:l,avgJitterBufferDelay:p};return(v||g)&&t.push({statsSample:S,type:Rt.Network,reason:kt.InboundNetworkQuality,iceCandidate:e.connection.local.id}),b&&t.push({statsSample:S,type:Rt.Server,reason:kt.ServerIssue,iceCandidate:e.connection.remote.id}),E&&t.push({statsSample:S,type:Rt.Network,reason:kt.InboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),w&&t.push({statsSample:S,type:Rt.Network,reason:kt.NetworkMediaSyncFailure,iceCandidate:e.connection.local.id}),t}}class Jt extends Gt{#d;constructor(e={}){super(),this.#d=e.correctedSamplesThresholdPct??5}performDetection(e){return this.processData(e)}processData(e){const t=e.audio.inbound,r=[],n=this.getLastProcessedStats(e.connection.id)?.audio.inbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;const i=e.track.insertedSamplesForDeceleration+e.track.removedSamplesForAcceleration,s=t.track.insertedSamplesForDeceleration+t.track.removedSamplesForAcceleration;if(i===s)return;const o=e.track.totalSamplesReceived-t.track.totalSamplesReceived,a=i-s,c=Math.round(100*a/o),d={correctedSamplesPct:c};c>this.#d&&r.push({statsSample:d,type:Rt.Network,reason:kt.NetworkMediaSyncFailure,ssrc:e.ssrc})})),r):r}}class Kt extends Gt{#s;#o;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...e.remote?.audio.inbound||[],...e.remote?.video.inbound||[]];if(!r.length)return t;const n=this.getLastProcessedStats(e.connection.id);if(!n)return t;const i=[...n.remote?.audio.inbound||[],...n.remote?.video.inbound||[]],{packetsSent:s}=e.connection,o=n.connection.packetsSent,a=r.reduce(((e,t)=>{const r=i.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),c=1e3*e.connection.currentRoundTripTime||0,{sumJitter:d}=a,u=1e3*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:Rt.Network,reason:kt.OutboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),g&&t.push({statsSample:v,type:Rt.Network,reason:kt.OutboundNetworkQuality,iceCandidate:e.connection.local.id}),t}}class Qt extends Gt{performDetection(e){return this.processData(e)}processData(e){const t=e.video.outbound.filter((e=>"none"!==e.qualityLimitationReason)),r=[],n=this.getLastProcessedStats(e.connection.id)?.video.outbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;const i={qualityLimitationReason:e.qualityLimitationReason};e.framesSent>t.framesSent||("cpu"===e.qualityLimitationReason&&r.push({statsSample:i,type:Rt.CPU,reason:kt.EncoderCPUThrottling,ssrc:e.ssrc}),"bandwidth"===e.qualityLimitationReason&&r.push({statsSample:i,type:Rt.Network,reason:kt.OutboundNetworkThroughput,ssrc:e.ssrc}))})),r):r}}class Zt extends Gt{UNKNOWN_DECODER="unknown";#u={};performDetection(e){return this.processData(e)}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;super.performPrevStatsCleanup({...e,cleanupCallback:()=>{delete this.#u[t],"function"==typeof r&&r()}})}processData(e){const t=[],{id:r}=e.connection,n=this.getLastProcessedStats(r)?.video.inbound;return e.video.inbound.forEach((e=>{const{decoderImplementation:i,ssrc:s}=e,o=n?.find((e=>e.ssrc===s));if(o)if(i===this.UNKNOWN_DECODER){if(!this.hadLastDecoderWithIssue(r,s)){this.setLastDecoderWithIssue(r,s,this.UNKNOWN_DECODER);const n={mimeType:e.mimeType,decoderImplementation:i};t.push({ssrc:s,statsSample:n,type:Rt.Stream,reason:kt.UnknownVideoDecoderIssue,trackIdentifier:e.track.trackIdentifier})}}else this.setLastDecoderWithIssue(r,s,void 0)})),t}setLastDecoderWithIssue(e,t,r){const n=this.#u[e]??{};void 0===r?delete n[t]:n[t]=r,this.#u[e]=n}hadLastDecoderWithIssue(e,t){const r=this.#u[e];return(r&&r[t])===this.UNKNOWN_DECODER}}const Xt=e=>e.reduce(((e,t)=>e+t),0)/e.length,er=(e,t,r=30)=>{const n=[];for(let r=1;r<t.length-1;r+=1){const i=t[r]?.video?.inbound.find((t=>t.ssrc===e));if(!i)continue;const s=t[r-1]?.video?.inbound?.find((t=>t.ssrc===e));if(!i||!s)continue;const o=i.timestamp-s.timestamp,a=i.framesDecoded-s.framesDecoded;if(a>0){const e=o/a;n.push(e)}}return!(n.length<=1)&&(e=>{const t=((e,t)=>t.reduce(((t,r)=>t+(r-e)**2),0)/t.length)(Xt(e),e);return Math.sqrt(t)})(n)>r},tr=(e,t)=>{for(let r=1;r<t.length;r+=1){const n=t[r].video.inbound.find((t=>t.ssrc===e));if(!n)continue;const i=t[r-1].video.inbound.find((t=>t.ssrc===e)),s=n.frameWidth!==i?.frameWidth,o=n.frameHeight!==i?.frameHeight;if(s||o)return!0}return!1};class rr extends Gt{#l;#p;#h;constructor(e={}){super(),this.#l=e.avgFreezeDurationThresholdMs??1e3,this.#p=e.frozenDurationThresholdPct??30,this.#h=e.minMosQuality??Dt.BAD}performDetection(e){const t=e.networkScores.inbound;return void 0!==t&&t<=this.#h?[]:this.processData(e)}processData(e){const t=[],r=this.getAllLastProcessedStats(e.connection.id);if(0===r.length)return[];const n=e.video.inbound.map((t=>{const n=r[r.length-1].video.inbound.find((e=>e.ssrc===t.ssrc));if(!n)return;if(tr(t.ssrc,[r[r.length-1],e]))return;if(er(t.ssrc,r))return;const i=t.freezeCount-(n.freezeCount??0),s=1e3*(t.totalFreezesDuration-(n.totalFreezesDuration??0)),o=i>0?s/i:0,a=s/(t.timestamp-n.timestamp)*100;return a>this.#p||o>this.#l?{ssrc:t.ssrc,avgFreezeDurationMs:o,frozenDurationPct:a}:void 0})).filter((e=>void 0!==e));return n.length>0&&(t.push({type:Rt.Stream,reason:kt.FrozenVideoTrack,statsSample:{ssrcs:n.map((e=>e.ssrc))}}),this.deleteLastProcessedStats(e.connection.id)),t}}class nr extends Gt{#f;#m;#h;constructor(e={}){super(e),this.#f=e.volatilityThreshold??8,this.#m=e.affectedStreamsPercentThreshold??30,this.#h=e.minMosQuality??Dt.BAD}performDetection(e){return[...this.getAllLastProcessedStats(e.connection.id),e].find((e=>void 0!==e.networkScores.inbound&&e.networkScores.inbound<=this.#h))?[]:this.processData(e)}processData(e){const t=[],r=[...this.getAllLastProcessedStats(e.connection.id),e],n=e.video.inbound.map((e=>{if(r.length<5)return;if(tr(e.ssrc,r))return;const t=[];for(let n=0;n<r.length-1;n+=1){const i=r[n].video.inbound.find((t=>t.ssrc===e.ssrc));void 0!==i?.framesPerSecond&&t.push(i.framesPerSecond)}if(t.length<5)return;if(er(e.ssrc,r))return;const n=(e=>{if(0===e.length)throw new Error("Cannot calculate volatility for empty array");const t=Xt(e);return e.reduce(((e,r)=>e+Math.abs(r-t)),0)/e.length*100/t})(t);return n>this.#f?{ssrc:e.ssrc,allFps:t,volatility:n}:void 0})).filter((e=>Boolean(e)));if(0===n.length)return t;const i=n.length/(e.video.inbound.length/100);return i>this.#m&&(t.push({type:Rt.CPU,reason:kt.DecoderCPUThrottling,statsSample:{affectedStreamsPercent:i,throtthedStreams:n}}),this.deleteLastProcessedStats(e.connection.id)),t}}class ir extends Gt{#g=new Map;#v;#y;constructor(e={}){super(),this.#v=e.timeoutMs??15e3,this.#y=e.steps??3}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...this.getAllLastProcessedStats(e.connection.id),e];if(r.length<this.#y)return t;const n=r.slice(-this.#y),i=n.map((e=>e.video.inbound)),s=n.map((e=>e.audio.inbound));return t.push(...this.detectMissingData(s,Rt.Stream,kt.MissingAudioStreamData)),t.push(...this.detectMissingData(i,Rt.Stream,kt.MissingVideoStreamData)),new Set(this.#g.keys()).forEach((e=>{const t=this.#g.get(e);t&&Date.now()-t>this.#v&&this.removeMarkedIssue(e)})),t}detectMissingData(e,t,r){const n=[],i=e.pop(),s=ir.mapStatsByTrackId(e);return i.forEach((e=>{const i=e.track.trackIdentifier,o=s.get(i);if(!Array.isArray(o)||0===o.length)return;if(e.track.detached||e.track.ended)return;if(!ir.isAllBytesReceivedDidntChange(e.bytesReceived,o))return void this.removeMarkedIssue(i);if(!this.markIssue(i))return;const a={bytesReceived:e.bytesReceived};n.push({type:t,reason:r,statsSample:a,trackIdentifier:i})})),n}static mapStatsByTrackId(e){const t=new Map;return e.forEach((e=>{e.forEach((e=>{const r=t.get(e.track.trackIdentifier)||[];r.push(e),t.set(e.track.trackIdentifier,r)}))})),t}static isAllBytesReceivedDidntChange(e,t){for(let r=0;r<t.length;r+=1)if(t[r].bytesReceived!==e)return!1;return!0}markIssue(e){const t=Date.now(),r=this.#g.get(e);return(!r||t-r>this.#v)&&(this.#g.set(e,t),!0)}removeMarkedIssue(e){this.#g.delete(e)}}const sr=e=>"closed"===e.iceConnectionState||"closed"===e.connectionState,or=(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 ar{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(!sr(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 cr{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(!sr(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()}),qt({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=or(e,r,"bytesReceived"),e.packetRate=or(e,r,"packetsReceived")})),e.audio.outbound.forEach((e=>{const r=t.audio.outbound.find((({id:t})=>t===e.id));e.bitrate=or(e,r,"bytesSent"),e.packetRate=or(e,r,"packetsSent")})),e.video.inbound.forEach((e=>{const r=t.video.inbound.find((({id:t})=>t===e.id));e.bitrate=or(e,r,"bytesReceived"),e.packetRate=or(e,r,"packetsReceived")})),e.video.outbound.forEach((e=>{const r=t.video.outbound.find((({id:t})=>t===e.id));e.bitrate=or(e,r,"bytesSent"),e.packetRate=or(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 dr{eventEmitter;#_=!1;detectors=[];networkScoresCalculator;statsReporter;compositeStatsParser;logger;autoAddPeerConnections;constructor(e){this.logger=e.logger??{debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},this.eventEmitter=e.issueEmitter??new Wt,e.onIssues&&this.eventEmitter.on(Tt.Issue,e.onIssues),e.onNetworkScoresUpdated&&this.eventEmitter.on(Tt.NetworkScoresUpdated,e.onNetworkScoresUpdated),this.detectors=e.detectors??[new Qt,new $t,new Kt,new Jt,new Yt,new Zt,new rr,new nr,new ir],this.networkScoresCalculator=e.networkScoresCalculator??new zt,this.compositeStatsParser=e.compositeStatsParser??new ar({statsParser:new cr({ignoreSSRCList:e.ignoreSSRCList,logger:this.logger})}),this.statsReporter=e.statsReporter??new Ht({compositeStatsParser:this.compositeStatsParser,getStatsInterval:e.getStatsInterval??5e3}),window.wid=this,this.autoAddPeerConnections=e.autoAddPeerConnections??!0,this.autoAddPeerConnections&&this.wrapRTCPeerConnection(),this.statsReporter.on(Ht.STATS_REPORT_READY_EVENT,(e=>{const t=this.calculateNetworkScores(e.stats);this.detectIssues({data:e.stats},t)})),this.statsReporter.on(Ht.STATS_REPORTS_PARSED,(t=>{const r={timeTaken:t.timeTaken,ts:Date.now()};e.onStats&&e.onStats(t.reportItems),this.eventEmitter.emit(Tt.StatsParsingFinished,r)}))}watchNewPeerConnections(){if(!this.autoAddPeerConnections)throw new Error("Auto add peer connections was disabled in the constructor.");this.#_?this.logger.warn("WebRTCIssueDetector is already started. Skip processing"):(this.logger.info("Start watching peer connections"),this.#_=!0,this.statsReporter.startReporting())}stopWatchingNewPeerConnections(){this.#_?(this.logger.info("Stop watching peer connections"),this.#_=!1,this.statsReporter.stopReporting()):this.logger.warn("WebRTCIssueDetector is already stopped. Skip processing")}handleNewPeerConnection(e,t){this.#_||!this.autoAddPeerConnections?(this.#_||!1!==this.autoAddPeerConnections||(this.logger.info("Starting stats reporting for new peer connection"),this.#_=!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(Tt.Issue,e)}detectIssues({data:e},t){const r=this.detectors.reduce(((r,n)=>[...r,...n.detect(e,t)]),[]);r.length>0&&this.emitIssues(r)}calculateNetworkScores(e){const t=this.networkScoresCalculator.calculate(e);return this.eventEmitter.emit(Tt.NetworkScoresUpdated,t),t}wrapRTCPeerConnection(){if(!window.RTCPeerConnection)return void this.logger.warn("No RTCPeerConnection found in browser window. Skipping");const e=window.RTCPeerConnection,t=e=>this.handleNewPeerConnection(e);function r(r){const n=new e(r);return t(n),n}r.prototype=e.prototype,window.RTCPeerConnection=r}}var ur,lr,pr,hr;ur=new WeakMap,lr=new WeakMap,pr=new WeakMap,hr=new WeakMap;var fr=new class{constructor(){ur.set(this,void 0),lr.set(this,void 0),pr.set(this,void 0),hr.set(this,void 0)}get meta(){return{peerId:c(this,ur,"f"),channelId:c(this,lr,"f"),appId:c(this,pr,"f"),datacenterName:c(this,hr,"f")}}setPeerId(e){d(this,ur,e,"f")}setChannelId(e){d(this,lr,e,"f")}setAppId(e){d(this,pr,e,"f")}setDatacenterName(e){d(this,hr,e,"f")}clear(){d(this,ur,void 0,"f"),d(this,lr,void 0,"f"),d(this,pr,void 0,"f"),d(this,hr,void 0,"f")}};const mr="peer.updateAppData",gr="channel-event",vr="peer-joined",yr="peer-left",_r="channel-activity-confirmation-required",br="channel-activity-confirmation-acquired",Er="channel-activity-confirmation-expired",wr="channel-rejoin-required",Sr="devices-list-updated",Cr="transport-connection-timeout",Pr="track-force-closed",Tr="track-failed",Rr="active-speaker-changed",kr="channel-state-inconsistent",Dr="connection-lost",Ir="connection-restored",Ar="denoiser-initializing",Or="channel-state-synced",Nr="denoiser-enabled",Mr="denoiser-disabled",Lr="denoiser-fallback",xr="denoiser-failed",Fr="volume-changed",jr="track-produced",Ur="track-unproduced",Vr="track-paused",Br="track-resumed",Wr="track-closed",Hr="track-reopened",qr="track-failed",zr="media-published",Gr="media-unpublished",Yr="publisher-paused",$r="publisher-resumed",Jr="track-start",Kr="track-end",Qr="track-paused",Zr="track-resumed",Xr="track-failed",en="app-data-updated",tn="produce-permissions-changed",rn="groups-changed",nn="peer.newProducer",sn="producer.close",on="producer.setMaxSpatialLayer",an="producer.requestMaxSpatialLayer",cn="consumer.close",dn="consumer.pause",un="consumer.resume",ln="consumer.changeConsumerPreferredLayers",pn="transport.connectionTimeout",hn="transport-state";var fn;!function(e){e.CloseProducer="CloseProducer",e.Mute="Mute",e.Resume="Resume",e.Join="Join"}(fn||(fn={}));class mn extends Error{constructor(e,t,r){super(null!=e?e:"Unexpected Livedigital SDK error"),Object.setPrototypeOf(this,new.target.prototype),this.name=new.target.name,this.errorCode=null!=t?t:"unknown_error",this.meta=r}}class gn extends mn{constructor(e,t,r){super(null!=e?e:gn.DEFAULT_MESSAGE,null!=t?t:"need_joined_to_channel",r)}}gn.DEFAULT_MESSAGE="Peer must join the channel before performing this request";class vn extends mn{constructor(e,t,r){super(null!=e?e:vn.DEFAULT_MESSAGE,null!=t?t:"unsupported_error",r)}}vn.UNSUPPORTED_DEVICE_CODE="unsupported_device_error",vn.UNSUPPORTED_OPERATION_CODE="unsupported_operation_error",vn.DEFAULT_MESSAGE="Unsupported operation";const yn=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 _n={exports:{}},bn=p(_n.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}}));function En(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function wn(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=En(n)&&En(s);(o&&!wn(n,s)||!o&&n!==s)&&(i=!1)})),i}function Sn(e,t,r=!1){let n=null;return function(...i){return a(this,void 0,void 0,(function*(){const s=r&&!n;"number"==typeof n&&clearTimeout(n),n=setTimeout((()=>a(this,void 0,void 0,(function*(){n=null,r||(yield e.apply(this,i))}))),t),s&&(yield e.apply(this,i))}))}}function Cn(e,t){return a(this,void 0,void 0,(function*(){try{return yield e()}catch(e){return void(null==t||t(e))}}))}const Pn=e=>{var t,r;return null!==(r=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 n&&!e.includes(n)&&e.push(n),e}),[]))&&void 0!==r?r:[]},Tn=e=>["video/vp9","vp9"].includes(e.toLowerCase()),Rn=Array.from({length:256},((e,t)=>(t+256).toString(16).slice(1)));function kn(e=24){const t=new Uint8Array(e);crypto.getRandomValues(t);let r="";for(let e=0;e<t.length;e++)r+=Rn[t[e]];return r}class Dn{sleepMs(e){return a(this,void 0,void 0,(function*(){yield new Promise((t=>setTimeout(t,e)))}))}now(){return new Date(Date.now())}}const In=new Dn,An=(e,...t)=>a(void 0,[e,...t],void 0,(function*(e,t={}){var r,n,i,s;const o=null!==(r=t.maxRetries)&&void 0!==r?r:2,a=null!==(n=t.minBackoffDelayMs)&&void 0!==n?n:50;let c,d=0;for(;d<o;){d+=1;try{return yield e()}catch(e){if(c=e,t.logger&&t.logger.info("Action retry failed",{currentAttempt:d,actionName:t.actionName,error:Ct(e)}),null===(i=t.abortOnError)||void 0===i?void 0:i.call(t,e))throw c;if(t.onError&&(yield t.onError(e)),d<o){const e=Math.pow(2,d-1)*a;yield In.sleepMs(Math.min(e,null!==(s=t.maxBackoffDelayMs)&&void 0!==s?s:e))}}}throw null!=c?c:new Error("retryAsync logic failed")}));var On,Nn,Mn;!function(e){e.Config="Config",e.Engine="Engine",e.System="System",e.Media="Media",e.Network="Network",e.MediaEventHandler="MediaEventHandler",e.ChannelEventHandler="ChannelEventHandler",e.ChannelAudioObserverEventHandler="ChannelAudioObserverEventHandler",e.ChannelAudioObserverMissingProducerRestorer="ChannelAudioObserverMissingProducerRestorer",e.ChannelStateSynchronizer="ChannelStateSynchronizer",e.ChannelStateSyncEventHandler="ChannelStateSyncEventHandler",e.WebRTCIssueDetector="WebRTCIssueDetector",e.LoggerFactory="LoggerFactory",e.MediaStreamTrackManager="MediaStreamTrackManager",e.EventsQueue="EventsQueue",e.ClientEventEmitter="ClientEventEmitter",e.Peers="Peers",e.CallState="CallState",e.RemotePeerTracks="RemotePeerTracks",e.MyPeer="MyPeer",e.InternalEventEmitter="InternalEventEmitter",e.PeerTrackFactory="PeerTrackFactory",e.PeerFactory="PeerFactory",e.PeerConsumerFactory="PeerConsumerFactory",e.AudioTrackFactory="AudioTrackFactory",e.VideoTrackFactory="VideoTrackFactory",e.AudioTrackProcessorFactory="AudioTrackProcessorFactory",e.IntegrationsService="IntegrationsService",e.ProcessorsCache="ProcessorsCache",e.StatsHandler="StatsHandler",e.DataChannelsManager="DataChannelsManager",e.WIDHandler="WIDHandler",e.AnalyticsApiClient="AnalyticsApiClient",e.TransportsStatsProvider="TransportsStatsProvider",e.LocalMutex="LocalMutex",e.PeersStorage="PeersStorage",e.SignalingApiClient="SignalingApiClient",e.DatachannelHeartbeater="DatachannelHeartbeater",e.SignalingHeartbeater="SignalingHeartbeater",e.PendingClosureProducerStorage="PendingClosureProducerStorage",e.ProducerCloseManager="ProducerCloseManager",e.NetworkTransportPolicyManager="NetworkTransportPolicyManager"}(On||(On={})),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.CustomVideo="custom-video",e.CustomAudio="custom-audio",e.Unknown="unknown"}(Nn||(Nn={})),function(e){e.NotFoundError="NotFoundError",e.NoDevices="NoDevices",e.DeviceIsBusy="DeviceIsBusy",e.NotAllowedError="NotAllowedError",e.RequestDevicesUnknownError="RequestDevicesUnknownError"}(Mn||(Mn={}));let Ln=class{constructor(){this.isJoined=!1,this.isChannelJoining=!1}reset(){this.appId=void 0,this.channelId=void 0,this.isJoined=!1,this.isChannelJoining=!1}};function xn(){let e=0,t=0;for(let r=0;r<28;r+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<r,0==(128&n))return this.assertBounds(),[e,t]}let r=this.buf[this.pos++];if(e|=(15&r)<<28,t=(112&r)>>4,0==(128&r))return this.assertBounds(),[e,t];for(let r=3;r<=31;r+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<r,0==(128&n))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function Fn(e,t,r){for(let n=0;n<28;n+=7){const i=e>>>n,s=!(i>>>7==0&&0==t),o=255&(s?128|i:i);if(r.push(o),!s)return}const n=e>>>28&15|(7&t)<<4,i=!(t>>3==0);if(r.push(255&(i?128|n:n)),i){for(let e=3;e<31;e+=7){const n=t>>>e,i=!(n>>>7==0),s=255&(i?128|n:n);if(r.push(s),!i)return}r.push(t>>>31&1)}}Ln=i([at()],Ln);function jn(e){const t="-"===e[0];t&&(e=e.slice(1));const r=1e6;let n=0,i=0;function s(t,s){const o=Number(e.slice(t,s));i*=r,n=n*r+o,n>=4294967296&&(i+=n/4294967296|0,n%=4294967296)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),t?Bn(n,i):Vn(n,i)}function Un(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(4294967296*t+e);const r=16777215&(e>>>24|t<<8),n=t>>16&65535;let i=(16777215&e)+6777216*r+6710656*n,s=r+8147497*n,o=2*n;const a=1e7;return i>=a&&(s+=Math.floor(i/a),i%=a),s>=a&&(o+=Math.floor(s/a),s%=a),o.toString()+Wn(s)+Wn(i)}function Vn(e,t){return{lo:0|e,hi:0|t}}function Bn(e,t){return t=~t,e?e=1+~e:t+=1,Vn(e,t)}const Wn=e=>{const t=String(e);return"0000000".slice(t.length)+t};function Hn(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let r=0;r<9;r++)t.push(127&e|128),e>>=7;t.push(1)}}function qn(){let e=this.buf[this.pos++],t=127&e;if(0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,0==(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;0!=(128&e)&&t<10;t++)e=this.buf[this.pos++];if(0!=(128&e))throw new Error("invalid varint");return this.assertBounds(),t>>>0}const zn=Gn();function Gn(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&("object"!=typeof process||"object"!=typeof process.env||"1"!==process.env.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),n=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const n="bigint"==typeof e?e:BigInt(e);if(n>r||n<t)throw new Error(`invalid int64: ${e}`);return n},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>i||t<n)throw new Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,r)=>(e.setInt32(0,t,!0),e.setInt32(4,r,!0),e.getBigInt64(0,!0)),uDec:(t,r)=>(e.setInt32(0,t,!0),e.setInt32(4,r,!0),e.getBigUint64(0,!0))}}return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),Yn(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),$n(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),Yn(e),jn(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),$n(e),jn(e)),dec:(e,t)=>function(e,t){let r=Vn(e,t);const n=2147483648&r.hi;n&&(r=Bn(r.lo,r.hi));const i=Un(r.lo,r.hi);return n?"-"+i:i}(e,t),uDec:(e,t)=>Un(e,t)}}function Yn(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function $n(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}const Jn=Symbol.for("@bufbuild/protobuf/text-encoding");function Kn(){if(null==globalThis[Jn]){const e=new globalThis.TextEncoder,t=new globalThis.TextDecoder;globalThis[Jn]={encodeUtf8:t=>e.encode(t),decodeUtf8:e=>t.decode(e),checkUtf8(e){try{return encodeURIComponent(e),!0}catch(e){return!1}}}}return globalThis[Jn]}var Qn;!function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(Qn||(Qn={}));const Zn=34028234663852886e22,Xn=-34028234663852886e22;class ei{constructor(e=Kn().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),r=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],r),r+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(ni(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return ri(e),Hn(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){!function(e){if("string"==typeof e){const t=e;if(e=Number(e),Number.isNaN(e)&&"NaN"!==t)throw new Error("invalid float32: "+t)}else if("number"!=typeof e)throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>Zn||e<Xn))throw new Error("invalid float32: "+e)}(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){ni(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){ri(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return ri(e),Hn(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=zn.enc(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=zn.uEnc(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}int64(e){let t=zn.enc(e);return Fn(t.lo,t.hi,this.buf),this}sint64(e){const t=zn.enc(e),r=t.hi>>31;return Fn(t.lo<<1^r,(t.hi<<1|t.lo>>>31)^r,this.buf),this}uint64(e){const t=zn.uEnc(e);return Fn(t.lo,t.hi,this.buf),this}}class ti{constructor(e,t=Kn().decodeUtf8){this.decodeUtf8=t,this.varint64=xn,this.uint32=qn,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),t=e>>>3,r=7&e;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e,t){let r=this.pos;switch(e){case Qn.Varint:for(;128&this.buf[this.pos++];);break;case Qn.Bit64:this.pos+=4;case Qn.Bit32:this.pos+=4;break;case Qn.LengthDelimited:let r=this.uint32();this.pos+=r;break;case Qn.StartGroup:for(;;){const[e,r]=this.tag();if(r===Qn.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(r,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return zn.dec(...this.varint64())}uint64(){return zn.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(1&e);return e=(e>>>1|(1&t)<<31)^r,t=t>>>1^r,zn.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return zn.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return zn.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.decodeUtf8(this.bytes())}}function ri(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int32: "+e)}function ni(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint32: "+e)}const ii={encode:(e,t=new ei)=>(0!==e.time&&t.uint32(8).int64(e.time),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={time:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.time=si(r.int64());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON(e){return{time:(t=e.time,null!=t?globalThis.Number(e.time):0)};var t},toJSON(e){const t={};return 0!==e.time&&(t.time=Math.round(e.time)),t},create:e=>ii.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={time:0};return r.time=null!==(t=e.time)&&void 0!==t?t:0,r}};function si(e){const t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}var oi;function ai(e){switch(e){case 0:case"NULL_VALUE":return oi.NULL_VALUE;default:return oi.UNRECOGNIZED}}!function(e){e[e.NULL_VALUE=0]="NULL_VALUE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(oi||(oi={}));const ci={encode:(e,t=new ei)=>(Object.entries(e.fields).forEach((([e,r])=>{void 0!==r&&di.encode({key:e,value:r},t.uint32(10).fork()).join()})),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={fields:{}};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:{if(10!==e)break;const t=di.decode(r,r.uint32());void 0!==t.value&&(i.fields[t.key]=t.value);continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({fields:pi(e.fields)?Object.entries(e.fields).reduce(((e,[t,r])=>(e[t]=r,e)),{}):{}}),toJSON(e){const t={};if(e.fields){const r=Object.entries(e.fields);r.length>0&&(t.fields={},r.forEach((([e,r])=>{t.fields[e]=r})))}return t},create:e=>ci.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={fields:{}};return r.fields=Object.entries(null!==(t=e.fields)&&void 0!==t?t:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=r),e)),{}),r},wrap(e){const t={fields:{}};if(void 0!==e)for(const r of Object.keys(e))t.fields[r]=e[r];return t},unwrap(e){const t={};if(e.fields)for(const r of Object.keys(e.fields))t[r]=e.fields[r];return t}};const di={encode:(e,t=new ei)=>(""!==e.key&&t.uint32(10).string(e.key),void 0!==e.value&&ui.encode(ui.wrap(e.value),t.uint32(18).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={key:"",value:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.key=r.string();continue;case 2:if(18!==e)break;i.value=ui.unwrap(ui.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({key:hi(e.key)?globalThis.String(e.key):"",value:hi(null==e?void 0:e.value)?e.value:void 0}),toJSON(e){const t={};return""!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},create:e=>di.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={key:"",value:void 0};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:void 0,n}};const ui={encode:(e,t=new ei)=>(void 0!==e.nullValue&&t.uint32(8).int32(e.nullValue),void 0!==e.numberValue&&t.uint32(17).double(e.numberValue),void 0!==e.stringValue&&t.uint32(26).string(e.stringValue),void 0!==e.boolValue&&t.uint32(32).bool(e.boolValue),void 0!==e.structValue&&ci.encode(ci.wrap(e.structValue),t.uint32(42).fork()).join(),void 0!==e.listValue&&li.encode(li.wrap(e.listValue),t.uint32(50).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.nullValue=r.int32();continue;case 2:if(17!==e)break;i.numberValue=r.double();continue;case 3:if(26!==e)break;i.stringValue=r.string();continue;case 4:if(32!==e)break;i.boolValue=r.bool();continue;case 5:if(42!==e)break;i.structValue=ci.unwrap(ci.decode(r,r.uint32()));continue;case 6:if(50!==e)break;i.listValue=li.unwrap(li.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({nullValue:hi(e.nullValue)?ai(e.nullValue):void 0,numberValue:hi(e.numberValue)?globalThis.Number(e.numberValue):void 0,stringValue:hi(e.stringValue)?globalThis.String(e.stringValue):void 0,boolValue:hi(e.boolValue)?globalThis.Boolean(e.boolValue):void 0,structValue:pi(e.structValue)?e.structValue:void 0,listValue:globalThis.Array.isArray(e.listValue)?[...e.listValue]:void 0}),toJSON(e){const t={};return void 0!==e.nullValue&&(t.nullValue=function(e){switch(e){case oi.NULL_VALUE:return"NULL_VALUE";case oi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.nullValue)),void 0!==e.numberValue&&(t.numberValue=e.numberValue),void 0!==e.stringValue&&(t.stringValue=e.stringValue),void 0!==e.boolValue&&(t.boolValue=e.boolValue),void 0!==e.structValue&&(t.structValue=e.structValue),void 0!==e.listValue&&(t.listValue=e.listValue),t},create:e=>ui.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s,o;const a={nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0};return a.nullValue=null!==(t=e.nullValue)&&void 0!==t?t:void 0,a.numberValue=null!==(r=e.numberValue)&&void 0!==r?r:void 0,a.stringValue=null!==(n=e.stringValue)&&void 0!==n?n:void 0,a.boolValue=null!==(i=e.boolValue)&&void 0!==i?i:void 0,a.structValue=null!==(s=e.structValue)&&void 0!==s?s:void 0,a.listValue=null!==(o=e.listValue)&&void 0!==o?o:void 0,a},wrap(e){const t={nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0};if(null===e)t.nullValue=oi.NULL_VALUE;else if("boolean"==typeof e)t.boolValue=e;else if("number"==typeof e)t.numberValue=e;else if("string"==typeof e)t.stringValue=e;else if(globalThis.Array.isArray(e))t.listValue=e;else if("object"==typeof e)t.structValue=e;else if(void 0!==e)throw new globalThis.Error("Unsupported any value type: "+typeof e);return t},unwrap:e=>void 0!==e.stringValue?e.stringValue:void 0!==(null==e?void 0:e.numberValue)?e.numberValue:void 0!==(null==e?void 0:e.boolValue)?e.boolValue:void 0!==(null==e?void 0:e.structValue)?e.structValue:void 0!==(null==e?void 0:e.listValue)?e.listValue:void 0!==(null==e?void 0:e.nullValue)?null:void 0};const li={encode(e,t=new ei){for(const r of e.values)ui.encode(ui.wrap(r),t.uint32(10).fork()).join();return t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={values:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.values.push(ui.unwrap(ui.decode(r,r.uint32())));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({values:globalThis.Array.isArray(null==e?void 0:e.values)?[...e.values]:[]}),toJSON(e){var t;const r={};return(null===(t=e.values)||void 0===t?void 0:t.length)&&(r.values=e.values),r},create:e=>li.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={values:[]};return r.values=(null===(t=e.values)||void 0===t?void 0:t.map((e=>e)))||[],r},wrap(e){const t={values:[]};return t.values=null!=e?e:[],t},unwrap:e=>(null==e?void 0:e.hasOwnProperty("values"))&&globalThis.Array.isArray(e.values)?e.values:e};function pi(e){return"object"==typeof e&&null!==e}function hi(e){return null!=e}const fi={encode:(e,t=new ei)=>(Object.entries(e.event).forEach((([e,r])=>{void 0!==r&&mi.encode({key:e,value:r},t.uint32(10).fork()).join()})),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={event:{}};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:{if(10!==e)break;const t=mi.decode(r,r.uint32());void 0!==t.value&&(i.event[t.key]=t.value);continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON(e){return{event:(t=e.event,"object"==typeof t&&null!==t?Object.entries(e.event).reduce(((e,[t,r])=>(e[t]=r,e)),{}):{})};var t},toJSON(e){const t={};if(e.event){const r=Object.entries(e.event);r.length>0&&(t.event={},r.forEach((([e,r])=>{t.event[e]=r})))}return t},create:e=>fi.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={event:{}};return r.event=Object.entries(null!==(t=e.event)&&void 0!==t?t:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=r),e)),{}),r}};const mi={encode:(e,t=new ei)=>(""!==e.key&&t.uint32(10).string(e.key),void 0!==e.value&&ui.encode(ui.wrap(e.value),t.uint32(18).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={key:"",value:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.key=r.string();continue;case 2:if(18!==e)break;i.value=ui.unwrap(ui.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({key:gi(e.key)?globalThis.String(e.key):"",value:gi(null==e?void 0:e.value)?e.value:void 0}),toJSON(e){const t={};return""!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},create:e=>mi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={key:"",value:void 0};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:void 0,n}};function gi(e){return null!=e}var vi,yi;function _i(e){switch(e){case 0:case"PEER_GROUP_UNSPECIFIED":return vi.PEER_GROUP_UNSPECIFIED;case 1:case"PEER_GROUP_MODERATOR":return vi.PEER_GROUP_MODERATOR;case 2:case"PEER_GROUP_USER":return vi.PEER_GROUP_USER;default:return vi.UNRECOGNIZED}}function bi(e){switch(e){case vi.PEER_GROUP_UNSPECIFIED:return"PEER_GROUP_UNSPECIFIED";case vi.PEER_GROUP_MODERATOR:return"PEER_GROUP_MODERATOR";case vi.PEER_GROUP_USER:return"PEER_GROUP_USER";case vi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function Ei(e){switch(e){case 0:case"PRODUCER_LABEL_UNSPECIFIED":return yi.PRODUCER_LABEL_UNSPECIFIED;case 1:case"PRODUCER_LABEL_CAMERA":return yi.PRODUCER_LABEL_CAMERA;case 2:case"PRODUCER_LABEL_MICROPHONE":return yi.PRODUCER_LABEL_MICROPHONE;case 3:case"PRODUCER_LABEL_SCREEN_VIDEO":return yi.PRODUCER_LABEL_SCREEN_VIDEO;case 4:case"PRODUCER_LABEL_SCREEN_AUDIO":return yi.PRODUCER_LABEL_SCREEN_AUDIO;case 5:case"PRODUCER_LABEL_CUSTOM_VIDEO":return yi.PRODUCER_LABEL_CUSTOM_VIDEO;case 6:case"PRODUCER_LABEL_CUSTOM_AUDIO":return yi.PRODUCER_LABEL_CUSTOM_AUDIO;case 7:case"PRODUCER_LABEL_UNKNOWN":return yi.PRODUCER_LABEL_UNKNOWN;default:return yi.UNRECOGNIZED}}function wi(e){switch(e){case yi.PRODUCER_LABEL_UNSPECIFIED:return"PRODUCER_LABEL_UNSPECIFIED";case yi.PRODUCER_LABEL_CAMERA:return"PRODUCER_LABEL_CAMERA";case yi.PRODUCER_LABEL_MICROPHONE:return"PRODUCER_LABEL_MICROPHONE";case yi.PRODUCER_LABEL_SCREEN_VIDEO:return"PRODUCER_LABEL_SCREEN_VIDEO";case yi.PRODUCER_LABEL_SCREEN_AUDIO:return"PRODUCER_LABEL_SCREEN_AUDIO";case yi.PRODUCER_LABEL_CUSTOM_VIDEO:return"PRODUCER_LABEL_CUSTOM_VIDEO";case yi.PRODUCER_LABEL_CUSTOM_AUDIO:return"PRODUCER_LABEL_CUSTOM_AUDIO";case yi.PRODUCER_LABEL_UNKNOWN:return"PRODUCER_LABEL_UNKNOWN";case yi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.PEER_GROUP_UNSPECIFIED=0]="PEER_GROUP_UNSPECIFIED",e[e.PEER_GROUP_MODERATOR=1]="PEER_GROUP_MODERATOR",e[e.PEER_GROUP_USER=2]="PEER_GROUP_USER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(vi||(vi={})),function(e){e[e.PRODUCER_LABEL_UNSPECIFIED=0]="PRODUCER_LABEL_UNSPECIFIED",e[e.PRODUCER_LABEL_CAMERA=1]="PRODUCER_LABEL_CAMERA",e[e.PRODUCER_LABEL_MICROPHONE=2]="PRODUCER_LABEL_MICROPHONE",e[e.PRODUCER_LABEL_SCREEN_VIDEO=3]="PRODUCER_LABEL_SCREEN_VIDEO",e[e.PRODUCER_LABEL_SCREEN_AUDIO=4]="PRODUCER_LABEL_SCREEN_AUDIO",e[e.PRODUCER_LABEL_CUSTOM_VIDEO=5]="PRODUCER_LABEL_CUSTOM_VIDEO",e[e.PRODUCER_LABEL_CUSTOM_AUDIO=6]="PRODUCER_LABEL_CUSTOM_AUDIO",e[e.PRODUCER_LABEL_UNKNOWN=7]="PRODUCER_LABEL_UNKNOWN",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(yi||(yi={}));const Si={encode(e,t=new ei){t.uint32(10).fork();for(const r of e.groups)t.int32(r);t.join(),t.uint32(18).fork();for(const r of e.producePermissions)t.int32(r);t.join(),t.uint32(26).fork();for(const r of e.changedProducePermissions)t.int32(r);return t.join(),t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={groups:[],producePermissions:[],changedProducePermissions:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8===e){i.groups.push(r.int32());continue}if(10===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.groups.push(r.int32());continue}break;case 2:if(16===e){i.producePermissions.push(r.int32());continue}if(18===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.producePermissions.push(r.int32());continue}break;case 3:if(24===e){i.changedProducePermissions.push(r.int32());continue}if(26===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.changedProducePermissions.push(r.int32());continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({groups:globalThis.Array.isArray(null==e?void 0:e.groups)?e.groups.map((e=>_i(e))):[],producePermissions:globalThis.Array.isArray(null==e?void 0:e.producePermissions)?e.producePermissions.map((e=>Ei(e))):[],changedProducePermissions:globalThis.Array.isArray(null==e?void 0:e.changedProducePermissions)?e.changedProducePermissions.map((e=>Ei(e))):[]}),toJSON(e){var t,r,n;const i={};return(null===(t=e.groups)||void 0===t?void 0:t.length)&&(i.groups=e.groups.map((e=>bi(e)))),(null===(r=e.producePermissions)||void 0===r?void 0:r.length)&&(i.producePermissions=e.producePermissions.map((e=>wi(e)))),(null===(n=e.changedProducePermissions)||void 0===n?void 0:n.length)&&(i.changedProducePermissions=e.changedProducePermissions.map((e=>wi(e)))),i},create:e=>Si.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n;const i={groups:[],producePermissions:[],changedProducePermissions:[]};return i.groups=(null===(t=e.groups)||void 0===t?void 0:t.map((e=>e)))||[],i.producePermissions=(null===(r=e.producePermissions)||void 0===r?void 0:r.map((e=>e)))||[],i.changedProducePermissions=(null===(n=e.changedProducePermissions)||void 0===n?void 0:n.map((e=>e)))||[],i}};const Ci={encode:(e,t=new ei)=>(0!==e.seconds&&t.uint32(8).int64(e.seconds),0!==e.nanos&&t.uint32(16).int32(e.nanos),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={seconds:0,nanos:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.seconds=Pi(r.int64());continue;case 2:if(16!==e)break;i.nanos=r.int32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({seconds:Ti(e.seconds)?globalThis.Number(e.seconds):0,nanos:Ti(e.nanos)?globalThis.Number(e.nanos):0}),toJSON(e){const t={};return 0!==e.seconds&&(t.seconds=Math.round(e.seconds)),0!==e.nanos&&(t.nanos=Math.round(e.nanos)),t},create:e=>Ci.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={seconds:0,nanos:0};return n.seconds=null!==(t=e.seconds)&&void 0!==t?t:0,n.nanos=null!==(r=e.nanos)&&void 0!==r?r:0,n}};function Pi(e){const t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}function Ti(e){return null!=e}var Ri;function ki(e){switch(e){case 0:case"PRODUCER_KIND_UNSPECIFIED":return Ri.PRODUCER_KIND_UNSPECIFIED;case 1:case"PRODUCER_KIND_AUDIO":return Ri.PRODUCER_KIND_AUDIO;case 2:case"PRODUCER_KIND_VIDEO":return Ri.PRODUCER_KIND_VIDEO;default:return Ri.UNRECOGNIZED}}!function(e){e[e.PRODUCER_KIND_UNSPECIFIED=0]="PRODUCER_KIND_UNSPECIFIED",e[e.PRODUCER_KIND_AUDIO=1]="PRODUCER_KIND_AUDIO",e[e.PRODUCER_KIND_VIDEO=2]="PRODUCER_KIND_VIDEO",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ri||(Ri={}));const Di={encode(e,t=new ei){""!==e.id&&t.uint32(10).string(e.id),0!==e.kind&&t.uint32(16).int32(e.kind),0!==e.label&&t.uint32(24).int32(e.label),""!==e.peerId&&t.uint32(34).string(e.peerId),!1!==e.paused&&t.uint32(40).bool(e.paused);for(const r of e.encodings)ui.encode(ui.wrap(r),t.uint32(50).fork()).join();return void 0!==e.maxSpatialLayer&&t.uint32(56).uint32(e.maxSpatialLayer),t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={id:"",kind:0,label:0,peerId:"",paused:!1,encodings:[],maxSpatialLayer:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(16!==e)break;i.kind=r.int32();continue;case 3:if(24!==e)break;i.label=r.int32();continue;case 4:if(34!==e)break;i.peerId=r.string();continue;case 5:if(40!==e)break;i.paused=r.bool();continue;case 6:if(50!==e)break;i.encodings.push(ui.unwrap(ui.decode(r,r.uint32())));continue;case 7:if(56!==e)break;i.maxSpatialLayer=r.uint32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:Ii(e.id)?globalThis.String(e.id):"",kind:Ii(e.kind)?ki(e.kind):0,label:Ii(e.label)?Ei(e.label):0,peerId:Ii(e.peerId)?globalThis.String(e.peerId):"",paused:!!Ii(e.paused)&&globalThis.Boolean(e.paused),encodings:globalThis.Array.isArray(null==e?void 0:e.encodings)?[...e.encodings]:[],maxSpatialLayer:Ii(e.maxSpatialLayer)?globalThis.Number(e.maxSpatialLayer):void 0}),toJSON(e){var t;const r={};return""!==e.id&&(r.id=e.id),0!==e.kind&&(r.kind=function(e){switch(e){case Ri.PRODUCER_KIND_UNSPECIFIED:return"PRODUCER_KIND_UNSPECIFIED";case Ri.PRODUCER_KIND_AUDIO:return"PRODUCER_KIND_AUDIO";case Ri.PRODUCER_KIND_VIDEO:return"PRODUCER_KIND_VIDEO";case Ri.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.kind)),0!==e.label&&(r.label=wi(e.label)),""!==e.peerId&&(r.peerId=e.peerId),!1!==e.paused&&(r.paused=e.paused),(null===(t=e.encodings)||void 0===t?void 0:t.length)&&(r.encodings=e.encodings),void 0!==e.maxSpatialLayer&&(r.maxSpatialLayer=Math.round(e.maxSpatialLayer)),r},create:e=>Di.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s,o,a;const c={id:"",kind:0,label:0,peerId:"",paused:!1,encodings:[],maxSpatialLayer:void 0};return c.id=null!==(t=e.id)&&void 0!==t?t:"",c.kind=null!==(r=e.kind)&&void 0!==r?r:0,c.label=null!==(n=e.label)&&void 0!==n?n:0,c.peerId=null!==(i=e.peerId)&&void 0!==i?i:"",c.paused=null!==(s=e.paused)&&void 0!==s&&s,c.encodings=(null===(o=e.encodings)||void 0===o?void 0:o.map((e=>e)))||[],c.maxSpatialLayer=null!==(a=e.maxSpatialLayer)&&void 0!==a?a:void 0,c}};function Ii(e){return null!=e}var Ai;function Oi(e){switch(e){case 0:case"PEER_ROLE_UNSPECIFIED":return Ai.PEER_ROLE_UNSPECIFIED;case 1:case"PEER_ROLE_HOST":return Ai.PEER_ROLE_HOST;case 2:case"PEER_ROLE_AUDIENCE":return Ai.PEER_ROLE_AUDIENCE;default:return Ai.UNRECOGNIZED}}!function(e){e[e.PEER_ROLE_UNSPECIFIED=0]="PEER_ROLE_UNSPECIFIED",e[e.PEER_ROLE_HOST=1]="PEER_ROLE_HOST",e[e.PEER_ROLE_AUDIENCE=2]="PEER_ROLE_AUDIENCE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ai||(Ai={}));const Ni={encode(e,t=new ei){""!==e.id&&t.uint32(10).string(e.id);for(const r of e.channelIds)t.uint32(18).string(r);for(const r of e.producers)Di.encode(r,t.uint32(26).fork()).join();""!==e.uid&&t.uint32(50).string(e.uid),""!==e.appId&&t.uint32(58).string(e.appId),Object.entries(e.appData).forEach((([e,r])=>{void 0!==r&&Mi.encode({key:e,value:r},t.uint32(66).fork()).join()})),0!==e.role&&t.uint32(72).int32(e.role),void 0!==e.loginDate&&Ci.encode(function(e){const t=Math.trunc(e.getTime()/1e3),r=e.getTime()%1e3*1e6;return{seconds:t,nanos:r}}(e.loginDate),t.uint32(82).fork()).join(),t.uint32(90).fork();for(const r of e.groups)t.int32(r);t.join(),t.uint32(98).fork();for(const r of e.producePermissions)t.int32(r);return t.join(),t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={id:"",channelIds:[],producers:[],uid:"",appId:"",appData:{},role:0,loginDate:void 0,groups:[],producePermissions:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(18!==e)break;i.channelIds.push(r.string());continue;case 3:if(26!==e)break;i.producers.push(Di.decode(r,r.uint32()));continue;case 6:if(50!==e)break;i.uid=r.string();continue;case 7:if(58!==e)break;i.appId=r.string();continue;case 8:{if(66!==e)break;const t=Mi.decode(r,r.uint32());void 0!==t.value&&(i.appData[t.key]=t.value);continue}case 9:if(72!==e)break;i.role=r.int32();continue;case 10:if(82!==e)break;i.loginDate=Li(Ci.decode(r,r.uint32()));continue;case 11:if(88===e){i.groups.push(r.int32());continue}if(90===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.groups.push(r.int32());continue}break;case 12:if(96===e){i.producePermissions.push(r.int32());continue}if(98===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.producePermissions.push(r.int32());continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON(e){return{id:Fi(e.id)?globalThis.String(e.id):"",channelIds:globalThis.Array.isArray(null==e?void 0:e.channelIds)?e.channelIds.map((e=>globalThis.String(e))):[],producers:globalThis.Array.isArray(null==e?void 0:e.producers)?e.producers.map((e=>Di.fromJSON(e))):[],uid:Fi(e.uid)?globalThis.String(e.uid):"",appId:Fi(e.appId)?globalThis.String(e.appId):"",appData:(t=e.appData,"object"==typeof t&&null!==t?Object.entries(e.appData).reduce(((e,[t,r])=>(e[t]=r,e)),{}):{}),role:Fi(e.role)?Oi(e.role):0,loginDate:Fi(e.loginDate)?xi(e.loginDate):void 0,groups:globalThis.Array.isArray(null==e?void 0:e.groups)?e.groups.map((e=>_i(e))):[],producePermissions:globalThis.Array.isArray(null==e?void 0:e.producePermissions)?e.producePermissions.map((e=>Ei(e))):[]};var t},toJSON(e){var t,r,n,i;const s={};if(""!==e.id&&(s.id=e.id),(null===(t=e.channelIds)||void 0===t?void 0:t.length)&&(s.channelIds=e.channelIds),(null===(r=e.producers)||void 0===r?void 0:r.length)&&(s.producers=e.producers.map((e=>Di.toJSON(e)))),""!==e.uid&&(s.uid=e.uid),""!==e.appId&&(s.appId=e.appId),e.appData){const t=Object.entries(e.appData);t.length>0&&(s.appData={},t.forEach((([e,t])=>{s.appData[e]=t})))}return 0!==e.role&&(s.role=function(e){switch(e){case Ai.PEER_ROLE_UNSPECIFIED:return"PEER_ROLE_UNSPECIFIED";case Ai.PEER_ROLE_HOST:return"PEER_ROLE_HOST";case Ai.PEER_ROLE_AUDIENCE:return"PEER_ROLE_AUDIENCE";case Ai.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.role)),void 0!==e.loginDate&&(s.loginDate=e.loginDate.toISOString()),(null===(n=e.groups)||void 0===n?void 0:n.length)&&(s.groups=e.groups.map((e=>bi(e)))),(null===(i=e.producePermissions)||void 0===i?void 0:i.length)&&(s.producePermissions=e.producePermissions.map((e=>wi(e)))),s},create:e=>Ni.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s,o,a,c,d,u;const l={id:"",channelIds:[],producers:[],uid:"",appId:"",appData:{},role:0,loginDate:void 0,groups:[],producePermissions:[]};return l.id=null!==(t=e.id)&&void 0!==t?t:"",l.channelIds=(null===(r=e.channelIds)||void 0===r?void 0:r.map((e=>e)))||[],l.producers=(null===(n=e.producers)||void 0===n?void 0:n.map((e=>Di.fromPartial(e))))||[],l.uid=null!==(i=e.uid)&&void 0!==i?i:"",l.appId=null!==(s=e.appId)&&void 0!==s?s:"",l.appData=Object.entries(null!==(o=e.appData)&&void 0!==o?o:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=r),e)),{}),l.role=null!==(a=e.role)&&void 0!==a?a:0,l.loginDate=null!==(c=e.loginDate)&&void 0!==c?c:void 0,l.groups=(null===(d=e.groups)||void 0===d?void 0:d.map((e=>e)))||[],l.producePermissions=(null===(u=e.producePermissions)||void 0===u?void 0:u.map((e=>e)))||[],l}};const Mi={encode:(e,t=new ei)=>(""!==e.key&&t.uint32(10).string(e.key),void 0!==e.value&&ui.encode(ui.wrap(e.value),t.uint32(18).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={key:"",value:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.key=r.string();continue;case 2:if(18!==e)break;i.value=ui.unwrap(ui.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({key:Fi(e.key)?globalThis.String(e.key):"",value:Fi(null==e?void 0:e.value)?e.value:void 0}),toJSON(e){const t={};return""!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},create:e=>Mi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={key:"",value:void 0};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:void 0,n}};function Li(e){let t=1e3*(e.seconds||0);return t+=(e.nanos||0)/1e6,new globalThis.Date(t)}function xi(e){return e instanceof globalThis.Date?e:"string"==typeof e?new globalThis.Date(e):Li(Ci.fromJSON(e))}function Fi(e){return null!=e}const ji={encode(e,t=new ei){for(const r of e.peers)Ni.encode(r,t.uint32(10).fork()).join();return t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={peers:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.peers.push(Ni.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({peers:globalThis.Array.isArray(null==e?void 0:e.peers)?e.peers.map((e=>Ni.fromJSON(e))):[]}),toJSON(e){var t;const r={};return(null===(t=e.peers)||void 0===t?void 0:t.length)&&(r.peers=e.peers.map((e=>Ni.toJSON(e)))),r},create:e=>ji.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={peers:[]};return r.peers=(null===(t=e.peers)||void 0===t?void 0:t.map((e=>Ni.fromPartial(e))))||[],r}};const Ui={encode:(e,t=new ei)=>(""!==e.id&&t.uint32(10).string(e.id),!1!==e.paused&&t.uint32(16).bool(e.paused),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={id:"",paused:!1};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(16!==e)break;i.paused=r.bool();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:Wi(e.id)?globalThis.String(e.id):"",paused:!!Wi(e.paused)&&globalThis.Boolean(e.paused)}),toJSON(e){const t={};return""!==e.id&&(t.id=e.id),!1!==e.paused&&(t.paused=e.paused),t},create:e=>Ui.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={id:"",paused:!1};return n.id=null!==(t=e.id)&&void 0!==t?t:"",n.paused=null!==(r=e.paused)&&void 0!==r&&r,n}};const Vi={encode(e,t=new ei){""!==e.id&&t.uint32(10).string(e.id);for(const r of e.producers)Ui.encode(r,t.uint32(18).fork()).join();return void 0!==e.appDataHash&&t.uint32(26).string(e.appDataHash),t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={id:"",producers:[],appDataHash:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(18!==e)break;i.producers.push(Ui.decode(r,r.uint32()));continue;case 3:if(26!==e)break;i.appDataHash=r.string();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:Wi(e.id)?globalThis.String(e.id):"",producers:globalThis.Array.isArray(null==e?void 0:e.producers)?e.producers.map((e=>Ui.fromJSON(e))):[],appDataHash:Wi(e.appDataHash)?globalThis.String(e.appDataHash):void 0}),toJSON(e){var t;const r={};return""!==e.id&&(r.id=e.id),(null===(t=e.producers)||void 0===t?void 0:t.length)&&(r.producers=e.producers.map((e=>Ui.toJSON(e)))),void 0!==e.appDataHash&&(r.appDataHash=e.appDataHash),r},create:e=>Vi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n;const i={id:"",producers:[],appDataHash:void 0};return i.id=null!==(t=e.id)&&void 0!==t?t:"",i.producers=(null===(r=e.producers)||void 0===r?void 0:r.map((e=>Ui.fromPartial(e))))||[],i.appDataHash=null!==(n=e.appDataHash)&&void 0!==n?n:void 0,i}};const Bi={encode(e,t=new ei){for(const r of e.peers)Vi.encode(r,t.uint32(10).fork()).join();return t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={peers:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.peers.push(Vi.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({peers:globalThis.Array.isArray(null==e?void 0:e.peers)?e.peers.map((e=>Vi.fromJSON(e))):[]}),toJSON(e){var t;const r={};return(null===(t=e.peers)||void 0===t?void 0:t.length)&&(r.peers=e.peers.map((e=>Vi.toJSON(e)))),r},create:e=>Bi.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={peers:[]};return r.peers=(null===(t=e.peers)||void 0===t?void 0:t.map((e=>Vi.fromPartial(e))))||[],r}};function Wi(e){return null!=e}var Hi;function qi(e){switch(e){case 0:case"CHANNEL_EVENT_TYPE_UNSPECIFIED":return Hi.CHANNEL_EVENT_TYPE_UNSPECIFIED;case 1:case"CHANNEL_EVENT_TYPE_CHANNEL_STATE":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_STATE;case 2:case"CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT;case 3:case"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED;case 4:case"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED;case 5:case"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED;case 6:case"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED;case 7:case"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED;case 8:case"CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT;case 14:case"CHANNEL_EVENT_TYPE_PEER_JOINED":return Hi.CHANNEL_EVENT_TYPE_PEER_JOINED;case 15:case"CHANNEL_EVENT_TYPE_PEER_LEFT":return Hi.CHANNEL_EVENT_TYPE_PEER_LEFT;case 16:case"CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED":return Hi.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED;case 17:case"CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED":return Hi.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED;case 18:case"CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED":return Hi.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED;default:return Hi.UNRECOGNIZED}}function zi(e){switch(e){case Hi.CHANNEL_EVENT_TYPE_UNSPECIFIED:return"CHANNEL_EVENT_TYPE_UNSPECIFIED";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_STATE:return"CHANNEL_EVENT_TYPE_CHANNEL_STATE";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT:return"CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED:return"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED:return"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED:return"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED:return"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED:return"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT:return"CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT";case Hi.CHANNEL_EVENT_TYPE_PEER_JOINED:return"CHANNEL_EVENT_TYPE_PEER_JOINED";case Hi.CHANNEL_EVENT_TYPE_PEER_LEFT:return"CHANNEL_EVENT_TYPE_PEER_LEFT";case Hi.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED:return"CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED";case Hi.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED:return"CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED";case Hi.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED:return"CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED";case Hi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.CHANNEL_EVENT_TYPE_UNSPECIFIED=0]="CHANNEL_EVENT_TYPE_UNSPECIFIED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_STATE=1]="CHANNEL_EVENT_TYPE_CHANNEL_STATE",e[e.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT=2]="CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT",e[e.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED=3]="CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED=4]="CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED=5]="CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED=6]="CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED=7]="CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT=8]="CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT",e[e.CHANNEL_EVENT_TYPE_PEER_JOINED=14]="CHANNEL_EVENT_TYPE_PEER_JOINED",e[e.CHANNEL_EVENT_TYPE_PEER_LEFT=15]="CHANNEL_EVENT_TYPE_PEER_LEFT",e[e.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED=16]="CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED",e[e.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED=17]="CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED",e[e.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED=18]="CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Hi||(Hi={}));const Gi={encode:(e,t=new ei)=>(0!==e.eventType&&t.uint32(8).int32(e.eventType),void 0!==e.channelState&&ji.encode(e.channelState,t.uint32(18).fork()).join(),void 0!==e.channelStateShort&&Bi.encode(e.channelStateShort,t.uint32(26).fork()).join(),void 0!==e.channelActivityConfirmationTime&&ii.encode(e.channelActivityConfirmationTime,t.uint32(34).fork()).join(),void 0!==e.channelManagementEvent&&fi.encode(e.channelManagementEvent,t.uint32(42).fork()).join(),void 0!==e.channelProducePermissions&&Si.encode(e.channelProducePermissions,t.uint32(50).fork()).join(),void 0!==e.peer&&Ni.encode(e.peer,t.uint32(58).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={eventType:0,channelState:void 0,channelStateShort:void 0,channelActivityConfirmationTime:void 0,channelManagementEvent:void 0,channelProducePermissions:void 0,peer:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.eventType=r.int32();continue;case 2:if(18!==e)break;i.channelState=ji.decode(r,r.uint32());continue;case 3:if(26!==e)break;i.channelStateShort=Bi.decode(r,r.uint32());continue;case 4:if(34!==e)break;i.channelActivityConfirmationTime=ii.decode(r,r.uint32());continue;case 5:if(42!==e)break;i.channelManagementEvent=fi.decode(r,r.uint32());continue;case 6:if(50!==e)break;i.channelProducePermissions=Si.decode(r,r.uint32());continue;case 7:if(58!==e)break;i.peer=Ni.decode(r,r.uint32());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({eventType:Yi(e.eventType)?qi(e.eventType):0,channelState:Yi(e.channelState)?ji.fromJSON(e.channelState):void 0,channelStateShort:Yi(e.channelStateShort)?Bi.fromJSON(e.channelStateShort):void 0,channelActivityConfirmationTime:Yi(e.channelActivityConfirmationTime)?ii.fromJSON(e.channelActivityConfirmationTime):void 0,channelManagementEvent:Yi(e.channelManagementEvent)?fi.fromJSON(e.channelManagementEvent):void 0,channelProducePermissions:Yi(e.channelProducePermissions)?Si.fromJSON(e.channelProducePermissions):void 0,peer:Yi(e.peer)?Ni.fromJSON(e.peer):void 0}),toJSON(e){const t={};return 0!==e.eventType&&(t.eventType=zi(e.eventType)),void 0!==e.channelState&&(t.channelState=ji.toJSON(e.channelState)),void 0!==e.channelStateShort&&(t.channelStateShort=Bi.toJSON(e.channelStateShort)),void 0!==e.channelActivityConfirmationTime&&(t.channelActivityConfirmationTime=ii.toJSON(e.channelActivityConfirmationTime)),void 0!==e.channelManagementEvent&&(t.channelManagementEvent=fi.toJSON(e.channelManagementEvent)),void 0!==e.channelProducePermissions&&(t.channelProducePermissions=Si.toJSON(e.channelProducePermissions)),void 0!==e.peer&&(t.peer=Ni.toJSON(e.peer)),t},create:e=>Gi.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={eventType:0,channelState:void 0,channelStateShort:void 0,channelActivityConfirmationTime:void 0,channelManagementEvent:void 0,channelProducePermissions:void 0,peer:void 0};return r.eventType=null!==(t=e.eventType)&&void 0!==t?t:0,r.channelState=void 0!==e.channelState&&null!==e.channelState?ji.fromPartial(e.channelState):void 0,r.channelStateShort=void 0!==e.channelStateShort&&null!==e.channelStateShort?Bi.fromPartial(e.channelStateShort):void 0,r.channelActivityConfirmationTime=void 0!==e.channelActivityConfirmationTime&&null!==e.channelActivityConfirmationTime?ii.fromPartial(e.channelActivityConfirmationTime):void 0,r.channelManagementEvent=void 0!==e.channelManagementEvent&&null!==e.channelManagementEvent?fi.fromPartial(e.channelManagementEvent):void 0,r.channelProducePermissions=void 0!==e.channelProducePermissions&&null!==e.channelProducePermissions?Si.fromPartial(e.channelProducePermissions):void 0,r.peer=void 0!==e.peer&&null!==e.peer?Ni.fromPartial(e.peer):void 0,r}};function Yi(e){return null!=e}const $i={encode:(e,t=new ei)=>(""!==e.id&&t.uint32(10).string(e.id),""!==e.peerId&&t.uint32(18).string(e.peerId),""!==e.producerPeerId&&t.uint32(26).string(e.producerPeerId),void 0!==e.spatialLayer&&t.uint32(32).uint32(e.spatialLayer),void 0!==e.temporalLayer&&t.uint32(40).uint32(e.temporalLayer),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={id:"",peerId:"",producerPeerId:"",spatialLayer:void 0,temporalLayer:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(18!==e)break;i.peerId=r.string();continue;case 3:if(26!==e)break;i.producerPeerId=r.string();continue;case 4:if(32!==e)break;i.spatialLayer=r.uint32();continue;case 5:if(40!==e)break;i.temporalLayer=r.uint32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:Ji(e.id)?globalThis.String(e.id):"",peerId:Ji(e.peerId)?globalThis.String(e.peerId):"",producerPeerId:Ji(e.producerPeerId)?globalThis.String(e.producerPeerId):"",spatialLayer:Ji(e.spatialLayer)?globalThis.Number(e.spatialLayer):void 0,temporalLayer:Ji(e.temporalLayer)?globalThis.Number(e.temporalLayer):void 0}),toJSON(e){const t={};return""!==e.id&&(t.id=e.id),""!==e.peerId&&(t.peerId=e.peerId),""!==e.producerPeerId&&(t.producerPeerId=e.producerPeerId),void 0!==e.spatialLayer&&(t.spatialLayer=Math.round(e.spatialLayer)),void 0!==e.temporalLayer&&(t.temporalLayer=Math.round(e.temporalLayer)),t},create:e=>$i.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s;const o={id:"",peerId:"",producerPeerId:"",spatialLayer:void 0,temporalLayer:void 0};return o.id=null!==(t=e.id)&&void 0!==t?t:"",o.peerId=null!==(r=e.peerId)&&void 0!==r?r:"",o.producerPeerId=null!==(n=e.producerPeerId)&&void 0!==n?n:"",o.spatialLayer=null!==(i=e.spatialLayer)&&void 0!==i?i:void 0,o.temporalLayer=null!==(s=e.temporalLayer)&&void 0!==s?s:void 0,o}};function Ji(e){return null!=e}const Ki={encode:(e,t=new ei)=>(""!==e.producerId&&t.uint32(10).string(e.producerId),0!==e.spatialLayer&&t.uint32(16).uint32(e.spatialLayer),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={producerId:"",spatialLayer:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.producerId=r.string();continue;case 2:if(16!==e)break;i.spatialLayer=r.uint32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({producerId:Qi(e.producerId)?globalThis.String(e.producerId):"",spatialLayer:Qi(e.spatialLayer)?globalThis.Number(e.spatialLayer):0}),toJSON(e){const t={};return""!==e.producerId&&(t.producerId=e.producerId),0!==e.spatialLayer&&(t.spatialLayer=Math.round(e.spatialLayer)),t},create:e=>Ki.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={producerId:"",spatialLayer:0};return n.producerId=null!==(t=e.producerId)&&void 0!==t?t:"",n.spatialLayer=null!==(r=e.spatialLayer)&&void 0!==r?r:0,n}};function Qi(e){return null!=e}var Zi,Xi;function es(e){switch(e){case 0:case"TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED":return Zi.TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED;case 1:case"TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS":return Zi.TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS;case 2:case"TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE":return Zi.TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE;default:return Zi.UNRECOGNIZED}}function ts(e){switch(e){case 0:case"TRANSPORT_DIRECTION_UNSPECIFIED":return Xi.TRANSPORT_DIRECTION_UNSPECIFIED;case 1:case"TRANSPORT_DIRECTION_SEND":return Xi.TRANSPORT_DIRECTION_SEND;case 2:case"TRANSPORT_DIRECTION_RECEIVE":return Xi.TRANSPORT_DIRECTION_RECEIVE;default:return Xi.UNRECOGNIZED}}!function(e){e[e.TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED=0]="TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED",e[e.TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS=1]="TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS",e[e.TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE=2]="TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Zi||(Zi={})),function(e){e[e.TRANSPORT_DIRECTION_UNSPECIFIED=0]="TRANSPORT_DIRECTION_UNSPECIFIED",e[e.TRANSPORT_DIRECTION_SEND=1]="TRANSPORT_DIRECTION_SEND",e[e.TRANSPORT_DIRECTION_RECEIVE=2]="TRANSPORT_DIRECTION_RECEIVE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Xi||(Xi={}));const rs={encode:(e,t=new ei)=>(""!==e.transportId&&t.uint32(10).string(e.transportId),0!==e.timeout&&t.uint32(16).uint32(e.timeout),0!==e.direction&&t.uint32(24).int32(e.direction),0!==e.reason&&t.uint32(32).int32(e.reason),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={transportId:"",timeout:0,direction:0,reason:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.transportId=r.string();continue;case 2:if(16!==e)break;i.timeout=r.uint32();continue;case 3:if(24!==e)break;i.direction=r.int32();continue;case 4:if(32!==e)break;i.reason=r.int32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({transportId:ns(e.transportId)?globalThis.String(e.transportId):"",timeout:ns(e.timeout)?globalThis.Number(e.timeout):0,direction:ns(e.direction)?ts(e.direction):0,reason:ns(e.reason)?es(e.reason):0}),toJSON(e){const t={};return""!==e.transportId&&(t.transportId=e.transportId),0!==e.timeout&&(t.timeout=Math.round(e.timeout)),0!==e.direction&&(t.direction=function(e){switch(e){case Xi.TRANSPORT_DIRECTION_UNSPECIFIED:return"TRANSPORT_DIRECTION_UNSPECIFIED";case Xi.TRANSPORT_DIRECTION_SEND:return"TRANSPORT_DIRECTION_SEND";case Xi.TRANSPORT_DIRECTION_RECEIVE:return"TRANSPORT_DIRECTION_RECEIVE";case Xi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.direction)),0!==e.reason&&(t.reason=function(e){switch(e){case Zi.TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED:return"TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED";case Zi.TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS:return"TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS";case Zi.TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE:return"TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE";case Zi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.reason)),t},create:e=>rs.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i;const s={transportId:"",timeout:0,direction:0,reason:0};return s.transportId=null!==(t=e.transportId)&&void 0!==t?t:"",s.timeout=null!==(r=e.timeout)&&void 0!==r?r:0,s.direction=null!==(n=e.direction)&&void 0!==n?n:0,s.reason=null!==(i=e.reason)&&void 0!==i?i:0,s}};function ns(e){return null!=e}var is;function ss(e){switch(e){case 0:case"MEDIA_EVENT_TYPE_UNSPECIFIED":return is.MEDIA_EVENT_TYPE_UNSPECIFIED;case 1:case"MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT":return is.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT;case 2:case"MEDIA_EVENT_TYPE_PRODUCER_CREATED":return is.MEDIA_EVENT_TYPE_PRODUCER_CREATED;case 3:case"MEDIA_EVENT_TYPE_PRODUCER_PAUSED":return is.MEDIA_EVENT_TYPE_PRODUCER_PAUSED;case 4:case"MEDIA_EVENT_TYPE_PRODUCER_RESUMED":return is.MEDIA_EVENT_TYPE_PRODUCER_RESUMED;case 5:case"MEDIA_EVENT_TYPE_PRODUCER_CLOSED":return is.MEDIA_EVENT_TYPE_PRODUCER_CLOSED;case 6:case"MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED":return is.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED;case 7:case"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED":return is.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED;case 8:case"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED":return is.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED;case 9:case"MEDIA_EVENT_TYPE_CONSUMER_CLOSED":return is.MEDIA_EVENT_TYPE_CONSUMER_CLOSED;case 10:case"MEDIA_EVENT_TYPE_CONSUMER_PAUSED":return is.MEDIA_EVENT_TYPE_CONSUMER_PAUSED;case 11:case"MEDIA_EVENT_TYPE_CONSUMER_RESUMED":return is.MEDIA_EVENT_TYPE_CONSUMER_RESUMED;case 12:case"MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED":return is.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED;default:return is.UNRECOGNIZED}}function os(e){switch(e){case is.MEDIA_EVENT_TYPE_UNSPECIFIED:return"MEDIA_EVENT_TYPE_UNSPECIFIED";case is.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT:return"MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT";case is.MEDIA_EVENT_TYPE_PRODUCER_CREATED:return"MEDIA_EVENT_TYPE_PRODUCER_CREATED";case is.MEDIA_EVENT_TYPE_PRODUCER_PAUSED:return"MEDIA_EVENT_TYPE_PRODUCER_PAUSED";case is.MEDIA_EVENT_TYPE_PRODUCER_RESUMED:return"MEDIA_EVENT_TYPE_PRODUCER_RESUMED";case is.MEDIA_EVENT_TYPE_PRODUCER_CLOSED:return"MEDIA_EVENT_TYPE_PRODUCER_CLOSED";case is.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED:return"MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED";case is.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED:return"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED";case is.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED:return"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED";case is.MEDIA_EVENT_TYPE_CONSUMER_CLOSED:return"MEDIA_EVENT_TYPE_CONSUMER_CLOSED";case is.MEDIA_EVENT_TYPE_CONSUMER_PAUSED:return"MEDIA_EVENT_TYPE_CONSUMER_PAUSED";case is.MEDIA_EVENT_TYPE_CONSUMER_RESUMED:return"MEDIA_EVENT_TYPE_CONSUMER_RESUMED";case is.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED:return"MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED";case is.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.MEDIA_EVENT_TYPE_UNSPECIFIED=0]="MEDIA_EVENT_TYPE_UNSPECIFIED",e[e.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT=1]="MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT",e[e.MEDIA_EVENT_TYPE_PRODUCER_CREATED=2]="MEDIA_EVENT_TYPE_PRODUCER_CREATED",e[e.MEDIA_EVENT_TYPE_PRODUCER_PAUSED=3]="MEDIA_EVENT_TYPE_PRODUCER_PAUSED",e[e.MEDIA_EVENT_TYPE_PRODUCER_RESUMED=4]="MEDIA_EVENT_TYPE_PRODUCER_RESUMED",e[e.MEDIA_EVENT_TYPE_PRODUCER_CLOSED=5]="MEDIA_EVENT_TYPE_PRODUCER_CLOSED",e[e.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED=6]="MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED",e[e.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED=7]="MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED",e[e.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED=8]="MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED",e[e.MEDIA_EVENT_TYPE_CONSUMER_CLOSED=9]="MEDIA_EVENT_TYPE_CONSUMER_CLOSED",e[e.MEDIA_EVENT_TYPE_CONSUMER_PAUSED=10]="MEDIA_EVENT_TYPE_CONSUMER_PAUSED",e[e.MEDIA_EVENT_TYPE_CONSUMER_RESUMED=11]="MEDIA_EVENT_TYPE_CONSUMER_RESUMED",e[e.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED=12]="MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(is||(is={}));const as={encode:(e,t=new ei)=>(0!==e.eventType&&t.uint32(8).int32(e.eventType),void 0!==e.producer&&Di.encode(e.producer,t.uint32(18).fork()).join(),void 0!==e.consumer&&$i.encode(e.consumer,t.uint32(26).fork()).join(),void 0!==e.producerSpatialLayerRequest&&Ki.encode(e.producerSpatialLayerRequest,t.uint32(34).fork()).join(),void 0!==e.transportConnectionTimeout&&rs.encode(e.transportConnectionTimeout,t.uint32(42).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={eventType:0,producer:void 0,consumer:void 0,producerSpatialLayerRequest:void 0,transportConnectionTimeout:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.eventType=r.int32();continue;case 2:if(18!==e)break;i.producer=Di.decode(r,r.uint32());continue;case 3:if(26!==e)break;i.consumer=$i.decode(r,r.uint32());continue;case 4:if(34!==e)break;i.producerSpatialLayerRequest=Ki.decode(r,r.uint32());continue;case 5:if(42!==e)break;i.transportConnectionTimeout=rs.decode(r,r.uint32());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({eventType:cs(e.eventType)?ss(e.eventType):0,producer:cs(e.producer)?Di.fromJSON(e.producer):void 0,consumer:cs(e.consumer)?$i.fromJSON(e.consumer):void 0,producerSpatialLayerRequest:cs(e.producerSpatialLayerRequest)?Ki.fromJSON(e.producerSpatialLayerRequest):void 0,transportConnectionTimeout:cs(e.transportConnectionTimeout)?rs.fromJSON(e.transportConnectionTimeout):void 0}),toJSON(e){const t={};return 0!==e.eventType&&(t.eventType=os(e.eventType)),void 0!==e.producer&&(t.producer=Di.toJSON(e.producer)),void 0!==e.consumer&&(t.consumer=$i.toJSON(e.consumer)),void 0!==e.producerSpatialLayerRequest&&(t.producerSpatialLayerRequest=Ki.toJSON(e.producerSpatialLayerRequest)),void 0!==e.transportConnectionTimeout&&(t.transportConnectionTimeout=rs.toJSON(e.transportConnectionTimeout)),t},create:e=>as.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={eventType:0,producer:void 0,consumer:void 0,producerSpatialLayerRequest:void 0,transportConnectionTimeout:void 0};return r.eventType=null!==(t=e.eventType)&&void 0!==t?t:0,r.producer=void 0!==e.producer&&null!==e.producer?Di.fromPartial(e.producer):void 0,r.consumer=void 0!==e.consumer&&null!==e.consumer?$i.fromPartial(e.consumer):void 0,r.producerSpatialLayerRequest=void 0!==e.producerSpatialLayerRequest&&null!==e.producerSpatialLayerRequest?Ki.fromPartial(e.producerSpatialLayerRequest):void 0,r.transportConnectionTimeout=void 0!==e.transportConnectionTimeout&&null!==e.transportConnectionTimeout?rs.fromPartial(e.transportConnectionTimeout):void 0,r}};function cs(e){return null!=e}const ds={encode:(e,t=new ei)=>(0!==e.id&&t.uint32(8).int32(e.id),void 0!==e.channelEvent&&Gi.encode(e.channelEvent,t.uint32(18).fork()).join(),void 0!==e.mediaEvent&&as.encode(e.mediaEvent,t.uint32(26).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={id:0,channelEvent:void 0,mediaEvent:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.id=r.int32();continue;case 2:if(18!==e)break;i.channelEvent=Gi.decode(r,r.uint32());continue;case 3:if(26!==e)break;i.mediaEvent=as.decode(r,r.uint32());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:us(e.id)?globalThis.Number(e.id):0,channelEvent:us(e.channelEvent)?Gi.fromJSON(e.channelEvent):void 0,mediaEvent:us(e.mediaEvent)?as.fromJSON(e.mediaEvent):void 0}),toJSON(e){const t={};return 0!==e.id&&(t.id=Math.round(e.id)),void 0!==e.channelEvent&&(t.channelEvent=Gi.toJSON(e.channelEvent)),void 0!==e.mediaEvent&&(t.mediaEvent=as.toJSON(e.mediaEvent)),t},create:e=>ds.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={id:0,channelEvent:void 0,mediaEvent:void 0};return r.id=null!==(t=e.id)&&void 0!==t?t:0,r.channelEvent=void 0!==e.channelEvent&&null!==e.channelEvent?Gi.fromPartial(e.channelEvent):void 0,r.mediaEvent=void 0!==e.mediaEvent&&null!==e.mediaEvent?as.fromPartial(e.mediaEvent):void 0,r}};function us(e){return null!=e}var ls,ps,hs,fs,ms,gs,vs,ys;let _s=class{constructor(e){ls.set(this,[]),ps.set(this,!1),hs.set(this,!1),fs.set(this,void 0),ms.set(this,void 0),gs.set(this,new Map),vs.set(this,void 0),ys.set(this,new Set),d(this,vs,e("EventsQueue"),"f")}setMediaEventHandler(e){d(this,fs,e,"f"),c(this,vs,"f").info("Media event handler set",{case:"EventsQueue"})}setChannelEventHandler(e){d(this,ms,e,"f"),c(this,vs,"f").info("Channel event handler set",{case:"EventsQueue"})}subscribe(e){d(this,ys,new Set,"f");let t=0;const r=e=>{try{const r=this.processMessageChunk(e);if(!r||!this.isPendingMessageFullyReceived(r))return;const n=this.finalizeMessageBytes(r),i=ds.decode(n);i.id&&(c(this,ys,"f").has(i.id)&&c(this,vs,"f").warn("Received duplicate message",{case:"EventsQueue",lastReceivedMsgId:t,currentReceivedMsgId:i.id}),i.id>t+1&&c(this,vs,"f").warn("Received out of order message",{case:"EventsQueue",lastReceivedMsgId:t,currentReceivedMsgId:i.id})),c(this,ys,"f").add(i.id),t=i.id,this.push(i)}catch(e){c(this,vs,"f").error("Failed to parse channel message",{error:Ct(e),case:"EventsQueue"})}},n=()=>{e.removeListener("message",r),e.removeListener("close",n)};e.on("close",n),e.on("message",r),c(this,vs,"f").info("Subscribed to data channel",{case:"EventsQueue"})}push(e){c(this,ls,"f").push(e),this.process()}process(){return a(this,void 0,void 0,(function*(){if(!c(this,ps,"f")&&!c(this,hs,"f")){for(d(this,hs,!0,"f");!c(this,ps,"f")&&c(this,ls,"f").length>0;){const e=c(this,ls,"f").shift();if(e)try{if(e.channelEvent&&c(this,ms,"f")){c(this,vs,"f").debug("Handle channel event",{case:"EventsQueue",id:e.id,type:zi(e.channelEvent.eventType),event:e.channelEvent}),yield c(this,ms,"f").call(this,e.channelEvent);continue}if(e.mediaEvent&&c(this,fs,"f")){c(this,vs,"f").debug("Handle media event",{case:"EventsQueue",id:e.id,type:os(e.mediaEvent.eventType),event:e.mediaEvent}),yield c(this,fs,"f").call(this,e.mediaEvent);continue}c(this,vs,"f").warn("Received unknown message",{message:e,case:"EventsQueue"})}catch(t){c(this,vs,"f").error("Failed to handle event",{case:"EventsQueue",id:e.id,error:Ct(t)})}}d(this,hs,!1,"f"),!c(this,ps,"f")&&c(this,ls,"f").length>0&&queueMicrotask((()=>{this.process()}))}}))}processMessageChunk(e){const t=new Uint8Array(e);if(t.length<12)return void c(this,vs,"f").warn("Chunk too small",{case:"EventsQueue",bytesLength:t.length});const{msgId:r,index:n,total:i}=this.parseMessageChunkHeader(t),s=t.slice(12);c(this,gs,"f").has(r)||c(this,gs,"f").set(r,{msgId:r,total:i,received:[]});const o=c(this,gs,"f").get(r);if(o)return o.received[n]=s,o.msgId=r,o;c(this,vs,"f").warn("Chunk buffer entry not found for msgId",{msgId:r,case:"EventsQueue"})}parseMessageChunkHeader(e){const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{msgId:t.getUint32(0),index:t.getUint32(4),total:t.getUint32(8)}}isPendingMessageFullyReceived(e){return e.received.filter(Boolean).length===e.total}finalizeMessageBytes(e){const t=new Uint8Array(e.received.reduce(((e,t)=>e+t.length),0));let r=0;for(const n of e.received)t.set(n,r),r+=n.length;return c(this,gs,"f").delete(e.msgId),t}pause(){d(this,ps,!0,"f")}size(){return c(this,ls,"f").length}resume(){d(this,ps,!1,"f"),this.process()}isMessageReceived(e){return c(this,ys,"f").has(e)}};ls=new WeakMap,ps=new WeakMap,hs=new WeakMap,fs=new WeakMap,ms=new WeakMap,gs=new WeakMap,vs=new WeakMap,ys=new WeakMap,_s=i([at(),s(0,dt(On.LoggerFactory)),o("design:paramtypes",[Function])],_s);var bs=_s;function Es(e){return{id:e.id,appId:e.appId,role:e.role,groups:e.groups,producePermissions:e.producePermissions}}let ws=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)}};ws=i([at()],ws);class Ss extends mn{constructor(e,t,r){super(null!=e?e:Ss.DEFAULT_MESSAGE,null!=t?t:"something_went_wrong",r)}}Ss.DEFAULT_MESSAGE="Request failed";const Cs=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 Ps(e){return!e.response&&(!!e.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(e.code)&&(e=>!Cs.has(e&&e.code))(e)))}const Ts=["get","head","options"],Rs=Ts.concat(["put","delete"]);function ks(e){return"ECONNABORTED"!==e.code&&(!e.response||429===e.response.status||e.response.status>=500&&e.response.status<=599)}function Ds(e){return!!e.config?.method&&(ks(e)&&-1!==Rs.indexOf(e.config.method))}function Is(e){return Ps(e)||Ds(e)}function As(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 Os={retries:3,retryCondition:Is,retryDelay:function(e=0,t){return Math.max(0,As(t))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function Ns(e,t,r=!1){const n=function(e,t){return{...Os,...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 Ms=(e,t)=>{const r=e.interceptors.request.use((e=>(Ns(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=Ns(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}};function Ls(e,t){return function(){return e.apply(t,arguments)}}Ms.isNetworkError=Ps,Ms.isSafeRequestError=function(e){return!!e.config?.method&&(ks(e)&&-1!==Ts.indexOf(e.config.method))},Ms.isIdempotentRequestError=Ds,Ms.isNetworkOrIdempotentRequestError=Is,Ms.exponentialDelay=function(e=0,t,r=100){const n=2**e*r,i=Math.max(n,As(t));return i+.2*i*Math.random()},Ms.linearDelay=function(e=100){return(t=0,r)=>{const n=t*e;return Math.max(n,As(r))}},Ms.isRetryableError=ks;const{toString:xs}=Object.prototype,{getPrototypeOf:Fs}=Object,{iterator:js,toStringTag:Us}=Symbol,Vs=(Bs=Object.create(null),e=>{const t=xs.call(e);return Bs[t]||(Bs[t]=t.slice(8,-1).toLowerCase())});var Bs;const Ws=e=>(e=e.toLowerCase(),t=>Vs(t)===e),Hs=e=>t=>typeof t===e,{isArray:qs}=Array,zs=Hs("undefined");const Gs=Ws("ArrayBuffer");const Ys=Hs("string"),$s=Hs("function"),Js=Hs("number"),Ks=e=>null!==e&&"object"==typeof e,Qs=e=>{if("object"!==Vs(e))return!1;const t=Fs(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Us in e||js in e)},Zs=Ws("Date"),Xs=Ws("File"),eo=Ws("Blob"),to=Ws("FileList"),ro=Ws("URLSearchParams"),[no,io,so,oo]=["ReadableStream","Request","Response","Headers"].map(Ws);function ao(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),qs(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length;let o;for(n=0;n<s;n++)o=i[n],t.call(null,e[o],o,e)}}function co(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,i=r.length;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}const uo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,lo=e=>!zs(e)&&e!==uo;const po=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&Fs(Uint8Array)),ho=Ws("HTMLFormElement"),fo=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),mo=Ws("RegExp"),go=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};ao(r,((r,i)=>{let s;!1!==(s=t(r,i,e))&&(n[i]=s||r)})),Object.defineProperties(e,n)};const vo=Ws("AsyncFunction"),yo=(_o="function"==typeof setImmediate,bo=$s(uo.postMessage),_o?setImmediate:bo?(Eo=`axios@${Math.random()}`,wo=[],uo.addEventListener("message",(({source:e,data:t})=>{e===uo&&t===Eo&&wo.length&&wo.shift()()}),!1),e=>{wo.push(e),uo.postMessage(Eo,"*")}):e=>setTimeout(e));var _o,bo,Eo,wo;const So="undefined"!=typeof queueMicrotask?queueMicrotask.bind(uo):"undefined"!=typeof process&&process.nextTick||yo;var Co={isArray:qs,isArrayBuffer:Gs,isBuffer:function(e){return null!==e&&!zs(e)&&null!==e.constructor&&!zs(e.constructor)&&$s(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||$s(e.append)&&("formdata"===(t=Vs(e))||"object"===t&&$s(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Gs(e.buffer),t},isString:Ys,isNumber:Js,isBoolean:e=>!0===e||!1===e,isObject:Ks,isPlainObject:Qs,isReadableStream:no,isRequest:io,isResponse:so,isHeaders:oo,isUndefined:zs,isDate:Zs,isFile:Xs,isBlob:eo,isRegExp:mo,isFunction:$s,isStream:e=>Ks(e)&&$s(e.pipe),isURLSearchParams:ro,isTypedArray:po,isFileList:to,forEach:ao,merge:function e(){const{caseless:t}=lo(this)&&this||{},r={},n=(n,i)=>{const s=t&&co(r,i)||i;Qs(r[s])&&Qs(n)?r[s]=e(r[s],n):Qs(n)?r[s]=e({},n):qs(n)?r[s]=n.slice():r[s]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&ao(arguments[e],n);return r},extend:(e,t,r,{allOwnKeys:n}={})=>(ao(t,((t,n)=>{r&&$s(t)?e[n]=Ls(t,r):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let i,s,o;const a={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),s=i.length;s-- >0;)o=i[s],n&&!n(o,e,t)||a[o]||(t[o]=e[o],a[o]=!0);e=!1!==r&&Fs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:Vs,kindOfTest:Ws,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(qs(e))return e;let t=e.length;if(!Js(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[js]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:ho,hasOwnProperty:fo,hasOwnProp:fo,reduceDescriptors:go,freezeMethods:e=>{go(e,((t,r)=>{if($s(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];$s(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return qs(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:co,global:uo,isContextDefined:lo,isSpecCompliantForm:function(e){return!!(e&&$s(e.append)&&"FormData"===e[Us]&&e[js])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(Ks(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const i=qs(e)?[]:{};return ao(e,((e,t)=>{const s=r(e,n+1);!zs(s)&&(i[t]=s)})),t[n]=void 0,i}}return e};return r(e,0)},isAsyncFn:vo,isThenable:e=>e&&(Ks(e)||$s(e))&&$s(e.then)&&$s(e.catch),setImmediate:yo,asap:So,isIterable:e=>null!=e&&$s(e[js])};function Po(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Co.inherits(Po,Error,{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:Co.toJSONObject(this.config),code:this.code,status:this.status}}});const To=Po.prototype,Ro={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{Ro[e]={value:e}})),Object.defineProperties(Po,Ro),Object.defineProperty(To,"isAxiosError",{value:!0}),Po.from=(e,t,r,n,i,s)=>{const o=Object.create(To);return Co.toFlatObject(e,o,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),Po.call(o,e.message,t,r,n,i),o.cause=e,o.name=e.name,s&&Object.assign(o,s),o};function ko(e){return Co.isPlainObject(e)||Co.isArray(e)}function Do(e){return Co.endsWith(e,"[]")?e.slice(0,-2):e}function Io(e,t,r){return e?e.concat(t).map((function(e,t){return e=Do(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const Ao=Co.toFlatObject(Co,{},null,(function(e){return/^is[A-Z]/.test(e)}));function Oo(e,t,r){if(!Co.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=Co.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!Co.isUndefined(t[e])}))).metaTokens,i=r.visitor||d,s=r.dots,o=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&Co.isSpecCompliantForm(t);if(!Co.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(Co.isDate(e))return e.toISOString();if(Co.isBoolean(e))return e.toString();if(!a&&Co.isBlob(e))throw new Po("Blob is not supported. Use a Buffer instead.");return Co.isArrayBuffer(e)||Co.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function d(e,r,i){let a=e;if(e&&!i&&"object"==typeof e)if(Co.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(Co.isArray(e)&&function(e){return Co.isArray(e)&&!e.some(ko)}(e)||(Co.isFileList(e)||Co.endsWith(r,"[]"))&&(a=Co.toArray(e)))return r=Do(r),a.forEach((function(e,n){!Co.isUndefined(e)&&null!==e&&t.append(!0===o?Io([r],n,s):null===o?r:r+"[]",c(e))})),!1;return!!ko(e)||(t.append(Io(i,r,s),c(e)),!1)}const u=[],l=Object.assign(Ao,{defaultVisitor:d,convertValue:c,isVisitable:ko});if(!Co.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!Co.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),Co.forEach(r,(function(r,s){!0===(!(Co.isUndefined(r)||null===r)&&i.call(t,r,Co.isString(s)?s.trim():s,n,l))&&e(r,n?n.concat(s):[s])})),u.pop()}}(e),t}function No(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function Mo(e,t){this._pairs=[],e&&Oo(e,this,t)}const Lo=Mo.prototype;function xo(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Fo(e,t,r){if(!t)return e;const n=r&&r.encode||xo;Co.isFunction(r)&&(r={serialize:r});const i=r&&r.serialize;let s;if(s=i?i(t,r):Co.isURLSearchParams(t)?t.toString():new Mo(t,r).toString(n),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}Lo.append=function(e,t){this._pairs.push([e,t])},Lo.toString=function(e){const t=e?function(t){return e.call(this,t,No)}:No;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var jo=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Co.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},Uo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Vo={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Mo,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Bo="undefined"!=typeof window&&"undefined"!=typeof document,Wo="object"==typeof navigator&&navigator||void 0,Ho=Bo&&(!Wo||["ReactNative","NativeScript","NS"].indexOf(Wo.product)<0),qo="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,zo=Bo&&window.location.href||"http://localhost";var Go={...Object.freeze({__proto__:null,hasBrowserEnv:Bo,hasStandardBrowserWebWorkerEnv:qo,hasStandardBrowserEnv:Ho,navigator:Wo,origin:zo}),...Vo};function Yo(e){function t(e,r,n,i){let s=e[i++];if("__proto__"===s)return!0;const o=Number.isFinite(+s),a=i>=e.length;if(s=!s&&Co.isArray(n)?n.length:s,a)return Co.hasOwnProp(n,s)?n[s]=[n[s],r]:n[s]=r,!o;n[s]&&Co.isObject(n[s])||(n[s]=[]);return t(e,r,n[s],i)&&Co.isArray(n[s])&&(n[s]=function(e){const t={},r=Object.keys(e);let n;const i=r.length;let s;for(n=0;n<i;n++)s=r[n],t[s]=e[s];return t}(n[s])),!o}if(Co.isFormData(e)&&Co.isFunction(e.entries)){const r={};return Co.forEachEntry(e,((e,n)=>{t(function(e){return Co.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const $o={transitional:Uo,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=Co.isObject(e);i&&Co.isHTMLForm(e)&&(e=new FormData(e));if(Co.isFormData(e))return n?JSON.stringify(Yo(e)):e;if(Co.isArrayBuffer(e)||Co.isBuffer(e)||Co.isStream(e)||Co.isFile(e)||Co.isBlob(e)||Co.isReadableStream(e))return e;if(Co.isArrayBufferView(e))return e.buffer;if(Co.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Oo(e,new Go.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return Go.isNode&&Co.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((s=Co.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Oo(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),function(e,t,r){if(Co.isString(e))try{return(t||JSON.parse)(e),Co.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||$o.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(Co.isResponse(e)||Co.isReadableStream(e))return e;if(e&&Co.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw Po.from(e,Po.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Go.classes.FormData,Blob:Go.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Co.forEach(["delete","get","head","post","put","patch"],(e=>{$o.headers[e]={}}));var Jo=$o;const Ko=Co.toObjectSet(["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"]);const Qo=Symbol("internals");function Zo(e){return e&&String(e).trim().toLowerCase()}function Xo(e){return!1===e||null==e?e:Co.isArray(e)?e.map(Xo):String(e)}function ea(e,t,r,n,i){return Co.isFunction(n)?n.call(this,t,r):(i&&(t=r),Co.isString(t)?Co.isString(n)?-1!==t.indexOf(n):Co.isRegExp(n)?n.test(t):void 0:void 0)}class ta{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function i(e,t,r){const i=Zo(t);if(!i)throw new Error("header name must be a non-empty string");const s=Co.findKey(n,i);(!s||void 0===n[s]||!0===r||void 0===r&&!1!==n[s])&&(n[s||t]=Xo(e))}const s=(e,t)=>Co.forEach(e,((e,r)=>i(e,r,t)));if(Co.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if(Co.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))s((e=>{const t={};let r,n,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!r||t[r]&&Ko[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t);else if(Co.isObject(e)&&Co.isIterable(e)){let r,n,i={};for(const t of e){if(!Co.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[n=t[0]]=(r=i[n])?Co.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}s(i,t)}else null!=e&&i(t,e,r);return this}get(e,t){if(e=Zo(e)){const r=Co.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(Co.isFunction(t))return t.call(this,e,r);if(Co.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Zo(e)){const r=Co.findKey(this,e);return!(!r||void 0===this[r]||t&&!ea(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function i(e){if(e=Zo(e)){const i=Co.findKey(r,e);!i||t&&!ea(0,r[i],i,t)||(delete r[i],n=!0)}}return Co.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const i=t[r];e&&!ea(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,r={};return Co.forEach(this,((n,i)=>{const s=Co.findKey(r,i);if(s)return t[s]=Xo(n),void delete t[i];const o=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(i):String(i).trim();o!==i&&delete t[i],t[o]=Xo(n),r[o]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Co.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&Co.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[Qo]=this[Qo]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=Zo(e);t[n]||(!function(e,t){const r=Co.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,i){return this[n].call(this,t,e,r,i)},configurable:!0})}))}(r,e),t[n]=!0)}return Co.isArray(e)?e.forEach(n):n(e),this}}ta.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Co.reduceDescriptors(ta.prototype,(({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}})),Co.freezeMethods(ta);var ra=ta;function na(e,t){const r=this||Jo,n=t||r,i=ra.from(n.headers);let s=n.data;return Co.forEach(e,(function(e){s=e.call(r,s,i.normalize(),t?t.status:void 0)})),i.normalize(),s}function ia(e){return!(!e||!e.__CANCEL__)}function sa(e,t,r){Po.call(this,null==e?"canceled":e,Po.ERR_CANCELED,t,r),this.name="CanceledError"}function oa(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new Po("Request failed with status code "+r.status,[Po.ERR_BAD_REQUEST,Po.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}Co.inherits(sa,Po,{__CANCEL__:!0});const aa=(e,t,r=3)=>{let n=0;const i=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i,s=0,o=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),d=n[o];i||(i=c),r[s]=a,n[s]=c;let u=o,l=0;for(;u!==s;)l+=r[u++],u%=e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),c-i<t)return;const p=d&&c-d;return p?Math.round(1e3*l/p):void 0}}(50,250);return function(e,t){let r,n,i=0,s=1e3/t;const o=(t,s=Date.now())=>{i=s,r=null,n&&(clearTimeout(n),n=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),a=t-i;a>=s?o(e,t):(r=e,n||(n=setTimeout((()=>{n=null,o(r)}),s-a)))},()=>r&&o(r)]}((r=>{const s=r.loaded,o=r.lengthComputable?r.total:void 0,a=s-n,c=i(a);n=s;e({loaded:s,total:o,progress:o?s/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&s<=o?(o-s)/c:void 0,event:r,lengthComputable:null!=o,[t?"download":"upload"]:!0})}),r)},ca=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},da=e=>(...t)=>Co.asap((()=>e(...t)));var ua=Go.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,Go.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(Go.origin),Go.navigator&&/(msie|trident)/i.test(Go.navigator.userAgent)):()=>!0,la=Go.hasStandardBrowserEnv?{write(e,t,r,n,i,s){const o=[e+"="+encodeURIComponent(t)];Co.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Co.isString(n)&&o.push("path="+n),Co.isString(i)&&o.push("domain="+i),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function pa(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const ha=e=>e instanceof ra?{...e}:e;function fa(e,t){t=t||{};const r={};function n(e,t,r,n){return Co.isPlainObject(e)&&Co.isPlainObject(t)?Co.merge.call({caseless:n},e,t):Co.isPlainObject(t)?Co.merge({},t):Co.isArray(t)?t.slice():t}function i(e,t,r,i){return Co.isUndefined(t)?Co.isUndefined(e)?void 0:n(void 0,e,0,i):n(e,t,0,i)}function s(e,t){if(!Co.isUndefined(t))return n(void 0,t)}function o(e,t){return Co.isUndefined(t)?Co.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(r,i,s){return s in t?n(r,i):s in e?n(void 0,r):void 0}const c={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(e,t,r)=>i(ha(e),ha(t),0,!0)};return Co.forEach(Object.keys(Object.assign({},e,t)),(function(n){const s=c[n]||i,o=s(e[n],t[n],n);Co.isUndefined(o)&&s!==a||(r[n]=o)})),r}var ma=e=>{const t=fa({},e);let r,{data:n,withXSRFToken:i,xsrfHeaderName:s,xsrfCookieName:o,headers:a,auth:c}=t;if(t.headers=a=ra.from(a),t.url=Fo(pa(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),Co.isFormData(n))if(Go.hasStandardBrowserEnv||Go.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(r=a.getContentType())){const[e,...t]=r?r.split(";").map((e=>e.trim())).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(Go.hasStandardBrowserEnv&&(i&&Co.isFunction(i)&&(i=i(t)),i||!1!==i&&ua(t.url))){const e=s&&o&&la.read(o);e&&a.set(s,e)}return t};var ga="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){const n=ma(e);let i=n.data;const s=ra.from(n.headers).normalize();let o,a,c,d,u,{responseType:l,onUploadProgress:p,onDownloadProgress:h}=n;function f(){d&&d(),u&&u(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let m=new XMLHttpRequest;function g(){if(!m)return;const n=ra.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());oa((function(e){t(e),f()}),(function(e){r(e),f()}),{data:l&&"text"!==l&&"json"!==l?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:n,config:e,request:m}),m=null}m.open(n.method.toUpperCase(),n.url,!0),m.timeout=n.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(r(new Po("Request aborted",Po.ECONNABORTED,e,m)),m=null)},m.onerror=function(){r(new Po("Network Error",Po.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const i=n.transitional||Uo;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new Po(t,i.clarifyTimeoutError?Po.ETIMEDOUT:Po.ECONNABORTED,e,m)),m=null},void 0===i&&s.setContentType(null),"setRequestHeader"in m&&Co.forEach(s.toJSON(),(function(e,t){m.setRequestHeader(t,e)})),Co.isUndefined(n.withCredentials)||(m.withCredentials=!!n.withCredentials),l&&"json"!==l&&(m.responseType=n.responseType),h&&([c,u]=aa(h,!0),m.addEventListener("progress",c)),p&&m.upload&&([a,d]=aa(p),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",d)),(n.cancelToken||n.signal)&&(o=t=>{m&&(r(!t||t.type?new sa(null,e,m):t),m.abort(),m=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));const v=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);v&&-1===Go.protocols.indexOf(v)?r(new Po("Unsupported protocol "+v+":",Po.ERR_BAD_REQUEST,e)):m.send(i||null)}))};var va=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const i=function(e){if(!r){r=!0,o();const t=e instanceof Error?e:this.reason;n.abort(t instanceof Po?t:new sa(t instanceof Error?t.message:t))}};let s=t&&setTimeout((()=>{s=null,i(new Po(`timeout ${t} of ms exceeded`,Po.ETIMEDOUT))}),t);const o=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)})),e=null)};e.forEach((e=>e.addEventListener("abort",i)));const{signal:a}=n;return a.unsubscribe=()=>Co.asap(o),a}};const ya=function*(e,t){let r=e.byteLength;if(!t||r<t)return void(yield e);let n,i=0;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},_a=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}},ba=(e,t,r,n)=>{const i=async function*(e,t){for await(const r of _a(e))yield*ya(r,t)}(e,t);let s,o=0,a=e=>{s||(s=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await i.next();if(t)return a(),void e.close();let s=n.byteLength;if(r){let e=o+=s;r(e)}e.enqueue(new Uint8Array(n))}catch(e){throw a(e),e}},cancel:e=>(a(e),i.return())},{highWaterMark:2})},Ea="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,wa=Ea&&"function"==typeof ReadableStream,Sa=Ea&&("function"==typeof TextEncoder?(Ca=new TextEncoder,e=>Ca.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var Ca;const Pa=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Ta=wa&&Pa((()=>{let e=!1;const t=new Request(Go.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),Ra=wa&&Pa((()=>Co.isReadableStream(new Response("").body))),ka={stream:Ra&&(e=>e.body)};var Da;Ea&&(Da=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!ka[e]&&(ka[e]=Co.isFunction(Da[e])?t=>t[e]():(t,r)=>{throw new Po(`Response type '${e}' is not supported`,Po.ERR_NOT_SUPPORT,r)})})));const Ia=async(e,t)=>{const r=Co.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Co.isBlob(e))return e.size;if(Co.isSpecCompliantForm(e)){const t=new Request(Go.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Co.isArrayBufferView(e)||Co.isArrayBuffer(e)?e.byteLength:(Co.isURLSearchParams(e)&&(e+=""),Co.isString(e)?(await Sa(e)).byteLength:void 0)})(t):r};var Aa=Ea&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:s,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:d,headers:u,withCredentials:l="same-origin",fetchOptions:p}=ma(e);d=d?(d+"").toLowerCase():"text";let h,f=va([i,s&&s.toAbortSignal()],o);const m=f&&f.unsubscribe&&(()=>{f.unsubscribe()});let g;try{if(c&&Ta&&"get"!==r&&"head"!==r&&0!==(g=await Ia(u,n))){let e,r=new Request(t,{method:"POST",body:n,duplex:"half"});if(Co.isFormData(n)&&(e=r.headers.get("content-type"))&&u.setContentType(e),r.body){const[e,t]=ca(g,aa(da(c)));n=ba(r.body,65536,e,t)}}Co.isString(l)||(l=l?"include":"omit");const i="credentials"in Request.prototype;h=new Request(t,{...p,signal:f,method:r.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:i?l:void 0});let s=await fetch(h,p);const o=Ra&&("stream"===d||"response"===d);if(Ra&&(a||o&&m)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=s[t]}));const t=Co.toFiniteNumber(s.headers.get("content-length")),[r,n]=a&&ca(t,aa(da(a),!0))||[];s=new Response(ba(s.body,65536,r,(()=>{n&&n(),m&&m()})),e)}d=d||"text";let v=await ka[Co.findKey(ka,d)||"text"](s,e);return!o&&m&&m(),await new Promise(((t,r)=>{oa(t,r,{data:v,headers:ra.from(s.headers),status:s.status,statusText:s.statusText,config:e,request:h})}))}catch(t){if(m&&m(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new Po("Network Error",Po.ERR_NETWORK,e,h),{cause:t.cause||t});throw Po.from(t,t&&t.code,e,h)}});const Oa={http:null,xhr:ga,fetch:Aa};Co.forEach(Oa,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const Na=e=>`- ${e}`,Ma=e=>Co.isFunction(e)||null===e||!1===e;var La=e=>{e=Co.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let s=0;s<t;s++){let t;if(r=e[s],n=r,!Ma(r)&&(n=Oa[(t=String(r)).toLowerCase()],void 0===n))throw new Po(`Unknown adapter '${t}'`);if(n)break;i[t||"#"+s]=n}if(!n){const e=Object.entries(i).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new Po("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Na).join("\n"):" "+Na(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function xa(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new sa(null,e)}function Fa(e){xa(e),e.headers=ra.from(e.headers),e.data=na.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return La(e.adapter||Jo.adapter)(e).then((function(t){return xa(e),t.data=na.call(e,e.transformResponse,t),t.headers=ra.from(t.headers),t}),(function(t){return ia(t)||(xa(e),t&&t.response&&(t.response.data=na.call(e,e.transformResponse,t.response),t.response.headers=ra.from(t.response.headers))),Promise.reject(t)}))}const ja={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{ja[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const Ua={};ja.transitional=function(e,t,r){function n(e,t){return"[Axios v1.10.0] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,s)=>{if(!1===e)throw new Po(n(i," has been removed"+(t?" in "+t:"")),Po.ERR_DEPRECATED);return t&&!Ua[i]&&(Ua[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,s)}},ja.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var Va={assertOptions:function(e,t,r){if("object"!=typeof e)throw new Po("options must be an object",Po.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const s=n[i],o=t[s];if(o){const t=e[s],r=void 0===t||o(t,s,e);if(!0!==r)throw new Po("option "+s+" must be "+r,Po.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new Po("Unknown option "+s,Po.ERR_BAD_OPTION)}},validators:ja};const Ba=Va.validators;class Wa{constructor(e){this.defaults=e||{},this.interceptors={request:new jo,response:new jo}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const r=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?r&&!String(e.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+r):e.stack=r}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=fa(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:i}=t;void 0!==r&&Va.assertOptions(r,{silentJSONParsing:Ba.transitional(Ba.boolean),forcedJSONParsing:Ba.transitional(Ba.boolean),clarifyTimeoutError:Ba.transitional(Ba.boolean)},!1),null!=n&&(Co.isFunction(n)?t.paramsSerializer={serialize:n}:Va.assertOptions(n,{encode:Ba.function,serialize:Ba.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Va.assertOptions(t,{baseUrl:Ba.spelling("baseURL"),withXsrfToken:Ba.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=i&&Co.merge(i.common,i[t.method]);i&&Co.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete i[e]})),t.headers=ra.concat(s,i);const o=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,o.unshift(e.fulfilled,e.rejected))}));const c=[];let d;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let u,l=0;if(!a){const e=[Fa.bind(this),void 0];for(e.unshift.apply(e,o),e.push.apply(e,c),u=e.length,d=Promise.resolve(t);l<u;)d=d.then(e[l++],e[l++]);return d}u=o.length;let p=t;for(l=0;l<u;){const e=o[l++],t=o[l++];try{p=e(p)}catch(e){t.call(this,e);break}}try{d=Fa.call(this,p)}catch(e){return Promise.reject(e)}for(l=0,u=c.length;l<u;)d=d.then(c[l++],c[l++]);return d}getUri(e){return Fo(pa((e=fa(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}Co.forEach(["delete","get","head","options"],(function(e){Wa.prototype[e]=function(t,r){return this.request(fa(r||{},{method:e,url:t,data:(r||{}).data}))}})),Co.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(fa(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}Wa.prototype[e]=t(),Wa.prototype[e+"Form"]=t(!0)}));var Ha=Wa;class qa{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,i){r.reason||(r.reason=new sa(e,n,i),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;const t=new qa((function(t){e=t}));return{token:t,cancel:e}}}var za=qa;const Ga={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ga).forEach((([e,t])=>{Ga[t]=e}));var Ya=Ga;const $a=function e(t){const r=new Ha(t),n=Ls(Ha.prototype.request,r);return Co.extend(n,Ha.prototype,r,{allOwnKeys:!0}),Co.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(fa(t,r))},n}(Jo);$a.Axios=Ha,$a.CanceledError=sa,$a.CancelToken=za,$a.isCancel=ia,$a.VERSION="1.10.0",$a.toFormData=Oo,$a.AxiosError=Po,$a.Cancel=$a.CanceledError,$a.all=function(e){return Promise.all(e)},$a.spread=function(e){return function(t){return e.apply(null,t)}},$a.isAxiosError=function(e){return Co.isObject(e)&&!0===e.isAxiosError},$a.mergeConfig=fa,$a.AxiosHeaders=ra,$a.formToJSON=e=>Yo(Co.isHTMLForm(e)?new FormData(e):e),$a.getAdapter=La,$a.HttpStatusCode=Ya,$a.default=$a;var Ja=$a;class Ka extends mn{constructor(e,t,r){super(null!=e?e:Ka.DEFAULT_MESSAGE,null!=t?t:"already_connected",r)}}Ka.DEFAULT_MESSAGE="Peer is already connected";class Qa extends mn{constructor(e,t,r){super(null!=e?e:Qa.DEFAULT_MESSAGE,null!=t?t:"already_created",r)}}Qa.DEFAULT_MESSAGE="Resource has already been created";class Za extends mn{constructor(e,t,r){super(null!=e?e:Za.DEFAULT_MESSAGE,null!=t?t:"forbidden",r)}}Za.DEFAULT_MESSAGE="Forbidden";class Xa extends mn{constructor(e,t,r){super(null!=e?e:Xa.DEFAULT_MESSAGE,null!=t?t:"invalid_request",r)}}Xa.DEFAULT_MESSAGE="Invalid request";class ec extends mn{constructor(e,t,r){super(null!=e?e:ec.DEFAULT_MESSAGE,null!=t?t:"not_found",r)}}ec.DEFAULT_MESSAGE="Requested resource was not found";class tc extends mn{constructor(e,t,r){super(null!=e?e:tc.DEFAULT_MESSAGE,null!=t?t:"timeout",r)}}tc.DEFAULT_MESSAGE="Request timed out";class rc extends mn{constructor(e,t,r){super(null!=e?e:rc.DEFAULT_MESSAGE,null!=t?t:"too_many_requests",r)}}rc.DEFAULT_MESSAGE="Too many requests";class nc extends mn{constructor(e,t,r){super(null!=e?e:nc.DEFAULT_MESSAGE,null!=t?t:"unauthorized",r)}}nc.DEFAULT_MESSAGE="Unauthorized";const ic=e=>(t,r,n)=>new e(t,r,n),sc={check_access_fail:ic(Za),join_room_fail:ic(Xa),need_joined_to_channel:ic(gn),forbidden:ic(Za),not_found:ic(ec),invalid_request:ic(Xa),invalid_payload:ic(Xa),already_created:ic(Qa),too_many_requests:ic(rc),something_went_wrong:ic(Ss),di_error:ic(Xa),resources_lock_error:ic(Xa),already_connected:ic(Ka),timeout:ic(tc),unauthorized:ic(nc)},oc=e=>{if(!(e=>"object"==typeof e&&null!==e&&!Array.isArray(e))(e))return!1;const{error:t,errorCode:r}=e;return!(void 0!==t&&"string"!=typeof t||void 0!==r&&"string"!=typeof r)},ac=(e,t)=>{var r,n,i,s;const o={};return t&&Object.keys(t).length>0&&(o.response=t),"number"==typeof(null===(r=e.response)||void 0===r?void 0:r.status)&&(o.status=e.response.status),(null===(n=e.response)||void 0===n?void 0:n.statusText)&&(o.statusText=e.response.statusText),e.code&&(o.axiosCode=e.code),(null===(i=e.config)||void 0===i?void 0:i.url)&&(o.url=e.config.url),(null===(s=e.config)||void 0===s?void 0:s.method)&&(o.method=e.config.method),Object.keys(o).length>0?o:void 0};var cc;!function(e){e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain"}(cc||(cc={}));let dc=class extends class extends class{constructor(e={}){var{securityWorker:t,secure:r,format:i}=e,s=n(e,["securityWorker","secure","format"]);this.securityData=null,this.setSecurityData=e=>{this.securityData=e},this.request=e=>a(this,void 0,void 0,(function*(){var{secure:t,path:r,type:i,query:s,format:o,body:a}=e,c=n(e,["secure","path","type","query","format","body"]);const d=("boolean"==typeof t?t:this.secure)&&this.securityWorker&&(yield this.securityWorker(this.securityData))||{},u=this.mergeRequestParams(c,d),l=o||this.format||void 0;return i===cc.FormData&&a&&null!==a&&"object"==typeof a&&(a=this.createFormData(a)),i===cc.Text&&a&&null!==a&&"string"!=typeof a&&(a=JSON.stringify(a)),this.instance.request(Object.assign(Object.assign({},u),{headers:Object.assign(Object.assign({},u.headers||{}),i&&i!==cc.FormData?{"Content-Type":i}:{}),params:s,responseType:l,data:a,url:r}))})),this.instance=Ja.create(Object.assign(Object.assign({},s),{baseURL:s.baseURL||"signaling.livedigital.space/v1"})),this.secure=r,this.format=i,this.securityWorker=t}mergeRequestParams(e,t){const r=e.method||t&&t.method;return Object.assign(Object.assign(Object.assign(Object.assign({},this.instance.defaults),e),t||{}),{headers:Object.assign(Object.assign(Object.assign({},r&&this.instance.defaults.headers[r.toLowerCase()]||{}),e.headers||{}),t&&t.headers||{})})}stringifyFormItem(e){return"object"==typeof e&&null!==e?JSON.stringify(e):`${e}`}createFormData(e){return Object.keys(e||{}).reduce(((t,r)=>{const n=e[r],i=n instanceof Array?n:[n];for(const e of i){const n=e instanceof Blob||e instanceof File;t.append(r,n?e:this.stringifyFormItem(e))}return t}),new FormData)}}{constructor(){super(...arguments),this.peers={getPeers:(e,t={})=>this.request(Object.assign({path:"/peers",method:"GET",query:e,secure:!0,format:"json"},t)),registerPeer:(e,t={})=>this.request(Object.assign({path:"/peers",method:"POST",body:e,secure:!0,type:cc.Json,format:"json"},t)),disconnectPeer:(e={})=>this.request(Object.assign({path:"/peers",method:"DELETE",secure:!0},e)),changePeerProducePermissions:(e,t,r={})=>this.request(Object.assign({path:`/peers/${e}/produce-permissions`,method:"PUT",body:t,secure:!0,type:cc.Json},r)),addPeerProducePermissions:(e,t,r={})=>this.request(Object.assign({path:`/peers/${e}/produce-permissions/${t}`,method:"POST",secure:!0},r)),removePeerProducePermissions:(e,t,r={})=>this.request(Object.assign({path:`/peers/${e}/produce-permissions/${t}`,method:"DELETE",secure:!0},r))},this.router={getRtpCapabilities:(e={})=>this.request(Object.assign({path:"/router/rtp-capabilities",method:"GET",secure:!0,format:"json"},e))},this.channel={confirmChannelActivity:(e={})=>this.request(Object.assign({path:"/channel/activity",method:"PATCH",secure:!0},e)),triggerChannelStateEvent:(e,t={})=>this.request(Object.assign({path:"/channel/peers-state-message-id",method:"GET",query:e,secure:!0,format:"json"},t))},this.ping={pingPeer:(e={})=>this.request(Object.assign({path:"/ping",method:"POST",secure:!0},e))},this.appData={updateSelfPeerAppData:(e,t={})=>this.request(Object.assign({path:"/app-data",method:"PUT",body:e,secure:!0,type:cc.Json},t))},this.producer={getGeneralDataProducer:(e={})=>this.request(Object.assign({path:"/producer/general-data",method:"GET",secure:!0,format:"json"},e)),getAudioObserverProducer:(e={})=>this.request(Object.assign({path:"/producer/audio-observer",method:"GET",secure:!0,format:"json"},e)),getChannelStateSyncDataProducer:(e={})=>this.request(Object.assign({path:"/producer/channel-state-sync-data",method:"GET",secure:!0,format:"json"},e)),closeProducer:(e,t={})=>this.request(Object.assign({path:`/producer/${e}`,method:"DELETE",secure:!0},t)),pauseProducer:(e,t={})=>this.request(Object.assign({path:`/producer/${e}/actions/pause`,method:"POST",secure:!0},t)),resumeProducer:(e,t={})=>this.request(Object.assign({path:`/producer/${e}/actions/resume`,method:"POST",secure:!0},t)),requestProducerMaxSpatialLayer:(e,t,r={})=>this.request(Object.assign({path:`/producer/${e}/max-spatial-layer`,method:"POST",body:t,secure:!0,type:cc.Json},r)),setProducerMaxSpatialLayer:(e,t,r={})=>this.request(Object.assign({path:`/producer/${e}/max-spatial-layer`,method:"PUT",body:t,secure:!0,type:cc.Json},r))},this.consumer={createConsumer:(e,t={})=>this.request(Object.assign({path:"/consumer",method:"POST",body:e,secure:!0,type:cc.Json,format:"json"},t)),closeConsumer:(e,t={})=>this.request(Object.assign({path:`/consumer/${e}`,method:"DELETE",secure:!0},t)),pauseConsumer:(e,t={})=>this.request(Object.assign({path:`/consumer/${e}/actions/pause`,method:"POST",secure:!0},t)),resumeConsumer:(e,t={})=>this.request(Object.assign({path:`/consumer/${e}/actions/resume`,method:"POST",secure:!0},t)),updateConsumerPreferredLayers:(e,t,r={})=>this.request(Object.assign({path:`/consumer/${e}/preferred-layers`,method:"PUT",body:t,secure:!0,type:cc.Json},r)),requestConsumerKeyFrame:(e,t={})=>this.request(Object.assign({path:`/consumer/${e}/key-frame`,method:"POST",secure:!0},t))},this.dataConsumer={createDataConsumer:(e,t={})=>this.request(Object.assign({path:"/data-consumer",method:"POST",body:e,secure:!0,type:cc.Json,format:"json"},t))},this.transport={createTransport:(e,t={})=>this.request(Object.assign({path:"/transport",method:"POST",body:e,secure:!0,type:cc.Json,format:"json"},t)),getTransportIceParameters:(e,t={})=>this.request(Object.assign({path:`/transport/${e}/ice-parameters`,method:"GET",secure:!0,format:"json"},t)),connectTransport:(e,t,r={})=>this.request(Object.assign({path:`/transport/${e}/connect`,method:"PUT",body:t,secure:!0,type:cc.Json},r)),produceMediaToTransport:(e,t,r={})=>this.request(Object.assign({path:`/transport/${e}/media-producer`,method:"PUT",body:t,secure:!0,type:cc.Json,format:"json"},r)),produceDataToTransport:(e,t,r={})=>this.request(Object.assign({path:`/transport/${e}/data-producer`,method:"PUT",body:t,secure:!0,type:cc.Json,format:"json"},r)),closeTransport:(e,t={})=>this.request(Object.assign({path:`/transport/${e}`,method:"DELETE",secure:!0},t))}}}{constructor(e){super({baseURL:String("https://signaling-api.livedigital.space/v1"),securityWorker:e=>{if(!e)return;const t={};return e.token&&(t.Authorization=`Bearer ${e.token}`),e.peerApiVersion&&(t["x-peer-api-version"]=String(e.peerApiVersion)),e.datacenterType&&(t["x-datacenter-type"]=e.datacenterType),{headers:t}}}),this.config=e,this.errorListeners=new Set,this.abortController=new AbortController,this.instance.interceptors.request.use((e=>(!e.signal&&this.abortController&&(e.signal=this.abortController.signal),e))),Ms(this.instance,{retries:10,shouldResetTimeout:!0,retryDelay:e=>Math.min(200*Math.pow(2,e-1),2e3),retryCondition:e=>"ERR_CANCELED"!==e.code&&(Ms.isNetworkError(e)||"ECONNABORTED"===e.code&&!e.response)}),this.instance.interceptors.response.use((e=>e),(e=>{const t=(e=>{var t,r;if(!Ja.isAxiosError(e))return e instanceof Error?e:new Ss;const n=e;if(!n.response){const e=ac(n),r=n.message||Ss.DEFAULT_MESSAGE,i=null!==(t=n.code)&&void 0!==t?t:"network_error";return new Ss(r,i,e)}const i=oc(n.response.data)?n.response.data:void 0,s="string"==typeof(null==i?void 0:i.errorCode)?i.errorCode:void 0,o="string"==typeof(null==i?void 0:i.error)?i.error:void 0,a=(o&&o.trim().length>0?o:n.message)||Ss.DEFAULT_MESSAGE,c=ac(n,i);if(s){const e=sc[s];return e?e(a,s,c):new Ss(a,s,c)}const d=null!==(r=n.code)&&void 0!==r?r:"number"==typeof n.response.status?`http_${n.response.status}`:"something_went_wrong";return new Ss(a,d,c)})(e);throw this.notifyErrorListeners(t),t})),this.instance.defaults.timeout=3e3;const t=this.config.get("signalingServerUrl");t&&(this.instance.defaults.baseURL=t)}abortPendingRequests(e){this.abortController.abort(e),this.abortController=new AbortController}addErrorListener(e){return this.errorListeners.add(e),()=>{this.errorListeners.delete(e)}}notifyErrorListeners(e){this.errorListeners.forEach((t=>{try{t(e)}catch(e){}}))}};dc=i([at(),s(0,dt(On.Config)),o("design:paramtypes",[bt])],dc);var uc,lc,pc,hc,fc,mc,gc=dc;let vc=class{constructor(e){uc.set(this,void 0),lc.set(this,void 0),pc.set(this,void 0),hc.set(this,[]),fc.set(this,void 0),mc.set(this,new Uint8Array(0)),d(this,fc,e("DatachannelHeartbeater"),"f")}init(e,t){d(this,pc,e,"f"),d(this,lc,t,"f"),this.subscribeToDataProducerEvents(t),this.startHeartbeatInterval()}dispose(){this.stopHeartbeatInterval(),this.cleanupDataProducerEvents(),d(this,lc,void 0,"f"),d(this,pc,void 0,"f")}startHeartbeatInterval(){c(this,uc,"f")||(d(this,uc,setInterval((()=>{this.sendHeartbeat()}),5e3),"f"),c(this,fc,"f").debug("Datachannel heartbeat interval started"))}stopHeartbeatInterval(){c(this,uc,"f")&&(clearInterval(c(this,uc,"f")),d(this,uc,void 0,"f"),c(this,fc,"f").debug("Datachannel heartbeat interval stopped"))}canSendHeartbeat(){return!(!c(this,lc,"f")||!c(this,pc,"f"))&&(!c(this,lc,"f").closed&&"connected"===c(this,pc,"f").connectionState&&"open"===c(this,lc,"f").readyState)}subscribeToDataProducerEvents(e){this.cleanupDataProducerEvents();const t=t=>{c(this,fc,"f").debug(`Heartbeat data producer ${t}`,{readyState:e.readyState,closed:e.closed})},r=()=>t("open"),n=()=>t("close"),i=()=>t("transport closed");e.on("open",r),e.on("close",n),e.on("transportclose",i),d(this,hc,[()=>e.off("open",r),()=>e.off("close",n),()=>e.off("transportclose",i)],"f")}cleanupDataProducerEvents(){c(this,hc,"f").forEach((e=>e())),d(this,hc,[],"f")}sendHeartbeat(){if(c(this,lc,"f")&&this.canSendHeartbeat())try{c(this,lc,"f").send(c(this,mc,"f"))}catch(e){c(this,fc,"f").debug("Failed to send datachannel heartbeat",{error:Ct(e)})}}};uc=new WeakMap,lc=new WeakMap,pc=new WeakMap,hc=new WeakMap,fc=new WeakMap,mc=new WeakMap,vc=i([at(),s(0,dt(On.LoggerFactory)),o("design:paramtypes",[Function])],vc);var yc,_c=vc;class bc extends mn{constructor(e,t,r){super(null!=e?e:bc.DEFAULT_MESSAGE,null!=t?t:"invalid_payload",r)}}bc.DEFAULT_MESSAGE="Invalid payload",function(e){e.DominantSpeaker="dominant-speaker",e.PeersVolumes="peers-volumes",e.Silence="silence"}(yc||(yc={}));let Ec=class{constructor(){this.peers=new Map}has(e){return this.peers.has(e)}set(e,t){this.peers.set(e,t)}get(e){return this.peers.get(e)}delete(e){return this.peers.delete(e)}all(){return Array.from(this.peers.values())}hosts(){return this.all().filter((e=>"host"===e.role))}audience(){return this.all().filter((e=>"audience"===e.role))}clear(){this.peers.clear()}};Ec=i([at()],Ec);var wc=Ec;const Sc=[{scaleResolutionDownBy:4,maxBitrate:15e4,maxFramerate:12},{scaleResolutionDownBy:2,maxBitrate:35e4,maxFramerate:18},{scaleResolutionDownBy:1,maxBitrate:9e5,maxFramerate:24}],Cc=[{maxBitrate:1e6,dtx:!0}],Pc=[{maxBitrate:4e4,dtx:!0}];var Tc;let Rc=class{constructor(e,t){this.peersStorage=e,Tc.set(this,void 0),d(this,Tc,t("ChannelAudioObserverMissingProducerRestorer"),"f")}handlePeerVolume(e){const{peerId:t,producerId:r}=e,n=this.peersStorage.get(t);if(!n)return;if(n.producers.has(r))return;const i={id:r,kind:"audio",peerId:t,label:Nn.Microphone,paused:!1,encodings:Pc,maxSpatialLayer:0};n.observer.safeEmit(nn,i),c(this,Tc,"f").warn("Recovered missing audio producer from audio observer volume",{peerId:t,producerId:r})}};Tc=new WeakMap,Rc=i([at(),s(0,dt(On.PeersStorage)),s(1,dt(On.LoggerFactory)),o("design:paramtypes",[wc,Function])],Rc);var kc,Dc,Ic,Ac,Oc,Nc=Rc;let Mc=Oc=class{constructor(e,t,r,n){this.peersStorage=e,this.clientEventEmitter=t,this.channelAudioObserverMissingProducerRestorer=r,kc.set(this,void 0),Dc.set(this,void 0),Ic.set(this,void 0),Ac.set(this,void 0),d(this,kc,n("ChannelAudioObserverEventHandler"),"f"),this.watchPeersLeave()}handle(e){try{const t=JSON.parse(e);switch(Oc.validateEventPayload(t),t.event){case yc.DominantSpeaker:this.handleDominantSpeaker(t);break;case yc.PeersVolumes:this.handlePeerVolumes(t);break;case yc.Silence:this.handleSilence()}}catch(t){c(this,kc,"f").warn("Failed to handle audio observer event",{error:Ct(t),eventData:e})}}handleDominantSpeaker(e){const{peerId:t}=e.data,r=this.peersStorage.get(t);d(this,Ic,r,"f"),d(this,Ac,r,"f"),this.setActiveSpeaker(r)}handlePeerVolumes(e){e.volumes.forEach((e=>{var t;this.channelAudioObserverMissingProducerRestorer.handlePeerVolume(e);const{peerId:r,trackLabel:n,value:i}=e,s=this.peersStorage.get(r);if(!s)return;i>0&&!c(this,Ic,"f")&&s.id===(null===(t=c(this,Ac,"f"))||void 0===t?void 0:t.id)&&(d(this,Ic,s,"f"),this.setActiveSpeaker(s));const o=null==s?void 0:s.tracks.get(n);o&&o.setVolume(i)}))}handleSilence(){this.peersStorage.all().flatMap((e=>Array.from(e.tracks.values()))).forEach((e=>e.setVolume(0))),d(this,Ic,void 0,"f"),this.setActiveSpeaker(void 0)}watchPeersLeave(){this.clientEventEmitter.on(yr,(e=>{var t;e===(null===(t=c(this,Ic,"f"))||void 0===t?void 0:t.id)&&this.setActiveSpeaker(void 0)}))}setActiveSpeaker(e){c(this,Dc,"f")!==(null==e?void 0:e.id)&&(d(this,Dc,null==e?void 0:e.id,"f"),this.clientEventEmitter.safeEmit(Rr,{peer:e}))}static validateEventPayload(e){switch(e.event){case yc.Silence:break;case yc.DominantSpeaker:{e.data||Oc.throwInvalidPayload();const{peerId:t,producerId:r,trackLabel:n}=e.data;"string"==typeof t&&"string"==typeof r&&n===Nn.Microphone||Oc.throwInvalidPayload();break}case yc.PeersVolumes:Array.isArray(e.volumes)||Oc.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===Nn.Microphone||Oc.throwInvalidPayload()}));break;default:Oc.throwInvalidPayload()}}static throwInvalidPayload(){throw new bc("invalid_channel_audio_observer_payload")}};kc=new WeakMap,Dc=new WeakMap,Ic=new WeakMap,Ac=new WeakMap,Mc=Oc=i([at(),s(0,dt(On.PeersStorage)),s(1,dt(On.ClientEventEmitter)),s(2,dt(On.ChannelAudioObserverMissingProducerRestorer)),s(3,dt(On.LoggerFactory)),o("design:paramtypes",[wc,Et,Nc,Function])],Mc);var Lc,xc,Fc,jc=Mc;let Uc=class{constructor(e,t,r,n,i){this.state=e,this.myPeer=r,this.signalingApiClient=n,this.channelAudioObserverEventHandler=i,Lc.set(this,void 0),xc.set(this,void 0),Fc.set(this,void 0),d(this,Lc,t("DataChannels"),"f")}get channelMessagesDataConsumer(){return c(this,Fc,"f")}createAudioObserver(e){return a(this,void 0,void 0,(function*(){var t;const r={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(t=this.myPeer)||void 0===t?void 0:t.id};try{const{producerId:t}=yield this.getAudioObserverProducer();d(this,xc,yield this.createDataConsumer({producerId:t,appId:this.state.appId,channelId:this.state.channelId,transport:e}),"f");const n=this.channelAudioObserverEventHandler.handle.bind(this.channelAudioObserverEventHandler),i=()=>{var e,t;null===(e=c(this,xc,"f"))||void 0===e||e.removeListener("message",n),null===(t=c(this,xc,"f"))||void 0===t||t.removeListener("close",i)};c(this,xc,"f").on("close",i),c(this,xc,"f").on("message",n),c(this,Lc,"f").debug("Successfully create audio observer",r)}catch(e){c(this,Lc,"f").error("Failed to create audio observer",Object.assign(Object.assign({},r),{error:Ct(e)}))}}))}createChannelMessagesDataConsumer(e){return a(this,void 0,void 0,(function*(){var t;const r={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(t=this.myPeer)||void 0===t?void 0:t.id};try{const{id:t}=yield this.createDataProducer(e.id,"channel-messages-data-producer");d(this,Fc,yield this.createDataConsumer({producerId:t,appId:this.state.appId,channelId:this.state.channelId,ordered:!0,transport:e}),"f"),c(this,Lc,"f").debug("Successfully created channel messages data consumer",Object.assign(Object.assign({},r),{producerId:t}))}catch(e){throw c(this,Lc,"f").error("Failed to create channel messages data consumer",Object.assign(Object.assign({},r),{error:e})),e}}))}closeAudioObserver(){var e;null===(e=c(this,xc,"f"))||void 0===e||e.close()}closeChannelMessagesDataConsumer(){var e;null===(e=c(this,Fc,"f"))||void 0===e||e.close()}createDataProducer(e,t){return a(this,void 0,void 0,(function*(){const{data:r}=yield this.signalingApiClient.transport.produceDataToTransport(e,{label:t});return r}))}createDataConsumer(e){return a(this,arguments,void 0,(function*({producerId:e,appId:t,channelId:r,ordered:n,transport:i}){if(!i)throw c(this,Lc,"f").error("createDataConsumer()",{reason:"missing receive transport"}),new Error("Failed to create data consumer due to missing receive transport");c(this,Lc,"f").debug("createDataConsumer()",{producerId:e});const s=(yield this.signalingApiClient.dataConsumer.createDataConsumer({ordered:n,dataProducerId:e,transportId:i.id,appData:{peerId:this.myPeer.id,producerId:e,appId:t,channelId:r}})).data,o=yield i.consumeData(s);return c(this,Lc,"f").debug("Data consumer created",{consumerId:o.id}),o}))}getAudioObserverProducer(){return a(this,void 0,void 0,(function*(){const{data:e}=yield this.signalingApiClient.producer.getAudioObserverProducer();return e}))}};Lc=new WeakMap,xc=new WeakMap,Fc=new WeakMap,Uc=i([at(),s(0,dt(On.CallState)),s(1,dt(On.LoggerFactory)),s(2,dt(On.MyPeer)),s(3,dt(On.SignalingApiClient)),s(4,dt(On.ChannelAudioObserverEventHandler)),o("design:paramtypes",[Ln,Function,ws,gc,jc])],Uc);var Vc,Bc,Wc=Uc;let Hc=class{constructor(e,t){this.signalingApiClient=t,Vc.set(this,void 0),Bc.set(this,void 0),d(this,Bc,e("SignalingHeartbeater"),"f")}start(){c(this,Vc,"f")||(d(this,Vc,setInterval((()=>a(this,void 0,void 0,(function*(){yield this.sendHeartbeat()}))),15e3),"f"),c(this,Bc,"f").debug("Signaling heartbeat interval started"))}dispose(){c(this,Vc,"f")&&(clearInterval(c(this,Vc,"f")),d(this,Vc,void 0,"f"),c(this,Bc,"f").debug("Signaling heartbeat interval stopped"))}sendHeartbeat(){return a(this,void 0,void 0,(function*(){try{yield this.signalingApiClient.ping.pingPeer()}catch(e){c(this,Bc,"f").debug("Failed to send signaling heartbeat",{error:Ct(e)})}}))}};Vc=new WeakMap,Bc=new WeakMap,Hc=i([at(),s(0,dt(On.LoggerFactory)),s(1,dt(On.SignalingApiClient)),o("design:paramtypes",[Function,gc])],Hc);var qc,zc,Gc,Yc=Hc;let $c=class{constructor(e,t,r,n,i,s,o,a){this.state=e,this.myPeer=t,this.clientEventEmitter=n,this.dataChannelsManager=i,this.signalingApiClient=s,this.datachannelHeartbeater=o,this.signalingHeartbeater=a,qc.set(this,new Map),zc.set(this,void 0),Gc.set(this,void 0),this.peersLoaded=!1,d(this,Gc,r("Network"),"f"),d(this,zc,new Et,"f")}get isNetworkActive(){var e,t,r,n;return["connected","new"].includes(null!==(t=null===(e=this.receiveTransport)||void 0===e?void 0:e.connectionState)&&void 0!==t?t:"")&&["connected","new"].includes(null!==(n=null===(r=this.sendTransport)||void 0===r?void 0:r.connectionState)&&void 0!==n?n:"")}get observer(){return c(this,zc,"f")}removeEventListeners(){const{sendTransport:e,receiveTransport:t,signalingTransport:r}=this;if(e){["connect","produce","connectionstatechange"].forEach((t=>e.removeAllListeners(t)))}if(t){["connect","produce","connectionstatechange"].forEach((e=>t.removeAllListeners(e)))}if(r){["connect","produce","producedata","connectionstatechange"].forEach((e=>r.removeAllListeners(e)))}}reset(){this.datachannelHeartbeater.dispose(),this.signalingHeartbeater.dispose(),this.heartbeatDataProducer=void 0,this.peersLoaded=!1,this.stopRestartIceAttempts(),this.removeEventListeners(),this.closeAllDataChannels(),this.closeSendTransport(),this.closeReceiveTransport(),this.closeConnectionTransport()}closeRemoteProducer(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.producer.closeProducer(e)}))}closeSendTransport(){this.sendTransport?(this.closeTransport(this.sendTransport),this.sendTransport=void 0):c(this,Gc,"f").debug("closeSendTransport()",{message:"No available send transport"})}closeReceiveTransport(){this.receiveTransport?(this.closeTransport(this.receiveTransport),this.receiveTransport=void 0):c(this,Gc,"f").debug("closeReceiveTransport()",{message:"No available receive transport"})}closeConnectionTransport(){this.signalingTransport?(this.closeTransport(this.signalingTransport),this.signalingTransport=void 0):c(this,Gc,"f").debug("closeConnectionTransport()",{message:"No available connection transport"})}closeTransport(e){try{e.close(),c(this,Gc,"f").debug("closeTransport()",{transportId:e.id,direction:e.direction})}catch(t){c(this,Gc,"f").error("closeTransport()",{error:t,transportId:e.id,direction:e.direction})}}createSendTransport(e){return a(this,void 0,void 0,(function*(){if(this.sendTransport)throw c(this,Gc,"f").warn("createSendTransport()",{message:"Send transport already exists"}),new mn("Send transport already exists","already_exists");const{data:t}=yield this.signalingApiClient.transport.createTransport({localDirection:"send"}),r=e.createSendTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return c(this,Gc,"f").debug("createSendTransport()",{transportId:r.id,direction:r.direction}),this.sendTransport=r,this.subscribeCommonTransportEvents(r),r}))}createRecvTransport(e){return a(this,void 0,void 0,(function*(){if(this.receiveTransport)throw c(this,Gc,"f").warn("createReceiveTransport()",{message:"Receive transport already exists"}),new mn("Receive transport already exists","already_exists");const{data:t}=yield this.signalingApiClient.transport.createTransport({localDirection:"receive"}),r=e.createRecvTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return c(this,Gc,"f").debug("createReceiveTransport()",{transportId:r.id,direction:r.direction}),this.receiveTransport=r,this.subscribeCommonTransportEvents(r),r}))}createSignalingTransport(e){return a(this,void 0,void 0,(function*(){if(this.signalingTransport)throw c(this,Gc,"f").warn("createConnectionTransport()",{message:"Connection transport already exists"}),new mn("Connection transport already exists","already_exists");const{data:t}=yield this.signalingApiClient.transport.createTransport({localDirection:"receive",tcpOnly:!0}),r=e.createSendTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return c(this,Gc,"f").debug("createConnectionTransport()",{transportId:r.id,direction:r.direction,tcpOnly:!0}),this.signalingTransport=r,this.subscribeCommonTransportEvents(r),r}))}getIceParameters(e){return a(this,void 0,void 0,(function*(){const{data:{iceParameters:t}}=yield this.signalingApiClient.transport.getTransportIceParameters(e.id);return t}))}restartIce(e){return a(this,void 0,void 0,(function*(){try{const t=yield this.getIceParameters(e);yield e.restartIce({iceParameters:t}),c(this,Gc,"f").info("restartIce completed",{iceParameters:t})}catch(e){c(this,Gc,"f").error("restartIce error",{error:e})}}))}createConsumer(e){return a(this,arguments,void 0,(function*({producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i}){var s;const o=this.receiveTransport;if(!o)throw c(this,Gc,"f").error("createConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer due to missing receive transport");let a;c(this,Gc,"f").debug("createConsumer()",{producerId:e});try{const{data:r}=yield this.signalingApiClient.consumer.createConsumer({producerId:e,transportId:o.id,rtpCapabilities:t,producerPeerId:i});a=this.toRemoteConsumerOptions(r)}catch(t){if(!(t instanceof Ss&&(null===(s=t.meta)||void 0===s?void 0:s.existedConsumer)))throw c(this,Gc,"f").error("Failed to get consumer options",{producerId:e,appId:r,channelId:n,producerPeerId:i,error:Ct(t)}),new Error("Failed to create consumer due to error while fetching consumer options");a=t.meta.existedConsumer}if(!a)throw new Error("Failed to create consumer due to missing consumer options");const d=yield o.consume(a),{producerPaused:u}=a;return u&&"audio"!==d.kind&&d.pause(),c(this,Gc,"f").debug("Consumer created",{consumerId:d.id,label:d.appData.label,isProducerPaused:u}),{consumer:d,isProducerPaused:u}}))}initializeHeartbeats(){return a(this,void 0,void 0,(function*(){this.signalingHeartbeater.start();const e=this.sendTransport;if(!e)throw c(this,Gc,"f").error("createHeartbeatProducer()",{reason:"missing send transport"}),new Error("Failed to create data producer");const t=yield e.produceData({label:"heart-beater",protocol:"heartbeat"});this.heartbeatDataProducer=t,t.once("transportclose",(()=>{var e;null===(e=this.heartbeatDataProducer)||void 0===e||e.close(),this.heartbeatDataProducer=void 0,this.datachannelHeartbeater.dispose()})),this.datachannelHeartbeater.init(e,t)}))}createKeepAliveConsumer(){return a(this,void 0,void 0,(function*(){const e=this.signalingTransport;if(!e)return void c(this,Gc,"f").error("createKeepAliveConsumer()",{reason:"missing signaling transport"});const t=yield e.produceData({label:"consumers-scores",protocol:"keepalive"});t.once("open",(()=>{t.send(new Uint8Array(0))})),t.once("transportclose",(()=>{t.close()}))}))}get channelMessagesDataConsumer(){return this.dataChannelsManager.channelMessagesDataConsumer}closeRemoteConsumer(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.consumer.closeConsumer(e)}))}resumeRemoteConsumer(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.consumer.resumeConsumer(e)}))}pauseRemoteProducer(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.producer.pauseProducer(e)}))}resumeRemoteProducer(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.producer.resumeProducer(e)}))}pauseRemoteConsumer(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.consumer.pauseConsumer(e)}))}updatePeerAppData(e){return a(this,arguments,void 0,(function*({appData:e}){yield this.signalingApiClient.appData.updateSelfPeerAppData({appData:e})}))}setProducerMaxSpatialLayer(e,t){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.producer.setProducerMaxSpatialLayer(e,{maxSpatialLayer:t})}))}requestProducerMaxSpatialLayer(e,t){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.producer.requestProducerMaxSpatialLayer(e,{spatialLayer:t})}))}changePeerProducePermissions(e,t){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.peers.changePeerProducePermissions(e,{producePermissions:null==t?void 0:t.map((e=>e))})}))}addPeerProducePermission(e,t){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.peers.addPeerProducePermissions(e,t)}))}removePeerProducePermission(e,t){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.peers.removePeerProducePermissions(e,t)}))}updateConsumerPreferredLayers(e,t,r){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.consumer.updateConsumerPreferredLayers(e,{spatialLayer:t,temporalLayer:r})}))}requestConsumerKeyFrame(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.consumer.requestConsumerKeyFrame(e)}))}ping(){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.ping.pingPeer()}))}getTransportsStateInfo(){return a(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([this.getParsedTransportStats(this.receiveTransport),this.getParsedTransportStats(this.sendTransport)]);return{receive:e,send:t}}))}setPreferRelay(e){this.preferRelay=e}getPreferRelay(){var e;return null!==(e=this.preferRelay)&&void 0!==e&&e}getChannelPeers(e){return a(this,void 0,void 0,(function*(){var t;const{data:r}=yield this.signalingApiClient.peers.getPeers({role:e});this.peersLoaded=!0;return{peers:(null!==(t=r.items)&&void 0!==t?t:[]).map((e=>this.mapPeerResponse(e)))}}))}createAllDataChannels(){return a(this,void 0,void 0,(function*(){if(!this.receiveTransport)throw new Error("Receive transport is not created");yield Promise.all([this.dataChannelsManager.createAudioObserver(this.receiveTransport),this.dataChannelsManager.createChannelMessagesDataConsumer(this.receiveTransport)])}))}closeAllDataChannels(){this.dataChannelsManager.closeAudioObserver(),this.dataChannelsManager.closeChannelMessagesDataConsumer()}waitForReceiveTransportConnected(e){return a(this,arguments,void 0,(function*({onReceiveTransportFailed:e}){if(!this.receiveTransport)throw new Error("receiveTransport is not initialized");if("connected"===(yield this.waitForTransportTerminalState(this.receiveTransport)))return;yield e();const t=yield this.waitForTransportTerminalState(this.receiveTransport);if("connected"!==t)throw new Error(`receiveTransport connection failed after relay escalation: ${t}`)}))}triggerChannelStateEvent(e){return a(this,void 0,void 0,(function*(){const{data:t}=yield this.signalingApiClient.channel.triggerChannelStateEvent({role:e});if("number"!=typeof t.messageId)throw new Error("Invalid channel state event response");return t.messageId}))}waitForChannelMessagesDataConsumerConnected(){return a(this,void 0,void 0,(function*(){if(!this.dataChannelsManager.channelMessagesDataConsumer)throw new Error("channelMessagesDataConsumer is not initialized");yield this.waitForDataConsumerConnected(this.dataChannelsManager.channelMessagesDataConsumer)}))}waitForTransportTerminalState(e){return a(this,arguments,void 0,(function*(e,t=6e4){return"connected"===e.connectionState?e.connectionState:yield new Promise(((r,n)=>{const i=setTimeout((()=>{s(),r(e.connectionState)}),t),s=()=>{clearTimeout(i),e.off("connectionstatechange",o)},o=()=>{["connected","failed"].includes(e.connectionState)?(s(),r(e.connectionState)):"closed"===e.connectionState&&(s(),n(new Error(`receiveTransport connection failed: ${e.connectionState}`)))};e.on("connectionstatechange",o)}))}))}waitForDataConsumerConnected(e){return a(this,arguments,void 0,(function*(e,t=6e4){if(!e)throw new Error("Data consumer is not initialized");"open"!==e.readyState&&(yield new Promise(((r,n)=>{const i=setTimeout((()=>{s(),n(new Error("Timed out waiting for data consumer to connect"))}),t),s=()=>{clearTimeout(i),e.off("open",o),e.off("close",a)},o=()=>{s(),r()},a=()=>{s(),n(new Error(`Data consumer closed unexpectedly: ${e.readyState}`))};e.on("open",o),e.on("close",a)})))}))}getParsedTransportStats(e){return a(this,void 0,void 0,(function*(){if(e)try{const t=Array.from((yield e.getStats()).values()),r=t.find((e=>"local-candidate"===e.type)),n=t.find((e=>"remote-candidate"===e.type)),i=t.find((e=>"transport"===e.type));return{dtlsState:null==i?void 0:i.dtlsState,iceState:null==i?void 0:i.iceState,dtlsRole:null==i?void 0:i.dtlsRole,iceRole:null==i?void 0:i.iceRole,selectedCandidatePairChanges:null==i?void 0:i.selectedCandidatePairChanges,tlsVersion:null==i?void 0:i.tlsVersion,localCandidateState:{ip:null==r?void 0:r.ip,address:null==r?void 0:r.address,port:null==r?void 0:r.port,protocol:null==r?void 0:r.protocol,candidateType:null==r?void 0:r.candidateType},remoteCandidateState:{ip:null==n?void 0:n.ip,address:null==n?void 0:n.address,port:null==n?void 0:n.port,protocol:null==n?void 0:n.protocol,candidateType:null==n?void 0:n.candidateType}}}catch(e){return void c(this,Gc,"f").warn("getParsedTransportStats()",{error:e})}else c(this,Gc,"f").debug("getParsedTransportStats()",{message:"Transport is missing"})}))}logTransportDetails(e){return a(this,void 0,void 0,(function*(){var t,r,n,i;let s;try{s=yield e.getStats()}catch(t){return void c(this,Gc,"f").error("Failed to log detailed WebRTC transport stats",{error:Ct(t),transportId:e.id,reason:"failed to parse getStats"})}try{const o=[...s],[,a]=null!==(t=o.find((([,e])=>"transport"===(null==e?void 0:e.type))))&&void 0!==t?t:[],[,d]=null!==(r=o.find((([,e])=>"candidate-pair"===e.type&&"succeeded"===e.state&&e.nominated)))&&void 0!==r?r:[],u=s.get(String(null!==(n=null==d?void 0:d.localCandidateId)&&void 0!==n?n:"-")),l=s.get(String(null!==(i=null==d?void 0:d.remoteCandidateId)&&void 0!==i?i:"-")),p={hasNominatedPair:!!d,transportId:e.id,iceRole:null==a?void 0:a.iceRole,iceState:null==a?void 0:a.iceState,dtlsRole:null==a?void 0:a.dtlsRole,dtlsState:null==a?void 0:a.dtlsState,local:{address:null==u?void 0:u.address,candidateType:null==u?void 0:u.candidateType,foundation:null==u?void 0:u.foundation,networkType:null==u?void 0:u.networkType,isRemote:null==u?void 0:u.isRemote,port:null==u?void 0:u.port,protocol:null==u?void 0:u.protocol,relatedAddress:null==u?void 0:u.relatedAddress,relatedPort:null==u?void 0:u.relatedPort,transportId:null==u?void 0:u.transportId,relayProtocol:null==u?void 0:u.relayProtocol,url:null==u?void 0:u.url},remote:{address:null==l?void 0:l.address,candidateType:null==l?void 0:l.candidateType,foundation:null==l?void 0:l.foundation,isRemote:null==l?void 0:l.isRemote,port:null==l?void 0:l.port,protocol:null==l?void 0:l.protocol,transportId:null==l?void 0:l.transportId}};(null==d?void 0:d.totalRoundTripTime)&&(null==d?void 0:d.responsesReceived)&&(p.pairRoundTripTime=Math.round(d.totalRoundTripTime/d.responsesReceived*1e3)),c(this,Gc,"f").info("Detailed WebRTC transport stats",p)}catch(t){c(this,Gc,"f").error("Failed to log detailed WebRTC transport stats",{error:Ct(t),transportId:e.id,reason:"-"})}}))}stopRestartIceAttempts(){Array.from(c(this,qc,"f").values()).forEach((e=>clearInterval(e)))}toRemoteConsumerOptions(e){const{producerPaused:t}=e,r=n(e,["producerPaused"]);return Object.assign(Object.assign({},r),{producerPaused:t})}mapPeerResponse(e){var t,r,n,i,s,o,a,c;return{id:e.id,channelIds:null!==(t=e.channelIds)&&void 0!==t?t:[],groups:null!==(r=e.groups)&&void 0!==r?r:[],producePermissions:null!==(n=e.producePermissions)&&void 0!==n?n:[],appId:null!==(s=null!==(i=e.appId)&&void 0!==i?i:this.state.appId)&&void 0!==s?s:"",producers:(null!==(o=e.producers)&&void 0!==o?o:[]).map((e=>this.mapProducer(e))),uid:e.uid,appData:null!==(a=e.appData)&&void 0!==a?a:{},role:null!==(c=e.role)&&void 0!==c?c:"audience",loginDate:e.loginDate?new Date(e.loginDate):new Date}}mapProducer(e){var t;return{id:e.id,kind:e.kind,peerId:e.peerId,label:e.label,paused:null!==(t=e.paused)&&void 0!==t&&t,encodings:[],maxSpatialLayer:0}}subscribeCommonTransportEvents(e){e.on("connect",((t,r,n)=>a(this,[t,r,n],void 0,(function*({dtlsParameters:t},r,n){try{yield this.signalingApiClient.transport.connectTransport(e.id,{dtlsParameters:t}),r(),c(this,Gc,"f").debug(`${e.direction}Transport.connect()`,{transportId:e.id,dtlsRole:t.role}),setTimeout((()=>a(this,void 0,void 0,(function*(){return yield this.logTransportDetails(e)}))),2e3),setTimeout((()=>a(this,void 0,void 0,(function*(){return yield this.checkTransportState(e)}))),15e3)}catch(t){c(this,Gc,"f").error(`${e.direction}Transport.on('connect')`,{error:t}),n(t)}})))),e.on("produce",((t,r,n)=>a(this,void 0,void 0,(function*(){try{const{data:n}=yield this.signalingApiClient.transport.produceMediaToTransport(e.id,{kind:t.kind,rtpParameters:t.rtpParameters,appData:t.appData}),i=n.id;r({id:i}),c(this,Gc,"f").debug(`${e.direction}Transport.produce()`,{producerId:i,transportId:e.id,kind:t.kind})}catch(r){c(this,Gc,"f").error(`${e.direction}Transport.produce()`,{error:Ct(r),transportId:e.id,kind:t.kind}),n(r)}})))),e.on("producedata",((t,r,n)=>a(this,void 0,void 0,(function*(){try{const{data:n}=yield this.signalingApiClient.transport.produceDataToTransport(e.id,{label:t.label,sctpStreamParameters:t.sctpStreamParameters,appData:t.appData});r({id:n.id}),c(this,Gc,"f").debug(`${e.direction}Transport.produceData()`,{producerId:n.id,transportId:e.id,sctpStreamParameters:t.sctpStreamParameters,label:t.label})}catch(r){c(this,Gc,"f").error(`${e.direction}Transport.produceData()`,{error:Ct(r),transportId:e.id,sctpStreamParameters:t.sctpStreamParameters,label:t.label}),n(r)}})))),e.on("connectionstatechange",(t=>{if(c(this,Gc,"f").info(`${e.direction}Transport.state`,{state:t}),["closed","connected"].includes(t))return c(this,zc,"f").safeEmit(hn,{state:t,direction:e.direction}),c(this,qc,"f").has(e.id)&&(c(this,Gc,"f").debug("Stop receiveTransport.restartIce() retries",{recvTransportId:e.id}),clearInterval(c(this,qc,"f").get(e.id)),c(this,qc,"f").delete(e.id),"connected"===t&&c(this,zc,"f").safeEmit(hn,{state:"reconnected",direction:e.direction})),void("connected"===t&&setTimeout((()=>{this.logTransportDetails(e).catch((e=>{c(this,Gc,"f").debug("Failed to log transport details",{error:Ct(e)})}))}),1500));if(c(this,zc,"f").safeEmit(hn,{state:t,direction:e.direction}),["disconnected","failed"].includes(t)){if(c(this,qc,"f").has(e.id))return;"failed"===t&&(c(this,Gc,"f").debug(`${e.id} transport.restartIce()`,{transportId:e.id,direction:e.direction}),this.restartIce(e).catch((t=>{c(this,Gc,"f").debug("Failed to execute restartIce",{error:Ct(t),transportId:e.id,direction:e.direction})}))),c(this,qc,"f").set(e.id,setInterval((()=>{this.restartIce(e).catch((t=>{c(this,Gc,"f").debug("Failed to execute restartIce",{error:Ct(t),transportId:e.id,direction:e.direction})})),c(this,Gc,"f").debug(`${e.id} transport.restartIce() attempt`,{recvTransportId:e.id,transportId:e.id,direction:e.direction})}),1500))}})),e.on("icegatheringstatechange",(t=>{c(this,Gc,"f").info("icegatheringstatechange",{state:t,transportId:e.id,transportDirection:e.direction})}))}checkTransportState(e){return a(this,void 0,void 0,(function*(){try{const t=yield this.getParsedTransportStats(e);if(!t)return;const r="send"===e.direction?"send":"receive";if("connected"!==t.iceState)return this.clientEventEmitter.emit(Cr,{direction:r,reason:"ice"}),void c(this,Gc,"f").warn(pn,{reason:"ice",transportId:e.id,direction:r});"connected"!==t.dtlsState&&(this.clientEventEmitter.emit(Cr,{direction:r,reason:"dtls"}),c(this,Gc,"f").warn(pn,{reason:"dtls",transportId:e.id,direction:r}))}catch(t){c(this,Gc,"f").error("checkTransportState()",{error:Ct(t),transportId:e.id,direction:e.direction})}}))}};qc=new WeakMap,zc=new WeakMap,Gc=new WeakMap,$c=i([at(),s(0,dt(On.CallState)),s(1,dt(On.MyPeer)),s(2,dt(On.LoggerFactory)),s(3,dt(On.ClientEventEmitter)),s(4,dt(On.DataChannelsManager)),s(5,dt(On.SignalingApiClient)),s(6,dt(On.DatachannelHeartbeater)),s(7,dt(On.SignalingHeartbeater)),o("design:paramtypes",[Ln,ws,Function,Et,Wc,gc,_c,Yc])],$c);var Jc=$c;let Kc=class{constructor(e,t,r,n,i){this.myPeer=e,this.network=t,this.peerFactory=r,this.clientEventEmitter=n,this.peersStorage=i}has(e){return this.peersStorage.has(e)}set(e,t){e===this.myPeer.id&&this.myPeer.set(t),this.peersStorage.set(e,t)}get(e){return this.peersStorage.get(e)}delete(e){return e===this.myPeer.id&&this.myPeer.delete(),this.peersStorage.delete(e)}remove(e){return a(this,void 0,void 0,(function*(){const t=this.get(e);t&&(yield t.reset(),this.delete(e),this.clientEventEmitter.safeEmit(yr,e))}))}all(){return this.peersStorage.all()}hosts(){return this.peersStorage.hosts()}audience(){return this.peersStorage.audience()}reset(){return a(this,void 0,void 0,(function*(){yield Promise.all(this.peersStorage.all().map((e=>a(this,void 0,void 0,(function*(){return yield e.reset()}))))),this.peersStorage.clear()}))}load(e){return a(this,void 0,void 0,(function*(){const{peers:t}=yield this.network.getChannelPeers(e);t.filter((e=>!this.has(e.id))).forEach((e=>this.add(e,!1)))}))}add(e,t=!0){const r=this.get(e.id);if(r)return r;const n=this.peerFactory(e);return this.set(n.id,n),t&&this.clientEventEmitter.safeEmit(vr,n),n}isModerator(e){if(void 0===e)return!1;const t=this.get(e);return!!t&&t.isModerator}};function Qc(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 Zc(e,t,r,n){var i=Qc(Qc(Qc(e,r),function(e){return Object.prototype.toString.call(e)}(t)),typeof t);if(null===t)return Qc(i,"null");if(void 0===t)return Qc(i,"undefined");if("object"==typeof t||"function"==typeof t){if(-1!==n.indexOf(t))return Qc(i,"[Circular]"+r);n.push(t);var s=function(e,t,r){return Object.keys(t).sort().reduce((function(e,n){return Zc(e,t[n],n,r)}),e)}(i,t,n);if(!("valueOf"in t)||"function"!=typeof t.valueOf)return s;try{return Qc(s,String(t.valueOf()))}catch(e){return Qc(s,"[valueOf exception]"+(e.stack||e.message))}}return Qc(i,t.toString())}Kc=i([at(),s(0,dt(On.MyPeer)),s(1,dt(On.Network)),s(2,dt(On.PeerFactory)),s(3,dt(On.ClientEventEmitter)),s(4,dt(On.PeersStorage)),o("design:paramtypes",[ws,Jc,Function,Et,wc])],Kc);var Xc=function(e){return function(e,t){for(;e.length<t;)e="0"+e;return e}(Zc(0,e,"",[]).toString(16),8)};class ed{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 td{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.findLocalProducerById(t,e.id);if(!r)return void this.missingProducers.push(e.id);if(this.isLocalProducerStateChangedRecently(r))return;if(r.paused!==e.paused)return void this.producersWithInconsistentState.push(e.id);const n=this.findLocalConsumerByProducerId(t,e.id);n&&n.paused!==e.paused&&this.consumersWithInconsistentState.push(n.id),r||this.missingProducers.push(e.id)}))})),new ed({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=[]}isLocalProducerStateChangedRecently(e){return Date.now()-e.stateChangedAt<5e3}}var rd,nd,id,sd,od,ad,cd;!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"}(rd||(rd={}));let dd=class{constructor(e,t,r,n,i,s,o){var a;this.network=t,this.callState=r,this.peersStorage=n,this.clientEventEmitter=i,this.signalingApiClient=s,this.webRtcIssueDetector=o,nd.set(this,void 0),id.set(this,void 0),sd.set(this,[]),od.set(this,!1),ad.set(this,{inbound:4.3,outbound:4.3}),cd.set(this,(new Date).getTime()-15e3),d(this,id,null===(a=this.webRtcIssueDetector)||void 0===a?void 0:a.eventEmitter,"f"),d(this,nd,e("ChannelStateSyncEventHandler"),"f"),this.debouncedHandleChannelStateEvent=Sn(this.handleChannelStateEvent.bind(this),3e3),this.listenNetworkScoresUpdatedEvents()}handleChannelStateShort(e){return a(this,void 0,void 0,(function*(){try{yield this.debouncedHandleChannelStateEvent(e)}catch(e){c(this,nd,"f").error("handleChannelStateSyncEvent()",{error:Ct(e)})}}))}handleChannelStateEvent(e){return a(this,void 0,void 0,(function*(){if(c(this,od,"f"))c(this,nd,"f").warn("Channel state event is already being handled, skipping new event",{case:"handleChannelStateEvent"});else{d(this,od,!0,"f");try{yield this.collectProbableInconsistencyCases(e);const t=this.getConfirmedInconsistencyResult();if(!(null==t?void 0:t.hasInconsistencyCases()))return;if(this.isRestoreStateRequestToEarly())return void c(this,nd,"f").info("Inconsistency detected, but restore skipped",Object.assign({},t));this.handleConfirmedInconsistencyResult(t)}finally{d(this,od,!1,"f")}}}))}getLastInconsistencyCheckResult(){return c(this,sd,"f")[c(this,sd,"f").length-1]}handleConfirmedInconsistencyResult(e){e.missingPeers.forEach((e=>{this.clientEventEmitter.safeEmit(kr,{peerId:e,peersLoaded:this.network.peersLoaded,sdkInstances:Array.from(window._sdkMarks||[]).length,type:rd.MissingPeer})})),e.missingProducers.forEach((e=>{this.clientEventEmitter.safeEmit(kr,{producerId:e,type:rd.MissingProducer})})),e.producersWithInconsistentState.forEach((e=>{this.clientEventEmitter.safeEmit(kr,{producerId:e,type:rd.IncorrectProducerState})})),e.peersWithInconsistentAppData.forEach((e=>{this.clientEventEmitter.safeEmit(kr,{peerId:e,type:rd.IncorrectAppData})}))}getConfirmedInconsistencyResult(){const e=this.getLastInconsistencyCheckResult();if(!e)return;return new ed({missingPeers:this.getConfirmedMissingPeers(e.missingPeers),missingProducers:this.getConfirmedMissingProducers(e.missingProducers),consumersWithInconsistentState:this.getConfirmedConsumersWithInconsistencState(e.consumersWithInconsistentState),producersWithInconsistentState:this.getConfirmedProducersWithInconsistencState(e.producersWithInconsistentState),peersWithInconsistentAppData:this.getConfirmedPeersWithInconsistentAppData(e.missingPeers)})}collectProbableInconsistencyCases(e){return a(this,void 0,void 0,(function*(){const t=new td({remoteState:e,localState:this.getLocalState()}).check();if(this.rotateLastProbableInconsistencyCheckResults(t),!t.hasInconsistencyCases())return;if(this.isBadNetworkScore())return void this.resetLastProbableInconsistencyCheckResults();(yield this.getIsConnectionActive())&&this.callState.isJoined&&this.network.isNetworkActive||this.resetLastProbableInconsistencyCheckResults()}))}resetLastProbableInconsistencyCheckResults(){d(this,sd,[],"f")}rotateLastProbableInconsistencyCheckResults(e){4===c(this,sd,"f").length&&c(this,sd,"f").shift(),c(this,sd,"f").push(e)}isReachedMaxCheckRetries(e,t,r=4){let n=0;return c(this,sd,"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)))}getLocalState(){return{peers:this.peersStorage.hosts().map((e=>({id:e.id,appDataHash:Xc(e.appData),producers:e.getProducers().map((e=>({id:e.id,paused:e.paused,stateChangedAt:e.getStateChangedAt()}))),consumers:e.getConsumersState()})))}}getIsConnectionActive(){return a(this,void 0,void 0,(function*(){try{return!!this.network.isNetworkActive&&(yield this.signalingApiClient.ping.pingPeer(),!0)}catch(e){return!1}}))}listenNetworkScoresUpdatedEvents(){c(this,id,"f")&&c(this,id,"f").on(Tt.NetworkScoresUpdated,(e=>{e.inbound&&(c(this,ad,"f").inbound=e.inbound),e.outbound&&(c(this,ad,"f").outbound=e.outbound)}))}isBadNetworkScore(){const{inbound:e,outbound:t}=c(this,ad,"f");return e<=2.6||t<=2.6}compareCheckedAndRestoredResults(e,t){return new ed({missingPeers:e.missingPeers.filter((e=>!t.missingPeers.includes(e))),missingProducers:e.missingProducers.filter((e=>!t.missingProducers.includes(e))),consumersWithInconsistentState:e.consumersWithInconsistentState.filter((e=>!t.fixedConsumersState.includes(e))),producersWithInconsistentState:e.producersWithInconsistentState.filter((e=>!t.fixedProducersState.includes(e))),peersWithInconsistentAppData:e.peersWithInconsistentAppData.filter((e=>!t.restoredAppDataPeers.includes(e)))})}isRestoreStateRequestToEarly(){return(new Date).getTime()-c(this,cd,"f")<=15e3}};nd=new WeakMap,id=new WeakMap,sd=new WeakMap,od=new WeakMap,ad=new WeakMap,cd=new WeakMap,dd=i([at(),s(0,dt(On.LoggerFactory)),s(1,dt(On.Network)),s(2,dt(On.CallState)),s(3,dt(On.PeersStorage)),s(4,dt(On.ClientEventEmitter)),s(5,dt(On.SignalingApiClient)),s(6,dt(On.WebRTCIssueDetector)),o("design:paramtypes",[Function,Jc,Ln,wc,Et,gc,dr])],dd);var ud=dd,ld={},pd={exports:{}},hd=1e3,fd=6e4,md=60*fd,gd=24*md,vd=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*gd;case"hours":case"hour":case"hrs":case"hr":case"h":return r*md;case"minutes":case"minute":case"mins":case"min":case"m":return r*fd;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>=gd)return yd(e,t,gd,"day");if(t>=md)return yd(e,t,md,"hour");if(t>=fd)return yd(e,t,fd,"minute");if(t>=1e3)return yd(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=gd)return Math.round(e/gd)+"d";if(t>=md)return Math.round(e/md)+"h";if(t>=fd)return Math.round(e/fd)+"m";if(t>=hd)return Math.round(e/hd)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function yd(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var _d=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,t){let r=0,n=0,i=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(i=n,s=r,n++):(r++,n++);else{if(-1===i)return!1;n=i+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}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,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=vd,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")||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=_d(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(pd,pd.exports);var bd={};Object.defineProperty(bd,"__esModule",{value:!0});var Ed={},wd=Object.defineProperty,Sd=Object.getOwnPropertyDescriptor,Cd=Object.getOwnPropertyNames,Pd=Object.prototype.hasOwnProperty,Td={};((e,t)=>{for(var r in t)wd(e,r,{get:t[r],enumerable:!0})})(Td,{BrowserDetector:()=>Od,KnownBrowsers:()=>kd,KnownPlatforms:()=>Dd,default:()=>Nd});var Rd=(e=>((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of Cd(t))!Pd.call(e,i)&&i!==r&&wd(e,i,{get:()=>t[i],enumerable:!(n=Sd(t,i))||n.enumerable});return e})(wd({},"__esModule",{value:!0}),e))(Td),kd={chrome:"Google Chrome",brave:"Brave",crios:"Google Chrome",edge:"Microsoft Edge",edg:"Microsoft Edge",edgios:"Microsoft Edge",fennec:"Mozilla Firefox",jsdom:"JsDOM",mozilla:"Mozilla Firefox",fxios:"Mozilla Firefox",msie:"Microsoft Internet Explorer",opera:"Opera",opios:"Opera",opr:"Opera",opt:"Opera",rv:"Microsoft Internet Explorer",safari:"Safari",samsungbrowser:"Samsung Browser",electron:"Electron"},Dd={android:"Android",androidTablet:"Android Tablet",cros:"Chrome OS",fennec:"Android Tablet",ipad:"IPad",ipod:"IPod",iphone:"IPhone",jsdom:"JsDOM",linux:"Linux",mac:"Macintosh",tablet:"Android Tablet",win:"Windows","windows phone":"Windows Phone",xbox:"Microsoft Xbox"},Id=(e,t=-1)=>{let r=new RegExp(`^-?\\d+(?:.\\d{0,${t}})?`),n=Number(e).toString().match(r);return n?n[0]:null},Ad=()=>typeof window<"u"?window.navigator:null,Od=class{userAgent;constructor(e){this.userAgent=e||Ad()?.userAgent||null}static get VERSION(){return"4.1.0"}parseUserAgent(e){let t={},r=e||this.userAgent||"",n=r.toLowerCase().replace(/\s\s+/g," "),i=/(edge)\/([\w.]+)/.exec(n)||/(edg)[/]([\w.]+)/.exec(n)||/(opr)[/]([\w.]+)/.exec(n)||/(opt)[/]([\w.]+)/.exec(n)||/(fxios)[/]([\w.]+)/.exec(n)||/(edgios)[/]([\w.]+)/.exec(n)||/(jsdom)[/]([\w.]+)/.exec(n)||/(samsungbrowser)[/]([\w.]+)/.exec(n)||/(electron)[/]([\w.]+)/.exec(n)||/(chrome)[/]([\w.]+)/.exec(n)||/(crios)[/]([\w.]+)/.exec(n)||/(opios)[/]([\w.]+)/.exec(n)||/(version)(applewebkit)[/]([\w.]+).*(safari)[/]([\w.]+)/.exec(n)||/(webkit)[/]([\w.]+).*(version)[/]([\w.]+).*(safari)[/]([\w.]+)/.exec(n)||/(applewebkit)[/]([\w.]+).*(safari)[/]([\w.]+)/.exec(n)||/(webkit)[/]([\w.]+)/.exec(n)||/(opera)(?:.*version|)[/]([\w.]+)/.exec(n)||/(msie) ([\w.]+)/.exec(n)||/(fennec)[/]([\w.]+)/.exec(n)||n.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(n)||n.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(n)||[],s=/(ipad)/.exec(n)||/(ipod)/.exec(n)||/(iphone)/.exec(n)||/(jsdom)/.exec(n)||/(windows phone)/.exec(n)||/(xbox)/.exec(n)||/(win)/.exec(n)||/(tablet)/.exec(n)||/(android)/.test(n)&&!1===/(mobile)/.test(n)&&["androidTablet"]||/(android)/.exec(n)||/(mac)/.exec(n)||/(linux)/.exec(n)||/(cros)/.exec(n)||[],o=i[5]||i[3]||i[1]||null,a=s[0]||null,c=i[4]||i[2]||null,d=Ad();"chrome"===o&&"function"==typeof d?.brave?.isBrave&&(o="brave"),o&&(t[o]=!0),a&&(t[a]=!0);let u=!!(t.tablet||t.android||t.androidTablet),l=!!(t.ipad||t.tablet||t.androidTablet),p=!!(t.android||t.androidTablet||t.tablet||t.ipad||t.ipod||t.iphone||t["windows phone"]),h=!!(t.cros||t.mac||t.linux||t.win),f=!!(t.brave||t.chrome||t.crios||t.opr||t.safari||t.edg||t.electron),m=!(!t.msie&&!t.rv),g=!(!t.chrome&&!t.crios),v=!!(t.fxios||t.fennec||t.mozilla),y=!!t.safari,_=!!(t.opera||t.opios||t.opr||t.opt),b=!!(t.edg||t.edge||t.edgios);return{name:kd[o]??null,platform:Dd[a]??null,userAgent:r,version:c,shortVersion:c?Id(parseFloat(c),2):null,isAndroid:u,isTablet:l,isMobile:p,isDesktop:h,isWebkit:f,isIE:m,isChrome:g,isFireFox:v,isSafari:y,isOpera:_,isEdge:b}}getBrowserInfo(){let e=this.parseUserAgent();return{name:e.name,platform:e.platform,userAgent:e.userAgent,version:e.version,shortVersion:e.shortVersion}}},Nd=Od,Md={};Object.defineProperty(Md,"__esModule",{value:!0}),Md.Logger=void 0;const Ld=pd.exports,xd="mediasoup-client";Md.Logger=class{_debug;_warn;_error;constructor(e){e?(this._debug=(0,Ld.default)(`${xd}:${e}`),this._warn=(0,Ld.default)(`${xd}:WARN:${e}`),this._error=(0,Ld.default)(`${xd}:ERROR:${e}`)):(this._debug=(0,Ld.default)(xd),this._warn=(0,Ld.default)(`${xd}:WARN`),this._error=(0,Ld.default)(`${xd}: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 Fd,jd={},Ud={exports:{}},Vd="object"==typeof Reflect?Reflect:null,Bd=Vd&&"function"==typeof Vd.apply?Vd.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};Fd=Vd&&"function"==typeof Vd.ownKeys?Vd.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var Wd=Number.isNaN||function(e){return e!=e};function Hd(){Hd.init.call(this)}Ud.exports=Hd,Ud.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))}Xd(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&Xd(e,"error",t,r)}(e,i,{once:!0})}))},Hd.EventEmitter=Hd,Hd.prototype._events=void 0,Hd.prototype._eventsCount=0,Hd.prototype._maxListeners=void 0;var qd=10;function zd(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Gd(e){return void 0===e._maxListeners?Hd.defaultMaxListeners:e._maxListeners}function Yd(e,t,r,n){var i,s,o,a;if(zd(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=Gd(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 $d(){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 Jd(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=$d.bind(n);return i.listener=r,n.wrapFn=i,i}function Kd(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):Zd(i,i.length)}function Qd(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 Zd(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function Xd(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(Hd,"defaultMaxListeners",{enumerable:!0,get:function(){return qd},set:function(e){if("number"!=typeof e||e<0||Wd(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");qd=e}}),Hd.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},Hd.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||Wd(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},Hd.prototype.getMaxListeners=function(){return Gd(this)},Hd.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)Bd(a,this,t);else{var c=a.length,d=Zd(a,c);for(r=0;r<c;++r)Bd(d[r],this,t)}return!0},Hd.prototype.addListener=function(e,t){return Yd(this,e,t,!1)},Hd.prototype.on=Hd.prototype.addListener,Hd.prototype.prependListener=function(e,t){return Yd(this,e,t,!0)},Hd.prototype.once=function(e,t){return zd(t),this.on(e,Jd(this,e,t)),this},Hd.prototype.prependOnceListener=function(e,t){return zd(t),this.prependListener(e,Jd(this,e,t)),this},Hd.prototype.removeListener=function(e,t){var r,n,i,s,o;if(zd(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},Hd.prototype.off=Hd.prototype.removeListener,Hd.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},Hd.prototype.listeners=function(e){return Kd(this,e,!0)},Hd.prototype.rawListeners=function(e){return Kd(this,e,!1)},Hd.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Qd.call(e,t)},Hd.prototype.listenerCount=Qd,Hd.prototype.eventNames=function(){return this._eventsCount>0?Fd(this._events):[]},Object.defineProperty(jd,"__esModule",{value:!0}),jd.EnhancedEventEmitter=void 0;const eu=Ud.exports,tu=new Md.Logger("EnhancedEventEmitter");class ru extends eu.EventEmitter{constructor(){super(),this.setMaxListeners(1/0)}close(){super.removeAllListeners()}emit(e,...t){return super.emit(e,...t)}safeEmit(e,...t){try{return super.emit(e,...t)}catch(t){tu.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)}}jd.EnhancedEventEmitter=ru;var nu={};Object.defineProperty(nu,"__esModule",{value:!0}),nu.InvalidStateError=nu.UnsupportedError=void 0;class iu extends Error{constructor(e){super(e),this.name="UnsupportedError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,iu):this.stack=new Error(e).stack}}nu.UnsupportedError=iu;class su extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,su):this.stack=new Error(e).stack}}nu.InvalidStateError=su;var ou={};Object.defineProperty(ou,"__esModule",{value:!0}),ou.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},ou.generateRandomNumber=function(){return Math.round(1e7*Math.random())},ou.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 au={},cu={},du={},uu={exports:{}};var lu=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,t){let r=0,n=0,i=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(i=n,s=r,n++):(r++,n++);else{if(-1===i)return!1;n=i+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}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,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=vd,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")||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=lu(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(uu,uu.exports);var pu=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(du,"__esModule",{value:!0}),du.Logger=void 0;const hu=pu(uu.exports),fu="h264-profile-level-id";du.Logger=class{constructor(e){e?(this._debug=(0,hu.default)(`${fu}:${e}`),this._warn=(0,hu.default)(`${fu}:WARN:${e}`),this._error=(0,hu.default)(`${fu}:ERROR:${e}`)):(this._debug=(0,hu.default)(fu),this._warn=(0,hu.default)(`${fu}:WARN`),this._error=(0,hu.default)(`${fu}: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(cu,"__esModule",{value:!0}),cu.ProfileLevelId=cu.Level=cu.Profile=void 0,cu.parseProfileLevelId=Cu,cu.profileLevelIdToString=Pu,cu.profileToString=function(e){switch(e){case gu.ConstrainedBaseline:return"ConstrainedBaseline";case gu.Baseline:return"Baseline";case gu.Main:return"Main";case gu.ConstrainedHigh:return"ConstrainedHigh";case gu.High:return"High";case gu.PredictiveHigh444:return"PredictiveHigh444";default:return void mu.warn(`profileToString() | unrecognized profile ${e}`)}},cu.levelToString=function(e){switch(e){case vu.L1_b:return"1b";case vu.L1:return"1";case vu.L1_1:return"1.1";case vu.L1_2:return"1.2";case vu.L1_3:return"1.3";case vu.L2:return"2";case vu.L2_1:return"2.1";case vu.L2_2:return"2.2";case vu.L3:return"3";case vu.L3_1:return"3.1";case vu.L3_2:return"3.2";case vu.L4:return"4";case vu.L4_1:return"4.1";case vu.L4_2:return"4.2";case vu.L5:return"5";case vu.L5_1:return"5.1";case vu.L5_2:return"5.2";default:return void mu.warn(`levelToString() | unrecognized level ${e}`)}},cu.parseSdpProfileLevelId=Tu,cu.isSameProfile=function(e={},t={}){const r=Tu(e),n=Tu(t);return Boolean(r&&n&&r.profile===n.profile)},cu.isSameProfileAndLevel=function(e={},t={}){const r=Tu(e),n=Tu(t);return Boolean(r&&n&&r.profile===n.profile&&r.level==n.level)},cu.generateProfileLevelIdStringForAnswer=function(e={},t={}){if(!e["profile-level-id"]&&!t["profile-level-id"])return void mu.warn("generateProfileLevelIdStringForAnswer() | profile-level-id missing in local and remote params");const r=Tu(e),n=Tu(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=ku(e)&&ku(t),s=r.level,o=n.level,a=function(e,t){return function(e,t){if(e===vu.L1_b)return t!==vu.L1&&t!==vu.L1_b;if(t===vu.L1_b)return e!==vu.L1;return e<t}(e,t)?e:t}(s,o),c=i?s:a;return mu.debug(`generateProfileLevelIdStringForAnswer() | result [profile:${r.profile}, level:${c}]`),Pu(new yu(r.profile,c))},cu.supportedLevel=function(e,t){for(let r=Su.length-1;r>=0;--r){const n=Su[r];if(256*n.max_macroblock_frame_size<=e&&n.max_macroblocks_per_second<=t*n.max_macroblock_frame_size)return mu.debug(`supportedLevel() | result [max_frame_pixel_count:${e}, max_fps:${t}, level:${n.level}]`),n.level}return void mu.warn(`supportedLevel() | no level supported [max_frame_pixel_count:${e}, max_fps:${t}]`)};const mu=new du.Logger;var gu,vu;!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"}(gu||(cu.Profile=gu={})),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"}(vu||(cu.Level=vu={}));class yu{constructor(e,t){this.profile=e,this.level=t}}cu.ProfileLevelId=yu;const _u=new yu(gu.ConstrainedBaseline,vu.L3_1);class bu{constructor(e){this.mask=~Ru("x",e),this.masked_value=Ru("1",e)}isMatch(e){return this.masked_value===(e&this.mask)}}class Eu{constructor(e,t,r){this.profile_idc=e,this.profile_iop=t,this.profile=r}}const wu=[new Eu(66,new bu("x1xx0000"),gu.ConstrainedBaseline),new Eu(77,new bu("1xxx0000"),gu.ConstrainedBaseline),new Eu(88,new bu("11xx0000"),gu.ConstrainedBaseline),new Eu(66,new bu("x0xx0000"),gu.Baseline),new Eu(88,new bu("10xx0000"),gu.Baseline),new Eu(77,new bu("0x0x0000"),gu.Main),new Eu(100,new bu("00000000"),gu.High),new Eu(100,new bu("00001100"),gu.ConstrainedHigh),new Eu(244,new bu("00000000"),gu.PredictiveHigh444)],Su=[{max_macroblocks_per_second:1485,max_macroblock_frame_size:99,level:vu.L1},{max_macroblocks_per_second:1485,max_macroblock_frame_size:99,level:vu.L1_b},{max_macroblocks_per_second:3e3,max_macroblock_frame_size:396,level:vu.L1_1},{max_macroblocks_per_second:6e3,max_macroblock_frame_size:396,level:vu.L1_2},{max_macroblocks_per_second:11880,max_macroblock_frame_size:396,level:vu.L1_3},{max_macroblocks_per_second:11880,max_macroblock_frame_size:396,level:vu.L2},{max_macroblocks_per_second:19800,max_macroblock_frame_size:792,level:vu.L2_1},{max_macroblocks_per_second:20250,max_macroblock_frame_size:1620,level:vu.L2_2},{max_macroblocks_per_second:40500,max_macroblock_frame_size:1620,level:vu.L3},{max_macroblocks_per_second:108e3,max_macroblock_frame_size:3600,level:vu.L3_1},{max_macroblocks_per_second:216e3,max_macroblock_frame_size:5120,level:vu.L3_2},{max_macroblocks_per_second:245760,max_macroblock_frame_size:8192,level:vu.L4},{max_macroblocks_per_second:245760,max_macroblock_frame_size:8192,level:vu.L4_1},{max_macroblocks_per_second:522240,max_macroblock_frame_size:8704,level:vu.L4_2},{max_macroblocks_per_second:589824,max_macroblock_frame_size:22080,level:vu.L5},{max_macroblocks_per_second:983040,max_macroblock_frame_size:36864,level:vu.L5_1},{max_macroblocks_per_second:2073600,max_macroblock_frame_size:36864,level:vu.L5_2}];function Cu(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 vu.L1_1:s=0!=(16&n)?vu.L1_b:vu.L1_1;break;case vu.L1:case vu.L1_2:case vu.L1_3:case vu.L2:case vu.L2_1:case vu.L2_2:case vu.L3:case vu.L3_1:case vu.L3_2:case vu.L4:case vu.L4_1:case vu.L4_2:case vu.L5:case vu.L5_1:case vu.L5_2:s=r;break;default:return void mu.warn(`parseProfileLevelId() | unrecognized level_idc [str:${e}, level_idc:${r}]`)}for(const t of wu)if(i===t.profile_idc&&t.profile_iop.isMatch(n))return mu.debug(`parseProfileLevelId() | result [str:${e}, profile:${t.profile}, level:${s}]`),new yu(t.profile,s);mu.warn(`parseProfileLevelId() | unrecognized profile_idc/profile_iop combination [str:${e}, profile_idc:${i}, profile_iop:${n}]`)}function Pu(e){if(e.level==vu.L1_b)switch(e.profile){case gu.ConstrainedBaseline:return"42f00b";case gu.Baseline:return"42100b";case gu.Main:return"4d100b";default:return void mu.warn(`profileLevelIdToString() | Level 1_b not is allowed for profile ${e.profile}`)}let t;switch(e.profile){case gu.ConstrainedBaseline:t="42e0";break;case gu.Baseline:t="4200";break;case gu.Main:t="4d00";break;case gu.ConstrainedHigh:t="640c";break;case gu.High:t="6400";break;case gu.PredictiveHigh444:t="f400";break;default:return void mu.warn(`profileLevelIdToString() | unrecognized profile ${e.profile}`)}let r=e.level.toString(16);return 1===r.length&&(r=`0${r}`),`${t}${r}`}function Tu(e={}){const t=e["profile-level-id"];return t?Cu(t):_u}function Ru(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 ku(e={}){const t=e["level-asymmetry-allowed"];return!0===t||1===t||"1"===t}Object.defineProperty(au,"__esModule",{value:!0}),au.validateAndNormalizeRtpCapabilities=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)Ou(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)Mu(t)},au.validateAndNormalizeRtpParameters=Au,au.validateAndNormalizeSctpStreamParameters=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")},au.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)},au.getExtendedRtpCapabilities=function(e,t,r){const n={codecs:[],headerExtensions:[]};if(r)for(const r of e.codecs??[]){if(ju(r))continue;const e=(t.codecs??[]).find((e=>Uu(e,r,{strict:!0,modify:!0})));if(!e)continue;const i={kind:r.kind,mimeType:r.mimeType,clockRate:r.clockRate,channels:r.channels,localPayloadType:r.preferredPayloadType,localRtxPayloadType:void 0,remotePayloadType:e.preferredPayloadType,remoteRtxPayloadType:void 0,localParameters:r.parameters??{},remoteParameters:e.parameters??{},rtcpFeedback:Bu(r,e)};n.codecs.push(i)}else for(const r of t.codecs??[]){if(ju(r))continue;const t=(e.codecs??[]).find((e=>Uu(e,r,{strict:!0,modify:!0})));if(!t)continue;const i={kind:t.kind,mimeType:t.mimeType,clockRate:t.clockRate,channels:t.channels,localPayloadType:t.preferredPayloadType,localRtxPayloadType:void 0,remotePayloadType:r.preferredPayloadType,remoteRtxPayloadType:void 0,localParameters:t.parameters??{},remoteParameters:r.parameters??{},rtcpFeedback:Bu(t,r)};n.codecs.push(i)}for(const r of n.codecs){const n=e.codecs.find((e=>ju(e)&&e.parameters?.apt===r.localPayloadType)),i=t.codecs.find((e=>ju(e)&&e.parameters?.apt===r.remotePayloadType));n&&i&&(r.localRtxPayloadType=n.preferredPayloadType,r.remoteRtxPayloadType=i.preferredPayloadType)}for(const r of t.headerExtensions){const t=e.headerExtensions.find((e=>Vu(e,r)));if(!t)continue;const i={kind:r.kind,uri:r.uri,sendId:t.preferredId,recvId:r.preferredId,encrypt:t.preferredEncrypt??!1,direction:"sendrecv"};switch(r.direction){case"sendrecv":i.direction="sendrecv";break;case"recvonly":i.direction="sendonly";break;case"sendonly":i.direction="recvonly";break;case"inactive":i.direction="inactive"}n.headerExtensions.push(i)}return n},au.getRecvRtpCapabilities=function(e){const t={codecs:[],headerExtensions:[]};for(const r of e.codecs){const e={kind:r.kind,mimeType:r.mimeType,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={kind:r.kind,mimeType:`${r.kind}/rtx`,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??!1,direction:r.direction};t.headerExtensions.push(e)}return t},au.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},au.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},au.reduceCodecs=function(e,t){const r=[];if(t){for(let n=0;n<e.length;++n)if(Uu(e[n],t,{strict:!0})){r.push(e[n]),ju(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]),ju(e[1])&&r.push(e[1]);return r},au.generateProbatorRtpParameters=function(e){Au(e=Iu.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},au.canSend=function(e,t){return(t.codecs??[]).some((t=>t.kind===e))},au.canReceive=function(e,t){if(Au(e),0===e.codecs.length)return!1;const r=e.codecs[0];return(t.codecs??[]).some((e=>e.preferredPayloadType===r.payloadType))};const Du=cu,Iu=ou;function Au(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)Lu(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)xu(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)Fu(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 Ou(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(),"number"!=typeof e.preferredPayloadType)throw new TypeError("missing 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)Nu(t)}function Nu(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 Mu(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 Lu(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)Nu(t)}function xu(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 Fu(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 ju(e){return!!e&&/.+\/rtx$/i.test(e.mimeType)}function Uu(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(!Du.isSameProfile(e.parameters,t.parameters))return!1;let r;try{r=Du.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 Vu(e,t){return(!e.kind||!t.kind||e.kind===t.kind)&&e.uri===t.uri}function Bu(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 Wu={},Hu={},qu={},zu={};Object.defineProperty(zu,"__esModule",{value:!0}),zu.Logger=void 0;const Gu=pd.exports,Yu="awaitqueue";zu.Logger=class{_debug;_warn;_error;constructor(e){e?(this._debug=Gu(`awaitqueue:${e}`),this._warn=Gu(`awaitqueue:WARN:${e}`),this._error=Gu(`awaitqueue:ERROR:${e}`)):(this._debug=Gu(Yu),this._warn=Gu("awaitqueue:WARN"),this._error=Gu("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}};var $u={};Object.defineProperty($u,"__esModule",{value:!0}),$u.AwaitQueueRemovedTaskError=$u.AwaitQueueStoppedError=void 0;class Ju extends Error{constructor(e){super(e??"queue stopped"),this.name="AwaitQueueStoppedError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Ju)}}$u.AwaitQueueStoppedError=Ju;class Ku extends Error{constructor(e){super(e??"queue task removed"),this.name="AwaitQueueRemovedTaskError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Ku)}}$u.AwaitQueueRemovedTaskError=Ku,Object.defineProperty(qu,"__esModule",{value:!0}),qu.AwaitQueue=void 0;const Qu=$u,Zu=new zu.Logger("AwaitQueue");qu.AwaitQueue=class{pendingTasks=new Map;nextTaskId=0;stopping=!1;constructor(){Zu.debug("constructor()")}get size(){return this.pendingTasks.size}async push(e,t){if(t=t??e.name,Zu.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),Zu.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),Zu.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(){Zu.debug("stop()"),this.stopping=!0;for(const e of this.pendingTasks.values())Zu.debug(`stop() | stopping task [name:${e.name}]`),e.reject(new Qu.AwaitQueueStoppedError);this.stopping=!1}remove(e){Zu.debug(`remove() [taskIdx:${e}]`);const t=Array.from(this.pendingTasks.values())[e];t?t.reject(new Qu.AwaitQueueRemovedTaskError):Zu.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(Zu.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)}}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AwaitQueueRemovedTaskError=e.AwaitQueueStoppedError=e.AwaitQueue=void 0;var t=qu;Object.defineProperty(e,"AwaitQueue",{enumerable:!0,get:function(){return t.AwaitQueue}});var r=$u;Object.defineProperty(e,"AwaitQueueStoppedError",{enumerable:!0,get:function(){return r.AwaitQueueStoppedError}}),Object.defineProperty(e,"AwaitQueueRemovedTaskError",{enumerable:!0,get:function(){return r.AwaitQueueRemovedTaskError}})}(Hu);var Xu={};Object.defineProperty(Xu,"__esModule",{value:!0}),Xu.Producer=void 0;const el=jd,tl=nu,rl=new Md.Logger("Producer");class nl extends el.EnhancedEventEmitter{_id;_localId;_closed=!1;_rtpSender;_track;_kind;_rtpParameters;_paused;_maxSpatialLayer;_stopTracks;_disableTrackOnPause;_zeroRtpOnPause;_appData;_observer=new el.EnhancedEventEmitter;constructor({id:e,localId:t,rtpSender:r,track:n,rtpParameters:i,stopTracks:s,disableTrackOnPause:o,zeroRtpOnPause:a,appData:c}){super(),rl.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||(rl.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"),super.close(),this._observer.close())}transportClosed(){this._closed||(rl.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new tl.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){rl.debug("pause()"),this._closed?rl.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(){rl.debug("resume()"),this._closed?rl.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(rl.debug("replaceTrack() [track:%o]",e),this._closed){if(e&&this._stopTracks)try{e.stop()}catch(e){}throw new tl.InvalidStateError("closed")}if(e&&"ended"===e.readyState)throw new tl.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()):rl.debug("replaceTrack() | same track, ignored")}async setMaxSpatialLayer(e){if(this._closed)throw new tl.InvalidStateError("closed");if("video"!==this._kind)throw new tl.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 tl.InvalidStateError("closed");if("object"!=typeof e)throw new TypeError("invalid params");await new Promise(((t,r)=>{this.safeEmit("@setrtpencodingparameters",e,t,r)}))}onTrackEnded(){rl.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){}}}Xu.Producer=nl;var il={};Object.defineProperty(il,"__esModule",{value:!0}),il.Consumer=void 0;const sl=jd,ol=nu,al=new Md.Logger("Consumer");class cl extends sl.EnhancedEventEmitter{_id;_localId;_producerId;_closed=!1;_rtpReceiver;_track;_rtpParameters;_paused;_appData;_observer=new sl.EnhancedEventEmitter;constructor({id:e,localId:t,producerId:r,rtpReceiver:n,track:i,rtpParameters:s,appData:o}){super(),al.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||(al.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"),super.close(),this._observer.close())}transportClosed(){this._closed||(al.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new ol.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){al.debug("pause()"),this._closed?al.error("pause() | Consumer closed"):this._paused?al.debug("pause() | Consumer is already paused"):(this._paused=!0,this._track.enabled=!1,this.emit("@pause"),this._observer.safeEmit("pause"))}resume(){al.debug("resume()"),this._closed?al.error("resume() | Consumer closed"):this._paused?(this._paused=!1,this._track.enabled=!0,this.emit("@resume"),this._observer.safeEmit("resume")):al.debug("resume() | Consumer is already resumed")}onTrackEnded(){al.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){}}}il.Consumer=cl;var dl={};Object.defineProperty(dl,"__esModule",{value:!0}),dl.DataProducer=void 0;const ul=jd,ll=nu,pl=new Md.Logger("DataProducer");class hl extends ul.EnhancedEventEmitter{_id;_dataChannel;_closed=!1;_sctpStreamParameters;_appData;_observer=new ul.EnhancedEventEmitter;constructor({id:e,dataChannel:t,sctpStreamParameters:r,appData:n}){super(),pl.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||(pl.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"),super.close(),this._observer.close())}transportClosed(){this._closed||(pl.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}send(e){if(pl.debug("send()"),this._closed)throw new ll.InvalidStateError("closed");this._dataChannel.send(e)}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(pl.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;const t=e.error??new Error("unknown DataChannel error");"sctp-failure"===e.error?.errorDetail?pl.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",e.error?.sctpCauseCode,e.error.message):pl.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(pl.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(()=>{this._closed||pl.warn('DataChannel "message" event in a DataProducer, message discarded')})),this._dataChannel.addEventListener("bufferedamountlow",(()=>{this._closed||this.safeEmit("bufferedamountlow")}))}}dl.DataProducer=hl;var fl={};Object.defineProperty(fl,"__esModule",{value:!0}),fl.DataConsumer=void 0;const ml=jd,gl=new Md.Logger("DataConsumer");class vl extends ml.EnhancedEventEmitter{_id;_dataProducerId;_dataChannel;_closed=!1;_sctpStreamParameters;_appData;_observer=new ml.EnhancedEventEmitter;constructor({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:n,appData:i}){super(),gl.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||(gl.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"),super.close(),this._observer.close())}transportClosed(){this._closed||(gl.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(gl.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;const t=e.error??new Error("unknown DataChannel error");"sctp-failure"===e.error?.errorDetail?gl.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",e.error?.sctpCauseCode,e.error.message):gl.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(gl.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)}))}}fl.DataConsumer=vl,Object.defineProperty(Wu,"__esModule",{value:!0}),Wu.Transport=void 0;const yl=Hu,_l=jd,bl=nu,El=ou,wl=au,Sl=Xu,Cl=il,Pl=dl,Tl=fl,Rl=new Md.Logger("Transport");class kl{consumerOptions;promise;resolve;reject;constructor(e){this.consumerOptions=e,this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class Dl extends _l.EnhancedEventEmitter{_id;_closed=!1;_direction;_getSendExtendedRtpCapabilities;_recvRtpCapabilities;_canProduceByKind;_maxSctpMessageSize;_handler;_iceGatheringState="new";_connectionState="new";_appData;_producers=new Map;_consumers=new Map;_dataProducers=new Map;_dataConsumers=new Map;_probatorConsumerCreated=!1;_awaitQueue=new yl.AwaitQueue;_pendingConsumerTasks=[];_consumerCreationInProgress=!1;_pendingPauseConsumers=new Map;_consumerPauseInProgress=!1;_pendingResumeConsumers=new Map;_consumerResumeInProgress=!1;_pendingCloseConsumers=new Map;_consumerCloseInProgress=!1;_observer=new _l.EnhancedEventEmitter;constructor({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,appData:d,handlerFactory:u,getSendExtendedRtpCapabilities:l,recvRtpCapabilities:p,canProduceByKind:h}){super(),Rl.debug("constructor() [id:%s, direction:%s]",t,e),this._id=t,this._direction=e,this._getSendExtendedRtpCapabilities=l,this._recvRtpCapabilities=p,this._canProduceByKind=h,this._maxSctpMessageSize=s?s.maxMessageSize:null;const f=El.clone(c)??{};delete f.iceServers,delete f.iceTransportPolicy,delete f.bundlePolicy,delete f.rtcpMuxPolicy,this._handler=u.factory({direction:e,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:f,getSendExtendedRtpCapabilities:this._getSendExtendedRtpCapabilities}),this._appData=d??{},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){Rl.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"),super.close(),this._observer.close()}}async getStats(){if(this._closed)throw new bl.InvalidStateError("closed");return this._handler.getTransportStats()}async restartIce({iceParameters:e}){if(Rl.debug("restartIce()"),this._closed)throw new bl.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(Rl.debug("updateIceServers()"),this._closed)throw new bl.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(Rl.debug("produce() [track:%o]",e),this._closed)throw new bl.InvalidStateError("closed");if(!e)throw new TypeError("missing track");if("send"!==this._direction)throw new bl.UnsupportedError("not a sending Transport");if(!this._canProduceByKind[e.kind])throw new bl.UnsupportedError(`cannot produce ${e.kind}`);if("ended"===e.readyState)throw new bl.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{wl.validateAndNormalizeRtpParameters(l);const{id:t}=await new Promise(((t,r)=>{this.safeEmit("produce",{kind:e.kind,rtpParameters:l,appData:c},t,r)})),r=new Sl.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(Rl.debug("consume()"),this._closed)throw new bl.InvalidStateError("closed");if("recv"!==this._direction)throw new bl.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=El.clone(n);if(!wl.canReceive(a,this._recvRtpCapabilities))throw new bl.UnsupportedError("cannot consume this Producer");const c=new kl({id:e,producerId:t,kind:r,rtpParameters:a,streamId:i,onRtpReceiver:s,appData:o});return this._pendingConsumerTasks.push(c),queueMicrotask((()=>{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(Rl.debug("produceData()"),this._closed)throw new bl.InvalidStateError("closed");if("send"!==this._direction)throw new bl.UnsupportedError("not a sending Transport");if(!this._maxSctpMessageSize)throw new bl.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});wl.validateAndNormalizeSctpStreamParameters(a);const{id:c}=await new Promise(((e,t)=>{this.safeEmit("producedata",{sctpStreamParameters:a,label:n,protocol:i,appData:s},e,t)})),d=new Pl.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(Rl.debug("consumeData()"),this._closed)throw new bl.InvalidStateError("closed");if("recv"!==this._direction)throw new bl.UnsupportedError("not a receiving Transport");if(!this._maxSctpMessageSize)throw new bl.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=El.clone(r);return wl.validateAndNormalizeSctpStreamParameters(o),this._awaitQueue.push((async()=>{const{dataChannel:r}=await this._handler.receiveDataChannel({sctpStreamParameters:o,label:n,protocol:i}),a=new Tl.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()")}createPendingConsumers(){this._consumerCreationInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingConsumerTasks.length)return void Rl.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 Cl.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=wl.generateProbatorRtpParameters(t.rtpParameters);await this._handler.receive([{trackId:"probator",kind:"video",rtpParameters:e}]),Rl.debug("createPendingConsumers() | Consumer for RTP probation created"),this._probatorConsumerCreated=!0}catch(e){Rl.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 Rl.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){Rl.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 Rl.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){Rl.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 Rl.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){Rl.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 bl.InvalidStateError("closed")):this.safeEmit("connect",{dtlsParameters:e},t,r)})),e.on("@icegatheringstatechange",(e=>{e!==this._iceGatheringState&&(Rl.debug("ICE gathering state changed to %s",e),this._iceGatheringState=e,this._closed||this.safeEmit("icegatheringstatechange",e))})),e.on("@icecandidateerror",(e=>{Rl.warn(`ICE candidate error [url:${e.url}, localAddress:${e.address}, localPort:${e.port}]: ${e.errorCode} "${e.errorText}"`),this.safeEmit("icecandidateerror",e)})),e.on("@connectionstatechange",(e=>{e!==this._connectionState&&(Rl.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=>Rl.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 bl.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),queueMicrotask((()=>{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),queueMicrotask((()=>{this._closed||!1===this._consumerResumeInProgress&&this.resumePendingConsumers()}))})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new bl.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)}))}}Wu.Transport=Dl;var Il={},Al={},Ol={},Nl={exports:{}},Ml=Nl.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(Ml).forEach((function(e){Ml[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=Nl.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}}))}))}}(Ol);var Ll=Nl.exports,xl=/%[sdv%]/g,Fl=function(e){var t=1,r=arguments,n=r.length;return e.replace(xl,(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""}}))},jl=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 Fl.apply(null,n)},Ul=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Vl=["i","c","b","a"],Bl=Ol,Wl=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||Ul,n=t.innerOrder||Vl,i=[];return r.forEach((function(t){Ll[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(jl(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(jl(t,r,e))}))}))})),e.media.forEach((function(e){i.push(jl("m",Ll.m[0],e)),n.forEach((function(t){Ll[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(jl(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(jl(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"},Hl=Nl.exports;Al.grammar=Hl,Al.write=Wl,Al.parse=Bl.parse,Al.parseParams=Bl.parseParams,Al.parseFmtpConfig=Bl.parseFmtpConfig,Al.parsePayloads=Bl.parsePayloads,Al.parseRemoteCandidates=Bl.parseRemoteCandidates,Al.parseImageAttributes=Bl.parseImageAttributes,Al.parseSimulcastStreamList=Bl.parseSimulcastStreamList;var ql={};Object.defineProperty(ql,"__esModule",{value:!0}),ql.parse=function(e){const t=zl.exec(e??"");return t?{spatialLayers:Number(t[1]),temporalLayers:Number(t[2])}:{spatialLayers:1,temporalLayers:1}};const zl=new RegExp("^[LS]([1-9]\\d{0,1})T([1-9]\\d{0,1})");var Gl={};Object.defineProperty(Gl,"__esModule",{value:!0}),Gl.extractRtpCapabilities=function({sdpObject:e}){const t=new Map,r=new Map;for(const n of e.media){const e=n.type;switch(e){case"audio":case"video":break;default:continue}for(const r of n.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 n.fmtp??[]){const r=Yl.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 n.rtcpFb??[]){const n={type:r.type,parameter:r.subtype};if(n.parameter||delete n.parameter,"*"!==r.payload){const e=t.get(Number(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 n.ext??[]){if(t["encrypt-uri"])continue;const n={kind:e,uri:t.uri,preferredId:t.value};r.set(n.preferredId,n)}}return{codecs:Array.from(t.values()),headerExtensions:Array.from(r.values())}},Gl.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??=t.setup,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}]}},Gl.getCname=function({offerMediaObject:e}){const t=(e.ssrcs??[]).find((e=>"cname"===e.attribute));if(!t)return"";return t.value},Gl.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=Yl.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 Yl=Al;var $l={};Object.defineProperty($l,"__esModule",{value:!0}),$l.getRtpEncodings=function({offerMediaObject:e}){const t=new Set;for(const r of e.ssrcs??[]){const e=r.id;e&&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;const e=n.ssrcs.split(/\s+/),i=Number(e[0]),s=Number(e[1]);t.has(i)&&(t.delete(i),t.delete(s),r.set(i,s))}for(const e of t)r.set(e,void 0);const n=[];for(const[e,t]of r){const r={ssrc:e};t&&(r.rtx={ssrc:t}),n.push(r)}return n},$l.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 Jl={};Object.defineProperty(Jl,"__esModule",{value:!0}),Jl.addNackSupportForOpus=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 Kl={},Ql={};Object.defineProperty(Ql,"__esModule",{value:!0}),Ql.OfferMediaSection=Ql.AnswerMediaSection=Ql.MediaSection=void 0;const Zl=Al,Xl=ou;class ep{_mediaObject;constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r}){if(this._mediaObject={type:"",port:0,protocol:"",payloads:"",rtp:[],fmtp:[]},e&&this.setIceParameters(e),t){this._mediaObject.candidates=[];for(const e of t){const t={foundation:e.foundation,component:1,ip:e.address??e.ip,port:e.port,priority:e.priority,transport:e.protocol,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}}Ql.MediaSection=ep;Ql.AnswerMediaSection=class extends ep{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,offerMediaObject:s,offerRtpParameters:o,answerRtpParameters:a,codecOptions:c}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r}),this._mediaObject.mid=String(s.mid),this._mediaObject.type=s.type,this._mediaObject.protocol=s.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),s.type){case"audio":case"video":this._mediaObject.direction="recvonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[];for(const e of a.codecs){const t={payload:e.payloadType,codec:tp(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r=Xl.clone(e.parameters)??{};let n=Xl.clone(e.rtcpFeedback)??[];if(c){const{opusStereo:t,opusFec:i,opusDtx:s,opusMaxPlaybackRate:a,opusMaxAverageBitrate:d,opusPtime:u,opusNack:l,videoGoogleStartBitrate:p,videoGoogleMaxBitrate:h,videoGoogleMinBitrate:f}=c,m=o.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!==a&&(r.maxplaybackrate=a),void 0!==d&&(r.maxaveragebitrate=d),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":case"video/av1":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=a.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of a.headerExtensions){(s.ext??[]).some((t=>t.uri===e.uri))&&this._mediaObject.ext.push({uri:e.uri,value:e.id})}if("extmap-allow-mixed"===s.extmapAllowMixed&&(this._mediaObject.extmapAllowMixed="extmap-allow-mixed"),s.simulcast){this._mediaObject.simulcast={dir1:"recv",list1:s.simulcast.list1},this._mediaObject.rids=[];for(const e of s.rids??[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}else if(s.simulcast_03){this._mediaObject.simulcast_03={value:s.simulcast_03.value.replace(/send/g,"recv")},this._mediaObject.rids=[];for(const e of s.rids??[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize";break;case"application":"number"==typeof s.sctpPort?(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=n.port,this._mediaObject.maxMessageSize=n.maxMessageSize):s.sctpmap&&(this._mediaObject.payloads=String(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=Zl.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 tp(e){const t=new RegExp("^(audio|video)/(.+)","i").exec(e.mimeType);if(!t)throw new TypeError("invalid codec.mimeType");return t[2]}Ql.OfferMediaSection=class extends ep{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,mid:s,kind:o,offerRtpParameters:a,streamId:c,trackId:d}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r}),this._mediaObject.mid=String(s),this._mediaObject.type=o,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),this._mediaObject.extmapAllowMixed="extmap-allow-mixed",o){case"audio":case"video":{this._mediaObject.direction="sendonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[],this._mediaObject.msid=`${c??"-"} ${d}`;for(const e of a.codecs){const t={payload:e.payloadType,codec:tp(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=a.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of a.headerExtensions)this._mediaObject.ext.push({uri:e.uri,value:e.id});this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize";const e=a.encodings[0],t=e.ssrc,r=e.rtx?.ssrc;this._mediaObject.ssrcs=[],this._mediaObject.ssrcGroups=[],t&&a.rtcp.cname&&this._mediaObject.ssrcs.push({id:t,attribute:"cname",value:a.rtcp.cname}),r&&(a.rtcp.cname&&this._mediaObject.ssrcs.push({id:r,attribute:"cname",value:a.rtcp.cname}),t&&this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}));break}case"application":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"}},Object.defineProperty(Kl,"__esModule",{value:!0}),Kl.RemoteSdp=void 0;const rp=Al,np=Ql,ip=["av1","h264"],sp=new Md.Logger("RemoteSdp");Kl.RemoteSdp=class{_iceParameters;_iceCandidates;_dtlsParameters;_sctpParameters;_plainRtpParameters;_mediaSections=[];_midToIndex=new Map;_firstMid;_sdpObject;constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i}){if(this._iceParameters=e,this._iceCandidates=t,this._dtlsParameters=r,this._sctpParameters=n,this._plainRtpParameters=i,this._sdpObject={version:0,origin:{address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"10000",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){sp.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){sp.debug("updateDtlsRole() [role:%s]",e),this._dtlsParameters.role=e;for(const t of this._mediaSections)t.setDtlsRole(e)}setSessionExtmapAllowMixed(){sp.debug("setSessionExtmapAllowMixed()"),this._sdpObject.extmapAllowMixed="extmap-allow-mixed"}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}){const s=new np.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,offerMediaObject:e,offerRtpParameters:r,answerRtpParameters:n,codecOptions:i}),o=s.getObject();o.rtp.find((e=>ip.includes(e.codec.toLowerCase())))||(o.ext=o.ext?.filter((e=>"https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension"!==e.uri))),t?this._replaceMediaSection(s,t):this._midToIndex.has(s.mid)?this._replaceMediaSection(s):this._addMediaSection(s)}receive({mid:e,kind:t,offerRtpParameters:r,streamId:n,trackId:i}){this.setSessionExtmapAllowMixed();const s=new np.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,mid:e,kind:t,offerRtpParameters:r,streamId:n,trackId:i}),o=this._mediaSections.find((e=>e.closed));o?this._replaceMediaSection(s,o.mid):this._addMediaSection(s)}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?(sp.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)}sendSctpAssociation({offerMediaObject:e}){const t=new np.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,offerMediaObject:e});this._addMediaSection(t)}receiveSctpAssociation(){const e=new np.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,mid:"datachannel",kind:"application"});this._addMediaSection(e)}getSdp(){return this._sdpObject.origin.sessionVersion++,rp.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(" "))}},Object.defineProperty(Il,"__esModule",{value:!0}),Il.Chrome111=void 0;const op=Al,ap=jd,cp=au,dp=nu,up=ql,lp=Gl,pp=$l,hp=Jl,fp=Kl,mp=new Md.Logger("Chrome111"),gp={OS:1024,MIS:1024};class vp extends ap.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"Chrome111",factory:e=>new vp(e),getNativeRtpCapabilities:async()=>{mp.debug("getNativeRtpCapabilities()");let e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});try{e.addTransceiver("audio"),e.addTransceiver("video",{sendEncodings:[{scalabilityMode:"L3T3"}]});const t=await e.createOffer();try{e.close()}catch(e){}e=void 0;const r=op.parse(t.sdp);return vp.getLocalRtpCapabilities(r)}catch(t){try{e?.close()}catch(e){}throw e=void 0,t}},getNativeSctpCapabilities:async()=>(mp.debug("getNativeSctpCapabilities()"),{numStreams:gp})}}static getLocalRtpCapabilities(e){const t=lp.extractRtpCapabilities({sdpObject:e});return cp.validateAndNormalizeRtpCapabilities(t),hp.addNackSupportForOpus(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),mp.debug("constructor()"),this._direction=e,this._remoteSdp=new fp.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,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}),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(mp.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"Chrome111"}close(){if(mp.debug("close()"),!this._closed){this._closed=!0;try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){this.assertNotClosed(),mp.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),mp.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});mp.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};mp.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};mp.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();mp.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(),mp.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,up.parse)(r.scalabilityMode).temporalLayers:3;t>e&&(e=t)}t.forEach(((t,r)=>{t.rid=`r${r}`,t.scalabilityMode=`L1T${e}`}))}const s=this._remoteSdp.getNextMediaSectionIdx(),o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(o.sender);const a=await this._pc.createOffer();let c=op.parse(a.sdp);c.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const d=vp.getLocalRtpCapabilities(c),u=this._getSendExtendedRtpCapabilities(d),l=cp.getSendingRtpParameters(e.kind,u);l.codecs=cp.reduceCodecs(l.codecs,n);const p=cp.getSendingRemoteRtpParameters(e.kind,u);p.codecs=cp.reduceCodecs(p.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:c}),mp.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);const h=o.mid;l.mid=h,c=op.parse(this._pc.localDescription.sdp);const f=c.media[s.idx];if(l.rtcp.cname=lp.getCname({offerMediaObject:f}),t)if(1===t.length){const e=pp.getRtpEncodings({offerMediaObject:f});Object.assign(e[0],t[0]),l.encodings=e}else l.encodings=t;else l.encodings=pp.getRtpEncodings({offerMediaObject:f});this._remoteSdp.send({offerMediaObject:f,reuseMid:s.reuseMid,offerRtpParameters:l,answerRtpParameters:p,codecOptions:r});const m={type:"answer",sdp:this._remoteSdp.getSdp()};return mp.debug("send() | calling pc.setRemoteDescription() [answer:%o]",m),await this._pc.setRemoteDescription(m),this._mapMidTransceiver.set(h,o),{localId:h,rtpParameters:l,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),mp.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();mp.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};mp.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),mp.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();mp.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};mp.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),mp.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();mp.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};mp.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?mp.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):mp.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(),mp.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();mp.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};mp.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),mp.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();mp.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};mp.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};mp.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%gp.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=op.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),mp.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()};mp.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;mp.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()};mp.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=op.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));lp.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:op.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),mp.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){mp.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()};mp.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();mp.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){mp.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()};mp.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();mp.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){mp.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()};mp.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();mp.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};mp.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()};mp.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=op.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}mp.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=op.parse(this._pc.localDescription.sdp));const r=lp.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}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{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")}};assertNotClosed(){if(this._closed)throw new dp.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')}}Il.Chrome111=vp;var yp={};Object.defineProperty(yp,"__esModule",{value:!0}),yp.Chrome74=void 0;const _p=Al,bp=jd,Ep=au,wp=nu,Sp=ql,Cp=Gl,Pp=$l,Tp=Jl,Rp=Kl,kp=new Md.Logger("Chrome74"),Dp={OS:1024,MIS:1024};class Ip extends bp.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"Chrome74",factory:e=>new Ip(e),getNativeRtpCapabilities:async()=>{kp.debug("getNativeRtpCapabilities()");let 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){}e=void 0;const r=_p.parse(t.sdp);return Ip.getLocalRtpCapabilities(r)}catch(t){try{e?.close()}catch(e){}throw e=void 0,t}},getNativeSctpCapabilities:async()=>(kp.debug("getNativeSctpCapabilities()"),{numStreams:Dp})}}static getLocalRtpCapabilities(e){const t=Cp.extractRtpCapabilities({sdpObject:e});return Ep.validateAndNormalizeRtpCapabilities(t),Tp.addNackSupportForOpus(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),kp.debug("constructor()"),this._direction=e,this._remoteSdp=new Rp.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,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}),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(kp.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"Chrome74"}close(){if(kp.debug("close()"),!this._closed){this._closed=!0;try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){this.assertNotClosed(),kp.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),kp.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});kp.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};kp.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};kp.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();kp.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(),kp.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=this._remoteSdp.getNextMediaSectionIdx(),s=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});let o=await this._pc.createOffer(),a=_p.parse(o.sdp);a.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const c=Ip.getLocalRtpCapabilities(a),d=this._getSendExtendedRtpCapabilities(c),u=Ep.getSendingRtpParameters(e.kind,d);u.codecs=Ep.reduceCodecs(u.codecs,n);const l=Ep.getSendingRemoteRtpParameters(e.kind,d);l.codecs=Ep.reduceCodecs(l.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:a});let p=!1;const h=(0,Sp.parse)((t??[{}])[0].scalabilityMode);let f;t&&1===t.length&&h.spatialLayers>1&&"video/vp9"===u.codecs[0].mimeType.toLowerCase()&&(kp.debug("send() | enabling legacy simulcast for VP9 SVC"),p=!0,a=_p.parse(o.sdp),f=a.media[i.idx],Pp.addLegacySimulcast({offerMediaObject:f,numStreams:h.spatialLayers}),o={type:"offer",sdp:_p.write(a)}),kp.debug("send() | calling pc.setLocalDescription() [offer:%o]",o),await this._pc.setLocalDescription(o);const m=s.mid;if(u.mid=m,a=_p.parse(this._pc.localDescription.sdp),f=a.media[i.idx],u.rtcp.cname=Cp.getCname({offerMediaObject:f}),t)if(1===t.length){let e=Pp.getRtpEncodings({offerMediaObject:f});Object.assign(e[0],t[0]),p&&(e=[e[0]]),u.encodings=e}else u.encodings=t;else u.encodings=Pp.getRtpEncodings({offerMediaObject:f});if(u.encodings.length>1&&("video/vp8"===u.codecs[0].mimeType.toLowerCase()||"video/h264"===u.codecs[0].mimeType.toLowerCase()))for(const e of u.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${h.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:f,reuseMid:i.reuseMid,offerRtpParameters:u,answerRtpParameters:l,codecOptions:r});const g={type:"answer",sdp:this._remoteSdp.getSdp()};return kp.debug("send() | calling pc.setRemoteDescription() [answer:%o]",g),await this._pc.setRemoteDescription(g),this._mapMidTransceiver.set(m,s),{localId:m,rtpParameters:u,rtpSender:s.sender}}async stopSending(e){if(this.assertSendDirection(),kp.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();kp.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};kp.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),kp.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();kp.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};kp.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),kp.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();kp.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};kp.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?kp.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):kp.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(),kp.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();kp.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};kp.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),kp.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();kp.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};kp.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};kp.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Dp.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=_p.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),kp.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()};kp.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;kp.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()};kp.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=_p.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));Cp.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:_p.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),kp.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){kp.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()};kp.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();kp.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){kp.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()};kp.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();kp.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){kp.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()};kp.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();kp.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};kp.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()};kp.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=_p.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}kp.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=_p.parse(this._pc.localDescription.sdp));const r=Cp.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}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{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")}};assertNotClosed(){if(this._closed)throw new wp.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')}}yp.Chrome74=Ip;var Ap={};Object.defineProperty(Ap,"__esModule",{value:!0}),Ap.Firefox120=void 0;const Op=Al,Np=jd,Mp=nu,Lp=au,xp=ql,Fp=Gl,jp=$l,Up=Kl,Vp=new Md.Logger("Firefox120"),Bp={OS:16,MIS:2048};class Wp extends Np.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"Firefox120",factory:e=>new Wp(e),getNativeRtpCapabilities:async()=>{Vp.debug("getNativeRtpCapabilities()");let e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});const 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){}e=void 0;const i=Op.parse(n.sdp);return Wp.getLocalRtpCapabilities(i)}catch(n){try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e?.close()}catch(e){}throw e=void 0,n}},getNativeSctpCapabilities:async()=>(Vp.debug("getNativeSctpCapabilities()"),{numStreams:Bp})}}static getLocalRtpCapabilities(e){const t=Fp.extractRtpCapabilities({sdpObject:e});return Lp.validateAndNormalizeRtpCapabilities(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),Vp.debug("constructor()"),this._direction=e,this._remoteSdp=new Up.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a}),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(Vp.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"Firefox120"}close(){if(Vp.debug("close()"),!this._closed){this._closed=!0;try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){throw this.assertNotClosed(),new Mp.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),Vp.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Vp.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Vp.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Vp.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Vp.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(),Vp.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=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(s.sender);const o=await this._pc.createOffer();let a=Op.parse(o.sdp);a.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const c=Wp.getLocalRtpCapabilities(a),d=this._getSendExtendedRtpCapabilities(c),u=Lp.getSendingRtpParameters(e.kind,d);u.codecs=Lp.reduceCodecs(u.codecs,n);const l=Lp.getSendingRemoteRtpParameters(e.kind,d);l.codecs=Lp.reduceCodecs(l.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:a});const p=(0,xp.parse)((t??[{}])[0].scalabilityMode);Vp.debug("send() | calling pc.setLocalDescription() [offer:%o]",o),await this._pc.setLocalDescription(o);const h=s.mid;u.mid=h,a=Op.parse(this._pc.localDescription.sdp);const f=a.media[a.media.length-1];if(u.rtcp.cname=Fp.getCname({offerMediaObject:f}),t)if(1===t.length){const e=jp.getRtpEncodings({offerMediaObject:f});Object.assign(e[0],t[0]),u.encodings=e}else u.encodings=t;else u.encodings=jp.getRtpEncodings({offerMediaObject:f});if(u.encodings.length>1&&("video/vp8"===u.codecs[0].mimeType.toLowerCase()||"video/h264"===u.codecs[0].mimeType.toLowerCase()))for(const e of u.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${p.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:f,offerRtpParameters:u,answerRtpParameters:l,codecOptions:r});const m={type:"answer",sdp:this._remoteSdp.getSdp()};return Vp.debug("send() | calling pc.setRemoteDescription() [answer:%o]",m),await this._pc.setRemoteDescription(m),this._mapMidTransceiver.set(h,s),{localId:h,rtpParameters:u,rtpSender:s.sender}}async stopSending(e){if(this.assertSendDirection(),Vp.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();Vp.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Vp.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Vp.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();Vp.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Vp.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Vp.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();Vp.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Vp.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Vp.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Vp.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(),Vp.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();Vp.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Vp.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Vp.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();Vp.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Vp.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};Vp.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Bp.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Op.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),Vp.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()};Vp.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;Vp.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()};Vp.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=Op.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));Fp.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:Op.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),Vp.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){Vp.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()};Vp.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Vp.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){Vp.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()};Vp.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Vp.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){Vp.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()};Vp.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Vp.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};Vp.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()};Vp.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Op.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}Vp.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=Op.parse(this._pc.localDescription.sdp));const r=Fp.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}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{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")}};assertNotClosed(){if(this._closed)throw new Mp.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')}}Ap.Firefox120=Wp;var Hp={};Object.defineProperty(Hp,"__esModule",{value:!0}),Hp.Safari12=void 0;const qp=Al,zp=jd,Gp=au,Yp=nu,$p=ql,Jp=Kl,Kp=Gl,Qp=$l,Zp=Jl,Xp=new Md.Logger("Safari12"),eh={OS:1024,MIS:1024};class th extends zp.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"Safari12",factory:e=>new th(e),getNativeRtpCapabilities:async()=>{Xp.debug("getNativeRtpCapabilities()");let 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){}e=void 0;const r=qp.parse(t.sdp);return th.getLocalRtpCapabilities(r)}catch(t){try{e?.close()}catch(e){}throw e=void 0,t}},getNativeSctpCapabilities:async()=>(Xp.debug("getNativeSctpCapabilities()"),{numStreams:eh})}}static getLocalRtpCapabilities(e){const t=Kp.extractRtpCapabilities({sdpObject:e});return Gp.validateAndNormalizeRtpCapabilities(t),Zp.addNackSupportForOpus(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),Xp.debug("constructor()"),this._direction=e,this._remoteSdp=new Jp.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,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}),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(Xp.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"Safari12"}close(){if(Xp.debug("close()"),!this._closed){this._closed=!0;try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){this.assertNotClosed(),Xp.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Xp.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Xp.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Xp.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Xp.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Xp.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(),Xp.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const s=this._remoteSdp.getNextMediaSectionIdx(),o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});i&&i(o.sender);let a=await this._pc.createOffer(),c=qp.parse(a.sdp);c.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const d=th.getLocalRtpCapabilities(c),u=this._getSendExtendedRtpCapabilities(d),l=Gp.getSendingRtpParameters(e.kind,u);l.codecs=Gp.reduceCodecs(l.codecs,n);const p=Gp.getSendingRemoteRtpParameters(e.kind,u);let h;p.codecs=Gp.reduceCodecs(p.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:c});const f=(0,$p.parse)((t??[{}])[0].scalabilityMode);t&&t.length>1&&(Xp.debug("send() | enabling legacy simulcast"),c=qp.parse(a.sdp),h=c.media[s.idx],Qp.addLegacySimulcast({offerMediaObject:h,numStreams:t.length}),a={type:"offer",sdp:qp.write(c)}),Xp.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);const m=o.mid;if(l.mid=m,c=qp.parse(this._pc.localDescription.sdp),h=c.media[s.idx],l.rtcp.cname=Kp.getCname({offerMediaObject:h}),l.encodings=Qp.getRtpEncodings({offerMediaObject:h}),t)for(let e=0;e<l.encodings.length;++e)t[e]&&Object.assign(l.encodings[e],t[e]);if(l.encodings.length>1&&("video/vp8"===l.codecs[0].mimeType.toLowerCase()||"video/h264"===l.codecs[0].mimeType.toLowerCase()))for(const e of l.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${f.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:h,reuseMid:s.reuseMid,offerRtpParameters:l,answerRtpParameters:p,codecOptions:r});const g={type:"answer",sdp:this._remoteSdp.getSdp()};return Xp.debug("send() | calling pc.setRemoteDescription() [answer:%o]",g),await this._pc.setRemoteDescription(g),this._mapMidTransceiver.set(m,o),{localId:m,rtpParameters:l,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;Xp.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();Xp.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Xp.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Xp.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();Xp.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Xp.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Xp.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();Xp.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Xp.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Xp.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Xp.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(),Xp.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();Xp.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Xp.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Xp.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();Xp.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Xp.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};Xp.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%eh.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=qp.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Xp.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()};Xp.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;Xp.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()};Xp.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=qp.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));Kp.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:qp.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Xp.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){Xp.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()};Xp.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Xp.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){Xp.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()};Xp.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Xp.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){Xp.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()};Xp.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Xp.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};Xp.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()};Xp.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=qp.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Xp.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=qp.parse(this._pc.localDescription.sdp));const r=Kp.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}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{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")}};assertNotClosed(){if(this._closed)throw new Yp.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')}}Hp.Safari12=th;var rh={};Object.defineProperty(rh,"__esModule",{value:!0}),rh.ReactNative106=void 0;const nh=Al,ih=jd,sh=au,oh=nu,ah=ql,ch=Kl,dh=Gl,uh=$l,lh=Jl,ph=new Md.Logger("ReactNative106"),hh={OS:1024,MIS:1024};class fh extends ih.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"ReactNative106",factory:e=>new fh(e),getNativeRtpCapabilities:async()=>{ph.debug("getNativeRtpCapabilities()");let 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){}e=void 0;const r=nh.parse(t.sdp);return fh.getLocalRtpCapabilities(r)}catch(t){try{e?.close()}catch(e){}throw e=void 0,t}},getNativeSctpCapabilities:async()=>(ph.debug("getNativeSctpCapabilities()"),{numStreams:hh})}}static getLocalRtpCapabilities(e){const t=dh.extractRtpCapabilities({sdpObject:e});return sh.validateAndNormalizeRtpCapabilities(t),lh.addNackSupportForOpus(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),ph.debug("constructor()"),this._direction=e,this._remoteSdp=new ch.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,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}),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(ph.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"ReactNative106"}close(){if(ph.debug("close()"),!this._closed){this._closed=!0,this._sendStream.release(!1);try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){this.assertNotClosed(),ph.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),ph.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});ph.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};ph.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};ph.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();ph.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(),ph.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=this._remoteSdp.getNextMediaSectionIdx(),o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(o.sender);let a=await this._pc.createOffer(),c=nh.parse(a.sdp);c.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const d=fh.getLocalRtpCapabilities(c),u=this._getSendExtendedRtpCapabilities(d),l=sh.getSendingRtpParameters(e.kind,u);l.codecs=sh.reduceCodecs(l.codecs,n);const p=sh.getSendingRemoteRtpParameters(e.kind,u);p.codecs=sh.reduceCodecs(p.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:c});let h=!1;const f=(0,ah.parse)((t??[{}])[0].scalabilityMode);let m;t&&1===t.length&&f.spatialLayers>1&&"video/vp9"===l.codecs[0].mimeType.toLowerCase()&&(ph.debug("send() | enabling legacy simulcast for VP9 SVC"),h=!0,c=nh.parse(a.sdp),m=c.media[s.idx],uh.addLegacySimulcast({offerMediaObject:m,numStreams:f.spatialLayers}),a={type:"offer",sdp:nh.write(c)}),ph.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);let g=o.mid??void 0;if(g||ph.warn("send() | missing transceiver.mid (bug in react-native-webrtc, using a workaround"),l.mid=g,c=nh.parse(this._pc.localDescription.sdp),m=c.media[s.idx],l.rtcp.cname=dh.getCname({offerMediaObject:m}),t)if(1===t.length){let e=uh.getRtpEncodings({offerMediaObject:m});Object.assign(e[0],t[0]),h&&(e=[e[0]]),l.encodings=e}else l.encodings=t;else l.encodings=uh.getRtpEncodings({offerMediaObject:m});if(l.encodings.length>1&&("video/vp8"===l.codecs[0].mimeType.toLowerCase()||"video/h264"===l.codecs[0].mimeType.toLowerCase()))for(const e of l.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${f.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:m,reuseMid:s.reuseMid,offerRtpParameters:l,answerRtpParameters:p,codecOptions:r});const v={type:"answer",sdp:this._remoteSdp.getSdp()};return ph.debug("send() | calling pc.setRemoteDescription() [answer:%o]",v),await this._pc.setRemoteDescription(v),g||(g=o.mid,l.mid=g),this._mapMidTransceiver.set(g,o),{localId:g,rtpParameters:l,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;ph.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();ph.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ph.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),ph.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();ph.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ph.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),ph.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();ph.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};ph.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?ph.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):ph.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(),ph.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();ph.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};ph.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),ph.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();ph.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};ph.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};ph.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%hh.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=nh.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),ph.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()};ph.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;ph.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()};ph.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=nh.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));dh.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:nh.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),ph.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){ph.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()};ph.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ph.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){ph.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()};ph.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ph.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){ph.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()};ph.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();ph.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};ph.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()};ph.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=nh.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}ph.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=nh.parse(this._pc.localDescription.sdp));const r=dh.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}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{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")}};assertNotClosed(){if(this._closed)throw new oh.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')}}rh.ReactNative106=fh,Object.defineProperty(Ed,"__esModule",{value:!0}),Ed.Device=void 0,Ed.detectDevice=Rh,Ed.detectDeviceAsync=kh;const mh=Rd,gh=jd,vh=nu,yh=ou,_h=au,bh=Wu,Eh=Il,wh=yp,Sh=Ap,Ch=Hp,Ph=rh,Th=new Md.Logger("Device");function Rh(e){Th.debug("detectDevice() [userAgent:%s]",e),e||"object"!=typeof navigator||(e=navigator.userAgent);return Ih(new mh.default(e))}async function kh(e){Th.debug("detectDeviceAsync() [userAgent:%s]",e),e||"object"!=typeof navigator||(e=navigator.userAgent);return Ih(new mh.default(e))}class Dh{_handlerFactory;_handlerName;_loaded=!1;_getSendExtendedRtpCapabilities;_recvRtpCapabilities;_canProduceByKind={audio:!1,video:!1};_sctpCapabilities;_observer=new gh.EnhancedEventEmitter;static async factory({handlerName:e,handlerFactory:t}={}){if(Th.debug("factory()"),e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(!e&&!t&&!(e=await kh()))throw new vh.UnsupportedError("device not supported");return new Dh({handlerName:e,handlerFactory:t})}constructor({handlerName:e,handlerFactory:t}={}){if(Th.debug("constructor()"),e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(t)this._handlerFactory=t;else{if(e)Th.debug("constructor() | handler given: %s",e);else{if(!(e=Rh()))throw new vh.UnsupportedError("device not supported");Th.debug("constructor() | detected handler: %s",e)}switch(e){case"Chrome111":this._handlerFactory=Eh.Chrome111.createFactory();break;case"Chrome74":this._handlerFactory=wh.Chrome74.createFactory();break;case"Firefox120":this._handlerFactory=Sh.Firefox120.createFactory();break;case"Safari12":this._handlerFactory=Ch.Safari12.createFactory();break;case"ReactNative106":this._handlerFactory=Ph.ReactNative106.createFactory();break;default:throw new TypeError(`unknown handlerName "${e}"`)}}this._handlerName=this._handlerFactory.name}get handlerName(){return this._handlerName}get loaded(){return this._loaded}get rtpCapabilities(){if(!this._loaded)throw new vh.InvalidStateError("not loaded");return this._recvRtpCapabilities}get sctpCapabilities(){if(!this._loaded)throw new vh.InvalidStateError("not loaded");return this._sctpCapabilities}get observer(){return this._observer}async load({routerRtpCapabilities:e,preferLocalCodecsOrder:t=!1}){if(Th.debug("load() [routerRtpCapabilities:%o]",e),this._loaded)throw new vh.InvalidStateError("already loaded");const r=yh.clone(e);_h.validateAndNormalizeRtpCapabilities(r);const{getNativeRtpCapabilities:n,getNativeSctpCapabilities:i}=this._handlerFactory,s=yh.clone(await n());_h.validateAndNormalizeRtpCapabilities(s),Th.debug("load() | got native RTP capabilities:%o",s),this._getSendExtendedRtpCapabilities=e=>yh.clone(_h.getExtendedRtpCapabilities(e,r,t));const o=_h.getExtendedRtpCapabilities(s,r,!1);this._recvRtpCapabilities=_h.getRecvRtpCapabilities(o),_h.validateAndNormalizeRtpCapabilities(this._recvRtpCapabilities),Th.debug("load() | got receiving RTP capabilities:%o",this._recvRtpCapabilities),this._canProduceByKind.audio=_h.canSend("audio",this._recvRtpCapabilities),this._canProduceByKind.video=_h.canSend("video",this._recvRtpCapabilities),this._sctpCapabilities=await i(),_h.validateSctpCapabilities(this._sctpCapabilities),Th.debug("load() | got native SCTP capabilities:%o",this._sctpCapabilities),Th.debug("load() succeeded"),this._loaded=!0}canProduce(e){if(!this._loaded)throw new vh.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,appData:c}){return Th.debug("createSendTransport()"),this.createTransport({direction:"send",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,appData:c})}createRecvTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,appData:c}){return Th.debug("createRecvTransport()"),this.createTransport({direction:"recv",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,appData:c})}createTransport({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,appData:d}){if(!this._loaded)throw new vh.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(d&&"object"!=typeof d)throw new TypeError("if given, appData must be an object");const u=new bh.Transport({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,appData:d,handlerFactory:this._handlerFactory,getSendExtendedRtpCapabilities:this._getSendExtendedRtpCapabilities,recvRtpCapabilities:this._recvRtpCapabilities,canProduceByKind:this._canProduceByKind});return this._observer.safeEmit("newtransport",u),u}}function Ih(e){if("object"==typeof navigator&&"ReactNative"===navigator.product)return Th.debug("detectDeviceImpl() | React-Native detected"),"undefined"==typeof RTCPeerConnection||"undefined"==typeof RTCRtpTransceiver?void Th.warn("detectDeviceImpl() | unsupported react-native-webrtc without RTCPeerConnection or RTCRtpTransceiver, forgot to call registerGlobals() on it?"):"ReactNative106";{const t=e.parseUserAgent(),r=/^\d+/.exec(t?.shortVersion??"0"),n=parseInt(r?.[0]??"0",10),i=t.platform===mh.KnownPlatforms.iphone||t.platform===mh.KnownPlatforms.ipad||t.platform===mh.KnownPlatforms.mac&&(t.isMobile||t.isTablet||"object"==typeof navigator&&navigator?.maxTouchPoints>=2),s=t.isChrome,o=t.isFireFox,a=t.isSafari,c=t.isEdge,d=t.isDesktop&&t.name===mh.KnownBrowsers.electron,u=t.isWebkit,l={browserMajorVersion:n,isIOS:i,isChrome:s,isFirefox:o,isSafari:a,isElectron:d,isWebkit:u};if(Th.debug("detectDeviceImpl() | detected browser [userAgent:%s, parsed:%o, result:%o]",t.userAgent,t,l),(s||c)&&!i&&n>=111)return"Chrome111";if(s&&!i&&n>=74||c&&!i&&n>=88)return"Chrome74";if(d)return"Chrome111";if(o&&!i&&n>=120)return"Firefox120";if(a&&n>=12&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(i&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(u){const t=e.userAgent?.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);if(t){return Number(t[1])>=111?"Chrome111":"Chrome74"}return"Chrome111"}return void Th.warn("detectDeviceImpl() | browser not supported [userAgent:%s, parsed:%o, result:%o]",t.userAgent,t,l)}}Ed.Device=Dh;var Ah={},Oh={},Nh={},Mh={};Object.defineProperty(Mh,"__esModule",{value:!0}),Mh.default="ffffffff-ffff-ffff-ffff-ffffffffffff";var Lh={};Object.defineProperty(Lh,"__esModule",{value:!0}),Lh.default="00000000-0000-0000-0000-000000000000";var xh={},Fh={},jh={};Object.defineProperty(jh,"__esModule",{value:!0}),jh.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i,Object.defineProperty(Fh,"__esModule",{value:!0});const Uh=jh;Fh.default=function(e){return"string"==typeof e&&Uh.default.test(e)},Object.defineProperty(xh,"__esModule",{value:!0});const Vh=Fh;xh.default=function(e){if(!(0,Vh.default)(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,255&t,(t=parseInt(e.slice(9,13),16))>>>8,255&t,(t=parseInt(e.slice(14,18),16))>>>8,255&t,(t=parseInt(e.slice(19,23),16))>>>8,255&t,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,255&t)};var Bh={};Object.defineProperty(Bh,"__esModule",{value:!0}),Bh.unsafeStringify=void 0;const Wh=Fh,Hh=[];for(let e=0;e<256;++e)Hh.push((e+256).toString(16).slice(1));function qh(e,t=0){return(Hh[e[t+0]]+Hh[e[t+1]]+Hh[e[t+2]]+Hh[e[t+3]]+"-"+Hh[e[t+4]]+Hh[e[t+5]]+"-"+Hh[e[t+6]]+Hh[e[t+7]]+"-"+Hh[e[t+8]]+Hh[e[t+9]]+"-"+Hh[e[t+10]]+Hh[e[t+11]]+Hh[e[t+12]]+Hh[e[t+13]]+Hh[e[t+14]]+Hh[e[t+15]]).toLowerCase()}Bh.unsafeStringify=qh,Bh.default=function(e,t=0){const r=qh(e,t);if(!(0,Wh.default)(r))throw TypeError("Stringified UUID is invalid");return r};var zh={},Gh={};let Yh;Object.defineProperty(Gh,"__esModule",{value:!0});const $h=new Uint8Array(16);Gh.default=function(){if(!Yh){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Yh=crypto.getRandomValues.bind(crypto)}return Yh($h)},Object.defineProperty(zh,"__esModule",{value:!0}),zh.updateV1State=void 0;const Jh=Gh,Kh=Bh,Qh={};function Zh(e,t,r){return e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0),e.node||(e.node=r.slice(10,16),e.node[0]|=1,e.clockseq=16383&(r[8]<<8|r[9])),e.msecs=t,e}function Xh(e,t,r,n,i,s,o=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(s){if(o<0||o+16>s.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`)}else s=new Uint8Array(16),o=0;t??=Date.now(),r??=0,n??=16383&(e[8]<<8|e[9]),i??=e.slice(10,16);const a=(1e4*(268435455&(t+=122192928e5))+r)%4294967296;s[o++]=a>>>24&255,s[o++]=a>>>16&255,s[o++]=a>>>8&255,s[o++]=255&a;const c=t/4294967296*1e4&268435455;s[o++]=c>>>8&255,s[o++]=255&c,s[o++]=c>>>24&15|16,s[o++]=c>>>16&255,s[o++]=n>>>8|128,s[o++]=255&n;for(let e=0;e<6;++e)s[o++]=i[e];return s}zh.updateV1State=Zh,zh.default=function(e,t,r){let n;const i=e?._v6??!1;if(e){const t=Object.keys(e);1===t.length&&"_v6"===t[0]&&(e=void 0)}if(e)n=Xh(e.random??e.rng?.()??(0,Jh.default)(),e.msecs,e.nsecs,e.clockseq,e.node,t,r);else{const e=Date.now(),s=(0,Jh.default)();Zh(Qh,e,s),n=Xh(s,Qh.msecs,Qh.nsecs,i?void 0:Qh.clockseq,i?void 0:Qh.node,t,r)}return t??(0,Kh.unsafeStringify)(n)};var ef={};Object.defineProperty(ef,"__esModule",{value:!0});const tf=xh,rf=Bh;ef.default=function(e){const t=function(e){return Uint8Array.of((15&e[6])<<4|e[7]>>4&15,(15&e[7])<<4|(240&e[4])>>4,(15&e[4])<<4|(240&e[5])>>4,(15&e[5])<<4|(240&e[0])>>4,(15&e[0])<<4|(240&e[1])>>4,(15&e[1])<<4|(240&e[2])>>4,96|15&e[2],e[3],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}("string"==typeof e?(0,tf.default)(e):e);return"string"==typeof e?(0,rf.unsafeStringify)(t):t};var nf={},sf={};function of(e){return 14+(e+64>>>9<<4)+1}function af(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function cf(e,t,r,n,i,s){return af((o=af(af(t,e),af(n,s)))<<(a=i)|o>>>32-a,r);var o,a}function df(e,t,r,n,i,s,o){return cf(t&r|~t&n,e,t,i,s,o)}function uf(e,t,r,n,i,s,o){return cf(t&n|r&~n,e,t,i,s,o)}function lf(e,t,r,n,i,s,o){return cf(t^r^n,e,t,i,s,o)}function pf(e,t,r,n,i,s,o){return cf(r^(t|~n),e,t,i,s,o)}Object.defineProperty(sf,"__esModule",{value:!0}),sf.default=function(e){const t=function(e){if(0===e.length)return new Uint32Array;const t=new Uint32Array(of(8*e.length)).fill(0);for(let r=0;r<e.length;r++)t[r>>2]|=(255&e[r])<<r%4*8;return t}(e),r=function(e,t){const r=new Uint32Array(of(t)).fill(0);r.set(e),r[t>>5]|=128<<t%32,r[r.length-1]=t,e=r;let n=1732584193,i=-271733879,s=-1732584194,o=271733878;for(let t=0;t<e.length;t+=16){const r=n,a=i,c=s,d=o;n=df(n,i,s,o,e[t],7,-680876936),o=df(o,n,i,s,e[t+1],12,-389564586),s=df(s,o,n,i,e[t+2],17,606105819),i=df(i,s,o,n,e[t+3],22,-1044525330),n=df(n,i,s,o,e[t+4],7,-176418897),o=df(o,n,i,s,e[t+5],12,1200080426),s=df(s,o,n,i,e[t+6],17,-1473231341),i=df(i,s,o,n,e[t+7],22,-45705983),n=df(n,i,s,o,e[t+8],7,1770035416),o=df(o,n,i,s,e[t+9],12,-1958414417),s=df(s,o,n,i,e[t+10],17,-42063),i=df(i,s,o,n,e[t+11],22,-1990404162),n=df(n,i,s,o,e[t+12],7,1804603682),o=df(o,n,i,s,e[t+13],12,-40341101),s=df(s,o,n,i,e[t+14],17,-1502002290),i=df(i,s,o,n,e[t+15],22,1236535329),n=uf(n,i,s,o,e[t+1],5,-165796510),o=uf(o,n,i,s,e[t+6],9,-1069501632),s=uf(s,o,n,i,e[t+11],14,643717713),i=uf(i,s,o,n,e[t],20,-373897302),n=uf(n,i,s,o,e[t+5],5,-701558691),o=uf(o,n,i,s,e[t+10],9,38016083),s=uf(s,o,n,i,e[t+15],14,-660478335),i=uf(i,s,o,n,e[t+4],20,-405537848),n=uf(n,i,s,o,e[t+9],5,568446438),o=uf(o,n,i,s,e[t+14],9,-1019803690),s=uf(s,o,n,i,e[t+3],14,-187363961),i=uf(i,s,o,n,e[t+8],20,1163531501),n=uf(n,i,s,o,e[t+13],5,-1444681467),o=uf(o,n,i,s,e[t+2],9,-51403784),s=uf(s,o,n,i,e[t+7],14,1735328473),i=uf(i,s,o,n,e[t+12],20,-1926607734),n=lf(n,i,s,o,e[t+5],4,-378558),o=lf(o,n,i,s,e[t+8],11,-2022574463),s=lf(s,o,n,i,e[t+11],16,1839030562),i=lf(i,s,o,n,e[t+14],23,-35309556),n=lf(n,i,s,o,e[t+1],4,-1530992060),o=lf(o,n,i,s,e[t+4],11,1272893353),s=lf(s,o,n,i,e[t+7],16,-155497632),i=lf(i,s,o,n,e[t+10],23,-1094730640),n=lf(n,i,s,o,e[t+13],4,681279174),o=lf(o,n,i,s,e[t],11,-358537222),s=lf(s,o,n,i,e[t+3],16,-722521979),i=lf(i,s,o,n,e[t+6],23,76029189),n=lf(n,i,s,o,e[t+9],4,-640364487),o=lf(o,n,i,s,e[t+12],11,-421815835),s=lf(s,o,n,i,e[t+15],16,530742520),i=lf(i,s,o,n,e[t+2],23,-995338651),n=pf(n,i,s,o,e[t],6,-198630844),o=pf(o,n,i,s,e[t+7],10,1126891415),s=pf(s,o,n,i,e[t+14],15,-1416354905),i=pf(i,s,o,n,e[t+5],21,-57434055),n=pf(n,i,s,o,e[t+12],6,1700485571),o=pf(o,n,i,s,e[t+3],10,-1894986606),s=pf(s,o,n,i,e[t+10],15,-1051523),i=pf(i,s,o,n,e[t+1],21,-2054922799),n=pf(n,i,s,o,e[t+8],6,1873313359),o=pf(o,n,i,s,e[t+15],10,-30611744),s=pf(s,o,n,i,e[t+6],15,-1560198380),i=pf(i,s,o,n,e[t+13],21,1309151649),n=pf(n,i,s,o,e[t+4],6,-145523070),o=pf(o,n,i,s,e[t+11],10,-1120210379),s=pf(s,o,n,i,e[t+2],15,718787259),i=pf(i,s,o,n,e[t+9],21,-343485551),n=af(n,r),i=af(i,a),s=af(s,c),o=af(o,d)}return Uint32Array.of(n,i,s,o)}(t,8*e.length);return function(e){const t=new Uint8Array(4*e.length);for(let r=0;r<4*e.length;r++)t[r]=e[r>>2]>>>r%4*8&255;return t}(r)};var hf={};Object.defineProperty(hf,"__esModule",{value:!0}),hf.URL=hf.DNS=hf.stringToBytes=void 0;const ff=xh,mf=Bh;function gf(e){e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}hf.stringToBytes=gf,hf.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",hf.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",hf.default=function(e,t,r,n,i,s){const o="string"==typeof r?gf(r):r,a="string"==typeof n?(0,ff.default)(n):n;if("string"==typeof n&&(n=(0,ff.default)(n)),16!==n?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(a),c.set(o,a.length),c=t(c),c[6]=15&c[6]|e,c[8]=63&c[8]|128,i){s=s||0;for(let e=0;e<16;++e)i[s+e]=c[e];return i}return(0,mf.unsafeStringify)(c)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.URL=e.DNS=void 0;const t=sf,r=hf;var n=hf;function i(e,n,i,s){return(0,r.default)(48,t.default,e,n,i,s)}Object.defineProperty(e,"DNS",{enumerable:!0,get:function(){return n.DNS}}),Object.defineProperty(e,"URL",{enumerable:!0,get:function(){return n.URL}}),i.DNS=r.DNS,i.URL=r.URL,e.default=i}(nf);var vf={},yf={};Object.defineProperty(yf,"__esModule",{value:!0});const _f="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);yf.default={randomUUID:_f},Object.defineProperty(vf,"__esModule",{value:!0});const bf=yf,Ef=Gh,wf=Bh;vf.default=function(e,t,r){if(bf.default.randomUUID&&!t&&!e)return bf.default.randomUUID();const n=(e=e||{}).random??e.rng?.()??(0,Ef.default)();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((r=r||0)<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=n[e];return t}return(0,wf.unsafeStringify)(n)};var Sf={},Cf={};function Pf(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function Tf(e,t){return e<<t|e>>>32-t}Object.defineProperty(Cf,"__esModule",{value:!0}),Cf.default=function(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128;const i=(e=n).length/4+2,s=Math.ceil(i/16),o=new Array(s);for(let t=0;t<s;++t){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=e[64*t+4*n]<<24|e[64*t+4*n+1]<<16|e[64*t+4*n+2]<<8|e[64*t+4*n+3];o[t]=r}o[s-1][14]=8*(e.length-1)/Math.pow(2,32),o[s-1][14]=Math.floor(o[s-1][14]),o[s-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<s;++e){const n=new Uint32Array(80);for(let t=0;t<16;++t)n[t]=o[e][t];for(let e=16;e<80;++e)n[e]=Tf(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let i=r[0],s=r[1],a=r[2],c=r[3],d=r[4];for(let e=0;e<80;++e){const r=Math.floor(e/20),o=Tf(i,5)+Pf(r,s,a,c)+d+t[r]+n[e]>>>0;d=c,c=a,a=Tf(s,30)>>>0,s=i,i=o}r[0]=r[0]+i>>>0,r[1]=r[1]+s>>>0,r[2]=r[2]+a>>>0,r[3]=r[3]+c>>>0,r[4]=r[4]+d>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.URL=e.DNS=void 0;const t=Cf,r=hf;var n=hf;function i(e,n,i,s){return(0,r.default)(80,t.default,e,n,i,s)}Object.defineProperty(e,"DNS",{enumerable:!0,get:function(){return n.DNS}}),Object.defineProperty(e,"URL",{enumerable:!0,get:function(){return n.URL}}),i.DNS=r.DNS,i.URL=r.URL,e.default=i}(Sf);var Rf={};Object.defineProperty(Rf,"__esModule",{value:!0});const kf=Bh,Df=zh,If=ef;Rf.default=function(e,t,r){e??={},r??=0;let n=(0,Df.default)({...e,_v6:!0},new Uint8Array(16));if(n=(0,If.default)(n),t){for(let e=0;e<16;e++)t[r+e]=n[e];return t}return(0,kf.unsafeStringify)(n)};var Af={};Object.defineProperty(Af,"__esModule",{value:!0});const Of=xh,Nf=Bh;Af.default=function(e){const t=function(e){return Uint8Array.of((15&e[3])<<4|e[4]>>4&15,(15&e[4])<<4|(240&e[5])>>4,(15&e[5])<<4|15&e[6],e[7],(15&e[1])<<4|(240&e[2])>>4,(15&e[2])<<4|(240&e[3])>>4,16|(240&e[0])>>4,(15&e[0])<<4|(240&e[1])>>4,e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}("string"==typeof e?(0,Of.default)(e):e);return"string"==typeof e?(0,Nf.unsafeStringify)(t):t};var Mf={};Object.defineProperty(Mf,"__esModule",{value:!0}),Mf.updateV7State=void 0;const Lf=Gh,xf=Bh,Ff={};function jf(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,0===e.seq&&e.msecs++),e}function Uf(e,t,r,n,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(n){if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`)}else n=new Uint8Array(16),i=0;return t??=Date.now(),r??=127*e[6]<<24|e[7]<<16|e[8]<<8|e[9],n[i++]=t/1099511627776&255,n[i++]=t/4294967296&255,n[i++]=t/16777216&255,n[i++]=t/65536&255,n[i++]=t/256&255,n[i++]=255&t,n[i++]=112|r>>>28&15,n[i++]=r>>>20&255,n[i++]=128|r>>>14&63,n[i++]=r>>>6&255,n[i++]=r<<2&255|3&e[10],n[i++]=e[11],n[i++]=e[12],n[i++]=e[13],n[i++]=e[14],n[i++]=e[15],n}Mf.updateV7State=jf,Mf.default=function(e,t,r){let n;if(e)n=Uf(e.random??e.rng?.()??(0,Lf.default)(),e.msecs,e.seq,t,r);else{const e=Date.now(),i=(0,Lf.default)();jf(Ff,e,i),n=Uf(i,Ff.msecs,Ff.seq,t,r)}return t??(0,xf.unsafeStringify)(n)};var Vf={};Object.defineProperty(Vf,"__esModule",{value:!0});const Bf=Fh;Vf.default=function(e){if(!(0,Bf.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.version=e.validate=e.v7=e.v6ToV1=e.v6=e.v5=e.v4=e.v3=e.v1ToV6=e.v1=e.stringify=e.parse=e.NIL=e.MAX=void 0;var t=Mh;Object.defineProperty(e,"MAX",{enumerable:!0,get:function(){return t.default}});var r=Lh;Object.defineProperty(e,"NIL",{enumerable:!0,get:function(){return r.default}});var n=xh;Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return n.default}});var i=Bh;Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return i.default}});var s=zh;Object.defineProperty(e,"v1",{enumerable:!0,get:function(){return s.default}});var o=ef;Object.defineProperty(e,"v1ToV6",{enumerable:!0,get:function(){return o.default}});var a=nf;Object.defineProperty(e,"v3",{enumerable:!0,get:function(){return a.default}});var c=vf;Object.defineProperty(e,"v4",{enumerable:!0,get:function(){return c.default}});var d=Sf;Object.defineProperty(e,"v5",{enumerable:!0,get:function(){return d.default}});var u=Rf;Object.defineProperty(e,"v6",{enumerable:!0,get:function(){return u.default}});var l=Af;Object.defineProperty(e,"v6ToV1",{enumerable:!0,get:function(){return l.default}});var p=Mf;Object.defineProperty(e,"v7",{enumerable:!0,get:function(){return p.default}});var h=Fh;Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return h.default}});var f=Vf;Object.defineProperty(e,"version",{enumerable:!0,get:function(){return f.default}})}(Nh);var Wf={};Object.defineProperty(Wf,"__esModule",{value:!0}),Wf.FakeEventTarget=void 0;Wf.FakeEventTarget=class{listeners={};addEventListener(e,t,r){t&&(this.listeners[e]??=[],this.listeners[e].push({callback:"function"==typeof t?t:t.handleEvent,once:"object"==typeof r&&!0===r.once}))}removeEventListener(e,t,r){this.listeners[e]&&t&&(this.listeners[e]=this.listeners[e].filter((e=>e.callback!==("function"==typeof t?t:t.handleEvent))))}dispatchEvent(e){if(!e||"string"!=typeof e.type)throw new Error("invalid event object");const t=this.listeners[e.type];if(!t)return!0;for(const r of[...t]){try{r.callback.call(this,e)}catch(e){setTimeout((()=>{throw e}),0)}r.once&&this.removeEventListener(e.type,r.callback)}return!e.defaultPrevented}};var Hf={};Object.defineProperty(Hf,"__esModule",{value:!0}),Hf.FakeEvent=void 0;Hf.FakeEvent=class{NONE=0;CAPTURING_PHASE=1;AT_TARGET=2;BUBBLING_PHASE=3;type;bubbles;cancelable;defaultPrevented=!1;composed=!1;currentTarget=null;eventPhase=l.NONE;isTrusted=!0;target=null;timeStamp=0;cancelBubble=!1;returnValue=!0;srcElement=null;constructor(e,t={}){this.type=e,this.bubbles=t.bubbles??!1,this.cancelable=t.cancelable??!1}preventDefault(){this.cancelable&&(this.defaultPrevented=!0)}stopPropagation(){}stopImmediatePropagation(){}composedPath(){return[]}initEvent(e,t,r){}};var qf={};Object.defineProperty(qf,"__esModule",{value:!0}),qf.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},Object.defineProperty(Oh,"__esModule",{value:!0}),Oh.FakeMediaStreamTrack=void 0;const zf=Nh,Gf=Wf,Yf=Hf,$f=qf;class Jf extends Gf.FakeEventTarget{#b;#E;#w;#S;#C;#P;#T;#R;#k;#D;#I;#A=null;#O=null;#N=null;#M=null;#L=null;constructor({kind:e,id:t,label:r,contentHint:n,enabled:i,muted:s,readyState:o,capabilities:a,constraints:c,settings:d,data:u}){super(),this.#b=t??(0,zf.v4)(),this.#E=e,this.#w=r??"",this.#T=n??"",this.#C=i??!0,this.#P=s??!1,this.#S=o??"live",this.#R=a??{},this.#k=c??{},this.#D=d??{},this.#I=u??{}}get id(){return this.#b}get kind(){return this.#E}get label(){return this.#w}get contentHint(){return this.#T}set contentHint(e){this.#T=e}get enabled(){return this.#C}set enabled(e){const t=this.#C!==e;this.#C=e,t&&this.dispatchEvent(new Yf.FakeEvent("enabledchange"))}get muted(){return this.#P}get readyState(){return this.#S}get data(){return this.#I}set data(e){this.#I=e}get onmute(){return this.#A}set onmute(e){this.#A&&this.removeEventListener("mute",this.#A),this.#A=e,e&&this.addEventListener("mute",e)}get onunmute(){return this.#O}set onunmute(e){this.#O&&this.removeEventListener("unmute",this.#O),this.#O=e,e&&this.addEventListener("unmute",e)}get onended(){return this.#N}set onended(e){this.#N&&this.removeEventListener("ended",this.#N),this.#N=e,e&&this.addEventListener("ended",e)}get onenabledchange(){return this.#M}set onenabledchange(e){this.#M&&this.removeEventListener("enabledchange",this.#M),this.#M=e,e&&this.addEventListener("enabledchange",e)}get onstopped(){return this.#L}set onstopped(e){this.#L&&this.removeEventListener("stopped",this.#L),this.#L=e,e&&this.addEventListener("stopped",e)}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t,r){super.removeEventListener(e,t,r)}stop(){"ended"!==this.#S&&(this.#S="ended",this.dispatchEvent(new Yf.FakeEvent("stopped")))}clone({id:e,data:t}={}){return new Jf({id:e??(0,zf.v4)(),kind:this.#E,label:this.#w,contentHint:this.#T,enabled:this.#C,muted:this.#P,readyState:this.#S,capabilities:(0,$f.clone)(this.#R),constraints:(0,$f.clone)(this.#k),settings:(0,$f.clone)(this.#D),data:t??(0,$f.clone)(this.#I)})}getCapabilities(){return this.#R}getConstraints(){return this.#k}async applyConstraints(e={}){return this.#k=e,Promise.resolve()}getSettings(){return this.#D}remoteStop(){"ended"!==this.#S&&(this.#S="ended",this.dispatchEvent(new Yf.FakeEvent("stopped")),this.dispatchEvent(new Yf.FakeEvent("ended")))}remoteMute(){this.#P||(this.#P=!0,this.dispatchEvent(new Yf.FakeEvent("mute")))}remoteUnmute(){this.#P&&(this.#P=!1,this.dispatchEvent(new Yf.FakeEvent("unmute")))}}Oh.FakeMediaStreamTrack=Jf;var Kf={};Object.defineProperty(Kf,"__esModule",{value:!0}),Kf.FakeEventTarget=void 0;Kf.FakeEventTarget=class{listeners={};addEventListener(e,t,r){t&&(this.listeners[e]??=[],this.listeners[e].push({callback:"function"==typeof t?t:t.handleEvent,once:"object"==typeof r&&!0===r.once}))}removeEventListener(e,t,r){this.listeners[e]&&t&&(this.listeners[e]=this.listeners[e].filter((e=>e.callback!==("function"==typeof t?t:t.handleEvent))))}dispatchEvent(e){if(!e||"string"!=typeof e.type)throw new Error("invalid event object");const t=this.listeners[e.type];if(!t)return!0;for(const r of[...t]){try{r.callback.call(this,e)}catch(e){setTimeout((()=>{throw e}),0)}r.once&&this.removeEventListener(e.type,r.callback)}return!e.defaultPrevented}},Object.defineProperty(Ah,"__esModule",{value:!0}),Ah.FakeHandler=void 0;const Qf=Oh,Zf=jd,Xf=ou,em=au,tm=nu,rm=Kf,nm=new Md.Logger("FakeHandler");class im extends Zf.EnhancedEventEmitter{_closed=!1;_fakeParameters;_getSendExtendedRtpCapabilities;_cname=`CNAME-${Xf.generateRandomNumber()}`;_transportReady=!1;_nextLocalId=1;_tracks=new Map;_nextSctpStreamId=0;static createFactory(e){return{name:"FakeHandler",factory:t=>new im(t,e),getNativeRtpCapabilities:async()=>(nm.debug("getNativeRtpCapabilities()"),im.getLocalRtpCapabilities(e)),getNativeSctpCapabilities:async()=>(nm.debug("getNativeSctpCapabilities()"),e.generateNativeSctpCapabilities())}}static getLocalRtpCapabilities(e){const t=e.generateNativeRtpCapabilities();return em.validateAndNormalizeRtpCapabilities(t),t}constructor({getSendExtendedRtpCapabilities:e},t){super(),nm.debug("constructor()"),this._getSendExtendedRtpCapabilities=e,this._fakeParameters=t}get name(){return"FakeHandler"}close(){nm.debug("close()"),this._closed||(this._closed=!0,super.close())}setIceGatheringState(e){this.emit("@icegatheringstatechange",e)}setConnectionState(e){this.emit("@connectionstatechange",e)}async updateIceServers(e){this.assertNotClosed(),nm.debug("updateIceServers()")}async restartIce(e){this.assertNotClosed(),nm.debug("restartIce()")}async getTransportStats(){return this.assertNotClosed(),new Map}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertNotClosed(),nm.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),this._transportReady||await this.setupTransport({localDtlsRole:"server"});const i=im.getLocalRtpCapabilities(this._fakeParameters),s=this._getSendExtendedRtpCapabilities(i),o=em.getSendingRtpParameters(e.kind,s);o.codecs=em.reduceCodecs(o.codecs,n);const a=o.codecs.some((e=>/.+\/rtx$/i.test(e.mimeType)));o.mid=`mid-${Xf.generateRandomNumber()}`,t||(t=[{}]);for(const e of t)e.ssrc=Xf.generateRandomNumber(),a&&(e.rtx={ssrc:Xf.generateRandomNumber()});o.encodings=t,o.rtcp={cname:this._cname,reducedSize:!0,mux:!0};const c=this._nextLocalId++;return this._tracks.set(c,e),{localId:String(c),rtpParameters:o}}async stopSending(e){if(nm.debug("stopSending() [localId:%s]",e),!this._closed){if(!this._tracks.has(Number(e)))throw new Error("local track not found");this._tracks.delete(Number(e))}}async pauseSending(e){this.assertNotClosed()}async resumeSending(e){this.assertNotClosed()}async replaceTrack(e,t){this.assertNotClosed(),t?nm.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):nm.debug("replaceTrack() [localId:%s, no track]",e),this._tracks.delete(Number(e)),this._tracks.set(Number(e),t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),nm.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),nm.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t)}async getSenderStats(e){return this.assertNotClosed(),new Map}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this._transportReady||await this.setupTransport({localDtlsRole:"server"}),nm.debug("sendDataChannel()");return{dataChannel:new sm({id:this._nextSctpStreamId++,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}),sctpStreamParameters:{streamId:this._nextSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r}}}async receive(e){this.assertNotClosed();const t=[];for(const r of e){const{trackId:e,kind:n}=r;this._transportReady||await this.setupTransport({localDtlsRole:"client"}),nm.debug("receive() [trackId:%s, kind:%s]",e,n);const i=this._nextLocalId++,s=new Qf.FakeMediaStreamTrack({kind:n});this._tracks.set(i,s),t.push({localId:String(i),track:s})}return t}async stopReceiving(e){if(!this._closed)for(const t of e)nm.debug("stopReceiving() [localId:%s]",t),this._tracks.delete(Number(t))}async pauseReceiving(e){this.assertNotClosed()}async resumeReceiving(e){this.assertNotClosed()}async getReceiverStats(e){return this.assertNotClosed(),new Map}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this._transportReady||await this.setupTransport({localDtlsRole:"client"}),nm.debug("receiveDataChannel()");return{dataChannel:new sm({id:e.streamId,ordered:e.ordered,maxPacketLifeTime:e.maxPacketLifeTime,maxRetransmits:e.maxRetransmits,label:t,protocol:r})}}async setupTransport({localDtlsRole:e,localSdpObject:t}){const r=Xf.clone(this._fakeParameters.generateLocalDtlsParameters());e&&(r.role=e),this.emit("@connectionstatechange","connecting"),await new Promise(((e,t)=>this.emit("@connect",{dtlsParameters:r},e,t))),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new tm.InvalidStateError("method called in a closed handler")}}Ah.FakeHandler=im;class sm extends rm.FakeEventTarget{_id;_negotiated=!0;_ordered;_maxPacketLifeTime;_maxRetransmits;_label;_protocol;_readyState="connecting";_bufferedAmount=0;_bufferedAmountLowThreshold=0;_binaryType="arraybuffer";_onopen=null;_onclosing=null;_onclose=null;_onmessage=null;_onbufferedamountlow=null;_onerror=null;constructor({id:e,ordered:t=!0,maxPacketLifeTime:r=null,maxRetransmits:n=null,label:i="",protocol:s=""}){super(),nm.debug(`constructor() [id:${e}, ordered:${t}, maxPacketLifeTime:${r}, maxRetransmits:${n}, label:${i}, protocol:${s}`),this._id=e,this._ordered=t,this._maxPacketLifeTime=r,this._maxRetransmits=n,this._label=i,this._protocol=s}get id(){return this._id}get negotiated(){return this._negotiated}get ordered(){return this._ordered}get maxPacketLifeTime(){return this._maxPacketLifeTime}get maxRetransmits(){return this._maxRetransmits}get label(){return this._label}get protocol(){return this._protocol}get readyState(){return this._readyState}get bufferedAmount(){return this._bufferedAmount}get bufferedAmountLowThreshold(){return this._bufferedAmountLowThreshold}set bufferedAmountLowThreshold(e){this._bufferedAmountLowThreshold=e}get binaryType(){return this._binaryType}set binaryType(e){this._binaryType=e}get onopen(){return this._onopen}set onopen(e){this._onopen&&this.removeEventListener("open",this._onopen),this._onopen=e,e&&this.addEventListener("open",e)}get onclosing(){return this._onclosing}set onclosing(e){this._onclosing&&this.removeEventListener("closing",this._onclosing),this._onclosing=e,e&&this.addEventListener("closing",e)}get onclose(){return this._onclose}set onclose(e){this._onclose&&this.removeEventListener("close",this._onclose),this._onclose=e,e&&this.addEventListener("close",e)}get onmessage(){return this._onmessage}set onmessage(e){this._onmessage&&this.removeEventListener("message",this._onmessage),this._onmessage=e,e&&this.addEventListener("message",e)}get onbufferedamountlow(){return this._onbufferedamountlow}set onbufferedamountlow(e){this._onbufferedamountlow&&this.removeEventListener("bufferedamountlow",this._onbufferedamountlow),this._onbufferedamountlow=e,e&&this.addEventListener("bufferedamountlow",e)}get onerror(){return this._onerror}set onerror(e){this._onerror&&this.removeEventListener("error",this._onerror),this._onerror=e,e&&this.addEventListener("error",e)}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t,r){super.removeEventListener(e,t,r)}close(){["closing","closed"].includes(this._readyState)||(this._readyState="closed")}send(e){if("open"!==this._readyState)throw new tm.InvalidStateError("not open")}}var om={};Object.defineProperty(om,"__esModule",{value:!0}),om.generateRouterRtpCapabilities=function(){return am.deepFreeze({codecs:[{mimeType:"audio/opus",kind:"audio",preferredPayloadType:100,clockRate:48e3,channels:2,rtcpFeedback:[{type:"transport-cc"}],parameters:{useinbandfec:1,foo:"bar"}},{mimeType:"video/VP8",kind:"video",preferredPayloadType:101,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"x-google-start-bitrate":1500}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:102,clockRate:9e4,rtcpFeedback:[],parameters:{apt:101}},{mimeType:"video/H264",kind:"video",preferredPayloadType:103,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"level-asymmetry-allowed":1,"packetization-mode":1,"profile-level-id":"42e01f"}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:104,clockRate:9e4,rtcpFeedback:[],parameters:{apt:103}},{mimeType:"video/VP9",kind:"video",preferredPayloadType:105,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"profile-id":0,"x-google-start-bitrate":1500}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:106,clockRate:9e4,rtcpFeedback:[],parameters:{apt:105}}],headerExtensions:[{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id",preferredId:2,preferredEncrypt:!1,direction:"recvonly"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id",preferredId:3,preferredEncrypt:!1,direction:"recvonly"},{kind:"audio",uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",preferredId:4,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",preferredId:4,preferredEncrypt:!1,direction:"sendrecv"},{kind:"audio",uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",preferredId:5,preferredEncrypt:!1,direction:"recvonly"},{kind:"video",uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",preferredId:5,preferredEncrypt:!1,direction:"sendrecv"},{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",preferredId:10,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:3gpp:video-orientation",preferredId:11,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:toffset",preferredId:12,preferredEncrypt:!1,direction:"sendrecv"}]})},om.generateNativeRtpCapabilities=function(){return{codecs:[{mimeType:"audio/opus",kind:"audio",preferredPayloadType:111,clockRate:48e3,channels:2,rtcpFeedback:[{type:"transport-cc"}],parameters:{minptime:10,useinbandfec:1}},{mimeType:"audio/ISAC",kind:"audio",preferredPayloadType:103,clockRate:16e3,channels:1,rtcpFeedback:[{type:"transport-cc"}],parameters:{}},{mimeType:"audio/CN",kind:"audio",preferredPayloadType:106,clockRate:32e3,channels:1,rtcpFeedback:[{type:"transport-cc"}],parameters:{}},{mimeType:"audio/foo",kind:"audio",preferredPayloadType:107,clockRate:9e4,channels:4,rtcpFeedback:[{type:"foo-qwe-qwe"}],parameters:{foo:"lalala"}},{mimeType:"video/BAZCODEC",kind:"video",preferredPayloadType:100,clockRate:9e4,rtcpFeedback:[{type:"foo"},{type:"transport-cc"},{type:"ccm",parameter:"fir"},{type:"nack"},{type:"nack",parameter:"pli"}],parameters:{baz:"1234abcd"}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:101,clockRate:9e4,rtcpFeedback:[],parameters:{apt:100}},{mimeType:"video/VP8",kind:"video",preferredPayloadType:96,clockRate:9e4,rtcpFeedback:[{type:"goog-remb"},{type:"transport-cc"},{type:"ccm",parameter:"fir"},{type:"nack"},{type:"nack",parameter:"pli"}],parameters:{baz:"1234abcd"}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:97,clockRate:9e4,rtcpFeedback:[],parameters:{apt:96}},{mimeType:"video/VP9",kind:"video",preferredPayloadType:98,clockRate:9e4,rtcpFeedback:[{type:"goog-remb"},{type:"transport-cc"},{type:"ccm",parameter:"fir"},{type:"nack"},{type:"nack",parameter:"pli"}],parameters:{"profile-id":0}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:99,clockRate:9e4,rtcpFeedback:[],parameters:{apt:98}}],headerExtensions:[{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:toffset",preferredId:2},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",preferredId:3},{kind:"video",uri:"urn:3gpp:video-orientation",preferredId:4},{kind:"video",uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",preferredId:5},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/playout-delay",preferredId:6},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/video-content-type",preferredId:7},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/video-timing",preferredId:8},{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",preferredId:10}]}},om.generateNativeSctpCapabilities=function(){return am.deepFreeze({numStreams:{OS:2048,MIS:2048}})},om.generateLocalDtlsParameters=function(){return am.deepFreeze({fingerprints:[{algorithm:"sha-256",value:"82:5A:68:3D:36:C3:0A:DE:AF:E7:32:43:D2:88:83:57:AC:2D:65:E5:80:C4:B6:FB:AF:1A:A0:21:9F:6D:0C:AD"}],role:"auto"})},om.generateTransportRemoteParameters=function(){return{id:cm(),iceParameters:am.deepFreeze({iceLite:!0,password:"yku5ej8nvfaor28lvtrabcx0wkrpkztz",usernameFragment:"h3hk1iz6qqlnqlne"}),iceCandidates:am.deepFreeze([{foundation:"udpcandidate",address:"9.9.9.9",ip:"9.9.9.9",port:40533,priority:1078862079,protocol:"udp",type:"host",tcpType:"passive"},{foundation:"udpcandidate",address:"9.9.9.9",ip:"9:9:9:9:9:9",port:41333,priority:1078862089,protocol:"udp",type:"host",tcpType:"passive"}]),dtlsParameters:am.deepFreeze({fingerprints:[{algorithm:"sha-256",value:"A9:F4:E0:D2:74:D3:0F:D9:CA:A5:2F:9F:7F:47:FA:F0:C4:72:DD:73:49:D0:3B:14:90:20:51:30:1B:90:8E:71"},{algorithm:"sha-384",value:"03:D9:0B:87:13:98:F6:6D:BC:FC:92:2E:39:D4:E1:97:32:61:30:56:84:70:81:6E:D1:82:97:EA:D9:C1:21:0F:6B:C5:E7:7F:E1:97:0C:17:97:6E:CF:B3:EF:2E:74:B0"},{algorithm:"sha-512",value:"84:27:A4:28:A4:73:AF:43:02:2A:44:68:FF:2F:29:5C:3B:11:9A:60:F4:A8:F0:F5:AC:A0:E3:49:3E:B1:34:53:A9:85:CE:51:9B:ED:87:5E:B8:F4:8E:3D:FA:20:51:B8:96:EE:DA:56:DC:2F:5C:62:79:15:23:E0:21:82:2B:2C"}],role:"auto"}),sctpParameters:am.deepFreeze({port:5e3,OS:2048,MIS:2048,maxMessageSize:2e6})}},om.generateProducerRemoteParameters=function(){return am.deepFreeze({id:cm()})},om.generateConsumerRemoteParameters=function({id:e,codecMimeType:t}={}){switch(t){case"audio/opus":return{id:e??cm(),producerId:cm(),kind:"audio",rtpParameters:am.deepFreeze({codecs:[{mimeType:"audio/opus",payloadType:100,clockRate:48e3,channels:2,rtcpFeedback:[{type:"transport-cc"}],parameters:{useinbandfec:1,foo:"bar"}}],encodings:[{ssrc:46687003}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5},{uri:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",id:10}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};case"audio/ISAC":return{id:e??cm(),producerId:cm(),kind:"audio",rtpParameters:am.deepFreeze({codecs:[{mimeType:"audio/ISAC",payloadType:111,clockRate:16e3,channels:1,rtcpFeedback:[{type:"transport-cc"}],parameters:{}}],encodings:[{ssrc:46687004}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};case"video/VP8":return{id:e??cm(),producerId:cm(),kind:"video",rtpParameters:am.deepFreeze({codecs:[{mimeType:"video/VP8",payloadType:101,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"x-google-start-bitrate":1500}},{mimeType:"video/rtx",payloadType:102,clockRate:9e4,rtcpFeedback:[],parameters:{apt:101}}],encodings:[{ssrc:99991111,rtx:{ssrc:99991112}}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",id:4},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5},{uri:"urn:3gpp:video-orientation",id:11},{uri:"urn:ietf:params:rtp-hdrext:toffset",id:12}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};case"video/H264":return{id:e??cm(),producerId:cm(),kind:"video",rtpParameters:am.deepFreeze({codecs:[{mimeType:"video/H264",payloadType:103,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"level-asymmetry-allowed":1,"packetization-mode":1,"profile-level-id":"42e01f"}},{mimeType:"video/rtx",payloadType:104,clockRate:9e4,rtcpFeedback:[],parameters:{apt:103}}],encodings:[{ssrc:99991113,rtx:{ssrc:99991114}}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",id:4},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5},{uri:"urn:3gpp:video-orientation",id:11},{uri:"urn:ietf:params:rtp-hdrext:toffset",id:12}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};default:throw new TypeError(`unknown codecMimeType '${t}'`)}},om.generateDataProducerRemoteParameters=function(){return am.deepFreeze({id:cm()})},om.generateDataConsumerRemoteParameters=function({id:e}={}){return{id:e??cm(),dataProducerId:cm(),sctpStreamParameters:am.deepFreeze({streamId:666,maxPacketLifeTime:5e3,maxRetransmits:void 0})}};const am=ou;function cm(){return String(am.generateRandomNumber())}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.debug=e.testFakeParameters=e.FakeHandler=e.enhancedEvents=e.ortc=e.parseScalabilityMode=e.detectDeviceAsync=e.detectDevice=e.Device=e.version=e.types=void 0;const t=pd.exports;e.debug=t.default,e.types=bd,e.version="3.15.6";var r=Ed;Object.defineProperty(e,"Device",{enumerable:!0,get:function(){return r.Device}}),Object.defineProperty(e,"detectDevice",{enumerable:!0,get:function(){return r.detectDevice}}),Object.defineProperty(e,"detectDeviceAsync",{enumerable:!0,get:function(){return r.detectDeviceAsync}});var n=ql;Object.defineProperty(e,"parseScalabilityMode",{enumerable:!0,get:function(){return n.parse}}),e.ortc=au,e.enhancedEvents=jd;var i=Ah;Object.defineProperty(e,"FakeHandler",{enumerable:!0,get:function(){return i.FakeHandler}}),e.testFakeParameters=om}(ld);const dm={width:1280,height:720},um=0,lm=2,pm=0;function hm(e,t){e.onload=function(){this.onerror=this.onload=null,t(null,e)},e.onerror=function(){this.onerror=this.onload=null,t(new Error("Failed to load "+this.src),e)}}function fm(e,t){e.onreadystatechange=function(){"complete"!=this.readyState&&"loaded"!=this.readyState||(this.onreadystatechange=null,t(null,e))}}const mm=new Dn,gm=e=>a(void 0,void 0,void 0,(function*(){return yield new Promise(((t,r)=>{!function(e,t,r){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("script");"function"==typeof t&&(r=t,t={}),t=t||{},r=r||function(){},i.type=t.type||"text/javascript",i.charset=t.charset||"utf8",i.async=!("async"in t)||!!t.async,i.src=e,t.attrs&&function(e,t){for(var r in t)e.setAttribute(r,t[r])}(i,t.attrs),t.text&&(i.text=""+t.text),("onload"in i?hm:fm)(i,r),i.onload||hm(i,r),n.appendChild(i)}(e,((e,n)=>{e?r(e):t(n)}))}))})),vm=(e,...t)=>a(void 0,[e,...t],void 0,(function*(e,t=3,r=500){let n=0;for(;n<t;)try{return void(yield gm(e))}catch(e){if(n+=1,!(n<t))throw e;yield mm.sleepMs(r)}}));var ym;let _m=class{constructor(){ym.set(this,new Map)}add(e,t,r){const n=this.getKey(e,t);if(c(this,ym,"f").has(n))throw new Error("Attempt to rewrite cached track processor");c(this,ym,"f").set(n,r)}get(e,t){return c(this,ym,"f").get(this.getKey(e,t))}has(e,t){return c(this,ym,"f").has(this.getKey(e,t))}getKey(e,t){return`${e}:${t}`}reset(){for(const e of c(this,ym,"f").values())try{e.stopProcessing(),e.release()}catch(e){}c(this,ym,"f").clear()}};var bm,Em;ym=new WeakMap,_m=i([at()],_m);let wm=class{constructor(e,t,r,n){this.config=e,this.processorsCache=t,this.audioTrackProcessorFactory=r,bm.set(this,new Map),Em.set(this,void 0),d(this,Em,n("IntegrationsService"),"f")}init(){const e=this.config.get("denoiser");if("asdk"===e){c(this,Em,"f").info("Start integration of ASDK",{denoiser:e});const t={integrated:!1,initPromise:this.integrateASDK()};c(this,bm,"f").set("asdk",t)}else{c(this,Em,"f").info("Start integration of RNNoise",{denoiser:e});const t={integrated:!1,initPromise:this.integrateRNNoise()};c(this,bm,"f").set("rnnoise",t)}}integrateASDK(){return a(this,void 0,void 0,(function*(){const e=this.config.get("asdk"),t=this.config.get("staticFilesPath");if(!window.atsvb){const s=`https://effectssdk.ai/sdk/audio/dev/${e.version}/atsvb-web.js`;let o=s;if(e.localDir){const n=`${e.localDir}/${e.version}/atsvb-web.js`;o=new r(n,t).href}yield(n=o,i=s,a(void 0,void 0,void 0,(function*(){try{yield vm(n)}catch(e){if(!i)throw e;yield vm(i)}})))}var n,i;if(!window.atsvb)throw c(this,Em,"f").info("Audio Effects SDK is not loaded, skipping initialization",{case:"initAudioSDK"}),new Error("windows.atsvb is still missing");const s=this.audioTrackProcessorFactory({trackLabel:Nn.Microphone});yield s.init(),this.processorsCache.add("asdk",Nn.Microphone,s);const o=c(this,bm,"f").get("asdk");if(!o)throw Error("IntegrationContext is missing for ASDK");o.integrated=!0}))}get audio(){return"asdk"===this.config.get("denoiser")?this.getASDKState():this.getRNNoiseState()}getASDKState(){var e,t;const r=c(this,bm,"f").get("asdk");return{type:"asdk",enabled:Boolean(r),isInitialized:null!==(e=null==r?void 0:r.integrated)&&void 0!==e&&e,waitForInitialization:null!==(t=null==r?void 0:r.initPromise)&&void 0!==t?t:Promise.resolve()}}getRNNoiseState(){var e,t;const r=c(this,bm,"f").get("rnnoise");return{type:"rnnoise",enabled:Boolean(r),isInitialized:null!==(e=null==r?void 0:r.integrated)&&void 0!==e&&e,waitForInitialization:null!==(t=null==r?void 0:r.initPromise)&&void 0!==t?t:Promise.resolve()}}integrateRNNoise(){return a(this,void 0,void 0,(function*(){const e=yield function(e){return a(this,void 0,void 0,(function*(){if(!window.WebAssembly)throw new Error("Webassembly not supported");const t=yield fetch(`${e}/rnnoise-processor.wasm`);return yield WebAssembly.instantiate(yield t.arrayBuffer())}))}(this.config.get("staticFilesPath")),t=this.audioTrackProcessorFactory({trackLabel:Nn.Microphone,noiseSuppressor:e});this.processorsCache.add("rnnoise",Nn.Microphone,t);const r=c(this,bm,"f").get("rnnoise");if(!r)throw Error("IntegrationContext is missing for RNNoise");r.integrated=!0}))}reset(){c(this,bm,"f").clear()}};var Sm,Cm,Pm,Tm,Rm,km,Dm,Im,Am;bm=new WeakMap,Em=new WeakMap,wm=i([at(),s(0,dt(On.Config)),s(1,dt(On.ProcessorsCache)),s(2,dt(On.AudioTrackProcessorFactory)),s(3,dt(On.LoggerFactory)),o("design:paramtypes",[bt,_m,Function,Function])],wm),function(e){e.INFO="info",e.WARNING="warning",e.ERROR="error"}(Im||(Im={})),function(e){e.TSVB="tsvb",e.COMPONENTS_SYSTEM="components_system",e.SRTEAM_PROCESSOR="stream_processor",e.ML_INFERENCE="ml_inference",e.PRESET_INIT="preset_init",e.RENDERER="renderer",e.RECORDER="recorder",e.EFFECT_VIRTUAL_BACKGROUND="effect_virtual_background",e.EFFECT_COLOR_CORRECTION="effect_color_correction",e.EFFECT_COLOR_FILTER="effect_color_filter",e.EFFECT_SMART_ZOOM="effect_smart_zoom",e.EFFECT_LOW_LIGHT="effect_low_light"}(Am||(Am={}));class Om{constructor(e){Sm.set(this,void 0),Cm.set(this,void 0),Pm.set(this,{lowLighter:!1,colorCorrector:!1,faceDetector:!1,segmentation:!1}),Tm.set(this,null),Rm.set(this,void 0),km.set(this,!1),Dm.set(this,void 0);const{loggerFactory:t}=e;if(d(this,Cm,t("EffectsSDKTrackProcessor"),"f"),d(this,Dm,e.onModelsLoaded,"f"),!e.customerId)throw new Error("Customer ID must be provided");d(this,Sm,new window.tsvb(e.customerId),"f"),c(this,Sm,"f").onError(this.tsvbErrorHandler.bind(this)),c(this,Sm,"f").onReady=this.onReady.bind(this);const r=e.config.get("staticFilesPath"),{localDir:n,version:i}=e.config.get("effectsSDKParams"),s=n&&i?`${r}/esdk/${null!=i?i:"3.5.8"}`:`https://effectssdk.ai/sdk/web/${null!=i?i:"3.5.8"}`,o={preset:"balanced",provider:"webgpu",sdk_url:e.sdk_url,api_url:e.api_url,test_inference:!0,wasmPaths:{"ort-wasm.wasm":`${s}/ort-wasm.wasm`,"ort-wasm-simd.wasm":`${s}/ort-wasm-simd.wasm`,"ort-wasm-simd.jsep.wasm":`${s}/ort-wasm-simd.jsep.wasm`}};c(this,Sm,"f").config(o)}init(){return a(this,void 0,void 0,(function*(){yield c(this,Sm,"f").preload(),yield c(this,Sm,"f").cache(),d(this,km,!0,"f")}))}awaitReady(){return a(this,void 0,void 0,(function*(){yield new Promise(((e,t)=>{const r=Date.now(),n=setInterval((()=>{if(this.isModelsLoaded)return clearInterval(n),void e();Date.now()-r>6e4&&(clearInterval(n),t(new Error("ESDK init timeout")))}),100)}))}))}tsvbErrorHandler(e){var t;const{emitter:r,type:i}=e,s=n(e,["emitter","type"]),o=null!=r?r:"N/A emitter";i===Im.ERROR&&c(this,Cm,"f").error(o,Object.assign({error:Ct(e)},s)),i===Im.WARNING&&c(this,Cm,"f").warn(o,Object.assign({},s)),i===Im.INFO&&c(this,Cm,"f").info(o,Object.assign({},s)),r===Am.ML_INFERENCE&&(s.message.toLocaleLowerCase().includes("init lowlighter")&&(c(this,Pm,"f").lowLighter=!0),s.message.toLocaleLowerCase().includes("init colorcorrector")&&(c(this,Pm,"f").colorCorrector=!0),s.message.toLocaleLowerCase().includes("init facedetector")&&(c(this,Pm,"f").faceDetector=!0),s.message.toLocaleLowerCase().includes("init segmentation")&&(c(this,Pm,"f").segmentation=!0),this.isModelsLoaded&&(null===(t=c(this,Dm,"f"))||void 0===t||t.call(this)))}get isModelsLoaded(){return c(this,Pm,"f").colorCorrector&&c(this,Pm,"f").faceDetector&&c(this,Pm,"f").lowLighter&&c(this,Pm,"f").segmentation}get modelsLoadProgress(){return Object.values(c(this,Pm,"f")).filter(Boolean).length/Object.keys(c(this,Pm,"f")).length}get isReady(){return c(this,km,"f")}setOnLoadModels(e){d(this,Dm,e,"f"),this.isModelsLoaded&&c(this,Dm,"f").call(this)}onReady(){d(this,km,!0,"f"),c(this,Cm,"f").debug("onReady()",{description:"ESDK is ready"}),this.updateEffects(c(this,Rm,"f"))}processTrack(e){var t,r,n;if(c(this,Tm,"f")===e||"ended"===e.readyState)return null!==(r=null===(t=c(this,Sm,"f").getStream())||void 0===t?void 0:t.getVideoTracks()[0])&&void 0!==r?r:e;this.stopProcessing();try{c(this,Sm,"f").useStream(new MediaStream([e]));const t=null===(n=c(this,Sm,"f").getStream())||void 0===n?void 0:n.getVideoTracks()[0];return t?(d(this,Tm,e,"f"),t):e}catch(t){throw c(this,Cm,"f").error("processTrack()",{error:t,track:e}),new Error("Can not process this track")}}stopProcessing(){try{c(this,Sm,"f").clear(),c(this,Sm,"f").stop()}catch(e){c(this,Cm,"f").error("stopProcessing()",{error:e})}finally{d(this,Tm,null,"f")}}updateEffects(e){var t,r,n,i,s,o,a,u,l,p,h,f,m,g,v,y,_,b,E,w,S,C;if(d(this,Rm,e,"f"),!c(this,km,"f"))return void c(this,Cm,"f").warn("updateEffects()",{description:"Esdk not ready"});if(!c(this,Rm,"f")||0===Object.keys(c(this,Rm,"f")).length)return void c(this,Sm,"f").stop();let P=0;if((null===(t=c(this,Rm,"f"))||void 0===t?void 0:t.blur)&&!(null===(r=c(this,Rm,"f"))||void 0===r?void 0:r.backgroundColor)?(c(this,Sm,"f").setBlur(c(this,Rm,"f").blur),P+=1):c(this,Sm,"f").clearBlur(),void 0!==(null===(n=c(this,Rm,"f"))||void 0===n?void 0:n.background)?(c(this,Sm,"f").setBackground(c(this,Rm,"f").background),P+=1):void 0!==(null===(i=c(this,Rm,"f"))||void 0===i?void 0:i.backgroundColor)?(c(this,Sm,"f").setBackgroundColor(null===(s=c(this,Rm,"f"))||void 0===s?void 0:s.backgroundColor),c(this,Sm,"f").setBackground("color"),P+=1):c(this,Sm,"f").clearBackground(),(null===(o=c(this,Rm,"f"))||void 0===o?void 0:o.beautification)?(c(this,Sm,"f").enableBeautification(),c(this,Sm,"f").setBeautificationLevel(c(this,Rm,"f").beautification),P+=1):c(this,Sm,"f").disableBeautification(),(null===(a=c(this,Rm,"f"))||void 0===a?void 0:a.lowLightEffect)?(c(this,Sm,"f").enableLowLightEffect(),c(this,Sm,"f").setLowLightEffectPower(c(this,Rm,"f").lowLightEffect),P+=1):c(this,Sm,"f").disableLowLightEffect(),(null===(u=c(this,Rm,"f"))||void 0===u?void 0:u.colorCorrector)?(c(this,Sm,"f").enableColorCorrector(),c(this,Sm,"f").setColorCorrectorPower(c(this,Rm,"f").colorCorrector),P+=1):c(this,Sm,"f").disableColorCorrector(),(null===(l=c(this,Rm,"f"))||void 0===l?void 0:l.smartZoom)?(c(this,Sm,"f").enableSmartZoom(),c(this,Sm,"f").setFaceArea(c(this,Rm,"f").smartZoom),P+=1):c(this,Sm,"f").disableSmartZoom(),(null===(p=c(this,Rm,"f"))||void 0===p?void 0:p.layout)?(c(this,Sm,"f").setLayout(c(this,Rm,"f").layout),P+=1):c(this,Sm,"f").setLayout("center"),(null===(h=c(this,Rm,"f"))||void 0===h?void 0:h.colorFilter)&&(null===(f=c(this,Rm,"f"))||void 0===f?void 0:f.colorFilter.power)&&(null===(m=c(this,Rm,"f"))||void 0===m?void 0:m.colorFilter.url)?(c(this,Sm,"f").setColorFilterConfig({lut:c(this,Rm,"f").colorFilter.url,power:c(this,Rm,"f").colorFilter.power}),c(this,Sm,"f").enableColorFilter(),P+=1):c(this,Sm,"f").disableColorFilter(),null===(g=c(this,Rm,"f"))||void 0===g?void 0:g.lowerThird){const e=c(this,Sm,"f").createComponent({component:c(this,Rm,"f").lowerThird.type,options:null!==(v=c(this,Rm,"f").lowerThird.options)&&void 0!==v?v:{}});null===(b=null===(_=null===(y=c(this,Sm,"f").components)||void 0===y?void 0:y.lowerThird)||void 0===_?void 0:_.hideLowerThird)||void 0===b||b.call(_),c(this,Sm,"f").addComponent(e,"lowerThird"),c(this,Sm,"f").components.lowerThird.showLowerThird(),P+=1}else null===(S=null===(w=null===(E=c(this,Sm,"f").components)||void 0===E?void 0:E.lowerThird)||void 0===w?void 0:w.hideLowerThird)||void 0===S||S.call(w);(null===(C=c(this,Rm,"f"))||void 0===C?void 0:C.sharpness)?(c(this,Sm,"f").setSharpnessEffectConfig(c(this,Rm,"f").sharpness),P+=1):c(this,Sm,"f").disableSharpnessEffect(),P>2?c(this,Sm,"f").enableFrameSkipping():c(this,Sm,"f").disableFrameSkipping(),c(this,Sm,"f").run()}}Sm=new WeakMap,Cm=new WeakMap,Pm=new WeakMap,Tm=new WeakMap,Rm=new WeakMap,km=new WeakMap,Dm=new WeakMap;const Nm=e=>"rtx"!==e.mimeType;var Mm,Lm,xm,Fm,jm,Um,Vm,Bm,Wm,Hm,qm,zm,Gm,Ym,$m,Jm;class Km{constructor({track:e,statsHandler:t}){Mm.set(this,void 0),Lm.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return c(this,Mm,"f")}get audioWebRTCStats(){return c(this,Lm,"f")}handleWebRTCStats(e,t){e.addEventListener("ended",(()=>{t.removeInboundVideoHandler(e.id),t.removeInboundAudioHandler(e.id)}),{once:!0}),"video"!==e.kind?t.addOutboundAudioHandler(e.id,this.setAudioWebRTCStats.bind(this)):t.addOutboundVideoHandler(e.id,this.setVideoWebRTCStats.bind(this))}setVideoWebRTCStats(e){d(this,Mm,e,"f")}setAudioWebRTCStats(e){d(this,Lm,e,"f")}}Mm=new WeakMap,Lm=new WeakMap;class Qm{constructor(e){xm.set(this,void 0),Fm.set(this,void 0),this.encoderConfig={},this.label=Nn.Unknown,jm.set(this,void 0),Um.set(this,void 0),Vm.set(this,void 0),Bm.set(this,void 0),Wm.set(this,void 0),Hm.set(this,void 0),qm.set(this,void 0),zm.set(this,void 0),Gm.set(this,!0),Ym.set(this,void 0),$m.set(this,void 0),Jm.set(this,void 0);const{mediaStreamTrack:t,internalEventEmitter:r,constraints:n,mediaStreamTrackManager:i,media:s,myPeer:o,network:a,producerCloseManager:c,mutex:u,loggerFactory:l,loggerNamespace:p,statsHandler:h}=e;d(this,xm,t,"f"),d(this,Wm,r,"f"),d(this,Hm,n,"f"),d(this,qm,i,"f"),d(this,zm,new Et,"f"),this.logger=l(p),d(this,Ym,u,"f"),d(this,Um,s,"f"),d(this,jm,o,"f"),d(this,Vm,a,"f"),d(this,Bm,c,"f"),d(this,Jm,h,"f"),d(this,$m,new Km({track:t,statsHandler:h}),"f")}get videoWebRTCStats(){return c(this,$m,"f").videoWebRTCStats}get audioWebRTCStats(){return c(this,$m,"f").audioWebRTCStats}get logCtx(){return{label:this.getLabel(),id:this.id,kind:this.kind,producerId:this.producerId,paused:this.isPaused,published:this.isPublished}}get observer(){return c(this,zm,"f")}get mediaStreamTrack(){return c(this,xm,"f")}get originalTrack(){return c(this,Fm,"f")}get id(){return this.mediaStreamTrack.id}get kind(){return this.mediaStreamTrack.kind}get producerId(){var e;return null===(e=this.producer)||void 0===e?void 0:e.id}get isPublished(){return!!this.producer&&!this.producer.closed}get isPaused(){var e,t;return null!==(t=null===(e=this.producer)||void 0===e?void 0:e.paused)&&void 0!==t&&t}get internalEventEmitter(){return c(this,Wm,"f")}getLabel(){return this.label}setLabel(e){this.label=e}setEncoderConfig(e){this.encoderConfig=e}getEncoderConfig(){return this.encoderConfig}setProducer(e){this.producer=e}setStopTrackOnPause(e){this.isPublished||d(this,Gm,e,"f")}getProducer(){return this.producer}setOriginalTrack(){d(this,Fm,this.mediaStreamTrack,"f")}closeProducer(){return a(this,arguments,void 0,(function*(e=!0){const t=yield c(this,Ym,"f").lock(fn.CloseProducer);if(!this.producer)return void t();const{producerId:r}=this;r&&(yield c(this,Bm,"f").close(this.getLabel(),r)),this.producer.close(),this.producer=void 0,e&&this.stopMediaStreamTrack(),t()}))}setPriority(e){return a(this,void 0,void 0,(function*(){this.producer?(yield this.producer.setRtpEncodingParameters({priority:e}),this.logger.debug("setPriority()",{label:this.getLabel(),priority:e})):this.logger.warn("setPriority()",{priority:e,reason:"Not published yet"})}))}stopMediaStreamTrack(){this.mediaStreamTrack.stop(),this.mediaStreamTrack.dispatchEvent(new Event("ended")),this.stopOriginalTrack()}stopOriginalTrack(){c(this,Fm,"f")&&(c(this,Fm,"f").stop(),d(this,Fm,void 0,"f"))}produce(e){return a(this,arguments,void 0,(function*({encodings:e,codecOptions:t,preferredCodec:r,transformParams:n,keyFrameRequestDelay:i}){var s,o,a,d,u;if(!c(this,jm,"f").canPublish)throw this.logger.error("produce()",{message:"Not enough access to produce"}),new Pt("not_enough_access",new Error("Not enough access to produce"));if(this.producer)throw new Pt("track_already_produced",new Error("Track already produced"));try{yield c(this,Bm,"f").ensureNoPending(this.getLabel()),yield c(this,Vm,"f").ping();const{rtpCapabilities:{codecs:l}}=c(this,Um,"f").mediasoupDevice,p=null==l?void 0:l.find((e=>e.mimeType.toLowerCase()===`${this.kind}/${r}`)),h=0,f=this.prepareProducerEncodings({codec:p,encodings:null!=e?e:[],maxSpatialLayer:(null!=e?e:[]).length-1}),m={trackTransformParams:n,peerId:String(c(this,jm,"f").id),label:this.getLabel(),maxSpatialLayer:h,encodings:f,codecOptions:t,preferredCodec:r,codec:p,keyFrameRequestDelay:i},g=yield null===(s=c(this,Vm,"f").sendTransport)||void 0===s?void 0:s.produce({track:this.mediaStreamTrack,encodings:f,codecOptions:t,codec:p,stopTracks:!1,disableTrackOnPause:!0,zeroRtpOnPause:!0,appData:m});if(!g)return;const v=g.rtpSender,y=()=>/Safari/i.test(navigator.userAgent);if(e&&v&&y()){const t=v.getParameters();e.forEach((({maxBitrate:e,scaleResolutionDownBy:r},n)=>{t.encodings[n]&&(t.encodings[n].maxBitrate=e,t.encodings[n].scaleResolutionDownBy=r)})),yield v.setParameters(t)}this.setProducer(g),(null===(a=null===(o=this.producer)||void 0===o?void 0:o.track)||void 0===a?void 0:a.id)!==c(this,xm,"f").id&&(this.logger.info("Producer initialized with old track, updating",{oldTrackId:null===(u=null===(d=this.producer)||void 0===d?void 0:d.track)||void 0===u?void 0:u.id,newTrackId:c(this,xm,"f").id}),yield this.replaceTrack(c(this,xm,"f"))),"video"===this.kind&&(e&&v&&p&&Tn(p.mimeType)&&!y()?yield v.setParameters(Object.assign(Object.assign({},v.getParameters()),{encodings:this.prepareProducerEncodings({encodings:e,codec:p,maxSpatialLayer:h})})):yield g.setMaxSpatialLayer(h),yield c(this,Vm,"f").setProducerMaxSpatialLayer(g.id,h)),"audio"===this.kind&&(yield this.setPriority("high")),this.logger.debug("produce()",{track:this.logCtx,encodings:e,codecOptions:t})}catch(e){throw this.logger.error("produce()",{error:e,track:this.logCtx}),new Pt("track_publish_failed",e)}}))}publish(){return a(this,void 0,void 0,(function*(){yield this.produce({}),this.internalEventEmitter.emit(jr,this)}))}unpublish(){return a(this,arguments,void 0,(function*(e=!0){try{e&&this.stopMediaStreamTrack(),this.internalEventEmitter.emit(Ur,this),this.producer&&(yield this.closeProducer()),this.logger.debug("unpublish()",{track:this.logCtx})}catch(e){this.logger.error("unpublish()",{error:e})}}))}pauseRemoteProducer(e){return a(this,void 0,void 0,(function*(){yield c(this,Vm,"f").pauseRemoteProducer(e)}))}resumeRemoteProducer(e){return a(this,void 0,void 0,(function*(){yield c(this,Vm,"f").resumeRemoteProducer(e)}))}mute(e){return a(this,void 0,void 0,(function*(){const t=yield c(this,Ym,"f").lock(fn.Mute);if(!this.producer)return this.logger.warn("pause()",{message:"Track is not published",track:this.logCtx}),void t();try{if(this.producer.pause(),this.logger.debug("pause()",{track:this.logCtx}),c(this,Gm,"f"))return null==e||e(),c(this,xm,"f").stop(),this.stopOriginalTrack(),this.internalEventEmitter.emit(Wr,this),void(yield this.pauseRemoteProducer(this.producer.id));yield this.pauseRemoteProducer(this.producer.id),this.internalEventEmitter.emit(Vr,this)}catch(e){throw this.logger.error("pause()",{error:e,track:this.logCtx}),yield c(this,Um,"f").deleteTrack(this),this.internalEventEmitter.emit(qr,this),new Pt("track_pause_failed",e)}finally{t()}}))}resume(){return a(this,void 0,void 0,(function*(){const e=yield c(this,Ym,"f").lock(fn.Resume);if(!this.producer)return this.logger.warn("resume()",{message:"Track is not published",track:this.logCtx}),void e();try{if(this.logger.debug("resume()",{track:this.logCtx}),c(this,Gm,"f"))return yield this.reopenMediaStreamTrack(),yield this.resumeProducer(),void this.internalEventEmitter.emit(Hr,this);yield this.resumeProducer(),this.internalEventEmitter.emit(Br,this)}catch(e){throw this.logger.error("resume()",{error:e,track:this.logCtx}),new Pt("track_resume_failed",e)}finally{e()}}))}getInfo(){return a(this,void 0,void 0,(function*(){const{width:e,height:t,frameRate:r,aspectRatio:n}=c(this,xm,"f").getSettings();return{trackId:c(this,xm,"f").id,readyState:c(this,xm,"f").readyState,kind:this.kind,label:this.label,width:e,height:t,frameRate:r,aspectRatio:n,paused:this.isPaused,trackOutboundStats:yield this.getStats()}}))}getStats(){return a(this,void 0,void 0,(function*(){var e,t,r,n,i;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=>Nm(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){return a(this,void 0,void 0,(function*(){var t;try{d(this,xm,e,"f"),this.internalEventEmitter.emit(Hr,this),this.observer.safeEmit("track-changed",{track:e}),yield null===(t=this.producer)||void 0===t?void 0:t.replaceTrack({track:e}),d(this,$m,new Km({track:e,statsHandler:c(this,Jm,"f")}),"f")}catch(e){this.logger.warn("replaceTrack()",{error:e})}}))}resumeProducer(){return a(this,void 0,void 0,(function*(){this.producer?(yield this.resumeRemoteProducer(this.producer.id),this.producer.resume()):this.logger.debug("resumeProducer()",{message:"Track not produced yet",track:this.logCtx})}))}reopenMediaStreamTrack(){return a(this,void 0,void 0,(function*(){var e;const t=yield c(this,qm,"f").createMediaStreamTrack({label:this.label,constraints:c(this,Hm,"f")});d(this,xm,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&&Tn(r.mimeType)?[t[n]||t[0]]:t}getOutboundRTPStreamStats(){return a(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{const r=(...n)=>a(this,[...n],void 0,(function*(n=0){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((()=>a(this,void 0,void 0,(function*(){return yield 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().catch((e=>{this.logger.debug("Error executing getRTCStatsReport",{case:"DefaultBaseTrack",error:Ct(e)})}))}))}))}}var Zm,Xm,eg,tg;xm=new WeakMap,Fm=new WeakMap,jm=new WeakMap,Um=new WeakMap,Vm=new WeakMap,Bm=new WeakMap,Wm=new WeakMap,Hm=new WeakMap,qm=new WeakMap,zm=new WeakMap,Gm=new WeakMap,Ym=new WeakMap,$m=new WeakMap,Jm=new WeakMap;class rg extends Qm{constructor(e){super(e),this.transformParams={},Zm.set(this,void 0),Xm.set(this,void 0),eg.set(this,!1),tg.set(this,(()=>{})),d(this,Xm,e,"f")}get logCtx(){return{label:this.getLabel(),id:this.id,kind:this.kind,producerId:this.producerId,paused:this.isPaused,published:this.isPublished,isEffectsProcessing:this.isEffectsProcessing}}get isEffectsProcessing(){return Boolean(c(this,Zm,"f"))}getEncoderConfig(){return this.encoderConfig}getCodecOptions(){var e;return{videoGoogleStartBitrate:null!==(e=this.getEncoderConfig().videoGoogleStartBitrate)&&void 0!==e?e:1e3}}getPreferredCodec(){const{preferredCodec:e}=this.getEncoderConfig();return e||(this.getLabel()===Nn.ScreenVideo?"vp8":"h264")}getEncodings(){var e;return null!==(e=this.getEncoderConfig().encodings)&&void 0!==e?e:Sc}setTransformParams(e){this.transformParams=e}setMaxSpatialLayer(e){return a(this,void 0,void 0,(function*(){const t=this.getProducer();t?(yield t.setMaxSpatialLayer(e),this.logger.debug("setMaxSpatialLayer()",{label:this.getLabel(),spatialLayer:e})):this.logger.warn("setMaxSpatialLayer()",{message:"Not produced yet"})}))}getMaxSpatialLayer(){const e=this.getProducer();if(e)return e.maxSpatialLayer;this.logger.warn("getMaxSpatialLayer()",{message:"Not produced yet"})}enableEffects(){return a(this,void 0,void 0,(function*(){if(!c(this,eg,"f")){d(this,eg,!0,"f");try{if(c(this,Zm,"f"))return this.logger.debug("enableEffects()",{description:"Track is already processed"}),void d(this,eg,!1,"f");if("ended"===this.mediaStreamTrack.readyState)return void this.logger.warn("Track already ended",{case:"enableEffects"});const{media:e}=c(this,Xm,"f");if(!e.effectsSDKInitialized)return void this.logger.warn("Effects SDK not initialized",{case:"enableEffects"});const t=Date.now();d(this,Zm,yield e.createEffectsSDKTrackProcessor(this.getLabel()),"f"),this.setOriginalTrack();const r=c(this,Zm,"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:Ct(e)}),this.disableEffects().catch((e=>{this.logger.warn("Failed to this.disableEffects() in catch{}",{track:this.logCtx,error:Ct(e)})})),c(this,tg,"f").call(this,e)}finally{d(this,eg,!1,"f")}}}))}disableEffects(){return a(this,void 0,void 0,(function*(){var e;try{if(!c(this,Zm,"f"))return void this.logger.debug("disableEffects()",{description:"Track is not processed"});this.originalTrack?yield this.replaceTrack(this.originalTrack):this.logger.warn("disableEffects()",{description:"Original track missing"}),null===(e=c(this,Zm,"f"))||void 0===e||e.stopProcessing(),d(this,Zm,void 0,"f"),this.logger.info("disableEffects()",{track:this.logCtx})}catch(e){this.logger.warn("disableEffects()",{track:this.logCtx,error:e})}}))}publish(){return a(this,arguments,void 0,(function*(e={}){var t;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(jr,this)}))}adjustEncodingPresetToCurrentMaxSpatialLayer(e){return a(this,void 0,void 0,(function*(){var t;if(!Tn(this.getPreferredCodec()))return;const{rtpSender:r}=null!==(t=this.getProducer())&&void 0!==t?t:{};if(!r)return void this.logger.warn("No rtpSender found in producer to change encodings",{maxSpatialLayer:e,trackId:this.id,producerId:this.producerId});const{encodings:n=[]}=this.getEncoderConfig(),i=n[e];if(!i)return void this.logger.warn("Skipping RTPSender params update. No target encoding found",{initialEncodings:n});this.logger.debug("Adjusting encoding parameters to max spatial layer",{targetEncoding:i,maxSpatialLayer:e});const s=r.getParameters();yield r.setParameters(Object.assign(Object.assign({},s),{encodings:[Object.assign(Object.assign({},s.encodings[0]),i)]}))}))}applyEffects(e){return a(this,void 0,void 0,(function*(){var t;try{!this.isEffectsProcessing&&Object.keys(e).length>0&&(yield this.enableEffects()),null===(t=c(this,Zm,"f"))||void 0===t||t.updateEffects(e)}catch(e){c(this,tg,"f").call(this,e)}}))}resetEffects(){var e;null===(e=c(this,Zm,"f"))||void 0===e||e.updateEffects({})}setOnLoadModels(e){var t;null===(t=c(this,Zm,"f"))||void 0===t||t.setOnLoadModels(e)}get modelsLoadProgress(){var e,t;return null!==(t=null===(e=c(this,Zm,"f"))||void 0===e?void 0:e.modelsLoadProgress)&&void 0!==t?t:0}pause(){return a(this,void 0,void 0,(function*(){yield this.mute((()=>{var e;c(this,Zm,"f")&&(null===(e=c(this,Zm,"f"))||void 0===e||e.stopProcessing(),d(this,Zm,void 0,"f"))}))}))}setOnEffectError(e){d(this,tg,e,"f")}}var ng,ig;Zm=new WeakMap,Xm=new WeakMap,eg=new WeakMap,tg=new WeakMap;let sg=ig=class{constructor(e){ng.set(this,void 0),d(this,ng,e("MediaStreamTrackManager"),"f")}createMediaStreamTrack(e){return a(this,arguments,void 0,(function*({label:e,constraints:t}){if(ig.isDisplayMedia(e)){const[e]=yield this.createDisplayMediaTracks(t);return e}const[r]=yield this.createUserMediaTracks(t);return r}))}static isDisplayMedia(e){return[Nn.ScreenVideo,Nn.ScreenAudio].includes(e)}createUserMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getUserMedia(e);return c(this,ng,"f").debug("createUserMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}createDisplayMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getDisplayMedia(e);return c(this,ng,"f").debug("getDisplayMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}};ng=new WeakMap,sg=ig=i([at(),s(0,dt(On.LoggerFactory)),o("design:paramtypes",[Function])],sg);var og,ag,cg,dg,ug,lg,pg,hg=sg;let fg=class{constructor(e,t,r,n,i,s,o,a,c){this.config=e,this.loggerFactory=t,this.audioTrackFactory=r,this.clientEventEmitter=n,this.integrationsService=i,this.processorsCache=s,this.videoTrackFactory=o,this.mediaStreamTrackManager=a,this.signalingApiClient=c,this.isDeviceLoaded=!1,this.tracks=new Map,og.set(this,void 0),ag.set(this,null),cg.set(this,!1),dg.set(this,new Map),ug.set(this,!1),lg.set(this,!1),pg.set(this,void 0);const u=this.config.get("effectsSDKParams");d(this,pg,this.config.get("denoiser"),"f"),d(this,og,this.loggerFactory("Media"),"f"),d(this,ag,null!=u?u:null,"f")}get mediasoupDevice(){var e;return null!==(e=this.device)&&void 0!==e||(this.device=this.createDevice()),this.device}get effectsSDKInitialized(){return c(this,cg,"f")}get effectsSDKParams(){return c(this,ag,"f")}getTrack(e){return this.tracks.get(e)}loadDevice(e){return a(this,void 0,void 0,(function*(){this.isDeviceLoaded||(yield this.mediasoupDevice.load({routerRtpCapabilities:e}),this.isDeviceLoaded=!0)}))}getTrackCodec(e){const{rtpCapabilities:t,rtpCapabilities:{codecs:r}}=this.mediasoupDevice;if(r)return r.find((t=>t.mimeType.toLowerCase()===`${e.kind}/${e.getPreferredCodec()}`));c(this,og,"f").error("getTrackCodec()",{label:e.getLabel,rtpCapabilities:t})}createTracks({constraints:e,mediaStreamTracks:t}){return t.map((t=>{const r={mediaStreamTrack:t,constraints:e};let n;return n="audio"===t.kind?this.audioTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"AudioTrack"})):this.videoTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"VideoTrack"})),c(this,og,"f").debug("createTrack() track created",{trackId:n.id,kind:n.kind}),n}))}createUserMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createUserMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}createDisplayMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createDisplayMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}createCustomMediaTrack(e,t){return this.createTracks({constraints:t,mediaStreamTracks:[e]})[0]}deleteTrack(e){return a(this,void 0,void 0,(function*(){const t={trackId:e.id,label:e.getLabel(),producerId:e.producerId};try{"disableNoiseSuppression"in e&&(yield e.disableNoiseSuppression()),"disableEffects"in e&&(yield e.disableEffects())}catch(e){c(this,og,"f").warn("deleteTrack()",Object.assign({error:e},t))}try{this.tracks.delete(e.getLabel()),e.stopMediaStreamTrack(),yield e.closeProducer()}catch(e){c(this,og,"f").error("deleteTrack()",{error:e})}finally{c(this,og,"f").debug("deleteTrack()",t)}}))}getAllTracks(){return Array.from(this.tracks.values())}publishedTracks(){return this.getAllTracks().filter((e=>e.isPublished))}clearTracks(){try{this.getAllTracks().forEach((e=>e.stopMediaStreamTrack()))}catch(e){c(this,og,"f").warn("clearTracks()",{error:e})}finally{this.tracks.clear()}}unpublishTracks(){return a(this,void 0,void 0,(function*(){try{yield Promise.all(this.publishedTracks().map((e=>a(this,void 0,void 0,(function*(){return yield e.unpublish(!1)})))))}catch(e){c(this,og,"f").warn("unpublishTracks()",{error:e})}}))}setTrack(e){this.tracks.set(e.getLabel(),e)}initEffectsSDK(){return a(this,void 0,void 0,(function*(){if(c(this,cg,"f"))return!0;if(!c(this,ag,"f"))throw c(this,og,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Pt("effects_sdk_config_missing",new Error("Effects SDK config not provided"));const e=(e,t)=>a(this,void 0,void 0,(function*(){if(!window.tsvb)return c(this,og,"f").info("Effects SDK not loaded, skipping initialization",{case:"initEffectsSDK"}),void e(!1);c(this,og,"f").info("Effects SDK initializing",{case:"initEffectsSDK"});try{c(this,dg,"f").set(Nn.Camera,yield this.createEffectsSDKTrackProcessor(Nn.Camera)),c(this,dg,"f").set(Nn.CameraPreview,yield this.createEffectsSDKTrackProcessor(Nn.CameraPreview)),d(this,cg,!0,"f"),c(this,og,"f").info("Effects SDK initialized",{case:"initEffectsSDK"}),e(!0)}catch(e){c(this,og,"f").error("Failed to initialize Effects SDK",{error:e,case:"initEffectsSDK"}),t(e)}}));return yield new Promise(((t,r)=>{if(!window.tsvb)return c(this,og,"f").info("Effects SDK tsvb-web.js is not ready, waiting",{case:"initEffectsSDK"}),void window.addEventListener("load",(()=>a(this,void 0,void 0,(function*(){return yield e(t,r)}))));e(t,r).catch((e=>{c(this,og,"f").error("Failed to execute init() in initEffectsSDK",{error:Ct(e)})}))}))}))}initDenoiser(e,t){return a(this,void 0,void 0,(function*(){if(!c(this,ug,"f"))try{d(this,ug,!0,"f"),this.clientEventEmitter.emit(Ar,!0);try{yield this.integrationsService.audio.waitForInitialization}catch(e){"asdk"===c(this,pg,"f")&&(d(this,lg,!0,"f"),d(this,pg,"rnnoise","f"),this.config.set("denoiser",c(this,pg,"f")),c(this,og,"f").debug("Set config to rnnoise denoiser",{case:"Denoiser",error:Ct(e),type:this.config.get("denoiser")}),this.clientEventEmitter.emit(Lr),this.integrationsService.init(),yield this.integrationsService.audio.waitForInitialization)}c(this,og,"f").debug("Denoiser initialized, activating",{case:"Denoiser",type:this.integrationsService.audio.type,trackLabel:e.getLabel()});const r=e,n=this.processorsCache.get(c(this,pg,"f"),Nn.Microphone);if(!n)return void c(this,og,"f").error("No cached trackProcessor found",{case:"Denoiser",trackLabel:e.getLabel(),type:this.integrationsService.audio.type});"asdk"===n.type&&n.setOnError(((r,n)=>{this.clientEventEmitter.emit(Ar,!0),this.fallbackToRNoise(e,{reason:r,options:t,error:n}).catch((t=>{c(this,og,"f").error("Failed to fallback to RNNoise through onError",{case:"Denoiser",type:c(this,pg,"f"),error:Ct(t),label:e.getLabel()})})).then((()=>{this.clientEventEmitter.emit(Ar,!1)})).catch((()=>{}))})),r.setTrackProcessor(n),c(this,og,"f").debug("Denoiser trackProcessor set, check if activation is needed",{case:"Denoiser",type:c(this,pg,"f"),shouldEnableDenoiser:null==t?void 0:t.noiseSuppression,trackLabel:e.getLabel()}),(null==t?void 0:t.noiseSuppression)&&(yield e.enableNoiseSuppression())}catch(r){if(c(this,og,"f").warn("Failed to start noise suppression, featured original track",{case:"Denoiser",type:c(this,pg,"f"),error:Ct(r),label:e.getLabel()}),"asdk"===c(this,pg,"f"))try{c(this,og,"f").warn("Fallback to RNNoise",{error:Ct(r)}),yield this.fallbackToRNoise(e,{options:t,reason:"ASDK init error",error:r})}catch(t){c(this,og,"f").error("Failed to fallback to RNNoise through catch",{case:"Denoiser",type:c(this,pg,"f"),error:Ct(t),label:e.getLabel()})}}finally{this.clientEventEmitter.emit(Ar,!1),d(this,ug,!1,"f")}}))}fallbackToRNoise(e,t){return a(this,void 0,void 0,(function*(){var r;if(c(this,lg,"f"))return;if(d(this,lg,!0,"f"),"rnnoise"===c(this,pg,"f"))return;this.clientEventEmitter.emit(Lr),c(this,og,"f").info("Fallback to RNNoise",{reason:null==t?void 0:t.reason,error:Ct(null==t?void 0:t.error),case:"Denoiser"});const n=e;yield n.disableNoiseSuppression(),n.unsetTrackProcessor(),d(this,pg,"rnnoise","f"),this.config.set("denoiser",c(this,pg,"f")),c(this,og,"f").debug("Set config to rnnoise denoiser",{case:"Denoiser",type:this.config.get("denoiser")}),this.integrationsService.init(),yield this.integrationsService.audio.waitForInitialization;const i=this.processorsCache.get(c(this,pg,"f"),Nn.Microphone);i?(n.setTrackProcessor(i),(null===(r=null==t?void 0:t.options)||void 0===r?void 0:r.noiseSuppression)&&(yield n.enableNoiseSuppression())):c(this,og,"f").error("No cached trackProcessor found",{case:"Denoiser",trackLabel:e.getLabel(),type:this.integrationsService.audio.type})}))}createEffectsSDKTrackProcessor(e){return a(this,void 0,void 0,(function*(){var t,r,n;if(e){const t=c(this,dg,"f").get(e);if(t)return t}if(!c(this,ag,"f"))throw c(this,og,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Pt("effects_sdk_config_missing",new Error("Effects SDK config not provided"));const i=new Om({loggerFactory:this.loggerFactory,customerId:null===(t=this.config.get("effectsSDKParams"))||void 0===t?void 0:t.customerId,sdk_url:null===(r=this.config.get("effectsSDKParams"))||void 0===r?void 0:r.sdk_url,api_url:null===(n=this.config.get("effectsSDKParams"))||void 0===n?void 0:n.api_url,config:this.config});return yield i.init(),c(this,og,"f").info("Track effects processor initialized",{trackLabel:e}),i}))}handleProducerSetMaxSpatialLayer(e){return a(this,arguments,void 0,(function*({producerId:e,spatialLayer:t}){const r=this.getAllTracks().find((t=>{var r;return(null===(r=t.getProducer())||void 0===r?void 0:r.id)===e}));if(!r)return void c(this,og,"f").warn("producerRequestMaxSpatialLayer()",{message:"Producer not found"});if(!(r instanceof rg))return void c(this,og,"f").warn("producerRequestMaxSpatialLayer()",{message:"Wrong producer kind"});const n=null!=t?t:um,i=r.getMaxSpatialLayer();i!==n?(r.getEncodings().length>1&&(yield r.setMaxSpatialLayer(n)),yield this.signalingApiClient.producer.setProducerMaxSpatialLayer(e,{maxSpatialLayer:n}),yield r.adjustEncodingPresetToCurrentMaxSpatialLayer(n)):c(this,og,"f").debug("producerRequestMaxSpatialLayer()",{message:"Skip set max spatial layer",requestedSpatialLayer:n,currentMaxSpatialLayer:i})}))}static getVideoTrackTransformParams(e){var t,r;const n=e.getSettings();return{width:null!==(t=n.width)&&void 0!==t?t:dm.width,height:null!==(r=n.height)&&void 0!==r?r:dm.height}}static getScreenVideoTrackParams(e){var t,r;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:20},width:{max:dm.width},height:{max:dm.height}},encoderConfig:null!==(r=null==e?void 0:e.videoEncoderConfig)&&void 0!==r?r:{encodings:Cc}}}static getCameraVideoTrackParams(e){var t,r;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:24},width:{max:dm.width},height:{max:dm.height}},encoderConfig:null!==(r=null==e?void 0:e.encoderConfig)&&void 0!==r?r:{encodings:Sc}}}createDevice(){const e=(e=>{const t=null!=e?e:null===navigator||void 0===navigator?void 0:navigator.userAgent;if(!t)return;const r=bn.getParser(t);return r.satisfies({"yandex browser":">=25"})&&"iOS"===r.getOSName()?void 0:r.satisfies({"yandex browser":">=23.7"})?"Chrome111":r.satisfies({"yandex browser":">=22"})?"Chrome74":r.satisfies({"Samsung Internet for Android":">=17"})?"Chrome111":void 0})();return c(this,og,"f").debug("Creating a media device",{handlerName:null!=e?e:"not specified"}),new ld.Device({handlerName:e})}};og=new WeakMap,ag=new WeakMap,cg=new WeakMap,dg=new WeakMap,ug=new WeakMap,lg=new WeakMap,pg=new WeakMap,fg=i([at(),s(0,dt(On.Config)),s(1,dt(On.LoggerFactory)),s(2,dt(On.AudioTrackFactory)),s(3,dt(On.ClientEventEmitter)),s(4,dt(On.IntegrationsService)),s(5,dt(On.ProcessorsCache)),s(6,dt(On.VideoTrackFactory)),s(7,dt(On.MediaStreamTrackManager)),s(8,dt(On.SignalingApiClient)),o("design:paramtypes",[bt,Function,Function,Et,wm,_m,Function,hg,gc])],fg);var mg=fg;const gg={[Ri.PRODUCER_KIND_VIDEO]:"video",[Ri.PRODUCER_KIND_AUDIO]:"audio"},vg={[Ai.PEER_ROLE_HOST]:"host",[Ai.PEER_ROLE_AUDIENCE]:"audience"},yg={[yi.PRODUCER_LABEL_CAMERA]:Nn.Camera,[yi.PRODUCER_LABEL_MICROPHONE]:Nn.Microphone,[yi.PRODUCER_LABEL_SCREEN_VIDEO]:Nn.ScreenVideo,[yi.PRODUCER_LABEL_SCREEN_AUDIO]:Nn.ScreenAudio,[yi.PRODUCER_LABEL_CUSTOM_VIDEO]:Nn.CustomVideo,[yi.PRODUCER_LABEL_CUSTOM_AUDIO]:Nn.CustomAudio,[yi.PRODUCER_LABEL_UNKNOWN]:Nn.Unknown,[yi.PRODUCER_LABEL_UNSPECIFIED]:Nn.Unknown},_g={[vi.PEER_GROUP_MODERATOR]:"moderator",[vi.PEER_GROUP_USER]:"user"},bg=e=>{const t=gg[e];if(!t)throw new Error(`Unknown producer kind: ${e}`);return t},Eg=e=>{const t=_g[e];if(!t)throw new Error(`Unknown peer group: ${e}`);return t},wg=e=>{const t=yg[e];if(!t)throw new Error(`Unknown producer label: ${e}`);return t},Sg=e=>{const t=vg[e];if(!t)throw new Error(`Unknown peer role: ${e}`);return t},Cg=e=>({id:e.id,channelIds:e.channelIds,groups:e.groups.map(Eg),producePermissions:e.producePermissions.map(wg),appId:e.appId,producers:e.producers.map(Pg),uid:e.uid,appData:e.appData,role:Sg(e.role),loginDate:e.loginDate}),Pg=e=>{var t;return{id:e.id,kind:bg(e.kind),label:wg(e.label),peerId:e.peerId,paused:e.paused,encodings:e.encodings,maxSpatialLayer:null!==(t=e.maxSpatialLayer)&&void 0!==t?t:0}},Tg=e=>{switch(e){case"moderator":return vi.PEER_GROUP_MODERATOR;case"user":return vi.PEER_GROUP_USER;default:return vi.PEER_GROUP_UNSPECIFIED}};var Rg;let kg=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,Rg.set(this,void 0),d(this,Rg,o("ChannelStateSyncEventHandler"),"f"),this.debouncedTriggerChannelStateEvent=Sn(this.triggerChannelStateEvent.bind(this),3e3),this.watchNetworkState()}handleChannelStateEvent(e){return a(this,void 0,void 0,(function*(){this.network.peersLoaded?yield this.restoreState(e):this.loadChannelState(e),this.clientEventEmitter.emit(Or)}))}watchNetworkState(){this.clientEventEmitter.on(Ir,(()=>{this.debouncedTriggerChannelStateEvent()}))}triggerChannelStateEvent(){return a(this,void 0,void 0,(function*(){const e=()=>a(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>a(this,void 0,void 0,(function*(){const r=yield this.network.triggerChannelStateEvent("host"),n=setTimeout((()=>{this.eventsQueue.isMessageReceived(r)?(c(this,Rg,"f").info("Channel state event received",{case:"ChannelStateSynchronizer.triggerChannelStateEvent"}),e()):t(new Error("Channel state event not received"))}),5e3),i=()=>{clearTimeout(n),this.clientEventEmitter.off(Dr,i),e()};this.clientEventEmitter.on(Dr,i)}))))}));try{yield An(e,{maxRetries:5,actionName:"triggerChannelStateEventWithRetry",logger:c(this,Rg,"f")})}catch(e){c(this,Rg,"f").warn("Failed to trigger channel state event",{case:"ChannelStateSynchronizer.triggerChannelStateEvent",error:Ct(e)})}}))}loadChannelState(e){c(this,Rg,"f").info("Loading channel state",{case:"loadChannelState"});try{const t=this.peers.hosts().map((e=>e.shortData)),r=e.peers.filter((e=>e.role===Ai.PEER_ROLE_HOST));this.setMissingPeers(t,r),this.restoreLocalPeersState(r),this.network.peersLoaded=!0}catch(e){c(this,Rg,"f").error("Failed to load channel state",{case:"loadState",error:Ct(e)})}}restoreState(e){return a(this,void 0,void 0,(function*(){const{peers:t}=e,r={missingPeers:[],removedPeers:[],missingProducers:[],removedProducers:[],fixedProducersState:[],fixedConsumersState:[],restoredAppDataPeers:[]};try{if(!this.network.isNetworkActive)return c(this,Rg,"f").info("Connection inactive, skipping restore local state",{case:"restoreLocalState"}),r;c(this,Rg,"f").info("Restoring local state",{case:"restoreLocalState"});const e=this.peers.hosts().map((e=>e.shortData)),n=t.filter((e=>e.role===Ai.PEER_ROLE_HOST)),{removedProducers:i,fixedProducersState:s}=yield this.restoreRemoteProducersState(n);r.fixedProducersState.push(...s),r.removedProducers.push(...i),r.removedPeers.push(...this.removeUnnecessaryPeers(e,n)),r.missingPeers.push(...this.setMissingPeers(e,n));const o=this.restoreLocalPeersState(n);return r.missingProducers.push(...o.missingProducers),r.removedProducers.push(...o.removedProducers),r.restoredAppDataPeers.push(...o.restoredAppDataPeers),r.fixedProducersState.push(...o.fixedProducersState),r.fixedConsumersState.push(...o.fixedConsumersState),r}catch(e){return c(this,Rg,"f").info("Failed to restore local state",{case:"restoreLocalState",error:Ct(e)}),r}}))}restoreRemoteProducersState(e){return a(this,void 0,void 0,(function*(){const t={removedProducers:[],fixedProducersState:[]},r=this.myPeer.get(),n=e.find((e=>e.id===this.myPeer.id));if(!r||!n)return t;const i=new Map;this.media.getAllTracks().forEach((e=>{e.producerId&&i.set(e.producerId,e)}));const s=new Set(i.keys()),o=n.producers.filter((e=>!s.has(e.id)));yield Promise.all(o.map((e=>a(this,void 0,void 0,(function*(){yield this.network.closeRemoteProducer(e.id),r.producers.delete(e.id),t.removedProducers.push(e.id),c(this,Rg,"f").info("Unnecessary local producer closed",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId})})))));const d=[];for(const e of n.producers){const t=i.get(e.id);t&&(t.isPaused!==e.paused&&d.push({cp:e,localTrack:t}))}return yield Promise.all(d.map((e=>a(this,[e],void 0,(function*({cp:e,localTrack:r}){r.isPaused?yield this.network.pauseRemoteProducer(e.id):yield this.network.resumeRemoteProducer(e.id),t.fixedProducersState.push(e.id),e.paused=r.isPaused,c(this,Rg,"f").info("Remote producer state repaired",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId,paused:r.isPaused})}))))),t}))}removeUnnecessaryPeers(e,t){const r=[];return e.filter((e=>!t.find((t=>t.id===e.id)))).forEach((e=>{this.peers.remove(e.id).catch((e=>{c(this,Rg,"f").error("Failed to remove peer",{error:Ct(e)})})),r.push(e.id),c(this,Rg,"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(Cg(t));r.push(n.id),c(this,Rg,"f").info("Missing peer added to storage",{case:"restoreLocalState",peerId:t.id})})),r}restoreLocalPeersState(e){const t=new Map(e.map((e=>[e.id,e]))),r=this.peers.hosts(),n={removedProducers:[],missingProducers:[],restoredAppDataPeers:[],fixedConsumersState:[],fixedProducersState:[]};return r.forEach((e=>{const r=t.get(e.id);if(!r)return void c(this,Rg,"f").warn("Found new local peer, skip restoring state",{case:"restoreLocalState",newPeerId:e.id});n.removedProducers.push(...this.removeUnnecessaryProducers(e,r));this.restoreAppData(e,r)&&n.restoredAppDataPeers.push(e.id);const{fixedProducersState:i,fixedConsumersState:s,missingProducers:o}=this.restoreTracksState(e,r);n.fixedProducersState.push(...i),n.fixedConsumersState.push(...s),n.missingProducers.push(...o)})),c(this,Rg,"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(sn,t),r.push(t.id),c(this,Rg,"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(nn,Pg(t)),r.missingProducers.push(t.id),void c(this,Rg,"f").info("Missing producer added to storage",{case:"restoreLocalState",producerId:t.id,producerPeerId:t.peerId});const{paused:s}=t;if(i.paused!==s){i.setPaused(s);const n=i.paused?Yr:$r;e.observer.safeEmit(n,{producerId:i.id,kind:i.kind,label:i.label,paused:i.paused}),r.fixedProducersState.push(t.id),c(this,Rg,"f").info("Producer state fixed",{case:"restoreLocalState",producerId:t.id,producerPeerId:t.peerId})}const o=e.tracks.get(i.label);if((null==o?void 0:o.consumerId)&&(null===(n=o.consumer)||void 0===n?void 0:n.paused)!==t.paused){const{consumerId:n}=o,s=i.paused?dn:un;e.observer.safeEmit(s,n),r.fixedConsumersState.push(n),c(this,Rg,"f").info("Consumer state fixed",{case:"restoreLocalState",consumerId:n,consumerProducerId:t.id,consumerProducerPeerId:t.peerId})}})),r}restoreAppData(e,t){return!wn(e.appData,t.appData)&&(e.observer.emit(mr,t.appData),c(this,Rg,"f").info("Application data restored",{case:"restoreLocalState",peerId:e.id,appData:t.appData}),!0)}};Rg=new WeakMap,kg=i([at(),s(0,dt(On.Network)),s(1,dt(On.Media)),s(2,dt(On.MyPeer)),s(3,dt(On.EventsQueue)),s(4,dt(On.ClientEventEmitter)),s(5,dt(On.Peers)),s(6,dt(On.LoggerFactory)),o("design:paramtypes",[Jc,mg,ws,bs,Et,Kc,Function])],kg);var Dg,Ig=kg;let Ag=class{constructor(e,t,r,n,i){this.peers=e,this.clientEventEmitter=t,this.channelStateSyncEventHandler=n,this.channelStateSynchronizer=i,Dg.set(this,void 0),d(this,Dg,r("ChannelEvents"),"f")}handleChannelEvent(e){return a(this,void 0,void 0,(function*(){switch(e.eventType){case Hi.CHANNEL_EVENT_TYPE_CHANNEL_STATE:yield this.handleChannelState(e);break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT:this.handleChannelStateShort(e);break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT:this.handleChannelManagementEvent(e);break;case Hi.CHANNEL_EVENT_TYPE_PEER_JOINED:this.handlePeerJoined(e);break;case Hi.CHANNEL_EVENT_TYPE_PEER_LEFT:this.handlePeerLeft(e);break;case Hi.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED:this.handlePeerAppDataChanged(e);break;case Hi.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED:this.handlePeerGroupsChanged(e);break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED:this.handleChannelActivityConfirmationAcquired();break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED:this.handleChannelActivityConfirmationExpired();break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED:this.handleChannelActivityConfirmationRequired(e);break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED:this.handleChannelProducePermissionsChanged(e);break;case Hi.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED:this.handlePeerProducePermissionsChanged(e);break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED:this.handleChannelProducePermissionsDeleted(e);break;default:throw new Error(`Unsupported event type: ${e.eventType}`)}}))}handleChannelManagementEvent(e){if(!e.channelManagementEvent)throw new Error("Missing channelManagementEvent in CHANNEL_MANAGEMENT_EVENT");const t=e.channelManagementEvent.event;this.clientEventEmitter.safeEmit(gr,t),c(this,Dg,"f").debug("New channel event",{event:t})}handlePeerJoined(e){if(!e.peer)throw new Error("Missing peer in PEER_APP_DATA_CHANGED event");const t=this.peers.add(Cg(e.peer));c(this,Dg,"f").debug("Peer joined to the channel",{peer:Es(t)})}handlePeerLeft(e){if(!e.peer)throw new Error("Missing peer in PEER_LEFT event");this.peers.remove(e.peer.id).catch((e=>{c(this,Dg,"f").debug("Failed to remove peer",{error:Ct(e)})})),c(this,Dg,"f").debug("Peer left the channel",{peerId:e.peer.id})}handleChannelState(e){return a(this,void 0,void 0,(function*(){if(!e.channelState)throw new Error("Missing channelState in CHANNEL_STATE event");try{yield this.channelStateSynchronizer.handleChannelStateEvent(e.channelState)}catch(e){c(this,Dg,"f").error("Failed to restore channel state",{case:"restoreLocalState",error:Ct(e)})}}))}handleChannelStateShort(e){if(!e.channelStateShort)throw new Error("Missing channelStateShort in CHANNEL_STATE_SHORT event");this.channelStateSyncEventHandler.handleChannelStateShort(e.channelStateShort).catch((e=>{c(this,Dg,"f").error("Failed to handle channel state short event",{error:Ct(e)})}))}handlePeerAppDataChanged(e){if(!e.peer)throw new Error("Missing peer in PEER_APP_DATA_CHANGED event");const t=this.peers.get(e.peer.id);t&&t.observer.emit(mr,e.peer.appData)}handlePeerGroupsChanged(e){if(!e.peer)throw new Error("Missing peer in PEER_GROUP_CHANGED event");const t=this.peers.get(e.peer.id);null==t||t.handleGroupsChange(e.peer.groups.map(Eg))}handleChannelActivityConfirmationExpired(){this.clientEventEmitter.safeEmit(Er),c(this,Dg,"f").info("Notify the channel that it has disconnected due to the activity confirmation expiring",{})}handleChannelActivityConfirmationAcquired(){this.clientEventEmitter.safeEmit(br),c(this,Dg,"f").info("Notify the channel that the activity has been acquired.",{})}handleChannelActivityConfirmationRequired(e){if(!e.channelActivityConfirmationTime)throw new Error("Missing channelActivityConfirmationTime in CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED event");const t=e.channelActivityConfirmationTime;this.clientEventEmitter.safeEmit(_r,t),c(this,Dg,"f").info("Notify the channel that activity confirmation is required",{event:e.channelActivityConfirmationTime})}handleChannelProducePermissionsChanged(e){if(!e.channelProducePermissions)throw new Error("Missing channelProducePermissions in CHANNEL_PRODUCE_PERMISSIONS_CHANGED event");const{groups:t}=e.channelProducePermissions,r=this.peers.all().filter((e=>e.groups.some((e=>t.includes(Tg(e)))))),n=e.channelProducePermissions.producePermissions.map(wg),i=e.channelProducePermissions.changedProducePermissions.map(wg);r.forEach((e=>{const t=Array.from(new Set([...e.producePermissions,...i])).filter((e=>!i.includes(e)||n.includes(e)));e.handleProducePermissionsChange(t)})),c(this,Dg,"f").info("Peers changed produce permissions",{groups:t,producePermissions:n})}handlePeerProducePermissionsChanged(e){if(!e.peer)throw new Error("Missing peer in PEER_PRODUCE_PERMISSIONS_CHANGED event");const t=this.peers.get(e.peer.id);if(!t)return;const r=e.peer.producePermissions.map(wg);t.handleProducePermissionsChange(r)}handleChannelProducePermissionsDeleted(e){if(!e.channelProducePermissions)throw new Error("Missing channelProducePermissions in CHANNEL_PRODUCE_PERMISSIONS_DELETED event");const{groups:t}=e.channelProducePermissions,r=this.peers.all().filter((e=>e.groups.some((e=>t.includes(Tg(e)))))),n=e.channelProducePermissions.producePermissions.map(wg);r.forEach((e=>{const t=e.producePermissions.filter((e=>!n.includes(e)));e.handleProducePermissionsChange(t)})),c(this,Dg,"f").info("Peers deleted produce permissions",{groups:t,producePermissions:n})}};Dg=new WeakMap,Ag=i([at(),s(0,dt(On.Peers)),s(1,dt(On.ClientEventEmitter)),s(2,dt(On.LoggerFactory)),s(3,dt(On.ChannelStateSyncEventHandler)),s(4,dt(On.ChannelStateSynchronizer)),o("design:paramtypes",[Kc,Et,Function,ud,Ig])],Ag);var Og=Ag,Ng={},Mg=l&&l.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(Ng,"__esModule",{value:!0});var Lg,xg,Fg=Ng.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 Mg(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 Mg(this,void 0,void 0,(function*(){const e=this.pendingTasks[0];e&&(yield this.executeTask(e),this.pendingTasks.shift(),this.next())}))}executeTask(e){return Mg(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)}}}))}};let jg=class{constructor(e,t,r,n,i){this.media=e,this.internalEventEmitter=t,this.peersStorage=r,this.clientEventEmitter=n,Lg.set(this,new Fg),xg.set(this,void 0),d(this,xg,i("MediaEvents"),"f")}handleMediaEvent(e){var t;switch(e.eventType){case is.MEDIA_EVENT_TYPE_PRODUCER_CREATED:this.handleProducerCreated(e);break;case is.MEDIA_EVENT_TYPE_PRODUCER_CLOSED:this.handleProducerClosed(e);break;case is.MEDIA_EVENT_TYPE_PRODUCER_PAUSED:this.handleProducerPaused(e);break;case is.MEDIA_EVENT_TYPE_PRODUCER_RESUMED:this.handleProducerResumed(e);break;case is.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED:this.handleProducerMaxSpatialLayerChanged(e);break;case is.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED:this.handleProducerRequestMaxSpatialLayer(e).catch((e=>{c(this,xg,"f").error("Failed to handle producer max spatial layer requested event",{error:Ct(e)})}));break;case is.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED:this.handleProducerForciblyClosed(e).catch((e=>{c(this,xg,"f").error("Failed to handle producer forcibly closed event",{error:Ct(e)})}));break;case is.MEDIA_EVENT_TYPE_CONSUMER_CLOSED:c(this,xg,"f").debug("Close consumer event received, skip",{consumerId:null===(t=e.consumer)||void 0===t?void 0:t.id});break;case is.MEDIA_EVENT_TYPE_CONSUMER_RESUMED:this.handleConsumerResumed(e);break;case is.MEDIA_EVENT_TYPE_CONSUMER_PAUSED:this.handleConsumerPaused(e);break;case is.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED:this.handleConsumerPreferredLayersChanged(e);break;case is.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT:this.handleTransportConnectionTimeout(e);break;default:throw new Error(`Unsupported event type: ${e.eventType}`)}}handleProducerCreated(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_CREATED");const t=this.peersStorage.get(e.producer.peerId);null==t||t.observer.safeEmit(nn,Pg(e.producer))}handleProducerClosed(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_CLOSED");const t=this.peersStorage.get(e.producer.peerId);null==t||t.observer.safeEmit(sn,Pg(e.producer))}handleProducerPaused(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_PAUSED");const t=this.peersStorage.get(e.producer.peerId),r=null==t?void 0:t.producers.get(e.producer.id);t?r?(r.setPaused(!0),t.observer.safeEmit(Yr,{producerId:r.id,kind:r.kind,label:r.label,paused:r.paused})):t.observer.safeEmit(nn,Object.assign(Object.assign({},Pg(e.producer)),{paused:!0})):c(this,xg,"f").warn("Peer not found for producer paused event",{peerId:e.producer.peerId})}handleProducerResumed(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_RESUMED");const t=this.peersStorage.get(e.producer.peerId),r=null==t?void 0:t.producers.get(e.producer.id);t?r?(r.setPaused(!1),t.observer.safeEmit($r,{producerId:r.id,kind:r.kind,label:r.label,paused:r.paused})):t.observer.safeEmit(nn,Object.assign(Object.assign({},Pg(e.producer)),{paused:!1})):c(this,xg,"f").warn("Peer not found for producer resumed event",{peerId:e.producer.peerId})}handleProducerMaxSpatialLayerChanged(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED");if(void 0===e.producer.maxSpatialLayer)return;const t=this.peersStorage.get(e.producer.peerId);null==t||t.observer.safeEmit(on,{peerId:e.producer.peerId,producerId:e.producer.id,spatialLayer:e.producer.maxSpatialLayer})}handleProducerRequestMaxSpatialLayer(e){return a(this,void 0,void 0,(function*(){if(!e.producerSpatialLayerRequest)throw new Error("Missing producerSpatialLayerRequest in MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED");const{producerId:t,spatialLayer:r}=e.producerSpatialLayerRequest;yield c(this,Lg,"f").push((()=>a(this,void 0,void 0,(function*(){yield this.media.handleProducerSetMaxSpatialLayer({producerId:t,spatialLayer:r})}))),an)}))}handleProducerForciblyClosed(e){return a(this,void 0,void 0,(function*(){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED");const t=wg(e.producer.label),r=this.media.getTrack(t);if(!r)return;r.stopMediaStreamTrack(),this.internalEventEmitter.safeEmit(Wr,r);const n={label:t};this.clientEventEmitter.emit(Pr,n),yield this.media.deleteTrack(r)}))}handleConsumerResumed(e){if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_RESUMED");const t=this.peersStorage.get(e.consumer.producerPeerId);null==t||t.observer.safeEmit(un,e.consumer.id)}handleConsumerPaused(e){if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_PAUSED");const t=this.peersStorage.get(e.consumer.producerPeerId);null==t||t.observer.safeEmit(dn,e.consumer.id)}handleConsumerPreferredLayersChanged(e){var t;if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED");if(void 0===e.consumer.spatialLayer)return;const r=e.consumer.producerPeerId||e.consumer.peerId,n=this.peersStorage.get(r);null==n||n.observer.safeEmit(ln,{consumerId:e.consumer.id,spatialLayer:e.consumer.spatialLayer,temporalLayer:null!==(t=e.consumer.temporalLayer)&&void 0!==t?t:pm})}handleTransportConnectionTimeout(e){if(!e.transportConnectionTimeout)throw new Error("Missing transportConnectionTimeout in MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT");c(this,xg,"f").warn("Transport connection timed out",{transportId:e.transportConnectionTimeout.transportId,direction:e.transportConnectionTimeout.direction,timeout:e.transportConnectionTimeout.timeout,reason:e.transportConnectionTimeout.reason})}};Lg=new WeakMap,xg=new WeakMap,jg=i([at(),s(0,dt(On.Media)),s(1,dt(On.InternalEventEmitter)),s(2,dt(On.PeersStorage)),s(3,dt(On.ClientEventEmitter)),s(4,dt(On.LoggerFactory)),o("design:paramtypes",[mg,Et,wc,Et,Function])],jg);var Ug,Vg=jg;let Bg=class{constructor(){Ug.set(this,new Map)}set(e,t){c(this,Ug,"f").set(e,{label:e,producerId:t})}get(e){return c(this,Ug,"f").get(e)}has(e){return c(this,Ug,"f").has(e)}delete(e){c(this,Ug,"f").delete(e)}entries(){return Array.from(c(this,Ug,"f").values())}};Ug=new WeakMap,Bg=i([at()],Bg);var Wg,Hg=Bg;let qg=class{constructor(e,t,r){this.network=e,this.storage=t,Wg.set(this,void 0),d(this,Wg,r("ProducerCloseManager"),"f")}close(e,t){return a(this,void 0,void 0,(function*(){try{const r=yield this.sendCloseRequest(t);if(this.storage.delete(e),!r)return;c(this,Wg,"f").info("Remote producer closed",{label:e,producerId:t})}catch(r){this.storage.set(e,t),c(this,Wg,"f").warn("Failed to close remote producer, queued for retry",{label:e,producerId:t,error:Ct(r)})}}))}ensureNoPending(e){return a(this,void 0,void 0,(function*(){const t=this.storage.get(e);t&&(yield this.flushEntry(t))}))}flushPending(){return a(this,void 0,void 0,(function*(){const e=this.storage.entries();for(const t of e)try{yield this.flushEntry(t)}catch(e){}}))}flushEntry(e){return a(this,void 0,void 0,(function*(){try{yield An((()=>a(this,void 0,void 0,(function*(){yield this.sendCloseRequest(e.producerId)}))),{maxRetries:5,minBackoffDelayMs:200,maxBackoffDelayMs:1e3,actionName:"closeRemoteProducer",logger:c(this,Wg,"f")}),this.storage.delete(e.label),c(this,Wg,"f").info("Pending remote producer closed",{label:e.label,producerId:e.producerId})}catch(t){throw c(this,Wg,"f").warn("Failed to close pending remote producer",{label:e.label,producerId:e.producerId,error:Ct(t)}),t}}))}sendCloseRequest(e){return a(this,void 0,void 0,(function*(){try{return yield this.network.closeRemoteProducer(e),!0}catch(t){if(t instanceof ec)return c(this,Wg,"f").debug("Remote producer maybe already closed",{producerId:e}),!1;throw t}}))}};Wg=new WeakMap,qg=i([at(),s(0,dt(On.Network)),s(1,dt(On.PendingClosureProducerStorage)),s(2,dt(On.LoggerFactory)),o("design:paramtypes",[Function,Hg,Function])],qg);var zg,Gg,Yg,$g,Jg,Kg,Qg=qg;const Zg=["send","recv"];let Xg=Kg=class{constructor(e,t){this.network=e,this.loggerFactory=t,zg.set(this,!1),Gg.set(this,new Map),Yg.set(this,new Set),$g.set(this,new Map),Jg.set(this,void 0),this.handleTransportState=({state:e,direction:t})=>{if(!c(this,zg,"f"))return;if(c(this,Yg,"f").has(t))return;if(c(this,$g,"f").has(t))return;if(!["disconnected","failed"].includes(e))return;const r=this.recordDisconnectAndGetCount(t);r&&(r<=3||(c(this,Jg,"f").warn("transport instability detected. Escalating to relay",{direction:t,disconnectCount:r}),this.escalateDirectionToRelay(t).catch((e=>{c(this,Jg,"f").warn("Failed to apply relay policy",{direction:t,error:Ct(e)})}))))},d(this,Jg,this.loggerFactory("NetworkTransportPolicyManager"),"f")}startMonitoring(){c(this,zg,"f")||(this.refreshDirectionRelayState(),c(this,Gg,"f").clear(),d(this,zg,!0,"f"),this.network.observer.on(hn,this.handleTransportState))}stopMonitoring(){c(this,zg,"f")&&(this.network.observer.off(hn,this.handleTransportState),d(this,zg,!1,"f"),c(this,Gg,"f").clear())}changeIceTransportPolicy(e){return a(this,void 0,void 0,(function*(){yield Promise.all(c(this,$g,"f").values()),yield Promise.all(Zg.map((t=>a(this,void 0,void 0,(function*(){return yield this.applyRelayPolicy(t,e)}))))),c(this,Gg,"f").clear(),"all"!==e?this.stopMonitoring():c(this,Yg,"f").clear()}))}recordDisconnectAndGetCount(e){var t;const r=Date.now(),n=null!==(t=c(this,Gg,"f").get(e))&&void 0!==t?t:[],i=n[n.length-1];if(Kg.isDuplicateDisconnect(i,r))return;const s=Kg.getDisconnectsInWindow(n,r);return s.push(r),c(this,Gg,"f").set(e,s),s.length}applyRelayPolicy(e,t){return a(this,void 0,void 0,(function*(){const r=this.getTransportByDirection(e);if(!r)return;const n=Kg.getPeerConnection(r);n&&(n.setConfiguration(Object.assign(Object.assign({},n.getConfiguration()),{iceTransportPolicy:t})),yield this.network.restartIce(r),"relay"===t?c(this,Yg,"f").add(e):c(this,Yg,"f").delete(e))}))}escalateDirectionToRelay(e){return a(this,void 0,void 0,(function*(){if(c(this,Yg,"f").has(e))return;const t=c(this,$g,"f").get(e);if(t)return void(yield t);const r=(()=>a(this,void 0,void 0,(function*(){yield this.applyRelayPolicy(e,"relay"),c(this,Gg,"f").delete(e)})))();c(this,$g,"f").set(e,r);try{yield r}finally{c(this,$g,"f").delete(e)}}))}refreshDirectionRelayState(){Zg.forEach((e=>{const t=this.getTransportByDirection(e),r=Kg.getPeerConnection(t);"relay"!==(null==r?void 0:r.getConfiguration().iceTransportPolicy)?c(this,Yg,"f").delete(e):c(this,Yg,"f").add(e)}))}getTransportByDirection(e){return"send"===e?this.network.sendTransport:this.network.receiveTransport}static getPeerConnection(e){var t;return null===(t=null==e?void 0:e.handler)||void 0===t?void 0:t._pc}static getDisconnectsInWindow(e,t){const r=t-3e4;return e.filter((e=>e>=r))}static isDuplicateDisconnect(e,t){return"number"==typeof e&&t-e<400}};zg=new WeakMap,Gg=new WeakMap,Yg=new WeakMap,$g=new WeakMap,Jg=new WeakMap,Xg=Kg=i([at(),s(0,dt(On.Network)),s(1,dt(On.LoggerFactory)),o("design:paramtypes",[Jc,Function])],Xg);var ev=Xg;const tv=new Error("request for lock canceled");var rv=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){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};class nv{constructor(e,t=tv){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise(((r,n)=>{const i={resolve:r,reject:n,weight:e,priority:t},s=iv(this._queue,(e=>t<=e.priority));-1===s&&e<=this._value?this._dispatchItem(i):this._queue.splice(s+1,0,i)}))}runExclusive(e){return rv(this,arguments,void 0,(function*(e,t=1,r=0){const[n,i]=yield this.acquire(t,r);try{return yield e(n)}finally{i()}}))}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise((r=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),function(e,t){const r=iv(e,(e=>t.priority<=e.priority));e.splice(r+1,0,t)}(this._weightedWaiters[e-1],{resolve:r,priority:t})}))}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach((e=>e.reject(this._cancelError))),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(0===this._queue.length)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach((e=>e.resolve())),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const r=this._weightedWaiters[t-1];if(!r)continue;const n=r.findIndex((t=>t.priority<=e));(-1===n?r:r.splice(0,n)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(0===this._queue.length||this._queue[0].priority<t)&&e<=this._value}}function iv(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1}var sv,ov=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){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};class av{constructor(e){this._semaphore=new nv(1,e)}acquire(){return ov(this,arguments,void 0,(function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t}))}runExclusive(e,t=0){return this._semaphore.runExclusive((()=>e()),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}let cv=class{constructor(){sv.set(this,new Map)}lock(e){return a(this,void 0,void 0,(function*(){let t=c(this,sv,"f").get(e);return t||(t=new av,c(this,sv,"f").set(e,t)),t.isLocked()&&(yield t.waitForUnlock()),yield t.acquire()}))}isLocked(e){const t=c(this,sv,"f").get(e);return!!t&&t.isLocked()}waitForUnlock(e){return a(this,void 0,void 0,(function*(){const t=c(this,sv,"f").get(e);(null==t?void 0:t.isLocked())?yield t.waitForUnlock():yield Promise.resolve()}))}};sv=new WeakMap,cv=i([at()],cv);var dv,uv=cv;let lv=class{constructor(e,t){this.clientEventEmitter=e,this.isEnableVideoDevicesLock=!1,this.isEnableAudioDevicesLock=!1,this.isDevicesDetected=!1,this.availableVideoDevices=[],this.availableAudioDevices=[],dv.set(this,void 0),d(this,dv,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(){return a(this,arguments,void 0,(function*(e={video:!0,audio:!0}){try{return(yield navigator.mediaDevices.getUserMedia(e)).getTracks()}catch(t){c(this,dv,"f").error("getUserMedia()",{error:t,constraints:e});const r=t instanceof Error?t.name:void 0;if("NotAllowedError"===r)throw new Error(Mn.NotAllowedError);if("NotReadableError"===r)throw new Error(Mn.DeviceIsBusy);if("NotFoundError"===r)throw new Error(Mn.NotFoundError);throw new Error(Mn.RequestDevicesUnknownError)}}))}hasAvailableMediaDevicesList(){return a(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices();if(0===e.length)return!0;return e.every((e=>e.deviceId&&e.label))}))}refreshAvailableMediaDevicesList(){return a(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices(),t=[],r=[];e.forEach((e=>{""!==e.deviceId&&("videoinput"===e.kind&&t.push(e),"audioinput"===e.kind&&r.push(e))})),this.setAvailableVideoDevices(t),this.setAvailableAudioDevices(r);const n=({label:e,kind:t})=>({label:e,kind:t});return c(this,dv,"f").debug("Devices list updated",{videoDevices:t.map(n),audioDevices:r.map(n)}),e}))}detectDevices(e){return a(this,void 0,void 0,(function*(){if(this.isDevicesDetected&&!e)return;(yield this.hasAvailableMediaDevicesList())||(yield this.tryToAccessDevices()),this.isDevicesDetected=!0;const t=yield this.refreshAvailableMediaDevicesList(),r=t.some((e=>"audioinput"===e.kind)),n=t.some((e=>"videoinput"===e.kind));if(!r&&!n)throw new Error(Mn.NoDevices)}))}deviceChangeHandler(){return a(this,void 0,void 0,(function*(){if(!this.isDevicesDetected)return;yield this.refreshAvailableMediaDevicesList();const e={audio:this.availableAudioDevices,video:this.availableVideoDevices};this.clientEventEmitter.safeEmit(Sr,e)}))}listenDevices(){navigator.mediaDevices.addEventListener("devicechange",this.deviceChangeHandler)}assertHasAccessToMediaDevices(){return a(this,arguments,void 0,(function*(e={video:!0,audio:!0}){(yield this.requestMediaDevicesAccess(e)).forEach((e=>e.stop()))}))}tryToAccessDevices(){return a(this,void 0,void 0,(function*(){try{(yield this.requestMediaDevicesAccess()).forEach((e=>e.stop()))}catch(t){const r=(e=>{if(e instanceof Error)return e.message;if("string"==typeof e)return e;if(e&&"object"==typeof e&&"message"in e){const t=e.message;return"string"==typeof t?t:void 0}})(t);if(!r||(e=r,![Mn.NotFoundError,Mn.NotAllowedError,Mn.DeviceIsBusy].includes(e)))throw t;r!==Mn.DeviceIsBusy&&(yield this.assertHasAccessToMediaDevices({audio:!0}),yield this.assertHasAccessToMediaDevices({video:!0}))}var e}))}};dv=new WeakMap,lv=i([at(),s(0,dt(On.ClientEventEmitter)),s(1,dt(On.LoggerFactory)),o("design:paramtypes",[Et,Function])],lv);var pv,hv,fv,mv,gv,vv,yv=lv;class _v{constructor({transport:e,statsHandler:t}){pv.set(this,void 0),this.handleWebRTCStats(e,t)}get connectionStats(){return c(this,pv,"f")}handleWebRTCStats(e,t){t.addConnectionHandler(e.id,this.setConnectionStats.bind(this)),e.observer.once("close",(()=>{t.removeConnectionHandler(e.id)}))}setConnectionStats(e){d(this,pv,e,"f")}}pv=new WeakMap;let bv=class{constructor(){hv.set(this,new Map),fv.set(this,new Map),mv.set(this,new Map),gv.set(this,new Map),vv.set(this,new Map)}handle(e){e.forEach((({id:e,stats:t})=>{var r;null===(r=c(this,hv,"f").get(e))||void 0===r||r(t.connection),t.video.inbound.forEach((e=>{var t;return null===(t=c(this,fv,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.inbound.forEach((e=>{var t;return null===(t=c(this,mv,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.video.outbound.forEach((e=>{var t;return null===(t=c(this,gv,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.outbound.forEach((e=>{var t;return null===(t=c(this,vv,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)}))}))}addConnectionHandler(e,t){c(this,hv,"f").set(e,t)}addInboundVideoHandler(e,t){c(this,fv,"f").set(e,t)}addInboundAudioHandler(e,t){c(this,mv,"f").set(e,t)}addOutboundVideoHandler(e,t){c(this,gv,"f").set(e,t)}addOutboundAudioHandler(e,t){c(this,vv,"f").set(e,t)}removeConnectionHandler(e){c(this,hv,"f").delete(e)}removeInboundVideoHandler(e){c(this,fv,"f").delete(e)}removeInboundAudioHandler(e){c(this,gv,"f").delete(e)}removeOutboundVideoHandler(e){c(this,vv,"f").delete(e)}removeOutboundAudioHandler(e){c(this,vv,"f").delete(e)}clear(){c(this,hv,"f").clear(),c(this,fv,"f").clear(),c(this,mv,"f").clear(),c(this,gv,"f").clear(),c(this,vv,"f").clear()}};hv=new WeakMap,fv=new WeakMap,mv=new WeakMap,gv=new WeakMap,vv=new WeakMap,bv=i([at()],bv);var Ev,wv,Sv,Cv,Pv,Tv,Rv=bv;let kv=class{constructor(e){Ev.set(this,!1),wv.set(this,void 0),Sv.set(this,void 0),Cv.set(this,void 0),Pv.set(this,void 0),Tv.set(this,void 0),d(this,wv,e("IntegrationsService"),"f")}init({sendTransportConnectionManager:e,receiveTransportConnectionManager:t,media:r,peers:n}){d(this,Sv,e,"f"),d(this,Cv,t,"f"),d(this,Pv,r,"f"),d(this,Tv,n,"f"),d(this,Ev,!0,"f")}getStats(){try{return this.doGetStats()}catch(e){return c(this,wv,"f").error("Failed to get stats",{error:Ct(e)}),{}}}clear(){d(this,Sv,void 0,"f"),d(this,Cv,void 0,"f"),d(this,Pv,void 0,"f"),d(this,Tv,void 0,"f")}doGetStats(){var e,t,r,n;if(!c(this,Ev,"f"))throw new Error("TransportsStatsProvider is not initialized");return Object.assign(Object.assign({},(null===(t=null===(e=c(this,Sv,"f"))||void 0===e?void 0:e.connectionStats)||void 0===t?void 0:t.id)?{outbound:Object.assign(Object.assign({},c(this,Sv,"f").connectionStats),{bitrate:this.calculateOutboundTracksBitrate()})}:{}),(null===(n=null===(r=c(this,Cv,"f"))||void 0===r?void 0:r.connectionStats)||void 0===n?void 0:n.id)?{inbound:Object.assign(Object.assign({},c(this,Cv,"f").connectionStats),{bitrate:this.calculateInboundTracksBitrate()})}:{})}calculateInboundTracksBitrate(){if(void 0===c(this,Tv,"f"))throw new Error("Peers is undefined");return c(this,Tv,"f").hosts().reduce(((e,t)=>{if(t.isMe)return e;return e+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)}),0)}calculateOutboundTracksBitrate(){if(void 0===c(this,Pv,"f"))throw new Error("Media is undefined");return c(this,Pv,"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)}};Ev=new WeakMap,wv=new WeakMap,Sv=new WeakMap,Cv=new WeakMap,Pv=new WeakMap,Tv=new WeakMap,kv=i([at(),s(0,dt(On.LoggerFactory)),o("design:paramtypes",[Function])],kv);var Dv,Iv,Av,Ov=kv;let Nv=class{constructor(e,t,r,n,i,s,o,a,c,u,l,p,h,f,m,g,v,y,_,b,E,w,S){var C;this.state=e,this.myPeer=t,this.integrationsService=n,this.processorsCache=i,this.mediaEventHandler=s,this.channelEventsHandler=o,this.peerTrackFactory=a,this.peers=c,this.peersStorage=u,this.system=l,this.media=p,this.network=h,this.networkTransportPolicyManager=f,this.producerCloseManager=m,this.signalingApiClient=g,this.eventsQueue=v,this.clientEventEmitter=y,this.internalEventEmitter=_,this.statsHandler=b,this.transportsStatsProvider=E,this.localMutex=w,this.webRtcIssueDetector=S,Dv.set(this,void 0),this.rejoinRequested=!1,this.isReleasing=!1,Iv.set(this,!1),Av.set(this,!1),this.mark=kn(),this.handleSignalingError=e=>{this.isReleasing||!this.isChannelJoined||this.state.isChannelJoining||e instanceof gn&&this.triggerRejoinEventIfAppropriate(e.errorCode)},d(this,Dv,r("Engine"),"f"),this.watchNetworkState(),this.watchDocumentUnload(),this.watchInternalEvents(),this.signalingApiClient.addErrorListener(this.handleSignalingError),C=this.mark,window._sdkMarks||(window._sdkMarks=new Set),window._sdkMarks.add(C)}get isChannelJoined(){return this.state.isJoined}initialize(){return a(this,void 0,void 0,(function*(){var e,t,r,n;try{const{data:i}=yield this.signalingApiClient.router.getRtpCapabilities(),{rtpCapabilities:s}=i;this.integrationsService.init(),yield this.media.loadDevice(s),c(this,Dv,"f").info("Supported capabilities",{codecs:Pn(this.media.mediasoupDevice)});const[o,a]=yield Promise.all([this.network.createSendTransport(this.media.mediasoupDevice),this.network.createRecvTransport(this.media.mediasoupDevice)]);null===(e=this.webRtcIssueDetector)||void 0===e||e.handleNewPeerConnection(o.handler._pc,o.id),null===(t=this.webRtcIssueDetector)||void 0===t||t.handleNewPeerConnection(a.handler._pc,a.id),this.transportsStatsProvider.init({media:this.media,peers:this.peers,receiveTransportConnectionManager:new _v({transport:a,statsHandler:this.statsHandler}),sendTransportConnectionManager:new _v({transport:o,statsHandler:this.statsHandler})}),yield this.network.initializeHeartbeats();const{isChromiumBased:d}=(e=>{var t;const r=null!=e?e:"undefined"!=typeof navigator?navigator.userAgent:void 0;if(!r)return{isMobile:!1,isChromiumBased:!1};const n=bn.getParser(r),i=n.getPlatformType(!0),s="mobile"===i||"tablet"===i,o=n.getEngineName().toLowerCase(),a=null!==(t=n.satisfies({chrome:">=0",chromium:">=0","chromium webview":">=0",edge:">=0",opera:">=0","opera coast":">=0","samsung internet for android":">=0","yandex browser":">=0",electron:">=0"}))&&void 0!==t&&t;return{isMobile:s,isChromiumBased:"blink"===o||a&&"webkit"!==o}})();d||(yield this.network.createSignalingTransport(this.media.mediasoupDevice),yield this.network.createKeepAliveConsumer()),yield this.network.createAllDataChannels(),this.network.channelMessagesDataConsumer&&(this.eventsQueue.setChannelEventHandler(this.channelEventsHandler.handleChannelEvent.bind(this.channelEventsHandler)),this.eventsQueue.setMediaEventHandler(this.mediaEventHandler.handleMediaEvent.bind(this.mediaEventHandler)),this.eventsQueue.subscribe(this.network.channelMessagesDataConsumer)),c(this,Dv,"f").debug("initialize()",{sendTransportId:null===(r=this.network.sendTransport)||void 0===r?void 0:r.id,recvTransportId:null===(n=this.network.receiveTransport)||void 0===n?void 0:n.id})}catch(e){c(this,Dv,"f").error("initialize()",{error:e});const t=e instanceof Error&&"UnsupportedError"===e.name&&"device not supported"===e.message,r=e instanceof Error&&"RTCPeerConnection is not defined"===e.message;if(t||r)throw new vn("Device not supported",vn.UNSUPPORTED_DEVICE_CODE);if(e instanceof mn)throw e;throw new Pt("initialize_engine_error",e)}}))}release(e){return a(this,void 0,void 0,(function*(){var t;if(this.isReleasing)return;const r=this.myPeer.get(),n={case:"release",applicationId:this.state.appId,channelId:this.state.channelId,peerId:null!==(t=null==r?void 0:r.id)&&void 0!==t?t:this.myPeerId,peerRole:null==r?void 0:r.role,isJoined:this.state.isJoined,isChannelJoining:this.state.isChannelJoining,rejoinRequested:this.rejoinRequested};this.isReleasing=!0;const i=yield this.localMutex.lock(fn.Join);this.signalingApiClient.abortPendingRequests("release");try{e||this.media.clearTracks(),yield Promise.all([Cn((()=>a(this,void 0,void 0,(function*(){return yield this.peers.reset()})))),Cn((()=>a(this,void 0,void 0,(function*(){return yield this.media.unpublishTracks()})))),Cn((()=>a(this,void 0,void 0,(function*(){return yield this.signalingApiClient.peers.disconnectPeer()}))))]),this.cleanup(),c(this,Dv,"f").debug("release()",n)}catch(e){c(this,Dv,"f").error("Failed to release",Object.assign(Object.assign({},n),{error:Ct(e)}))}finally{this.isReleasing=!1,i()}}))}getPeers(){return this.peers.all()}get myPeerId(){return this.myPeer.id}confirmActivity(){return a(this,void 0,void 0,(function*(){try{yield this.signalingApiClient.channel.confirmChannelActivity()}catch(e){throw new Pt("confirm_activity_failed",e)}}))}join(e){return a(this,void 0,void 0,(function*(){const t=yield this.localMutex.lock(fn.Join);if(this.signalingApiClient.abortPendingRequests("join"),this.isChannelJoined)throw new Pt("method_not_available_when_joined");try{c(this,Dv,"f").debug("join()",{params:e}),this.state.isChannelJoining=!0,this.signalingApiClient.setSecurityData({token:e.token,peerApiVersion:8,datacenterType:e.isP2pCall?"p2p":"common"});const{data:r,headers:n}=yield this.signalingApiClient.peers.registerPeer({appData:e.appData}),{appId:i,channelId:s,peerId:o}=r,d=String(n["x-datacenter-name"]);this.myPeer.id=o,this.state.appId=i,this.state.channelId=s,fr.setPeerId(o),fr.setChannelId(s),fr.setAppId(i),fr.setDatacenterName(d),yield this.initialize(),yield this.network.waitForReceiveTransportConnected({onReceiveTransportFailed:()=>a(this,void 0,void 0,(function*(){yield this.networkTransportPolicyManager.escalateDirectionToRelay("recv")}))}),yield this.network.waitForChannelMessagesDataConsumerConnected(),this.state.isJoined=!0,this.networkTransportPolicyManager.startMonitoring(),c(this,Dv,"f").info("Successfully joined channel",{channelId:s,datacenterName:d})}catch(e){throw this.signalingApiClient.abortPendingRequests("join"),yield this.release(),c(this,Dv,"f").error("join()",{error:e}),new Pt("join_failed",e)}finally{this.state.isChannelJoining=!1,this.rejoinRequested=!1,t()}}))}loadPeers(e){return a(this,void 0,void 0,(function*(){try{yield this.peers.load(e)}catch(e){throw new Pt("load_peers_failed",e)}}))}requestChannelStateSync(){An((()=>a(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>a(this,void 0,void 0,(function*(){if(!this.isChannelJoined||this.rejoinRequested||this.state.isChannelJoining)return e();const r=yield this.network.triggerChannelStateEvent("host"),n=setTimeout((()=>{this.eventsQueue.isMessageReceived(r)?(c(this,Dv,"f").info("Channel state event received",{case:"Engine.requestChannelStateSync"}),e()):t(new Pt("channel_state_event_not_received",new Error("Channel state event not received")))}),5e3),i=()=>{clearTimeout(n),this.clientEventEmitter.off(Dr,i),e()};this.clientEventEmitter.on(Dr,i)}))))}))),{minBackoffDelayMs:0,maxBackoffDelayMs:0,maxRetries:10,actionName:"triggerChannelStateEventWithRetry",logger:c(this,Dv,"f")}).catch((e=>{c(this,Dv,"f").error("Failed to request channel state event",{case:"Engine.requestChannelStateSync",error:Ct(e)})}))}updateAppData(e){return a(this,void 0,void 0,(function*(){const t=this.myPeer.get();if(!t)throw new Pt("need_joined_to_channel",new Error("Need join to channel first"));try{yn(e)}catch(e){throw c(this,Dv,"f").error("updateAppData() validation failed",{error:e}),new Pt("invalid_app_data",e)}try{yield this.network.updatePeerAppData({peerId:t.id,appData:e})}catch(e){throw c(this,Dv,"f").error("updateAppData()",{error:e}),new Pt("update_app_data_failed",e)}}))}createCameraVideoTrack(e){return a(this,void 0,void 0,(function*(){const t=mg.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 rg&&(r.setLabel((null==e?void 0:e.isPreview)?Nn.CameraPreview:Nn.Camera),r.setEncoderConfig(t.encoderConfig),r.setTransformParams(mg.getVideoTrackTransformParams(r.mediaStreamTrack))),this.media.setTrack(r),c(this,Dv,"f").debug("createCameraVideoTrack()",{trackParams:t}),r}catch(e){throw c(this,Dv,"f").error("createCameraVideoTrack()",{error:e,trackParams:t}),new Pt("create_camera_track_failed",e)}}))}createMicrophoneAudioTrack(e){return a(this,void 0,void 0,(function*(){try{const[t]=yield this.media.createUserMediaTracks({video:!1,audio:null==e?void 0:e.audio}),r=(null==e?void 0:e.isPreview)?Nn.MicrophonePreview:Nn.Microphone;return t.setLabel(r),t.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),(null==e?void 0:e.encoderConfig)&&t.setEncoderConfig(e.encoderConfig),"audio"!==t.kind||t.getLabel()!==Nn.Microphone||c(this,Av,"f")||this.media.initDenoiser(t,e).catch((t=>{this.clientEventEmitter.emit(xr,{cause:"Failed to initialize denoiser",error:t}),c(this,Dv,"f").error("Failed to execute initDenoiser",{case:"Denoiser",options:e,error:Ct(t)})})),this.media.setTrack(t),c(this,Dv,"f").debug("createMicrophoneAudioTrack()",{options:e,trackLabel:t.getLabel()}),t}catch(t){throw c(this,Dv,"f").error("createMicrophoneAudioTrack()",{error:t,options:e}),new Pt("create_microphone_track_failed",t)}}))}createScreenMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=mg.getScreenVideoTrackParams(e);try{const r=yield this.media.createDisplayMediaTracks({audio:null==e?void 0:e.audio,video:null==e?void 0:e.video});return r.forEach((r=>{if(r.mediaStreamTrack.addEventListener("ended",(()=>{r.unpublish().catch((e=>{c(this,Dv,"f").error("Failed to unpublish screen track",{error:Ct(e)})}))}),{once:!0}),r.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),r instanceof rg){r.setLabel(Nn.ScreenVideo),r.setEncoderConfig(t.encoderConfig);const e=mg.getVideoTrackTransformParams(r.mediaStreamTrack);return r.setTransformParams(e),this.media.setTrack(r),void c(this,Dv,"f").debug("createScreenMediaTrack()",{trackParams:t,transformParams:e,label:r.logCtx})}r.setLabel(Nn.ScreenAudio),(null==e?void 0:e.audioEncoderConfig)&&r.setEncoderConfig(e.audioEncoderConfig),this.media.setTrack(r),c(this,Dv,"f").debug("createScreenMediaTrack()",{trackParams:null==e?void 0:e.audio,encoderConfig:null==e?void 0:e.audioEncoderConfig})})),r}catch(e){throw c(this,Dv,"f").error("createScreenMediaTrack()",{error:e,trackParams:t}),new Pt("create_screen_tracks_failed",e)}}))}createCustomAudioTrack(e){if(!e.audioTrack)throw new Pt("missing_audio_track",new Error("options.audioTrack is required"));try{const t=this.media.createCustomMediaTrack(e.audioTrack,{audio:e.audio});return t.mediaStreamTrack.addEventListener("ended",(()=>{t.unpublish().catch((e=>{c(this,Dv,"f").error("Failed to unpublish custom audio track",{track:t,error:Ct(e)})}))}),{once:!0}),t.setStopTrackOnPause(Boolean(e.stopTrackOnPause)),t.setLabel(Nn.CustomAudio),e.audioEncoderConfig&&t.setEncoderConfig(e.audioEncoderConfig),this.media.setTrack(t),c(this,Dv,"f").debug("createCustomAudioTrack()",{trackParams:e.audio,encoderConfig:e.audioEncoderConfig}),t}catch(t){throw c(this,Dv,"f").error("createCustomAudioTrack()",{error:t,trackParams:e.audioTrack}),new Pt("create_custom_audio_track_failed",t)}}createCustomVideoTrack(e){const t=mg.getScreenVideoTrackParams(e);if(!e.videoTrack)throw new Pt("missing_video_track",new Error("options.videoTrack is required"));try{const r=this.media.createCustomMediaTrack(e.videoTrack,{video:e.video});r.mediaStreamTrack.addEventListener("ended",(()=>{r.unpublish().catch((e=>{c(this,Dv,"f").error("Failed to unpublish custom video track",{track:r,error:Ct(e)})}))}),{once:!0}),r.mediaStreamTrack.contentHint="customVideo",r.setLabel(Nn.CustomVideo),r.setEncoderConfig(t.encoderConfig);const n=mg.getVideoTrackTransformParams(r.mediaStreamTrack);return r.setTransformParams(n),this.media.setTrack(r),c(this,Dv,"f").debug("createCustomVideoTrack()",{trackParams:t,transformParams:n,label:r.logCtx}),r}catch(e){throw c(this,Dv,"f").error("createCustomVideoTrack()",{error:e,trackParams:t}),new Pt("create_custom_video_track_failed",e)}}deleteTrack(e){return a(this,void 0,void 0,(function*(){try{yield this.media.deleteTrack(e)}catch(e){throw new Pt("delete_track_failed",e)}}))}transportsStats(){return this.transportsStatsProvider.getStats()}setSignalingServerUrl(e){if(this.isChannelJoined||this.rejoinRequested||this.state.isChannelJoining)throw new Pt("method_not_available_when_joined",new Error("Method not available when joined channel"));this.signalingApiClient.instance.defaults.baseURL=e}cleanup(){var e;this.signalingApiClient.abortPendingRequests("cleanup"),this.networkTransportPolicyManager.stopMonitoring(),this.state.reset(),this.network.reset(),this.peersStorage.clear(),this.transportsStatsProvider.clear(),this.statsHandler.clear(),this.integrationsService.reset(),null===(e=this.webRtcIssueDetector)||void 0===e||e.stopWatchingNewPeerConnections(),this.processorsCache.reset(),fr.clear()}watchInternalEvents(){this.internalEventEmitter.on(jr,(e=>a(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(Ur,(e=>a(this,void 0,void 0,(function*(){var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.close())||void 0===r||r.catch((e=>{c(this,Dv,"f").debug("Failed to close peerTrack",{error:Ct(e)})})),yield this.media.deleteTrack(e)})))),this.internalEventEmitter.on(Vr,(e=>{var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.pause())||void 0===r||r.catch((e=>{c(this,Dv,"f").debug("Failed to pause peerTrack",{error:Ct(e)})}))})),this.internalEventEmitter.on(Br,(e=>{var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.resume())||void 0===r||r.catch((e=>{c(this,Dv,"f").debug("Failed to resume peerTrack",{error:Ct(e)})}))})),this.internalEventEmitter.on(Wr,(e=>{var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.close())||void 0===r||r.catch((e=>{c(this,Dv,"f").debug("Failed to close peerTrack",{error:Ct(e)})}))})),this.internalEventEmitter.on(Hr,(e=>a(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(qr,(e=>{this.clientEventEmitter.safeEmit(Tr,{label:e.getLabel()})}))}createSelfPeerTrack(e){return a(this,void 0,void 0,(function*(){var t;if(!this.myPeer.id)return;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.isChannelJoined||this.isReleasing||this.state.isChannelJoining||this.rejoinRequested||(c(this,Dv,"f").debug("Triggering channel rejoin required event",{reason:e}),this.signalingApiClient.abortPendingRequests("channel-rejoin"),this.rejoinRequested=!0,this.clientEventEmitter.emit(wr))}watchNetworkState(){this.network.observer.on(hn,(({state:e,direction:t})=>{if(!this.isReleasing&&(["disconnected","failed"].includes(e)&&this.isChannelJoined&&!c(this,Iv,"f")&&(d(this,Iv,!0,"f"),c(this,Dv,"f").info("connection lost",{channel:"webrtc-transport",direction:t}),this.clientEventEmitter.safeEmit(Dr)),"reconnected"===e&&this.isChannelJoined&&c(this,Dv,"f").info("connection restored",{channel:"webrtc-transport",direction:t}),"reconnected"===e&&this.isChannelJoined&&c(this,Iv,"f"))){if(![this.network.receiveTransport,this.network.sendTransport].every((e=>"connected"===(null==e?void 0:e.connectionState)||"new"===(null==e?void 0:e.connectionState))))return;d(this,Iv,!1,"f"),this.clientEventEmitter.safeEmit(Ir),this.producerCloseManager.flushPending().catch((e=>{c(this,Dv,"f").warn("Failed to flush pending remote producers",{error:Ct(e)})}))}}))}watchDocumentUnload(){try{window.addEventListener("unload",(()=>{var e,t;null===(e=this.network.sendTransport)||void 0===e||e.close(),null===(t=this.network.receiveTransport)||void 0===t||t.close()}))}catch(e){c(this,Dv,"f").error("Failed to add watchDocumentUnload listener",{channelId:this.state.channelId,error:Ct(e)})}}};Dv=new WeakMap,Iv=new WeakMap,Av=new WeakMap,Nv=i([at(),s(0,dt(On.CallState)),s(1,dt(On.MyPeer)),s(2,dt(On.LoggerFactory)),s(3,dt(On.IntegrationsService)),s(4,dt(On.ProcessorsCache)),s(5,dt(On.MediaEventHandler)),s(6,dt(On.ChannelEventHandler)),s(7,dt(On.PeerTrackFactory)),s(8,dt(On.Peers)),s(9,dt(On.PeersStorage)),s(10,dt(On.System)),s(11,dt(On.Media)),s(12,dt(On.Network)),s(13,dt(On.NetworkTransportPolicyManager)),s(14,dt(On.ProducerCloseManager)),s(15,dt(On.SignalingApiClient)),s(16,dt(On.EventsQueue)),s(17,dt(On.ClientEventEmitter)),s(18,dt(On.InternalEventEmitter)),s(19,dt(On.StatsHandler)),s(20,dt(On.TransportsStatsProvider)),s(21,dt(On.LocalMutex)),s(22,dt(On.WebRTCIssueDetector)),o("design:paramtypes",[Ln,ws,Function,wm,_m,Vg,Og,Function,Object,wc,yv,mg,Jc,ev,Qg,gc,bs,Et,Et,Rv,Ov,uv,dr])],Nv);var Mv=Nv,Lv="undefined"!=typeof Symbol&&Symbol,xv=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},Fv="Function.prototype.bind called on incompatible ",jv=Array.prototype.slice,Uv=Object.prototype.toString,Vv=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==Uv.call(t))throw new TypeError(Fv+t);for(var r,n=jv.call(arguments,1),i=function(){if(this instanceof r){var i=t.apply(this,n.concat(jv.call(arguments)));return Object(i)===i?i:this}return t.apply(e,n.concat(jv.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},Bv=Function.prototype.bind||Vv,Wv="Function.prototype.bind called on incompatible ",Hv=Array.prototype.slice,qv=Object.prototype.toString,zv=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==qv.call(t))throw new TypeError(Wv+t);for(var r,n=Hv.call(arguments,1),i=function(){if(this instanceof r){var i=t.apply(this,n.concat(Hv.call(arguments)));return Object(i)===i?i:this}return t.apply(e,n.concat(Hv.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},Gv=(Function.prototype.bind||zv).call(Function.call,Object.prototype.hasOwnProperty),Yv=SyntaxError,$v=Function,Jv=TypeError,Kv=function(e){try{return $v('"use strict"; return ('+e+").constructor;")()}catch(e){}},Qv=Object.getOwnPropertyDescriptor;if(Qv)try{Qv({},"")}catch(Rt){Qv=null}var Zv=function(){throw new Jv},Xv=Qv?function(){try{return Zv}catch(e){try{return Qv(arguments,"callee").get}catch(e){return Zv}}}():Zv,ey="function"==typeof Lv&&"function"==typeof Symbol&&"symbol"==typeof Lv("foo")&&"symbol"==typeof Symbol("bar")&&xv(),ty=Object.getPrototypeOf||function(e){return e.__proto__},ry={},ny="undefined"==typeof Uint8Array?undefined:ty(Uint8Array),iy={"%AggregateError%":"undefined"==typeof AggregateError?undefined:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?undefined:ArrayBuffer,"%ArrayIteratorPrototype%":ey?ty([][Symbol.iterator]()):undefined,"%AsyncFromSyncIteratorPrototype%":undefined,"%AsyncFunction%":ry,"%AsyncGenerator%":ry,"%AsyncGeneratorFunction%":ry,"%AsyncIteratorPrototype%":ry,"%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%":$v,"%GeneratorFunction%":ry,"%Int8Array%":"undefined"==typeof Int8Array?undefined:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?undefined:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?undefined:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ey?ty(ty([][Symbol.iterator]())):undefined,"%JSON%":"object"==typeof JSON?JSON:undefined,"%Map%":"undefined"==typeof Map?undefined:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&ey?ty((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&&ey?ty((new Set)[Symbol.iterator]()):undefined,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?undefined:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ey?ty(""[Symbol.iterator]()):undefined,"%Symbol%":ey?Symbol:undefined,"%SyntaxError%":Yv,"%ThrowTypeError%":Xv,"%TypedArray%":ny,"%TypeError%":Jv,"%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},sy=function e(t){var r;if("%AsyncFunction%"===t)r=Kv("async function () {}");else if("%GeneratorFunction%"===t)r=Kv("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=Kv("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&(r=ty(i.prototype))}return iy[t]=r,r},oy={"%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"]},ay=Bv,cy=Gv,dy=ay.call(Function.call,Array.prototype.concat),uy=ay.call(Function.apply,Array.prototype.splice),ly=ay.call(Function.call,String.prototype.replace),py=ay.call(Function.call,String.prototype.slice),hy=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,fy=/\\(\\)?/g,my=function(e){var t=py(e,0,1),r=py(e,-1);if("%"===t&&"%"!==r)throw new Yv("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new Yv("invalid intrinsic syntax, expected opening `%`");var n=[];return ly(e,hy,(function(e,t,r,i){n[n.length]=r?ly(i,fy,"$1"):t||e})),n},gy=function(e,t){var r,n=e;if(cy(oy,n)&&(n="%"+(r=oy[n])[0]+"%"),cy(iy,n)){var i=iy[n];if(i===ry&&(i=sy(n)),void 0===i&&!t)throw new Jv("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new Yv("intrinsic "+e+" does not exist!")},vy=function(e,t){if("string"!=typeof e||0===e.length)throw new Jv("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new Jv('"allowMissing" argument must be a boolean');var r=my(e),n=r.length>0?r[0]:"",i=gy("%"+n+"%",t),s=i.name,o=i.value,a=!1,c=i.alias;c&&(n=c[0],uy(r,dy([0,1],c)));for(var d=1,u=!0;d<r.length;d+=1){var l=r[d],p=py(l,0,1),h=py(l,-1);if(('"'===p||"'"===p||"`"===p||'"'===h||"'"===h||"`"===h)&&p!==h)throw new Yv("property names with quotes must have matching quotes");if("constructor"!==l&&u||(a=!0),cy(iy,s="%"+(n+="."+l)+"%"))o=iy[s];else if(null!=o){if(!(l in o)){if(!t)throw new Jv("base intrinsic for "+e+" exists, but the property is not available.");return}if(Qv&&d+1>=r.length){var f=Qv(o,l);o=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:o[l]}else u=cy(o,l),o=o[l];u&&!a&&(iy[s]=o)}}return o},yy={exports:{}};!function(e){var t=Bv,r=vy,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}(yy);var _y=vy,by=yy.exports,Ey=by(_y("String.prototype.indexOf")),wy=h(Object.freeze({__proto__:null,default:{}})),Sy="function"==typeof Map&&Map.prototype,Cy=Object.getOwnPropertyDescriptor&&Sy?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Py=Sy&&Cy&&"function"==typeof Cy.get?Cy.get:null,Ty=Sy&&Map.prototype.forEach,Ry="function"==typeof Set&&Set.prototype,ky=Object.getOwnPropertyDescriptor&&Ry?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Dy=Ry&&ky&&"function"==typeof ky.get?ky.get:null,Iy=Ry&&Set.prototype.forEach,Ay="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Oy="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Ny="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,My=Boolean.prototype.valueOf,Ly=Object.prototype.toString,xy=Function.prototype.toString,Fy=String.prototype.match,jy="function"==typeof BigInt?BigInt.prototype.valueOf:null,Uy=Object.getOwnPropertySymbols,Vy="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,By="function"==typeof Symbol&&"object"==typeof Symbol.iterator,Wy=Object.prototype.propertyIsEnumerable,Hy=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null),qy=wy.custom,zy=qy&&Ky(qy)?qy:null,Gy="function"==typeof Symbol&&void 0!==Symbol.toStringTag?Symbol.toStringTag:null;function Yy(e,t,r){var n="double"===(r.quoteStyle||t)?'"':"'";return n+e+n}function $y(e){return String(e).replace(/"/g,""")}function Jy(e){return!("[object Array]"!==Xy(e)||Gy&&"object"==typeof e&&Gy in e)}function Ky(e){if(By)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Vy)return!1;try{return Vy.call(e),!0}catch(e){}return!1}var Qy=Object.prototype.hasOwnProperty||function(e){return e in this};function Zy(e,t){return Qy.call(e,t)}function Xy(e){return Ly.call(e)}function e_(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 t_(e,t){if(e.length>t.maxStringLength){var r=e.length-t.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return t_(e.slice(0,t.maxStringLength),t)+n}return Yy(e.replace(/(['\\])/g,"\\$1").replace(/[\x00-\x1f]/g,r_),"single",t)}function r_(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 n_(e){return"Object("+e+")"}function i_(e){return e+" { ? }"}function s_(e,t,r,n){return e+" ("+t+") {"+(n?o_(r,n):r.join(", "))+"}"}function o_(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+e.join(","+r)+"\n"+t.prev}function a_(e,t){var r=Jy(e),n=[];if(r){n.length=e.length;for(var i=0;i<e.length;i++)n[i]=Zy(e,i)?t(e[i],e):""}var s,o="function"==typeof Uy?Uy(e):[];if(By){s={};for(var a=0;a<o.length;a++)s["$"+o[a]]=o[a]}for(var c in e)Zy(e,c)&&(r&&String(Number(c))===c&&c<e.length||By&&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 Uy)for(var d=0;d<o.length;d++)Wy.call(e,o[d])&&n.push("["+t(o[d])+"]: "+t(e[o[d]],e));return n}var c_=vy,d_=function(e,t){var r=_y(e,!!t);return"function"==typeof r&&Ey(e,".prototype.")>-1?by(r):r},u_=function e(t,r,n,i){var s=r||{};if(Zy(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Zy(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=!Zy(s,"customInspect")||s.customInspect;if("boolean"!=typeof o&&"symbol"!==o)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Zy(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 t_(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 Jy(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(e_(i,t)>=0)return"[Circular]";function d(t,r,o){if(r&&(i=i.slice()).push(r),o){var a={depth:s.depth};return Zy(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=Fy.call(xy.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),l=a_(t,d);return"[Function"+(u?": "+u:" (anonymous)")+"]"+(l.length>0?" { "+l.join(", ")+" }":"")}if(Ky(t)){var p=By?String(t).replace(/^(Symbol\(.*\))_[^)]*$/,"$1"):Vy.call(t);return"object"!=typeof t||By?p:n_(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+"="+Yy($y(f[m].value),"double",s);return h+=">",t.childNodes&&t.childNodes.length&&(h+="..."),h+="</"+String(t.nodeName).toLowerCase()+">"}if(Jy(t)){if(0===t.length)return"[]";var g=a_(t,d);return c&&!function(e){for(var t=0;t<e.length;t++)if(e_(e[t],"\n")>=0)return!1;return!0}(g)?"["+o_(g,c)+"]":"[ "+g.join(", ")+" ]"}if(function(e){return!("[object Error]"!==Xy(e)||Gy&&"object"==typeof e&&Gy in e)}(t)){var v=a_(t,d);return 0===v.length?"["+String(t)+"]":"{ ["+String(t)+"] "+v.join(", ")+" }"}if("object"==typeof t&&o){if(zy&&"function"==typeof t[zy])return t[zy]();if("symbol"!==o&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!Py||!e||"object"!=typeof e)return!1;try{Py.call(e);try{Dy.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var y=[];return Ty.call(t,(function(e,r){y.push(d(r,t,!0)+" => "+d(e,t))})),s_("Map",Py.call(t),y,c)}if(function(e){if(!Dy||!e||"object"!=typeof e)return!1;try{Dy.call(e);try{Py.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var _=[];return Iy.call(t,(function(e){_.push(d(e,t))})),s_("Set",Dy.call(t),_,c)}if(function(e){if(!Ay||!e||"object"!=typeof e)return!1;try{Ay.call(e,Ay);try{Oy.call(e,Oy)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return i_("WeakMap");if(function(e){if(!Oy||!e||"object"!=typeof e)return!1;try{Oy.call(e,Oy);try{Ay.call(e,Ay)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return i_("WeakSet");if(function(e){if(!Ny||!e||"object"!=typeof e)return!1;try{return Ny.call(e),!0}catch(e){}return!1}(t))return i_("WeakRef");if(function(e){return!("[object Number]"!==Xy(e)||Gy&&"object"==typeof e&&Gy in e)}(t))return n_(d(Number(t)));if(function(e){if(!e||"object"!=typeof e||!jy)return!1;try{return jy.call(e),!0}catch(e){}return!1}(t))return n_(d(jy.call(t)));if(function(e){return!("[object Boolean]"!==Xy(e)||Gy&&"object"==typeof e&&Gy in e)}(t))return n_(My.call(t));if(function(e){return!("[object String]"!==Xy(e)||Gy&&"object"==typeof e&&Gy in e)}(t))return n_(d(String(t)));if(!function(e){return!("[object Date]"!==Xy(e)||Gy&&"object"==typeof e&&Gy in e)}(t)&&!function(e){return!("[object RegExp]"!==Xy(e)||Gy&&"object"==typeof e&&Gy in e)}(t)){var b=a_(t,d),E=Hy?Hy(t)===Object.prototype:t instanceof Object||t.constructor===Object,w=t instanceof Object?"":"null prototype",S=!E&&Gy&&Object(t)===t&&Gy in t?Xy(t).slice(8,-1):w?"Object":"",C=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(S||w?"["+[].concat(S||[],w||[]).join(": ")+"] ":"");return 0===b.length?C+"{}":c?C+"{"+o_(b,c)+"}":C+"{ "+b.join(", ")+" }"}return String(t)},l_=c_("%TypeError%"),p_=c_("%WeakMap%",!0),h_=c_("%Map%",!0),f_=d_("WeakMap.prototype.get",!0),m_=d_("WeakMap.prototype.set",!0),g_=d_("WeakMap.prototype.has",!0),v_=d_("Map.prototype.get",!0),y_=d_("Map.prototype.set",!0),__=d_("Map.prototype.has",!0),b_=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},E_=String.prototype.replace,w_=/%20/g,S_="RFC3986",C_={default:S_,formatters:{RFC1738:function(e){return E_.call(e,w_,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:S_},P_=C_,T_=Object.prototype.hasOwnProperty,R_=Array.isArray,k_=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),D_=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},I_={arrayToObject:D_,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(R_(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===P_.RFC1738&&(40===c||41===c)?o+=s.charAt(a):c<128?o+=k_[c]:c<2048?o+=k_[192|c>>6]+k_[128|63&c]:c<55296||c>=57344?o+=k_[224|c>>12]+k_[128|c>>6&63]+k_[128|63&c]:(a+=1,c=65536+((1023&c)<<10|1023&s.charCodeAt(a)),o+=k_[240|c>>18]+k_[128|c>>12&63]+k_[128|c>>6&63]+k_[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(R_(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(R_(t))t.push(r);else{if(!t||"object"!=typeof t)return[t,r];(n&&(n.plainObjects||n.allowPrototypes)||!T_.call(Object.prototype,r))&&(t[r]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(r);var i=t;return R_(t)&&!R_(r)&&(i=D_(t,n)),R_(t)&&R_(r)?(r.forEach((function(r,i){if(T_.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 T_.call(t,i)?t[i]=e(t[i],s,n):t[i]=s,t}),i)}},A_=function(){var e,t,r,n={assert:function(e){if(!n.has(e))throw new l_("Side channel does not contain "+u_(e))},get:function(n){if(p_&&n&&("object"==typeof n||"function"==typeof n)){if(e)return f_(e,n)}else if(h_){if(t)return v_(t,n)}else if(r)return function(e,t){var r=b_(e,t);return r&&r.value}(r,n)},has:function(n){if(p_&&n&&("object"==typeof n||"function"==typeof n)){if(e)return g_(e,n)}else if(h_){if(t)return __(t,n)}else if(r)return function(e,t){return!!b_(e,t)}(r,n);return!1},set:function(n,i){p_&&n&&("object"==typeof n||"function"==typeof n)?(e||(e=new p_),m_(e,n,i)):h_?(t||(t=new h_),y_(t,n,i)):(r||(r={key:{},next:null}),function(e,t,r){var n=b_(e,t);n?n.value=r:e.next={key:t,next:e.next,value:r}}(r,n,i))}};return n},O_=I_,N_=C_,M_=Object.prototype.hasOwnProperty,L_={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},x_=Array.isArray,F_=String.prototype.split,j_=Array.prototype.push,U_=function(e,t){j_.apply(e,x_(t)?t:[t])},V_=Date.prototype.toISOString,B_=N_.default,W_={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:O_.encode,encodeValuesOnly:!1,format:B_,formatter:N_.formatters[B_],indices:!1,serializeDate:function(e){return V_.call(e)},skipNulls:!1,strictNullHandling:!1},H_={},q_=function e(t,r,n,i,s,o,a,c,d,u,l,p,h,f,m,g){for(var v=t,y=g,_=0,b=!1;void 0!==(y=y.get(H_))&&!b;){var E=y.get(t);if(_+=1,void 0!==E){if(E===_)throw new RangeError("Cyclic object value");b=!0}void 0===y.get(H_)&&(_=0)}if("function"==typeof c?v=c(r,v):v instanceof Date?v=l(v):"comma"===n&&x_(v)&&(v=O_.maybeMap(v,(function(e){return e instanceof Date?l(e):e}))),null===v){if(s)return a&&!f?a(r,W_.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)||O_.isBuffer(v)){if(a){var w=f?r:a(r,W_.encoder,m,"key",p);if("comma"===n&&f){for(var S=F_.call(String(v),","),C="",P=0;P<S.length;++P)C+=(0===P?"":",")+h(a(S[P],W_.encoder,m,"value",p));return[h(w)+(i&&x_(v)&&1===S.length?"[]":"")+"="+C]}return[h(w)+"="+h(a(v,W_.encoder,m,"value",p))]}return[h(r)+"="+h(String(v))]}var T,R=[];if(void 0===v)return R;if("comma"===n&&x_(v))T=[{value:v.length>0?v.join(",")||null:void 0}];else if(x_(c))T=c;else{var k=Object.keys(v);T=d?k.sort(d):k}for(var D=i&&x_(v)&&1===v.length?r+"[]":r,I=0;I<T.length;++I){var A=T[I],O="object"==typeof A&&void 0!==A.value?A.value:v[A];if(!o||null!==O){var N=x_(v)?"function"==typeof n?n(D,A):D:D+(u?"."+A:"["+A+"]");g.set(t,_);var M=A_();M.set(H_,g),U_(R,e(O,N,n,i,s,o,a,c,d,u,l,p,h,f,m,M))}}return R},z_=I_,G_=Object.prototype.hasOwnProperty,Y_=Array.isArray,$_={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:z_.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},J_=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},K_=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},Q_=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&&G_.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&&G_.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:K_(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)}},Z_=function(e,t){var r,n=e,i=function(e){if(!e)return W_;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||W_.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=N_.default;if(void 0!==e.format){if(!M_.call(N_.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n=N_.formatters[r],i=W_.filter;return("function"==typeof e.filter||x_(e.filter))&&(i=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:W_.addQueryPrefix,allowDots:void 0===e.allowDots?W_.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:W_.charsetSentinel,delimiter:void 0===e.delimiter?W_.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:W_.encode,encoder:"function"==typeof e.encoder?e.encoder:W_.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:W_.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:W_.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:W_.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:W_.strictNullHandling}}(t);"function"==typeof i.filter?n=(0,i.filter)("",n):x_(i.filter)&&(r=i.filter);var s,o=[];if("object"!=typeof n||null===n)return"";s=t&&t.arrayFormat in L_?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var a=L_[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=A_(),u=0;u<r.length;++u){var l=r[u];i.skipNulls&&null===n[l]||U_(o,q_(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:""},X_=function(e,t){var r=function(e){if(!e)return $_;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?$_.charset:e.charset;return{allowDots:void 0===e.allowDots?$_.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:$_.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:$_.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:$_.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:$_.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:$_.comma,decoder:"function"==typeof e.decoder?e.decoder:$_.decoder,delimiter:"string"==typeof e.delimiter||z_.isRegExp(e.delimiter)?e.delimiter:$_.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:$_.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:$_.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:$_.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:$_.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:$_.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,$_.decoder,c,"key"),u=t.strictNullHandling?null:""):(d=t.decoder(l.slice(0,h),$_.decoder,c,"key"),u=z_.maybeMap(K_(l.slice(h+1),t),(function(e){return t.decoder(e,$_.decoder,c,"value")}))),u&&t.interpretNumericEntities&&"iso-8859-1"===c&&(u=J_(u)),l.indexOf("[]=")>-1&&(u=Y_(u)?[u]:u),G_.call(n,d)?n[d]=z_.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=Q_(a,n[a],r,"string"==typeof e);i=z_.merge(i,c,r)}return!0===r.allowSparse?i:z_.compact(i)},eb={formats:C_,parse:X_,stringify:Z_};let tb,rb=!1;const nb=()=>{try{return rb?null:window.localStorage}catch(e){return console.error("Get local storage error",{error:Ct(e)}),e instanceof Error&&"SecurityError"===e.name&&(rb=!0),null}};function ib(e){const t=nb();if(!t)return null;try{const r=t.getItem(e);return r?JSON.parse(r):null}catch(e){return null}}const sb=()=>{if(tb)return tb;const e=ib("sdk_clientUniqueId");if(e)return tb=e,e;const t=kn(12);return tb=t,function(e,t){const r=nb();if(r)try{r.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}}("sdk_clientUniqueId",t),t},ob=()=>{const e=ib("sdk_clientUniqueId");return e||(null!=tb?tb:sb())};class ab{constructor(e){this.api=e,Ms(this.api,{retries:2,shouldResetTimeout:!0,retryDelay:e=>1500*e,retryCondition:e=>{var t,r;return/^\/?log\//.test(null!==(r=null===(t=e.config)||void 0===t?void 0:t.url)&&void 0!==r?r:"")||!1}})}batch(e){return a(this,void 0,void 0,(function*(){yield this.api.post("/log/batch",e)}))}}class cb{constructor(e){this.api=e,Ms(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}})}sendNetworkMetrics(e){return a(this,void 0,void 0,(function*(){yield this.api.post("/analytics/network-metrics",e)}))}sendWIDMetrics(e){return a(this,void 0,void 0,(function*(){yield this.api.post("/analytics/wid-metrics",Object.assign({},e))}))}}let db=class{constructor(){this.api=Ja.create({baseURL:"https://moodhood-analytics.livedigital.space/v1",timeout:1e4,withCredentials:!0,paramsSerializer:e=>eb.stringify(e),headers:{"x-cl-id":ob()}}),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 ab(this.api),this.metricsApi=new cb(this.api)}get log(){return this.logApi}get metrics(){return this.metricsApi}};db=i([at(),o("design:paramtypes",[])],db);var ub=db,lb={exports:{}},pb=1e3,hb=60*pb,fb=60*hb,mb=24*fb,gb=7*mb,vb=365.25*mb,yb=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*vb;case"weeks":case"week":case"w":return r*gb;case"days":case"day":case"d":return r*mb;case"hours":case"hour":case"hrs":case"hr":case"h":return r*fb;case"minutes":case"minute":case"mins":case"min":case"m":return r*hb;case"seconds":case"second":case"secs":case"sec":case"s":return r*pb;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>=mb)return _b(e,t,mb,"day");if(t>=fb)return _b(e,t,fb,"hour");if(t>=hb)return _b(e,t,hb,"minute");if(t>=pb)return _b(e,t,pb,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=mb)return Math.round(e/mb)+"d";if(t>=fb)return Math.round(e/fb)+"h";if(t>=hb)return Math.round(e/hb)+"m";if(t>=pb)return Math.round(e/pb)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function _b(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var bb=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=yb,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=bb(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(lb,lb.exports);var Eb,wb,Sb=lb.exports,Cb={},Pb={},Tb={},Rb={exports:{}};
|
|
29
|
+
***************************************************************************** */!function(e){!function(t){var r="object"==typeof globalThis?globalThis:"object"==typeof l?l:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(e){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(e){}}(),n=i(e);function i(e,t){return function(r,n){Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0!==r.Reflect&&(n=i(r.Reflect,n)),function(e,t){var r=Object.prototype.hasOwnProperty,n="function"==typeof Symbol,i=n&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",s=n&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",o="function"==typeof Object.create,a={__proto__:[]}instanceof Array,c=!o&&!a,d={create:o?function(){return le(Object.create(null))}:a?function(){return le({__proto__:null})}:function(){return le({})},has:c?function(e,t){return r.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return r.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),l="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:ce(),p="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:de(),h="function"==typeof WeakMap?WeakMap:ue(),f=n?Symbol.for("@reflect-metadata:registry"):void 0,m=ie(),g=se(m);function v(e,t,r,n){if(F(r)){if(!G(e))throw new TypeError;if(!$(t))throw new TypeError;return R(e,t)}if(!G(e))throw new TypeError;if(!V(t))throw new TypeError;if(!V(n)&&!F(n)&&!j(n))throw new TypeError;return j(n)&&(n=void 0),k(e,t,r=z(r),n)}function y(e,t){function r(r,n){if(!V(r))throw new TypeError;if(!F(n)&&!J(n))throw new TypeError;N(e,t,r,n)}return r}function _(e,t,r,n){if(!V(r))throw new TypeError;return F(n)||(n=z(n)),N(e,t,r,n)}function b(e,t,r){if(!V(t))throw new TypeError;return F(r)||(r=z(r)),D(e,t,r)}function E(e,t,r){if(!V(t))throw new TypeError;return F(r)||(r=z(r)),I(e,t,r)}function w(e,t,r){if(!V(t))throw new TypeError;return F(r)||(r=z(r)),A(e,t,r)}function S(e,t,r){if(!V(t))throw new TypeError;return F(r)||(r=z(r)),O(e,t,r)}function C(e,t){if(!V(e))throw new TypeError;return F(t)||(t=z(t)),M(e,t)}function P(e,t){if(!V(e))throw new TypeError;return F(t)||(t=z(t)),L(e,t)}function T(e,t,r){if(!V(t))throw new TypeError;if(F(r)||(r=z(r)),!V(t))throw new TypeError;F(r)||(r=z(r));var n=ae(t,r,!1);return!F(n)&&n.OrdinaryDeleteMetadata(e,t,r)}function R(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!F(n)&&!j(n)){if(!$(n))throw new TypeError;t=n}}return t}function k(e,t,r,n){for(var i=e.length-1;i>=0;--i){var s=(0,e[i])(t,r,n);if(!F(s)&&!j(s)){if(!V(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!j(n)&&D(e,n,r)}function I(e,t,r){var n=ae(t,r,!1);return!F(n)&&H(n.OrdinaryHasOwnMetadata(e,t,r))}function A(e,t,r){if(I(e,t,r))return O(e,t,r);var n=re(t);return j(n)?void 0:A(e,n,r)}function O(e,t,r){var n=ae(t,r,!1);if(!F(n))return n.OrdinaryGetOwnMetadata(e,t,r)}function N(e,t,r,n){ae(r,n,!0).OrdinaryDefineOwnMetadata(e,t,r,n)}function M(e,t){var r=L(e,t),n=re(e);if(null===n)return r;var i=M(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 L(e,t){var r=ae(e,t,!1);return r?r.OrdinaryOwnMetadataKeys(e,t):[]}function x(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 j(e){return null===e}function U(e){return"symbol"==typeof e}function V(e){return"object"==typeof e?null!==e:"function"==typeof e}function B(e,t){switch(x(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=Q(e,i);if(void 0!==n){var s=n.call(e,r);if(V(s))throw new TypeError;return s}return W(e,"default"===r?"number":r)}function W(e,t){if("string"===t){var r=e.toString;if(Y(r))if(!V(i=r.call(e)))return i;if(Y(n=e.valueOf))if(!V(i=n.call(e)))return i}else{var n;if(Y(n=e.valueOf))if(!V(i=n.call(e)))return i;var i,s=e.toString;if(Y(s))if(!V(i=s.call(e)))return i}throw new TypeError}function H(e){return!!e}function q(e){return""+e}function z(e){var t=B(e,3);return U(t)?t:q(t)}function G(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function Y(e){return"function"==typeof e}function $(e){return"function"==typeof e}function J(e){switch(x(e)){case 3:case 4:return!0;default:return!1}}function K(e,t){return e===t||e!=e&&t!=t}function Q(e,t){var r=e[t];if(null!=r){if(!Y(r))throw new TypeError;return r}}function Z(e){var t=Q(e,s);if(!Y(t))throw new TypeError;var r=t.call(e);if(!V(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)&&V(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[f]),F(e)&&(e=ne()),!F(f)&&V(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)&&H(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--,K(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(!K(this._cacheKey,e)){this._cacheIndex=-1;for(var r=0;r<this._keys.length;r++)if(K(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(){return 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}()}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",_),e("hasMetadata",b),e("hasOwnMetadata",E),e("getMetadata",w),e("getOwnMetadata",S),e("getMetadataKeys",C),e("getOwnMetadataKeys",P),e("deleteMetadata",T)}(n,r),void 0===r.Reflect&&(r.Reflect=e)}()}(u||(u={}));var f=["inject","multi_inject","name","unmanaged","named","optional"],m="Request",g="Singleton",v="Transient",y="ConstantValue",_="Constructor",b="DynamicValue",E="Factory",w="Function",S="Instance",C="Invalid",P="Provider",T="ClassProperty",R="ConstructorArgument",k="Variable",D=0;function I(){return D++}var A=function(){function e(e,t){this.id=I(),this.activated=!1,this.serviceIdentifier=e,this.scope=t,this.type=C,this.constraint=function(e){return!0},this.implementationType=null,this.cache=null,this.factory=null,this.provider=null,this.onActivation=null,this.onDeactivation=null,this.dynamicValue=null}return e.prototype.clone=function(){var t=new e(this.serviceIdentifier,this.scope);return t.activated=t.scope===g&&this.activated,t.implementationType=this.implementationType,t.dynamicValue=this.dynamicValue,t.scope=this.scope,t.type=this.type,t.factory=this.factory,t.provider=this.provider,t.constraint=this.constraint,t.onActivation=this.onActivation,t.onDeactivation=this.onDeactivation,t.cache=this.cache,t},e}(),O="No matching bindings found for serviceIdentifier:",N="The @inject @multiInject @tagged and @named decorators must be applied to the parameters of a class constructor or a class property.",M=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}(),x=0,F=1;function j(e){return e instanceof RangeError||"Maximum call stack size exceeded"===e.message}function U(e){return"function"==typeof e?e.name:"symbol"==typeof e?e.toString():e}function V(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=H(e.implementationType)),n=n+"\n "+t,e.constraint.metaData&&(n=n+" - "+e.constraint.metaData)}))),n}function B(e,t){return null!==e.parentRequest&&(e.parentRequest.serviceIdentifier===t||B(e.parentRequest,t))}function W(e){e.childRequests.forEach((function(e){if(B(e,e.serviceIdentifier)){var t=function(e){return function e(t,r){void 0===r&&(r=[]);var n=U(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)}W(e)}))}function H(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 q=function(){function e(e){this.id=I(),this.container=e}return e.prototype.addPlan=function(e){this.plan=e},e.prototype.setCurrentRequest=function(e){this.currentRequest=e},e}(),z=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}(),G=function(e,t){this.parentContext=e,this.rootRequest=t},Y=function(){function e(e){this._cb=e}return e.prototype.unwrap=function(){return this._cb()},e}(),$=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}(),J=function(){function e(e,t,r,n){this.id=I(),this.type=e,this.serviceIdentifier=r;var i="symbol"==typeof t?function(e){return e.toString().slice(7,-1)}(t):t;this.name=new $(i||""),this.identifier=t,this.metadata=new Array;var s=null;"string"==typeof n?s=new z("named",n):n instanceof z&&(s=n),null!==s&&this.metadata.push(s)}return e.prototype.hasTag=function(e){for(var t=0,r=this.metadata;t<r.length;t++){if(r[t].key===e)return!0}return!1},e.prototype.isArray=function(){return this.hasTag("multi_inject")},e.prototype.matchesArray=function(e){return this.matchesTag("multi_inject")(e)},e.prototype.isNamed=function(){return this.hasTag("named")},e.prototype.isTagged=function(){return this.metadata.some((function(e){return f.every((function(t){return e.key!==t}))}))},e.prototype.isOptional=function(){return this.matchesTag("optional")(!0)},e.prototype.getNamedTag=function(){return this.isNamed()?this.metadata.filter((function(e){return"named"===e.key}))[0]:null},e.prototype.getCustomTags=function(){return this.isTagged()?this.metadata.filter((function(e){return f.every((function(t){return e.key!==t}))})):null},e.prototype.matchesNamedTag=function(e){return this.matchesTag("named")(e)},e.prototype.matchesTag=function(e){var t=this;return function(r){for(var n=0,i=t.metadata;n<i.length;n++){var s=i[n];if(s.key===e&&s.value===r)return!0}return!1}},e}(),K=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=Z(o,e,t,r,n);null!==a&&s.push(a)}return s}(n,t,s,o,c||d?a.length:r.length),l=ee(e,r,t);return K(K([],u,!0),l,!0)}function Z(e,t,r,n,i){var s=i[e.toString()]||[],o=re(s),a=!0!==o.unmanaged,c=n[e],d=o.inject||o.multiInject;if((c=d||c)instanceof Y&&(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 J(R,o.targetName,c);return u.metadata=s,u}return null}function X(e,t,r,n){var i=e||t;if(void 0===i){var s="Missing required @injectable annotation in: for property "+String(r)+" in class "+n+".";throw new Error(s)}return i}function ee(e,t,r){for(var n=e.getPropertiesMetadata(t),i=[],s=Object.getOwnPropertySymbols(n),o=0,a=Object.keys(n).concat(s);o<a.length;o++){var c=a[o],d=n[c],u=re(d),l=u.targetName||c,p=X(u.inject,u.multiInject,c,r),h=new J(T,l,p);h.metadata=d,i.push(h)}var f=Object.getPrototypeOf(t.prototype).constructor;if(f!==Object){var m=ee(e,f,r);i=K(K([],i,!0),m,!0)}return i}function te(e,t){var r=Object.getPrototypeOf(t.prototype).constructor;if(r!==Object){var n=Q(e,H(r),r,!0),i=n.map((function(e){return e.metadata.filter((function(e){return"unmanaged"===e.key}))})),s=[].concat.apply([],i).length,o=n.length-s;return o>0?o:te(e,r)}return 0}function re(e){var t={};return e.forEach((function(e){t[e.key.toString()]=e.value})),{inject:t.inject,multiInject:t.multi_inject,targetName:t.name,unmanaged:t.unmanaged}}var ne=function(){function e(e,t,r,n,i){this.id=I(),this.serviceIdentifier=e,this.parentContext=t,this.parentRequest=r,this.target=i,this.childRequests=[],this.bindings=Array.isArray(n)?n:[n],this.requestScope=null===r?new Map:null}return e.prototype.addChildRequest=function(t,r,n){var i=new e(t,this.parentContext,this,r,n);return this.childRequests.push(i),i},e}();function ie(e){return e._bindingDictionary}function se(e,t,r,n,i){var s=ae(r.container,i.serviceIdentifier),o=[];return s.length===x&&r.container.options.autoBindInjectable&&"function"==typeof i.serviceIdentifier&&e.getConstructorMetadata(i.serviceIdentifier).compilerGeneratedMetadata&&(r.container.bind(i.serviceIdentifier).toSelf(),s=ae(r.container,i.serviceIdentifier)),o=t?s:s.filter((function(e){var t=new ne(e.serviceIdentifier,r,n,e,i);return e.constraint(t)})),function(e,t,r,n){switch(t.length){case x:if(r.isOptional())return t;var i=U(e),s=O;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+=V(n,i,ae),new Error(s);case F:return t;default:if(r.isArray())return t;s="Ambiguous match found for serviceIdentifier: "+(i=U(e));throw s+=V(n,i,ae),new Error(s)}}(i.serviceIdentifier,o,i,r.container),o}function oe(e,t,r,n,i,s){var o,a;if(null===i){o=se(e,t,n,null,s),a=new ne(r,n,null,o,s);var c=new G(n,a);n.addPlan(c)}else o=se(e,t,n,i,s),a=i.addChildRequest(s.serviceIdentifier,o,s);o.forEach((function(t){var r=null;if(s.isArray())r=a.addChildRequest(t.serviceIdentifier,t,s);else{if(t.cache)return;r=a}if(t.type===S&&null!==t.implementationType){var i=function(e,t){return Q(e,H(t),t,!1)}(e,t.implementationType);if(!n.container.options.skipBaseClassChecks){var o=te(e,t.implementationType);if(i.length<o){var c=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return"The number of constructor arguments in the derived class "+e[0]+" must be >= than the number of constructor arguments of its base class."}(H(t.implementationType));throw new Error(c)}}i.forEach((function(t){oe(e,!1,t.serviceIdentifier,n,r,t)}))}}))}function ae(e,t){var r=[],n=ie(e);return n.hasKey(t)?r=n.get(t):null!==e.parent&&(r=ae(e.parent,t)),r}function ce(e,t,r,n,i,s,o,a){void 0===a&&(a=!1);var c=new q(t),d=function(e,t,r,n,i,s){var o=new z(e?"multi_inject":"inject",r),a=new J(t,n,r,o);if(void 0!==i){var c=new z(i,s);a.metadata.push(c)}return a}(r,n,i,"",s,o);try{return oe(e,a,i,c,null,d),c}catch(e){throw j(e)&&W(c.plan.rootRequest),e}}function de(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then}function ue(e){return!!de(e)||Array.isArray(e)&&e.some(de)}var le,pe=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},he=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},fe=function(e,t,r){e.has(t.id)||e.set(t.id,r)},me=function(e,t){e.cache=t,e.activated=!0,de(t)&&ge(e,t)},ge=function(e,t){return pe(void 0,void 0,void 0,(function(){var r,n;return he(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t];case 1:return r=i.sent(),e.cache=r,[3,3];case 2:throw n=i.sent(),e.cache=null,e.activated=!1,n;case 3:return[2]}}))}))};!function(e){e.DynamicValue="toDynamicValue",e.Factory="toFactory",e.Provider="toProvider"}(le||(le={}));var ve=function(){return ve=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ve.apply(this,arguments)},ye=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},_e=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 Ee(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===R?e.constructorInjections.push(n):(e.propertyRequests.push(r),e.propertyInjections.push(n)),e.isAsync||(e.isAsync=ue(n)),e}),{constructorInjections:[],propertyInjections:[],propertyRequests:[],isAsync:!1})}(t,r),s=ve(ve({},i),{constr:e});n=i.isAsync?function(e){return ye(this,void 0,void 0,(function(){var t,r;return _e(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,we(ve(ve({},e),{constructorInjections:t,propertyInjections:r}))]}}))}))}(s):we(s)}else n=new e;return n}function we(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 ye(this,void 0,void 0,(function(){var t,r,n,i;return _e(this,(function(s){for(t=[],r=0,n=e;r<n.length;r++)i=n[r],Array.isArray(i)?t.push(Promise.all(i)):t.push(i);return[2,Promise.all(t)]}))}))}function Ce(e,t){var r=function(e,t){var r,n;if(Reflect.hasMetadata("post_construct",e)){var i=Reflect.getMetadata("post_construct",e);try{return null===(n=(r=t)[i.value])||void 0===n?void 0:n.call(r)}catch(t){if(t instanceof Error)throw new Error((s=e.name,o=t.message,"@postConstruct error in class "+s+": "+o))}}var s,o}(e,t);return de(r)?r.then((function(){return t})):t}function Pe(e,t){e.scope!==g&&function(e,t){var r="Class cannot be instantiated in "+(e.scope===m?"request":"transient")+" scope.";if("function"==typeof e.onDeactivation)throw new Error(M(t.name,r));if(Reflect.hasMetadata("pre_destroy",t))throw new Error("@preDestroy error in class "+t.name+": "+r)}(e,t)}var Te=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){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},Re=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])}}},ke=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 ke(e)(t)}));if(!t.target.isOptional()||0!==r.length){var o=r[0];return Oe(e,t,o)}}},De=function(e,t){var r=function(e){switch(e.type){case E:return{factory:e.factory,factoryType:le.Factory};case P:return{factory:e.provider,factoryType:le.Provider};case b:return{factory:e.dynamicValue,factoryType:le.DynamicValue};default:throw new Error("Unexpected factory type "+e.type)}}(e);return function(e,t){try{return e()}catch(e){throw j(e)&&(e=t()),e}}((function(){return r.factory.bind(e)(t)}),(function(){return new Error((e=r.factoryType,n=t.currentRequest.serviceIdentifier.toString(),"It looks like there is a circular dependency in one of the '"+e+"' bindings. Please investigate bindings with service identifier '"+n+"'."));var e,n}))},Ie=function(e,t,r){var n,i=t.childRequests;switch(function(e){var t=null;switch(e.type){case y:case w:t=e.cache;break;case _:case S:t=e.implementationType;break;case b:t=e.dynamicValue;break;case P:t=e.provider;break;case E:t=e.factory}if(null===t){var r=U(e.serviceIdentifier);throw new Error("Invalid binding type: "+r)}}(r),r.type){case y:case w:n=r.cache;break;case _:n=r.implementationType;break;case S:n=function(e,t,r,n){Pe(e,t);var i=Ee(t,r,n);return de(i)?i.then((function(e){return Ce(t,e)})):Ce(t,i)}(r,r.implementationType,i,ke(e));break;default:n=De(r,t.parentContext)}return n},Ae=function(e,t,r){var n=function(e,t){return t.scope===g&&t.activated?t.cache:t.scope===m&&e.has(t.id)?e.get(t.id):null}(e,t);return null!==n||function(e,t,r){t.scope===g&&me(t,r),t.scope===m&&fe(e,t,r)}(e,t,n=r()),n},Oe=function(e,t,r){return Ae(e,r,(function(){var n=Ie(e,t,r);return n=de(n)?n.then((function(e){return Ne(t,r,e)})):Ne(t,r,n)}))};function Ne(e,t,r){var n,i=Me(e.parentContext,t,r),s=je(e.parentContext.container),o=s.next();do{n=o.value;var a=e.parentContext,c=e.serviceIdentifier,d=Fe(n,c);i=de(i)?xe(d,a,i):Le(d,a,i),o=s.next()}while(!0!==o.done&&!ie(n).hasKey(e.serviceIdentifier));return i}var Me=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(de(r=n.value(t,r)))return xe(e,t,r);n=e.next()}return r},xe=function(e,t,r){return Te(void 0,void 0,void 0,(function(){var n,i;return Re(this,(function(s){switch(s.label){case 0:return[4,r];case 1:n=s.sent(),i=e.next(),s.label=2;case 2:return i.done?[3,4]:[4,i.value(t,n)];case 3:return n=s.sent(),i=e.next(),[3,2];case 4:return[2,n]}}))}))},Fe=function(e,t){var r=e._activations;return r.hasKey(t)?r.get(t).values():[].values()},je=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 Ue=function(e,t){var r=e.parentRequest;return null!==r&&(!!t(r)||Ue(r,t))},Ve=function(e){return function(t){var r=function(r){return null!==r&&null!==r.target&&r.target.matchesTag(e)(t)};return r.metaData=new z(e,t),r}},Be=Ve("named"),We=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}},He=function(){function e(e){this._binding=e}return e.prototype.when=function(e){return this._binding.constraint=e,new qe(this._binding)},e.prototype.whenTargetNamed=function(e){return this._binding.constraint=Be(e),new qe(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 qe(this._binding)},e.prototype.whenTargetTagged=function(e,t){return this._binding.constraint=Ve(e)(t),new qe(this._binding)},e.prototype.whenInjectedInto=function(e){return this._binding.constraint=function(t){return null!==t&&We(e)(t.parentRequest)},new qe(this._binding)},e.prototype.whenParentNamed=function(e){return this._binding.constraint=function(t){return null!==t&&Be(e)(t.parentRequest)},new qe(this._binding)},e.prototype.whenParentTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&Ve(e)(t)(r.parentRequest)},new qe(this._binding)},e.prototype.whenAnyAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&Ue(t,We(e))},new qe(this._binding)},e.prototype.whenNoAncestorIs=function(e){return this._binding.constraint=function(t){return null!==t&&!Ue(t,We(e))},new qe(this._binding)},e.prototype.whenAnyAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&Ue(t,Be(e))},new qe(this._binding)},e.prototype.whenNoAncestorNamed=function(e){return this._binding.constraint=function(t){return null!==t&&!Ue(t,Be(e))},new qe(this._binding)},e.prototype.whenAnyAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&Ue(r,Ve(e)(t))},new qe(this._binding)},e.prototype.whenNoAncestorTagged=function(e,t){return this._binding.constraint=function(r){return null!==r&&!Ue(r,Ve(e)(t))},new qe(this._binding)},e.prototype.whenAnyAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&Ue(t,e)},new qe(this._binding)},e.prototype.whenNoAncestorMatches=function(e){return this._binding.constraint=function(t){return null!==t&&!Ue(t,e)},new qe(this._binding)},e}(),qe=function(){function e(e){this._binding=e}return e.prototype.onActivation=function(e){return this._binding.onActivation=e,new He(this._binding)},e.prototype.onDeactivation=function(e){return this._binding.onDeactivation=e,new He(this._binding)},e}(),ze=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new He(this._binding),this._bindingOnSyntax=new qe(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}(),Ge=function(){function e(e){this._binding=e}return e.prototype.inRequestScope=function(){return this._binding.scope=m,new ze(this._binding)},e.prototype.inSingletonScope=function(){return this._binding.scope=g,new ze(this._binding)},e.prototype.inTransientScope=function(){return this._binding.scope=v,new ze(this._binding)},e}(),Ye=function(){function e(e){this._binding=e,this._bindingWhenSyntax=new He(this._binding),this._bindingOnSyntax=new qe(this._binding),this._bindingInSyntax=new Ge(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}(),$e=function(){function e(e){this._binding=e}return e.prototype.to=function(e){return this._binding.type=S,this._binding.implementationType=e,new Ye(this._binding)},e.prototype.toSelf=function(){if("function"!=typeof this._binding.serviceIdentifier)throw new Error("The toSelf function can only be applied when a constructor is used as service identifier");var e=this._binding.serviceIdentifier;return this.to(e)},e.prototype.toConstantValue=function(e){return this._binding.type=y,this._binding.cache=e,this._binding.dynamicValue=null,this._binding.implementationType=null,this._binding.scope=g,new ze(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 Ye(this._binding)},e.prototype.toConstructor=function(e){return this._binding.type=_,this._binding.implementationType=e,this._binding.scope=g,new ze(this._binding)},e.prototype.toFactory=function(e){return this._binding.type=E,this._binding.factory=e,this._binding.scope=g,new ze(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=w,this._binding.scope=g,t},e.prototype.toAutoFactory=function(e){return this._binding.type=E,this._binding.factory=function(t){return function(){return t.container.get(e)}},this._binding.scope=g,new ze(this._binding)},e.prototype.toAutoNamedFactory=function(e){return this._binding.type=E,this._binding.factory=function(t){return function(r){return t.container.getNamed(e,r)}},new ze(this._binding)},e.prototype.toProvider=function(e){return this._binding.type=P,this._binding.provider=e,this._binding.scope=g,new ze(this._binding)},e.prototype.toService=function(e){this.toDynamicValue((function(t){return t.container.get(e)}))},e}(),Je=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 Ke=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 Ke,onDeactivations:new Ke}},e}(),Ze=function(){return Ze=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ze.apply(this,arguments)},Xe=function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))},et=function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},tt=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},rt=function(){function e(e){var t=e||{};if("object"!=typeof t)throw new Error("Invalid Container constructor argument. Container options must be an object.");if(void 0===t.defaultScope)t.defaultScope=v;else if(t.defaultScope!==g&&t.defaultScope!==v&&t.defaultScope!==m)throw new Error('Invalid Container option. Default scope must be a string ("singleton" or "transient").');if(void 0===t.autoBindInjectable)t.autoBindInjectable=!1;else if("boolean"!=typeof t.autoBindInjectable)throw new Error("Invalid Container option. Auto bind injectable must be a boolean");if(void 0===t.skipBaseClassChecks)t.skipBaseClassChecks=!1;else if("boolean"!=typeof t.skipBaseClassChecks)throw new Error("Invalid Container option. Skip base check must be a boolean");this.options={autoBindInjectable:t.autoBindInjectable,defaultScope:t.defaultScope,skipBaseClassChecks:t.skipBaseClassChecks},this.id=I(),this._bindingDictionary=new Ke,this._snapshots=[],this._middleware=null,this._activations=new Ke,this._deactivations=new Ke,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=tt([t,r],n,!0).map((function(e){return ie(e)})),a=ie(s);function c(e,t){e.traverse((function(e,r){r.forEach((function(e){t.add(e.serviceIdentifier,e.clone())}))}))}return o.forEach((function(e){c(e,a)})),s},e.prototype.load=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=this._getContainerModuleHelpersFactory(),n=0,i=e;n<i.length;n++){var s=i[n],o=r(s.id);s.registry(o.bindFunction,o.unbindFunction,o.isboundFunction,o.rebindFunction,o.unbindAsyncFunction,o.onActivationFunction,o.onDeactivationFunction)}},e.prototype.loadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Xe(this,void 0,void 0,(function(){var t,r,n,i,s;return et(this,(function(o){switch(o.label){case 0:t=this._getContainerModuleHelpersFactory(),r=0,n=e,o.label=1;case 1:return r<n.length?(i=n[r],s=t(i.id),[4,i.registry(s.bindFunction,s.unbindFunction,s.isboundFunction,s.rebindFunction,s.unbindAsyncFunction,s.onActivationFunction,s.onDeactivationFunction)]):[3,4];case 2:o.sent(),o.label=3;case 3:return r++,[3,1];case 4:return[2]}}))}))},e.prototype.unload=function(){for(var e=this,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];t.forEach((function(t){var r=e._removeModuleBindings(t.id);e._deactivateSingletons(r),e._removeModuleHandlers(t.id)}))},e.prototype.unloadAsync=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Xe(this,void 0,void 0,(function(){var t,r,n,i;return et(this,(function(s){switch(s.label){case 0:t=0,r=e,s.label=1;case 1:return t<r.length?(n=r[t],i=this._removeModuleBindings(n.id),[4,this._deactivateSingletonsAsync(i)]):[3,4];case 2:s.sent(),this._removeModuleHandlers(n.id),s.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},e.prototype.bind=function(e){var t=this.options.defaultScope||v,r=new A(e,t);return this._bindingDictionary.add(e,r),new $e(r)},e.prototype.rebind=function(e){return this.unbind(e),this.bind(e)},e.prototype.rebindAsync=function(e){return Xe(this,void 0,void 0,(function(){return et(this,(function(t){switch(t.label){case 0:return[4,this.unbindAsync(e)];case 1:return t.sent(),[2,this.bind(e)]}}))}))},e.prototype.unbind=function(e){if(this._bindingDictionary.hasKey(e)){var t=this._bindingDictionary.get(e);this._deactivateSingletons(t)}this._removeServiceFromDictionary(e)},e.prototype.unbindAsync=function(e){return Xe(this,void 0,void 0,(function(){var t;return et(this,(function(r){switch(r.label){case 0:return this._bindingDictionary.hasKey(e)?(t=this._bindingDictionary.get(e),[4,this._deactivateSingletonsAsync(t)]):[3,2];case 1:r.sent(),r.label=2;case 2:return this._removeServiceFromDictionary(e),[2]}}))}))},e.prototype.unbindAll=function(){var e=this;this._bindingDictionary.traverse((function(t,r){e._deactivateSingletons(r)})),this._bindingDictionary=new Ke},e.prototype.unbindAllAsync=function(){return Xe(this,void 0,void 0,(function(){var e,t=this;return et(this,(function(r){switch(r.label){case 0:return e=[],this._bindingDictionary.traverse((function(r,n){e.push(t._deactivateSingletonsAsync(n))})),[4,Promise.all(e)];case 1:return r.sent(),this._bindingDictionary=new Ke,[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 J(k,"",t,new z(r,n)),s=new q(e);return new ne(t,s,null,[],i)}(this,e,t,r);n=i.some((function(e){return e.constraint(s)}))}return!n&&this.parent&&(n=this.parent.isBoundTagged(e,t,r)),n},e.prototype.snapshot=function(){this._snapshots.push(Je.of(this._bindingDictionary.clone(),this._middleware,this._activations.clone(),this._deactivations.clone(),this._moduleActivationStore.clone()))},e.prototype.restore=function(){var e=this._snapshots.pop();if(void 0===e)throw new Error("No snapshot available to restore.");this._bindingDictionary=e.bindings,this._activations=e.activations,this._deactivations=e.deactivations,this._middleware=e.middleware,this._moduleActivationStore=e.moduleActivationStore},e.prototype.createChild=function(t){var r=new e(t||this.options);return r.parent=this,r},e.prototype.applyMiddleware=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=this._middleware?this._middleware:this._planAndResolve();this._middleware=e.reduce((function(e,t){return t(e)}),r)},e.prototype.applyCustomMetadataReader=function(e){this._metadataReader=e},e.prototype.get=function(e){var t=this._getNotAllArgs(e,!1);return this._getButThrowIfAsync(t)},e.prototype.getAsync=function(e){return Xe(this,void 0,void 0,(function(){var t;return et(this,(function(r){return t=this._getNotAllArgs(e,!1),[2,this._get(t)]}))}))},e.prototype.getTagged=function(e,t,r){var n=this._getNotAllArgs(e,!1,t,r);return this._getButThrowIfAsync(n)},e.prototype.getTaggedAsync=function(e,t,r){return Xe(this,void 0,void 0,(function(){var n;return et(this,(function(i){return n=this._getNotAllArgs(e,!1,t,r),[2,this._get(n)]}))}))},e.prototype.getNamed=function(e,t){return this.getTagged(e,"named",t)},e.prototype.getNamedAsync=function(e,t){return this.getTaggedAsync(e,"named",t)},e.prototype.getAll=function(e){var t=this._getAllArgs(e);return this._getButThrowIfAsync(t)},e.prototype.getAllAsync=function(e){var t=this._getAllArgs(e);return this._getAll(t)},e.prototype.getAllTagged=function(e,t,r){var n=this._getNotAllArgs(e,!0,t,r);return this._getButThrowIfAsync(n)},e.prototype.getAllTaggedAsync=function(e,t,r){var n=this._getNotAllArgs(e,!0,t,r);return this._getAll(n)},e.prototype.getAllNamed=function(e,t){return this.getAllTagged(e,"named",t)},e.prototype.getAllNamedAsync=function(e,t){return this.getAllTaggedAsync(e,"named",t)},e.prototype.resolve=function(e){var t=this.isBound(e);t||this.bind(e).toSelf();var r=this.get(e);return t||this.unbind(e),r},e.prototype._preDestroy=function(e,t){var r,n;if(Reflect.hasMetadata("pre_destroy",e))return null===(n=(r=t)[Reflect.getMetadata("pre_destroy",e).value])||void 0===n?void 0:n.call(r)},e.prototype._removeModuleHandlers=function(e){var t=this._moduleActivationStore.remove(e);this._activations.removeIntersection(t.onActivations),this._deactivations.removeIntersection(t.onDeactivations)},e.prototype._removeModuleBindings=function(e){return this._bindingDictionary.removeByCondition((function(t){return t.moduleId===e}))},e.prototype._deactivate=function(e,t){var r=this,n=Object.getPrototypeOf(t).constructor;try{if(this._deactivations.hasKey(e.serviceIdentifier)){var i=this._deactivateContainer(t,this._deactivations.get(e.serviceIdentifier).values());if(de(i))return this._handleDeactivationError(i.then((function(){return r._propagateContainerDeactivationThenBindingAndPreDestroyAsync(e,t,n)})),n)}var s=this._propagateContainerDeactivationThenBindingAndPreDestroy(e,t,n);if(de(s))return this._handleDeactivationError(s,n)}catch(e){if(e instanceof Error)throw new Error(M(n.name,e.message))}},e.prototype._handleDeactivationError=function(e,t){return Xe(this,void 0,void 0,(function(){var r;return et(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,e];case 1:return n.sent(),[3,3];case 2:if((r=n.sent())instanceof Error)throw new Error(M(t.name,r.message));return[3,3];case 3:return[2]}}))}))},e.prototype._deactivateContainer=function(e,t){for(var r=this,n=t.next();n.value;){var i=n.value(e);if(de(i))return i.then((function(){return r._deactivateContainerAsync(e,t)}));n=t.next()}},e.prototype._deactivateContainerAsync=function(e,t){return Xe(this,void 0,void 0,(function(){var r;return et(this,(function(n){switch(n.label){case 0:r=t.next(),n.label=1;case 1:return r.value?[4,r.value(e)]:[3,3];case 2:return n.sent(),r=t.next(),[3,1];case 3:return[2]}}))}))},e.prototype._getContainerModuleHelpersFactory=function(){var e=this,t=function(e,t){e._binding.moduleId=t},r=function(r){return function(n){var i=e.rebind(n);return t(i,r),i}},n=function(t){return function(r,n){e._moduleActivationStore.addActivation(t,r,n),e.onActivation(r,n)}},i=function(t){return function(r,n){e._moduleActivationStore.addDeactivation(t,r,n),e.onDeactivation(r,n)}};return function(s){return{bindFunction:(o=s,function(r){var n=e.bind(r);return t(n,o),n}),isboundFunction:function(t){return e.isBound(t)},onActivationFunction:n(s),onDeactivationFunction:i(s),rebindFunction:r(s),unbindFunction:function(t){return e.unbind(t)},unbindAsyncFunction:function(t){return e.unbindAsync(t)}};var o}},e.prototype._getAll=function(e){return Promise.all(this._get(e))},e.prototype._get=function(e){var t=Ze(Ze({},e),{contextInterceptor:function(e){return e},targetType:k});if(this._middleware){var r=this._middleware(t);if(null==r)throw new Error("Invalid return type in middleware. Middleware must return!");return r}return this._planAndResolve()(t)},e.prototype._getButThrowIfAsync=function(e){var t=this._get(e);if(ue(t))throw new Error("You are attempting to construct '"+e.serviceIdentifier+"' in a synchronous way\n but it has asynchronous dependencies.");return t},e.prototype._getAllArgs=function(e){return{avoidConstraints:!0,isMultiInject:!0,serviceIdentifier:e}},e.prototype._getNotAllArgs=function(e,t,r,n){return{avoidConstraints:!1,isMultiInject:t,serviceIdentifier:e,key:r,value:n}},e.prototype._planAndResolve=function(){var e=this;return function(t){var r=ce(e._metadataReader,e,t.isMultiInject,t.targetType,t.serviceIdentifier,t.key,t.value,t.avoidConstraints);return function(e){return ke(e.plan.rootRequest.requestScope)(e.plan.rootRequest)}(r=t.contextInterceptor(r))}},e.prototype._deactivateIfSingleton=function(e){var t=this;if(e.activated)return de(e.cache)?e.cache.then((function(r){return t._deactivate(e,r)})):this._deactivate(e,e.cache)},e.prototype._deactivateSingletons=function(e){for(var t=0,r=e;t<r.length;t++){var n=r[t];if(de(this._deactivateIfSingleton(n)))throw new Error("Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)")}},e.prototype._deactivateSingletonsAsync=function(e){return Xe(this,void 0,void 0,(function(){var t=this;return et(this,(function(r){switch(r.label){case 0:return[4,Promise.all(e.map((function(e){return t._deactivateIfSingleton(e)})))];case 1:return r.sent(),[2]}}))}))},e.prototype._propagateContainerDeactivationThenBindingAndPreDestroy=function(e,t,r){return this.parent?this._deactivate.bind(this.parent)(e,t):this._bindingDeactivationAndPreDestroy(e,t,r)},e.prototype._propagateContainerDeactivationThenBindingAndPreDestroyAsync=function(e,t,r){return Xe(this,void 0,void 0,(function(){return et(this,(function(n){switch(n.label){case 0:return this.parent?[4,this._deactivate.bind(this.parent)(e,t)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,this._bindingDeactivationAndPreDestroyAsync(e,t,r)];case 3:n.sent(),n.label=4;case 4:return[2]}}))}))},e.prototype._removeServiceFromDictionary=function(e){try{this._bindingDictionary.remove(e)}catch(t){throw new Error("Could not unbind serviceIdentifier: "+U(e))}},e.prototype._bindingDeactivationAndPreDestroy=function(e,t,r){var n=this;if("function"==typeof e.onDeactivation){var i=e.onDeactivation(t);if(de(i))return i.then((function(){return n._preDestroy(r,t)}))}return this._preDestroy(r,t)},e.prototype._bindingDeactivationAndPreDestroyAsync=function(e,t,r){return Xe(this,void 0,void 0,(function(){return et(this,(function(n){switch(n.label){case 0:return"function"!=typeof e.onDeactivation?[3,2]:[4,e.onDeactivation(t)];case 1:n.sent(),n.label=2;case 2:return[4,this._preDestroy(r,t)];case 3:return n.sent(),[2]}}))}))},e}();function nt(e,t,r,n){!function(e){if(void 0!==e)throw new Error(N)}(t),st("inversify:tagged",e,r.toString(),n)}function it(e){var t=[];if(Array.isArray(e)){var r=function(e){for(var t=new Set,r=0,n=e;r<n.length;r++){var i=n[r];if(t.has(i))return i;t.add(i)}}((t=e).map((function(e){return e.key})));if(void 0!==r)throw new Error("Metadata key was used more than once in a parameter: "+r.toString())}else t=[e];return t}function st(e,t,r,n){var i=it(n),s={};Reflect.hasOwnMetadata(e,t)&&(s=Reflect.getMetadata(e,t));var o=s[r];if(void 0===o)o=[];else for(var a=function(e){if(i.some((function(t){return t.key===e.key})))throw new Error("Metadata key was used more than once in a parameter: "+e.key.toString())},c=0,d=o;c<d.length;c++){a(d[c])}o.push.apply(o,i),s[r]=o,Reflect.defineMetadata(e,s,t)}function ot(e){return function(t,r,n){"number"==typeof n?nt(t,r,n,e):function(e,t,r){if(void 0!==e.prototype)throw new Error(N);st("inversify:tagged_props",e.constructor,t,r)}(t,r,e)}}function at(){return function(e){if(Reflect.hasOwnMetadata("inversify:paramtypes",e))throw new Error("Cannot apply @injectable decorator multiple times.");var t=Reflect.getMetadata("design:paramtypes",e)||[];return Reflect.defineMetadata("inversify:paramtypes",t,e),e}}var ct,dt=(ct="inject",function(e){return function(t,r,n){if(void 0===e){var i="function"==typeof t?t.name:t.constructor.name;throw new Error("@inject called with undefined this could mean that the class "+i+" has a circular dependency problem. You can use a LazyServiceIdentifier to overcome this limitation.")}return ot(new z(ct,e))(t,r,n)}});const ut=3,lt=4,pt=6,ht=7;var ft;!function(e){e[e.Continue=100]="Continue",e[e.SwitchingProtocols=101]="SwitchingProtocols",e[e.Processing=102]="Processing",e[e.OK=200]="OK",e[e.Created=201]="Created",e[e.Accepted=202]="Accepted",e[e.NonAuthoritativeInformation=203]="NonAuthoritativeInformation",e[e.NoContent=204]="NoContent",e[e.ResetContent=205]="ResetContent",e[e.PartialContent=206]="PartialContent",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.Found=302]="Found",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.UnsupportedMediaType=415]="UnsupportedMediaType",e[e.TooManyRequests=429]="TooManyRequests",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout"}(ft||(ft={}));var mt;const gt={customerId:String("b149fa74b11d989a60fb08e98e6a82883de0b468"),sdk_url:String("https://effectssdk.ai/sdk/audio/"),api_url:String("https://effectssdk.ai/sdk/session/"),version:"2.3.5"},vt={customerId:String("89c41ecf3b3f46fef5dfa9f96842014c21d4901c"),sdk_url:String("https://effectssdk.ai/sdk/"),api_url:String("https://effectssdk.ai/sdk/session/")},yt=()=>{};let _t=class{constructor(e){var t,r,n,i,s,o,a,c,u;mt.set(this,void 0),d(this,mt,{denoiser:null!==(t=e.denoiser)&&void 0!==t?t:"rnnoise",asdk:Object.assign(Object.assign({},gt),e.asdk),signalingServerUrl:null!==(r=e.signalingServerUrl)&&void 0!==r?r:String("https://signaling-api.livedigital.space/v1"),logLevel:null!==(n=e.logLevel)&&void 0!==n?n:ut,sendAnalytics:null!==(i=e.sendAnalytics)&&void 0!==i&&i,onLogMessage:null!==(s=e.onLogMessage)&&void 0!==s?s:yt,onIssues:null!==(o=e.onIssues)&&void 0!==o?o:yt,disableWid:null!==(a=e.disableWid)&&void 0!==a&&a,effectsSDKParams:Object.assign(Object.assign({},vt),e.effectsSDKParams),onNetworkScoresUpdated:null!==(c=e.onNetworkScoresUpdated)&&void 0!==c?c:yt,getStatsInterval:null!==(u=e.getStatsInterval)&&void 0!==u?u:5e3,staticFilesPath:e.staticFilesPath||window.location.origin},"f")}get(e){return c(this,mt,"f")[e]}set(e,t){c(this,mt,"f")[e]=t}};mt=new WeakMap,_t=i([at(),o("design:paramtypes",[Object])],_t);var bt=_t;class Et extends t{constructor(){super(),this.addListener=(e,t)=>this.on(e,t),this.removeListener=(e,t)=>this.off(e,t),this.prependListener=(e,t)=>(super.prependListener(e,t),this),this.prependOnceListener=(e,t)=>(super.prependOnceListener(e,t),this),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!!super.listenerCount(e)}}on(e,t){return super.on(e,t)}off(e,t){return super.off(e,t)}once(e,t){return super.once(e,t)}removeAllListeners(e){return super.removeAllListeners(e),this}}Error;const wt=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],St=({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]=St({from:e[r],seen:t.slice(),forceEnumerable:n}):i[r]=s);for(const{property:t,enumerable:r}of wt)"string"==typeof e[t]&&Object.defineProperty(i,t,{value:e[t],enumerable:!!n||r,configurable:!0,writable:!0});return i};var Ct=e=>"object"==typeof e&&null!==e?St({from:e,seen:[],forceEnumerable:!0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e;class Pt extends Error{constructor(e,t){var r;if(t instanceof Pt)return super(t.message),Object.setPrototypeOf(this,new.target.prototype),this.name=new.target.name,this.errorCode=t.errorCode,void(this.cause=t.cause);const n=Ct(t),i=null!==(r=(e=>{if("string"==typeof e)return e;if(e instanceof Error)return e.message;if(e&&"object"==typeof e&&"message"in e){const t=e.message;return"string"==typeof t?t:void 0}})(n))&&void 0!==r?r:"Operation failed";super(i),Object.setPrototypeOf(this,new.target.prototype),this.name=new.target.name,this.errorCode=e,this.cause=Ct(n)}}var Tt,Rt,kt,Dt;function It(){}function At(){At.init.call(this)}function Ot(e){return void 0===e._maxListeners?At.defaultMaxListeners:e._maxListeners}function Nt(e,t,r){if(t)e.call(r);else for(var n=e.length,i=Bt(e,n),s=0;s<n;++s)i[s].call(r)}function Mt(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,s=Bt(e,i),o=0;o<i;++o)s[o].call(r,n)}function Lt(e,t,r,n,i){if(t)e.call(r,n,i);else for(var s=e.length,o=Bt(e,s),a=0;a<s;++a)o[a].call(r,n,i)}function xt(e,t,r,n,i,s){if(t)e.call(r,n,i,s);else for(var o=e.length,a=Bt(e,o),c=0;c<o;++c)a[c].call(r,n,i,s)}function Ft(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,s=Bt(e,i),o=0;o<i;++o)s[o].apply(r,n)}function jt(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 It,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=Ot(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 Ut(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 Vt(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 Bt(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}It.prototype=Object.create(null),At.EventEmitter=At,At.usingDomains=!1,At.prototype.domain=void 0,At.prototype._events=void 0,At.prototype._maxListeners=void 0,At.defaultMaxListeners=10,At.init=function(){this.domain=null,At.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new It,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},At.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},At.prototype.getMaxListeners=function(){return Ot(this)},At.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:Nt(r,u,this);break;case 2:Mt(r,u,this,arguments[1]);break;case 3:Lt(r,u,this,arguments[1],arguments[2]);break;case 4:xt(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),s=1;s<n;s++)i[s-1]=arguments[s];Ft(r,u,this,i)}return!0},At.prototype.addListener=function(e,t){return jt(this,e,t,!1)},At.prototype.on=At.prototype.addListener,At.prototype.prependListener=function(e,t){return jt(this,e,t,!0)},At.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Ut(this,e,t)),this},At.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Ut(this,e,t)),this},At.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 It:(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 It,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},At.prototype.off=function(e,t){return this.removeListener(e,t)},At.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new It,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new It: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 It,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},At.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):[]},At.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Vt.call(e,t)},At.prototype.listenerCount=Vt,At.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};class Wt extends At{}!function(e){e.Issue="issue",e.NetworkScoresUpdated="network-scores-updated",e.StatsParsingFinished="stats-parsing-finished"}(Tt||(Tt={})),function(e){e.Network="network",e.CPU="cpu",e.Server="server",e.Stream="stream"}(Rt||(Rt={})),function(e){e.OutboundNetworkQuality="outbound-network-quality",e.InboundNetworkQuality="inbound-network-quality",e.OutboundNetworkMediaLatency="outbound-network-media-latency",e.InboundNetworkMediaLatency="inbound-network-media-latency",e.NetworkMediaSyncFailure="network-media-sync-failure",e.OutboundNetworkThroughput="outbound-network-throughput",e.InboundNetworkThroughput="inbound-network-throughput",e.EncoderCPUThrottling="encoder-cpu-throttling",e.DecoderCPUThrottling="decoder-cpu-throttling",e.ServerIssue="server-issue",e.UnknownVideoDecoderIssue="unknown-video-decoder",e.LowInboundMOS="low-inbound-mean-opinion-score",e.LowOutboundMOS="low-outbound-mean-opinion-score",e.FrozenVideoTrack="frozen-video-track",e.MissingVideoStreamData="missing-video-stream-data",e.MissingAudioStreamData="missing-audio-stream-data"}(kt||(kt={})),function(e){e[e.BAD=2.1]="BAD",e[e.POOR=2.6]="POOR",e[e.FAIR=3.1]="FAIR",e[e.GOOD=3.8]="GOOD",e[e.EXCELLENT=4.3]="EXCELLENT"}(Dt||(Dt={}));class Ht extends At{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(Ht.STATS_REPORTS_PARSED,{timeTaken:r,reportItems:t}),t.forEach((e=>{this.emit(Ht.STATS_REPORT_READY_EVENT,e)}))}}const qt=(()=>{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 zt{#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,qt({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=1e3*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=1e3*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;i-=2.5*r;const s=1+.035*i+7e-6*i*(i-60)*(100-i);return Math.max(0,Math.min(5,s))}}class Gt{#t=new Map;#r;#n;constructor(e={}){this.#r=e.statsCleanupTtlMs??35e3,this.#n=e.maxParsedStatsStorageSize??5}detect(e,t){const r={...e,networkScores:{...t,statsSamples:t?.statsSamples||{}}},n=this.performDetection(r);return this.setLastProcessedStats(e.connection.id,r),this.performPrevStatsCleanup({connectionId:e.connection.id}),n}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;this.#t.has(t)&&qt({taskId:t,delayMs:this.#r,callback:()=>{this.deleteLastProcessedStats(t),"function"==typeof r&&r()}})}setLastProcessedStats(e,t){if(!e||t.connection.id!==e)return;const r=this.#t.get(e)??[];r.push(t),r.length>this.#n&&r.shift(),this.#t.set(e,r)}getLastProcessedStats(e){const t=this.#t.get(e);return t?.[t.length-1]}getAllLastProcessedStats(e){return this.#t.get(e)??[]}deleteLastProcessedStats(e){this.#t.delete(e)}}class Yt extends Gt{#i;constructor(e={}){super(e),this.#i=e.availableOutgoingBitrateThreshold??1e5}performDetection(e){const t=[],{availableOutgoingBitrate:r}=e.connection;if(void 0===r)return t;const n=e.audio.outbound.reduce(((e,t)=>e+t.targetBitrate),0),i=e.video.outbound.reduce(((e,t)=>e+t.bitrate),0);if(!n&&!i)return t;const s={availableOutgoingBitrate:r,videoStreamsTotalBitrate:i,audioStreamsTotalTargetBitrate:n};return n>r||i>0&&r<this.#i?(t.push({statsSample:s,type:Rt.Network,reason:kt.OutboundNetworkThroughput}),t):t}}class $t extends Gt{#s;#o;#a;#c;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200,this.#a=e.highJitterBufferDelayThresholdMs??500,this.#c=e.highRttThresholdMs??250}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...e.audio?.inbound,...e.video?.inbound];if(!r.length)return t;const n=this.getLastProcessedStats(e.connection.id);if(!n)return t;const i=[...n.video?.inbound,...n.audio?.inbound],{packetsReceived:s}=e.connection,o=n.connection.packetsReceived,a=r.reduce(((e,t)=>{const r=i.find((e=>e.ssrc===t.ssrc)),n=r?.jitterBufferDelay||0,s=r?.jitterBufferEmittedCount||0,o=t.jitterBufferDelay-n,a=t.jitterBufferEmittedCount-s,c=o&&a?1e3*o/a:0;return{sumJitter:e.sumJitter+t.jitter,sumJitterBufferDelayMs:e.sumJitterBufferDelayMs+c,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,sumJitterBufferDelayMs:0,packetsLost:0,lastPacketsLost:0}),c=1e3*e.connection.currentRoundTripTime||0,{sumJitter:d,sumJitterBufferDelayMs:u}=a,l=1e3*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,_=p>this.#a,b=y&&!v&&!g,E=g&&v,w=v&&_,S={rtt:c,packetLossPct:m,avgJitter:l,avgJitterBufferDelay:p};return(v||g)&&t.push({statsSample:S,type:Rt.Network,reason:kt.InboundNetworkQuality,iceCandidate:e.connection.local.id}),b&&t.push({statsSample:S,type:Rt.Server,reason:kt.ServerIssue,iceCandidate:e.connection.remote.id}),E&&t.push({statsSample:S,type:Rt.Network,reason:kt.InboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),w&&t.push({statsSample:S,type:Rt.Network,reason:kt.NetworkMediaSyncFailure,iceCandidate:e.connection.local.id}),t}}class Jt extends Gt{#d;constructor(e={}){super(),this.#d=e.correctedSamplesThresholdPct??5}performDetection(e){return this.processData(e)}processData(e){const t=e.audio.inbound,r=[],n=this.getLastProcessedStats(e.connection.id)?.audio.inbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;const i=e.track.insertedSamplesForDeceleration+e.track.removedSamplesForAcceleration,s=t.track.insertedSamplesForDeceleration+t.track.removedSamplesForAcceleration;if(i===s)return;const o=e.track.totalSamplesReceived-t.track.totalSamplesReceived,a=i-s,c=Math.round(100*a/o),d={correctedSamplesPct:c};c>this.#d&&r.push({statsSample:d,type:Rt.Network,reason:kt.NetworkMediaSyncFailure,ssrc:e.ssrc})})),r):r}}class Kt extends Gt{#s;#o;constructor(e={}){super(),this.#s=e.highPacketLossThresholdPct??5,this.#o=e.highJitterThreshold??200}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...e.remote?.audio.inbound||[],...e.remote?.video.inbound||[]];if(!r.length)return t;const n=this.getLastProcessedStats(e.connection.id);if(!n)return t;const i=[...n.remote?.audio.inbound||[],...n.remote?.video.inbound||[]],{packetsSent:s}=e.connection,o=n.connection.packetsSent,a=r.reduce(((e,t)=>{const r=i.find((e=>e.ssrc===t.ssrc));return{sumJitter:e.sumJitter+t.jitter,packetsLost:e.packetsLost+t.packetsLost,lastPacketsLost:e.lastPacketsLost+(r?.packetsLost||0)}}),{sumJitter:0,packetsLost:0,lastPacketsLost:0}),c=1e3*e.connection.currentRoundTripTime||0,{sumJitter:d}=a,u=1e3*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:Rt.Network,reason:kt.OutboundNetworkMediaLatency,iceCandidate:e.connection.local.id}),g&&t.push({statsSample:v,type:Rt.Network,reason:kt.OutboundNetworkQuality,iceCandidate:e.connection.local.id}),t}}class Qt extends Gt{performDetection(e){return this.processData(e)}processData(e){const t=e.video.outbound.filter((e=>"none"!==e.qualityLimitationReason)),r=[],n=this.getLastProcessedStats(e.connection.id)?.video.outbound;return n?(t.forEach((e=>{const t=n.find((t=>t.ssrc===e.ssrc));if(!t)return;const i={qualityLimitationReason:e.qualityLimitationReason};e.framesSent>t.framesSent||("cpu"===e.qualityLimitationReason&&r.push({statsSample:i,type:Rt.CPU,reason:kt.EncoderCPUThrottling,ssrc:e.ssrc}),"bandwidth"===e.qualityLimitationReason&&r.push({statsSample:i,type:Rt.Network,reason:kt.OutboundNetworkThroughput,ssrc:e.ssrc}))})),r):r}}class Zt extends Gt{UNKNOWN_DECODER="unknown";#u={};performDetection(e){return this.processData(e)}performPrevStatsCleanup(e){const{connectionId:t,cleanupCallback:r}=e;super.performPrevStatsCleanup({...e,cleanupCallback:()=>{delete this.#u[t],"function"==typeof r&&r()}})}processData(e){const t=[],{id:r}=e.connection,n=this.getLastProcessedStats(r)?.video.inbound;return e.video.inbound.forEach((e=>{const{decoderImplementation:i,ssrc:s}=e,o=n?.find((e=>e.ssrc===s));if(o)if(i===this.UNKNOWN_DECODER){if(!this.hadLastDecoderWithIssue(r,s)){this.setLastDecoderWithIssue(r,s,this.UNKNOWN_DECODER);const n={mimeType:e.mimeType,decoderImplementation:i};t.push({ssrc:s,statsSample:n,type:Rt.Stream,reason:kt.UnknownVideoDecoderIssue,trackIdentifier:e.track.trackIdentifier})}}else this.setLastDecoderWithIssue(r,s,void 0)})),t}setLastDecoderWithIssue(e,t,r){const n=this.#u[e]??{};void 0===r?delete n[t]:n[t]=r,this.#u[e]=n}hadLastDecoderWithIssue(e,t){const r=this.#u[e];return(r&&r[t])===this.UNKNOWN_DECODER}}const Xt=e=>e.reduce(((e,t)=>e+t),0)/e.length,er=(e,t,r=30)=>{const n=[];for(let r=1;r<t.length-1;r+=1){const i=t[r]?.video?.inbound.find((t=>t.ssrc===e));if(!i)continue;const s=t[r-1]?.video?.inbound?.find((t=>t.ssrc===e));if(!i||!s)continue;const o=i.timestamp-s.timestamp,a=i.framesDecoded-s.framesDecoded;if(a>0){const e=o/a;n.push(e)}}return!(n.length<=1)&&(e=>{const t=((e,t)=>t.reduce(((t,r)=>t+(r-e)**2),0)/t.length)(Xt(e),e);return Math.sqrt(t)})(n)>r},tr=(e,t)=>{for(let r=1;r<t.length;r+=1){const n=t[r].video.inbound.find((t=>t.ssrc===e));if(!n)continue;const i=t[r-1].video.inbound.find((t=>t.ssrc===e)),s=n.frameWidth!==i?.frameWidth,o=n.frameHeight!==i?.frameHeight;if(s||o)return!0}return!1};class rr extends Gt{#l;#p;#h;constructor(e={}){super(),this.#l=e.avgFreezeDurationThresholdMs??1e3,this.#p=e.frozenDurationThresholdPct??30,this.#h=e.minMosQuality??Dt.BAD}performDetection(e){const t=e.networkScores.inbound;return void 0!==t&&t<=this.#h?[]:this.processData(e)}processData(e){const t=[],r=this.getAllLastProcessedStats(e.connection.id);if(0===r.length)return[];const n=e.video.inbound.map((t=>{const n=r[r.length-1].video.inbound.find((e=>e.ssrc===t.ssrc));if(!n)return;if(tr(t.ssrc,[r[r.length-1],e]))return;if(er(t.ssrc,r))return;const i=t.freezeCount-(n.freezeCount??0),s=1e3*(t.totalFreezesDuration-(n.totalFreezesDuration??0)),o=i>0?s/i:0,a=s/(t.timestamp-n.timestamp)*100;return a>this.#p||o>this.#l?{ssrc:t.ssrc,avgFreezeDurationMs:o,frozenDurationPct:a}:void 0})).filter((e=>void 0!==e));return n.length>0&&(t.push({type:Rt.Stream,reason:kt.FrozenVideoTrack,statsSample:{ssrcs:n.map((e=>e.ssrc))}}),this.deleteLastProcessedStats(e.connection.id)),t}}class nr extends Gt{#f;#m;#h;constructor(e={}){super(e),this.#f=e.volatilityThreshold??8,this.#m=e.affectedStreamsPercentThreshold??30,this.#h=e.minMosQuality??Dt.BAD}performDetection(e){return[...this.getAllLastProcessedStats(e.connection.id),e].find((e=>void 0!==e.networkScores.inbound&&e.networkScores.inbound<=this.#h))?[]:this.processData(e)}processData(e){const t=[],r=[...this.getAllLastProcessedStats(e.connection.id),e],n=e.video.inbound.map((e=>{if(r.length<5)return;if(tr(e.ssrc,r))return;const t=[];for(let n=0;n<r.length-1;n+=1){const i=r[n].video.inbound.find((t=>t.ssrc===e.ssrc));void 0!==i?.framesPerSecond&&t.push(i.framesPerSecond)}if(t.length<5)return;if(er(e.ssrc,r))return;const n=(e=>{if(0===e.length)throw new Error("Cannot calculate volatility for empty array");const t=Xt(e);return e.reduce(((e,r)=>e+Math.abs(r-t)),0)/e.length*100/t})(t);return n>this.#f?{ssrc:e.ssrc,allFps:t,volatility:n}:void 0})).filter((e=>Boolean(e)));if(0===n.length)return t;const i=n.length/(e.video.inbound.length/100);return i>this.#m&&(t.push({type:Rt.CPU,reason:kt.DecoderCPUThrottling,statsSample:{affectedStreamsPercent:i,throtthedStreams:n}}),this.deleteLastProcessedStats(e.connection.id)),t}}class ir extends Gt{#g=new Map;#v;#y;constructor(e={}){super(),this.#v=e.timeoutMs??15e3,this.#y=e.steps??3}performDetection(e){return this.processData(e)}processData(e){const t=[],r=[...this.getAllLastProcessedStats(e.connection.id),e];if(r.length<this.#y)return t;const n=r.slice(-this.#y),i=n.map((e=>e.video.inbound)),s=n.map((e=>e.audio.inbound));return t.push(...this.detectMissingData(s,Rt.Stream,kt.MissingAudioStreamData)),t.push(...this.detectMissingData(i,Rt.Stream,kt.MissingVideoStreamData)),new Set(this.#g.keys()).forEach((e=>{const t=this.#g.get(e);t&&Date.now()-t>this.#v&&this.removeMarkedIssue(e)})),t}detectMissingData(e,t,r){const n=[],i=e.pop(),s=ir.mapStatsByTrackId(e);return i.forEach((e=>{const i=e.track.trackIdentifier,o=s.get(i);if(!Array.isArray(o)||0===o.length)return;if(e.track.detached||e.track.ended)return;if(!ir.isAllBytesReceivedDidntChange(e.bytesReceived,o))return void this.removeMarkedIssue(i);if(!this.markIssue(i))return;const a={bytesReceived:e.bytesReceived};n.push({type:t,reason:r,statsSample:a,trackIdentifier:i})})),n}static mapStatsByTrackId(e){const t=new Map;return e.forEach((e=>{e.forEach((e=>{const r=t.get(e.track.trackIdentifier)||[];r.push(e),t.set(e.track.trackIdentifier,r)}))})),t}static isAllBytesReceivedDidntChange(e,t){for(let r=0;r<t.length;r+=1)if(t[r].bytesReceived!==e)return!1;return!0}markIssue(e){const t=Date.now(),r=this.#g.get(e);return(!r||t-r>this.#v)&&(this.#g.set(e,t),!0)}removeMarkedIssue(e){this.#g.delete(e)}}const sr=e=>"closed"===e.iceConnectionState||"closed"===e.connectionState,or=(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 ar{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(!sr(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 cr{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(!sr(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()}),qt({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=or(e,r,"bytesReceived"),e.packetRate=or(e,r,"packetsReceived")})),e.audio.outbound.forEach((e=>{const r=t.audio.outbound.find((({id:t})=>t===e.id));e.bitrate=or(e,r,"bytesSent"),e.packetRate=or(e,r,"packetsSent")})),e.video.inbound.forEach((e=>{const r=t.video.inbound.find((({id:t})=>t===e.id));e.bitrate=or(e,r,"bytesReceived"),e.packetRate=or(e,r,"packetsReceived")})),e.video.outbound.forEach((e=>{const r=t.video.outbound.find((({id:t})=>t===e.id));e.bitrate=or(e,r,"bytesSent"),e.packetRate=or(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 dr{eventEmitter;#_=!1;detectors=[];networkScoresCalculator;statsReporter;compositeStatsParser;logger;autoAddPeerConnections;constructor(e){this.logger=e.logger??{debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},this.eventEmitter=e.issueEmitter??new Wt,e.onIssues&&this.eventEmitter.on(Tt.Issue,e.onIssues),e.onNetworkScoresUpdated&&this.eventEmitter.on(Tt.NetworkScoresUpdated,e.onNetworkScoresUpdated),this.detectors=e.detectors??[new Qt,new $t,new Kt,new Jt,new Yt,new Zt,new rr,new nr,new ir],this.networkScoresCalculator=e.networkScoresCalculator??new zt,this.compositeStatsParser=e.compositeStatsParser??new ar({statsParser:new cr({ignoreSSRCList:e.ignoreSSRCList,logger:this.logger})}),this.statsReporter=e.statsReporter??new Ht({compositeStatsParser:this.compositeStatsParser,getStatsInterval:e.getStatsInterval??5e3}),window.wid=this,this.autoAddPeerConnections=e.autoAddPeerConnections??!0,this.autoAddPeerConnections&&this.wrapRTCPeerConnection(),this.statsReporter.on(Ht.STATS_REPORT_READY_EVENT,(e=>{const t=this.calculateNetworkScores(e.stats);this.detectIssues({data:e.stats},t)})),this.statsReporter.on(Ht.STATS_REPORTS_PARSED,(t=>{const r={timeTaken:t.timeTaken,ts:Date.now()};e.onStats&&e.onStats(t.reportItems),this.eventEmitter.emit(Tt.StatsParsingFinished,r)}))}watchNewPeerConnections(){if(!this.autoAddPeerConnections)throw new Error("Auto add peer connections was disabled in the constructor.");this.#_?this.logger.warn("WebRTCIssueDetector is already started. Skip processing"):(this.logger.info("Start watching peer connections"),this.#_=!0,this.statsReporter.startReporting())}stopWatchingNewPeerConnections(){this.#_?(this.logger.info("Stop watching peer connections"),this.#_=!1,this.statsReporter.stopReporting()):this.logger.warn("WebRTCIssueDetector is already stopped. Skip processing")}handleNewPeerConnection(e,t){this.#_||!this.autoAddPeerConnections?(this.#_||!1!==this.autoAddPeerConnections||(this.logger.info("Starting stats reporting for new peer connection"),this.#_=!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(Tt.Issue,e)}detectIssues({data:e},t){const r=this.detectors.reduce(((r,n)=>[...r,...n.detect(e,t)]),[]);r.length>0&&this.emitIssues(r)}calculateNetworkScores(e){const t=this.networkScoresCalculator.calculate(e);return this.eventEmitter.emit(Tt.NetworkScoresUpdated,t),t}wrapRTCPeerConnection(){if(!window.RTCPeerConnection)return void this.logger.warn("No RTCPeerConnection found in browser window. Skipping");const e=window.RTCPeerConnection,t=e=>this.handleNewPeerConnection(e);function r(r){const n=new e(r);return t(n),n}r.prototype=e.prototype,window.RTCPeerConnection=r}}var ur,lr,pr,hr;ur=new WeakMap,lr=new WeakMap,pr=new WeakMap,hr=new WeakMap;var fr=new class{constructor(){ur.set(this,void 0),lr.set(this,void 0),pr.set(this,void 0),hr.set(this,void 0)}get meta(){return{peerId:c(this,ur,"f"),channelId:c(this,lr,"f"),appId:c(this,pr,"f"),datacenterName:c(this,hr,"f")}}setPeerId(e){d(this,ur,e,"f")}setChannelId(e){d(this,lr,e,"f")}setAppId(e){d(this,pr,e,"f")}setDatacenterName(e){d(this,hr,e,"f")}clear(){d(this,ur,void 0,"f"),d(this,lr,void 0,"f"),d(this,pr,void 0,"f"),d(this,hr,void 0,"f")}};const mr="peer.updateAppData",gr="channel-event",vr="peer-joined",yr="peer-left",_r="channel-activity-confirmation-required",br="channel-activity-confirmation-acquired",Er="channel-activity-confirmation-expired",wr="channel-rejoin-required",Sr="devices-list-updated",Cr="transport-connection-timeout",Pr="track-force-closed",Tr="track-failed",Rr="active-speaker-changed",kr="channel-state-inconsistent",Dr="connection-lost",Ir="connection-restored",Ar="denoiser-initializing",Or="channel-state-synced",Nr="denoiser-enabled",Mr="denoiser-disabled",Lr="denoiser-fallback",xr="denoiser-failed",Fr="volume-changed",jr="track-produced",Ur="track-unproduced",Vr="track-paused",Br="track-resumed",Wr="track-closed",Hr="track-reopened",qr="track-failed",zr="media-published",Gr="media-unpublished",Yr="publisher-paused",$r="publisher-resumed",Jr="track-start",Kr="track-end",Qr="track-paused",Zr="track-resumed",Xr="track-failed",en="app-data-updated",tn="produce-permissions-changed",rn="groups-changed",nn="peer.newProducer",sn="producer.close",on="producer.setMaxSpatialLayer",an="producer.requestMaxSpatialLayer",cn="consumer.close",dn="consumer.pause",un="consumer.resume",ln="consumer.changeConsumerPreferredLayers",pn="transport.connectionTimeout",hn="transport-state";var fn;!function(e){e.CloseProducer="CloseProducer",e.Mute="Mute",e.Resume="Resume",e.Join="Join"}(fn||(fn={}));class mn extends Error{constructor(e,t,r){super(null!=e?e:"Unexpected Livedigital SDK error"),Object.setPrototypeOf(this,new.target.prototype),this.name=new.target.name,this.errorCode=null!=t?t:"unknown_error",this.meta=r}}class gn extends mn{constructor(e,t,r){super(null!=e?e:gn.DEFAULT_MESSAGE,null!=t?t:"need_joined_to_channel",r)}}gn.DEFAULT_MESSAGE="Peer must join the channel before performing this request";class vn extends mn{constructor(e,t,r){super(null!=e?e:vn.DEFAULT_MESSAGE,null!=t?t:"unsupported_error",r)}}vn.UNSUPPORTED_DEVICE_CODE="unsupported_device_error",vn.UNSUPPORTED_OPERATION_CODE="unsupported_operation_error",vn.DEFAULT_MESSAGE="Unsupported operation";const yn=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 _n={exports:{}},bn=p(_n.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}}));function En(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function wn(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=En(n)&&En(s);(o&&!wn(n,s)||!o&&n!==s)&&(i=!1)})),i}function Sn(e,t,r=!1){let n=null;return function(...i){return a(this,void 0,void 0,(function*(){const s=r&&!n;"number"==typeof n&&clearTimeout(n),n=setTimeout((()=>a(this,void 0,void 0,(function*(){n=null,r||(yield e.apply(this,i))}))),t),s&&(yield e.apply(this,i))}))}}function Cn(e,t){return a(this,void 0,void 0,(function*(){try{return yield e()}catch(e){return void(null==t||t(e))}}))}const Pn=e=>{var t,r;return null!==(r=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 n&&!e.includes(n)&&e.push(n),e}),[]))&&void 0!==r?r:[]},Tn=e=>["video/vp9","vp9"].includes(e.toLowerCase()),Rn=Array.from({length:256},((e,t)=>(t+256).toString(16).slice(1)));function kn(e=24){const t=new Uint8Array(e);crypto.getRandomValues(t);let r="";for(let e=0;e<t.length;e++)r+=Rn[t[e]];return r}class Dn{sleepMs(e){return a(this,void 0,void 0,(function*(){yield new Promise((t=>setTimeout(t,e)))}))}now(){return new Date(Date.now())}}const In=new Dn,An=(e,...t)=>a(void 0,[e,...t],void 0,(function*(e,t={}){var r,n,i,s;const o=null!==(r=t.maxRetries)&&void 0!==r?r:2,a=null!==(n=t.minBackoffDelayMs)&&void 0!==n?n:50;let c,d=0;for(;d<o;){d+=1;try{return yield e()}catch(e){if(c=e,t.logger&&t.logger.info("Action retry failed",{currentAttempt:d,actionName:t.actionName,error:Ct(e)}),null===(i=t.abortOnError)||void 0===i?void 0:i.call(t,e))throw c;if(t.onError&&(yield t.onError(e)),d<o){const e=Math.pow(2,d-1)*a;yield In.sleepMs(Math.min(e,null!==(s=t.maxBackoffDelayMs)&&void 0!==s?s:e))}}}throw null!=c?c:new Error("retryAsync logic failed")}));var On,Nn,Mn;!function(e){e.Config="Config",e.Engine="Engine",e.System="System",e.Media="Media",e.Network="Network",e.MediaEventHandler="MediaEventHandler",e.ChannelEventHandler="ChannelEventHandler",e.ChannelAudioObserverEventHandler="ChannelAudioObserverEventHandler",e.ChannelAudioObserverMissingProducerRestorer="ChannelAudioObserverMissingProducerRestorer",e.ChannelStateSynchronizer="ChannelStateSynchronizer",e.ChannelStateSyncEventHandler="ChannelStateSyncEventHandler",e.WebRTCIssueDetector="WebRTCIssueDetector",e.LoggerFactory="LoggerFactory",e.MediaStreamTrackManager="MediaStreamTrackManager",e.EventsQueue="EventsQueue",e.ClientEventEmitter="ClientEventEmitter",e.Peers="Peers",e.CallState="CallState",e.RemotePeerTracks="RemotePeerTracks",e.MyPeer="MyPeer",e.InternalEventEmitter="InternalEventEmitter",e.PeerTrackFactory="PeerTrackFactory",e.PeerFactory="PeerFactory",e.PeerConsumerFactory="PeerConsumerFactory",e.AudioTrackFactory="AudioTrackFactory",e.VideoTrackFactory="VideoTrackFactory",e.AudioTrackProcessorFactory="AudioTrackProcessorFactory",e.IntegrationsService="IntegrationsService",e.ProcessorsCache="ProcessorsCache",e.StatsHandler="StatsHandler",e.DataChannelsManager="DataChannelsManager",e.WIDHandler="WIDHandler",e.AnalyticsApiClient="AnalyticsApiClient",e.TransportsStatsProvider="TransportsStatsProvider",e.LocalMutex="LocalMutex",e.PeersStorage="PeersStorage",e.SignalingApiClient="SignalingApiClient",e.DatachannelHeartbeater="DatachannelHeartbeater",e.SignalingHeartbeater="SignalingHeartbeater",e.PendingClosureProducerStorage="PendingClosureProducerStorage",e.ProducerCloseManager="ProducerCloseManager",e.NetworkTransportPolicyManager="NetworkTransportPolicyManager"}(On||(On={})),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.CustomVideo="custom-video",e.CustomAudio="custom-audio",e.Unknown="unknown"}(Nn||(Nn={})),function(e){e.NotFoundError="NotFoundError",e.NoDevices="NoDevices",e.DeviceIsBusy="DeviceIsBusy",e.NotAllowedError="NotAllowedError",e.RequestDevicesUnknownError="RequestDevicesUnknownError"}(Mn||(Mn={}));let Ln=class{constructor(){this.isJoined=!1,this.isChannelJoining=!1}reset(){this.appId=void 0,this.channelId=void 0,this.isJoined=!1,this.isChannelJoining=!1}};function xn(){let e=0,t=0;for(let r=0;r<28;r+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<r,0==(128&n))return this.assertBounds(),[e,t]}let r=this.buf[this.pos++];if(e|=(15&r)<<28,t=(112&r)>>4,0==(128&r))return this.assertBounds(),[e,t];for(let r=3;r<=31;r+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<r,0==(128&n))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function Fn(e,t,r){for(let n=0;n<28;n+=7){const i=e>>>n,s=!(i>>>7==0&&0==t),o=255&(s?128|i:i);if(r.push(o),!s)return}const n=e>>>28&15|(7&t)<<4,i=!(t>>3==0);if(r.push(255&(i?128|n:n)),i){for(let e=3;e<31;e+=7){const n=t>>>e,i=!(n>>>7==0),s=255&(i?128|n:n);if(r.push(s),!i)return}r.push(t>>>31&1)}}Ln=i([at()],Ln);function jn(e){const t="-"===e[0];t&&(e=e.slice(1));const r=1e6;let n=0,i=0;function s(t,s){const o=Number(e.slice(t,s));i*=r,n=n*r+o,n>=4294967296&&(i+=n/4294967296|0,n%=4294967296)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),t?Bn(n,i):Vn(n,i)}function Un(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(4294967296*t+e);const r=16777215&(e>>>24|t<<8),n=t>>16&65535;let i=(16777215&e)+6777216*r+6710656*n,s=r+8147497*n,o=2*n;const a=1e7;return i>=a&&(s+=Math.floor(i/a),i%=a),s>=a&&(o+=Math.floor(s/a),s%=a),o.toString()+Wn(s)+Wn(i)}function Vn(e,t){return{lo:0|e,hi:0|t}}function Bn(e,t){return t=~t,e?e=1+~e:t+=1,Vn(e,t)}const Wn=e=>{const t=String(e);return"0000000".slice(t.length)+t};function Hn(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let r=0;r<9;r++)t.push(127&e|128),e>>=7;t.push(1)}}function qn(){let e=this.buf[this.pos++],t=127&e;if(0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,0==(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,0==(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let t=5;0!=(128&e)&&t<10;t++)e=this.buf[this.pos++];if(0!=(128&e))throw new Error("invalid varint");return this.assertBounds(),t>>>0}const zn=Gn();function Gn(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&("object"!=typeof process||"object"!=typeof process.env||"1"!==process.env.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),n=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const n="bigint"==typeof e?e:BigInt(e);if(n>r||n<t)throw new Error(`invalid int64: ${e}`);return n},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>i||t<n)throw new Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,r)=>(e.setInt32(0,t,!0),e.setInt32(4,r,!0),e.getBigInt64(0,!0)),uDec:(t,r)=>(e.setInt32(0,t,!0),e.setInt32(4,r,!0),e.getBigUint64(0,!0))}}return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),Yn(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),$n(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),Yn(e),jn(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),$n(e),jn(e)),dec:(e,t)=>function(e,t){let r=Vn(e,t);const n=2147483648&r.hi;n&&(r=Bn(r.lo,r.hi));const i=Un(r.lo,r.hi);return n?"-"+i:i}(e,t),uDec:(e,t)=>Un(e,t)}}function Yn(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function $n(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}const Jn=Symbol.for("@bufbuild/protobuf/text-encoding");function Kn(){if(null==globalThis[Jn]){const e=new globalThis.TextEncoder,t=new globalThis.TextDecoder;globalThis[Jn]={encodeUtf8:t=>e.encode(t),decodeUtf8:e=>t.decode(e),checkUtf8(e){try{return encodeURIComponent(e),!0}catch(e){return!1}}}}return globalThis[Jn]}var Qn;!function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"}(Qn||(Qn={}));const Zn=34028234663852886e22,Xn=-34028234663852886e22;class ei{constructor(e=Kn().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),r=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],r),r+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(ni(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return ri(e),Hn(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){!function(e){if("string"==typeof e){const t=e;if(e=Number(e),Number.isNaN(e)&&"NaN"!==t)throw new Error("invalid float32: "+t)}else if("number"!=typeof e)throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>Zn||e<Xn))throw new Error("invalid float32: "+e)}(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){ni(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){ri(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return ri(e),Hn(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=zn.enc(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),n=zn.uEnc(e);return r.setInt32(0,n.lo,!0),r.setInt32(4,n.hi,!0),this.raw(t)}int64(e){let t=zn.enc(e);return Fn(t.lo,t.hi,this.buf),this}sint64(e){const t=zn.enc(e),r=t.hi>>31;return Fn(t.lo<<1^r,(t.hi<<1|t.lo>>>31)^r,this.buf),this}uint64(e){const t=zn.uEnc(e);return Fn(t.lo,t.hi,this.buf),this}}class ti{constructor(e,t=Kn().decodeUtf8){this.decodeUtf8=t,this.varint64=xn,this.uint32=qn,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),t=e>>>3,r=7&e;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e,t){let r=this.pos;switch(e){case Qn.Varint:for(;128&this.buf[this.pos++];);break;case Qn.Bit64:this.pos+=4;case Qn.Bit32:this.pos+=4;break;case Qn.LengthDelimited:let r=this.uint32();this.pos+=r;break;case Qn.StartGroup:for(;;){const[e,r]=this.tag();if(r===Qn.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(r,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return zn.dec(...this.varint64())}uint64(){return zn.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(1&e);return e=(e>>>1|(1&t)<<31)^r,t=t>>>1^r,zn.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return zn.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return zn.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.decodeUtf8(this.bytes())}}function ri(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int32: "+e)}function ni(e){if("string"==typeof e)e=Number(e);else if("number"!=typeof e)throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint32: "+e)}const ii={encode:(e,t=new ei)=>(0!==e.time&&t.uint32(8).int64(e.time),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={time:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.time=si(r.int64());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON(e){return{time:(t=e.time,null!=t?globalThis.Number(e.time):0)};var t},toJSON(e){const t={};return 0!==e.time&&(t.time=Math.round(e.time)),t},create:e=>ii.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={time:0};return r.time=null!==(t=e.time)&&void 0!==t?t:0,r}};function si(e){const t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}var oi;function ai(e){switch(e){case 0:case"NULL_VALUE":return oi.NULL_VALUE;default:return oi.UNRECOGNIZED}}!function(e){e[e.NULL_VALUE=0]="NULL_VALUE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(oi||(oi={}));const ci={encode:(e,t=new ei)=>(Object.entries(e.fields).forEach((([e,r])=>{void 0!==r&&di.encode({key:e,value:r},t.uint32(10).fork()).join()})),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={fields:{}};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:{if(10!==e)break;const t=di.decode(r,r.uint32());void 0!==t.value&&(i.fields[t.key]=t.value);continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({fields:pi(e.fields)?Object.entries(e.fields).reduce(((e,[t,r])=>(e[t]=r,e)),{}):{}}),toJSON(e){const t={};if(e.fields){const r=Object.entries(e.fields);r.length>0&&(t.fields={},r.forEach((([e,r])=>{t.fields[e]=r})))}return t},create:e=>ci.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={fields:{}};return r.fields=Object.entries(null!==(t=e.fields)&&void 0!==t?t:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=r),e)),{}),r},wrap(e){const t={fields:{}};if(void 0!==e)for(const r of Object.keys(e))t.fields[r]=e[r];return t},unwrap(e){const t={};if(e.fields)for(const r of Object.keys(e.fields))t[r]=e.fields[r];return t}};const di={encode:(e,t=new ei)=>(""!==e.key&&t.uint32(10).string(e.key),void 0!==e.value&&ui.encode(ui.wrap(e.value),t.uint32(18).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={key:"",value:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.key=r.string();continue;case 2:if(18!==e)break;i.value=ui.unwrap(ui.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({key:hi(e.key)?globalThis.String(e.key):"",value:hi(null==e?void 0:e.value)?e.value:void 0}),toJSON(e){const t={};return""!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},create:e=>di.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={key:"",value:void 0};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:void 0,n}};const ui={encode:(e,t=new ei)=>(void 0!==e.nullValue&&t.uint32(8).int32(e.nullValue),void 0!==e.numberValue&&t.uint32(17).double(e.numberValue),void 0!==e.stringValue&&t.uint32(26).string(e.stringValue),void 0!==e.boolValue&&t.uint32(32).bool(e.boolValue),void 0!==e.structValue&&ci.encode(ci.wrap(e.structValue),t.uint32(42).fork()).join(),void 0!==e.listValue&&li.encode(li.wrap(e.listValue),t.uint32(50).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.nullValue=r.int32();continue;case 2:if(17!==e)break;i.numberValue=r.double();continue;case 3:if(26!==e)break;i.stringValue=r.string();continue;case 4:if(32!==e)break;i.boolValue=r.bool();continue;case 5:if(42!==e)break;i.structValue=ci.unwrap(ci.decode(r,r.uint32()));continue;case 6:if(50!==e)break;i.listValue=li.unwrap(li.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({nullValue:hi(e.nullValue)?ai(e.nullValue):void 0,numberValue:hi(e.numberValue)?globalThis.Number(e.numberValue):void 0,stringValue:hi(e.stringValue)?globalThis.String(e.stringValue):void 0,boolValue:hi(e.boolValue)?globalThis.Boolean(e.boolValue):void 0,structValue:pi(e.structValue)?e.structValue:void 0,listValue:globalThis.Array.isArray(e.listValue)?[...e.listValue]:void 0}),toJSON(e){const t={};return void 0!==e.nullValue&&(t.nullValue=function(e){switch(e){case oi.NULL_VALUE:return"NULL_VALUE";case oi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.nullValue)),void 0!==e.numberValue&&(t.numberValue=e.numberValue),void 0!==e.stringValue&&(t.stringValue=e.stringValue),void 0!==e.boolValue&&(t.boolValue=e.boolValue),void 0!==e.structValue&&(t.structValue=e.structValue),void 0!==e.listValue&&(t.listValue=e.listValue),t},create:e=>ui.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s,o;const a={nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0};return a.nullValue=null!==(t=e.nullValue)&&void 0!==t?t:void 0,a.numberValue=null!==(r=e.numberValue)&&void 0!==r?r:void 0,a.stringValue=null!==(n=e.stringValue)&&void 0!==n?n:void 0,a.boolValue=null!==(i=e.boolValue)&&void 0!==i?i:void 0,a.structValue=null!==(s=e.structValue)&&void 0!==s?s:void 0,a.listValue=null!==(o=e.listValue)&&void 0!==o?o:void 0,a},wrap(e){const t={nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0};if(null===e)t.nullValue=oi.NULL_VALUE;else if("boolean"==typeof e)t.boolValue=e;else if("number"==typeof e)t.numberValue=e;else if("string"==typeof e)t.stringValue=e;else if(globalThis.Array.isArray(e))t.listValue=e;else if("object"==typeof e)t.structValue=e;else if(void 0!==e)throw new globalThis.Error("Unsupported any value type: "+typeof e);return t},unwrap:e=>void 0!==e.stringValue?e.stringValue:void 0!==(null==e?void 0:e.numberValue)?e.numberValue:void 0!==(null==e?void 0:e.boolValue)?e.boolValue:void 0!==(null==e?void 0:e.structValue)?e.structValue:void 0!==(null==e?void 0:e.listValue)?e.listValue:void 0!==(null==e?void 0:e.nullValue)?null:void 0};const li={encode(e,t=new ei){for(const r of e.values)ui.encode(ui.wrap(r),t.uint32(10).fork()).join();return t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={values:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.values.push(ui.unwrap(ui.decode(r,r.uint32())));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({values:globalThis.Array.isArray(null==e?void 0:e.values)?[...e.values]:[]}),toJSON(e){var t;const r={};return(null===(t=e.values)||void 0===t?void 0:t.length)&&(r.values=e.values),r},create:e=>li.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={values:[]};return r.values=(null===(t=e.values)||void 0===t?void 0:t.map((e=>e)))||[],r},wrap(e){const t={values:[]};return t.values=null!=e?e:[],t},unwrap:e=>(null==e?void 0:e.hasOwnProperty("values"))&&globalThis.Array.isArray(e.values)?e.values:e};function pi(e){return"object"==typeof e&&null!==e}function hi(e){return null!=e}const fi={encode:(e,t=new ei)=>(Object.entries(e.event).forEach((([e,r])=>{void 0!==r&&mi.encode({key:e,value:r},t.uint32(10).fork()).join()})),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={event:{}};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:{if(10!==e)break;const t=mi.decode(r,r.uint32());void 0!==t.value&&(i.event[t.key]=t.value);continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON(e){return{event:(t=e.event,"object"==typeof t&&null!==t?Object.entries(e.event).reduce(((e,[t,r])=>(e[t]=r,e)),{}):{})};var t},toJSON(e){const t={};if(e.event){const r=Object.entries(e.event);r.length>0&&(t.event={},r.forEach((([e,r])=>{t.event[e]=r})))}return t},create:e=>fi.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={event:{}};return r.event=Object.entries(null!==(t=e.event)&&void 0!==t?t:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=r),e)),{}),r}};const mi={encode:(e,t=new ei)=>(""!==e.key&&t.uint32(10).string(e.key),void 0!==e.value&&ui.encode(ui.wrap(e.value),t.uint32(18).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={key:"",value:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.key=r.string();continue;case 2:if(18!==e)break;i.value=ui.unwrap(ui.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({key:gi(e.key)?globalThis.String(e.key):"",value:gi(null==e?void 0:e.value)?e.value:void 0}),toJSON(e){const t={};return""!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},create:e=>mi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={key:"",value:void 0};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:void 0,n}};function gi(e){return null!=e}var vi,yi;function _i(e){switch(e){case 0:case"PEER_GROUP_UNSPECIFIED":return vi.PEER_GROUP_UNSPECIFIED;case 1:case"PEER_GROUP_MODERATOR":return vi.PEER_GROUP_MODERATOR;case 2:case"PEER_GROUP_USER":return vi.PEER_GROUP_USER;default:return vi.UNRECOGNIZED}}function bi(e){switch(e){case vi.PEER_GROUP_UNSPECIFIED:return"PEER_GROUP_UNSPECIFIED";case vi.PEER_GROUP_MODERATOR:return"PEER_GROUP_MODERATOR";case vi.PEER_GROUP_USER:return"PEER_GROUP_USER";case vi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function Ei(e){switch(e){case 0:case"PRODUCER_LABEL_UNSPECIFIED":return yi.PRODUCER_LABEL_UNSPECIFIED;case 1:case"PRODUCER_LABEL_CAMERA":return yi.PRODUCER_LABEL_CAMERA;case 2:case"PRODUCER_LABEL_MICROPHONE":return yi.PRODUCER_LABEL_MICROPHONE;case 3:case"PRODUCER_LABEL_SCREEN_VIDEO":return yi.PRODUCER_LABEL_SCREEN_VIDEO;case 4:case"PRODUCER_LABEL_SCREEN_AUDIO":return yi.PRODUCER_LABEL_SCREEN_AUDIO;case 5:case"PRODUCER_LABEL_CUSTOM_VIDEO":return yi.PRODUCER_LABEL_CUSTOM_VIDEO;case 6:case"PRODUCER_LABEL_CUSTOM_AUDIO":return yi.PRODUCER_LABEL_CUSTOM_AUDIO;case 7:case"PRODUCER_LABEL_UNKNOWN":return yi.PRODUCER_LABEL_UNKNOWN;default:return yi.UNRECOGNIZED}}function wi(e){switch(e){case yi.PRODUCER_LABEL_UNSPECIFIED:return"PRODUCER_LABEL_UNSPECIFIED";case yi.PRODUCER_LABEL_CAMERA:return"PRODUCER_LABEL_CAMERA";case yi.PRODUCER_LABEL_MICROPHONE:return"PRODUCER_LABEL_MICROPHONE";case yi.PRODUCER_LABEL_SCREEN_VIDEO:return"PRODUCER_LABEL_SCREEN_VIDEO";case yi.PRODUCER_LABEL_SCREEN_AUDIO:return"PRODUCER_LABEL_SCREEN_AUDIO";case yi.PRODUCER_LABEL_CUSTOM_VIDEO:return"PRODUCER_LABEL_CUSTOM_VIDEO";case yi.PRODUCER_LABEL_CUSTOM_AUDIO:return"PRODUCER_LABEL_CUSTOM_AUDIO";case yi.PRODUCER_LABEL_UNKNOWN:return"PRODUCER_LABEL_UNKNOWN";case yi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.PEER_GROUP_UNSPECIFIED=0]="PEER_GROUP_UNSPECIFIED",e[e.PEER_GROUP_MODERATOR=1]="PEER_GROUP_MODERATOR",e[e.PEER_GROUP_USER=2]="PEER_GROUP_USER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(vi||(vi={})),function(e){e[e.PRODUCER_LABEL_UNSPECIFIED=0]="PRODUCER_LABEL_UNSPECIFIED",e[e.PRODUCER_LABEL_CAMERA=1]="PRODUCER_LABEL_CAMERA",e[e.PRODUCER_LABEL_MICROPHONE=2]="PRODUCER_LABEL_MICROPHONE",e[e.PRODUCER_LABEL_SCREEN_VIDEO=3]="PRODUCER_LABEL_SCREEN_VIDEO",e[e.PRODUCER_LABEL_SCREEN_AUDIO=4]="PRODUCER_LABEL_SCREEN_AUDIO",e[e.PRODUCER_LABEL_CUSTOM_VIDEO=5]="PRODUCER_LABEL_CUSTOM_VIDEO",e[e.PRODUCER_LABEL_CUSTOM_AUDIO=6]="PRODUCER_LABEL_CUSTOM_AUDIO",e[e.PRODUCER_LABEL_UNKNOWN=7]="PRODUCER_LABEL_UNKNOWN",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(yi||(yi={}));const Si={encode(e,t=new ei){t.uint32(10).fork();for(const r of e.groups)t.int32(r);t.join(),t.uint32(18).fork();for(const r of e.producePermissions)t.int32(r);t.join(),t.uint32(26).fork();for(const r of e.changedProducePermissions)t.int32(r);return t.join(),t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={groups:[],producePermissions:[],changedProducePermissions:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8===e){i.groups.push(r.int32());continue}if(10===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.groups.push(r.int32());continue}break;case 2:if(16===e){i.producePermissions.push(r.int32());continue}if(18===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.producePermissions.push(r.int32());continue}break;case 3:if(24===e){i.changedProducePermissions.push(r.int32());continue}if(26===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.changedProducePermissions.push(r.int32());continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({groups:globalThis.Array.isArray(null==e?void 0:e.groups)?e.groups.map((e=>_i(e))):[],producePermissions:globalThis.Array.isArray(null==e?void 0:e.producePermissions)?e.producePermissions.map((e=>Ei(e))):[],changedProducePermissions:globalThis.Array.isArray(null==e?void 0:e.changedProducePermissions)?e.changedProducePermissions.map((e=>Ei(e))):[]}),toJSON(e){var t,r,n;const i={};return(null===(t=e.groups)||void 0===t?void 0:t.length)&&(i.groups=e.groups.map((e=>bi(e)))),(null===(r=e.producePermissions)||void 0===r?void 0:r.length)&&(i.producePermissions=e.producePermissions.map((e=>wi(e)))),(null===(n=e.changedProducePermissions)||void 0===n?void 0:n.length)&&(i.changedProducePermissions=e.changedProducePermissions.map((e=>wi(e)))),i},create:e=>Si.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n;const i={groups:[],producePermissions:[],changedProducePermissions:[]};return i.groups=(null===(t=e.groups)||void 0===t?void 0:t.map((e=>e)))||[],i.producePermissions=(null===(r=e.producePermissions)||void 0===r?void 0:r.map((e=>e)))||[],i.changedProducePermissions=(null===(n=e.changedProducePermissions)||void 0===n?void 0:n.map((e=>e)))||[],i}};const Ci={encode:(e,t=new ei)=>(0!==e.seconds&&t.uint32(8).int64(e.seconds),0!==e.nanos&&t.uint32(16).int32(e.nanos),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={seconds:0,nanos:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.seconds=Pi(r.int64());continue;case 2:if(16!==e)break;i.nanos=r.int32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({seconds:Ti(e.seconds)?globalThis.Number(e.seconds):0,nanos:Ti(e.nanos)?globalThis.Number(e.nanos):0}),toJSON(e){const t={};return 0!==e.seconds&&(t.seconds=Math.round(e.seconds)),0!==e.nanos&&(t.nanos=Math.round(e.nanos)),t},create:e=>Ci.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={seconds:0,nanos:0};return n.seconds=null!==(t=e.seconds)&&void 0!==t?t:0,n.nanos=null!==(r=e.nanos)&&void 0!==r?r:0,n}};function Pi(e){const t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}function Ti(e){return null!=e}var Ri;function ki(e){switch(e){case 0:case"PRODUCER_KIND_UNSPECIFIED":return Ri.PRODUCER_KIND_UNSPECIFIED;case 1:case"PRODUCER_KIND_AUDIO":return Ri.PRODUCER_KIND_AUDIO;case 2:case"PRODUCER_KIND_VIDEO":return Ri.PRODUCER_KIND_VIDEO;default:return Ri.UNRECOGNIZED}}!function(e){e[e.PRODUCER_KIND_UNSPECIFIED=0]="PRODUCER_KIND_UNSPECIFIED",e[e.PRODUCER_KIND_AUDIO=1]="PRODUCER_KIND_AUDIO",e[e.PRODUCER_KIND_VIDEO=2]="PRODUCER_KIND_VIDEO",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ri||(Ri={}));const Di={encode(e,t=new ei){""!==e.id&&t.uint32(10).string(e.id),0!==e.kind&&t.uint32(16).int32(e.kind),0!==e.label&&t.uint32(24).int32(e.label),""!==e.peerId&&t.uint32(34).string(e.peerId),!1!==e.paused&&t.uint32(40).bool(e.paused);for(const r of e.encodings)ui.encode(ui.wrap(r),t.uint32(50).fork()).join();return void 0!==e.maxSpatialLayer&&t.uint32(56).uint32(e.maxSpatialLayer),t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={id:"",kind:0,label:0,peerId:"",paused:!1,encodings:[],maxSpatialLayer:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(16!==e)break;i.kind=r.int32();continue;case 3:if(24!==e)break;i.label=r.int32();continue;case 4:if(34!==e)break;i.peerId=r.string();continue;case 5:if(40!==e)break;i.paused=r.bool();continue;case 6:if(50!==e)break;i.encodings.push(ui.unwrap(ui.decode(r,r.uint32())));continue;case 7:if(56!==e)break;i.maxSpatialLayer=r.uint32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:Ii(e.id)?globalThis.String(e.id):"",kind:Ii(e.kind)?ki(e.kind):0,label:Ii(e.label)?Ei(e.label):0,peerId:Ii(e.peerId)?globalThis.String(e.peerId):"",paused:!!Ii(e.paused)&&globalThis.Boolean(e.paused),encodings:globalThis.Array.isArray(null==e?void 0:e.encodings)?[...e.encodings]:[],maxSpatialLayer:Ii(e.maxSpatialLayer)?globalThis.Number(e.maxSpatialLayer):void 0}),toJSON(e){var t;const r={};return""!==e.id&&(r.id=e.id),0!==e.kind&&(r.kind=function(e){switch(e){case Ri.PRODUCER_KIND_UNSPECIFIED:return"PRODUCER_KIND_UNSPECIFIED";case Ri.PRODUCER_KIND_AUDIO:return"PRODUCER_KIND_AUDIO";case Ri.PRODUCER_KIND_VIDEO:return"PRODUCER_KIND_VIDEO";case Ri.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.kind)),0!==e.label&&(r.label=wi(e.label)),""!==e.peerId&&(r.peerId=e.peerId),!1!==e.paused&&(r.paused=e.paused),(null===(t=e.encodings)||void 0===t?void 0:t.length)&&(r.encodings=e.encodings),void 0!==e.maxSpatialLayer&&(r.maxSpatialLayer=Math.round(e.maxSpatialLayer)),r},create:e=>Di.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s,o,a;const c={id:"",kind:0,label:0,peerId:"",paused:!1,encodings:[],maxSpatialLayer:void 0};return c.id=null!==(t=e.id)&&void 0!==t?t:"",c.kind=null!==(r=e.kind)&&void 0!==r?r:0,c.label=null!==(n=e.label)&&void 0!==n?n:0,c.peerId=null!==(i=e.peerId)&&void 0!==i?i:"",c.paused=null!==(s=e.paused)&&void 0!==s&&s,c.encodings=(null===(o=e.encodings)||void 0===o?void 0:o.map((e=>e)))||[],c.maxSpatialLayer=null!==(a=e.maxSpatialLayer)&&void 0!==a?a:void 0,c}};function Ii(e){return null!=e}var Ai;function Oi(e){switch(e){case 0:case"PEER_ROLE_UNSPECIFIED":return Ai.PEER_ROLE_UNSPECIFIED;case 1:case"PEER_ROLE_HOST":return Ai.PEER_ROLE_HOST;case 2:case"PEER_ROLE_AUDIENCE":return Ai.PEER_ROLE_AUDIENCE;default:return Ai.UNRECOGNIZED}}!function(e){e[e.PEER_ROLE_UNSPECIFIED=0]="PEER_ROLE_UNSPECIFIED",e[e.PEER_ROLE_HOST=1]="PEER_ROLE_HOST",e[e.PEER_ROLE_AUDIENCE=2]="PEER_ROLE_AUDIENCE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ai||(Ai={}));const Ni={encode(e,t=new ei){""!==e.id&&t.uint32(10).string(e.id);for(const r of e.channelIds)t.uint32(18).string(r);for(const r of e.producers)Di.encode(r,t.uint32(26).fork()).join();""!==e.uid&&t.uint32(50).string(e.uid),""!==e.appId&&t.uint32(58).string(e.appId),Object.entries(e.appData).forEach((([e,r])=>{void 0!==r&&Mi.encode({key:e,value:r},t.uint32(66).fork()).join()})),0!==e.role&&t.uint32(72).int32(e.role),void 0!==e.loginDate&&Ci.encode(function(e){const t=Math.trunc(e.getTime()/1e3),r=e.getTime()%1e3*1e6;return{seconds:t,nanos:r}}(e.loginDate),t.uint32(82).fork()).join(),t.uint32(90).fork();for(const r of e.groups)t.int32(r);t.join(),t.uint32(98).fork();for(const r of e.producePermissions)t.int32(r);return t.join(),t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={id:"",channelIds:[],producers:[],uid:"",appId:"",appData:{},role:0,loginDate:void 0,groups:[],producePermissions:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(18!==e)break;i.channelIds.push(r.string());continue;case 3:if(26!==e)break;i.producers.push(Di.decode(r,r.uint32()));continue;case 6:if(50!==e)break;i.uid=r.string();continue;case 7:if(58!==e)break;i.appId=r.string();continue;case 8:{if(66!==e)break;const t=Mi.decode(r,r.uint32());void 0!==t.value&&(i.appData[t.key]=t.value);continue}case 9:if(72!==e)break;i.role=r.int32();continue;case 10:if(82!==e)break;i.loginDate=Li(Ci.decode(r,r.uint32()));continue;case 11:if(88===e){i.groups.push(r.int32());continue}if(90===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.groups.push(r.int32());continue}break;case 12:if(96===e){i.producePermissions.push(r.int32());continue}if(98===e){const e=r.uint32()+r.pos;for(;r.pos<e;)i.producePermissions.push(r.int32());continue}}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON(e){return{id:Fi(e.id)?globalThis.String(e.id):"",channelIds:globalThis.Array.isArray(null==e?void 0:e.channelIds)?e.channelIds.map((e=>globalThis.String(e))):[],producers:globalThis.Array.isArray(null==e?void 0:e.producers)?e.producers.map((e=>Di.fromJSON(e))):[],uid:Fi(e.uid)?globalThis.String(e.uid):"",appId:Fi(e.appId)?globalThis.String(e.appId):"",appData:(t=e.appData,"object"==typeof t&&null!==t?Object.entries(e.appData).reduce(((e,[t,r])=>(e[t]=r,e)),{}):{}),role:Fi(e.role)?Oi(e.role):0,loginDate:Fi(e.loginDate)?xi(e.loginDate):void 0,groups:globalThis.Array.isArray(null==e?void 0:e.groups)?e.groups.map((e=>_i(e))):[],producePermissions:globalThis.Array.isArray(null==e?void 0:e.producePermissions)?e.producePermissions.map((e=>Ei(e))):[]};var t},toJSON(e){var t,r,n,i;const s={};if(""!==e.id&&(s.id=e.id),(null===(t=e.channelIds)||void 0===t?void 0:t.length)&&(s.channelIds=e.channelIds),(null===(r=e.producers)||void 0===r?void 0:r.length)&&(s.producers=e.producers.map((e=>Di.toJSON(e)))),""!==e.uid&&(s.uid=e.uid),""!==e.appId&&(s.appId=e.appId),e.appData){const t=Object.entries(e.appData);t.length>0&&(s.appData={},t.forEach((([e,t])=>{s.appData[e]=t})))}return 0!==e.role&&(s.role=function(e){switch(e){case Ai.PEER_ROLE_UNSPECIFIED:return"PEER_ROLE_UNSPECIFIED";case Ai.PEER_ROLE_HOST:return"PEER_ROLE_HOST";case Ai.PEER_ROLE_AUDIENCE:return"PEER_ROLE_AUDIENCE";case Ai.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.role)),void 0!==e.loginDate&&(s.loginDate=e.loginDate.toISOString()),(null===(n=e.groups)||void 0===n?void 0:n.length)&&(s.groups=e.groups.map((e=>bi(e)))),(null===(i=e.producePermissions)||void 0===i?void 0:i.length)&&(s.producePermissions=e.producePermissions.map((e=>wi(e)))),s},create:e=>Ni.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s,o,a,c,d,u;const l={id:"",channelIds:[],producers:[],uid:"",appId:"",appData:{},role:0,loginDate:void 0,groups:[],producePermissions:[]};return l.id=null!==(t=e.id)&&void 0!==t?t:"",l.channelIds=(null===(r=e.channelIds)||void 0===r?void 0:r.map((e=>e)))||[],l.producers=(null===(n=e.producers)||void 0===n?void 0:n.map((e=>Di.fromPartial(e))))||[],l.uid=null!==(i=e.uid)&&void 0!==i?i:"",l.appId=null!==(s=e.appId)&&void 0!==s?s:"",l.appData=Object.entries(null!==(o=e.appData)&&void 0!==o?o:{}).reduce(((e,[t,r])=>(void 0!==r&&(e[t]=r),e)),{}),l.role=null!==(a=e.role)&&void 0!==a?a:0,l.loginDate=null!==(c=e.loginDate)&&void 0!==c?c:void 0,l.groups=(null===(d=e.groups)||void 0===d?void 0:d.map((e=>e)))||[],l.producePermissions=(null===(u=e.producePermissions)||void 0===u?void 0:u.map((e=>e)))||[],l}};const Mi={encode:(e,t=new ei)=>(""!==e.key&&t.uint32(10).string(e.key),void 0!==e.value&&ui.encode(ui.wrap(e.value),t.uint32(18).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={key:"",value:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.key=r.string();continue;case 2:if(18!==e)break;i.value=ui.unwrap(ui.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({key:Fi(e.key)?globalThis.String(e.key):"",value:Fi(null==e?void 0:e.value)?e.value:void 0}),toJSON(e){const t={};return""!==e.key&&(t.key=e.key),void 0!==e.value&&(t.value=e.value),t},create:e=>Mi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={key:"",value:void 0};return n.key=null!==(t=e.key)&&void 0!==t?t:"",n.value=null!==(r=e.value)&&void 0!==r?r:void 0,n}};function Li(e){let t=1e3*(e.seconds||0);return t+=(e.nanos||0)/1e6,new globalThis.Date(t)}function xi(e){return e instanceof globalThis.Date?e:"string"==typeof e?new globalThis.Date(e):Li(Ci.fromJSON(e))}function Fi(e){return null!=e}const ji={encode(e,t=new ei){for(const r of e.peers)Ni.encode(r,t.uint32(10).fork()).join();return t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={peers:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.peers.push(Ni.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({peers:globalThis.Array.isArray(null==e?void 0:e.peers)?e.peers.map((e=>Ni.fromJSON(e))):[]}),toJSON(e){var t;const r={};return(null===(t=e.peers)||void 0===t?void 0:t.length)&&(r.peers=e.peers.map((e=>Ni.toJSON(e)))),r},create:e=>ji.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={peers:[]};return r.peers=(null===(t=e.peers)||void 0===t?void 0:t.map((e=>Ni.fromPartial(e))))||[],r}};const Ui={encode:(e,t=new ei)=>(""!==e.id&&t.uint32(10).string(e.id),!1!==e.paused&&t.uint32(16).bool(e.paused),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={id:"",paused:!1};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(16!==e)break;i.paused=r.bool();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:Wi(e.id)?globalThis.String(e.id):"",paused:!!Wi(e.paused)&&globalThis.Boolean(e.paused)}),toJSON(e){const t={};return""!==e.id&&(t.id=e.id),!1!==e.paused&&(t.paused=e.paused),t},create:e=>Ui.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={id:"",paused:!1};return n.id=null!==(t=e.id)&&void 0!==t?t:"",n.paused=null!==(r=e.paused)&&void 0!==r&&r,n}};const Vi={encode(e,t=new ei){""!==e.id&&t.uint32(10).string(e.id);for(const r of e.producers)Ui.encode(r,t.uint32(18).fork()).join();return void 0!==e.appDataHash&&t.uint32(26).string(e.appDataHash),t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={id:"",producers:[],appDataHash:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(18!==e)break;i.producers.push(Ui.decode(r,r.uint32()));continue;case 3:if(26!==e)break;i.appDataHash=r.string();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:Wi(e.id)?globalThis.String(e.id):"",producers:globalThis.Array.isArray(null==e?void 0:e.producers)?e.producers.map((e=>Ui.fromJSON(e))):[],appDataHash:Wi(e.appDataHash)?globalThis.String(e.appDataHash):void 0}),toJSON(e){var t;const r={};return""!==e.id&&(r.id=e.id),(null===(t=e.producers)||void 0===t?void 0:t.length)&&(r.producers=e.producers.map((e=>Ui.toJSON(e)))),void 0!==e.appDataHash&&(r.appDataHash=e.appDataHash),r},create:e=>Vi.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n;const i={id:"",producers:[],appDataHash:void 0};return i.id=null!==(t=e.id)&&void 0!==t?t:"",i.producers=(null===(r=e.producers)||void 0===r?void 0:r.map((e=>Ui.fromPartial(e))))||[],i.appDataHash=null!==(n=e.appDataHash)&&void 0!==n?n:void 0,i}};const Bi={encode(e,t=new ei){for(const r of e.peers)Vi.encode(r,t.uint32(10).fork()).join();return t},decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={peers:[]};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.peers.push(Vi.decode(r,r.uint32()));continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({peers:globalThis.Array.isArray(null==e?void 0:e.peers)?e.peers.map((e=>Vi.fromJSON(e))):[]}),toJSON(e){var t;const r={};return(null===(t=e.peers)||void 0===t?void 0:t.length)&&(r.peers=e.peers.map((e=>Vi.toJSON(e)))),r},create:e=>Bi.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={peers:[]};return r.peers=(null===(t=e.peers)||void 0===t?void 0:t.map((e=>Vi.fromPartial(e))))||[],r}};function Wi(e){return null!=e}var Hi;function qi(e){switch(e){case 0:case"CHANNEL_EVENT_TYPE_UNSPECIFIED":return Hi.CHANNEL_EVENT_TYPE_UNSPECIFIED;case 1:case"CHANNEL_EVENT_TYPE_CHANNEL_STATE":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_STATE;case 2:case"CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT;case 3:case"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED;case 4:case"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED;case 5:case"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED;case 6:case"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED;case 7:case"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED;case 8:case"CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT":return Hi.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT;case 14:case"CHANNEL_EVENT_TYPE_PEER_JOINED":return Hi.CHANNEL_EVENT_TYPE_PEER_JOINED;case 15:case"CHANNEL_EVENT_TYPE_PEER_LEFT":return Hi.CHANNEL_EVENT_TYPE_PEER_LEFT;case 16:case"CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED":return Hi.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED;case 17:case"CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED":return Hi.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED;case 18:case"CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED":return Hi.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED;default:return Hi.UNRECOGNIZED}}function zi(e){switch(e){case Hi.CHANNEL_EVENT_TYPE_UNSPECIFIED:return"CHANNEL_EVENT_TYPE_UNSPECIFIED";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_STATE:return"CHANNEL_EVENT_TYPE_CHANNEL_STATE";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT:return"CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED:return"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED:return"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED:return"CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED:return"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED:return"CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED";case Hi.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT:return"CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT";case Hi.CHANNEL_EVENT_TYPE_PEER_JOINED:return"CHANNEL_EVENT_TYPE_PEER_JOINED";case Hi.CHANNEL_EVENT_TYPE_PEER_LEFT:return"CHANNEL_EVENT_TYPE_PEER_LEFT";case Hi.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED:return"CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED";case Hi.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED:return"CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED";case Hi.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED:return"CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED";case Hi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.CHANNEL_EVENT_TYPE_UNSPECIFIED=0]="CHANNEL_EVENT_TYPE_UNSPECIFIED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_STATE=1]="CHANNEL_EVENT_TYPE_CHANNEL_STATE",e[e.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT=2]="CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT",e[e.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED=3]="CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED=4]="CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED=5]="CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED=6]="CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED=7]="CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED",e[e.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT=8]="CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT",e[e.CHANNEL_EVENT_TYPE_PEER_JOINED=14]="CHANNEL_EVENT_TYPE_PEER_JOINED",e[e.CHANNEL_EVENT_TYPE_PEER_LEFT=15]="CHANNEL_EVENT_TYPE_PEER_LEFT",e[e.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED=16]="CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED",e[e.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED=17]="CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED",e[e.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED=18]="CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Hi||(Hi={}));const Gi={encode:(e,t=new ei)=>(0!==e.eventType&&t.uint32(8).int32(e.eventType),void 0!==e.channelState&&ji.encode(e.channelState,t.uint32(18).fork()).join(),void 0!==e.channelStateShort&&Bi.encode(e.channelStateShort,t.uint32(26).fork()).join(),void 0!==e.channelActivityConfirmationTime&&ii.encode(e.channelActivityConfirmationTime,t.uint32(34).fork()).join(),void 0!==e.channelManagementEvent&&fi.encode(e.channelManagementEvent,t.uint32(42).fork()).join(),void 0!==e.channelProducePermissions&&Si.encode(e.channelProducePermissions,t.uint32(50).fork()).join(),void 0!==e.peer&&Ni.encode(e.peer,t.uint32(58).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={eventType:0,channelState:void 0,channelStateShort:void 0,channelActivityConfirmationTime:void 0,channelManagementEvent:void 0,channelProducePermissions:void 0,peer:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.eventType=r.int32();continue;case 2:if(18!==e)break;i.channelState=ji.decode(r,r.uint32());continue;case 3:if(26!==e)break;i.channelStateShort=Bi.decode(r,r.uint32());continue;case 4:if(34!==e)break;i.channelActivityConfirmationTime=ii.decode(r,r.uint32());continue;case 5:if(42!==e)break;i.channelManagementEvent=fi.decode(r,r.uint32());continue;case 6:if(50!==e)break;i.channelProducePermissions=Si.decode(r,r.uint32());continue;case 7:if(58!==e)break;i.peer=Ni.decode(r,r.uint32());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({eventType:Yi(e.eventType)?qi(e.eventType):0,channelState:Yi(e.channelState)?ji.fromJSON(e.channelState):void 0,channelStateShort:Yi(e.channelStateShort)?Bi.fromJSON(e.channelStateShort):void 0,channelActivityConfirmationTime:Yi(e.channelActivityConfirmationTime)?ii.fromJSON(e.channelActivityConfirmationTime):void 0,channelManagementEvent:Yi(e.channelManagementEvent)?fi.fromJSON(e.channelManagementEvent):void 0,channelProducePermissions:Yi(e.channelProducePermissions)?Si.fromJSON(e.channelProducePermissions):void 0,peer:Yi(e.peer)?Ni.fromJSON(e.peer):void 0}),toJSON(e){const t={};return 0!==e.eventType&&(t.eventType=zi(e.eventType)),void 0!==e.channelState&&(t.channelState=ji.toJSON(e.channelState)),void 0!==e.channelStateShort&&(t.channelStateShort=Bi.toJSON(e.channelStateShort)),void 0!==e.channelActivityConfirmationTime&&(t.channelActivityConfirmationTime=ii.toJSON(e.channelActivityConfirmationTime)),void 0!==e.channelManagementEvent&&(t.channelManagementEvent=fi.toJSON(e.channelManagementEvent)),void 0!==e.channelProducePermissions&&(t.channelProducePermissions=Si.toJSON(e.channelProducePermissions)),void 0!==e.peer&&(t.peer=Ni.toJSON(e.peer)),t},create:e=>Gi.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={eventType:0,channelState:void 0,channelStateShort:void 0,channelActivityConfirmationTime:void 0,channelManagementEvent:void 0,channelProducePermissions:void 0,peer:void 0};return r.eventType=null!==(t=e.eventType)&&void 0!==t?t:0,r.channelState=void 0!==e.channelState&&null!==e.channelState?ji.fromPartial(e.channelState):void 0,r.channelStateShort=void 0!==e.channelStateShort&&null!==e.channelStateShort?Bi.fromPartial(e.channelStateShort):void 0,r.channelActivityConfirmationTime=void 0!==e.channelActivityConfirmationTime&&null!==e.channelActivityConfirmationTime?ii.fromPartial(e.channelActivityConfirmationTime):void 0,r.channelManagementEvent=void 0!==e.channelManagementEvent&&null!==e.channelManagementEvent?fi.fromPartial(e.channelManagementEvent):void 0,r.channelProducePermissions=void 0!==e.channelProducePermissions&&null!==e.channelProducePermissions?Si.fromPartial(e.channelProducePermissions):void 0,r.peer=void 0!==e.peer&&null!==e.peer?Ni.fromPartial(e.peer):void 0,r}};function Yi(e){return null!=e}const $i={encode:(e,t=new ei)=>(""!==e.id&&t.uint32(10).string(e.id),""!==e.peerId&&t.uint32(18).string(e.peerId),""!==e.producerPeerId&&t.uint32(26).string(e.producerPeerId),void 0!==e.spatialLayer&&t.uint32(32).uint32(e.spatialLayer),void 0!==e.temporalLayer&&t.uint32(40).uint32(e.temporalLayer),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={id:"",peerId:"",producerPeerId:"",spatialLayer:void 0,temporalLayer:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.id=r.string();continue;case 2:if(18!==e)break;i.peerId=r.string();continue;case 3:if(26!==e)break;i.producerPeerId=r.string();continue;case 4:if(32!==e)break;i.spatialLayer=r.uint32();continue;case 5:if(40!==e)break;i.temporalLayer=r.uint32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:Ji(e.id)?globalThis.String(e.id):"",peerId:Ji(e.peerId)?globalThis.String(e.peerId):"",producerPeerId:Ji(e.producerPeerId)?globalThis.String(e.producerPeerId):"",spatialLayer:Ji(e.spatialLayer)?globalThis.Number(e.spatialLayer):void 0,temporalLayer:Ji(e.temporalLayer)?globalThis.Number(e.temporalLayer):void 0}),toJSON(e){const t={};return""!==e.id&&(t.id=e.id),""!==e.peerId&&(t.peerId=e.peerId),""!==e.producerPeerId&&(t.producerPeerId=e.producerPeerId),void 0!==e.spatialLayer&&(t.spatialLayer=Math.round(e.spatialLayer)),void 0!==e.temporalLayer&&(t.temporalLayer=Math.round(e.temporalLayer)),t},create:e=>$i.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i,s;const o={id:"",peerId:"",producerPeerId:"",spatialLayer:void 0,temporalLayer:void 0};return o.id=null!==(t=e.id)&&void 0!==t?t:"",o.peerId=null!==(r=e.peerId)&&void 0!==r?r:"",o.producerPeerId=null!==(n=e.producerPeerId)&&void 0!==n?n:"",o.spatialLayer=null!==(i=e.spatialLayer)&&void 0!==i?i:void 0,o.temporalLayer=null!==(s=e.temporalLayer)&&void 0!==s?s:void 0,o}};function Ji(e){return null!=e}const Ki={encode:(e,t=new ei)=>(""!==e.producerId&&t.uint32(10).string(e.producerId),0!==e.spatialLayer&&t.uint32(16).uint32(e.spatialLayer),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={producerId:"",spatialLayer:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.producerId=r.string();continue;case 2:if(16!==e)break;i.spatialLayer=r.uint32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({producerId:Qi(e.producerId)?globalThis.String(e.producerId):"",spatialLayer:Qi(e.spatialLayer)?globalThis.Number(e.spatialLayer):0}),toJSON(e){const t={};return""!==e.producerId&&(t.producerId=e.producerId),0!==e.spatialLayer&&(t.spatialLayer=Math.round(e.spatialLayer)),t},create:e=>Ki.fromPartial(null!=e?e:{}),fromPartial(e){var t,r;const n={producerId:"",spatialLayer:0};return n.producerId=null!==(t=e.producerId)&&void 0!==t?t:"",n.spatialLayer=null!==(r=e.spatialLayer)&&void 0!==r?r:0,n}};function Qi(e){return null!=e}var Zi,Xi;function es(e){switch(e){case 0:case"TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED":return Zi.TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED;case 1:case"TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS":return Zi.TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS;case 2:case"TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE":return Zi.TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE;default:return Zi.UNRECOGNIZED}}function ts(e){switch(e){case 0:case"TRANSPORT_DIRECTION_UNSPECIFIED":return Xi.TRANSPORT_DIRECTION_UNSPECIFIED;case 1:case"TRANSPORT_DIRECTION_SEND":return Xi.TRANSPORT_DIRECTION_SEND;case 2:case"TRANSPORT_DIRECTION_RECEIVE":return Xi.TRANSPORT_DIRECTION_RECEIVE;default:return Xi.UNRECOGNIZED}}!function(e){e[e.TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED=0]="TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED",e[e.TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS=1]="TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS",e[e.TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE=2]="TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Zi||(Zi={})),function(e){e[e.TRANSPORT_DIRECTION_UNSPECIFIED=0]="TRANSPORT_DIRECTION_UNSPECIFIED",e[e.TRANSPORT_DIRECTION_SEND=1]="TRANSPORT_DIRECTION_SEND",e[e.TRANSPORT_DIRECTION_RECEIVE=2]="TRANSPORT_DIRECTION_RECEIVE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Xi||(Xi={}));const rs={encode:(e,t=new ei)=>(""!==e.transportId&&t.uint32(10).string(e.transportId),0!==e.timeout&&t.uint32(16).uint32(e.timeout),0!==e.direction&&t.uint32(24).int32(e.direction),0!==e.reason&&t.uint32(32).int32(e.reason),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={transportId:"",timeout:0,direction:0,reason:0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(10!==e)break;i.transportId=r.string();continue;case 2:if(16!==e)break;i.timeout=r.uint32();continue;case 3:if(24!==e)break;i.direction=r.int32();continue;case 4:if(32!==e)break;i.reason=r.int32();continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({transportId:ns(e.transportId)?globalThis.String(e.transportId):"",timeout:ns(e.timeout)?globalThis.Number(e.timeout):0,direction:ns(e.direction)?ts(e.direction):0,reason:ns(e.reason)?es(e.reason):0}),toJSON(e){const t={};return""!==e.transportId&&(t.transportId=e.transportId),0!==e.timeout&&(t.timeout=Math.round(e.timeout)),0!==e.direction&&(t.direction=function(e){switch(e){case Xi.TRANSPORT_DIRECTION_UNSPECIFIED:return"TRANSPORT_DIRECTION_UNSPECIFIED";case Xi.TRANSPORT_DIRECTION_SEND:return"TRANSPORT_DIRECTION_SEND";case Xi.TRANSPORT_DIRECTION_RECEIVE:return"TRANSPORT_DIRECTION_RECEIVE";case Xi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.direction)),0!==e.reason&&(t.reason=function(e){switch(e){case Zi.TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED:return"TRANSPORT_CONNECTION_TIMEOUT_REASON_UNSPECIFIED";case Zi.TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS:return"TRANSPORT_CONNECTION_TIMEOUT_REASON_DTLS";case Zi.TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE:return"TRANSPORT_CONNECTION_TIMEOUT_REASON_ICE";case Zi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.reason)),t},create:e=>rs.fromPartial(null!=e?e:{}),fromPartial(e){var t,r,n,i;const s={transportId:"",timeout:0,direction:0,reason:0};return s.transportId=null!==(t=e.transportId)&&void 0!==t?t:"",s.timeout=null!==(r=e.timeout)&&void 0!==r?r:0,s.direction=null!==(n=e.direction)&&void 0!==n?n:0,s.reason=null!==(i=e.reason)&&void 0!==i?i:0,s}};function ns(e){return null!=e}var is;function ss(e){switch(e){case 0:case"MEDIA_EVENT_TYPE_UNSPECIFIED":return is.MEDIA_EVENT_TYPE_UNSPECIFIED;case 1:case"MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT":return is.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT;case 2:case"MEDIA_EVENT_TYPE_PRODUCER_CREATED":return is.MEDIA_EVENT_TYPE_PRODUCER_CREATED;case 3:case"MEDIA_EVENT_TYPE_PRODUCER_PAUSED":return is.MEDIA_EVENT_TYPE_PRODUCER_PAUSED;case 4:case"MEDIA_EVENT_TYPE_PRODUCER_RESUMED":return is.MEDIA_EVENT_TYPE_PRODUCER_RESUMED;case 5:case"MEDIA_EVENT_TYPE_PRODUCER_CLOSED":return is.MEDIA_EVENT_TYPE_PRODUCER_CLOSED;case 6:case"MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED":return is.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED;case 7:case"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED":return is.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED;case 8:case"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED":return is.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED;case 9:case"MEDIA_EVENT_TYPE_CONSUMER_CLOSED":return is.MEDIA_EVENT_TYPE_CONSUMER_CLOSED;case 10:case"MEDIA_EVENT_TYPE_CONSUMER_PAUSED":return is.MEDIA_EVENT_TYPE_CONSUMER_PAUSED;case 11:case"MEDIA_EVENT_TYPE_CONSUMER_RESUMED":return is.MEDIA_EVENT_TYPE_CONSUMER_RESUMED;case 12:case"MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED":return is.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED;default:return is.UNRECOGNIZED}}function os(e){switch(e){case is.MEDIA_EVENT_TYPE_UNSPECIFIED:return"MEDIA_EVENT_TYPE_UNSPECIFIED";case is.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT:return"MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT";case is.MEDIA_EVENT_TYPE_PRODUCER_CREATED:return"MEDIA_EVENT_TYPE_PRODUCER_CREATED";case is.MEDIA_EVENT_TYPE_PRODUCER_PAUSED:return"MEDIA_EVENT_TYPE_PRODUCER_PAUSED";case is.MEDIA_EVENT_TYPE_PRODUCER_RESUMED:return"MEDIA_EVENT_TYPE_PRODUCER_RESUMED";case is.MEDIA_EVENT_TYPE_PRODUCER_CLOSED:return"MEDIA_EVENT_TYPE_PRODUCER_CLOSED";case is.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED:return"MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED";case is.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED:return"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED";case is.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED:return"MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED";case is.MEDIA_EVENT_TYPE_CONSUMER_CLOSED:return"MEDIA_EVENT_TYPE_CONSUMER_CLOSED";case is.MEDIA_EVENT_TYPE_CONSUMER_PAUSED:return"MEDIA_EVENT_TYPE_CONSUMER_PAUSED";case is.MEDIA_EVENT_TYPE_CONSUMER_RESUMED:return"MEDIA_EVENT_TYPE_CONSUMER_RESUMED";case is.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED:return"MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED";case is.UNRECOGNIZED:default:return"UNRECOGNIZED"}}!function(e){e[e.MEDIA_EVENT_TYPE_UNSPECIFIED=0]="MEDIA_EVENT_TYPE_UNSPECIFIED",e[e.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT=1]="MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT",e[e.MEDIA_EVENT_TYPE_PRODUCER_CREATED=2]="MEDIA_EVENT_TYPE_PRODUCER_CREATED",e[e.MEDIA_EVENT_TYPE_PRODUCER_PAUSED=3]="MEDIA_EVENT_TYPE_PRODUCER_PAUSED",e[e.MEDIA_EVENT_TYPE_PRODUCER_RESUMED=4]="MEDIA_EVENT_TYPE_PRODUCER_RESUMED",e[e.MEDIA_EVENT_TYPE_PRODUCER_CLOSED=5]="MEDIA_EVENT_TYPE_PRODUCER_CLOSED",e[e.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED=6]="MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED",e[e.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED=7]="MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED",e[e.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED=8]="MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED",e[e.MEDIA_EVENT_TYPE_CONSUMER_CLOSED=9]="MEDIA_EVENT_TYPE_CONSUMER_CLOSED",e[e.MEDIA_EVENT_TYPE_CONSUMER_PAUSED=10]="MEDIA_EVENT_TYPE_CONSUMER_PAUSED",e[e.MEDIA_EVENT_TYPE_CONSUMER_RESUMED=11]="MEDIA_EVENT_TYPE_CONSUMER_RESUMED",e[e.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED=12]="MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(is||(is={}));const as={encode:(e,t=new ei)=>(0!==e.eventType&&t.uint32(8).int32(e.eventType),void 0!==e.producer&&Di.encode(e.producer,t.uint32(18).fork()).join(),void 0!==e.consumer&&$i.encode(e.consumer,t.uint32(26).fork()).join(),void 0!==e.producerSpatialLayerRequest&&Ki.encode(e.producerSpatialLayerRequest,t.uint32(34).fork()).join(),void 0!==e.transportConnectionTimeout&&rs.encode(e.transportConnectionTimeout,t.uint32(42).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={eventType:0,producer:void 0,consumer:void 0,producerSpatialLayerRequest:void 0,transportConnectionTimeout:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.eventType=r.int32();continue;case 2:if(18!==e)break;i.producer=Di.decode(r,r.uint32());continue;case 3:if(26!==e)break;i.consumer=$i.decode(r,r.uint32());continue;case 4:if(34!==e)break;i.producerSpatialLayerRequest=Ki.decode(r,r.uint32());continue;case 5:if(42!==e)break;i.transportConnectionTimeout=rs.decode(r,r.uint32());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({eventType:cs(e.eventType)?ss(e.eventType):0,producer:cs(e.producer)?Di.fromJSON(e.producer):void 0,consumer:cs(e.consumer)?$i.fromJSON(e.consumer):void 0,producerSpatialLayerRequest:cs(e.producerSpatialLayerRequest)?Ki.fromJSON(e.producerSpatialLayerRequest):void 0,transportConnectionTimeout:cs(e.transportConnectionTimeout)?rs.fromJSON(e.transportConnectionTimeout):void 0}),toJSON(e){const t={};return 0!==e.eventType&&(t.eventType=os(e.eventType)),void 0!==e.producer&&(t.producer=Di.toJSON(e.producer)),void 0!==e.consumer&&(t.consumer=$i.toJSON(e.consumer)),void 0!==e.producerSpatialLayerRequest&&(t.producerSpatialLayerRequest=Ki.toJSON(e.producerSpatialLayerRequest)),void 0!==e.transportConnectionTimeout&&(t.transportConnectionTimeout=rs.toJSON(e.transportConnectionTimeout)),t},create:e=>as.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={eventType:0,producer:void 0,consumer:void 0,producerSpatialLayerRequest:void 0,transportConnectionTimeout:void 0};return r.eventType=null!==(t=e.eventType)&&void 0!==t?t:0,r.producer=void 0!==e.producer&&null!==e.producer?Di.fromPartial(e.producer):void 0,r.consumer=void 0!==e.consumer&&null!==e.consumer?$i.fromPartial(e.consumer):void 0,r.producerSpatialLayerRequest=void 0!==e.producerSpatialLayerRequest&&null!==e.producerSpatialLayerRequest?Ki.fromPartial(e.producerSpatialLayerRequest):void 0,r.transportConnectionTimeout=void 0!==e.transportConnectionTimeout&&null!==e.transportConnectionTimeout?rs.fromPartial(e.transportConnectionTimeout):void 0,r}};function cs(e){return null!=e}const ds={encode:(e,t=new ei)=>(0!==e.id&&t.uint32(8).int32(e.id),void 0!==e.channelEvent&&Gi.encode(e.channelEvent,t.uint32(18).fork()).join(),void 0!==e.mediaEvent&&as.encode(e.mediaEvent,t.uint32(26).fork()).join(),t),decode(e,t){const r=e instanceof ti?e:new ti(e),n=void 0===t?r.len:r.pos+t,i={id:0,channelEvent:void 0,mediaEvent:void 0};for(;r.pos<n;){const e=r.uint32();switch(e>>>3){case 1:if(8!==e)break;i.id=r.int32();continue;case 2:if(18!==e)break;i.channelEvent=Gi.decode(r,r.uint32());continue;case 3:if(26!==e)break;i.mediaEvent=as.decode(r,r.uint32());continue}if(4==(7&e)||0===e)break;r.skip(7&e)}return i},fromJSON:e=>({id:us(e.id)?globalThis.Number(e.id):0,channelEvent:us(e.channelEvent)?Gi.fromJSON(e.channelEvent):void 0,mediaEvent:us(e.mediaEvent)?as.fromJSON(e.mediaEvent):void 0}),toJSON(e){const t={};return 0!==e.id&&(t.id=Math.round(e.id)),void 0!==e.channelEvent&&(t.channelEvent=Gi.toJSON(e.channelEvent)),void 0!==e.mediaEvent&&(t.mediaEvent=as.toJSON(e.mediaEvent)),t},create:e=>ds.fromPartial(null!=e?e:{}),fromPartial(e){var t;const r={id:0,channelEvent:void 0,mediaEvent:void 0};return r.id=null!==(t=e.id)&&void 0!==t?t:0,r.channelEvent=void 0!==e.channelEvent&&null!==e.channelEvent?Gi.fromPartial(e.channelEvent):void 0,r.mediaEvent=void 0!==e.mediaEvent&&null!==e.mediaEvent?as.fromPartial(e.mediaEvent):void 0,r}};function us(e){return null!=e}var ls,ps,hs,fs,ms,gs,vs,ys;let _s=class{constructor(e){ls.set(this,[]),ps.set(this,!1),hs.set(this,!1),fs.set(this,void 0),ms.set(this,void 0),gs.set(this,new Map),vs.set(this,void 0),ys.set(this,new Set),d(this,vs,e("EventsQueue"),"f")}setMediaEventHandler(e){d(this,fs,e,"f"),c(this,vs,"f").info("Media event handler set",{case:"EventsQueue"})}setChannelEventHandler(e){d(this,ms,e,"f"),c(this,vs,"f").info("Channel event handler set",{case:"EventsQueue"})}subscribe(e){d(this,ys,new Set,"f");let t=0;const r=e=>{try{const r=this.processMessageChunk(e);if(!r||!this.isPendingMessageFullyReceived(r))return;const n=this.finalizeMessageBytes(r),i=ds.decode(n);i.id&&(c(this,ys,"f").has(i.id)&&c(this,vs,"f").warn("Received duplicate message",{case:"EventsQueue",lastReceivedMsgId:t,currentReceivedMsgId:i.id}),i.id>t+1&&c(this,vs,"f").warn("Received out of order message",{case:"EventsQueue",lastReceivedMsgId:t,currentReceivedMsgId:i.id})),c(this,ys,"f").add(i.id),t=i.id,this.push(i)}catch(e){c(this,vs,"f").error("Failed to parse channel message",{error:Ct(e),case:"EventsQueue"})}},n=()=>{e.removeListener("message",r),e.removeListener("close",n)};e.on("close",n),e.on("message",r),c(this,vs,"f").info("Subscribed to data channel",{case:"EventsQueue"})}push(e){c(this,ls,"f").push(e),this.process()}process(){return a(this,void 0,void 0,(function*(){if(!c(this,ps,"f")&&!c(this,hs,"f")){for(d(this,hs,!0,"f");!c(this,ps,"f")&&c(this,ls,"f").length>0;){const e=c(this,ls,"f").shift();if(e)try{if(e.channelEvent&&c(this,ms,"f")){c(this,vs,"f").debug("Handle channel event",{case:"EventsQueue",id:e.id,type:zi(e.channelEvent.eventType),event:e.channelEvent}),yield c(this,ms,"f").call(this,e.channelEvent);continue}if(e.mediaEvent&&c(this,fs,"f")){c(this,vs,"f").debug("Handle media event",{case:"EventsQueue",id:e.id,type:os(e.mediaEvent.eventType),event:e.mediaEvent}),yield c(this,fs,"f").call(this,e.mediaEvent);continue}c(this,vs,"f").warn("Received unknown message",{message:e,case:"EventsQueue"})}catch(t){c(this,vs,"f").error("Failed to handle event",{case:"EventsQueue",id:e.id,error:Ct(t)})}}d(this,hs,!1,"f"),!c(this,ps,"f")&&c(this,ls,"f").length>0&&queueMicrotask((()=>{this.process()}))}}))}processMessageChunk(e){const t=new Uint8Array(e);if(t.length<12)return void c(this,vs,"f").warn("Chunk too small",{case:"EventsQueue",bytesLength:t.length});const{msgId:r,index:n,total:i}=this.parseMessageChunkHeader(t),s=t.slice(12);c(this,gs,"f").has(r)||c(this,gs,"f").set(r,{msgId:r,total:i,received:[]});const o=c(this,gs,"f").get(r);if(o)return o.received[n]=s,o.msgId=r,o;c(this,vs,"f").warn("Chunk buffer entry not found for msgId",{msgId:r,case:"EventsQueue"})}parseMessageChunkHeader(e){const t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{msgId:t.getUint32(0),index:t.getUint32(4),total:t.getUint32(8)}}isPendingMessageFullyReceived(e){return e.received.filter(Boolean).length===e.total}finalizeMessageBytes(e){const t=new Uint8Array(e.received.reduce(((e,t)=>e+t.length),0));let r=0;for(const n of e.received)t.set(n,r),r+=n.length;return c(this,gs,"f").delete(e.msgId),t}pause(){d(this,ps,!0,"f")}size(){return c(this,ls,"f").length}resume(){d(this,ps,!1,"f"),this.process()}isMessageReceived(e){return c(this,ys,"f").has(e)}};ls=new WeakMap,ps=new WeakMap,hs=new WeakMap,fs=new WeakMap,ms=new WeakMap,gs=new WeakMap,vs=new WeakMap,ys=new WeakMap,_s=i([at(),s(0,dt(On.LoggerFactory)),o("design:paramtypes",[Function])],_s);var bs=_s;function Es(e){return{id:e.id,appId:e.appId,role:e.role,groups:e.groups,producePermissions:e.producePermissions}}let ws=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)}};ws=i([at()],ws);class Ss extends mn{constructor(e,t,r){super(null!=e?e:Ss.DEFAULT_MESSAGE,null!=t?t:"something_went_wrong",r)}}Ss.DEFAULT_MESSAGE="Request failed";const Cs=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 Ps(e){return!e.response&&(!!e.code&&(!["ERR_CANCELED","ECONNABORTED"].includes(e.code)&&(e=>!Cs.has(e&&e.code))(e)))}const Ts=["get","head","options"],Rs=Ts.concat(["put","delete"]);function ks(e){return"ECONNABORTED"!==e.code&&(!e.response||429===e.response.status||e.response.status>=500&&e.response.status<=599)}function Ds(e){return!!e.config?.method&&(ks(e)&&-1!==Rs.indexOf(e.config.method))}function Is(e){return Ps(e)||Ds(e)}function As(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 Os={retries:3,retryCondition:Is,retryDelay:function(e=0,t){return Math.max(0,As(t))},shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function Ns(e,t,r=!1){const n=function(e,t){return{...Os,...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 Ms=(e,t)=>{const r=e.interceptors.request.use((e=>(Ns(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=Ns(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}};function Ls(e,t){return function(){return e.apply(t,arguments)}}Ms.isNetworkError=Ps,Ms.isSafeRequestError=function(e){return!!e.config?.method&&(ks(e)&&-1!==Ts.indexOf(e.config.method))},Ms.isIdempotentRequestError=Ds,Ms.isNetworkOrIdempotentRequestError=Is,Ms.exponentialDelay=function(e=0,t,r=100){const n=2**e*r,i=Math.max(n,As(t));return i+.2*i*Math.random()},Ms.linearDelay=function(e=100){return(t=0,r)=>{const n=t*e;return Math.max(n,As(r))}},Ms.isRetryableError=ks;const{toString:xs}=Object.prototype,{getPrototypeOf:Fs}=Object,{iterator:js,toStringTag:Us}=Symbol,Vs=(Bs=Object.create(null),e=>{const t=xs.call(e);return Bs[t]||(Bs[t]=t.slice(8,-1).toLowerCase())});var Bs;const Ws=e=>(e=e.toLowerCase(),t=>Vs(t)===e),Hs=e=>t=>typeof t===e,{isArray:qs}=Array,zs=Hs("undefined");const Gs=Ws("ArrayBuffer");const Ys=Hs("string"),$s=Hs("function"),Js=Hs("number"),Ks=e=>null!==e&&"object"==typeof e,Qs=e=>{if("object"!==Vs(e))return!1;const t=Fs(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Us in e||js in e)},Zs=Ws("Date"),Xs=Ws("File"),eo=Ws("Blob"),to=Ws("FileList"),ro=Ws("URLSearchParams"),[no,io,so,oo]=["ReadableStream","Request","Response","Headers"].map(Ws);function ao(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),qs(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length;let o;for(n=0;n<s;n++)o=i[n],t.call(null,e[o],o,e)}}function co(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,i=r.length;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}const uo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,lo=e=>!zs(e)&&e!==uo;const po=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&Fs(Uint8Array)),ho=Ws("HTMLFormElement"),fo=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),mo=Ws("RegExp"),go=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};ao(r,((r,i)=>{let s;!1!==(s=t(r,i,e))&&(n[i]=s||r)})),Object.defineProperties(e,n)};const vo=Ws("AsyncFunction"),yo=(_o="function"==typeof setImmediate,bo=$s(uo.postMessage),_o?setImmediate:bo?(Eo=`axios@${Math.random()}`,wo=[],uo.addEventListener("message",(({source:e,data:t})=>{e===uo&&t===Eo&&wo.length&&wo.shift()()}),!1),e=>{wo.push(e),uo.postMessage(Eo,"*")}):e=>setTimeout(e));var _o,bo,Eo,wo;const So="undefined"!=typeof queueMicrotask?queueMicrotask.bind(uo):"undefined"!=typeof process&&process.nextTick||yo;var Co={isArray:qs,isArrayBuffer:Gs,isBuffer:function(e){return null!==e&&!zs(e)&&null!==e.constructor&&!zs(e.constructor)&&$s(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||$s(e.append)&&("formdata"===(t=Vs(e))||"object"===t&&$s(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Gs(e.buffer),t},isString:Ys,isNumber:Js,isBoolean:e=>!0===e||!1===e,isObject:Ks,isPlainObject:Qs,isReadableStream:no,isRequest:io,isResponse:so,isHeaders:oo,isUndefined:zs,isDate:Zs,isFile:Xs,isBlob:eo,isRegExp:mo,isFunction:$s,isStream:e=>Ks(e)&&$s(e.pipe),isURLSearchParams:ro,isTypedArray:po,isFileList:to,forEach:ao,merge:function e(){const{caseless:t}=lo(this)&&this||{},r={},n=(n,i)=>{const s=t&&co(r,i)||i;Qs(r[s])&&Qs(n)?r[s]=e(r[s],n):Qs(n)?r[s]=e({},n):qs(n)?r[s]=n.slice():r[s]=n};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&ao(arguments[e],n);return r},extend:(e,t,r,{allOwnKeys:n}={})=>(ao(t,((t,n)=>{r&&$s(t)?e[n]=Ls(t,r):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let i,s,o;const a={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),s=i.length;s-- >0;)o=i[s],n&&!n(o,e,t)||a[o]||(t[o]=e[o],a[o]=!0);e=!1!==r&&Fs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:Vs,kindOfTest:Ws,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(qs(e))return e;let t=e.length;if(!Js(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[js]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:ho,hasOwnProperty:fo,hasOwnProp:fo,reduceDescriptors:go,freezeMethods:e=>{go(e,((t,r)=>{if($s(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];$s(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return qs(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:co,global:uo,isContextDefined:lo,isSpecCompliantForm:function(e){return!!(e&&$s(e.append)&&"FormData"===e[Us]&&e[js])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(Ks(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const i=qs(e)?[]:{};return ao(e,((e,t)=>{const s=r(e,n+1);!zs(s)&&(i[t]=s)})),t[n]=void 0,i}}return e};return r(e,0)},isAsyncFn:vo,isThenable:e=>e&&(Ks(e)||$s(e))&&$s(e.then)&&$s(e.catch),setImmediate:yo,asap:So,isIterable:e=>null!=e&&$s(e[js])};function Po(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Co.inherits(Po,Error,{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:Co.toJSONObject(this.config),code:this.code,status:this.status}}});const To=Po.prototype,Ro={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{Ro[e]={value:e}})),Object.defineProperties(Po,Ro),Object.defineProperty(To,"isAxiosError",{value:!0}),Po.from=(e,t,r,n,i,s)=>{const o=Object.create(To);return Co.toFlatObject(e,o,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),Po.call(o,e.message,t,r,n,i),o.cause=e,o.name=e.name,s&&Object.assign(o,s),o};function ko(e){return Co.isPlainObject(e)||Co.isArray(e)}function Do(e){return Co.endsWith(e,"[]")?e.slice(0,-2):e}function Io(e,t,r){return e?e.concat(t).map((function(e,t){return e=Do(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const Ao=Co.toFlatObject(Co,{},null,(function(e){return/^is[A-Z]/.test(e)}));function Oo(e,t,r){if(!Co.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=Co.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!Co.isUndefined(t[e])}))).metaTokens,i=r.visitor||d,s=r.dots,o=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&Co.isSpecCompliantForm(t);if(!Co.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(Co.isDate(e))return e.toISOString();if(Co.isBoolean(e))return e.toString();if(!a&&Co.isBlob(e))throw new Po("Blob is not supported. Use a Buffer instead.");return Co.isArrayBuffer(e)||Co.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function d(e,r,i){let a=e;if(e&&!i&&"object"==typeof e)if(Co.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(Co.isArray(e)&&function(e){return Co.isArray(e)&&!e.some(ko)}(e)||(Co.isFileList(e)||Co.endsWith(r,"[]"))&&(a=Co.toArray(e)))return r=Do(r),a.forEach((function(e,n){!Co.isUndefined(e)&&null!==e&&t.append(!0===o?Io([r],n,s):null===o?r:r+"[]",c(e))})),!1;return!!ko(e)||(t.append(Io(i,r,s),c(e)),!1)}const u=[],l=Object.assign(Ao,{defaultVisitor:d,convertValue:c,isVisitable:ko});if(!Co.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!Co.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),Co.forEach(r,(function(r,s){!0===(!(Co.isUndefined(r)||null===r)&&i.call(t,r,Co.isString(s)?s.trim():s,n,l))&&e(r,n?n.concat(s):[s])})),u.pop()}}(e),t}function No(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function Mo(e,t){this._pairs=[],e&&Oo(e,this,t)}const Lo=Mo.prototype;function xo(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Fo(e,t,r){if(!t)return e;const n=r&&r.encode||xo;Co.isFunction(r)&&(r={serialize:r});const i=r&&r.serialize;let s;if(s=i?i(t,r):Co.isURLSearchParams(t)?t.toString():new Mo(t,r).toString(n),s){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}Lo.append=function(e,t){this._pairs.push([e,t])},Lo.toString=function(e){const t=e?function(t){return e.call(this,t,No)}:No;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var jo=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Co.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},Uo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Vo={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Mo,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Bo="undefined"!=typeof window&&"undefined"!=typeof document,Wo="object"==typeof navigator&&navigator||void 0,Ho=Bo&&(!Wo||["ReactNative","NativeScript","NS"].indexOf(Wo.product)<0),qo="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,zo=Bo&&window.location.href||"http://localhost";var Go={...Object.freeze({__proto__:null,hasBrowserEnv:Bo,hasStandardBrowserWebWorkerEnv:qo,hasStandardBrowserEnv:Ho,navigator:Wo,origin:zo}),...Vo};function Yo(e){function t(e,r,n,i){let s=e[i++];if("__proto__"===s)return!0;const o=Number.isFinite(+s),a=i>=e.length;if(s=!s&&Co.isArray(n)?n.length:s,a)return Co.hasOwnProp(n,s)?n[s]=[n[s],r]:n[s]=r,!o;n[s]&&Co.isObject(n[s])||(n[s]=[]);return t(e,r,n[s],i)&&Co.isArray(n[s])&&(n[s]=function(e){const t={},r=Object.keys(e);let n;const i=r.length;let s;for(n=0;n<i;n++)s=r[n],t[s]=e[s];return t}(n[s])),!o}if(Co.isFormData(e)&&Co.isFunction(e.entries)){const r={};return Co.forEachEntry(e,((e,n)=>{t(function(e){return Co.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const $o={transitional:Uo,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=Co.isObject(e);i&&Co.isHTMLForm(e)&&(e=new FormData(e));if(Co.isFormData(e))return n?JSON.stringify(Yo(e)):e;if(Co.isArrayBuffer(e)||Co.isBuffer(e)||Co.isStream(e)||Co.isFile(e)||Co.isBlob(e)||Co.isReadableStream(e))return e;if(Co.isArrayBufferView(e))return e.buffer;if(Co.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Oo(e,new Go.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return Go.isNode&&Co.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((s=Co.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Oo(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),function(e,t,r){if(Co.isString(e))try{return(t||JSON.parse)(e),Co.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||$o.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(Co.isResponse(e)||Co.isReadableStream(e))return e;if(e&&Co.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw Po.from(e,Po.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Go.classes.FormData,Blob:Go.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Co.forEach(["delete","get","head","post","put","patch"],(e=>{$o.headers[e]={}}));var Jo=$o;const Ko=Co.toObjectSet(["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"]);const Qo=Symbol("internals");function Zo(e){return e&&String(e).trim().toLowerCase()}function Xo(e){return!1===e||null==e?e:Co.isArray(e)?e.map(Xo):String(e)}function ea(e,t,r,n,i){return Co.isFunction(n)?n.call(this,t,r):(i&&(t=r),Co.isString(t)?Co.isString(n)?-1!==t.indexOf(n):Co.isRegExp(n)?n.test(t):void 0:void 0)}class ta{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function i(e,t,r){const i=Zo(t);if(!i)throw new Error("header name must be a non-empty string");const s=Co.findKey(n,i);(!s||void 0===n[s]||!0===r||void 0===r&&!1!==n[s])&&(n[s||t]=Xo(e))}const s=(e,t)=>Co.forEach(e,((e,r)=>i(e,r,t)));if(Co.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if(Co.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))s((e=>{const t={};let r,n,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!r||t[r]&&Ko[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t);else if(Co.isObject(e)&&Co.isIterable(e)){let r,n,i={};for(const t of e){if(!Co.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[n=t[0]]=(r=i[n])?Co.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}s(i,t)}else null!=e&&i(t,e,r);return this}get(e,t){if(e=Zo(e)){const r=Co.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(Co.isFunction(t))return t.call(this,e,r);if(Co.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Zo(e)){const r=Co.findKey(this,e);return!(!r||void 0===this[r]||t&&!ea(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function i(e){if(e=Zo(e)){const i=Co.findKey(r,e);!i||t&&!ea(0,r[i],i,t)||(delete r[i],n=!0)}}return Co.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const i=t[r];e&&!ea(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,r={};return Co.forEach(this,((n,i)=>{const s=Co.findKey(r,i);if(s)return t[s]=Xo(n),void delete t[i];const o=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(i):String(i).trim();o!==i&&delete t[i],t[o]=Xo(n),r[o]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Co.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&Co.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[Qo]=this[Qo]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=Zo(e);t[n]||(!function(e,t){const r=Co.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,i){return this[n].call(this,t,e,r,i)},configurable:!0})}))}(r,e),t[n]=!0)}return Co.isArray(e)?e.forEach(n):n(e),this}}ta.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Co.reduceDescriptors(ta.prototype,(({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}})),Co.freezeMethods(ta);var ra=ta;function na(e,t){const r=this||Jo,n=t||r,i=ra.from(n.headers);let s=n.data;return Co.forEach(e,(function(e){s=e.call(r,s,i.normalize(),t?t.status:void 0)})),i.normalize(),s}function ia(e){return!(!e||!e.__CANCEL__)}function sa(e,t,r){Po.call(this,null==e?"canceled":e,Po.ERR_CANCELED,t,r),this.name="CanceledError"}function oa(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new Po("Request failed with status code "+r.status,[Po.ERR_BAD_REQUEST,Po.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}Co.inherits(sa,Po,{__CANCEL__:!0});const aa=(e,t,r=3)=>{let n=0;const i=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i,s=0,o=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),d=n[o];i||(i=c),r[s]=a,n[s]=c;let u=o,l=0;for(;u!==s;)l+=r[u++],u%=e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),c-i<t)return;const p=d&&c-d;return p?Math.round(1e3*l/p):void 0}}(50,250);return function(e,t){let r,n,i=0,s=1e3/t;const o=(t,s=Date.now())=>{i=s,r=null,n&&(clearTimeout(n),n=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),a=t-i;a>=s?o(e,t):(r=e,n||(n=setTimeout((()=>{n=null,o(r)}),s-a)))},()=>r&&o(r)]}((r=>{const s=r.loaded,o=r.lengthComputable?r.total:void 0,a=s-n,c=i(a);n=s;e({loaded:s,total:o,progress:o?s/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&s<=o?(o-s)/c:void 0,event:r,lengthComputable:null!=o,[t?"download":"upload"]:!0})}),r)},ca=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},da=e=>(...t)=>Co.asap((()=>e(...t)));var ua=Go.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,Go.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(Go.origin),Go.navigator&&/(msie|trident)/i.test(Go.navigator.userAgent)):()=>!0,la=Go.hasStandardBrowserEnv?{write(e,t,r,n,i,s){const o=[e+"="+encodeURIComponent(t)];Co.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Co.isString(n)&&o.push("path="+n),Co.isString(i)&&o.push("domain="+i),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function pa(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const ha=e=>e instanceof ra?{...e}:e;function fa(e,t){t=t||{};const r={};function n(e,t,r,n){return Co.isPlainObject(e)&&Co.isPlainObject(t)?Co.merge.call({caseless:n},e,t):Co.isPlainObject(t)?Co.merge({},t):Co.isArray(t)?t.slice():t}function i(e,t,r,i){return Co.isUndefined(t)?Co.isUndefined(e)?void 0:n(void 0,e,0,i):n(e,t,0,i)}function s(e,t){if(!Co.isUndefined(t))return n(void 0,t)}function o(e,t){return Co.isUndefined(t)?Co.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(r,i,s){return s in t?n(r,i):s in e?n(void 0,r):void 0}const c={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(e,t,r)=>i(ha(e),ha(t),0,!0)};return Co.forEach(Object.keys(Object.assign({},e,t)),(function(n){const s=c[n]||i,o=s(e[n],t[n],n);Co.isUndefined(o)&&s!==a||(r[n]=o)})),r}var ma=e=>{const t=fa({},e);let r,{data:n,withXSRFToken:i,xsrfHeaderName:s,xsrfCookieName:o,headers:a,auth:c}=t;if(t.headers=a=ra.from(a),t.url=Fo(pa(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),Co.isFormData(n))if(Go.hasStandardBrowserEnv||Go.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(r=a.getContentType())){const[e,...t]=r?r.split(";").map((e=>e.trim())).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(Go.hasStandardBrowserEnv&&(i&&Co.isFunction(i)&&(i=i(t)),i||!1!==i&&ua(t.url))){const e=s&&o&&la.read(o);e&&a.set(s,e)}return t};var ga="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){const n=ma(e);let i=n.data;const s=ra.from(n.headers).normalize();let o,a,c,d,u,{responseType:l,onUploadProgress:p,onDownloadProgress:h}=n;function f(){d&&d(),u&&u(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let m=new XMLHttpRequest;function g(){if(!m)return;const n=ra.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());oa((function(e){t(e),f()}),(function(e){r(e),f()}),{data:l&&"text"!==l&&"json"!==l?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:n,config:e,request:m}),m=null}m.open(n.method.toUpperCase(),n.url,!0),m.timeout=n.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(r(new Po("Request aborted",Po.ECONNABORTED,e,m)),m=null)},m.onerror=function(){r(new Po("Network Error",Po.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const i=n.transitional||Uo;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new Po(t,i.clarifyTimeoutError?Po.ETIMEDOUT:Po.ECONNABORTED,e,m)),m=null},void 0===i&&s.setContentType(null),"setRequestHeader"in m&&Co.forEach(s.toJSON(),(function(e,t){m.setRequestHeader(t,e)})),Co.isUndefined(n.withCredentials)||(m.withCredentials=!!n.withCredentials),l&&"json"!==l&&(m.responseType=n.responseType),h&&([c,u]=aa(h,!0),m.addEventListener("progress",c)),p&&m.upload&&([a,d]=aa(p),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",d)),(n.cancelToken||n.signal)&&(o=t=>{m&&(r(!t||t.type?new sa(null,e,m):t),m.abort(),m=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));const v=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);v&&-1===Go.protocols.indexOf(v)?r(new Po("Unsupported protocol "+v+":",Po.ERR_BAD_REQUEST,e)):m.send(i||null)}))};var va=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const i=function(e){if(!r){r=!0,o();const t=e instanceof Error?e:this.reason;n.abort(t instanceof Po?t:new sa(t instanceof Error?t.message:t))}};let s=t&&setTimeout((()=>{s=null,i(new Po(`timeout ${t} of ms exceeded`,Po.ETIMEDOUT))}),t);const o=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)})),e=null)};e.forEach((e=>e.addEventListener("abort",i)));const{signal:a}=n;return a.unsubscribe=()=>Co.asap(o),a}};const ya=function*(e,t){let r=e.byteLength;if(!t||r<t)return void(yield e);let n,i=0;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},_a=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}},ba=(e,t,r,n)=>{const i=async function*(e,t){for await(const r of _a(e))yield*ya(r,t)}(e,t);let s,o=0,a=e=>{s||(s=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await i.next();if(t)return a(),void e.close();let s=n.byteLength;if(r){let e=o+=s;r(e)}e.enqueue(new Uint8Array(n))}catch(e){throw a(e),e}},cancel:e=>(a(e),i.return())},{highWaterMark:2})},Ea="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,wa=Ea&&"function"==typeof ReadableStream,Sa=Ea&&("function"==typeof TextEncoder?(Ca=new TextEncoder,e=>Ca.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var Ca;const Pa=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Ta=wa&&Pa((()=>{let e=!1;const t=new Request(Go.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),Ra=wa&&Pa((()=>Co.isReadableStream(new Response("").body))),ka={stream:Ra&&(e=>e.body)};var Da;Ea&&(Da=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!ka[e]&&(ka[e]=Co.isFunction(Da[e])?t=>t[e]():(t,r)=>{throw new Po(`Response type '${e}' is not supported`,Po.ERR_NOT_SUPPORT,r)})})));const Ia=async(e,t)=>{const r=Co.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Co.isBlob(e))return e.size;if(Co.isSpecCompliantForm(e)){const t=new Request(Go.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Co.isArrayBufferView(e)||Co.isArrayBuffer(e)?e.byteLength:(Co.isURLSearchParams(e)&&(e+=""),Co.isString(e)?(await Sa(e)).byteLength:void 0)})(t):r};var Aa=Ea&&(async e=>{let{url:t,method:r,data:n,signal:i,cancelToken:s,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:d,headers:u,withCredentials:l="same-origin",fetchOptions:p}=ma(e);d=d?(d+"").toLowerCase():"text";let h,f=va([i,s&&s.toAbortSignal()],o);const m=f&&f.unsubscribe&&(()=>{f.unsubscribe()});let g;try{if(c&&Ta&&"get"!==r&&"head"!==r&&0!==(g=await Ia(u,n))){let e,r=new Request(t,{method:"POST",body:n,duplex:"half"});if(Co.isFormData(n)&&(e=r.headers.get("content-type"))&&u.setContentType(e),r.body){const[e,t]=ca(g,aa(da(c)));n=ba(r.body,65536,e,t)}}Co.isString(l)||(l=l?"include":"omit");const i="credentials"in Request.prototype;h=new Request(t,{...p,signal:f,method:r.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:i?l:void 0});let s=await fetch(h,p);const o=Ra&&("stream"===d||"response"===d);if(Ra&&(a||o&&m)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=s[t]}));const t=Co.toFiniteNumber(s.headers.get("content-length")),[r,n]=a&&ca(t,aa(da(a),!0))||[];s=new Response(ba(s.body,65536,r,(()=>{n&&n(),m&&m()})),e)}d=d||"text";let v=await ka[Co.findKey(ka,d)||"text"](s,e);return!o&&m&&m(),await new Promise(((t,r)=>{oa(t,r,{data:v,headers:ra.from(s.headers),status:s.status,statusText:s.statusText,config:e,request:h})}))}catch(t){if(m&&m(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new Po("Network Error",Po.ERR_NETWORK,e,h),{cause:t.cause||t});throw Po.from(t,t&&t.code,e,h)}});const Oa={http:null,xhr:ga,fetch:Aa};Co.forEach(Oa,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const Na=e=>`- ${e}`,Ma=e=>Co.isFunction(e)||null===e||!1===e;var La=e=>{e=Co.isArray(e)?e:[e];const{length:t}=e;let r,n;const i={};for(let s=0;s<t;s++){let t;if(r=e[s],n=r,!Ma(r)&&(n=Oa[(t=String(r)).toLowerCase()],void 0===n))throw new Po(`Unknown adapter '${t}'`);if(n)break;i[t||"#"+s]=n}if(!n){const e=Object.entries(i).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new Po("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(Na).join("\n"):" "+Na(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function xa(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new sa(null,e)}function Fa(e){xa(e),e.headers=ra.from(e.headers),e.data=na.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return La(e.adapter||Jo.adapter)(e).then((function(t){return xa(e),t.data=na.call(e,e.transformResponse,t),t.headers=ra.from(t.headers),t}),(function(t){return ia(t)||(xa(e),t&&t.response&&(t.response.data=na.call(e,e.transformResponse,t.response),t.response.headers=ra.from(t.response.headers))),Promise.reject(t)}))}const ja={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{ja[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const Ua={};ja.transitional=function(e,t,r){function n(e,t){return"[Axios v1.10.0] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,s)=>{if(!1===e)throw new Po(n(i," has been removed"+(t?" in "+t:"")),Po.ERR_DEPRECATED);return t&&!Ua[i]&&(Ua[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,s)}},ja.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var Va={assertOptions:function(e,t,r){if("object"!=typeof e)throw new Po("options must be an object",Po.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const s=n[i],o=t[s];if(o){const t=e[s],r=void 0===t||o(t,s,e);if(!0!==r)throw new Po("option "+s+" must be "+r,Po.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new Po("Unknown option "+s,Po.ERR_BAD_OPTION)}},validators:ja};const Ba=Va.validators;class Wa{constructor(e){this.defaults=e||{},this.interceptors={request:new jo,response:new jo}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const r=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?r&&!String(e.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+r):e.stack=r}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=fa(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:i}=t;void 0!==r&&Va.assertOptions(r,{silentJSONParsing:Ba.transitional(Ba.boolean),forcedJSONParsing:Ba.transitional(Ba.boolean),clarifyTimeoutError:Ba.transitional(Ba.boolean)},!1),null!=n&&(Co.isFunction(n)?t.paramsSerializer={serialize:n}:Va.assertOptions(n,{encode:Ba.function,serialize:Ba.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Va.assertOptions(t,{baseUrl:Ba.spelling("baseURL"),withXsrfToken:Ba.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=i&&Co.merge(i.common,i[t.method]);i&&Co.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete i[e]})),t.headers=ra.concat(s,i);const o=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,o.unshift(e.fulfilled,e.rejected))}));const c=[];let d;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let u,l=0;if(!a){const e=[Fa.bind(this),void 0];for(e.unshift.apply(e,o),e.push.apply(e,c),u=e.length,d=Promise.resolve(t);l<u;)d=d.then(e[l++],e[l++]);return d}u=o.length;let p=t;for(l=0;l<u;){const e=o[l++],t=o[l++];try{p=e(p)}catch(e){t.call(this,e);break}}try{d=Fa.call(this,p)}catch(e){return Promise.reject(e)}for(l=0,u=c.length;l<u;)d=d.then(c[l++],c[l++]);return d}getUri(e){return Fo(pa((e=fa(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}Co.forEach(["delete","get","head","options"],(function(e){Wa.prototype[e]=function(t,r){return this.request(fa(r||{},{method:e,url:t,data:(r||{}).data}))}})),Co.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(fa(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}Wa.prototype[e]=t(),Wa.prototype[e+"Form"]=t(!0)}));var Ha=Wa;class qa{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,i){r.reason||(r.reason=new sa(e,n,i),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;const t=new qa((function(t){e=t}));return{token:t,cancel:e}}}var za=qa;const Ga={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ga).forEach((([e,t])=>{Ga[t]=e}));var Ya=Ga;const $a=function e(t){const r=new Ha(t),n=Ls(Ha.prototype.request,r);return Co.extend(n,Ha.prototype,r,{allOwnKeys:!0}),Co.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(fa(t,r))},n}(Jo);$a.Axios=Ha,$a.CanceledError=sa,$a.CancelToken=za,$a.isCancel=ia,$a.VERSION="1.10.0",$a.toFormData=Oo,$a.AxiosError=Po,$a.Cancel=$a.CanceledError,$a.all=function(e){return Promise.all(e)},$a.spread=function(e){return function(t){return e.apply(null,t)}},$a.isAxiosError=function(e){return Co.isObject(e)&&!0===e.isAxiosError},$a.mergeConfig=fa,$a.AxiosHeaders=ra,$a.formToJSON=e=>Yo(Co.isHTMLForm(e)?new FormData(e):e),$a.getAdapter=La,$a.HttpStatusCode=Ya,$a.default=$a;var Ja=$a;class Ka extends mn{constructor(e,t,r){super(null!=e?e:Ka.DEFAULT_MESSAGE,null!=t?t:"already_connected",r)}}Ka.DEFAULT_MESSAGE="Peer is already connected";class Qa extends mn{constructor(e,t,r){super(null!=e?e:Qa.DEFAULT_MESSAGE,null!=t?t:"already_created",r)}}Qa.DEFAULT_MESSAGE="Resource has already been created";class Za extends mn{constructor(e,t,r){super(null!=e?e:Za.DEFAULT_MESSAGE,null!=t?t:"forbidden",r)}}Za.DEFAULT_MESSAGE="Forbidden";class Xa extends mn{constructor(e,t,r){super(null!=e?e:Xa.DEFAULT_MESSAGE,null!=t?t:"invalid_request",r)}}Xa.DEFAULT_MESSAGE="Invalid request";class ec extends mn{constructor(e,t,r){super(null!=e?e:ec.DEFAULT_MESSAGE,null!=t?t:"not_found",r)}}ec.DEFAULT_MESSAGE="Requested resource was not found";class tc extends mn{constructor(e,t,r){super(null!=e?e:tc.DEFAULT_MESSAGE,null!=t?t:"timeout",r)}}tc.DEFAULT_MESSAGE="Request timed out";class rc extends mn{constructor(e,t,r){super(null!=e?e:rc.DEFAULT_MESSAGE,null!=t?t:"too_many_requests",r)}}rc.DEFAULT_MESSAGE="Too many requests";class nc extends mn{constructor(e,t,r){super(null!=e?e:nc.DEFAULT_MESSAGE,null!=t?t:"unauthorized",r)}}nc.DEFAULT_MESSAGE="Unauthorized";const ic=e=>(t,r,n)=>new e(t,r,n),sc={check_access_fail:ic(Za),join_room_fail:ic(Xa),need_joined_to_channel:ic(gn),forbidden:ic(Za),not_found:ic(ec),invalid_request:ic(Xa),invalid_payload:ic(Xa),already_created:ic(Qa),too_many_requests:ic(rc),something_went_wrong:ic(Ss),di_error:ic(Xa),resources_lock_error:ic(Xa),already_connected:ic(Ka),timeout:ic(tc),unauthorized:ic(nc)},oc=e=>{if(!(e=>"object"==typeof e&&null!==e&&!Array.isArray(e))(e))return!1;const{error:t,errorCode:r}=e;return!(void 0!==t&&"string"!=typeof t||void 0!==r&&"string"!=typeof r)},ac=(e,t)=>{var r,n,i,s;const o={};return t&&Object.keys(t).length>0&&(o.response=t),"number"==typeof(null===(r=e.response)||void 0===r?void 0:r.status)&&(o.status=e.response.status),(null===(n=e.response)||void 0===n?void 0:n.statusText)&&(o.statusText=e.response.statusText),e.code&&(o.axiosCode=e.code),(null===(i=e.config)||void 0===i?void 0:i.url)&&(o.url=e.config.url),(null===(s=e.config)||void 0===s?void 0:s.method)&&(o.method=e.config.method),Object.keys(o).length>0?o:void 0};var cc;!function(e){e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain"}(cc||(cc={}));const dc=["/ping","/ice-parameters"];let uc=class extends class extends class{constructor(e={}){var{securityWorker:t,secure:r,format:i}=e,s=n(e,["securityWorker","secure","format"]);this.securityData=null,this.setSecurityData=e=>{this.securityData=e},this.request=e=>a(this,void 0,void 0,(function*(){var{secure:t,path:r,type:i,query:s,format:o,body:a}=e,c=n(e,["secure","path","type","query","format","body"]);const d=("boolean"==typeof t?t:this.secure)&&this.securityWorker&&(yield this.securityWorker(this.securityData))||{},u=this.mergeRequestParams(c,d),l=o||this.format||void 0;return i===cc.FormData&&a&&null!==a&&"object"==typeof a&&(a=this.createFormData(a)),i===cc.Text&&a&&null!==a&&"string"!=typeof a&&(a=JSON.stringify(a)),this.instance.request(Object.assign(Object.assign({},u),{headers:Object.assign(Object.assign({},u.headers||{}),i&&i!==cc.FormData?{"Content-Type":i}:{}),params:s,responseType:l,data:a,url:r}))})),this.instance=Ja.create(Object.assign(Object.assign({},s),{baseURL:s.baseURL||"signaling.livedigital.space/v1"})),this.secure=r,this.format=i,this.securityWorker=t}mergeRequestParams(e,t){const r=e.method||t&&t.method;return Object.assign(Object.assign(Object.assign(Object.assign({},this.instance.defaults),e),t||{}),{headers:Object.assign(Object.assign(Object.assign({},r&&this.instance.defaults.headers[r.toLowerCase()]||{}),e.headers||{}),t&&t.headers||{})})}stringifyFormItem(e){return"object"==typeof e&&null!==e?JSON.stringify(e):`${e}`}createFormData(e){return Object.keys(e||{}).reduce(((t,r)=>{const n=e[r],i=n instanceof Array?n:[n];for(const e of i){const n=e instanceof Blob||e instanceof File;t.append(r,n?e:this.stringifyFormItem(e))}return t}),new FormData)}}{constructor(){super(...arguments),this.peers={getPeers:(e,t={})=>this.request(Object.assign({path:"/peers",method:"GET",query:e,secure:!0,format:"json"},t)),registerPeer:(e,t={})=>this.request(Object.assign({path:"/peers",method:"POST",body:e,secure:!0,type:cc.Json,format:"json"},t)),disconnectPeer:(e={})=>this.request(Object.assign({path:"/peers",method:"DELETE",secure:!0},e)),changePeerProducePermissions:(e,t,r={})=>this.request(Object.assign({path:`/peers/${e}/produce-permissions`,method:"PUT",body:t,secure:!0,type:cc.Json},r)),addPeerProducePermissions:(e,t,r={})=>this.request(Object.assign({path:`/peers/${e}/produce-permissions/${t}`,method:"POST",secure:!0},r)),removePeerProducePermissions:(e,t,r={})=>this.request(Object.assign({path:`/peers/${e}/produce-permissions/${t}`,method:"DELETE",secure:!0},r))},this.router={getRtpCapabilities:(e={})=>this.request(Object.assign({path:"/router/rtp-capabilities",method:"GET",secure:!0,format:"json"},e))},this.channel={confirmChannelActivity:(e={})=>this.request(Object.assign({path:"/channel/activity",method:"PATCH",secure:!0},e)),triggerChannelStateEvent:(e,t={})=>this.request(Object.assign({path:"/channel/peers-state-message-id",method:"GET",query:e,secure:!0,format:"json"},t))},this.ping={pingPeer:(e={})=>this.request(Object.assign({path:"/ping",method:"POST",secure:!0},e))},this.appData={updateSelfPeerAppData:(e,t={})=>this.request(Object.assign({path:"/app-data",method:"PUT",body:e,secure:!0,type:cc.Json},t))},this.producer={getGeneralDataProducer:(e={})=>this.request(Object.assign({path:"/producer/general-data",method:"GET",secure:!0,format:"json"},e)),getAudioObserverProducer:(e={})=>this.request(Object.assign({path:"/producer/audio-observer",method:"GET",secure:!0,format:"json"},e)),getChannelStateSyncDataProducer:(e={})=>this.request(Object.assign({path:"/producer/channel-state-sync-data",method:"GET",secure:!0,format:"json"},e)),closeProducer:(e,t={})=>this.request(Object.assign({path:`/producer/${e}`,method:"DELETE",secure:!0},t)),pauseProducer:(e,t={})=>this.request(Object.assign({path:`/producer/${e}/actions/pause`,method:"POST",secure:!0},t)),resumeProducer:(e,t={})=>this.request(Object.assign({path:`/producer/${e}/actions/resume`,method:"POST",secure:!0},t)),requestProducerMaxSpatialLayer:(e,t,r={})=>this.request(Object.assign({path:`/producer/${e}/max-spatial-layer`,method:"POST",body:t,secure:!0,type:cc.Json},r)),setProducerMaxSpatialLayer:(e,t,r={})=>this.request(Object.assign({path:`/producer/${e}/max-spatial-layer`,method:"PUT",body:t,secure:!0,type:cc.Json},r))},this.consumer={createConsumer:(e,t={})=>this.request(Object.assign({path:"/consumer",method:"POST",body:e,secure:!0,type:cc.Json,format:"json"},t)),closeConsumer:(e,t={})=>this.request(Object.assign({path:`/consumer/${e}`,method:"DELETE",secure:!0},t)),pauseConsumer:(e,t={})=>this.request(Object.assign({path:`/consumer/${e}/actions/pause`,method:"POST",secure:!0},t)),resumeConsumer:(e,t={})=>this.request(Object.assign({path:`/consumer/${e}/actions/resume`,method:"POST",secure:!0},t)),updateConsumerPreferredLayers:(e,t,r={})=>this.request(Object.assign({path:`/consumer/${e}/preferred-layers`,method:"PUT",body:t,secure:!0,type:cc.Json},r)),requestConsumerKeyFrame:(e,t={})=>this.request(Object.assign({path:`/consumer/${e}/key-frame`,method:"POST",secure:!0},t))},this.dataConsumer={createDataConsumer:(e,t={})=>this.request(Object.assign({path:"/data-consumer",method:"POST",body:e,secure:!0,type:cc.Json,format:"json"},t))},this.transport={createTransport:(e,t={})=>this.request(Object.assign({path:"/transport",method:"POST",body:e,secure:!0,type:cc.Json,format:"json"},t)),getTransportIceParameters:(e,t={})=>this.request(Object.assign({path:`/transport/${e}/ice-parameters`,method:"GET",secure:!0,format:"json"},t)),connectTransport:(e,t,r={})=>this.request(Object.assign({path:`/transport/${e}/connect`,method:"PUT",body:t,secure:!0,type:cc.Json},r)),produceMediaToTransport:(e,t,r={})=>this.request(Object.assign({path:`/transport/${e}/media-producer`,method:"PUT",body:t,secure:!0,type:cc.Json,format:"json"},r)),produceDataToTransport:(e,t,r={})=>this.request(Object.assign({path:`/transport/${e}/data-producer`,method:"PUT",body:t,secure:!0,type:cc.Json,format:"json"},r)),closeTransport:(e,t={})=>this.request(Object.assign({path:`/transport/${e}`,method:"DELETE",secure:!0},t))}}}{constructor(e){super({baseURL:String("https://signaling-api.livedigital.space/v1"),securityWorker:e=>{if(!e)return;const t={};return e.token&&(t.Authorization=`Bearer ${e.token}`),e.peerApiVersion&&(t["x-peer-api-version"]=String(e.peerApiVersion)),e.datacenterType&&(t["x-datacenter-type"]=e.datacenterType),{headers:t}}}),this.config=e,this.errorListeners=new Set,this.abortController=new AbortController,this.instance.interceptors.request.use((e=>(!e.signal&&this.abortController&&(e.signal=this.abortController.signal),e))),Ms(this.instance,{retries:5,shouldResetTimeout:!0,retryDelay:e=>Math.min(300*Math.pow(2,e-1),2e3),retryCondition:e=>{var t,r;return"ERR_CANCELED"!==e.code&&(("string"!=typeof(r=null===(t=e.config)||void 0===t?void 0:t.url)||!dc.some((e=>r.includes(e))))&&(Ms.isNetworkError(e)||"ECONNABORTED"===e.code&&!e.response))}}),this.instance.interceptors.response.use((e=>e),(e=>{const t=(e=>{var t,r;if(!Ja.isAxiosError(e))return e instanceof Error?e:new Ss;const n=e;if(!n.response){const e=ac(n),r=n.message||Ss.DEFAULT_MESSAGE,i=null!==(t=n.code)&&void 0!==t?t:"network_error";return new Ss(r,i,e)}const i=oc(n.response.data)?n.response.data:void 0,s="string"==typeof(null==i?void 0:i.errorCode)?i.errorCode:void 0,o="string"==typeof(null==i?void 0:i.error)?i.error:void 0,a=(o&&o.trim().length>0?o:n.message)||Ss.DEFAULT_MESSAGE,c=ac(n,i);if(s){const e=sc[s];return e?e(a,s,c):new Ss(a,s,c)}const d=null!==(r=n.code)&&void 0!==r?r:"number"==typeof n.response.status?`http_${n.response.status}`:"something_went_wrong";return new Ss(a,d,c)})(e);throw this.notifyErrorListeners(t),t})),this.instance.defaults.timeout=3e3;const t=this.config.get("signalingServerUrl");t&&(this.instance.defaults.baseURL=t)}abortPendingRequests(e){this.abortController.abort(e),this.abortController=new AbortController}addErrorListener(e){return this.errorListeners.add(e),()=>{this.errorListeners.delete(e)}}notifyErrorListeners(e){this.errorListeners.forEach((t=>{try{t(e)}catch(e){}}))}};uc=i([at(),s(0,dt(On.Config)),o("design:paramtypes",[bt])],uc);var lc,pc,hc,fc,mc,gc,vc=uc;let yc=class{constructor(e){lc.set(this,void 0),pc.set(this,void 0),hc.set(this,void 0),fc.set(this,[]),mc.set(this,void 0),gc.set(this,new Uint8Array(0)),d(this,mc,e("DatachannelHeartbeater"),"f")}init(e,t){d(this,hc,e,"f"),d(this,pc,t,"f"),this.subscribeToDataProducerEvents(t),this.startHeartbeatInterval()}dispose(){this.stopHeartbeatInterval(),this.cleanupDataProducerEvents(),d(this,pc,void 0,"f"),d(this,hc,void 0,"f")}startHeartbeatInterval(){c(this,lc,"f")||(d(this,lc,setInterval((()=>{this.sendHeartbeat()}),5e3),"f"),c(this,mc,"f").debug("Datachannel heartbeat interval started"))}stopHeartbeatInterval(){c(this,lc,"f")&&(clearInterval(c(this,lc,"f")),d(this,lc,void 0,"f"),c(this,mc,"f").debug("Datachannel heartbeat interval stopped"))}canSendHeartbeat(){return!(!c(this,pc,"f")||!c(this,hc,"f"))&&(!c(this,pc,"f").closed&&"connected"===c(this,hc,"f").connectionState&&"open"===c(this,pc,"f").readyState)}subscribeToDataProducerEvents(e){this.cleanupDataProducerEvents();const t=t=>{c(this,mc,"f").debug(`Heartbeat data producer ${t}`,{readyState:e.readyState,closed:e.closed})},r=()=>t("open"),n=()=>t("close"),i=()=>t("transport closed");e.on("open",r),e.on("close",n),e.on("transportclose",i),d(this,fc,[()=>e.off("open",r),()=>e.off("close",n),()=>e.off("transportclose",i)],"f")}cleanupDataProducerEvents(){c(this,fc,"f").forEach((e=>e())),d(this,fc,[],"f")}sendHeartbeat(){if(c(this,pc,"f")&&this.canSendHeartbeat())try{c(this,pc,"f").send(c(this,gc,"f"))}catch(e){c(this,mc,"f").debug("Failed to send datachannel heartbeat",{error:Ct(e)})}}};lc=new WeakMap,pc=new WeakMap,hc=new WeakMap,fc=new WeakMap,mc=new WeakMap,gc=new WeakMap,yc=i([at(),s(0,dt(On.LoggerFactory)),o("design:paramtypes",[Function])],yc);var _c,bc=yc;class Ec extends mn{constructor(e,t,r){super(null!=e?e:Ec.DEFAULT_MESSAGE,null!=t?t:"invalid_payload",r)}}Ec.DEFAULT_MESSAGE="Invalid payload",function(e){e.DominantSpeaker="dominant-speaker",e.PeersVolumes="peers-volumes",e.Silence="silence"}(_c||(_c={}));let wc=class{constructor(){this.peers=new Map}has(e){return this.peers.has(e)}set(e,t){this.peers.set(e,t)}get(e){return this.peers.get(e)}delete(e){return this.peers.delete(e)}all(){return Array.from(this.peers.values())}hosts(){return this.all().filter((e=>"host"===e.role))}audience(){return this.all().filter((e=>"audience"===e.role))}clear(){this.peers.clear()}};wc=i([at()],wc);var Sc=wc;const Cc=[{scaleResolutionDownBy:4,maxBitrate:15e4,maxFramerate:12},{scaleResolutionDownBy:2,maxBitrate:35e4,maxFramerate:18},{scaleResolutionDownBy:1,maxBitrate:9e5,maxFramerate:24}],Pc=[{maxBitrate:1e6,dtx:!0}],Tc=[{maxBitrate:4e4,dtx:!0}];var Rc;let kc=class{constructor(e,t){this.peersStorage=e,Rc.set(this,void 0),d(this,Rc,t("ChannelAudioObserverMissingProducerRestorer"),"f")}handlePeerVolume(e){const{peerId:t,producerId:r}=e,n=this.peersStorage.get(t);if(!n)return;if(n.producers.has(r))return;const i={id:r,kind:"audio",peerId:t,label:Nn.Microphone,paused:!1,encodings:Tc,maxSpatialLayer:0};n.observer.safeEmit(nn,i),c(this,Rc,"f").warn("Recovered missing audio producer from audio observer volume",{peerId:t,producerId:r})}};Rc=new WeakMap,kc=i([at(),s(0,dt(On.PeersStorage)),s(1,dt(On.LoggerFactory)),o("design:paramtypes",[Sc,Function])],kc);var Dc,Ic,Ac,Oc,Nc,Mc=kc;let Lc=Nc=class{constructor(e,t,r,n){this.peersStorage=e,this.clientEventEmitter=t,this.channelAudioObserverMissingProducerRestorer=r,Dc.set(this,void 0),Ic.set(this,void 0),Ac.set(this,void 0),Oc.set(this,void 0),d(this,Dc,n("ChannelAudioObserverEventHandler"),"f"),this.watchPeersLeave()}handle(e){try{const t=JSON.parse(e);switch(Nc.validateEventPayload(t),t.event){case _c.DominantSpeaker:this.handleDominantSpeaker(t);break;case _c.PeersVolumes:this.handlePeerVolumes(t);break;case _c.Silence:this.handleSilence()}}catch(t){c(this,Dc,"f").warn("Failed to handle audio observer event",{error:Ct(t),eventData:e})}}handleDominantSpeaker(e){const{peerId:t}=e.data,r=this.peersStorage.get(t);d(this,Ac,r,"f"),d(this,Oc,r,"f"),this.setActiveSpeaker(r)}handlePeerVolumes(e){e.volumes.forEach((e=>{var t;this.channelAudioObserverMissingProducerRestorer.handlePeerVolume(e);const{peerId:r,trackLabel:n,value:i}=e,s=this.peersStorage.get(r);if(!s)return;i>0&&!c(this,Ac,"f")&&s.id===(null===(t=c(this,Oc,"f"))||void 0===t?void 0:t.id)&&(d(this,Ac,s,"f"),this.setActiveSpeaker(s));const o=null==s?void 0:s.tracks.get(n);o&&o.setVolume(i)}))}handleSilence(){this.peersStorage.all().flatMap((e=>Array.from(e.tracks.values()))).forEach((e=>e.setVolume(0))),d(this,Ac,void 0,"f"),this.setActiveSpeaker(void 0)}watchPeersLeave(){this.clientEventEmitter.on(yr,(e=>{var t;e===(null===(t=c(this,Ac,"f"))||void 0===t?void 0:t.id)&&this.setActiveSpeaker(void 0)}))}setActiveSpeaker(e){c(this,Ic,"f")!==(null==e?void 0:e.id)&&(d(this,Ic,null==e?void 0:e.id,"f"),this.clientEventEmitter.safeEmit(Rr,{peer:e}))}static validateEventPayload(e){switch(e.event){case _c.Silence:break;case _c.DominantSpeaker:{e.data||Nc.throwInvalidPayload();const{peerId:t,producerId:r,trackLabel:n}=e.data;"string"==typeof t&&"string"==typeof r&&n===Nn.Microphone||Nc.throwInvalidPayload();break}case _c.PeersVolumes:Array.isArray(e.volumes)||Nc.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===Nn.Microphone||Nc.throwInvalidPayload()}));break;default:Nc.throwInvalidPayload()}}static throwInvalidPayload(){throw new Ec("invalid_channel_audio_observer_payload")}};Dc=new WeakMap,Ic=new WeakMap,Ac=new WeakMap,Oc=new WeakMap,Lc=Nc=i([at(),s(0,dt(On.PeersStorage)),s(1,dt(On.ClientEventEmitter)),s(2,dt(On.ChannelAudioObserverMissingProducerRestorer)),s(3,dt(On.LoggerFactory)),o("design:paramtypes",[Sc,Et,Mc,Function])],Lc);var xc,Fc,jc,Uc=Lc;let Vc=class{constructor(e,t,r,n,i){this.state=e,this.myPeer=r,this.signalingApiClient=n,this.channelAudioObserverEventHandler=i,xc.set(this,void 0),Fc.set(this,void 0),jc.set(this,void 0),d(this,xc,t("DataChannels"),"f")}get channelMessagesDataConsumer(){return c(this,jc,"f")}createAudioObserver(e){return a(this,void 0,void 0,(function*(){var t;const r={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(t=this.myPeer)||void 0===t?void 0:t.id};try{const{producerId:t}=yield this.getAudioObserverProducer();d(this,Fc,yield this.createDataConsumer({producerId:t,appId:this.state.appId,channelId:this.state.channelId,transport:e}),"f");const n=this.channelAudioObserverEventHandler.handle.bind(this.channelAudioObserverEventHandler),i=()=>{var e,t;null===(e=c(this,Fc,"f"))||void 0===e||e.removeListener("message",n),null===(t=c(this,Fc,"f"))||void 0===t||t.removeListener("close",i)};c(this,Fc,"f").on("close",i),c(this,Fc,"f").on("message",n),c(this,xc,"f").debug("Successfully create audio observer",r)}catch(e){c(this,xc,"f").error("Failed to create audio observer",Object.assign(Object.assign({},r),{error:Ct(e)}))}}))}createChannelMessagesDataConsumer(e){return a(this,void 0,void 0,(function*(){var t;const r={channelId:this.state.channelId,appId:this.state.appId,peerId:null===(t=this.myPeer)||void 0===t?void 0:t.id};try{const{id:t}=yield this.createDataProducer(e.id,"channel-messages-data-producer");d(this,jc,yield this.createDataConsumer({producerId:t,appId:this.state.appId,channelId:this.state.channelId,ordered:!0,transport:e}),"f"),c(this,xc,"f").debug("Successfully created channel messages data consumer",Object.assign(Object.assign({},r),{producerId:t}))}catch(e){throw c(this,xc,"f").error("Failed to create channel messages data consumer",Object.assign(Object.assign({},r),{error:e})),e}}))}closeAudioObserver(){var e;null===(e=c(this,Fc,"f"))||void 0===e||e.close()}closeChannelMessagesDataConsumer(){var e;null===(e=c(this,jc,"f"))||void 0===e||e.close()}createDataProducer(e,t){return a(this,void 0,void 0,(function*(){const{data:r}=yield this.signalingApiClient.transport.produceDataToTransport(e,{label:t});return r}))}createDataConsumer(e){return a(this,arguments,void 0,(function*({producerId:e,appId:t,channelId:r,ordered:n,transport:i}){if(!i)throw c(this,xc,"f").error("createDataConsumer()",{reason:"missing receive transport"}),new Error("Failed to create data consumer due to missing receive transport");c(this,xc,"f").debug("createDataConsumer()",{producerId:e});const s=(yield this.signalingApiClient.dataConsumer.createDataConsumer({ordered:n,dataProducerId:e,transportId:i.id,appData:{peerId:this.myPeer.id,producerId:e,appId:t,channelId:r}})).data,o=yield i.consumeData(s);return c(this,xc,"f").debug("Data consumer created",{consumerId:o.id}),o}))}getAudioObserverProducer(){return a(this,void 0,void 0,(function*(){const{data:e}=yield this.signalingApiClient.producer.getAudioObserverProducer();return e}))}};xc=new WeakMap,Fc=new WeakMap,jc=new WeakMap,Vc=i([at(),s(0,dt(On.CallState)),s(1,dt(On.LoggerFactory)),s(2,dt(On.MyPeer)),s(3,dt(On.SignalingApiClient)),s(4,dt(On.ChannelAudioObserverEventHandler)),o("design:paramtypes",[Ln,Function,ws,vc,Uc])],Vc);var Bc,Wc,Hc=Vc;let qc=class{constructor(e,t){this.signalingApiClient=t,Bc.set(this,void 0),Wc.set(this,void 0),d(this,Wc,e("SignalingHeartbeater"),"f")}start(){c(this,Bc,"f")||(d(this,Bc,setInterval((()=>a(this,void 0,void 0,(function*(){yield this.sendHeartbeat()}))),15e3),"f"),c(this,Wc,"f").debug("Signaling heartbeat interval started"))}dispose(){c(this,Bc,"f")&&(clearInterval(c(this,Bc,"f")),d(this,Bc,void 0,"f"),c(this,Wc,"f").debug("Signaling heartbeat interval stopped"))}sendHeartbeat(){return a(this,void 0,void 0,(function*(){try{yield this.signalingApiClient.ping.pingPeer()}catch(e){c(this,Wc,"f").debug("Failed to send signaling heartbeat",{error:Ct(e)})}}))}};Bc=new WeakMap,Wc=new WeakMap,qc=i([at(),s(0,dt(On.LoggerFactory)),s(1,dt(On.SignalingApiClient)),o("design:paramtypes",[Function,vc])],qc);var zc,Gc,Yc,$c=qc;let Jc=class{constructor(e,t,r,n,i,s,o,a){this.state=e,this.myPeer=t,this.clientEventEmitter=n,this.dataChannelsManager=i,this.signalingApiClient=s,this.datachannelHeartbeater=o,this.signalingHeartbeater=a,zc.set(this,new Map),Gc.set(this,void 0),Yc.set(this,void 0),this.peersLoaded=!1,d(this,Yc,r("Network"),"f"),d(this,Gc,new Et,"f")}get isNetworkActive(){var e,t,r,n;return["connected","new"].includes(null!==(t=null===(e=this.receiveTransport)||void 0===e?void 0:e.connectionState)&&void 0!==t?t:"")&&["connected","new"].includes(null!==(n=null===(r=this.sendTransport)||void 0===r?void 0:r.connectionState)&&void 0!==n?n:"")}get observer(){return c(this,Gc,"f")}removeEventListeners(){const{sendTransport:e,receiveTransport:t,signalingTransport:r}=this;if(e){["connect","produce","connectionstatechange"].forEach((t=>e.removeAllListeners(t)))}if(t){["connect","produce","connectionstatechange"].forEach((e=>t.removeAllListeners(e)))}if(r){["connect","produce","producedata","connectionstatechange"].forEach((e=>r.removeAllListeners(e)))}}reset(){this.datachannelHeartbeater.dispose(),this.signalingHeartbeater.dispose(),this.heartbeatDataProducer=void 0,this.peersLoaded=!1,this.stopRestartIceAttempts(),this.removeEventListeners(),this.closeAllDataChannels(),this.closeSendTransport(),this.closeReceiveTransport(),this.closeConnectionTransport()}closeRemoteProducer(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.producer.closeProducer(e)}))}closeSendTransport(){this.sendTransport?(this.closeTransport(this.sendTransport),this.sendTransport=void 0):c(this,Yc,"f").debug("closeSendTransport()",{message:"No available send transport"})}closeReceiveTransport(){this.receiveTransport?(this.closeTransport(this.receiveTransport),this.receiveTransport=void 0):c(this,Yc,"f").debug("closeReceiveTransport()",{message:"No available receive transport"})}closeConnectionTransport(){this.signalingTransport?(this.closeTransport(this.signalingTransport),this.signalingTransport=void 0):c(this,Yc,"f").debug("closeConnectionTransport()",{message:"No available connection transport"})}closeTransport(e){try{e.close(),c(this,Yc,"f").debug("closeTransport()",{transportId:e.id,direction:e.direction})}catch(t){c(this,Yc,"f").error("closeTransport()",{error:t,transportId:e.id,direction:e.direction})}}createSendTransport(e){return a(this,void 0,void 0,(function*(){if(this.sendTransport)throw c(this,Yc,"f").warn("createSendTransport()",{message:"Send transport already exists"}),new mn("Send transport already exists","already_exists");const{data:t}=yield this.signalingApiClient.transport.createTransport({localDirection:"send"}),r=e.createSendTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return c(this,Yc,"f").debug("createSendTransport()",{transportId:r.id,direction:r.direction}),this.sendTransport=r,this.subscribeCommonTransportEvents(r),r}))}createRecvTransport(e){return a(this,void 0,void 0,(function*(){if(this.receiveTransport)throw c(this,Yc,"f").warn("createReceiveTransport()",{message:"Receive transport already exists"}),new mn("Receive transport already exists","already_exists");const{data:t}=yield this.signalingApiClient.transport.createTransport({localDirection:"receive"}),r=e.createRecvTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return c(this,Yc,"f").debug("createReceiveTransport()",{transportId:r.id,direction:r.direction}),this.receiveTransport=r,this.subscribeCommonTransportEvents(r),r}))}createSignalingTransport(e){return a(this,void 0,void 0,(function*(){if(this.signalingTransport)throw c(this,Yc,"f").warn("createConnectionTransport()",{message:"Connection transport already exists"}),new mn("Connection transport already exists","already_exists");const{data:t}=yield this.signalingApiClient.transport.createTransport({localDirection:"receive",tcpOnly:!0}),r=e.createSendTransport(Object.assign(Object.assign({},t),{iceTransportPolicy:this.preferRelay?"relay":t.iceTransportPolicy}));return c(this,Yc,"f").debug("createConnectionTransport()",{transportId:r.id,direction:r.direction,tcpOnly:!0}),this.signalingTransport=r,this.subscribeCommonTransportEvents(r),r}))}getIceParameters(e){return a(this,void 0,void 0,(function*(){const{data:{iceParameters:t}}=yield this.signalingApiClient.transport.getTransportIceParameters(e.id);return t}))}restartIce(e){return a(this,void 0,void 0,(function*(){try{const t=yield this.getIceParameters(e);yield e.restartIce({iceParameters:t}),c(this,Yc,"f").info("restartIce completed",{iceParameters:t})}catch(e){c(this,Yc,"f").error("restartIce error",{error:e})}}))}createConsumer(e){return a(this,arguments,void 0,(function*({producerId:e,rtpCapabilities:t,appId:r,channelId:n,producerPeerId:i}){var s;const o=this.receiveTransport;if(!o)throw c(this,Yc,"f").error("createConsumer()",{reason:"missing receive transport"}),new Error("Failed to create consumer due to missing receive transport");let a;c(this,Yc,"f").debug("createConsumer()",{producerId:e});try{const{data:r}=yield this.signalingApiClient.consumer.createConsumer({producerId:e,transportId:o.id,rtpCapabilities:t,producerPeerId:i});a=this.toRemoteConsumerOptions(r)}catch(t){if(!(t instanceof Ss&&(null===(s=t.meta)||void 0===s?void 0:s.existedConsumer)))throw c(this,Yc,"f").error("Failed to get consumer options",{producerId:e,appId:r,channelId:n,producerPeerId:i,error:Ct(t)}),new Error("Failed to create consumer due to error while fetching consumer options");a=t.meta.existedConsumer}if(!a)throw new Error("Failed to create consumer due to missing consumer options");const d=yield o.consume(a),{producerPaused:u}=a;return u&&"audio"!==d.kind&&d.pause(),c(this,Yc,"f").debug("Consumer created",{consumerId:d.id,label:d.appData.label,isProducerPaused:u}),{consumer:d,isProducerPaused:u}}))}initializeHeartbeats(){return a(this,void 0,void 0,(function*(){this.signalingHeartbeater.start();const e=this.sendTransport;if(!e)throw c(this,Yc,"f").error("createHeartbeatProducer()",{reason:"missing send transport"}),new Error("Failed to create data producer");const t=yield e.produceData({label:"heart-beater",protocol:"heartbeat"});this.heartbeatDataProducer=t,t.once("transportclose",(()=>{var e;null===(e=this.heartbeatDataProducer)||void 0===e||e.close(),this.heartbeatDataProducer=void 0,this.datachannelHeartbeater.dispose()})),this.datachannelHeartbeater.init(e,t)}))}createKeepAliveConsumer(){return a(this,void 0,void 0,(function*(){const e=this.signalingTransport;if(!e)return void c(this,Yc,"f").error("createKeepAliveConsumer()",{reason:"missing signaling transport"});const t=yield e.produceData({label:"consumers-scores",protocol:"keepalive"});t.once("open",(()=>{t.send(new Uint8Array(0))})),t.once("transportclose",(()=>{t.close()}))}))}get channelMessagesDataConsumer(){return this.dataChannelsManager.channelMessagesDataConsumer}closeRemoteConsumer(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.consumer.closeConsumer(e)}))}resumeRemoteConsumer(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.consumer.resumeConsumer(e)}))}pauseRemoteProducer(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.producer.pauseProducer(e)}))}resumeRemoteProducer(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.producer.resumeProducer(e)}))}pauseRemoteConsumer(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.consumer.pauseConsumer(e)}))}updatePeerAppData(e){return a(this,arguments,void 0,(function*({appData:e}){yield this.signalingApiClient.appData.updateSelfPeerAppData({appData:e})}))}setProducerMaxSpatialLayer(e,t){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.producer.setProducerMaxSpatialLayer(e,{maxSpatialLayer:t})}))}requestProducerMaxSpatialLayer(e,t){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.producer.requestProducerMaxSpatialLayer(e,{spatialLayer:t})}))}changePeerProducePermissions(e,t){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.peers.changePeerProducePermissions(e,{producePermissions:null==t?void 0:t.map((e=>e))})}))}addPeerProducePermission(e,t){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.peers.addPeerProducePermissions(e,t)}))}removePeerProducePermission(e,t){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.peers.removePeerProducePermissions(e,t)}))}updateConsumerPreferredLayers(e,t,r){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.consumer.updateConsumerPreferredLayers(e,{spatialLayer:t,temporalLayer:r})}))}requestConsumerKeyFrame(e){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.consumer.requestConsumerKeyFrame(e)}))}ping(){return a(this,void 0,void 0,(function*(){yield this.signalingApiClient.ping.pingPeer()}))}getTransportsStateInfo(){return a(this,void 0,void 0,(function*(){const[e,t]=yield Promise.all([this.getParsedTransportStats(this.receiveTransport),this.getParsedTransportStats(this.sendTransport)]);return{receive:e,send:t}}))}setPreferRelay(e){this.preferRelay=e}getPreferRelay(){var e;return null!==(e=this.preferRelay)&&void 0!==e&&e}getChannelPeers(e){return a(this,void 0,void 0,(function*(){var t;const{data:r}=yield this.signalingApiClient.peers.getPeers({role:e});this.peersLoaded=!0;return{peers:(null!==(t=r.items)&&void 0!==t?t:[]).map((e=>this.mapPeerResponse(e)))}}))}createAllDataChannels(){return a(this,void 0,void 0,(function*(){if(!this.receiveTransport)throw new Error("Receive transport is not created");yield Promise.all([this.dataChannelsManager.createAudioObserver(this.receiveTransport),this.dataChannelsManager.createChannelMessagesDataConsumer(this.receiveTransport)])}))}closeAllDataChannels(){this.dataChannelsManager.closeAudioObserver(),this.dataChannelsManager.closeChannelMessagesDataConsumer()}waitForReceiveTransportConnected(e){return a(this,arguments,void 0,(function*({onReceiveTransportFailed:e}){if(!this.receiveTransport)throw new Error("receiveTransport is not initialized");if("connected"===(yield this.waitForTransportTerminalState(this.receiveTransport)))return;yield e();const t=yield this.waitForTransportTerminalState(this.receiveTransport);if("connected"!==t)throw new Error(`receiveTransport connection failed after relay escalation: ${t}`)}))}triggerChannelStateEvent(e){return a(this,void 0,void 0,(function*(){const{data:t}=yield this.signalingApiClient.channel.triggerChannelStateEvent({role:e});if("number"!=typeof t.messageId)throw new Error("Invalid channel state event response");return t.messageId}))}waitForChannelMessagesDataConsumerConnected(){return a(this,void 0,void 0,(function*(){if(!this.dataChannelsManager.channelMessagesDataConsumer)throw new Error("channelMessagesDataConsumer is not initialized");yield this.waitForDataConsumerConnected(this.dataChannelsManager.channelMessagesDataConsumer)}))}waitForTransportTerminalState(e){return a(this,arguments,void 0,(function*(e,t=6e4){return"connected"===e.connectionState?e.connectionState:yield new Promise(((r,n)=>{const i=setTimeout((()=>{s(),r(e.connectionState)}),t),s=()=>{clearTimeout(i),e.off("connectionstatechange",o)},o=()=>{["connected","failed"].includes(e.connectionState)?(s(),r(e.connectionState)):"closed"===e.connectionState&&(s(),n(new Error(`receiveTransport connection failed: ${e.connectionState}`)))};e.on("connectionstatechange",o)}))}))}waitForDataConsumerConnected(e){return a(this,arguments,void 0,(function*(e,t=6e4){if(!e)throw new Error("Data consumer is not initialized");"open"!==e.readyState&&(yield new Promise(((r,n)=>{const i=setTimeout((()=>{s(),n(new Error("Timed out waiting for data consumer to connect"))}),t),s=()=>{clearTimeout(i),e.off("open",o),e.off("close",a)},o=()=>{s(),r()},a=()=>{s(),n(new Error(`Data consumer closed unexpectedly: ${e.readyState}`))};e.on("open",o),e.on("close",a)})))}))}getParsedTransportStats(e){return a(this,void 0,void 0,(function*(){if(e)try{const t=Array.from((yield e.getStats()).values()),r=t.find((e=>"local-candidate"===e.type)),n=t.find((e=>"remote-candidate"===e.type)),i=t.find((e=>"transport"===e.type));return{dtlsState:null==i?void 0:i.dtlsState,iceState:null==i?void 0:i.iceState,dtlsRole:null==i?void 0:i.dtlsRole,iceRole:null==i?void 0:i.iceRole,selectedCandidatePairChanges:null==i?void 0:i.selectedCandidatePairChanges,tlsVersion:null==i?void 0:i.tlsVersion,localCandidateState:{ip:null==r?void 0:r.ip,address:null==r?void 0:r.address,port:null==r?void 0:r.port,protocol:null==r?void 0:r.protocol,candidateType:null==r?void 0:r.candidateType},remoteCandidateState:{ip:null==n?void 0:n.ip,address:null==n?void 0:n.address,port:null==n?void 0:n.port,protocol:null==n?void 0:n.protocol,candidateType:null==n?void 0:n.candidateType}}}catch(e){return void c(this,Yc,"f").warn("getParsedTransportStats()",{error:e})}else c(this,Yc,"f").debug("getParsedTransportStats()",{message:"Transport is missing"})}))}logTransportDetails(e){return a(this,void 0,void 0,(function*(){var t,r,n,i;let s;try{s=yield e.getStats()}catch(t){return void c(this,Yc,"f").error("Failed to log detailed WebRTC transport stats",{error:Ct(t),transportId:e.id,reason:"failed to parse getStats"})}try{const o=[...s],[,a]=null!==(t=o.find((([,e])=>"transport"===(null==e?void 0:e.type))))&&void 0!==t?t:[],[,d]=null!==(r=o.find((([,e])=>"candidate-pair"===e.type&&"succeeded"===e.state&&e.nominated)))&&void 0!==r?r:[],u=s.get(String(null!==(n=null==d?void 0:d.localCandidateId)&&void 0!==n?n:"-")),l=s.get(String(null!==(i=null==d?void 0:d.remoteCandidateId)&&void 0!==i?i:"-")),p={hasNominatedPair:!!d,transportId:e.id,iceRole:null==a?void 0:a.iceRole,iceState:null==a?void 0:a.iceState,dtlsRole:null==a?void 0:a.dtlsRole,dtlsState:null==a?void 0:a.dtlsState,local:{address:null==u?void 0:u.address,candidateType:null==u?void 0:u.candidateType,foundation:null==u?void 0:u.foundation,networkType:null==u?void 0:u.networkType,isRemote:null==u?void 0:u.isRemote,port:null==u?void 0:u.port,protocol:null==u?void 0:u.protocol,relatedAddress:null==u?void 0:u.relatedAddress,relatedPort:null==u?void 0:u.relatedPort,transportId:null==u?void 0:u.transportId,relayProtocol:null==u?void 0:u.relayProtocol,url:null==u?void 0:u.url},remote:{address:null==l?void 0:l.address,candidateType:null==l?void 0:l.candidateType,foundation:null==l?void 0:l.foundation,isRemote:null==l?void 0:l.isRemote,port:null==l?void 0:l.port,protocol:null==l?void 0:l.protocol,transportId:null==l?void 0:l.transportId}};(null==d?void 0:d.totalRoundTripTime)&&(null==d?void 0:d.responsesReceived)&&(p.pairRoundTripTime=Math.round(d.totalRoundTripTime/d.responsesReceived*1e3)),c(this,Yc,"f").info("Detailed WebRTC transport stats",p)}catch(t){c(this,Yc,"f").error("Failed to log detailed WebRTC transport stats",{error:Ct(t),transportId:e.id,reason:"-"})}}))}stopRestartIceAttempts(){Array.from(c(this,zc,"f").values()).forEach((e=>clearInterval(e)))}toRemoteConsumerOptions(e){const{producerPaused:t}=e,r=n(e,["producerPaused"]);return Object.assign(Object.assign({},r),{producerPaused:t})}mapPeerResponse(e){var t,r,n,i,s,o,a,c;return{id:e.id,channelIds:null!==(t=e.channelIds)&&void 0!==t?t:[],groups:null!==(r=e.groups)&&void 0!==r?r:[],producePermissions:null!==(n=e.producePermissions)&&void 0!==n?n:[],appId:null!==(s=null!==(i=e.appId)&&void 0!==i?i:this.state.appId)&&void 0!==s?s:"",producers:(null!==(o=e.producers)&&void 0!==o?o:[]).map((e=>this.mapProducer(e))),uid:e.uid,appData:null!==(a=e.appData)&&void 0!==a?a:{},role:null!==(c=e.role)&&void 0!==c?c:"audience",loginDate:e.loginDate?new Date(e.loginDate):new Date}}mapProducer(e){var t;return{id:e.id,kind:e.kind,peerId:e.peerId,label:e.label,paused:null!==(t=e.paused)&&void 0!==t&&t,encodings:[],maxSpatialLayer:0}}subscribeCommonTransportEvents(e){e.on("connect",((t,r,n)=>a(this,[t,r,n],void 0,(function*({dtlsParameters:t},r,n){try{yield this.signalingApiClient.transport.connectTransport(e.id,{dtlsParameters:t}),r(),c(this,Yc,"f").debug(`${e.direction}Transport.connect()`,{transportId:e.id,dtlsRole:t.role}),setTimeout((()=>a(this,void 0,void 0,(function*(){return yield this.logTransportDetails(e)}))),2e3),setTimeout((()=>a(this,void 0,void 0,(function*(){return yield this.checkTransportState(e)}))),15e3)}catch(t){c(this,Yc,"f").error(`${e.direction}Transport.on('connect')`,{error:t}),n(t)}})))),e.on("produce",((t,r,n)=>a(this,void 0,void 0,(function*(){try{const{data:n}=yield this.signalingApiClient.transport.produceMediaToTransport(e.id,{kind:t.kind,rtpParameters:t.rtpParameters,appData:t.appData}),i=n.id;r({id:i}),c(this,Yc,"f").debug(`${e.direction}Transport.produce()`,{producerId:i,transportId:e.id,kind:t.kind})}catch(r){c(this,Yc,"f").error(`${e.direction}Transport.produce()`,{error:Ct(r),transportId:e.id,kind:t.kind}),n(r)}})))),e.on("producedata",((t,r,n)=>a(this,void 0,void 0,(function*(){try{const{data:n}=yield this.signalingApiClient.transport.produceDataToTransport(e.id,{label:t.label,sctpStreamParameters:t.sctpStreamParameters,appData:t.appData});r({id:n.id}),c(this,Yc,"f").debug(`${e.direction}Transport.produceData()`,{producerId:n.id,transportId:e.id,sctpStreamParameters:t.sctpStreamParameters,label:t.label})}catch(r){c(this,Yc,"f").error(`${e.direction}Transport.produceData()`,{error:Ct(r),transportId:e.id,sctpStreamParameters:t.sctpStreamParameters,label:t.label}),n(r)}})))),e.on("connectionstatechange",(t=>{if(c(this,Yc,"f").info(`${e.direction}Transport.state`,{state:t}),["closed","connected"].includes(t))return c(this,Gc,"f").safeEmit(hn,{state:t,direction:e.direction}),c(this,zc,"f").has(e.id)&&(c(this,Yc,"f").debug("Stop receiveTransport.restartIce() retries",{recvTransportId:e.id}),clearInterval(c(this,zc,"f").get(e.id)),c(this,zc,"f").delete(e.id),"connected"===t&&c(this,Gc,"f").safeEmit(hn,{state:"reconnected",direction:e.direction})),void("connected"===t&&setTimeout((()=>{this.logTransportDetails(e).catch((e=>{c(this,Yc,"f").debug("Failed to log transport details",{error:Ct(e)})}))}),1500));if(c(this,Gc,"f").safeEmit(hn,{state:t,direction:e.direction}),["disconnected","failed"].includes(t)){if(c(this,zc,"f").has(e.id))return;"failed"===t&&(c(this,Yc,"f").debug(`${e.id} transport.restartIce()`,{transportId:e.id,direction:e.direction}),this.restartIce(e).catch((t=>{c(this,Yc,"f").debug("Failed to execute restartIce",{error:Ct(t),transportId:e.id,direction:e.direction})}))),c(this,zc,"f").set(e.id,setInterval((()=>{this.restartIce(e).catch((t=>{c(this,Yc,"f").debug("Failed to execute restartIce",{error:Ct(t),transportId:e.id,direction:e.direction})})),c(this,Yc,"f").debug(`${e.id} transport.restartIce() attempt`,{recvTransportId:e.id,transportId:e.id,direction:e.direction})}),1500))}})),e.on("icegatheringstatechange",(t=>{c(this,Yc,"f").info("icegatheringstatechange",{state:t,transportId:e.id,transportDirection:e.direction})}))}checkTransportState(e){return a(this,void 0,void 0,(function*(){try{const t=yield this.getParsedTransportStats(e);if(!t)return;const r="send"===e.direction?"send":"receive";if("connected"!==t.iceState)return this.clientEventEmitter.emit(Cr,{direction:r,reason:"ice"}),void c(this,Yc,"f").warn(pn,{reason:"ice",transportId:e.id,direction:r});"connected"!==t.dtlsState&&(this.clientEventEmitter.emit(Cr,{direction:r,reason:"dtls"}),c(this,Yc,"f").warn(pn,{reason:"dtls",transportId:e.id,direction:r}))}catch(t){c(this,Yc,"f").error("checkTransportState()",{error:Ct(t),transportId:e.id,direction:e.direction})}}))}};zc=new WeakMap,Gc=new WeakMap,Yc=new WeakMap,Jc=i([at(),s(0,dt(On.CallState)),s(1,dt(On.MyPeer)),s(2,dt(On.LoggerFactory)),s(3,dt(On.ClientEventEmitter)),s(4,dt(On.DataChannelsManager)),s(5,dt(On.SignalingApiClient)),s(6,dt(On.DatachannelHeartbeater)),s(7,dt(On.SignalingHeartbeater)),o("design:paramtypes",[Ln,ws,Function,Et,Hc,vc,bc,$c])],Jc);var Kc=Jc;let Qc=class{constructor(e,t,r,n,i){this.myPeer=e,this.network=t,this.peerFactory=r,this.clientEventEmitter=n,this.peersStorage=i}has(e){return this.peersStorage.has(e)}set(e,t){e===this.myPeer.id&&this.myPeer.set(t),this.peersStorage.set(e,t)}get(e){return this.peersStorage.get(e)}delete(e){return e===this.myPeer.id&&this.myPeer.delete(),this.peersStorage.delete(e)}remove(e){return a(this,void 0,void 0,(function*(){const t=this.get(e);t&&(yield t.reset(),this.delete(e),this.clientEventEmitter.safeEmit(yr,e))}))}all(){return this.peersStorage.all()}hosts(){return this.peersStorage.hosts()}audience(){return this.peersStorage.audience()}reset(){return a(this,void 0,void 0,(function*(){yield Promise.all(this.peersStorage.all().map((e=>a(this,void 0,void 0,(function*(){return yield e.reset()}))))),this.peersStorage.clear()}))}load(e){return a(this,void 0,void 0,(function*(){const{peers:t}=yield this.network.getChannelPeers(e);t.filter((e=>!this.has(e.id))).forEach((e=>this.add(e,!1)))}))}add(e,t=!0){const r=this.get(e.id);if(r)return r;const n=this.peerFactory(e);return this.set(n.id,n),t&&this.clientEventEmitter.safeEmit(vr,n),n}isModerator(e){if(void 0===e)return!1;const t=this.get(e);return!!t&&t.isModerator}};function Zc(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 Xc(e,t,r,n){var i=Zc(Zc(Zc(e,r),function(e){return Object.prototype.toString.call(e)}(t)),typeof t);if(null===t)return Zc(i,"null");if(void 0===t)return Zc(i,"undefined");if("object"==typeof t||"function"==typeof t){if(-1!==n.indexOf(t))return Zc(i,"[Circular]"+r);n.push(t);var s=function(e,t,r){return Object.keys(t).sort().reduce((function(e,n){return Xc(e,t[n],n,r)}),e)}(i,t,n);if(!("valueOf"in t)||"function"!=typeof t.valueOf)return s;try{return Zc(s,String(t.valueOf()))}catch(e){return Zc(s,"[valueOf exception]"+(e.stack||e.message))}}return Zc(i,t.toString())}Qc=i([at(),s(0,dt(On.MyPeer)),s(1,dt(On.Network)),s(2,dt(On.PeerFactory)),s(3,dt(On.ClientEventEmitter)),s(4,dt(On.PeersStorage)),o("design:paramtypes",[ws,Kc,Function,Et,Sc])],Qc);var ed=function(e){return function(e,t){for(;e.length<t;)e="0"+e;return e}(Xc(0,e,"",[]).toString(16),8)};class td{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 rd{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.findLocalProducerById(t,e.id);if(!r)return void this.missingProducers.push(e.id);if(this.isLocalProducerStateChangedRecently(r))return;if(r.paused!==e.paused)return void this.producersWithInconsistentState.push(e.id);const n=this.findLocalConsumerByProducerId(t,e.id);n&&n.paused!==e.paused&&this.consumersWithInconsistentState.push(n.id),r||this.missingProducers.push(e.id)}))})),new td({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=[]}isLocalProducerStateChangedRecently(e){return Date.now()-e.stateChangedAt<5e3}}var nd,id,sd,od,ad,cd,dd;!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"}(nd||(nd={}));let ud=class{constructor(e,t,r,n,i,s,o){var a;this.network=t,this.callState=r,this.peersStorage=n,this.clientEventEmitter=i,this.signalingApiClient=s,this.webRtcIssueDetector=o,id.set(this,void 0),sd.set(this,void 0),od.set(this,[]),ad.set(this,!1),cd.set(this,{inbound:4.3,outbound:4.3}),dd.set(this,(new Date).getTime()-15e3),d(this,sd,null===(a=this.webRtcIssueDetector)||void 0===a?void 0:a.eventEmitter,"f"),d(this,id,e("ChannelStateSyncEventHandler"),"f"),this.debouncedHandleChannelStateEvent=Sn(this.handleChannelStateEvent.bind(this),3e3),this.listenNetworkScoresUpdatedEvents()}handleChannelStateShort(e){return a(this,void 0,void 0,(function*(){try{yield this.debouncedHandleChannelStateEvent(e)}catch(e){c(this,id,"f").error("handleChannelStateSyncEvent()",{error:Ct(e)})}}))}handleChannelStateEvent(e){return a(this,void 0,void 0,(function*(){if(c(this,ad,"f"))c(this,id,"f").warn("Channel state event is already being handled, skipping new event",{case:"handleChannelStateEvent"});else{d(this,ad,!0,"f");try{yield this.collectProbableInconsistencyCases(e);const t=this.getConfirmedInconsistencyResult();if(!(null==t?void 0:t.hasInconsistencyCases()))return;if(this.isRestoreStateRequestToEarly())return void c(this,id,"f").info("Inconsistency detected, but restore skipped",Object.assign({},t));this.handleConfirmedInconsistencyResult(t)}finally{d(this,ad,!1,"f")}}}))}getLastInconsistencyCheckResult(){return c(this,od,"f")[c(this,od,"f").length-1]}handleConfirmedInconsistencyResult(e){e.missingPeers.forEach((e=>{this.clientEventEmitter.safeEmit(kr,{peerId:e,peersLoaded:this.network.peersLoaded,sdkInstances:Array.from(window._sdkMarks||[]).length,type:nd.MissingPeer})})),e.missingProducers.forEach((e=>{this.clientEventEmitter.safeEmit(kr,{producerId:e,type:nd.MissingProducer})})),e.producersWithInconsistentState.forEach((e=>{this.clientEventEmitter.safeEmit(kr,{producerId:e,type:nd.IncorrectProducerState})})),e.peersWithInconsistentAppData.forEach((e=>{this.clientEventEmitter.safeEmit(kr,{peerId:e,type:nd.IncorrectAppData})}))}getConfirmedInconsistencyResult(){const e=this.getLastInconsistencyCheckResult();if(!e)return;return new td({missingPeers:this.getConfirmedMissingPeers(e.missingPeers),missingProducers:this.getConfirmedMissingProducers(e.missingProducers),consumersWithInconsistentState:this.getConfirmedConsumersWithInconsistencState(e.consumersWithInconsistentState),producersWithInconsistentState:this.getConfirmedProducersWithInconsistencState(e.producersWithInconsistentState),peersWithInconsistentAppData:this.getConfirmedPeersWithInconsistentAppData(e.missingPeers)})}collectProbableInconsistencyCases(e){return a(this,void 0,void 0,(function*(){const t=new rd({remoteState:e,localState:this.getLocalState()}).check();if(this.rotateLastProbableInconsistencyCheckResults(t),!t.hasInconsistencyCases())return;if(this.isBadNetworkScore())return void this.resetLastProbableInconsistencyCheckResults();(yield this.getIsConnectionActive())&&this.callState.isJoined&&this.network.isNetworkActive||this.resetLastProbableInconsistencyCheckResults()}))}resetLastProbableInconsistencyCheckResults(){d(this,od,[],"f")}rotateLastProbableInconsistencyCheckResults(e){4===c(this,od,"f").length&&c(this,od,"f").shift(),c(this,od,"f").push(e)}isReachedMaxCheckRetries(e,t,r=4){let n=0;return c(this,od,"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)))}getLocalState(){return{peers:this.peersStorage.hosts().map((e=>({id:e.id,appDataHash:ed(e.appData),producers:e.getProducers().map((e=>({id:e.id,paused:e.paused,stateChangedAt:e.getStateChangedAt()}))),consumers:e.getConsumersState()})))}}getIsConnectionActive(){return a(this,void 0,void 0,(function*(){try{return!!this.network.isNetworkActive&&(yield this.signalingApiClient.ping.pingPeer(),!0)}catch(e){return!1}}))}listenNetworkScoresUpdatedEvents(){c(this,sd,"f")&&c(this,sd,"f").on(Tt.NetworkScoresUpdated,(e=>{e.inbound&&(c(this,cd,"f").inbound=e.inbound),e.outbound&&(c(this,cd,"f").outbound=e.outbound)}))}isBadNetworkScore(){const{inbound:e,outbound:t}=c(this,cd,"f");return e<=2.6||t<=2.6}compareCheckedAndRestoredResults(e,t){return new td({missingPeers:e.missingPeers.filter((e=>!t.missingPeers.includes(e))),missingProducers:e.missingProducers.filter((e=>!t.missingProducers.includes(e))),consumersWithInconsistentState:e.consumersWithInconsistentState.filter((e=>!t.fixedConsumersState.includes(e))),producersWithInconsistentState:e.producersWithInconsistentState.filter((e=>!t.fixedProducersState.includes(e))),peersWithInconsistentAppData:e.peersWithInconsistentAppData.filter((e=>!t.restoredAppDataPeers.includes(e)))})}isRestoreStateRequestToEarly(){return(new Date).getTime()-c(this,dd,"f")<=15e3}};id=new WeakMap,sd=new WeakMap,od=new WeakMap,ad=new WeakMap,cd=new WeakMap,dd=new WeakMap,ud=i([at(),s(0,dt(On.LoggerFactory)),s(1,dt(On.Network)),s(2,dt(On.CallState)),s(3,dt(On.PeersStorage)),s(4,dt(On.ClientEventEmitter)),s(5,dt(On.SignalingApiClient)),s(6,dt(On.WebRTCIssueDetector)),o("design:paramtypes",[Function,Kc,Ln,Sc,Et,vc,dr])],ud);var ld=ud,pd={},hd={exports:{}},fd=1e3,md=6e4,gd=60*md,vd=24*gd,yd=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*vd;case"hours":case"hour":case"hrs":case"hr":case"h":return r*gd;case"minutes":case"minute":case"mins":case"min":case"m":return r*md;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>=vd)return _d(e,t,vd,"day");if(t>=gd)return _d(e,t,gd,"hour");if(t>=md)return _d(e,t,md,"minute");if(t>=1e3)return _d(e,t,1e3,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=vd)return Math.round(e/vd)+"d";if(t>=gd)return Math.round(e/gd)+"h";if(t>=md)return Math.round(e/md)+"m";if(t>=fd)return Math.round(e/fd)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function _d(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var bd=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,t){let r=0,n=0,i=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(i=n,s=r,n++):(r++,n++);else{if(-1===i)return!1;n=i+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}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,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=yd,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")||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=bd(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(hd,hd.exports);var Ed={};Object.defineProperty(Ed,"__esModule",{value:!0});var wd={},Sd=Object.defineProperty,Cd=Object.getOwnPropertyDescriptor,Pd=Object.getOwnPropertyNames,Td=Object.prototype.hasOwnProperty,Rd={};((e,t)=>{for(var r in t)Sd(e,r,{get:t[r],enumerable:!0})})(Rd,{BrowserDetector:()=>Nd,KnownBrowsers:()=>Dd,KnownPlatforms:()=>Id,default:()=>Md});var kd=(e=>((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of Pd(t))!Td.call(e,i)&&i!==r&&Sd(e,i,{get:()=>t[i],enumerable:!(n=Cd(t,i))||n.enumerable});return e})(Sd({},"__esModule",{value:!0}),e))(Rd),Dd={chrome:"Google Chrome",brave:"Brave",crios:"Google Chrome",edge:"Microsoft Edge",edg:"Microsoft Edge",edgios:"Microsoft Edge",fennec:"Mozilla Firefox",jsdom:"JsDOM",mozilla:"Mozilla Firefox",fxios:"Mozilla Firefox",msie:"Microsoft Internet Explorer",opera:"Opera",opios:"Opera",opr:"Opera",opt:"Opera",rv:"Microsoft Internet Explorer",safari:"Safari",samsungbrowser:"Samsung Browser",electron:"Electron"},Id={android:"Android",androidTablet:"Android Tablet",cros:"Chrome OS",fennec:"Android Tablet",ipad:"IPad",ipod:"IPod",iphone:"IPhone",jsdom:"JsDOM",linux:"Linux",mac:"Macintosh",tablet:"Android Tablet",win:"Windows","windows phone":"Windows Phone",xbox:"Microsoft Xbox"},Ad=(e,t=-1)=>{let r=new RegExp(`^-?\\d+(?:.\\d{0,${t}})?`),n=Number(e).toString().match(r);return n?n[0]:null},Od=()=>typeof window<"u"?window.navigator:null,Nd=class{userAgent;constructor(e){this.userAgent=e||Od()?.userAgent||null}static get VERSION(){return"4.1.0"}parseUserAgent(e){let t={},r=e||this.userAgent||"",n=r.toLowerCase().replace(/\s\s+/g," "),i=/(edge)\/([\w.]+)/.exec(n)||/(edg)[/]([\w.]+)/.exec(n)||/(opr)[/]([\w.]+)/.exec(n)||/(opt)[/]([\w.]+)/.exec(n)||/(fxios)[/]([\w.]+)/.exec(n)||/(edgios)[/]([\w.]+)/.exec(n)||/(jsdom)[/]([\w.]+)/.exec(n)||/(samsungbrowser)[/]([\w.]+)/.exec(n)||/(electron)[/]([\w.]+)/.exec(n)||/(chrome)[/]([\w.]+)/.exec(n)||/(crios)[/]([\w.]+)/.exec(n)||/(opios)[/]([\w.]+)/.exec(n)||/(version)(applewebkit)[/]([\w.]+).*(safari)[/]([\w.]+)/.exec(n)||/(webkit)[/]([\w.]+).*(version)[/]([\w.]+).*(safari)[/]([\w.]+)/.exec(n)||/(applewebkit)[/]([\w.]+).*(safari)[/]([\w.]+)/.exec(n)||/(webkit)[/]([\w.]+)/.exec(n)||/(opera)(?:.*version|)[/]([\w.]+)/.exec(n)||/(msie) ([\w.]+)/.exec(n)||/(fennec)[/]([\w.]+)/.exec(n)||n.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(n)||n.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(n)||[],s=/(ipad)/.exec(n)||/(ipod)/.exec(n)||/(iphone)/.exec(n)||/(jsdom)/.exec(n)||/(windows phone)/.exec(n)||/(xbox)/.exec(n)||/(win)/.exec(n)||/(tablet)/.exec(n)||/(android)/.test(n)&&!1===/(mobile)/.test(n)&&["androidTablet"]||/(android)/.exec(n)||/(mac)/.exec(n)||/(linux)/.exec(n)||/(cros)/.exec(n)||[],o=i[5]||i[3]||i[1]||null,a=s[0]||null,c=i[4]||i[2]||null,d=Od();"chrome"===o&&"function"==typeof d?.brave?.isBrave&&(o="brave"),o&&(t[o]=!0),a&&(t[a]=!0);let u=!!(t.tablet||t.android||t.androidTablet),l=!!(t.ipad||t.tablet||t.androidTablet),p=!!(t.android||t.androidTablet||t.tablet||t.ipad||t.ipod||t.iphone||t["windows phone"]),h=!!(t.cros||t.mac||t.linux||t.win),f=!!(t.brave||t.chrome||t.crios||t.opr||t.safari||t.edg||t.electron),m=!(!t.msie&&!t.rv),g=!(!t.chrome&&!t.crios),v=!!(t.fxios||t.fennec||t.mozilla),y=!!t.safari,_=!!(t.opera||t.opios||t.opr||t.opt),b=!!(t.edg||t.edge||t.edgios);return{name:Dd[o]??null,platform:Id[a]??null,userAgent:r,version:c,shortVersion:c?Ad(parseFloat(c),2):null,isAndroid:u,isTablet:l,isMobile:p,isDesktop:h,isWebkit:f,isIE:m,isChrome:g,isFireFox:v,isSafari:y,isOpera:_,isEdge:b}}getBrowserInfo(){let e=this.parseUserAgent();return{name:e.name,platform:e.platform,userAgent:e.userAgent,version:e.version,shortVersion:e.shortVersion}}},Md=Nd,Ld={};Object.defineProperty(Ld,"__esModule",{value:!0}),Ld.Logger=void 0;const xd=hd.exports,Fd="mediasoup-client";Ld.Logger=class{_debug;_warn;_error;constructor(e){e?(this._debug=(0,xd.default)(`${Fd}:${e}`),this._warn=(0,xd.default)(`${Fd}:WARN:${e}`),this._error=(0,xd.default)(`${Fd}:ERROR:${e}`)):(this._debug=(0,xd.default)(Fd),this._warn=(0,xd.default)(`${Fd}:WARN`),this._error=(0,xd.default)(`${Fd}: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 jd,Ud={},Vd={exports:{}},Bd="object"==typeof Reflect?Reflect:null,Wd=Bd&&"function"==typeof Bd.apply?Bd.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};jd=Bd&&"function"==typeof Bd.ownKeys?Bd.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var Hd=Number.isNaN||function(e){return e!=e};function qd(){qd.init.call(this)}Vd.exports=qd,Vd.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))}eu(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&eu(e,"error",t,r)}(e,i,{once:!0})}))},qd.EventEmitter=qd,qd.prototype._events=void 0,qd.prototype._eventsCount=0,qd.prototype._maxListeners=void 0;var zd=10;function Gd(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function Yd(e){return void 0===e._maxListeners?qd.defaultMaxListeners:e._maxListeners}function $d(e,t,r,n){var i,s,o,a;if(Gd(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=Yd(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 Jd(){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 Kd(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=Jd.bind(n);return i.listener=r,n.wrapFn=i,i}function Qd(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):Xd(i,i.length)}function Zd(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 Xd(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function eu(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(qd,"defaultMaxListeners",{enumerable:!0,get:function(){return zd},set:function(e){if("number"!=typeof e||e<0||Hd(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");zd=e}}),qd.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},qd.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||Hd(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},qd.prototype.getMaxListeners=function(){return Yd(this)},qd.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)Wd(a,this,t);else{var c=a.length,d=Xd(a,c);for(r=0;r<c;++r)Wd(d[r],this,t)}return!0},qd.prototype.addListener=function(e,t){return $d(this,e,t,!1)},qd.prototype.on=qd.prototype.addListener,qd.prototype.prependListener=function(e,t){return $d(this,e,t,!0)},qd.prototype.once=function(e,t){return Gd(t),this.on(e,Kd(this,e,t)),this},qd.prototype.prependOnceListener=function(e,t){return Gd(t),this.prependListener(e,Kd(this,e,t)),this},qd.prototype.removeListener=function(e,t){var r,n,i,s,o;if(Gd(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},qd.prototype.off=qd.prototype.removeListener,qd.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},qd.prototype.listeners=function(e){return Qd(this,e,!0)},qd.prototype.rawListeners=function(e){return Qd(this,e,!1)},qd.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Zd.call(e,t)},qd.prototype.listenerCount=Zd,qd.prototype.eventNames=function(){return this._eventsCount>0?jd(this._events):[]},Object.defineProperty(Ud,"__esModule",{value:!0}),Ud.EnhancedEventEmitter=void 0;const tu=Vd.exports,ru=new Ld.Logger("EnhancedEventEmitter");class nu extends tu.EventEmitter{constructor(){super(),this.setMaxListeners(1/0)}close(){super.removeAllListeners()}emit(e,...t){return super.emit(e,...t)}safeEmit(e,...t){try{return super.emit(e,...t)}catch(t){ru.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)}}Ud.EnhancedEventEmitter=nu;var iu={};Object.defineProperty(iu,"__esModule",{value:!0}),iu.InvalidStateError=iu.UnsupportedError=void 0;class su extends Error{constructor(e){super(e),this.name="UnsupportedError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,su):this.stack=new Error(e).stack}}iu.UnsupportedError=su;class ou extends Error{constructor(e){super(e),this.name="InvalidStateError",Error.hasOwnProperty("captureStackTrace")?Error.captureStackTrace(this,ou):this.stack=new Error(e).stack}}iu.InvalidStateError=ou;var au={};Object.defineProperty(au,"__esModule",{value:!0}),au.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},au.generateRandomNumber=function(){return Math.round(1e7*Math.random())},au.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 cu={},du={},uu={},lu={exports:{}};var pu=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,t){let r=0,n=0,i=-1,s=0;for(;r<e.length;)if(n<t.length&&(t[n]===e[r]||"*"===t[n]))"*"===t[n]?(i=n,s=r,n++):(r++,n++);else{if(-1===i)return!1;n=i+1,s++,r=s}for(;n<t.length&&"*"===t[n];)n++;return n===t.length}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,...t.skips.map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of r)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const r of t.skips)if(n(e,r))return!1;for(const r of t.names)if(n(e,r))return!0;return!1},t.humanize=yd,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")||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=pu(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(lu,lu.exports);var hu=l&&l.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(uu,"__esModule",{value:!0}),uu.Logger=void 0;const fu=hu(lu.exports),mu="h264-profile-level-id";uu.Logger=class{constructor(e){e?(this._debug=(0,fu.default)(`${mu}:${e}`),this._warn=(0,fu.default)(`${mu}:WARN:${e}`),this._error=(0,fu.default)(`${mu}:ERROR:${e}`)):(this._debug=(0,fu.default)(mu),this._warn=(0,fu.default)(`${mu}:WARN`),this._error=(0,fu.default)(`${mu}: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(du,"__esModule",{value:!0}),du.ProfileLevelId=du.Level=du.Profile=void 0,du.parseProfileLevelId=Pu,du.profileLevelIdToString=Tu,du.profileToString=function(e){switch(e){case vu.ConstrainedBaseline:return"ConstrainedBaseline";case vu.Baseline:return"Baseline";case vu.Main:return"Main";case vu.ConstrainedHigh:return"ConstrainedHigh";case vu.High:return"High";case vu.PredictiveHigh444:return"PredictiveHigh444";default:return void gu.warn(`profileToString() | unrecognized profile ${e}`)}},du.levelToString=function(e){switch(e){case yu.L1_b:return"1b";case yu.L1:return"1";case yu.L1_1:return"1.1";case yu.L1_2:return"1.2";case yu.L1_3:return"1.3";case yu.L2:return"2";case yu.L2_1:return"2.1";case yu.L2_2:return"2.2";case yu.L3:return"3";case yu.L3_1:return"3.1";case yu.L3_2:return"3.2";case yu.L4:return"4";case yu.L4_1:return"4.1";case yu.L4_2:return"4.2";case yu.L5:return"5";case yu.L5_1:return"5.1";case yu.L5_2:return"5.2";default:return void gu.warn(`levelToString() | unrecognized level ${e}`)}},du.parseSdpProfileLevelId=Ru,du.isSameProfile=function(e={},t={}){const r=Ru(e),n=Ru(t);return Boolean(r&&n&&r.profile===n.profile)},du.isSameProfileAndLevel=function(e={},t={}){const r=Ru(e),n=Ru(t);return Boolean(r&&n&&r.profile===n.profile&&r.level==n.level)},du.generateProfileLevelIdStringForAnswer=function(e={},t={}){if(!e["profile-level-id"]&&!t["profile-level-id"])return void gu.warn("generateProfileLevelIdStringForAnswer() | profile-level-id missing in local and remote params");const r=Ru(e),n=Ru(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=Du(e)&&Du(t),s=r.level,o=n.level,a=function(e,t){return function(e,t){if(e===yu.L1_b)return t!==yu.L1&&t!==yu.L1_b;if(t===yu.L1_b)return e!==yu.L1;return e<t}(e,t)?e:t}(s,o),c=i?s:a;return gu.debug(`generateProfileLevelIdStringForAnswer() | result [profile:${r.profile}, level:${c}]`),Tu(new _u(r.profile,c))},du.supportedLevel=function(e,t){for(let r=Cu.length-1;r>=0;--r){const n=Cu[r];if(256*n.max_macroblock_frame_size<=e&&n.max_macroblocks_per_second<=t*n.max_macroblock_frame_size)return gu.debug(`supportedLevel() | result [max_frame_pixel_count:${e}, max_fps:${t}, level:${n.level}]`),n.level}return void gu.warn(`supportedLevel() | no level supported [max_frame_pixel_count:${e}, max_fps:${t}]`)};const gu=new uu.Logger;var vu,yu;!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"}(vu||(du.Profile=vu={})),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"}(yu||(du.Level=yu={}));class _u{constructor(e,t){this.profile=e,this.level=t}}du.ProfileLevelId=_u;const bu=new _u(vu.ConstrainedBaseline,yu.L3_1);class Eu{constructor(e){this.mask=~ku("x",e),this.masked_value=ku("1",e)}isMatch(e){return this.masked_value===(e&this.mask)}}class wu{constructor(e,t,r){this.profile_idc=e,this.profile_iop=t,this.profile=r}}const Su=[new wu(66,new Eu("x1xx0000"),vu.ConstrainedBaseline),new wu(77,new Eu("1xxx0000"),vu.ConstrainedBaseline),new wu(88,new Eu("11xx0000"),vu.ConstrainedBaseline),new wu(66,new Eu("x0xx0000"),vu.Baseline),new wu(88,new Eu("10xx0000"),vu.Baseline),new wu(77,new Eu("0x0x0000"),vu.Main),new wu(100,new Eu("00000000"),vu.High),new wu(100,new Eu("00001100"),vu.ConstrainedHigh),new wu(244,new Eu("00000000"),vu.PredictiveHigh444)],Cu=[{max_macroblocks_per_second:1485,max_macroblock_frame_size:99,level:yu.L1},{max_macroblocks_per_second:1485,max_macroblock_frame_size:99,level:yu.L1_b},{max_macroblocks_per_second:3e3,max_macroblock_frame_size:396,level:yu.L1_1},{max_macroblocks_per_second:6e3,max_macroblock_frame_size:396,level:yu.L1_2},{max_macroblocks_per_second:11880,max_macroblock_frame_size:396,level:yu.L1_3},{max_macroblocks_per_second:11880,max_macroblock_frame_size:396,level:yu.L2},{max_macroblocks_per_second:19800,max_macroblock_frame_size:792,level:yu.L2_1},{max_macroblocks_per_second:20250,max_macroblock_frame_size:1620,level:yu.L2_2},{max_macroblocks_per_second:40500,max_macroblock_frame_size:1620,level:yu.L3},{max_macroblocks_per_second:108e3,max_macroblock_frame_size:3600,level:yu.L3_1},{max_macroblocks_per_second:216e3,max_macroblock_frame_size:5120,level:yu.L3_2},{max_macroblocks_per_second:245760,max_macroblock_frame_size:8192,level:yu.L4},{max_macroblocks_per_second:245760,max_macroblock_frame_size:8192,level:yu.L4_1},{max_macroblocks_per_second:522240,max_macroblock_frame_size:8704,level:yu.L4_2},{max_macroblocks_per_second:589824,max_macroblock_frame_size:22080,level:yu.L5},{max_macroblocks_per_second:983040,max_macroblock_frame_size:36864,level:yu.L5_1},{max_macroblocks_per_second:2073600,max_macroblock_frame_size:36864,level:yu.L5_2}];function Pu(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 yu.L1_1:s=0!=(16&n)?yu.L1_b:yu.L1_1;break;case yu.L1:case yu.L1_2:case yu.L1_3:case yu.L2:case yu.L2_1:case yu.L2_2:case yu.L3:case yu.L3_1:case yu.L3_2:case yu.L4:case yu.L4_1:case yu.L4_2:case yu.L5:case yu.L5_1:case yu.L5_2:s=r;break;default:return void gu.warn(`parseProfileLevelId() | unrecognized level_idc [str:${e}, level_idc:${r}]`)}for(const t of Su)if(i===t.profile_idc&&t.profile_iop.isMatch(n))return gu.debug(`parseProfileLevelId() | result [str:${e}, profile:${t.profile}, level:${s}]`),new _u(t.profile,s);gu.warn(`parseProfileLevelId() | unrecognized profile_idc/profile_iop combination [str:${e}, profile_idc:${i}, profile_iop:${n}]`)}function Tu(e){if(e.level==yu.L1_b)switch(e.profile){case vu.ConstrainedBaseline:return"42f00b";case vu.Baseline:return"42100b";case vu.Main:return"4d100b";default:return void gu.warn(`profileLevelIdToString() | Level 1_b not is allowed for profile ${e.profile}`)}let t;switch(e.profile){case vu.ConstrainedBaseline:t="42e0";break;case vu.Baseline:t="4200";break;case vu.Main:t="4d00";break;case vu.ConstrainedHigh:t="640c";break;case vu.High:t="6400";break;case vu.PredictiveHigh444:t="f400";break;default:return void gu.warn(`profileLevelIdToString() | unrecognized profile ${e.profile}`)}let r=e.level.toString(16);return 1===r.length&&(r=`0${r}`),`${t}${r}`}function Ru(e={}){const t=e["profile-level-id"];return t?Pu(t):bu}function ku(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 Du(e={}){const t=e["level-asymmetry-allowed"];return!0===t||1===t||"1"===t}Object.defineProperty(cu,"__esModule",{value:!0}),cu.validateAndNormalizeRtpCapabilities=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)Nu(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)Lu(t)},cu.validateAndNormalizeRtpParameters=Ou,cu.validateAndNormalizeSctpStreamParameters=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")},cu.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)},cu.getExtendedRtpCapabilities=function(e,t,r){const n={codecs:[],headerExtensions:[]};if(r)for(const r of e.codecs??[]){if(Uu(r))continue;const e=(t.codecs??[]).find((e=>Vu(e,r,{strict:!0,modify:!0})));if(!e)continue;const i={kind:r.kind,mimeType:r.mimeType,clockRate:r.clockRate,channels:r.channels,localPayloadType:r.preferredPayloadType,localRtxPayloadType:void 0,remotePayloadType:e.preferredPayloadType,remoteRtxPayloadType:void 0,localParameters:r.parameters??{},remoteParameters:e.parameters??{},rtcpFeedback:Wu(r,e)};n.codecs.push(i)}else for(const r of t.codecs??[]){if(Uu(r))continue;const t=(e.codecs??[]).find((e=>Vu(e,r,{strict:!0,modify:!0})));if(!t)continue;const i={kind:t.kind,mimeType:t.mimeType,clockRate:t.clockRate,channels:t.channels,localPayloadType:t.preferredPayloadType,localRtxPayloadType:void 0,remotePayloadType:r.preferredPayloadType,remoteRtxPayloadType:void 0,localParameters:t.parameters??{},remoteParameters:r.parameters??{},rtcpFeedback:Wu(t,r)};n.codecs.push(i)}for(const r of n.codecs){const n=e.codecs.find((e=>Uu(e)&&e.parameters?.apt===r.localPayloadType)),i=t.codecs.find((e=>Uu(e)&&e.parameters?.apt===r.remotePayloadType));n&&i&&(r.localRtxPayloadType=n.preferredPayloadType,r.remoteRtxPayloadType=i.preferredPayloadType)}for(const r of t.headerExtensions){const t=e.headerExtensions.find((e=>Bu(e,r)));if(!t)continue;const i={kind:r.kind,uri:r.uri,sendId:t.preferredId,recvId:r.preferredId,encrypt:t.preferredEncrypt??!1,direction:"sendrecv"};switch(r.direction){case"sendrecv":i.direction="sendrecv";break;case"recvonly":i.direction="sendonly";break;case"sendonly":i.direction="recvonly";break;case"inactive":i.direction="inactive"}n.headerExtensions.push(i)}return n},cu.getRecvRtpCapabilities=function(e){const t={codecs:[],headerExtensions:[]};for(const r of e.codecs){const e={kind:r.kind,mimeType:r.mimeType,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={kind:r.kind,mimeType:`${r.kind}/rtx`,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??!1,direction:r.direction};t.headerExtensions.push(e)}return t},cu.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},cu.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},cu.reduceCodecs=function(e,t){const r=[];if(t){for(let n=0;n<e.length;++n)if(Vu(e[n],t,{strict:!0})){r.push(e[n]),Uu(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]),Uu(e[1])&&r.push(e[1]);return r},cu.generateProbatorRtpParameters=function(e){Ou(e=Au.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},cu.canSend=function(e,t){return(t.codecs??[]).some((t=>t.kind===e))},cu.canReceive=function(e,t){if(Ou(e),0===e.codecs.length)return!1;const r=e.codecs[0];return(t.codecs??[]).some((e=>e.preferredPayloadType===r.payloadType))};const Iu=du,Au=au;function Ou(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)xu(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)Fu(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)ju(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 Nu(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(),"number"!=typeof e.preferredPayloadType)throw new TypeError("missing 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)Mu(t)}function Mu(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 Lu(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 xu(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)Mu(t)}function Fu(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 ju(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 Uu(e){return!!e&&/.+\/rtx$/i.test(e.mimeType)}function Vu(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(!Iu.isSameProfile(e.parameters,t.parameters))return!1;let r;try{r=Iu.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 Bu(e,t){return(!e.kind||!t.kind||e.kind===t.kind)&&e.uri===t.uri}function Wu(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 Hu={},qu={},zu={},Gu={};Object.defineProperty(Gu,"__esModule",{value:!0}),Gu.Logger=void 0;const Yu=hd.exports,$u="awaitqueue";Gu.Logger=class{_debug;_warn;_error;constructor(e){e?(this._debug=Yu(`awaitqueue:${e}`),this._warn=Yu(`awaitqueue:WARN:${e}`),this._error=Yu(`awaitqueue:ERROR:${e}`)):(this._debug=Yu($u),this._warn=Yu("awaitqueue:WARN"),this._error=Yu("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}};var Ju={};Object.defineProperty(Ju,"__esModule",{value:!0}),Ju.AwaitQueueRemovedTaskError=Ju.AwaitQueueStoppedError=void 0;class Ku extends Error{constructor(e){super(e??"queue stopped"),this.name="AwaitQueueStoppedError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Ku)}}Ju.AwaitQueueStoppedError=Ku;class Qu extends Error{constructor(e){super(e??"queue task removed"),this.name="AwaitQueueRemovedTaskError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Qu)}}Ju.AwaitQueueRemovedTaskError=Qu,Object.defineProperty(zu,"__esModule",{value:!0}),zu.AwaitQueue=void 0;const Zu=Ju,Xu=new Gu.Logger("AwaitQueue");zu.AwaitQueue=class{pendingTasks=new Map;nextTaskId=0;stopping=!1;constructor(){Xu.debug("constructor()")}get size(){return this.pendingTasks.size}async push(e,t){if(t=t??e.name,Xu.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),Xu.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),Xu.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(){Xu.debug("stop()"),this.stopping=!0;for(const e of this.pendingTasks.values())Xu.debug(`stop() | stopping task [name:${e.name}]`),e.reject(new Zu.AwaitQueueStoppedError);this.stopping=!1}remove(e){Xu.debug(`remove() [taskIdx:${e}]`);const t=Array.from(this.pendingTasks.values())[e];t?t.reject(new Zu.AwaitQueueRemovedTaskError):Xu.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(Xu.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)}}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.AwaitQueueRemovedTaskError=e.AwaitQueueStoppedError=e.AwaitQueue=void 0;var t=zu;Object.defineProperty(e,"AwaitQueue",{enumerable:!0,get:function(){return t.AwaitQueue}});var r=Ju;Object.defineProperty(e,"AwaitQueueStoppedError",{enumerable:!0,get:function(){return r.AwaitQueueStoppedError}}),Object.defineProperty(e,"AwaitQueueRemovedTaskError",{enumerable:!0,get:function(){return r.AwaitQueueRemovedTaskError}})}(qu);var el={};Object.defineProperty(el,"__esModule",{value:!0}),el.Producer=void 0;const tl=Ud,rl=iu,nl=new Ld.Logger("Producer");class il extends tl.EnhancedEventEmitter{_id;_localId;_closed=!1;_rtpSender;_track;_kind;_rtpParameters;_paused;_maxSpatialLayer;_stopTracks;_disableTrackOnPause;_zeroRtpOnPause;_appData;_observer=new tl.EnhancedEventEmitter;constructor({id:e,localId:t,rtpSender:r,track:n,rtpParameters:i,stopTracks:s,disableTrackOnPause:o,zeroRtpOnPause:a,appData:c}){super(),nl.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||(nl.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"),super.close(),this._observer.close())}transportClosed(){this._closed||(nl.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new rl.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){nl.debug("pause()"),this._closed?nl.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(){nl.debug("resume()"),this._closed?nl.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(nl.debug("replaceTrack() [track:%o]",e),this._closed){if(e&&this._stopTracks)try{e.stop()}catch(e){}throw new rl.InvalidStateError("closed")}if(e&&"ended"===e.readyState)throw new rl.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()):nl.debug("replaceTrack() | same track, ignored")}async setMaxSpatialLayer(e){if(this._closed)throw new rl.InvalidStateError("closed");if("video"!==this._kind)throw new rl.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 rl.InvalidStateError("closed");if("object"!=typeof e)throw new TypeError("invalid params");await new Promise(((t,r)=>{this.safeEmit("@setrtpencodingparameters",e,t,r)}))}onTrackEnded(){nl.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){}}}el.Producer=il;var sl={};Object.defineProperty(sl,"__esModule",{value:!0}),sl.Consumer=void 0;const ol=Ud,al=iu,cl=new Ld.Logger("Consumer");class dl extends ol.EnhancedEventEmitter{_id;_localId;_producerId;_closed=!1;_rtpReceiver;_track;_rtpParameters;_paused;_appData;_observer=new ol.EnhancedEventEmitter;constructor({id:e,localId:t,producerId:r,rtpReceiver:n,track:i,rtpParameters:s,appData:o}){super(),cl.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||(cl.debug("close()"),this._closed=!0,this.destroyTrack(),this.emit("@close"),this._observer.safeEmit("close"),super.close(),this._observer.close())}transportClosed(){this._closed||(cl.debug("transportClosed()"),this._closed=!0,this.destroyTrack(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}async getStats(){if(this._closed)throw new al.InvalidStateError("closed");return new Promise(((e,t)=>{this.safeEmit("@getstats",e,t)}))}pause(){cl.debug("pause()"),this._closed?cl.error("pause() | Consumer closed"):this._paused?cl.debug("pause() | Consumer is already paused"):(this._paused=!0,this._track.enabled=!1,this.emit("@pause"),this._observer.safeEmit("pause"))}resume(){cl.debug("resume()"),this._closed?cl.error("resume() | Consumer closed"):this._paused?(this._paused=!1,this._track.enabled=!0,this.emit("@resume"),this._observer.safeEmit("resume")):cl.debug("resume() | Consumer is already resumed")}onTrackEnded(){cl.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){}}}sl.Consumer=dl;var ul={};Object.defineProperty(ul,"__esModule",{value:!0}),ul.DataProducer=void 0;const ll=Ud,pl=iu,hl=new Ld.Logger("DataProducer");class fl extends ll.EnhancedEventEmitter{_id;_dataChannel;_closed=!1;_sctpStreamParameters;_appData;_observer=new ll.EnhancedEventEmitter;constructor({id:e,dataChannel:t,sctpStreamParameters:r,appData:n}){super(),hl.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||(hl.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"),super.close(),this._observer.close())}transportClosed(){this._closed||(hl.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}send(e){if(hl.debug("send()"),this._closed)throw new pl.InvalidStateError("closed");this._dataChannel.send(e)}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(hl.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;const t=e.error??new Error("unknown DataChannel error");"sctp-failure"===e.error?.errorDetail?hl.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",e.error?.sctpCauseCode,e.error.message):hl.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(hl.warn('DataChannel "close" event'),this._closed=!0,this.emit("@close"),this.safeEmit("close"),this._observer.safeEmit("close"))})),this._dataChannel.addEventListener("message",(()=>{this._closed||hl.warn('DataChannel "message" event in a DataProducer, message discarded')})),this._dataChannel.addEventListener("bufferedamountlow",(()=>{this._closed||this.safeEmit("bufferedamountlow")}))}}ul.DataProducer=fl;var ml={};Object.defineProperty(ml,"__esModule",{value:!0}),ml.DataConsumer=void 0;const gl=Ud,vl=new Ld.Logger("DataConsumer");class yl extends gl.EnhancedEventEmitter{_id;_dataProducerId;_dataChannel;_closed=!1;_sctpStreamParameters;_appData;_observer=new gl.EnhancedEventEmitter;constructor({id:e,dataProducerId:t,dataChannel:r,sctpStreamParameters:n,appData:i}){super(),vl.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||(vl.debug("close()"),this._closed=!0,this._dataChannel.close(),this.emit("@close"),this._observer.safeEmit("close"),super.close(),this._observer.close())}transportClosed(){this._closed||(vl.debug("transportClosed()"),this._closed=!0,this._dataChannel.close(),this.safeEmit("transportclose"),this._observer.safeEmit("close"))}handleDataChannel(){this._dataChannel.addEventListener("open",(()=>{this._closed||(vl.debug('DataChannel "open" event'),this.safeEmit("open"))})),this._dataChannel.addEventListener("error",(e=>{if(this._closed)return;const t=e.error??new Error("unknown DataChannel error");"sctp-failure"===e.error?.errorDetail?vl.error("DataChannel SCTP error [sctpCauseCode:%s]: %s",e.error?.sctpCauseCode,e.error.message):vl.error('DataChannel "error" event: %o',t),this.safeEmit("error",t)})),this._dataChannel.addEventListener("close",(()=>{this._closed||(vl.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)}))}}ml.DataConsumer=yl,Object.defineProperty(Hu,"__esModule",{value:!0}),Hu.Transport=void 0;const _l=qu,bl=Ud,El=iu,wl=au,Sl=cu,Cl=el,Pl=sl,Tl=ul,Rl=ml,kl=new Ld.Logger("Transport");class Dl{consumerOptions;promise;resolve;reject;constructor(e){this.consumerOptions=e,this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class Il extends bl.EnhancedEventEmitter{_id;_closed=!1;_direction;_getSendExtendedRtpCapabilities;_recvRtpCapabilities;_canProduceByKind;_maxSctpMessageSize;_handler;_iceGatheringState="new";_connectionState="new";_appData;_producers=new Map;_consumers=new Map;_dataProducers=new Map;_dataConsumers=new Map;_probatorConsumerCreated=!1;_awaitQueue=new _l.AwaitQueue;_pendingConsumerTasks=[];_consumerCreationInProgress=!1;_pendingPauseConsumers=new Map;_consumerPauseInProgress=!1;_pendingResumeConsumers=new Map;_consumerResumeInProgress=!1;_pendingCloseConsumers=new Map;_consumerCloseInProgress=!1;_observer=new bl.EnhancedEventEmitter;constructor({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,appData:d,handlerFactory:u,getSendExtendedRtpCapabilities:l,recvRtpCapabilities:p,canProduceByKind:h}){super(),kl.debug("constructor() [id:%s, direction:%s]",t,e),this._id=t,this._direction=e,this._getSendExtendedRtpCapabilities=l,this._recvRtpCapabilities=p,this._canProduceByKind=h,this._maxSctpMessageSize=s?s.maxMessageSize:null;const f=wl.clone(c)??{};delete f.iceServers,delete f.iceTransportPolicy,delete f.bundlePolicy,delete f.rtcpMuxPolicy,this._handler=u.factory({direction:e,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:f,getSendExtendedRtpCapabilities:this._getSendExtendedRtpCapabilities}),this._appData=d??{},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){kl.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"),super.close(),this._observer.close()}}async getStats(){if(this._closed)throw new El.InvalidStateError("closed");return this._handler.getTransportStats()}async restartIce({iceParameters:e}){if(kl.debug("restartIce()"),this._closed)throw new El.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(kl.debug("updateIceServers()"),this._closed)throw new El.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(kl.debug("produce() [track:%o]",e),this._closed)throw new El.InvalidStateError("closed");if(!e)throw new TypeError("missing track");if("send"!==this._direction)throw new El.UnsupportedError("not a sending Transport");if(!this._canProduceByKind[e.kind])throw new El.UnsupportedError(`cannot produce ${e.kind}`);if("ended"===e.readyState)throw new El.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{Sl.validateAndNormalizeRtpParameters(l);const{id:t}=await new Promise(((t,r)=>{this.safeEmit("produce",{kind:e.kind,rtpParameters:l,appData:c},t,r)})),r=new Cl.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(kl.debug("consume()"),this._closed)throw new El.InvalidStateError("closed");if("recv"!==this._direction)throw new El.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=wl.clone(n);if(!Sl.canReceive(a,this._recvRtpCapabilities))throw new El.UnsupportedError("cannot consume this Producer");const c=new Dl({id:e,producerId:t,kind:r,rtpParameters:a,streamId:i,onRtpReceiver:s,appData:o});return this._pendingConsumerTasks.push(c),queueMicrotask((()=>{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(kl.debug("produceData()"),this._closed)throw new El.InvalidStateError("closed");if("send"!==this._direction)throw new El.UnsupportedError("not a sending Transport");if(!this._maxSctpMessageSize)throw new El.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});Sl.validateAndNormalizeSctpStreamParameters(a);const{id:c}=await new Promise(((e,t)=>{this.safeEmit("producedata",{sctpStreamParameters:a,label:n,protocol:i,appData:s},e,t)})),d=new Tl.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(kl.debug("consumeData()"),this._closed)throw new El.InvalidStateError("closed");if("recv"!==this._direction)throw new El.UnsupportedError("not a receiving Transport");if(!this._maxSctpMessageSize)throw new El.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=wl.clone(r);return Sl.validateAndNormalizeSctpStreamParameters(o),this._awaitQueue.push((async()=>{const{dataChannel:r}=await this._handler.receiveDataChannel({sctpStreamParameters:o,label:n,protocol:i}),a=new Rl.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()")}createPendingConsumers(){this._consumerCreationInProgress=!0,this._awaitQueue.push((async()=>{if(0===this._pendingConsumerTasks.length)return void kl.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 Pl.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=Sl.generateProbatorRtpParameters(t.rtpParameters);await this._handler.receive([{trackId:"probator",kind:"video",rtpParameters:e}]),kl.debug("createPendingConsumers() | Consumer for RTP probation created"),this._probatorConsumerCreated=!0}catch(e){kl.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 kl.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){kl.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 kl.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){kl.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 kl.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){kl.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 El.InvalidStateError("closed")):this.safeEmit("connect",{dtlsParameters:e},t,r)})),e.on("@icegatheringstatechange",(e=>{e!==this._iceGatheringState&&(kl.debug("ICE gathering state changed to %s",e),this._iceGatheringState=e,this._closed||this.safeEmit("icegatheringstatechange",e))})),e.on("@icecandidateerror",(e=>{kl.warn(`ICE candidate error [url:${e.url}, localAddress:${e.address}, localPort:${e.port}]: ${e.errorCode} "${e.errorText}"`),this.safeEmit("icecandidateerror",e)})),e.on("@connectionstatechange",(e=>{e!==this._connectionState&&(kl.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=>kl.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 El.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),queueMicrotask((()=>{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),queueMicrotask((()=>{this._closed||!1===this._consumerResumeInProgress&&this.resumePendingConsumers()}))})),e.on("@getstats",((t,r)=>{if(this._closed)return r(new El.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)}))}}Hu.Transport=Il;var Al={},Ol={},Nl={},Ml={exports:{}},Ll=Ml.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(Ll).forEach((function(e){Ll[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=Ml.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}}))}))}}(Nl);var xl=Ml.exports,Fl=/%[sdv%]/g,jl=function(e){var t=1,r=arguments,n=r.length;return e.replace(Fl,(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""}}))},Ul=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 jl.apply(null,n)},Vl=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Bl=["i","c","b","a"],Wl=Nl,Hl=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||Vl,n=t.innerOrder||Bl,i=[];return r.forEach((function(t){xl[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(Ul(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(Ul(t,r,e))}))}))})),e.media.forEach((function(e){i.push(Ul("m",xl.m[0],e)),n.forEach((function(t){xl[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(Ul(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(Ul(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"},ql=Ml.exports;Ol.grammar=ql,Ol.write=Hl,Ol.parse=Wl.parse,Ol.parseParams=Wl.parseParams,Ol.parseFmtpConfig=Wl.parseFmtpConfig,Ol.parsePayloads=Wl.parsePayloads,Ol.parseRemoteCandidates=Wl.parseRemoteCandidates,Ol.parseImageAttributes=Wl.parseImageAttributes,Ol.parseSimulcastStreamList=Wl.parseSimulcastStreamList;var zl={};Object.defineProperty(zl,"__esModule",{value:!0}),zl.parse=function(e){const t=Gl.exec(e??"");return t?{spatialLayers:Number(t[1]),temporalLayers:Number(t[2])}:{spatialLayers:1,temporalLayers:1}};const Gl=new RegExp("^[LS]([1-9]\\d{0,1})T([1-9]\\d{0,1})");var Yl={};Object.defineProperty(Yl,"__esModule",{value:!0}),Yl.extractRtpCapabilities=function({sdpObject:e}){const t=new Map,r=new Map;for(const n of e.media){const e=n.type;switch(e){case"audio":case"video":break;default:continue}for(const r of n.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 n.fmtp??[]){const r=$l.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 n.rtcpFb??[]){const n={type:r.type,parameter:r.subtype};if(n.parameter||delete n.parameter,"*"!==r.payload){const e=t.get(Number(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 n.ext??[]){if(t["encrypt-uri"])continue;const n={kind:e,uri:t.uri,preferredId:t.value};r.set(n.preferredId,n)}}return{codecs:Array.from(t.values()),headerExtensions:Array.from(r.values())}},Yl.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??=t.setup,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}]}},Yl.getCname=function({offerMediaObject:e}){const t=(e.ssrcs??[]).find((e=>"cname"===e.attribute));if(!t)return"";return t.value},Yl.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=$l.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 $l=Ol;var Jl={};Object.defineProperty(Jl,"__esModule",{value:!0}),Jl.getRtpEncodings=function({offerMediaObject:e}){const t=new Set;for(const r of e.ssrcs??[]){const e=r.id;e&&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;const e=n.ssrcs.split(/\s+/),i=Number(e[0]),s=Number(e[1]);t.has(i)&&(t.delete(i),t.delete(s),r.set(i,s))}for(const e of t)r.set(e,void 0);const n=[];for(const[e,t]of r){const r={ssrc:e};t&&(r.rtx={ssrc:t}),n.push(r)}return n},Jl.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 Kl={};Object.defineProperty(Kl,"__esModule",{value:!0}),Kl.addNackSupportForOpus=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 Ql={},Zl={};Object.defineProperty(Zl,"__esModule",{value:!0}),Zl.OfferMediaSection=Zl.AnswerMediaSection=Zl.MediaSection=void 0;const Xl=Ol,ep=au;class tp{_mediaObject;constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r}){if(this._mediaObject={type:"",port:0,protocol:"",payloads:"",rtp:[],fmtp:[]},e&&this.setIceParameters(e),t){this._mediaObject.candidates=[];for(const e of t){const t={foundation:e.foundation,component:1,ip:e.address??e.ip,port:e.port,priority:e.priority,transport:e.protocol,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}}Zl.MediaSection=tp;Zl.AnswerMediaSection=class extends tp{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,offerMediaObject:s,offerRtpParameters:o,answerRtpParameters:a,codecOptions:c}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r}),this._mediaObject.mid=String(s.mid),this._mediaObject.type=s.type,this._mediaObject.protocol=s.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),s.type){case"audio":case"video":this._mediaObject.direction="recvonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[];for(const e of a.codecs){const t={payload:e.payloadType,codec:rp(e),rate:e.clockRate};e.channels>1&&(t.encoding=e.channels),this._mediaObject.rtp.push(t);const r=ep.clone(e.parameters)??{};let n=ep.clone(e.rtcpFeedback)??[];if(c){const{opusStereo:t,opusFec:i,opusDtx:s,opusMaxPlaybackRate:a,opusMaxAverageBitrate:d,opusPtime:u,opusNack:l,videoGoogleStartBitrate:p,videoGoogleMaxBitrate:h,videoGoogleMinBitrate:f}=c,m=o.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!==a&&(r.maxplaybackrate=a),void 0!==d&&(r.maxaveragebitrate=d),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":case"video/av1":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=a.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of a.headerExtensions){(s.ext??[]).some((t=>t.uri===e.uri))&&this._mediaObject.ext.push({uri:e.uri,value:e.id})}if("extmap-allow-mixed"===s.extmapAllowMixed&&(this._mediaObject.extmapAllowMixed="extmap-allow-mixed"),s.simulcast){this._mediaObject.simulcast={dir1:"recv",list1:s.simulcast.list1},this._mediaObject.rids=[];for(const e of s.rids??[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}else if(s.simulcast_03){this._mediaObject.simulcast_03={value:s.simulcast_03.value.replace(/send/g,"recv")},this._mediaObject.rids=[];for(const e of s.rids??[])"send"===e.direction&&this._mediaObject.rids.push({id:e.id,direction:"recv"})}this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize";break;case"application":"number"==typeof s.sctpPort?(this._mediaObject.payloads="webrtc-datachannel",this._mediaObject.sctpPort=n.port,this._mediaObject.maxMessageSize=n.maxMessageSize):s.sctpmap&&(this._mediaObject.payloads=String(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=Xl.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 rp(e){const t=new RegExp("^(audio|video)/(.+)","i").exec(e.mimeType);if(!t)throw new TypeError("invalid codec.mimeType");return t[2]}Zl.OfferMediaSection=class extends tp{constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i,mid:s,kind:o,offerRtpParameters:a,streamId:c,trackId:d}){switch(super({iceParameters:e,iceCandidates:t,dtlsParameters:r}),this._mediaObject.mid=String(s),this._mediaObject.type=o,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),this._mediaObject.extmapAllowMixed="extmap-allow-mixed",o){case"audio":case"video":{this._mediaObject.direction="sendonly",this._mediaObject.rtp=[],this._mediaObject.rtcpFb=[],this._mediaObject.fmtp=[],this._mediaObject.msid=`${c??"-"} ${d}`;for(const e of a.codecs){const t={payload:e.payloadType,codec:rp(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=a.codecs.map((e=>e.payloadType)).join(" "),this._mediaObject.ext=[];for(const e of a.headerExtensions)this._mediaObject.ext.push({uri:e.uri,value:e.id});this._mediaObject.rtcpMux="rtcp-mux",this._mediaObject.rtcpRsize="rtcp-rsize";const e=a.encodings[0],t=e.ssrc,r=e.rtx?.ssrc;this._mediaObject.ssrcs=[],this._mediaObject.ssrcGroups=[],t&&a.rtcp.cname&&this._mediaObject.ssrcs.push({id:t,attribute:"cname",value:a.rtcp.cname}),r&&(a.rtcp.cname&&this._mediaObject.ssrcs.push({id:r,attribute:"cname",value:a.rtcp.cname}),t&&this._mediaObject.ssrcGroups.push({semantics:"FID",ssrcs:`${t} ${r}`}));break}case"application":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"}},Object.defineProperty(Ql,"__esModule",{value:!0}),Ql.RemoteSdp=void 0;const np=Ol,ip=Zl,sp=["av1","h264"],op=new Ld.Logger("RemoteSdp");Ql.RemoteSdp=class{_iceParameters;_iceCandidates;_dtlsParameters;_sctpParameters;_plainRtpParameters;_mediaSections=[];_midToIndex=new Map;_firstMid;_sdpObject;constructor({iceParameters:e,iceCandidates:t,dtlsParameters:r,sctpParameters:n,plainRtpParameters:i}){if(this._iceParameters=e,this._iceCandidates=t,this._dtlsParameters=r,this._sctpParameters=n,this._plainRtpParameters=i,this._sdpObject={version:0,origin:{address:"0.0.0.0",ipVer:4,netType:"IN",sessionId:"10000",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){op.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){op.debug("updateDtlsRole() [role:%s]",e),this._dtlsParameters.role=e;for(const t of this._mediaSections)t.setDtlsRole(e)}setSessionExtmapAllowMixed(){op.debug("setSessionExtmapAllowMixed()"),this._sdpObject.extmapAllowMixed="extmap-allow-mixed"}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}){const s=new ip.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,offerMediaObject:e,offerRtpParameters:r,answerRtpParameters:n,codecOptions:i}),o=s.getObject();o.rtp.find((e=>sp.includes(e.codec.toLowerCase())))||(o.ext=o.ext?.filter((e=>"https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension"!==e.uri))),t?this._replaceMediaSection(s,t):this._midToIndex.has(s.mid)?this._replaceMediaSection(s):this._addMediaSection(s)}receive({mid:e,kind:t,offerRtpParameters:r,streamId:n,trackId:i}){this.setSessionExtmapAllowMixed();const s=new ip.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,plainRtpParameters:this._plainRtpParameters,mid:e,kind:t,offerRtpParameters:r,streamId:n,trackId:i}),o=this._mediaSections.find((e=>e.closed));o?this._replaceMediaSection(s,o.mid):this._addMediaSection(s)}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?(op.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)}sendSctpAssociation({offerMediaObject:e}){const t=new ip.AnswerMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,offerMediaObject:e});this._addMediaSection(t)}receiveSctpAssociation(){const e=new ip.OfferMediaSection({iceParameters:this._iceParameters,iceCandidates:this._iceCandidates,dtlsParameters:this._dtlsParameters,sctpParameters:this._sctpParameters,plainRtpParameters:this._plainRtpParameters,mid:"datachannel",kind:"application"});this._addMediaSection(e)}getSdp(){return this._sdpObject.origin.sessionVersion++,np.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(" "))}},Object.defineProperty(Al,"__esModule",{value:!0}),Al.Chrome111=void 0;const ap=Ol,cp=Ud,dp=cu,up=iu,lp=zl,pp=Yl,hp=Jl,fp=Kl,mp=Ql,gp=new Ld.Logger("Chrome111"),vp={OS:1024,MIS:1024};class yp extends cp.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"Chrome111",factory:e=>new yp(e),getNativeRtpCapabilities:async()=>{gp.debug("getNativeRtpCapabilities()");let e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});try{e.addTransceiver("audio"),e.addTransceiver("video",{sendEncodings:[{scalabilityMode:"L3T3"}]});const t=await e.createOffer();try{e.close()}catch(e){}e=void 0;const r=ap.parse(t.sdp);return yp.getLocalRtpCapabilities(r)}catch(t){try{e?.close()}catch(e){}throw e=void 0,t}},getNativeSctpCapabilities:async()=>(gp.debug("getNativeSctpCapabilities()"),{numStreams:vp})}}static getLocalRtpCapabilities(e){const t=pp.extractRtpCapabilities({sdpObject:e});return dp.validateAndNormalizeRtpCapabilities(t),fp.addNackSupportForOpus(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),gp.debug("constructor()"),this._direction=e,this._remoteSdp=new mp.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,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}),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(gp.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"Chrome111"}close(){if(gp.debug("close()"),!this._closed){this._closed=!0;try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){this.assertNotClosed(),gp.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),gp.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});gp.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};gp.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};gp.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();gp.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(),gp.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,lp.parse)(r.scalabilityMode).temporalLayers:3;t>e&&(e=t)}t.forEach(((t,r)=>{t.rid=`r${r}`,t.scalabilityMode=`L1T${e}`}))}const s=this._remoteSdp.getNextMediaSectionIdx(),o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(o.sender);const a=await this._pc.createOffer();let c=ap.parse(a.sdp);c.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const d=yp.getLocalRtpCapabilities(c),u=this._getSendExtendedRtpCapabilities(d),l=dp.getSendingRtpParameters(e.kind,u);l.codecs=dp.reduceCodecs(l.codecs,n);const p=dp.getSendingRemoteRtpParameters(e.kind,u);p.codecs=dp.reduceCodecs(p.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:c}),gp.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);const h=o.mid;l.mid=h,c=ap.parse(this._pc.localDescription.sdp);const f=c.media[s.idx];if(l.rtcp.cname=pp.getCname({offerMediaObject:f}),t)if(1===t.length){const e=hp.getRtpEncodings({offerMediaObject:f});Object.assign(e[0],t[0]),l.encodings=e}else l.encodings=t;else l.encodings=hp.getRtpEncodings({offerMediaObject:f});this._remoteSdp.send({offerMediaObject:f,reuseMid:s.reuseMid,offerRtpParameters:l,answerRtpParameters:p,codecOptions:r});const m={type:"answer",sdp:this._remoteSdp.getSdp()};return gp.debug("send() | calling pc.setRemoteDescription() [answer:%o]",m),await this._pc.setRemoteDescription(m),this._mapMidTransceiver.set(h,o),{localId:h,rtpParameters:l,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),gp.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();gp.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};gp.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),gp.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();gp.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};gp.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),gp.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();gp.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};gp.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?gp.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):gp.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(),gp.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();gp.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};gp.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),gp.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();gp.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};gp.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};gp.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%vp.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=ap.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),gp.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()};gp.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;gp.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()};gp.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=ap.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));pp.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:ap.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),gp.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){gp.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()};gp.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();gp.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){gp.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()};gp.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();gp.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){gp.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()};gp.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();gp.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};gp.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()};gp.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=ap.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}gp.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=ap.parse(this._pc.localDescription.sdp));const r=pp.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}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{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")}};assertNotClosed(){if(this._closed)throw new up.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')}}Al.Chrome111=yp;var _p={};Object.defineProperty(_p,"__esModule",{value:!0}),_p.Chrome74=void 0;const bp=Ol,Ep=Ud,wp=cu,Sp=iu,Cp=zl,Pp=Yl,Tp=Jl,Rp=Kl,kp=Ql,Dp=new Ld.Logger("Chrome74"),Ip={OS:1024,MIS:1024};class Ap extends Ep.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"Chrome74",factory:e=>new Ap(e),getNativeRtpCapabilities:async()=>{Dp.debug("getNativeRtpCapabilities()");let 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){}e=void 0;const r=bp.parse(t.sdp);return Ap.getLocalRtpCapabilities(r)}catch(t){try{e?.close()}catch(e){}throw e=void 0,t}},getNativeSctpCapabilities:async()=>(Dp.debug("getNativeSctpCapabilities()"),{numStreams:Ip})}}static getLocalRtpCapabilities(e){const t=Pp.extractRtpCapabilities({sdpObject:e});return wp.validateAndNormalizeRtpCapabilities(t),Rp.addNackSupportForOpus(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),Dp.debug("constructor()"),this._direction=e,this._remoteSdp=new kp.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,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}),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(Dp.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"Chrome74"}close(){if(Dp.debug("close()"),!this._closed){this._closed=!0;try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){this.assertNotClosed(),Dp.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),Dp.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Dp.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Dp.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Dp.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Dp.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(),Dp.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=this._remoteSdp.getNextMediaSectionIdx(),s=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});let o=await this._pc.createOffer(),a=bp.parse(o.sdp);a.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const c=Ap.getLocalRtpCapabilities(a),d=this._getSendExtendedRtpCapabilities(c),u=wp.getSendingRtpParameters(e.kind,d);u.codecs=wp.reduceCodecs(u.codecs,n);const l=wp.getSendingRemoteRtpParameters(e.kind,d);l.codecs=wp.reduceCodecs(l.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:a});let p=!1;const h=(0,Cp.parse)((t??[{}])[0].scalabilityMode);let f;t&&1===t.length&&h.spatialLayers>1&&"video/vp9"===u.codecs[0].mimeType.toLowerCase()&&(Dp.debug("send() | enabling legacy simulcast for VP9 SVC"),p=!0,a=bp.parse(o.sdp),f=a.media[i.idx],Tp.addLegacySimulcast({offerMediaObject:f,numStreams:h.spatialLayers}),o={type:"offer",sdp:bp.write(a)}),Dp.debug("send() | calling pc.setLocalDescription() [offer:%o]",o),await this._pc.setLocalDescription(o);const m=s.mid;if(u.mid=m,a=bp.parse(this._pc.localDescription.sdp),f=a.media[i.idx],u.rtcp.cname=Pp.getCname({offerMediaObject:f}),t)if(1===t.length){let e=Tp.getRtpEncodings({offerMediaObject:f});Object.assign(e[0],t[0]),p&&(e=[e[0]]),u.encodings=e}else u.encodings=t;else u.encodings=Tp.getRtpEncodings({offerMediaObject:f});if(u.encodings.length>1&&("video/vp8"===u.codecs[0].mimeType.toLowerCase()||"video/h264"===u.codecs[0].mimeType.toLowerCase()))for(const e of u.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${h.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:f,reuseMid:i.reuseMid,offerRtpParameters:u,answerRtpParameters:l,codecOptions:r});const g={type:"answer",sdp:this._remoteSdp.getSdp()};return Dp.debug("send() | calling pc.setRemoteDescription() [answer:%o]",g),await this._pc.setRemoteDescription(g),this._mapMidTransceiver.set(m,s),{localId:m,rtpParameters:u,rtpSender:s.sender}}async stopSending(e){if(this.assertSendDirection(),Dp.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();Dp.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Dp.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Dp.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();Dp.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Dp.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Dp.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();Dp.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Dp.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Dp.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Dp.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(),Dp.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();Dp.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Dp.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Dp.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();Dp.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Dp.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};Dp.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Ip.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=bp.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),Dp.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()};Dp.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;Dp.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()};Dp.debug("receive() | calling pc.setRemoteDescription() [offer:%o]",n),await this._pc.setRemoteDescription(n);let i=await this._pc.createAnswer();const s=bp.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));Pp.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:bp.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),Dp.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){Dp.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()};Dp.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Dp.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){Dp.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()};Dp.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Dp.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){Dp.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()};Dp.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Dp.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};Dp.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()};Dp.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=bp.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}Dp.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=bp.parse(this._pc.localDescription.sdp));const r=Pp.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}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{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")}};assertNotClosed(){if(this._closed)throw new Sp.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')}}_p.Chrome74=Ap;var Op={};Object.defineProperty(Op,"__esModule",{value:!0}),Op.Firefox120=void 0;const Np=Ol,Mp=Ud,Lp=iu,xp=cu,Fp=zl,jp=Yl,Up=Jl,Vp=Ql,Bp=new Ld.Logger("Firefox120"),Wp={OS:16,MIS:2048};class Hp extends Mp.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"Firefox120",factory:e=>new Hp(e),getNativeRtpCapabilities:async()=>{Bp.debug("getNativeRtpCapabilities()");let e=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"});const 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){}e=void 0;const i=Np.parse(n.sdp);return Hp.getLocalRtpCapabilities(i)}catch(n){try{t.remove()}catch(e){}try{r.stop()}catch(e){}try{e?.close()}catch(e){}throw e=void 0,n}},getNativeSctpCapabilities:async()=>(Bp.debug("getNativeSctpCapabilities()"),{numStreams:Wp})}}static getLocalRtpCapabilities(e){const t=jp.extractRtpCapabilities({sdpObject:e});return xp.validateAndNormalizeRtpCapabilities(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),Bp.debug("constructor()"),this._direction=e,this._remoteSdp=new Vp.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,this._pc=new RTCPeerConnection({iceServers:s??[],iceTransportPolicy:o??"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",...a}),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(Bp.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"Firefox120"}close(){if(Bp.debug("close()"),!this._closed){this._closed=!0;try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){throw this.assertNotClosed(),new Lp.UnsupportedError("not supported")}async restartIce(e){if(this.assertNotClosed(),Bp.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});Bp.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};Bp.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};Bp.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();Bp.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(),Bp.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=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(s.sender);const o=await this._pc.createOffer();let a=Np.parse(o.sdp);a.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const c=Hp.getLocalRtpCapabilities(a),d=this._getSendExtendedRtpCapabilities(c),u=xp.getSendingRtpParameters(e.kind,d);u.codecs=xp.reduceCodecs(u.codecs,n);const l=xp.getSendingRemoteRtpParameters(e.kind,d);l.codecs=xp.reduceCodecs(l.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:a});const p=(0,Fp.parse)((t??[{}])[0].scalabilityMode);Bp.debug("send() | calling pc.setLocalDescription() [offer:%o]",o),await this._pc.setLocalDescription(o);const h=s.mid;u.mid=h,a=Np.parse(this._pc.localDescription.sdp);const f=a.media[a.media.length-1];if(u.rtcp.cname=jp.getCname({offerMediaObject:f}),t)if(1===t.length){const e=Up.getRtpEncodings({offerMediaObject:f});Object.assign(e[0],t[0]),u.encodings=e}else u.encodings=t;else u.encodings=Up.getRtpEncodings({offerMediaObject:f});if(u.encodings.length>1&&("video/vp8"===u.codecs[0].mimeType.toLowerCase()||"video/h264"===u.codecs[0].mimeType.toLowerCase()))for(const e of u.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${p.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:f,offerRtpParameters:u,answerRtpParameters:l,codecOptions:r});const m={type:"answer",sdp:this._remoteSdp.getSdp()};return Bp.debug("send() | calling pc.setRemoteDescription() [answer:%o]",m),await this._pc.setRemoteDescription(m),this._mapMidTransceiver.set(h,s),{localId:h,rtpParameters:u,rtpSender:s.sender}}async stopSending(e){if(this.assertSendDirection(),Bp.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();Bp.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Bp.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),Bp.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();Bp.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Bp.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),Bp.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();Bp.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};Bp.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?Bp.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):Bp.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(),Bp.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();Bp.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Bp.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),Bp.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();Bp.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};Bp.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};Bp.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%Wp.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=Np.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:t}),Bp.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()};Bp.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;Bp.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()};Bp.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=Np.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));jp.applyCodecParameters({offerRtpParameters:n,answerMediaObject:a}),i={type:"answer",sdp:Np.write(s)}}this._transportReady||await this.setupTransport({localDtlsRole:"client",localSdpObject:s}),Bp.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){Bp.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()};Bp.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Bp.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){Bp.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()};Bp.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Bp.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){Bp.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()};Bp.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();Bp.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};Bp.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()};Bp.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=Np.parse(t.sdp);await this.setupTransport({localDtlsRole:"client",localSdpObject:e})}Bp.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=Np.parse(this._pc.localDescription.sdp));const r=jp.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}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{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")}};assertNotClosed(){if(this._closed)throw new Lp.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')}}Op.Firefox120=Hp;var qp={};Object.defineProperty(qp,"__esModule",{value:!0}),qp.Safari12=void 0;const zp=Ol,Gp=Ud,Yp=cu,$p=iu,Jp=zl,Kp=Ql,Qp=Yl,Zp=Jl,Xp=Kl,eh=new Ld.Logger("Safari12"),th={OS:1024,MIS:1024};class rh extends Gp.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"Safari12",factory:e=>new rh(e),getNativeRtpCapabilities:async()=>{eh.debug("getNativeRtpCapabilities()");let 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){}e=void 0;const r=zp.parse(t.sdp);return rh.getLocalRtpCapabilities(r)}catch(t){try{e?.close()}catch(e){}throw e=void 0,t}},getNativeSctpCapabilities:async()=>(eh.debug("getNativeSctpCapabilities()"),{numStreams:th})}}static getLocalRtpCapabilities(e){const t=Qp.extractRtpCapabilities({sdpObject:e});return Yp.validateAndNormalizeRtpCapabilities(t),Xp.addNackSupportForOpus(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),eh.debug("constructor()"),this._direction=e,this._remoteSdp=new Kp.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,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}),this._pc.addEventListener("icegatheringstatechange",(()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)})),this._pc.addEventListener("icecandidateerror",(e=>{this.emit("@icecandidateerror",e)})),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(eh.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"Safari12"}close(){if(eh.debug("close()"),!this._closed){this._closed=!0;try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){this.assertNotClosed(),eh.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),eh.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});eh.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};eh.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};eh.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();eh.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(),eh.debug("send() [kind:%s, track.id:%s]",e.kind,e.id);const s=this._remoteSdp.getNextMediaSectionIdx(),o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream]});i&&i(o.sender);let a=await this._pc.createOffer(),c=zp.parse(a.sdp);c.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const d=rh.getLocalRtpCapabilities(c),u=this._getSendExtendedRtpCapabilities(d),l=Yp.getSendingRtpParameters(e.kind,u);l.codecs=Yp.reduceCodecs(l.codecs,n);const p=Yp.getSendingRemoteRtpParameters(e.kind,u);let h;p.codecs=Yp.reduceCodecs(p.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:c});const f=(0,Jp.parse)((t??[{}])[0].scalabilityMode);t&&t.length>1&&(eh.debug("send() | enabling legacy simulcast"),c=zp.parse(a.sdp),h=c.media[s.idx],Zp.addLegacySimulcast({offerMediaObject:h,numStreams:t.length}),a={type:"offer",sdp:zp.write(c)}),eh.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);const m=o.mid;if(l.mid=m,c=zp.parse(this._pc.localDescription.sdp),h=c.media[s.idx],l.rtcp.cname=Qp.getCname({offerMediaObject:h}),l.encodings=Zp.getRtpEncodings({offerMediaObject:h}),t)for(let e=0;e<l.encodings.length;++e)t[e]&&Object.assign(l.encodings[e],t[e]);if(l.encodings.length>1&&("video/vp8"===l.codecs[0].mimeType.toLowerCase()||"video/h264"===l.codecs[0].mimeType.toLowerCase()))for(const e of l.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${f.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:h,reuseMid:s.reuseMid,offerRtpParameters:l,answerRtpParameters:p,codecOptions:r});const g={type:"answer",sdp:this._remoteSdp.getSdp()};return eh.debug("send() | calling pc.setRemoteDescription() [answer:%o]",g),await this._pc.setRemoteDescription(g),this._mapMidTransceiver.set(m,o),{localId:m,rtpParameters:l,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;eh.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();eh.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};eh.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),eh.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();eh.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};eh.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),eh.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();eh.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};eh.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?eh.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):eh.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(),eh.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();eh.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};eh.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),eh.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();eh.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};eh.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};eh.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%th.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=zp.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),eh.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()};eh.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;eh.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()};eh.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=zp.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));Qp.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:zp.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),eh.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){eh.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()};eh.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();eh.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){eh.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()};eh.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();eh.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){eh.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()};eh.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();eh.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};eh.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()};eh.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=zp.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}eh.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=zp.parse(this._pc.localDescription.sdp));const r=Qp.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}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{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")}};assertNotClosed(){if(this._closed)throw new $p.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')}}qp.Safari12=rh;var nh={};Object.defineProperty(nh,"__esModule",{value:!0}),nh.ReactNative106=void 0;const ih=Ol,sh=Ud,oh=cu,ah=iu,ch=zl,dh=Ql,uh=Yl,lh=Jl,ph=Kl,hh=new Ld.Logger("ReactNative106"),fh={OS:1024,MIS:1024};class mh extends sh.EnhancedEventEmitter{_closed=!1;_direction;_remoteSdp;_getSendExtendedRtpCapabilities;_forcedLocalDtlsRole;_pc;_mapMidTransceiver=new Map;_sendStream=new MediaStream;_hasDataChannelMediaSection=!1;_nextSendSctpStreamId=0;_transportReady=!1;static createFactory(){return{name:"ReactNative106",factory:e=>new mh(e),getNativeRtpCapabilities:async()=>{hh.debug("getNativeRtpCapabilities()");let 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){}e=void 0;const r=ih.parse(t.sdp);return mh.getLocalRtpCapabilities(r)}catch(t){try{e?.close()}catch(e){}throw e=void 0,t}},getNativeSctpCapabilities:async()=>(hh.debug("getNativeSctpCapabilities()"),{numStreams:fh})}}static getLocalRtpCapabilities(e){const t=uh.extractRtpCapabilities({sdpObject:e});return oh.validateAndNormalizeRtpCapabilities(t),ph.addNackSupportForOpus(t),t}constructor({direction:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,getSendExtendedRtpCapabilities:c}){super(),hh.debug("constructor()"),this._direction=e,this._remoteSdp=new dh.RemoteSdp({iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i}),this._getSendExtendedRtpCapabilities=c,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}),this._pc.addEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.addEventListener("icecandidateerror",this.onIceCandidateError),this._pc.connectionState?this._pc.addEventListener("connectionstatechange",this.onConnectionStateChange):(hh.warn("run() | pc.connectionState not supported, using pc.iceConnectionState"),this._pc.addEventListener("iceconnectionstatechange",this.onIceConnectionStateChange))}get name(){return"ReactNative106"}close(){if(hh.debug("close()"),!this._closed){this._closed=!0,this._sendStream.release(!1);try{this._pc.close()}catch(e){}this._pc.removeEventListener("icegatheringstatechange",this.onIceGatheringStateChange),this._pc.removeEventListener("icecandidateerror",this.onIceCandidateError),this._pc.removeEventListener("connectionstatechange",this.onConnectionStateChange),this._pc.removeEventListener("iceconnectionstatechange",this.onIceConnectionStateChange),this.emit("@close"),super.close()}}async updateIceServers(e){this.assertNotClosed(),hh.debug("updateIceServers()");const t=this._pc.getConfiguration();t.iceServers=e,this._pc.setConfiguration(t)}async restartIce(e){if(this.assertNotClosed(),hh.debug("restartIce()"),this._remoteSdp.updateIceParameters(e),this._transportReady)if("send"===this._direction){const e=await this._pc.createOffer({iceRestart:!0});hh.debug("restartIce() | calling pc.setLocalDescription() [offer:%o]",e),await this._pc.setLocalDescription(e);const t={type:"answer",sdp:this._remoteSdp.getSdp()};hh.debug("restartIce() | calling pc.setRemoteDescription() [answer:%o]",t),await this._pc.setRemoteDescription(t)}else{const e={type:"offer",sdp:this._remoteSdp.getSdp()};hh.debug("restartIce() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();hh.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(),hh.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=this._remoteSdp.getNextMediaSectionIdx(),o=this._pc.addTransceiver(e,{direction:"sendonly",streams:[this._sendStream],sendEncodings:t});i&&i(o.sender);let a=await this._pc.createOffer(),c=ih.parse(a.sdp);c.extmapAllowMixed&&this._remoteSdp.setSessionExtmapAllowMixed();const d=mh.getLocalRtpCapabilities(c),u=this._getSendExtendedRtpCapabilities(d),l=oh.getSendingRtpParameters(e.kind,u);l.codecs=oh.reduceCodecs(l.codecs,n);const p=oh.getSendingRemoteRtpParameters(e.kind,u);p.codecs=oh.reduceCodecs(p.codecs,n),this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:c});let h=!1;const f=(0,ch.parse)((t??[{}])[0].scalabilityMode);let m;t&&1===t.length&&f.spatialLayers>1&&"video/vp9"===l.codecs[0].mimeType.toLowerCase()&&(hh.debug("send() | enabling legacy simulcast for VP9 SVC"),h=!0,c=ih.parse(a.sdp),m=c.media[s.idx],lh.addLegacySimulcast({offerMediaObject:m,numStreams:f.spatialLayers}),a={type:"offer",sdp:ih.write(c)}),hh.debug("send() | calling pc.setLocalDescription() [offer:%o]",a),await this._pc.setLocalDescription(a);let g=o.mid??void 0;if(g||hh.warn("send() | missing transceiver.mid (bug in react-native-webrtc, using a workaround"),l.mid=g,c=ih.parse(this._pc.localDescription.sdp),m=c.media[s.idx],l.rtcp.cname=uh.getCname({offerMediaObject:m}),t)if(1===t.length){let e=lh.getRtpEncodings({offerMediaObject:m});Object.assign(e[0],t[0]),h&&(e=[e[0]]),l.encodings=e}else l.encodings=t;else l.encodings=lh.getRtpEncodings({offerMediaObject:m});if(l.encodings.length>1&&("video/vp8"===l.codecs[0].mimeType.toLowerCase()||"video/h264"===l.codecs[0].mimeType.toLowerCase()))for(const e of l.encodings)e.scalabilityMode?e.scalabilityMode=`L1T${f.temporalLayers}`:e.scalabilityMode="L1T3";this._remoteSdp.send({offerMediaObject:m,reuseMid:s.reuseMid,offerRtpParameters:l,answerRtpParameters:p,codecOptions:r});const v={type:"answer",sdp:this._remoteSdp.getSdp()};return hh.debug("send() | calling pc.setRemoteDescription() [answer:%o]",v),await this._pc.setRemoteDescription(v),g||(g=o.mid,l.mid=g),this._mapMidTransceiver.set(g,o),{localId:g,rtpParameters:l,rtpSender:o.sender}}async stopSending(e){if(this.assertSendDirection(),this._closed)return;hh.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();hh.debug("stopSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};hh.debug("stopSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n),this._mapMidTransceiver.delete(e)}async pauseSending(e){this.assertNotClosed(),this.assertSendDirection(),hh.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();hh.debug("pauseSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};hh.debug("pauseSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async resumeSending(e){this.assertNotClosed(),this.assertSendDirection(),hh.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();hh.debug("resumeSending() | calling pc.setLocalDescription() [offer:%o]",r),await this._pc.setLocalDescription(r);const n={type:"answer",sdp:this._remoteSdp.getSdp()};hh.debug("resumeSending() | calling pc.setRemoteDescription() [answer:%o]",n),await this._pc.setRemoteDescription(n)}async replaceTrack(e,t){this.assertNotClosed(),this.assertSendDirection(),t?hh.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):hh.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(),hh.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();hh.debug("setMaxSpatialLayer() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};hh.debug("setMaxSpatialLayer() | calling pc.setRemoteDescription() [answer:%o]",s),await this._pc.setRemoteDescription(s)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),this.assertSendDirection(),hh.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();hh.debug("setRtpEncodingParameters() | calling pc.setLocalDescription() [offer:%o]",i),await this._pc.setLocalDescription(i);const s={type:"answer",sdp:this._remoteSdp.getSdp()};hh.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};hh.debug("sendDataChannel() [options:%o]",s);const o=this._pc.createDataChannel(n,s);if(this._nextSendSctpStreamId=++this._nextSendSctpStreamId%fh.MIS,!this._hasDataChannelMediaSection){const e=await this._pc.createOffer(),t=ih.parse(e.sdp),r=t.media.find((e=>"application"===e.type));this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:t}),hh.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()};hh.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;hh.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()};hh.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=ih.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));uh.applyCodecParameters({offerRtpParameters:n,answerMediaObject:o})}i={type:"answer",sdp:ih.write(s)},this._transportReady||await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:s}),hh.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){hh.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()};hh.debug("stopReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();hh.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){hh.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()};hh.debug("pauseReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();hh.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){hh.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()};hh.debug("resumeReceiving() | calling pc.setRemoteDescription() [offer:%o]",t),await this._pc.setRemoteDescription(t);const r=await this._pc.createAnswer();hh.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};hh.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()};hh.debug("receiveDataChannel() | calling pc.setRemoteDescription() [offer:%o]",e),await this._pc.setRemoteDescription(e);const t=await this._pc.createAnswer();if(!this._transportReady){const e=ih.parse(t.sdp);await this.setupTransport({localDtlsRole:this._forcedLocalDtlsRole??"client",localSdpObject:e})}hh.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=ih.parse(this._pc.localDescription.sdp));const r=uh.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}onIceGatheringStateChange=()=>{this.emit("@icegatheringstatechange",this._pc.iceGatheringState)};onIceCandidateError=e=>{this.emit("@icecandidateerror",e)};onConnectionStateChange=()=>{this.emit("@connectionstatechange",this._pc.connectionState)};onIceConnectionStateChange=()=>{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")}};assertNotClosed(){if(this._closed)throw new ah.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')}}nh.ReactNative106=mh,Object.defineProperty(wd,"__esModule",{value:!0}),wd.Device=void 0,wd.detectDevice=kh,wd.detectDeviceAsync=Dh;const gh=kd,vh=Ud,yh=iu,_h=au,bh=cu,Eh=Hu,wh=Al,Sh=_p,Ch=Op,Ph=qp,Th=nh,Rh=new Ld.Logger("Device");function kh(e){Rh.debug("detectDevice() [userAgent:%s]",e),e||"object"!=typeof navigator||(e=navigator.userAgent);return Ah(new gh.default(e))}async function Dh(e){Rh.debug("detectDeviceAsync() [userAgent:%s]",e),e||"object"!=typeof navigator||(e=navigator.userAgent);return Ah(new gh.default(e))}class Ih{_handlerFactory;_handlerName;_loaded=!1;_getSendExtendedRtpCapabilities;_recvRtpCapabilities;_canProduceByKind={audio:!1,video:!1};_sctpCapabilities;_observer=new vh.EnhancedEventEmitter;static async factory({handlerName:e,handlerFactory:t}={}){if(Rh.debug("factory()"),e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(!e&&!t&&!(e=await Dh()))throw new yh.UnsupportedError("device not supported");return new Ih({handlerName:e,handlerFactory:t})}constructor({handlerName:e,handlerFactory:t}={}){if(Rh.debug("constructor()"),e&&t)throw new TypeError("just one of handlerName or handlerInterface can be given");if(t)this._handlerFactory=t;else{if(e)Rh.debug("constructor() | handler given: %s",e);else{if(!(e=kh()))throw new yh.UnsupportedError("device not supported");Rh.debug("constructor() | detected handler: %s",e)}switch(e){case"Chrome111":this._handlerFactory=wh.Chrome111.createFactory();break;case"Chrome74":this._handlerFactory=Sh.Chrome74.createFactory();break;case"Firefox120":this._handlerFactory=Ch.Firefox120.createFactory();break;case"Safari12":this._handlerFactory=Ph.Safari12.createFactory();break;case"ReactNative106":this._handlerFactory=Th.ReactNative106.createFactory();break;default:throw new TypeError(`unknown handlerName "${e}"`)}}this._handlerName=this._handlerFactory.name}get handlerName(){return this._handlerName}get loaded(){return this._loaded}get rtpCapabilities(){if(!this._loaded)throw new yh.InvalidStateError("not loaded");return this._recvRtpCapabilities}get sctpCapabilities(){if(!this._loaded)throw new yh.InvalidStateError("not loaded");return this._sctpCapabilities}get observer(){return this._observer}async load({routerRtpCapabilities:e,preferLocalCodecsOrder:t=!1}){if(Rh.debug("load() [routerRtpCapabilities:%o]",e),this._loaded)throw new yh.InvalidStateError("already loaded");const r=_h.clone(e);bh.validateAndNormalizeRtpCapabilities(r);const{getNativeRtpCapabilities:n,getNativeSctpCapabilities:i}=this._handlerFactory,s=_h.clone(await n());bh.validateAndNormalizeRtpCapabilities(s),Rh.debug("load() | got native RTP capabilities:%o",s),this._getSendExtendedRtpCapabilities=e=>_h.clone(bh.getExtendedRtpCapabilities(e,r,t));const o=bh.getExtendedRtpCapabilities(s,r,!1);this._recvRtpCapabilities=bh.getRecvRtpCapabilities(o),bh.validateAndNormalizeRtpCapabilities(this._recvRtpCapabilities),Rh.debug("load() | got receiving RTP capabilities:%o",this._recvRtpCapabilities),this._canProduceByKind.audio=bh.canSend("audio",this._recvRtpCapabilities),this._canProduceByKind.video=bh.canSend("video",this._recvRtpCapabilities),this._sctpCapabilities=await i(),bh.validateSctpCapabilities(this._sctpCapabilities),Rh.debug("load() | got native SCTP capabilities:%o",this._sctpCapabilities),Rh.debug("load() succeeded"),this._loaded=!0}canProduce(e){if(!this._loaded)throw new yh.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,appData:c}){return Rh.debug("createSendTransport()"),this.createTransport({direction:"send",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,appData:c})}createRecvTransport({id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,appData:c}){return Rh.debug("createRecvTransport()"),this.createTransport({direction:"recv",id:e,iceParameters:t,iceCandidates:r,dtlsParameters:n,sctpParameters:i,iceServers:s,iceTransportPolicy:o,additionalSettings:a,appData:c})}createTransport({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,appData:d}){if(!this._loaded)throw new yh.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(d&&"object"!=typeof d)throw new TypeError("if given, appData must be an object");const u=new Eh.Transport({direction:e,id:t,iceParameters:r,iceCandidates:n,dtlsParameters:i,sctpParameters:s,iceServers:o,iceTransportPolicy:a,additionalSettings:c,appData:d,handlerFactory:this._handlerFactory,getSendExtendedRtpCapabilities:this._getSendExtendedRtpCapabilities,recvRtpCapabilities:this._recvRtpCapabilities,canProduceByKind:this._canProduceByKind});return this._observer.safeEmit("newtransport",u),u}}function Ah(e){if("object"==typeof navigator&&"ReactNative"===navigator.product)return Rh.debug("detectDeviceImpl() | React-Native detected"),"undefined"==typeof RTCPeerConnection||"undefined"==typeof RTCRtpTransceiver?void Rh.warn("detectDeviceImpl() | unsupported react-native-webrtc without RTCPeerConnection or RTCRtpTransceiver, forgot to call registerGlobals() on it?"):"ReactNative106";{const t=e.parseUserAgent(),r=/^\d+/.exec(t?.shortVersion??"0"),n=parseInt(r?.[0]??"0",10),i=t.platform===gh.KnownPlatforms.iphone||t.platform===gh.KnownPlatforms.ipad||t.platform===gh.KnownPlatforms.mac&&(t.isMobile||t.isTablet||"object"==typeof navigator&&navigator?.maxTouchPoints>=2),s=t.isChrome,o=t.isFireFox,a=t.isSafari,c=t.isEdge,d=t.isDesktop&&t.name===gh.KnownBrowsers.electron,u=t.isWebkit,l={browserMajorVersion:n,isIOS:i,isChrome:s,isFirefox:o,isSafari:a,isElectron:d,isWebkit:u};if(Rh.debug("detectDeviceImpl() | detected browser [userAgent:%s, parsed:%o, result:%o]",t.userAgent,t,l),(s||c)&&!i&&n>=111)return"Chrome111";if(s&&!i&&n>=74||c&&!i&&n>=88)return"Chrome74";if(d)return"Chrome111";if(o&&!i&&n>=120)return"Firefox120";if(a&&n>=12&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(i&&"undefined"!=typeof RTCRtpTransceiver&&RTCRtpTransceiver.prototype.hasOwnProperty("currentDirection"))return"Safari12";if(u){const t=e.userAgent?.match(/(?:(?:Chrome|Chromium))[ /](\w+)/i);if(t){return Number(t[1])>=111?"Chrome111":"Chrome74"}return"Chrome111"}return void Rh.warn("detectDeviceImpl() | browser not supported [userAgent:%s, parsed:%o, result:%o]",t.userAgent,t,l)}}wd.Device=Ih;var Oh={},Nh={},Mh={},Lh={};Object.defineProperty(Lh,"__esModule",{value:!0}),Lh.default="ffffffff-ffff-ffff-ffff-ffffffffffff";var xh={};Object.defineProperty(xh,"__esModule",{value:!0}),xh.default="00000000-0000-0000-0000-000000000000";var Fh={},jh={},Uh={};Object.defineProperty(Uh,"__esModule",{value:!0}),Uh.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i,Object.defineProperty(jh,"__esModule",{value:!0});const Vh=Uh;jh.default=function(e){return"string"==typeof e&&Vh.default.test(e)},Object.defineProperty(Fh,"__esModule",{value:!0});const Bh=jh;Fh.default=function(e){if(!(0,Bh.default)(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,255&t,(t=parseInt(e.slice(9,13),16))>>>8,255&t,(t=parseInt(e.slice(14,18),16))>>>8,255&t,(t=parseInt(e.slice(19,23),16))>>>8,255&t,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,255&t)};var Wh={};Object.defineProperty(Wh,"__esModule",{value:!0}),Wh.unsafeStringify=void 0;const Hh=jh,qh=[];for(let e=0;e<256;++e)qh.push((e+256).toString(16).slice(1));function zh(e,t=0){return(qh[e[t+0]]+qh[e[t+1]]+qh[e[t+2]]+qh[e[t+3]]+"-"+qh[e[t+4]]+qh[e[t+5]]+"-"+qh[e[t+6]]+qh[e[t+7]]+"-"+qh[e[t+8]]+qh[e[t+9]]+"-"+qh[e[t+10]]+qh[e[t+11]]+qh[e[t+12]]+qh[e[t+13]]+qh[e[t+14]]+qh[e[t+15]]).toLowerCase()}Wh.unsafeStringify=zh,Wh.default=function(e,t=0){const r=zh(e,t);if(!(0,Hh.default)(r))throw TypeError("Stringified UUID is invalid");return r};var Gh={},Yh={};let $h;Object.defineProperty(Yh,"__esModule",{value:!0});const Jh=new Uint8Array(16);Yh.default=function(){if(!$h){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");$h=crypto.getRandomValues.bind(crypto)}return $h(Jh)},Object.defineProperty(Gh,"__esModule",{value:!0}),Gh.updateV1State=void 0;const Kh=Yh,Qh=Wh,Zh={};function Xh(e,t,r){return e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0),e.node||(e.node=r.slice(10,16),e.node[0]|=1,e.clockseq=16383&(r[8]<<8|r[9])),e.msecs=t,e}function ef(e,t,r,n,i,s,o=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(s){if(o<0||o+16>s.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`)}else s=new Uint8Array(16),o=0;t??=Date.now(),r??=0,n??=16383&(e[8]<<8|e[9]),i??=e.slice(10,16);const a=(1e4*(268435455&(t+=122192928e5))+r)%4294967296;s[o++]=a>>>24&255,s[o++]=a>>>16&255,s[o++]=a>>>8&255,s[o++]=255&a;const c=t/4294967296*1e4&268435455;s[o++]=c>>>8&255,s[o++]=255&c,s[o++]=c>>>24&15|16,s[o++]=c>>>16&255,s[o++]=n>>>8|128,s[o++]=255&n;for(let e=0;e<6;++e)s[o++]=i[e];return s}Gh.updateV1State=Xh,Gh.default=function(e,t,r){let n;const i=e?._v6??!1;if(e){const t=Object.keys(e);1===t.length&&"_v6"===t[0]&&(e=void 0)}if(e)n=ef(e.random??e.rng?.()??(0,Kh.default)(),e.msecs,e.nsecs,e.clockseq,e.node,t,r);else{const e=Date.now(),s=(0,Kh.default)();Xh(Zh,e,s),n=ef(s,Zh.msecs,Zh.nsecs,i?void 0:Zh.clockseq,i?void 0:Zh.node,t,r)}return t??(0,Qh.unsafeStringify)(n)};var tf={};Object.defineProperty(tf,"__esModule",{value:!0});const rf=Fh,nf=Wh;tf.default=function(e){const t=function(e){return Uint8Array.of((15&e[6])<<4|e[7]>>4&15,(15&e[7])<<4|(240&e[4])>>4,(15&e[4])<<4|(240&e[5])>>4,(15&e[5])<<4|(240&e[0])>>4,(15&e[0])<<4|(240&e[1])>>4,(15&e[1])<<4|(240&e[2])>>4,96|15&e[2],e[3],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}("string"==typeof e?(0,rf.default)(e):e);return"string"==typeof e?(0,nf.unsafeStringify)(t):t};var sf={},of={};function af(e){return 14+(e+64>>>9<<4)+1}function cf(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function df(e,t,r,n,i,s){return cf((o=cf(cf(t,e),cf(n,s)))<<(a=i)|o>>>32-a,r);var o,a}function uf(e,t,r,n,i,s,o){return df(t&r|~t&n,e,t,i,s,o)}function lf(e,t,r,n,i,s,o){return df(t&n|r&~n,e,t,i,s,o)}function pf(e,t,r,n,i,s,o){return df(t^r^n,e,t,i,s,o)}function hf(e,t,r,n,i,s,o){return df(r^(t|~n),e,t,i,s,o)}Object.defineProperty(of,"__esModule",{value:!0}),of.default=function(e){const t=function(e){if(0===e.length)return new Uint32Array;const t=new Uint32Array(af(8*e.length)).fill(0);for(let r=0;r<e.length;r++)t[r>>2]|=(255&e[r])<<r%4*8;return t}(e),r=function(e,t){const r=new Uint32Array(af(t)).fill(0);r.set(e),r[t>>5]|=128<<t%32,r[r.length-1]=t,e=r;let n=1732584193,i=-271733879,s=-1732584194,o=271733878;for(let t=0;t<e.length;t+=16){const r=n,a=i,c=s,d=o;n=uf(n,i,s,o,e[t],7,-680876936),o=uf(o,n,i,s,e[t+1],12,-389564586),s=uf(s,o,n,i,e[t+2],17,606105819),i=uf(i,s,o,n,e[t+3],22,-1044525330),n=uf(n,i,s,o,e[t+4],7,-176418897),o=uf(o,n,i,s,e[t+5],12,1200080426),s=uf(s,o,n,i,e[t+6],17,-1473231341),i=uf(i,s,o,n,e[t+7],22,-45705983),n=uf(n,i,s,o,e[t+8],7,1770035416),o=uf(o,n,i,s,e[t+9],12,-1958414417),s=uf(s,o,n,i,e[t+10],17,-42063),i=uf(i,s,o,n,e[t+11],22,-1990404162),n=uf(n,i,s,o,e[t+12],7,1804603682),o=uf(o,n,i,s,e[t+13],12,-40341101),s=uf(s,o,n,i,e[t+14],17,-1502002290),i=uf(i,s,o,n,e[t+15],22,1236535329),n=lf(n,i,s,o,e[t+1],5,-165796510),o=lf(o,n,i,s,e[t+6],9,-1069501632),s=lf(s,o,n,i,e[t+11],14,643717713),i=lf(i,s,o,n,e[t],20,-373897302),n=lf(n,i,s,o,e[t+5],5,-701558691),o=lf(o,n,i,s,e[t+10],9,38016083),s=lf(s,o,n,i,e[t+15],14,-660478335),i=lf(i,s,o,n,e[t+4],20,-405537848),n=lf(n,i,s,o,e[t+9],5,568446438),o=lf(o,n,i,s,e[t+14],9,-1019803690),s=lf(s,o,n,i,e[t+3],14,-187363961),i=lf(i,s,o,n,e[t+8],20,1163531501),n=lf(n,i,s,o,e[t+13],5,-1444681467),o=lf(o,n,i,s,e[t+2],9,-51403784),s=lf(s,o,n,i,e[t+7],14,1735328473),i=lf(i,s,o,n,e[t+12],20,-1926607734),n=pf(n,i,s,o,e[t+5],4,-378558),o=pf(o,n,i,s,e[t+8],11,-2022574463),s=pf(s,o,n,i,e[t+11],16,1839030562),i=pf(i,s,o,n,e[t+14],23,-35309556),n=pf(n,i,s,o,e[t+1],4,-1530992060),o=pf(o,n,i,s,e[t+4],11,1272893353),s=pf(s,o,n,i,e[t+7],16,-155497632),i=pf(i,s,o,n,e[t+10],23,-1094730640),n=pf(n,i,s,o,e[t+13],4,681279174),o=pf(o,n,i,s,e[t],11,-358537222),s=pf(s,o,n,i,e[t+3],16,-722521979),i=pf(i,s,o,n,e[t+6],23,76029189),n=pf(n,i,s,o,e[t+9],4,-640364487),o=pf(o,n,i,s,e[t+12],11,-421815835),s=pf(s,o,n,i,e[t+15],16,530742520),i=pf(i,s,o,n,e[t+2],23,-995338651),n=hf(n,i,s,o,e[t],6,-198630844),o=hf(o,n,i,s,e[t+7],10,1126891415),s=hf(s,o,n,i,e[t+14],15,-1416354905),i=hf(i,s,o,n,e[t+5],21,-57434055),n=hf(n,i,s,o,e[t+12],6,1700485571),o=hf(o,n,i,s,e[t+3],10,-1894986606),s=hf(s,o,n,i,e[t+10],15,-1051523),i=hf(i,s,o,n,e[t+1],21,-2054922799),n=hf(n,i,s,o,e[t+8],6,1873313359),o=hf(o,n,i,s,e[t+15],10,-30611744),s=hf(s,o,n,i,e[t+6],15,-1560198380),i=hf(i,s,o,n,e[t+13],21,1309151649),n=hf(n,i,s,o,e[t+4],6,-145523070),o=hf(o,n,i,s,e[t+11],10,-1120210379),s=hf(s,o,n,i,e[t+2],15,718787259),i=hf(i,s,o,n,e[t+9],21,-343485551),n=cf(n,r),i=cf(i,a),s=cf(s,c),o=cf(o,d)}return Uint32Array.of(n,i,s,o)}(t,8*e.length);return function(e){const t=new Uint8Array(4*e.length);for(let r=0;r<4*e.length;r++)t[r]=e[r>>2]>>>r%4*8&255;return t}(r)};var ff={};Object.defineProperty(ff,"__esModule",{value:!0}),ff.URL=ff.DNS=ff.stringToBytes=void 0;const mf=Fh,gf=Wh;function vf(e){e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}ff.stringToBytes=vf,ff.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",ff.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",ff.default=function(e,t,r,n,i,s){const o="string"==typeof r?vf(r):r,a="string"==typeof n?(0,mf.default)(n):n;if("string"==typeof n&&(n=(0,mf.default)(n)),16!==n?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(a),c.set(o,a.length),c=t(c),c[6]=15&c[6]|e,c[8]=63&c[8]|128,i){s=s||0;for(let e=0;e<16;++e)i[s+e]=c[e];return i}return(0,gf.unsafeStringify)(c)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.URL=e.DNS=void 0;const t=of,r=ff;var n=ff;function i(e,n,i,s){return(0,r.default)(48,t.default,e,n,i,s)}Object.defineProperty(e,"DNS",{enumerable:!0,get:function(){return n.DNS}}),Object.defineProperty(e,"URL",{enumerable:!0,get:function(){return n.URL}}),i.DNS=r.DNS,i.URL=r.URL,e.default=i}(sf);var yf={},_f={};Object.defineProperty(_f,"__esModule",{value:!0});const bf="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);_f.default={randomUUID:bf},Object.defineProperty(yf,"__esModule",{value:!0});const Ef=_f,wf=Yh,Sf=Wh;yf.default=function(e,t,r){if(Ef.default.randomUUID&&!t&&!e)return Ef.default.randomUUID();const n=(e=e||{}).random??e.rng?.()??(0,wf.default)();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((r=r||0)<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=n[e];return t}return(0,Sf.unsafeStringify)(n)};var Cf={},Pf={};function Tf(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function Rf(e,t){return e<<t|e>>>32-t}Object.defineProperty(Pf,"__esModule",{value:!0}),Pf.default=function(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128;const i=(e=n).length/4+2,s=Math.ceil(i/16),o=new Array(s);for(let t=0;t<s;++t){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=e[64*t+4*n]<<24|e[64*t+4*n+1]<<16|e[64*t+4*n+2]<<8|e[64*t+4*n+3];o[t]=r}o[s-1][14]=8*(e.length-1)/Math.pow(2,32),o[s-1][14]=Math.floor(o[s-1][14]),o[s-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<s;++e){const n=new Uint32Array(80);for(let t=0;t<16;++t)n[t]=o[e][t];for(let e=16;e<80;++e)n[e]=Rf(n[e-3]^n[e-8]^n[e-14]^n[e-16],1);let i=r[0],s=r[1],a=r[2],c=r[3],d=r[4];for(let e=0;e<80;++e){const r=Math.floor(e/20),o=Rf(i,5)+Tf(r,s,a,c)+d+t[r]+n[e]>>>0;d=c,c=a,a=Rf(s,30)>>>0,s=i,i=o}r[0]=r[0]+i>>>0,r[1]=r[1]+s>>>0,r[2]=r[2]+a>>>0,r[3]=r[3]+c>>>0,r[4]=r[4]+d>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.URL=e.DNS=void 0;const t=Pf,r=ff;var n=ff;function i(e,n,i,s){return(0,r.default)(80,t.default,e,n,i,s)}Object.defineProperty(e,"DNS",{enumerable:!0,get:function(){return n.DNS}}),Object.defineProperty(e,"URL",{enumerable:!0,get:function(){return n.URL}}),i.DNS=r.DNS,i.URL=r.URL,e.default=i}(Cf);var kf={};Object.defineProperty(kf,"__esModule",{value:!0});const Df=Wh,If=Gh,Af=tf;kf.default=function(e,t,r){e??={},r??=0;let n=(0,If.default)({...e,_v6:!0},new Uint8Array(16));if(n=(0,Af.default)(n),t){for(let e=0;e<16;e++)t[r+e]=n[e];return t}return(0,Df.unsafeStringify)(n)};var Of={};Object.defineProperty(Of,"__esModule",{value:!0});const Nf=Fh,Mf=Wh;Of.default=function(e){const t=function(e){return Uint8Array.of((15&e[3])<<4|e[4]>>4&15,(15&e[4])<<4|(240&e[5])>>4,(15&e[5])<<4|15&e[6],e[7],(15&e[1])<<4|(240&e[2])>>4,(15&e[2])<<4|(240&e[3])>>4,16|(240&e[0])>>4,(15&e[0])<<4|(240&e[1])>>4,e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}("string"==typeof e?(0,Nf.default)(e):e);return"string"==typeof e?(0,Mf.unsafeStringify)(t):t};var Lf={};Object.defineProperty(Lf,"__esModule",{value:!0}),Lf.updateV7State=void 0;const xf=Yh,Ff=Wh,jf={};function Uf(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,0===e.seq&&e.msecs++),e}function Vf(e,t,r,n,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(n){if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`)}else n=new Uint8Array(16),i=0;return t??=Date.now(),r??=127*e[6]<<24|e[7]<<16|e[8]<<8|e[9],n[i++]=t/1099511627776&255,n[i++]=t/4294967296&255,n[i++]=t/16777216&255,n[i++]=t/65536&255,n[i++]=t/256&255,n[i++]=255&t,n[i++]=112|r>>>28&15,n[i++]=r>>>20&255,n[i++]=128|r>>>14&63,n[i++]=r>>>6&255,n[i++]=r<<2&255|3&e[10],n[i++]=e[11],n[i++]=e[12],n[i++]=e[13],n[i++]=e[14],n[i++]=e[15],n}Lf.updateV7State=Uf,Lf.default=function(e,t,r){let n;if(e)n=Vf(e.random??e.rng?.()??(0,xf.default)(),e.msecs,e.seq,t,r);else{const e=Date.now(),i=(0,xf.default)();Uf(jf,e,i),n=Vf(i,jf.msecs,jf.seq,t,r)}return t??(0,Ff.unsafeStringify)(n)};var Bf={};Object.defineProperty(Bf,"__esModule",{value:!0});const Wf=jh;Bf.default=function(e){if(!(0,Wf.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.version=e.validate=e.v7=e.v6ToV1=e.v6=e.v5=e.v4=e.v3=e.v1ToV6=e.v1=e.stringify=e.parse=e.NIL=e.MAX=void 0;var t=Lh;Object.defineProperty(e,"MAX",{enumerable:!0,get:function(){return t.default}});var r=xh;Object.defineProperty(e,"NIL",{enumerable:!0,get:function(){return r.default}});var n=Fh;Object.defineProperty(e,"parse",{enumerable:!0,get:function(){return n.default}});var i=Wh;Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return i.default}});var s=Gh;Object.defineProperty(e,"v1",{enumerable:!0,get:function(){return s.default}});var o=tf;Object.defineProperty(e,"v1ToV6",{enumerable:!0,get:function(){return o.default}});var a=sf;Object.defineProperty(e,"v3",{enumerable:!0,get:function(){return a.default}});var c=yf;Object.defineProperty(e,"v4",{enumerable:!0,get:function(){return c.default}});var d=Cf;Object.defineProperty(e,"v5",{enumerable:!0,get:function(){return d.default}});var u=kf;Object.defineProperty(e,"v6",{enumerable:!0,get:function(){return u.default}});var l=Of;Object.defineProperty(e,"v6ToV1",{enumerable:!0,get:function(){return l.default}});var p=Lf;Object.defineProperty(e,"v7",{enumerable:!0,get:function(){return p.default}});var h=jh;Object.defineProperty(e,"validate",{enumerable:!0,get:function(){return h.default}});var f=Bf;Object.defineProperty(e,"version",{enumerable:!0,get:function(){return f.default}})}(Mh);var Hf={};Object.defineProperty(Hf,"__esModule",{value:!0}),Hf.FakeEventTarget=void 0;Hf.FakeEventTarget=class{listeners={};addEventListener(e,t,r){t&&(this.listeners[e]??=[],this.listeners[e].push({callback:"function"==typeof t?t:t.handleEvent,once:"object"==typeof r&&!0===r.once}))}removeEventListener(e,t,r){this.listeners[e]&&t&&(this.listeners[e]=this.listeners[e].filter((e=>e.callback!==("function"==typeof t?t:t.handleEvent))))}dispatchEvent(e){if(!e||"string"!=typeof e.type)throw new Error("invalid event object");const t=this.listeners[e.type];if(!t)return!0;for(const r of[...t]){try{r.callback.call(this,e)}catch(e){setTimeout((()=>{throw e}),0)}r.once&&this.removeEventListener(e.type,r.callback)}return!e.defaultPrevented}};var qf={};Object.defineProperty(qf,"__esModule",{value:!0}),qf.FakeEvent=void 0;qf.FakeEvent=class{NONE=0;CAPTURING_PHASE=1;AT_TARGET=2;BUBBLING_PHASE=3;type;bubbles;cancelable;defaultPrevented=!1;composed=!1;currentTarget=null;eventPhase=l.NONE;isTrusted=!0;target=null;timeStamp=0;cancelBubble=!1;returnValue=!0;srcElement=null;constructor(e,t={}){this.type=e,this.bubbles=t.bubbles??!1,this.cancelable=t.cancelable??!1}preventDefault(){this.cancelable&&(this.defaultPrevented=!0)}stopPropagation(){}stopImmediatePropagation(){}composedPath(){return[]}initEvent(e,t,r){}};var zf={};Object.defineProperty(zf,"__esModule",{value:!0}),zf.clone=function(e){return void 0===e?void 0:Number.isNaN(e)?NaN:"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))},Object.defineProperty(Nh,"__esModule",{value:!0}),Nh.FakeMediaStreamTrack=void 0;const Gf=Mh,Yf=Hf,$f=qf,Jf=zf;class Kf extends Yf.FakeEventTarget{#b;#E;#w;#S;#C;#P;#T;#R;#k;#D;#I;#A=null;#O=null;#N=null;#M=null;#L=null;constructor({kind:e,id:t,label:r,contentHint:n,enabled:i,muted:s,readyState:o,capabilities:a,constraints:c,settings:d,data:u}){super(),this.#b=t??(0,Gf.v4)(),this.#E=e,this.#w=r??"",this.#T=n??"",this.#C=i??!0,this.#P=s??!1,this.#S=o??"live",this.#R=a??{},this.#k=c??{},this.#D=d??{},this.#I=u??{}}get id(){return this.#b}get kind(){return this.#E}get label(){return this.#w}get contentHint(){return this.#T}set contentHint(e){this.#T=e}get enabled(){return this.#C}set enabled(e){const t=this.#C!==e;this.#C=e,t&&this.dispatchEvent(new $f.FakeEvent("enabledchange"))}get muted(){return this.#P}get readyState(){return this.#S}get data(){return this.#I}set data(e){this.#I=e}get onmute(){return this.#A}set onmute(e){this.#A&&this.removeEventListener("mute",this.#A),this.#A=e,e&&this.addEventListener("mute",e)}get onunmute(){return this.#O}set onunmute(e){this.#O&&this.removeEventListener("unmute",this.#O),this.#O=e,e&&this.addEventListener("unmute",e)}get onended(){return this.#N}set onended(e){this.#N&&this.removeEventListener("ended",this.#N),this.#N=e,e&&this.addEventListener("ended",e)}get onenabledchange(){return this.#M}set onenabledchange(e){this.#M&&this.removeEventListener("enabledchange",this.#M),this.#M=e,e&&this.addEventListener("enabledchange",e)}get onstopped(){return this.#L}set onstopped(e){this.#L&&this.removeEventListener("stopped",this.#L),this.#L=e,e&&this.addEventListener("stopped",e)}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t,r){super.removeEventListener(e,t,r)}stop(){"ended"!==this.#S&&(this.#S="ended",this.dispatchEvent(new $f.FakeEvent("stopped")))}clone({id:e,data:t}={}){return new Kf({id:e??(0,Gf.v4)(),kind:this.#E,label:this.#w,contentHint:this.#T,enabled:this.#C,muted:this.#P,readyState:this.#S,capabilities:(0,Jf.clone)(this.#R),constraints:(0,Jf.clone)(this.#k),settings:(0,Jf.clone)(this.#D),data:t??(0,Jf.clone)(this.#I)})}getCapabilities(){return this.#R}getConstraints(){return this.#k}async applyConstraints(e={}){return this.#k=e,Promise.resolve()}getSettings(){return this.#D}remoteStop(){"ended"!==this.#S&&(this.#S="ended",this.dispatchEvent(new $f.FakeEvent("stopped")),this.dispatchEvent(new $f.FakeEvent("ended")))}remoteMute(){this.#P||(this.#P=!0,this.dispatchEvent(new $f.FakeEvent("mute")))}remoteUnmute(){this.#P&&(this.#P=!1,this.dispatchEvent(new $f.FakeEvent("unmute")))}}Nh.FakeMediaStreamTrack=Kf;var Qf={};Object.defineProperty(Qf,"__esModule",{value:!0}),Qf.FakeEventTarget=void 0;Qf.FakeEventTarget=class{listeners={};addEventListener(e,t,r){t&&(this.listeners[e]??=[],this.listeners[e].push({callback:"function"==typeof t?t:t.handleEvent,once:"object"==typeof r&&!0===r.once}))}removeEventListener(e,t,r){this.listeners[e]&&t&&(this.listeners[e]=this.listeners[e].filter((e=>e.callback!==("function"==typeof t?t:t.handleEvent))))}dispatchEvent(e){if(!e||"string"!=typeof e.type)throw new Error("invalid event object");const t=this.listeners[e.type];if(!t)return!0;for(const r of[...t]){try{r.callback.call(this,e)}catch(e){setTimeout((()=>{throw e}),0)}r.once&&this.removeEventListener(e.type,r.callback)}return!e.defaultPrevented}},Object.defineProperty(Oh,"__esModule",{value:!0}),Oh.FakeHandler=void 0;const Zf=Nh,Xf=Ud,em=au,tm=cu,rm=iu,nm=Qf,im=new Ld.Logger("FakeHandler");class sm extends Xf.EnhancedEventEmitter{_closed=!1;_fakeParameters;_getSendExtendedRtpCapabilities;_cname=`CNAME-${em.generateRandomNumber()}`;_transportReady=!1;_nextLocalId=1;_tracks=new Map;_nextSctpStreamId=0;static createFactory(e){return{name:"FakeHandler",factory:t=>new sm(t,e),getNativeRtpCapabilities:async()=>(im.debug("getNativeRtpCapabilities()"),sm.getLocalRtpCapabilities(e)),getNativeSctpCapabilities:async()=>(im.debug("getNativeSctpCapabilities()"),e.generateNativeSctpCapabilities())}}static getLocalRtpCapabilities(e){const t=e.generateNativeRtpCapabilities();return tm.validateAndNormalizeRtpCapabilities(t),t}constructor({getSendExtendedRtpCapabilities:e},t){super(),im.debug("constructor()"),this._getSendExtendedRtpCapabilities=e,this._fakeParameters=t}get name(){return"FakeHandler"}close(){im.debug("close()"),this._closed||(this._closed=!0,super.close())}setIceGatheringState(e){this.emit("@icegatheringstatechange",e)}setConnectionState(e){this.emit("@connectionstatechange",e)}async updateIceServers(e){this.assertNotClosed(),im.debug("updateIceServers()")}async restartIce(e){this.assertNotClosed(),im.debug("restartIce()")}async getTransportStats(){return this.assertNotClosed(),new Map}async send({track:e,encodings:t,codecOptions:r,codec:n}){this.assertNotClosed(),im.debug("send() [kind:%s, track.id:%s]",e.kind,e.id),this._transportReady||await this.setupTransport({localDtlsRole:"server"});const i=sm.getLocalRtpCapabilities(this._fakeParameters),s=this._getSendExtendedRtpCapabilities(i),o=tm.getSendingRtpParameters(e.kind,s);o.codecs=tm.reduceCodecs(o.codecs,n);const a=o.codecs.some((e=>/.+\/rtx$/i.test(e.mimeType)));o.mid=`mid-${em.generateRandomNumber()}`,t||(t=[{}]);for(const e of t)e.ssrc=em.generateRandomNumber(),a&&(e.rtx={ssrc:em.generateRandomNumber()});o.encodings=t,o.rtcp={cname:this._cname,reducedSize:!0,mux:!0};const c=this._nextLocalId++;return this._tracks.set(c,e),{localId:String(c),rtpParameters:o}}async stopSending(e){if(im.debug("stopSending() [localId:%s]",e),!this._closed){if(!this._tracks.has(Number(e)))throw new Error("local track not found");this._tracks.delete(Number(e))}}async pauseSending(e){this.assertNotClosed()}async resumeSending(e){this.assertNotClosed()}async replaceTrack(e,t){this.assertNotClosed(),t?im.debug("replaceTrack() [localId:%s, track.id:%s]",e,t.id):im.debug("replaceTrack() [localId:%s, no track]",e),this._tracks.delete(Number(e)),this._tracks.set(Number(e),t)}async setMaxSpatialLayer(e,t){this.assertNotClosed(),im.debug("setMaxSpatialLayer() [localId:%s, spatialLayer:%s]",e,t)}async setRtpEncodingParameters(e,t){this.assertNotClosed(),im.debug("setRtpEncodingParameters() [localId:%s, params:%o]",e,t)}async getSenderStats(e){return this.assertNotClosed(),new Map}async sendDataChannel({ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}){this.assertNotClosed(),this._transportReady||await this.setupTransport({localDtlsRole:"server"}),im.debug("sendDataChannel()");return{dataChannel:new om({id:this._nextSctpStreamId++,ordered:e,maxPacketLifeTime:t,maxRetransmits:r,label:n,protocol:i}),sctpStreamParameters:{streamId:this._nextSctpStreamId,ordered:e,maxPacketLifeTime:t,maxRetransmits:r}}}async receive(e){this.assertNotClosed();const t=[];for(const r of e){const{trackId:e,kind:n}=r;this._transportReady||await this.setupTransport({localDtlsRole:"client"}),im.debug("receive() [trackId:%s, kind:%s]",e,n);const i=this._nextLocalId++,s=new Zf.FakeMediaStreamTrack({kind:n});this._tracks.set(i,s),t.push({localId:String(i),track:s})}return t}async stopReceiving(e){if(!this._closed)for(const t of e)im.debug("stopReceiving() [localId:%s]",t),this._tracks.delete(Number(t))}async pauseReceiving(e){this.assertNotClosed()}async resumeReceiving(e){this.assertNotClosed()}async getReceiverStats(e){return this.assertNotClosed(),new Map}async receiveDataChannel({sctpStreamParameters:e,label:t,protocol:r}){this.assertNotClosed(),this._transportReady||await this.setupTransport({localDtlsRole:"client"}),im.debug("receiveDataChannel()");return{dataChannel:new om({id:e.streamId,ordered:e.ordered,maxPacketLifeTime:e.maxPacketLifeTime,maxRetransmits:e.maxRetransmits,label:t,protocol:r})}}async setupTransport({localDtlsRole:e,localSdpObject:t}){const r=em.clone(this._fakeParameters.generateLocalDtlsParameters());e&&(r.role=e),this.emit("@connectionstatechange","connecting"),await new Promise(((e,t)=>this.emit("@connect",{dtlsParameters:r},e,t))),this._transportReady=!0}assertNotClosed(){if(this._closed)throw new rm.InvalidStateError("method called in a closed handler")}}Oh.FakeHandler=sm;class om extends nm.FakeEventTarget{_id;_negotiated=!0;_ordered;_maxPacketLifeTime;_maxRetransmits;_label;_protocol;_readyState="connecting";_bufferedAmount=0;_bufferedAmountLowThreshold=0;_binaryType="arraybuffer";_onopen=null;_onclosing=null;_onclose=null;_onmessage=null;_onbufferedamountlow=null;_onerror=null;constructor({id:e,ordered:t=!0,maxPacketLifeTime:r=null,maxRetransmits:n=null,label:i="",protocol:s=""}){super(),im.debug(`constructor() [id:${e}, ordered:${t}, maxPacketLifeTime:${r}, maxRetransmits:${n}, label:${i}, protocol:${s}`),this._id=e,this._ordered=t,this._maxPacketLifeTime=r,this._maxRetransmits=n,this._label=i,this._protocol=s}get id(){return this._id}get negotiated(){return this._negotiated}get ordered(){return this._ordered}get maxPacketLifeTime(){return this._maxPacketLifeTime}get maxRetransmits(){return this._maxRetransmits}get label(){return this._label}get protocol(){return this._protocol}get readyState(){return this._readyState}get bufferedAmount(){return this._bufferedAmount}get bufferedAmountLowThreshold(){return this._bufferedAmountLowThreshold}set bufferedAmountLowThreshold(e){this._bufferedAmountLowThreshold=e}get binaryType(){return this._binaryType}set binaryType(e){this._binaryType=e}get onopen(){return this._onopen}set onopen(e){this._onopen&&this.removeEventListener("open",this._onopen),this._onopen=e,e&&this.addEventListener("open",e)}get onclosing(){return this._onclosing}set onclosing(e){this._onclosing&&this.removeEventListener("closing",this._onclosing),this._onclosing=e,e&&this.addEventListener("closing",e)}get onclose(){return this._onclose}set onclose(e){this._onclose&&this.removeEventListener("close",this._onclose),this._onclose=e,e&&this.addEventListener("close",e)}get onmessage(){return this._onmessage}set onmessage(e){this._onmessage&&this.removeEventListener("message",this._onmessage),this._onmessage=e,e&&this.addEventListener("message",e)}get onbufferedamountlow(){return this._onbufferedamountlow}set onbufferedamountlow(e){this._onbufferedamountlow&&this.removeEventListener("bufferedamountlow",this._onbufferedamountlow),this._onbufferedamountlow=e,e&&this.addEventListener("bufferedamountlow",e)}get onerror(){return this._onerror}set onerror(e){this._onerror&&this.removeEventListener("error",this._onerror),this._onerror=e,e&&this.addEventListener("error",e)}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t,r){super.removeEventListener(e,t,r)}close(){["closing","closed"].includes(this._readyState)||(this._readyState="closed")}send(e){if("open"!==this._readyState)throw new rm.InvalidStateError("not open")}}var am={};Object.defineProperty(am,"__esModule",{value:!0}),am.generateRouterRtpCapabilities=function(){return cm.deepFreeze({codecs:[{mimeType:"audio/opus",kind:"audio",preferredPayloadType:100,clockRate:48e3,channels:2,rtcpFeedback:[{type:"transport-cc"}],parameters:{useinbandfec:1,foo:"bar"}},{mimeType:"video/VP8",kind:"video",preferredPayloadType:101,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"x-google-start-bitrate":1500}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:102,clockRate:9e4,rtcpFeedback:[],parameters:{apt:101}},{mimeType:"video/H264",kind:"video",preferredPayloadType:103,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"level-asymmetry-allowed":1,"packetization-mode":1,"profile-level-id":"42e01f"}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:104,clockRate:9e4,rtcpFeedback:[],parameters:{apt:103}},{mimeType:"video/VP9",kind:"video",preferredPayloadType:105,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"profile-id":0,"x-google-start-bitrate":1500}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:106,clockRate:9e4,rtcpFeedback:[],parameters:{apt:105}}],headerExtensions:[{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id",preferredId:2,preferredEncrypt:!1,direction:"recvonly"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id",preferredId:3,preferredEncrypt:!1,direction:"recvonly"},{kind:"audio",uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",preferredId:4,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",preferredId:4,preferredEncrypt:!1,direction:"sendrecv"},{kind:"audio",uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",preferredId:5,preferredEncrypt:!1,direction:"recvonly"},{kind:"video",uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",preferredId:5,preferredEncrypt:!1,direction:"sendrecv"},{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",preferredId:10,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:3gpp:video-orientation",preferredId:11,preferredEncrypt:!1,direction:"sendrecv"},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:toffset",preferredId:12,preferredEncrypt:!1,direction:"sendrecv"}]})},am.generateNativeRtpCapabilities=function(){return{codecs:[{mimeType:"audio/opus",kind:"audio",preferredPayloadType:111,clockRate:48e3,channels:2,rtcpFeedback:[{type:"transport-cc"}],parameters:{minptime:10,useinbandfec:1}},{mimeType:"audio/ISAC",kind:"audio",preferredPayloadType:103,clockRate:16e3,channels:1,rtcpFeedback:[{type:"transport-cc"}],parameters:{}},{mimeType:"audio/CN",kind:"audio",preferredPayloadType:106,clockRate:32e3,channels:1,rtcpFeedback:[{type:"transport-cc"}],parameters:{}},{mimeType:"audio/foo",kind:"audio",preferredPayloadType:107,clockRate:9e4,channels:4,rtcpFeedback:[{type:"foo-qwe-qwe"}],parameters:{foo:"lalala"}},{mimeType:"video/BAZCODEC",kind:"video",preferredPayloadType:100,clockRate:9e4,rtcpFeedback:[{type:"foo"},{type:"transport-cc"},{type:"ccm",parameter:"fir"},{type:"nack"},{type:"nack",parameter:"pli"}],parameters:{baz:"1234abcd"}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:101,clockRate:9e4,rtcpFeedback:[],parameters:{apt:100}},{mimeType:"video/VP8",kind:"video",preferredPayloadType:96,clockRate:9e4,rtcpFeedback:[{type:"goog-remb"},{type:"transport-cc"},{type:"ccm",parameter:"fir"},{type:"nack"},{type:"nack",parameter:"pli"}],parameters:{baz:"1234abcd"}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:97,clockRate:9e4,rtcpFeedback:[],parameters:{apt:96}},{mimeType:"video/VP9",kind:"video",preferredPayloadType:98,clockRate:9e4,rtcpFeedback:[{type:"goog-remb"},{type:"transport-cc"},{type:"ccm",parameter:"fir"},{type:"nack"},{type:"nack",parameter:"pli"}],parameters:{"profile-id":0}},{mimeType:"video/rtx",kind:"video",preferredPayloadType:99,clockRate:9e4,rtcpFeedback:[],parameters:{apt:98}}],headerExtensions:[{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:sdes:mid",preferredId:1},{kind:"video",uri:"urn:ietf:params:rtp-hdrext:toffset",preferredId:2},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",preferredId:3},{kind:"video",uri:"urn:3gpp:video-orientation",preferredId:4},{kind:"video",uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",preferredId:5},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/playout-delay",preferredId:6},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/video-content-type",preferredId:7},{kind:"video",uri:"http://www.webrtc.org/experiments/rtp-hdrext/video-timing",preferredId:8},{kind:"audio",uri:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",preferredId:10}]}},am.generateNativeSctpCapabilities=function(){return cm.deepFreeze({numStreams:{OS:2048,MIS:2048}})},am.generateLocalDtlsParameters=function(){return cm.deepFreeze({fingerprints:[{algorithm:"sha-256",value:"82:5A:68:3D:36:C3:0A:DE:AF:E7:32:43:D2:88:83:57:AC:2D:65:E5:80:C4:B6:FB:AF:1A:A0:21:9F:6D:0C:AD"}],role:"auto"})},am.generateTransportRemoteParameters=function(){return{id:dm(),iceParameters:cm.deepFreeze({iceLite:!0,password:"yku5ej8nvfaor28lvtrabcx0wkrpkztz",usernameFragment:"h3hk1iz6qqlnqlne"}),iceCandidates:cm.deepFreeze([{foundation:"udpcandidate",address:"9.9.9.9",ip:"9.9.9.9",port:40533,priority:1078862079,protocol:"udp",type:"host",tcpType:"passive"},{foundation:"udpcandidate",address:"9.9.9.9",ip:"9:9:9:9:9:9",port:41333,priority:1078862089,protocol:"udp",type:"host",tcpType:"passive"}]),dtlsParameters:cm.deepFreeze({fingerprints:[{algorithm:"sha-256",value:"A9:F4:E0:D2:74:D3:0F:D9:CA:A5:2F:9F:7F:47:FA:F0:C4:72:DD:73:49:D0:3B:14:90:20:51:30:1B:90:8E:71"},{algorithm:"sha-384",value:"03:D9:0B:87:13:98:F6:6D:BC:FC:92:2E:39:D4:E1:97:32:61:30:56:84:70:81:6E:D1:82:97:EA:D9:C1:21:0F:6B:C5:E7:7F:E1:97:0C:17:97:6E:CF:B3:EF:2E:74:B0"},{algorithm:"sha-512",value:"84:27:A4:28:A4:73:AF:43:02:2A:44:68:FF:2F:29:5C:3B:11:9A:60:F4:A8:F0:F5:AC:A0:E3:49:3E:B1:34:53:A9:85:CE:51:9B:ED:87:5E:B8:F4:8E:3D:FA:20:51:B8:96:EE:DA:56:DC:2F:5C:62:79:15:23:E0:21:82:2B:2C"}],role:"auto"}),sctpParameters:cm.deepFreeze({port:5e3,OS:2048,MIS:2048,maxMessageSize:2e6})}},am.generateProducerRemoteParameters=function(){return cm.deepFreeze({id:dm()})},am.generateConsumerRemoteParameters=function({id:e,codecMimeType:t}={}){switch(t){case"audio/opus":return{id:e??dm(),producerId:dm(),kind:"audio",rtpParameters:cm.deepFreeze({codecs:[{mimeType:"audio/opus",payloadType:100,clockRate:48e3,channels:2,rtcpFeedback:[{type:"transport-cc"}],parameters:{useinbandfec:1,foo:"bar"}}],encodings:[{ssrc:46687003}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5},{uri:"urn:ietf:params:rtp-hdrext:ssrc-audio-level",id:10}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};case"audio/ISAC":return{id:e??dm(),producerId:dm(),kind:"audio",rtpParameters:cm.deepFreeze({codecs:[{mimeType:"audio/ISAC",payloadType:111,clockRate:16e3,channels:1,rtcpFeedback:[{type:"transport-cc"}],parameters:{}}],encodings:[{ssrc:46687004}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};case"video/VP8":return{id:e??dm(),producerId:dm(),kind:"video",rtpParameters:cm.deepFreeze({codecs:[{mimeType:"video/VP8",payloadType:101,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"x-google-start-bitrate":1500}},{mimeType:"video/rtx",payloadType:102,clockRate:9e4,rtcpFeedback:[],parameters:{apt:101}}],encodings:[{ssrc:99991111,rtx:{ssrc:99991112}}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",id:4},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5},{uri:"urn:3gpp:video-orientation",id:11},{uri:"urn:ietf:params:rtp-hdrext:toffset",id:12}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};case"video/H264":return{id:e??dm(),producerId:dm(),kind:"video",rtpParameters:cm.deepFreeze({codecs:[{mimeType:"video/H264",payloadType:103,clockRate:9e4,rtcpFeedback:[{type:"nack"},{type:"nack",parameter:"pli"},{type:"ccm",parameter:"fir"},{type:"goog-remb"},{type:"transport-cc"}],parameters:{"level-asymmetry-allowed":1,"packetization-mode":1,"profile-level-id":"42e01f"}},{mimeType:"video/rtx",payloadType:104,clockRate:9e4,rtcpFeedback:[],parameters:{apt:103}}],encodings:[{ssrc:99991113,rtx:{ssrc:99991114}}],headerExtensions:[{uri:"urn:ietf:params:rtp-hdrext:sdes:mid",id:1},{uri:"http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time",id:4},{uri:"http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01",id:5},{uri:"urn:3gpp:video-orientation",id:11},{uri:"urn:ietf:params:rtp-hdrext:toffset",id:12}],rtcp:{cname:"wB4Ql4lrsxYLjzuN",reducedSize:!0,mux:!0}})};default:throw new TypeError(`unknown codecMimeType '${t}'`)}},am.generateDataProducerRemoteParameters=function(){return cm.deepFreeze({id:dm()})},am.generateDataConsumerRemoteParameters=function({id:e}={}){return{id:e??dm(),dataProducerId:dm(),sctpStreamParameters:cm.deepFreeze({streamId:666,maxPacketLifeTime:5e3,maxRetransmits:void 0})}};const cm=au;function dm(){return String(cm.generateRandomNumber())}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.debug=e.testFakeParameters=e.FakeHandler=e.enhancedEvents=e.ortc=e.parseScalabilityMode=e.detectDeviceAsync=e.detectDevice=e.Device=e.version=e.types=void 0;const t=hd.exports;e.debug=t.default,e.types=Ed,e.version="3.15.6";var r=wd;Object.defineProperty(e,"Device",{enumerable:!0,get:function(){return r.Device}}),Object.defineProperty(e,"detectDevice",{enumerable:!0,get:function(){return r.detectDevice}}),Object.defineProperty(e,"detectDeviceAsync",{enumerable:!0,get:function(){return r.detectDeviceAsync}});var n=zl;Object.defineProperty(e,"parseScalabilityMode",{enumerable:!0,get:function(){return n.parse}}),e.ortc=cu,e.enhancedEvents=Ud;var i=Oh;Object.defineProperty(e,"FakeHandler",{enumerable:!0,get:function(){return i.FakeHandler}}),e.testFakeParameters=am}(pd);const um={width:1280,height:720},lm=0,pm=2,hm=0;function fm(e,t){e.onload=function(){this.onerror=this.onload=null,t(null,e)},e.onerror=function(){this.onerror=this.onload=null,t(new Error("Failed to load "+this.src),e)}}function mm(e,t){e.onreadystatechange=function(){"complete"!=this.readyState&&"loaded"!=this.readyState||(this.onreadystatechange=null,t(null,e))}}const gm=new Dn,vm=e=>a(void 0,void 0,void 0,(function*(){return yield new Promise(((t,r)=>{!function(e,t,r){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("script");"function"==typeof t&&(r=t,t={}),t=t||{},r=r||function(){},i.type=t.type||"text/javascript",i.charset=t.charset||"utf8",i.async=!("async"in t)||!!t.async,i.src=e,t.attrs&&function(e,t){for(var r in t)e.setAttribute(r,t[r])}(i,t.attrs),t.text&&(i.text=""+t.text),("onload"in i?fm:mm)(i,r),i.onload||fm(i,r),n.appendChild(i)}(e,((e,n)=>{e?r(e):t(n)}))}))})),ym=(e,...t)=>a(void 0,[e,...t],void 0,(function*(e,t=3,r=500){let n=0;for(;n<t;)try{return void(yield vm(e))}catch(e){if(n+=1,!(n<t))throw e;yield gm.sleepMs(r)}}));var _m;let bm=class{constructor(){_m.set(this,new Map)}add(e,t,r){const n=this.getKey(e,t);if(c(this,_m,"f").has(n))throw new Error("Attempt to rewrite cached track processor");c(this,_m,"f").set(n,r)}get(e,t){return c(this,_m,"f").get(this.getKey(e,t))}has(e,t){return c(this,_m,"f").has(this.getKey(e,t))}getKey(e,t){return`${e}:${t}`}reset(){for(const e of c(this,_m,"f").values())try{e.stopProcessing(),e.release()}catch(e){}c(this,_m,"f").clear()}};var Em,wm;_m=new WeakMap,bm=i([at()],bm);let Sm=class{constructor(e,t,r,n){this.config=e,this.processorsCache=t,this.audioTrackProcessorFactory=r,Em.set(this,new Map),wm.set(this,void 0),d(this,wm,n("IntegrationsService"),"f")}init(){const e=this.config.get("denoiser");if("asdk"===e){c(this,wm,"f").info("Start integration of ASDK",{denoiser:e});const t={integrated:!1,initPromise:this.integrateASDK()};c(this,Em,"f").set("asdk",t)}else{c(this,wm,"f").info("Start integration of RNNoise",{denoiser:e});const t={integrated:!1,initPromise:this.integrateRNNoise()};c(this,Em,"f").set("rnnoise",t)}}integrateASDK(){return a(this,void 0,void 0,(function*(){const e=this.config.get("asdk"),t=this.config.get("staticFilesPath");if(!window.atsvb){const s=`https://effectssdk.ai/sdk/audio/dev/${e.version}/atsvb-web.js`;let o=s;if(e.localDir){const n=`${e.localDir}/${e.version}/atsvb-web.js`;o=new r(n,t).href}yield(n=o,i=s,a(void 0,void 0,void 0,(function*(){try{yield ym(n)}catch(e){if(!i)throw e;yield ym(i)}})))}var n,i;if(!window.atsvb)throw c(this,wm,"f").info("Audio Effects SDK is not loaded, skipping initialization",{case:"initAudioSDK"}),new Error("windows.atsvb is still missing");const s=this.audioTrackProcessorFactory({trackLabel:Nn.Microphone});yield s.init(),this.processorsCache.add("asdk",Nn.Microphone,s);const o=c(this,Em,"f").get("asdk");if(!o)throw Error("IntegrationContext is missing for ASDK");o.integrated=!0}))}get audio(){return"asdk"===this.config.get("denoiser")?this.getASDKState():this.getRNNoiseState()}getASDKState(){var e,t;const r=c(this,Em,"f").get("asdk");return{type:"asdk",enabled:Boolean(r),isInitialized:null!==(e=null==r?void 0:r.integrated)&&void 0!==e&&e,waitForInitialization:null!==(t=null==r?void 0:r.initPromise)&&void 0!==t?t:Promise.resolve()}}getRNNoiseState(){var e,t;const r=c(this,Em,"f").get("rnnoise");return{type:"rnnoise",enabled:Boolean(r),isInitialized:null!==(e=null==r?void 0:r.integrated)&&void 0!==e&&e,waitForInitialization:null!==(t=null==r?void 0:r.initPromise)&&void 0!==t?t:Promise.resolve()}}integrateRNNoise(){return a(this,void 0,void 0,(function*(){const e=yield function(e){return a(this,void 0,void 0,(function*(){if(!window.WebAssembly)throw new Error("Webassembly not supported");const t=yield fetch(`${e}/rnnoise-processor.wasm`);return yield WebAssembly.instantiate(yield t.arrayBuffer())}))}(this.config.get("staticFilesPath")),t=this.audioTrackProcessorFactory({trackLabel:Nn.Microphone,noiseSuppressor:e});this.processorsCache.add("rnnoise",Nn.Microphone,t);const r=c(this,Em,"f").get("rnnoise");if(!r)throw Error("IntegrationContext is missing for RNNoise");r.integrated=!0}))}reset(){c(this,Em,"f").clear()}};var Cm,Pm,Tm,Rm,km,Dm,Im,Am,Om;Em=new WeakMap,wm=new WeakMap,Sm=i([at(),s(0,dt(On.Config)),s(1,dt(On.ProcessorsCache)),s(2,dt(On.AudioTrackProcessorFactory)),s(3,dt(On.LoggerFactory)),o("design:paramtypes",[bt,bm,Function,Function])],Sm),function(e){e.INFO="info",e.WARNING="warning",e.ERROR="error"}(Am||(Am={})),function(e){e.TSVB="tsvb",e.COMPONENTS_SYSTEM="components_system",e.SRTEAM_PROCESSOR="stream_processor",e.ML_INFERENCE="ml_inference",e.PRESET_INIT="preset_init",e.RENDERER="renderer",e.RECORDER="recorder",e.EFFECT_VIRTUAL_BACKGROUND="effect_virtual_background",e.EFFECT_COLOR_CORRECTION="effect_color_correction",e.EFFECT_COLOR_FILTER="effect_color_filter",e.EFFECT_SMART_ZOOM="effect_smart_zoom",e.EFFECT_LOW_LIGHT="effect_low_light"}(Om||(Om={}));class Nm{constructor(e){Cm.set(this,void 0),Pm.set(this,void 0),Tm.set(this,{lowLighter:!1,colorCorrector:!1,faceDetector:!1,segmentation:!1}),Rm.set(this,null),km.set(this,void 0),Dm.set(this,!1),Im.set(this,void 0);const{loggerFactory:t}=e;if(d(this,Pm,t("EffectsSDKTrackProcessor"),"f"),d(this,Im,e.onModelsLoaded,"f"),!e.customerId)throw new Error("Customer ID must be provided");d(this,Cm,new window.tsvb(e.customerId),"f"),c(this,Cm,"f").onError(this.tsvbErrorHandler.bind(this)),c(this,Cm,"f").onReady=this.onReady.bind(this);const r=e.config.get("staticFilesPath"),{localDir:n,version:i}=e.config.get("effectsSDKParams"),s=n&&i?`${r}/esdk/${null!=i?i:"3.5.8"}`:`https://effectssdk.ai/sdk/web/${null!=i?i:"3.5.8"}`,o={preset:"balanced",provider:"webgpu",sdk_url:e.sdk_url,api_url:e.api_url,test_inference:!0,wasmPaths:{"ort-wasm.wasm":`${s}/ort-wasm.wasm`,"ort-wasm-simd.wasm":`${s}/ort-wasm-simd.wasm`,"ort-wasm-simd.jsep.wasm":`${s}/ort-wasm-simd.jsep.wasm`}};c(this,Cm,"f").config(o)}init(){return a(this,void 0,void 0,(function*(){yield c(this,Cm,"f").preload(),yield c(this,Cm,"f").cache(),d(this,Dm,!0,"f")}))}awaitReady(){return a(this,void 0,void 0,(function*(){yield new Promise(((e,t)=>{const r=Date.now(),n=setInterval((()=>{if(this.isModelsLoaded)return clearInterval(n),void e();Date.now()-r>6e4&&(clearInterval(n),t(new Error("ESDK init timeout")))}),100)}))}))}tsvbErrorHandler(e){var t;const{emitter:r,type:i}=e,s=n(e,["emitter","type"]),o=null!=r?r:"N/A emitter";i===Am.ERROR&&c(this,Pm,"f").error(o,Object.assign({error:Ct(e)},s)),i===Am.WARNING&&c(this,Pm,"f").warn(o,Object.assign({},s)),i===Am.INFO&&c(this,Pm,"f").info(o,Object.assign({},s)),r===Om.ML_INFERENCE&&(s.message.toLocaleLowerCase().includes("init lowlighter")&&(c(this,Tm,"f").lowLighter=!0),s.message.toLocaleLowerCase().includes("init colorcorrector")&&(c(this,Tm,"f").colorCorrector=!0),s.message.toLocaleLowerCase().includes("init facedetector")&&(c(this,Tm,"f").faceDetector=!0),s.message.toLocaleLowerCase().includes("init segmentation")&&(c(this,Tm,"f").segmentation=!0),this.isModelsLoaded&&(null===(t=c(this,Im,"f"))||void 0===t||t.call(this)))}get isModelsLoaded(){return c(this,Tm,"f").colorCorrector&&c(this,Tm,"f").faceDetector&&c(this,Tm,"f").lowLighter&&c(this,Tm,"f").segmentation}get modelsLoadProgress(){return Object.values(c(this,Tm,"f")).filter(Boolean).length/Object.keys(c(this,Tm,"f")).length}get isReady(){return c(this,Dm,"f")}setOnLoadModels(e){d(this,Im,e,"f"),this.isModelsLoaded&&c(this,Im,"f").call(this)}onReady(){d(this,Dm,!0,"f"),c(this,Pm,"f").debug("onReady()",{description:"ESDK is ready"}),this.updateEffects(c(this,km,"f"))}processTrack(e){var t,r,n;if(c(this,Rm,"f")===e||"ended"===e.readyState)return null!==(r=null===(t=c(this,Cm,"f").getStream())||void 0===t?void 0:t.getVideoTracks()[0])&&void 0!==r?r:e;this.stopProcessing();try{c(this,Cm,"f").useStream(new MediaStream([e]));const t=null===(n=c(this,Cm,"f").getStream())||void 0===n?void 0:n.getVideoTracks()[0];return t?(d(this,Rm,e,"f"),t):e}catch(t){throw c(this,Pm,"f").error("processTrack()",{error:t,track:e}),new Error("Can not process this track")}}stopProcessing(){try{c(this,Cm,"f").clear(),c(this,Cm,"f").stop()}catch(e){c(this,Pm,"f").error("stopProcessing()",{error:e})}finally{d(this,Rm,null,"f")}}updateEffects(e){var t,r,n,i,s,o,a,u,l,p,h,f,m,g,v,y,_,b,E,w,S,C;if(d(this,km,e,"f"),!c(this,Dm,"f"))return void c(this,Pm,"f").warn("updateEffects()",{description:"Esdk not ready"});if(!c(this,km,"f")||0===Object.keys(c(this,km,"f")).length)return void c(this,Cm,"f").stop();let P=0;if((null===(t=c(this,km,"f"))||void 0===t?void 0:t.blur)&&!(null===(r=c(this,km,"f"))||void 0===r?void 0:r.backgroundColor)?(c(this,Cm,"f").setBlur(c(this,km,"f").blur),P+=1):c(this,Cm,"f").clearBlur(),void 0!==(null===(n=c(this,km,"f"))||void 0===n?void 0:n.background)?(c(this,Cm,"f").setBackground(c(this,km,"f").background),P+=1):void 0!==(null===(i=c(this,km,"f"))||void 0===i?void 0:i.backgroundColor)?(c(this,Cm,"f").setBackgroundColor(null===(s=c(this,km,"f"))||void 0===s?void 0:s.backgroundColor),c(this,Cm,"f").setBackground("color"),P+=1):c(this,Cm,"f").clearBackground(),(null===(o=c(this,km,"f"))||void 0===o?void 0:o.beautification)?(c(this,Cm,"f").enableBeautification(),c(this,Cm,"f").setBeautificationLevel(c(this,km,"f").beautification),P+=1):c(this,Cm,"f").disableBeautification(),(null===(a=c(this,km,"f"))||void 0===a?void 0:a.lowLightEffect)?(c(this,Cm,"f").enableLowLightEffect(),c(this,Cm,"f").setLowLightEffectPower(c(this,km,"f").lowLightEffect),P+=1):c(this,Cm,"f").disableLowLightEffect(),(null===(u=c(this,km,"f"))||void 0===u?void 0:u.colorCorrector)?(c(this,Cm,"f").enableColorCorrector(),c(this,Cm,"f").setColorCorrectorPower(c(this,km,"f").colorCorrector),P+=1):c(this,Cm,"f").disableColorCorrector(),(null===(l=c(this,km,"f"))||void 0===l?void 0:l.smartZoom)?(c(this,Cm,"f").enableSmartZoom(),c(this,Cm,"f").setFaceArea(c(this,km,"f").smartZoom),P+=1):c(this,Cm,"f").disableSmartZoom(),(null===(p=c(this,km,"f"))||void 0===p?void 0:p.layout)?(c(this,Cm,"f").setLayout(c(this,km,"f").layout),P+=1):c(this,Cm,"f").setLayout("center"),(null===(h=c(this,km,"f"))||void 0===h?void 0:h.colorFilter)&&(null===(f=c(this,km,"f"))||void 0===f?void 0:f.colorFilter.power)&&(null===(m=c(this,km,"f"))||void 0===m?void 0:m.colorFilter.url)?(c(this,Cm,"f").setColorFilterConfig({lut:c(this,km,"f").colorFilter.url,power:c(this,km,"f").colorFilter.power}),c(this,Cm,"f").enableColorFilter(),P+=1):c(this,Cm,"f").disableColorFilter(),null===(g=c(this,km,"f"))||void 0===g?void 0:g.lowerThird){const e=c(this,Cm,"f").createComponent({component:c(this,km,"f").lowerThird.type,options:null!==(v=c(this,km,"f").lowerThird.options)&&void 0!==v?v:{}});null===(b=null===(_=null===(y=c(this,Cm,"f").components)||void 0===y?void 0:y.lowerThird)||void 0===_?void 0:_.hideLowerThird)||void 0===b||b.call(_),c(this,Cm,"f").addComponent(e,"lowerThird"),c(this,Cm,"f").components.lowerThird.showLowerThird(),P+=1}else null===(S=null===(w=null===(E=c(this,Cm,"f").components)||void 0===E?void 0:E.lowerThird)||void 0===w?void 0:w.hideLowerThird)||void 0===S||S.call(w);(null===(C=c(this,km,"f"))||void 0===C?void 0:C.sharpness)?(c(this,Cm,"f").setSharpnessEffectConfig(c(this,km,"f").sharpness),P+=1):c(this,Cm,"f").disableSharpnessEffect(),P>2?c(this,Cm,"f").enableFrameSkipping():c(this,Cm,"f").disableFrameSkipping(),c(this,Cm,"f").run()}}Cm=new WeakMap,Pm=new WeakMap,Tm=new WeakMap,Rm=new WeakMap,km=new WeakMap,Dm=new WeakMap,Im=new WeakMap;const Mm=e=>"rtx"!==e.mimeType;var Lm,xm,Fm,jm,Um,Vm,Bm,Wm,Hm,qm,zm,Gm,Ym,$m,Jm,Km;class Qm{constructor({track:e,statsHandler:t}){Lm.set(this,void 0),xm.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return c(this,Lm,"f")}get audioWebRTCStats(){return c(this,xm,"f")}handleWebRTCStats(e,t){e.addEventListener("ended",(()=>{t.removeInboundVideoHandler(e.id),t.removeInboundAudioHandler(e.id)}),{once:!0}),"video"!==e.kind?t.addOutboundAudioHandler(e.id,this.setAudioWebRTCStats.bind(this)):t.addOutboundVideoHandler(e.id,this.setVideoWebRTCStats.bind(this))}setVideoWebRTCStats(e){d(this,Lm,e,"f")}setAudioWebRTCStats(e){d(this,xm,e,"f")}}Lm=new WeakMap,xm=new WeakMap;class Zm{constructor(e){Fm.set(this,void 0),jm.set(this,void 0),this.encoderConfig={},this.label=Nn.Unknown,Um.set(this,void 0),Vm.set(this,void 0),Bm.set(this,void 0),Wm.set(this,void 0),Hm.set(this,void 0),qm.set(this,void 0),zm.set(this,void 0),Gm.set(this,void 0),Ym.set(this,!0),$m.set(this,void 0),Jm.set(this,void 0),Km.set(this,void 0);const{mediaStreamTrack:t,internalEventEmitter:r,constraints:n,mediaStreamTrackManager:i,media:s,myPeer:o,network:a,producerCloseManager:c,mutex:u,loggerFactory:l,loggerNamespace:p,statsHandler:h}=e;d(this,Fm,t,"f"),d(this,Hm,r,"f"),d(this,qm,n,"f"),d(this,zm,i,"f"),d(this,Gm,new Et,"f"),this.logger=l(p),d(this,$m,u,"f"),d(this,Vm,s,"f"),d(this,Um,o,"f"),d(this,Bm,a,"f"),d(this,Wm,c,"f"),d(this,Km,h,"f"),d(this,Jm,new Qm({track:t,statsHandler:h}),"f")}get videoWebRTCStats(){return c(this,Jm,"f").videoWebRTCStats}get audioWebRTCStats(){return c(this,Jm,"f").audioWebRTCStats}get logCtx(){return{label:this.getLabel(),id:this.id,kind:this.kind,producerId:this.producerId,paused:this.isPaused,published:this.isPublished}}get observer(){return c(this,Gm,"f")}get mediaStreamTrack(){return c(this,Fm,"f")}get originalTrack(){return c(this,jm,"f")}get id(){return this.mediaStreamTrack.id}get kind(){return this.mediaStreamTrack.kind}get producerId(){var e;return null===(e=this.producer)||void 0===e?void 0:e.id}get isPublished(){return!!this.producer&&!this.producer.closed}get isPaused(){var e,t;return null!==(t=null===(e=this.producer)||void 0===e?void 0:e.paused)&&void 0!==t&&t}get internalEventEmitter(){return c(this,Hm,"f")}getLabel(){return this.label}setLabel(e){this.label=e}setEncoderConfig(e){this.encoderConfig=e}getEncoderConfig(){return this.encoderConfig}setProducer(e){this.producer=e}setStopTrackOnPause(e){this.isPublished||d(this,Ym,e,"f")}getProducer(){return this.producer}setOriginalTrack(){d(this,jm,this.mediaStreamTrack,"f")}closeProducer(){return a(this,arguments,void 0,(function*(e=!0){const t=yield c(this,$m,"f").lock(fn.CloseProducer);if(!this.producer)return void t();const{producerId:r}=this;r&&(yield c(this,Wm,"f").close(this.getLabel(),r)),this.producer.close(),this.producer=void 0,e&&this.stopMediaStreamTrack(),t()}))}setPriority(e){return a(this,void 0,void 0,(function*(){this.producer?(yield this.producer.setRtpEncodingParameters({priority:e}),this.logger.debug("setPriority()",{label:this.getLabel(),priority:e})):this.logger.warn("setPriority()",{priority:e,reason:"Not published yet"})}))}stopMediaStreamTrack(){this.mediaStreamTrack.stop(),this.mediaStreamTrack.dispatchEvent(new Event("ended")),this.stopOriginalTrack()}stopOriginalTrack(){c(this,jm,"f")&&(c(this,jm,"f").stop(),d(this,jm,void 0,"f"))}produce(e){return a(this,arguments,void 0,(function*({encodings:e,codecOptions:t,preferredCodec:r,transformParams:n,keyFrameRequestDelay:i}){var s,o,a,d,u;if(!c(this,Um,"f").canPublish)throw this.logger.error("produce()",{message:"Not enough access to produce"}),new Pt("not_enough_access",new Error("Not enough access to produce"));if(this.producer)throw new Pt("track_already_produced",new Error("Track already produced"));try{yield c(this,Wm,"f").ensureNoPending(this.getLabel()),yield c(this,Bm,"f").ping();const{rtpCapabilities:{codecs:l}}=c(this,Vm,"f").mediasoupDevice,p=null==l?void 0:l.find((e=>e.mimeType.toLowerCase()===`${this.kind}/${r}`)),h=0,f=this.prepareProducerEncodings({codec:p,encodings:null!=e?e:[],maxSpatialLayer:(null!=e?e:[]).length-1}),m={trackTransformParams:n,peerId:String(c(this,Um,"f").id),label:this.getLabel(),maxSpatialLayer:h,encodings:f,codecOptions:t,preferredCodec:r,codec:p,keyFrameRequestDelay:i},g=yield null===(s=c(this,Bm,"f").sendTransport)||void 0===s?void 0:s.produce({track:this.mediaStreamTrack,encodings:f,codecOptions:t,codec:p,stopTracks:!1,disableTrackOnPause:!0,zeroRtpOnPause:!0,appData:m});if(!g)return;const v=g.rtpSender,y=()=>/Safari/i.test(navigator.userAgent);if(e&&v&&y()){const t=v.getParameters();e.forEach((({maxBitrate:e,scaleResolutionDownBy:r},n)=>{t.encodings[n]&&(t.encodings[n].maxBitrate=e,t.encodings[n].scaleResolutionDownBy=r)})),yield v.setParameters(t)}this.setProducer(g),(null===(a=null===(o=this.producer)||void 0===o?void 0:o.track)||void 0===a?void 0:a.id)!==c(this,Fm,"f").id&&(this.logger.info("Producer initialized with old track, updating",{oldTrackId:null===(u=null===(d=this.producer)||void 0===d?void 0:d.track)||void 0===u?void 0:u.id,newTrackId:c(this,Fm,"f").id}),yield this.replaceTrack(c(this,Fm,"f"))),"video"===this.kind&&(e&&v&&p&&Tn(p.mimeType)&&!y()?yield v.setParameters(Object.assign(Object.assign({},v.getParameters()),{encodings:this.prepareProducerEncodings({encodings:e,codec:p,maxSpatialLayer:h})})):yield g.setMaxSpatialLayer(h),yield c(this,Bm,"f").setProducerMaxSpatialLayer(g.id,h)),"audio"===this.kind&&(yield this.setPriority("high")),this.logger.debug("produce()",{track:this.logCtx,encodings:e,codecOptions:t})}catch(e){throw this.logger.error("produce()",{error:e,track:this.logCtx}),new Pt("track_publish_failed",e)}}))}publish(){return a(this,void 0,void 0,(function*(){yield this.produce({}),this.internalEventEmitter.emit(jr,this)}))}unpublish(){return a(this,arguments,void 0,(function*(e=!0){try{e&&this.stopMediaStreamTrack(),this.internalEventEmitter.emit(Ur,this),this.producer&&(yield this.closeProducer()),this.logger.debug("unpublish()",{track:this.logCtx})}catch(e){this.logger.error("unpublish()",{error:e})}}))}pauseRemoteProducer(e){return a(this,void 0,void 0,(function*(){yield c(this,Bm,"f").pauseRemoteProducer(e)}))}resumeRemoteProducer(e){return a(this,void 0,void 0,(function*(){yield c(this,Bm,"f").resumeRemoteProducer(e)}))}mute(e){return a(this,void 0,void 0,(function*(){const t=yield c(this,$m,"f").lock(fn.Mute);if(!this.producer)return this.logger.warn("pause()",{message:"Track is not published",track:this.logCtx}),void t();try{if(this.producer.pause(),this.logger.debug("pause()",{track:this.logCtx}),c(this,Ym,"f"))return null==e||e(),c(this,Fm,"f").stop(),this.stopOriginalTrack(),this.internalEventEmitter.emit(Wr,this),void(yield this.pauseRemoteProducer(this.producer.id));yield this.pauseRemoteProducer(this.producer.id),this.internalEventEmitter.emit(Vr,this)}catch(e){throw this.logger.error("pause()",{error:e,track:this.logCtx}),yield c(this,Vm,"f").deleteTrack(this),this.internalEventEmitter.emit(qr,this),new Pt("track_pause_failed",e)}finally{t()}}))}resume(){return a(this,void 0,void 0,(function*(){const e=yield c(this,$m,"f").lock(fn.Resume);if(!this.producer)return this.logger.warn("resume()",{message:"Track is not published",track:this.logCtx}),void e();try{if(this.logger.debug("resume()",{track:this.logCtx}),c(this,Ym,"f"))return yield this.reopenMediaStreamTrack(),yield this.resumeProducer(),void this.internalEventEmitter.emit(Hr,this);yield this.resumeProducer(),this.internalEventEmitter.emit(Br,this)}catch(e){throw this.logger.error("resume()",{error:e,track:this.logCtx}),new Pt("track_resume_failed",e)}finally{e()}}))}getInfo(){return a(this,void 0,void 0,(function*(){const{width:e,height:t,frameRate:r,aspectRatio:n}=c(this,Fm,"f").getSettings();return{trackId:c(this,Fm,"f").id,readyState:c(this,Fm,"f").readyState,kind:this.kind,label:this.label,width:e,height:t,frameRate:r,aspectRatio:n,paused:this.isPaused,trackOutboundStats:yield this.getStats()}}))}getStats(){return a(this,void 0,void 0,(function*(){var e,t,r,n,i;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=>Mm(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){return a(this,void 0,void 0,(function*(){var t;try{d(this,Fm,e,"f"),this.internalEventEmitter.emit(Hr,this),this.observer.safeEmit("track-changed",{track:e}),yield null===(t=this.producer)||void 0===t?void 0:t.replaceTrack({track:e}),d(this,Jm,new Qm({track:e,statsHandler:c(this,Km,"f")}),"f")}catch(e){this.logger.warn("replaceTrack()",{error:e})}}))}resumeProducer(){return a(this,void 0,void 0,(function*(){this.producer?(yield this.resumeRemoteProducer(this.producer.id),this.producer.resume()):this.logger.debug("resumeProducer()",{message:"Track not produced yet",track:this.logCtx})}))}reopenMediaStreamTrack(){return a(this,void 0,void 0,(function*(){var e;const t=yield c(this,zm,"f").createMediaStreamTrack({label:this.label,constraints:c(this,qm,"f")});d(this,Fm,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&&Tn(r.mimeType)?[t[n]||t[0]]:t}getOutboundRTPStreamStats(){return a(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{const r=(...n)=>a(this,[...n],void 0,(function*(n=0){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((()=>a(this,void 0,void 0,(function*(){return yield 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().catch((e=>{this.logger.debug("Error executing getRTCStatsReport",{case:"DefaultBaseTrack",error:Ct(e)})}))}))}))}}var Xm,eg,tg,rg;Fm=new WeakMap,jm=new WeakMap,Um=new WeakMap,Vm=new WeakMap,Bm=new WeakMap,Wm=new WeakMap,Hm=new WeakMap,qm=new WeakMap,zm=new WeakMap,Gm=new WeakMap,Ym=new WeakMap,$m=new WeakMap,Jm=new WeakMap,Km=new WeakMap;class ng extends Zm{constructor(e){super(e),this.transformParams={},Xm.set(this,void 0),eg.set(this,void 0),tg.set(this,!1),rg.set(this,(()=>{})),d(this,eg,e,"f")}get logCtx(){return{label:this.getLabel(),id:this.id,kind:this.kind,producerId:this.producerId,paused:this.isPaused,published:this.isPublished,isEffectsProcessing:this.isEffectsProcessing}}get isEffectsProcessing(){return Boolean(c(this,Xm,"f"))}getEncoderConfig(){return this.encoderConfig}getCodecOptions(){var e;return{videoGoogleStartBitrate:null!==(e=this.getEncoderConfig().videoGoogleStartBitrate)&&void 0!==e?e:1e3}}getPreferredCodec(){const{preferredCodec:e}=this.getEncoderConfig();return e||(this.getLabel()===Nn.ScreenVideo?"vp8":"h264")}getEncodings(){var e;return null!==(e=this.getEncoderConfig().encodings)&&void 0!==e?e:Cc}setTransformParams(e){this.transformParams=e}setMaxSpatialLayer(e){return a(this,void 0,void 0,(function*(){const t=this.getProducer();t?(yield t.setMaxSpatialLayer(e),this.logger.debug("setMaxSpatialLayer()",{label:this.getLabel(),spatialLayer:e})):this.logger.warn("setMaxSpatialLayer()",{message:"Not produced yet"})}))}getMaxSpatialLayer(){const e=this.getProducer();if(e)return e.maxSpatialLayer;this.logger.warn("getMaxSpatialLayer()",{message:"Not produced yet"})}enableEffects(){return a(this,void 0,void 0,(function*(){if(!c(this,tg,"f")){d(this,tg,!0,"f");try{if(c(this,Xm,"f"))return this.logger.debug("enableEffects()",{description:"Track is already processed"}),void d(this,tg,!1,"f");if("ended"===this.mediaStreamTrack.readyState)return void this.logger.warn("Track already ended",{case:"enableEffects"});const{media:e}=c(this,eg,"f");if(!e.effectsSDKInitialized)return void this.logger.warn("Effects SDK not initialized",{case:"enableEffects"});const t=Date.now();d(this,Xm,yield e.createEffectsSDKTrackProcessor(this.getLabel()),"f"),this.setOriginalTrack();const r=c(this,Xm,"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:Ct(e)}),this.disableEffects().catch((e=>{this.logger.warn("Failed to this.disableEffects() in catch{}",{track:this.logCtx,error:Ct(e)})})),c(this,rg,"f").call(this,e)}finally{d(this,tg,!1,"f")}}}))}disableEffects(){return a(this,void 0,void 0,(function*(){var e;try{if(!c(this,Xm,"f"))return void this.logger.debug("disableEffects()",{description:"Track is not processed"});this.originalTrack?yield this.replaceTrack(this.originalTrack):this.logger.warn("disableEffects()",{description:"Original track missing"}),null===(e=c(this,Xm,"f"))||void 0===e||e.stopProcessing(),d(this,Xm,void 0,"f"),this.logger.info("disableEffects()",{track:this.logCtx})}catch(e){this.logger.warn("disableEffects()",{track:this.logCtx,error:e})}}))}publish(){return a(this,arguments,void 0,(function*(e={}){var t;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(jr,this)}))}adjustEncodingPresetToCurrentMaxSpatialLayer(e){return a(this,void 0,void 0,(function*(){var t;if(!Tn(this.getPreferredCodec()))return;const{rtpSender:r}=null!==(t=this.getProducer())&&void 0!==t?t:{};if(!r)return void this.logger.warn("No rtpSender found in producer to change encodings",{maxSpatialLayer:e,trackId:this.id,producerId:this.producerId});const{encodings:n=[]}=this.getEncoderConfig(),i=n[e];if(!i)return void this.logger.warn("Skipping RTPSender params update. No target encoding found",{initialEncodings:n});this.logger.debug("Adjusting encoding parameters to max spatial layer",{targetEncoding:i,maxSpatialLayer:e});const s=r.getParameters();yield r.setParameters(Object.assign(Object.assign({},s),{encodings:[Object.assign(Object.assign({},s.encodings[0]),i)]}))}))}applyEffects(e){return a(this,void 0,void 0,(function*(){var t;try{!this.isEffectsProcessing&&Object.keys(e).length>0&&(yield this.enableEffects()),null===(t=c(this,Xm,"f"))||void 0===t||t.updateEffects(e)}catch(e){c(this,rg,"f").call(this,e)}}))}resetEffects(){var e;null===(e=c(this,Xm,"f"))||void 0===e||e.updateEffects({})}setOnLoadModels(e){var t;null===(t=c(this,Xm,"f"))||void 0===t||t.setOnLoadModels(e)}get modelsLoadProgress(){var e,t;return null!==(t=null===(e=c(this,Xm,"f"))||void 0===e?void 0:e.modelsLoadProgress)&&void 0!==t?t:0}pause(){return a(this,void 0,void 0,(function*(){yield this.mute((()=>{var e;c(this,Xm,"f")&&(null===(e=c(this,Xm,"f"))||void 0===e||e.stopProcessing(),d(this,Xm,void 0,"f"))}))}))}setOnEffectError(e){d(this,rg,e,"f")}}var ig,sg;Xm=new WeakMap,eg=new WeakMap,tg=new WeakMap,rg=new WeakMap;let og=sg=class{constructor(e){ig.set(this,void 0),d(this,ig,e("MediaStreamTrackManager"),"f")}createMediaStreamTrack(e){return a(this,arguments,void 0,(function*({label:e,constraints:t}){if(sg.isDisplayMedia(e)){const[e]=yield this.createDisplayMediaTracks(t);return e}const[r]=yield this.createUserMediaTracks(t);return r}))}static isDisplayMedia(e){return[Nn.ScreenVideo,Nn.ScreenAudio].includes(e)}createUserMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getUserMedia(e);return c(this,ig,"f").debug("createUserMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}createDisplayMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield navigator.mediaDevices.getDisplayMedia(e);return c(this,ig,"f").debug("getDisplayMediaTracks() stream created",{streamId:t.id}),t.getTracks()}))}};ig=new WeakMap,og=sg=i([at(),s(0,dt(On.LoggerFactory)),o("design:paramtypes",[Function])],og);var ag,cg,dg,ug,lg,pg,hg,fg=og;let mg=class{constructor(e,t,r,n,i,s,o,a,c){this.config=e,this.loggerFactory=t,this.audioTrackFactory=r,this.clientEventEmitter=n,this.integrationsService=i,this.processorsCache=s,this.videoTrackFactory=o,this.mediaStreamTrackManager=a,this.signalingApiClient=c,this.isDeviceLoaded=!1,this.tracks=new Map,ag.set(this,void 0),cg.set(this,null),dg.set(this,!1),ug.set(this,new Map),lg.set(this,!1),pg.set(this,!1),hg.set(this,void 0);const u=this.config.get("effectsSDKParams");d(this,hg,this.config.get("denoiser"),"f"),d(this,ag,this.loggerFactory("Media"),"f"),d(this,cg,null!=u?u:null,"f")}get mediasoupDevice(){var e;return null!==(e=this.device)&&void 0!==e||(this.device=this.createDevice()),this.device}get effectsSDKInitialized(){return c(this,dg,"f")}get effectsSDKParams(){return c(this,cg,"f")}getTrack(e){return this.tracks.get(e)}loadDevice(e){return a(this,void 0,void 0,(function*(){this.isDeviceLoaded||(yield this.mediasoupDevice.load({routerRtpCapabilities:e}),this.isDeviceLoaded=!0)}))}getTrackCodec(e){const{rtpCapabilities:t,rtpCapabilities:{codecs:r}}=this.mediasoupDevice;if(r)return r.find((t=>t.mimeType.toLowerCase()===`${e.kind}/${e.getPreferredCodec()}`));c(this,ag,"f").error("getTrackCodec()",{label:e.getLabel,rtpCapabilities:t})}createTracks({constraints:e,mediaStreamTracks:t}){return t.map((t=>{const r={mediaStreamTrack:t,constraints:e};let n;return n="audio"===t.kind?this.audioTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"AudioTrack"})):this.videoTrackFactory(Object.assign(Object.assign({},r),{loggerNamespace:"VideoTrack"})),c(this,ag,"f").debug("createTrack() track created",{trackId:n.id,kind:n.kind}),n}))}createUserMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createUserMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}createDisplayMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=yield this.mediaStreamTrackManager.createDisplayMediaTracks(e);return this.createTracks({constraints:e,mediaStreamTracks:t})}))}createCustomMediaTrack(e,t){return this.createTracks({constraints:t,mediaStreamTracks:[e]})[0]}deleteTrack(e){return a(this,void 0,void 0,(function*(){const t={trackId:e.id,label:e.getLabel(),producerId:e.producerId};try{"disableNoiseSuppression"in e&&(yield e.disableNoiseSuppression()),"disableEffects"in e&&(yield e.disableEffects())}catch(e){c(this,ag,"f").warn("deleteTrack()",Object.assign({error:e},t))}try{this.tracks.delete(e.getLabel()),e.stopMediaStreamTrack(),yield e.closeProducer()}catch(e){c(this,ag,"f").error("deleteTrack()",{error:e})}finally{c(this,ag,"f").debug("deleteTrack()",t)}}))}getAllTracks(){return Array.from(this.tracks.values())}publishedTracks(){return this.getAllTracks().filter((e=>e.isPublished))}clearTracks(){try{this.getAllTracks().forEach((e=>e.stopMediaStreamTrack()))}catch(e){c(this,ag,"f").warn("clearTracks()",{error:e})}finally{this.tracks.clear()}}unpublishTracks(){return a(this,void 0,void 0,(function*(){try{yield Promise.all(this.publishedTracks().map((e=>a(this,void 0,void 0,(function*(){return yield e.unpublish(!1)})))))}catch(e){c(this,ag,"f").warn("unpublishTracks()",{error:e})}}))}setTrack(e){this.tracks.set(e.getLabel(),e)}initEffectsSDK(){return a(this,void 0,void 0,(function*(){if(c(this,dg,"f"))return!0;if(!c(this,cg,"f"))throw c(this,ag,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Pt("effects_sdk_config_missing",new Error("Effects SDK config not provided"));const e=(e,t)=>a(this,void 0,void 0,(function*(){if(!window.tsvb)return c(this,ag,"f").info("Effects SDK not loaded, skipping initialization",{case:"initEffectsSDK"}),void e(!1);c(this,ag,"f").info("Effects SDK initializing",{case:"initEffectsSDK"});try{c(this,ug,"f").set(Nn.Camera,yield this.createEffectsSDKTrackProcessor(Nn.Camera)),c(this,ug,"f").set(Nn.CameraPreview,yield this.createEffectsSDKTrackProcessor(Nn.CameraPreview)),d(this,dg,!0,"f"),c(this,ag,"f").info("Effects SDK initialized",{case:"initEffectsSDK"}),e(!0)}catch(e){c(this,ag,"f").error("Failed to initialize Effects SDK",{error:e,case:"initEffectsSDK"}),t(e)}}));return yield new Promise(((t,r)=>{if(!window.tsvb)return c(this,ag,"f").info("Effects SDK tsvb-web.js is not ready, waiting",{case:"initEffectsSDK"}),void window.addEventListener("load",(()=>a(this,void 0,void 0,(function*(){return yield e(t,r)}))));e(t,r).catch((e=>{c(this,ag,"f").error("Failed to execute init() in initEffectsSDK",{error:Ct(e)})}))}))}))}initDenoiser(e,t){return a(this,void 0,void 0,(function*(){if(!c(this,lg,"f"))try{d(this,lg,!0,"f"),this.clientEventEmitter.emit(Ar,!0);try{yield this.integrationsService.audio.waitForInitialization}catch(e){"asdk"===c(this,hg,"f")&&(d(this,pg,!0,"f"),d(this,hg,"rnnoise","f"),this.config.set("denoiser",c(this,hg,"f")),c(this,ag,"f").debug("Set config to rnnoise denoiser",{case:"Denoiser",error:Ct(e),type:this.config.get("denoiser")}),this.clientEventEmitter.emit(Lr),this.integrationsService.init(),yield this.integrationsService.audio.waitForInitialization)}c(this,ag,"f").debug("Denoiser initialized, activating",{case:"Denoiser",type:this.integrationsService.audio.type,trackLabel:e.getLabel()});const r=e,n=this.processorsCache.get(c(this,hg,"f"),Nn.Microphone);if(!n)return void c(this,ag,"f").error("No cached trackProcessor found",{case:"Denoiser",trackLabel:e.getLabel(),type:this.integrationsService.audio.type});"asdk"===n.type&&n.setOnError(((r,n)=>{this.clientEventEmitter.emit(Ar,!0),this.fallbackToRNoise(e,{reason:r,options:t,error:n}).catch((t=>{c(this,ag,"f").error("Failed to fallback to RNNoise through onError",{case:"Denoiser",type:c(this,hg,"f"),error:Ct(t),label:e.getLabel()})})).then((()=>{this.clientEventEmitter.emit(Ar,!1)})).catch((()=>{}))})),r.setTrackProcessor(n),c(this,ag,"f").debug("Denoiser trackProcessor set, check if activation is needed",{case:"Denoiser",type:c(this,hg,"f"),shouldEnableDenoiser:null==t?void 0:t.noiseSuppression,trackLabel:e.getLabel()}),(null==t?void 0:t.noiseSuppression)&&(yield e.enableNoiseSuppression())}catch(r){if(c(this,ag,"f").warn("Failed to start noise suppression, featured original track",{case:"Denoiser",type:c(this,hg,"f"),error:Ct(r),label:e.getLabel()}),"asdk"===c(this,hg,"f"))try{c(this,ag,"f").warn("Fallback to RNNoise",{error:Ct(r)}),yield this.fallbackToRNoise(e,{options:t,reason:"ASDK init error",error:r})}catch(t){c(this,ag,"f").error("Failed to fallback to RNNoise through catch",{case:"Denoiser",type:c(this,hg,"f"),error:Ct(t),label:e.getLabel()})}}finally{this.clientEventEmitter.emit(Ar,!1),d(this,lg,!1,"f")}}))}fallbackToRNoise(e,t){return a(this,void 0,void 0,(function*(){var r;if(c(this,pg,"f"))return;if(d(this,pg,!0,"f"),"rnnoise"===c(this,hg,"f"))return;this.clientEventEmitter.emit(Lr),c(this,ag,"f").info("Fallback to RNNoise",{reason:null==t?void 0:t.reason,error:Ct(null==t?void 0:t.error),case:"Denoiser"});const n=e;yield n.disableNoiseSuppression(),n.unsetTrackProcessor(),d(this,hg,"rnnoise","f"),this.config.set("denoiser",c(this,hg,"f")),c(this,ag,"f").debug("Set config to rnnoise denoiser",{case:"Denoiser",type:this.config.get("denoiser")}),this.integrationsService.init(),yield this.integrationsService.audio.waitForInitialization;const i=this.processorsCache.get(c(this,hg,"f"),Nn.Microphone);i?(n.setTrackProcessor(i),(null===(r=null==t?void 0:t.options)||void 0===r?void 0:r.noiseSuppression)&&(yield n.enableNoiseSuppression())):c(this,ag,"f").error("No cached trackProcessor found",{case:"Denoiser",trackLabel:e.getLabel(),type:this.integrationsService.audio.type})}))}createEffectsSDKTrackProcessor(e){return a(this,void 0,void 0,(function*(){var t,r,n;if(e){const t=c(this,ug,"f").get(e);if(t)return t}if(!c(this,cg,"f"))throw c(this,ag,"f").error("Effects SDK config params not provided",{case:"initEffectsSDK"}),new Pt("effects_sdk_config_missing",new Error("Effects SDK config not provided"));const i=new Nm({loggerFactory:this.loggerFactory,customerId:null===(t=this.config.get("effectsSDKParams"))||void 0===t?void 0:t.customerId,sdk_url:null===(r=this.config.get("effectsSDKParams"))||void 0===r?void 0:r.sdk_url,api_url:null===(n=this.config.get("effectsSDKParams"))||void 0===n?void 0:n.api_url,config:this.config});return yield i.init(),c(this,ag,"f").info("Track effects processor initialized",{trackLabel:e}),i}))}handleProducerSetMaxSpatialLayer(e){return a(this,arguments,void 0,(function*({producerId:e,spatialLayer:t}){const r=this.getAllTracks().find((t=>{var r;return(null===(r=t.getProducer())||void 0===r?void 0:r.id)===e}));if(!r)return void c(this,ag,"f").warn("producerRequestMaxSpatialLayer()",{message:"Producer not found"});if(!(r instanceof ng))return void c(this,ag,"f").warn("producerRequestMaxSpatialLayer()",{message:"Wrong producer kind"});const n=null!=t?t:lm,i=r.getMaxSpatialLayer();i!==n?(r.getEncodings().length>1&&(yield r.setMaxSpatialLayer(n)),yield this.signalingApiClient.producer.setProducerMaxSpatialLayer(e,{maxSpatialLayer:n}),yield r.adjustEncodingPresetToCurrentMaxSpatialLayer(n)):c(this,ag,"f").debug("producerRequestMaxSpatialLayer()",{message:"Skip set max spatial layer",requestedSpatialLayer:n,currentMaxSpatialLayer:i})}))}static getVideoTrackTransformParams(e){var t,r;const n=e.getSettings();return{width:null!==(t=n.width)&&void 0!==t?t:um.width,height:null!==(r=n.height)&&void 0!==r?r:um.height}}static getScreenVideoTrackParams(e){var t,r;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:20},width:{max:um.width},height:{max:um.height}},encoderConfig:null!==(r=null==e?void 0:e.videoEncoderConfig)&&void 0!==r?r:{encodings:Pc}}}static getCameraVideoTrackParams(e){var t,r;return{videoTrackOptions:null!==(t=null==e?void 0:e.video)&&void 0!==t?t:{frameRate:{max:24},width:{max:um.width},height:{max:um.height}},encoderConfig:null!==(r=null==e?void 0:e.encoderConfig)&&void 0!==r?r:{encodings:Cc}}}createDevice(){const e=(e=>{const t=null!=e?e:null===navigator||void 0===navigator?void 0:navigator.userAgent;if(!t)return;const r=bn.getParser(t);return r.satisfies({"yandex browser":">=25"})&&"iOS"===r.getOSName()?void 0:r.satisfies({"yandex browser":">=23.7"})?"Chrome111":r.satisfies({"yandex browser":">=22"})?"Chrome74":r.satisfies({"Samsung Internet for Android":">=17"})?"Chrome111":void 0})();return c(this,ag,"f").debug("Creating a media device",{handlerName:null!=e?e:"not specified"}),new pd.Device({handlerName:e})}};ag=new WeakMap,cg=new WeakMap,dg=new WeakMap,ug=new WeakMap,lg=new WeakMap,pg=new WeakMap,hg=new WeakMap,mg=i([at(),s(0,dt(On.Config)),s(1,dt(On.LoggerFactory)),s(2,dt(On.AudioTrackFactory)),s(3,dt(On.ClientEventEmitter)),s(4,dt(On.IntegrationsService)),s(5,dt(On.ProcessorsCache)),s(6,dt(On.VideoTrackFactory)),s(7,dt(On.MediaStreamTrackManager)),s(8,dt(On.SignalingApiClient)),o("design:paramtypes",[bt,Function,Function,Et,Sm,bm,Function,fg,vc])],mg);var gg=mg;const vg={[Ri.PRODUCER_KIND_VIDEO]:"video",[Ri.PRODUCER_KIND_AUDIO]:"audio"},yg={[Ai.PEER_ROLE_HOST]:"host",[Ai.PEER_ROLE_AUDIENCE]:"audience"},_g={[yi.PRODUCER_LABEL_CAMERA]:Nn.Camera,[yi.PRODUCER_LABEL_MICROPHONE]:Nn.Microphone,[yi.PRODUCER_LABEL_SCREEN_VIDEO]:Nn.ScreenVideo,[yi.PRODUCER_LABEL_SCREEN_AUDIO]:Nn.ScreenAudio,[yi.PRODUCER_LABEL_CUSTOM_VIDEO]:Nn.CustomVideo,[yi.PRODUCER_LABEL_CUSTOM_AUDIO]:Nn.CustomAudio,[yi.PRODUCER_LABEL_UNKNOWN]:Nn.Unknown,[yi.PRODUCER_LABEL_UNSPECIFIED]:Nn.Unknown},bg={[vi.PEER_GROUP_MODERATOR]:"moderator",[vi.PEER_GROUP_USER]:"user"},Eg=e=>{const t=vg[e];if(!t)throw new Error(`Unknown producer kind: ${e}`);return t},wg=e=>{const t=bg[e];if(!t)throw new Error(`Unknown peer group: ${e}`);return t},Sg=e=>{const t=_g[e];if(!t)throw new Error(`Unknown producer label: ${e}`);return t},Cg=e=>{const t=yg[e];if(!t)throw new Error(`Unknown peer role: ${e}`);return t},Pg=e=>({id:e.id,channelIds:e.channelIds,groups:e.groups.map(wg),producePermissions:e.producePermissions.map(Sg),appId:e.appId,producers:e.producers.map(Tg),uid:e.uid,appData:e.appData,role:Cg(e.role),loginDate:e.loginDate}),Tg=e=>{var t;return{id:e.id,kind:Eg(e.kind),label:Sg(e.label),peerId:e.peerId,paused:e.paused,encodings:e.encodings,maxSpatialLayer:null!==(t=e.maxSpatialLayer)&&void 0!==t?t:0}},Rg=e=>{switch(e){case"moderator":return vi.PEER_GROUP_MODERATOR;case"user":return vi.PEER_GROUP_USER;default:return vi.PEER_GROUP_UNSPECIFIED}};var kg;let Dg=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,kg.set(this,void 0),d(this,kg,o("ChannelStateSyncEventHandler"),"f"),this.debouncedTriggerChannelStateEvent=Sn(this.triggerChannelStateEvent.bind(this),3e3),this.watchNetworkState()}handleChannelStateEvent(e){return a(this,void 0,void 0,(function*(){this.network.peersLoaded?yield this.restoreState(e):this.loadChannelState(e),this.clientEventEmitter.emit(Or)}))}watchNetworkState(){this.clientEventEmitter.on(Ir,(()=>{this.debouncedTriggerChannelStateEvent()}))}triggerChannelStateEvent(){return a(this,void 0,void 0,(function*(){const e=()=>a(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>a(this,void 0,void 0,(function*(){const r=yield this.network.triggerChannelStateEvent("host"),n=setTimeout((()=>{this.eventsQueue.isMessageReceived(r)?(c(this,kg,"f").info("Channel state event received",{case:"ChannelStateSynchronizer.triggerChannelStateEvent"}),e()):t(new Error("Channel state event not received"))}),5e3),i=()=>{clearTimeout(n),this.clientEventEmitter.off(Dr,i),e()};this.clientEventEmitter.on(Dr,i)}))))}));try{yield An(e,{maxRetries:5,actionName:"triggerChannelStateEventWithRetry",logger:c(this,kg,"f")})}catch(e){c(this,kg,"f").warn("Failed to trigger channel state event",{case:"ChannelStateSynchronizer.triggerChannelStateEvent",error:Ct(e)})}}))}loadChannelState(e){c(this,kg,"f").info("Loading channel state",{case:"loadChannelState"});try{const t=this.peers.hosts().map((e=>e.shortData)),r=e.peers.filter((e=>e.role===Ai.PEER_ROLE_HOST));this.setMissingPeers(t,r),this.restoreLocalPeersState(r),this.network.peersLoaded=!0}catch(e){c(this,kg,"f").error("Failed to load channel state",{case:"loadState",error:Ct(e)})}}restoreState(e){return a(this,void 0,void 0,(function*(){const{peers:t}=e,r={missingPeers:[],removedPeers:[],missingProducers:[],removedProducers:[],fixedProducersState:[],fixedConsumersState:[],restoredAppDataPeers:[]};try{if(!this.network.isNetworkActive)return c(this,kg,"f").info("Connection inactive, skipping restore local state",{case:"restoreLocalState"}),r;c(this,kg,"f").info("Restoring local state",{case:"restoreLocalState"});const e=this.peers.hosts().map((e=>e.shortData)),n=t.filter((e=>e.role===Ai.PEER_ROLE_HOST)),{removedProducers:i,fixedProducersState:s}=yield this.restoreRemoteProducersState(n);r.fixedProducersState.push(...s),r.removedProducers.push(...i),r.removedPeers.push(...this.removeUnnecessaryPeers(e,n)),r.missingPeers.push(...this.setMissingPeers(e,n));const o=this.restoreLocalPeersState(n);return r.missingProducers.push(...o.missingProducers),r.removedProducers.push(...o.removedProducers),r.restoredAppDataPeers.push(...o.restoredAppDataPeers),r.fixedProducersState.push(...o.fixedProducersState),r.fixedConsumersState.push(...o.fixedConsumersState),r}catch(e){return c(this,kg,"f").info("Failed to restore local state",{case:"restoreLocalState",error:Ct(e)}),r}}))}restoreRemoteProducersState(e){return a(this,void 0,void 0,(function*(){const t={removedProducers:[],fixedProducersState:[]},r=this.myPeer.get(),n=e.find((e=>e.id===this.myPeer.id));if(!r||!n)return t;const i=new Map;this.media.getAllTracks().forEach((e=>{e.producerId&&i.set(e.producerId,e)}));const s=new Set(i.keys()),o=n.producers.filter((e=>!s.has(e.id)));yield Promise.all(o.map((e=>a(this,void 0,void 0,(function*(){yield this.network.closeRemoteProducer(e.id),r.producers.delete(e.id),t.removedProducers.push(e.id),c(this,kg,"f").info("Unnecessary local producer closed",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId})})))));const d=[];for(const e of n.producers){const t=i.get(e.id);t&&(t.isPaused!==e.paused&&d.push({cp:e,localTrack:t}))}return yield Promise.all(d.map((e=>a(this,[e],void 0,(function*({cp:e,localTrack:r}){r.isPaused?yield this.network.pauseRemoteProducer(e.id):yield this.network.resumeRemoteProducer(e.id),t.fixedProducersState.push(e.id),e.paused=r.isPaused,c(this,kg,"f").info("Remote producer state repaired",{case:"restoreLocalState",removedProducerId:e.id,removedProducerPeerId:e.peerId,paused:r.isPaused})}))))),t}))}removeUnnecessaryPeers(e,t){const r=[];return e.filter((e=>!t.find((t=>t.id===e.id)))).forEach((e=>{this.peers.remove(e.id).catch((e=>{c(this,kg,"f").error("Failed to remove peer",{error:Ct(e)})})),r.push(e.id),c(this,kg,"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(Pg(t));r.push(n.id),c(this,kg,"f").info("Missing peer added to storage",{case:"restoreLocalState",peerId:t.id})})),r}restoreLocalPeersState(e){const t=new Map(e.map((e=>[e.id,e]))),r=this.peers.hosts(),n={removedProducers:[],missingProducers:[],restoredAppDataPeers:[],fixedConsumersState:[],fixedProducersState:[]};return r.forEach((e=>{const r=t.get(e.id);if(!r)return void c(this,kg,"f").warn("Found new local peer, skip restoring state",{case:"restoreLocalState",newPeerId:e.id});n.removedProducers.push(...this.removeUnnecessaryProducers(e,r));this.restoreAppData(e,r)&&n.restoredAppDataPeers.push(e.id);const{fixedProducersState:i,fixedConsumersState:s,missingProducers:o}=this.restoreTracksState(e,r);n.fixedProducersState.push(...i),n.fixedConsumersState.push(...s),n.missingProducers.push(...o)})),c(this,kg,"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(sn,t),r.push(t.id),c(this,kg,"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(nn,Tg(t)),r.missingProducers.push(t.id),void c(this,kg,"f").info("Missing producer added to storage",{case:"restoreLocalState",producerId:t.id,producerPeerId:t.peerId});const{paused:s}=t;if(i.paused!==s){i.setPaused(s);const n=i.paused?Yr:$r;e.observer.safeEmit(n,{producerId:i.id,kind:i.kind,label:i.label,paused:i.paused}),r.fixedProducersState.push(t.id),c(this,kg,"f").info("Producer state fixed",{case:"restoreLocalState",producerId:t.id,producerPeerId:t.peerId})}const o=e.tracks.get(i.label);if((null==o?void 0:o.consumerId)&&(null===(n=o.consumer)||void 0===n?void 0:n.paused)!==t.paused){const{consumerId:n}=o,s=i.paused?dn:un;e.observer.safeEmit(s,n),r.fixedConsumersState.push(n),c(this,kg,"f").info("Consumer state fixed",{case:"restoreLocalState",consumerId:n,consumerProducerId:t.id,consumerProducerPeerId:t.peerId})}})),r}restoreAppData(e,t){return!wn(e.appData,t.appData)&&(e.observer.emit(mr,t.appData),c(this,kg,"f").info("Application data restored",{case:"restoreLocalState",peerId:e.id,appData:t.appData}),!0)}};kg=new WeakMap,Dg=i([at(),s(0,dt(On.Network)),s(1,dt(On.Media)),s(2,dt(On.MyPeer)),s(3,dt(On.EventsQueue)),s(4,dt(On.ClientEventEmitter)),s(5,dt(On.Peers)),s(6,dt(On.LoggerFactory)),o("design:paramtypes",[Kc,gg,ws,bs,Et,Qc,Function])],Dg);var Ig,Ag=Dg;let Og=class{constructor(e,t,r,n,i){this.peers=e,this.clientEventEmitter=t,this.channelStateSyncEventHandler=n,this.channelStateSynchronizer=i,Ig.set(this,void 0),d(this,Ig,r("ChannelEvents"),"f")}handleChannelEvent(e){return a(this,void 0,void 0,(function*(){switch(e.eventType){case Hi.CHANNEL_EVENT_TYPE_CHANNEL_STATE:yield this.handleChannelState(e);break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_STATE_SHORT:this.handleChannelStateShort(e);break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_MANAGEMENT_EVENT:this.handleChannelManagementEvent(e);break;case Hi.CHANNEL_EVENT_TYPE_PEER_JOINED:this.handlePeerJoined(e);break;case Hi.CHANNEL_EVENT_TYPE_PEER_LEFT:this.handlePeerLeft(e);break;case Hi.CHANNEL_EVENT_TYPE_PEER_APP_DATA_CHANGED:this.handlePeerAppDataChanged(e);break;case Hi.CHANNEL_EVENT_TYPE_PEER_GROUP_CHANGED:this.handlePeerGroupsChanged(e);break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_ACQUIRED:this.handleChannelActivityConfirmationAcquired();break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_EXPIRED:this.handleChannelActivityConfirmationExpired();break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED:this.handleChannelActivityConfirmationRequired(e);break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_CHANGED:this.handleChannelProducePermissionsChanged(e);break;case Hi.CHANNEL_EVENT_TYPE_PEER_PRODUCE_PERMISSIONS_CHANGED:this.handlePeerProducePermissionsChanged(e);break;case Hi.CHANNEL_EVENT_TYPE_CHANNEL_PRODUCE_PERMISSIONS_DELETED:this.handleChannelProducePermissionsDeleted(e);break;default:throw new Error(`Unsupported event type: ${e.eventType}`)}}))}handleChannelManagementEvent(e){if(!e.channelManagementEvent)throw new Error("Missing channelManagementEvent in CHANNEL_MANAGEMENT_EVENT");const t=e.channelManagementEvent.event;this.clientEventEmitter.safeEmit(gr,t),c(this,Ig,"f").debug("New channel event",{event:t})}handlePeerJoined(e){if(!e.peer)throw new Error("Missing peer in PEER_APP_DATA_CHANGED event");const t=this.peers.add(Pg(e.peer));c(this,Ig,"f").debug("Peer joined to the channel",{peer:Es(t)})}handlePeerLeft(e){if(!e.peer)throw new Error("Missing peer in PEER_LEFT event");this.peers.remove(e.peer.id).catch((e=>{c(this,Ig,"f").debug("Failed to remove peer",{error:Ct(e)})})),c(this,Ig,"f").debug("Peer left the channel",{peerId:e.peer.id})}handleChannelState(e){return a(this,void 0,void 0,(function*(){if(!e.channelState)throw new Error("Missing channelState in CHANNEL_STATE event");try{yield this.channelStateSynchronizer.handleChannelStateEvent(e.channelState)}catch(e){c(this,Ig,"f").error("Failed to restore channel state",{case:"restoreLocalState",error:Ct(e)})}}))}handleChannelStateShort(e){if(!e.channelStateShort)throw new Error("Missing channelStateShort in CHANNEL_STATE_SHORT event");this.channelStateSyncEventHandler.handleChannelStateShort(e.channelStateShort).catch((e=>{c(this,Ig,"f").error("Failed to handle channel state short event",{error:Ct(e)})}))}handlePeerAppDataChanged(e){if(!e.peer)throw new Error("Missing peer in PEER_APP_DATA_CHANGED event");const t=this.peers.get(e.peer.id);t&&t.observer.emit(mr,e.peer.appData)}handlePeerGroupsChanged(e){if(!e.peer)throw new Error("Missing peer in PEER_GROUP_CHANGED event");const t=this.peers.get(e.peer.id);null==t||t.handleGroupsChange(e.peer.groups.map(wg))}handleChannelActivityConfirmationExpired(){this.clientEventEmitter.safeEmit(Er),c(this,Ig,"f").info("Notify the channel that it has disconnected due to the activity confirmation expiring",{})}handleChannelActivityConfirmationAcquired(){this.clientEventEmitter.safeEmit(br),c(this,Ig,"f").info("Notify the channel that the activity has been acquired.",{})}handleChannelActivityConfirmationRequired(e){if(!e.channelActivityConfirmationTime)throw new Error("Missing channelActivityConfirmationTime in CHANNEL_ACTIVITY_CONFIRMATION_REQUIRED event");const t=e.channelActivityConfirmationTime;this.clientEventEmitter.safeEmit(_r,t),c(this,Ig,"f").info("Notify the channel that activity confirmation is required",{event:e.channelActivityConfirmationTime})}handleChannelProducePermissionsChanged(e){if(!e.channelProducePermissions)throw new Error("Missing channelProducePermissions in CHANNEL_PRODUCE_PERMISSIONS_CHANGED event");const{groups:t}=e.channelProducePermissions,r=this.peers.all().filter((e=>e.groups.some((e=>t.includes(Rg(e)))))),n=e.channelProducePermissions.producePermissions.map(Sg),i=e.channelProducePermissions.changedProducePermissions.map(Sg);r.forEach((e=>{const t=Array.from(new Set([...e.producePermissions,...i])).filter((e=>!i.includes(e)||n.includes(e)));e.handleProducePermissionsChange(t)})),c(this,Ig,"f").info("Peers changed produce permissions",{groups:t,producePermissions:n})}handlePeerProducePermissionsChanged(e){if(!e.peer)throw new Error("Missing peer in PEER_PRODUCE_PERMISSIONS_CHANGED event");const t=this.peers.get(e.peer.id);if(!t)return;const r=e.peer.producePermissions.map(Sg);t.handleProducePermissionsChange(r)}handleChannelProducePermissionsDeleted(e){if(!e.channelProducePermissions)throw new Error("Missing channelProducePermissions in CHANNEL_PRODUCE_PERMISSIONS_DELETED event");const{groups:t}=e.channelProducePermissions,r=this.peers.all().filter((e=>e.groups.some((e=>t.includes(Rg(e)))))),n=e.channelProducePermissions.producePermissions.map(Sg);r.forEach((e=>{const t=e.producePermissions.filter((e=>!n.includes(e)));e.handleProducePermissionsChange(t)})),c(this,Ig,"f").info("Peers deleted produce permissions",{groups:t,producePermissions:n})}};Ig=new WeakMap,Og=i([at(),s(0,dt(On.Peers)),s(1,dt(On.ClientEventEmitter)),s(2,dt(On.LoggerFactory)),s(3,dt(On.ChannelStateSyncEventHandler)),s(4,dt(On.ChannelStateSynchronizer)),o("design:paramtypes",[Qc,Et,Function,ld,Ag])],Og);var Ng=Og,Mg={},Lg=l&&l.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{c(n.next(e))}catch(e){s(e)}}function a(e){try{c(n.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(Mg,"__esModule",{value:!0});var xg,Fg,jg=Mg.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 Lg(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 Lg(this,void 0,void 0,(function*(){const e=this.pendingTasks[0];e&&(yield this.executeTask(e),this.pendingTasks.shift(),this.next())}))}executeTask(e){return Lg(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)}}}))}};let Ug=class{constructor(e,t,r,n,i){this.media=e,this.internalEventEmitter=t,this.peersStorage=r,this.clientEventEmitter=n,xg.set(this,new jg),Fg.set(this,void 0),d(this,Fg,i("MediaEvents"),"f")}handleMediaEvent(e){var t;switch(e.eventType){case is.MEDIA_EVENT_TYPE_PRODUCER_CREATED:this.handleProducerCreated(e);break;case is.MEDIA_EVENT_TYPE_PRODUCER_CLOSED:this.handleProducerClosed(e);break;case is.MEDIA_EVENT_TYPE_PRODUCER_PAUSED:this.handleProducerPaused(e);break;case is.MEDIA_EVENT_TYPE_PRODUCER_RESUMED:this.handleProducerResumed(e);break;case is.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED:this.handleProducerMaxSpatialLayerChanged(e);break;case is.MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED:this.handleProducerRequestMaxSpatialLayer(e).catch((e=>{c(this,Fg,"f").error("Failed to handle producer max spatial layer requested event",{error:Ct(e)})}));break;case is.MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED:this.handleProducerForciblyClosed(e).catch((e=>{c(this,Fg,"f").error("Failed to handle producer forcibly closed event",{error:Ct(e)})}));break;case is.MEDIA_EVENT_TYPE_CONSUMER_CLOSED:c(this,Fg,"f").debug("Close consumer event received, skip",{consumerId:null===(t=e.consumer)||void 0===t?void 0:t.id});break;case is.MEDIA_EVENT_TYPE_CONSUMER_RESUMED:this.handleConsumerResumed(e);break;case is.MEDIA_EVENT_TYPE_CONSUMER_PAUSED:this.handleConsumerPaused(e);break;case is.MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED:this.handleConsumerPreferredLayersChanged(e);break;case is.MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT:this.handleTransportConnectionTimeout(e);break;default:throw new Error(`Unsupported event type: ${e.eventType}`)}}handleProducerCreated(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_CREATED");const t=this.peersStorage.get(e.producer.peerId);null==t||t.observer.safeEmit(nn,Tg(e.producer))}handleProducerClosed(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_CLOSED");const t=this.peersStorage.get(e.producer.peerId);null==t||t.observer.safeEmit(sn,Tg(e.producer))}handleProducerPaused(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_PAUSED");const t=this.peersStorage.get(e.producer.peerId),r=null==t?void 0:t.producers.get(e.producer.id);t?r?(r.setPaused(!0),t.observer.safeEmit(Yr,{producerId:r.id,kind:r.kind,label:r.label,paused:r.paused})):t.observer.safeEmit(nn,Object.assign(Object.assign({},Tg(e.producer)),{paused:!0})):c(this,Fg,"f").warn("Peer not found for producer paused event",{peerId:e.producer.peerId})}handleProducerResumed(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_RESUMED");const t=this.peersStorage.get(e.producer.peerId),r=null==t?void 0:t.producers.get(e.producer.id);t?r?(r.setPaused(!1),t.observer.safeEmit($r,{producerId:r.id,kind:r.kind,label:r.label,paused:r.paused})):t.observer.safeEmit(nn,Object.assign(Object.assign({},Tg(e.producer)),{paused:!1})):c(this,Fg,"f").warn("Peer not found for producer resumed event",{peerId:e.producer.peerId})}handleProducerMaxSpatialLayerChanged(e){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_CHANGED");if(void 0===e.producer.maxSpatialLayer)return;const t=this.peersStorage.get(e.producer.peerId);null==t||t.observer.safeEmit(on,{peerId:e.producer.peerId,producerId:e.producer.id,spatialLayer:e.producer.maxSpatialLayer})}handleProducerRequestMaxSpatialLayer(e){return a(this,void 0,void 0,(function*(){if(!e.producerSpatialLayerRequest)throw new Error("Missing producerSpatialLayerRequest in MEDIA_EVENT_TYPE_PRODUCER_MAX_SPATIAL_LAYER_REQUESTED");const{producerId:t,spatialLayer:r}=e.producerSpatialLayerRequest;yield c(this,xg,"f").push((()=>a(this,void 0,void 0,(function*(){yield this.media.handleProducerSetMaxSpatialLayer({producerId:t,spatialLayer:r})}))),an)}))}handleProducerForciblyClosed(e){return a(this,void 0,void 0,(function*(){if(!e.producer)throw new Error("Missing producer in MEDIA_EVENT_TYPE_PRODUCER_FORCIBLY_CLOSED");const t=Sg(e.producer.label),r=this.media.getTrack(t);if(!r)return;r.stopMediaStreamTrack(),this.internalEventEmitter.safeEmit(Wr,r);const n={label:t};this.clientEventEmitter.emit(Pr,n),yield this.media.deleteTrack(r)}))}handleConsumerResumed(e){if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_RESUMED");const t=this.peersStorage.get(e.consumer.producerPeerId);null==t||t.observer.safeEmit(un,e.consumer.id)}handleConsumerPaused(e){if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_PAUSED");const t=this.peersStorage.get(e.consumer.producerPeerId);null==t||t.observer.safeEmit(dn,e.consumer.id)}handleConsumerPreferredLayersChanged(e){var t;if(!e.consumer)throw new Error("Missing consumer in MEDIA_EVENT_TYPE_CONSUMER_PREFERRED_LAYERS_CHANGED");if(void 0===e.consumer.spatialLayer)return;const r=e.consumer.producerPeerId||e.consumer.peerId,n=this.peersStorage.get(r);null==n||n.observer.safeEmit(ln,{consumerId:e.consumer.id,spatialLayer:e.consumer.spatialLayer,temporalLayer:null!==(t=e.consumer.temporalLayer)&&void 0!==t?t:hm})}handleTransportConnectionTimeout(e){if(!e.transportConnectionTimeout)throw new Error("Missing transportConnectionTimeout in MEDIA_EVENT_TYPE_TRANSPORT_CONNECTION_TIMEOUT");c(this,Fg,"f").warn("Transport connection timed out",{transportId:e.transportConnectionTimeout.transportId,direction:e.transportConnectionTimeout.direction,timeout:e.transportConnectionTimeout.timeout,reason:e.transportConnectionTimeout.reason})}};xg=new WeakMap,Fg=new WeakMap,Ug=i([at(),s(0,dt(On.Media)),s(1,dt(On.InternalEventEmitter)),s(2,dt(On.PeersStorage)),s(3,dt(On.ClientEventEmitter)),s(4,dt(On.LoggerFactory)),o("design:paramtypes",[gg,Et,Sc,Et,Function])],Ug);var Vg,Bg=Ug;let Wg=class{constructor(){Vg.set(this,new Map)}set(e,t){c(this,Vg,"f").set(e,{label:e,producerId:t})}get(e){return c(this,Vg,"f").get(e)}has(e){return c(this,Vg,"f").has(e)}delete(e){c(this,Vg,"f").delete(e)}entries(){return Array.from(c(this,Vg,"f").values())}};Vg=new WeakMap,Wg=i([at()],Wg);var Hg,qg=Wg;let zg=class{constructor(e,t,r){this.network=e,this.storage=t,Hg.set(this,void 0),d(this,Hg,r("ProducerCloseManager"),"f")}close(e,t){return a(this,void 0,void 0,(function*(){try{const r=yield this.sendCloseRequest(t);if(this.storage.delete(e),!r)return;c(this,Hg,"f").info("Remote producer closed",{label:e,producerId:t})}catch(r){this.storage.set(e,t),c(this,Hg,"f").warn("Failed to close remote producer, queued for retry",{label:e,producerId:t,error:Ct(r)})}}))}ensureNoPending(e){return a(this,void 0,void 0,(function*(){const t=this.storage.get(e);t&&(yield this.flushEntry(t))}))}flushPending(){return a(this,void 0,void 0,(function*(){const e=this.storage.entries();for(const t of e)try{yield this.flushEntry(t)}catch(e){}}))}flushEntry(e){return a(this,void 0,void 0,(function*(){try{yield An((()=>a(this,void 0,void 0,(function*(){yield this.sendCloseRequest(e.producerId)}))),{maxRetries:5,minBackoffDelayMs:200,maxBackoffDelayMs:1e3,actionName:"closeRemoteProducer",logger:c(this,Hg,"f")}),this.storage.delete(e.label),c(this,Hg,"f").info("Pending remote producer closed",{label:e.label,producerId:e.producerId})}catch(t){throw c(this,Hg,"f").warn("Failed to close pending remote producer",{label:e.label,producerId:e.producerId,error:Ct(t)}),t}}))}sendCloseRequest(e){return a(this,void 0,void 0,(function*(){try{return yield this.network.closeRemoteProducer(e),!0}catch(t){if(t instanceof ec)return c(this,Hg,"f").debug("Remote producer maybe already closed",{producerId:e}),!1;throw t}}))}};Hg=new WeakMap,zg=i([at(),s(0,dt(On.Network)),s(1,dt(On.PendingClosureProducerStorage)),s(2,dt(On.LoggerFactory)),o("design:paramtypes",[Function,qg,Function])],zg);var Gg,Yg,$g,Jg,Kg,Qg,Zg=zg;const Xg=["send","recv"];let ev=Qg=class{constructor(e,t){this.network=e,this.loggerFactory=t,Gg.set(this,!1),Yg.set(this,new Map),$g.set(this,new Set),Jg.set(this,new Map),Kg.set(this,void 0),this.handleTransportState=({state:e,direction:t})=>{if(!c(this,Gg,"f"))return;if(c(this,$g,"f").has(t))return;if(c(this,Jg,"f").has(t))return;if(!["disconnected","failed"].includes(e))return;const r=this.recordDisconnectAndGetCount(t);r&&(r<=3||(c(this,Kg,"f").warn("transport instability detected. Escalating to relay",{direction:t,disconnectCount:r}),this.escalateDirectionToRelay(t).catch((e=>{c(this,Kg,"f").warn("Failed to apply relay policy",{direction:t,error:Ct(e)})}))))},d(this,Kg,this.loggerFactory("NetworkTransportPolicyManager"),"f")}startMonitoring(){c(this,Gg,"f")||(this.refreshDirectionRelayState(),c(this,Yg,"f").clear(),d(this,Gg,!0,"f"),this.network.observer.on(hn,this.handleTransportState))}stopMonitoring(){c(this,Gg,"f")&&(this.network.observer.off(hn,this.handleTransportState),d(this,Gg,!1,"f"),c(this,Yg,"f").clear())}changeIceTransportPolicy(e){return a(this,void 0,void 0,(function*(){yield Promise.all(c(this,Jg,"f").values()),yield Promise.all(Xg.map((t=>a(this,void 0,void 0,(function*(){return yield this.applyRelayPolicy(t,e)}))))),c(this,Yg,"f").clear(),"all"!==e?this.stopMonitoring():c(this,$g,"f").clear()}))}recordDisconnectAndGetCount(e){var t;const r=Date.now(),n=null!==(t=c(this,Yg,"f").get(e))&&void 0!==t?t:[],i=n[n.length-1];if(Qg.isDuplicateDisconnect(i,r))return;const s=Qg.getDisconnectsInWindow(n,r);return s.push(r),c(this,Yg,"f").set(e,s),s.length}applyRelayPolicy(e,t){return a(this,void 0,void 0,(function*(){const r=this.getTransportByDirection(e);if(!r)return;const n=Qg.getPeerConnection(r);n&&(n.setConfiguration(Object.assign(Object.assign({},n.getConfiguration()),{iceTransportPolicy:t})),yield this.network.restartIce(r),"relay"===t?c(this,$g,"f").add(e):c(this,$g,"f").delete(e))}))}escalateDirectionToRelay(e){return a(this,void 0,void 0,(function*(){if(c(this,$g,"f").has(e))return;const t=c(this,Jg,"f").get(e);if(t)return void(yield t);const r=(()=>a(this,void 0,void 0,(function*(){yield this.applyRelayPolicy(e,"relay"),c(this,Yg,"f").delete(e)})))();c(this,Jg,"f").set(e,r);try{yield r}finally{c(this,Jg,"f").delete(e)}}))}refreshDirectionRelayState(){Xg.forEach((e=>{const t=this.getTransportByDirection(e),r=Qg.getPeerConnection(t);"relay"!==(null==r?void 0:r.getConfiguration().iceTransportPolicy)?c(this,$g,"f").delete(e):c(this,$g,"f").add(e)}))}getTransportByDirection(e){return"send"===e?this.network.sendTransport:this.network.receiveTransport}static getPeerConnection(e){var t;return null===(t=null==e?void 0:e.handler)||void 0===t?void 0:t._pc}static getDisconnectsInWindow(e,t){const r=t-3e4;return e.filter((e=>e>=r))}static isDuplicateDisconnect(e,t){return"number"==typeof e&&t-e<400}};Gg=new WeakMap,Yg=new WeakMap,$g=new WeakMap,Jg=new WeakMap,Kg=new WeakMap,ev=Qg=i([at(),s(0,dt(On.Network)),s(1,dt(On.LoggerFactory)),o("design:paramtypes",[Kc,Function])],ev);var tv=ev;const rv=new Error("request for lock canceled");var nv=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){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};class iv{constructor(e,t=rv){this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise(((r,n)=>{const i={resolve:r,reject:n,weight:e,priority:t},s=sv(this._queue,(e=>t<=e.priority));-1===s&&e<=this._value?this._dispatchItem(i):this._queue.splice(s+1,0,i)}))}runExclusive(e){return nv(this,arguments,void 0,(function*(e,t=1,r=0){const[n,i]=yield this.acquire(t,r);try{return yield e(n)}finally{i()}}))}waitForUnlock(e=1,t=0){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise((r=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),function(e,t){const r=sv(e,(e=>t.priority<=e.priority));e.splice(r+1,0,t)}(this._weightedWaiters[e-1],{resolve:r,priority:t})}))}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach((e=>e.reject(this._cancelError))),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(0===this._queue.length)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach((e=>e.resolve())),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const r=this._weightedWaiters[t-1];if(!r)continue;const n=r.findIndex((t=>t.priority<=e));(-1===n?r:r.splice(0,n)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(0===this._queue.length||this._queue[0].priority<t)&&e<=this._value}}function sv(e,t){for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1}var ov,av=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){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((n=n.apply(e,t||[])).next())}))};class cv{constructor(e){this._semaphore=new iv(1,e)}acquire(){return av(this,arguments,void 0,(function*(e=0){const[,t]=yield this._semaphore.acquire(1,e);return t}))}runExclusive(e,t=0){return this._semaphore.runExclusive((()=>e()),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(e=0){return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}let dv=class{constructor(){ov.set(this,new Map)}lock(e){return a(this,void 0,void 0,(function*(){let t=c(this,ov,"f").get(e);return t||(t=new cv,c(this,ov,"f").set(e,t)),t.isLocked()&&(yield t.waitForUnlock()),yield t.acquire()}))}isLocked(e){const t=c(this,ov,"f").get(e);return!!t&&t.isLocked()}waitForUnlock(e){return a(this,void 0,void 0,(function*(){const t=c(this,ov,"f").get(e);(null==t?void 0:t.isLocked())?yield t.waitForUnlock():yield Promise.resolve()}))}};ov=new WeakMap,dv=i([at()],dv);var uv,lv=dv;let pv=class{constructor(e,t){this.clientEventEmitter=e,this.isEnableVideoDevicesLock=!1,this.isEnableAudioDevicesLock=!1,this.isDevicesDetected=!1,this.availableVideoDevices=[],this.availableAudioDevices=[],uv.set(this,void 0),d(this,uv,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(){return a(this,arguments,void 0,(function*(e={video:!0,audio:!0}){try{return(yield navigator.mediaDevices.getUserMedia(e)).getTracks()}catch(t){c(this,uv,"f").error("getUserMedia()",{error:t,constraints:e});const r=t instanceof Error?t.name:void 0;if("NotAllowedError"===r)throw new Error(Mn.NotAllowedError);if("NotReadableError"===r)throw new Error(Mn.DeviceIsBusy);if("NotFoundError"===r)throw new Error(Mn.NotFoundError);throw new Error(Mn.RequestDevicesUnknownError)}}))}hasAvailableMediaDevicesList(){return a(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices();if(0===e.length)return!0;return e.every((e=>e.deviceId&&e.label))}))}refreshAvailableMediaDevicesList(){return a(this,void 0,void 0,(function*(){const e=yield navigator.mediaDevices.enumerateDevices(),t=[],r=[];e.forEach((e=>{""!==e.deviceId&&("videoinput"===e.kind&&t.push(e),"audioinput"===e.kind&&r.push(e))})),this.setAvailableVideoDevices(t),this.setAvailableAudioDevices(r);const n=({label:e,kind:t})=>({label:e,kind:t});return c(this,uv,"f").debug("Devices list updated",{videoDevices:t.map(n),audioDevices:r.map(n)}),e}))}detectDevices(e){return a(this,void 0,void 0,(function*(){if(this.isDevicesDetected&&!e)return;(yield this.hasAvailableMediaDevicesList())||(yield this.tryToAccessDevices()),this.isDevicesDetected=!0;const t=yield this.refreshAvailableMediaDevicesList(),r=t.some((e=>"audioinput"===e.kind)),n=t.some((e=>"videoinput"===e.kind));if(!r&&!n)throw new Error(Mn.NoDevices)}))}deviceChangeHandler(){return a(this,void 0,void 0,(function*(){if(!this.isDevicesDetected)return;yield this.refreshAvailableMediaDevicesList();const e={audio:this.availableAudioDevices,video:this.availableVideoDevices};this.clientEventEmitter.safeEmit(Sr,e)}))}listenDevices(){navigator.mediaDevices.addEventListener("devicechange",this.deviceChangeHandler)}assertHasAccessToMediaDevices(){return a(this,arguments,void 0,(function*(e={video:!0,audio:!0}){(yield this.requestMediaDevicesAccess(e)).forEach((e=>e.stop()))}))}tryToAccessDevices(){return a(this,void 0,void 0,(function*(){try{(yield this.requestMediaDevicesAccess()).forEach((e=>e.stop()))}catch(t){const r=(e=>{if(e instanceof Error)return e.message;if("string"==typeof e)return e;if(e&&"object"==typeof e&&"message"in e){const t=e.message;return"string"==typeof t?t:void 0}})(t);if(!r||(e=r,![Mn.NotFoundError,Mn.NotAllowedError,Mn.DeviceIsBusy].includes(e)))throw t;r!==Mn.DeviceIsBusy&&(yield this.assertHasAccessToMediaDevices({audio:!0}),yield this.assertHasAccessToMediaDevices({video:!0}))}var e}))}};uv=new WeakMap,pv=i([at(),s(0,dt(On.ClientEventEmitter)),s(1,dt(On.LoggerFactory)),o("design:paramtypes",[Et,Function])],pv);var hv,fv,mv,gv,vv,yv,_v=pv;class bv{constructor({transport:e,statsHandler:t}){hv.set(this,void 0),this.handleWebRTCStats(e,t)}get connectionStats(){return c(this,hv,"f")}handleWebRTCStats(e,t){t.addConnectionHandler(e.id,this.setConnectionStats.bind(this)),e.observer.once("close",(()=>{t.removeConnectionHandler(e.id)}))}setConnectionStats(e){d(this,hv,e,"f")}}hv=new WeakMap;let Ev=class{constructor(){fv.set(this,new Map),mv.set(this,new Map),gv.set(this,new Map),vv.set(this,new Map),yv.set(this,new Map)}handle(e){e.forEach((({id:e,stats:t})=>{var r;null===(r=c(this,fv,"f").get(e))||void 0===r||r(t.connection),t.video.inbound.forEach((e=>{var t;return null===(t=c(this,mv,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.inbound.forEach((e=>{var t;return null===(t=c(this,gv,"f").get(e.trackIdentifier))||void 0===t?void 0:t(e)})),t.video.outbound.forEach((e=>{var t;return null===(t=c(this,vv,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)})),t.audio.outbound.forEach((e=>{var t;return null===(t=c(this,yv,"f").get(e.track.trackIdentifier))||void 0===t?void 0:t(e)}))}))}addConnectionHandler(e,t){c(this,fv,"f").set(e,t)}addInboundVideoHandler(e,t){c(this,mv,"f").set(e,t)}addInboundAudioHandler(e,t){c(this,gv,"f").set(e,t)}addOutboundVideoHandler(e,t){c(this,vv,"f").set(e,t)}addOutboundAudioHandler(e,t){c(this,yv,"f").set(e,t)}removeConnectionHandler(e){c(this,fv,"f").delete(e)}removeInboundVideoHandler(e){c(this,mv,"f").delete(e)}removeInboundAudioHandler(e){c(this,vv,"f").delete(e)}removeOutboundVideoHandler(e){c(this,yv,"f").delete(e)}removeOutboundAudioHandler(e){c(this,yv,"f").delete(e)}clear(){c(this,fv,"f").clear(),c(this,mv,"f").clear(),c(this,gv,"f").clear(),c(this,vv,"f").clear(),c(this,yv,"f").clear()}};fv=new WeakMap,mv=new WeakMap,gv=new WeakMap,vv=new WeakMap,yv=new WeakMap,Ev=i([at()],Ev);var wv,Sv,Cv,Pv,Tv,Rv,kv=Ev;let Dv=class{constructor(e){wv.set(this,!1),Sv.set(this,void 0),Cv.set(this,void 0),Pv.set(this,void 0),Tv.set(this,void 0),Rv.set(this,void 0),d(this,Sv,e("IntegrationsService"),"f")}init({sendTransportConnectionManager:e,receiveTransportConnectionManager:t,media:r,peers:n}){d(this,Cv,e,"f"),d(this,Pv,t,"f"),d(this,Tv,r,"f"),d(this,Rv,n,"f"),d(this,wv,!0,"f")}getStats(){try{return this.doGetStats()}catch(e){return c(this,Sv,"f").error("Failed to get stats",{error:Ct(e)}),{}}}clear(){d(this,Cv,void 0,"f"),d(this,Pv,void 0,"f"),d(this,Tv,void 0,"f"),d(this,Rv,void 0,"f")}doGetStats(){var e,t,r,n;if(!c(this,wv,"f"))throw new Error("TransportsStatsProvider is not initialized");return Object.assign(Object.assign({},(null===(t=null===(e=c(this,Cv,"f"))||void 0===e?void 0:e.connectionStats)||void 0===t?void 0:t.id)?{outbound:Object.assign(Object.assign({},c(this,Cv,"f").connectionStats),{bitrate:this.calculateOutboundTracksBitrate()})}:{}),(null===(n=null===(r=c(this,Pv,"f"))||void 0===r?void 0:r.connectionStats)||void 0===n?void 0:n.id)?{inbound:Object.assign(Object.assign({},c(this,Pv,"f").connectionStats),{bitrate:this.calculateInboundTracksBitrate()})}:{})}calculateInboundTracksBitrate(){if(void 0===c(this,Rv,"f"))throw new Error("Peers is undefined");return c(this,Rv,"f").hosts().reduce(((e,t)=>{if(t.isMe)return e;return e+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)}),0)}calculateOutboundTracksBitrate(){if(void 0===c(this,Tv,"f"))throw new Error("Media is undefined");return c(this,Tv,"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)}};wv=new WeakMap,Sv=new WeakMap,Cv=new WeakMap,Pv=new WeakMap,Tv=new WeakMap,Rv=new WeakMap,Dv=i([at(),s(0,dt(On.LoggerFactory)),o("design:paramtypes",[Function])],Dv);var Iv,Av,Ov,Nv=Dv;let Mv=class{constructor(e,t,r,n,i,s,o,a,c,u,l,p,h,f,m,g,v,y,_,b,E,w,S){var C;this.state=e,this.myPeer=t,this.integrationsService=n,this.processorsCache=i,this.mediaEventHandler=s,this.channelEventsHandler=o,this.peerTrackFactory=a,this.peers=c,this.peersStorage=u,this.system=l,this.media=p,this.network=h,this.networkTransportPolicyManager=f,this.producerCloseManager=m,this.signalingApiClient=g,this.eventsQueue=v,this.clientEventEmitter=y,this.internalEventEmitter=_,this.statsHandler=b,this.transportsStatsProvider=E,this.localMutex=w,this.webRtcIssueDetector=S,Iv.set(this,void 0),this.rejoinRequested=!1,this.isReleasing=!1,Av.set(this,!1),Ov.set(this,!1),this.mark=kn(),this.handleSignalingError=e=>{this.isReleasing||!this.isChannelJoined||this.state.isChannelJoining||e instanceof gn&&this.triggerRejoinEventIfAppropriate(e.errorCode)},d(this,Iv,r("Engine"),"f"),this.watchNetworkState(),this.watchDocumentUnload(),this.watchInternalEvents(),this.signalingApiClient.addErrorListener(this.handleSignalingError),C=this.mark,window._sdkMarks||(window._sdkMarks=new Set),window._sdkMarks.add(C)}get isChannelJoined(){return this.state.isJoined}initialize(){return a(this,void 0,void 0,(function*(){var e,t,r,n;try{const{data:i}=yield this.signalingApiClient.router.getRtpCapabilities(),{rtpCapabilities:s}=i;this.integrationsService.init(),yield this.media.loadDevice(s),c(this,Iv,"f").info("Supported capabilities",{codecs:Pn(this.media.mediasoupDevice)});const[o,a]=yield Promise.all([this.network.createSendTransport(this.media.mediasoupDevice),this.network.createRecvTransport(this.media.mediasoupDevice)]);null===(e=this.webRtcIssueDetector)||void 0===e||e.handleNewPeerConnection(o.handler._pc,o.id),null===(t=this.webRtcIssueDetector)||void 0===t||t.handleNewPeerConnection(a.handler._pc,a.id),this.transportsStatsProvider.init({media:this.media,peers:this.peers,receiveTransportConnectionManager:new bv({transport:a,statsHandler:this.statsHandler}),sendTransportConnectionManager:new bv({transport:o,statsHandler:this.statsHandler})}),yield this.network.initializeHeartbeats();const{isChromiumBased:d}=(e=>{var t;const r=null!=e?e:"undefined"!=typeof navigator?navigator.userAgent:void 0;if(!r)return{isMobile:!1,isChromiumBased:!1};const n=bn.getParser(r),i=n.getPlatformType(!0),s="mobile"===i||"tablet"===i,o=n.getEngineName().toLowerCase(),a=null!==(t=n.satisfies({chrome:">=0",chromium:">=0","chromium webview":">=0",edge:">=0",opera:">=0","opera coast":">=0","samsung internet for android":">=0","yandex browser":">=0",electron:">=0"}))&&void 0!==t&&t;return{isMobile:s,isChromiumBased:"blink"===o||a&&"webkit"!==o}})();d||(yield this.network.createSignalingTransport(this.media.mediasoupDevice),yield this.network.createKeepAliveConsumer()),yield this.network.createAllDataChannels(),this.network.channelMessagesDataConsumer&&(this.eventsQueue.setChannelEventHandler(this.channelEventsHandler.handleChannelEvent.bind(this.channelEventsHandler)),this.eventsQueue.setMediaEventHandler(this.mediaEventHandler.handleMediaEvent.bind(this.mediaEventHandler)),this.eventsQueue.subscribe(this.network.channelMessagesDataConsumer)),c(this,Iv,"f").debug("initialize()",{sendTransportId:null===(r=this.network.sendTransport)||void 0===r?void 0:r.id,recvTransportId:null===(n=this.network.receiveTransport)||void 0===n?void 0:n.id})}catch(e){c(this,Iv,"f").error("initialize()",{error:e});const t=e instanceof Error&&"UnsupportedError"===e.name&&"device not supported"===e.message,r=e instanceof Error&&"RTCPeerConnection is not defined"===e.message;if(t||r)throw new vn("Device not supported",vn.UNSUPPORTED_DEVICE_CODE);if(e instanceof mn)throw e;throw new Pt("initialize_engine_error",e)}}))}release(e){return a(this,void 0,void 0,(function*(){var t;if(this.isReleasing)return;const r=this.myPeer.get(),n={case:"release",applicationId:this.state.appId,channelId:this.state.channelId,peerId:null!==(t=null==r?void 0:r.id)&&void 0!==t?t:this.myPeerId,peerRole:null==r?void 0:r.role,isJoined:this.state.isJoined,isChannelJoining:this.state.isChannelJoining,rejoinRequested:this.rejoinRequested};this.isReleasing=!0;const i=yield this.localMutex.lock(fn.Join);this.signalingApiClient.abortPendingRequests("release");try{e||this.media.clearTracks(),yield Promise.all([Cn((()=>a(this,void 0,void 0,(function*(){return yield this.peers.reset()})))),Cn((()=>a(this,void 0,void 0,(function*(){return yield this.media.unpublishTracks()})))),Cn((()=>a(this,void 0,void 0,(function*(){return yield this.signalingApiClient.peers.disconnectPeer()}))))]),this.cleanup(),c(this,Iv,"f").debug("release()",n)}catch(e){c(this,Iv,"f").error("Failed to release",Object.assign(Object.assign({},n),{error:Ct(e)}))}finally{this.isReleasing=!1,i()}}))}getPeers(){return this.peers.all()}get myPeerId(){return this.myPeer.id}confirmActivity(){return a(this,void 0,void 0,(function*(){try{yield this.signalingApiClient.channel.confirmChannelActivity()}catch(e){throw new Pt("confirm_activity_failed",e)}}))}join(e){return a(this,void 0,void 0,(function*(){const t=yield this.localMutex.lock(fn.Join);if(this.signalingApiClient.abortPendingRequests("join"),this.isChannelJoined)throw new Pt("method_not_available_when_joined");try{c(this,Iv,"f").debug("join()",{params:e}),this.state.isChannelJoining=!0,this.signalingApiClient.setSecurityData({token:e.token,peerApiVersion:8,datacenterType:e.isP2pCall?"p2p":"common"});const{data:r,headers:n}=yield this.signalingApiClient.peers.registerPeer({appData:e.appData}),{appId:i,channelId:s,peerId:o}=r,d=String(n["x-datacenter-name"]);this.myPeer.id=o,this.state.appId=i,this.state.channelId=s,fr.setPeerId(o),fr.setChannelId(s),fr.setAppId(i),fr.setDatacenterName(d),yield this.initialize(),yield this.network.waitForReceiveTransportConnected({onReceiveTransportFailed:()=>a(this,void 0,void 0,(function*(){yield this.networkTransportPolicyManager.escalateDirectionToRelay("recv")}))}),yield this.network.waitForChannelMessagesDataConsumerConnected(),this.state.isJoined=!0,this.networkTransportPolicyManager.startMonitoring(),c(this,Iv,"f").info("Successfully joined channel",{channelId:s,datacenterName:d})}catch(e){throw this.signalingApiClient.abortPendingRequests("join"),yield this.release(),c(this,Iv,"f").error("join()",{error:e}),new Pt("join_failed",e)}finally{this.state.isChannelJoining=!1,this.rejoinRequested=!1,t()}}))}loadPeers(e){return a(this,void 0,void 0,(function*(){try{yield this.peers.load(e)}catch(e){throw new Pt("load_peers_failed",e)}}))}requestChannelStateSync(){An((()=>a(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>a(this,void 0,void 0,(function*(){if(!this.isChannelJoined||this.rejoinRequested||this.state.isChannelJoining)return e();const r=yield this.network.triggerChannelStateEvent("host"),n=setTimeout((()=>{this.eventsQueue.isMessageReceived(r)?(c(this,Iv,"f").info("Channel state event received",{case:"Engine.requestChannelStateSync"}),e()):t(new Pt("channel_state_event_not_received",new Error("Channel state event not received")))}),5e3),i=()=>{clearTimeout(n),this.clientEventEmitter.off(Dr,i),e()};this.clientEventEmitter.on(Dr,i)}))))}))),{minBackoffDelayMs:0,maxBackoffDelayMs:0,maxRetries:10,actionName:"triggerChannelStateEventWithRetry",logger:c(this,Iv,"f")}).catch((e=>{c(this,Iv,"f").error("Failed to request channel state event",{case:"Engine.requestChannelStateSync",error:Ct(e)})}))}updateAppData(e){return a(this,void 0,void 0,(function*(){const t=this.myPeer.get();if(!t)throw new Pt("need_joined_to_channel",new Error("Need join to channel first"));try{yn(e)}catch(e){throw c(this,Iv,"f").error("updateAppData() validation failed",{error:e}),new Pt("invalid_app_data",e)}try{yield this.network.updatePeerAppData({peerId:t.id,appData:e})}catch(e){throw c(this,Iv,"f").error("updateAppData()",{error:e}),new Pt("update_app_data_failed",e)}}))}createCameraVideoTrack(e){return a(this,void 0,void 0,(function*(){const t=gg.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 ng&&(r.setLabel((null==e?void 0:e.isPreview)?Nn.CameraPreview:Nn.Camera),r.setEncoderConfig(t.encoderConfig),r.setTransformParams(gg.getVideoTrackTransformParams(r.mediaStreamTrack))),this.media.setTrack(r),c(this,Iv,"f").debug("createCameraVideoTrack()",{trackParams:t}),r}catch(e){throw c(this,Iv,"f").error("createCameraVideoTrack()",{error:e,trackParams:t}),new Pt("create_camera_track_failed",e)}}))}createMicrophoneAudioTrack(e){return a(this,void 0,void 0,(function*(){try{const[t]=yield this.media.createUserMediaTracks({video:!1,audio:null==e?void 0:e.audio}),r=(null==e?void 0:e.isPreview)?Nn.MicrophonePreview:Nn.Microphone;return t.setLabel(r),t.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),(null==e?void 0:e.encoderConfig)&&t.setEncoderConfig(e.encoderConfig),"audio"!==t.kind||t.getLabel()!==Nn.Microphone||c(this,Ov,"f")||this.media.initDenoiser(t,e).catch((t=>{this.clientEventEmitter.emit(xr,{cause:"Failed to initialize denoiser",error:t}),c(this,Iv,"f").error("Failed to execute initDenoiser",{case:"Denoiser",options:e,error:Ct(t)})})),this.media.setTrack(t),c(this,Iv,"f").debug("createMicrophoneAudioTrack()",{options:e,trackLabel:t.getLabel()}),t}catch(t){throw c(this,Iv,"f").error("createMicrophoneAudioTrack()",{error:t,options:e}),new Pt("create_microphone_track_failed",t)}}))}createScreenMediaTracks(e){return a(this,void 0,void 0,(function*(){const t=gg.getScreenVideoTrackParams(e);try{const r=yield this.media.createDisplayMediaTracks({audio:null==e?void 0:e.audio,video:null==e?void 0:e.video});return r.forEach((r=>{if(r.mediaStreamTrack.addEventListener("ended",(()=>{r.unpublish().catch((e=>{c(this,Iv,"f").error("Failed to unpublish screen track",{error:Ct(e)})}))}),{once:!0}),r.setStopTrackOnPause(Boolean(null==e?void 0:e.stopTrackOnPause)),r instanceof ng){r.setLabel(Nn.ScreenVideo),r.setEncoderConfig(t.encoderConfig);const e=gg.getVideoTrackTransformParams(r.mediaStreamTrack);return r.setTransformParams(e),this.media.setTrack(r),void c(this,Iv,"f").debug("createScreenMediaTrack()",{trackParams:t,transformParams:e,label:r.logCtx})}r.setLabel(Nn.ScreenAudio),(null==e?void 0:e.audioEncoderConfig)&&r.setEncoderConfig(e.audioEncoderConfig),this.media.setTrack(r),c(this,Iv,"f").debug("createScreenMediaTrack()",{trackParams:null==e?void 0:e.audio,encoderConfig:null==e?void 0:e.audioEncoderConfig})})),r}catch(e){throw c(this,Iv,"f").error("createScreenMediaTrack()",{error:e,trackParams:t}),new Pt("create_screen_tracks_failed",e)}}))}createCustomAudioTrack(e){if(!e.audioTrack)throw new Pt("missing_audio_track",new Error("options.audioTrack is required"));try{const t=this.media.createCustomMediaTrack(e.audioTrack,{audio:e.audio});return t.mediaStreamTrack.addEventListener("ended",(()=>{t.unpublish().catch((e=>{c(this,Iv,"f").error("Failed to unpublish custom audio track",{track:t,error:Ct(e)})}))}),{once:!0}),t.setStopTrackOnPause(Boolean(e.stopTrackOnPause)),t.setLabel(Nn.CustomAudio),e.audioEncoderConfig&&t.setEncoderConfig(e.audioEncoderConfig),this.media.setTrack(t),c(this,Iv,"f").debug("createCustomAudioTrack()",{trackParams:e.audio,encoderConfig:e.audioEncoderConfig}),t}catch(t){throw c(this,Iv,"f").error("createCustomAudioTrack()",{error:t,trackParams:e.audioTrack}),new Pt("create_custom_audio_track_failed",t)}}createCustomVideoTrack(e){const t=gg.getScreenVideoTrackParams(e);if(!e.videoTrack)throw new Pt("missing_video_track",new Error("options.videoTrack is required"));try{const r=this.media.createCustomMediaTrack(e.videoTrack,{video:e.video});r.mediaStreamTrack.addEventListener("ended",(()=>{r.unpublish().catch((e=>{c(this,Iv,"f").error("Failed to unpublish custom video track",{track:r,error:Ct(e)})}))}),{once:!0}),r.mediaStreamTrack.contentHint="customVideo",r.setLabel(Nn.CustomVideo),r.setEncoderConfig(t.encoderConfig);const n=gg.getVideoTrackTransformParams(r.mediaStreamTrack);return r.setTransformParams(n),this.media.setTrack(r),c(this,Iv,"f").debug("createCustomVideoTrack()",{trackParams:t,transformParams:n,label:r.logCtx}),r}catch(e){throw c(this,Iv,"f").error("createCustomVideoTrack()",{error:e,trackParams:t}),new Pt("create_custom_video_track_failed",e)}}deleteTrack(e){return a(this,void 0,void 0,(function*(){try{yield this.media.deleteTrack(e)}catch(e){throw new Pt("delete_track_failed",e)}}))}transportsStats(){return this.transportsStatsProvider.getStats()}setSignalingServerUrl(e){if(this.isChannelJoined||this.rejoinRequested||this.state.isChannelJoining)throw new Pt("method_not_available_when_joined",new Error("Method not available when joined channel"));this.signalingApiClient.instance.defaults.baseURL=e}cleanup(){var e;this.signalingApiClient.abortPendingRequests("cleanup"),this.networkTransportPolicyManager.stopMonitoring(),this.state.reset(),this.network.reset(),this.peersStorage.clear(),this.transportsStatsProvider.clear(),this.statsHandler.clear(),this.integrationsService.reset(),null===(e=this.webRtcIssueDetector)||void 0===e||e.stopWatchingNewPeerConnections(),this.processorsCache.reset(),fr.clear()}watchInternalEvents(){this.internalEventEmitter.on(jr,(e=>a(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(Ur,(e=>a(this,void 0,void 0,(function*(){var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.close())||void 0===r||r.catch((e=>{c(this,Iv,"f").debug("Failed to close peerTrack",{error:Ct(e)})})),yield this.media.deleteTrack(e)})))),this.internalEventEmitter.on(Vr,(e=>{var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.pause())||void 0===r||r.catch((e=>{c(this,Iv,"f").debug("Failed to pause peerTrack",{error:Ct(e)})}))})),this.internalEventEmitter.on(Br,(e=>{var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.resume())||void 0===r||r.catch((e=>{c(this,Iv,"f").debug("Failed to resume peerTrack",{error:Ct(e)})}))})),this.internalEventEmitter.on(Wr,(e=>{var t,r;const n=null===(t=this.myPeer.get())||void 0===t?void 0:t.tracks.get(e.getLabel());null===(r=null==n?void 0:n.close())||void 0===r||r.catch((e=>{c(this,Iv,"f").debug("Failed to close peerTrack",{error:Ct(e)})}))})),this.internalEventEmitter.on(Hr,(e=>a(this,void 0,void 0,(function*(){yield this.createSelfPeerTrack(e)})))),this.internalEventEmitter.on(qr,(e=>{this.clientEventEmitter.safeEmit(Tr,{label:e.getLabel()})}))}createSelfPeerTrack(e){return a(this,void 0,void 0,(function*(){var t;if(!this.myPeer.id)return;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.isChannelJoined||this.isReleasing||this.state.isChannelJoining||this.rejoinRequested||(c(this,Iv,"f").debug("Triggering channel rejoin required event",{reason:e}),this.signalingApiClient.abortPendingRequests("channel-rejoin"),this.rejoinRequested=!0,this.clientEventEmitter.emit(wr))}watchNetworkState(){this.network.observer.on(hn,(({state:e,direction:t})=>{if(!this.isReleasing&&(["disconnected","failed"].includes(e)&&this.isChannelJoined&&!c(this,Av,"f")&&(d(this,Av,!0,"f"),c(this,Iv,"f").info("connection lost",{channel:"webrtc-transport",direction:t}),this.clientEventEmitter.safeEmit(Dr)),"reconnected"===e&&this.isChannelJoined&&c(this,Iv,"f").info("connection restored",{channel:"webrtc-transport",direction:t}),"reconnected"===e&&this.isChannelJoined&&c(this,Av,"f"))){if(![this.network.receiveTransport,this.network.sendTransport].every((e=>"connected"===(null==e?void 0:e.connectionState)||"new"===(null==e?void 0:e.connectionState))))return;d(this,Av,!1,"f"),this.clientEventEmitter.safeEmit(Ir),this.producerCloseManager.flushPending().catch((e=>{c(this,Iv,"f").warn("Failed to flush pending remote producers",{error:Ct(e)})}))}}))}watchDocumentUnload(){try{window.addEventListener("unload",(()=>{var e,t;null===(e=this.network.sendTransport)||void 0===e||e.close(),null===(t=this.network.receiveTransport)||void 0===t||t.close()}))}catch(e){c(this,Iv,"f").error("Failed to add watchDocumentUnload listener",{channelId:this.state.channelId,error:Ct(e)})}}};Iv=new WeakMap,Av=new WeakMap,Ov=new WeakMap,Mv=i([at(),s(0,dt(On.CallState)),s(1,dt(On.MyPeer)),s(2,dt(On.LoggerFactory)),s(3,dt(On.IntegrationsService)),s(4,dt(On.ProcessorsCache)),s(5,dt(On.MediaEventHandler)),s(6,dt(On.ChannelEventHandler)),s(7,dt(On.PeerTrackFactory)),s(8,dt(On.Peers)),s(9,dt(On.PeersStorage)),s(10,dt(On.System)),s(11,dt(On.Media)),s(12,dt(On.Network)),s(13,dt(On.NetworkTransportPolicyManager)),s(14,dt(On.ProducerCloseManager)),s(15,dt(On.SignalingApiClient)),s(16,dt(On.EventsQueue)),s(17,dt(On.ClientEventEmitter)),s(18,dt(On.InternalEventEmitter)),s(19,dt(On.StatsHandler)),s(20,dt(On.TransportsStatsProvider)),s(21,dt(On.LocalMutex)),s(22,dt(On.WebRTCIssueDetector)),o("design:paramtypes",[Ln,ws,Function,Sm,bm,Bg,Ng,Function,Object,Sc,_v,gg,Kc,tv,Zg,vc,bs,Et,Et,kv,Nv,lv,dr])],Mv);var Lv=Mv,xv="undefined"!=typeof Symbol&&Symbol,Fv=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},jv="Function.prototype.bind called on incompatible ",Uv=Array.prototype.slice,Vv=Object.prototype.toString,Bv=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==Vv.call(t))throw new TypeError(jv+t);for(var r,n=Uv.call(arguments,1),i=function(){if(this instanceof r){var i=t.apply(this,n.concat(Uv.call(arguments)));return Object(i)===i?i:this}return t.apply(e,n.concat(Uv.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},Wv=Function.prototype.bind||Bv,Hv="Function.prototype.bind called on incompatible ",qv=Array.prototype.slice,zv=Object.prototype.toString,Gv=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==zv.call(t))throw new TypeError(Hv+t);for(var r,n=qv.call(arguments,1),i=function(){if(this instanceof r){var i=t.apply(this,n.concat(qv.call(arguments)));return Object(i)===i?i:this}return t.apply(e,n.concat(qv.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},Yv=(Function.prototype.bind||Gv).call(Function.call,Object.prototype.hasOwnProperty),$v=SyntaxError,Jv=Function,Kv=TypeError,Qv=function(e){try{return Jv('"use strict"; return ('+e+").constructor;")()}catch(e){}},Zv=Object.getOwnPropertyDescriptor;if(Zv)try{Zv({},"")}catch(Rt){Zv=null}var Xv=function(){throw new Kv},ey=Zv?function(){try{return Xv}catch(e){try{return Zv(arguments,"callee").get}catch(e){return Xv}}}():Xv,ty="function"==typeof xv&&"function"==typeof Symbol&&"symbol"==typeof xv("foo")&&"symbol"==typeof Symbol("bar")&&Fv(),ry=Object.getPrototypeOf||function(e){return e.__proto__},ny={},iy="undefined"==typeof Uint8Array?undefined:ry(Uint8Array),sy={"%AggregateError%":"undefined"==typeof AggregateError?undefined:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?undefined:ArrayBuffer,"%ArrayIteratorPrototype%":ty?ry([][Symbol.iterator]()):undefined,"%AsyncFromSyncIteratorPrototype%":undefined,"%AsyncFunction%":ny,"%AsyncGenerator%":ny,"%AsyncGeneratorFunction%":ny,"%AsyncIteratorPrototype%":ny,"%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%":Jv,"%GeneratorFunction%":ny,"%Int8Array%":"undefined"==typeof Int8Array?undefined:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?undefined:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?undefined:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":ty?ry(ry([][Symbol.iterator]())):undefined,"%JSON%":"object"==typeof JSON?JSON:undefined,"%Map%":"undefined"==typeof Map?undefined:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&ty?ry((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&&ty?ry((new Set)[Symbol.iterator]()):undefined,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?undefined:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":ty?ry(""[Symbol.iterator]()):undefined,"%Symbol%":ty?Symbol:undefined,"%SyntaxError%":$v,"%ThrowTypeError%":ey,"%TypedArray%":iy,"%TypeError%":Kv,"%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},oy=function e(t){var r;if("%AsyncFunction%"===t)r=Qv("async function () {}");else if("%GeneratorFunction%"===t)r=Qv("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=Qv("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&(r=ry(i.prototype))}return sy[t]=r,r},ay={"%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"]},cy=Wv,dy=Yv,uy=cy.call(Function.call,Array.prototype.concat),ly=cy.call(Function.apply,Array.prototype.splice),py=cy.call(Function.call,String.prototype.replace),hy=cy.call(Function.call,String.prototype.slice),fy=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,my=/\\(\\)?/g,gy=function(e){var t=hy(e,0,1),r=hy(e,-1);if("%"===t&&"%"!==r)throw new $v("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new $v("invalid intrinsic syntax, expected opening `%`");var n=[];return py(e,fy,(function(e,t,r,i){n[n.length]=r?py(i,my,"$1"):t||e})),n},vy=function(e,t){var r,n=e;if(dy(ay,n)&&(n="%"+(r=ay[n])[0]+"%"),dy(sy,n)){var i=sy[n];if(i===ny&&(i=oy(n)),void 0===i&&!t)throw new Kv("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new $v("intrinsic "+e+" does not exist!")},yy=function(e,t){if("string"!=typeof e||0===e.length)throw new Kv("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new Kv('"allowMissing" argument must be a boolean');var r=gy(e),n=r.length>0?r[0]:"",i=vy("%"+n+"%",t),s=i.name,o=i.value,a=!1,c=i.alias;c&&(n=c[0],ly(r,uy([0,1],c)));for(var d=1,u=!0;d<r.length;d+=1){var l=r[d],p=hy(l,0,1),h=hy(l,-1);if(('"'===p||"'"===p||"`"===p||'"'===h||"'"===h||"`"===h)&&p!==h)throw new $v("property names with quotes must have matching quotes");if("constructor"!==l&&u||(a=!0),dy(sy,s="%"+(n+="."+l)+"%"))o=sy[s];else if(null!=o){if(!(l in o)){if(!t)throw new Kv("base intrinsic for "+e+" exists, but the property is not available.");return}if(Zv&&d+1>=r.length){var f=Zv(o,l);o=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:o[l]}else u=dy(o,l),o=o[l];u&&!a&&(sy[s]=o)}}return o},_y={exports:{}};!function(e){var t=Wv,r=yy,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}(_y);var by=yy,Ey=_y.exports,wy=Ey(by("String.prototype.indexOf")),Sy=h(Object.freeze({__proto__:null,default:{}})),Cy="function"==typeof Map&&Map.prototype,Py=Object.getOwnPropertyDescriptor&&Cy?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Ty=Cy&&Py&&"function"==typeof Py.get?Py.get:null,Ry=Cy&&Map.prototype.forEach,ky="function"==typeof Set&&Set.prototype,Dy=Object.getOwnPropertyDescriptor&&ky?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Iy=ky&&Dy&&"function"==typeof Dy.get?Dy.get:null,Ay=ky&&Set.prototype.forEach,Oy="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Ny="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,My="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Ly=Boolean.prototype.valueOf,xy=Object.prototype.toString,Fy=Function.prototype.toString,jy=String.prototype.match,Uy="function"==typeof BigInt?BigInt.prototype.valueOf:null,Vy=Object.getOwnPropertySymbols,By="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,Wy="function"==typeof Symbol&&"object"==typeof Symbol.iterator,Hy=Object.prototype.propertyIsEnumerable,qy=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null),zy=Sy.custom,Gy=zy&&Qy(zy)?zy:null,Yy="function"==typeof Symbol&&void 0!==Symbol.toStringTag?Symbol.toStringTag:null;function $y(e,t,r){var n="double"===(r.quoteStyle||t)?'"':"'";return n+e+n}function Jy(e){return String(e).replace(/"/g,""")}function Ky(e){return!("[object Array]"!==e_(e)||Yy&&"object"==typeof e&&Yy in e)}function Qy(e){if(Wy)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!By)return!1;try{return By.call(e),!0}catch(e){}return!1}var Zy=Object.prototype.hasOwnProperty||function(e){return e in this};function Xy(e,t){return Zy.call(e,t)}function e_(e){return xy.call(e)}function t_(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 r_(e,t){if(e.length>t.maxStringLength){var r=e.length-t.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return r_(e.slice(0,t.maxStringLength),t)+n}return $y(e.replace(/(['\\])/g,"\\$1").replace(/[\x00-\x1f]/g,n_),"single",t)}function n_(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 i_(e){return"Object("+e+")"}function s_(e){return e+" { ? }"}function o_(e,t,r,n){return e+" ("+t+") {"+(n?a_(r,n):r.join(", "))+"}"}function a_(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+e.join(","+r)+"\n"+t.prev}function c_(e,t){var r=Ky(e),n=[];if(r){n.length=e.length;for(var i=0;i<e.length;i++)n[i]=Xy(e,i)?t(e[i],e):""}var s,o="function"==typeof Vy?Vy(e):[];if(Wy){s={};for(var a=0;a<o.length;a++)s["$"+o[a]]=o[a]}for(var c in e)Xy(e,c)&&(r&&String(Number(c))===c&&c<e.length||Wy&&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 Vy)for(var d=0;d<o.length;d++)Hy.call(e,o[d])&&n.push("["+t(o[d])+"]: "+t(e[o[d]],e));return n}var d_=yy,u_=function(e,t){var r=by(e,!!t);return"function"==typeof r&&wy(e,".prototype.")>-1?Ey(r):r},l_=function e(t,r,n,i){var s=r||{};if(Xy(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Xy(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=!Xy(s,"customInspect")||s.customInspect;if("boolean"!=typeof o&&"symbol"!==o)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Xy(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 r_(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 Ky(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(t_(i,t)>=0)return"[Circular]";function d(t,r,o){if(r&&(i=i.slice()).push(r),o){var a={depth:s.depth};return Xy(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=jy.call(Fy.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),l=c_(t,d);return"[Function"+(u?": "+u:" (anonymous)")+"]"+(l.length>0?" { "+l.join(", ")+" }":"")}if(Qy(t)){var p=Wy?String(t).replace(/^(Symbol\(.*\))_[^)]*$/,"$1"):By.call(t);return"object"!=typeof t||Wy?p:i_(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+"="+$y(Jy(f[m].value),"double",s);return h+=">",t.childNodes&&t.childNodes.length&&(h+="..."),h+="</"+String(t.nodeName).toLowerCase()+">"}if(Ky(t)){if(0===t.length)return"[]";var g=c_(t,d);return c&&!function(e){for(var t=0;t<e.length;t++)if(t_(e[t],"\n")>=0)return!1;return!0}(g)?"["+a_(g,c)+"]":"[ "+g.join(", ")+" ]"}if(function(e){return!("[object Error]"!==e_(e)||Yy&&"object"==typeof e&&Yy in e)}(t)){var v=c_(t,d);return 0===v.length?"["+String(t)+"]":"{ ["+String(t)+"] "+v.join(", ")+" }"}if("object"==typeof t&&o){if(Gy&&"function"==typeof t[Gy])return t[Gy]();if("symbol"!==o&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!Ty||!e||"object"!=typeof e)return!1;try{Ty.call(e);try{Iy.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var y=[];return Ry.call(t,(function(e,r){y.push(d(r,t,!0)+" => "+d(e,t))})),o_("Map",Ty.call(t),y,c)}if(function(e){if(!Iy||!e||"object"!=typeof e)return!1;try{Iy.call(e);try{Ty.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var _=[];return Ay.call(t,(function(e){_.push(d(e,t))})),o_("Set",Iy.call(t),_,c)}if(function(e){if(!Oy||!e||"object"!=typeof e)return!1;try{Oy.call(e,Oy);try{Ny.call(e,Ny)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return s_("WeakMap");if(function(e){if(!Ny||!e||"object"!=typeof e)return!1;try{Ny.call(e,Ny);try{Oy.call(e,Oy)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return s_("WeakSet");if(function(e){if(!My||!e||"object"!=typeof e)return!1;try{return My.call(e),!0}catch(e){}return!1}(t))return s_("WeakRef");if(function(e){return!("[object Number]"!==e_(e)||Yy&&"object"==typeof e&&Yy in e)}(t))return i_(d(Number(t)));if(function(e){if(!e||"object"!=typeof e||!Uy)return!1;try{return Uy.call(e),!0}catch(e){}return!1}(t))return i_(d(Uy.call(t)));if(function(e){return!("[object Boolean]"!==e_(e)||Yy&&"object"==typeof e&&Yy in e)}(t))return i_(Ly.call(t));if(function(e){return!("[object String]"!==e_(e)||Yy&&"object"==typeof e&&Yy in e)}(t))return i_(d(String(t)));if(!function(e){return!("[object Date]"!==e_(e)||Yy&&"object"==typeof e&&Yy in e)}(t)&&!function(e){return!("[object RegExp]"!==e_(e)||Yy&&"object"==typeof e&&Yy in e)}(t)){var b=c_(t,d),E=qy?qy(t)===Object.prototype:t instanceof Object||t.constructor===Object,w=t instanceof Object?"":"null prototype",S=!E&&Yy&&Object(t)===t&&Yy in t?e_(t).slice(8,-1):w?"Object":"",C=(E||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(S||w?"["+[].concat(S||[],w||[]).join(": ")+"] ":"");return 0===b.length?C+"{}":c?C+"{"+a_(b,c)+"}":C+"{ "+b.join(", ")+" }"}return String(t)},p_=d_("%TypeError%"),h_=d_("%WeakMap%",!0),f_=d_("%Map%",!0),m_=u_("WeakMap.prototype.get",!0),g_=u_("WeakMap.prototype.set",!0),v_=u_("WeakMap.prototype.has",!0),y_=u_("Map.prototype.get",!0),__=u_("Map.prototype.set",!0),b_=u_("Map.prototype.has",!0),E_=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},w_=String.prototype.replace,S_=/%20/g,C_="RFC3986",P_={default:C_,formatters:{RFC1738:function(e){return w_.call(e,S_,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:C_},T_=P_,R_=Object.prototype.hasOwnProperty,k_=Array.isArray,D_=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),I_=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},A_={arrayToObject:I_,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(k_(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===T_.RFC1738&&(40===c||41===c)?o+=s.charAt(a):c<128?o+=D_[c]:c<2048?o+=D_[192|c>>6]+D_[128|63&c]:c<55296||c>=57344?o+=D_[224|c>>12]+D_[128|c>>6&63]+D_[128|63&c]:(a+=1,c=65536+((1023&c)<<10|1023&s.charCodeAt(a)),o+=D_[240|c>>18]+D_[128|c>>12&63]+D_[128|c>>6&63]+D_[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(k_(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(k_(t))t.push(r);else{if(!t||"object"!=typeof t)return[t,r];(n&&(n.plainObjects||n.allowPrototypes)||!R_.call(Object.prototype,r))&&(t[r]=!0)}return t}if(!t||"object"!=typeof t)return[t].concat(r);var i=t;return k_(t)&&!k_(r)&&(i=I_(t,n)),k_(t)&&k_(r)?(r.forEach((function(r,i){if(R_.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 R_.call(t,i)?t[i]=e(t[i],s,n):t[i]=s,t}),i)}},O_=function(){var e,t,r,n={assert:function(e){if(!n.has(e))throw new p_("Side channel does not contain "+l_(e))},get:function(n){if(h_&&n&&("object"==typeof n||"function"==typeof n)){if(e)return m_(e,n)}else if(f_){if(t)return y_(t,n)}else if(r)return function(e,t){var r=E_(e,t);return r&&r.value}(r,n)},has:function(n){if(h_&&n&&("object"==typeof n||"function"==typeof n)){if(e)return v_(e,n)}else if(f_){if(t)return b_(t,n)}else if(r)return function(e,t){return!!E_(e,t)}(r,n);return!1},set:function(n,i){h_&&n&&("object"==typeof n||"function"==typeof n)?(e||(e=new h_),g_(e,n,i)):f_?(t||(t=new f_),__(t,n,i)):(r||(r={key:{},next:null}),function(e,t,r){var n=E_(e,t);n?n.value=r:e.next={key:t,next:e.next,value:r}}(r,n,i))}};return n},N_=A_,M_=P_,L_=Object.prototype.hasOwnProperty,x_={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},F_=Array.isArray,j_=String.prototype.split,U_=Array.prototype.push,V_=function(e,t){U_.apply(e,F_(t)?t:[t])},B_=Date.prototype.toISOString,W_=M_.default,H_={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:N_.encode,encodeValuesOnly:!1,format:W_,formatter:M_.formatters[W_],indices:!1,serializeDate:function(e){return B_.call(e)},skipNulls:!1,strictNullHandling:!1},q_={},z_=function e(t,r,n,i,s,o,a,c,d,u,l,p,h,f,m,g){for(var v=t,y=g,_=0,b=!1;void 0!==(y=y.get(q_))&&!b;){var E=y.get(t);if(_+=1,void 0!==E){if(E===_)throw new RangeError("Cyclic object value");b=!0}void 0===y.get(q_)&&(_=0)}if("function"==typeof c?v=c(r,v):v instanceof Date?v=l(v):"comma"===n&&F_(v)&&(v=N_.maybeMap(v,(function(e){return e instanceof Date?l(e):e}))),null===v){if(s)return a&&!f?a(r,H_.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)||N_.isBuffer(v)){if(a){var w=f?r:a(r,H_.encoder,m,"key",p);if("comma"===n&&f){for(var S=j_.call(String(v),","),C="",P=0;P<S.length;++P)C+=(0===P?"":",")+h(a(S[P],H_.encoder,m,"value",p));return[h(w)+(i&&F_(v)&&1===S.length?"[]":"")+"="+C]}return[h(w)+"="+h(a(v,H_.encoder,m,"value",p))]}return[h(r)+"="+h(String(v))]}var T,R=[];if(void 0===v)return R;if("comma"===n&&F_(v))T=[{value:v.length>0?v.join(",")||null:void 0}];else if(F_(c))T=c;else{var k=Object.keys(v);T=d?k.sort(d):k}for(var D=i&&F_(v)&&1===v.length?r+"[]":r,I=0;I<T.length;++I){var A=T[I],O="object"==typeof A&&void 0!==A.value?A.value:v[A];if(!o||null!==O){var N=F_(v)?"function"==typeof n?n(D,A):D:D+(u?"."+A:"["+A+"]");g.set(t,_);var M=O_();M.set(q_,g),V_(R,e(O,N,n,i,s,o,a,c,d,u,l,p,h,f,m,M))}}return R},G_=A_,Y_=Object.prototype.hasOwnProperty,$_=Array.isArray,J_={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:G_.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},K_=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},Q_=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},Z_=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&&Y_.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&&Y_.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:Q_(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)}},X_=function(e,t){var r,n=e,i=function(e){if(!e)return H_;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||H_.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=M_.default;if(void 0!==e.format){if(!L_.call(M_.formatters,e.format))throw new TypeError("Unknown format option provided.");r=e.format}var n=M_.formatters[r],i=H_.filter;return("function"==typeof e.filter||F_(e.filter))&&(i=e.filter),{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:H_.addQueryPrefix,allowDots:void 0===e.allowDots?H_.allowDots:!!e.allowDots,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:H_.charsetSentinel,delimiter:void 0===e.delimiter?H_.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:H_.encode,encoder:"function"==typeof e.encoder?e.encoder:H_.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:H_.encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:H_.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:H_.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:H_.strictNullHandling}}(t);"function"==typeof i.filter?n=(0,i.filter)("",n):F_(i.filter)&&(r=i.filter);var s,o=[];if("object"!=typeof n||null===n)return"";s=t&&t.arrayFormat in x_?t.arrayFormat:t&&"indices"in t?t.indices?"indices":"repeat":"indices";var a=x_[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=O_(),u=0;u<r.length;++u){var l=r[u];i.skipNulls&&null===n[l]||V_(o,z_(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:""},eb=function(e,t){var r=function(e){if(!e)return J_;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?J_.charset:e.charset;return{allowDots:void 0===e.allowDots?J_.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:J_.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:J_.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:J_.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:J_.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:J_.comma,decoder:"function"==typeof e.decoder?e.decoder:J_.decoder,delimiter:"string"==typeof e.delimiter||G_.isRegExp(e.delimiter)?e.delimiter:J_.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:J_.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:J_.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:J_.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:J_.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:J_.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,J_.decoder,c,"key"),u=t.strictNullHandling?null:""):(d=t.decoder(l.slice(0,h),J_.decoder,c,"key"),u=G_.maybeMap(Q_(l.slice(h+1),t),(function(e){return t.decoder(e,J_.decoder,c,"value")}))),u&&t.interpretNumericEntities&&"iso-8859-1"===c&&(u=K_(u)),l.indexOf("[]=")>-1&&(u=$_(u)?[u]:u),Y_.call(n,d)?n[d]=G_.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=Z_(a,n[a],r,"string"==typeof e);i=G_.merge(i,c,r)}return!0===r.allowSparse?i:G_.compact(i)},tb={formats:P_,parse:eb,stringify:X_};let rb,nb=!1;const ib=()=>{try{return nb?null:window.localStorage}catch(e){return console.error("Get local storage error",{error:Ct(e)}),e instanceof Error&&"SecurityError"===e.name&&(nb=!0),null}};function sb(e){const t=ib();if(!t)return null;try{const r=t.getItem(e);return r?JSON.parse(r):null}catch(e){return null}}const ob=()=>{if(rb)return rb;const e=sb("sdk_clientUniqueId");if(e)return rb=e,e;const t=kn(12);return rb=t,function(e,t){const r=ib();if(r)try{r.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}}("sdk_clientUniqueId",t),t},ab=()=>{const e=sb("sdk_clientUniqueId");return e||(null!=rb?rb:ob())};class cb{constructor(e){this.api=e,Ms(this.api,{retries:2,shouldResetTimeout:!0,retryDelay:e=>1500*e,retryCondition:e=>{var t,r;return/^\/?log\//.test(null!==(r=null===(t=e.config)||void 0===t?void 0:t.url)&&void 0!==r?r:"")||!1}})}batch(e){return a(this,void 0,void 0,(function*(){yield this.api.post("/log/batch",e)}))}}class db{constructor(e){this.api=e,Ms(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}})}sendNetworkMetrics(e){return a(this,void 0,void 0,(function*(){yield this.api.post("/analytics/network-metrics",e)}))}sendWIDMetrics(e){return a(this,void 0,void 0,(function*(){yield this.api.post("/analytics/wid-metrics",Object.assign({},e))}))}}let ub=class{constructor(){this.api=Ja.create({baseURL:"https://moodhood-analytics.livedigital.space/v1",timeout:1e4,withCredentials:!0,paramsSerializer:e=>tb.stringify(e),headers:{"x-cl-id":ab()}}),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 cb(this.api),this.metricsApi=new db(this.api)}get log(){return this.logApi}get metrics(){return this.metricsApi}};ub=i([at(),o("design:paramtypes",[])],ub);var lb=ub,pb={exports:{}},hb=1e3,fb=60*hb,mb=60*fb,gb=24*mb,vb=7*gb,yb=365.25*gb,_b=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*yb;case"weeks":case"week":case"w":return r*vb;case"days":case"day":case"d":return r*gb;case"hours":case"hour":case"hrs":case"hr":case"h":return r*mb;case"minutes":case"minute":case"mins":case"min":case"m":return r*fb;case"seconds":case"second":case"secs":case"sec":case"s":return r*hb;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>=gb)return bb(e,t,gb,"day");if(t>=mb)return bb(e,t,mb,"hour");if(t>=fb)return bb(e,t,fb,"minute");if(t>=hb)return bb(e,t,hb,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=gb)return Math.round(e/gb)+"d";if(t>=mb)return Math.round(e/mb)+"h";if(t>=fb)return Math.round(e/fb)+"m";if(t>=hb)return Math.round(e/hb)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function bb(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var Eb=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=_b,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=Eb(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(pb,pb.exports);var wb,Sb,Cb=pb.exports,Pb={},Tb={},Rb={},kb={exports:{}};
|
|
30
30
|
/**
|
|
31
31
|
* @license
|
|
32
32
|
* Lodash <https://lodash.com/>
|
|
@@ -35,4 +35,4 @@ and limitations under the License.
|
|
|
35
35
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
36
36
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
37
37
|
*/
|
|
38
|
-
Eb=Rb,wb=Rb.exports,function(){var e,t="Expected a function",r="__lodash_hash_undefined__",n="__lodash_placeholder__",i=16,s=32,o=64,a=128,c=256,d=1/0,u=9007199254740991,p=NaN,h=4294967295,f=[["ary",a],["bind",1],["bindKey",2],["curry",8],["curryRight",i],["flip",512],["partial",s],["partialRight",o],["rearg",c]],m="[object Arguments]",g="[object Array]",v="[object Boolean]",y="[object Date]",_="[object Error]",b="[object Function]",E="[object GeneratorFunction]",w="[object Map]",S="[object Number]",C="[object Object]",P="[object Promise]",T="[object RegExp]",R="[object Set]",k="[object String]",D="[object Symbol]",I="[object WeakMap]",A="[object ArrayBuffer]",O="[object DataView]",N="[object Float32Array]",M="[object Float64Array]",L="[object Int8Array]",x="[object Int16Array]",F="[object Int32Array]",j="[object Uint8Array]",U="[object Uint8ClampedArray]",V="[object Uint16Array]",B="[object Uint32Array]",W=/\b__p \+= '';/g,H=/\b(__p \+=) '' \+/g,q=/(__e\(.*?\)|\b__t\)) \+\n'';/g,z=/&(?:amp|lt|gt|quot|#39);/g,G=/[&<>"']/g,Y=RegExp(z.source),$=RegExp(G.source),J=/<%-([\s\S]+?)%>/g,K=/<%([\s\S]+?)%>/g,Q=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,X=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,re=RegExp(te.source),ne=/^\s+/,ie=/\s/,se=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,oe=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,ce=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,de=/[()=,{}\[\]\/\s]/,ue=/\\(\\)?/g,le=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,pe=/\w*$/,he=/^[-+]0x[0-9a-f]+$/i,fe=/^0b[01]+$/i,me=/^\[object .+?Constructor\]$/,ge=/^0o[0-7]+$/i,ve=/^(?:0|[1-9]\d*)$/,ye=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,_e=/($^)/,be=/['\n\r\u2028\u2029\\]/g,Ee="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",we="\\u2700-\\u27bf",Se="a-z\\xdf-\\xf6\\xf8-\\xff",Ce="A-Z\\xc0-\\xd6\\xd8-\\xde",Pe="\\ufe0e\\ufe0f",Te="\\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",Re="['’]",ke="[\\ud800-\\udfff]",De="["+Te+"]",Ie="["+Ee+"]",Ae="\\d+",Oe="[\\u2700-\\u27bf]",Ne="["+Se+"]",Me="[^\\ud800-\\udfff"+Te+Ae+we+Se+Ce+"]",Le="\\ud83c[\\udffb-\\udfff]",xe="[^\\ud800-\\udfff]",Fe="(?:\\ud83c[\\udde6-\\uddff]){2}",je="[\\ud800-\\udbff][\\udc00-\\udfff]",Ue="["+Ce+"]",Ve="(?:"+Ne+"|"+Me+")",Be="(?:"+Ue+"|"+Me+")",We="(?:['’](?:d|ll|m|re|s|t|ve))?",He="(?:['’](?:D|LL|M|RE|S|T|VE))?",qe="(?:"+Ie+"|"+Le+")?",ze="[\\ufe0e\\ufe0f]?",Ge=ze+qe+"(?:\\u200d(?:"+[xe,Fe,je].join("|")+")"+ze+qe+")*",Ye="(?:"+[Oe,Fe,je].join("|")+")"+Ge,$e="(?:"+[xe+Ie+"?",Ie,Fe,je,ke].join("|")+")",Je=RegExp(Re,"g"),Ke=RegExp(Ie,"g"),Qe=RegExp(Le+"(?="+Le+")|"+$e+Ge,"g"),Ze=RegExp([Ue+"?"+Ne+"+"+We+"(?="+[De,Ue,"$"].join("|")+")",Be+"+"+He+"(?="+[De,Ue+Ve,"$"].join("|")+")",Ue+"?"+Ve+"+"+We,Ue+"+"+He,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ae,Ye].join("|"),"g"),Xe=RegExp("[\\u200d\\ud800-\\udfff"+Ee+Pe+"]"),et=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,tt=["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"],rt=-1,nt={};nt[N]=nt[M]=nt[L]=nt[x]=nt[F]=nt[j]=nt[U]=nt[V]=nt[B]=!0,nt[m]=nt[g]=nt[A]=nt[v]=nt[O]=nt[y]=nt[_]=nt[b]=nt[w]=nt[S]=nt[C]=nt[T]=nt[R]=nt[k]=nt[I]=!1;var it={};it[m]=it[g]=it[A]=it[O]=it[v]=it[y]=it[N]=it[M]=it[L]=it[x]=it[F]=it[w]=it[S]=it[C]=it[T]=it[R]=it[k]=it[D]=it[j]=it[U]=it[V]=it[B]=!0,it[_]=it[b]=it[I]=!1;var st={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ot=parseFloat,at=parseInt,ct="object"==typeof l&&l&&l.Object===Object&&l,dt="object"==typeof self&&self&&self.Object===Object&&self,ut=ct||dt||Function("return this")(),lt=wb&&!wb.nodeType&&wb,pt=lt&&Eb&&!Eb.nodeType&&Eb,ht=pt&&pt.exports===lt,ft=ht&&ct.process,mt=function(){try{var e=pt&&pt.require&&pt.require("util").types;return e||ft&&ft.binding&&ft.binding("util")}catch(e){}}(),gt=mt&&mt.isArrayBuffer,vt=mt&&mt.isDate,yt=mt&&mt.isMap,_t=mt&&mt.isRegExp,bt=mt&&mt.isSet,Et=mt&&mt.isTypedArray;function wt(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 St(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 Ct(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}function Pt(e,t){for(var r=null==e?0:e.length;r--&&!1!==t(e[r],r,e););return e}function Tt(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 Rt(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 kt(e,t){return!(null==e||!e.length)&&jt(e,t,0)>-1}function Dt(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 It(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 At(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}function Ot(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 Nt(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 Mt(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 Lt=Wt("length");function xt(e,t,r){var n;return r(e,(function(e,r,i){if(t(e,r,i))return n=r,!1})),n}function Ft(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 jt(e,t,r){return t==t?function(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1}(e,t,r):Ft(e,Vt,r)}function Ut(e,t,r,n){for(var i=r-1,s=e.length;++i<s;)if(n(e[i],t))return i;return-1}function Vt(e){return e!=e}function Bt(e,t){var r=null==e?0:e.length;return r?zt(e,t)/r:p}function Wt(t){return function(r){return null==r?e:r[t]}}function Ht(t){return function(r){return null==t?e:t[r]}}function qt(e,t,r,n,i){return i(e,(function(e,i,s){r=n?(n=!1,e):t(r,e,i,s)})),r}function zt(t,r){for(var n,i=-1,s=t.length;++i<s;){var o=r(t[i]);o!==e&&(n=n===e?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 Yt(e){return e?e.slice(0,lr(e)+1).replace(ne,""):e}function $t(e){return function(t){return e(t)}}function Jt(e,t){return It(t,(function(t){return e[t]}))}function Kt(e,t){return e.has(t)}function Qt(e,t){for(var r=-1,n=e.length;++r<n&&jt(t,e[r],0)>-1;);return r}function Zt(e,t){for(var r=e.length;r--&&jt(t,e[r],0)>-1;);return r}function Xt(e,t){for(var r=e.length,n=0;r--;)e[r]===t&&++n;return n}var er=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"}),tr=Ht({"&":"&","<":"<",">":">",'"':""","'":"'"});function rr(e){return"\\"+st[e]}function nr(e){return Xe.test(e)}function ir(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function sr(e,t){return function(r){return e(t(r))}}function or(e,t){for(var r=-1,i=e.length,s=0,o=[];++r<i;){var a=e[r];a!==t&&a!==n||(e[r]=n,o[s++]=r)}return o}function ar(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}function cr(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=[e,e]})),r}function dr(e){return nr(e)?function(e){for(var t=Qe.lastIndex=0;Qe.test(e);)++t;return t}(e):Lt(e)}function ur(e){return nr(e)?function(e){return e.match(Qe)||[]}(e):function(e){return e.split("")}(e)}function lr(e){for(var t=e.length;t--&&ie.test(e.charAt(t)););return t}var pr=Ht({"&":"&","<":"<",">":">",""":'"',"'":"'"}),hr=function l(ie){var Ee,we=(ie=null==ie?ut:hr.defaults(ut.Object(),ie,hr.pick(ut,tt))).Array,Se=ie.Date,Ce=ie.Error,Pe=ie.Function,Te=ie.Math,Re=ie.Object,ke=ie.RegExp,De=ie.String,Ie=ie.TypeError,Ae=we.prototype,Oe=Pe.prototype,Ne=Re.prototype,Me=ie["__core-js_shared__"],Le=Oe.toString,xe=Ne.hasOwnProperty,Fe=0,je=(Ee=/[^.]+$/.exec(Me&&Me.keys&&Me.keys.IE_PROTO||""))?"Symbol(src)_1."+Ee:"",Ue=Ne.toString,Ve=Le.call(Re),Be=ut._,We=ke("^"+Le.call(xe).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),He=ht?ie.Buffer:e,qe=ie.Symbol,ze=ie.Uint8Array,Ge=He?He.allocUnsafe:e,Ye=sr(Re.getPrototypeOf,Re),$e=Re.create,Qe=Ne.propertyIsEnumerable,Xe=Ae.splice,st=qe?qe.isConcatSpreadable:e,ct=qe?qe.iterator:e,dt=qe?qe.toStringTag:e,lt=function(){try{var e=hs(Re,"defineProperty");return e({},"",{}),e}catch(e){}}(),pt=ie.clearTimeout!==ut.clearTimeout&&ie.clearTimeout,ft=Se&&Se.now!==ut.Date.now&&Se.now,mt=ie.setTimeout!==ut.setTimeout&&ie.setTimeout,Lt=Te.ceil,Ht=Te.floor,fr=Re.getOwnPropertySymbols,mr=He?He.isBuffer:e,gr=ie.isFinite,vr=Ae.join,yr=sr(Re.keys,Re),_r=Te.max,br=Te.min,Er=Se.now,wr=ie.parseInt,Sr=Te.random,Cr=Ae.reverse,Pr=hs(ie,"DataView"),Tr=hs(ie,"Map"),Rr=hs(ie,"Promise"),kr=hs(ie,"Set"),Dr=hs(ie,"WeakMap"),Ir=hs(Re,"create"),Ar=Dr&&new Dr,Or={},Nr=Vs(Pr),Mr=Vs(Tr),Lr=Vs(Rr),xr=Vs(kr),Fr=Vs(Dr),jr=qe?qe.prototype:e,Ur=jr?jr.valueOf:e,Vr=jr?jr.toString:e;function Br(e){if(ia(e)&&!Yo(e)&&!(e instanceof zr)){if(e instanceof qr)return e;if(xe.call(e,"__wrapped__"))return Bs(e)}return new qr(e)}var Wr=function(){function t(){}return function(r){if(!na(r))return{};if($e)return $e(r);t.prototype=r;var n=new t;return t.prototype=e,n}}();function Hr(){}function qr(t,r){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!r,this.__index__=0,this.__values__=e}function zr(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=h,this.__views__=[]}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 Yr(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 $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 Jr(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new $r;++t<r;)this.add(e[t])}function Kr(e){var t=this.__data__=new Yr(e);this.size=t.size}function Qr(e,t){var r=Yo(e),n=!r&&Go(e),i=!r&&!n&&Qo(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&&!xe.call(e,d)||o&&("length"==d||i&&("offset"==d||"parent"==d)||s&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||bs(d,c))||a.push(d);return a}function Zr(t){var r=t.length;return r?t[Kn(0,r-1)]:e}function Xr(e,t){return Fs(Ai(e),dn(t,0,e.length))}function en(e){return Fs(Ai(e))}function tn(t,r,n){(n!==e&&!Ho(t[r],n)||n===e&&!(r in t))&&an(t,r,n)}function rn(t,r,n){var i=t[r];xe.call(t,r)&&Ho(i,n)&&(n!==e||r in t)||an(t,r,n)}function nn(e,t){for(var r=e.length;r--;)if(Ho(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&&Oi(t,Ma(t),e)}function an(e,t,r){"__proto__"==t&<?lt(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function cn(t,r){for(var n=-1,i=r.length,s=we(i),o=null==t;++n<i;)s[n]=o?e:Da(t,r[n]);return s}function dn(t,r,n){return t==t&&(n!==e&&(t=t<=n?t:n),r!==e&&(t=t>=r?t:r)),t}function un(t,r,n,i,s,o){var a,c=1&r,d=2&r,u=4&r;if(n&&(a=s?n(t,i,s,o):n(t)),a!==e)return a;if(!na(t))return t;var l=Yo(t);if(l){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&xe.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(t),!c)return Ai(t,a)}else{var p=gs(t),h=p==b||p==E;if(Qo(t))return Pi(t,c);if(p==C||p==m||h&&!s){if(a=d||h?{}:ys(t),!c)return d?function(e,t){return Oi(e,ms(e),t)}(t,function(e,t){return e&&Oi(t,La(t),e)}(a,t)):function(e,t){return Oi(e,fs(e),t)}(t,on(a,t))}else{if(!it[p])return s?t:{};a=function(e,t,r){var n=e.constructor;switch(t){case A:return Ti(e);case v:case y:return new n(+e);case O:return function(e,t){var r=t?Ti(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case N:case M:case L:case x:case F:case j:case U:case V:case B:return Ri(e,r);case w:case R:return new n;case S:case k:return new n(e);case T:return function(e){var t=new e.constructor(e.source,pe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case D:return function(e){return Ur?Re(Ur.call(e)):{}}(e)}}(t,p,c)}}o||(o=new Kr);var f=o.get(t);if(f)return f;o.set(t,a),da(t)?t.forEach((function(e){a.add(un(e,r,n,e,t,o))})):sa(t)&&t.forEach((function(e,i){a.set(i,un(e,r,n,i,t,o))}));var g=l?e:(u?d?os:ss:d?La:Ma)(t);return Ct(g||t,(function(e,i){g&&(e=t[i=e]),rn(a,i,un(e,r,n,i,t,o))})),a}function ln(t,r,n){var i=n.length;if(null==t)return!i;for(t=Re(t);i--;){var s=n[i],o=r[s],a=t[s];if(a===e&&!(s in t)||!o(a))return!1}return!0}function pn(r,n,i){if("function"!=typeof r)throw new Ie(t);return Ns((function(){r.apply(e,i)}),n)}function hn(e,t,r,n){var i=-1,s=kt,o=!0,a=e.length,c=[],d=t.length;if(!a)return c;r&&(t=It(t,$t(r))),n?(s=Dt,o=!1):t.length>=200&&(s=Kt,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}Br.templateSettings={escape:J,evaluate:K,interpolate:Q,variable:"",imports:{_:Br}},Br.prototype=Hr.prototype,Br.prototype.constructor=Br,qr.prototype=Wr(Hr.prototype),qr.prototype.constructor=qr,zr.prototype=Wr(Hr.prototype),zr.prototype.constructor=zr,Gr.prototype.clear=function(){this.__data__=Ir?Ir(null):{},this.size=0},Gr.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Gr.prototype.get=function(t){var n=this.__data__;if(Ir){var i=n[t];return i===r?e:i}return xe.call(n,t)?n[t]:e},Gr.prototype.has=function(t){var r=this.__data__;return Ir?r[t]!==e:xe.call(r,t)},Gr.prototype.set=function(t,n){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Ir&&n===e?r:n,this},Yr.prototype.clear=function(){this.__data__=[],this.size=0},Yr.prototype.delete=function(e){var t=this.__data__,r=nn(t,e);return!(r<0||(r==t.length-1?t.pop():Xe.call(t,r,1),--this.size,0))},Yr.prototype.get=function(t){var r=this.__data__,n=nn(r,t);return n<0?e:r[n][1]},Yr.prototype.has=function(e){return nn(this.__data__,e)>-1},Yr.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},$r.prototype.clear=function(){this.size=0,this.__data__={hash:new Gr,map:new(Tr||Yr),string:new Gr}},$r.prototype.delete=function(e){var t=ls(this,e).delete(e);return this.size-=t?1:0,t},$r.prototype.get=function(e){return ls(this,e).get(e)},$r.prototype.has=function(e){return ls(this,e).has(e)},$r.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,r),this},Jr.prototype.has=function(e){return this.__data__.has(e)},Kr.prototype.clear=function(){this.__data__=new Yr,this.size=0},Kr.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Kr.prototype.get=function(e){return this.__data__.get(e)},Kr.prototype.has=function(e){return this.__data__.has(e)},Kr.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Yr){var n=r.__data__;if(!Tr||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new $r(n)}return r.set(e,t),this.size=r.size,this};var fn=Li(wn),mn=Li(Sn,!0);function gn(e,t){var r=!0;return fn(e,(function(e,n,i){return r=!!t(e,n,i)})),r}function vn(t,r,n){for(var i=-1,s=t.length;++i<s;){var o=t[i],a=r(o);if(null!=a&&(c===e?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 _n(e,t,r,n,i){var s=-1,o=e.length;for(r||(r=_s),i||(i=[]);++s<o;){var a=e[s];t>0&&r(a)?t>1?_n(a,t-1,r,n,i):At(i,a):n||(i[i.length]=a)}return i}var bn=xi(),En=xi(!0);function wn(e,t){return e&&bn(e,t,Ma)}function Sn(e,t){return e&&En(e,t,Ma)}function Cn(e,t){return Rt(t,(function(t){return ea(e[t])}))}function Pn(t,r){for(var n=0,i=(r=Ei(r,t)).length;null!=t&&n<i;)t=t[Us(r[n++])];return n&&n==i?t:e}function Tn(e,t,r){var n=t(e);return Yo(e)?n:At(n,r(e))}function Rn(t){return null==t?t===e?"[object Undefined]":"[object Null]":dt&&dt in Re(t)?function(t){var r=xe.call(t,dt),n=t[dt];try{t[dt]=e;var i=!0}catch(e){}var s=Ue.call(t);return i&&(r?t[dt]=n:delete t[dt]),s}(t):function(e){return Ue.call(e)}(t)}function kn(e,t){return e>t}function Dn(e,t){return null!=e&&xe.call(e,t)}function In(e,t){return null!=e&&t in Re(e)}function An(t,r,n){for(var i=n?Dt:kt,s=t[0].length,o=t.length,a=o,c=we(o),d=1/0,u=[];a--;){var l=t[a];a&&r&&(l=It(l,$t(r))),d=br(l.length,d),c[a]=!n&&(r||s>=120&&l.length>=120)?new Jr(a&&l):e}l=t[0];var p=-1,h=c[0];e:for(;++p<s&&u.length<d;){var f=l[p],m=r?r(f):f;if(f=n||0!==f?f:0,!(h?Kt(h,m):i(u,m,n))){for(a=o;--a;){var g=c[a];if(!(g?Kt(g,m):i(t[a],m,n)))continue e}h&&h.push(m),u.push(f)}}return u}function On(t,r,n){var i=null==(t=Ds(t,r=Ei(r,t)))?t:t[Us(Zs(r))];return null==i?e:wt(i,t,n)}function Nn(e){return ia(e)&&Rn(e)==m}function Mn(t,r,n,i,s){return t===r||(null==t||null==r||!ia(t)&&!ia(r)?t!=t&&r!=r:function(t,r,n,i,s,o){var a=Yo(t),c=Yo(r),d=a?g:gs(t),u=c?g:gs(r),l=(d=d==m?C:d)==C,p=(u=u==m?C:u)==C,h=d==u;if(h&&Qo(t)){if(!Qo(r))return!1;a=!0,l=!1}if(h&&!l)return o||(o=new Kr),a||pa(t)?ns(t,r,n,i,s,o):function(e,t,r,n,i,s,o){switch(r){case O:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case A:return!(e.byteLength!=t.byteLength||!s(new ze(e),new ze(t)));case v:case y:case S:return Ho(+e,+t);case _:return e.name==t.name&&e.message==t.message;case T:case k:return e==t+"";case w:var a=ir;case R:var c=1&n;if(a||(a=ar),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 D:if(Ur)return Ur.call(e)==Ur.call(t)}return!1}(t,r,d,n,i,s,o);if(!(1&n)){var f=l&&xe.call(t,"__wrapped__"),b=p&&xe.call(r,"__wrapped__");if(f||b){var E=f?t.value():t,P=b?r.value():r;return o||(o=new Kr),s(E,P,n,i,o)}}return!!h&&(o||(o=new Kr),function(t,r,n,i,s,o){var a=1&n,c=ss(t),d=c.length,u=ss(r).length;if(d!=u&&!a)return!1;for(var l=d;l--;){var p=c[l];if(!(a?p in r:xe.call(r,p)))return!1}var h=o.get(t),f=o.get(r);if(h&&f)return h==r&&f==t;var m=!0;o.set(t,r),o.set(r,t);for(var g=a;++l<d;){var v=t[p=c[l]],y=r[p];if(i)var _=a?i(y,v,p,r,t,o):i(v,y,p,t,r,o);if(!(_===e?v===y||s(v,y,n,i,o):_)){m=!1;break}g||(g="constructor"==p)}if(m&&!g){var b=t.constructor,E=r.constructor;b==E||!("constructor"in t)||!("constructor"in r)||"function"==typeof b&&b instanceof b&&"function"==typeof E&&E instanceof E||(m=!1)}return o.delete(t),o.delete(r),m}(t,r,n,i,s,o))}(t,r,n,i,Mn,s))}function Ln(t,r,n,i){var s=n.length,o=s,a=!i;if(null==t)return!o;for(t=Re(t);s--;){var c=n[s];if(a&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++s<o;){var d=(c=n[s])[0],u=t[d],l=c[1];if(a&&c[2]){if(u===e&&!(d in t))return!1}else{var p=new Kr;if(i)var h=i(u,l,d,t,r,p);if(!(h===e?Mn(l,u,3,i,p):h))return!1}}return!0}function xn(e){return!(!na(e)||(t=e,je&&je in t))&&(ea(e)?We:me).test(Vs(e));var t}function Fn(e){return"function"==typeof e?e:null==e?oc:"object"==typeof e?Yo(e)?Hn(e[0],e[1]):Wn(e):mc(e)}function jn(e){if(!Ps(e))return yr(e);var t=[];for(var r in Re(e))xe.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Un(e){if(!na(e))return function(e){var t=[];if(null!=e)for(var r in Re(e))t.push(r);return t}(e);var t=Ps(e),r=[];for(var n in e)("constructor"!=n||!t&&xe.call(e,n))&&r.push(n);return r}function Vn(e,t){return e<t}function Bn(e,t){var r=-1,n=Jo(e)?we(e.length):[];return fn(e,(function(e,i,s){n[++r]=t(e,i,s)})),n}function Wn(e){var t=ps(e);return 1==t.length&&t[0][2]?Rs(t[0][0],t[0][1]):function(r){return r===e||Ln(r,e,t)}}function Hn(t,r){return ws(t)&&Ts(r)?Rs(Us(t),r):function(n){var i=Da(n,t);return i===e&&i===r?Ia(n,t):Mn(r,i,3)}}function qn(t,r,n,i,s){t!==r&&bn(r,(function(o,a){if(s||(s=new Kr),na(o))!function(t,r,n,i,s,o,a){var c=As(t,n),d=As(r,n),u=a.get(d);if(u)tn(t,n,u);else{var l=o?o(c,d,n+"",t,r,a):e,p=l===e;if(p){var h=Yo(d),f=!h&&Qo(d),m=!h&&!f&&pa(d);l=d,h||f||m?Yo(c)?l=c:Ko(c)?l=Ai(c):f?(p=!1,l=Pi(d,!0)):m?(p=!1,l=Ri(d,!0)):l=[]:aa(d)||Go(d)?(l=c,Go(c)?l=ba(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(t,n,l)}}(t,r,a,n,qn,i,s);else{var c=i?i(As(t,a),o,a+"",t,r,s):e;c===e&&(c=o),tn(t,a,c)}}),La)}function zn(t,r){var n=t.length;if(n)return bs(r+=r<0?n:0,n)?t[r]:e}function Gn(e,t,r){t=t.length?It(t,(function(e){return Yo(e)?function(t){return Pn(t,1===e.length?e[0]:e)}:e})):[oc];var n=-1;t=It(t,$t(us()));var i=Bn(e,(function(e,r,i){var s=It(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){for(var n=-1,i=e.criteria,s=t.criteria,o=i.length,a=r.length;++n<o;){var c=ki(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 Yn(e,t,r){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=Pn(e,o);r(a,o)&&ti(s,Ei(o,e),a)}return s}function $n(e,t,r,n){var i=n?Ut:jt,s=-1,o=t.length,a=e;for(e===t&&(t=Ai(t)),r&&(a=It(e,$t(r)));++s<o;)for(var c=0,d=t[s],u=r?r(d):d;(c=i(a,u,c,n))>-1;)a!==e&&Xe.call(a,c,1),Xe.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;bs(i)?Xe.call(e,i,1):hi(e,i)}}return e}function Kn(e,t){return e+Ht(Sr()*(t-e+1))}function Qn(e,t){var r="";if(!e||t<1||t>u)return r;do{t%2&&(r+=e),(t=Ht(t/2))&&(e+=e)}while(t);return r}function Zn(e,t){return Ms(ks(e,t,oc),e+"")}function Xn(e){return Zr(Ha(e))}function ei(e,t){var r=Ha(e);return Fs(r,dn(t,0,r.length))}function ti(t,r,n,i){if(!na(t))return t;for(var s=-1,o=(r=Ei(r,t)).length,a=o-1,c=t;null!=c&&++s<o;){var d=Us(r[s]),u=n;if("__proto__"===d||"constructor"===d||"prototype"===d)return t;if(s!=a){var l=c[d];(u=i?i(l,d,c):e)===e&&(u=na(l)?l:bs(r[s+1])?[]:{})}rn(c,d,u),c=c[d]}return t}var ri=Ar?function(e,t){return Ar.set(e,t),e}:oc,ni=lt?function(e,t){return lt(e,"toString",{configurable:!0,enumerable:!1,value:nc(t),writable:!0})}:oc;function ii(e){return Fs(Ha(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=we(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(t,r,n,i){var s=0,o=null==t?0:t.length;if(0===o)return 0;for(var a=(r=n(r))!=r,c=null===r,d=la(r),u=r===e;s<o;){var l=Ht((s+o)/2),p=n(t[l]),h=p!==e,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<=r:p<r);v?s=l+1:o=l}return br(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||!Ho(a,c)){var c=a;s[i++]=0===o?0:o}}return s}function ui(e){return"number"==typeof e?e:la(e)?p:+e}function li(e){if("string"==typeof e)return e;if(Yo(e))return It(e,li)+"";if(la(e))return Vr?Vr.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function pi(e,t,r){var n=-1,i=kt,s=e.length,o=!0,a=[],c=a;if(r)o=!1,i=Dt;else if(s>=200){var d=t?null:Qi(e);if(d)return ar(d);o=!1,i=Kt,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=Ei(t,e)))||delete e[Us(Zs(t))]}function fi(e,t,r,n){return ti(e,t,r(Pn(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 zr&&(r=r.value()),Ot(t,(function(e,t){return t.func.apply(t.thisArg,At([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=we(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(_n(s,1),t,r)}function yi(t,r,n){for(var i=-1,s=t.length,o=r.length,a={};++i<s;){var c=i<o?r[i]:e;n(a,t[i],c)}return a}function _i(e){return Ko(e)?e:[]}function bi(e){return"function"==typeof e?e:oc}function Ei(e,t){return Yo(e)?e:ws(e,t)?[e]:js(Ea(e))}var wi=Zn;function Si(t,r,n){var i=t.length;return n=n===e?i:n,!r&&n>=i?t:si(t,r,n)}var Ci=pt||function(e){return ut.clearTimeout(e)};function Pi(e,t){if(t)return e.slice();var r=e.length,n=Ge?Ge(r):new e.constructor(r);return e.copy(n),n}function Ti(e){var t=new e.constructor(e.byteLength);return new ze(t).set(new ze(e)),t}function Ri(e,t){var r=t?Ti(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function ki(t,r){if(t!==r){var n=t!==e,i=null===t,s=t==t,o=la(t),a=r!==e,c=null===r,d=r==r,u=la(r);if(!c&&!u&&!o&&t>r||o&&a&&d&&!c&&!u||i&&a&&d||!n&&d||!s)return 1;if(!i&&!o&&!u&&t<r||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=_r(s-o,0),u=we(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=_r(s-a,0),l=we(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 Ai(e,t){var r=-1,n=e.length;for(t||(t=we(n));++r<n;)t[r]=e[r];return t}function Oi(t,r,n,i){var s=!n;n||(n={});for(var o=-1,a=r.length;++o<a;){var c=r[o],d=i?i(n[c],t[c],c,n,t):e;d===e&&(d=t[c]),s?an(n,c,d):rn(n,c,d)}return n}function Ni(e,t){return function(r,n){var i=Yo(r)?St:sn,s=t?t():{};return i(r,e,us(n,2),s)}}function Mi(t){return Zn((function(r,n){var i=-1,s=n.length,o=s>1?n[s-1]:e,a=s>2?n[2]:e;for(o=t.length>3&&"function"==typeof o?(s--,o):e,a&&Es(n[0],n[1],a)&&(o=s<3?e:o,s=1),r=Re(r);++i<s;){var c=n[i];c&&t(r,c,i,o)}return r}))}function Li(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=Re(r);(t?s--:++s<i)&&!1!==n(o[s],s,o););return r}}function xi(e){return function(t,r,n){for(var i=-1,s=Re(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(t){return function(r){var n=nr(r=Ea(r))?ur(r):e,i=n?n[0]:r.charAt(0),s=n?Si(n,1).join(""):r.slice(1);return i[t]()+s}}function ji(e){return function(t){return Ot(ec(Ga(t).replace(Je,"")),e,"")}}function Ui(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=Wr(e.prototype),n=e.apply(r,t);return na(n)?n:r}}function Vi(t){return function(r,n,i){var s=Re(r);if(!Jo(r)){var o=us(n,3);r=Ma(r),n=function(e){return o(s[e],e,s)}}var a=t(r,n,i);return a>-1?s[o?r[a]:a]:e}}function Bi(r){return is((function(n){var i=n.length,s=i,o=qr.prototype.thru;for(r&&n.reverse();s--;){var a=n[s];if("function"!=typeof a)throw new Ie(t);if(o&&!c&&"wrapper"==cs(a))var c=new qr([],!0)}for(s=c?s:i;++s<i;){var d=cs(a=n[s]),u="wrapper"==d?as(a):e;c=u&&Ss(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?c[cs(u[0])].apply(c,u[3]):1==a.length&&Ss(a)?c[d]():c.thru(a)}return function(){var e=arguments,t=e[0];if(c&&1==e.length&&Yo(t))return c.plant(t).value();for(var r=0,s=i?n[r].apply(this,e):t;++r<i;)s=n[r].call(this,s);return s}}))}function Wi(t,r,n,i,s,o,c,d,u,l){var p=r&a,h=1&r,f=2&r,m=24&r,g=512&r,v=f?e:Ui(t);return function e(){for(var a=arguments.length,y=we(a),_=a;_--;)y[_]=arguments[_];if(m)var b=ds(e),E=Xt(y,b);if(i&&(y=Di(y,i,s,m)),o&&(y=Ii(y,o,c,m)),a-=E,m&&a<l){var w=or(y,b);return Ji(t,r,Wi,e.placeholder,n,y,w,d,u,l-a)}var S=h?n:this,C=f?S[t]:t;return a=y.length,d?y=Is(y,d):g&&a>1&&y.reverse(),p&&u<a&&(y.length=u),this&&this!==ut&&this instanceof e&&(C=v||Ui(C)),C.apply(S,y)}}function Hi(e,t){return function(r,n){return function(e,t,r,n){return wn(e,(function(e,i,s){t(n,r(e),i,s)})),n}(r,e,t(n),{})}}function qi(t,r){return function(n,i){var s;if(n===e&&i===e)return r;if(n!==e&&(s=n),i!==e){if(s===e)return i;"string"==typeof n||"string"==typeof i?(n=li(n),i=li(i)):(n=ui(n),i=ui(i)),s=t(n,i)}return s}}function zi(e){return is((function(t){return t=It(t,$t(us())),Zn((function(r){var n=this;return e(t,(function(e){return wt(e,n,r)}))}))}))}function Gi(t,r){var n=(r=r===e?" ":li(r)).length;if(n<2)return n?Qn(r,t):r;var i=Qn(r,Lt(t/dr(r)));return nr(r)?Si(ur(i),0,t).join(""):i.slice(0,t)}function Yi(t){return function(r,n,i){return i&&"number"!=typeof i&&Es(r,n,i)&&(n=i=e),r=ga(r),n===e?(n=r,r=0):n=ga(n),function(e,t,r,n){for(var i=-1,s=_r(Lt((t-e)/(r||1)),0),o=we(s);s--;)o[n?s:++i]=e,e+=r;return o}(r,n,i=i===e?r<n?1:-1:ga(i),t)}}function $i(e){return function(t,r){return"string"==typeof t&&"string"==typeof r||(t=_a(t),r=_a(r)),e(t,r)}}function Ji(t,r,n,i,a,c,d,u,l,p){var h=8&r;r|=h?s:o,4&(r&=~(h?o:s))||(r&=-4);var f=[t,r,a,h?c:e,h?d:e,h?e:c,h?e:d,u,l,p],m=n.apply(e,f);return Ss(t)&&Os(m,f),m.placeholder=i,Ls(m,t,r)}function Ki(e){var t=Te[e];return function(e,r){if(e=_a(e),(r=null==r?0:br(va(r),292))&&gr(e)){var n=(Ea(e)+"e").split("e");return+((n=(Ea(t(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return t(e)}}var Qi=kr&&1/ar(new kr([,-0]))[1]==d?function(e){return new kr(e)}:lc;function Zi(e){return function(t){var r=gs(t);return r==w?ir(t):r==R?cr(t):function(e,t){return It(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Xi(r,d,u,l,p,h,f,m){var g=2&d;if(!g&&"function"!=typeof r)throw new Ie(t);var v=l?l.length:0;if(v||(d&=-97,l=p=e),f=f===e?f:_r(va(f),0),m=m===e?m:va(m),v-=p?p.length:0,d&o){var y=l,_=p;l=p=e}var b=g?e:as(r),E=[r,d,u,l,p,y,_,h,f,m];if(b&&function(e,t){var r=e[1],i=t[1],s=r|i,o=s<131,d=i==a&&8==r||i==a&&r==c&&e[7].length<=t[8]||384==i&&t[7].length<=t[8]&&8==r;if(!o&&!d)return e;1&i&&(e[2]=t[2],s|=1&r?0:4);var u=t[3];if(u){var l=e[3];e[3]=l?Di(l,u,t[4]):u,e[4]=l?or(e[3],n):t[4]}(u=t[5])&&(l=e[5],e[5]=l?Ii(l,u,t[6]):u,e[6]=l?or(e[5],n):t[6]),(u=t[7])&&(e[7]=u),i&a&&(e[8]=null==e[8]?t[8]:br(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=s}(E,b),r=E[0],d=E[1],u=E[2],l=E[3],p=E[4],!(m=E[9]=E[9]===e?g?0:r.length:_r(E[9]-v,0))&&24&d&&(d&=-25),d&&1!=d)w=8==d||d==i?function(t,r,n){var i=Ui(t);return function s(){for(var o=arguments.length,a=we(o),c=o,d=ds(s);c--;)a[c]=arguments[c];var u=o<3&&a[0]!==d&&a[o-1]!==d?[]:or(a,d);return(o-=u.length)<n?Ji(t,r,Wi,s.placeholder,e,a,u,e,e,n-o):wt(this&&this!==ut&&this instanceof s?i:t,this,a)}}(r,d,m):d!=s&&33!=d||p.length?Wi.apply(e,E):function(e,t,r,n){var i=1&t,s=Ui(e);return function t(){for(var o=-1,a=arguments.length,c=-1,d=n.length,u=we(d+a),l=this&&this!==ut&&this instanceof t?s:e;++c<d;)u[c]=n[c];for(;a--;)u[c++]=arguments[++o];return wt(l,i?r:this,u)}}(r,d,u,l);else var w=function(e,t,r){var n=1&t,i=Ui(e);return function t(){return(this&&this!==ut&&this instanceof t?i:e).apply(n?r:this,arguments)}}(r,d,u);return Ls((b?ri:Os)(w,E),r,d)}function es(t,r,n,i){return t===e||Ho(t,Ne[n])&&!xe.call(i,n)?r:t}function ts(t,r,n,i,s,o){return na(t)&&na(r)&&(o.set(r,t),qn(t,r,e,ts,o),o.delete(r)),t}function rs(t){return aa(t)?e:t}function ns(t,r,n,i,s,o){var a=1&n,c=t.length,d=r.length;if(c!=d&&!(a&&d>c))return!1;var u=o.get(t),l=o.get(r);if(u&&l)return u==r&&l==t;var p=-1,h=!0,f=2&n?new Jr:e;for(o.set(t,r),o.set(r,t);++p<c;){var m=t[p],g=r[p];if(i)var v=a?i(g,m,p,r,t,o):i(m,g,p,t,r,o);if(v!==e){if(v)continue;h=!1;break}if(f){if(!Mt(r,(function(e,t){if(!Kt(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(t),o.delete(r),h}function is(t){return Ms(ks(t,e,Ys),t+"")}function ss(e){return Tn(e,Ma,fs)}function os(e){return Tn(e,La,ms)}var as=Ar?function(e){return Ar.get(e)}:lc;function cs(e){for(var t=e.name+"",r=Or[t],n=xe.call(Or,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(xe.call(Br,"placeholder")?Br:e).placeholder}function us(){var e=Br.iteratee||ac;return e=e===ac?Fn:e,arguments.length?e(arguments[0],arguments[1]):e}function ls(e,t){var r,n,i=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof t?"string":"hash"]:i.map}function ps(e){for(var t=Ma(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Ts(i)]}return t}function hs(t,r){var n=function(t,r){return null==t?e:t[r]}(t,r);return xn(n)?n:e}var fs=fr?function(e){return null==e?[]:(e=Re(e),Rt(fr(e),(function(t){return Qe.call(e,t)})))}:yc,ms=fr?function(e){for(var t=[];e;)At(t,fs(e)),e=Ye(e);return t}:yc,gs=Rn;function vs(e,t,r){for(var n=-1,i=(t=Ei(t,e)).length,s=!1;++n<i;){var o=Us(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)&&bs(o,i)&&(Yo(e)||Go(e))}function ys(e){return"function"!=typeof e.constructor||Ps(e)?{}:Wr(Ye(e))}function _s(e){return Yo(e)||Go(e)||!!(st&&e&&e[st])}function bs(e,t){var r=typeof e;return!!(t=null==t?u:t)&&("number"==r||"symbol"!=r&&ve.test(e))&&e>-1&&e%1==0&&e<t}function Es(e,t,r){if(!na(r))return!1;var n=typeof t;return!!("number"==n?Jo(r)&&bs(t,r.length):"string"==n&&t in r)&&Ho(r[t],e)}function ws(e,t){if(Yo(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!la(e))||X.test(e)||!Z.test(e)||null!=t&&e in Re(t)}function Ss(e){var t=cs(e),r=Br[t];if("function"!=typeof r||!(t in zr.prototype))return!1;if(e===r)return!0;var n=as(r);return!!n&&e===n[0]}(Pr&&gs(new Pr(new ArrayBuffer(1)))!=O||Tr&&gs(new Tr)!=w||Rr&&gs(Rr.resolve())!=P||kr&&gs(new kr)!=R||Dr&&gs(new Dr)!=I)&&(gs=function(t){var r=Rn(t),n=r==C?t.constructor:e,i=n?Vs(n):"";if(i)switch(i){case Nr:return O;case Mr:return w;case Lr:return P;case xr:return R;case Fr:return I}return r});var Cs=Me?ea:_c;function Ps(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Ne)}function Ts(e){return e==e&&!na(e)}function Rs(t,r){return function(n){return null!=n&&n[t]===r&&(r!==e||t in Re(n))}}function ks(t,r,n){return r=_r(r===e?t.length-1:r,0),function(){for(var e=arguments,i=-1,s=_r(e.length-r,0),o=we(s);++i<s;)o[i]=e[r+i];i=-1;for(var a=we(r+1);++i<r;)a[i]=e[i];return a[r]=n(o),wt(t,this,a)}}function Ds(e,t){return t.length<2?e:Pn(e,si(t,0,-1))}function Is(t,r){for(var n=t.length,i=br(r.length,n),s=Ai(t);i--;){var o=r[i];t[i]=bs(o,n)?s[o]:e}return t}function As(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Os=xs(ri),Ns=mt||function(e,t){return ut.setTimeout(e,t)},Ms=xs(ni);function Ls(e,t,r){var n=t+"";return Ms(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(se,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return Ct(f,(function(r){var n="_."+r[0];t&r[1]&&!kt(e,n)&&e.push(n)})),e.sort()}(function(e){var t=e.match(oe);return t?t[1].split(ae):[]}(n),r)))}function xs(t){var r=0,n=0;return function(){var i=Er(),s=16-(i-n);if(n=i,s>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(e,arguments)}}function Fs(t,r){var n=-1,i=t.length,s=i-1;for(r=r===e?i:r;++n<r;){var o=Kn(n,s),a=t[o];t[o]=t[n],t[n]=a}return t.length=r,t}var js=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(ee,(function(e,r,n,i){t.push(n?i.replace(ue,"$1"):r||e)})),t}));function Us(e){if("string"==typeof e||la(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Vs(e){if(null!=e){try{return Le.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Bs(e){if(e instanceof zr)return e.clone();var t=new qr(e.__wrapped__,e.__chain__);return t.__actions__=Ai(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var Ws=Zn((function(e,t){return Ko(e)?hn(e,_n(t,1,Ko,!0)):[]})),Hs=Zn((function(t,r){var n=Zs(r);return Ko(n)&&(n=e),Ko(t)?hn(t,_n(r,1,Ko,!0),us(n,2)):[]})),qs=Zn((function(t,r){var n=Zs(r);return Ko(n)&&(n=e),Ko(t)?hn(t,_n(r,1,Ko,!0),e,n):[]}));function zs(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=_r(n+i,0)),Ft(e,us(t,3),i)}function Gs(t,r,n){var i=null==t?0:t.length;if(!i)return-1;var s=i-1;return n!==e&&(s=va(n),s=n<0?_r(i+s,0):br(s,i-1)),Ft(t,us(r,3),s,!0)}function Ys(e){return null!=e&&e.length?_n(e,1):[]}function $s(t){return t&&t.length?t[0]:e}var Js=Zn((function(e){var t=It(e,_i);return t.length&&t[0]===e[0]?An(t):[]})),Ks=Zn((function(t){var r=Zs(t),n=It(t,_i);return r===Zs(n)?r=e:n.pop(),n.length&&n[0]===t[0]?An(n,us(r,2)):[]})),Qs=Zn((function(t){var r=Zs(t),n=It(t,_i);return(r="function"==typeof r?r:e)&&n.pop(),n.length&&n[0]===t[0]?An(n,e,r):[]}));function Zs(t){var r=null==t?0:t.length;return r?t[r-1]:e}var Xs=Zn(eo);function eo(e,t){return e&&e.length&&t&&t.length?$n(e,t):e}var to=is((function(e,t){var r=null==e?0:e.length,n=cn(e,t);return Jn(e,It(t,(function(e){return bs(e,r)?+e:e})).sort(ki)),n}));function ro(e){return null==e?e:Cr.call(e)}var no=Zn((function(e){return pi(_n(e,1,Ko,!0))})),io=Zn((function(t){var r=Zs(t);return Ko(r)&&(r=e),pi(_n(t,1,Ko,!0),us(r,2))})),so=Zn((function(t){var r=Zs(t);return r="function"==typeof r?r:e,pi(_n(t,1,Ko,!0),e,r)}));function oo(e){if(!e||!e.length)return[];var t=0;return e=Rt(e,(function(e){if(Ko(e))return t=_r(e.length,t),!0})),Gt(t,(function(t){return It(e,Wt(t))}))}function ao(t,r){if(!t||!t.length)return[];var n=oo(t);return null==r?n:It(n,(function(t){return wt(r,e,t)}))}var co=Zn((function(e,t){return Ko(e)?hn(e,t):[]})),uo=Zn((function(e){return vi(Rt(e,Ko))})),lo=Zn((function(t){var r=Zs(t);return Ko(r)&&(r=e),vi(Rt(t,Ko),us(r,2))})),po=Zn((function(t){var r=Zs(t);return r="function"==typeof r?r:e,vi(Rt(t,Ko),e,r)})),ho=Zn(oo),fo=Zn((function(t){var r=t.length,n=r>1?t[r-1]:e;return n="function"==typeof n?(t.pop(),n):e,ao(t,n)}));function mo(e){var t=Br(e);return t.__chain__=!0,t}function go(e,t){return t(e)}var vo=is((function(t){var r=t.length,n=r?t[0]:0,i=this.__wrapped__,s=function(e){return cn(e,t)};return!(r>1||this.__actions__.length)&&i instanceof zr&&bs(n)?((i=i.slice(n,+n+(r?1:0))).__actions__.push({func:go,args:[s],thisArg:e}),new qr(i,this.__chain__).thru((function(t){return r&&!t.length&&t.push(e),t}))):this.thru(s)})),yo=Ni((function(e,t,r){xe.call(e,r)?++e[r]:an(e,r,1)})),_o=Vi(zs),bo=Vi(Gs);function Eo(e,t){return(Yo(e)?Ct:fn)(e,us(t,3))}function wo(e,t){return(Yo(e)?Pt:mn)(e,us(t,3))}var So=Ni((function(e,t,r){xe.call(e,r)?e[r].push(t):an(e,r,[t])})),Co=Zn((function(e,t,r){var n=-1,i="function"==typeof t,s=Jo(e)?we(e.length):[];return fn(e,(function(e){s[++n]=i?wt(t,e,r):On(e,t,r)})),s})),Po=Ni((function(e,t,r){an(e,r,t)}));function To(e,t){return(Yo(e)?It:Bn)(e,us(t,3))}var Ro=Ni((function(e,t,r){e[r?0:1].push(t)}),(function(){return[[],[]]})),ko=Zn((function(e,t){if(null==e)return[];var r=t.length;return r>1&&Es(e,t[0],t[1])?t=[]:r>2&&Es(t[0],t[1],t[2])&&(t=[t[0]]),Gn(e,_n(t,1),[])})),Do=ft||function(){return ut.Date.now()};function Io(t,r,n){return r=n?e:r,r=t&&null==r?t.length:r,Xi(t,a,e,e,e,e,r)}function Ao(r,n){var i;if("function"!=typeof n)throw new Ie(t);return r=va(r),function(){return--r>0&&(i=n.apply(this,arguments)),r<=1&&(n=e),i}}var Oo=Zn((function(e,t,r){var n=1;if(r.length){var i=or(r,ds(Oo));n|=s}return Xi(e,n,t,r,i)})),No=Zn((function(e,t,r){var n=3;if(r.length){var i=or(r,ds(No));n|=s}return Xi(t,n,e,r,i)}));function Mo(r,n,i){var s,o,a,c,d,u,l=0,p=!1,h=!1,f=!0;if("function"!=typeof r)throw new Ie(t);function m(t){var n=s,i=o;return s=o=e,l=t,c=r.apply(i,n)}function g(e){return l=e,d=Ns(y,n),p?m(e):c}function v(t){var r=t-u;return u===e||r>=n||r<0||h&&t-l>=a}function y(){var e=Do();if(v(e))return _(e);d=Ns(y,function(e){var t=n-(e-u);return h?br(t,a-(e-l)):t}(e))}function _(t){return d=e,f&&s?m(t):(s=o=e,c)}function b(){var t=Do(),r=v(t);if(s=arguments,o=this,u=t,r){if(d===e)return g(u);if(h)return Ci(d),d=Ns(y,n),m(u)}return d===e&&(d=Ns(y,n)),c}return n=_a(n)||0,na(i)&&(p=!!i.leading,a=(h="maxWait"in i)?_r(_a(i.maxWait)||0,n):a,f="trailing"in i?!!i.trailing:f),b.cancel=function(){d!==e&&Ci(d),l=0,s=u=o=d=e},b.flush=function(){return d===e?c:_(Do())},b}var Lo=Zn((function(e,t){return pn(e,1,t)})),xo=Zn((function(e,t,r){return pn(e,_a(t)||0,r)}));function Fo(e,r){if("function"!=typeof e||null!=r&&"function"!=typeof r)throw new Ie(t);var n=function(){var t=arguments,i=r?r.apply(this,t):t[0],s=n.cache;if(s.has(i))return s.get(i);var o=e.apply(this,t);return n.cache=s.set(i,o)||s,o};return n.cache=new(Fo.Cache||$r),n}function jo(e){if("function"!=typeof e)throw new Ie(t);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=$r;var Uo=wi((function(e,t){var r=(t=1==t.length&&Yo(t[0])?It(t[0],$t(us())):It(_n(t,1),$t(us()))).length;return Zn((function(n){for(var i=-1,s=br(n.length,r);++i<s;)n[i]=t[i].call(this,n[i]);return wt(e,this,n)}))})),Vo=Zn((function(t,r){var n=or(r,ds(Vo));return Xi(t,s,e,r,n)})),Bo=Zn((function(t,r){var n=or(r,ds(Bo));return Xi(t,o,e,r,n)})),Wo=is((function(t,r){return Xi(t,c,e,e,e,r)}));function Ho(e,t){return e===t||e!=e&&t!=t}var qo=$i(kn),zo=$i((function(e,t){return e>=t})),Go=Nn(function(){return arguments}())?Nn:function(e){return ia(e)&&xe.call(e,"callee")&&!Qe.call(e,"callee")},Yo=we.isArray,$o=gt?$t(gt):function(e){return ia(e)&&Rn(e)==A};function Jo(e){return null!=e&&ra(e.length)&&!ea(e)}function Ko(e){return ia(e)&&Jo(e)}var Qo=mr||_c,Zo=vt?$t(vt):function(e){return ia(e)&&Rn(e)==y};function Xo(e){if(!ia(e))return!1;var t=Rn(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=Rn(e);return t==b||t==E||"[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<=u}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=yt?$t(yt):function(e){return ia(e)&&gs(e)==w};function oa(e){return"number"==typeof e||ia(e)&&Rn(e)==S}function aa(e){if(!ia(e)||Rn(e)!=C)return!1;var t=Ye(e);if(null===t)return!0;var r=xe.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Le.call(r)==Ve}var ca=_t?$t(_t):function(e){return ia(e)&&Rn(e)==T},da=bt?$t(bt):function(e){return ia(e)&&gs(e)==R};function ua(e){return"string"==typeof e||!Yo(e)&&ia(e)&&Rn(e)==k}function la(e){return"symbol"==typeof e||ia(e)&&Rn(e)==D}var pa=Et?$t(Et):function(e){return ia(e)&&ra(e.length)&&!!nt[Rn(e)]},ha=$i(Vn),fa=$i((function(e,t){return e<=t}));function ma(e){if(!e)return[];if(Jo(e))return ua(e)?ur(e):Ai(e);if(ct&&e[ct])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[ct]());var t=gs(e);return(t==w?ir:t==R?ar:Ha)(e)}function ga(e){return e?(e=_a(e))===d||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,h):0}function _a(e){if("number"==typeof e)return e;if(la(e))return p;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=Yt(e);var r=fe.test(e);return r||ge.test(e)?at(e.slice(2),r?2:8):he.test(e)?p:+e}function ba(e){return Oi(e,La(e))}function Ea(e){return null==e?"":li(e)}var wa=Mi((function(e,t){if(Ps(t)||Jo(t))Oi(t,Ma(t),e);else for(var r in t)xe.call(t,r)&&rn(e,r,t[r])})),Sa=Mi((function(e,t){Oi(t,La(t),e)})),Ca=Mi((function(e,t,r,n){Oi(t,La(t),e,n)})),Pa=Mi((function(e,t,r,n){Oi(t,Ma(t),e,n)})),Ta=is(cn),Ra=Zn((function(t,r){t=Re(t);var n=-1,i=r.length,s=i>2?r[2]:e;for(s&&Es(r[0],r[1],s)&&(i=1);++n<i;)for(var o=r[n],a=La(o),c=-1,d=a.length;++c<d;){var u=a[c],l=t[u];(l===e||Ho(l,Ne[u])&&!xe.call(t,u))&&(t[u]=o[u])}return t})),ka=Zn((function(t){return t.push(e,ts),wt(Fa,e,t)}));function Da(t,r,n){var i=null==t?e:Pn(t,r);return i===e?n:i}function Ia(e,t){return null!=e&&vs(e,t,In)}var Aa=Hi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=Ue.call(t)),e[t]=r}),nc(oc)),Oa=Hi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=Ue.call(t)),xe.call(e,t)?e[t].push(r):e[t]=[r]}),us),Na=Zn(On);function Ma(e){return Jo(e)?Qr(e):jn(e)}function La(e){return Jo(e)?Qr(e,!0):Un(e)}var xa=Mi((function(e,t,r){qn(e,t,r)})),Fa=Mi((function(e,t,r,n){qn(e,t,r,n)})),ja=is((function(e,t){var r={};if(null==e)return r;var n=!1;t=It(t,(function(t){return t=Ei(t,e),n||(n=t.length>1),t})),Oi(e,os(e),r),n&&(r=un(r,7,rs));for(var i=t.length;i--;)hi(r,t[i]);return r})),Ua=is((function(e,t){return null==e?{}:function(e,t){return Yn(e,t,(function(t,r){return Ia(e,r)}))}(e,t)}));function Va(e,t){if(null==e)return{};var r=It(os(e),(function(e){return[e]}));return t=us(t),Yn(e,r,(function(e,r){return t(e,r[0])}))}var Ba=Zi(Ma),Wa=Zi(La);function Ha(e){return null==e?[]:Jt(e,Ma(e))}var qa=ji((function(e,t,r){return t=t.toLowerCase(),e+(r?za(t):t)}));function za(e){return Xa(Ea(e).toLowerCase())}function Ga(e){return(e=Ea(e))&&e.replace(ye,er).replace(Ke,"")}var Ya=ji((function(e,t,r){return e+(r?"-":"")+t.toLowerCase()})),$a=ji((function(e,t,r){return e+(r?" ":"")+t.toLowerCase()})),Ja=Fi("toLowerCase"),Ka=ji((function(e,t,r){return e+(r?"_":"")+t.toLowerCase()})),Qa=ji((function(e,t,r){return e+(r?" ":"")+Xa(t)})),Za=ji((function(e,t,r){return e+(r?" ":"")+t.toUpperCase()})),Xa=Fi("toUpperCase");function ec(t,r,n){return t=Ea(t),(r=n?e:r)===e?function(e){return et.test(e)}(t)?function(e){return e.match(Ze)||[]}(t):function(e){return e.match(ce)||[]}(t):t.match(r)||[]}var tc=Zn((function(t,r){try{return wt(t,e,r)}catch(e){return Xo(e)?e:new Ce(e)}})),rc=is((function(e,t){return Ct(t,(function(t){t=Us(t),an(e,t,Oo(e[t],e))})),e}));function nc(e){return function(){return e}}var ic=Bi(),sc=Bi(!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 On(r,e,t)}})),dc=Zn((function(e,t){return function(r){return On(e,r,t)}}));function uc(e,t,r){var n=Ma(t),i=Cn(t,n);null!=r||na(t)&&(i.length||!n.length)||(r=t,t=e,e=this,i=Cn(t,Ma(t)));var s=!(na(r)&&"chain"in r&&!r.chain),o=ea(e);return Ct(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__=Ai(this.__actions__);return i.push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,At([this.value()],arguments))})})),e}function lc(){}var pc=zi(It),hc=zi(Tt),fc=zi(Mt);function mc(e){return ws(e)?Wt(Us(e)):function(e){return function(t){return Pn(t,e)}}(e)}var gc=Yi(),vc=Yi(!0);function yc(){return[]}function _c(){return!1}var bc,Ec=qi((function(e,t){return e+t}),0),wc=Ki("ceil"),Sc=qi((function(e,t){return e/t}),1),Cc=Ki("floor"),Pc=qi((function(e,t){return e*t}),1),Tc=Ki("round"),Rc=qi((function(e,t){return e-t}),0);return Br.after=function(e,r){if("function"!=typeof r)throw new Ie(t);return e=va(e),function(){if(--e<1)return r.apply(this,arguments)}},Br.ary=Io,Br.assign=wa,Br.assignIn=Sa,Br.assignInWith=Ca,Br.assignWith=Pa,Br.at=Ta,Br.before=Ao,Br.bind=Oo,Br.bindAll=rc,Br.bindKey=No,Br.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Yo(e)?e:[e]},Br.chain=mo,Br.chunk=function(t,r,n){r=(n?Es(t,r,n):r===e)?1:_r(va(r),0);var i=null==t?0:t.length;if(!i||r<1)return[];for(var s=0,o=0,a=we(Lt(i/r));s<i;)a[o++]=si(t,s,s+=r);return a},Br.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},Br.concat=function(){var e=arguments.length;if(!e)return[];for(var t=we(e-1),r=arguments[0],n=e;n--;)t[n-1]=arguments[n];return At(Yo(r)?Ai(r):[r],_n(t,1))},Br.cond=function(e){var r=null==e?0:e.length,n=us();return e=r?It(e,(function(e){if("function"!=typeof e[1])throw new Ie(t);return[n(e[0]),e[1]]})):[],Zn((function(t){for(var n=-1;++n<r;){var i=e[n];if(wt(i[0],this,t))return wt(i[1],this,t)}}))},Br.conforms=function(e){return function(e){var t=Ma(e);return function(r){return ln(r,e,t)}}(un(e,1))},Br.constant=nc,Br.countBy=yo,Br.create=function(e,t){var r=Wr(e);return null==t?r:on(r,t)},Br.curry=function t(r,n,i){var s=Xi(r,8,e,e,e,e,e,n=i?e:n);return s.placeholder=t.placeholder,s},Br.curryRight=function t(r,n,s){var o=Xi(r,i,e,e,e,e,e,n=s?e:n);return o.placeholder=t.placeholder,o},Br.debounce=Mo,Br.defaults=Ra,Br.defaultsDeep=ka,Br.defer=Lo,Br.delay=xo,Br.difference=Ws,Br.differenceBy=Hs,Br.differenceWith=qs,Br.drop=function(t,r,n){var i=null==t?0:t.length;return i?si(t,(r=n||r===e?1:va(r))<0?0:r,i):[]},Br.dropRight=function(t,r,n){var i=null==t?0:t.length;return i?si(t,0,(r=i-(r=n||r===e?1:va(r)))<0?0:r):[]},Br.dropRightWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!0,!0):[]},Br.dropWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!0):[]},Br.fill=function(t,r,n,i){var s=null==t?0:t.length;return s?(n&&"number"!=typeof n&&Es(t,r,n)&&(n=0,i=s),function(t,r,n,i){var s=t.length;for((n=va(n))<0&&(n=-n>s?0:s+n),(i=i===e||i>s?s:va(i))<0&&(i+=s),i=n>i?0:ya(i);n<i;)t[n++]=r;return t}(t,r,n,i)):[]},Br.filter=function(e,t){return(Yo(e)?Rt:yn)(e,us(t,3))},Br.flatMap=function(e,t){return _n(To(e,t),1)},Br.flatMapDeep=function(e,t){return _n(To(e,t),d)},Br.flatMapDepth=function(t,r,n){return n=n===e?1:va(n),_n(To(t,r),n)},Br.flatten=Ys,Br.flattenDeep=function(e){return null!=e&&e.length?_n(e,d):[]},Br.flattenDepth=function(t,r){return null!=t&&t.length?_n(t,r=r===e?1:va(r)):[]},Br.flip=function(e){return Xi(e,512)},Br.flow=ic,Br.flowRight=sc,Br.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},Br.functions=function(e){return null==e?[]:Cn(e,Ma(e))},Br.functionsIn=function(e){return null==e?[]:Cn(e,La(e))},Br.groupBy=So,Br.initial=function(e){return null!=e&&e.length?si(e,0,-1):[]},Br.intersection=Js,Br.intersectionBy=Ks,Br.intersectionWith=Qs,Br.invert=Aa,Br.invertBy=Oa,Br.invokeMap=Co,Br.iteratee=ac,Br.keyBy=Po,Br.keys=Ma,Br.keysIn=La,Br.map=To,Br.mapKeys=function(e,t){var r={};return t=us(t,3),wn(e,(function(e,n,i){an(r,t(e,n,i),e)})),r},Br.mapValues=function(e,t){var r={};return t=us(t,3),wn(e,(function(e,n,i){an(r,n,t(e,n,i))})),r},Br.matches=function(e){return Wn(un(e,1))},Br.matchesProperty=function(e,t){return Hn(e,un(t,1))},Br.memoize=Fo,Br.merge=xa,Br.mergeWith=Fa,Br.method=cc,Br.methodOf=dc,Br.mixin=uc,Br.negate=jo,Br.nthArg=function(e){return e=va(e),Zn((function(t){return zn(t,e)}))},Br.omit=ja,Br.omitBy=function(e,t){return Va(e,jo(us(t)))},Br.once=function(e){return Ao(2,e)},Br.orderBy=function(t,r,n,i){return null==t?[]:(Yo(r)||(r=null==r?[]:[r]),Yo(n=i?e:n)||(n=null==n?[]:[n]),Gn(t,r,n))},Br.over=pc,Br.overArgs=Uo,Br.overEvery=hc,Br.overSome=fc,Br.partial=Vo,Br.partialRight=Bo,Br.partition=Ro,Br.pick=Ua,Br.pickBy=Va,Br.property=mc,Br.propertyOf=function(t){return function(r){return null==t?e:Pn(t,r)}},Br.pull=Xs,Br.pullAll=eo,Br.pullAllBy=function(e,t,r){return e&&e.length&&t&&t.length?$n(e,t,us(r,2)):e},Br.pullAllWith=function(t,r,n){return t&&t.length&&r&&r.length?$n(t,r,e,n):t},Br.pullAt=to,Br.range=gc,Br.rangeRight=vc,Br.rearg=Wo,Br.reject=function(e,t){return(Yo(e)?Rt:yn)(e,jo(us(t,3)))},Br.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},Br.rest=function(r,n){if("function"!=typeof r)throw new Ie(t);return Zn(r,n=n===e?n:va(n))},Br.reverse=ro,Br.sampleSize=function(t,r,n){return r=(n?Es(t,r,n):r===e)?1:va(r),(Yo(t)?Xr:ei)(t,r)},Br.set=function(e,t,r){return null==e?e:ti(e,t,r)},Br.setWith=function(t,r,n,i){return i="function"==typeof i?i:e,null==t?t:ti(t,r,n,i)},Br.shuffle=function(e){return(Yo(e)?en:ii)(e)},Br.slice=function(t,r,n){var i=null==t?0:t.length;return i?(n&&"number"!=typeof n&&Es(t,r,n)?(r=0,n=i):(r=null==r?0:va(r),n=n===e?i:va(n)),si(t,r,n)):[]},Br.sortBy=ko,Br.sortedUniq=function(e){return e&&e.length?di(e):[]},Br.sortedUniqBy=function(e,t){return e&&e.length?di(e,us(t,2)):[]},Br.split=function(t,r,n){return n&&"number"!=typeof n&&Es(t,r,n)&&(r=n=e),(n=n===e?h:n>>>0)?(t=Ea(t))&&("string"==typeof r||null!=r&&!ca(r))&&!(r=li(r))&&nr(t)?Si(ur(t),0,n):t.split(r,n):[]},Br.spread=function(e,r){if("function"!=typeof e)throw new Ie(t);return r=null==r?0:_r(va(r),0),Zn((function(t){var n=t[r],i=Si(t,0,r);return n&&At(i,n),wt(e,this,i)}))},Br.tail=function(e){var t=null==e?0:e.length;return t?si(e,1,t):[]},Br.take=function(t,r,n){return t&&t.length?si(t,0,(r=n||r===e?1:va(r))<0?0:r):[]},Br.takeRight=function(t,r,n){var i=null==t?0:t.length;return i?si(t,(r=i-(r=n||r===e?1:va(r)))<0?0:r,i):[]},Br.takeRightWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!1,!0):[]},Br.takeWhile=function(e,t){return e&&e.length?mi(e,us(t,3)):[]},Br.tap=function(e,t){return t(e),e},Br.throttle=function(e,r,n){var i=!0,s=!0;if("function"!=typeof e)throw new Ie(t);return na(n)&&(i="leading"in n?!!n.leading:i,s="trailing"in n?!!n.trailing:s),Mo(e,r,{leading:i,maxWait:r,trailing:s})},Br.thru=go,Br.toArray=ma,Br.toPairs=Ba,Br.toPairsIn=Wa,Br.toPath=function(e){return Yo(e)?It(e,Us):la(e)?[e]:Ai(js(Ea(e)))},Br.toPlainObject=ba,Br.transform=function(e,t,r){var n=Yo(e),i=n||Qo(e)||pa(e);if(t=us(t,4),null==r){var s=e&&e.constructor;r=i?n?new s:[]:na(e)&&ea(s)?Wr(Ye(e)):{}}return(i?Ct:wn)(e,(function(e,n,i){return t(r,e,n,i)})),r},Br.unary=function(e){return Io(e,1)},Br.union=no,Br.unionBy=io,Br.unionWith=so,Br.uniq=function(e){return e&&e.length?pi(e):[]},Br.uniqBy=function(e,t){return e&&e.length?pi(e,us(t,2)):[]},Br.uniqWith=function(t,r){return r="function"==typeof r?r:e,t&&t.length?pi(t,e,r):[]},Br.unset=function(e,t){return null==e||hi(e,t)},Br.unzip=oo,Br.unzipWith=ao,Br.update=function(e,t,r){return null==e?e:fi(e,t,bi(r))},Br.updateWith=function(t,r,n,i){return i="function"==typeof i?i:e,null==t?t:fi(t,r,bi(n),i)},Br.values=Ha,Br.valuesIn=function(e){return null==e?[]:Jt(e,La(e))},Br.without=co,Br.words=ec,Br.wrap=function(e,t){return Vo(bi(t),e)},Br.xor=uo,Br.xorBy=lo,Br.xorWith=po,Br.zip=ho,Br.zipObject=function(e,t){return yi(e||[],t||[],rn)},Br.zipObjectDeep=function(e,t){return yi(e||[],t||[],ti)},Br.zipWith=fo,Br.entries=Ba,Br.entriesIn=Wa,Br.extend=Sa,Br.extendWith=Ca,uc(Br,Br),Br.add=Ec,Br.attempt=tc,Br.camelCase=qa,Br.capitalize=za,Br.ceil=wc,Br.clamp=function(t,r,n){return n===e&&(n=r,r=e),n!==e&&(n=(n=_a(n))==n?n:0),r!==e&&(r=(r=_a(r))==r?r:0),dn(_a(t),r,n)},Br.clone=function(e){return un(e,4)},Br.cloneDeep=function(e){return un(e,5)},Br.cloneDeepWith=function(t,r){return un(t,5,r="function"==typeof r?r:e)},Br.cloneWith=function(t,r){return un(t,4,r="function"==typeof r?r:e)},Br.conformsTo=function(e,t){return null==t||ln(e,t,Ma(t))},Br.deburr=Ga,Br.defaultTo=function(e,t){return null==e||e!=e?t:e},Br.divide=Sc,Br.endsWith=function(t,r,n){t=Ea(t),r=li(r);var i=t.length,s=n=n===e?i:dn(va(n),0,i);return(n-=r.length)>=0&&t.slice(n,s)==r},Br.eq=Ho,Br.escape=function(e){return(e=Ea(e))&&$.test(e)?e.replace(G,tr):e},Br.escapeRegExp=function(e){return(e=Ea(e))&&re.test(e)?e.replace(te,"\\$&"):e},Br.every=function(t,r,n){var i=Yo(t)?Tt:gn;return n&&Es(t,r,n)&&(r=e),i(t,us(r,3))},Br.find=_o,Br.findIndex=zs,Br.findKey=function(e,t){return xt(e,us(t,3),wn)},Br.findLast=bo,Br.findLastIndex=Gs,Br.findLastKey=function(e,t){return xt(e,us(t,3),Sn)},Br.floor=Cc,Br.forEach=Eo,Br.forEachRight=wo,Br.forIn=function(e,t){return null==e?e:bn(e,us(t,3),La)},Br.forInRight=function(e,t){return null==e?e:En(e,us(t,3),La)},Br.forOwn=function(e,t){return e&&wn(e,us(t,3))},Br.forOwnRight=function(e,t){return e&&Sn(e,us(t,3))},Br.get=Da,Br.gt=qo,Br.gte=zo,Br.has=function(e,t){return null!=e&&vs(e,t,Dn)},Br.hasIn=Ia,Br.head=$s,Br.identity=oc,Br.includes=function(e,t,r,n){e=Jo(e)?e:Ha(e),r=r&&!n?va(r):0;var i=e.length;return r<0&&(r=_r(i+r,0)),ua(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&jt(e,t,r)>-1},Br.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=_r(n+i,0)),jt(e,t,i)},Br.inRange=function(t,r,n){return r=ga(r),n===e?(n=r,r=0):n=ga(n),function(e,t,r){return e>=br(t,r)&&e<_r(t,r)}(t=_a(t),r,n)},Br.invoke=Na,Br.isArguments=Go,Br.isArray=Yo,Br.isArrayBuffer=$o,Br.isArrayLike=Jo,Br.isArrayLikeObject=Ko,Br.isBoolean=function(e){return!0===e||!1===e||ia(e)&&Rn(e)==v},Br.isBuffer=Qo,Br.isDate=Zo,Br.isElement=function(e){return ia(e)&&1===e.nodeType&&!aa(e)},Br.isEmpty=function(e){if(null==e)return!0;if(Jo(e)&&(Yo(e)||"string"==typeof e||"function"==typeof e.splice||Qo(e)||pa(e)||Go(e)))return!e.length;var t=gs(e);if(t==w||t==R)return!e.size;if(Ps(e))return!jn(e).length;for(var r in e)if(xe.call(e,r))return!1;return!0},Br.isEqual=function(e,t){return Mn(e,t)},Br.isEqualWith=function(t,r,n){var i=(n="function"==typeof n?n:e)?n(t,r):e;return i===e?Mn(t,r,e,n):!!i},Br.isError=Xo,Br.isFinite=function(e){return"number"==typeof e&&gr(e)},Br.isFunction=ea,Br.isInteger=ta,Br.isLength=ra,Br.isMap=sa,Br.isMatch=function(e,t){return e===t||Ln(e,t,ps(t))},Br.isMatchWith=function(t,r,n){return n="function"==typeof n?n:e,Ln(t,r,ps(r),n)},Br.isNaN=function(e){return oa(e)&&e!=+e},Br.isNative=function(e){if(Cs(e))throw new Ce("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return xn(e)},Br.isNil=function(e){return null==e},Br.isNull=function(e){return null===e},Br.isNumber=oa,Br.isObject=na,Br.isObjectLike=ia,Br.isPlainObject=aa,Br.isRegExp=ca,Br.isSafeInteger=function(e){return ta(e)&&e>=-9007199254740991&&e<=u},Br.isSet=da,Br.isString=ua,Br.isSymbol=la,Br.isTypedArray=pa,Br.isUndefined=function(t){return t===e},Br.isWeakMap=function(e){return ia(e)&&gs(e)==I},Br.isWeakSet=function(e){return ia(e)&&"[object WeakSet]"==Rn(e)},Br.join=function(e,t){return null==e?"":vr.call(e,t)},Br.kebabCase=Ya,Br.last=Zs,Br.lastIndexOf=function(t,r,n){var i=null==t?0:t.length;if(!i)return-1;var s=i;return n!==e&&(s=(s=va(n))<0?_r(i+s,0):br(s,i-1)),r==r?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(t,r,s):Ft(t,Vt,s,!0)},Br.lowerCase=$a,Br.lowerFirst=Ja,Br.lt=ha,Br.lte=fa,Br.max=function(t){return t&&t.length?vn(t,oc,kn):e},Br.maxBy=function(t,r){return t&&t.length?vn(t,us(r,2),kn):e},Br.mean=function(e){return Bt(e,oc)},Br.meanBy=function(e,t){return Bt(e,us(t,2))},Br.min=function(t){return t&&t.length?vn(t,oc,Vn):e},Br.minBy=function(t,r){return t&&t.length?vn(t,us(r,2),Vn):e},Br.stubArray=yc,Br.stubFalse=_c,Br.stubObject=function(){return{}},Br.stubString=function(){return""},Br.stubTrue=function(){return!0},Br.multiply=Pc,Br.nth=function(t,r){return t&&t.length?zn(t,va(r)):e},Br.noConflict=function(){return ut._===this&&(ut._=Be),this},Br.noop=lc,Br.now=Do,Br.pad=function(e,t,r){e=Ea(e);var n=(t=va(t))?dr(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return Gi(Ht(i),r)+e+Gi(Lt(i),r)},Br.padEnd=function(e,t,r){e=Ea(e);var n=(t=va(t))?dr(e):0;return t&&n<t?e+Gi(t-n,r):e},Br.padStart=function(e,t,r){e=Ea(e);var n=(t=va(t))?dr(e):0;return t&&n<t?Gi(t-n,r)+e:e},Br.parseInt=function(e,t,r){return r||null==t?t=0:t&&(t=+t),wr(Ea(e).replace(ne,""),t||0)},Br.random=function(t,r,n){if(n&&"boolean"!=typeof n&&Es(t,r,n)&&(r=n=e),n===e&&("boolean"==typeof r?(n=r,r=e):"boolean"==typeof t&&(n=t,t=e)),t===e&&r===e?(t=0,r=1):(t=ga(t),r===e?(r=t,t=0):r=ga(r)),t>r){var i=t;t=r,r=i}if(n||t%1||r%1){var s=Sr();return br(t+s*(r-t+ot("1e-"+((s+"").length-1))),r)}return Kn(t,r)},Br.reduce=function(e,t,r){var n=Yo(e)?Ot:qt,i=arguments.length<3;return n(e,us(t,4),r,i,fn)},Br.reduceRight=function(e,t,r){var n=Yo(e)?Nt:qt,i=arguments.length<3;return n(e,us(t,4),r,i,mn)},Br.repeat=function(t,r,n){return r=(n?Es(t,r,n):r===e)?1:va(r),Qn(Ea(t),r)},Br.replace=function(){var e=arguments,t=Ea(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Br.result=function(t,r,n){var i=-1,s=(r=Ei(r,t)).length;for(s||(s=1,t=e);++i<s;){var o=null==t?e:t[Us(r[i])];o===e&&(i=s,o=n),t=ea(o)?o.call(t):o}return t},Br.round=Tc,Br.runInContext=l,Br.sample=function(e){return(Yo(e)?Zr:Xn)(e)},Br.size=function(e){if(null==e)return 0;if(Jo(e))return ua(e)?dr(e):e.length;var t=gs(e);return t==w||t==R?e.size:jn(e).length},Br.snakeCase=Ka,Br.some=function(t,r,n){var i=Yo(t)?Mt:oi;return n&&Es(t,r,n)&&(r=e),i(t,us(r,3))},Br.sortedIndex=function(e,t){return ai(e,t)},Br.sortedIndexBy=function(e,t,r){return ci(e,t,us(r,2))},Br.sortedIndexOf=function(e,t){var r=null==e?0:e.length;if(r){var n=ai(e,t);if(n<r&&Ho(e[n],t))return n}return-1},Br.sortedLastIndex=function(e,t){return ai(e,t,!0)},Br.sortedLastIndexBy=function(e,t,r){return ci(e,t,us(r,2),!0)},Br.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var r=ai(e,t,!0)-1;if(Ho(e[r],t))return r}return-1},Br.startCase=Qa,Br.startsWith=function(e,t,r){return e=Ea(e),r=null==r?0:dn(va(r),0,e.length),t=li(t),e.slice(r,r+t.length)==t},Br.subtract=Rc,Br.sum=function(e){return e&&e.length?zt(e,oc):0},Br.sumBy=function(e,t){return e&&e.length?zt(e,us(t,2)):0},Br.template=function(t,r,n){var i=Br.templateSettings;n&&Es(t,r,n)&&(r=e),t=Ea(t),r=Ca({},r,i,es);var s,o,a=Ca({},r.imports,i.imports,es),c=Ma(a),d=Jt(a,c),u=0,l=r.interpolate||_e,p="__p += '",h=ke((r.escape||_e).source+"|"+l.source+"|"+(l===Q?le:_e).source+"|"+(r.evaluate||_e).source+"|$","g"),f="//# sourceURL="+(xe.call(r,"sourceURL")?(r.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rt+"]")+"\n";t.replace(h,(function(e,r,n,i,a,c){return n||(n=i),p+=t.slice(u,c).replace(be,rr),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+e.length,e})),p+="';\n";var m=xe.call(r,"variable")&&r.variable;if(m){if(de.test(m))throw new Ce("Invalid `variable` option passed into `_.template`")}else p="with (obj) {\n"+p+"\n}\n";p=(o?p.replace(W,""):p).replace(H,"$1").replace(q,"$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 Pe(c,f+"return "+p).apply(e,d)}));if(g.source=p,Xo(g))throw g;return g},Br.times=function(e,t){if((e=va(e))<1||e>u)return[];var r=h,n=br(e,h);t=us(t),e-=h;for(var i=Gt(n,t);++r<e;)t(r);return i},Br.toFinite=ga,Br.toInteger=va,Br.toLength=ya,Br.toLower=function(e){return Ea(e).toLowerCase()},Br.toNumber=_a,Br.toSafeInteger=function(e){return e?dn(va(e),-9007199254740991,u):0===e?e:0},Br.toString=Ea,Br.toUpper=function(e){return Ea(e).toUpperCase()},Br.trim=function(t,r,n){if((t=Ea(t))&&(n||r===e))return Yt(t);if(!t||!(r=li(r)))return t;var i=ur(t),s=ur(r);return Si(i,Qt(i,s),Zt(i,s)+1).join("")},Br.trimEnd=function(t,r,n){if((t=Ea(t))&&(n||r===e))return t.slice(0,lr(t)+1);if(!t||!(r=li(r)))return t;var i=ur(t);return Si(i,0,Zt(i,ur(r))+1).join("")},Br.trimStart=function(t,r,n){if((t=Ea(t))&&(n||r===e))return t.replace(ne,"");if(!t||!(r=li(r)))return t;var i=ur(t);return Si(i,Qt(i,ur(r))).join("")},Br.truncate=function(t,r){var n=30,i="...";if(na(r)){var s="separator"in r?r.separator:s;n="length"in r?va(r.length):n,i="omission"in r?li(r.omission):i}var o=(t=Ea(t)).length;if(nr(t)){var a=ur(t);o=a.length}if(n>=o)return t;var c=n-dr(i);if(c<1)return i;var d=a?Si(a,0,c).join(""):t.slice(0,c);if(s===e)return d+i;if(a&&(c+=d.length-c),ca(s)){if(t.slice(c).search(s)){var u,l=d;for(s.global||(s=ke(s.source,Ea(pe.exec(s))+"g")),s.lastIndex=0;u=s.exec(l);)var p=u.index;d=d.slice(0,p===e?c:p)}}else if(t.indexOf(li(s),c)!=c){var h=d.lastIndexOf(s);h>-1&&(d=d.slice(0,h))}return d+i},Br.unescape=function(e){return(e=Ea(e))&&Y.test(e)?e.replace(z,pr):e},Br.uniqueId=function(e){var t=++Fe;return Ea(e)+t},Br.upperCase=Za,Br.upperFirst=Xa,Br.each=Eo,Br.eachRight=wo,Br.first=$s,uc(Br,(bc={},wn(Br,(function(e,t){xe.call(Br.prototype,t)||(bc[t]=e)})),bc),{chain:!1}),Br.VERSION="4.17.21",Ct(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Br[e].placeholder=Br})),Ct(["drop","take"],(function(t,r){zr.prototype[t]=function(n){n=n===e?1:_r(va(n),0);var i=this.__filtered__&&!r?new zr(this):this.clone();return i.__filtered__?i.__takeCount__=br(n,i.__takeCount__):i.__views__.push({size:br(n,h),type:t+(i.__dir__<0?"Right":"")}),i},zr.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),Ct(["filter","map","takeWhile"],(function(e,t){var r=t+1,n=1==r||3==r;zr.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:us(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}})),Ct(["head","last"],(function(e,t){var r="take"+(t?"Right":"");zr.prototype[e]=function(){return this[r](1).value()[0]}})),Ct(["initial","tail"],(function(e,t){var r="drop"+(t?"":"Right");zr.prototype[e]=function(){return this.__filtered__?new zr(this):this[r](1)}})),zr.prototype.compact=function(){return this.filter(oc)},zr.prototype.find=function(e){return this.filter(e).head()},zr.prototype.findLast=function(e){return this.reverse().find(e)},zr.prototype.invokeMap=Zn((function(e,t){return"function"==typeof e?new zr(this):this.map((function(r){return On(r,e,t)}))})),zr.prototype.reject=function(e){return this.filter(jo(us(e)))},zr.prototype.slice=function(t,r){t=va(t);var n=this;return n.__filtered__&&(t>0||r<0)?new zr(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),r!==e&&(n=(r=va(r))<0?n.dropRight(-r):n.take(r-t)),n)},zr.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},zr.prototype.toArray=function(){return this.take(h)},wn(zr.prototype,(function(t,r){var n=/^(?:filter|find|map|reject)|While$/.test(r),i=/^(?:head|last)$/.test(r),s=Br[i?"take"+("last"==r?"Right":""):r],o=i||/^find/.test(r);s&&(Br.prototype[r]=function(){var r=this.__wrapped__,a=i?[1]:arguments,c=r instanceof zr,d=a[0],u=c||Yo(r),l=function(e){var t=s.apply(Br,At([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){r=m?r:new zr(this);var g=t.apply(r,a);return g.__actions__.push({func:go,args:[l],thisArg:e}),new qr(g,p)}return f&&m?t.apply(this,a):(g=this.thru(l),f?i?g.value()[0]:g.value():g)})})),Ct(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ae[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);Br.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(Yo(i)?i:[],e)}return this[r]((function(r){return t.apply(Yo(r)?r:[],e)}))}})),wn(zr.prototype,(function(e,t){var r=Br[t];if(r){var n=r.name+"";xe.call(Or,n)||(Or[n]=[]),Or[n].push({name:t,func:r})}})),Or[Wi(e,2).name]=[{name:"wrapper",func:e}],zr.prototype.clone=function(){var e=new zr(this.__wrapped__);return e.__actions__=Ai(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ai(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ai(this.__views__),e},zr.prototype.reverse=function(){if(this.__filtered__){var e=new zr(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},zr.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=Yo(e),n=t<0,i=r?e.length:0,s=function(e,t,r){for(var n=-1,i=r.length;++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=br(t,e+o);break;case"takeRight":e=_r(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=br(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,_=v.type,b=y(g);if(2==_)g=b;else if(!b){if(1==_)continue e;break e}}f[p++]=g}return f},Br.prototype.at=vo,Br.prototype.chain=function(){return mo(this)},Br.prototype.commit=function(){return new qr(this.value(),this.__chain__)},Br.prototype.next=function(){this.__values__===e&&(this.__values__=ma(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?e:this.__values__[this.__index__++]}},Br.prototype.plant=function(t){for(var r,n=this;n instanceof Hr;){var i=Bs(n);i.__index__=0,i.__values__=e,r?s.__wrapped__=i:r=i;var s=i;n=n.__wrapped__}return s.__wrapped__=t,r},Br.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof zr){var r=t;return this.__actions__.length&&(r=new zr(this)),(r=r.reverse()).__actions__.push({func:go,args:[ro],thisArg:e}),new qr(r,this.__chain__)}return this.thru(ro)},Br.prototype.toJSON=Br.prototype.valueOf=Br.prototype.value=function(){return gi(this.__wrapped__,this.__actions__)},Br.prototype.first=Br.prototype.head,ct&&(Br.prototype[ct]=function(){return this}),Br}();pt?((pt.exports=hr)._=hr,lt._=hr):ut._=hr}.call(l);var kb,Db=l&&l.__extends||(kb=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}kb(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(Tb,"__esModule",{value:!0});var Ib,Ab,Ob,Nb,Mb,Lb,xb,Fb,jb=Rb.exports,Ub=["MaxBatchSize","MaxDelay","MinDelay"],Vb=function(e){function t(t){var r=e.call(this)||this;return r.fifo=[],r.firstBatch=!0,function(e){if(Ub.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=jb.debounce(r.releaseBatch.bind(r),r.options.MaxDelay,{maxWait:r.options.MaxDelay}),r.releaseBatchDebouncedMin=jb.debounce(r.releaseBatch.bind(r),r.options.MinDelay,{maxWait:r.options.MinDelay}),r}return Db(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);Tb.MessageBatcher=Vb,function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(Tb)}(Pb),function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(Pb)}(Cb);class Bb{constructor(e){Ib.add(this),Ab.set(this,void 0),Ob.set(this,void 0),Nb.set(this,void 0),Mb.set(this,void 0),Lb.set(this,void 0);const{logLevel:t,namespace:r,onLogMessage:n}=e;d(this,Ab,r,"f"),d(this,Ob,t,"f"),this.onLogMessage=n,d(this,Mb,new ub,"f"),d(this,Nb,new Cb.MessageBatcher({MaxBatchSize:50,MaxDelay:1e3,MinDelay:500}),"f"),d(this,Lb,e.sendAnalytics,"f"),c(this,Nb,"f").on("batch",(e=>{this.logToApi(e).catch((e=>{this.error("Failed to log to api",{case:"Logger",error:Ct(e)})}))})),this._debug=Sb("LiveDigital").extend("debug").extend(c(this,Ab,"f")),this._info=Sb("LiveDigital").extend("info").extend(c(this,Ab,"f")),this._warn=Sb("LiveDigital").extend("warn").extend(c(this,Ab,"f")),this._error=Sb("LiveDigital").extend("error").extend(c(this,Ab,"f")),this._debug.log=console.info.bind(console),this._info.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}debug(e,t){this._debug(e,t),c(this,Lb,"f")&&c(this,Nb,"f").Queue({level:"debug",message:e,meta:t}),c(this,Ob,"f")>=ht&&c(this,Ib,"m",xb).call(this,"debug",e,t)}info(e,t){this._info(e,t),c(this,Lb,"f")&&c(this,Nb,"f").Queue({level:"info",message:e,meta:t}),c(this,Ob,"f")>=pt&&c(this,Ib,"m",xb).call(this,"info",e,t)}warn(e,t){this._warn(e,t),c(this,Lb,"f")&&c(this,Nb,"f").Queue({level:"warn",message:e,meta:t}),c(this,Ob,"f")>=lt&&c(this,Ib,"m",xb).call(this,"warn",e,t)}error(e,t){this._error(e,t),c(this,Lb,"f")&&c(this,Nb,"f").Queue({level:"error",message:e,meta:t}),c(this,Ob,"f")>=ut&&c(this,Ib,"m",xb).call(this,"error",e,t)}logToApi(e){return a(this,void 0,void 0,(function*(){try{yield c(this,Mb,"f").log.batch({logs:e.map((e=>c(this,Ib,"m",Fb).call(this,Object.assign(Object.assign({},e),{meta:this.prepareRecordMeta(e.meta)})))),clientMeta:this.getClientMeta()})}catch(e){this._debug("Log request was not successful",{error:e})}}))}getClientMeta(){return Object.assign(Object.assign({},fr.meta),{clUId:ob()})}prepareRecordMeta(e){const t=null!=e?e:{},{error:r}=t;return Object.assign(Object.assign(Object.assign({},t),{clientTimestamp:(new Date).toISOString(),from_sdk:!0}),r&&"object"==typeof r?{error:Ct(r)}:{})}}Ab=new WeakMap,Ob=new WeakMap,Nb=new WeakMap,Mb=new WeakMap,Lb=new WeakMap,Ib=new WeakSet,xb=function(e,t,...r){"function"==typeof this.onLogMessage&&this.onLogMessage(t,...c(this,Ib,"m",Fb).call(this,r),e)},Fb=function(e){const t=new WeakMap;return function e(r,n=[]){if(!En(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 Wb=class{constructor(e){this.peerTrackFactory=e,this.tracksByConsumerId=new Map}register(e,t){this.tracksByConsumerId.set(e,t)}get(e){return this.tracksByConsumerId.get(e)}delete(e){return this.tracksByConsumerId.delete(e)}reset(){this.tracksByConsumerId.clear()}create(e){const{consumer:t,label:r,muted:n=!1,mediaStreamTrack:i,paused:s,peerEventEmitter:o}=e,a=this.peerTrackFactory({consumer:t,label:r,mediaStreamTrack:i,paused:s,peerEventEmitter:o,muted:n,onClose:()=>{void 0!==a.consumerId&&this.delete(a.consumerId)}});return void 0!==a.consumerId&&this.register(a.consumerId,a),a}};var Hb,qb,zb;Wb=i([at(),s(0,dt(On.PeerTrackFactory)),o("design:paramtypes",[Function])],Wb);const Gb=["frozen-video-track","network-media-sync-failure","encoder-cpu-throttling","decoder-cpu-throttling","missing-video-stream-data","missing-audio-stream-data"];let Yb=class{constructor(e,t,r,n,i){this.analyticsApiClient=e,this.peers=t,this.myPeer=r,this.transportsStatsProvider=i,Hb.set(this,void 0),qb.set(this,void 0),zb.set(this,void 0),d(this,zb,n("IntegrationsService"),"f"),d(this,qb,new Cb.MessageBatcher({MaxBatchSize:50,MaxDelay:6e4,MinDelay:3e4}),"f"),c(this,qb,"f").on("batch",(e=>{this.analyticsApiClient.metrics.sendWIDMetrics({reasons:e,clientMeta:this.getClientMeta()}).catch((e=>{c(this,zb,"f").debug("Failed to sendWIDMetrics",{error:Ct(e)})}))})),d(this,Hb,new Cb.MessageBatcher({MaxBatchSize:100,MaxDelay:6e4,MinDelay:3e4}),"f"),c(this,Hb,"f").on("batch",(e=>{this.analyticsApiClient.metrics.sendNetworkMetrics({metrics:e,clientMeta:this.getClientMeta()}).catch((e=>{c(this,zb,"f").debug("Failed to sendNetworkMetrics",{error:Ct(e)})}))}))}handleIssues(e){e.forEach((e=>c(this,zb,"f").info("WebRTCIssue",e)));const t=e.filter((e=>Gb.includes(e.reason)));0!==t.length&&t.forEach((e=>c(this,qb,"f").Queue(e.reason)))}handleNetworkScores(e){var t,r,n,i,s,o;const{inbound:a,outbound:d,statsSamples:{inboundStatsSample:u,outboundStatsSample:l}}=e,p=this.getNodeActiveStreamsStat(),h=this.transportsStatsProvider.getStats();if(void 0!==a&&u){const e={jitter:Math.round(u.avgJitter),packetLoss:u.packetsLoss,rtt:u.rtt,mos:Math.round(10*a)/10,streams:p.inboundActiveStreams,direction:"inbound",node:null!==(t=fr.meta.datacenterName)&&void 0!==t?t:"unknown node",bitrate:null!==(n=null===(r=null==h?void 0:h.inbound)||void 0===r?void 0:r.bitrate)&&void 0!==n?n:0,timestamp:(new Date).toISOString()};c(this,Hb,"f").Queue(e)}if(void 0!==d&&l){const e={jitter:Math.round(l.avgJitter),packetLoss:l.packetsLoss,rtt:l.rtt,mos:Math.round(10*d)/10,streams:p.outboundActiveStreams,direction:"outbound",node:null!==(i=fr.meta.datacenterName)&&void 0!==i?i:"unknown node",bitrate:null!==(o=null===(s=null==h?void 0:h.outbound)||void 0===s?void 0:s.bitrate)&&void 0!==o?o:0,timestamp:(new Date).toISOString()};c(this,Hb,"f").Queue(e)}}getNodeActiveStreamsStat(){var e;const 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{inboundActiveStreams:t,outboundActiveStreams:null!==(e=null==r?void 0:r.getActivePublishersCount())&&void 0!==e?e:0}}getClientMeta(){return Object.assign(Object.assign({},fr.meta),{clientUniqueId:ob()})}};Hb=new WeakMap,qb=new WeakMap,zb=new WeakMap,Yb=i([at(),s(0,dt(On.AnalyticsApiClient)),s(1,dt(On.Peers)),s(2,dt(On.MyPeer)),s(3,dt(On.LoggerFactory)),s(4,dt(On.TransportsStatsProvider)),o("design:paramtypes",[ub,Object,ws,Function,Ov])],Yb);var $b,Jb,Kb,Qb,Zb,Xb,eE,tE,rE,nE=Yb;!function(e){e.INFO="info",e.WARNING="warning",e.ERROR="error"}(eE||(eE={})),function(e){e[e.PERFORMANCE_STOP=1001]="PERFORMANCE_STOP",e[e.REDUCE_LATENCY=1002]="REDUCE_LATENCY"}(tE||(tE={})),function(e){e.ATSVB="atsvb",e.STREAM_PROCESSOR="stream_processor",e.ML_INFERENCE="ml_inference",e.MODEL="model",e.WORKLET="worklet",e.WORKER="worker",e.MODEL_LOADER="model_loader"}(rE||(rE={}));const iE=()=>{};class sE{constructor(e){$b.set(this,void 0),Jb.set(this,void 0),Kb.set(this,null),Qb.set(this,new Map),Zb.set(this,void 0),this.type="asdk",Xb.set(this,void 0);const{loggerFactory:t}=e;d(this,Jb,t("ASDKTrackProcessor"),"f"),d(this,Xb,"function"==typeof e.onError?e.onError:iE,"f"),d(this,$b,new window.atsvb(e.asdkCustomerId),"f");const n=e.config.get("staticFilesPath"),{localDir:i,version:s,sdk_url:o,api_url:a}=e.config.get("asdk");let u=`https://effectssdk.ai/sdk/audio/dev/${null!=s?s:"2.4.3"}`;if(i){u=new r(`${i}/${null!=s?s:"2.4.3"}`,n).href}const l={preset:"balanced",sample_rate:48e3,api_url:a,wasmPaths:{"ort-wasm.wasm":`${u}/ort-wasm.wasm`,"ort-wasm-simd.wasm":`${u}/ort-wasm-simd.wasm`}},p=!o&&i,h=p?`${u}/`:o;p&&c(this,Jb,"f").warn("Using static ASDK path due to missing config",Object.assign(Object.assign({case:"Denoiser",type:"asdk"},e.config.get("asdk")),{sdkUrl:l.sdk_url})),h&&(l.sdk_url=h),c(this,$b,"f").config(l),c(this,$b,"f").onError(this.onError.bind(this))}setOnError(e){d(this,Xb,e,"f")}init(){return a(this,void 0,void 0,(function*(){yield c(this,$b,"f").preload()}))}release(){c(this,$b,"f").stop(),c(this,$b,"f").clear()}get isProcessing(){return!!c(this,Zb,"f")}processTrack(e){return a(this,void 0,void 0,(function*(){var t;if(c(this,Kb,"f")===e||"ended"===e.readyState)return(null===(t=c(this,$b,"f").getStream())||void 0===t?void 0:t.getAudioTracks()[0])||e;this.stopProcessing();try{const t=new Promise(((t,r)=>{c(this,$b,"f").onReady=()=>{try{const r=c(this,$b,"f").getStream(),n=null==r?void 0:r.getAudioTracks()[0];if(!n)return void t(e);d(this,Kb,e,"f"),d(this,Zb,n,"f"),t(n),c(this,$b,"f").run()}catch(e){r(e)}finally{c(this,$b,"f").onReady=void 0}}}));c(this,$b,"f").useStream(new MediaStream([e]));const r=yield t;return c(this,Jb,"f").info("processTrack()",{case:"Denoiser",type:this.type,track:e.id}),r}catch(t){throw c(this,Jb,"f").error("processTrack()",{error:Ct(t),type:this.type,case:"Denoiser",track:e}),c(this,Xb,"f").call(this,"ASDK processTrack() error",t),d(this,Xb,iE,"f"),new Error("Can not process this track")}}))}stopProcessing(){try{c(this,$b,"f").stop()}catch(e){c(this,Jb,"f").error("stopProcessing()",{type:this.type,case:"Denoiser",error:Ct(e)})}finally{d(this,Kb,null,"f")}}getUpdatedDebounceCounter(e){var t;let r=null!==(t=c(this,Qb,"f").get(e))&&void 0!==t?t:0;return r+=1,c(this,Qb,"f").set(e,r),setTimeout((()=>{var t;const r=null!==(t=c(this,Qb,"f").get(e))&&void 0!==t?t:0;r<=0?c(this,Qb,"f").set(e,0):c(this,Qb,"f").set(e,r-1)}),1e4),r}onError(e){const{message:t,type:r,cause:i}=e,s=n(e,["message","type","cause"]);if(r===eE.ERROR)if(c(this,Jb,"f").error(t,Object.assign(Object.assign({error:Ct(i),cause:i},s),{type:this.type,case:"Denoiser"})),s.code===tE.REDUCE_LATENCY||s.code===tE.PERFORMANCE_STOP){this.getUpdatedDebounceCounter(s.code)>3&&(c(this,Qb,"f").set(s.code,0),c(this,Xb,"f").call(this,`ASDK performance issue(${s.code}): ${t}`,i),d(this,Xb,iE,"f"))}else c(this,Xb,"f").call(this,`ASDK runtime error: ${t}`,i),d(this,Xb,iE,"f");r===eE.WARNING&&c(this,Jb,"f").warn(t,Object.assign(Object.assign({},s),{type:this.type,case:"Denoiser"})),r===eE.INFO&&c(this,Jb,"f").info(t,Object.assign(Object.assign({},s),{type:this.type,case:"Denoiser"}))}}$b=new WeakMap,Jb=new WeakMap,Kb=new WeakMap,Qb=new WeakMap,Zb=new WeakMap,Xb=new WeakMap;class oE extends AudioWorkletNode{constructor(e){super(e.context,"rnnoise",{channelCountMode:"explicit",channelCount:1,channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{module:e.noiseSuppressor.module}}),this.port.onmessage=({data:e})=>{const t=Object.assign(new Event("status"),e);this.dispatchEvent(t)}}update(e){this.port.postMessage(e)}static register(e){return a(this,void 0,void 0,(function*(){const t=aw.get(On.Config);yield e.audioWorklet.addModule(`${t.get("staticFilesPath")}/noiseSuppressionWorklet.js`)}))}}var aE,cE,dE,uE,lE,pE;class hE{constructor(e){aE.set(this,void 0),cE.set(this,void 0),dE.set(this,void 0),uE.set(this,void 0),lE.set(this,void 0),pE.set(this,!0),d(this,aE,e.noiseSuppressor.instance.exports,"f"),d(this,cE,e.context,"f"),d(this,dE,new Float32Array(c(this,aE,"f").memory.buffer),"f"),d(this,uE,c(this,aE,"f").newState(),"f"),d(this,lE,c(this,cE,"f").createScriptProcessor(),"f"),this.setOnAudioProcess()}get noiseSuppressionScriptProcessorNode(){return c(this,lE,"f")}update(e){e||(d(this,pE,!1,"f"),c(this,aE,"f").deleteState(c(this,uE,"f")));const t=Object.assign(new Event("status"),{vadProb:c(this,aE,"f").getVadProb(c(this,uE,"f"))});c(this,lE,"f").dispatchEvent(t)}setOnAudioProcess(){c(this,lE,"f").addEventListener("audioprocess",(({inputBuffer:e,outputBuffer:t})=>{if(!c(this,pE,"f"))return;c(this,dE,"f").set(e.getChannelData(0),c(this,aE,"f").getInput(c(this,uE,"f"))/4);const r=t.getChannelData(0),n=c(this,aE,"f").pipe(c(this,uE,"f"),r.length)/4;n&&r.set(c(this,dE,"f").subarray(n,n+r.length))}))}}var fE,mE,gE,vE,yE,_E,bE,EE,wE,SE,CE,PE,TE,RE,kE,DE,IE,AE,OE,NE,ME,LE,xE,FE,jE,UE,VE,BE,WE,HE,qE,zE,GE,YE,$E,JE,KE,QE,ZE;aE=new WeakMap,cE=new WeakMap,dE=new WeakMap,uE=new WeakMap,lE=new WeakMap,pE=new WeakMap;class XE{constructor({context:e,noiseSuppressor:t}){fE.set(this,void 0),mE.set(this,void 0),gE.set(this,void 0),d(this,fE,e,"f"),d(this,mE,t,"f")}createNoiseSuppressionNode(){return a(this,void 0,void 0,(function*(){return/apple/i.test(navigator.vendor)?this.createScriptProcessorNode():yield this.createAudioWorkletNode()}))}stop(){var e;null===(e=c(this,gE,"f"))||void 0===e||e.update(!1)}createAudioWorkletNode(){return a(this,void 0,void 0,(function*(){return yield oE.register(c(this,fE,"f")),d(this,gE,new oE({context:c(this,fE,"f"),noiseSuppressor:c(this,mE,"f")}),"f"),c(this,gE,"f")}))}createScriptProcessorNode(){return d(this,gE,new hE({context:c(this,fE,"f"),noiseSuppressor:c(this,mE,"f")}),"f"),c(this,gE,"f").noiseSuppressionScriptProcessorNode}}fE=new WeakMap,mE=new WeakMap,gE=new WeakMap;class ew{constructor(e){vE.set(this,void 0),yE.set(this,void 0),_E.set(this,void 0),bE.set(this,void 0),this.type="rnnoise",d(this,vE,e.noiseSuppressor,"f"),d(this,_E,e.loggerFactory("TrackProcessor"),"f")}get isProcessing(){return!!c(this,bE,"f")}release(){this.stopProcessing()}processTrack(e){return a(this,void 0,void 0,(function*(){const t=(e=>{const t=window.AudioContext||window.webkitAudioContext||!1;return t?new t(e):null})();if(!t)throw new Error("AudioContext is not available");const r=new MediaStreamAudioDestinationNode(t,{channelCountMode:"explicit",channelCount:1,channelInterpretation:"speakers"});yield oE.register(t);const n=t.createMediaStreamSource(new MediaStream([e])),i=new XE({context:t,noiseSuppressor:c(this,vE,"f")}),s=yield i.createNoiseSuppressionNode();s.connect(r),n.connect(s);const[o]=r.stream.getTracks();return d(this,yE,{audioContext:t,streamDestination:r,noiseSuppressionNode:s,noiseSuppressionProvider:i},"f"),d(this,bE,o,"f"),c(this,_E,"f").info("processTrack()",{case:"Denoiser",type:this.type,track:e.id}),o}))}stopProcessing(){var e;if(this.isProcessing)if(c(this,yE,"f"))try{c(this,yE,"f").noiseSuppressionProvider.stop(),c(this,yE,"f").noiseSuppressionNode.disconnect(),c(this,yE,"f").streamDestination.disconnect(),c(this,yE,"f").audioContext.close().catch((e=>{c(this,_E,"f").error("stopProcessing()",{success:!1,error:Ct(e),case:"Denoiser",type:this.type})})),null===(e=c(this,bE,"f"))||void 0===e||e.stop(),d(this,bE,void 0,"f"),c(this,_E,"f").info("stopProcessing()",{success:!0,case:"Denoiser",type:this.type})}catch(e){c(this,_E,"f").error("stopProcessing()",{success:!1,error:Ct(e),case:"Denoiser",type:this.type})}else c(this,_E,"f").warn("stopProcessing()",{success:!1,description:"Processing context is not available",case:"Denoiser",type:this.type});else c(this,_E,"f").debug("stopProcessing()",{description:"Track is not processed",case:"Denoiser",type:this.type})}}vE=new WeakMap,yE=new WeakMap,_E=new WeakMap,bE=new WeakMap;class tw extends Qm{constructor(e){super(e),EE.set(this,!1),wE.set(this,void 0),SE.set(this,void 0),CE.set(this,void 0),d(this,CE,e.clientEventEmitter,"f")}get isDenoiserRequireActivation(){var e;return!(null===(e=c(this,wE,"f"))||void 0===e?void 0:e.isProcessing)&&c(this,EE,"f")}setTrackProcessor(e){if(!e)throw new Pt("track_processor_missing",new Error("trackProcessor must be passed as parameter"));this.logger.debug("Setting trackProcessor to AudioTrack",{case:"Denoiser",type:e.type}),d(this,wE,e,"f")}unsetTrackProcessor(){d(this,wE,void 0,"f")}get isEffectsProcessing(){var e;return Boolean(null===(e=c(this,wE,"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:Pc}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(){return a(this,void 0,void 0,(function*(){var e,t,r;if(d(this,EE,!0,"f"),!c(this,wE,"f"))return this.logger.warn("enableNoiseSuppression()",{description:"Track suppressor is not defined"}),void c(this,CE,"f").emit(xr,{cause:"Track suppressor is not defined"});try{const n=yield null===(e=c(this,wE,"f"))||void 0===e?void 0:e.processTrack(this.mediaStreamTrack);d(this,SE,this.mediaStreamTrack,"f"),yield this.replaceTrack(n),this.logger.debug("Denoiser activated",{case:"Denoiser",type:(null===(t=c(this,wE,"f"))||void 0===t?void 0:t.type)||"none"}),c(this,CE,"f").emit(Nr,{type:null===(r=c(this,wE,"f"))||void 0===r?void 0:r.type})}catch(e){throw this.logger.warn("enableNoiseSuppression()",{description:"Can not enable noise suppression",track:this.logCtx,error:Ct(e)}),c(this,CE,"f").emit(xr,{cause:"Failed to enable noise suppression",error:e}),new Pt("noise_suppression_enable_failed",e)}}))}disableNoiseSuppression(){return a(this,void 0,void 0,(function*(){var e,t,r,n;d(this,EE,!1,"f");try{if(!(null===(e=c(this,wE,"f"))||void 0===e?void 0:e.isProcessing))return void this.logger.debug("stopProcessing()",{description:"Track is not processed"});if(!c(this,SE,"f"))return void this.logger.warn("disableNoiseSuppression()",{description:"Original track missing"});yield this.replaceTrack(c(this,SE,"f")),null===(t=c(this,wE,"f"))||void 0===t||t.stopProcessing(),this.logger.debug("Denoiser deactivated",{case:"Denoiser",type:(null===(r=c(this,wE,"f"))||void 0===r?void 0:r.type)||"none"}),c(this,CE,"f").emit(Mr,{type:null===(n=c(this,wE,"f"))||void 0===n?void 0:n.type})}catch(e){throw this.logger.warn("disableNoiseSuppression()",{description:"Can not disable noise suppression",track:this.logCtx,error:Ct(e)}),c(this,CE,"f").emit(xr,{cause:"Failed to disable noise suppression",error:e}),new Pt("noise_suppression_disable_failed",e)}}))}publish(){return a(this,void 0,void 0,(function*(){yield this.produce({encodings:this.getEncodings(),preferredCodec:this.getPreferredCodec(),codecOptions:this.getCodecOptions()}),this.internalEventEmitter.emit(jr,this)}))}pause(){return a(this,void 0,void 0,(function*(){yield this.mute()}))}}EE=new WeakMap,wE=new WeakMap,SE=new WeakMap,CE=new WeakMap;class rw{constructor({track:e,statsHandler:t}){PE.set(this,void 0),TE.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return c(this,PE,"f")}get audioWebRTCStats(){return c(this,TE,"f")}handleWebRTCStats(e,t){e.addEventListener("ended",(()=>{t.removeInboundVideoHandler(e.id),t.removeInboundAudioHandler(e.id)}),{once:!0}),"video"!==e.kind?t.addInboundAudioHandler(e.id,this.setAudioWebRTCStats.bind(this)):t.addInboundVideoHandler(e.id,this.setVideoWebRTCStats.bind(this))}setVideoWebRTCStats(e){d(this,PE,e,"f")}setAudioWebRTCStats(e){d(this,TE,e,"f")}}PE=new WeakMap,TE=new WeakMap;class nw{constructor(e){this.label=Nn.Unknown,RE.set(this,void 0),kE.set(this,void 0),DE.set(this,void 0),IE.set(this,void 0),AE.set(this,void 0),OE.set(this,void 0),NE.set(this,void 0),ME.set(this,void 0),LE.set(this,void 0),xE.set(this,!1),FE.set(this,void 0),jE.set(this,!1),UE.set(this,new Fg),VE.set(this,!1),BE.set(this,0),WE.set(this,void 0),this.observer=new Et,d(this,ME,e.mediaStreamTrack,"f"),this.label=e.label,this.consumer=e.consumer,d(this,IE,e.peerConsumerFactory,"f"),d(this,OE,e.loggerFactory("PeerTrack"),"f"),d(this,NE,e.peerEventEmitter,"f"),d(this,VE,e.muted,"f"),d(this,LE,e.paused,"f"),d(this,RE,e.network,"f"),d(this,kE,e.media,"f"),d(this,AE,e.callState,"f"),d(this,DE,e.onClose,"f"),d(this,WE,new rw({track:e.mediaStreamTrack,statsHandler:e.statsHandler}),"f")}get videoWebRTCStats(){return c(this,WE,"f").videoWebRTCStats}get audioWebRTCStats(){return c(this,WE,"f").audioWebRTCStats}get logCtx(){var e,t;return{id:c(this,ME,"f").id,label:this.label,consumerId:null===(e=this.consumer)||void 0===e?void 0:e.id,producerId:null===(t=this.consumer)||void 0===t?void 0:t.producerId,muted:c(this,VE,"f"),paused:c(this,LE,"f"),closed:c(this,jE,"f")}}get volume(){return c(this,BE,"f")}get isRemote(){return!!this.consumer}get mediaStreamTrack(){return c(this,ME,"f")}get kind(){return this.mediaStreamTrack.kind}get isPaused(){return c(this,LE,"f")}get isMuted(){return c(this,VE,"f")}get consumerId(){var e;return null===(e=this.consumer)||void 0===e?void 0:e.id}get currentSpatialLayer(){var e,t;return null!==(t=null===(e=this.consumer)||void 0===e?void 0:e.currentSpatialLayer)&&void 0!==t?t:um}close(){return a(this,void 0,void 0,(function*(){c(this,NE,"f").safeEmit(Kr,this),d(this,jE,!0,"f"),c(this,DE,"f").call(this),this.consumer&&(yield this.closeConsumer(),this.clearCheckStateTimeout())}))}mute(){return a(this,void 0,void 0,(function*(){yield c(this,UE,"f").push((()=>a(this,void 0,void 0,(function*(){c(this,OE,"f").debug("mute()",{track:this.logCtx}),yield this.pauseConsumer(),d(this,VE,!0,"f")}))))}))}unmute(){return a(this,void 0,void 0,(function*(){yield c(this,UE,"f").push((()=>a(this,void 0,void 0,(function*(){c(this,OE,"f").debug("unmute()",{track:this.logCtx}),yield this.resumeConsumer(),d(this,VE,!1,"f")}))))}))}pause(){return a(this,arguments,void 0,(function*(e=!0){yield c(this,UE,"f").push((()=>a(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return d(this,LE,!0,"f"),c(this,NE,"f").safeEmit(Qr,this),void c(this,OE,"f").debug("pause()",{track:this.logCtx});yield this.pauseConsumer(e),d(this,LE,!0,"f"),c(this,NE,"f").safeEmit(Qr,this)}))))}))}resume(){return a(this,arguments,void 0,(function*(e=!0){yield c(this,UE,"f").push((()=>a(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return d(this,LE,!1,"f"),c(this,NE,"f").safeEmit(Zr,this),void c(this,OE,"f").debug("resume()",{track:this.logCtx});yield this.resumeConsumer(e),d(this,LE,!1,"f"),c(this,NE,"f").safeEmit(Zr,this)}))))}))}resumeConsumer(){return a(this,arguments,void 0,(function*(e=!0){if(this.consumer)try{this.consumer.resume(),e&&(yield c(this,RE,"f").resumeRemoteConsumer(this.consumer.id)),this.checkConsumerState().catch((e=>{c(this,OE,"f").warn("Failed to checkConsumerState()",{track:this.logCtx,error:Ct(e)})})),c(this,OE,"f").debug("resumeConsumer()",{track:this.logCtx})}catch(e){c(this,OE,"f").warn("resumeConsumer()",{error:e})}}))}pauseConsumer(){return a(this,arguments,void 0,(function*(e=!0){if(this.consumer)try{if(this.clearCheckStateTimeout(),e&&(yield c(this,RE,"f").pauseRemoteConsumer(this.consumer.id)),"audio"===this.kind)return void c(this,OE,"f").debug("pauseConsumer() - skipping for audio",{track:this.logCtx});this.consumer.pause(),d(this,xE,!1,"f"),c(this,OE,"f").debug("pauseConsumer()",{track:this.logCtx})}catch(e){c(this,OE,"f").warn("pauseConsumer()",{error:e,track:this.logCtx})}}))}requestVideoPreferredLayers(e){return a(this,arguments,void 0,(function*({spatialLayer:e,temporalLayer:t}){if(this.consumer)try{if(this.consumer.isAudio)return void c(this,OE,"f").warn("Only video consumers support layers",{case:"requestVideoPreferredLayers"});if(e===this.consumer.currentSpatialLayer)return;if(e>this.consumer.spatialLayers)return void c(this,OE,"f").warn("Invalid spatial layer",{spatialLayer:e,consumerSpatialLayers:this.consumer.spatialLayers,case:"requestVideoPreferredLayers"});if(e>this.consumer.currentMaxSpatialLayer)return void(yield this.requestMaxSpatialLayer(this.consumer.id,e));yield c(this,RE,"f").updateConsumerPreferredLayers(this.consumer.id,e,t),c(this,OE,"f").debug("requestVideoPreferredLayers()",{track:this.logCtx,consumer:this.consumer,spatialLayer:e,temporalLayer:t})}catch(e){throw c(this,OE,"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 Pt("peer_track_request_preferred_layers_failed",e)}}))}requestKeyFrame(){return a(this,void 0,void 0,(function*(){if(this.consumerId){c(this,OE,"f").debug("requestKeyFrame()",{track:this.logCtx});try{yield c(this,RE,"f").requestConsumerKeyFrame(this.consumerId)}catch(e){throw c(this,OE,"f").error("requestKeyFrame()",{error:e,track:this.logCtx,consumerId:this.consumerId}),new Pt("peer_track_request_key_frame_failed",e)}}}))}getVideoAvailableLayers(){if(this.consumer){if(!this.consumer.isAudio)return this.consumer.availableSpatialLayers;c(this,OE,"f").warn("Only video consumers support layers",{case:"getVideoAvailableLayers"})}}getInfo(){return a(this,void 0,void 0,(function*(){var e;const{width:t,height:r,frameRate:n,aspectRatio:i}=c(this,ME,"f").getSettings();return{trackId:c(this,ME,"f").id,readyState:c(this,ME,"f").readyState,isRemote:this.isRemote,kind:this.kind,label:this.label,width:t,height:r,frameRate:n,aspectRatio:i,paused:c(this,LE,"f"),trackInboundStats:yield null===(e=this.consumer)||void 0===e?void 0:e.getStats(),trackOutboundStats:yield this.getOutboundStats()}}))}getOutboundStats(){return a(this,void 0,void 0,(function*(){if(this.isRemote)return;const e=c(this,kE,"f").getAllTracks().find((e=>e.getLabel()===this.label));return e?yield e.getStats():void 0}))}requestMaxSpatialLayer(e,t){return a(this,void 0,void 0,(function*(){try{if(!this.consumer)return;if(this.consumer.isAudio||0===this.consumer.spatialLayers||this.consumer.currentMaxSpatialLayer===t||t<this.consumer.currentMaxSpatialLayer)return void c(this,OE,"f").warn("Can`t request this spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t});this.consumer.setRequestedSpatialLayer(t),yield c(this,RE,"f").requestProducerMaxSpatialLayer(this.consumer.producerId,t),c(this,OE,"f").debug("requestMaxSpatialLayer()",{consumerId:e,spatialLayer:t})}catch(r){c(this,OE,"f").warn("Failed to request max spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t,error:r})}}))}checkConsumerState(){return a(this,void 0,void 0,(function*(){try{if(c(this,jE,"f")||"audio"===this.kind)return;c(this,OE,"f").debug("checkConsumerState()",{track:this.logCtx});if((yield this.isInboundRTPStreamActive())||c(this,jE,"f"))return;yield this.requestKeyFrame();if((yield this.isInboundRTPStreamActive())||c(this,jE,"f"))return;if(c(this,xE,"f"))return c(this,NE,"f").emit(Xr,this),void c(this,OE,"f").debug("trackFail()",{track:this.logCtx});yield this.restartConsumer()}catch(e){c(this,OE,"f").warn("checkConsumerState()",{track:this,error:e})}}))}setVolume(e){c(this,BE,"f")!==e&&(d(this,BE,e,"f"),this.observer.safeEmit(Fr,{value:e}))}closeConsumer(){return a(this,void 0,void 0,(function*(){try{if(!this.consumer)return;this.consumer.close(),yield c(this,RE,"f").closeRemoteConsumer(this.consumer.id)}catch(e){c(this,OE,"f").debug("closeConsumer()",{track:this,error:e})}}))}restartConsumer(){return a(this,void 0,void 0,(function*(){try{if(!this.consumer||c(this,jE,"f"))return;c(this,OE,"f").debug("restartConsumer()",{track:this.logCtx}),c(this,NE,"f").emit(Kr,this),d(this,LE,!0,"f"),yield this.closeConsumer();const{consumer:e}=yield c(this,RE,"f").createConsumer({producerId:this.consumer.producerId,rtpCapabilities:c(this,kE,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.consumer.appData.producerData.peerId,appId:c(this,AE,"f").appId,channelId:c(this,AE,"f").channelId});d(this,xE,!0,"f"),this.consumer=c(this,IE,"f").call(this,{consumer:e}),d(this,ME,e.track,"f"),yield this.resume(),c(this,NE,"f").emit(Jr,this)}catch(e){d(this,xE,!0,"f"),c(this,OE,"f").warn("restartConsumer()",{track:this,error:e})}}))}isInboundRTPStreamActive(){return a(this,void 0,void 0,(function*(){if(!this.consumer||c(this,jE,"f"))return!1;const{framesDecoded:e}=yield this.consumer.getInboundRTPStreamStats();return yield new Promise((t=>{d(this,FE,setTimeout((()=>a(this,void 0,void 0,(function*(){try{if(!this.consumer)return void t(!1);const{framesDecoded:r}=yield this.consumer.getInboundRTPStreamStats();if(e===r&&!this.isPaused)return void t(!1);t(!0)}catch(e){c(this,OE,"f").debug("isInboundRTPStreamActive()",{error:e,track:this.logCtx}),t(!1)}}))),4500),"f")}))}))}clearCheckStateTimeout(){c(this,FE,"f")||clearTimeout(c(this,FE,"f"))}}RE=new WeakMap,kE=new WeakMap,DE=new WeakMap,IE=new WeakMap,AE=new WeakMap,OE=new WeakMap,NE=new WeakMap,ME=new WeakMap,LE=new WeakMap,xE=new WeakMap,FE=new WeakMap,jE=new WeakMap,UE=new WeakMap,VE=new WeakMap,BE=new WeakMap,WE=new WeakMap;class iw{constructor(e){this.encodings=[],HE.set(this,void 0);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,d(this,HE,Date.now(),"f")}setPaused(e){this.paused=e,d(this,HE,Date.now(),"f")}getStateChangedAt(){return c(this,HE,"f")}}HE=new WeakMap;class sw{constructor({id:e,channelIds:t,groups:r,producePermissions:n,appId:i,loginDate:s,producers:o=[],appData:a,uid:c,role:u,loggerFactory:l,myPeer:p,callState:h,peers:f,remotePeerTracks:m,media:g,network:v,peerConsumerFactory:y}){this.producers=new Map,this.tracks=new Map,qE.set(this,void 0),zE.set(this,void 0),GE.set(this,void 0),YE.set(this,void 0),$E.set(this,void 0),JE.set(this,void 0),KE.set(this,void 0),QE.set(this,void 0),this._observer=new Et,this.id=e,this.channelIds=t,this.groups=r,this.producePermissions=n,this.appId=i,this.loginDate=s,this.applicationData=null!=a?a:{},this.uid=c,this.role=u,d(this,$E,p,"f"),d(this,JE,h,"f"),d(this,qE,f,"f"),d(this,zE,m,"f"),d(this,KE,y,"f"),d(this,GE,v,"f"),d(this,YE,g,"f"),d(this,QE,l("Peer"),"f"),o.forEach(this.handleNewProducer.bind(this)),this.handlePeerEvents()}get appData(){return this.applicationData}get observer(){return this._observer}get isMe(){return this.id===c(this,$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(e){return a(this,arguments,void 0,(function*({producerId:e,muted:t=!1}){try{const r=this.producers.get(e);if(!r)return void c(this,QE,"f").warn("subscribe()",{message:"Peer does not have a producer",peer:Es(this),producerId:e});if(this.getAllConsumers().find((t=>t.producerId===e)))return void c(this,QE,"f").debug("subscribe()",{message:"Already subscribed to producer",peer:Es(this),producerId:e});const{consumer:n,isProducerPaused:i}=yield c(this,GE,"f").createConsumer({producerId:r.id,rtpCapabilities:c(this,YE,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.id,appId:c(this,JE,"f").appId,channelId:c(this,JE,"f").channelId});if(!this.producePermissions.includes(r.label)&&Object.values(Nn).includes(r.label))return void c(this,QE,"f").debug("subscribe()",{message:"Producer is not allowed anymore",peer:Es(this),producerId:e});const s=c(this,zE,"f").create({mediaStreamTrack:n.track,label:r.label,consumer:c(this,KE,"f").call(this,{consumer:n}),muted:t,paused:i,peerEventEmitter:this.observer});t||(yield s.unmute()),this.tracks.set(s.label,s),c(this,QE,"f").debug(`Subscribed for ${r.kind}`,{peer:Es(this)})}catch(t){throw c(this,QE,"f").error("subscribe()",{producerId:e,error:t,peer:Es(this)}),new Pt("peer_subscribe_failed",t)}}))}unsubscribe(e){return a(this,void 0,void 0,(function*(){try{const t=this.getConsumerByProducerId(e);if(!t)return;const r=this.getTrackByConsumerId(t.id);if(!r)return;yield r.close(),this.tracks.delete(r.label),c(this,QE,"f").debug(`Unsubscribed consumer ${t.kind}`,{peer:Es(this)})}catch(t){throw c(this,QE,"f").error("unsubscribe()",{producerId:e,error:t}),new Pt("peer_unsubscribe_failed",t)}}))}setProducePermissions(e){return a(this,void 0,void 0,(function*(){this.throwIfIamNotModerator();try{yield c(this,GE,"f").changePeerProducePermissions(this.id,e)}catch(e){throw new Pt("peer_set_produce_permissions_failed",e)}c(this,QE,"f").debug("Produce permissions changed",{peerId:this.id,producePermissions:e})}))}addProducePermission(e){return a(this,void 0,void 0,(function*(){this.throwIfIamNotModerator();try{yield c(this,GE,"f").addPeerProducePermission(this.id,e)}catch(e){throw new Pt("peer_add_produce_permission_failed",e)}c(this,QE,"f").debug("Add produce permission requested",{peerId:this.id,label:e})}))}removeProducePermission(e){return a(this,void 0,void 0,(function*(){this.throwIfIamNotModerator();try{yield c(this,GE,"f").removePeerProducePermission(this.id,e)}catch(e){throw new Pt("peer_remove_produce_permission_failed",e)}c(this,QE,"f").debug("Remove produce permission requested",{peerId:this.id,label:e})}))}getInfo(){return a(this,void 0,void 0,(function*(){try{return{id:this.id,appData:this.appData,role:this.role,channelIds:this.channelIds,appId:this.appId,uid:this.uid,loginDate:this.loginDate,tracks:yield Promise.all(Array.from(this.tracks.values()).map((e=>a(this,void 0,void 0,(function*(){return yield e.getInfo()})))))}}catch(e){throw c(this,QE,"f").error("getInfo()",{peer:Es(this),error:e}),new Pt("peer_get_info_failed",e)}}))}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 iw(e);this.producers.set(t.id,t),c(this,QE,"f").debug("Peer published media:",{peer:Es(this),producer:t});const r={producerId:t.id,kind:t.kind,label:t.label,paused:t.paused};this.observer.safeEmit(zr,r)}handlePeerEvents(){this.observer.on(nn,this.handleNewProducer.bind(this)),this.observer.on(sn,(e=>a(this,void 0,void 0,(function*(){this.producers.delete(e.id),c(this,QE,"f").debug("Peer unpublished media:",{peer:Es(this),producer:e}),this.observer.safeEmit(Gr,{producerId:e.id,kind:e.kind,label:e.label,paused:e.paused});const t=this.tracks.get(e.label);if(t)try{yield t.close()}catch(e){c(this,QE,"f").warn("Failed to close peer track due to producer closed",{label:t.label,peerId:this.id,error:Ct(e)})}})))),this.observer.on(cn,(e=>a(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.close(),this.tracks.delete(t.label),c(this,QE,"f").debug("Peer video track was ended:",{peer:Es(this),track:t.logCtx}))})))),this.observer.on(dn,(e=>a(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.pause(!1))})))),this.observer.on(un,(e=>a(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.resume(!1))})))),this.observer.on(ln,(e=>{const t=this.getConsumerById(e.consumerId);(null==t?void 0:t.isVideo)&&(t.applyLayersUpdate({spatialLayer:e.spatialLayer,temporalLayer:e.temporalLayer}),e.spatialLayer===t.requestedSpatialLayer&&t.setRequestedSpatialLayer(void 0),c(this,QE,"f").debug("consumerChangePreferredLayers()",Object.assign({},e)))})),this.observer.on(on,(e=>a(this,void 0,void 0,(function*(){const{producerId:t,spatialLayer:r}=e,n=this.getConsumerByProducerId(t);n?(n.setCurrentMaxSpatialLayer(r),c(this,QE,"f").debug("producerSetMaxSpatialLayer()",{producerId:t,consumerId:n.id,spatialLayer:r}),n.requestedSpatialLayer===r?(yield c(this,GE,"f").updateConsumerPreferredLayers(n.id,r),c(this,QE,"f").debug("requestVideoPreferredLayers()",{producerId:t,consumerId:n.id,spatialLayer:r})):c(this,QE,"f").debug("producerSetMaxSpatialLayer()",{message:"No need to request new preferred layer",currentMaxSpatialLayer:r,requestedMaxSpatialLayer:n.requestedSpatialLayer})):c(this,QE,"f").debug("producerSetMaxSpatialLayer()",{message:"Consumer for producer not created, ignore MaxSpatialLayer change"})})))),this.observer.on(mr,(e=>{try{yn(e),this.setAppData(e),this.observer.emit(en,e),c(this,QE,"f").debug("updatePeerAppData",{peer:Es(this),appData:e})}catch(t){c(this,QE,"f").error("updatePeerAppData",{peer:Es(this),appData:e,error:t})}}))}reset(){return a(this,void 0,void 0,(function*(){this.producers.clear(),yield Promise.all(Array.from(this.tracks.values()).map((e=>a(this,void 0,void 0,(function*(){return yield e.close()}))))),this.tracks.clear();[nn,sn,cn,dn,un,ln,on,mr].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(Nn).filter((e=>!this.producePermissions.includes(e))).forEach((e=>{const t=this.tracks.get(e);t&&(this.tracks.delete(t.label),t.close().catch((e=>{c(this,QE,"f").error("Failed to close track",{case:"Peer",error:Ct(e)})})))})),this.observer.safeEmit(tn,{labels:this.producePermissions})}handleGroupsChange(e){this.groups=e,this.observer.safeEmit(rn,{groups:e})}getAllConsumers(){return Array.from(this.tracks.values()).map((e=>e.consumer)).filter((e=>!!e))}getConsumerByProducerId(e){return this.getAllConsumers().find((t=>t.producerId===e))}getConsumerById(e){return this.getAllConsumers().find((t=>t.id===e))}getTrackByConsumerId(e){return Array.from(this.tracks.values()).find((t=>t.consumerId===e))}setAppData(e){this.applicationData=e}throwIfIamNotModerator(){if(!c(this,qE,"f").isModerator(c(this,$E,"f").id))throw new Pt("not_enough_access",new Error("Not enough access"))}}qE=new WeakMap,zE=new WeakMap,GE=new WeakMap,YE=new WeakMap,$E=new WeakMap,JE=new WeakMap,KE=new WeakMap,QE=new WeakMap;class ow{constructor(e){this.spatialLayers=um,this.temporalLayers=pm,this.currentSpatialLayer=um,this.currentTemporalLayer=pm,this.availableSpatialLayers=[],ZE.set(this,void 0);const{consumer:t,loggerFactory:r}=e;this.id=t.id,this.kind=t.kind,this.producerId=t.producerId,this.appData=t.appData,this.consumer=t,d(this,ZE,r("PeerConsumer"),"f"),this.currentMaxSpatialLayer=this.appData.producerData.maxSpatialLayer,this.parseScalabilityMode(),this.initAvailableSpatialLayers(),this.setCurrentSpatialLayerParams()}get paused(){return this.consumer.paused}pause(){this.consumer.pause()}resume(){this.consumer.resume()}close(){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}=ld.parseScalabilityMode(e);this.spatialLayers=t,this.temporalLayers=r,c(this,ZE,"f").debug("parseScalabilityMode()",{scalabilityMode:e,spatialLayers:t,temporalLayers:r})}}initAvailableSpatialLayers(){const{encodings:e,trackTransformParams:t}=this.appData.producerData;if(!Array.isArray(e))return;if(this.availableSpatialLayers=e.map((e=>this.tryPrepareSpatialLayerParams(e))),!t||this.availableSpatialLayers.length>1||this.spatialLayers<lm)return void c(this,ZE,"f").debug("Using available spatial layers",{case:"initAvailableSpatialLayers"});c(this,ZE,"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;(null==e?void 0:e[this.currentSpatialLayer])&&(this.currentSpatialLayerParams=this.tryPrepareSpatialLayerParams(e[this.currentSpatialLayer]),c(this,ZE,"f").debug("setCurrentSpatialLayerParams()",{currentSpatialLayerParams:this.currentSpatialLayerParams}))}tryPrepareSpatialLayerParams(e){var t;const{trackTransformParams:r}=this.appData.producerData;if(!r)return e;const{width:n,height:i}=r,s=null!==(t=e.scaleResolutionDownBy)&&void 0!==t?t:1;return n&&i?Object.assign({width:n/s,height:i/s},e):e}setCurrentSpatialLayer(e){if(!this.isVideo)throw new Error("setCurrentSpatialLayer applies to video consumers only");this.currentSpatialLayer=e,c(this,ZE,"f").debug("setCurrentSpatialLayer()",{currentSpatialLayer:e}),this.setCurrentSpatialLayerParams()}setCurrentTemporalLayer(e){if(!this.isVideo)throw new Error("setCurrentTemporalLayer applies to video consumers only");this.currentTemporalLayer=e,c(this,ZE,"f").debug("setCurrentTemporalLayer()",{currentTemporalLayer:e})}applyLayersUpdate(e){if(!this.isVideo)throw new Error("applyLayersUpdate applies to video consumers only");const{spatialLayer:t,temporalLayer:r}=e;void 0!==t&&this.setCurrentSpatialLayer(t),void 0!==r&&this.setCurrentTemporalLayer(r)}setRequestedSpatialLayer(e){this.requestedSpatialLayer=e}setCurrentMaxSpatialLayer(e){this.currentMaxSpatialLayer=e}getStats(){return a(this,void 0,void 0,(function*(){var e,t;try{return{consumerId:this.consumer.id,codec:this.consumer.rtpParameters.codecs.find((e=>Nm(e))),dtlsState:null===(t=null===(e=this.consumer.rtpReceiver)||void 0===e?void 0:e.transport)||void 0===t?void 0:t.state,availableSpatialLayers:this.availableSpatialLayers,currentSpatialLayerParams:this.currentSpatialLayerParams,requestedSpatialLayer:this.requestedSpatialLayer,rtcStats:yield this.getInboundRTPStreamStats()}}catch(e){return void c(this,ZE,"f").debug("getStats()",{error:e})}}))}getInboundRTPStreamStats(){return a(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{const r=(...n)=>a(this,[...n],void 0,(function*(n=0){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).catch((e=>{c(this,ZE,"f").debug("Error getting RTCStatsReport",{attempt:n,error:Ct(e)})}))}),150);n>=5&&!s&&t(new Error("InboundRTPStreamStat not exist")),e(s)}catch(e){t(new Error("Can not get RTCStatsReport")),c(this,ZE,"f").debug("getInboundRTPStreamStats()",{error:e})}}));r().catch((e=>{c(this,ZE,"f").debug("Error executing getRTCStatsReport",{case:"PeerConsumer",error:Ct(e)})}))}))}))}}ZE=new WeakMap;const aw=new rt({autoBindInjectable:!0});var cw,dw;aw.bind(On.LocalMutex).to(uv).inSingletonScope(),aw.bind(On.SignalingApiClient).toDynamicValue((e=>new gc(e.container.get(On.Config)))).inSingletonScope(),aw.bind(On.CallState).to(Ln).inSingletonScope(),aw.bind(On.MyPeer).to(ws).inSingletonScope(),aw.bind(On.LoggerFactory).toFactory((e=>{const t=e.container.get(On.Config),r=t.get("logLevel"),n=t.get("sendAnalytics"),i=t.get("onLogMessage");return e=>new Bb({logLevel:r,namespace:e,onLogMessage:i,sendAnalytics:n})})),aw.bind(On.System).to(yv).inSingletonScope(),aw.bind(On.ProcessorsCache).to(_m).inSingletonScope(),aw.bind(On.IntegrationsService).to(wm).inSingletonScope(),aw.bind(On.MediaStreamTrackManager).to(hg).inSingletonScope(),aw.bind(On.Media).to(mg).inSingletonScope(),aw.bind(On.Network).to(Jc).inSingletonScope(),aw.bind(On.NetworkTransportPolicyManager).to(ev).inSingletonScope(),aw.bind(On.PendingClosureProducerStorage).to(Hg).inSingletonScope(),aw.bind(On.ProducerCloseManager).to(Qg).inSingletonScope(),aw.bind(On.RemotePeerTracks).to(Wb).inSingletonScope(),aw.bind(On.Peers).to(Kc).inSingletonScope(),aw.bind(On.MediaEventHandler).to(Vg).inSingletonScope(),aw.bind(On.ChannelEventHandler).to(Og).inSingletonScope(),aw.bind(On.ChannelAudioObserverEventHandler).to(jc).inSingletonScope(),aw.bind(On.ChannelAudioObserverMissingProducerRestorer).to(Nc).inSingletonScope(),aw.bind(On.EventsQueue).to(bs).inSingletonScope(),aw.bind(On.ChannelStateSynchronizer).to(Ig).inSingletonScope(),aw.bind(On.ChannelStateSyncEventHandler).to(ud).inSingletonScope(),aw.bind(On.StatsHandler).to(Rv).inSingletonScope(),aw.bind(On.WIDHandler).to(nE).inSingletonScope(),aw.bind(On.WebRTCIssueDetector).toDynamicValue((e=>{const t=e.container.get(On.Config),r=e.container.get(On.WIDHandler);if(t.get("disableWid"))return;const n=e.container.get(On.StatsHandler),i=[1234],s=e.container.get(On.LoggerFactory)("WID"),o=new ar({statsParser:new cr({ignoreSSRCList:i,logger:s})});return new dr({onIssues:e=>{var n;r.handleIssues(e),null===(n=t.get("onIssues"))||void 0===n||n(e)},issueEmitter:new Wt,networkScoresCalculator:new zt,detectors:[new Qt,new $t,new Kt,new Jt,new Yt,new Zt,new rr({minMosQuality:Dt.GOOD,avgFreezeDurationThresholdMs:2e3,frozenDurationThresholdPct:50}),new nr({minMosQuality:Dt.GOOD,volatilityThreshold:10,affectedStreamsPercentThreshold:60})],statsReporter:new Ht({compositeStatsParser:o,getStatsInterval:t.get("getStatsInterval")}),onNetworkScoresUpdated:e=>{var n;r.handleNetworkScores(e),null===(n=t.get("onNetworkScoresUpdated"))||void 0===n||n(e)},onStats:n.handle.bind(n),ignoreSSRCList:i,compositeStatsParser:o,logger:s,autoAddPeerConnections:!1})})).inSingletonScope(),aw.bind(On.Engine).to(Mv).inSingletonScope(),aw.bind(On.PeerTrackFactory).toFactory((function(e){const t=e.container.get(On.LoggerFactory),r=e.container.get(On.CallState),n=e.container.get(On.StatsHandler);return i=>{const s={callState:r,loggerFactory:t,media:e.container.get(On.Media),network:e.container.get(On.Network),peerConsumerFactory:e.container.get(On.PeerConsumerFactory)},{peerEventEmitter:o}=i,a=new nw(Object.assign(Object.assign(Object.assign({},i),s),{statsHandler:n}));return o.safeEmit(Jr,a),a}})),aw.bind(On.PeerFactory).toFactory((function(e){const t=e.container.get(On.LoggerFactory),r=e.container.get(On.CallState);return n=>{const i={callState:r,loggerFactory:t,media:e.container.get(On.Media),myPeer:e.container.get(On.MyPeer),network:e.container.get(On.Network),peers:e.container.get(On.Peers),remotePeerTracks:e.container.get(On.RemotePeerTracks),peerConsumerFactory:e.container.get(On.PeerConsumerFactory)};return new sw(Object.assign(Object.assign({},i),n))}})),aw.bind(On.PeerConsumerFactory).toFactory((function(e){const t=e.container.get(On.LoggerFactory);return e=>{const r={loggerFactory:t};return new ow(Object.assign(Object.assign({},r),e))}})),aw.bind(On.AudioTrackFactory).toFactory((function(e){const t=e.container.get(On.LoggerFactory),r=e.container.get(On.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(On.InternalEventEmitter),loggerFactory:t,media:e.container.get(On.Media),mediaStreamTrackManager:e.container.get(On.MediaStreamTrackManager),myPeer:e.container.get(On.MyPeer),network:e.container.get(On.Network),producerCloseManager:e.container.get(On.ProducerCloseManager),mutex:e.container.get(On.LocalMutex),processorFactory:e.container.get(On.AudioTrackProcessorFactory),clientEventEmitter:e.container.get(On.ClientEventEmitter),statsHandler:r};return new tw(Object.assign(Object.assign({},i),n))}})),aw.bind(On.VideoTrackFactory).toFactory((function(e){const t=e.container.get(On.LoggerFactory),r=e.container.get(On.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(On.InternalEventEmitter),loggerFactory:t,media:e.container.get(On.Media),mediaStreamTrackManager:e.container.get(On.MediaStreamTrackManager),myPeer:e.container.get(On.MyPeer),network:e.container.get(On.Network),producerCloseManager:e.container.get(On.ProducerCloseManager),mutex:e.container.get(On.LocalMutex),statsHandler:r};return new rg(Object.assign(Object.assign({},i),n))}})),aw.bind(On.AudioTrackProcessorFactory).toFactory((function(e){const t=e.container.get(On.LoggerFactory),r=e.container.get(On.Config),n=e.container.get(On.ProcessorsCache),i=r.get("asdk");return e=>{const s=r.get("denoiser");let o=n.get(s,e.trackLabel);if(o)return o;if("rnnoise"===s&&e.noiseSuppressor&&(o=new ew({noiseSuppressor:e.noiseSuppressor,loggerFactory:t})),"asdk"===s&&(null==i?void 0:i.customerId)&&(o=new sE({asdkCustomerId:i.customerId,loggerFactory:t,config:r})),!o)throw new TypeError("Incorrect parameters passed to AudioTrackProcessorFactory");return o}})),aw.bind(On.DataChannelsManager).to(Wc).inSingletonScope(),aw.bind(On.DatachannelHeartbeater).to(_c).inSingletonScope(),aw.bind(On.SignalingHeartbeater).to(Yc).inSingletonScope(),aw.bind(On.AnalyticsApiClient).to(ub).inSingletonScope(),aw.bind(On.PeersStorage).to(wc).inSingletonScope(),aw.bind(On.TransportsStatsProvider).to(Ov).inSingletonScope();class uw{constructor(e){cw.set(this,void 0),dw.set(this,void 0),this.canUseNoiseSuppression=!0;const{clientEventEmitter:t,internalEventEmitter:r}=e;aw.bind(On.Config).toDynamicValue((()=>new bt(e))).inSingletonScope(),aw.bind(On.InternalEventEmitter).toDynamicValue((()=>null!=r?r:new Et)).inSingletonScope(),aw.bind(On.ClientEventEmitter).toDynamicValue((()=>null!=t?t:new Et)).inSingletonScope(),aw.get(On.IntegrationsService),this.clientEventEmitter=aw.get(On.ClientEventEmitter),d(this,cw,aw.get(On.Engine),"f"),d(this,dw,aw.get(On.NetworkTransportPolicyManager),"f")}get observer(){return this.clientEventEmitter}get id(){return c(this,cw,"f").myPeerId}get peers(){return c(this,cw,"f").getPeers()}get availableVideoDevices(){return c(this,cw,"f").system.availableVideoDevices}get availableAudioDevices(){return c(this,cw,"f").system.availableAudioDevices}get effectsSDKInitialized(){return c(this,cw,"f").media.effectsSDKInitialized}detectDevices(e){return a(this,void 0,void 0,(function*(){try{yield c(this,cw,"f").system.detectDevices(e)}catch(e){const t=e instanceof Error?e.message:"detect_devices_failed";throw new Pt(t,e)}return{video:c(this,cw,"f").system.availableVideoDevices,audio:c(this,cw,"f").system.availableAudioDevices}}))}initEffectsSDK(){return a(this,void 0,void 0,(function*(){return yield c(this,cw,"f").media.initEffectsSDK()}))}join(e){return a(this,void 0,void 0,(function*(){yield c(this,cw,"f").join(e)}))}leave(e){return a(this,void 0,void 0,(function*(){yield c(this,cw,"f").release(e)}))}confirmActivity(){return a(this,void 0,void 0,(function*(){yield c(this,cw,"f").confirmActivity()}))}createCameraVideoTrack(e){return a(this,void 0,void 0,(function*(){return yield c(this,cw,"f").createCameraVideoTrack(e)}))}createMicrophoneAudioTrack(e){return a(this,void 0,void 0,(function*(){return yield c(this,cw,"f").createMicrophoneAudioTrack(e)}))}createScreenMediaTracks(e){return a(this,void 0,void 0,(function*(){return yield c(this,cw,"f").createScreenMediaTracks(e)}))}createCustomAudioTrack(e){return c(this,cw,"f").createCustomAudioTrack(e)}createCustomVideoTrack(e){return c(this,cw,"f").createCustomVideoTrack(e)}deleteTrack(e){return a(this,void 0,void 0,(function*(){yield c(this,cw,"f").deleteTrack(e)}))}loadPeers(e){return a(this,void 0,void 0,(function*(){yield c(this,cw,"f").loadPeers(e)}))}requestChannelStateSync(){c(this,cw,"f").requestChannelStateSync()}updateAppData(e){return a(this,void 0,void 0,(function*(){yield c(this,cw,"f").updateAppData(e)}))}getTransportsInfo(){return a(this,void 0,void 0,(function*(){return yield c(this,cw,"f").network.getTransportsStateInfo()}))}setPreferRelay(e){c(this,cw,"f").network.setPreferRelay(e)}getPreferRelay(){return c(this,cw,"f").network.getPreferRelay()}changeIceTransportPolicy(e){return a(this,void 0,void 0,(function*(){yield c(this,dw,"f").changeIceTransportPolicy(e)}))}transportsStats(){return c(this,cw,"f").transportsStats()}setSignalingServerUrl(e){c(this,cw,"f").setSignalingServerUrl(e)}}cw=new WeakMap,dw=new WeakMap;export{uw as default};
|
|
38
|
+
wb=kb,Sb=kb.exports,function(){var e,t="Expected a function",r="__lodash_hash_undefined__",n="__lodash_placeholder__",i=16,s=32,o=64,a=128,c=256,d=1/0,u=9007199254740991,p=NaN,h=4294967295,f=[["ary",a],["bind",1],["bindKey",2],["curry",8],["curryRight",i],["flip",512],["partial",s],["partialRight",o],["rearg",c]],m="[object Arguments]",g="[object Array]",v="[object Boolean]",y="[object Date]",_="[object Error]",b="[object Function]",E="[object GeneratorFunction]",w="[object Map]",S="[object Number]",C="[object Object]",P="[object Promise]",T="[object RegExp]",R="[object Set]",k="[object String]",D="[object Symbol]",I="[object WeakMap]",A="[object ArrayBuffer]",O="[object DataView]",N="[object Float32Array]",M="[object Float64Array]",L="[object Int8Array]",x="[object Int16Array]",F="[object Int32Array]",j="[object Uint8Array]",U="[object Uint8ClampedArray]",V="[object Uint16Array]",B="[object Uint32Array]",W=/\b__p \+= '';/g,H=/\b(__p \+=) '' \+/g,q=/(__e\(.*?\)|\b__t\)) \+\n'';/g,z=/&(?:amp|lt|gt|quot|#39);/g,G=/[&<>"']/g,Y=RegExp(z.source),$=RegExp(G.source),J=/<%-([\s\S]+?)%>/g,K=/<%([\s\S]+?)%>/g,Q=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,X=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,re=RegExp(te.source),ne=/^\s+/,ie=/\s/,se=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,oe=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,ce=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,de=/[()=,{}\[\]\/\s]/,ue=/\\(\\)?/g,le=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,pe=/\w*$/,he=/^[-+]0x[0-9a-f]+$/i,fe=/^0b[01]+$/i,me=/^\[object .+?Constructor\]$/,ge=/^0o[0-7]+$/i,ve=/^(?:0|[1-9]\d*)$/,ye=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,_e=/($^)/,be=/['\n\r\u2028\u2029\\]/g,Ee="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",we="\\u2700-\\u27bf",Se="a-z\\xdf-\\xf6\\xf8-\\xff",Ce="A-Z\\xc0-\\xd6\\xd8-\\xde",Pe="\\ufe0e\\ufe0f",Te="\\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",Re="['’]",ke="[\\ud800-\\udfff]",De="["+Te+"]",Ie="["+Ee+"]",Ae="\\d+",Oe="[\\u2700-\\u27bf]",Ne="["+Se+"]",Me="[^\\ud800-\\udfff"+Te+Ae+we+Se+Ce+"]",Le="\\ud83c[\\udffb-\\udfff]",xe="[^\\ud800-\\udfff]",Fe="(?:\\ud83c[\\udde6-\\uddff]){2}",je="[\\ud800-\\udbff][\\udc00-\\udfff]",Ue="["+Ce+"]",Ve="(?:"+Ne+"|"+Me+")",Be="(?:"+Ue+"|"+Me+")",We="(?:['’](?:d|ll|m|re|s|t|ve))?",He="(?:['’](?:D|LL|M|RE|S|T|VE))?",qe="(?:"+Ie+"|"+Le+")?",ze="[\\ufe0e\\ufe0f]?",Ge=ze+qe+"(?:\\u200d(?:"+[xe,Fe,je].join("|")+")"+ze+qe+")*",Ye="(?:"+[Oe,Fe,je].join("|")+")"+Ge,$e="(?:"+[xe+Ie+"?",Ie,Fe,je,ke].join("|")+")",Je=RegExp(Re,"g"),Ke=RegExp(Ie,"g"),Qe=RegExp(Le+"(?="+Le+")|"+$e+Ge,"g"),Ze=RegExp([Ue+"?"+Ne+"+"+We+"(?="+[De,Ue,"$"].join("|")+")",Be+"+"+He+"(?="+[De,Ue+Ve,"$"].join("|")+")",Ue+"?"+Ve+"+"+We,Ue+"+"+He,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ae,Ye].join("|"),"g"),Xe=RegExp("[\\u200d\\ud800-\\udfff"+Ee+Pe+"]"),et=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,tt=["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"],rt=-1,nt={};nt[N]=nt[M]=nt[L]=nt[x]=nt[F]=nt[j]=nt[U]=nt[V]=nt[B]=!0,nt[m]=nt[g]=nt[A]=nt[v]=nt[O]=nt[y]=nt[_]=nt[b]=nt[w]=nt[S]=nt[C]=nt[T]=nt[R]=nt[k]=nt[I]=!1;var it={};it[m]=it[g]=it[A]=it[O]=it[v]=it[y]=it[N]=it[M]=it[L]=it[x]=it[F]=it[w]=it[S]=it[C]=it[T]=it[R]=it[k]=it[D]=it[j]=it[U]=it[V]=it[B]=!0,it[_]=it[b]=it[I]=!1;var st={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ot=parseFloat,at=parseInt,ct="object"==typeof l&&l&&l.Object===Object&&l,dt="object"==typeof self&&self&&self.Object===Object&&self,ut=ct||dt||Function("return this")(),lt=Sb&&!Sb.nodeType&&Sb,pt=lt&&wb&&!wb.nodeType&&wb,ht=pt&&pt.exports===lt,ft=ht&&ct.process,mt=function(){try{var e=pt&&pt.require&&pt.require("util").types;return e||ft&&ft.binding&&ft.binding("util")}catch(e){}}(),gt=mt&&mt.isArrayBuffer,vt=mt&&mt.isDate,yt=mt&&mt.isMap,_t=mt&&mt.isRegExp,bt=mt&&mt.isSet,Et=mt&&mt.isTypedArray;function wt(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 St(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 Ct(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}function Pt(e,t){for(var r=null==e?0:e.length;r--&&!1!==t(e[r],r,e););return e}function Tt(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 Rt(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 kt(e,t){return!(null==e||!e.length)&&jt(e,t,0)>-1}function Dt(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 It(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 At(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}function Ot(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 Nt(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 Mt(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 Lt=Wt("length");function xt(e,t,r){var n;return r(e,(function(e,r,i){if(t(e,r,i))return n=r,!1})),n}function Ft(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 jt(e,t,r){return t==t?function(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1}(e,t,r):Ft(e,Vt,r)}function Ut(e,t,r,n){for(var i=r-1,s=e.length;++i<s;)if(n(e[i],t))return i;return-1}function Vt(e){return e!=e}function Bt(e,t){var r=null==e?0:e.length;return r?zt(e,t)/r:p}function Wt(t){return function(r){return null==r?e:r[t]}}function Ht(t){return function(r){return null==t?e:t[r]}}function qt(e,t,r,n,i){return i(e,(function(e,i,s){r=n?(n=!1,e):t(r,e,i,s)})),r}function zt(t,r){for(var n,i=-1,s=t.length;++i<s;){var o=r(t[i]);o!==e&&(n=n===e?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 Yt(e){return e?e.slice(0,lr(e)+1).replace(ne,""):e}function $t(e){return function(t){return e(t)}}function Jt(e,t){return It(t,(function(t){return e[t]}))}function Kt(e,t){return e.has(t)}function Qt(e,t){for(var r=-1,n=e.length;++r<n&&jt(t,e[r],0)>-1;);return r}function Zt(e,t){for(var r=e.length;r--&&jt(t,e[r],0)>-1;);return r}function Xt(e,t){for(var r=e.length,n=0;r--;)e[r]===t&&++n;return n}var er=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"}),tr=Ht({"&":"&","<":"<",">":">",'"':""","'":"'"});function rr(e){return"\\"+st[e]}function nr(e){return Xe.test(e)}function ir(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function sr(e,t){return function(r){return e(t(r))}}function or(e,t){for(var r=-1,i=e.length,s=0,o=[];++r<i;){var a=e[r];a!==t&&a!==n||(e[r]=n,o[s++]=r)}return o}function ar(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}function cr(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=[e,e]})),r}function dr(e){return nr(e)?function(e){for(var t=Qe.lastIndex=0;Qe.test(e);)++t;return t}(e):Lt(e)}function ur(e){return nr(e)?function(e){return e.match(Qe)||[]}(e):function(e){return e.split("")}(e)}function lr(e){for(var t=e.length;t--&&ie.test(e.charAt(t)););return t}var pr=Ht({"&":"&","<":"<",">":">",""":'"',"'":"'"}),hr=function l(ie){var Ee,we=(ie=null==ie?ut:hr.defaults(ut.Object(),ie,hr.pick(ut,tt))).Array,Se=ie.Date,Ce=ie.Error,Pe=ie.Function,Te=ie.Math,Re=ie.Object,ke=ie.RegExp,De=ie.String,Ie=ie.TypeError,Ae=we.prototype,Oe=Pe.prototype,Ne=Re.prototype,Me=ie["__core-js_shared__"],Le=Oe.toString,xe=Ne.hasOwnProperty,Fe=0,je=(Ee=/[^.]+$/.exec(Me&&Me.keys&&Me.keys.IE_PROTO||""))?"Symbol(src)_1."+Ee:"",Ue=Ne.toString,Ve=Le.call(Re),Be=ut._,We=ke("^"+Le.call(xe).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),He=ht?ie.Buffer:e,qe=ie.Symbol,ze=ie.Uint8Array,Ge=He?He.allocUnsafe:e,Ye=sr(Re.getPrototypeOf,Re),$e=Re.create,Qe=Ne.propertyIsEnumerable,Xe=Ae.splice,st=qe?qe.isConcatSpreadable:e,ct=qe?qe.iterator:e,dt=qe?qe.toStringTag:e,lt=function(){try{var e=hs(Re,"defineProperty");return e({},"",{}),e}catch(e){}}(),pt=ie.clearTimeout!==ut.clearTimeout&&ie.clearTimeout,ft=Se&&Se.now!==ut.Date.now&&Se.now,mt=ie.setTimeout!==ut.setTimeout&&ie.setTimeout,Lt=Te.ceil,Ht=Te.floor,fr=Re.getOwnPropertySymbols,mr=He?He.isBuffer:e,gr=ie.isFinite,vr=Ae.join,yr=sr(Re.keys,Re),_r=Te.max,br=Te.min,Er=Se.now,wr=ie.parseInt,Sr=Te.random,Cr=Ae.reverse,Pr=hs(ie,"DataView"),Tr=hs(ie,"Map"),Rr=hs(ie,"Promise"),kr=hs(ie,"Set"),Dr=hs(ie,"WeakMap"),Ir=hs(Re,"create"),Ar=Dr&&new Dr,Or={},Nr=Vs(Pr),Mr=Vs(Tr),Lr=Vs(Rr),xr=Vs(kr),Fr=Vs(Dr),jr=qe?qe.prototype:e,Ur=jr?jr.valueOf:e,Vr=jr?jr.toString:e;function Br(e){if(ia(e)&&!Yo(e)&&!(e instanceof zr)){if(e instanceof qr)return e;if(xe.call(e,"__wrapped__"))return Bs(e)}return new qr(e)}var Wr=function(){function t(){}return function(r){if(!na(r))return{};if($e)return $e(r);t.prototype=r;var n=new t;return t.prototype=e,n}}();function Hr(){}function qr(t,r){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!r,this.__index__=0,this.__values__=e}function zr(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=h,this.__views__=[]}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 Yr(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 $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 Jr(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new $r;++t<r;)this.add(e[t])}function Kr(e){var t=this.__data__=new Yr(e);this.size=t.size}function Qr(e,t){var r=Yo(e),n=!r&&Go(e),i=!r&&!n&&Qo(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&&!xe.call(e,d)||o&&("length"==d||i&&("offset"==d||"parent"==d)||s&&("buffer"==d||"byteLength"==d||"byteOffset"==d)||bs(d,c))||a.push(d);return a}function Zr(t){var r=t.length;return r?t[Kn(0,r-1)]:e}function Xr(e,t){return Fs(Ai(e),dn(t,0,e.length))}function en(e){return Fs(Ai(e))}function tn(t,r,n){(n!==e&&!Ho(t[r],n)||n===e&&!(r in t))&&an(t,r,n)}function rn(t,r,n){var i=t[r];xe.call(t,r)&&Ho(i,n)&&(n!==e||r in t)||an(t,r,n)}function nn(e,t){for(var r=e.length;r--;)if(Ho(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&&Oi(t,Ma(t),e)}function an(e,t,r){"__proto__"==t&<?lt(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function cn(t,r){for(var n=-1,i=r.length,s=we(i),o=null==t;++n<i;)s[n]=o?e:Da(t,r[n]);return s}function dn(t,r,n){return t==t&&(n!==e&&(t=t<=n?t:n),r!==e&&(t=t>=r?t:r)),t}function un(t,r,n,i,s,o){var a,c=1&r,d=2&r,u=4&r;if(n&&(a=s?n(t,i,s,o):n(t)),a!==e)return a;if(!na(t))return t;var l=Yo(t);if(l){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&xe.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(t),!c)return Ai(t,a)}else{var p=gs(t),h=p==b||p==E;if(Qo(t))return Pi(t,c);if(p==C||p==m||h&&!s){if(a=d||h?{}:ys(t),!c)return d?function(e,t){return Oi(e,ms(e),t)}(t,function(e,t){return e&&Oi(t,La(t),e)}(a,t)):function(e,t){return Oi(e,fs(e),t)}(t,on(a,t))}else{if(!it[p])return s?t:{};a=function(e,t,r){var n=e.constructor;switch(t){case A:return Ti(e);case v:case y:return new n(+e);case O:return function(e,t){var r=t?Ti(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case N:case M:case L:case x:case F:case j:case U:case V:case B:return Ri(e,r);case w:case R:return new n;case S:case k:return new n(e);case T:return function(e){var t=new e.constructor(e.source,pe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case D:return function(e){return Ur?Re(Ur.call(e)):{}}(e)}}(t,p,c)}}o||(o=new Kr);var f=o.get(t);if(f)return f;o.set(t,a),da(t)?t.forEach((function(e){a.add(un(e,r,n,e,t,o))})):sa(t)&&t.forEach((function(e,i){a.set(i,un(e,r,n,i,t,o))}));var g=l?e:(u?d?os:ss:d?La:Ma)(t);return Ct(g||t,(function(e,i){g&&(e=t[i=e]),rn(a,i,un(e,r,n,i,t,o))})),a}function ln(t,r,n){var i=n.length;if(null==t)return!i;for(t=Re(t);i--;){var s=n[i],o=r[s],a=t[s];if(a===e&&!(s in t)||!o(a))return!1}return!0}function pn(r,n,i){if("function"!=typeof r)throw new Ie(t);return Ns((function(){r.apply(e,i)}),n)}function hn(e,t,r,n){var i=-1,s=kt,o=!0,a=e.length,c=[],d=t.length;if(!a)return c;r&&(t=It(t,$t(r))),n?(s=Dt,o=!1):t.length>=200&&(s=Kt,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}Br.templateSettings={escape:J,evaluate:K,interpolate:Q,variable:"",imports:{_:Br}},Br.prototype=Hr.prototype,Br.prototype.constructor=Br,qr.prototype=Wr(Hr.prototype),qr.prototype.constructor=qr,zr.prototype=Wr(Hr.prototype),zr.prototype.constructor=zr,Gr.prototype.clear=function(){this.__data__=Ir?Ir(null):{},this.size=0},Gr.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Gr.prototype.get=function(t){var n=this.__data__;if(Ir){var i=n[t];return i===r?e:i}return xe.call(n,t)?n[t]:e},Gr.prototype.has=function(t){var r=this.__data__;return Ir?r[t]!==e:xe.call(r,t)},Gr.prototype.set=function(t,n){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Ir&&n===e?r:n,this},Yr.prototype.clear=function(){this.__data__=[],this.size=0},Yr.prototype.delete=function(e){var t=this.__data__,r=nn(t,e);return!(r<0||(r==t.length-1?t.pop():Xe.call(t,r,1),--this.size,0))},Yr.prototype.get=function(t){var r=this.__data__,n=nn(r,t);return n<0?e:r[n][1]},Yr.prototype.has=function(e){return nn(this.__data__,e)>-1},Yr.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},$r.prototype.clear=function(){this.size=0,this.__data__={hash:new Gr,map:new(Tr||Yr),string:new Gr}},$r.prototype.delete=function(e){var t=ls(this,e).delete(e);return this.size-=t?1:0,t},$r.prototype.get=function(e){return ls(this,e).get(e)},$r.prototype.has=function(e){return ls(this,e).has(e)},$r.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,r),this},Jr.prototype.has=function(e){return this.__data__.has(e)},Kr.prototype.clear=function(){this.__data__=new Yr,this.size=0},Kr.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Kr.prototype.get=function(e){return this.__data__.get(e)},Kr.prototype.has=function(e){return this.__data__.has(e)},Kr.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Yr){var n=r.__data__;if(!Tr||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new $r(n)}return r.set(e,t),this.size=r.size,this};var fn=Li(wn),mn=Li(Sn,!0);function gn(e,t){var r=!0;return fn(e,(function(e,n,i){return r=!!t(e,n,i)})),r}function vn(t,r,n){for(var i=-1,s=t.length;++i<s;){var o=t[i],a=r(o);if(null!=a&&(c===e?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 _n(e,t,r,n,i){var s=-1,o=e.length;for(r||(r=_s),i||(i=[]);++s<o;){var a=e[s];t>0&&r(a)?t>1?_n(a,t-1,r,n,i):At(i,a):n||(i[i.length]=a)}return i}var bn=xi(),En=xi(!0);function wn(e,t){return e&&bn(e,t,Ma)}function Sn(e,t){return e&&En(e,t,Ma)}function Cn(e,t){return Rt(t,(function(t){return ea(e[t])}))}function Pn(t,r){for(var n=0,i=(r=Ei(r,t)).length;null!=t&&n<i;)t=t[Us(r[n++])];return n&&n==i?t:e}function Tn(e,t,r){var n=t(e);return Yo(e)?n:At(n,r(e))}function Rn(t){return null==t?t===e?"[object Undefined]":"[object Null]":dt&&dt in Re(t)?function(t){var r=xe.call(t,dt),n=t[dt];try{t[dt]=e;var i=!0}catch(e){}var s=Ue.call(t);return i&&(r?t[dt]=n:delete t[dt]),s}(t):function(e){return Ue.call(e)}(t)}function kn(e,t){return e>t}function Dn(e,t){return null!=e&&xe.call(e,t)}function In(e,t){return null!=e&&t in Re(e)}function An(t,r,n){for(var i=n?Dt:kt,s=t[0].length,o=t.length,a=o,c=we(o),d=1/0,u=[];a--;){var l=t[a];a&&r&&(l=It(l,$t(r))),d=br(l.length,d),c[a]=!n&&(r||s>=120&&l.length>=120)?new Jr(a&&l):e}l=t[0];var p=-1,h=c[0];e:for(;++p<s&&u.length<d;){var f=l[p],m=r?r(f):f;if(f=n||0!==f?f:0,!(h?Kt(h,m):i(u,m,n))){for(a=o;--a;){var g=c[a];if(!(g?Kt(g,m):i(t[a],m,n)))continue e}h&&h.push(m),u.push(f)}}return u}function On(t,r,n){var i=null==(t=Ds(t,r=Ei(r,t)))?t:t[Us(Zs(r))];return null==i?e:wt(i,t,n)}function Nn(e){return ia(e)&&Rn(e)==m}function Mn(t,r,n,i,s){return t===r||(null==t||null==r||!ia(t)&&!ia(r)?t!=t&&r!=r:function(t,r,n,i,s,o){var a=Yo(t),c=Yo(r),d=a?g:gs(t),u=c?g:gs(r),l=(d=d==m?C:d)==C,p=(u=u==m?C:u)==C,h=d==u;if(h&&Qo(t)){if(!Qo(r))return!1;a=!0,l=!1}if(h&&!l)return o||(o=new Kr),a||pa(t)?ns(t,r,n,i,s,o):function(e,t,r,n,i,s,o){switch(r){case O:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case A:return!(e.byteLength!=t.byteLength||!s(new ze(e),new ze(t)));case v:case y:case S:return Ho(+e,+t);case _:return e.name==t.name&&e.message==t.message;case T:case k:return e==t+"";case w:var a=ir;case R:var c=1&n;if(a||(a=ar),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 D:if(Ur)return Ur.call(e)==Ur.call(t)}return!1}(t,r,d,n,i,s,o);if(!(1&n)){var f=l&&xe.call(t,"__wrapped__"),b=p&&xe.call(r,"__wrapped__");if(f||b){var E=f?t.value():t,P=b?r.value():r;return o||(o=new Kr),s(E,P,n,i,o)}}return!!h&&(o||(o=new Kr),function(t,r,n,i,s,o){var a=1&n,c=ss(t),d=c.length,u=ss(r).length;if(d!=u&&!a)return!1;for(var l=d;l--;){var p=c[l];if(!(a?p in r:xe.call(r,p)))return!1}var h=o.get(t),f=o.get(r);if(h&&f)return h==r&&f==t;var m=!0;o.set(t,r),o.set(r,t);for(var g=a;++l<d;){var v=t[p=c[l]],y=r[p];if(i)var _=a?i(y,v,p,r,t,o):i(v,y,p,t,r,o);if(!(_===e?v===y||s(v,y,n,i,o):_)){m=!1;break}g||(g="constructor"==p)}if(m&&!g){var b=t.constructor,E=r.constructor;b==E||!("constructor"in t)||!("constructor"in r)||"function"==typeof b&&b instanceof b&&"function"==typeof E&&E instanceof E||(m=!1)}return o.delete(t),o.delete(r),m}(t,r,n,i,s,o))}(t,r,n,i,Mn,s))}function Ln(t,r,n,i){var s=n.length,o=s,a=!i;if(null==t)return!o;for(t=Re(t);s--;){var c=n[s];if(a&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++s<o;){var d=(c=n[s])[0],u=t[d],l=c[1];if(a&&c[2]){if(u===e&&!(d in t))return!1}else{var p=new Kr;if(i)var h=i(u,l,d,t,r,p);if(!(h===e?Mn(l,u,3,i,p):h))return!1}}return!0}function xn(e){return!(!na(e)||(t=e,je&&je in t))&&(ea(e)?We:me).test(Vs(e));var t}function Fn(e){return"function"==typeof e?e:null==e?oc:"object"==typeof e?Yo(e)?Hn(e[0],e[1]):Wn(e):mc(e)}function jn(e){if(!Ps(e))return yr(e);var t=[];for(var r in Re(e))xe.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Un(e){if(!na(e))return function(e){var t=[];if(null!=e)for(var r in Re(e))t.push(r);return t}(e);var t=Ps(e),r=[];for(var n in e)("constructor"!=n||!t&&xe.call(e,n))&&r.push(n);return r}function Vn(e,t){return e<t}function Bn(e,t){var r=-1,n=Jo(e)?we(e.length):[];return fn(e,(function(e,i,s){n[++r]=t(e,i,s)})),n}function Wn(e){var t=ps(e);return 1==t.length&&t[0][2]?Rs(t[0][0],t[0][1]):function(r){return r===e||Ln(r,e,t)}}function Hn(t,r){return ws(t)&&Ts(r)?Rs(Us(t),r):function(n){var i=Da(n,t);return i===e&&i===r?Ia(n,t):Mn(r,i,3)}}function qn(t,r,n,i,s){t!==r&&bn(r,(function(o,a){if(s||(s=new Kr),na(o))!function(t,r,n,i,s,o,a){var c=As(t,n),d=As(r,n),u=a.get(d);if(u)tn(t,n,u);else{var l=o?o(c,d,n+"",t,r,a):e,p=l===e;if(p){var h=Yo(d),f=!h&&Qo(d),m=!h&&!f&&pa(d);l=d,h||f||m?Yo(c)?l=c:Ko(c)?l=Ai(c):f?(p=!1,l=Pi(d,!0)):m?(p=!1,l=Ri(d,!0)):l=[]:aa(d)||Go(d)?(l=c,Go(c)?l=ba(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(t,n,l)}}(t,r,a,n,qn,i,s);else{var c=i?i(As(t,a),o,a+"",t,r,s):e;c===e&&(c=o),tn(t,a,c)}}),La)}function zn(t,r){var n=t.length;if(n)return bs(r+=r<0?n:0,n)?t[r]:e}function Gn(e,t,r){t=t.length?It(t,(function(e){return Yo(e)?function(t){return Pn(t,1===e.length?e[0]:e)}:e})):[oc];var n=-1;t=It(t,$t(us()));var i=Bn(e,(function(e,r,i){var s=It(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){for(var n=-1,i=e.criteria,s=t.criteria,o=i.length,a=r.length;++n<o;){var c=ki(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 Yn(e,t,r){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=Pn(e,o);r(a,o)&&ti(s,Ei(o,e),a)}return s}function $n(e,t,r,n){var i=n?Ut:jt,s=-1,o=t.length,a=e;for(e===t&&(t=Ai(t)),r&&(a=It(e,$t(r)));++s<o;)for(var c=0,d=t[s],u=r?r(d):d;(c=i(a,u,c,n))>-1;)a!==e&&Xe.call(a,c,1),Xe.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;bs(i)?Xe.call(e,i,1):hi(e,i)}}return e}function Kn(e,t){return e+Ht(Sr()*(t-e+1))}function Qn(e,t){var r="";if(!e||t<1||t>u)return r;do{t%2&&(r+=e),(t=Ht(t/2))&&(e+=e)}while(t);return r}function Zn(e,t){return Ms(ks(e,t,oc),e+"")}function Xn(e){return Zr(Ha(e))}function ei(e,t){var r=Ha(e);return Fs(r,dn(t,0,r.length))}function ti(t,r,n,i){if(!na(t))return t;for(var s=-1,o=(r=Ei(r,t)).length,a=o-1,c=t;null!=c&&++s<o;){var d=Us(r[s]),u=n;if("__proto__"===d||"constructor"===d||"prototype"===d)return t;if(s!=a){var l=c[d];(u=i?i(l,d,c):e)===e&&(u=na(l)?l:bs(r[s+1])?[]:{})}rn(c,d,u),c=c[d]}return t}var ri=Ar?function(e,t){return Ar.set(e,t),e}:oc,ni=lt?function(e,t){return lt(e,"toString",{configurable:!0,enumerable:!1,value:nc(t),writable:!0})}:oc;function ii(e){return Fs(Ha(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=we(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(t,r,n,i){var s=0,o=null==t?0:t.length;if(0===o)return 0;for(var a=(r=n(r))!=r,c=null===r,d=la(r),u=r===e;s<o;){var l=Ht((s+o)/2),p=n(t[l]),h=p!==e,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<=r:p<r);v?s=l+1:o=l}return br(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||!Ho(a,c)){var c=a;s[i++]=0===o?0:o}}return s}function ui(e){return"number"==typeof e?e:la(e)?p:+e}function li(e){if("string"==typeof e)return e;if(Yo(e))return It(e,li)+"";if(la(e))return Vr?Vr.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function pi(e,t,r){var n=-1,i=kt,s=e.length,o=!0,a=[],c=a;if(r)o=!1,i=Dt;else if(s>=200){var d=t?null:Qi(e);if(d)return ar(d);o=!1,i=Kt,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=Ei(t,e)))||delete e[Us(Zs(t))]}function fi(e,t,r,n){return ti(e,t,r(Pn(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 zr&&(r=r.value()),Ot(t,(function(e,t){return t.func.apply(t.thisArg,At([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=we(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(_n(s,1),t,r)}function yi(t,r,n){for(var i=-1,s=t.length,o=r.length,a={};++i<s;){var c=i<o?r[i]:e;n(a,t[i],c)}return a}function _i(e){return Ko(e)?e:[]}function bi(e){return"function"==typeof e?e:oc}function Ei(e,t){return Yo(e)?e:ws(e,t)?[e]:js(Ea(e))}var wi=Zn;function Si(t,r,n){var i=t.length;return n=n===e?i:n,!r&&n>=i?t:si(t,r,n)}var Ci=pt||function(e){return ut.clearTimeout(e)};function Pi(e,t){if(t)return e.slice();var r=e.length,n=Ge?Ge(r):new e.constructor(r);return e.copy(n),n}function Ti(e){var t=new e.constructor(e.byteLength);return new ze(t).set(new ze(e)),t}function Ri(e,t){var r=t?Ti(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function ki(t,r){if(t!==r){var n=t!==e,i=null===t,s=t==t,o=la(t),a=r!==e,c=null===r,d=r==r,u=la(r);if(!c&&!u&&!o&&t>r||o&&a&&d&&!c&&!u||i&&a&&d||!n&&d||!s)return 1;if(!i&&!o&&!u&&t<r||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=_r(s-o,0),u=we(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=_r(s-a,0),l=we(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 Ai(e,t){var r=-1,n=e.length;for(t||(t=we(n));++r<n;)t[r]=e[r];return t}function Oi(t,r,n,i){var s=!n;n||(n={});for(var o=-1,a=r.length;++o<a;){var c=r[o],d=i?i(n[c],t[c],c,n,t):e;d===e&&(d=t[c]),s?an(n,c,d):rn(n,c,d)}return n}function Ni(e,t){return function(r,n){var i=Yo(r)?St:sn,s=t?t():{};return i(r,e,us(n,2),s)}}function Mi(t){return Zn((function(r,n){var i=-1,s=n.length,o=s>1?n[s-1]:e,a=s>2?n[2]:e;for(o=t.length>3&&"function"==typeof o?(s--,o):e,a&&Es(n[0],n[1],a)&&(o=s<3?e:o,s=1),r=Re(r);++i<s;){var c=n[i];c&&t(r,c,i,o)}return r}))}function Li(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=Re(r);(t?s--:++s<i)&&!1!==n(o[s],s,o););return r}}function xi(e){return function(t,r,n){for(var i=-1,s=Re(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(t){return function(r){var n=nr(r=Ea(r))?ur(r):e,i=n?n[0]:r.charAt(0),s=n?Si(n,1).join(""):r.slice(1);return i[t]()+s}}function ji(e){return function(t){return Ot(ec(Ga(t).replace(Je,"")),e,"")}}function Ui(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=Wr(e.prototype),n=e.apply(r,t);return na(n)?n:r}}function Vi(t){return function(r,n,i){var s=Re(r);if(!Jo(r)){var o=us(n,3);r=Ma(r),n=function(e){return o(s[e],e,s)}}var a=t(r,n,i);return a>-1?s[o?r[a]:a]:e}}function Bi(r){return is((function(n){var i=n.length,s=i,o=qr.prototype.thru;for(r&&n.reverse();s--;){var a=n[s];if("function"!=typeof a)throw new Ie(t);if(o&&!c&&"wrapper"==cs(a))var c=new qr([],!0)}for(s=c?s:i;++s<i;){var d=cs(a=n[s]),u="wrapper"==d?as(a):e;c=u&&Ss(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?c[cs(u[0])].apply(c,u[3]):1==a.length&&Ss(a)?c[d]():c.thru(a)}return function(){var e=arguments,t=e[0];if(c&&1==e.length&&Yo(t))return c.plant(t).value();for(var r=0,s=i?n[r].apply(this,e):t;++r<i;)s=n[r].call(this,s);return s}}))}function Wi(t,r,n,i,s,o,c,d,u,l){var p=r&a,h=1&r,f=2&r,m=24&r,g=512&r,v=f?e:Ui(t);return function e(){for(var a=arguments.length,y=we(a),_=a;_--;)y[_]=arguments[_];if(m)var b=ds(e),E=Xt(y,b);if(i&&(y=Di(y,i,s,m)),o&&(y=Ii(y,o,c,m)),a-=E,m&&a<l){var w=or(y,b);return Ji(t,r,Wi,e.placeholder,n,y,w,d,u,l-a)}var S=h?n:this,C=f?S[t]:t;return a=y.length,d?y=Is(y,d):g&&a>1&&y.reverse(),p&&u<a&&(y.length=u),this&&this!==ut&&this instanceof e&&(C=v||Ui(C)),C.apply(S,y)}}function Hi(e,t){return function(r,n){return function(e,t,r,n){return wn(e,(function(e,i,s){t(n,r(e),i,s)})),n}(r,e,t(n),{})}}function qi(t,r){return function(n,i){var s;if(n===e&&i===e)return r;if(n!==e&&(s=n),i!==e){if(s===e)return i;"string"==typeof n||"string"==typeof i?(n=li(n),i=li(i)):(n=ui(n),i=ui(i)),s=t(n,i)}return s}}function zi(e){return is((function(t){return t=It(t,$t(us())),Zn((function(r){var n=this;return e(t,(function(e){return wt(e,n,r)}))}))}))}function Gi(t,r){var n=(r=r===e?" ":li(r)).length;if(n<2)return n?Qn(r,t):r;var i=Qn(r,Lt(t/dr(r)));return nr(r)?Si(ur(i),0,t).join(""):i.slice(0,t)}function Yi(t){return function(r,n,i){return i&&"number"!=typeof i&&Es(r,n,i)&&(n=i=e),r=ga(r),n===e?(n=r,r=0):n=ga(n),function(e,t,r,n){for(var i=-1,s=_r(Lt((t-e)/(r||1)),0),o=we(s);s--;)o[n?s:++i]=e,e+=r;return o}(r,n,i=i===e?r<n?1:-1:ga(i),t)}}function $i(e){return function(t,r){return"string"==typeof t&&"string"==typeof r||(t=_a(t),r=_a(r)),e(t,r)}}function Ji(t,r,n,i,a,c,d,u,l,p){var h=8&r;r|=h?s:o,4&(r&=~(h?o:s))||(r&=-4);var f=[t,r,a,h?c:e,h?d:e,h?e:c,h?e:d,u,l,p],m=n.apply(e,f);return Ss(t)&&Os(m,f),m.placeholder=i,Ls(m,t,r)}function Ki(e){var t=Te[e];return function(e,r){if(e=_a(e),(r=null==r?0:br(va(r),292))&&gr(e)){var n=(Ea(e)+"e").split("e");return+((n=(Ea(t(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return t(e)}}var Qi=kr&&1/ar(new kr([,-0]))[1]==d?function(e){return new kr(e)}:lc;function Zi(e){return function(t){var r=gs(t);return r==w?ir(t):r==R?cr(t):function(e,t){return It(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Xi(r,d,u,l,p,h,f,m){var g=2&d;if(!g&&"function"!=typeof r)throw new Ie(t);var v=l?l.length:0;if(v||(d&=-97,l=p=e),f=f===e?f:_r(va(f),0),m=m===e?m:va(m),v-=p?p.length:0,d&o){var y=l,_=p;l=p=e}var b=g?e:as(r),E=[r,d,u,l,p,y,_,h,f,m];if(b&&function(e,t){var r=e[1],i=t[1],s=r|i,o=s<131,d=i==a&&8==r||i==a&&r==c&&e[7].length<=t[8]||384==i&&t[7].length<=t[8]&&8==r;if(!o&&!d)return e;1&i&&(e[2]=t[2],s|=1&r?0:4);var u=t[3];if(u){var l=e[3];e[3]=l?Di(l,u,t[4]):u,e[4]=l?or(e[3],n):t[4]}(u=t[5])&&(l=e[5],e[5]=l?Ii(l,u,t[6]):u,e[6]=l?or(e[5],n):t[6]),(u=t[7])&&(e[7]=u),i&a&&(e[8]=null==e[8]?t[8]:br(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=s}(E,b),r=E[0],d=E[1],u=E[2],l=E[3],p=E[4],!(m=E[9]=E[9]===e?g?0:r.length:_r(E[9]-v,0))&&24&d&&(d&=-25),d&&1!=d)w=8==d||d==i?function(t,r,n){var i=Ui(t);return function s(){for(var o=arguments.length,a=we(o),c=o,d=ds(s);c--;)a[c]=arguments[c];var u=o<3&&a[0]!==d&&a[o-1]!==d?[]:or(a,d);return(o-=u.length)<n?Ji(t,r,Wi,s.placeholder,e,a,u,e,e,n-o):wt(this&&this!==ut&&this instanceof s?i:t,this,a)}}(r,d,m):d!=s&&33!=d||p.length?Wi.apply(e,E):function(e,t,r,n){var i=1&t,s=Ui(e);return function t(){for(var o=-1,a=arguments.length,c=-1,d=n.length,u=we(d+a),l=this&&this!==ut&&this instanceof t?s:e;++c<d;)u[c]=n[c];for(;a--;)u[c++]=arguments[++o];return wt(l,i?r:this,u)}}(r,d,u,l);else var w=function(e,t,r){var n=1&t,i=Ui(e);return function t(){return(this&&this!==ut&&this instanceof t?i:e).apply(n?r:this,arguments)}}(r,d,u);return Ls((b?ri:Os)(w,E),r,d)}function es(t,r,n,i){return t===e||Ho(t,Ne[n])&&!xe.call(i,n)?r:t}function ts(t,r,n,i,s,o){return na(t)&&na(r)&&(o.set(r,t),qn(t,r,e,ts,o),o.delete(r)),t}function rs(t){return aa(t)?e:t}function ns(t,r,n,i,s,o){var a=1&n,c=t.length,d=r.length;if(c!=d&&!(a&&d>c))return!1;var u=o.get(t),l=o.get(r);if(u&&l)return u==r&&l==t;var p=-1,h=!0,f=2&n?new Jr:e;for(o.set(t,r),o.set(r,t);++p<c;){var m=t[p],g=r[p];if(i)var v=a?i(g,m,p,r,t,o):i(m,g,p,t,r,o);if(v!==e){if(v)continue;h=!1;break}if(f){if(!Mt(r,(function(e,t){if(!Kt(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(t),o.delete(r),h}function is(t){return Ms(ks(t,e,Ys),t+"")}function ss(e){return Tn(e,Ma,fs)}function os(e){return Tn(e,La,ms)}var as=Ar?function(e){return Ar.get(e)}:lc;function cs(e){for(var t=e.name+"",r=Or[t],n=xe.call(Or,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(xe.call(Br,"placeholder")?Br:e).placeholder}function us(){var e=Br.iteratee||ac;return e=e===ac?Fn:e,arguments.length?e(arguments[0],arguments[1]):e}function ls(e,t){var r,n,i=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof t?"string":"hash"]:i.map}function ps(e){for(var t=Ma(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Ts(i)]}return t}function hs(t,r){var n=function(t,r){return null==t?e:t[r]}(t,r);return xn(n)?n:e}var fs=fr?function(e){return null==e?[]:(e=Re(e),Rt(fr(e),(function(t){return Qe.call(e,t)})))}:yc,ms=fr?function(e){for(var t=[];e;)At(t,fs(e)),e=Ye(e);return t}:yc,gs=Rn;function vs(e,t,r){for(var n=-1,i=(t=Ei(t,e)).length,s=!1;++n<i;){var o=Us(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)&&bs(o,i)&&(Yo(e)||Go(e))}function ys(e){return"function"!=typeof e.constructor||Ps(e)?{}:Wr(Ye(e))}function _s(e){return Yo(e)||Go(e)||!!(st&&e&&e[st])}function bs(e,t){var r=typeof e;return!!(t=null==t?u:t)&&("number"==r||"symbol"!=r&&ve.test(e))&&e>-1&&e%1==0&&e<t}function Es(e,t,r){if(!na(r))return!1;var n=typeof t;return!!("number"==n?Jo(r)&&bs(t,r.length):"string"==n&&t in r)&&Ho(r[t],e)}function ws(e,t){if(Yo(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!la(e))||X.test(e)||!Z.test(e)||null!=t&&e in Re(t)}function Ss(e){var t=cs(e),r=Br[t];if("function"!=typeof r||!(t in zr.prototype))return!1;if(e===r)return!0;var n=as(r);return!!n&&e===n[0]}(Pr&&gs(new Pr(new ArrayBuffer(1)))!=O||Tr&&gs(new Tr)!=w||Rr&&gs(Rr.resolve())!=P||kr&&gs(new kr)!=R||Dr&&gs(new Dr)!=I)&&(gs=function(t){var r=Rn(t),n=r==C?t.constructor:e,i=n?Vs(n):"";if(i)switch(i){case Nr:return O;case Mr:return w;case Lr:return P;case xr:return R;case Fr:return I}return r});var Cs=Me?ea:_c;function Ps(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Ne)}function Ts(e){return e==e&&!na(e)}function Rs(t,r){return function(n){return null!=n&&n[t]===r&&(r!==e||t in Re(n))}}function ks(t,r,n){return r=_r(r===e?t.length-1:r,0),function(){for(var e=arguments,i=-1,s=_r(e.length-r,0),o=we(s);++i<s;)o[i]=e[r+i];i=-1;for(var a=we(r+1);++i<r;)a[i]=e[i];return a[r]=n(o),wt(t,this,a)}}function Ds(e,t){return t.length<2?e:Pn(e,si(t,0,-1))}function Is(t,r){for(var n=t.length,i=br(r.length,n),s=Ai(t);i--;){var o=r[i];t[i]=bs(o,n)?s[o]:e}return t}function As(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Os=xs(ri),Ns=mt||function(e,t){return ut.setTimeout(e,t)},Ms=xs(ni);function Ls(e,t,r){var n=t+"";return Ms(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(se,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return Ct(f,(function(r){var n="_."+r[0];t&r[1]&&!kt(e,n)&&e.push(n)})),e.sort()}(function(e){var t=e.match(oe);return t?t[1].split(ae):[]}(n),r)))}function xs(t){var r=0,n=0;return function(){var i=Er(),s=16-(i-n);if(n=i,s>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(e,arguments)}}function Fs(t,r){var n=-1,i=t.length,s=i-1;for(r=r===e?i:r;++n<r;){var o=Kn(n,s),a=t[o];t[o]=t[n],t[n]=a}return t.length=r,t}var js=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(ee,(function(e,r,n,i){t.push(n?i.replace(ue,"$1"):r||e)})),t}));function Us(e){if("string"==typeof e||la(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Vs(e){if(null!=e){try{return Le.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Bs(e){if(e instanceof zr)return e.clone();var t=new qr(e.__wrapped__,e.__chain__);return t.__actions__=Ai(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var Ws=Zn((function(e,t){return Ko(e)?hn(e,_n(t,1,Ko,!0)):[]})),Hs=Zn((function(t,r){var n=Zs(r);return Ko(n)&&(n=e),Ko(t)?hn(t,_n(r,1,Ko,!0),us(n,2)):[]})),qs=Zn((function(t,r){var n=Zs(r);return Ko(n)&&(n=e),Ko(t)?hn(t,_n(r,1,Ko,!0),e,n):[]}));function zs(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=_r(n+i,0)),Ft(e,us(t,3),i)}function Gs(t,r,n){var i=null==t?0:t.length;if(!i)return-1;var s=i-1;return n!==e&&(s=va(n),s=n<0?_r(i+s,0):br(s,i-1)),Ft(t,us(r,3),s,!0)}function Ys(e){return null!=e&&e.length?_n(e,1):[]}function $s(t){return t&&t.length?t[0]:e}var Js=Zn((function(e){var t=It(e,_i);return t.length&&t[0]===e[0]?An(t):[]})),Ks=Zn((function(t){var r=Zs(t),n=It(t,_i);return r===Zs(n)?r=e:n.pop(),n.length&&n[0]===t[0]?An(n,us(r,2)):[]})),Qs=Zn((function(t){var r=Zs(t),n=It(t,_i);return(r="function"==typeof r?r:e)&&n.pop(),n.length&&n[0]===t[0]?An(n,e,r):[]}));function Zs(t){var r=null==t?0:t.length;return r?t[r-1]:e}var Xs=Zn(eo);function eo(e,t){return e&&e.length&&t&&t.length?$n(e,t):e}var to=is((function(e,t){var r=null==e?0:e.length,n=cn(e,t);return Jn(e,It(t,(function(e){return bs(e,r)?+e:e})).sort(ki)),n}));function ro(e){return null==e?e:Cr.call(e)}var no=Zn((function(e){return pi(_n(e,1,Ko,!0))})),io=Zn((function(t){var r=Zs(t);return Ko(r)&&(r=e),pi(_n(t,1,Ko,!0),us(r,2))})),so=Zn((function(t){var r=Zs(t);return r="function"==typeof r?r:e,pi(_n(t,1,Ko,!0),e,r)}));function oo(e){if(!e||!e.length)return[];var t=0;return e=Rt(e,(function(e){if(Ko(e))return t=_r(e.length,t),!0})),Gt(t,(function(t){return It(e,Wt(t))}))}function ao(t,r){if(!t||!t.length)return[];var n=oo(t);return null==r?n:It(n,(function(t){return wt(r,e,t)}))}var co=Zn((function(e,t){return Ko(e)?hn(e,t):[]})),uo=Zn((function(e){return vi(Rt(e,Ko))})),lo=Zn((function(t){var r=Zs(t);return Ko(r)&&(r=e),vi(Rt(t,Ko),us(r,2))})),po=Zn((function(t){var r=Zs(t);return r="function"==typeof r?r:e,vi(Rt(t,Ko),e,r)})),ho=Zn(oo),fo=Zn((function(t){var r=t.length,n=r>1?t[r-1]:e;return n="function"==typeof n?(t.pop(),n):e,ao(t,n)}));function mo(e){var t=Br(e);return t.__chain__=!0,t}function go(e,t){return t(e)}var vo=is((function(t){var r=t.length,n=r?t[0]:0,i=this.__wrapped__,s=function(e){return cn(e,t)};return!(r>1||this.__actions__.length)&&i instanceof zr&&bs(n)?((i=i.slice(n,+n+(r?1:0))).__actions__.push({func:go,args:[s],thisArg:e}),new qr(i,this.__chain__).thru((function(t){return r&&!t.length&&t.push(e),t}))):this.thru(s)})),yo=Ni((function(e,t,r){xe.call(e,r)?++e[r]:an(e,r,1)})),_o=Vi(zs),bo=Vi(Gs);function Eo(e,t){return(Yo(e)?Ct:fn)(e,us(t,3))}function wo(e,t){return(Yo(e)?Pt:mn)(e,us(t,3))}var So=Ni((function(e,t,r){xe.call(e,r)?e[r].push(t):an(e,r,[t])})),Co=Zn((function(e,t,r){var n=-1,i="function"==typeof t,s=Jo(e)?we(e.length):[];return fn(e,(function(e){s[++n]=i?wt(t,e,r):On(e,t,r)})),s})),Po=Ni((function(e,t,r){an(e,r,t)}));function To(e,t){return(Yo(e)?It:Bn)(e,us(t,3))}var Ro=Ni((function(e,t,r){e[r?0:1].push(t)}),(function(){return[[],[]]})),ko=Zn((function(e,t){if(null==e)return[];var r=t.length;return r>1&&Es(e,t[0],t[1])?t=[]:r>2&&Es(t[0],t[1],t[2])&&(t=[t[0]]),Gn(e,_n(t,1),[])})),Do=ft||function(){return ut.Date.now()};function Io(t,r,n){return r=n?e:r,r=t&&null==r?t.length:r,Xi(t,a,e,e,e,e,r)}function Ao(r,n){var i;if("function"!=typeof n)throw new Ie(t);return r=va(r),function(){return--r>0&&(i=n.apply(this,arguments)),r<=1&&(n=e),i}}var Oo=Zn((function(e,t,r){var n=1;if(r.length){var i=or(r,ds(Oo));n|=s}return Xi(e,n,t,r,i)})),No=Zn((function(e,t,r){var n=3;if(r.length){var i=or(r,ds(No));n|=s}return Xi(t,n,e,r,i)}));function Mo(r,n,i){var s,o,a,c,d,u,l=0,p=!1,h=!1,f=!0;if("function"!=typeof r)throw new Ie(t);function m(t){var n=s,i=o;return s=o=e,l=t,c=r.apply(i,n)}function g(e){return l=e,d=Ns(y,n),p?m(e):c}function v(t){var r=t-u;return u===e||r>=n||r<0||h&&t-l>=a}function y(){var e=Do();if(v(e))return _(e);d=Ns(y,function(e){var t=n-(e-u);return h?br(t,a-(e-l)):t}(e))}function _(t){return d=e,f&&s?m(t):(s=o=e,c)}function b(){var t=Do(),r=v(t);if(s=arguments,o=this,u=t,r){if(d===e)return g(u);if(h)return Ci(d),d=Ns(y,n),m(u)}return d===e&&(d=Ns(y,n)),c}return n=_a(n)||0,na(i)&&(p=!!i.leading,a=(h="maxWait"in i)?_r(_a(i.maxWait)||0,n):a,f="trailing"in i?!!i.trailing:f),b.cancel=function(){d!==e&&Ci(d),l=0,s=u=o=d=e},b.flush=function(){return d===e?c:_(Do())},b}var Lo=Zn((function(e,t){return pn(e,1,t)})),xo=Zn((function(e,t,r){return pn(e,_a(t)||0,r)}));function Fo(e,r){if("function"!=typeof e||null!=r&&"function"!=typeof r)throw new Ie(t);var n=function(){var t=arguments,i=r?r.apply(this,t):t[0],s=n.cache;if(s.has(i))return s.get(i);var o=e.apply(this,t);return n.cache=s.set(i,o)||s,o};return n.cache=new(Fo.Cache||$r),n}function jo(e){if("function"!=typeof e)throw new Ie(t);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=$r;var Uo=wi((function(e,t){var r=(t=1==t.length&&Yo(t[0])?It(t[0],$t(us())):It(_n(t,1),$t(us()))).length;return Zn((function(n){for(var i=-1,s=br(n.length,r);++i<s;)n[i]=t[i].call(this,n[i]);return wt(e,this,n)}))})),Vo=Zn((function(t,r){var n=or(r,ds(Vo));return Xi(t,s,e,r,n)})),Bo=Zn((function(t,r){var n=or(r,ds(Bo));return Xi(t,o,e,r,n)})),Wo=is((function(t,r){return Xi(t,c,e,e,e,r)}));function Ho(e,t){return e===t||e!=e&&t!=t}var qo=$i(kn),zo=$i((function(e,t){return e>=t})),Go=Nn(function(){return arguments}())?Nn:function(e){return ia(e)&&xe.call(e,"callee")&&!Qe.call(e,"callee")},Yo=we.isArray,$o=gt?$t(gt):function(e){return ia(e)&&Rn(e)==A};function Jo(e){return null!=e&&ra(e.length)&&!ea(e)}function Ko(e){return ia(e)&&Jo(e)}var Qo=mr||_c,Zo=vt?$t(vt):function(e){return ia(e)&&Rn(e)==y};function Xo(e){if(!ia(e))return!1;var t=Rn(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=Rn(e);return t==b||t==E||"[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<=u}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=yt?$t(yt):function(e){return ia(e)&&gs(e)==w};function oa(e){return"number"==typeof e||ia(e)&&Rn(e)==S}function aa(e){if(!ia(e)||Rn(e)!=C)return!1;var t=Ye(e);if(null===t)return!0;var r=xe.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Le.call(r)==Ve}var ca=_t?$t(_t):function(e){return ia(e)&&Rn(e)==T},da=bt?$t(bt):function(e){return ia(e)&&gs(e)==R};function ua(e){return"string"==typeof e||!Yo(e)&&ia(e)&&Rn(e)==k}function la(e){return"symbol"==typeof e||ia(e)&&Rn(e)==D}var pa=Et?$t(Et):function(e){return ia(e)&&ra(e.length)&&!!nt[Rn(e)]},ha=$i(Vn),fa=$i((function(e,t){return e<=t}));function ma(e){if(!e)return[];if(Jo(e))return ua(e)?ur(e):Ai(e);if(ct&&e[ct])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[ct]());var t=gs(e);return(t==w?ir:t==R?ar:Ha)(e)}function ga(e){return e?(e=_a(e))===d||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,h):0}function _a(e){if("number"==typeof e)return e;if(la(e))return p;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=Yt(e);var r=fe.test(e);return r||ge.test(e)?at(e.slice(2),r?2:8):he.test(e)?p:+e}function ba(e){return Oi(e,La(e))}function Ea(e){return null==e?"":li(e)}var wa=Mi((function(e,t){if(Ps(t)||Jo(t))Oi(t,Ma(t),e);else for(var r in t)xe.call(t,r)&&rn(e,r,t[r])})),Sa=Mi((function(e,t){Oi(t,La(t),e)})),Ca=Mi((function(e,t,r,n){Oi(t,La(t),e,n)})),Pa=Mi((function(e,t,r,n){Oi(t,Ma(t),e,n)})),Ta=is(cn),Ra=Zn((function(t,r){t=Re(t);var n=-1,i=r.length,s=i>2?r[2]:e;for(s&&Es(r[0],r[1],s)&&(i=1);++n<i;)for(var o=r[n],a=La(o),c=-1,d=a.length;++c<d;){var u=a[c],l=t[u];(l===e||Ho(l,Ne[u])&&!xe.call(t,u))&&(t[u]=o[u])}return t})),ka=Zn((function(t){return t.push(e,ts),wt(Fa,e,t)}));function Da(t,r,n){var i=null==t?e:Pn(t,r);return i===e?n:i}function Ia(e,t){return null!=e&&vs(e,t,In)}var Aa=Hi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=Ue.call(t)),e[t]=r}),nc(oc)),Oa=Hi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=Ue.call(t)),xe.call(e,t)?e[t].push(r):e[t]=[r]}),us),Na=Zn(On);function Ma(e){return Jo(e)?Qr(e):jn(e)}function La(e){return Jo(e)?Qr(e,!0):Un(e)}var xa=Mi((function(e,t,r){qn(e,t,r)})),Fa=Mi((function(e,t,r,n){qn(e,t,r,n)})),ja=is((function(e,t){var r={};if(null==e)return r;var n=!1;t=It(t,(function(t){return t=Ei(t,e),n||(n=t.length>1),t})),Oi(e,os(e),r),n&&(r=un(r,7,rs));for(var i=t.length;i--;)hi(r,t[i]);return r})),Ua=is((function(e,t){return null==e?{}:function(e,t){return Yn(e,t,(function(t,r){return Ia(e,r)}))}(e,t)}));function Va(e,t){if(null==e)return{};var r=It(os(e),(function(e){return[e]}));return t=us(t),Yn(e,r,(function(e,r){return t(e,r[0])}))}var Ba=Zi(Ma),Wa=Zi(La);function Ha(e){return null==e?[]:Jt(e,Ma(e))}var qa=ji((function(e,t,r){return t=t.toLowerCase(),e+(r?za(t):t)}));function za(e){return Xa(Ea(e).toLowerCase())}function Ga(e){return(e=Ea(e))&&e.replace(ye,er).replace(Ke,"")}var Ya=ji((function(e,t,r){return e+(r?"-":"")+t.toLowerCase()})),$a=ji((function(e,t,r){return e+(r?" ":"")+t.toLowerCase()})),Ja=Fi("toLowerCase"),Ka=ji((function(e,t,r){return e+(r?"_":"")+t.toLowerCase()})),Qa=ji((function(e,t,r){return e+(r?" ":"")+Xa(t)})),Za=ji((function(e,t,r){return e+(r?" ":"")+t.toUpperCase()})),Xa=Fi("toUpperCase");function ec(t,r,n){return t=Ea(t),(r=n?e:r)===e?function(e){return et.test(e)}(t)?function(e){return e.match(Ze)||[]}(t):function(e){return e.match(ce)||[]}(t):t.match(r)||[]}var tc=Zn((function(t,r){try{return wt(t,e,r)}catch(e){return Xo(e)?e:new Ce(e)}})),rc=is((function(e,t){return Ct(t,(function(t){t=Us(t),an(e,t,Oo(e[t],e))})),e}));function nc(e){return function(){return e}}var ic=Bi(),sc=Bi(!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 On(r,e,t)}})),dc=Zn((function(e,t){return function(r){return On(e,r,t)}}));function uc(e,t,r){var n=Ma(t),i=Cn(t,n);null!=r||na(t)&&(i.length||!n.length)||(r=t,t=e,e=this,i=Cn(t,Ma(t)));var s=!(na(r)&&"chain"in r&&!r.chain),o=ea(e);return Ct(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__=Ai(this.__actions__);return i.push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,At([this.value()],arguments))})})),e}function lc(){}var pc=zi(It),hc=zi(Tt),fc=zi(Mt);function mc(e){return ws(e)?Wt(Us(e)):function(e){return function(t){return Pn(t,e)}}(e)}var gc=Yi(),vc=Yi(!0);function yc(){return[]}function _c(){return!1}var bc,Ec=qi((function(e,t){return e+t}),0),wc=Ki("ceil"),Sc=qi((function(e,t){return e/t}),1),Cc=Ki("floor"),Pc=qi((function(e,t){return e*t}),1),Tc=Ki("round"),Rc=qi((function(e,t){return e-t}),0);return Br.after=function(e,r){if("function"!=typeof r)throw new Ie(t);return e=va(e),function(){if(--e<1)return r.apply(this,arguments)}},Br.ary=Io,Br.assign=wa,Br.assignIn=Sa,Br.assignInWith=Ca,Br.assignWith=Pa,Br.at=Ta,Br.before=Ao,Br.bind=Oo,Br.bindAll=rc,Br.bindKey=No,Br.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Yo(e)?e:[e]},Br.chain=mo,Br.chunk=function(t,r,n){r=(n?Es(t,r,n):r===e)?1:_r(va(r),0);var i=null==t?0:t.length;if(!i||r<1)return[];for(var s=0,o=0,a=we(Lt(i/r));s<i;)a[o++]=si(t,s,s+=r);return a},Br.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},Br.concat=function(){var e=arguments.length;if(!e)return[];for(var t=we(e-1),r=arguments[0],n=e;n--;)t[n-1]=arguments[n];return At(Yo(r)?Ai(r):[r],_n(t,1))},Br.cond=function(e){var r=null==e?0:e.length,n=us();return e=r?It(e,(function(e){if("function"!=typeof e[1])throw new Ie(t);return[n(e[0]),e[1]]})):[],Zn((function(t){for(var n=-1;++n<r;){var i=e[n];if(wt(i[0],this,t))return wt(i[1],this,t)}}))},Br.conforms=function(e){return function(e){var t=Ma(e);return function(r){return ln(r,e,t)}}(un(e,1))},Br.constant=nc,Br.countBy=yo,Br.create=function(e,t){var r=Wr(e);return null==t?r:on(r,t)},Br.curry=function t(r,n,i){var s=Xi(r,8,e,e,e,e,e,n=i?e:n);return s.placeholder=t.placeholder,s},Br.curryRight=function t(r,n,s){var o=Xi(r,i,e,e,e,e,e,n=s?e:n);return o.placeholder=t.placeholder,o},Br.debounce=Mo,Br.defaults=Ra,Br.defaultsDeep=ka,Br.defer=Lo,Br.delay=xo,Br.difference=Ws,Br.differenceBy=Hs,Br.differenceWith=qs,Br.drop=function(t,r,n){var i=null==t?0:t.length;return i?si(t,(r=n||r===e?1:va(r))<0?0:r,i):[]},Br.dropRight=function(t,r,n){var i=null==t?0:t.length;return i?si(t,0,(r=i-(r=n||r===e?1:va(r)))<0?0:r):[]},Br.dropRightWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!0,!0):[]},Br.dropWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!0):[]},Br.fill=function(t,r,n,i){var s=null==t?0:t.length;return s?(n&&"number"!=typeof n&&Es(t,r,n)&&(n=0,i=s),function(t,r,n,i){var s=t.length;for((n=va(n))<0&&(n=-n>s?0:s+n),(i=i===e||i>s?s:va(i))<0&&(i+=s),i=n>i?0:ya(i);n<i;)t[n++]=r;return t}(t,r,n,i)):[]},Br.filter=function(e,t){return(Yo(e)?Rt:yn)(e,us(t,3))},Br.flatMap=function(e,t){return _n(To(e,t),1)},Br.flatMapDeep=function(e,t){return _n(To(e,t),d)},Br.flatMapDepth=function(t,r,n){return n=n===e?1:va(n),_n(To(t,r),n)},Br.flatten=Ys,Br.flattenDeep=function(e){return null!=e&&e.length?_n(e,d):[]},Br.flattenDepth=function(t,r){return null!=t&&t.length?_n(t,r=r===e?1:va(r)):[]},Br.flip=function(e){return Xi(e,512)},Br.flow=ic,Br.flowRight=sc,Br.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},Br.functions=function(e){return null==e?[]:Cn(e,Ma(e))},Br.functionsIn=function(e){return null==e?[]:Cn(e,La(e))},Br.groupBy=So,Br.initial=function(e){return null!=e&&e.length?si(e,0,-1):[]},Br.intersection=Js,Br.intersectionBy=Ks,Br.intersectionWith=Qs,Br.invert=Aa,Br.invertBy=Oa,Br.invokeMap=Co,Br.iteratee=ac,Br.keyBy=Po,Br.keys=Ma,Br.keysIn=La,Br.map=To,Br.mapKeys=function(e,t){var r={};return t=us(t,3),wn(e,(function(e,n,i){an(r,t(e,n,i),e)})),r},Br.mapValues=function(e,t){var r={};return t=us(t,3),wn(e,(function(e,n,i){an(r,n,t(e,n,i))})),r},Br.matches=function(e){return Wn(un(e,1))},Br.matchesProperty=function(e,t){return Hn(e,un(t,1))},Br.memoize=Fo,Br.merge=xa,Br.mergeWith=Fa,Br.method=cc,Br.methodOf=dc,Br.mixin=uc,Br.negate=jo,Br.nthArg=function(e){return e=va(e),Zn((function(t){return zn(t,e)}))},Br.omit=ja,Br.omitBy=function(e,t){return Va(e,jo(us(t)))},Br.once=function(e){return Ao(2,e)},Br.orderBy=function(t,r,n,i){return null==t?[]:(Yo(r)||(r=null==r?[]:[r]),Yo(n=i?e:n)||(n=null==n?[]:[n]),Gn(t,r,n))},Br.over=pc,Br.overArgs=Uo,Br.overEvery=hc,Br.overSome=fc,Br.partial=Vo,Br.partialRight=Bo,Br.partition=Ro,Br.pick=Ua,Br.pickBy=Va,Br.property=mc,Br.propertyOf=function(t){return function(r){return null==t?e:Pn(t,r)}},Br.pull=Xs,Br.pullAll=eo,Br.pullAllBy=function(e,t,r){return e&&e.length&&t&&t.length?$n(e,t,us(r,2)):e},Br.pullAllWith=function(t,r,n){return t&&t.length&&r&&r.length?$n(t,r,e,n):t},Br.pullAt=to,Br.range=gc,Br.rangeRight=vc,Br.rearg=Wo,Br.reject=function(e,t){return(Yo(e)?Rt:yn)(e,jo(us(t,3)))},Br.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},Br.rest=function(r,n){if("function"!=typeof r)throw new Ie(t);return Zn(r,n=n===e?n:va(n))},Br.reverse=ro,Br.sampleSize=function(t,r,n){return r=(n?Es(t,r,n):r===e)?1:va(r),(Yo(t)?Xr:ei)(t,r)},Br.set=function(e,t,r){return null==e?e:ti(e,t,r)},Br.setWith=function(t,r,n,i){return i="function"==typeof i?i:e,null==t?t:ti(t,r,n,i)},Br.shuffle=function(e){return(Yo(e)?en:ii)(e)},Br.slice=function(t,r,n){var i=null==t?0:t.length;return i?(n&&"number"!=typeof n&&Es(t,r,n)?(r=0,n=i):(r=null==r?0:va(r),n=n===e?i:va(n)),si(t,r,n)):[]},Br.sortBy=ko,Br.sortedUniq=function(e){return e&&e.length?di(e):[]},Br.sortedUniqBy=function(e,t){return e&&e.length?di(e,us(t,2)):[]},Br.split=function(t,r,n){return n&&"number"!=typeof n&&Es(t,r,n)&&(r=n=e),(n=n===e?h:n>>>0)?(t=Ea(t))&&("string"==typeof r||null!=r&&!ca(r))&&!(r=li(r))&&nr(t)?Si(ur(t),0,n):t.split(r,n):[]},Br.spread=function(e,r){if("function"!=typeof e)throw new Ie(t);return r=null==r?0:_r(va(r),0),Zn((function(t){var n=t[r],i=Si(t,0,r);return n&&At(i,n),wt(e,this,i)}))},Br.tail=function(e){var t=null==e?0:e.length;return t?si(e,1,t):[]},Br.take=function(t,r,n){return t&&t.length?si(t,0,(r=n||r===e?1:va(r))<0?0:r):[]},Br.takeRight=function(t,r,n){var i=null==t?0:t.length;return i?si(t,(r=i-(r=n||r===e?1:va(r)))<0?0:r,i):[]},Br.takeRightWhile=function(e,t){return e&&e.length?mi(e,us(t,3),!1,!0):[]},Br.takeWhile=function(e,t){return e&&e.length?mi(e,us(t,3)):[]},Br.tap=function(e,t){return t(e),e},Br.throttle=function(e,r,n){var i=!0,s=!0;if("function"!=typeof e)throw new Ie(t);return na(n)&&(i="leading"in n?!!n.leading:i,s="trailing"in n?!!n.trailing:s),Mo(e,r,{leading:i,maxWait:r,trailing:s})},Br.thru=go,Br.toArray=ma,Br.toPairs=Ba,Br.toPairsIn=Wa,Br.toPath=function(e){return Yo(e)?It(e,Us):la(e)?[e]:Ai(js(Ea(e)))},Br.toPlainObject=ba,Br.transform=function(e,t,r){var n=Yo(e),i=n||Qo(e)||pa(e);if(t=us(t,4),null==r){var s=e&&e.constructor;r=i?n?new s:[]:na(e)&&ea(s)?Wr(Ye(e)):{}}return(i?Ct:wn)(e,(function(e,n,i){return t(r,e,n,i)})),r},Br.unary=function(e){return Io(e,1)},Br.union=no,Br.unionBy=io,Br.unionWith=so,Br.uniq=function(e){return e&&e.length?pi(e):[]},Br.uniqBy=function(e,t){return e&&e.length?pi(e,us(t,2)):[]},Br.uniqWith=function(t,r){return r="function"==typeof r?r:e,t&&t.length?pi(t,e,r):[]},Br.unset=function(e,t){return null==e||hi(e,t)},Br.unzip=oo,Br.unzipWith=ao,Br.update=function(e,t,r){return null==e?e:fi(e,t,bi(r))},Br.updateWith=function(t,r,n,i){return i="function"==typeof i?i:e,null==t?t:fi(t,r,bi(n),i)},Br.values=Ha,Br.valuesIn=function(e){return null==e?[]:Jt(e,La(e))},Br.without=co,Br.words=ec,Br.wrap=function(e,t){return Vo(bi(t),e)},Br.xor=uo,Br.xorBy=lo,Br.xorWith=po,Br.zip=ho,Br.zipObject=function(e,t){return yi(e||[],t||[],rn)},Br.zipObjectDeep=function(e,t){return yi(e||[],t||[],ti)},Br.zipWith=fo,Br.entries=Ba,Br.entriesIn=Wa,Br.extend=Sa,Br.extendWith=Ca,uc(Br,Br),Br.add=Ec,Br.attempt=tc,Br.camelCase=qa,Br.capitalize=za,Br.ceil=wc,Br.clamp=function(t,r,n){return n===e&&(n=r,r=e),n!==e&&(n=(n=_a(n))==n?n:0),r!==e&&(r=(r=_a(r))==r?r:0),dn(_a(t),r,n)},Br.clone=function(e){return un(e,4)},Br.cloneDeep=function(e){return un(e,5)},Br.cloneDeepWith=function(t,r){return un(t,5,r="function"==typeof r?r:e)},Br.cloneWith=function(t,r){return un(t,4,r="function"==typeof r?r:e)},Br.conformsTo=function(e,t){return null==t||ln(e,t,Ma(t))},Br.deburr=Ga,Br.defaultTo=function(e,t){return null==e||e!=e?t:e},Br.divide=Sc,Br.endsWith=function(t,r,n){t=Ea(t),r=li(r);var i=t.length,s=n=n===e?i:dn(va(n),0,i);return(n-=r.length)>=0&&t.slice(n,s)==r},Br.eq=Ho,Br.escape=function(e){return(e=Ea(e))&&$.test(e)?e.replace(G,tr):e},Br.escapeRegExp=function(e){return(e=Ea(e))&&re.test(e)?e.replace(te,"\\$&"):e},Br.every=function(t,r,n){var i=Yo(t)?Tt:gn;return n&&Es(t,r,n)&&(r=e),i(t,us(r,3))},Br.find=_o,Br.findIndex=zs,Br.findKey=function(e,t){return xt(e,us(t,3),wn)},Br.findLast=bo,Br.findLastIndex=Gs,Br.findLastKey=function(e,t){return xt(e,us(t,3),Sn)},Br.floor=Cc,Br.forEach=Eo,Br.forEachRight=wo,Br.forIn=function(e,t){return null==e?e:bn(e,us(t,3),La)},Br.forInRight=function(e,t){return null==e?e:En(e,us(t,3),La)},Br.forOwn=function(e,t){return e&&wn(e,us(t,3))},Br.forOwnRight=function(e,t){return e&&Sn(e,us(t,3))},Br.get=Da,Br.gt=qo,Br.gte=zo,Br.has=function(e,t){return null!=e&&vs(e,t,Dn)},Br.hasIn=Ia,Br.head=$s,Br.identity=oc,Br.includes=function(e,t,r,n){e=Jo(e)?e:Ha(e),r=r&&!n?va(r):0;var i=e.length;return r<0&&(r=_r(i+r,0)),ua(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&jt(e,t,r)>-1},Br.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=_r(n+i,0)),jt(e,t,i)},Br.inRange=function(t,r,n){return r=ga(r),n===e?(n=r,r=0):n=ga(n),function(e,t,r){return e>=br(t,r)&&e<_r(t,r)}(t=_a(t),r,n)},Br.invoke=Na,Br.isArguments=Go,Br.isArray=Yo,Br.isArrayBuffer=$o,Br.isArrayLike=Jo,Br.isArrayLikeObject=Ko,Br.isBoolean=function(e){return!0===e||!1===e||ia(e)&&Rn(e)==v},Br.isBuffer=Qo,Br.isDate=Zo,Br.isElement=function(e){return ia(e)&&1===e.nodeType&&!aa(e)},Br.isEmpty=function(e){if(null==e)return!0;if(Jo(e)&&(Yo(e)||"string"==typeof e||"function"==typeof e.splice||Qo(e)||pa(e)||Go(e)))return!e.length;var t=gs(e);if(t==w||t==R)return!e.size;if(Ps(e))return!jn(e).length;for(var r in e)if(xe.call(e,r))return!1;return!0},Br.isEqual=function(e,t){return Mn(e,t)},Br.isEqualWith=function(t,r,n){var i=(n="function"==typeof n?n:e)?n(t,r):e;return i===e?Mn(t,r,e,n):!!i},Br.isError=Xo,Br.isFinite=function(e){return"number"==typeof e&&gr(e)},Br.isFunction=ea,Br.isInteger=ta,Br.isLength=ra,Br.isMap=sa,Br.isMatch=function(e,t){return e===t||Ln(e,t,ps(t))},Br.isMatchWith=function(t,r,n){return n="function"==typeof n?n:e,Ln(t,r,ps(r),n)},Br.isNaN=function(e){return oa(e)&&e!=+e},Br.isNative=function(e){if(Cs(e))throw new Ce("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return xn(e)},Br.isNil=function(e){return null==e},Br.isNull=function(e){return null===e},Br.isNumber=oa,Br.isObject=na,Br.isObjectLike=ia,Br.isPlainObject=aa,Br.isRegExp=ca,Br.isSafeInteger=function(e){return ta(e)&&e>=-9007199254740991&&e<=u},Br.isSet=da,Br.isString=ua,Br.isSymbol=la,Br.isTypedArray=pa,Br.isUndefined=function(t){return t===e},Br.isWeakMap=function(e){return ia(e)&&gs(e)==I},Br.isWeakSet=function(e){return ia(e)&&"[object WeakSet]"==Rn(e)},Br.join=function(e,t){return null==e?"":vr.call(e,t)},Br.kebabCase=Ya,Br.last=Zs,Br.lastIndexOf=function(t,r,n){var i=null==t?0:t.length;if(!i)return-1;var s=i;return n!==e&&(s=(s=va(n))<0?_r(i+s,0):br(s,i-1)),r==r?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(t,r,s):Ft(t,Vt,s,!0)},Br.lowerCase=$a,Br.lowerFirst=Ja,Br.lt=ha,Br.lte=fa,Br.max=function(t){return t&&t.length?vn(t,oc,kn):e},Br.maxBy=function(t,r){return t&&t.length?vn(t,us(r,2),kn):e},Br.mean=function(e){return Bt(e,oc)},Br.meanBy=function(e,t){return Bt(e,us(t,2))},Br.min=function(t){return t&&t.length?vn(t,oc,Vn):e},Br.minBy=function(t,r){return t&&t.length?vn(t,us(r,2),Vn):e},Br.stubArray=yc,Br.stubFalse=_c,Br.stubObject=function(){return{}},Br.stubString=function(){return""},Br.stubTrue=function(){return!0},Br.multiply=Pc,Br.nth=function(t,r){return t&&t.length?zn(t,va(r)):e},Br.noConflict=function(){return ut._===this&&(ut._=Be),this},Br.noop=lc,Br.now=Do,Br.pad=function(e,t,r){e=Ea(e);var n=(t=va(t))?dr(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return Gi(Ht(i),r)+e+Gi(Lt(i),r)},Br.padEnd=function(e,t,r){e=Ea(e);var n=(t=va(t))?dr(e):0;return t&&n<t?e+Gi(t-n,r):e},Br.padStart=function(e,t,r){e=Ea(e);var n=(t=va(t))?dr(e):0;return t&&n<t?Gi(t-n,r)+e:e},Br.parseInt=function(e,t,r){return r||null==t?t=0:t&&(t=+t),wr(Ea(e).replace(ne,""),t||0)},Br.random=function(t,r,n){if(n&&"boolean"!=typeof n&&Es(t,r,n)&&(r=n=e),n===e&&("boolean"==typeof r?(n=r,r=e):"boolean"==typeof t&&(n=t,t=e)),t===e&&r===e?(t=0,r=1):(t=ga(t),r===e?(r=t,t=0):r=ga(r)),t>r){var i=t;t=r,r=i}if(n||t%1||r%1){var s=Sr();return br(t+s*(r-t+ot("1e-"+((s+"").length-1))),r)}return Kn(t,r)},Br.reduce=function(e,t,r){var n=Yo(e)?Ot:qt,i=arguments.length<3;return n(e,us(t,4),r,i,fn)},Br.reduceRight=function(e,t,r){var n=Yo(e)?Nt:qt,i=arguments.length<3;return n(e,us(t,4),r,i,mn)},Br.repeat=function(t,r,n){return r=(n?Es(t,r,n):r===e)?1:va(r),Qn(Ea(t),r)},Br.replace=function(){var e=arguments,t=Ea(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Br.result=function(t,r,n){var i=-1,s=(r=Ei(r,t)).length;for(s||(s=1,t=e);++i<s;){var o=null==t?e:t[Us(r[i])];o===e&&(i=s,o=n),t=ea(o)?o.call(t):o}return t},Br.round=Tc,Br.runInContext=l,Br.sample=function(e){return(Yo(e)?Zr:Xn)(e)},Br.size=function(e){if(null==e)return 0;if(Jo(e))return ua(e)?dr(e):e.length;var t=gs(e);return t==w||t==R?e.size:jn(e).length},Br.snakeCase=Ka,Br.some=function(t,r,n){var i=Yo(t)?Mt:oi;return n&&Es(t,r,n)&&(r=e),i(t,us(r,3))},Br.sortedIndex=function(e,t){return ai(e,t)},Br.sortedIndexBy=function(e,t,r){return ci(e,t,us(r,2))},Br.sortedIndexOf=function(e,t){var r=null==e?0:e.length;if(r){var n=ai(e,t);if(n<r&&Ho(e[n],t))return n}return-1},Br.sortedLastIndex=function(e,t){return ai(e,t,!0)},Br.sortedLastIndexBy=function(e,t,r){return ci(e,t,us(r,2),!0)},Br.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var r=ai(e,t,!0)-1;if(Ho(e[r],t))return r}return-1},Br.startCase=Qa,Br.startsWith=function(e,t,r){return e=Ea(e),r=null==r?0:dn(va(r),0,e.length),t=li(t),e.slice(r,r+t.length)==t},Br.subtract=Rc,Br.sum=function(e){return e&&e.length?zt(e,oc):0},Br.sumBy=function(e,t){return e&&e.length?zt(e,us(t,2)):0},Br.template=function(t,r,n){var i=Br.templateSettings;n&&Es(t,r,n)&&(r=e),t=Ea(t),r=Ca({},r,i,es);var s,o,a=Ca({},r.imports,i.imports,es),c=Ma(a),d=Jt(a,c),u=0,l=r.interpolate||_e,p="__p += '",h=ke((r.escape||_e).source+"|"+l.source+"|"+(l===Q?le:_e).source+"|"+(r.evaluate||_e).source+"|$","g"),f="//# sourceURL="+(xe.call(r,"sourceURL")?(r.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++rt+"]")+"\n";t.replace(h,(function(e,r,n,i,a,c){return n||(n=i),p+=t.slice(u,c).replace(be,rr),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+e.length,e})),p+="';\n";var m=xe.call(r,"variable")&&r.variable;if(m){if(de.test(m))throw new Ce("Invalid `variable` option passed into `_.template`")}else p="with (obj) {\n"+p+"\n}\n";p=(o?p.replace(W,""):p).replace(H,"$1").replace(q,"$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 Pe(c,f+"return "+p).apply(e,d)}));if(g.source=p,Xo(g))throw g;return g},Br.times=function(e,t){if((e=va(e))<1||e>u)return[];var r=h,n=br(e,h);t=us(t),e-=h;for(var i=Gt(n,t);++r<e;)t(r);return i},Br.toFinite=ga,Br.toInteger=va,Br.toLength=ya,Br.toLower=function(e){return Ea(e).toLowerCase()},Br.toNumber=_a,Br.toSafeInteger=function(e){return e?dn(va(e),-9007199254740991,u):0===e?e:0},Br.toString=Ea,Br.toUpper=function(e){return Ea(e).toUpperCase()},Br.trim=function(t,r,n){if((t=Ea(t))&&(n||r===e))return Yt(t);if(!t||!(r=li(r)))return t;var i=ur(t),s=ur(r);return Si(i,Qt(i,s),Zt(i,s)+1).join("")},Br.trimEnd=function(t,r,n){if((t=Ea(t))&&(n||r===e))return t.slice(0,lr(t)+1);if(!t||!(r=li(r)))return t;var i=ur(t);return Si(i,0,Zt(i,ur(r))+1).join("")},Br.trimStart=function(t,r,n){if((t=Ea(t))&&(n||r===e))return t.replace(ne,"");if(!t||!(r=li(r)))return t;var i=ur(t);return Si(i,Qt(i,ur(r))).join("")},Br.truncate=function(t,r){var n=30,i="...";if(na(r)){var s="separator"in r?r.separator:s;n="length"in r?va(r.length):n,i="omission"in r?li(r.omission):i}var o=(t=Ea(t)).length;if(nr(t)){var a=ur(t);o=a.length}if(n>=o)return t;var c=n-dr(i);if(c<1)return i;var d=a?Si(a,0,c).join(""):t.slice(0,c);if(s===e)return d+i;if(a&&(c+=d.length-c),ca(s)){if(t.slice(c).search(s)){var u,l=d;for(s.global||(s=ke(s.source,Ea(pe.exec(s))+"g")),s.lastIndex=0;u=s.exec(l);)var p=u.index;d=d.slice(0,p===e?c:p)}}else if(t.indexOf(li(s),c)!=c){var h=d.lastIndexOf(s);h>-1&&(d=d.slice(0,h))}return d+i},Br.unescape=function(e){return(e=Ea(e))&&Y.test(e)?e.replace(z,pr):e},Br.uniqueId=function(e){var t=++Fe;return Ea(e)+t},Br.upperCase=Za,Br.upperFirst=Xa,Br.each=Eo,Br.eachRight=wo,Br.first=$s,uc(Br,(bc={},wn(Br,(function(e,t){xe.call(Br.prototype,t)||(bc[t]=e)})),bc),{chain:!1}),Br.VERSION="4.17.21",Ct(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Br[e].placeholder=Br})),Ct(["drop","take"],(function(t,r){zr.prototype[t]=function(n){n=n===e?1:_r(va(n),0);var i=this.__filtered__&&!r?new zr(this):this.clone();return i.__filtered__?i.__takeCount__=br(n,i.__takeCount__):i.__views__.push({size:br(n,h),type:t+(i.__dir__<0?"Right":"")}),i},zr.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),Ct(["filter","map","takeWhile"],(function(e,t){var r=t+1,n=1==r||3==r;zr.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:us(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}})),Ct(["head","last"],(function(e,t){var r="take"+(t?"Right":"");zr.prototype[e]=function(){return this[r](1).value()[0]}})),Ct(["initial","tail"],(function(e,t){var r="drop"+(t?"":"Right");zr.prototype[e]=function(){return this.__filtered__?new zr(this):this[r](1)}})),zr.prototype.compact=function(){return this.filter(oc)},zr.prototype.find=function(e){return this.filter(e).head()},zr.prototype.findLast=function(e){return this.reverse().find(e)},zr.prototype.invokeMap=Zn((function(e,t){return"function"==typeof e?new zr(this):this.map((function(r){return On(r,e,t)}))})),zr.prototype.reject=function(e){return this.filter(jo(us(e)))},zr.prototype.slice=function(t,r){t=va(t);var n=this;return n.__filtered__&&(t>0||r<0)?new zr(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),r!==e&&(n=(r=va(r))<0?n.dropRight(-r):n.take(r-t)),n)},zr.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},zr.prototype.toArray=function(){return this.take(h)},wn(zr.prototype,(function(t,r){var n=/^(?:filter|find|map|reject)|While$/.test(r),i=/^(?:head|last)$/.test(r),s=Br[i?"take"+("last"==r?"Right":""):r],o=i||/^find/.test(r);s&&(Br.prototype[r]=function(){var r=this.__wrapped__,a=i?[1]:arguments,c=r instanceof zr,d=a[0],u=c||Yo(r),l=function(e){var t=s.apply(Br,At([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){r=m?r:new zr(this);var g=t.apply(r,a);return g.__actions__.push({func:go,args:[l],thisArg:e}),new qr(g,p)}return f&&m?t.apply(this,a):(g=this.thru(l),f?i?g.value()[0]:g.value():g)})})),Ct(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ae[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);Br.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(Yo(i)?i:[],e)}return this[r]((function(r){return t.apply(Yo(r)?r:[],e)}))}})),wn(zr.prototype,(function(e,t){var r=Br[t];if(r){var n=r.name+"";xe.call(Or,n)||(Or[n]=[]),Or[n].push({name:t,func:r})}})),Or[Wi(e,2).name]=[{name:"wrapper",func:e}],zr.prototype.clone=function(){var e=new zr(this.__wrapped__);return e.__actions__=Ai(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ai(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ai(this.__views__),e},zr.prototype.reverse=function(){if(this.__filtered__){var e=new zr(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},zr.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=Yo(e),n=t<0,i=r?e.length:0,s=function(e,t,r){for(var n=-1,i=r.length;++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=br(t,e+o);break;case"takeRight":e=_r(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=br(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,_=v.type,b=y(g);if(2==_)g=b;else if(!b){if(1==_)continue e;break e}}f[p++]=g}return f},Br.prototype.at=vo,Br.prototype.chain=function(){return mo(this)},Br.prototype.commit=function(){return new qr(this.value(),this.__chain__)},Br.prototype.next=function(){this.__values__===e&&(this.__values__=ma(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?e:this.__values__[this.__index__++]}},Br.prototype.plant=function(t){for(var r,n=this;n instanceof Hr;){var i=Bs(n);i.__index__=0,i.__values__=e,r?s.__wrapped__=i:r=i;var s=i;n=n.__wrapped__}return s.__wrapped__=t,r},Br.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof zr){var r=t;return this.__actions__.length&&(r=new zr(this)),(r=r.reverse()).__actions__.push({func:go,args:[ro],thisArg:e}),new qr(r,this.__chain__)}return this.thru(ro)},Br.prototype.toJSON=Br.prototype.valueOf=Br.prototype.value=function(){return gi(this.__wrapped__,this.__actions__)},Br.prototype.first=Br.prototype.head,ct&&(Br.prototype[ct]=function(){return this}),Br}();pt?((pt.exports=hr)._=hr,lt._=hr):ut._=hr}.call(l);var Db,Ib=l&&l.__extends||(Db=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}Db(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(Rb,"__esModule",{value:!0});var Ab,Ob,Nb,Mb,Lb,xb,Fb,jb,Ub=kb.exports,Vb=["MaxBatchSize","MaxDelay","MinDelay"],Bb=function(e){function t(t){var r=e.call(this)||this;return r.fifo=[],r.firstBatch=!0,function(e){if(Vb.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=Ub.debounce(r.releaseBatch.bind(r),r.options.MaxDelay,{maxWait:r.options.MaxDelay}),r.releaseBatchDebouncedMin=Ub.debounce(r.releaseBatch.bind(r),r.options.MinDelay,{maxWait:r.options.MinDelay}),r}return Ib(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);Rb.MessageBatcher=Bb,function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(Rb)}(Tb),function(e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}(Tb)}(Pb);class Wb{constructor(e){Ab.add(this),Ob.set(this,void 0),Nb.set(this,void 0),Mb.set(this,void 0),Lb.set(this,void 0),xb.set(this,void 0);const{logLevel:t,namespace:r,onLogMessage:n}=e;d(this,Ob,r,"f"),d(this,Nb,t,"f"),this.onLogMessage=n,d(this,Lb,new lb,"f"),d(this,Mb,new Pb.MessageBatcher({MaxBatchSize:50,MaxDelay:1e3,MinDelay:500}),"f"),d(this,xb,e.sendAnalytics,"f"),c(this,Mb,"f").on("batch",(e=>{this.logToApi(e).catch((e=>{this.error("Failed to log to api",{case:"Logger",error:Ct(e)})}))})),this._debug=Cb("LiveDigital").extend("debug").extend(c(this,Ob,"f")),this._info=Cb("LiveDigital").extend("info").extend(c(this,Ob,"f")),this._warn=Cb("LiveDigital").extend("warn").extend(c(this,Ob,"f")),this._error=Cb("LiveDigital").extend("error").extend(c(this,Ob,"f")),this._debug.log=console.info.bind(console),this._info.log=console.info.bind(console),this._warn.log=console.warn.bind(console),this._error.log=console.error.bind(console)}debug(e,t){this._debug(e,t),c(this,xb,"f")&&c(this,Mb,"f").Queue({level:"debug",message:e,meta:t}),c(this,Nb,"f")>=ht&&c(this,Ab,"m",Fb).call(this,"debug",e,t)}info(e,t){this._info(e,t),c(this,xb,"f")&&c(this,Mb,"f").Queue({level:"info",message:e,meta:t}),c(this,Nb,"f")>=pt&&c(this,Ab,"m",Fb).call(this,"info",e,t)}warn(e,t){this._warn(e,t),c(this,xb,"f")&&c(this,Mb,"f").Queue({level:"warn",message:e,meta:t}),c(this,Nb,"f")>=lt&&c(this,Ab,"m",Fb).call(this,"warn",e,t)}error(e,t){this._error(e,t),c(this,xb,"f")&&c(this,Mb,"f").Queue({level:"error",message:e,meta:t}),c(this,Nb,"f")>=ut&&c(this,Ab,"m",Fb).call(this,"error",e,t)}logToApi(e){return a(this,void 0,void 0,(function*(){try{yield c(this,Lb,"f").log.batch({logs:e.map((e=>c(this,Ab,"m",jb).call(this,Object.assign(Object.assign({},e),{meta:this.prepareRecordMeta(e.meta)})))),clientMeta:this.getClientMeta()})}catch(e){this._debug("Log request was not successful",{error:e})}}))}getClientMeta(){return Object.assign(Object.assign({},fr.meta),{clUId:ab()})}prepareRecordMeta(e){const t=null!=e?e:{},{error:r}=t;return Object.assign(Object.assign(Object.assign({},t),{clientTimestamp:(new Date).toISOString(),from_sdk:!0}),r&&"object"==typeof r?{error:Ct(r)}:{})}}Ob=new WeakMap,Nb=new WeakMap,Mb=new WeakMap,Lb=new WeakMap,xb=new WeakMap,Ab=new WeakSet,Fb=function(e,t,...r){"function"==typeof this.onLogMessage&&this.onLogMessage(t,...c(this,Ab,"m",jb).call(this,r),e)},jb=function(e){const t=new WeakMap;return function e(r,n=[]){if(!En(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 Hb=class{constructor(e){this.peerTrackFactory=e,this.tracksByConsumerId=new Map}register(e,t){this.tracksByConsumerId.set(e,t)}get(e){return this.tracksByConsumerId.get(e)}delete(e){return this.tracksByConsumerId.delete(e)}reset(){this.tracksByConsumerId.clear()}create(e){const{consumer:t,label:r,muted:n=!1,mediaStreamTrack:i,paused:s,peerEventEmitter:o}=e,a=this.peerTrackFactory({consumer:t,label:r,mediaStreamTrack:i,paused:s,peerEventEmitter:o,muted:n,onClose:()=>{void 0!==a.consumerId&&this.delete(a.consumerId)}});return void 0!==a.consumerId&&this.register(a.consumerId,a),a}};var qb,zb,Gb;Hb=i([at(),s(0,dt(On.PeerTrackFactory)),o("design:paramtypes",[Function])],Hb);const Yb=["frozen-video-track","network-media-sync-failure","encoder-cpu-throttling","decoder-cpu-throttling","missing-video-stream-data","missing-audio-stream-data"];let $b=class{constructor(e,t,r,n,i){this.analyticsApiClient=e,this.peers=t,this.myPeer=r,this.transportsStatsProvider=i,qb.set(this,void 0),zb.set(this,void 0),Gb.set(this,void 0),d(this,Gb,n("IntegrationsService"),"f"),d(this,zb,new Pb.MessageBatcher({MaxBatchSize:50,MaxDelay:6e4,MinDelay:3e4}),"f"),c(this,zb,"f").on("batch",(e=>{this.analyticsApiClient.metrics.sendWIDMetrics({reasons:e,clientMeta:this.getClientMeta()}).catch((e=>{c(this,Gb,"f").debug("Failed to sendWIDMetrics",{error:Ct(e)})}))})),d(this,qb,new Pb.MessageBatcher({MaxBatchSize:100,MaxDelay:6e4,MinDelay:3e4}),"f"),c(this,qb,"f").on("batch",(e=>{this.analyticsApiClient.metrics.sendNetworkMetrics({metrics:e,clientMeta:this.getClientMeta()}).catch((e=>{c(this,Gb,"f").debug("Failed to sendNetworkMetrics",{error:Ct(e)})}))}))}handleIssues(e){e.forEach((e=>c(this,Gb,"f").info("WebRTCIssue",e)));const t=e.filter((e=>Yb.includes(e.reason)));0!==t.length&&t.forEach((e=>c(this,zb,"f").Queue(e.reason)))}handleNetworkScores(e){var t,r,n,i,s,o;const{inbound:a,outbound:d,statsSamples:{inboundStatsSample:u,outboundStatsSample:l}}=e,p=this.getNodeActiveStreamsStat(),h=this.transportsStatsProvider.getStats();if(void 0!==a&&u){const e={jitter:Math.round(u.avgJitter),packetLoss:u.packetsLoss,rtt:u.rtt,mos:Math.round(10*a)/10,streams:p.inboundActiveStreams,direction:"inbound",node:null!==(t=fr.meta.datacenterName)&&void 0!==t?t:"unknown node",bitrate:null!==(n=null===(r=null==h?void 0:h.inbound)||void 0===r?void 0:r.bitrate)&&void 0!==n?n:0,timestamp:(new Date).toISOString()};c(this,qb,"f").Queue(e)}if(void 0!==d&&l){const e={jitter:Math.round(l.avgJitter),packetLoss:l.packetsLoss,rtt:l.rtt,mos:Math.round(10*d)/10,streams:p.outboundActiveStreams,direction:"outbound",node:null!==(i=fr.meta.datacenterName)&&void 0!==i?i:"unknown node",bitrate:null!==(o=null===(s=null==h?void 0:h.outbound)||void 0===s?void 0:s.bitrate)&&void 0!==o?o:0,timestamp:(new Date).toISOString()};c(this,qb,"f").Queue(e)}}getNodeActiveStreamsStat(){var e;const 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{inboundActiveStreams:t,outboundActiveStreams:null!==(e=null==r?void 0:r.getActivePublishersCount())&&void 0!==e?e:0}}getClientMeta(){return Object.assign(Object.assign({},fr.meta),{clientUniqueId:ab()})}};qb=new WeakMap,zb=new WeakMap,Gb=new WeakMap,$b=i([at(),s(0,dt(On.AnalyticsApiClient)),s(1,dt(On.Peers)),s(2,dt(On.MyPeer)),s(3,dt(On.LoggerFactory)),s(4,dt(On.TransportsStatsProvider)),o("design:paramtypes",[lb,Object,ws,Function,Nv])],$b);var Jb,Kb,Qb,Zb,Xb,eE,tE,rE,nE,iE=$b;!function(e){e.INFO="info",e.WARNING="warning",e.ERROR="error"}(tE||(tE={})),function(e){e[e.PERFORMANCE_STOP=1001]="PERFORMANCE_STOP",e[e.REDUCE_LATENCY=1002]="REDUCE_LATENCY"}(rE||(rE={})),function(e){e.ATSVB="atsvb",e.STREAM_PROCESSOR="stream_processor",e.ML_INFERENCE="ml_inference",e.MODEL="model",e.WORKLET="worklet",e.WORKER="worker",e.MODEL_LOADER="model_loader"}(nE||(nE={}));const sE=()=>{};class oE{constructor(e){Jb.set(this,void 0),Kb.set(this,void 0),Qb.set(this,null),Zb.set(this,new Map),Xb.set(this,void 0),this.type="asdk",eE.set(this,void 0);const{loggerFactory:t}=e;d(this,Kb,t("ASDKTrackProcessor"),"f"),d(this,eE,"function"==typeof e.onError?e.onError:sE,"f"),d(this,Jb,new window.atsvb(e.asdkCustomerId),"f");const n=e.config.get("staticFilesPath"),{localDir:i,version:s,sdk_url:o,api_url:a}=e.config.get("asdk");let u=`https://effectssdk.ai/sdk/audio/dev/${null!=s?s:"2.4.3"}`;if(i){u=new r(`${i}/${null!=s?s:"2.4.3"}`,n).href}const l={preset:"balanced",sample_rate:48e3,api_url:a,wasmPaths:{"ort-wasm.wasm":`${u}/ort-wasm.wasm`,"ort-wasm-simd.wasm":`${u}/ort-wasm-simd.wasm`}},p=!o&&i,h=p?`${u}/`:o;p&&c(this,Kb,"f").warn("Using static ASDK path due to missing config",Object.assign(Object.assign({case:"Denoiser",type:"asdk"},e.config.get("asdk")),{sdkUrl:l.sdk_url})),h&&(l.sdk_url=h),c(this,Jb,"f").config(l),c(this,Jb,"f").onError(this.onError.bind(this))}setOnError(e){d(this,eE,e,"f")}init(){return a(this,void 0,void 0,(function*(){yield c(this,Jb,"f").preload()}))}release(){c(this,Jb,"f").stop(),c(this,Jb,"f").clear()}get isProcessing(){return!!c(this,Xb,"f")}processTrack(e){return a(this,void 0,void 0,(function*(){var t;if(c(this,Qb,"f")===e||"ended"===e.readyState)return(null===(t=c(this,Jb,"f").getStream())||void 0===t?void 0:t.getAudioTracks()[0])||e;this.stopProcessing();try{const t=new Promise(((t,r)=>{c(this,Jb,"f").onReady=()=>{try{const r=c(this,Jb,"f").getStream(),n=null==r?void 0:r.getAudioTracks()[0];if(!n)return void t(e);d(this,Qb,e,"f"),d(this,Xb,n,"f"),t(n),c(this,Jb,"f").run()}catch(e){r(e)}finally{c(this,Jb,"f").onReady=void 0}}}));c(this,Jb,"f").useStream(new MediaStream([e]));const r=yield t;return c(this,Kb,"f").info("processTrack()",{case:"Denoiser",type:this.type,track:e.id}),r}catch(t){throw c(this,Kb,"f").error("processTrack()",{error:Ct(t),type:this.type,case:"Denoiser",track:e}),c(this,eE,"f").call(this,"ASDK processTrack() error",t),d(this,eE,sE,"f"),new Error("Can not process this track")}}))}stopProcessing(){try{c(this,Jb,"f").stop()}catch(e){c(this,Kb,"f").error("stopProcessing()",{type:this.type,case:"Denoiser",error:Ct(e)})}finally{d(this,Qb,null,"f")}}getUpdatedDebounceCounter(e){var t;let r=null!==(t=c(this,Zb,"f").get(e))&&void 0!==t?t:0;return r+=1,c(this,Zb,"f").set(e,r),setTimeout((()=>{var t;const r=null!==(t=c(this,Zb,"f").get(e))&&void 0!==t?t:0;r<=0?c(this,Zb,"f").set(e,0):c(this,Zb,"f").set(e,r-1)}),1e4),r}onError(e){const{message:t,type:r,cause:i}=e,s=n(e,["message","type","cause"]);if(r===tE.ERROR)if(c(this,Kb,"f").error(t,Object.assign(Object.assign({error:Ct(i),cause:i},s),{type:this.type,case:"Denoiser"})),s.code===rE.REDUCE_LATENCY||s.code===rE.PERFORMANCE_STOP){this.getUpdatedDebounceCounter(s.code)>3&&(c(this,Zb,"f").set(s.code,0),c(this,eE,"f").call(this,`ASDK performance issue(${s.code}): ${t}`,i),d(this,eE,sE,"f"))}else c(this,eE,"f").call(this,`ASDK runtime error: ${t}`,i),d(this,eE,sE,"f");r===tE.WARNING&&c(this,Kb,"f").warn(t,Object.assign(Object.assign({},s),{type:this.type,case:"Denoiser"})),r===tE.INFO&&c(this,Kb,"f").info(t,Object.assign(Object.assign({},s),{type:this.type,case:"Denoiser"}))}}Jb=new WeakMap,Kb=new WeakMap,Qb=new WeakMap,Zb=new WeakMap,Xb=new WeakMap,eE=new WeakMap;class aE extends AudioWorkletNode{constructor(e){super(e.context,"rnnoise",{channelCountMode:"explicit",channelCount:1,channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{module:e.noiseSuppressor.module}}),this.port.onmessage=({data:e})=>{const t=Object.assign(new Event("status"),e);this.dispatchEvent(t)}}update(e){this.port.postMessage(e)}static register(e){return a(this,void 0,void 0,(function*(){const t=cw.get(On.Config);yield e.audioWorklet.addModule(`${t.get("staticFilesPath")}/noiseSuppressionWorklet.js`)}))}}var cE,dE,uE,lE,pE,hE;class fE{constructor(e){cE.set(this,void 0),dE.set(this,void 0),uE.set(this,void 0),lE.set(this,void 0),pE.set(this,void 0),hE.set(this,!0),d(this,cE,e.noiseSuppressor.instance.exports,"f"),d(this,dE,e.context,"f"),d(this,uE,new Float32Array(c(this,cE,"f").memory.buffer),"f"),d(this,lE,c(this,cE,"f").newState(),"f"),d(this,pE,c(this,dE,"f").createScriptProcessor(),"f"),this.setOnAudioProcess()}get noiseSuppressionScriptProcessorNode(){return c(this,pE,"f")}update(e){e||(d(this,hE,!1,"f"),c(this,cE,"f").deleteState(c(this,lE,"f")));const t=Object.assign(new Event("status"),{vadProb:c(this,cE,"f").getVadProb(c(this,lE,"f"))});c(this,pE,"f").dispatchEvent(t)}setOnAudioProcess(){c(this,pE,"f").addEventListener("audioprocess",(({inputBuffer:e,outputBuffer:t})=>{if(!c(this,hE,"f"))return;c(this,uE,"f").set(e.getChannelData(0),c(this,cE,"f").getInput(c(this,lE,"f"))/4);const r=t.getChannelData(0),n=c(this,cE,"f").pipe(c(this,lE,"f"),r.length)/4;n&&r.set(c(this,uE,"f").subarray(n,n+r.length))}))}}var mE,gE,vE,yE,_E,bE,EE,wE,SE,CE,PE,TE,RE,kE,DE,IE,AE,OE,NE,ME,LE,xE,FE,jE,UE,VE,BE,WE,HE,qE,zE,GE,YE,$E,JE,KE,QE,ZE,XE;cE=new WeakMap,dE=new WeakMap,uE=new WeakMap,lE=new WeakMap,pE=new WeakMap,hE=new WeakMap;class ew{constructor({context:e,noiseSuppressor:t}){mE.set(this,void 0),gE.set(this,void 0),vE.set(this,void 0),d(this,mE,e,"f"),d(this,gE,t,"f")}createNoiseSuppressionNode(){return a(this,void 0,void 0,(function*(){return/apple/i.test(navigator.vendor)?this.createScriptProcessorNode():yield this.createAudioWorkletNode()}))}stop(){var e;null===(e=c(this,vE,"f"))||void 0===e||e.update(!1)}createAudioWorkletNode(){return a(this,void 0,void 0,(function*(){return yield aE.register(c(this,mE,"f")),d(this,vE,new aE({context:c(this,mE,"f"),noiseSuppressor:c(this,gE,"f")}),"f"),c(this,vE,"f")}))}createScriptProcessorNode(){return d(this,vE,new fE({context:c(this,mE,"f"),noiseSuppressor:c(this,gE,"f")}),"f"),c(this,vE,"f").noiseSuppressionScriptProcessorNode}}mE=new WeakMap,gE=new WeakMap,vE=new WeakMap;class tw{constructor(e){yE.set(this,void 0),_E.set(this,void 0),bE.set(this,void 0),EE.set(this,void 0),this.type="rnnoise",d(this,yE,e.noiseSuppressor,"f"),d(this,bE,e.loggerFactory("TrackProcessor"),"f")}get isProcessing(){return!!c(this,EE,"f")}release(){this.stopProcessing()}processTrack(e){return a(this,void 0,void 0,(function*(){const t=(e=>{const t=window.AudioContext||window.webkitAudioContext||!1;return t?new t(e):null})();if(!t)throw new Error("AudioContext is not available");const r=new MediaStreamAudioDestinationNode(t,{channelCountMode:"explicit",channelCount:1,channelInterpretation:"speakers"});yield aE.register(t);const n=t.createMediaStreamSource(new MediaStream([e])),i=new ew({context:t,noiseSuppressor:c(this,yE,"f")}),s=yield i.createNoiseSuppressionNode();s.connect(r),n.connect(s);const[o]=r.stream.getTracks();return d(this,_E,{audioContext:t,streamDestination:r,noiseSuppressionNode:s,noiseSuppressionProvider:i},"f"),d(this,EE,o,"f"),c(this,bE,"f").info("processTrack()",{case:"Denoiser",type:this.type,track:e.id}),o}))}stopProcessing(){var e;if(this.isProcessing)if(c(this,_E,"f"))try{c(this,_E,"f").noiseSuppressionProvider.stop(),c(this,_E,"f").noiseSuppressionNode.disconnect(),c(this,_E,"f").streamDestination.disconnect(),c(this,_E,"f").audioContext.close().catch((e=>{c(this,bE,"f").error("stopProcessing()",{success:!1,error:Ct(e),case:"Denoiser",type:this.type})})),null===(e=c(this,EE,"f"))||void 0===e||e.stop(),d(this,EE,void 0,"f"),c(this,bE,"f").info("stopProcessing()",{success:!0,case:"Denoiser",type:this.type})}catch(e){c(this,bE,"f").error("stopProcessing()",{success:!1,error:Ct(e),case:"Denoiser",type:this.type})}else c(this,bE,"f").warn("stopProcessing()",{success:!1,description:"Processing context is not available",case:"Denoiser",type:this.type});else c(this,bE,"f").debug("stopProcessing()",{description:"Track is not processed",case:"Denoiser",type:this.type})}}yE=new WeakMap,_E=new WeakMap,bE=new WeakMap,EE=new WeakMap;class rw extends Zm{constructor(e){super(e),wE.set(this,!1),SE.set(this,void 0),CE.set(this,void 0),PE.set(this,void 0),d(this,PE,e.clientEventEmitter,"f")}get isDenoiserRequireActivation(){var e;return!(null===(e=c(this,SE,"f"))||void 0===e?void 0:e.isProcessing)&&c(this,wE,"f")}setTrackProcessor(e){if(!e)throw new Pt("track_processor_missing",new Error("trackProcessor must be passed as parameter"));this.logger.debug("Setting trackProcessor to AudioTrack",{case:"Denoiser",type:e.type}),d(this,SE,e,"f")}unsetTrackProcessor(){d(this,SE,void 0,"f")}get isEffectsProcessing(){var e;return Boolean(null===(e=c(this,SE,"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:Tc}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(){return a(this,void 0,void 0,(function*(){var e,t,r;if(d(this,wE,!0,"f"),!c(this,SE,"f"))return this.logger.warn("enableNoiseSuppression()",{description:"Track suppressor is not defined"}),void c(this,PE,"f").emit(xr,{cause:"Track suppressor is not defined"});try{const n=yield null===(e=c(this,SE,"f"))||void 0===e?void 0:e.processTrack(this.mediaStreamTrack);d(this,CE,this.mediaStreamTrack,"f"),yield this.replaceTrack(n),this.logger.debug("Denoiser activated",{case:"Denoiser",type:(null===(t=c(this,SE,"f"))||void 0===t?void 0:t.type)||"none"}),c(this,PE,"f").emit(Nr,{type:null===(r=c(this,SE,"f"))||void 0===r?void 0:r.type})}catch(e){throw this.logger.warn("enableNoiseSuppression()",{description:"Can not enable noise suppression",track:this.logCtx,error:Ct(e)}),c(this,PE,"f").emit(xr,{cause:"Failed to enable noise suppression",error:e}),new Pt("noise_suppression_enable_failed",e)}}))}disableNoiseSuppression(){return a(this,void 0,void 0,(function*(){var e,t,r,n;d(this,wE,!1,"f");try{if(!(null===(e=c(this,SE,"f"))||void 0===e?void 0:e.isProcessing))return void this.logger.debug("stopProcessing()",{description:"Track is not processed"});if(!c(this,CE,"f"))return void this.logger.warn("disableNoiseSuppression()",{description:"Original track missing"});yield this.replaceTrack(c(this,CE,"f")),null===(t=c(this,SE,"f"))||void 0===t||t.stopProcessing(),this.logger.debug("Denoiser deactivated",{case:"Denoiser",type:(null===(r=c(this,SE,"f"))||void 0===r?void 0:r.type)||"none"}),c(this,PE,"f").emit(Mr,{type:null===(n=c(this,SE,"f"))||void 0===n?void 0:n.type})}catch(e){throw this.logger.warn("disableNoiseSuppression()",{description:"Can not disable noise suppression",track:this.logCtx,error:Ct(e)}),c(this,PE,"f").emit(xr,{cause:"Failed to disable noise suppression",error:e}),new Pt("noise_suppression_disable_failed",e)}}))}publish(){return a(this,void 0,void 0,(function*(){yield this.produce({encodings:this.getEncodings(),preferredCodec:this.getPreferredCodec(),codecOptions:this.getCodecOptions()}),this.internalEventEmitter.emit(jr,this)}))}pause(){return a(this,void 0,void 0,(function*(){yield this.mute()}))}}wE=new WeakMap,SE=new WeakMap,CE=new WeakMap,PE=new WeakMap;class nw{constructor({track:e,statsHandler:t}){TE.set(this,void 0),RE.set(this,void 0),this.handleWebRTCStats(e,t)}get videoWebRTCStats(){return c(this,TE,"f")}get audioWebRTCStats(){return c(this,RE,"f")}handleWebRTCStats(e,t){e.addEventListener("ended",(()=>{t.removeInboundVideoHandler(e.id),t.removeInboundAudioHandler(e.id)}),{once:!0}),"video"!==e.kind?t.addInboundAudioHandler(e.id,this.setAudioWebRTCStats.bind(this)):t.addInboundVideoHandler(e.id,this.setVideoWebRTCStats.bind(this))}setVideoWebRTCStats(e){d(this,TE,e,"f")}setAudioWebRTCStats(e){d(this,RE,e,"f")}}TE=new WeakMap,RE=new WeakMap;class iw{constructor(e){this.label=Nn.Unknown,kE.set(this,void 0),DE.set(this,void 0),IE.set(this,void 0),AE.set(this,void 0),OE.set(this,void 0),NE.set(this,void 0),ME.set(this,void 0),LE.set(this,void 0),xE.set(this,void 0),FE.set(this,!1),jE.set(this,void 0),UE.set(this,!1),VE.set(this,new jg),BE.set(this,!1),WE.set(this,0),HE.set(this,void 0),this.observer=new Et,d(this,LE,e.mediaStreamTrack,"f"),this.label=e.label,this.consumer=e.consumer,d(this,AE,e.peerConsumerFactory,"f"),d(this,NE,e.loggerFactory("PeerTrack"),"f"),d(this,ME,e.peerEventEmitter,"f"),d(this,BE,e.muted,"f"),d(this,xE,e.paused,"f"),d(this,kE,e.network,"f"),d(this,DE,e.media,"f"),d(this,OE,e.callState,"f"),d(this,IE,e.onClose,"f"),d(this,HE,new nw({track:e.mediaStreamTrack,statsHandler:e.statsHandler}),"f")}get videoWebRTCStats(){return c(this,HE,"f").videoWebRTCStats}get audioWebRTCStats(){return c(this,HE,"f").audioWebRTCStats}get logCtx(){var e,t;return{id:c(this,LE,"f").id,label:this.label,consumerId:null===(e=this.consumer)||void 0===e?void 0:e.id,producerId:null===(t=this.consumer)||void 0===t?void 0:t.producerId,muted:c(this,BE,"f"),paused:c(this,xE,"f"),closed:c(this,UE,"f")}}get volume(){return c(this,WE,"f")}get isRemote(){return!!this.consumer}get mediaStreamTrack(){return c(this,LE,"f")}get kind(){return this.mediaStreamTrack.kind}get isPaused(){return c(this,xE,"f")}get isMuted(){return c(this,BE,"f")}get consumerId(){var e;return null===(e=this.consumer)||void 0===e?void 0:e.id}get currentSpatialLayer(){var e,t;return null!==(t=null===(e=this.consumer)||void 0===e?void 0:e.currentSpatialLayer)&&void 0!==t?t:lm}close(){return a(this,void 0,void 0,(function*(){c(this,ME,"f").safeEmit(Kr,this),d(this,UE,!0,"f"),c(this,IE,"f").call(this),this.consumer&&(yield this.closeConsumer(),this.clearCheckStateTimeout())}))}mute(){return a(this,void 0,void 0,(function*(){yield c(this,VE,"f").push((()=>a(this,void 0,void 0,(function*(){c(this,NE,"f").debug("mute()",{track:this.logCtx}),yield this.pauseConsumer(),d(this,BE,!0,"f")}))))}))}unmute(){return a(this,void 0,void 0,(function*(){yield c(this,VE,"f").push((()=>a(this,void 0,void 0,(function*(){c(this,NE,"f").debug("unmute()",{track:this.logCtx}),yield this.resumeConsumer(),d(this,BE,!1,"f")}))))}))}pause(){return a(this,arguments,void 0,(function*(e=!0){yield c(this,VE,"f").push((()=>a(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return d(this,xE,!0,"f"),c(this,ME,"f").safeEmit(Qr,this),void c(this,NE,"f").debug("pause()",{track:this.logCtx});yield this.pauseConsumer(e),d(this,xE,!0,"f"),c(this,ME,"f").safeEmit(Qr,this)}))))}))}resume(){return a(this,arguments,void 0,(function*(e=!0){yield c(this,VE,"f").push((()=>a(this,void 0,void 0,(function*(){if(!this.consumer||this.isMuted)return d(this,xE,!1,"f"),c(this,ME,"f").safeEmit(Zr,this),void c(this,NE,"f").debug("resume()",{track:this.logCtx});yield this.resumeConsumer(e),d(this,xE,!1,"f"),c(this,ME,"f").safeEmit(Zr,this)}))))}))}resumeConsumer(){return a(this,arguments,void 0,(function*(e=!0){if(this.consumer)try{this.consumer.resume(),e&&(yield c(this,kE,"f").resumeRemoteConsumer(this.consumer.id)),this.checkConsumerState().catch((e=>{c(this,NE,"f").warn("Failed to checkConsumerState()",{track:this.logCtx,error:Ct(e)})})),c(this,NE,"f").debug("resumeConsumer()",{track:this.logCtx})}catch(e){c(this,NE,"f").warn("resumeConsumer()",{error:e})}}))}pauseConsumer(){return a(this,arguments,void 0,(function*(e=!0){if(this.consumer)try{if(this.clearCheckStateTimeout(),e&&(yield c(this,kE,"f").pauseRemoteConsumer(this.consumer.id)),"audio"===this.kind)return void c(this,NE,"f").debug("pauseConsumer() - skipping for audio",{track:this.logCtx});this.consumer.pause(),d(this,FE,!1,"f"),c(this,NE,"f").debug("pauseConsumer()",{track:this.logCtx})}catch(e){c(this,NE,"f").warn("pauseConsumer()",{error:e,track:this.logCtx})}}))}requestVideoPreferredLayers(e){return a(this,arguments,void 0,(function*({spatialLayer:e,temporalLayer:t}){if(this.consumer)try{if(this.consumer.isAudio)return void c(this,NE,"f").warn("Only video consumers support layers",{case:"requestVideoPreferredLayers"});if(e===this.consumer.currentSpatialLayer)return;if(e>this.consumer.spatialLayers)return void c(this,NE,"f").warn("Invalid spatial layer",{spatialLayer:e,consumerSpatialLayers:this.consumer.spatialLayers,case:"requestVideoPreferredLayers"});if(e>this.consumer.currentMaxSpatialLayer)return void(yield this.requestMaxSpatialLayer(this.consumer.id,e));yield c(this,kE,"f").updateConsumerPreferredLayers(this.consumer.id,e,t),c(this,NE,"f").debug("requestVideoPreferredLayers()",{track:this.logCtx,consumer:this.consumer,spatialLayer:e,temporalLayer:t})}catch(e){throw c(this,NE,"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 Pt("peer_track_request_preferred_layers_failed",e)}}))}requestKeyFrame(){return a(this,void 0,void 0,(function*(){if(this.consumerId){c(this,NE,"f").debug("requestKeyFrame()",{track:this.logCtx});try{yield c(this,kE,"f").requestConsumerKeyFrame(this.consumerId)}catch(e){throw c(this,NE,"f").error("requestKeyFrame()",{error:e,track:this.logCtx,consumerId:this.consumerId}),new Pt("peer_track_request_key_frame_failed",e)}}}))}getVideoAvailableLayers(){if(this.consumer){if(!this.consumer.isAudio)return this.consumer.availableSpatialLayers;c(this,NE,"f").warn("Only video consumers support layers",{case:"getVideoAvailableLayers"})}}getInfo(){return a(this,void 0,void 0,(function*(){var e;const{width:t,height:r,frameRate:n,aspectRatio:i}=c(this,LE,"f").getSettings();return{trackId:c(this,LE,"f").id,readyState:c(this,LE,"f").readyState,isRemote:this.isRemote,kind:this.kind,label:this.label,width:t,height:r,frameRate:n,aspectRatio:i,paused:c(this,xE,"f"),trackInboundStats:yield null===(e=this.consumer)||void 0===e?void 0:e.getStats(),trackOutboundStats:yield this.getOutboundStats()}}))}getOutboundStats(){return a(this,void 0,void 0,(function*(){if(this.isRemote)return;const e=c(this,DE,"f").getAllTracks().find((e=>e.getLabel()===this.label));return e?yield e.getStats():void 0}))}requestMaxSpatialLayer(e,t){return a(this,void 0,void 0,(function*(){try{if(!this.consumer)return;if(this.consumer.isAudio||0===this.consumer.spatialLayers||this.consumer.currentMaxSpatialLayer===t||t<this.consumer.currentMaxSpatialLayer)return void c(this,NE,"f").warn("Can`t request this spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t});this.consumer.setRequestedSpatialLayer(t),yield c(this,kE,"f").requestProducerMaxSpatialLayer(this.consumer.producerId,t),c(this,NE,"f").debug("requestMaxSpatialLayer()",{consumerId:e,spatialLayer:t})}catch(r){c(this,NE,"f").warn("Failed to request max spatial layer",{case:"requestMaxSpatialLayer",consumerId:e,spatialLayer:t,error:r})}}))}checkConsumerState(){return a(this,void 0,void 0,(function*(){try{if(c(this,UE,"f")||"audio"===this.kind)return;c(this,NE,"f").debug("checkConsumerState()",{track:this.logCtx});if((yield this.isInboundRTPStreamActive())||c(this,UE,"f"))return;yield this.requestKeyFrame();if((yield this.isInboundRTPStreamActive())||c(this,UE,"f"))return;if(c(this,FE,"f"))return c(this,ME,"f").emit(Xr,this),void c(this,NE,"f").debug("trackFail()",{track:this.logCtx});yield this.restartConsumer()}catch(e){c(this,NE,"f").warn("checkConsumerState()",{track:this,error:e})}}))}setVolume(e){c(this,WE,"f")!==e&&(d(this,WE,e,"f"),this.observer.safeEmit(Fr,{value:e}))}closeConsumer(){return a(this,void 0,void 0,(function*(){try{if(!this.consumer)return;this.consumer.close(),yield c(this,kE,"f").closeRemoteConsumer(this.consumer.id)}catch(e){c(this,NE,"f").debug("closeConsumer()",{track:this,error:e})}}))}restartConsumer(){return a(this,void 0,void 0,(function*(){try{if(!this.consumer||c(this,UE,"f"))return;c(this,NE,"f").debug("restartConsumer()",{track:this.logCtx}),c(this,ME,"f").emit(Kr,this),d(this,xE,!0,"f"),yield this.closeConsumer();const{consumer:e}=yield c(this,kE,"f").createConsumer({producerId:this.consumer.producerId,rtpCapabilities:c(this,DE,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.consumer.appData.producerData.peerId,appId:c(this,OE,"f").appId,channelId:c(this,OE,"f").channelId});d(this,FE,!0,"f"),this.consumer=c(this,AE,"f").call(this,{consumer:e}),d(this,LE,e.track,"f"),yield this.resume(),c(this,ME,"f").emit(Jr,this)}catch(e){d(this,FE,!0,"f"),c(this,NE,"f").warn("restartConsumer()",{track:this,error:e})}}))}isInboundRTPStreamActive(){return a(this,void 0,void 0,(function*(){if(!this.consumer||c(this,UE,"f"))return!1;const{framesDecoded:e}=yield this.consumer.getInboundRTPStreamStats();return yield new Promise((t=>{d(this,jE,setTimeout((()=>a(this,void 0,void 0,(function*(){try{if(!this.consumer)return void t(!1);const{framesDecoded:r}=yield this.consumer.getInboundRTPStreamStats();if(e===r&&!this.isPaused)return void t(!1);t(!0)}catch(e){c(this,NE,"f").debug("isInboundRTPStreamActive()",{error:e,track:this.logCtx}),t(!1)}}))),4500),"f")}))}))}clearCheckStateTimeout(){c(this,jE,"f")||clearTimeout(c(this,jE,"f"))}}kE=new WeakMap,DE=new WeakMap,IE=new WeakMap,AE=new WeakMap,OE=new WeakMap,NE=new WeakMap,ME=new WeakMap,LE=new WeakMap,xE=new WeakMap,FE=new WeakMap,jE=new WeakMap,UE=new WeakMap,VE=new WeakMap,BE=new WeakMap,WE=new WeakMap,HE=new WeakMap;class sw{constructor(e){this.encodings=[],qE.set(this,void 0);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,d(this,qE,Date.now(),"f")}setPaused(e){this.paused=e,d(this,qE,Date.now(),"f")}getStateChangedAt(){return c(this,qE,"f")}}qE=new WeakMap;class ow{constructor({id:e,channelIds:t,groups:r,producePermissions:n,appId:i,loginDate:s,producers:o=[],appData:a,uid:c,role:u,loggerFactory:l,myPeer:p,callState:h,peers:f,remotePeerTracks:m,media:g,network:v,peerConsumerFactory:y}){this.producers=new Map,this.tracks=new Map,zE.set(this,void 0),GE.set(this,void 0),YE.set(this,void 0),$E.set(this,void 0),JE.set(this,void 0),KE.set(this,void 0),QE.set(this,void 0),ZE.set(this,void 0),this._observer=new Et,this.id=e,this.channelIds=t,this.groups=r,this.producePermissions=n,this.appId=i,this.loginDate=s,this.applicationData=null!=a?a:{},this.uid=c,this.role=u,d(this,JE,p,"f"),d(this,KE,h,"f"),d(this,zE,f,"f"),d(this,GE,m,"f"),d(this,QE,y,"f"),d(this,YE,v,"f"),d(this,$E,g,"f"),d(this,ZE,l("Peer"),"f"),o.forEach(this.handleNewProducer.bind(this)),this.handlePeerEvents()}get appData(){return this.applicationData}get observer(){return this._observer}get isMe(){return this.id===c(this,JE,"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(e){return a(this,arguments,void 0,(function*({producerId:e,muted:t=!1}){try{const r=this.producers.get(e);if(!r)return void c(this,ZE,"f").warn("subscribe()",{message:"Peer does not have a producer",peer:Es(this),producerId:e});if(this.getAllConsumers().find((t=>t.producerId===e)))return void c(this,ZE,"f").debug("subscribe()",{message:"Already subscribed to producer",peer:Es(this),producerId:e});const{consumer:n,isProducerPaused:i}=yield c(this,YE,"f").createConsumer({producerId:r.id,rtpCapabilities:c(this,$E,"f").mediasoupDevice.rtpCapabilities,producerPeerId:this.id,appId:c(this,KE,"f").appId,channelId:c(this,KE,"f").channelId});if(!this.producePermissions.includes(r.label)&&Object.values(Nn).includes(r.label))return void c(this,ZE,"f").debug("subscribe()",{message:"Producer is not allowed anymore",peer:Es(this),producerId:e});const s=c(this,GE,"f").create({mediaStreamTrack:n.track,label:r.label,consumer:c(this,QE,"f").call(this,{consumer:n}),muted:t,paused:i,peerEventEmitter:this.observer});t||(yield s.unmute()),this.tracks.set(s.label,s),c(this,ZE,"f").debug(`Subscribed for ${r.kind}`,{peer:Es(this)})}catch(t){throw c(this,ZE,"f").error("subscribe()",{producerId:e,error:t,peer:Es(this)}),new Pt("peer_subscribe_failed",t)}}))}unsubscribe(e){return a(this,void 0,void 0,(function*(){try{const t=this.getConsumerByProducerId(e);if(!t)return;const r=this.getTrackByConsumerId(t.id);if(!r)return;yield r.close(),this.tracks.delete(r.label),c(this,ZE,"f").debug(`Unsubscribed consumer ${t.kind}`,{peer:Es(this)})}catch(t){throw c(this,ZE,"f").error("unsubscribe()",{producerId:e,error:t}),new Pt("peer_unsubscribe_failed",t)}}))}setProducePermissions(e){return a(this,void 0,void 0,(function*(){this.throwIfIamNotModerator();try{yield c(this,YE,"f").changePeerProducePermissions(this.id,e)}catch(e){throw new Pt("peer_set_produce_permissions_failed",e)}c(this,ZE,"f").debug("Produce permissions changed",{peerId:this.id,producePermissions:e})}))}addProducePermission(e){return a(this,void 0,void 0,(function*(){this.throwIfIamNotModerator();try{yield c(this,YE,"f").addPeerProducePermission(this.id,e)}catch(e){throw new Pt("peer_add_produce_permission_failed",e)}c(this,ZE,"f").debug("Add produce permission requested",{peerId:this.id,label:e})}))}removeProducePermission(e){return a(this,void 0,void 0,(function*(){this.throwIfIamNotModerator();try{yield c(this,YE,"f").removePeerProducePermission(this.id,e)}catch(e){throw new Pt("peer_remove_produce_permission_failed",e)}c(this,ZE,"f").debug("Remove produce permission requested",{peerId:this.id,label:e})}))}getInfo(){return a(this,void 0,void 0,(function*(){try{return{id:this.id,appData:this.appData,role:this.role,channelIds:this.channelIds,appId:this.appId,uid:this.uid,loginDate:this.loginDate,tracks:yield Promise.all(Array.from(this.tracks.values()).map((e=>a(this,void 0,void 0,(function*(){return yield e.getInfo()})))))}}catch(e){throw c(this,ZE,"f").error("getInfo()",{peer:Es(this),error:e}),new Pt("peer_get_info_failed",e)}}))}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 sw(e);this.producers.set(t.id,t),c(this,ZE,"f").debug("Peer published media:",{peer:Es(this),producer:t});const r={producerId:t.id,kind:t.kind,label:t.label,paused:t.paused};this.observer.safeEmit(zr,r)}handlePeerEvents(){this.observer.on(nn,this.handleNewProducer.bind(this)),this.observer.on(sn,(e=>a(this,void 0,void 0,(function*(){this.producers.delete(e.id),c(this,ZE,"f").debug("Peer unpublished media:",{peer:Es(this),producer:e}),this.observer.safeEmit(Gr,{producerId:e.id,kind:e.kind,label:e.label,paused:e.paused});const t=this.tracks.get(e.label);if(t)try{yield t.close()}catch(e){c(this,ZE,"f").warn("Failed to close peer track due to producer closed",{label:t.label,peerId:this.id,error:Ct(e)})}})))),this.observer.on(cn,(e=>a(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.close(),this.tracks.delete(t.label),c(this,ZE,"f").debug("Peer video track was ended:",{peer:Es(this),track:t.logCtx}))})))),this.observer.on(dn,(e=>a(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.pause(!1))})))),this.observer.on(un,(e=>a(this,void 0,void 0,(function*(){const t=this.getTrackByConsumerId(e);t&&(yield t.resume(!1))})))),this.observer.on(ln,(e=>{const t=this.getConsumerById(e.consumerId);(null==t?void 0:t.isVideo)&&(t.applyLayersUpdate({spatialLayer:e.spatialLayer,temporalLayer:e.temporalLayer}),e.spatialLayer===t.requestedSpatialLayer&&t.setRequestedSpatialLayer(void 0),c(this,ZE,"f").debug("consumerChangePreferredLayers()",Object.assign({},e)))})),this.observer.on(on,(e=>a(this,void 0,void 0,(function*(){const{producerId:t,spatialLayer:r}=e,n=this.getConsumerByProducerId(t);n?(n.setCurrentMaxSpatialLayer(r),c(this,ZE,"f").debug("producerSetMaxSpatialLayer()",{producerId:t,consumerId:n.id,spatialLayer:r}),n.requestedSpatialLayer===r?(yield c(this,YE,"f").updateConsumerPreferredLayers(n.id,r),c(this,ZE,"f").debug("requestVideoPreferredLayers()",{producerId:t,consumerId:n.id,spatialLayer:r})):c(this,ZE,"f").debug("producerSetMaxSpatialLayer()",{message:"No need to request new preferred layer",currentMaxSpatialLayer:r,requestedMaxSpatialLayer:n.requestedSpatialLayer})):c(this,ZE,"f").debug("producerSetMaxSpatialLayer()",{message:"Consumer for producer not created, ignore MaxSpatialLayer change"})})))),this.observer.on(mr,(e=>{try{yn(e),this.setAppData(e),this.observer.emit(en,e),c(this,ZE,"f").debug("updatePeerAppData",{peer:Es(this),appData:e})}catch(t){c(this,ZE,"f").error("updatePeerAppData",{peer:Es(this),appData:e,error:t})}}))}reset(){return a(this,void 0,void 0,(function*(){this.producers.clear(),yield Promise.all(Array.from(this.tracks.values()).map((e=>a(this,void 0,void 0,(function*(){return yield e.close()}))))),this.tracks.clear();[nn,sn,cn,dn,un,ln,on,mr].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(Nn).filter((e=>!this.producePermissions.includes(e))).forEach((e=>{const t=this.tracks.get(e);t&&(this.tracks.delete(t.label),t.close().catch((e=>{c(this,ZE,"f").error("Failed to close track",{case:"Peer",error:Ct(e)})})))})),this.observer.safeEmit(tn,{labels:this.producePermissions})}handleGroupsChange(e){this.groups=e,this.observer.safeEmit(rn,{groups:e})}getAllConsumers(){return Array.from(this.tracks.values()).map((e=>e.consumer)).filter((e=>!!e))}getConsumerByProducerId(e){return this.getAllConsumers().find((t=>t.producerId===e))}getConsumerById(e){return this.getAllConsumers().find((t=>t.id===e))}getTrackByConsumerId(e){return Array.from(this.tracks.values()).find((t=>t.consumerId===e))}setAppData(e){this.applicationData=e}throwIfIamNotModerator(){if(!c(this,zE,"f").isModerator(c(this,JE,"f").id))throw new Pt("not_enough_access",new Error("Not enough access"))}}zE=new WeakMap,GE=new WeakMap,YE=new WeakMap,$E=new WeakMap,JE=new WeakMap,KE=new WeakMap,QE=new WeakMap,ZE=new WeakMap;class aw{constructor(e){this.spatialLayers=lm,this.temporalLayers=hm,this.currentSpatialLayer=lm,this.currentTemporalLayer=hm,this.availableSpatialLayers=[],XE.set(this,void 0);const{consumer:t,loggerFactory:r}=e;this.id=t.id,this.kind=t.kind,this.producerId=t.producerId,this.appData=t.appData,this.consumer=t,d(this,XE,r("PeerConsumer"),"f"),this.currentMaxSpatialLayer=this.appData.producerData.maxSpatialLayer,this.parseScalabilityMode(),this.initAvailableSpatialLayers(),this.setCurrentSpatialLayerParams()}get paused(){return this.consumer.paused}pause(){this.consumer.pause()}resume(){this.consumer.resume()}close(){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}=pd.parseScalabilityMode(e);this.spatialLayers=t,this.temporalLayers=r,c(this,XE,"f").debug("parseScalabilityMode()",{scalabilityMode:e,spatialLayers:t,temporalLayers:r})}}initAvailableSpatialLayers(){const{encodings:e,trackTransformParams:t}=this.appData.producerData;if(!Array.isArray(e))return;if(this.availableSpatialLayers=e.map((e=>this.tryPrepareSpatialLayerParams(e))),!t||this.availableSpatialLayers.length>1||this.spatialLayers<pm)return void c(this,XE,"f").debug("Using available spatial layers",{case:"initAvailableSpatialLayers"});c(this,XE,"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;(null==e?void 0:e[this.currentSpatialLayer])&&(this.currentSpatialLayerParams=this.tryPrepareSpatialLayerParams(e[this.currentSpatialLayer]),c(this,XE,"f").debug("setCurrentSpatialLayerParams()",{currentSpatialLayerParams:this.currentSpatialLayerParams}))}tryPrepareSpatialLayerParams(e){var t;const{trackTransformParams:r}=this.appData.producerData;if(!r)return e;const{width:n,height:i}=r,s=null!==(t=e.scaleResolutionDownBy)&&void 0!==t?t:1;return n&&i?Object.assign({width:n/s,height:i/s},e):e}setCurrentSpatialLayer(e){if(!this.isVideo)throw new Error("setCurrentSpatialLayer applies to video consumers only");this.currentSpatialLayer=e,c(this,XE,"f").debug("setCurrentSpatialLayer()",{currentSpatialLayer:e}),this.setCurrentSpatialLayerParams()}setCurrentTemporalLayer(e){if(!this.isVideo)throw new Error("setCurrentTemporalLayer applies to video consumers only");this.currentTemporalLayer=e,c(this,XE,"f").debug("setCurrentTemporalLayer()",{currentTemporalLayer:e})}applyLayersUpdate(e){if(!this.isVideo)throw new Error("applyLayersUpdate applies to video consumers only");const{spatialLayer:t,temporalLayer:r}=e;void 0!==t&&this.setCurrentSpatialLayer(t),void 0!==r&&this.setCurrentTemporalLayer(r)}setRequestedSpatialLayer(e){this.requestedSpatialLayer=e}setCurrentMaxSpatialLayer(e){this.currentMaxSpatialLayer=e}getStats(){return a(this,void 0,void 0,(function*(){var e,t;try{return{consumerId:this.consumer.id,codec:this.consumer.rtpParameters.codecs.find((e=>Mm(e))),dtlsState:null===(t=null===(e=this.consumer.rtpReceiver)||void 0===e?void 0:e.transport)||void 0===t?void 0:t.state,availableSpatialLayers:this.availableSpatialLayers,currentSpatialLayerParams:this.currentSpatialLayerParams,requestedSpatialLayer:this.requestedSpatialLayer,rtcStats:yield this.getInboundRTPStreamStats()}}catch(e){return void c(this,XE,"f").debug("getStats()",{error:e})}}))}getInboundRTPStreamStats(){return a(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{const r=(...n)=>a(this,[...n],void 0,(function*(n=0){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).catch((e=>{c(this,XE,"f").debug("Error getting RTCStatsReport",{attempt:n,error:Ct(e)})}))}),150);n>=5&&!s&&t(new Error("InboundRTPStreamStat not exist")),e(s)}catch(e){t(new Error("Can not get RTCStatsReport")),c(this,XE,"f").debug("getInboundRTPStreamStats()",{error:e})}}));r().catch((e=>{c(this,XE,"f").debug("Error executing getRTCStatsReport",{case:"PeerConsumer",error:Ct(e)})}))}))}))}}XE=new WeakMap;const cw=new rt({autoBindInjectable:!0});var dw,uw;cw.bind(On.LocalMutex).to(lv).inSingletonScope(),cw.bind(On.SignalingApiClient).toDynamicValue((e=>new vc(e.container.get(On.Config)))).inSingletonScope(),cw.bind(On.CallState).to(Ln).inSingletonScope(),cw.bind(On.MyPeer).to(ws).inSingletonScope(),cw.bind(On.LoggerFactory).toFactory((e=>{const t=e.container.get(On.Config),r=t.get("logLevel"),n=t.get("sendAnalytics"),i=t.get("onLogMessage");return e=>new Wb({logLevel:r,namespace:e,onLogMessage:i,sendAnalytics:n})})),cw.bind(On.System).to(_v).inSingletonScope(),cw.bind(On.ProcessorsCache).to(bm).inSingletonScope(),cw.bind(On.IntegrationsService).to(Sm).inSingletonScope(),cw.bind(On.MediaStreamTrackManager).to(fg).inSingletonScope(),cw.bind(On.Media).to(gg).inSingletonScope(),cw.bind(On.Network).to(Kc).inSingletonScope(),cw.bind(On.NetworkTransportPolicyManager).to(tv).inSingletonScope(),cw.bind(On.PendingClosureProducerStorage).to(qg).inSingletonScope(),cw.bind(On.ProducerCloseManager).to(Zg).inSingletonScope(),cw.bind(On.RemotePeerTracks).to(Hb).inSingletonScope(),cw.bind(On.Peers).to(Qc).inSingletonScope(),cw.bind(On.MediaEventHandler).to(Bg).inSingletonScope(),cw.bind(On.ChannelEventHandler).to(Ng).inSingletonScope(),cw.bind(On.ChannelAudioObserverEventHandler).to(Uc).inSingletonScope(),cw.bind(On.ChannelAudioObserverMissingProducerRestorer).to(Mc).inSingletonScope(),cw.bind(On.EventsQueue).to(bs).inSingletonScope(),cw.bind(On.ChannelStateSynchronizer).to(Ag).inSingletonScope(),cw.bind(On.ChannelStateSyncEventHandler).to(ld).inSingletonScope(),cw.bind(On.StatsHandler).to(kv).inSingletonScope(),cw.bind(On.WIDHandler).to(iE).inSingletonScope(),cw.bind(On.WebRTCIssueDetector).toDynamicValue((e=>{const t=e.container.get(On.Config),r=e.container.get(On.WIDHandler);if(t.get("disableWid"))return;const n=e.container.get(On.StatsHandler),i=[1234],s=e.container.get(On.LoggerFactory)("WID"),o=new ar({statsParser:new cr({ignoreSSRCList:i,logger:s})});return new dr({onIssues:e=>{var n;r.handleIssues(e),null===(n=t.get("onIssues"))||void 0===n||n(e)},issueEmitter:new Wt,networkScoresCalculator:new zt,detectors:[new Qt,new $t,new Kt,new Jt,new Yt,new Zt,new rr({minMosQuality:Dt.GOOD,avgFreezeDurationThresholdMs:2e3,frozenDurationThresholdPct:50}),new nr({minMosQuality:Dt.GOOD,volatilityThreshold:10,affectedStreamsPercentThreshold:60})],statsReporter:new Ht({compositeStatsParser:o,getStatsInterval:t.get("getStatsInterval")}),onNetworkScoresUpdated:e=>{var n;r.handleNetworkScores(e),null===(n=t.get("onNetworkScoresUpdated"))||void 0===n||n(e)},onStats:n.handle.bind(n),ignoreSSRCList:i,compositeStatsParser:o,logger:s,autoAddPeerConnections:!1})})).inSingletonScope(),cw.bind(On.Engine).to(Lv).inSingletonScope(),cw.bind(On.PeerTrackFactory).toFactory((function(e){const t=e.container.get(On.LoggerFactory),r=e.container.get(On.CallState),n=e.container.get(On.StatsHandler);return i=>{const s={callState:r,loggerFactory:t,media:e.container.get(On.Media),network:e.container.get(On.Network),peerConsumerFactory:e.container.get(On.PeerConsumerFactory)},{peerEventEmitter:o}=i,a=new iw(Object.assign(Object.assign(Object.assign({},i),s),{statsHandler:n}));return o.safeEmit(Jr,a),a}})),cw.bind(On.PeerFactory).toFactory((function(e){const t=e.container.get(On.LoggerFactory),r=e.container.get(On.CallState);return n=>{const i={callState:r,loggerFactory:t,media:e.container.get(On.Media),myPeer:e.container.get(On.MyPeer),network:e.container.get(On.Network),peers:e.container.get(On.Peers),remotePeerTracks:e.container.get(On.RemotePeerTracks),peerConsumerFactory:e.container.get(On.PeerConsumerFactory)};return new ow(Object.assign(Object.assign({},i),n))}})),cw.bind(On.PeerConsumerFactory).toFactory((function(e){const t=e.container.get(On.LoggerFactory);return e=>{const r={loggerFactory:t};return new aw(Object.assign(Object.assign({},r),e))}})),cw.bind(On.AudioTrackFactory).toFactory((function(e){const t=e.container.get(On.LoggerFactory),r=e.container.get(On.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(On.InternalEventEmitter),loggerFactory:t,media:e.container.get(On.Media),mediaStreamTrackManager:e.container.get(On.MediaStreamTrackManager),myPeer:e.container.get(On.MyPeer),network:e.container.get(On.Network),producerCloseManager:e.container.get(On.ProducerCloseManager),mutex:e.container.get(On.LocalMutex),processorFactory:e.container.get(On.AudioTrackProcessorFactory),clientEventEmitter:e.container.get(On.ClientEventEmitter),statsHandler:r};return new rw(Object.assign(Object.assign({},i),n))}})),cw.bind(On.VideoTrackFactory).toFactory((function(e){const t=e.container.get(On.LoggerFactory),r=e.container.get(On.StatsHandler);return n=>{const i={internalEventEmitter:e.container.get(On.InternalEventEmitter),loggerFactory:t,media:e.container.get(On.Media),mediaStreamTrackManager:e.container.get(On.MediaStreamTrackManager),myPeer:e.container.get(On.MyPeer),network:e.container.get(On.Network),producerCloseManager:e.container.get(On.ProducerCloseManager),mutex:e.container.get(On.LocalMutex),statsHandler:r};return new ng(Object.assign(Object.assign({},i),n))}})),cw.bind(On.AudioTrackProcessorFactory).toFactory((function(e){const t=e.container.get(On.LoggerFactory),r=e.container.get(On.Config),n=e.container.get(On.ProcessorsCache),i=r.get("asdk");return e=>{const s=r.get("denoiser");let o=n.get(s,e.trackLabel);if(o)return o;if("rnnoise"===s&&e.noiseSuppressor&&(o=new tw({noiseSuppressor:e.noiseSuppressor,loggerFactory:t})),"asdk"===s&&(null==i?void 0:i.customerId)&&(o=new oE({asdkCustomerId:i.customerId,loggerFactory:t,config:r})),!o)throw new TypeError("Incorrect parameters passed to AudioTrackProcessorFactory");return o}})),cw.bind(On.DataChannelsManager).to(Hc).inSingletonScope(),cw.bind(On.DatachannelHeartbeater).to(bc).inSingletonScope(),cw.bind(On.SignalingHeartbeater).to($c).inSingletonScope(),cw.bind(On.AnalyticsApiClient).to(lb).inSingletonScope(),cw.bind(On.PeersStorage).to(Sc).inSingletonScope(),cw.bind(On.TransportsStatsProvider).to(Nv).inSingletonScope();class lw{constructor(e){dw.set(this,void 0),uw.set(this,void 0),this.canUseNoiseSuppression=!0;const{clientEventEmitter:t,internalEventEmitter:r}=e;cw.bind(On.Config).toDynamicValue((()=>new bt(e))).inSingletonScope(),cw.bind(On.InternalEventEmitter).toDynamicValue((()=>null!=r?r:new Et)).inSingletonScope(),cw.bind(On.ClientEventEmitter).toDynamicValue((()=>null!=t?t:new Et)).inSingletonScope(),cw.get(On.IntegrationsService),this.clientEventEmitter=cw.get(On.ClientEventEmitter),d(this,dw,cw.get(On.Engine),"f"),d(this,uw,cw.get(On.NetworkTransportPolicyManager),"f")}get observer(){return this.clientEventEmitter}get id(){return c(this,dw,"f").myPeerId}get peers(){return c(this,dw,"f").getPeers()}get availableVideoDevices(){return c(this,dw,"f").system.availableVideoDevices}get availableAudioDevices(){return c(this,dw,"f").system.availableAudioDevices}get effectsSDKInitialized(){return c(this,dw,"f").media.effectsSDKInitialized}detectDevices(e){return a(this,void 0,void 0,(function*(){try{yield c(this,dw,"f").system.detectDevices(e)}catch(e){const t=e instanceof Error?e.message:"detect_devices_failed";throw new Pt(t,e)}return{video:c(this,dw,"f").system.availableVideoDevices,audio:c(this,dw,"f").system.availableAudioDevices}}))}initEffectsSDK(){return a(this,void 0,void 0,(function*(){return yield c(this,dw,"f").media.initEffectsSDK()}))}join(e){return a(this,void 0,void 0,(function*(){yield c(this,dw,"f").join(e)}))}leave(e){return a(this,void 0,void 0,(function*(){yield c(this,dw,"f").release(e)}))}confirmActivity(){return a(this,void 0,void 0,(function*(){yield c(this,dw,"f").confirmActivity()}))}createCameraVideoTrack(e){return a(this,void 0,void 0,(function*(){return yield c(this,dw,"f").createCameraVideoTrack(e)}))}createMicrophoneAudioTrack(e){return a(this,void 0,void 0,(function*(){return yield c(this,dw,"f").createMicrophoneAudioTrack(e)}))}createScreenMediaTracks(e){return a(this,void 0,void 0,(function*(){return yield c(this,dw,"f").createScreenMediaTracks(e)}))}createCustomAudioTrack(e){return c(this,dw,"f").createCustomAudioTrack(e)}createCustomVideoTrack(e){return c(this,dw,"f").createCustomVideoTrack(e)}deleteTrack(e){return a(this,void 0,void 0,(function*(){yield c(this,dw,"f").deleteTrack(e)}))}loadPeers(e){return a(this,void 0,void 0,(function*(){yield c(this,dw,"f").loadPeers(e)}))}requestChannelStateSync(){c(this,dw,"f").requestChannelStateSync()}updateAppData(e){return a(this,void 0,void 0,(function*(){yield c(this,dw,"f").updateAppData(e)}))}getTransportsInfo(){return a(this,void 0,void 0,(function*(){return yield c(this,dw,"f").network.getTransportsStateInfo()}))}setPreferRelay(e){c(this,dw,"f").network.setPreferRelay(e)}getPreferRelay(){return c(this,dw,"f").network.getPreferRelay()}changeIceTransportPolicy(e){return a(this,void 0,void 0,(function*(){yield c(this,uw,"f").changeIceTransportPolicy(e)}))}transportsStats(){return c(this,dw,"f").transportsStats()}setSignalingServerUrl(e){c(this,dw,"f").setSignalingServerUrl(e)}}dw=new WeakMap,uw=new WeakMap;export{lw as default};
|