livekit-client 1.6.2 → 1.6.4
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/livekit-client.esm.mjs +468 -140
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/api/SignalClient.d.ts +3 -3
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/connectionHelper/ConnectionCheck.d.ts +2 -2
- package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/proto/livekit_models.d.ts +53 -4
- package/dist/src/proto/livekit_models.d.ts.map +1 -1
- package/dist/src/proto/livekit_rtc.d.ts +650 -91
- package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
- package/dist/src/room/PCTransport.d.ts +1 -0
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +2 -0
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +1 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/errors.d.ts +3 -0
- package/dist/src/room/errors.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +1 -3
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts +1 -1
- package/dist/src/room/participant/Participant.d.ts.map +1 -1
- package/dist/src/room/timers.d.ts +13 -0
- package/dist/src/room/timers.d.ts.map +1 -0
- package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/create.d.ts.map +1 -1
- package/dist/src/room/track/options.d.ts +2 -2
- package/dist/src/room/track/options.d.ts.map +1 -1
- package/dist/src/test/mocks.d.ts +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +3 -3
- package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +2 -2
- package/dist/ts4.2/src/index.d.ts +2 -1
- package/dist/ts4.2/src/proto/livekit_models.d.ts +59 -4
- package/dist/ts4.2/src/proto/livekit_rtc.d.ts +739 -120
- package/dist/ts4.2/src/room/PCTransport.d.ts +1 -0
- package/dist/ts4.2/src/room/RTCEngine.d.ts +2 -0
- package/dist/ts4.2/src/room/Room.d.ts +1 -1
- package/dist/ts4.2/src/room/errors.d.ts +3 -0
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +1 -3
- package/dist/ts4.2/src/room/participant/Participant.d.ts +1 -1
- package/dist/ts4.2/src/room/timers.d.ts +13 -0
- package/dist/ts4.2/src/room/track/options.d.ts +2 -2
- package/dist/ts4.2/src/test/mocks.d.ts +1 -1
- package/package.json +17 -17
- package/src/api/SignalClient.ts +33 -21
- package/src/connectionHelper/ConnectionCheck.ts +1 -1
- package/src/index.ts +2 -0
- package/src/proto/google/protobuf/timestamp.ts +2 -2
- package/src/proto/livekit_models.ts +158 -10
- package/src/proto/livekit_rtc.ts +205 -6
- package/src/room/PCTransport.ts +22 -6
- package/src/room/RTCEngine.ts +58 -45
- package/src/room/Room.ts +8 -10
- package/src/room/errors.ts +6 -0
- package/src/room/participant/LocalParticipant.ts +12 -17
- package/src/room/participant/Participant.ts +10 -2
- package/src/room/timers.ts +16 -0
- package/src/room/track/RemoteVideoTrack.ts +2 -1
- package/src/room/track/create.ts +6 -1
- package/src/room/track/options.ts +2 -2
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LivekitClient={})}(this,(function(e){"use strict";function t(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(i){if("default"!==i&&!(i in e)){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}}))})),Object.freeze(e)}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,s={};!function(e){var t,n;t=i,n=function(){var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function r(e,t){var i=e[t];if("function"==typeof i.bind)return i.bind(e);try{return Function.prototype.bind.call(i,e)}catch(t){return function(){return Function.prototype.apply.apply(i,[e,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function a(n){return"debug"===n&&(n="log"),typeof console!==t&&("trace"===n&&i?s:void 0!==console[n]?r(console,n):void 0!==console.log?r(console,"log"):e)}function o(t,i){for(var r=0;r<n.length;r++){var s=n[r];this[s]=r<t?e:this.methodFactory(s,t,i)}this.log=this.debug}function c(e,i,n){return function(){typeof console!==t&&(o.call(this,i,n),this[e].apply(this,arguments))}}function d(e,t,i){return a(e)||c.apply(this,arguments)}function u(e,i,r){var s,a=this;i=null==i?"WARN":i;var c="loglevel";function u(){var e;if(typeof window!==t&&c){try{e=window.localStorage[c]}catch(e){}if(typeof e===t)try{var i=window.document.cookie,n=i.indexOf(encodeURIComponent(c)+"=");-1!==n&&(e=/^([^;]+)/.exec(i.slice(n))[1])}catch(e){}return void 0===a.levels[e]&&(e=void 0),e}}"string"==typeof e?c+=":"+e:"symbol"==typeof e&&(c=void 0),a.name=e,a.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},a.methodFactory=r||d,a.getLevel=function(){return s},a.setLevel=function(i,r){if("string"==typeof i&&void 0!==a.levels[i.toUpperCase()]&&(i=a.levels[i.toUpperCase()]),!("number"==typeof i&&i>=0&&i<=a.levels.SILENT))throw"log.setLevel() called with invalid level: "+i;if(s=i,!1!==r&&function(e){var i=(n[e]||"silent").toUpperCase();if(typeof window!==t&&c){try{return void(window.localStorage[c]=i)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+i+";"}catch(e){}}}(i),o.call(a,i,e),typeof console===t&&i<a.levels.SILENT)return"No console available for logging"},a.setDefaultLevel=function(e){i=e,u()||a.setLevel(e,!1)},a.resetLevel=function(){a.setLevel(i,!1),function(){if(typeof window!==t&&c){try{return void window.localStorage.removeItem(c)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},a.enableAll=function(e){a.setLevel(a.levels.TRACE,e)},a.disableAll=function(e){a.setLevel(a.levels.SILENT,e)};var l=u();null==l&&(l=i),a.setLevel(l,!1)}var l=new u,h={};l.getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=h[e];return t||(t=h[e]=new u(e,l.getLevel(),l.methodFactory)),t};var p=typeof window!==t?window.log:void 0;return l.noConflict=function(){return typeof window!==t&&window.log===l&&(window.log=p),l},l.getLoggers=function(){return h},l.default=l,l},e.exports?e.exports=n():t.log=n()}({get exports(){return s},set exports(e){s=e}}),e.LogLevel=void 0,(r=e.LogLevel||(e.LogLevel={}))[r.trace=0]="trace",r[r.debug=1]="debug",r[r.info=2]="info",r[r.warn=3]="warn",r[r.error=4]="error",r[r.silent=5]="silent";const a=s.getLogger("livekit");a.setLevel(e.LogLevel.info);var o=d,c=null;try{c=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function d(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function u(e){return!0===(e&&e.__isLong__)}d.prototype.__isLong__,Object.defineProperty(d.prototype,"__isLong__",{value:!0}),d.isLong=u;var l={},h={};function p(e,t){var i,n,r;return t?(r=0<=(e>>>=0)&&e<256)&&(n=h[e])?n:(i=v(e,(0|e)<0?-1:0,!0),r&&(h[e]=i),i):(r=-128<=(e|=0)&&e<128)&&(n=l[e])?n:(i=v(e,e<0?-1:0,!1),r&&(l[e]=i),i)}function m(e,t){if(isNaN(e))return t?T:C;if(t){if(e<0)return T;if(e>=y)return N}else{if(e<=-S)return D;if(e+1>=S)return O}return e<0?m(-e,t).neg():v(e%k|0,e/k|0,t)}function v(e,t,i){return new d(e,t,i)}d.fromInt=p,d.fromNumber=m,d.fromBits=v;var f=Math.pow;function g(e,t,i){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return C;if("number"==typeof t?(i=t,t=!1):t=!!t,(i=i||10)<2||36<i)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return g(e.substring(1),t,i).neg();for(var r=m(f(i,8)),s=C,a=0;a<e.length;a+=8){var o=Math.min(8,e.length-a),c=parseInt(e.substring(a,a+o),i);if(o<8){var d=m(f(i,o));s=s.mul(d).add(m(c))}else s=(s=s.mul(r)).add(m(c))}return s.unsigned=t,s}function b(e,t){return"number"==typeof e?m(e,t):"string"==typeof e?g(e,t):v(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}d.fromString=g,d.fromValue=b;var k=4294967296,y=k*k,S=y/2,w=p(1<<24),C=p(0);d.ZERO=C;var T=p(0,!0);d.UZERO=T;var E=p(1);d.ONE=E;var P=p(1,!0);d.UONE=P;var R=p(-1);d.NEG_ONE=R;var O=v(-1,2147483647,!1);d.MAX_VALUE=O;var N=v(-1,-1,!0);d.MAX_UNSIGNED_VALUE=N;var D=v(0,-2147483648,!1);d.MIN_VALUE=D;var I=d.prototype;I.toInt=function(){return this.unsigned?this.low>>>0:this.low},I.toNumber=function(){return this.unsigned?(this.high>>>0)*k+(this.low>>>0):this.high*k+(this.low>>>0)},I.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(D)){var t=m(e),i=this.div(t),n=i.mul(t).sub(this);return i.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var r=m(f(e,6),this.unsigned),s=this,a="";;){var o=s.div(r),c=(s.sub(o.mul(r)).toInt()>>>0).toString(e);if((s=o).isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}},I.getHighBits=function(){return this.high},I.getHighBitsUnsigned=function(){return this.high>>>0},I.getLowBits=function(){return this.low},I.getLowBitsUnsigned=function(){return this.low>>>0},I.getNumBitsAbs=function(){if(this.isNegative())return this.eq(D)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},I.isZero=function(){return 0===this.high&&0===this.low},I.eqz=I.isZero,I.isNegative=function(){return!this.unsigned&&this.high<0},I.isPositive=function(){return this.unsigned||this.high>=0},I.isOdd=function(){return 1==(1&this.low)},I.isEven=function(){return 0==(1&this.low)},I.equals=function(e){return u(e)||(e=b(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},I.eq=I.equals,I.notEquals=function(e){return!this.eq(e)},I.neq=I.notEquals,I.ne=I.notEquals,I.lessThan=function(e){return this.comp(e)<0},I.lt=I.lessThan,I.lessThanOrEqual=function(e){return this.comp(e)<=0},I.lte=I.lessThanOrEqual,I.le=I.lessThanOrEqual,I.greaterThan=function(e){return this.comp(e)>0},I.gt=I.greaterThan,I.greaterThanOrEqual=function(e){return this.comp(e)>=0},I.gte=I.greaterThanOrEqual,I.ge=I.greaterThanOrEqual,I.compare=function(e){if(u(e)||(e=b(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},I.comp=I.compare,I.negate=function(){return!this.unsigned&&this.eq(D)?D:this.not().add(E)},I.neg=I.negate,I.add=function(e){u(e)||(e=b(e));var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,r=65535&this.low,s=e.high>>>16,a=65535&e.high,o=e.low>>>16,c=0,d=0,l=0,h=0;return l+=(h+=r+(65535&e.low))>>>16,d+=(l+=n+o)>>>16,c+=(d+=i+a)>>>16,c+=t+s,v((l&=65535)<<16|(h&=65535),(c&=65535)<<16|(d&=65535),this.unsigned)},I.subtract=function(e){return u(e)||(e=b(e)),this.add(e.neg())},I.sub=I.subtract,I.multiply=function(e){if(this.isZero())return C;if(u(e)||(e=b(e)),c)return v(c.mul(this.low,this.high,e.low,e.high),c.get_high(),this.unsigned);if(e.isZero())return C;if(this.eq(D))return e.isOdd()?D:C;if(e.eq(D))return this.isOdd()?D:C;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(w)&&e.lt(w))return m(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,r=65535&this.low,s=e.high>>>16,a=65535&e.high,o=e.low>>>16,d=65535&e.low,l=0,h=0,p=0,f=0;return p+=(f+=r*d)>>>16,h+=(p+=n*d)>>>16,p&=65535,h+=(p+=r*o)>>>16,l+=(h+=i*d)>>>16,h&=65535,l+=(h+=n*o)>>>16,h&=65535,l+=(h+=r*a)>>>16,l+=t*d+i*o+n*a+r*s,v((p&=65535)<<16|(f&=65535),(l&=65535)<<16|(h&=65535),this.unsigned)},I.mul=I.multiply,I.divide=function(e){if(u(e)||(e=b(e)),e.isZero())throw Error("division by zero");var t,i,n;if(c)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?v((this.unsigned?c.div_u:c.div_s)(this.low,this.high,e.low,e.high),c.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?T:C;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return T;if(e.gt(this.shru(1)))return P;n=T}else{if(this.eq(D))return e.eq(E)||e.eq(R)?D:e.eq(D)?E:(t=this.shr(1).div(e).shl(1)).eq(C)?e.isNegative()?E:R:(i=this.sub(e.mul(t)),n=t.add(i.div(e)));if(e.eq(D))return this.unsigned?T:C;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=C}for(i=this;i.gte(e);){t=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var r=Math.ceil(Math.log(t)/Math.LN2),s=r<=48?1:f(2,r-48),a=m(t),o=a.mul(e);o.isNegative()||o.gt(i);)o=(a=m(t-=s,this.unsigned)).mul(e);a.isZero()&&(a=E),n=n.add(a),i=i.sub(o)}return n},I.div=I.divide,I.modulo=function(e){return u(e)||(e=b(e)),c?v((this.unsigned?c.rem_u:c.rem_s)(this.low,this.high,e.low,e.high),c.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},I.mod=I.modulo,I.rem=I.modulo,I.not=function(){return v(~this.low,~this.high,this.unsigned)},I.and=function(e){return u(e)||(e=b(e)),v(this.low&e.low,this.high&e.high,this.unsigned)},I.or=function(e){return u(e)||(e=b(e)),v(this.low|e.low,this.high|e.high,this.unsigned)},I.xor=function(e){return u(e)||(e=b(e)),v(this.low^e.low,this.high^e.high,this.unsigned)},I.shiftLeft=function(e){return u(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?v(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):v(0,this.low<<e-32,this.unsigned)},I.shl=I.shiftLeft,I.shiftRight=function(e){return u(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?v(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):v(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},I.shr=I.shiftRight,I.shiftRightUnsigned=function(e){if(u(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?v(this.low>>>e|t<<32-e,t>>>e,this.unsigned):v(32===e?t:t>>>e-32,0,this.unsigned)},I.shru=I.shiftRightUnsigned,I.shr_u=I.shiftRightUnsigned,I.toSigned=function(){return this.unsigned?v(this.low,this.high,!1):this},I.toUnsigned=function(){return this.unsigned?this:v(this.low,this.high,!0)},I.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},I.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},I.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},d.fromBytes=function(e,t,i){return i?d.fromBytesLE(e,t):d.fromBytesBE(e,t)},d.fromBytesLE=function(e,t){return new d(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},d.fromBytesBE=function(e,t){return new d(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var A,U,L={},x={get exports(){return L},set exports(e){L=e}},M={},_={};var J,$,B,j,V,F,q,W={};var G,Q,z,H,Z,K,Y={};function X(){return K||(K=1,function(e){var t=e;function n(e,t,i){for(var n=Object.keys(t),r=0;r<n.length;++r)void 0!==e[n[r]]&&i||(e[n[r]]=t[n[r]]);return e}function r(e){function t(e,i){if(!(this instanceof t))return new t(e,i);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),i&&n(this,i)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:()=>e,set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}t.asPromise=(U||(U=1,A=function(e,t){for(var i=new Array(arguments.length-1),n=0,r=2,s=!0;r<arguments.length;)i[n++]=arguments[r++];return new Promise((function(r,a){i[n]=function(e){if(s)if(s=!1,e)a(e);else{for(var t=new Array(arguments.length-1),i=0;i<t.length;)t[i++]=arguments[i];r.apply(null,t)}};try{e.apply(t||null,i)}catch(e){s&&(s=!1,a(e))}}))}),A),t.base64=(J||(J=1,function(e){var t=e;t.length=function(e){var t=e.length;if(!t)return 0;for(var i=0;--t%4>1&&"="===e.charAt(t);)++i;return Math.ceil(3*e.length)/4-i};for(var i=new Array(64),n=new Array(123),r=0;r<64;)n[i[r]=r<26?r+65:r<52?r+71:r<62?r-4:r-59|43]=r++;t.encode=function(e,t,n){for(var r,s=null,a=[],o=0,c=0;t<n;){var d=e[t++];switch(c){case 0:a[o++]=i[d>>2],r=(3&d)<<4,c=1;break;case 1:a[o++]=i[r|d>>4],r=(15&d)<<2,c=2;break;case 2:a[o++]=i[r|d>>6],a[o++]=i[63&d],c=0}o>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,a)),o=0)}return c&&(a[o++]=i[r],a[o++]=61,1===c&&(a[o++]=61)),s?(o&&s.push(String.fromCharCode.apply(String,a.slice(0,o))),s.join("")):String.fromCharCode.apply(String,a.slice(0,o))};var s="invalid encoding";t.decode=function(e,t,i){for(var r,a=i,o=0,c=0;c<e.length;){var d=e.charCodeAt(c++);if(61===d&&o>1)break;if(void 0===(d=n[d]))throw Error(s);switch(o){case 0:r=d,o=1;break;case 1:t[i++]=r<<2|(48&d)>>4,r=d,o=2;break;case 2:t[i++]=(15&r)<<4|(60&d)>>2,r=d,o=3;break;case 3:t[i++]=(3&r)<<6|d,o=0}}if(1===o)throw Error(s);return i-a},t.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}}(W)),W),t.EventEmitter=function(){if(B)return $;function e(){this._listeners={}}return B=1,$=e,e.prototype.on=function(e,t,i){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:i||this}),this},e.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var i=this._listeners[e],n=0;n<i.length;)i[n].fn===t?i.splice(n,1):++n;return this},e.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var i=[],n=1;n<arguments.length;)i.push(arguments[n++]);for(n=0;n<t.length;)t[n].fn.apply(t[n++].ctx,i)}return this},$}(),t.float=function(){if(V)return j;function e(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),i=new Uint8Array(t.buffer),n=128===i[3];function r(e,n,r){t[0]=e,n[r]=i[0],n[r+1]=i[1],n[r+2]=i[2],n[r+3]=i[3]}function s(e,n,r){t[0]=e,n[r]=i[3],n[r+1]=i[2],n[r+2]=i[1],n[r+3]=i[0]}function a(e,n){return i[0]=e[n],i[1]=e[n+1],i[2]=e[n+2],i[3]=e[n+3],t[0]}function o(e,n){return i[3]=e[n],i[2]=e[n+1],i[1]=e[n+2],i[0]=e[n+3],t[0]}e.writeFloatLE=n?r:s,e.writeFloatBE=n?s:r,e.readFloatLE=n?a:o,e.readFloatBE=n?o:a}():function(){function s(e,t,i,n){var r=t<0?1:0;if(r&&(t=-t),0===t)e(1/t>0?0:2147483648,i,n);else if(isNaN(t))e(2143289344,i,n);else if(t>34028234663852886e22)e((r<<31|2139095040)>>>0,i,n);else if(t<11754943508222875e-54)e((r<<31|Math.round(t/1401298464324817e-60))>>>0,i,n);else{var s=Math.floor(Math.log(t)/Math.LN2);e((r<<31|s+127<<23|8388607&Math.round(t*Math.pow(2,-s)*8388608))>>>0,i,n)}}function a(e,t,i){var n=e(t,i),r=2*(n>>31)+1,s=n>>>23&255,a=8388607&n;return 255===s?a?NaN:r*(1/0):0===s?1401298464324817e-60*r*a:r*Math.pow(2,s-150)*(a+8388608)}e.writeFloatLE=s.bind(null,t),e.writeFloatBE=s.bind(null,i),e.readFloatLE=a.bind(null,n),e.readFloatBE=a.bind(null,r)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),i=new Uint8Array(t.buffer),n=128===i[7];function r(e,n,r){t[0]=e,n[r]=i[0],n[r+1]=i[1],n[r+2]=i[2],n[r+3]=i[3],n[r+4]=i[4],n[r+5]=i[5],n[r+6]=i[6],n[r+7]=i[7]}function s(e,n,r){t[0]=e,n[r]=i[7],n[r+1]=i[6],n[r+2]=i[5],n[r+3]=i[4],n[r+4]=i[3],n[r+5]=i[2],n[r+6]=i[1],n[r+7]=i[0]}function a(e,n){return i[0]=e[n],i[1]=e[n+1],i[2]=e[n+2],i[3]=e[n+3],i[4]=e[n+4],i[5]=e[n+5],i[6]=e[n+6],i[7]=e[n+7],t[0]}function o(e,n){return i[7]=e[n],i[6]=e[n+1],i[5]=e[n+2],i[4]=e[n+3],i[3]=e[n+4],i[2]=e[n+5],i[1]=e[n+6],i[0]=e[n+7],t[0]}e.writeDoubleLE=n?r:s,e.writeDoubleBE=n?s:r,e.readDoubleLE=n?a:o,e.readDoubleBE=n?o:a}():function(){function s(e,t,i,n,r,s){var a=n<0?1:0;if(a&&(n=-n),0===n)e(0,r,s+t),e(1/n>0?0:2147483648,r,s+i);else if(isNaN(n))e(0,r,s+t),e(2146959360,r,s+i);else if(n>17976931348623157e292)e(0,r,s+t),e((a<<31|2146435072)>>>0,r,s+i);else{var o;if(n<22250738585072014e-324)e((o=n/5e-324)>>>0,r,s+t),e((a<<31|o/4294967296)>>>0,r,s+i);else{var c=Math.floor(Math.log(n)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(o=n*Math.pow(2,-c))>>>0,r,s+t),e((a<<31|c+1023<<20|1048576*o&1048575)>>>0,r,s+i)}}}function a(e,t,i,n,r){var s=e(n,r+t),a=e(n,r+i),o=2*(a>>31)+1,c=a>>>20&2047,d=4294967296*(1048575&a)+s;return 2047===c?d?NaN:o*(1/0):0===c?5e-324*o*d:o*Math.pow(2,c-1075)*(d+4503599627370496)}e.writeDoubleLE=s.bind(null,t,0,4),e.writeDoubleBE=s.bind(null,i,4,0),e.readDoubleLE=a.bind(null,n,0,4),e.readDoubleBE=a.bind(null,r,4,0)}(),e}function t(e,t,i){t[i]=255&e,t[i+1]=e>>>8&255,t[i+2]=e>>>16&255,t[i+3]=e>>>24}function i(e,t,i){t[i]=e>>>24,t[i+1]=e>>>16&255,t[i+2]=e>>>8&255,t[i+3]=255&e}function n(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function r(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}return V=1,j=e(e)}(),t.inquire=q?F:(q=1,F=function(e){return null}),t.utf8=(G||(G=1,function(e){var t=e;t.length=function(e){for(var t=0,i=0,n=0;n<e.length;++n)(i=e.charCodeAt(n))<128?t+=1:i<2048?t+=2:55296==(64512&i)&&56320==(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t},t.read=function(e,t,i){if(i-t<1)return"";for(var n,r=null,s=[],a=0;t<i;)(n=e[t++])<128?s[a++]=n:n>191&&n<224?s[a++]=(31&n)<<6|63&e[t++]:n>239&&n<365?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,s[a++]=55296+(n>>10),s[a++]=56320+(1023&n)):s[a++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],a>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,s)),a=0);return r?(a&&r.push(String.fromCharCode.apply(String,s.slice(0,a))),r.join("")):String.fromCharCode.apply(String,s.slice(0,a))},t.write=function(e,t,i){for(var n,r,s=i,a=0;a<e.length;++a)(n=e.charCodeAt(a))<128?t[i++]=n:n<2048?(t[i++]=n>>6|192,t[i++]=63&n|128):55296==(64512&n)&&56320==(64512&(r=e.charCodeAt(a+1)))?(n=65536+((1023&n)<<10)+(1023&r),++a,t[i++]=n>>18|240,t[i++]=n>>12&63|128,t[i++]=n>>6&63|128,t[i++]=63&n|128):(t[i++]=n>>12|224,t[i++]=n>>6&63|128,t[i++]=63&n|128);return i-s}}(Y)),Y),t.pool=z?Q:(z=1,Q=function(e,t,i){var n=i||8192,r=n>>>1,s=null,a=n;return function(i){if(i<1||i>r)return e(i);a+i>n&&(s=e(n),a=0);var o=t.call(s,a,a+=i);return 7&a&&(a=1+(7|a)),o}}),t.LongBits=function(){if(Z)return H;Z=1,H=t;var e=X();function t(e,t){this.lo=e>>>0,this.hi=t>>>0}var i=t.zero=new t(0,0);i.toNumber=function(){return 0},i.zzEncode=i.zzDecode=function(){return this},i.length=function(){return 1};var n=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(e){if(0===e)return i;var n=e<0;n&&(e=-e);var r=e>>>0,s=(e-r)/4294967296>>>0;return n&&(s=~s>>>0,r=~r>>>0,++r>4294967295&&(r=0,++s>4294967295&&(s=0))),new t(r,s)},t.from=function(n){if("number"==typeof n)return t.fromNumber(n);if(e.isString(n)){if(!e.Long)return t.fromNumber(parseInt(n,10));n=e.Long.fromString(n)}return n.low||n.high?new t(n.low>>>0,n.high>>>0):i},t.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,i=~this.hi>>>0;return t||(i=i+1>>>0),-(t+4294967296*i)}return this.lo+4294967296*this.hi},t.prototype.toLong=function(t){return e.Long?new e.Long(0|this.lo,0|this.hi,Boolean(t)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(t)}};var r=String.prototype.charCodeAt;return t.fromHash=function(e){return e===n?i:new t((r.call(e,0)|r.call(e,1)<<8|r.call(e,2)<<16|r.call(e,3)<<24)>>>0,(r.call(e,4)|r.call(e,5)<<8|r.call(e,6)<<16|r.call(e,7)<<24)>>>0)},t.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},t.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},t.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},t.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return 0===i?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:i<128?9:10},H}(),t.isNode=Boolean(void 0!==i&&i&&i.process&&i.process.versions&&i.process.versions.node),t.global=t.isNode&&i||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||i,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},t.isString=function(e){return"string"==typeof e||e instanceof String},t.isObject=function(e){return e&&"object"==typeof e},t.isset=t.isSet=function(e,t){var i=e[t];return!(null==i||!e.hasOwnProperty(t))&&("object"!=typeof i||(Array.isArray(i)?i.length:Object.keys(i).length)>0)},t.Buffer=function(){try{var e=t.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(e){return"number"==typeof e?t.Buffer?t._Buffer_allocUnsafe(e):new t.Array(e):t.Buffer?t._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},t.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(e){return e?t.LongBits.from(e).toHash():t.LongBits.zeroHash},t.longFromHash=function(e,i){var n=t.LongBits.fromHash(e);return t.Long?t.Long.fromBits(n.lo,n.hi,i):n.toNumber(Boolean(i))},t.merge=n,t.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},t.newError=r,t.ProtocolError=r("ProtocolError"),t.oneOfGetter=function(e){for(var t={},i=0;i<e.length;++i)t[e[i]]=1;return function(){for(var e=Object.keys(this),i=e.length-1;i>-1;--i)if(1===t[e[i]]&&void 0!==this[e[i]]&&null!==this[e[i]])return e[i]}},t.oneOfSetter=function(e){return function(t){for(var i=0;i<e.length;++i)e[i]!==t&&delete this[e[i]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var e=t.Buffer;e?(t._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,i){return new e(t,i)},t._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):t._Buffer_from=t._Buffer_allocUnsafe=null}}(_)),_}var ee,te=de,ie=X(),ne=ie.LongBits,re=ie.base64,se=ie.utf8;function ae(e,t,i){this.fn=e,this.len=t,this.next=void 0,this.val=i}function oe(){}function ce(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function de(){this.len=0,this.head=new ae(oe,0,0),this.tail=this.head,this.states=null}var ue=function(){return ie.Buffer?function(){return(de.create=function(){return new ee})()}:function(){return new de}};function le(e,t,i){t[i]=255&e}function he(e,t){this.len=e,this.next=void 0,this.val=t}function pe(e,t,i){for(;e.hi;)t[i++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[i++]=127&e.lo|128,e.lo=e.lo>>>7;t[i++]=e.lo}function me(e,t,i){t[i]=255&e,t[i+1]=e>>>8&255,t[i+2]=e>>>16&255,t[i+3]=e>>>24}de.create=ue(),de.alloc=function(e){return new ie.Array(e)},ie.Array!==Array&&(de.alloc=ie.pool(de.alloc,ie.Array.prototype.subarray)),de.prototype._push=function(e,t,i){return this.tail=this.tail.next=new ae(e,t,i),this.len+=t,this},he.prototype=Object.create(ae.prototype),he.prototype.fn=function(e,t,i){for(;e>127;)t[i++]=127&e|128,e>>>=7;t[i]=e},de.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new he((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},de.prototype.int32=function(e){return e<0?this._push(pe,10,ne.fromNumber(e)):this.uint32(e)},de.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},de.prototype.uint64=function(e){var t=ne.from(e);return this._push(pe,t.length(),t)},de.prototype.int64=de.prototype.uint64,de.prototype.sint64=function(e){var t=ne.from(e).zzEncode();return this._push(pe,t.length(),t)},de.prototype.bool=function(e){return this._push(le,1,e?1:0)},de.prototype.fixed32=function(e){return this._push(me,4,e>>>0)},de.prototype.sfixed32=de.prototype.fixed32,de.prototype.fixed64=function(e){var t=ne.from(e);return this._push(me,4,t.lo)._push(me,4,t.hi)},de.prototype.sfixed64=de.prototype.fixed64,de.prototype.float=function(e){return this._push(ie.float.writeFloatLE,4,e)},de.prototype.double=function(e){return this._push(ie.float.writeDoubleLE,8,e)};var ve=ie.Array.prototype.set?function(e,t,i){t.set(e,i)}:function(e,t,i){for(var n=0;n<e.length;++n)t[i+n]=e[n]};de.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(le,1,0);if(ie.isString(e)){var i=de.alloc(t=re.length(e));re.decode(e,i,0),e=i}return this.uint32(t)._push(ve,t,e)},de.prototype.string=function(e){var t=se.length(e);return t?this.uint32(t)._push(se.write,t,e):this._push(le,1,0)},de.prototype.fork=function(){return this.states=new ce(this),this.head=this.tail=new ae(oe,0,0),this.len=0,this},de.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new ae(oe,0,0),this.len=0),this},de.prototype.ldelim=function(){var e=this.head,t=this.tail,i=this.len;return this.reset().uint32(i),i&&(this.tail.next=e.next,this.tail=t,this.len+=i),this},de.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),i=0;e;)e.fn(e.val,t,i),i+=e.len,e=e.next;return t},de._configure=function(e){ee=e,de.create=ue(),ee._configure()};var fe=ke,ge=te;(ke.prototype=Object.create(ge.prototype)).constructor=ke;var be=X();function ke(){ge.call(this)}function ye(e,t,i){e.length<40?be.utf8.write(e,t,i):t.utf8Write?t.utf8Write(e,i):t.write(e,i)}ke._configure=function(){ke.alloc=be._Buffer_allocUnsafe,ke.writeBytesBuffer=be.Buffer&&be.Buffer.prototype instanceof Uint8Array&&"set"===be.Buffer.prototype.set.name?function(e,t,i){t.set(e,i)}:function(e,t,i){if(e.copy)e.copy(t,i,0,e.length);else for(var n=0;n<e.length;)t[i++]=e[n++]}},ke.prototype.bytes=function(e){be.isString(e)&&(e=be._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(ke.writeBytesBuffer,t,e),this},ke.prototype.string=function(e){var t=be.Buffer.byteLength(e);return this.uint32(t),t&&this._push(ye,t,e),this},ke._configure();var Se,we=Re,Ce=X(),Te=Ce.LongBits,Ee=Ce.utf8;function Pe(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function Re(e){this.buf=e,this.pos=0,this.len=e.length}var Oe,Ne="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new Re(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new Re(e);throw Error("illegal buffer")},De=function(){return Ce.Buffer?function(e){return(Re.create=function(e){return Ce.Buffer.isBuffer(e)?new Se(e):Ne(e)})(e)}:Ne};function Ie(){var e=new Te(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw Pe(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Pe(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function Ae(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function Ue(){if(this.pos+8>this.len)throw Pe(this,8);return new Te(Ae(this.buf,this.pos+=4),Ae(this.buf,this.pos+=4))}Re.create=De(),Re.prototype._slice=Ce.Array.prototype.subarray||Ce.Array.prototype.slice,Re.prototype.uint32=(Oe=4294967295,function(){if(Oe=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return Oe;if(Oe=(Oe|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return Oe;if(Oe=(Oe|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return Oe;if(Oe=(Oe|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return Oe;if(Oe=(Oe|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return Oe;if((this.pos+=5)>this.len)throw this.pos=this.len,Pe(this,10);return Oe}),Re.prototype.int32=function(){return 0|this.uint32()},Re.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},Re.prototype.bool=function(){return 0!==this.uint32()},Re.prototype.fixed32=function(){if(this.pos+4>this.len)throw Pe(this,4);return Ae(this.buf,this.pos+=4)},Re.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Pe(this,4);return 0|Ae(this.buf,this.pos+=4)},Re.prototype.float=function(){if(this.pos+4>this.len)throw Pe(this,4);var e=Ce.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},Re.prototype.double=function(){if(this.pos+8>this.len)throw Pe(this,4);var e=Ce.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},Re.prototype.bytes=function(){var e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw Pe(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,i):t===i?new this.buf.constructor(0):this._slice.call(this.buf,t,i)},Re.prototype.string=function(){var e=this.bytes();return Ee.read(e,0,e.length)},Re.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw Pe(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw Pe(this)}while(128&this.buf[this.pos++]);return this},Re.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},Re._configure=function(e){Se=e,Re.create=De(),Se._configure();var t=Ce.Long?"toLong":"toNumber";Ce.merge(Re.prototype,{int64:function(){return Ie.call(this)[t](!1)},uint64:function(){return Ie.call(this)[t](!0)},sint64:function(){return Ie.call(this).zzDecode()[t](!1)},fixed64:function(){return Ue.call(this)[t](!0)},sfixed64:function(){return Ue.call(this)[t](!1)}})};var Le=_e,xe=we;(_e.prototype=Object.create(xe.prototype)).constructor=_e;var Me=X();function _e(e){xe.call(this,e)}_e._configure=function(){Me.Buffer&&(_e.prototype._slice=Me.Buffer.prototype.slice)},_e.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},_e._configure();var Je={},$e=je,Be=X();function je(e,t,i){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");Be.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(i)}(je.prototype=Object.create(Be.EventEmitter.prototype)).constructor=je,je.prototype.rpcCall=function e(t,i,n,r,s){if(!r)throw TypeError("request must be specified");var a=this;if(!s)return Be.asPromise(e,a,t,i,n,r);if(a.rpcImpl)try{return a.rpcImpl(t,i[a.requestDelimited?"encodeDelimited":"encode"](r).finish(),(function(e,i){if(e)return a.emit("error",e,t),s(e);if(null!==i){if(!(i instanceof n))try{i=n[a.responseDelimited?"decodeDelimited":"decode"](i)}catch(e){return a.emit("error",e,t),s(e)}return a.emit("data",i,t),s(null,i)}a.end(!0)}))}catch(e){return a.emit("error",e,t),void setTimeout((function(){s(e)}),0)}else setTimeout((function(){s(Error("already ended"))}),0)},je.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},function(e){e.Service=$e}(Je);var Ve={};!function(e){var t=e;function i(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}t.build="minimal",t.Writer=te,t.BufferWriter=fe,t.Reader=we,t.BufferReader=Le,t.util=X(),t.rpc=Je,t.roots=Ve,t.configure=i,i()}(M),function(e){e.exports=M}(x);var Fe,qe,We,Ge,Qe,ze,He,Ze,Ke,Ye,Xe=n(L),et=(()=>{if(void 0!==et)return et;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw"Unable to locate global object"})();function tt(e){switch(e){case 0:case"AUDIO":return Fe.AUDIO;case 1:case"VIDEO":return Fe.VIDEO;case 2:case"DATA":return Fe.DATA;default:return Fe.UNRECOGNIZED}}function it(e){switch(e){case Fe.AUDIO:return"AUDIO";case Fe.VIDEO:return"VIDEO";case Fe.DATA:return"DATA";case Fe.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function nt(e){switch(e){case 0:case"UNKNOWN":return qe.UNKNOWN;case 1:case"CAMERA":return qe.CAMERA;case 2:case"MICROPHONE":return qe.MICROPHONE;case 3:case"SCREEN_SHARE":return qe.SCREEN_SHARE;case 4:case"SCREEN_SHARE_AUDIO":return qe.SCREEN_SHARE_AUDIO;default:return qe.UNRECOGNIZED}}function rt(e){switch(e){case qe.UNKNOWN:return"UNKNOWN";case qe.CAMERA:return"CAMERA";case qe.MICROPHONE:return"MICROPHONE";case qe.SCREEN_SHARE:return"SCREEN_SHARE";case qe.SCREEN_SHARE_AUDIO:return"SCREEN_SHARE_AUDIO";case qe.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function st(t){switch(t){case 0:case"LOW":return e.VideoQuality.LOW;case 1:case"MEDIUM":return e.VideoQuality.MEDIUM;case 2:case"HIGH":return e.VideoQuality.HIGH;case 3:case"OFF":return e.VideoQuality.OFF;default:return e.VideoQuality.UNRECOGNIZED}}function at(t){switch(t){case e.VideoQuality.LOW:return"LOW";case e.VideoQuality.MEDIUM:return"MEDIUM";case e.VideoQuality.HIGH:return"HIGH";case e.VideoQuality.OFF:return"OFF";case e.VideoQuality.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function ot(e){switch(e){case 0:case"POOR":return Ge.POOR;case 1:case"GOOD":return Ge.GOOD;case 2:case"EXCELLENT":return Ge.EXCELLENT;default:return Ge.UNRECOGNIZED}}function ct(e){switch(e){case 0:case"UNSET":return Qe.UNSET;case 1:case"DISABLED":return Qe.DISABLED;case 2:case"ENABLED":return Qe.ENABLED;default:return Qe.UNRECOGNIZED}}function dt(e){switch(e){case Qe.UNSET:return"UNSET";case Qe.DISABLED:return"DISABLED";case Qe.ENABLED:return"ENABLED";case Qe.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function ut(t){switch(t){case 0:case"UNKNOWN_REASON":return e.DisconnectReason.UNKNOWN_REASON;case 1:case"CLIENT_INITIATED":return e.DisconnectReason.CLIENT_INITIATED;case 2:case"DUPLICATE_IDENTITY":return e.DisconnectReason.DUPLICATE_IDENTITY;case 3:case"SERVER_SHUTDOWN":return e.DisconnectReason.SERVER_SHUTDOWN;case 4:case"PARTICIPANT_REMOVED":return e.DisconnectReason.PARTICIPANT_REMOVED;case 5:case"ROOM_DELETED":return e.DisconnectReason.ROOM_DELETED;case 6:case"STATE_MISMATCH":return e.DisconnectReason.STATE_MISMATCH;case 7:case"JOIN_FAILURE":return e.DisconnectReason.JOIN_FAILURE;default:return e.DisconnectReason.UNRECOGNIZED}}function lt(e){switch(e){case 0:case"JOINING":return He.JOINING;case 1:case"JOINED":return He.JOINED;case 2:case"ACTIVE":return He.ACTIVE;case 3:case"DISCONNECTED":return He.DISCONNECTED;default:return He.UNRECOGNIZED}}function ht(t){switch(t){case 0:case"RELIABLE":return e.DataPacket_Kind.RELIABLE;case 1:case"LOSSY":return e.DataPacket_Kind.LOSSY;default:return e.DataPacket_Kind.UNRECOGNIZED}}function pt(e){switch(e){case 0:case"Standard":return Ke.Standard;case 1:case"Cloud":return Ke.Cloud;default:return Ke.UNRECOGNIZED}}function mt(e){switch(e){case 0:case"UNKNOWN":return Ye.UNKNOWN;case 1:case"JS":return Ye.JS;case 2:case"SWIFT":return Ye.SWIFT;case 3:case"ANDROID":return Ye.ANDROID;case 4:case"FLUTTER":return Ye.FLUTTER;case 5:case"GO":return Ye.GO;case 6:case"UNITY":return Ye.UNITY;default:return Ye.UNRECOGNIZED}}Xe.util.Long!==o&&(Xe.util.Long=o,Xe.configure()),function(e){e[e.AUDIO=0]="AUDIO",e[e.VIDEO=1]="VIDEO",e[e.DATA=2]="DATA",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Fe||(Fe={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.CAMERA=1]="CAMERA",e[e.MICROPHONE=2]="MICROPHONE",e[e.SCREEN_SHARE=3]="SCREEN_SHARE",e[e.SCREEN_SHARE_AUDIO=4]="SCREEN_SHARE_AUDIO",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(qe||(qe={})),e.VideoQuality=void 0,(We=e.VideoQuality||(e.VideoQuality={}))[We.LOW=0]="LOW",We[We.MEDIUM=1]="MEDIUM",We[We.HIGH=2]="HIGH",We[We.OFF=3]="OFF",We[We.UNRECOGNIZED=-1]="UNRECOGNIZED",function(e){e[e.POOR=0]="POOR",e[e.GOOD=1]="GOOD",e[e.EXCELLENT=2]="EXCELLENT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ge||(Ge={})),function(e){e[e.UNSET=0]="UNSET",e[e.DISABLED=1]="DISABLED",e[e.ENABLED=2]="ENABLED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Qe||(Qe={})),e.DisconnectReason=void 0,(ze=e.DisconnectReason||(e.DisconnectReason={}))[ze.UNKNOWN_REASON=0]="UNKNOWN_REASON",ze[ze.CLIENT_INITIATED=1]="CLIENT_INITIATED",ze[ze.DUPLICATE_IDENTITY=2]="DUPLICATE_IDENTITY",ze[ze.SERVER_SHUTDOWN=3]="SERVER_SHUTDOWN",ze[ze.PARTICIPANT_REMOVED=4]="PARTICIPANT_REMOVED",ze[ze.ROOM_DELETED=5]="ROOM_DELETED",ze[ze.STATE_MISMATCH=6]="STATE_MISMATCH",ze[ze.JOIN_FAILURE=7]="JOIN_FAILURE",ze[ze.UNRECOGNIZED=-1]="UNRECOGNIZED",function(e){e[e.JOINING=0]="JOINING",e[e.JOINED=1]="JOINED",e[e.ACTIVE=2]="ACTIVE",e[e.DISCONNECTED=3]="DISCONNECTED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(He||(He={})),e.DataPacket_Kind=void 0,(Ze=e.DataPacket_Kind||(e.DataPacket_Kind={}))[Ze.RELIABLE=0]="RELIABLE",Ze[Ze.LOSSY=1]="LOSSY",Ze[Ze.UNRECOGNIZED=-1]="UNRECOGNIZED",function(e){e[e.Standard=0]="Standard",e[e.Cloud=1]="Cloud",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ke||(Ke={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.JS=1]="JS",e[e.SWIFT=2]="SWIFT",e[e.ANDROID=3]="ANDROID",e[e.FLUTTER=4]="FLUTTER",e[e.GO=5]="GO",e[e.UNITY=6]="UNITY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ye||(Ye={}));const vt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();""!==e.sid&&t.uint32(10).string(e.sid),""!==e.name&&t.uint32(18).string(e.name),0!==e.emptyTimeout&&t.uint32(24).uint32(e.emptyTimeout),0!==e.maxParticipants&&t.uint32(32).uint32(e.maxParticipants),0!==e.creationTime&&t.uint32(40).int64(e.creationTime),""!==e.turnPassword&&t.uint32(50).string(e.turnPassword);for(const i of e.enabledCodecs)ft.encode(i,t.uint32(58).fork()).ldelim();return""!==e.metadata&&t.uint32(66).string(e.metadata),0!==e.numParticipants&&t.uint32(72).uint32(e.numParticipants),!0===e.activeRecording&&t.uint32(80).bool(e.activeRecording),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={sid:"",name:"",emptyTimeout:0,maxParticipants:0,creationTime:0,turnPassword:"",enabledCodecs:[],metadata:"",numParticipants:0,activeRecording:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.sid=i.string();break;case 2:r.name=i.string();break;case 3:r.emptyTimeout=i.uint32();break;case 4:r.maxParticipants=i.uint32();break;case 5:r.creationTime=xt(i.int64());break;case 6:r.turnPassword=i.string();break;case 7:r.enabledCodecs.push(ft.decode(i,i.uint32()));break;case 8:r.metadata=i.string();break;case 9:r.numParticipants=i.uint32();break;case 10:r.activeRecording=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({sid:Mt(e.sid)?String(e.sid):"",name:Mt(e.name)?String(e.name):"",emptyTimeout:Mt(e.emptyTimeout)?Number(e.emptyTimeout):0,maxParticipants:Mt(e.maxParticipants)?Number(e.maxParticipants):0,creationTime:Mt(e.creationTime)?Number(e.creationTime):0,turnPassword:Mt(e.turnPassword)?String(e.turnPassword):"",enabledCodecs:Array.isArray(null==e?void 0:e.enabledCodecs)?e.enabledCodecs.map((e=>ft.fromJSON(e))):[],metadata:Mt(e.metadata)?String(e.metadata):"",numParticipants:Mt(e.numParticipants)?Number(e.numParticipants):0,activeRecording:!!Mt(e.activeRecording)&&Boolean(e.activeRecording)}),toJSON(e){const t={};return void 0!==e.sid&&(t.sid=e.sid),void 0!==e.name&&(t.name=e.name),void 0!==e.emptyTimeout&&(t.emptyTimeout=Math.round(e.emptyTimeout)),void 0!==e.maxParticipants&&(t.maxParticipants=Math.round(e.maxParticipants)),void 0!==e.creationTime&&(t.creationTime=Math.round(e.creationTime)),void 0!==e.turnPassword&&(t.turnPassword=e.turnPassword),e.enabledCodecs?t.enabledCodecs=e.enabledCodecs.map((e=>e?ft.toJSON(e):void 0)):t.enabledCodecs=[],void 0!==e.metadata&&(t.metadata=e.metadata),void 0!==e.numParticipants&&(t.numParticipants=Math.round(e.numParticipants)),void 0!==e.activeRecording&&(t.activeRecording=e.activeRecording),t},fromPartial(e){var t,i,n,r,s,a,o,c,d,u;const l={sid:"",name:"",emptyTimeout:0,maxParticipants:0,creationTime:0,turnPassword:"",enabledCodecs:[],metadata:"",numParticipants:0,activeRecording:!1};return l.sid=null!==(t=e.sid)&&void 0!==t?t:"",l.name=null!==(i=e.name)&&void 0!==i?i:"",l.emptyTimeout=null!==(n=e.emptyTimeout)&&void 0!==n?n:0,l.maxParticipants=null!==(r=e.maxParticipants)&&void 0!==r?r:0,l.creationTime=null!==(s=e.creationTime)&&void 0!==s?s:0,l.turnPassword=null!==(a=e.turnPassword)&&void 0!==a?a:"",l.enabledCodecs=(null===(o=e.enabledCodecs)||void 0===o?void 0:o.map((e=>ft.fromPartial(e))))||[],l.metadata=null!==(c=e.metadata)&&void 0!==c?c:"",l.numParticipants=null!==(d=e.numParticipants)&&void 0!==d?d:0,l.activeRecording=null!==(u=e.activeRecording)&&void 0!==u&&u,l}};const ft={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return""!==e.mime&&t.uint32(10).string(e.mime),""!==e.fmtpLine&&t.uint32(18).string(e.fmtpLine),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={mime:"",fmtpLine:""};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.mime=i.string();break;case 2:r.fmtpLine=i.string();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({mime:Mt(e.mime)?String(e.mime):"",fmtpLine:Mt(e.fmtpLine)?String(e.fmtpLine):""}),toJSON(e){const t={};return void 0!==e.mime&&(t.mime=e.mime),void 0!==e.fmtpLine&&(t.fmtpLine=e.fmtpLine),t},fromPartial(e){var t,i;const n={mime:"",fmtpLine:""};return n.mime=null!==(t=e.mime)&&void 0!==t?t:"",n.fmtpLine=null!==(i=e.fmtpLine)&&void 0!==i?i:"",n}};const gt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return!0===e.canSubscribe&&t.uint32(8).bool(e.canSubscribe),!0===e.canPublish&&t.uint32(16).bool(e.canPublish),!0===e.canPublishData&&t.uint32(24).bool(e.canPublishData),!0===e.hidden&&t.uint32(56).bool(e.hidden),!0===e.recorder&&t.uint32(64).bool(e.recorder),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={canSubscribe:!1,canPublish:!1,canPublishData:!1,hidden:!1,recorder:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.canSubscribe=i.bool();break;case 2:r.canPublish=i.bool();break;case 3:r.canPublishData=i.bool();break;case 7:r.hidden=i.bool();break;case 8:r.recorder=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({canSubscribe:!!Mt(e.canSubscribe)&&Boolean(e.canSubscribe),canPublish:!!Mt(e.canPublish)&&Boolean(e.canPublish),canPublishData:!!Mt(e.canPublishData)&&Boolean(e.canPublishData),hidden:!!Mt(e.hidden)&&Boolean(e.hidden),recorder:!!Mt(e.recorder)&&Boolean(e.recorder)}),toJSON(e){const t={};return void 0!==e.canSubscribe&&(t.canSubscribe=e.canSubscribe),void 0!==e.canPublish&&(t.canPublish=e.canPublish),void 0!==e.canPublishData&&(t.canPublishData=e.canPublishData),void 0!==e.hidden&&(t.hidden=e.hidden),void 0!==e.recorder&&(t.recorder=e.recorder),t},fromPartial(e){var t,i,n,r,s;const a={canSubscribe:!1,canPublish:!1,canPublishData:!1,hidden:!1,recorder:!1};return a.canSubscribe=null!==(t=e.canSubscribe)&&void 0!==t&&t,a.canPublish=null!==(i=e.canPublish)&&void 0!==i&&i,a.canPublishData=null!==(n=e.canPublishData)&&void 0!==n&&n,a.hidden=null!==(r=e.hidden)&&void 0!==r&&r,a.recorder=null!==(s=e.recorder)&&void 0!==s&&s,a}};const bt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();""!==e.sid&&t.uint32(10).string(e.sid),""!==e.identity&&t.uint32(18).string(e.identity),0!==e.state&&t.uint32(24).int32(e.state);for(const i of e.tracks)yt.encode(i,t.uint32(34).fork()).ldelim();return""!==e.metadata&&t.uint32(42).string(e.metadata),0!==e.joinedAt&&t.uint32(48).int64(e.joinedAt),""!==e.name&&t.uint32(74).string(e.name),0!==e.version&&t.uint32(80).uint32(e.version),void 0!==e.permission&>.encode(e.permission,t.uint32(90).fork()).ldelim(),""!==e.region&&t.uint32(98).string(e.region),!0===e.isPublisher&&t.uint32(104).bool(e.isPublisher),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={sid:"",identity:"",state:0,tracks:[],metadata:"",joinedAt:0,name:"",version:0,permission:void 0,region:"",isPublisher:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.sid=i.string();break;case 2:r.identity=i.string();break;case 3:r.state=i.int32();break;case 4:r.tracks.push(yt.decode(i,i.uint32()));break;case 5:r.metadata=i.string();break;case 6:r.joinedAt=xt(i.int64());break;case 9:r.name=i.string();break;case 10:r.version=i.uint32();break;case 11:r.permission=gt.decode(i,i.uint32());break;case 12:r.region=i.string();break;case 13:r.isPublisher=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({sid:Mt(e.sid)?String(e.sid):"",identity:Mt(e.identity)?String(e.identity):"",state:Mt(e.state)?lt(e.state):0,tracks:Array.isArray(null==e?void 0:e.tracks)?e.tracks.map((e=>yt.fromJSON(e))):[],metadata:Mt(e.metadata)?String(e.metadata):"",joinedAt:Mt(e.joinedAt)?Number(e.joinedAt):0,name:Mt(e.name)?String(e.name):"",version:Mt(e.version)?Number(e.version):0,permission:Mt(e.permission)?gt.fromJSON(e.permission):void 0,region:Mt(e.region)?String(e.region):"",isPublisher:!!Mt(e.isPublisher)&&Boolean(e.isPublisher)}),toJSON(e){const t={};return void 0!==e.sid&&(t.sid=e.sid),void 0!==e.identity&&(t.identity=e.identity),void 0!==e.state&&(t.state=function(e){switch(e){case He.JOINING:return"JOINING";case He.JOINED:return"JOINED";case He.ACTIVE:return"ACTIVE";case He.DISCONNECTED:return"DISCONNECTED";case He.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.state)),e.tracks?t.tracks=e.tracks.map((e=>e?yt.toJSON(e):void 0)):t.tracks=[],void 0!==e.metadata&&(t.metadata=e.metadata),void 0!==e.joinedAt&&(t.joinedAt=Math.round(e.joinedAt)),void 0!==e.name&&(t.name=e.name),void 0!==e.version&&(t.version=Math.round(e.version)),void 0!==e.permission&&(t.permission=e.permission?gt.toJSON(e.permission):void 0),void 0!==e.region&&(t.region=e.region),void 0!==e.isPublisher&&(t.isPublisher=e.isPublisher),t},fromPartial(e){var t,i,n,r,s,a,o,c,d,u;const l={sid:"",identity:"",state:0,tracks:[],metadata:"",joinedAt:0,name:"",version:0,permission:void 0,region:"",isPublisher:!1};return l.sid=null!==(t=e.sid)&&void 0!==t?t:"",l.identity=null!==(i=e.identity)&&void 0!==i?i:"",l.state=null!==(n=e.state)&&void 0!==n?n:0,l.tracks=(null===(r=e.tracks)||void 0===r?void 0:r.map((e=>yt.fromPartial(e))))||[],l.metadata=null!==(s=e.metadata)&&void 0!==s?s:"",l.joinedAt=null!==(a=e.joinedAt)&&void 0!==a?a:0,l.name=null!==(o=e.name)&&void 0!==o?o:"",l.version=null!==(c=e.version)&&void 0!==c?c:0,l.permission=void 0!==e.permission&&null!==e.permission?gt.fromPartial(e.permission):void 0,l.region=null!==(d=e.region)&&void 0!==d?d:"",l.isPublisher=null!==(u=e.isPublisher)&&void 0!==u&&u,l}};const kt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();""!==e.mimeType&&t.uint32(10).string(e.mimeType),""!==e.mid&&t.uint32(18).string(e.mid),""!==e.cid&&t.uint32(26).string(e.cid);for(const i of e.layers)St.encode(i,t.uint32(34).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={mimeType:"",mid:"",cid:"",layers:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.mimeType=i.string();break;case 2:r.mid=i.string();break;case 3:r.cid=i.string();break;case 4:r.layers.push(St.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({mimeType:Mt(e.mimeType)?String(e.mimeType):"",mid:Mt(e.mid)?String(e.mid):"",cid:Mt(e.cid)?String(e.cid):"",layers:Array.isArray(null==e?void 0:e.layers)?e.layers.map((e=>St.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.mimeType&&(t.mimeType=e.mimeType),void 0!==e.mid&&(t.mid=e.mid),void 0!==e.cid&&(t.cid=e.cid),e.layers?t.layers=e.layers.map((e=>e?St.toJSON(e):void 0)):t.layers=[],t},fromPartial(e){var t,i,n,r;const s={mimeType:"",mid:"",cid:"",layers:[]};return s.mimeType=null!==(t=e.mimeType)&&void 0!==t?t:"",s.mid=null!==(i=e.mid)&&void 0!==i?i:"",s.cid=null!==(n=e.cid)&&void 0!==n?n:"",s.layers=(null===(r=e.layers)||void 0===r?void 0:r.map((e=>St.fromPartial(e))))||[],s}};const yt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();""!==e.sid&&t.uint32(10).string(e.sid),0!==e.type&&t.uint32(16).int32(e.type),""!==e.name&&t.uint32(26).string(e.name),!0===e.muted&&t.uint32(32).bool(e.muted),0!==e.width&&t.uint32(40).uint32(e.width),0!==e.height&&t.uint32(48).uint32(e.height),!0===e.simulcast&&t.uint32(56).bool(e.simulcast),!0===e.disableDtx&&t.uint32(64).bool(e.disableDtx),0!==e.source&&t.uint32(72).int32(e.source);for(const i of e.layers)St.encode(i,t.uint32(82).fork()).ldelim();""!==e.mimeType&&t.uint32(90).string(e.mimeType),""!==e.mid&&t.uint32(98).string(e.mid);for(const i of e.codecs)kt.encode(i,t.uint32(106).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={sid:"",type:0,name:"",muted:!1,width:0,height:0,simulcast:!1,disableDtx:!1,source:0,layers:[],mimeType:"",mid:"",codecs:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.sid=i.string();break;case 2:r.type=i.int32();break;case 3:r.name=i.string();break;case 4:r.muted=i.bool();break;case 5:r.width=i.uint32();break;case 6:r.height=i.uint32();break;case 7:r.simulcast=i.bool();break;case 8:r.disableDtx=i.bool();break;case 9:r.source=i.int32();break;case 10:r.layers.push(St.decode(i,i.uint32()));break;case 11:r.mimeType=i.string();break;case 12:r.mid=i.string();break;case 13:r.codecs.push(kt.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({sid:Mt(e.sid)?String(e.sid):"",type:Mt(e.type)?tt(e.type):0,name:Mt(e.name)?String(e.name):"",muted:!!Mt(e.muted)&&Boolean(e.muted),width:Mt(e.width)?Number(e.width):0,height:Mt(e.height)?Number(e.height):0,simulcast:!!Mt(e.simulcast)&&Boolean(e.simulcast),disableDtx:!!Mt(e.disableDtx)&&Boolean(e.disableDtx),source:Mt(e.source)?nt(e.source):0,layers:Array.isArray(null==e?void 0:e.layers)?e.layers.map((e=>St.fromJSON(e))):[],mimeType:Mt(e.mimeType)?String(e.mimeType):"",mid:Mt(e.mid)?String(e.mid):"",codecs:Array.isArray(null==e?void 0:e.codecs)?e.codecs.map((e=>kt.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.sid&&(t.sid=e.sid),void 0!==e.type&&(t.type=it(e.type)),void 0!==e.name&&(t.name=e.name),void 0!==e.muted&&(t.muted=e.muted),void 0!==e.width&&(t.width=Math.round(e.width)),void 0!==e.height&&(t.height=Math.round(e.height)),void 0!==e.simulcast&&(t.simulcast=e.simulcast),void 0!==e.disableDtx&&(t.disableDtx=e.disableDtx),void 0!==e.source&&(t.source=rt(e.source)),e.layers?t.layers=e.layers.map((e=>e?St.toJSON(e):void 0)):t.layers=[],void 0!==e.mimeType&&(t.mimeType=e.mimeType),void 0!==e.mid&&(t.mid=e.mid),e.codecs?t.codecs=e.codecs.map((e=>e?kt.toJSON(e):void 0)):t.codecs=[],t},fromPartial(e){var t,i,n,r,s,a,o,c,d,u,l,h,p;const m={sid:"",type:0,name:"",muted:!1,width:0,height:0,simulcast:!1,disableDtx:!1,source:0,layers:[],mimeType:"",mid:"",codecs:[]};return m.sid=null!==(t=e.sid)&&void 0!==t?t:"",m.type=null!==(i=e.type)&&void 0!==i?i:0,m.name=null!==(n=e.name)&&void 0!==n?n:"",m.muted=null!==(r=e.muted)&&void 0!==r&&r,m.width=null!==(s=e.width)&&void 0!==s?s:0,m.height=null!==(a=e.height)&&void 0!==a?a:0,m.simulcast=null!==(o=e.simulcast)&&void 0!==o&&o,m.disableDtx=null!==(c=e.disableDtx)&&void 0!==c&&c,m.source=null!==(d=e.source)&&void 0!==d?d:0,m.layers=(null===(u=e.layers)||void 0===u?void 0:u.map((e=>St.fromPartial(e))))||[],m.mimeType=null!==(l=e.mimeType)&&void 0!==l?l:"",m.mid=null!==(h=e.mid)&&void 0!==h?h:"",m.codecs=(null===(p=e.codecs)||void 0===p?void 0:p.map((e=>kt.fromPartial(e))))||[],m}};const St={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return 0!==e.quality&&t.uint32(8).int32(e.quality),0!==e.width&&t.uint32(16).uint32(e.width),0!==e.height&&t.uint32(24).uint32(e.height),0!==e.bitrate&&t.uint32(32).uint32(e.bitrate),0!==e.ssrc&&t.uint32(40).uint32(e.ssrc),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={quality:0,width:0,height:0,bitrate:0,ssrc:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.quality=i.int32();break;case 2:r.width=i.uint32();break;case 3:r.height=i.uint32();break;case 4:r.bitrate=i.uint32();break;case 5:r.ssrc=i.uint32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({quality:Mt(e.quality)?st(e.quality):0,width:Mt(e.width)?Number(e.width):0,height:Mt(e.height)?Number(e.height):0,bitrate:Mt(e.bitrate)?Number(e.bitrate):0,ssrc:Mt(e.ssrc)?Number(e.ssrc):0}),toJSON(e){const t={};return void 0!==e.quality&&(t.quality=at(e.quality)),void 0!==e.width&&(t.width=Math.round(e.width)),void 0!==e.height&&(t.height=Math.round(e.height)),void 0!==e.bitrate&&(t.bitrate=Math.round(e.bitrate)),void 0!==e.ssrc&&(t.ssrc=Math.round(e.ssrc)),t},fromPartial(e){var t,i,n,r,s;const a={quality:0,width:0,height:0,bitrate:0,ssrc:0};return a.quality=null!==(t=e.quality)&&void 0!==t?t:0,a.width=null!==(i=e.width)&&void 0!==i?i:0,a.height=null!==(n=e.height)&&void 0!==n?n:0,a.bitrate=null!==(r=e.bitrate)&&void 0!==r?r:0,a.ssrc=null!==(s=e.ssrc)&&void 0!==s?s:0,a}};const wt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();var i,n;return 0!==e.kind&&t.uint32(8).int32(e.kind),"user"===(null===(i=e.value)||void 0===i?void 0:i.$case)&&Pt.encode(e.value.user,t.uint32(18).fork()).ldelim(),"speaker"===(null===(n=e.value)||void 0===n?void 0:n.$case)&&Ct.encode(e.value.speaker,t.uint32(26).fork()).ldelim(),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={kind:0,value:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.kind=i.int32();break;case 2:r.value={$case:"user",user:Pt.decode(i,i.uint32())};break;case 3:r.value={$case:"speaker",speaker:Ct.decode(i,i.uint32())};break;default:i.skipType(7&e)}}return r},fromJSON:e=>({kind:Mt(e.kind)?ht(e.kind):0,value:Mt(e.user)?{$case:"user",user:Pt.fromJSON(e.user)}:Mt(e.speaker)?{$case:"speaker",speaker:Ct.fromJSON(e.speaker)}:void 0}),toJSON(t){var i,n,r,s,a,o;const c={};return void 0!==t.kind&&(c.kind=function(t){switch(t){case e.DataPacket_Kind.RELIABLE:return"RELIABLE";case e.DataPacket_Kind.LOSSY:return"LOSSY";case e.DataPacket_Kind.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(t.kind)),"user"===(null===(i=t.value)||void 0===i?void 0:i.$case)&&(c.user=(null===(n=t.value)||void 0===n?void 0:n.user)?Pt.toJSON(null===(r=t.value)||void 0===r?void 0:r.user):void 0),"speaker"===(null===(s=t.value)||void 0===s?void 0:s.$case)&&(c.speaker=(null===(a=t.value)||void 0===a?void 0:a.speaker)?Ct.toJSON(null===(o=t.value)||void 0===o?void 0:o.speaker):void 0),c},fromPartial(e){var t,i,n,r,s,a,o;const c={kind:0,value:void 0};return c.kind=null!==(t=e.kind)&&void 0!==t?t:0,"user"===(null===(i=e.value)||void 0===i?void 0:i.$case)&&void 0!==(null===(n=e.value)||void 0===n?void 0:n.user)&&null!==(null===(r=e.value)||void 0===r?void 0:r.user)&&(c.value={$case:"user",user:Pt.fromPartial(e.value.user)}),"speaker"===(null===(s=e.value)||void 0===s?void 0:s.$case)&&void 0!==(null===(a=e.value)||void 0===a?void 0:a.speaker)&&null!==(null===(o=e.value)||void 0===o?void 0:o.speaker)&&(c.value={$case:"speaker",speaker:Ct.fromPartial(e.value.speaker)}),c}};const Ct={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();for(const i of e.speakers)Tt.encode(i,t.uint32(10).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={speakers:[]};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.speakers.push(Tt.decode(i,i.uint32()));else i.skipType(7&e)}return r},fromJSON:e=>({speakers:Array.isArray(null==e?void 0:e.speakers)?e.speakers.map((e=>Tt.fromJSON(e))):[]}),toJSON(e){const t={};return e.speakers?t.speakers=e.speakers.map((e=>e?Tt.toJSON(e):void 0)):t.speakers=[],t},fromPartial(e){var t;const i={speakers:[]};return i.speakers=(null===(t=e.speakers)||void 0===t?void 0:t.map((e=>Tt.fromPartial(e))))||[],i}};const Tt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return""!==e.sid&&t.uint32(10).string(e.sid),0!==e.level&&t.uint32(21).float(e.level),!0===e.active&&t.uint32(24).bool(e.active),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={sid:"",level:0,active:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.sid=i.string();break;case 2:r.level=i.float();break;case 3:r.active=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({sid:Mt(e.sid)?String(e.sid):"",level:Mt(e.level)?Number(e.level):0,active:!!Mt(e.active)&&Boolean(e.active)}),toJSON(e){const t={};return void 0!==e.sid&&(t.sid=e.sid),void 0!==e.level&&(t.level=e.level),void 0!==e.active&&(t.active=e.active),t},fromPartial(e){var t,i,n;const r={sid:"",level:0,active:!1};return r.sid=null!==(t=e.sid)&&void 0!==t?t:"",r.level=null!==(i=e.level)&&void 0!==i?i:0,r.active=null!==(n=e.active)&&void 0!==n&&n,r}};function Et(){return{participantSid:"",payload:new Uint8Array,destinationSids:[]}}const Pt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();""!==e.participantSid&&t.uint32(10).string(e.participantSid),0!==e.payload.length&&t.uint32(18).bytes(e.payload);for(const i of e.destinationSids)t.uint32(26).string(i);return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r=Et();for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.participantSid=i.string();break;case 2:r.payload=i.bytes();break;case 3:r.destinationSids.push(i.string());break;default:i.skipType(7&e)}}return r},fromJSON:e=>({participantSid:Mt(e.participantSid)?String(e.participantSid):"",payload:Mt(e.payload)?Lt(e.payload):new Uint8Array,destinationSids:Array.isArray(null==e?void 0:e.destinationSids)?e.destinationSids.map((e=>String(e))):[]}),toJSON(e){const t={};return void 0!==e.participantSid&&(t.participantSid=e.participantSid),void 0!==e.payload&&(t.payload=function(e){if(Ut.Buffer)return Ut.Buffer.from(e).toString("base64");{const t=[];return e.forEach((e=>{t.push(String.fromCharCode(e))})),Ut.btoa(t.join(""))}}(void 0!==e.payload?e.payload:new Uint8Array)),e.destinationSids?t.destinationSids=e.destinationSids.map((e=>e)):t.destinationSids=[],t},fromPartial(e){var t,i,n;const r=Et();return r.participantSid=null!==(t=e.participantSid)&&void 0!==t?t:"",r.payload=null!==(i=e.payload)&&void 0!==i?i:new Uint8Array,r.destinationSids=(null===(n=e.destinationSids)||void 0===n?void 0:n.map((e=>e)))||[],r}};const Rt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();""!==e.participantSid&&t.uint32(10).string(e.participantSid);for(const i of e.trackSids)t.uint32(18).string(i);return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={participantSid:"",trackSids:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.participantSid=i.string();break;case 2:r.trackSids.push(i.string());break;default:i.skipType(7&e)}}return r},fromJSON:e=>({participantSid:Mt(e.participantSid)?String(e.participantSid):"",trackSids:Array.isArray(null==e?void 0:e.trackSids)?e.trackSids.map((e=>String(e))):[]}),toJSON(e){const t={};return void 0!==e.participantSid&&(t.participantSid=e.participantSid),e.trackSids?t.trackSids=e.trackSids.map((e=>e)):t.trackSids=[],t},fromPartial(e){var t,i;const n={participantSid:"",trackSids:[]};return n.participantSid=null!==(t=e.participantSid)&&void 0!==t?t:"",n.trackSids=(null===(i=e.trackSids)||void 0===i?void 0:i.map((e=>e)))||[],n}};const Ot={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return 0!==e.edition&&t.uint32(8).int32(e.edition),""!==e.version&&t.uint32(18).string(e.version),0!==e.protocol&&t.uint32(24).int32(e.protocol),""!==e.region&&t.uint32(34).string(e.region),""!==e.nodeId&&t.uint32(42).string(e.nodeId),""!==e.debugInfo&&t.uint32(50).string(e.debugInfo),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={edition:0,version:"",protocol:0,region:"",nodeId:"",debugInfo:""};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.edition=i.int32();break;case 2:r.version=i.string();break;case 3:r.protocol=i.int32();break;case 4:r.region=i.string();break;case 5:r.nodeId=i.string();break;case 6:r.debugInfo=i.string();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({edition:Mt(e.edition)?pt(e.edition):0,version:Mt(e.version)?String(e.version):"",protocol:Mt(e.protocol)?Number(e.protocol):0,region:Mt(e.region)?String(e.region):"",nodeId:Mt(e.nodeId)?String(e.nodeId):"",debugInfo:Mt(e.debugInfo)?String(e.debugInfo):""}),toJSON(e){const t={};return void 0!==e.edition&&(t.edition=function(e){switch(e){case Ke.Standard:return"Standard";case Ke.Cloud:return"Cloud";case Ke.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.edition)),void 0!==e.version&&(t.version=e.version),void 0!==e.protocol&&(t.protocol=Math.round(e.protocol)),void 0!==e.region&&(t.region=e.region),void 0!==e.nodeId&&(t.nodeId=e.nodeId),void 0!==e.debugInfo&&(t.debugInfo=e.debugInfo),t},fromPartial(e){var t,i,n,r,s,a;const o={edition:0,version:"",protocol:0,region:"",nodeId:"",debugInfo:""};return o.edition=null!==(t=e.edition)&&void 0!==t?t:0,o.version=null!==(i=e.version)&&void 0!==i?i:"",o.protocol=null!==(n=e.protocol)&&void 0!==n?n:0,o.region=null!==(r=e.region)&&void 0!==r?r:"",o.nodeId=null!==(s=e.nodeId)&&void 0!==s?s:"",o.debugInfo=null!==(a=e.debugInfo)&&void 0!==a?a:"",o}};const Nt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return 0!==e.sdk&&t.uint32(8).int32(e.sdk),""!==e.version&&t.uint32(18).string(e.version),0!==e.protocol&&t.uint32(24).int32(e.protocol),""!==e.os&&t.uint32(34).string(e.os),""!==e.osVersion&&t.uint32(42).string(e.osVersion),""!==e.deviceModel&&t.uint32(50).string(e.deviceModel),""!==e.browser&&t.uint32(58).string(e.browser),""!==e.browserVersion&&t.uint32(66).string(e.browserVersion),""!==e.address&&t.uint32(74).string(e.address),""!==e.network&&t.uint32(82).string(e.network),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={sdk:0,version:"",protocol:0,os:"",osVersion:"",deviceModel:"",browser:"",browserVersion:"",address:"",network:""};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.sdk=i.int32();break;case 2:r.version=i.string();break;case 3:r.protocol=i.int32();break;case 4:r.os=i.string();break;case 5:r.osVersion=i.string();break;case 6:r.deviceModel=i.string();break;case 7:r.browser=i.string();break;case 8:r.browserVersion=i.string();break;case 9:r.address=i.string();break;case 10:r.network=i.string();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({sdk:Mt(e.sdk)?mt(e.sdk):0,version:Mt(e.version)?String(e.version):"",protocol:Mt(e.protocol)?Number(e.protocol):0,os:Mt(e.os)?String(e.os):"",osVersion:Mt(e.osVersion)?String(e.osVersion):"",deviceModel:Mt(e.deviceModel)?String(e.deviceModel):"",browser:Mt(e.browser)?String(e.browser):"",browserVersion:Mt(e.browserVersion)?String(e.browserVersion):"",address:Mt(e.address)?String(e.address):"",network:Mt(e.network)?String(e.network):""}),toJSON(e){const t={};return void 0!==e.sdk&&(t.sdk=function(e){switch(e){case Ye.UNKNOWN:return"UNKNOWN";case Ye.JS:return"JS";case Ye.SWIFT:return"SWIFT";case Ye.ANDROID:return"ANDROID";case Ye.FLUTTER:return"FLUTTER";case Ye.GO:return"GO";case Ye.UNITY:return"UNITY";case Ye.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.sdk)),void 0!==e.version&&(t.version=e.version),void 0!==e.protocol&&(t.protocol=Math.round(e.protocol)),void 0!==e.os&&(t.os=e.os),void 0!==e.osVersion&&(t.osVersion=e.osVersion),void 0!==e.deviceModel&&(t.deviceModel=e.deviceModel),void 0!==e.browser&&(t.browser=e.browser),void 0!==e.browserVersion&&(t.browserVersion=e.browserVersion),void 0!==e.address&&(t.address=e.address),void 0!==e.network&&(t.network=e.network),t},fromPartial(e){var t,i,n,r,s,a,o,c,d,u;const l={sdk:0,version:"",protocol:0,os:"",osVersion:"",deviceModel:"",browser:"",browserVersion:"",address:"",network:""};return l.sdk=null!==(t=e.sdk)&&void 0!==t?t:0,l.version=null!==(i=e.version)&&void 0!==i?i:"",l.protocol=null!==(n=e.protocol)&&void 0!==n?n:0,l.os=null!==(r=e.os)&&void 0!==r?r:"",l.osVersion=null!==(s=e.osVersion)&&void 0!==s?s:"",l.deviceModel=null!==(a=e.deviceModel)&&void 0!==a?a:"",l.browser=null!==(o=e.browser)&&void 0!==o?o:"",l.browserVersion=null!==(c=e.browserVersion)&&void 0!==c?c:"",l.address=null!==(d=e.address)&&void 0!==d?d:"",l.network=null!==(u=e.network)&&void 0!==u?u:"",l}};const Dt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return void 0!==e.video&&It.encode(e.video,t.uint32(10).fork()).ldelim(),void 0!==e.screen&&It.encode(e.screen,t.uint32(18).fork()).ldelim(),0!==e.resumeConnection&&t.uint32(24).int32(e.resumeConnection),void 0!==e.disabledCodecs&&At.encode(e.disabledCodecs,t.uint32(34).fork()).ldelim(),0!==e.forceRelay&&t.uint32(40).int32(e.forceRelay),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={video:void 0,screen:void 0,resumeConnection:0,disabledCodecs:void 0,forceRelay:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.video=It.decode(i,i.uint32());break;case 2:r.screen=It.decode(i,i.uint32());break;case 3:r.resumeConnection=i.int32();break;case 4:r.disabledCodecs=At.decode(i,i.uint32());break;case 5:r.forceRelay=i.int32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({video:Mt(e.video)?It.fromJSON(e.video):void 0,screen:Mt(e.screen)?It.fromJSON(e.screen):void 0,resumeConnection:Mt(e.resumeConnection)?ct(e.resumeConnection):0,disabledCodecs:Mt(e.disabledCodecs)?At.fromJSON(e.disabledCodecs):void 0,forceRelay:Mt(e.forceRelay)?ct(e.forceRelay):0}),toJSON(e){const t={};return void 0!==e.video&&(t.video=e.video?It.toJSON(e.video):void 0),void 0!==e.screen&&(t.screen=e.screen?It.toJSON(e.screen):void 0),void 0!==e.resumeConnection&&(t.resumeConnection=dt(e.resumeConnection)),void 0!==e.disabledCodecs&&(t.disabledCodecs=e.disabledCodecs?At.toJSON(e.disabledCodecs):void 0),void 0!==e.forceRelay&&(t.forceRelay=dt(e.forceRelay)),t},fromPartial(e){var t,i;const n={video:void 0,screen:void 0,resumeConnection:0,disabledCodecs:void 0,forceRelay:0};return n.video=void 0!==e.video&&null!==e.video?It.fromPartial(e.video):void 0,n.screen=void 0!==e.screen&&null!==e.screen?It.fromPartial(e.screen):void 0,n.resumeConnection=null!==(t=e.resumeConnection)&&void 0!==t?t:0,n.disabledCodecs=void 0!==e.disabledCodecs&&null!==e.disabledCodecs?At.fromPartial(e.disabledCodecs):void 0,n.forceRelay=null!==(i=e.forceRelay)&&void 0!==i?i:0,n}};const It={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return 0!==e.hardwareEncoder&&t.uint32(8).int32(e.hardwareEncoder),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={hardwareEncoder:0};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.hardwareEncoder=i.int32();else i.skipType(7&e)}return r},fromJSON:e=>({hardwareEncoder:Mt(e.hardwareEncoder)?ct(e.hardwareEncoder):0}),toJSON(e){const t={};return void 0!==e.hardwareEncoder&&(t.hardwareEncoder=dt(e.hardwareEncoder)),t},fromPartial(e){var t;const i={hardwareEncoder:0};return i.hardwareEncoder=null!==(t=e.hardwareEncoder)&&void 0!==t?t:0,i}};const At={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();for(const i of e.codecs)ft.encode(i,t.uint32(10).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={codecs:[]};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.codecs.push(ft.decode(i,i.uint32()));else i.skipType(7&e)}return r},fromJSON:e=>({codecs:Array.isArray(null==e?void 0:e.codecs)?e.codecs.map((e=>ft.fromJSON(e))):[]}),toJSON(e){const t={};return e.codecs?t.codecs=e.codecs.map((e=>e?ft.toJSON(e):void 0)):t.codecs=[],t},fromPartial(e){var t;const i={codecs:[]};return i.codecs=(null===(t=e.codecs)||void 0===t?void 0:t.map((e=>ft.fromPartial(e))))||[],i}};var Ut=(()=>{if(void 0!==Ut)return Ut;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw"Unable to locate global object"})();function Lt(e){if(Ut.Buffer)return Uint8Array.from(Ut.Buffer.from(e,"base64"));{const t=Ut.atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;++e)i[e]=t.charCodeAt(e);return i}}function xt(e){if(e.gt(Number.MAX_SAFE_INTEGER))throw new Ut.Error("Value is larger than Number.MAX_SAFE_INTEGER");return e.toNumber()}function Mt(e){return null!=e}Xe.util.Long!==o&&(Xe.util.Long=o,Xe.configure());const _t=7e3,Jt=[0,300,1200,2700,4800,_t,_t,_t,_t,_t];class $t{constructor(e){this._retryDelays=void 0!==e?[...e]:Jt}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;const t=this._retryDelays[e.retryCount];return e.retryCount<=1?t:t+1e3*Math.random()}}function Bt(e){var t,i,n,r=2;for("undefined"!=typeof Symbol&&(i=Symbol.asyncIterator,n=Symbol.iterator);r--;){if(i&&null!=(t=e[i]))return t.call(e);if(n&&null!=(t=e[n]))return new jt(t.call(e));i="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function jt(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return jt=function(e){this.s=e,this.n=e.next},jt.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var i=this.s.return;return void 0===i?Promise.resolve({value:e,done:!0}):t(i.apply(this.s,arguments))},throw:function(e){var i=this.s.return;return void 0===i?Promise.reject(e):t(i.apply(this.s,arguments))}},new jt(e)}function Vt(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Ft(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Vt(Object(i),!0).forEach((function(t){qt(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Vt(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function qt(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}let Wt=!0,Gt=!0;function Qt(e,t,i){const n=e.match(t);return n&&n.length>=i&&parseInt(n[i],10)}function zt(e,t,i){if(!e.RTCPeerConnection)return;const n=e.RTCPeerConnection.prototype,r=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return r.apply(this,arguments);const s=e=>{const t=i(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(n,s),r.apply(this,[e,s])};const s=n.removeEventListener;n.removeEventListener=function(e,i){if(e!==t||!this._eventMap||!this._eventMap[t])return s.apply(this,arguments);if(!this._eventMap[t].has(i))return s.apply(this,arguments);const n=this._eventMap[t].get(i);return this._eventMap[t].delete(i),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,s.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function Ht(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(Wt=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function Zt(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(Gt=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Kt(){if("object"==typeof window){if(Wt)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function Yt(e,t){Gt&&console.warn(e+" is deprecated, please use "+t+" instead.")}function Xt(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:i}=e;if(i.mozGetUserMedia)t.browser="firefox",t.version=Qt(i.userAgent,/Firefox\/(\d+)\./,1);else if(i.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=Qt(i.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!i.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=Qt(i.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function ei(e){return"[object Object]"===Object.prototype.toString.call(e)}function ti(e){return ei(e)?Object.keys(e).reduce((function(t,i){const n=ei(e[i]),r=n?ti(e[i]):e[i],s=n&&!Object.keys(r).length;return void 0===r||s?t:Object.assign(t,{[i]:r})}),{}):e}function ii(e,t,i){t&&!i.has(t.id)&&(i.set(t.id,t),Object.keys(t).forEach((n=>{n.endsWith("Id")?ii(e,e.get(t[n]),i):n.endsWith("Ids")&&t[n].forEach((t=>{ii(e,e.get(t),i)}))})))}function ni(e,t,i){const n=i?"outbound-rtp":"inbound-rtp",r=new Map;if(null===t)return r;const s=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&s.push(e)})),s.forEach((t=>{e.forEach((i=>{i.type===n&&i.trackId===t.id&&ii(e,i,r)}))})),r}const ri=Kt;function si(e,t){const i=e&&e.navigator;if(!i.mediaDevices)return;const n=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((i=>{if("require"===i||"advanced"===i||"mediaSource"===i)return;const n="object"==typeof e[i]?e[i]:{ideal:e[i]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const r=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[r("min",i)]=n.ideal,t.optional.push(e),e={},e[r("max",i)]=n.ideal,t.optional.push(e)):(e[r("",i)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[r("",i)]=n.exact):["min","max"].forEach((e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[r(e,i)]=n[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},r=function(e,r){if(t.version>=61)return r(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"==typeof e.video){let s=e.video.facingMode;s=s&&("object"==typeof s?s:{ideal:s});const a=t.version<66;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&(!i.mediaDevices.getSupportedConstraints||!i.mediaDevices.getSupportedConstraints().facingMode||a)){let t;if(delete e.video.facingMode,"environment"===s.exact||"environment"===s.ideal?t=["back","rear"]:"user"!==s.exact&&"user"!==s.ideal||(t=["front"]),t)return i.mediaDevices.enumerateDevices().then((i=>{let a=(i=i.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!a&&i.length&&t.includes("back")&&(a=i[i.length-1]),a&&(e.video.deviceId=s.exact?{exact:a.deviceId}:{ideal:a.deviceId}),e.video=n(e.video),ri("chrome: "+JSON.stringify(e)),r(e)}))}e.video=n(e.video)}return ri("chrome: "+JSON.stringify(e)),r(e)},s=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(i.getUserMedia=function(e,t,n){r(e,(e=>{i.webkitGetUserMedia(e,t,(e=>{n&&n(s(e))}))}))}.bind(i),i.mediaDevices.getUserMedia){const e=i.mediaDevices.getUserMedia.bind(i.mediaDevices);i.mediaDevices.getUserMedia=function(t){return r(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(s(e))))))}}}function ai(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function oi(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(i=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.track.id)):{track:i.track};const r=new Event("track");r.track=i.track,r.receiver=n,r.transceiver={receiver:n},r.streams=[t.stream],this.dispatchEvent(r)})),t.stream.getTracks().forEach((i=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.id)):{track:i};const r=new Event("track");r.track=i,r.receiver=n,r.transceiver={receiver:n},r.streams=[t.stream],this.dispatchEvent(r)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else zt(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function ci(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){let r=i.apply(this,arguments);return r||(r=t(this,e),this._senders.push(r)),r};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function di(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,n]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const r=function(e){const t={};return e.result().forEach((e=>{const i={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{i[t]=e.stat(t)})),t[i.id]=i})),t},s=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const n=function(e){i(s(r(e)))};return t.apply(this,[n,e])}return new Promise(((e,i)=>{t.apply(this,[function(t){e(s(r(t)))},i])})).then(i,n)}}function ui(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>ni(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),zt(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>ni(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,i,n;return this.getSenders().forEach((i=>{i.track===e&&(t?n=!0:t=i)})),this.getReceivers().forEach((t=>(t.track===e&&(i?n=!0:i=t),t.track===e))),n||t&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function li(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){if(!i)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const n=t.apply(this,arguments);return this._shimmedLocalStreams[i.id]?-1===this._shimmedLocalStreams[i.id].indexOf(n)&&this._shimmedLocalStreams[i.id].push(n):this._shimmedLocalStreams[i.id]=[i,n],n};const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();i.apply(this,arguments);const n=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(n)};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const i=this._shimmedLocalStreams[t].indexOf(e);-1!==i&&this._shimmedLocalStreams[t].splice(i,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),r.apply(this,arguments)}}function hi(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return li(e);const i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=i.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};const r=e.RTCPeerConnection.prototype.removeStream;function s(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const n=e._reverseStreams[t],r=e._streams[n.id];i=i.replace(new RegExp(r.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:i})}function a(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const n=e._reverseStreams[t],r=e._streams[n.id];i=i.replace(new RegExp(n.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:i})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,i){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");const r=this.getSenders().find((e=>e.track===t));if(r)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const s=this._streams[i.id];if(s)s.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const n=new e.MediaStream([t]);this._streams[i.id]=n,this._reverseStreams[n.id]=i,this.addStream(n)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],n={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?i.apply(this,[t=>{const i=s(this,t);e[0].apply(null,[i])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):i.apply(this,arguments).then((e=>s(this,e)))}};e.RTCPeerConnection.prototype[t]=n[t]}));const o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=a(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};const c=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=c.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((i=>{this._streams[i].getTracks().find((t=>e.track===t))&&(t=this._streams[i])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function pi(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}))}function mi(e,t){zt(e,"negotiationneeded",(e=>{const i=e.target;if(!(t.version<72||i.getConfiguration&&"plan-b"===i.getConfiguration().sdpSemantics)||"stable"===i.signalingState)return e}))}var vi=Object.freeze({__proto__:null,fixNegotiationNeeded:mi,shimAddTrackRemoveTrack:hi,shimAddTrackRemoveTrackWithNative:li,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then((t=>{const n=i.video&&i.video.width,r=i.video&&i.video.height,s=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:s||3}},n&&(i.video.mandatory.maxWidth=n),r&&(i.video.mandatory.maxHeight=r),e.navigator.mediaDevices.getUserMedia(i)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))},shimGetSendersWithDtmf:ci,shimGetStats:di,shimGetUserMedia:si,shimMediaStream:ai,shimOnTrack:oi,shimPeerConnection:pi,shimSenderReceiverGetStats:ui});function fi(e,t){const i=e&&e.navigator,n=e&&e.MediaStreamTrack;if(i.getUserMedia=function(e,t,n){Yt("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),i.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in i.mediaDevices.getSupportedConstraints())){const e=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])},t=i.mediaDevices.getUserMedia.bind(i.mediaDevices);if(i.mediaDevices.getUserMedia=function(i){return"object"==typeof i&&"object"==typeof i.audio&&(i=JSON.parse(JSON.stringify(i)),e(i.audio,"autoGainControl","mozAutoGainControl"),e(i.audio,"noiseSuppression","mozNoiseSuppression")),t(i)},n&&n.prototype.getSettings){const t=n.prototype.getSettings;n.prototype.getSettings=function(){const i=t.apply(this,arguments);return e(i,"mozAutoGainControl","autoGainControl"),e(i,"mozNoiseSuppression","noiseSuppression"),i}}if(n&&n.prototype.applyConstraints){const t=n.prototype.applyConstraints;n.prototype.applyConstraints=function(i){return"audio"===this.kind&&"object"==typeof i&&(i=JSON.parse(JSON.stringify(i)),e(i,"autoGainControl","mozAutoGainControl"),e(i,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[i])}}}}function gi(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function bi(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}));const i={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,s]=arguments;return n.apply(this,[e||null]).then((e=>{if(t.version<53&&!r)try{e.forEach((e=>{e.type=i[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach(((t,n)=>{e.set(n,Object.assign({},t,{type:i[t.type]||t.type}))}))}return e})).then(r,s)}}function ki(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function yi(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),zt(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Si(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){Yt("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function wi(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function Ci(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],i=e&&"sendEncodings"in e;i&&e.sendEncodings.forEach((e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const n=t.apply(this,arguments);if(i){const{sender:t}=n,i=t.getParameters();(!("encodings"in i)||1===i.encodings.length&&0===Object.keys(i.encodings[0]).length)&&(i.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(i).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return n})}function Ti(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function Ei(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function Pi(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}var Ri=Object.freeze({__proto__:null,shimAddTransceiver:Ci,shimCreateAnswer:Pi,shimCreateOffer:Ei,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(i){if(!i||!i.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===i.video?i.video={mediaSource:t}:i.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(i)})},shimGetParameters:Ti,shimGetUserMedia:fi,shimOnTrack:gi,shimPeerConnection:bi,shimRTCDataChannel:wi,shimReceiverGetStats:yi,shimRemoveStream:Si,shimSenderGetStats:ki});function Oi(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((i=>t.call(this,i,e))),e.getVideoTracks().forEach((i=>t.call(this,i,e)))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return n&&n.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const i=e.getTracks();this.getSenders().forEach((e=>{i.includes(e.track)&&this.removeTrack(e)}))})}}function Ni(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const i=new Event("addstream");i.stream=t,e.dispatchEvent(i)}))}),t.apply(e,arguments)}}}function Di(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,i=t.createOffer,n=t.createAnswer,r=t.setLocalDescription,s=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],r=i.apply(this,[n]);return t?(r.then(e,t),Promise.resolve()):r},t.createAnswer=function(e,t){const i=arguments.length>=2?arguments[2]:arguments[0],r=n.apply(this,[i]);return t?(r.then(e,t),Promise.resolve()):r};let o=function(e,t,i){const n=r.apply(this,[e]);return i?(n.then(t,i),Promise.resolve()):n};t.setLocalDescription=o,o=function(e,t,i){const n=s.apply(this,[e]);return i?(n.then(t,i),Promise.resolve()):n},t.setRemoteDescription=o,o=function(e,t,i){const n=a.apply(this,[e]);return i?(n.then(t,i),Promise.resolve()):n},t.addIceCandidate=o}function Ii(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,i=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>i(Ai(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,i,n){t.mediaDevices.getUserMedia(e).then(i,n)}.bind(t))}function Ai(e){return e&&void 0!==e.video?Object.assign({},e,{video:ti(e.video)}):e}function Ui(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,i){if(e&&e.iceServers){const t=[];for(let i=0;i<e.iceServers.length;i++){let n=e.iceServers[i];!n.hasOwnProperty("urls")&&n.hasOwnProperty("url")?(Yt("RTCIceServer.url","RTCIceServer.urls"),n=JSON.parse(JSON.stringify(n)),n.urls=n.url,delete n.url,t.push(n)):t.push(e.iceServers[i])}e.iceServers=t}return new t(e,i)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function Li(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function xi(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const i=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveVideo||i||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function Mi(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var _i=Object.freeze({__proto__:null,shimAudioContext:Mi,shimCallbacksAPI:Di,shimConstraints:Ai,shimCreateOfferLegacy:xi,shimGetUserMedia:Ii,shimLocalStreamsAPI:Oi,shimRTCIceServerUrls:Ui,shimRemoteStreamsAPI:Ni,shimTrackEventTransceiver:Li}),Ji={};!function(e){const t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((e=>e.trim()))},t.splitSections=function(e){return e.split("\nm=").map(((e,t)=>(t>0?"m="+e:e).trim()+"\r\n"))},t.getDescription=function(e){const i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){const i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter((e=>0===e.indexOf(i)))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const i={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let e=8;e<t.length;e+=2)switch(t[e]){case"raddr":i.relatedAddress=t[e+1];break;case"rport":i.relatedPort=parseInt(t[e+1],10);break;case"tcptype":i.tcpType=t[e+1];break;case"ufrag":i.ufrag=t[e+1],i.usernameFragment=t[e+1];break;default:void 0===i[t[e]]&&(i[t[e]]=t[e+1])}return i},t.writeCandidate=function(e){const t=[];t.push(e.foundation);const i=e.component;"rtp"===i?t.push(1):"rtcp"===i?t.push(2):t.push(i),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);const n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){let t=e.substr(9).split(" ");const i={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),i.name=t[0],i.clockRate=parseInt(t[1],10),i.channels=3===t.length?parseInt(t[2],10):1,i.numChannels=i.channels,i},t.writeRtpMap=function(e){let t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);const i=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==i?"/"+i:"")+"\r\n"},t.parseExtmap=function(e){const t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){const t={};let i;const n=e.substr(e.indexOf(" ")+1).split(";");for(let e=0;e<n.length;e++)i=n[e].trim().split("="),t[i[0].trim()]=i[1];return t},t.writeFmtp=function(e){let t="",i=e.payloadType;if(void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){const n=[];Object.keys(e.parameters).forEach((t=>{void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+i+" "+n.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",i=e.payloadType;return void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((e=>{t+="a=rtcp-fb:"+i+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),i={ssrc:parseInt(e.substr(7,t-7),10)},n=e.indexOf(":",t);return n>-1?(i.attribute=e.substr(t+1,n-t-1),i.value=e.substr(n+1)):i.attribute=e.substr(t+1),i},t.parseSsrcGroup=function(e){const t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((e=>parseInt(e,10)))}},t.getMid=function(e){const i=t.matchPrefix(e,"a=mid:")[0];if(i)return i.substr(6)},t.parseFingerprint=function(e){const t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,i){return{role:"auto",fingerprints:t.matchPrefix(e+i,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let i="a=setup:"+t+"\r\n";return e.fingerprints.forEach((e=>{i+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),i},t.parseCryptoLine=function(e){const t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;const t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,i){return t.matchPrefix(e+i,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,i){const n=t.matchPrefix(e+i,"a=ice-ufrag:")[0],r=t.matchPrefix(e+i,"a=ice-pwd:")[0];return n&&r?{usernameFragment:n.substr(12),password:r.substr(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=t.splitLines(e)[0].split(" ");for(let r=3;r<n.length;r++){const s=n[r],a=t.matchPrefix(e,"a=rtpmap:"+s+" ")[0];if(a){const n=t.parseRtpMap(a),r=t.matchPrefix(e,"a=fmtp:"+s+" ");switch(n.parameters=r.length?t.parseFmtp(r[0]):{},n.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+s+" ").map(t.parseRtcpFb),i.codecs.push(n),n.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(n.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach((e=>{i.headerExtensions.push(t.parseExtmap(e))})),i},t.writeRtpDescription=function(e,i){let n="";n+="m="+e+" ",n+=i.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=i.codecs.map((e=>void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType)).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",i.codecs.forEach((e=>{n+=t.writeRtpMap(e),n+=t.writeFmtp(e),n+=t.writeRtcpFb(e)}));let r=0;return i.codecs.forEach((e=>{e.maxptime>r&&(r=e.maxptime)})),r>0&&(n+="a=maxptime:"+r+"\r\n"),i.headerExtensions&&i.headerExtensions.forEach((e=>{n+=t.writeExtmap(e)})),n},t.parseRtpEncodingParameters=function(e){const i=[],n=t.parseRtpParameters(e),r=-1!==n.fecMechanisms.indexOf("RED"),s=-1!==n.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute)),o=a.length>0&&a[0].ssrc;let c;const d=t.matchPrefix(e,"a=ssrc-group:FID").map((e=>e.substr(17).split(" ").map((e=>parseInt(e,10)))));d.length>0&&d[0].length>1&&d[0][0]===o&&(c=d[0][1]),n.codecs.forEach((e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:o,codecPayloadType:parseInt(e.parameters.apt,10)};o&&c&&(t.rtx={ssrc:c}),i.push(t),r&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:o,mechanism:s?"red+ulpfec":"red"},i.push(t))}})),0===i.length&&o&&i.push({ssrc:o});let u=t.matchPrefix(e,"b=");return u.length&&(u=0===u[0].indexOf("b=TIAS:")?parseInt(u[0].substr(7),10):0===u[0].indexOf("b=AS:")?1e3*parseInt(u[0].substr(5),10)*.95-16e3:void 0,i.forEach((e=>{e.maxBitrate=u}))),i},t.parseRtcpParameters=function(e){const i={},n=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute))[0];n&&(i.cname=n.value,i.ssrc=n.ssrc);const r=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=r.length>0,i.compound=0===r.length;const s=t.matchPrefix(e,"a=rtcp-mux");return i.mux=s.length>0,i},t.writeRtcpParameters=function(e){let t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){let i;const n=t.matchPrefix(e,"a=msid:");if(1===n.length)return i=n[0].substr(7).split(" "),{stream:i[0],track:i[1]};const r=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return r.length>0?(i=r[0].value.split(" "),{stream:i[0],track:i[1]}):void 0},t.parseSctpDescription=function(e){const i=t.parseMLine(e),n=t.matchPrefix(e,"a=max-message-size:");let r;n.length>0&&(r=parseInt(n[0].substr(19),10)),isNaN(r)&&(r=65536);const s=t.matchPrefix(e,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};const a=t.matchPrefix(e,"a=sctpmap:");if(a.length>0){const e=a[0].substr(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:r}}},t.writeSctpDescription=function(e,t){let i=[];return i="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&i.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),i.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,i,n){let r;const s=void 0!==i?i:2;r=e||t.generateSessionId();return"v=0\r\no="+(n||"thisisadapterortc")+" "+r+" "+s+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,i){const n=t.splitLines(e);for(let e=0;e<n.length;e++)switch(n[e]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[e].substr(2)}return i?t.getDirection(i):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){const i=t.splitLines(e)[0].substr(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},t.parseOLine=function(e){const i=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;const i=t.splitLines(e);for(let e=0;e<i.length;e++)if(i[e].length<2||"="!==i[e].charAt(1))return!1;return!0},e.exports=t}({get exports(){return Ji},set exports(e){Ji=e}});var $i=Ji,Bi=t({__proto__:null,default:$i},[Ji]);function ji(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const i=new t(e),n=$i.parseCandidate(e.candidate),r=Object.assign(i,n);return r.toJSON=function(){return{candidate:r.candidate,sdpMid:r.sdpMid,sdpMLineIndex:r.sdpMLineIndex,usernameFragment:r.usernameFragment}},r}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,zt(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function Vi(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const i=function(e){if(!e||!e.sdp)return!1;const t=$i.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=$i.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))},n=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const i=parseInt(t[1],10);return i!=i?-1:i},r=function(e){let i=65536;return"firefox"===t.browser&&(i=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),i},s=function(e,i){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const r=$i.matchPrefix(e.sdp,"a=max-message-size:");return r.length>0?n=parseInt(r[0].substr(19),10):"firefox"===t.browser&&-1!==i&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(i(arguments[0])){const e=n(arguments[0]),t=r(e),i=s(arguments[0],e);let a;a=0===t&&0===i?Number.POSITIVE_INFINITY:0===t||0===i?Math.max(t,i):Math.min(t,i);const o={};Object.defineProperty(o,"maxMessageSize",{get:()=>a}),this._sctp=o}return a.apply(this,arguments)}}function Fi(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const i=e.send;e.send=function(){const n=arguments[0],r=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&r>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return i.apply(e,arguments)}}const i=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=i.apply(this,arguments);return t(e,this),e},zt(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function qi(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const i=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const i=new Event("connectionstatechange",e);t.dispatchEvent(i)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}}))}function Wi(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const i=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:i}):t.sdp=i}return i.apply(this,arguments)}}function Gi(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.addIceCandidate;i&&0!==i.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():i.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function Qi(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.setLocalDescription;i&&0!==i.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if("object"!=typeof e||e.type&&e.sdp)return i.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":e.type="offer";break;default:e.type="answer"}if(e.sdp||"offer"!==e.type&&"answer"!==e.type)return i.apply(this,[e]);const t="offer"===e.type?this.createOffer:this.createAnswer;return t.apply(this).then((e=>i.apply(this,[e])))})}var zi,Hi,Zi,Ki=Object.freeze({__proto__:null,removeExtmapAllowMixed:Wi,shimAddIceCandidateNullOrEmpty:Gi,shimConnectionState:qi,shimMaxMessageSize:Vi,shimParameterlessSetLocalDescription:Qi,shimRTCIceCandidate:ji,shimSendThrowTypeError:Fi});function Yi(e){switch(e){case 0:case"PUBLISHER":return zi.PUBLISHER;case 1:case"SUBSCRIBER":return zi.SUBSCRIBER;default:return zi.UNRECOGNIZED}}function Xi(e){switch(e){case zi.PUBLISHER:return"PUBLISHER";case zi.SUBSCRIBER:return"SUBSCRIBER";case zi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function en(e){switch(e){case 0:case"ACTIVE":return Hi.ACTIVE;case 1:case"PAUSED":return Hi.PAUSED;default:return Hi.UNRECOGNIZED}}function tn(e){switch(e){case 0:case"UDP":return Zi.UDP;case 1:case"TCP":return Zi.TCP;case 2:case"TLS":return Zi.TLS;default:return Zi.UNRECOGNIZED}}!function(){let{window:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0};const i=Kt,n=Xt(e),r={browserDetails:n,commonShim:Ki,extractVersion:Qt,disableLog:Ht,disableWarnings:Zt,sdp:Bi};switch(n.browser){case"chrome":if(!vi||!pi||!t.shimChrome)return i("Chrome shim is not included in this adapter release."),r;if(null===n.version)return i("Chrome shim can not determine version, not shimming."),r;i("adapter.js shimming chrome."),r.browserShim=vi,Gi(e,n),Qi(e),si(e,n),ai(e),pi(e,n),oi(e),hi(e,n),ci(e),di(e),ui(e),mi(e,n),ji(e),qi(e),Vi(e,n),Fi(e),Wi(e,n);break;case"firefox":if(!Ri||!bi||!t.shimFirefox)return i("Firefox shim is not included in this adapter release."),r;i("adapter.js shimming firefox."),r.browserShim=Ri,Gi(e,n),Qi(e),fi(e,n),bi(e,n),gi(e),Si(e),ki(e),yi(e),wi(e),Ci(e),Ti(e),Ei(e),Pi(e),ji(e),qi(e),Vi(e,n),Fi(e);break;case"safari":if(!_i||!t.shimSafari)return i("Safari shim is not included in this adapter release."),r;i("adapter.js shimming safari."),r.browserShim=_i,Gi(e,n),Qi(e),Ui(e),xi(e),Di(e),Oi(e),Ni(e),Li(e),Ii(e),Mi(e),ji(e),Vi(e,n),Fi(e),Wi(e,n);break;default:i("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),function(e){e[e.PUBLISHER=0]="PUBLISHER",e[e.SUBSCRIBER=1]="SUBSCRIBER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(zi||(zi={})),function(e){e[e.ACTIVE=0]="ACTIVE",e[e.PAUSED=1]="PAUSED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Hi||(Hi={})),function(e){e[e.UDP=0]="UDP",e[e.TCP=1]="TCP",e[e.TLS=2]="TLS",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Zi||(Zi={}));const nn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();var i,n,r,s,a,o,c,d,u,l,h,p,m;return"offer"===(null===(i=e.message)||void 0===i?void 0:i.$case)&&hn.encode(e.message.offer,t.uint32(10).fork()).ldelim(),"answer"===(null===(n=e.message)||void 0===n?void 0:n.$case)&&hn.encode(e.message.answer,t.uint32(18).fork()).ldelim(),"trickle"===(null===(r=e.message)||void 0===r?void 0:r.$case)&&on.encode(e.message.trickle,t.uint32(26).fork()).ldelim(),"addTrack"===(null===(s=e.message)||void 0===s?void 0:s.$case)&&an.encode(e.message.addTrack,t.uint32(34).fork()).ldelim(),"mute"===(null===(a=e.message)||void 0===a?void 0:a.$case)&&cn.encode(e.message.mute,t.uint32(42).fork()).ldelim(),"subscription"===(null===(o=e.message)||void 0===o?void 0:o.$case)&&mn.encode(e.message.subscription,t.uint32(50).fork()).ldelim(),"trackSetting"===(null===(c=e.message)||void 0===c?void 0:c.$case)&&vn.encode(e.message.trackSetting,t.uint32(58).fork()).ldelim(),"leave"===(null===(d=e.message)||void 0===d?void 0:d.$case)&&fn.encode(e.message.leave,t.uint32(66).fork()).ldelim(),"updateLayers"===(null===(u=e.message)||void 0===u?void 0:u.$case)&&gn.encode(e.message.updateLayers,t.uint32(82).fork()).ldelim(),"subscriptionPermission"===(null===(l=e.message)||void 0===l?void 0:l.$case)&&Nn.encode(e.message.subscriptionPermission,t.uint32(90).fork()).ldelim(),"syncState"===(null===(h=e.message)||void 0===h?void 0:h.$case)&&In.encode(e.message.syncState,t.uint32(98).fork()).ldelim(),"simulate"===(null===(p=e.message)||void 0===p?void 0:p.$case)&&Un.encode(e.message.simulate,t.uint32(106).fork()).ldelim(),"ping"===(null===(m=e.message)||void 0===m?void 0:m.$case)&&t.uint32(112).int64(e.message.ping),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={message:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.message={$case:"offer",offer:hn.decode(i,i.uint32())};break;case 2:r.message={$case:"answer",answer:hn.decode(i,i.uint32())};break;case 3:r.message={$case:"trickle",trickle:on.decode(i,i.uint32())};break;case 4:r.message={$case:"addTrack",addTrack:an.decode(i,i.uint32())};break;case 5:r.message={$case:"mute",mute:cn.decode(i,i.uint32())};break;case 6:r.message={$case:"subscription",subscription:mn.decode(i,i.uint32())};break;case 7:r.message={$case:"trackSetting",trackSetting:vn.decode(i,i.uint32())};break;case 8:r.message={$case:"leave",leave:fn.decode(i,i.uint32())};break;case 10:r.message={$case:"updateLayers",updateLayers:gn.decode(i,i.uint32())};break;case 11:r.message={$case:"subscriptionPermission",subscriptionPermission:Nn.decode(i,i.uint32())};break;case 12:r.message={$case:"syncState",syncState:In.decode(i,i.uint32())};break;case 13:r.message={$case:"simulate",simulate:Un.decode(i,i.uint32())};break;case 14:r.message={$case:"ping",ping:Bn(i.int64())};break;default:i.skipType(7&e)}}return r},fromJSON:e=>({message:jn(e.offer)?{$case:"offer",offer:hn.fromJSON(e.offer)}:jn(e.answer)?{$case:"answer",answer:hn.fromJSON(e.answer)}:jn(e.trickle)?{$case:"trickle",trickle:on.fromJSON(e.trickle)}:jn(e.addTrack)?{$case:"addTrack",addTrack:an.fromJSON(e.addTrack)}:jn(e.mute)?{$case:"mute",mute:cn.fromJSON(e.mute)}:jn(e.subscription)?{$case:"subscription",subscription:mn.fromJSON(e.subscription)}:jn(e.trackSetting)?{$case:"trackSetting",trackSetting:vn.fromJSON(e.trackSetting)}:jn(e.leave)?{$case:"leave",leave:fn.fromJSON(e.leave)}:jn(e.updateLayers)?{$case:"updateLayers",updateLayers:gn.fromJSON(e.updateLayers)}:jn(e.subscriptionPermission)?{$case:"subscriptionPermission",subscriptionPermission:Nn.fromJSON(e.subscriptionPermission)}:jn(e.syncState)?{$case:"syncState",syncState:In.fromJSON(e.syncState)}:jn(e.simulate)?{$case:"simulate",simulate:Un.fromJSON(e.simulate)}:jn(e.ping)?{$case:"ping",ping:Number(e.ping)}:void 0}),toJSON(e){var t,i,n,r,s,a,o,c,d,u,l,h,p,m,v,f,g,b,k,y,S,w,C,T,E,P,R,O,N,D,I,A,U,L,x,M,_,J;const $={};return"offer"===(null===(t=e.message)||void 0===t?void 0:t.$case)&&($.offer=(null===(i=e.message)||void 0===i?void 0:i.offer)?hn.toJSON(null===(n=e.message)||void 0===n?void 0:n.offer):void 0),"answer"===(null===(r=e.message)||void 0===r?void 0:r.$case)&&($.answer=(null===(s=e.message)||void 0===s?void 0:s.answer)?hn.toJSON(null===(a=e.message)||void 0===a?void 0:a.answer):void 0),"trickle"===(null===(o=e.message)||void 0===o?void 0:o.$case)&&($.trickle=(null===(c=e.message)||void 0===c?void 0:c.trickle)?on.toJSON(null===(d=e.message)||void 0===d?void 0:d.trickle):void 0),"addTrack"===(null===(u=e.message)||void 0===u?void 0:u.$case)&&($.addTrack=(null===(l=e.message)||void 0===l?void 0:l.addTrack)?an.toJSON(null===(h=e.message)||void 0===h?void 0:h.addTrack):void 0),"mute"===(null===(p=e.message)||void 0===p?void 0:p.$case)&&($.mute=(null===(m=e.message)||void 0===m?void 0:m.mute)?cn.toJSON(null===(v=e.message)||void 0===v?void 0:v.mute):void 0),"subscription"===(null===(f=e.message)||void 0===f?void 0:f.$case)&&($.subscription=(null===(g=e.message)||void 0===g?void 0:g.subscription)?mn.toJSON(null===(b=e.message)||void 0===b?void 0:b.subscription):void 0),"trackSetting"===(null===(k=e.message)||void 0===k?void 0:k.$case)&&($.trackSetting=(null===(y=e.message)||void 0===y?void 0:y.trackSetting)?vn.toJSON(null===(S=e.message)||void 0===S?void 0:S.trackSetting):void 0),"leave"===(null===(w=e.message)||void 0===w?void 0:w.$case)&&($.leave=(null===(C=e.message)||void 0===C?void 0:C.leave)?fn.toJSON(null===(T=e.message)||void 0===T?void 0:T.leave):void 0),"updateLayers"===(null===(E=e.message)||void 0===E?void 0:E.$case)&&($.updateLayers=(null===(P=e.message)||void 0===P?void 0:P.updateLayers)?gn.toJSON(null===(R=e.message)||void 0===R?void 0:R.updateLayers):void 0),"subscriptionPermission"===(null===(O=e.message)||void 0===O?void 0:O.$case)&&($.subscriptionPermission=(null===(N=e.message)||void 0===N?void 0:N.subscriptionPermission)?Nn.toJSON(null===(D=e.message)||void 0===D?void 0:D.subscriptionPermission):void 0),"syncState"===(null===(I=e.message)||void 0===I?void 0:I.$case)&&($.syncState=(null===(A=e.message)||void 0===A?void 0:A.syncState)?In.toJSON(null===(U=e.message)||void 0===U?void 0:U.syncState):void 0),"simulate"===(null===(L=e.message)||void 0===L?void 0:L.$case)&&($.simulate=(null===(x=e.message)||void 0===x?void 0:x.simulate)?Un.toJSON(null===(M=e.message)||void 0===M?void 0:M.simulate):void 0),"ping"===(null===(_=e.message)||void 0===_?void 0:_.$case)&&($.ping=Math.round(null===(J=e.message)||void 0===J?void 0:J.ping)),$},fromPartial(e){var t,i,n,r,s,a,o,c,d,u,l,h,p,m,v,f,g,b,k,y,S,w,C,T,E,P,R,O,N,D,I,A,U,L,x,M,_,J,$;const B={message:void 0};return"offer"===(null===(t=e.message)||void 0===t?void 0:t.$case)&&void 0!==(null===(i=e.message)||void 0===i?void 0:i.offer)&&null!==(null===(n=e.message)||void 0===n?void 0:n.offer)&&(B.message={$case:"offer",offer:hn.fromPartial(e.message.offer)}),"answer"===(null===(r=e.message)||void 0===r?void 0:r.$case)&&void 0!==(null===(s=e.message)||void 0===s?void 0:s.answer)&&null!==(null===(a=e.message)||void 0===a?void 0:a.answer)&&(B.message={$case:"answer",answer:hn.fromPartial(e.message.answer)}),"trickle"===(null===(o=e.message)||void 0===o?void 0:o.$case)&&void 0!==(null===(c=e.message)||void 0===c?void 0:c.trickle)&&null!==(null===(d=e.message)||void 0===d?void 0:d.trickle)&&(B.message={$case:"trickle",trickle:on.fromPartial(e.message.trickle)}),"addTrack"===(null===(u=e.message)||void 0===u?void 0:u.$case)&&void 0!==(null===(l=e.message)||void 0===l?void 0:l.addTrack)&&null!==(null===(h=e.message)||void 0===h?void 0:h.addTrack)&&(B.message={$case:"addTrack",addTrack:an.fromPartial(e.message.addTrack)}),"mute"===(null===(p=e.message)||void 0===p?void 0:p.$case)&&void 0!==(null===(m=e.message)||void 0===m?void 0:m.mute)&&null!==(null===(v=e.message)||void 0===v?void 0:v.mute)&&(B.message={$case:"mute",mute:cn.fromPartial(e.message.mute)}),"subscription"===(null===(f=e.message)||void 0===f?void 0:f.$case)&&void 0!==(null===(g=e.message)||void 0===g?void 0:g.subscription)&&null!==(null===(b=e.message)||void 0===b?void 0:b.subscription)&&(B.message={$case:"subscription",subscription:mn.fromPartial(e.message.subscription)}),"trackSetting"===(null===(k=e.message)||void 0===k?void 0:k.$case)&&void 0!==(null===(y=e.message)||void 0===y?void 0:y.trackSetting)&&null!==(null===(S=e.message)||void 0===S?void 0:S.trackSetting)&&(B.message={$case:"trackSetting",trackSetting:vn.fromPartial(e.message.trackSetting)}),"leave"===(null===(w=e.message)||void 0===w?void 0:w.$case)&&void 0!==(null===(C=e.message)||void 0===C?void 0:C.leave)&&null!==(null===(T=e.message)||void 0===T?void 0:T.leave)&&(B.message={$case:"leave",leave:fn.fromPartial(e.message.leave)}),"updateLayers"===(null===(E=e.message)||void 0===E?void 0:E.$case)&&void 0!==(null===(P=e.message)||void 0===P?void 0:P.updateLayers)&&null!==(null===(R=e.message)||void 0===R?void 0:R.updateLayers)&&(B.message={$case:"updateLayers",updateLayers:gn.fromPartial(e.message.updateLayers)}),"subscriptionPermission"===(null===(O=e.message)||void 0===O?void 0:O.$case)&&void 0!==(null===(N=e.message)||void 0===N?void 0:N.subscriptionPermission)&&null!==(null===(D=e.message)||void 0===D?void 0:D.subscriptionPermission)&&(B.message={$case:"subscriptionPermission",subscriptionPermission:Nn.fromPartial(e.message.subscriptionPermission)}),"syncState"===(null===(I=e.message)||void 0===I?void 0:I.$case)&&void 0!==(null===(A=e.message)||void 0===A?void 0:A.syncState)&&null!==(null===(U=e.message)||void 0===U?void 0:U.syncState)&&(B.message={$case:"syncState",syncState:In.fromPartial(e.message.syncState)}),"simulate"===(null===(L=e.message)||void 0===L?void 0:L.$case)&&void 0!==(null===(x=e.message)||void 0===x?void 0:x.simulate)&&null!==(null===(M=e.message)||void 0===M?void 0:M.simulate)&&(B.message={$case:"simulate",simulate:Un.fromPartial(e.message.simulate)}),"ping"===(null===(_=e.message)||void 0===_?void 0:_.$case)&&void 0!==(null===(J=e.message)||void 0===J?void 0:J.ping)&&null!==(null===($=e.message)||void 0===$?void 0:$.ping)&&(B.message={$case:"ping",ping:e.message.ping}),B}};const rn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();var i,n,r,s,a,o,c,d,u,l,h,p,m,v,f,g,b;return"join"===(null===(i=e.message)||void 0===i?void 0:i.$case)&&dn.encode(e.message.join,t.uint32(10).fork()).ldelim(),"answer"===(null===(n=e.message)||void 0===n?void 0:n.$case)&&hn.encode(e.message.answer,t.uint32(18).fork()).ldelim(),"offer"===(null===(r=e.message)||void 0===r?void 0:r.$case)&&hn.encode(e.message.offer,t.uint32(26).fork()).ldelim(),"trickle"===(null===(s=e.message)||void 0===s?void 0:s.$case)&&on.encode(e.message.trickle,t.uint32(34).fork()).ldelim(),"update"===(null===(a=e.message)||void 0===a?void 0:a.$case)&&pn.encode(e.message.update,t.uint32(42).fork()).ldelim(),"trackPublished"===(null===(o=e.message)||void 0===o?void 0:o.$case)&&un.encode(e.message.trackPublished,t.uint32(50).fork()).ldelim(),"leave"===(null===(c=e.message)||void 0===c?void 0:c.$case)&&fn.encode(e.message.leave,t.uint32(66).fork()).ldelim(),"mute"===(null===(d=e.message)||void 0===d?void 0:d.$case)&&cn.encode(e.message.mute,t.uint32(74).fork()).ldelim(),"speakersChanged"===(null===(u=e.message)||void 0===u?void 0:u.$case)&&kn.encode(e.message.speakersChanged,t.uint32(82).fork()).ldelim(),"roomUpdate"===(null===(l=e.message)||void 0===l?void 0:l.$case)&&yn.encode(e.message.roomUpdate,t.uint32(90).fork()).ldelim(),"connectionQuality"===(null===(h=e.message)||void 0===h?void 0:h.$case)&&wn.encode(e.message.connectionQuality,t.uint32(98).fork()).ldelim(),"streamStateUpdate"===(null===(p=e.message)||void 0===p?void 0:p.$case)&&Tn.encode(e.message.streamStateUpdate,t.uint32(106).fork()).ldelim(),"subscribedQualityUpdate"===(null===(m=e.message)||void 0===m?void 0:m.$case)&&Rn.encode(e.message.subscribedQualityUpdate,t.uint32(114).fork()).ldelim(),"subscriptionPermissionUpdate"===(null===(v=e.message)||void 0===v?void 0:v.$case)&&Dn.encode(e.message.subscriptionPermissionUpdate,t.uint32(122).fork()).ldelim(),"refreshToken"===(null===(f=e.message)||void 0===f?void 0:f.$case)&&t.uint32(130).string(e.message.refreshToken),"trackUnpublished"===(null===(g=e.message)||void 0===g?void 0:g.$case)&&ln.encode(e.message.trackUnpublished,t.uint32(138).fork()).ldelim(),"pong"===(null===(b=e.message)||void 0===b?void 0:b.$case)&&t.uint32(144).int64(e.message.pong),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={message:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.message={$case:"join",join:dn.decode(i,i.uint32())};break;case 2:r.message={$case:"answer",answer:hn.decode(i,i.uint32())};break;case 3:r.message={$case:"offer",offer:hn.decode(i,i.uint32())};break;case 4:r.message={$case:"trickle",trickle:on.decode(i,i.uint32())};break;case 5:r.message={$case:"update",update:pn.decode(i,i.uint32())};break;case 6:r.message={$case:"trackPublished",trackPublished:un.decode(i,i.uint32())};break;case 8:r.message={$case:"leave",leave:fn.decode(i,i.uint32())};break;case 9:r.message={$case:"mute",mute:cn.decode(i,i.uint32())};break;case 10:r.message={$case:"speakersChanged",speakersChanged:kn.decode(i,i.uint32())};break;case 11:r.message={$case:"roomUpdate",roomUpdate:yn.decode(i,i.uint32())};break;case 12:r.message={$case:"connectionQuality",connectionQuality:wn.decode(i,i.uint32())};break;case 13:r.message={$case:"streamStateUpdate",streamStateUpdate:Tn.decode(i,i.uint32())};break;case 14:r.message={$case:"subscribedQualityUpdate",subscribedQualityUpdate:Rn.decode(i,i.uint32())};break;case 15:r.message={$case:"subscriptionPermissionUpdate",subscriptionPermissionUpdate:Dn.decode(i,i.uint32())};break;case 16:r.message={$case:"refreshToken",refreshToken:i.string()};break;case 17:r.message={$case:"trackUnpublished",trackUnpublished:ln.decode(i,i.uint32())};break;case 18:r.message={$case:"pong",pong:Bn(i.int64())};break;default:i.skipType(7&e)}}return r},fromJSON:e=>({message:jn(e.join)?{$case:"join",join:dn.fromJSON(e.join)}:jn(e.answer)?{$case:"answer",answer:hn.fromJSON(e.answer)}:jn(e.offer)?{$case:"offer",offer:hn.fromJSON(e.offer)}:jn(e.trickle)?{$case:"trickle",trickle:on.fromJSON(e.trickle)}:jn(e.update)?{$case:"update",update:pn.fromJSON(e.update)}:jn(e.trackPublished)?{$case:"trackPublished",trackPublished:un.fromJSON(e.trackPublished)}:jn(e.leave)?{$case:"leave",leave:fn.fromJSON(e.leave)}:jn(e.mute)?{$case:"mute",mute:cn.fromJSON(e.mute)}:jn(e.speakersChanged)?{$case:"speakersChanged",speakersChanged:kn.fromJSON(e.speakersChanged)}:jn(e.roomUpdate)?{$case:"roomUpdate",roomUpdate:yn.fromJSON(e.roomUpdate)}:jn(e.connectionQuality)?{$case:"connectionQuality",connectionQuality:wn.fromJSON(e.connectionQuality)}:jn(e.streamStateUpdate)?{$case:"streamStateUpdate",streamStateUpdate:Tn.fromJSON(e.streamStateUpdate)}:jn(e.subscribedQualityUpdate)?{$case:"subscribedQualityUpdate",subscribedQualityUpdate:Rn.fromJSON(e.subscribedQualityUpdate)}:jn(e.subscriptionPermissionUpdate)?{$case:"subscriptionPermissionUpdate",subscriptionPermissionUpdate:Dn.fromJSON(e.subscriptionPermissionUpdate)}:jn(e.refreshToken)?{$case:"refreshToken",refreshToken:String(e.refreshToken)}:jn(e.trackUnpublished)?{$case:"trackUnpublished",trackUnpublished:ln.fromJSON(e.trackUnpublished)}:jn(e.pong)?{$case:"pong",pong:Number(e.pong)}:void 0}),toJSON(e){var t,i,n,r,s,a,o,c,d,u,l,h,p,m,v,f,g,b,k,y,S,w,C,T,E,P,R,O,N,D,I,A,U,L,x,M,_,J,$,B,j,V,F,q,W,G,Q,z,H;const Z={};return"join"===(null===(t=e.message)||void 0===t?void 0:t.$case)&&(Z.join=(null===(i=e.message)||void 0===i?void 0:i.join)?dn.toJSON(null===(n=e.message)||void 0===n?void 0:n.join):void 0),"answer"===(null===(r=e.message)||void 0===r?void 0:r.$case)&&(Z.answer=(null===(s=e.message)||void 0===s?void 0:s.answer)?hn.toJSON(null===(a=e.message)||void 0===a?void 0:a.answer):void 0),"offer"===(null===(o=e.message)||void 0===o?void 0:o.$case)&&(Z.offer=(null===(c=e.message)||void 0===c?void 0:c.offer)?hn.toJSON(null===(d=e.message)||void 0===d?void 0:d.offer):void 0),"trickle"===(null===(u=e.message)||void 0===u?void 0:u.$case)&&(Z.trickle=(null===(l=e.message)||void 0===l?void 0:l.trickle)?on.toJSON(null===(h=e.message)||void 0===h?void 0:h.trickle):void 0),"update"===(null===(p=e.message)||void 0===p?void 0:p.$case)&&(Z.update=(null===(m=e.message)||void 0===m?void 0:m.update)?pn.toJSON(null===(v=e.message)||void 0===v?void 0:v.update):void 0),"trackPublished"===(null===(f=e.message)||void 0===f?void 0:f.$case)&&(Z.trackPublished=(null===(g=e.message)||void 0===g?void 0:g.trackPublished)?un.toJSON(null===(b=e.message)||void 0===b?void 0:b.trackPublished):void 0),"leave"===(null===(k=e.message)||void 0===k?void 0:k.$case)&&(Z.leave=(null===(y=e.message)||void 0===y?void 0:y.leave)?fn.toJSON(null===(S=e.message)||void 0===S?void 0:S.leave):void 0),"mute"===(null===(w=e.message)||void 0===w?void 0:w.$case)&&(Z.mute=(null===(C=e.message)||void 0===C?void 0:C.mute)?cn.toJSON(null===(T=e.message)||void 0===T?void 0:T.mute):void 0),"speakersChanged"===(null===(E=e.message)||void 0===E?void 0:E.$case)&&(Z.speakersChanged=(null===(P=e.message)||void 0===P?void 0:P.speakersChanged)?kn.toJSON(null===(R=e.message)||void 0===R?void 0:R.speakersChanged):void 0),"roomUpdate"===(null===(O=e.message)||void 0===O?void 0:O.$case)&&(Z.roomUpdate=(null===(N=e.message)||void 0===N?void 0:N.roomUpdate)?yn.toJSON(null===(D=e.message)||void 0===D?void 0:D.roomUpdate):void 0),"connectionQuality"===(null===(I=e.message)||void 0===I?void 0:I.$case)&&(Z.connectionQuality=(null===(A=e.message)||void 0===A?void 0:A.connectionQuality)?wn.toJSON(null===(U=e.message)||void 0===U?void 0:U.connectionQuality):void 0),"streamStateUpdate"===(null===(L=e.message)||void 0===L?void 0:L.$case)&&(Z.streamStateUpdate=(null===(x=e.message)||void 0===x?void 0:x.streamStateUpdate)?Tn.toJSON(null===(M=e.message)||void 0===M?void 0:M.streamStateUpdate):void 0),"subscribedQualityUpdate"===(null===(_=e.message)||void 0===_?void 0:_.$case)&&(Z.subscribedQualityUpdate=(null===(J=e.message)||void 0===J?void 0:J.subscribedQualityUpdate)?Rn.toJSON(null===($=e.message)||void 0===$?void 0:$.subscribedQualityUpdate):void 0),"subscriptionPermissionUpdate"===(null===(B=e.message)||void 0===B?void 0:B.$case)&&(Z.subscriptionPermissionUpdate=(null===(j=e.message)||void 0===j?void 0:j.subscriptionPermissionUpdate)?Dn.toJSON(null===(V=e.message)||void 0===V?void 0:V.subscriptionPermissionUpdate):void 0),"refreshToken"===(null===(F=e.message)||void 0===F?void 0:F.$case)&&(Z.refreshToken=null===(q=e.message)||void 0===q?void 0:q.refreshToken),"trackUnpublished"===(null===(W=e.message)||void 0===W?void 0:W.$case)&&(Z.trackUnpublished=(null===(G=e.message)||void 0===G?void 0:G.trackUnpublished)?ln.toJSON(null===(Q=e.message)||void 0===Q?void 0:Q.trackUnpublished):void 0),"pong"===(null===(z=e.message)||void 0===z?void 0:z.$case)&&(Z.pong=Math.round(null===(H=e.message)||void 0===H?void 0:H.pong)),Z},fromPartial(e){var t,i,n,r,s,a,o,c,d,u,l,h,p,m,v,f,g,b,k,y,S,w,C,T,E,P,R,O,N,D,I,A,U,L,x,M,_,J,$,B,j,V,F,q,W,G,Q,z,H,Z,K;const Y={message:void 0};return"join"===(null===(t=e.message)||void 0===t?void 0:t.$case)&&void 0!==(null===(i=e.message)||void 0===i?void 0:i.join)&&null!==(null===(n=e.message)||void 0===n?void 0:n.join)&&(Y.message={$case:"join",join:dn.fromPartial(e.message.join)}),"answer"===(null===(r=e.message)||void 0===r?void 0:r.$case)&&void 0!==(null===(s=e.message)||void 0===s?void 0:s.answer)&&null!==(null===(a=e.message)||void 0===a?void 0:a.answer)&&(Y.message={$case:"answer",answer:hn.fromPartial(e.message.answer)}),"offer"===(null===(o=e.message)||void 0===o?void 0:o.$case)&&void 0!==(null===(c=e.message)||void 0===c?void 0:c.offer)&&null!==(null===(d=e.message)||void 0===d?void 0:d.offer)&&(Y.message={$case:"offer",offer:hn.fromPartial(e.message.offer)}),"trickle"===(null===(u=e.message)||void 0===u?void 0:u.$case)&&void 0!==(null===(l=e.message)||void 0===l?void 0:l.trickle)&&null!==(null===(h=e.message)||void 0===h?void 0:h.trickle)&&(Y.message={$case:"trickle",trickle:on.fromPartial(e.message.trickle)}),"update"===(null===(p=e.message)||void 0===p?void 0:p.$case)&&void 0!==(null===(m=e.message)||void 0===m?void 0:m.update)&&null!==(null===(v=e.message)||void 0===v?void 0:v.update)&&(Y.message={$case:"update",update:pn.fromPartial(e.message.update)}),"trackPublished"===(null===(f=e.message)||void 0===f?void 0:f.$case)&&void 0!==(null===(g=e.message)||void 0===g?void 0:g.trackPublished)&&null!==(null===(b=e.message)||void 0===b?void 0:b.trackPublished)&&(Y.message={$case:"trackPublished",trackPublished:un.fromPartial(e.message.trackPublished)}),"leave"===(null===(k=e.message)||void 0===k?void 0:k.$case)&&void 0!==(null===(y=e.message)||void 0===y?void 0:y.leave)&&null!==(null===(S=e.message)||void 0===S?void 0:S.leave)&&(Y.message={$case:"leave",leave:fn.fromPartial(e.message.leave)}),"mute"===(null===(w=e.message)||void 0===w?void 0:w.$case)&&void 0!==(null===(C=e.message)||void 0===C?void 0:C.mute)&&null!==(null===(T=e.message)||void 0===T?void 0:T.mute)&&(Y.message={$case:"mute",mute:cn.fromPartial(e.message.mute)}),"speakersChanged"===(null===(E=e.message)||void 0===E?void 0:E.$case)&&void 0!==(null===(P=e.message)||void 0===P?void 0:P.speakersChanged)&&null!==(null===(R=e.message)||void 0===R?void 0:R.speakersChanged)&&(Y.message={$case:"speakersChanged",speakersChanged:kn.fromPartial(e.message.speakersChanged)}),"roomUpdate"===(null===(O=e.message)||void 0===O?void 0:O.$case)&&void 0!==(null===(N=e.message)||void 0===N?void 0:N.roomUpdate)&&null!==(null===(D=e.message)||void 0===D?void 0:D.roomUpdate)&&(Y.message={$case:"roomUpdate",roomUpdate:yn.fromPartial(e.message.roomUpdate)}),"connectionQuality"===(null===(I=e.message)||void 0===I?void 0:I.$case)&&void 0!==(null===(A=e.message)||void 0===A?void 0:A.connectionQuality)&&null!==(null===(U=e.message)||void 0===U?void 0:U.connectionQuality)&&(Y.message={$case:"connectionQuality",connectionQuality:wn.fromPartial(e.message.connectionQuality)}),"streamStateUpdate"===(null===(L=e.message)||void 0===L?void 0:L.$case)&&void 0!==(null===(x=e.message)||void 0===x?void 0:x.streamStateUpdate)&&null!==(null===(M=e.message)||void 0===M?void 0:M.streamStateUpdate)&&(Y.message={$case:"streamStateUpdate",streamStateUpdate:Tn.fromPartial(e.message.streamStateUpdate)}),"subscribedQualityUpdate"===(null===(_=e.message)||void 0===_?void 0:_.$case)&&void 0!==(null===(J=e.message)||void 0===J?void 0:J.subscribedQualityUpdate)&&null!==(null===($=e.message)||void 0===$?void 0:$.subscribedQualityUpdate)&&(Y.message={$case:"subscribedQualityUpdate",subscribedQualityUpdate:Rn.fromPartial(e.message.subscribedQualityUpdate)}),"subscriptionPermissionUpdate"===(null===(B=e.message)||void 0===B?void 0:B.$case)&&void 0!==(null===(j=e.message)||void 0===j?void 0:j.subscriptionPermissionUpdate)&&null!==(null===(V=e.message)||void 0===V?void 0:V.subscriptionPermissionUpdate)&&(Y.message={$case:"subscriptionPermissionUpdate",subscriptionPermissionUpdate:Dn.fromPartial(e.message.subscriptionPermissionUpdate)}),"refreshToken"===(null===(F=e.message)||void 0===F?void 0:F.$case)&&void 0!==(null===(q=e.message)||void 0===q?void 0:q.refreshToken)&&null!==(null===(W=e.message)||void 0===W?void 0:W.refreshToken)&&(Y.message={$case:"refreshToken",refreshToken:e.message.refreshToken}),"trackUnpublished"===(null===(G=e.message)||void 0===G?void 0:G.$case)&&void 0!==(null===(Q=e.message)||void 0===Q?void 0:Q.trackUnpublished)&&null!==(null===(z=e.message)||void 0===z?void 0:z.trackUnpublished)&&(Y.message={$case:"trackUnpublished",trackUnpublished:ln.fromPartial(e.message.trackUnpublished)}),"pong"===(null===(H=e.message)||void 0===H?void 0:H.$case)&&void 0!==(null===(Z=e.message)||void 0===Z?void 0:Z.pong)&&null!==(null===(K=e.message)||void 0===K?void 0:K.pong)&&(Y.message={$case:"pong",pong:e.message.pong}),Y}};const sn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return""!==e.codec&&t.uint32(10).string(e.codec),""!==e.cid&&t.uint32(18).string(e.cid),!0===e.enableSimulcastLayers&&t.uint32(24).bool(e.enableSimulcastLayers),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={codec:"",cid:"",enableSimulcastLayers:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.codec=i.string();break;case 2:r.cid=i.string();break;case 3:r.enableSimulcastLayers=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({codec:jn(e.codec)?String(e.codec):"",cid:jn(e.cid)?String(e.cid):"",enableSimulcastLayers:!!jn(e.enableSimulcastLayers)&&Boolean(e.enableSimulcastLayers)}),toJSON(e){const t={};return void 0!==e.codec&&(t.codec=e.codec),void 0!==e.cid&&(t.cid=e.cid),void 0!==e.enableSimulcastLayers&&(t.enableSimulcastLayers=e.enableSimulcastLayers),t},fromPartial(e){var t,i,n;const r={codec:"",cid:"",enableSimulcastLayers:!1};return r.codec=null!==(t=e.codec)&&void 0!==t?t:"",r.cid=null!==(i=e.cid)&&void 0!==i?i:"",r.enableSimulcastLayers=null!==(n=e.enableSimulcastLayers)&&void 0!==n&&n,r}};const an={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();""!==e.cid&&t.uint32(10).string(e.cid),""!==e.name&&t.uint32(18).string(e.name),0!==e.type&&t.uint32(24).int32(e.type),0!==e.width&&t.uint32(32).uint32(e.width),0!==e.height&&t.uint32(40).uint32(e.height),!0===e.muted&&t.uint32(48).bool(e.muted),!0===e.disableDtx&&t.uint32(56).bool(e.disableDtx),0!==e.source&&t.uint32(64).int32(e.source);for(const i of e.layers)St.encode(i,t.uint32(74).fork()).ldelim();for(const i of e.simulcastCodecs)sn.encode(i,t.uint32(82).fork()).ldelim();return""!==e.sid&&t.uint32(90).string(e.sid),!0===e.stereo&&t.uint32(96).bool(e.stereo),!0===e.disableRed&&t.uint32(104).bool(e.disableRed),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={cid:"",name:"",type:0,width:0,height:0,muted:!1,disableDtx:!1,source:0,layers:[],simulcastCodecs:[],sid:"",stereo:!1,disableRed:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.cid=i.string();break;case 2:r.name=i.string();break;case 3:r.type=i.int32();break;case 4:r.width=i.uint32();break;case 5:r.height=i.uint32();break;case 6:r.muted=i.bool();break;case 7:r.disableDtx=i.bool();break;case 8:r.source=i.int32();break;case 9:r.layers.push(St.decode(i,i.uint32()));break;case 10:r.simulcastCodecs.push(sn.decode(i,i.uint32()));break;case 11:r.sid=i.string();break;case 12:r.stereo=i.bool();break;case 13:r.disableRed=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({cid:jn(e.cid)?String(e.cid):"",name:jn(e.name)?String(e.name):"",type:jn(e.type)?tt(e.type):0,width:jn(e.width)?Number(e.width):0,height:jn(e.height)?Number(e.height):0,muted:!!jn(e.muted)&&Boolean(e.muted),disableDtx:!!jn(e.disableDtx)&&Boolean(e.disableDtx),source:jn(e.source)?nt(e.source):0,layers:Array.isArray(null==e?void 0:e.layers)?e.layers.map((e=>St.fromJSON(e))):[],simulcastCodecs:Array.isArray(null==e?void 0:e.simulcastCodecs)?e.simulcastCodecs.map((e=>sn.fromJSON(e))):[],sid:jn(e.sid)?String(e.sid):"",stereo:!!jn(e.stereo)&&Boolean(e.stereo),disableRed:!!jn(e.disableRed)&&Boolean(e.disableRed)}),toJSON(e){const t={};return void 0!==e.cid&&(t.cid=e.cid),void 0!==e.name&&(t.name=e.name),void 0!==e.type&&(t.type=it(e.type)),void 0!==e.width&&(t.width=Math.round(e.width)),void 0!==e.height&&(t.height=Math.round(e.height)),void 0!==e.muted&&(t.muted=e.muted),void 0!==e.disableDtx&&(t.disableDtx=e.disableDtx),void 0!==e.source&&(t.source=rt(e.source)),e.layers?t.layers=e.layers.map((e=>e?St.toJSON(e):void 0)):t.layers=[],e.simulcastCodecs?t.simulcastCodecs=e.simulcastCodecs.map((e=>e?sn.toJSON(e):void 0)):t.simulcastCodecs=[],void 0!==e.sid&&(t.sid=e.sid),void 0!==e.stereo&&(t.stereo=e.stereo),void 0!==e.disableRed&&(t.disableRed=e.disableRed),t},fromPartial(e){var t,i,n,r,s,a,o,c,d,u,l,h,p;const m={cid:"",name:"",type:0,width:0,height:0,muted:!1,disableDtx:!1,source:0,layers:[],simulcastCodecs:[],sid:"",stereo:!1,disableRed:!1};return m.cid=null!==(t=e.cid)&&void 0!==t?t:"",m.name=null!==(i=e.name)&&void 0!==i?i:"",m.type=null!==(n=e.type)&&void 0!==n?n:0,m.width=null!==(r=e.width)&&void 0!==r?r:0,m.height=null!==(s=e.height)&&void 0!==s?s:0,m.muted=null!==(a=e.muted)&&void 0!==a&&a,m.disableDtx=null!==(o=e.disableDtx)&&void 0!==o&&o,m.source=null!==(c=e.source)&&void 0!==c?c:0,m.layers=(null===(d=e.layers)||void 0===d?void 0:d.map((e=>St.fromPartial(e))))||[],m.simulcastCodecs=(null===(u=e.simulcastCodecs)||void 0===u?void 0:u.map((e=>sn.fromPartial(e))))||[],m.sid=null!==(l=e.sid)&&void 0!==l?l:"",m.stereo=null!==(h=e.stereo)&&void 0!==h&&h,m.disableRed=null!==(p=e.disableRed)&&void 0!==p&&p,m}};const on={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return""!==e.candidateInit&&t.uint32(10).string(e.candidateInit),0!==e.target&&t.uint32(16).int32(e.target),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={candidateInit:"",target:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.candidateInit=i.string();break;case 2:r.target=i.int32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({candidateInit:jn(e.candidateInit)?String(e.candidateInit):"",target:jn(e.target)?Yi(e.target):0}),toJSON(e){const t={};return void 0!==e.candidateInit&&(t.candidateInit=e.candidateInit),void 0!==e.target&&(t.target=Xi(e.target)),t},fromPartial(e){var t,i;const n={candidateInit:"",target:0};return n.candidateInit=null!==(t=e.candidateInit)&&void 0!==t?t:"",n.target=null!==(i=e.target)&&void 0!==i?i:0,n}};const cn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return""!==e.sid&&t.uint32(10).string(e.sid),!0===e.muted&&t.uint32(16).bool(e.muted),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={sid:"",muted:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.sid=i.string();break;case 2:r.muted=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({sid:jn(e.sid)?String(e.sid):"",muted:!!jn(e.muted)&&Boolean(e.muted)}),toJSON(e){const t={};return void 0!==e.sid&&(t.sid=e.sid),void 0!==e.muted&&(t.muted=e.muted),t},fromPartial(e){var t,i;const n={sid:"",muted:!1};return n.sid=null!==(t=e.sid)&&void 0!==t?t:"",n.muted=null!==(i=e.muted)&&void 0!==i&&i,n}};const dn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();void 0!==e.room&&vt.encode(e.room,t.uint32(10).fork()).ldelim(),void 0!==e.participant&&bt.encode(e.participant,t.uint32(18).fork()).ldelim();for(const i of e.otherParticipants)bt.encode(i,t.uint32(26).fork()).ldelim();""!==e.serverVersion&&t.uint32(34).string(e.serverVersion);for(const i of e.iceServers)bn.encode(i,t.uint32(42).fork()).ldelim();return!0===e.subscriberPrimary&&t.uint32(48).bool(e.subscriberPrimary),""!==e.alternativeUrl&&t.uint32(58).string(e.alternativeUrl),void 0!==e.clientConfiguration&&Dt.encode(e.clientConfiguration,t.uint32(66).fork()).ldelim(),""!==e.serverRegion&&t.uint32(74).string(e.serverRegion),0!==e.pingTimeout&&t.uint32(80).int32(e.pingTimeout),0!==e.pingInterval&&t.uint32(88).int32(e.pingInterval),void 0!==e.serverInfo&&Ot.encode(e.serverInfo,t.uint32(98).fork()).ldelim(),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={room:void 0,participant:void 0,otherParticipants:[],serverVersion:"",iceServers:[],subscriberPrimary:!1,alternativeUrl:"",clientConfiguration:void 0,serverRegion:"",pingTimeout:0,pingInterval:0,serverInfo:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.room=vt.decode(i,i.uint32());break;case 2:r.participant=bt.decode(i,i.uint32());break;case 3:r.otherParticipants.push(bt.decode(i,i.uint32()));break;case 4:r.serverVersion=i.string();break;case 5:r.iceServers.push(bn.decode(i,i.uint32()));break;case 6:r.subscriberPrimary=i.bool();break;case 7:r.alternativeUrl=i.string();break;case 8:r.clientConfiguration=Dt.decode(i,i.uint32());break;case 9:r.serverRegion=i.string();break;case 10:r.pingTimeout=i.int32();break;case 11:r.pingInterval=i.int32();break;case 12:r.serverInfo=Ot.decode(i,i.uint32());break;default:i.skipType(7&e)}}return r},fromJSON:e=>({room:jn(e.room)?vt.fromJSON(e.room):void 0,participant:jn(e.participant)?bt.fromJSON(e.participant):void 0,otherParticipants:Array.isArray(null==e?void 0:e.otherParticipants)?e.otherParticipants.map((e=>bt.fromJSON(e))):[],serverVersion:jn(e.serverVersion)?String(e.serverVersion):"",iceServers:Array.isArray(null==e?void 0:e.iceServers)?e.iceServers.map((e=>bn.fromJSON(e))):[],subscriberPrimary:!!jn(e.subscriberPrimary)&&Boolean(e.subscriberPrimary),alternativeUrl:jn(e.alternativeUrl)?String(e.alternativeUrl):"",clientConfiguration:jn(e.clientConfiguration)?Dt.fromJSON(e.clientConfiguration):void 0,serverRegion:jn(e.serverRegion)?String(e.serverRegion):"",pingTimeout:jn(e.pingTimeout)?Number(e.pingTimeout):0,pingInterval:jn(e.pingInterval)?Number(e.pingInterval):0,serverInfo:jn(e.serverInfo)?Ot.fromJSON(e.serverInfo):void 0}),toJSON(e){const t={};return void 0!==e.room&&(t.room=e.room?vt.toJSON(e.room):void 0),void 0!==e.participant&&(t.participant=e.participant?bt.toJSON(e.participant):void 0),e.otherParticipants?t.otherParticipants=e.otherParticipants.map((e=>e?bt.toJSON(e):void 0)):t.otherParticipants=[],void 0!==e.serverVersion&&(t.serverVersion=e.serverVersion),e.iceServers?t.iceServers=e.iceServers.map((e=>e?bn.toJSON(e):void 0)):t.iceServers=[],void 0!==e.subscriberPrimary&&(t.subscriberPrimary=e.subscriberPrimary),void 0!==e.alternativeUrl&&(t.alternativeUrl=e.alternativeUrl),void 0!==e.clientConfiguration&&(t.clientConfiguration=e.clientConfiguration?Dt.toJSON(e.clientConfiguration):void 0),void 0!==e.serverRegion&&(t.serverRegion=e.serverRegion),void 0!==e.pingTimeout&&(t.pingTimeout=Math.round(e.pingTimeout)),void 0!==e.pingInterval&&(t.pingInterval=Math.round(e.pingInterval)),void 0!==e.serverInfo&&(t.serverInfo=e.serverInfo?Ot.toJSON(e.serverInfo):void 0),t},fromPartial(e){var t,i,n,r,s,a,o,c;const d={room:void 0,participant:void 0,otherParticipants:[],serverVersion:"",iceServers:[],subscriberPrimary:!1,alternativeUrl:"",clientConfiguration:void 0,serverRegion:"",pingTimeout:0,pingInterval:0,serverInfo:void 0};return d.room=void 0!==e.room&&null!==e.room?vt.fromPartial(e.room):void 0,d.participant=void 0!==e.participant&&null!==e.participant?bt.fromPartial(e.participant):void 0,d.otherParticipants=(null===(t=e.otherParticipants)||void 0===t?void 0:t.map((e=>bt.fromPartial(e))))||[],d.serverVersion=null!==(i=e.serverVersion)&&void 0!==i?i:"",d.iceServers=(null===(n=e.iceServers)||void 0===n?void 0:n.map((e=>bn.fromPartial(e))))||[],d.subscriberPrimary=null!==(r=e.subscriberPrimary)&&void 0!==r&&r,d.alternativeUrl=null!==(s=e.alternativeUrl)&&void 0!==s?s:"",d.clientConfiguration=void 0!==e.clientConfiguration&&null!==e.clientConfiguration?Dt.fromPartial(e.clientConfiguration):void 0,d.serverRegion=null!==(a=e.serverRegion)&&void 0!==a?a:"",d.pingTimeout=null!==(o=e.pingTimeout)&&void 0!==o?o:0,d.pingInterval=null!==(c=e.pingInterval)&&void 0!==c?c:0,d.serverInfo=void 0!==e.serverInfo&&null!==e.serverInfo?Ot.fromPartial(e.serverInfo):void 0,d}};const un={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return""!==e.cid&&t.uint32(10).string(e.cid),void 0!==e.track&&yt.encode(e.track,t.uint32(18).fork()).ldelim(),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={cid:"",track:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.cid=i.string();break;case 2:r.track=yt.decode(i,i.uint32());break;default:i.skipType(7&e)}}return r},fromJSON:e=>({cid:jn(e.cid)?String(e.cid):"",track:jn(e.track)?yt.fromJSON(e.track):void 0}),toJSON(e){const t={};return void 0!==e.cid&&(t.cid=e.cid),void 0!==e.track&&(t.track=e.track?yt.toJSON(e.track):void 0),t},fromPartial(e){var t;const i={cid:"",track:void 0};return i.cid=null!==(t=e.cid)&&void 0!==t?t:"",i.track=void 0!==e.track&&null!==e.track?yt.fromPartial(e.track):void 0,i}};const ln={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return""!==e.trackSid&&t.uint32(10).string(e.trackSid),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={trackSid:""};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.trackSid=i.string();else i.skipType(7&e)}return r},fromJSON:e=>({trackSid:jn(e.trackSid)?String(e.trackSid):""}),toJSON(e){const t={};return void 0!==e.trackSid&&(t.trackSid=e.trackSid),t},fromPartial(e){var t;const i={trackSid:""};return i.trackSid=null!==(t=e.trackSid)&&void 0!==t?t:"",i}};const hn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return""!==e.type&&t.uint32(10).string(e.type),""!==e.sdp&&t.uint32(18).string(e.sdp),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={type:"",sdp:""};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.type=i.string();break;case 2:r.sdp=i.string();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({type:jn(e.type)?String(e.type):"",sdp:jn(e.sdp)?String(e.sdp):""}),toJSON(e){const t={};return void 0!==e.type&&(t.type=e.type),void 0!==e.sdp&&(t.sdp=e.sdp),t},fromPartial(e){var t,i;const n={type:"",sdp:""};return n.type=null!==(t=e.type)&&void 0!==t?t:"",n.sdp=null!==(i=e.sdp)&&void 0!==i?i:"",n}};const pn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();for(const i of e.participants)bt.encode(i,t.uint32(10).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={participants:[]};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.participants.push(bt.decode(i,i.uint32()));else i.skipType(7&e)}return r},fromJSON:e=>({participants:Array.isArray(null==e?void 0:e.participants)?e.participants.map((e=>bt.fromJSON(e))):[]}),toJSON(e){const t={};return e.participants?t.participants=e.participants.map((e=>e?bt.toJSON(e):void 0)):t.participants=[],t},fromPartial(e){var t;const i={participants:[]};return i.participants=(null===(t=e.participants)||void 0===t?void 0:t.map((e=>bt.fromPartial(e))))||[],i}};const mn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();for(const i of e.trackSids)t.uint32(10).string(i);!0===e.subscribe&&t.uint32(16).bool(e.subscribe);for(const i of e.participantTracks)Rt.encode(i,t.uint32(26).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={trackSids:[],subscribe:!1,participantTracks:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.trackSids.push(i.string());break;case 2:r.subscribe=i.bool();break;case 3:r.participantTracks.push(Rt.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({trackSids:Array.isArray(null==e?void 0:e.trackSids)?e.trackSids.map((e=>String(e))):[],subscribe:!!jn(e.subscribe)&&Boolean(e.subscribe),participantTracks:Array.isArray(null==e?void 0:e.participantTracks)?e.participantTracks.map((e=>Rt.fromJSON(e))):[]}),toJSON(e){const t={};return e.trackSids?t.trackSids=e.trackSids.map((e=>e)):t.trackSids=[],void 0!==e.subscribe&&(t.subscribe=e.subscribe),e.participantTracks?t.participantTracks=e.participantTracks.map((e=>e?Rt.toJSON(e):void 0)):t.participantTracks=[],t},fromPartial(e){var t,i,n;const r={trackSids:[],subscribe:!1,participantTracks:[]};return r.trackSids=(null===(t=e.trackSids)||void 0===t?void 0:t.map((e=>e)))||[],r.subscribe=null!==(i=e.subscribe)&&void 0!==i&&i,r.participantTracks=(null===(n=e.participantTracks)||void 0===n?void 0:n.map((e=>Rt.fromPartial(e))))||[],r}};const vn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();for(const i of e.trackSids)t.uint32(10).string(i);return!0===e.disabled&&t.uint32(24).bool(e.disabled),0!==e.quality&&t.uint32(32).int32(e.quality),0!==e.width&&t.uint32(40).uint32(e.width),0!==e.height&&t.uint32(48).uint32(e.height),0!==e.fps&&t.uint32(56).uint32(e.fps),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={trackSids:[],disabled:!1,quality:0,width:0,height:0,fps:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.trackSids.push(i.string());break;case 3:r.disabled=i.bool();break;case 4:r.quality=i.int32();break;case 5:r.width=i.uint32();break;case 6:r.height=i.uint32();break;case 7:r.fps=i.uint32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({trackSids:Array.isArray(null==e?void 0:e.trackSids)?e.trackSids.map((e=>String(e))):[],disabled:!!jn(e.disabled)&&Boolean(e.disabled),quality:jn(e.quality)?st(e.quality):0,width:jn(e.width)?Number(e.width):0,height:jn(e.height)?Number(e.height):0,fps:jn(e.fps)?Number(e.fps):0}),toJSON(e){const t={};return e.trackSids?t.trackSids=e.trackSids.map((e=>e)):t.trackSids=[],void 0!==e.disabled&&(t.disabled=e.disabled),void 0!==e.quality&&(t.quality=at(e.quality)),void 0!==e.width&&(t.width=Math.round(e.width)),void 0!==e.height&&(t.height=Math.round(e.height)),void 0!==e.fps&&(t.fps=Math.round(e.fps)),t},fromPartial(e){var t,i,n,r,s,a;const o={trackSids:[],disabled:!1,quality:0,width:0,height:0,fps:0};return o.trackSids=(null===(t=e.trackSids)||void 0===t?void 0:t.map((e=>e)))||[],o.disabled=null!==(i=e.disabled)&&void 0!==i&&i,o.quality=null!==(n=e.quality)&&void 0!==n?n:0,o.width=null!==(r=e.width)&&void 0!==r?r:0,o.height=null!==(s=e.height)&&void 0!==s?s:0,o.fps=null!==(a=e.fps)&&void 0!==a?a:0,o}};const fn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return!0===e.canReconnect&&t.uint32(8).bool(e.canReconnect),0!==e.reason&&t.uint32(16).int32(e.reason),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={canReconnect:!1,reason:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.canReconnect=i.bool();break;case 2:r.reason=i.int32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({canReconnect:!!jn(e.canReconnect)&&Boolean(e.canReconnect),reason:jn(e.reason)?ut(e.reason):0}),toJSON(t){const i={};return void 0!==t.canReconnect&&(i.canReconnect=t.canReconnect),void 0!==t.reason&&(i.reason=function(t){switch(t){case e.DisconnectReason.UNKNOWN_REASON:return"UNKNOWN_REASON";case e.DisconnectReason.CLIENT_INITIATED:return"CLIENT_INITIATED";case e.DisconnectReason.DUPLICATE_IDENTITY:return"DUPLICATE_IDENTITY";case e.DisconnectReason.SERVER_SHUTDOWN:return"SERVER_SHUTDOWN";case e.DisconnectReason.PARTICIPANT_REMOVED:return"PARTICIPANT_REMOVED";case e.DisconnectReason.ROOM_DELETED:return"ROOM_DELETED";case e.DisconnectReason.STATE_MISMATCH:return"STATE_MISMATCH";case e.DisconnectReason.JOIN_FAILURE:return"JOIN_FAILURE";case e.DisconnectReason.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(t.reason)),i},fromPartial(e){var t,i;const n={canReconnect:!1,reason:0};return n.canReconnect=null!==(t=e.canReconnect)&&void 0!==t&&t,n.reason=null!==(i=e.reason)&&void 0!==i?i:0,n}};const gn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();""!==e.trackSid&&t.uint32(10).string(e.trackSid);for(const i of e.layers)St.encode(i,t.uint32(18).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={trackSid:"",layers:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.trackSid=i.string();break;case 2:r.layers.push(St.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({trackSid:jn(e.trackSid)?String(e.trackSid):"",layers:Array.isArray(null==e?void 0:e.layers)?e.layers.map((e=>St.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.trackSid&&(t.trackSid=e.trackSid),e.layers?t.layers=e.layers.map((e=>e?St.toJSON(e):void 0)):t.layers=[],t},fromPartial(e){var t,i;const n={trackSid:"",layers:[]};return n.trackSid=null!==(t=e.trackSid)&&void 0!==t?t:"",n.layers=(null===(i=e.layers)||void 0===i?void 0:i.map((e=>St.fromPartial(e))))||[],n}};const bn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();for(const i of e.urls)t.uint32(10).string(i);return""!==e.username&&t.uint32(18).string(e.username),""!==e.credential&&t.uint32(26).string(e.credential),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={urls:[],username:"",credential:""};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.urls.push(i.string());break;case 2:r.username=i.string();break;case 3:r.credential=i.string();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({urls:Array.isArray(null==e?void 0:e.urls)?e.urls.map((e=>String(e))):[],username:jn(e.username)?String(e.username):"",credential:jn(e.credential)?String(e.credential):""}),toJSON(e){const t={};return e.urls?t.urls=e.urls.map((e=>e)):t.urls=[],void 0!==e.username&&(t.username=e.username),void 0!==e.credential&&(t.credential=e.credential),t},fromPartial(e){var t,i,n;const r={urls:[],username:"",credential:""};return r.urls=(null===(t=e.urls)||void 0===t?void 0:t.map((e=>e)))||[],r.username=null!==(i=e.username)&&void 0!==i?i:"",r.credential=null!==(n=e.credential)&&void 0!==n?n:"",r}};const kn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();for(const i of e.speakers)Tt.encode(i,t.uint32(10).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={speakers:[]};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.speakers.push(Tt.decode(i,i.uint32()));else i.skipType(7&e)}return r},fromJSON:e=>({speakers:Array.isArray(null==e?void 0:e.speakers)?e.speakers.map((e=>Tt.fromJSON(e))):[]}),toJSON(e){const t={};return e.speakers?t.speakers=e.speakers.map((e=>e?Tt.toJSON(e):void 0)):t.speakers=[],t},fromPartial(e){var t;const i={speakers:[]};return i.speakers=(null===(t=e.speakers)||void 0===t?void 0:t.map((e=>Tt.fromPartial(e))))||[],i}};const yn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return void 0!==e.room&&vt.encode(e.room,t.uint32(10).fork()).ldelim(),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={room:void 0};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.room=vt.decode(i,i.uint32());else i.skipType(7&e)}return r},fromJSON:e=>({room:jn(e.room)?vt.fromJSON(e.room):void 0}),toJSON(e){const t={};return void 0!==e.room&&(t.room=e.room?vt.toJSON(e.room):void 0),t},fromPartial(e){const t={room:void 0};return t.room=void 0!==e.room&&null!==e.room?vt.fromPartial(e.room):void 0,t}};const Sn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return""!==e.participantSid&&t.uint32(10).string(e.participantSid),0!==e.quality&&t.uint32(16).int32(e.quality),0!==e.score&&t.uint32(29).float(e.score),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={participantSid:"",quality:0,score:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.participantSid=i.string();break;case 2:r.quality=i.int32();break;case 3:r.score=i.float();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({participantSid:jn(e.participantSid)?String(e.participantSid):"",quality:jn(e.quality)?ot(e.quality):0,score:jn(e.score)?Number(e.score):0}),toJSON(e){const t={};return void 0!==e.participantSid&&(t.participantSid=e.participantSid),void 0!==e.quality&&(t.quality=function(e){switch(e){case Ge.POOR:return"POOR";case Ge.GOOD:return"GOOD";case Ge.EXCELLENT:return"EXCELLENT";case Ge.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.quality)),void 0!==e.score&&(t.score=e.score),t},fromPartial(e){var t,i,n;const r={participantSid:"",quality:0,score:0};return r.participantSid=null!==(t=e.participantSid)&&void 0!==t?t:"",r.quality=null!==(i=e.quality)&&void 0!==i?i:0,r.score=null!==(n=e.score)&&void 0!==n?n:0,r}};const wn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();for(const i of e.updates)Sn.encode(i,t.uint32(10).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={updates:[]};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.updates.push(Sn.decode(i,i.uint32()));else i.skipType(7&e)}return r},fromJSON:e=>({updates:Array.isArray(null==e?void 0:e.updates)?e.updates.map((e=>Sn.fromJSON(e))):[]}),toJSON(e){const t={};return e.updates?t.updates=e.updates.map((e=>e?Sn.toJSON(e):void 0)):t.updates=[],t},fromPartial(e){var t;const i={updates:[]};return i.updates=(null===(t=e.updates)||void 0===t?void 0:t.map((e=>Sn.fromPartial(e))))||[],i}};const Cn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return""!==e.participantSid&&t.uint32(10).string(e.participantSid),""!==e.trackSid&&t.uint32(18).string(e.trackSid),0!==e.state&&t.uint32(24).int32(e.state),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={participantSid:"",trackSid:"",state:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.participantSid=i.string();break;case 2:r.trackSid=i.string();break;case 3:r.state=i.int32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({participantSid:jn(e.participantSid)?String(e.participantSid):"",trackSid:jn(e.trackSid)?String(e.trackSid):"",state:jn(e.state)?en(e.state):0}),toJSON(e){const t={};return void 0!==e.participantSid&&(t.participantSid=e.participantSid),void 0!==e.trackSid&&(t.trackSid=e.trackSid),void 0!==e.state&&(t.state=function(e){switch(e){case Hi.ACTIVE:return"ACTIVE";case Hi.PAUSED:return"PAUSED";case Hi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.state)),t},fromPartial(e){var t,i,n;const r={participantSid:"",trackSid:"",state:0};return r.participantSid=null!==(t=e.participantSid)&&void 0!==t?t:"",r.trackSid=null!==(i=e.trackSid)&&void 0!==i?i:"",r.state=null!==(n=e.state)&&void 0!==n?n:0,r}};const Tn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();for(const i of e.streamStates)Cn.encode(i,t.uint32(10).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={streamStates:[]};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.streamStates.push(Cn.decode(i,i.uint32()));else i.skipType(7&e)}return r},fromJSON:e=>({streamStates:Array.isArray(null==e?void 0:e.streamStates)?e.streamStates.map((e=>Cn.fromJSON(e))):[]}),toJSON(e){const t={};return e.streamStates?t.streamStates=e.streamStates.map((e=>e?Cn.toJSON(e):void 0)):t.streamStates=[],t},fromPartial(e){var t;const i={streamStates:[]};return i.streamStates=(null===(t=e.streamStates)||void 0===t?void 0:t.map((e=>Cn.fromPartial(e))))||[],i}};const En={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return 0!==e.quality&&t.uint32(8).int32(e.quality),!0===e.enabled&&t.uint32(16).bool(e.enabled),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={quality:0,enabled:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.quality=i.int32();break;case 2:r.enabled=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({quality:jn(e.quality)?st(e.quality):0,enabled:!!jn(e.enabled)&&Boolean(e.enabled)}),toJSON(e){const t={};return void 0!==e.quality&&(t.quality=at(e.quality)),void 0!==e.enabled&&(t.enabled=e.enabled),t},fromPartial(e){var t,i;const n={quality:0,enabled:!1};return n.quality=null!==(t=e.quality)&&void 0!==t?t:0,n.enabled=null!==(i=e.enabled)&&void 0!==i&&i,n}};const Pn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();""!==e.codec&&t.uint32(10).string(e.codec);for(const i of e.qualities)En.encode(i,t.uint32(18).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={codec:"",qualities:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.codec=i.string();break;case 2:r.qualities.push(En.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({codec:jn(e.codec)?String(e.codec):"",qualities:Array.isArray(null==e?void 0:e.qualities)?e.qualities.map((e=>En.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.codec&&(t.codec=e.codec),e.qualities?t.qualities=e.qualities.map((e=>e?En.toJSON(e):void 0)):t.qualities=[],t},fromPartial(e){var t,i;const n={codec:"",qualities:[]};return n.codec=null!==(t=e.codec)&&void 0!==t?t:"",n.qualities=(null===(i=e.qualities)||void 0===i?void 0:i.map((e=>En.fromPartial(e))))||[],n}};const Rn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();""!==e.trackSid&&t.uint32(10).string(e.trackSid);for(const i of e.subscribedQualities)En.encode(i,t.uint32(18).fork()).ldelim();for(const i of e.subscribedCodecs)Pn.encode(i,t.uint32(26).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={trackSid:"",subscribedQualities:[],subscribedCodecs:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.trackSid=i.string();break;case 2:r.subscribedQualities.push(En.decode(i,i.uint32()));break;case 3:r.subscribedCodecs.push(Pn.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({trackSid:jn(e.trackSid)?String(e.trackSid):"",subscribedQualities:Array.isArray(null==e?void 0:e.subscribedQualities)?e.subscribedQualities.map((e=>En.fromJSON(e))):[],subscribedCodecs:Array.isArray(null==e?void 0:e.subscribedCodecs)?e.subscribedCodecs.map((e=>Pn.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.trackSid&&(t.trackSid=e.trackSid),e.subscribedQualities?t.subscribedQualities=e.subscribedQualities.map((e=>e?En.toJSON(e):void 0)):t.subscribedQualities=[],e.subscribedCodecs?t.subscribedCodecs=e.subscribedCodecs.map((e=>e?Pn.toJSON(e):void 0)):t.subscribedCodecs=[],t},fromPartial(e){var t,i,n;const r={trackSid:"",subscribedQualities:[],subscribedCodecs:[]};return r.trackSid=null!==(t=e.trackSid)&&void 0!==t?t:"",r.subscribedQualities=(null===(i=e.subscribedQualities)||void 0===i?void 0:i.map((e=>En.fromPartial(e))))||[],r.subscribedCodecs=(null===(n=e.subscribedCodecs)||void 0===n?void 0:n.map((e=>Pn.fromPartial(e))))||[],r}};const On={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();""!==e.participantSid&&t.uint32(10).string(e.participantSid),!0===e.allTracks&&t.uint32(16).bool(e.allTracks);for(const i of e.trackSids)t.uint32(26).string(i);return""!==e.participantIdentity&&t.uint32(34).string(e.participantIdentity),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={participantSid:"",allTracks:!1,trackSids:[],participantIdentity:""};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.participantSid=i.string();break;case 2:r.allTracks=i.bool();break;case 3:r.trackSids.push(i.string());break;case 4:r.participantIdentity=i.string();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({participantSid:jn(e.participantSid)?String(e.participantSid):"",allTracks:!!jn(e.allTracks)&&Boolean(e.allTracks),trackSids:Array.isArray(null==e?void 0:e.trackSids)?e.trackSids.map((e=>String(e))):[],participantIdentity:jn(e.participantIdentity)?String(e.participantIdentity):""}),toJSON(e){const t={};return void 0!==e.participantSid&&(t.participantSid=e.participantSid),void 0!==e.allTracks&&(t.allTracks=e.allTracks),e.trackSids?t.trackSids=e.trackSids.map((e=>e)):t.trackSids=[],void 0!==e.participantIdentity&&(t.participantIdentity=e.participantIdentity),t},fromPartial(e){var t,i,n,r;const s={participantSid:"",allTracks:!1,trackSids:[],participantIdentity:""};return s.participantSid=null!==(t=e.participantSid)&&void 0!==t?t:"",s.allTracks=null!==(i=e.allTracks)&&void 0!==i&&i,s.trackSids=(null===(n=e.trackSids)||void 0===n?void 0:n.map((e=>e)))||[],s.participantIdentity=null!==(r=e.participantIdentity)&&void 0!==r?r:"",s}};const Nn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();!0===e.allParticipants&&t.uint32(8).bool(e.allParticipants);for(const i of e.trackPermissions)On.encode(i,t.uint32(18).fork()).ldelim();return t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={allParticipants:!1,trackPermissions:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.allParticipants=i.bool();break;case 2:r.trackPermissions.push(On.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({allParticipants:!!jn(e.allParticipants)&&Boolean(e.allParticipants),trackPermissions:Array.isArray(null==e?void 0:e.trackPermissions)?e.trackPermissions.map((e=>On.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.allParticipants&&(t.allParticipants=e.allParticipants),e.trackPermissions?t.trackPermissions=e.trackPermissions.map((e=>e?On.toJSON(e):void 0)):t.trackPermissions=[],t},fromPartial(e){var t,i;const n={allParticipants:!1,trackPermissions:[]};return n.allParticipants=null!==(t=e.allParticipants)&&void 0!==t&&t,n.trackPermissions=(null===(i=e.trackPermissions)||void 0===i?void 0:i.map((e=>On.fromPartial(e))))||[],n}};const Dn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return""!==e.participantSid&&t.uint32(10).string(e.participantSid),""!==e.trackSid&&t.uint32(18).string(e.trackSid),!0===e.allowed&&t.uint32(24).bool(e.allowed),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={participantSid:"",trackSid:"",allowed:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.participantSid=i.string();break;case 2:r.trackSid=i.string();break;case 3:r.allowed=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({participantSid:jn(e.participantSid)?String(e.participantSid):"",trackSid:jn(e.trackSid)?String(e.trackSid):"",allowed:!!jn(e.allowed)&&Boolean(e.allowed)}),toJSON(e){const t={};return void 0!==e.participantSid&&(t.participantSid=e.participantSid),void 0!==e.trackSid&&(t.trackSid=e.trackSid),void 0!==e.allowed&&(t.allowed=e.allowed),t},fromPartial(e){var t,i,n;const r={participantSid:"",trackSid:"",allowed:!1};return r.participantSid=null!==(t=e.participantSid)&&void 0!==t?t:"",r.trackSid=null!==(i=e.trackSid)&&void 0!==i?i:"",r.allowed=null!==(n=e.allowed)&&void 0!==n&&n,r}};const In={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();void 0!==e.answer&&hn.encode(e.answer,t.uint32(10).fork()).ldelim(),void 0!==e.subscription&&mn.encode(e.subscription,t.uint32(18).fork()).ldelim();for(const i of e.publishTracks)un.encode(i,t.uint32(26).fork()).ldelim();for(const i of e.dataChannels)An.encode(i,t.uint32(34).fork()).ldelim();return void 0!==e.offer&&hn.encode(e.offer,t.uint32(42).fork()).ldelim(),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={answer:void 0,subscription:void 0,publishTracks:[],dataChannels:[],offer:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.answer=hn.decode(i,i.uint32());break;case 2:r.subscription=mn.decode(i,i.uint32());break;case 3:r.publishTracks.push(un.decode(i,i.uint32()));break;case 4:r.dataChannels.push(An.decode(i,i.uint32()));break;case 5:r.offer=hn.decode(i,i.uint32());break;default:i.skipType(7&e)}}return r},fromJSON:e=>({answer:jn(e.answer)?hn.fromJSON(e.answer):void 0,subscription:jn(e.subscription)?mn.fromJSON(e.subscription):void 0,publishTracks:Array.isArray(null==e?void 0:e.publishTracks)?e.publishTracks.map((e=>un.fromJSON(e))):[],dataChannels:Array.isArray(null==e?void 0:e.dataChannels)?e.dataChannels.map((e=>An.fromJSON(e))):[],offer:jn(e.offer)?hn.fromJSON(e.offer):void 0}),toJSON(e){const t={};return void 0!==e.answer&&(t.answer=e.answer?hn.toJSON(e.answer):void 0),void 0!==e.subscription&&(t.subscription=e.subscription?mn.toJSON(e.subscription):void 0),e.publishTracks?t.publishTracks=e.publishTracks.map((e=>e?un.toJSON(e):void 0)):t.publishTracks=[],e.dataChannels?t.dataChannels=e.dataChannels.map((e=>e?An.toJSON(e):void 0)):t.dataChannels=[],void 0!==e.offer&&(t.offer=e.offer?hn.toJSON(e.offer):void 0),t},fromPartial(e){var t,i;const n={answer:void 0,subscription:void 0,publishTracks:[],dataChannels:[],offer:void 0};return n.answer=void 0!==e.answer&&null!==e.answer?hn.fromPartial(e.answer):void 0,n.subscription=void 0!==e.subscription&&null!==e.subscription?mn.fromPartial(e.subscription):void 0,n.publishTracks=(null===(t=e.publishTracks)||void 0===t?void 0:t.map((e=>un.fromPartial(e))))||[],n.dataChannels=(null===(i=e.dataChannels)||void 0===i?void 0:i.map((e=>An.fromPartial(e))))||[],n.offer=void 0!==e.offer&&null!==e.offer?hn.fromPartial(e.offer):void 0,n}};const An={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();return""!==e.label&&t.uint32(10).string(e.label),0!==e.id&&t.uint32(16).uint32(e.id),0!==e.target&&t.uint32(24).int32(e.target),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={label:"",id:0,target:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.label=i.string();break;case 2:r.id=i.uint32();break;case 3:r.target=i.int32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({label:jn(e.label)?String(e.label):"",id:jn(e.id)?Number(e.id):0,target:jn(e.target)?Yi(e.target):0}),toJSON(e){const t={};return void 0!==e.label&&(t.label=e.label),void 0!==e.id&&(t.id=Math.round(e.id)),void 0!==e.target&&(t.target=Xi(e.target)),t},fromPartial(e){var t,i,n;const r={label:"",id:0,target:0};return r.label=null!==(t=e.label)&&void 0!==t?t:"",r.id=null!==(i=e.id)&&void 0!==i?i:0,r.target=null!==(n=e.target)&&void 0!==n?n:0,r}};const Un={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xe.Writer.create();var i,n,r,s,a;return"speakerUpdate"===(null===(i=e.scenario)||void 0===i?void 0:i.$case)&&t.uint32(8).int32(e.scenario.speakerUpdate),"nodeFailure"===(null===(n=e.scenario)||void 0===n?void 0:n.$case)&&t.uint32(16).bool(e.scenario.nodeFailure),"migration"===(null===(r=e.scenario)||void 0===r?void 0:r.$case)&&t.uint32(24).bool(e.scenario.migration),"serverLeave"===(null===(s=e.scenario)||void 0===s?void 0:s.$case)&&t.uint32(32).bool(e.scenario.serverLeave),"switchCandidateProtocol"===(null===(a=e.scenario)||void 0===a?void 0:a.$case)&&t.uint32(40).int32(e.scenario.switchCandidateProtocol),t},decode(e,t){const i=e instanceof Xe.Reader?e:new Xe.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={scenario:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.scenario={$case:"speakerUpdate",speakerUpdate:i.int32()};break;case 2:r.scenario={$case:"nodeFailure",nodeFailure:i.bool()};break;case 3:r.scenario={$case:"migration",migration:i.bool()};break;case 4:r.scenario={$case:"serverLeave",serverLeave:i.bool()};break;case 5:r.scenario={$case:"switchCandidateProtocol",switchCandidateProtocol:i.int32()};break;default:i.skipType(7&e)}}return r},fromJSON:e=>({scenario:jn(e.speakerUpdate)?{$case:"speakerUpdate",speakerUpdate:Number(e.speakerUpdate)}:jn(e.nodeFailure)?{$case:"nodeFailure",nodeFailure:Boolean(e.nodeFailure)}:jn(e.migration)?{$case:"migration",migration:Boolean(e.migration)}:jn(e.serverLeave)?{$case:"serverLeave",serverLeave:Boolean(e.serverLeave)}:jn(e.switchCandidateProtocol)?{$case:"switchCandidateProtocol",switchCandidateProtocol:tn(e.switchCandidateProtocol)}:void 0}),toJSON(e){var t,i,n,r,s,a,o,c,d,u,l;const h={};return"speakerUpdate"===(null===(t=e.scenario)||void 0===t?void 0:t.$case)&&(h.speakerUpdate=Math.round(null===(i=e.scenario)||void 0===i?void 0:i.speakerUpdate)),"nodeFailure"===(null===(n=e.scenario)||void 0===n?void 0:n.$case)&&(h.nodeFailure=null===(r=e.scenario)||void 0===r?void 0:r.nodeFailure),"migration"===(null===(s=e.scenario)||void 0===s?void 0:s.$case)&&(h.migration=null===(a=e.scenario)||void 0===a?void 0:a.migration),"serverLeave"===(null===(o=e.scenario)||void 0===o?void 0:o.$case)&&(h.serverLeave=null===(c=e.scenario)||void 0===c?void 0:c.serverLeave),"switchCandidateProtocol"===(null===(d=e.scenario)||void 0===d?void 0:d.$case)&&(h.switchCandidateProtocol=void 0!==(null===(u=e.scenario)||void 0===u?void 0:u.switchCandidateProtocol)?function(e){switch(e){case Zi.UDP:return"UDP";case Zi.TCP:return"TCP";case Zi.TLS:return"TLS";case Zi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(null===(l=e.scenario)||void 0===l?void 0:l.switchCandidateProtocol):void 0),h},fromPartial(e){var t,i,n,r,s,a,o,c,d,u,l,h,p,m,v;const f={scenario:void 0};return"speakerUpdate"===(null===(t=e.scenario)||void 0===t?void 0:t.$case)&&void 0!==(null===(i=e.scenario)||void 0===i?void 0:i.speakerUpdate)&&null!==(null===(n=e.scenario)||void 0===n?void 0:n.speakerUpdate)&&(f.scenario={$case:"speakerUpdate",speakerUpdate:e.scenario.speakerUpdate}),"nodeFailure"===(null===(r=e.scenario)||void 0===r?void 0:r.$case)&&void 0!==(null===(s=e.scenario)||void 0===s?void 0:s.nodeFailure)&&null!==(null===(a=e.scenario)||void 0===a?void 0:a.nodeFailure)&&(f.scenario={$case:"nodeFailure",nodeFailure:e.scenario.nodeFailure}),"migration"===(null===(o=e.scenario)||void 0===o?void 0:o.$case)&&void 0!==(null===(c=e.scenario)||void 0===c?void 0:c.migration)&&null!==(null===(d=e.scenario)||void 0===d?void 0:d.migration)&&(f.scenario={$case:"migration",migration:e.scenario.migration}),"serverLeave"===(null===(u=e.scenario)||void 0===u?void 0:u.$case)&&void 0!==(null===(l=e.scenario)||void 0===l?void 0:l.serverLeave)&&null!==(null===(h=e.scenario)||void 0===h?void 0:h.serverLeave)&&(f.scenario={$case:"serverLeave",serverLeave:e.scenario.serverLeave}),"switchCandidateProtocol"===(null===(p=e.scenario)||void 0===p?void 0:p.$case)&&void 0!==(null===(m=e.scenario)||void 0===m?void 0:m.switchCandidateProtocol)&&null!==(null===(v=e.scenario)||void 0===v?void 0:v.switchCandidateProtocol)&&(f.scenario={$case:"switchCandidateProtocol",switchCandidateProtocol:e.scenario.switchCandidateProtocol}),f}};var Ln,xn,Mn,_n,Jn,$n=(()=>{if(void 0!==$n)return $n;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw"Unable to locate global object"})();function Bn(e){if(e.gt(Number.MAX_SAFE_INTEGER))throw new $n.Error("Value is larger than Number.MAX_SAFE_INTEGER");return e.toNumber()}function jn(e){return null!=e}Xe.util.Long!==o&&(Xe.util.Long=o,Xe.configure());class Vn extends Error{constructor(e,t){super(t||"an error has occured"),this.code=e}}class Fn extends Vn{constructor(e,t,i){super(1,e),this.status=i,this.reason=t}}class qn extends Vn{constructor(e){super(20,null!=e?e:"track is invalid")}}class Wn extends Vn{constructor(e){super(10,null!=e?e:"unsupported server")}}class Gn extends Vn{constructor(e){super(12,null!=e?e:"unexpected connection state")}}class Qn extends Vn{constructor(e){super(13,null!=e?e:"unable to negotiate")}}e.MediaDeviceFailure=void 0,(Ln=e.MediaDeviceFailure||(e.MediaDeviceFailure={})).PermissionDenied="PermissionDenied",Ln.NotFound="NotFound",Ln.DeviceInUse="DeviceInUse",Ln.Other="Other",function(e){e.getFailure=function(t){if(t&&"name"in t)return"NotFoundError"===t.name||"DevicesNotFoundError"===t.name?e.NotFound:"NotAllowedError"===t.name||"PermissionDeniedError"===t.name?e.PermissionDenied:"NotReadableError"===t.name||"TrackStartError"===t.name?e.DeviceInUse:e.Other}}(e.MediaDeviceFailure||(e.MediaDeviceFailure={})),e.RoomEvent=void 0,(xn=e.RoomEvent||(e.RoomEvent={})).Connected="connected",xn.Reconnecting="reconnecting",xn.Reconnected="reconnected",xn.Disconnected="disconnected",xn.ConnectionStateChanged="connectionStateChanged",xn.StateChanged="connectionStateChanged",xn.MediaDevicesChanged="mediaDevicesChanged",xn.ParticipantConnected="participantConnected",xn.ParticipantDisconnected="participantDisconnected",xn.TrackPublished="trackPublished",xn.TrackSubscribed="trackSubscribed",xn.TrackSubscriptionFailed="trackSubscriptionFailed",xn.TrackUnpublished="trackUnpublished",xn.TrackUnsubscribed="trackUnsubscribed",xn.TrackMuted="trackMuted",xn.TrackUnmuted="trackUnmuted",xn.LocalTrackPublished="localTrackPublished",xn.LocalTrackUnpublished="localTrackUnpublished",xn.ActiveSpeakersChanged="activeSpeakersChanged",xn.ParticipantMetadataChanged="participantMetadataChanged",xn.RoomMetadataChanged="roomMetadataChanged",xn.DataReceived="dataReceived",xn.ConnectionQualityChanged="connectionQualityChanged",xn.TrackStreamStateChanged="trackStreamStateChanged",xn.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",xn.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",xn.AudioPlaybackStatusChanged="audioPlaybackChanged",xn.MediaDevicesError="mediaDevicesError",xn.ParticipantPermissionsChanged="participantPermissionsChanged",xn.SignalConnected="signalConnected",xn.RecordingStatusChanged="recordingStatusChanged",e.ParticipantEvent=void 0,(Mn=e.ParticipantEvent||(e.ParticipantEvent={})).TrackPublished="trackPublished",Mn.TrackSubscribed="trackSubscribed",Mn.TrackSubscriptionFailed="trackSubscriptionFailed",Mn.TrackUnpublished="trackUnpublished",Mn.TrackUnsubscribed="trackUnsubscribed",Mn.TrackMuted="trackMuted",Mn.TrackUnmuted="trackUnmuted",Mn.LocalTrackPublished="localTrackPublished",Mn.LocalTrackUnpublished="localTrackUnpublished",Mn.ParticipantMetadataChanged="participantMetadataChanged",Mn.DataReceived="dataReceived",Mn.IsSpeakingChanged="isSpeakingChanged",Mn.ConnectionQualityChanged="connectionQualityChanged",Mn.TrackStreamStateChanged="trackStreamStateChanged",Mn.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",Mn.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",Mn.MediaDevicesError="mediaDevicesError",Mn.ParticipantPermissionsChanged="participantPermissionsChanged",e.EngineEvent=void 0,(_n=e.EngineEvent||(e.EngineEvent={})).TransportsCreated="transportsCreated",_n.Connected="connected",_n.Disconnected="disconnected",_n.Resuming="resuming",_n.Resumed="resumed",_n.Restarting="restarting",_n.Restarted="restarted",_n.SignalResumed="signalResumed",_n.Closing="closing",_n.MediaTrackAdded="mediaTrackAdded",_n.ActiveSpeakersUpdate="activeSpeakersUpdate",_n.DataPacketReceived="dataPacketReceived",e.TrackEvent=void 0,(Jn=e.TrackEvent||(e.TrackEvent={})).Message="message",Jn.Muted="muted",Jn.Unmuted="unmuted",Jn.Restarted="restarted",Jn.Ended="ended",Jn.Subscribed="subscribed",Jn.Unsubscribed="unsubscribed",Jn.UpdateSettings="updateSettings",Jn.UpdateSubscription="updateSubscription",Jn.AudioPlaybackStarted="audioPlaybackStarted",Jn.AudioPlaybackFailed="audioPlaybackFailed",Jn.AudioSilenceDetected="audioSilenceDetected",Jn.VisibilityChanged="visibilityChanged",Jn.VideoDimensionsChanged="videoDimensionsChanged",Jn.ElementAttached="elementAttached",Jn.ElementDetached="elementDetached",Jn.UpstreamPaused="upstreamPaused",Jn.UpstreamResumed="upstreamResumed",Jn.SubscriptionPermissionChanged="subscriptionPermissionChanged",Jn.SubscriptionStatusChanged="subscriptionStatusChanged";const zn=2e3;function Hn(e,t){if(!t)return 0;let i,n;return"bytesReceived"in e?(i=e.bytesReceived,n=t.bytesReceived):"bytesSent"in e&&(i=e.bytesSent,n=t.bytesSent),void 0===i||void 0===n||void 0===e.timestamp||void 0===t.timestamp?0:8*(i-n)*1e3/(e.timestamp-t.timestamp)}var Zn={};!function(e,t){!function(i,n){var r="function",s="undefined",a="object",o="string",c="model",d="name",u="type",l="vendor",h="version",p="architecture",m="console",v="mobile",f="tablet",g="smarttv",b="wearable",k="embedded",y="Amazon",S="Apple",w="ASUS",C="BlackBerry",T="Firefox",E="Google",P="Huawei",R="LG",O="Microsoft",N="Motorola",D="Opera",I="Samsung",A="Sony",U="Xiaomi",L="Zebra",x="Facebook",M=function(e){for(var t={},i=0;i<e.length;i++)t[e[i].toUpperCase()]=e[i];return t},_=function(e,t){return typeof e===o&&-1!==J(t).indexOf(J(e))},J=function(e){return e.toLowerCase()},$=function(e,t){if(typeof e===o)return e=e.replace(/^\s\s*/,"").replace(/\s\s*$/,""),typeof t===s?e:e.substring(0,255)},B=function(e,t){for(var i,s,o,c,d,u,l=0;l<t.length&&!d;){var h=t[l],p=t[l+1];for(i=s=0;i<h.length&&!d;)if(d=h[i++].exec(e))for(o=0;o<p.length;o++)u=d[++s],typeof(c=p[o])===a&&c.length>0?2===c.length?typeof c[1]==r?this[c[0]]=c[1].call(this,u):this[c[0]]=c[1]:3===c.length?typeof c[1]!==r||c[1].exec&&c[1].test?this[c[0]]=u?u.replace(c[1],c[2]):n:this[c[0]]=u?c[1].call(this,u,c[2]):n:4===c.length&&(this[c[0]]=u?c[3].call(this,u.replace(c[1],c[2])):n):this[c]=u||n;l+=2}},j=function(e,t){for(var i in t)if(typeof t[i]===a&&t[i].length>0){for(var r=0;r<t[i].length;r++)if(_(t[i][r],e))return"?"===i?n:i}else if(_(t[i],e))return"?"===i?n:i;return e},V={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},F={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[h,[d,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[h,[d,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[d,h],[/opios[\/ ]+([\w\.]+)/i],[h,[d,"Opera Mini"]],[/\bopr\/([\w\.]+)/i],[h,[d,D]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale|qqbrowserlite|qq)\/([-\w\.]+)/i,/(weibo)__([\d\.]+)/i],[d,h],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[h,[d,"UCBrowser"]],[/\bqbcore\/([\w\.]+)/i],[h,[d,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[h,[d,"WeChat"]],[/konqueror\/([\w\.]+)/i],[h,[d,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[h,[d,"IE"]],[/yabrowser\/([\w\.]+)/i],[h,[d,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[d,/(.+)/,"$1 Secure Browser"],h],[/\bfocus\/([\w\.]+)/i],[h,[d,"Firefox Focus"]],[/\bopt\/([\w\.]+)/i],[h,[d,"Opera Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[h,[d,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[h,[d,"Dolphin"]],[/coast\/([\w\.]+)/i],[h,[d,"Opera Coast"]],[/miuibrowser\/([\w\.]+)/i],[h,[d,"MIUI Browser"]],[/fxios\/([-\w\.]+)/i],[h,[d,T]],[/\bqihu|(qi?ho?o?|360)browser/i],[[d,"360 Browser"]],[/(oculus|samsung|sailfish)browser\/([\w\.]+)/i],[[d,/(.+)/,"$1 Browser"],h],[/(comodo_dragon)\/([\w\.]+)/i],[[d,/_/g," "],h],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[d,h],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i],[d],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[d,x],h],[/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[d,h],[/\bgsa\/([\w\.]+) .*safari\//i],[h,[d,"GSA"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[h,[d,"Chrome Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[d,"Chrome WebView"],h],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[h,[d,"Android Browser"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[d,h],[/version\/([\w\.]+) .*mobile\/\w+ (safari)/i],[h,[d,"Mobile Safari"]],[/version\/([\w\.]+) .*(mobile ?safari|safari)/i],[h,d],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[d,[h,j,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[d,h],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[d,"Netscape"],h],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[h,[d,"Firefox Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[d,h]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[p,"amd64"]],[/(ia32(?=;))/i],[[p,J]],[/((?:i[346]|x)86)[;\)]/i],[[p,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[p,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[p,"armhf"]],[/windows (ce|mobile); ppc;/i],[[p,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[p,/ower/,"",J]],[/(sun4\w)[;\)]/i],[[p,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[p,J]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[pt]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[c,[l,I],[u,f]],[/\b((?:s[cgp]h|gt|sm)-\w+|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[c,[l,I],[u,v]],[/\((ip(?:hone|od)[\w ]*);/i],[c,[l,S],[u,v]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[c,[l,S],[u,f]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[c,[l,P],[u,f]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}-[atu]?[ln][01259x][012359][an]?)\b(?!.+d\/s)/i],[c,[l,P],[u,v]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[c,/_/g," "],[l,U],[u,v]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[c,/_/g," "],[l,U],[u,f]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[c,[l,"OPPO"],[u,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[c,[l,"Vivo"],[u,v]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[c,[l,"Realme"],[u,v]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[c,[l,N],[u,v]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[c,[l,N],[u,f]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[c,[l,R],[u,f]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[c,[l,R],[u,v]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[c,[l,"Lenovo"],[u,f]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[c,/_/g," "],[l,"Nokia"],[u,v]],[/(pixel c)\b/i],[c,[l,E],[u,f]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[c,[l,E],[u,v]],[/droid.+ ([c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[c,[l,A],[u,v]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[c,"Xperia Tablet"],[l,A],[u,f]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[c,[l,"OnePlus"],[u,v]],[/(alexa)webm/i,/(kf[a-z]{2}wi)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[c,[l,y],[u,f]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[c,/(.+)/g,"Fire Phone $1"],[l,y],[u,v]],[/(playbook);[-\w\),; ]+(rim)/i],[c,l,[u,f]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[c,[l,C],[u,v]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[c,[l,w],[u,f]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[c,[l,w],[u,v]],[/(nexus 9)/i],[c,[l,"HTC"],[u,f]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic|sony)[-_ ]?([-\w]*)/i],[l,[c,/_/g," "],[u,v]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[c,[l,"Acer"],[u,f]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[c,[l,"Meizu"],[u,v]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[c,[l,"Sharp"],[u,v]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[l,c,[u,v]],[/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[l,c,[u,f]],[/(surface duo)/i],[c,[l,O],[u,f]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[c,[l,"Fairphone"],[u,v]],[/(u304aa)/i],[c,[l,"AT&T"],[u,v]],[/\bsie-(\w*)/i],[c,[l,"Siemens"],[u,v]],[/\b(rct\w+) b/i],[c,[l,"RCA"],[u,f]],[/\b(venue[\d ]{2,7}) b/i],[c,[l,"Dell"],[u,f]],[/\b(q(?:mv|ta)\w+) b/i],[c,[l,"Verizon"],[u,f]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[c,[l,"Barnes & Noble"],[u,f]],[/\b(tm\d{3}\w+) b/i],[c,[l,"NuVision"],[u,f]],[/\b(k88) b/i],[c,[l,"ZTE"],[u,f]],[/\b(nx\d{3}j) b/i],[c,[l,"ZTE"],[u,v]],[/\b(gen\d{3}) b.+49h/i],[c,[l,"Swiss"],[u,v]],[/\b(zur\d{3}) b/i],[c,[l,"Swiss"],[u,f]],[/\b((zeki)?tb.*\b) b/i],[c,[l,"Zeki"],[u,f]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[l,"Dragon Touch"],c,[u,f]],[/\b(ns-?\w{0,9}) b/i],[c,[l,"Insignia"],[u,f]],[/\b((nxa|next)-?\w{0,9}) b/i],[c,[l,"NextBook"],[u,f]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[l,"Voice"],c,[u,v]],[/\b(lvtel\-)?(v1[12]) b/i],[[l,"LvTel"],c,[u,v]],[/\b(ph-1) /i],[c,[l,"Essential"],[u,v]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[c,[l,"Envizen"],[u,f]],[/\b(trio[-\w\. ]+) b/i],[c,[l,"MachSpeed"],[u,f]],[/\btu_(1491) b/i],[c,[l,"Rotor"],[u,f]],[/(shield[\w ]+) b/i],[c,[l,"Nvidia"],[u,f]],[/(sprint) (\w+)/i],[l,c,[u,v]],[/(kin\.[onetw]{3})/i],[[c,/\./g," "],[l,O],[u,v]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[c,[l,L],[u,f]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[c,[l,L],[u,v]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[l,c,[u,m]],[/droid.+; (shield) bui/i],[c,[l,"Nvidia"],[u,m]],[/(playstation [345portablevi]+)/i],[c,[l,A],[u,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[c,[l,O],[u,m]],[/smart-tv.+(samsung)/i],[l,[u,g]],[/hbbtv.+maple;(\d+)/i],[[c,/^/,"SmartTV"],[l,I],[u,g]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[l,R],[u,g]],[/(apple) ?tv/i],[l,[c,"Apple TV"],[u,g]],[/crkey/i],[[c,"Chromecast"],[l,E],[u,g]],[/droid.+aft(\w)( bui|\))/i],[c,[l,y],[u,g]],[/\(dtv[\);].+(aquos)/i],[c,[l,"Sharp"],[u,g]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w ]*; *(\w[^;]*);([^;]*)/i],[[l,$],[c,$],[u,g]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[u,g]],[/((pebble))app/i],[l,c,[u,b]],[/droid.+; (glass) \d/i],[c,[l,E],[u,b]],[/droid.+; (wt63?0{2,3})\)/i],[c,[l,L],[u,b]],[/(quest( 2)?)/i],[c,[l,x],[u,b]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[l,[u,k]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[c,[u,v]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[c,[u,f]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[u,f]],[/(phone|mobile(?:[;\/]| safari)|pda(?=.+windows ce))/i],[[u,v]],[/(android[-\w\. ]{0,9});.+buil/i],[c,[l,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[h,[d,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[h,[d,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i],[d,h],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[h,d]],os:[[/microsoft (windows) (vista|xp)/i],[d,h],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[d,[h,j,V]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[d,"Windows"],[h,j,V]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/cfnetwork\/.+darwin/i],[[h,/_/g,"."],[d,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[d,"Mac OS"],[h,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86)/i],[h,d],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[d,h],[/\(bb(10);/i],[h,[d,C]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[h,[d,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[h,[d,"Firefox OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[h,[d,"webOS"]],[/crkey\/([\d\.]+)/i],[h,[d,"Chromecast"]],[/(cros) [\w]+ ([\w\.]+\w)/i],[[d,"Chromium OS"],h],[/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[d,h],[/(sunos) ?([\w\.\d]*)/i],[[d,"Solaris"],h],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux)/i,/(unix) ?([\w\.]*)/i],[d,h]]},q=function(e,t){if(typeof e===a&&(t=e,e=n),!(this instanceof q))return new q(e,t).getResult();var r=e||(typeof i!==s&&i.navigator&&i.navigator.userAgent?i.navigator.userAgent:""),c=t?function(e,t){var i={};for(var n in e)t[n]&&t[n].length%2==0?i[n]=t[n].concat(e[n]):i[n]=e[n];return i}(F,t):F;return this.getBrowser=function(){var e={};return e.name=n,e.version=n,B.call(e,r,c.browser),e.major=function(e){return typeof e===o?e.replace(/[^\d\.]/g,"").split(".")[0]:n}(e.version),e},this.getCPU=function(){var e={};return e.architecture=n,B.call(e,r,c.cpu),e},this.getDevice=function(){var e={};return e.vendor=n,e.model=n,e.type=n,B.call(e,r,c.device),e},this.getEngine=function(){var e={};return e.name=n,e.version=n,B.call(e,r,c.engine),e},this.getOS=function(){var e={};return e.name=n,e.version=n,B.call(e,r,c.os),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return r},this.setUA=function(e){return r=typeof e===o&&e.length>255?$(e,255):e,this},this.setUA(r),this};q.VERSION="1.0.2",q.BROWSER=M([d,h,"major"]),q.CPU=M([p]),q.DEVICE=M([c,l,u,m,v,g,f,b,k]),q.ENGINE=q.OS=M([d,h]),e.exports&&(t=e.exports=q),t.UAParser=q;var W=typeof i!==s&&(i.jQuery||i.Zepto);if(W&&!W.ua){var G=new q;W.ua=G.getResult(),W.ua.get=function(){return G.getUA()},W.ua.set=function(e){G.setUA(e);var t=G.getResult();for(var i in t)W.ua[i]=t[i]}}}("object"==typeof window?window:i)}({get exports(){return Zn},set exports(e){Zn=e}},Zn);var Kn=Zn;const Yn="1.6.2";function Xn(e,t,i){const n=Ft({},e);return!0===n.audio&&(n.audio={}),!0===n.video&&(n.video={}),n.audio&&er(n.audio,t),n.video&&er(n.video,i),n}function er(e,t){return Object.keys(t).forEach((i=>{void 0===e[i]&&(e[i]=t[i])})),e}function tr(e){const t={};if(e.video)if("object"==typeof e.video){const i={},n=i,r=e.video;Object.keys(r).forEach((e=>{if("resolution"===e)er(n,r.resolution);else n[e]=r[e]})),t.video=i}else t.video=e.video;else t.video=!1;return e.audio?"object"==typeof e.audio?t.audio=e.audio:t.audio=!0:t.audio=!1,t}function ir(){const e=window.AudioContext||window.webkitAudioContext;if(e)return new e({latencyHint:"interactive"})}async function nr(e){return new Promise((t=>setTimeout(t,e)))}function rr(){return"addTransceiver"in RTCPeerConnection.prototype}function sr(){return"addTrack"in RTCPeerConnection.prototype}function ar(){const e=RTCRtpReceiver.getCapabilities("video");let t=!1,i=!1;if(e){for(const i of e.codecs)if("video/AV1"===i.mimeType){t=!0;break}for(const t of e.headerExtensions)if("https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension"===t.uri){i=!0;break}}return t&&i}function or(e){return!!document&&(e||(e=document.createElement("audio")),"setSinkId"in e)}const cr={Chrome:"100",Chromium:"100",Safari:"15",Firefox:"100",Edge:"100",Brave:"1.40"};function dr(e){if(!pr())return!1;if(!("setCodecPreferences"in e))return!1;const t=Kn();if(!t.browser.name||!t.browser.version)return!1;const i=cr[t.browser.name];return!!i&&function(e,t){const i=e.split("."),n=t.split("."),r=Math.min(e.length,t.length);for(let e=0;e<r;++e){const t=parseInt(i[e],10),r=parseInt(n[e],10);if(t>r)return 1;if(t<r)return-1}return i.length==n.length?0:i.length<n.length?-1:1}(t.browser.version,i)>=0}function ur(){return!!pr()&&-1!==navigator.userAgent.indexOf("Firefox")}function lr(){return!!pr()&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function hr(){return!!pr()&&/Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent)}function pr(){return"undefined"!=typeof document}function mr(e){for(const t of e)t.target.handleResize(t)}function vr(e){for(const t of e)t.target.handleVisibilityChanged(t)}let fr=null;const gr=()=>(fr||(fr=new ResizeObserver(mr)),fr);let br=null;const kr=()=>(br||(br=new IntersectionObserver(vr,{root:document,rootMargin:"0px"})),br);let yr,Sr;function wr(){return yr||(yr=Cr()),yr}function Cr(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r=document.createElement("canvas");r.width=e,r.height=t;const s=r.getContext("2d");null==s||s.fillRect(0,0,r.width,r.height),n&&s&&(s.beginPath(),s.arc(e/2,t/2,50,0,2*Math.PI,!0),s.closePath(),s.fillStyle="grey",s.fill());const a=r.captureStream(),[o]=a.getTracks();if(!o)throw Error("Could not get empty media stream video track");return o.enabled=i,o}function Tr(){if(!Sr){const e=new AudioContext,t=e.createOscillator(),i=e.createMediaStreamDestination();if(t.connect(i),t.start(),[Sr]=i.stream.getAudioTracks(),!Sr)throw Error("Could not get empty media stream audio track");Sr.enabled=!1}return Sr}class Er{constructor(e,t){this.onFinally=t,this.promise=new Promise((async(t,i)=>{this.resolve=t,this.reject=i,e&&await e(t,i)})).finally((()=>{var e;return null===(e=this.onFinally)||void 0===e?void 0:e.call(this)}))}}class Pr{constructor(){this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){let e;this._locks+=1;const t=new Promise((t=>e=()=>{this._locks-=1,t()})),i=this._locking.then((()=>e));return this._locking=this._locking.then((()=>t)),i}}class Rr{constructor(e,t){this.maxConcurrent=e||1,this.minCycle=t||0,this.queueRunning=[],this.queueWaiting={},this.lastRun=0}dequeue(e){const t=this.queueRunning,i=t.findIndex((t=>t.hash===e));if(-1==i)throw"queue desync";const n=t[i];return t.splice(i,1),n}getFirstWaiting(){for(let e of Object.keys(this.queueWaiting).sort(((e,t)=>e-t)))if(void 0!==this.queueWaiting[e]&&this.queueWaiting[e].length>0)return this.queueWaiting[e]}end(e){this.dequeue(e).resolve();const t=this.getFirstWaiting();if(void 0!==t){t.shift().resolve()}}async wait(e,t){const i=void 0===t?0:t;let n={hash:e,priority:i};for(null==this.queueWaiting[i]&&(this.queueWaiting[i]=[]),this.queueRunning.length>=this.maxConcurrent&&(n.promise=new Promise((e=>{n.resolve=e})),this.queueWaiting[i].push(n),await n.promise),this.queueRunning.push(n),n.promise=new Promise((e=>{n.resolve=e}));Date.now()-this.lastRun<this.minCycle;)await new Promise((e=>setTimeout(e,this.minCycle-Date.now()+this.lastRun)));this.lastRun=Date.now()}run(e,t){const i=void 0===t?0:t,n=Symbol();return this.wait(n,i).then((()=>e())).finally((()=>{this.end(n)}))}stat(){return{running:this.queueRunning.length,waiting:Object.keys(this.queueWaiting).reduce(((e,t)=>e+this.queueWaiting[t].length),0),last:this.lastRun}}async flush(){for(;this.stat().waiting>0;)for(let e of Object.keys(this.queueWaiting).sort(((e,t)=>t-e))){const t=this.queueWaiting[e];void 0!==t&&t.length>0&&await t[t.length-1].promise}for(;this.queueRunning.length>0;)await Promise.allSettled(this.queueRunning.map((e=>e.promise)))}}const Or="default";class Nr{static getInstance(){return void 0===this.instance&&(this.instance=new Nr),this.instance}async getDevices(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];var i;if((null===(i=Nr.userMediaPromiseMap)||void 0===i?void 0:i.size)>0){a.debug("awaiting getUserMedia promise");try{e?await Nr.userMediaPromiseMap.get(e):await Promise.all(Nr.userMediaPromiseMap.values())}catch(e){a.warn("error waiting for media permissons")}}let n=await navigator.mediaDevices.enumerateDevices();if(t&&e&&(!Nr.userMediaPromiseMap.get(e)||!lr())){if(0===n.length||n.some((t=>{const i=""===t.label,n=!e||t.kind===e;return i&&n}))){const t={video:"audioinput"!==e&&"audiooutput"!==e,audio:"videoinput"!==e},i=await navigator.mediaDevices.getUserMedia(t);n=await navigator.mediaDevices.enumerateDevices(),i.getTracks().forEach((e=>{e.stop()}))}}return e&&(n=n.filter((t=>t.kind===e))),n}async normalizeDeviceId(e,t,i){if(t!==Or)return t;const n=(await this.getDevices(e)).find((e=>e.groupId===i&&e.deviceId!==Or));return null==n?void 0:n.deviceId}}Nr.mediaDeviceKinds=["audioinput","audiooutput","videoinput"],Nr.userMediaPromiseMap=new Map;var Dr,Ir={},Ar={get exports(){return Ir},set exports(e){Ir=e}},Ur="object"==typeof Reflect?Reflect:null,Lr=Ur&&"function"==typeof Ur.apply?Ur.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};Dr=Ur&&"function"==typeof Ur.ownKeys?Ur.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var xr=Number.isNaN||function(e){return e!=e};function Mr(){Mr.init.call(this)}Ar.exports=Mr,Ir.once=function(e,t){return new Promise((function(i,n){function r(i){e.removeListener(t,s),n(i)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",r),i([].slice.call(arguments))}Gr(e,t,s,{once:!0}),"error"!==t&&function(e,t,i){"function"==typeof e.on&&Gr(e,"error",t,i)}(e,r,{once:!0})}))},Mr.EventEmitter=Mr,Mr.prototype._events=void 0,Mr.prototype._eventsCount=0,Mr.prototype._maxListeners=void 0;var _r=10;function Jr(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function $r(e){return void 0===e._maxListeners?Mr.defaultMaxListeners:e._maxListeners}function Br(e,t,i,n){var r,s,a,o;if(Jr(i),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),s=e._events),a=s[t]),void 0===a)a=s[t]=i,++e._eventsCount;else if("function"==typeof a?a=s[t]=n?[i,a]:[a,i]:n?a.unshift(i):a.push(i),(r=$r(e))>0&&a.length>r&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,o=c,console&&console.warn&&console.warn(o)}return e}function jr(){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 Vr(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=jr.bind(n);return r.listener=i,n.wrapFn=r,r}function Fr(e,t,i){var n=e._events;if(void 0===n)return[];var r=n[t];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(r):Wr(r,r.length)}function qr(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function Wr(e,t){for(var i=new Array(t),n=0;n<t;++n)i[n]=e[n];return i}function Gr(e,t,i,n){if("function"==typeof e.on)n.once?e.once(t,i):e.on(t,i);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 r(s){n.once&&e.removeEventListener(t,r),i(s)}))}}Object.defineProperty(Mr,"defaultMaxListeners",{enumerable:!0,get:function(){return _r},set:function(e){if("number"!=typeof e||e<0||xr(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");_r=e}}),Mr.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},Mr.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||xr(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},Mr.prototype.getMaxListeners=function(){return $r(this)},Mr.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var n="error"===e,r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var o=r[e];if(void 0===o)return!1;if("function"==typeof o)Lr(o,this,t);else{var c=o.length,d=Wr(o,c);for(i=0;i<c;++i)Lr(d[i],this,t)}return!0},Mr.prototype.addListener=function(e,t){return Br(this,e,t,!1)},Mr.prototype.on=Mr.prototype.addListener,Mr.prototype.prependListener=function(e,t){return Br(this,e,t,!0)},Mr.prototype.once=function(e,t){return Jr(t),this.on(e,Vr(this,e,t)),this},Mr.prototype.prependOnceListener=function(e,t){return Jr(t),this.prependListener(e,Vr(this,e,t)),this},Mr.prototype.removeListener=function(e,t){var i,n,r,s,a;if(Jr(t),void 0===(n=this._events))return this;if(void 0===(i=n[e]))return this;if(i===t||i.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(r=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){a=i[s].listener,r=s;break}if(r<0)return this;0===r?i.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(i,r),1===i.length&&(n[e]=i[0]),void 0!==n.removeListener&&this.emit("removeListener",e,a||t)}return this},Mr.prototype.off=Mr.prototype.removeListener,Mr.prototype.removeAllListeners=function(e){var t,i,n;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var r,s=Object.keys(i);for(n=0;n<s.length;++n)"removeListener"!==(r=s[n])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=i[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},Mr.prototype.listeners=function(e){return Fr(this,e,!0)},Mr.prototype.rawListeners=function(e){return Fr(this,e,!1)},Mr.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):qr.call(e,t)},Mr.prototype.listenerCount=qr,Mr.prototype.eventNames=function(){return this._eventsCount>0?Dr(this._events):[]};const Qr=[];class zr extends Ir.EventEmitter{constructor(e,t){super(),this.attachedElements=[],this.isMuted=!1,this.streamState=zr.StreamState.Active,this._currentBitrate=0,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),"hidden"===document.visibilityState?this.backgroundTimeout=setTimeout((()=>this.handleAppVisibilityChanged()),5e3):this.handleAppVisibilityChanged()},this.setMaxListeners(100),this.kind=t,this._mediaStreamTrack=e,this._mediaStreamID=e.id,this.source=zr.Source.Unknown,pr()?(this.isInBackground="hidden"===document.visibilityState,document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(t){let i="audio";this.kind===zr.Kind.Video&&(i="video"),t||("audio"===i&&(Qr.forEach((e=>{null!==e.parentElement||t||(t=e)})),t&&Qr.splice(Qr.indexOf(t),1)),t||(t=document.createElement(i))),this.attachedElements.includes(t)||this.attachedElements.push(t),Hr(this._mediaStreamTrack,t);const n=t.srcObject.getTracks();return n.some((e=>"audio"===e.kind))&&t.play().then((()=>{this.emit(e.TrackEvent.AudioPlaybackStarted)})).catch((i=>{this.emit(e.TrackEvent.AudioPlaybackFailed,i),t&&n.some((e=>"video"===e.kind))&&"NotAllowedError"===i.name&&(t.muted=!0,t.play().catch((()=>{})))})),this.emit(e.TrackEvent.ElementAttached,t),t}detach(t){if(t){Zr(this._mediaStreamTrack,t);const i=this.attachedElements.indexOf(t);return i>=0&&(this.attachedElements.splice(i,1),this.recycleElement(t),this.emit(e.TrackEvent.ElementDetached,t)),t}const i=[];return this.attachedElements.forEach((t=>{Zr(this._mediaStreamTrack,t),i.push(t),this.recycleElement(t),this.emit(e.TrackEvent.ElementDetached,t)})),this.attachedElements=[],i}stop(){this.stopMonitor(),this._mediaStreamTrack.stop(),pr()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}enable(){this._mediaStreamTrack.enabled=!0}disable(){this._mediaStreamTrack.enabled=!1}stopMonitor(){this.monitorInterval&&clearInterval(this.monitorInterval)}recycleElement(e){if(e instanceof HTMLAudioElement){let t=!0;e.pause(),Qr.forEach((e=>{e.parentElement||(t=!1)})),t&&Qr.push(e)}}async handleAppVisibilityChanged(){this.isInBackground="hidden"===document.visibilityState}}function Hr(e,t){let i,n;i=t.srcObject instanceof MediaStream?t.srcObject:new MediaStream,n="audio"===e.kind?i.getAudioTracks():i.getVideoTracks(),n.includes(e)||(n.forEach((e=>{i.removeTrack(e)})),i.addTrack(e)),t.autoplay=!0,t.muted=0===i.getAudioTracks().length,t instanceof HTMLVideoElement&&(t.playsInline=!0),t.srcObject!==i&&(t.srcObject=i,(lr()||ur())&&t instanceof HTMLVideoElement&&setTimeout((()=>{t.srcObject=i,t.play().catch((()=>{}))}),0))}function Zr(e,t){if(t.srcObject instanceof MediaStream){const i=t.srcObject;i.removeTrack(e),i.getTracks().length>0?t.srcObject=i:t.srcObject=null}}!function(e){let t,i,n;!function(e){e.Audio="audio",e.Video="video",e.Unknown="unknown"}(t=e.Kind||(e.Kind={})),function(e){e.Camera="camera",e.Microphone="microphone",e.ScreenShare="screen_share",e.ScreenShareAudio="screen_share_audio",e.Unknown="unknown"}(i=e.Source||(e.Source={})),function(e){e.Active="active",e.Paused="paused",e.Unknown="unknown"}(n=e.StreamState||(e.StreamState={})),e.kindToProto=function(e){switch(e){case t.Audio:return Fe.AUDIO;case t.Video:return Fe.VIDEO;default:return Fe.UNRECOGNIZED}},e.kindFromProto=function(e){switch(e){case Fe.AUDIO:return t.Audio;case Fe.VIDEO:return t.Video;default:return t.Unknown}},e.sourceToProto=function(e){switch(e){case i.Camera:return qe.CAMERA;case i.Microphone:return qe.MICROPHONE;case i.ScreenShare:return qe.SCREEN_SHARE;case i.ScreenShareAudio:return qe.SCREEN_SHARE_AUDIO;default:return qe.UNRECOGNIZED}},e.sourceFromProto=function(e){switch(e){case qe.CAMERA:return i.Camera;case qe.MICROPHONE:return i.Microphone;case qe.SCREEN_SHARE:return i.ScreenShare;case qe.SCREEN_SHARE_AUDIO:return i.ScreenShareAudio;default:return i.Unknown}},e.streamStateFromProto=function(e){switch(e){case Hi.ACTIVE:return n.Active;case Hi.PAUSED:return n.Paused;default:return n.Unknown}}}(zr||(zr={}));class Kr extends zr{constructor(t,i,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];super(t,i),this._isUpstreamPaused=!1,this.handleEnded=()=>{this.isInBackground&&(this.reacquireTrack=!0),this.emit(e.TrackEvent.Ended,this)},this._mediaStreamTrack.addEventListener("ended",this.handleEnded),this.constraints=null!=n?n:t.getConstraints(),this.reacquireTrack=!1,this.providedByUser=r,this.muteQueue=new Rr}get id(){return this._mediaStreamTrack.id}get dimensions(){if(this.kind!==zr.Kind.Video)return;const{width:e,height:t}=this._mediaStreamTrack.getSettings();return e&&t?{width:e,height:t}:void 0}get isUpstreamPaused(){return this._isUpstreamPaused}get isUserProvided(){return this.providedByUser}async waitForDimensions(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;if(this.kind===zr.Kind.Audio)throw new Error("cannot get dimensions for audio tracks");const t=Date.now();for(;Date.now()-t<e;){const e=this.dimensions;if(e)return e;await nr(50)}throw new qn("unable to get track dimensions after timeout")}async getDeviceId(){if(this.source===zr.Source.ScreenShare)return;const{deviceId:e,groupId:t}=this._mediaStreamTrack.getSettings(),i=this.kind===zr.Kind.Audio?"audioinput":"videoinput";return Nr.getInstance().normalizeDeviceId(i,e,t)}async mute(){return this.setTrackMuted(!0),this}async unmute(){return this.setTrackMuted(!1),this}async replaceTrack(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this.sender)throw new qn("unable to replace an unpublished track");return this.attachedElements.forEach((e=>{Zr(this._mediaStreamTrack,e)})),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this.providedByUser||this._mediaStreamTrack.stop(),e.addEventListener("ended",this.handleEnded),a.debug("replace MediaStreamTrack"),this.sender&&await this.sender.replaceTrack(e),this._mediaStreamTrack=e,this._mediaStreamTrack.enabled=!this.isMuted,await this.resumeUpstream(),this.attachedElements.forEach((t=>{Hr(e,t)})),this.mediaStream=new MediaStream([e]),this.providedByUser=t,this}async restart(t){t||(t=this.constraints),a.debug("restarting track with constraints",t);const i={audio:!1,video:!1};this.kind===zr.Kind.Video?i.video=t:i.audio=t,this.attachedElements.forEach((e=>{Zr(this._mediaStreamTrack,e)})),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.stop();const n=await navigator.mediaDevices.getUserMedia(i),r=n.getTracks()[0];return r.addEventListener("ended",this.handleEnded),a.debug("re-acquired MediaStreamTrack"),this.sender&&await this.sender.replaceTrack(r),this._mediaStreamTrack=r,await this.resumeUpstream(),this.attachedElements.forEach((e=>{Hr(r,e)})),this.mediaStream=n,this.constraints=t,this.emit(e.TrackEvent.Restarted,this),this}setTrackMuted(t){a.debug("setting ".concat(this.kind," track ").concat(t?"muted":"unmuted")),this.isMuted===t&&this._mediaStreamTrack.enabled!==t||(this.isMuted=t,this._mediaStreamTrack.enabled=!t,this.emit(t?e.TrackEvent.Muted:e.TrackEvent.Unmuted,this))}get needsReAcquisition(){return"live"!==this._mediaStreamTrack.readyState||this._mediaStreamTrack.muted||!this._mediaStreamTrack.enabled||this.reacquireTrack}async handleAppVisibilityChanged(){await super.handleAppVisibilityChanged(),hr()&&(a.debug("visibility changed, is in Background: ".concat(this.isInBackground)),this.isInBackground||!this.needsReAcquisition||this.isUserProvided||this.isMuted||(a.debug("track needs to be reaquired, restarting ".concat(this.source)),await this.restart(),this.reacquireTrack=!1))}async pauseUpstream(){this.muteQueue.run((async()=>{if(!0===this._isUpstreamPaused)return;if(!this.sender)return void a.warn("unable to pause upstream for an unpublished track");this._isUpstreamPaused=!0,this.emit(e.TrackEvent.UpstreamPaused,this);const t=this.kind===zr.Kind.Audio?Tr():wr();await this.sender.replaceTrack(t)}))}async resumeUpstream(){this.muteQueue.run((async()=>{!1!==this._isUpstreamPaused&&(this.sender?(this._isUpstreamPaused=!1,this.emit(e.TrackEvent.UpstreamResumed,this),await this.sender.replaceTrack(this._mediaStreamTrack)):a.warn("unable to resume upstream for an unpublished track"))}))}}class Yr extends Kr{constructor(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];super(e,zr.Kind.Audio,t,i),this.stopOnMute=!1,this.monitorSender=async()=>{if(!this.sender)return void(this._currentBitrate=0);let e;try{e=await this.getSenderStats()}catch(e){return void a.error("could not get audio sender stats",{error:e})}e&&this.prevStats&&(this._currentBitrate=Hn(e,this.prevStats)),this.prevStats=e},this.checkForSilence()}async setDeviceId(e){this.constraints.deviceId!==e&&(this.constraints.deviceId=e,this.isMuted||await this.restartTrack())}async mute(){return await this.muteQueue.run((async()=>{this.source===zr.Source.Microphone&&this.stopOnMute&&!this.isUserProvided&&(a.debug("stopping mic track"),this._mediaStreamTrack.stop()),await super.mute()})),this}async unmute(){return await this.muteQueue.run((async()=>{this.source===zr.Source.Microphone&&this.stopOnMute&&!this.isUserProvided&&(a.debug("reacquiring mic track"),await this.restartTrack()),await super.unmute()})),this}async restartTrack(e){let t;if(e){const i=tr({audio:e});"boolean"!=typeof i.audio&&(t=i.audio)}await this.restart(t)}async restart(e){const t=await super.restart(e);return this.checkForSilence(),t}startMonitor(){pr()&&(this.monitorInterval||(this.monitorInterval=setInterval((()=>{this.monitorSender()}),zn)))}async getSenderStats(){var e;if(!(null===(e=this.sender)||void 0===e?void 0:e.getStats))return;let t;return(await this.sender.getStats()).forEach((e=>{"outbound-rtp"===e.type&&(t={type:"audio",streamId:e.id,packetsSent:e.packetsSent,packetsLost:e.packetsLost,bytesSent:e.bytesSent,timestamp:e.timestamp,roundTripTime:e.roundTripTime,jitter:e.jitter})})),t}async checkForSilence(){const t=await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200;const i=ir();if(i){const n=i.createAnalyser();n.fftSize=2048;const r=n.frequencyBinCount,s=new Uint8Array(r);i.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(n),await nr(t),n.getByteTimeDomainData(s);const a=s.some((e=>128!==e&&0!==e));return i.close(),!a}return!1}(this);t&&(this.isMuted||a.warn("silence detected on local audio track"),this.emit(e.TrackEvent.AudioSilenceDetected))}}class Xr extends Kr{constructor(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];super(e,zr.Kind.Video,t,i),this.simulcastCodecs=new Map,this.monitorSender=async()=>{if(!this.sender)return void(this._currentBitrate=0);let e;try{e=await this.getSenderStats()}catch(e){return void a.error("could not get audio sender stats",{error:e})}const t=new Map(e.map((e=>[e.rid,e])));if(this.prevStats){let e=0;t.forEach(((t,i)=>{var n;const r=null===(n=this.prevStats)||void 0===n?void 0:n.get(i);e+=Hn(t,r)})),this._currentBitrate=e}this.prevStats=t}}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){var t;if(this.signalClient=e,!pr())return;const i=null===(t=this.sender)||void 0===t?void 0:t.getParameters();i&&(this.encodings=i.encodings),this.monitorInterval||(this.monitorInterval=setInterval((()=>{this.monitorSender()}),zn))}stop(){this._mediaStreamTrack.getConstraints(),this.simulcastCodecs.forEach((e=>{e.mediaStreamTrack.stop()})),super.stop()}async mute(){return await this.muteQueue.run((async()=>{this.source!==zr.Source.Camera||this.isUserProvided||(a.debug("stopping camera track"),this._mediaStreamTrack.stop()),await super.mute()})),this}async unmute(){return await this.muteQueue.run((async()=>{this.source!==zr.Source.Camera||this.isUserProvided||(a.debug("reacquiring camera track"),await this.restartTrack()),await super.unmute()})),this}async getSenderStats(){var e;if(!(null===(e=this.sender)||void 0===e?void 0:e.getStats))return[];const t=[],i=await this.sender.getStats();return i.forEach((e=>{var n;if("outbound-rtp"===e.type){const r={type:"video",streamId:e.id,frameHeight:e.frameHeight,frameWidth:e.frameWidth,firCount:e.firCount,pliCount:e.pliCount,nackCount:e.nackCount,packetsSent:e.packetsSent,bytesSent:e.bytesSent,framesSent:e.framesSent,timestamp:e.timestamp,rid:null!==(n=e.rid)&&void 0!==n?n:e.id,retransmittedPacketsSent:e.retransmittedPacketsSent,qualityLimitationReason:e.qualityLimitationReason,qualityLimitationResolutionChanges:e.qualityLimitationResolutionChanges},s=i.get(e.remoteId);s&&(r.jitter=s.jitter,r.packetsLost=s.packetsLost,r.roundTripTime=s.roundTripTime),t.push(r)}})),t}setPublishingQuality(t){const i=[];for(let n=e.VideoQuality.LOW;n<=e.VideoQuality.HIGH;n+=1)i.push({quality:n,enabled:n<=t});a.debug("setting publishing quality. max quality ".concat(t)),this.setPublishingLayers(i)}async setDeviceId(e){this.constraints.deviceId!==e&&(this.constraints.deviceId=e,this.isMuted||await this.restartTrack())}async restartTrack(e){let t;if(e){const i=tr({video:e});"boolean"!=typeof i.video&&(t=i.video)}await this.restart(t)}addSimulcastTrack(e,t){if(this.simulcastCodecs.has(e))throw new Error("".concat(e," already added"));const i={codec:e,mediaStreamTrack:this.mediaStreamTrack.clone(),sender:void 0,encodings:t};return this.simulcastCodecs.set(e,i),i}setSimulcastTrackSender(e,t){const i=this.simulcastCodecs.get(e);i&&(i.sender=t,setTimeout((()=>{this.subscribedCodecs&&this.setPublishingCodecs(this.subscribedCodecs)}),5e3))}async setPublishingCodecs(e){if(a.debug("setting publishing codecs",{codecs:e,currentCodec:this.codec}),!this.codec&&e.length>0)return await this.setPublishingLayers(e[0].qualities),[];this.subscribedCodecs=e;const t=[];var i,n=!1,r=!1;try{for(var s,o=Bt(e);n=!(s=await o.next()).done;n=!1){const e=s.value;if(this.codec&&this.codec!==e.codec){const i=this.simulcastCodecs.get(e.codec);if(a.debug("try setPublishingCodec for ".concat(e.codec),i),i&&i.sender)i.encodings&&(a.debug("try setPublishingLayersForSender ".concat(e.codec)),await es(i.sender,i.encodings,e.qualities));else for(const i of e.qualities)if(i.enabled){t.push(e.codec);break}}else await this.setPublishingLayers(e.qualities)}}catch(e){r=!0,i=e}finally{try{n&&null!=o.return&&await o.return()}finally{if(r)throw i}}return t}async setPublishingLayers(e){a.debug("setting publishing layers",e),this.sender&&this.encodings&&await es(this.sender,this.encodings,e)}async handleAppVisibilityChanged(){await super.handleAppVisibilityChanged(),hr()&&this.isInBackground&&this.source===zr.Source.Camera&&(this._mediaStreamTrack.enabled=!1)}}async function es(e,t,i){a.debug("setPublishingLayersForSender",{sender:e,qualities:i,senderEncodings:t});const n=e.getParameters(),{encodings:r}=n;if(!r)return;if(r.length!==t.length)return void a.warn("cannot set publishing layers, encodings mismatch");let s=!1;r.forEach(((e,n)=>{var r;let o=null!==(r=e.rid)&&void 0!==r?r:"";""===o&&(o="q");const c=ts(o),d=i.find((e=>e.quality===c));d&&e.active!==d.enabled&&(s=!0,e.active=d.enabled,a.debug("setting layer ".concat(d.quality," to ").concat(e.active?"enabled":"disabled")),ur()&&(d.enabled?(e.scaleResolutionDownBy=t[n].scaleResolutionDownBy,e.maxBitrate=t[n].maxBitrate,e.maxFrameRate=t[n].maxFrameRate):(e.scaleResolutionDownBy=4,e.maxBitrate=10,e.maxFrameRate=2)))})),s&&(n.encodings=r,await e.setParameters(n))}function ts(t){switch(t){case"f":return e.VideoQuality.HIGH;case"h":return e.VideoQuality.MEDIUM;case"q":return e.VideoQuality.LOW;default:return e.VideoQuality.UNRECOGNIZED}}function is(t,i,n){return n?n.map((r=>{var s,a,o;const c=null!==(s=r.scaleResolutionDownBy)&&void 0!==s?s:1;let d=ts(null!==(a=r.rid)&&void 0!==a?a:"");return d===e.VideoQuality.UNRECOGNIZED&&1===n.length&&(d=e.VideoQuality.HIGH),{quality:d,width:t/c,height:i/c,bitrate:null!==(o=r.maxBitrate)&&void 0!==o?o:0,ssrc:0}})):[{quality:e.VideoQuality.HIGH,width:t,height:i,bitrate:0,ssrc:0}]}class ns extends zr{constructor(e,t,i,n){super(e,i),this.sid=t,this.receiver=n}setMuted(t){this.isMuted!==t&&(this.isMuted=t,this._mediaStreamTrack.enabled=!t,this.emit(t?e.TrackEvent.Muted:e.TrackEvent.Unmuted,this))}setMediaStream(t){this.mediaStream=t,t.onremovetrack=()=>{this.receiver=void 0,this._currentBitrate=0,this.emit(e.TrackEvent.Ended,this)}}start(){this.startMonitor(),super.enable()}stop(){this.stopMonitor(),super.disable()}startMonitor(){this.monitorInterval||(this.monitorInterval=setInterval((()=>this.monitorReceiver()),zn))}}class rs extends ns{constructor(e,t,i,n,r){super(e,t,zr.Kind.Audio,i),this.monitorReceiver=async()=>{if(!this.receiver)return void(this._currentBitrate=0);const e=await this.getReceiverStats();e&&this.prevStats&&this.receiver&&(this._currentBitrate=Hn(e,this.prevStats)),this.prevStats=e},this.audioContext=n,this.webAudioPluginNodes=[],r&&(this.sinkId=r.deviceId)}setVolume(e){var t;for(const i of this.attachedElements)this.audioContext?null===(t=this.gainNode)||void 0===t||t.gain.setTargetAtTime(e,0,.1):i.volume=e;this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;let e=0;return this.attachedElements.forEach((t=>{t.volume>e&&(e=t.volume)})),e}async setSinkId(e){this.sinkId=e,await Promise.all(this.attachedElements.map((t=>{if(or(t))return t.setSinkId(e)})))}attach(e){const t=0===this.attachedElements.length;return e?super.attach(e):e=super.attach(),this.elementVolume&&(e.volume=this.elementVolume),this.sinkId&&or(e)&&e.setSinkId(this.sinkId),this.audioContext&&t&&(a.debug("using audio context mapping"),this.connectWebAudio(this.audioContext,e),e.volume=0,e.muted=!0),e}detach(e){let t;return e?(t=super.detach(e),this.audioContext&&(this.attachedElements.length>0?this.connectWebAudio(this.audioContext,this.attachedElements[0]):this.disconnectWebAudio())):(t=super.detach(),this.disconnectWebAudio()),t}setAudioContext(e){this.audioContext=e,e&&this.attachedElements.length>0?this.connectWebAudio(e,this.attachedElements[0]):e||this.disconnectWebAudio()}setWebAudioPlugins(e){this.webAudioPluginNodes=e,this.attachedElements.length>0&&this.audioContext&&this.connectWebAudio(this.audioContext,this.attachedElements[0])}connectWebAudio(t,i){this.disconnectWebAudio(),this.sourceNode=t.createMediaStreamSource(i.srcObject);let n=this.sourceNode;this.webAudioPluginNodes.forEach((e=>{n.connect(e),n=e})),this.gainNode=t.createGain(),n.connect(this.gainNode),this.gainNode.connect(t.destination),this.elementVolume&&this.gainNode.gain.setTargetAtTime(this.elementVolume,0,.1),"running"!==t.state&&t.resume().then((()=>{"running"!==t.state&&this.emit(e.TrackEvent.AudioPlaybackFailed,new Error("Audio Context couldn't be started automatically"))})).catch((t=>{this.emit(e.TrackEvent.AudioPlaybackFailed,t)}))}disconnectWebAudio(){var e,t;null===(e=this.gainNode)||void 0===e||e.disconnect(),null===(t=this.sourceNode)||void 0===t||t.disconnect(),this.gainNode=void 0,this.sourceNode=void 0}async getReceiverStats(){if(!this.receiver||!this.receiver.getStats)return;let e;return(await this.receiver.getStats()).forEach((t=>{"inbound-rtp"===t.type&&(e={type:"audio",timestamp:t.timestamp,jitter:t.jitter,bytesReceived:t.bytesReceived,concealedSamples:t.concealedSamples,concealmentEvents:t.concealmentEvents,silentConcealedSamples:t.silentConcealedSamples,silentConcealmentEvents:t.silentConcealmentEvents,totalAudioEnergy:t.totalAudioEnergy,totalSamplesDuration:t.totalSamplesDuration})})),e}}function ss(e,t,i){var n,r,s;void 0===t&&(t=50),void 0===i&&(i={});var a=null!=(n=i.isImmediate)&&n,o=null!=(r=i.callback)&&r,c=i.maxWait,d=Date.now(),u=[];function l(){if(void 0!==c){var e=Date.now()-d;if(e+t>=c)return c-e}return t}var h=function(){var t=[].slice.call(arguments),i=this;return new Promise((function(n,r){var c=a&&void 0===s;if(void 0!==s&&clearTimeout(s),s=setTimeout((function(){if(s=void 0,d=Date.now(),!a){var n=e.apply(i,t);o&&o(n),u.forEach((function(e){return(0,e.resolve)(n)})),u=[]}}),l()),c){var h=e.apply(i,t);return o&&o(h),n(h)}u.push({resolve:n,reject:r})}))};return h.cancel=function(e){void 0!==s&&clearTimeout(s),u.forEach((function(t){return(0,t.reject)(e)})),u=[]},h}class as extends ns{constructor(e,t,i,n){super(e,t,zr.Kind.Video,i),this.elementInfos=[],this.hasUsedAttach=!1,this.monitorReceiver=async()=>{if(!this.receiver)return void(this._currentBitrate=0);const e=await this.getReceiverStats();e&&this.prevStats&&this.receiver&&(this._currentBitrate=Hn(e,this.prevStats)),this.prevStats=e},this.debouncedHandleResize=ss((()=>{this.updateDimensions()}),100),this.adaptiveStreamSettings=n,this.isAdaptiveStream&&(this.streamState=zr.StreamState.Paused)}get isAdaptiveStream(){return void 0!==this.adaptiveStreamSettings}get mediaStreamTrack(){return this.isAdaptiveStream&&!this.hasUsedAttach&&a.warn("When using adaptiveStream, you need to use remoteVideoTrack.attach() to add the track to a HTMLVideoElement, otherwise your video tracks might never start"),this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach((t=>{e?Zr(this._mediaStreamTrack,t):Hr(this._mediaStreamTrack,t)}))}attach(e){if(e?super.attach(e):e=super.attach(),this.adaptiveStreamSettings&&void 0===this.elementInfos.find((t=>t.element===e))){const t=new os(e);this.observeElementInfo(t)}return this.hasUsedAttach=!0,e}observeElementInfo(e){this.adaptiveStreamSettings&&void 0===this.elementInfos.find((t=>t===e))?(e.handleResize=()=>{this.debouncedHandleResize()},e.handleVisibilityChanged=()=>{this.updateVisibility()},this.elementInfos.push(e),e.observe(),this.debouncedHandleResize(),this.updateVisibility()):a.warn("visibility resize observer not triggered")}stopObservingElementInfo(e){if(!this.isAdaptiveStream)return void a.warn("stopObservingElementInfo ignored");const t=this.elementInfos.filter((t=>t===e));for(const e of t)e.stopObserving();this.elementInfos=this.elementInfos.filter((t=>t!==e)),this.updateVisibility()}detach(e){let t=[];if(e)return this.stopObservingElement(e),super.detach(e);t=super.detach();for(const e of t)this.stopObservingElement(e);return t}getDecoderImplementation(){var e;return null===(e=this.prevStats)||void 0===e?void 0:e.decoderImplementation}async getReceiverStats(){if(!this.receiver||!this.receiver.getStats)return;let e;return(await this.receiver.getStats()).forEach((t=>{"inbound-rtp"===t.type&&(e={type:"video",framesDecoded:t.framesDecoded,framesDropped:t.framesDropped,framesReceived:t.framesReceived,packetsReceived:t.packetsReceived,packetsLost:t.packetsLost,frameWidth:t.frameWidth,frameHeight:t.frameHeight,pliCount:t.pliCount,firCount:t.firCount,nackCount:t.nackCount,jitter:t.jitter,timestamp:t.timestamp,bytesReceived:t.bytesReceived,decoderImplementation:t.decoderImplementation})})),e}stopObservingElement(e){const t=this.elementInfos.filter((t=>t.element===e));for(const e of t)e.stopObserving();this.elementInfos=this.elementInfos.filter((t=>t.element!==e))}async handleAppVisibilityChanged(){await super.handleAppVisibilityChanged(),this.isAdaptiveStream&&this.updateVisibility()}updateVisibility(){var t,i;const n=this.elementInfos.reduce(((e,t)=>Math.max(e,t.visibilityChangedAt||0)),0),r=!(null!==(i=null===(t=this.adaptiveStreamSettings)||void 0===t?void 0:t.pauseVideoInBackground)&&void 0!==i&&!i)&&this.isInBackground,s=this.elementInfos.some((e=>e.visible))&&!r;this.lastVisible!==s&&(!s&&Date.now()-n<100?setTimeout((()=>{this.updateVisibility()}),100):(this.lastVisible=s,this.emit(e.TrackEvent.VisibilityChanged,s,this)))}updateDimensions(){var t,i,n,r;let s=0,a=0;for(const e of this.elementInfos){const n=null!==(i=null===(t=this.adaptiveStreamSettings)||void 0===t?void 0:t.pixelDensity)&&void 0!==i?i:1,r="screen"===n?window.devicePixelRatio:n,o=e.width()*r,c=e.height()*r;o+c>s+a&&(s=o,a=c)}(null===(n=this.lastDimensions)||void 0===n?void 0:n.width)===s&&(null===(r=this.lastDimensions)||void 0===r?void 0:r.height)===a||(this.lastDimensions={width:s,height:a},this.emit(e.TrackEvent.VideoDimensionsChanged,this.lastDimensions,this))}}class os{constructor(e,t){this.onVisibilityChanged=e=>{var t;const{target:i,isIntersecting:n}=e;i===this.element&&(this.visible=n,this.visibilityChangedAt=Date.now(),null===(t=this.handleVisibilityChanged)||void 0===t||t.call(this))},this.element=e,this.visible=null!=t?t:function(e){let t=e.offsetTop,i=e.offsetLeft;const n=e.offsetWidth,r=e.offsetHeight,{hidden:s}=e,{opacity:a,display:o}=getComputedStyle(e);for(;e.offsetParent;)t+=(e=e.offsetParent).offsetTop,i+=e.offsetLeft;return t<window.pageYOffset+window.innerHeight&&i<window.pageXOffset+window.innerWidth&&t+r>window.pageYOffset&&i+n>window.pageXOffset&&!s&&(""===a||parseFloat(a)>0)&&"none"!==o}(e),this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){this.element.handleResize=()=>{var e;null===(e=this.handleResize)||void 0===e||e.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,kr().observe(this.element),gr().observe(this.element)}stopObserving(){var e,t;null===(e=kr())||void 0===e||e.unobserve(this.element),null===(t=gr())||void 0===t||t.unobserve(this.element)}}class cs extends Ir.EventEmitter{constructor(t,i,n){super(),this.metadataMuted=!1,this.handleMuted=()=>{this.emit(e.TrackEvent.Muted)},this.handleUnmuted=()=>{this.emit(e.TrackEvent.Unmuted)},this.setMaxListeners(100),this.kind=t,this.trackSid=i,this.trackName=n,this.source=zr.Source.Unknown}setTrack(t){this.track&&(this.track.off(e.TrackEvent.Muted,this.handleMuted),this.track.off(e.TrackEvent.Unmuted,this.handleUnmuted)),this.track=t,t&&(t.on(e.TrackEvent.Muted,this.handleMuted),t.on(e.TrackEvent.Unmuted,this.handleUnmuted))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return void 0!==this.track}get audioTrack(){if(this.track instanceof Yr||this.track instanceof rs)return this.track}get videoTrack(){if(this.track instanceof Xr||this.track instanceof as)return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=zr.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===zr.Kind.Video&&e.width>0&&(this.dimensions={width:e.width,height:e.height},this.simulcasted=e.simulcast),this.trackInfo=e,a.trace("update publication info",{info:e})}}!function(e){var t,i;(t=e.SubscriptionStatus||(e.SubscriptionStatus={})).Desired="desired",t.Subscribed="subscribed",t.Unsubscribed="unsubscribed",(i=e.PermissionStatus||(e.PermissionStatus={})).Allowed="allowed",i.NotAllowed="not_allowed"}(cs||(cs={}));class ds extends cs{get isUpstreamPaused(){var e;return null===(e=this.track)||void 0===e?void 0:e.isUpstreamPaused}constructor(t,i,n){super(t,i.sid,i.name),this.track=void 0,this.handleTrackEnded=()=>{this.emit(e.TrackEvent.Ended)},this.updateInfo(i),this.setTrack(n)}setTrack(t){this.track&&this.track.off(e.TrackEvent.Ended,this.handleTrackEnded),super.setTrack(t),t&&t.on(e.TrackEvent.Ended,this.handleTrackEnded)}get isMuted(){return this.track?this.track.isMuted:super.isMuted}get audioTrack(){return super.audioTrack}get videoTrack(){return super.videoTrack}async mute(){var e;return null===(e=this.track)||void 0===e?void 0:e.mute()}async unmute(){var e;return null===(e=this.track)||void 0===e?void 0:e.unmute()}async pauseUpstream(){var e;await(null===(e=this.track)||void 0===e?void 0:e.pauseUpstream())}async resumeUpstream(){var e;await(null===(e=this.track)||void 0===e?void 0:e.resumeUpstream())}}class us{constructor(e,t,i,n){this.width=e,this.height=t,this.encoding={maxBitrate:i,maxFramerate:n}}get resolution(){return{width:this.width,height:this.height,frameRate:this.encoding.maxFramerate,aspectRatio:this.width/this.height}}}const ls=["vp8","h264"];function hs(e){return!!ls.find((t=>t===e))}var ps;e.AudioPresets=void 0,(ps=e.AudioPresets||(e.AudioPresets={})).telephone={maxBitrate:12e3},ps.speech={maxBitrate:2e4},ps.music={maxBitrate:32e3},ps.musicStereo={maxBitrate:48e3},ps.musicHighQuality={maxBitrate:64e3},ps.musicHighQualityStereo={maxBitrate:96e3};const ms={h90:new us(160,90,6e4,15),h180:new us(320,180,12e4,15),h216:new us(384,216,18e4,15),h360:new us(640,360,3e5,20),h540:new us(960,540,6e5,25),h720:new us(1280,720,17e5,30),h1080:new us(1920,1080,3e6,30),h1440:new us(2560,1440,5e6,30),h2160:new us(3840,2160,8e6,30)},vs={h120:new us(160,120,8e4,15),h180:new us(240,180,1e5,15),h240:new us(320,240,15e4,15),h360:new us(480,360,225e3,20),h480:new us(640,480,3e5,20),h540:new us(720,540,45e4,25),h720:new us(960,720,15e5,30),h1080:new us(1440,1080,25e5,30),h1440:new us(1920,1440,35e5,30)},fs={h360fps3:new us(640,360,2e5,3),h720fps5:new us(1280,720,4e5,5),h720fps15:new us(1280,720,1e6,15),h1080fps15:new us(1920,1080,15e5,15),h1080fps30:new us(1920,1080,3e6,30)};e.ConnectionQuality=void 0,function(e){e.Excellent="excellent",e.Good="good",e.Poor="poor",e.Unknown="unknown"}(e.ConnectionQuality||(e.ConnectionQuality={}));class gs extends Ir.EventEmitter{constructor(t,i,n,r){super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=e.ConnectionQuality.Unknown,this.setMaxListeners(100),this.sid=t,this.identity=i,this.name=n,this.metadata=r,this.audioTracks=new Map,this.videoTracks=new Map,this.tracks=new Map}getTracks(){return Array.from(this.tracks.values())}getTrack(e){if(e!==zr.Source.Unknown)for(const[,t]of this.tracks)if(t.source===e)return t}getTrackByName(e){for(const[,t]of this.tracks)if(t.trackName===e)return t}get connectionQuality(){return this._connectionQuality}get isCameraEnabled(){var e;const t=this.getTrack(zr.Source.Camera);return!(null===(e=null==t?void 0:t.isMuted)||void 0===e||e)}get isMicrophoneEnabled(){var e;const t=this.getTrack(zr.Source.Microphone);return!(null===(e=null==t?void 0:t.isMuted)||void 0===e||e)}get isScreenShareEnabled(){return!!this.getTrack(zr.Source.ScreenShare)}get isLocal(){return!1}get joinedAt(){return this.participantInfo?new Date(1e3*this.participantInfo.joinedAt):new Date}updateInfo(e){this.identity=e.identity,this.sid=e.sid,this.name=e.name,this.setMetadata(e.metadata),e.permission&&this.setPermissions(e.permission),this.participantInfo=e,a.trace("update participant info",{info:e})}setMetadata(t){const i=this.metadata!==t,n=this.metadata;this.metadata=t,i&&this.emit(e.ParticipantEvent.ParticipantMetadataChanged,n)}setPermissions(e){var t,i,n,r,s;const a=e.canPublish!==(null===(t=this.permissions)||void 0===t?void 0:t.canPublish)||e.canSubscribe!==(null===(i=this.permissions)||void 0===i?void 0:i.canSubscribe)||e.canPublishData!==(null===(n=this.permissions)||void 0===n?void 0:n.canPublishData)||e.hidden!==(null===(r=this.permissions)||void 0===r?void 0:r.hidden)||e.recorder!==(null===(s=this.permissions)||void 0===s?void 0:s.recorder);return this.permissions=e,a}setIsSpeaking(t){t!==this.isSpeaking&&(this.isSpeaking=t,t&&(this.lastSpokeAt=new Date),this.emit(e.ParticipantEvent.IsSpeakingChanged,t))}setConnectionQuality(t){const i=this._connectionQuality;this._connectionQuality=function(t){switch(t){case Ge.EXCELLENT:return e.ConnectionQuality.Excellent;case Ge.GOOD:return e.ConnectionQuality.Good;case Ge.POOR:return e.ConnectionQuality.Poor;default:return e.ConnectionQuality.Unknown}}(t),i!==this._connectionQuality&&this.emit(e.ParticipantEvent.ConnectionQualityChanged,this._connectionQuality)}addTrackPublication(t){t.on(e.TrackEvent.Muted,(()=>{this.emit(e.ParticipantEvent.TrackMuted,t)})),t.on(e.TrackEvent.Unmuted,(()=>{this.emit(e.ParticipantEvent.TrackUnmuted,t)}));const i=t;switch(i.track&&(i.track.sid=t.trackSid),this.tracks.set(t.trackSid,t),t.kind){case zr.Kind.Audio:this.audioTracks.set(t.trackSid,t);break;case zr.Kind.Video:this.videoTracks.set(t.trackSid,t)}}}function bs(e,t){switch(e.kind){case"audio":return new Yr(e,t,!1);case"video":return new Xr(e,t,!1);default:throw new qn("unsupported track type: ".concat(e.kind))}}const ks=Object.values(ms),ys=Object.values(vs),Ss=Object.values(fs),ws=[ms.h180,ms.h360],Cs=[vs.h180,vs.h360],Ts=["q","h","f"];function Es(e,t,i,n){var r,s;let o=null==n?void 0:n.videoEncoding;e&&(o=null==n?void 0:n.screenShareEncoding);const c=null==n?void 0:n.simulcast,d=null==n?void 0:n.scalabilityMode,u=null==n?void 0:n.videoCodec;if(!o&&!c&&!d||!t||!i)return[{}];o||(o=function(e,t,i,n){const r=function(e,t,i){if(e)return Ss;const n=t>i?t/i:i/t;if(Math.abs(n-16/9)<Math.abs(n-4/3))return ks;return ys}(e,t,i);let{encoding:s}=r[0];const a=Math.max(t,i);for(let e=0;e<r.length;e+=1){const t=r[e];if(s=t.encoding,t.width>=a)break}if(n&&"av1"===n)s.maxBitrate=.7*s.maxBitrate;return s}(e,t,i,u),a.debug("using video encoding",o));const l=new us(t,i,o.maxBitrate,o.maxFramerate);if(d&&"av1"===u){a.debug("using svc with scalabilityMode ".concat(d));const e=[];if("L3T3"===d){for(let t=0;t<3;t+=1)e.push({rid:Ts[2-t],scaleResolutionDownBy:2**t,maxBitrate:o.maxBitrate/3**t,maxFramerate:l.encoding.maxFramerate,scalabilityMode:"L3T3"});return a.debug("encodings",e),e}throw new Error("unsupported scalabilityMode: ".concat(d))}if(!c)return[o];let h,p=[];if(p=e?null!==(r=Ns(null==n?void 0:n.screenShareSimulcastLayers))&&void 0!==r?r:Rs(e,l):null!==(s=Ns(null==n?void 0:n.videoSimulcastLayers))&&void 0!==s?s:Rs(e,l),p.length>0){const e=p[0];p.length>1&&([,h]=p);const n=Math.max(t,i);if(n>=960&&h)return Os(t,i,[e,h,l]);if(n>=480)return Os(t,i,[e,l])}return Os(t,i,[l])}function Ps(e,t,i){var n,r,s,o;if(!i.backupCodec||i.backupCodec.codec===i.videoCodec)return;t!==i.backupCodec.codec&&a.warn("requested a different codec than specified as backup",{serverRequested:t,backup:i.backupCodec.codec}),i.videoCodec=t,i.videoEncoding=i.backupCodec.encoding;const c=e.mediaStreamTrack.getSettings(),d=null!==(n=c.width)&&void 0!==n?n:null===(r=e.dimensions)||void 0===r?void 0:r.width,u=null!==(s=c.height)&&void 0!==s?s:null===(o=e.dimensions)||void 0===o?void 0:o.height;return Es(e.source===zr.Source.ScreenShare,d,u,i)}function Rs(e,t){if(e)return i=t,[{scaleResolutionDownBy:2,fps:3}].map((e=>{var t;return new us(Math.floor(i.width/e.scaleResolutionDownBy),Math.floor(i.height/e.scaleResolutionDownBy),Math.max(15e4,Math.floor(i.encoding.maxBitrate/(e.scaleResolutionDownBy**2*((null!==(t=i.encoding.maxFramerate)&&void 0!==t?t:30)/e.fps)))),e.fps)}));var i;const{width:n,height:r}=t,s=n>r?n/r:r/n;return Math.abs(s-16/9)<Math.abs(s-4/3)?ws:Cs}function Os(e,t,i){const n=[];return i.forEach(((i,r)=>{if(r>=Ts.length)return;const s=Math.min(e,t),a=Ts[r];n.push({rid:a,scaleResolutionDownBy:Math.max(1,s/Math.min(i.width,i.height)),maxBitrate:i.encoding.maxBitrate,maxFramerate:i.encoding.maxFramerate})})),n}function Ns(e){if(e)return e.sort(((e,t)=>{const{encoding:i}=e,{encoding:n}=t;return i.maxBitrate>n.maxBitrate?1:i.maxBitrate<n.maxBitrate?-1:i.maxBitrate===n.maxBitrate&&i.maxFramerate&&n.maxFramerate?i.maxFramerate>n.maxFramerate?1:-1:0}))}class Ds extends cs{constructor(t,i,n,r){super(t,i,n),this.track=void 0,this.allowed=!0,this.disabled=!1,this.currentVideoQuality=e.VideoQuality.HIGH,this.handleEnded=t=>{this.setTrack(void 0),this.emit(e.TrackEvent.Ended,t)},this.handleVisibilityChange=e=>{a.debug("adaptivestream video visibility ".concat(this.trackSid,", visible=").concat(e),{trackSid:this.trackSid}),this.disabled=!e,this.emitTrackUpdate()},this.handleVideoDimensionsChange=e=>{a.debug("adaptivestream video dimensions ".concat(e.width,"x").concat(e.height),{trackSid:this.trackSid}),this.videoDimensions=e,this.emitTrackUpdate()},this.subscribed=r}setSubscribed(t){const i=this.subscriptionStatus,n=this.permissionStatus;this.subscribed=t,t&&(this.allowed=!0);const r={trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[{participantSid:"",trackSids:[this.trackSid]}]};this.emit(e.TrackEvent.UpdateSubscription,r),this.emitSubscriptionUpdateIfChanged(i),this.emitPermissionUpdateIfChanged(n)}get subscriptionStatus(){return!1===this.subscribed?cs.SubscriptionStatus.Unsubscribed:super.isSubscribed?cs.SubscriptionStatus.Subscribed:cs.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?cs.PermissionStatus.Allowed:cs.PermissionStatus.NotAllowed}get isSubscribed(){return!1!==this.subscribed&&super.isSubscribed}get isDesired(){return!1!==this.subscribed}get isEnabled(){return!this.disabled}setEnabled(e){this.isManualOperationAllowed()&&this.disabled!==!e&&(this.disabled=!e,this.emitTrackUpdate())}setVideoQuality(e){this.isManualOperationAllowed()&&this.currentVideoQuality!==e&&(this.currentVideoQuality=e,this.videoDimensions=void 0,this.emitTrackUpdate())}setVideoDimensions(e){var t,i;this.isManualOperationAllowed()&&((null===(t=this.videoDimensions)||void 0===t?void 0:t.width)===e.width&&(null===(i=this.videoDimensions)||void 0===i?void 0:i.height)===e.height||(this.track instanceof as&&(this.videoDimensions=e),this.currentVideoQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&this.track instanceof as&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){return this.currentVideoQuality}setTrack(t){const i=this.subscriptionStatus,n=this.permissionStatus,r=this.track;r!==t&&(r&&(r.off(e.TrackEvent.VideoDimensionsChanged,this.handleVideoDimensionsChange),r.off(e.TrackEvent.VisibilityChanged,this.handleVisibilityChange),r.off(e.TrackEvent.Ended,this.handleEnded),r.detach(),this.emit(e.TrackEvent.Unsubscribed,r)),super.setTrack(t),t&&(t.sid=this.trackSid,t.on(e.TrackEvent.VideoDimensionsChanged,this.handleVideoDimensionsChange),t.on(e.TrackEvent.VisibilityChanged,this.handleVisibilityChange),t.on(e.TrackEvent.Ended,this.handleEnded),this.emit(e.TrackEvent.Subscribed,t)),this.emitPermissionUpdateIfChanged(n),this.emitSubscriptionUpdateIfChanged(i))}setAllowed(e){const t=this.subscriptionStatus,i=this.permissionStatus;this.allowed=e,this.emitPermissionUpdateIfChanged(i),this.emitSubscriptionUpdateIfChanged(t)}updateInfo(e){var t;super.updateInfo(e),this.metadataMuted=e.muted,null===(t=this.track)||void 0===t||t.setMuted(e.muted)}emitSubscriptionUpdateIfChanged(t){const i=this.subscriptionStatus;t!==i&&this.emit(e.TrackEvent.SubscriptionStatusChanged,i,t)}emitPermissionUpdateIfChanged(t){this.permissionStatus!==t&&this.emit(e.TrackEvent.SubscriptionPermissionChanged,this.permissionStatus,t)}isManualOperationAllowed(){return this.isAdaptiveStream?(a.warn("adaptive stream is enabled, cannot change track settings",{trackSid:this.trackSid}),!1):!!this.isDesired||(a.warn("cannot update track settings when not subscribed",{trackSid:this.trackSid}),!1)}get isAdaptiveStream(){return this.track instanceof as&&this.track.isAdaptiveStream}emitTrackUpdate(){const t=vn.fromPartial({trackSids:[this.trackSid],disabled:this.disabled,fps:this.fps});this.videoDimensions?(t.width=this.videoDimensions.width,t.height=this.videoDimensions.height):void 0!==this.currentVideoQuality?t.quality=this.currentVideoQuality:t.quality=e.VideoQuality.HIGH,this.emit(e.TrackEvent.UpdateSettings,t)}}class Is extends gs{static fromParticipantInfo(e,t){return new Is(e,t.sid,t.identity,t.name,t.metadata)}constructor(e,t,i,n,r){super(t,i||"",n,r),this.signalClient=e,this.tracks=new Map,this.audioTracks=new Map,this.videoTracks=new Map}addTrackPublication(t){super.addTrackPublication(t),t.on(e.TrackEvent.UpdateSettings,(e=>{a.debug("send update settings",e),this.signalClient.sendUpdateTrackSettings(e)})),t.on(e.TrackEvent.UpdateSubscription,(e=>{e.participantTracks.forEach((e=>{e.participantSid=this.sid})),this.signalClient.sendUpdateSubscription(e)})),t.on(e.TrackEvent.SubscriptionPermissionChanged,(i=>{this.emit(e.ParticipantEvent.TrackSubscriptionPermissionChanged,t,i)})),t.on(e.TrackEvent.SubscriptionStatusChanged,(i=>{this.emit(e.ParticipantEvent.TrackSubscriptionStatusChanged,t,i)})),t.on(e.TrackEvent.Subscribed,(i=>{this.emit(e.ParticipantEvent.TrackSubscribed,i,t)})),t.on(e.TrackEvent.Unsubscribed,(i=>{this.emit(e.ParticipantEvent.TrackUnsubscribed,i,t)}))}getTrack(e){const t=super.getTrack(e);if(t)return t}getTrackByName(e){const t=super.getTrackByName(e);if(t)return t}setVolume(e){this.volume=e;const t=this.getTrack(zr.Source.Microphone);t&&t.track&&t.track.setVolume(e)}getVolume(){const e=this.getTrack(zr.Source.Microphone);return e&&e.track?e.track.getVolume():this.volume}addSubscribedMediaTrack(t,i,n,r,s,o){let c=this.getTrackPublication(i);if(c||i.startsWith("TR")||this.tracks.forEach((e=>{c||t.kind!==e.kind.toString()||(c=e)})),!c)return 0===o?(a.error("could not find published track",{participant:this.sid,trackSid:i}),void this.emit(e.ParticipantEvent.TrackSubscriptionFailed,i)):(void 0===o&&(o=20),void setTimeout((()=>{this.addSubscribedMediaTrack(t,i,n,r,s,o-1)}),150));if("ended"===t.readyState)return a.error("unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()",{participant:this.sid,trackSid:i}),void this.emit(e.ParticipantEvent.TrackSubscriptionFailed,i);let d;return d="video"===t.kind?new as(t,i,r,s):new rs(t,i,r,this.audioContext,this.audioOutput),d.source=c.source,d.isMuted=c.isMuted,d.setMediaStream(n),d.start(),c.setTrack(d),void 0!==this.volume&&d instanceof rs&&d.source===zr.Source.Microphone&&d.setVolume(this.volume),c}get hasMetadata(){return!!this.participantInfo}getTrackPublication(e){return this.tracks.get(e)}updateInfo(t){super.updateInfo(t);const i=new Map,n=new Map;t.tracks.forEach((e=>{var r;let s=this.getTrackPublication(e.sid);if(s)s.updateInfo(e);else{const i=zr.kindFromProto(e.type);if(!i)return;s=new Ds(i,e.sid,e.name,null===(r=this.signalClient.connectOptions)||void 0===r?void 0:r.autoSubscribe),s.updateInfo(e),n.set(e.sid,s);const o=Array.from(this.tracks.values()).find((e=>e.source===(null==s?void 0:s.source)));o&&s.source!==zr.Source.Unknown&&a.warn("received a second track publication for ".concat(this.identity," with the same source: ").concat(s.source),{oldTrack:o,newTrack:s,participant:this,participantInfo:t}),this.addTrackPublication(s)}i.set(e.sid,s)})),this.tracks.forEach((e=>{i.has(e.trackSid)||(a.trace("detected removed track on remote participant, unpublishing",{publication:e,participantSid:this.sid}),this.unpublishTrack(e.trackSid,!0))})),n.forEach((t=>{this.emit(e.ParticipantEvent.TrackPublished,t)}))}unpublishTrack(t,i){const n=this.tracks.get(t);if(!n)return;switch(this.tracks.delete(t),n.kind){case zr.Kind.Audio:this.audioTracks.delete(t);break;case zr.Kind.Video:this.videoTracks.delete(t)}const{track:r}=n;r&&(r.stop(),n.setTrack(void 0)),i&&this.emit(e.ParticipantEvent.TrackUnpublished,n)}setAudioContext(e){this.audioContext=e,this.audioTracks.forEach((t=>t.track instanceof rs&&t.track.setAudioContext(e)))}async setAudioOutput(e){this.audioOutput=e;const t=[];this.audioTracks.forEach((i=>{var n;i.track instanceof rs&&t.push(i.track.setSinkId(null!==(n=e.deviceId)&&void 0!==n?n:"default"))})),await Promise.all(t)}emit(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return a.trace("participant event",{participant:this.sid,event:e,args:i}),super.emit(e,...i)}}class As extends gs{constructor(e,t,i,n){super(e,t),this.pendingPublishing=new Set,this.participantTrackPermissions=[],this.allParticipantsAllowedToSubscribe=!0,this.updateTrackSubscriptionPermissions=()=>{a.debug("updating track subscription permissions",{allParticipantsAllowed:this.allParticipantsAllowedToSubscribe,participantTrackPermissions:this.participantTrackPermissions}),this.engine.client.sendUpdateSubscriptionPermissions(this.allParticipantsAllowedToSubscribe,this.participantTrackPermissions.map((e=>function(e){var t,i,n;if(!e.participantSid&&!e.participantIdentity)throw new Error("Invalid track permission, must provide at least one of participantIdentity and participantSid");return{participantIdentity:null!==(t=e.participantIdentity)&&void 0!==t?t:"",participantSid:null!==(i=e.participantSid)&&void 0!==i?i:"",allTracks:null!==(n=e.allowAll)&&void 0!==n&&n,trackSids:e.allowedTrackSids||[]}}(e))))},this.onTrackUnmuted=e=>{this.onTrackMuted(e,e.isUpstreamPaused)},this.onTrackMuted=(e,t)=>{void 0===t&&(t=!0),e.sid?this.engine.updateMuteStatus(e.sid,t):a.error("could not update mute status for unpublished track",e)},this.onTrackUpstreamPaused=e=>{a.debug("upstream paused"),this.onTrackMuted(e,!0)},this.onTrackUpstreamResumed=e=>{a.debug("upstream resumed"),this.onTrackMuted(e,e.isMuted)},this.handleSubscribedQualityUpdate=async e=>{var t,i;if(!(null===(t=this.roomOptions)||void 0===t?void 0:t.dynacast))return;const n=this.videoTracks.get(e.trackSid);if(n)if(e.subscribedCodecs.length>0){if(!n.videoTrack)return;const t=await n.videoTrack.setPublishingCodecs(e.subscribedCodecs);var r,s=!1,o=!1;try{for(var c,d=Bt(t);s=!(c=await d.next()).done;s=!1){const e=c.value;hs(e)&&(a.debug("publish ".concat(e," for ").concat(n.videoTrack.sid)),await this.publishAdditionalCodecForTrack(n.videoTrack,e,n.options))}}catch(e){o=!0,r=e}finally{try{s&&null!=d.return&&await d.return()}finally{if(o)throw r}}}else e.subscribedQualities.length>0&&(null===(i=n.videoTrack)||void 0===i||i.setPublishingLayers(e.subscribedQualities));else a.warn("received subscribed quality update for unknown track",{method:"handleSubscribedQualityUpdate",sid:e.trackSid})},this.handleLocalTrackUnpublished=e=>{const t=this.tracks.get(e.trackSid);t?this.unpublishTrack(t.track):a.warn("received unpublished event for unknown track",{method:"handleLocalTrackUnpublished",trackSid:e.trackSid})},this.handleTrackEnded=async e=>{if(e.source===zr.Source.ScreenShare||e.source===zr.Source.ScreenShareAudio)a.debug("unpublishing local track due to TrackEnded",{track:e.sid}),this.unpublishTrack(e);else if(e.isUserProvided)await e.mute();else if(e instanceof Yr||e instanceof Xr)try{if(pr())try{const t=await(null===navigator||void 0===navigator?void 0:navigator.permissions.query({name:e.source===zr.Source.Camera?"camera":"microphone"}));if(t&&"denied"===t.state)throw a.warn("user has revoked access to ".concat(e.source)),t.onchange=()=>{"denied"!==t.state&&(e.restartTrack(),t.onchange=null)},new Error("GetUserMedia Permission denied")}catch(e){}a.debug("track ended, attempting to use a different device"),await e.restartTrack()}catch(t){a.warn("could not restart track, muting instead"),await e.mute()}},this.audioTracks=new Map,this.videoTracks=new Map,this.tracks=new Map,this.engine=i,this.roomOptions=n,this.setupEngine(i)}get lastCameraError(){return this.cameraError}get lastMicrophoneError(){return this.microphoneError}getTrack(e){const t=super.getTrack(e);if(t)return t}getTrackByName(e){const t=super.getTrackByName(e);if(t)return t}setupEngine(t){this.engine=t,this.engine.client.onRemoteMuteChanged=(e,t)=>{const i=this.tracks.get(e);i&&i.track&&(t?i.mute():i.unmute())},this.engine.client.onSubscribedQualityUpdate=this.handleSubscribedQualityUpdate,this.engine.client.onLocalTrackUnpublished=this.handleLocalTrackUnpublished,this.engine.on(e.EngineEvent.Connected,this.updateTrackSubscriptionPermissions).on(e.EngineEvent.Restarted,this.updateTrackSubscriptionPermissions).on(e.EngineEvent.Resumed,this.updateTrackSubscriptionPermissions)}setCameraEnabled(e,t,i){return this.setTrackEnabled(zr.Source.Camera,e,t,i)}setMicrophoneEnabled(e,t,i){return this.setTrackEnabled(zr.Source.Microphone,e,t,i)}setScreenShareEnabled(e,t,i){return this.setTrackEnabled(zr.Source.ScreenShare,e,t,i)}setPermissions(t){const i=this.permissions,n=super.setPermissions(t);return n&&i&&this.emit(e.ParticipantEvent.ParticipantPermissionsChanged,i),n}async setTrackEnabled(t,i,n,r){var s,o;a.debug("setTrackEnabled",{source:t,enabled:i});let c=this.getTrack(t);if(i)if(c)await c.unmute();else{let i;if(this.pendingPublishing.has(t))return void a.info("skipping duplicate published source",{source:t});this.pendingPublishing.add(t);try{switch(t){case zr.Source.Camera:i=await this.createTracks({video:null===(s=n)||void 0===s||s});break;case zr.Source.Microphone:i=await this.createTracks({audio:null===(o=n)||void 0===o||o});break;case zr.Source.ScreenShare:i=await this.createScreenTracks(Ft({},n));break;default:throw new qn(t)}const e=[];for(const t of i)a.info("publishing track",{localTrack:t}),e.push(this.publishTrack(t,r));const d=await Promise.all(e);[c]=d}catch(t){throw t instanceof Error&&!(t instanceof qn)&&this.emit(e.ParticipantEvent.MediaDevicesError,t),t}finally{this.pendingPublishing.delete(t)}}else if(c&&c.track)if(t===zr.Source.ScreenShare){c=await this.unpublishTrack(c.track);const e=this.getTrack(zr.Source.ScreenShareAudio);e&&e.track&&this.unpublishTrack(e.track)}else await c.mute();return c}async enableCameraAndMicrophone(){if(!this.pendingPublishing.has(zr.Source.Camera)&&!this.pendingPublishing.has(zr.Source.Microphone)){this.pendingPublishing.add(zr.Source.Camera),this.pendingPublishing.add(zr.Source.Microphone);try{const e=await this.createTracks({audio:!0,video:!0});await Promise.all(e.map((e=>this.publishTrack(e))))}finally{this.pendingPublishing.delete(zr.Source.Camera),this.pendingPublishing.delete(zr.Source.Microphone)}}}async createTracks(e){var t,i;const n=tr(Xn(e,null===(t=this.roomOptions)||void 0===t?void 0:t.audioCaptureDefaults,null===(i=this.roomOptions)||void 0===i?void 0:i.videoCaptureDefaults));let r;try{r=await navigator.mediaDevices.getUserMedia(n)}catch(e){throw e instanceof Error&&(n.audio&&(this.microphoneError=e),n.video&&(this.cameraError=e)),e}return n.audio&&(this.microphoneError=void 0),n.video&&(this.cameraError=void 0),r.getTracks().map((t=>{const i="audio"===t.kind;let s;i?e.audio:e.video;const a=i?n.audio:n.video;"boolean"!=typeof a&&(s=a);const o=bs(t,s);return o.kind===zr.Kind.Video?o.source=zr.Source.Camera:o.kind===zr.Kind.Audio&&(o.source=zr.Source.Microphone),o.mediaStream=r,o}))}async createScreenTracks(e){var t;void 0===e&&(e={}),void 0===e.resolution&&(e.resolution=fs.h1080fps15.resolution);let i=!0;e.resolution&&(i=lr()?{width:{max:e.resolution.width},height:{max:e.resolution.height},frameRate:e.resolution.frameRate}:{width:{ideal:e.resolution.width},height:{ideal:e.resolution.height},frameRate:e.resolution.frameRate});const n=await navigator.mediaDevices.getDisplayMedia({audio:null!==(t=e.audio)&&void 0!==t&&t,video:i}),r=n.getVideoTracks();if(0===r.length)throw new qn("no video track found");const s=new Xr(r[0],void 0,!1);s.source=zr.Source.ScreenShare;const a=[s];if(n.getAudioTracks().length>0){const e=new Yr(n.getAudioTracks()[0],void 0,!1);e.source=zr.Source.ScreenShareAudio,a.push(e)}return a}async publishTrack(t,i){var n,r,s,o,c;if(t instanceof MediaStreamTrack)switch(t.kind){case"audio":t=new Yr(t,void 0,!0);break;case"video":t=new Xr(t,void 0,!0);break;default:throw new qn("unsupported MediaStreamTrack kind ".concat(t.kind))}const d=(null==i?void 0:i.forceStereo)||"channelCount"in t.mediaStreamTrack.getSettings()&&2===t.mediaStreamTrack.getSettings().channelCount||2===t.mediaStreamTrack.getConstraints().channelCount;d&&(i||(i={}),void 0===i.dtx&&a.info("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work."),null!==(n=i.dtx)&&void 0!==n||(i.dtx=!1));const u=Ft(Ft({},this.roomOptions.publishDefaults),i);let l;if(this.tracks.forEach((e=>{e.track&&e.track===t&&(l=e)})),l)return l;u.source&&(t.source=u.source);const h=Array.from(this.tracks.values()).find((e=>t instanceof Kr&&e.source===t.source));if(h&&t.source!==zr.Source.Unknown)try{throw Error("publishing a second track with the same source: ".concat(t.source))}catch(e){e instanceof Error&&a.warn(e.message,{oldTrack:h,newTrack:t,trace:e.stack})}u.stopMicTrackOnMute&&t instanceof Yr&&(t.stopOnMute=!0),t.source===zr.Source.ScreenShare&&ur()&&(u.simulcast=!1),"av1"!==u.videoCodec||ar()||(u.videoCodec=void 0),t.on(e.TrackEvent.Muted,this.onTrackMuted),t.on(e.TrackEvent.Unmuted,this.onTrackUnmuted),t.on(e.TrackEvent.Ended,this.handleTrackEnded),t.on(e.TrackEvent.UpstreamPaused,this.onTrackUpstreamPaused),t.on(e.TrackEvent.UpstreamResumed,this.onTrackUpstreamResumed);const p=an.fromPartial({cid:t.mediaStreamTrack.id,name:null==i?void 0:i.name,type:zr.kindToProto(t.kind),muted:t.isMuted,source:zr.sourceToProto(t.source),disableDtx:!(null===(r=u.dtx)||void 0===r||r),stereo:d,disableRed:!(null===(s=u.red)||void 0===s||s)});let m,v;if(t.kind===zr.Kind.Video){let e={width:0,height:0};try{e=await t.waitForDimensions()}catch(e){a.error("could not determine track dimensions")}if(p.width=e.width,p.height=e.height,t instanceof Xr&&("av1"===(null==u?void 0:u.videoCodec)&&(u.scalabilityMode=null!==(o=u.scalabilityMode)&&void 0!==o?o:"L3T3"),u.videoCodec&&u.backupCodec&&u.videoCodec!==u.backupCodec.codec)){const e=Ft({},u);e.simulcast=!0,v=Ps(t,u.backupCodec.codec,e),p.simulcastCodecs=[{codec:u.videoCodec,cid:t.mediaStreamTrack.id,enableSimulcastLayers:!0},{codec:u.backupCodec.codec,cid:"",enableSimulcastLayers:!0}]}m=Es(t.source===zr.Source.ScreenShare,e.width,e.height,u),p.layers=is(p.width,p.height,null!=v?v:m)}else t.kind===zr.Kind.Audio&&u.audioBitrate&&(m=[{maxBitrate:u.audioBitrate}]);if(!this.engine||this.engine.isClosed)throw new Gn("cannot publish track when not connected");const f=await this.engine.addTrack(p),g=new ds(t.kind,f,t);if(g.options=u,t.sid=f.sid,!this.engine.publisher)throw new Gn("publisher is closed");return a.debug("publishing ".concat(t.kind," with encodings"),{encodings:m,trackInfo:f}),t.sender=await this.engine.createSender(t,u,m),"av1"===t.codec&&m&&(null===(c=m[0])||void 0===c?void 0:c.maxBitrate)&&this.engine.publisher.setTrackCodecBitrate(p.cid,t.codec,m[0].maxBitrate/1e3),this.engine.negotiate(),t instanceof Xr?t.startMonitor(this.engine.client):t instanceof Yr&&t.startMonitor(),this.addTrackPublication(g),this.emit(e.ParticipantEvent.LocalTrackPublished,g),g}get isLocal(){return!0}async publishAdditionalCodecForTrack(e,t,i){var n;let r;if(this.tracks.forEach((t=>{t.track&&t.track===e&&(r=t)})),!r)throw new qn("track is not published");if(!(e instanceof Xr))throw new qn("track is not a video track");const s=Ft(Ft({},null===(n=this.roomOptions)||void 0===n?void 0:n.publishDefaults),i),o=Ps(e,t,s);if(!o)return void a.info("backup codec has been disabled, ignoring request to add additional codec for track");const c=e.addSimulcastTrack(t,o),d=an.fromPartial({cid:c.mediaStreamTrack.id,type:zr.kindToProto(e.kind),muted:e.isMuted,source:zr.sourceToProto(e.source),sid:e.sid,simulcastCodecs:[{codec:s.videoCodec,cid:c.mediaStreamTrack.id,enableSimulcastLayers:s.simulcast}]});if(d.layers=is(d.width,d.height,o),!this.engine||this.engine.isClosed)throw new Gn("cannot publish track when not connected");const u=await this.engine.addTrack(d);await this.engine.createSimulcastSender(e,c,s,o),this.engine.negotiate(),a.debug("published ".concat(t," for track ").concat(e.sid),{encodings:o,trackInfo:u})}async unpublishTrack(t,i){var n,r;const s=this.getPublicationForTrack(t);if(a.debug("unpublishing track",{track:t,method:"unpublishTrack"}),s&&s.track){if((t=s.track).off(e.TrackEvent.Muted,this.onTrackMuted),t.off(e.TrackEvent.Unmuted,this.onTrackUnmuted),t.off(e.TrackEvent.Ended,this.handleTrackEnded),t.off(e.TrackEvent.UpstreamPaused,this.onTrackUpstreamPaused),t.off(e.TrackEvent.UpstreamResumed,this.onTrackUpstreamResumed),void 0===i&&(i=null===(r=null===(n=this.roomOptions)||void 0===n?void 0:n.stopLocalTrackOnUnpublish)||void 0===r||r),i&&t.stop(),this.engine.publisher&&"closed"!==this.engine.publisher.pc.connectionState&&t.sender)try{if(this.engine.removeTrack(t.sender),t instanceof Xr){for(const[,e]of t.simulcastCodecs)e.sender&&(this.engine.removeTrack(e.sender),e.sender=void 0);t.simulcastCodecs.clear()}}catch(e){a.warn("failed to unpublish track",{error:e,method:"unpublishTrack"})}finally{await this.engine.negotiate()}switch(t.sender=void 0,this.tracks.delete(s.trackSid),s.kind){case zr.Kind.Audio:this.audioTracks.delete(s.trackSid);break;case zr.Kind.Video:this.videoTracks.delete(s.trackSid)}return this.emit(e.ParticipantEvent.LocalTrackUnpublished,s),s.setTrack(void 0),s}a.warn("track was not unpublished because no publication was found",{track:t,method:"unpublishTrack"})}async unpublishTracks(e){return(await Promise.all(e.map((e=>this.unpublishTrack(e))))).filter((e=>e instanceof ds))}async republishAllTracks(e){const t=[];this.tracks.forEach((i=>{i.track&&(e&&(i.options=Ft(Ft({},i.options),e)),t.push(i))})),await Promise.all(t.map((async e=>{const t=e.track;await this.unpublishTrack(t,!1),await this.publishTrack(t,e.options)})))}async publishData(e,t,i){const n=[];void 0!==i&&i.forEach((e=>{e instanceof Is?n.push(e.sid):n.push(e)}));const r={kind:t,value:{$case:"user",user:{participantSid:this.sid,payload:e,destinationSids:n}}};await this.engine.sendDataPacket(r,t)}setTrackSubscriptionPermissions(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];this.participantTrackPermissions=t,this.allParticipantsAllowedToSubscribe=e,this.engine.client.isConnected&&this.updateTrackSubscriptionPermissions()}updateInfo(e){super.updateInfo(e),e.tracks.forEach((e=>{var t,i;const n=this.tracks.get(e.sid);if(n){const r=n.isMuted||null!==(i=null===(t=n.track)||void 0===t?void 0:t.isUpstreamPaused)&&void 0!==i&&i;r!==e.muted&&(a.debug("updating server mute state after reconcile",{sid:e.sid,muted:r}),this.engine.client.sendMuteTrack(e.sid,r))}}))}getPublicationForTrack(e){let t;return this.tracks.forEach((i=>{const n=i.track;n&&(e instanceof MediaStreamTrack?(n instanceof Yr||n instanceof Xr)&&n.mediaStreamTrack===e&&(t=i):e===n&&(t=i))})),t}publishedTracksInfo(){const e=[];return this.tracks.forEach((t=>{void 0!==t.track&&e.push({cid:t.track.mediaStreamID,track:t.trackInfo})})),e}dataChannelsInfo(){const t=[],i=(e,i)=>{void 0!==(null==e?void 0:e.id)&&null!==e.id&&t.push({label:e.label,id:e.id,target:i})};return i(this.engine.dataChannelForKind(e.DataPacket_Kind.LOSSY),zi.PUBLISHER),i(this.engine.dataChannelForKind(e.DataPacket_Kind.RELIABLE),zi.PUBLISHER),i(this.engine.dataChannelForKind(e.DataPacket_Kind.LOSSY,!0),zi.SUBSCRIBER),i(this.engine.dataChannelForKind(e.DataPacket_Kind.RELIABLE,!0),zi.SUBSCRIBER),t}}const Us=["syncState","trickle","offer","answer","simulate","leave"];class Ls{constructor(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isConnected=!1,this.isReconnecting=!1,this.useJSON=e,this.requestQueue=new Rr,this.queuedRequests=[],this.closingLock=new Pr}async join(e,t,i,n){this.isConnected=!1,this.options=i;return await this.connect(e,t,i,n)}async reconnect(e,t,i){this.options?(this.isReconnecting=!0,this.clearPingInterval(),await this.connect(e,t,Ft(Ft({},this.options),{},{reconnect:!0,sid:i}))):a.warn("attempted to reconnect without signal options being set, ignoring")}connect(e,t,i,n){this.connectOptions=i,e.startsWith("http")&&(e=e.replace("http","ws")),e=e.replace(/\/$/,""),e+="/rtc";const r=function(e,t,i){var n;const r=new URLSearchParams;r.set("access_token",e),i.reconnect&&(r.set("reconnect","1"),i.sid&&r.set("sid",i.sid));r.set("auto_subscribe",i.autoSubscribe?"1":"0"),r.set("sdk","js"),r.set("version",t.version),r.set("protocol",t.protocol.toString()),t.deviceModel&&r.set("device_model",t.deviceModel);t.os&&r.set("os",t.os);t.osVersion&&r.set("os_version",t.osVersion);t.browser&&r.set("browser",t.browser);t.browserVersion&&r.set("browser_version",t.browserVersion);void 0!==i.publishOnly&&r.set("publish",i.publishOnly);i.adaptiveStream&&r.set("adaptive_stream","1");(null===(n=navigator.connection)||void 0===n?void 0:n.type)&&r.set("network",navigator.connection.type);return"?".concat(r.toString())}(t,Nt.fromPartial({sdk:Ye.JS,protocol:8,version:Yn}),i);return new Promise((async(t,s)=>{const o=async()=>{await this.close(),s(new Fn("room connection has been cancelled"))};(null==n?void 0:n.aborted)&&o(),null==n||n.addEventListener("abort",o),a.debug("connecting to ".concat(e+r)),this.ws&&await this.close(),this.ws=new WebSocket(e+r),this.ws.binaryType="arraybuffer",this.ws.onerror=async t=>{if(this.isConnected)this.handleWSError(t);else try{const t=await fetch("http".concat(e.substring(2),"/validate").concat(r));if(t.ok)s(new Fn("Internal error",2,t.status));else{const e=await t.text();s(new Fn(e,0,t.status))}}catch(e){s(new Fn("server was not reachable",1))}},this.ws.onopen=()=>{i.reconnect&&(this.isConnected=!0,this.startPingInterval(),t())},this.ws.onmessage=async e=>{var i,r;let c;if("string"==typeof e.data){const t=JSON.parse(e.data);c=rn.fromJSON(t)}else{if(!(e.data instanceof ArrayBuffer))return void a.error("could not decode websocket message: ".concat(typeof e.data));c=rn.decode(new Uint8Array(e.data))}this.isConnected?(this.signalLatency&&await nr(this.signalLatency),this.handleSignalResponse(c)):"join"===(null===(i=c.message)||void 0===i?void 0:i.$case)?(this.isConnected=!0,null==n||n.removeEventListener("abort",o),this.pingTimeoutDuration=c.message.join.pingTimeout,this.pingIntervalDuration=c.message.join.pingInterval,this.pingTimeoutDuration&&this.pingTimeoutDuration>0&&(a.debug("ping config",{timeout:this.pingTimeoutDuration,interval:this.pingIntervalDuration}),this.startPingInterval()),t(c.message.join)):s(new Fn("did not receive join response, got ".concat(null===(r=c.message)||void 0===r?void 0:r.$case," instead")))},this.ws.onclose=e=>{this.isConnected&&(a.debug("websocket connection closed: ".concat(e.reason)),this.isConnected=!1,this.onClose&&this.onClose(e.reason),this.ws=void 0)}}))}async close(){const e=await this.closingLock.lock();try{if(this.isConnected=!1,this.ws){this.ws.onclose=null,this.ws.onmessage=null,this.ws.onopen=null;const e=new Promise((e=>{this.ws?this.ws.onclose=e:e(!0)}));this.ws.close(),await Promise.race([e,nr(250)])}this.ws=void 0,this.clearPingInterval()}finally{e()}}sendOffer(e){a.debug("sending offer",e),this.sendRequest({$case:"offer",offer:Ms(e)})}sendAnswer(e){a.debug("sending answer"),this.sendRequest({$case:"answer",answer:Ms(e)})}sendIceCandidate(e,t){a.trace("sending ice candidate",e),this.sendRequest({$case:"trickle",trickle:{candidateInit:JSON.stringify(e),target:t}})}sendMuteTrack(e,t){this.sendRequest({$case:"mute",mute:{sid:e,muted:t}})}sendAddTrack(e){this.sendRequest({$case:"addTrack",addTrack:an.fromPartial(e)})}sendUpdateTrackSettings(e){this.sendRequest({$case:"trackSetting",trackSetting:e})}sendUpdateSubscription(e){this.sendRequest({$case:"subscription",subscription:e})}sendSyncState(e){this.sendRequest({$case:"syncState",syncState:e})}sendUpdateVideoLayers(e,t){this.sendRequest({$case:"updateLayers",updateLayers:{trackSid:e,layers:t}})}sendUpdateSubscriptionPermissions(e,t){this.sendRequest({$case:"subscriptionPermission",subscriptionPermission:{allParticipants:e,trackPermissions:t}})}sendSimulateScenario(e){this.sendRequest({$case:"simulate",simulate:e})}sendPing(){this.sendRequest({$case:"ping",ping:Date.now()})}async sendLeave(){await this.sendRequest({$case:"leave",leave:{canReconnect:!1,reason:e.DisconnectReason.CLIENT_INITIATED}})}async sendRequest(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=!t&&!function(e){const t=Us.includes(e.$case);return a.trace("request allowed to bypass queue:",{canPass:t,req:e}),t}(e);if(i&&this.isReconnecting)return void this.queuedRequests.push((async()=>{await this.sendRequest(e,!0)}));if(t||await this.requestQueue.flush(),this.signalLatency&&await nr(this.signalLatency),!this.ws||this.ws.readyState!==this.ws.OPEN)return void a.error("cannot send signal request before connected, type: ".concat(null==e?void 0:e.$case));const n={message:e};try{this.useJSON?this.ws.send(JSON.stringify(nn.toJSON(n))):this.ws.send(nn.encode(n).finish())}catch(e){a.error("error sending signal message",{error:e})}}handleSignalResponse(e){var t,i;const n=e.message;if("answer"===n.$case){const e=xs(n.answer);this.onAnswer&&this.onAnswer(e)}else if("offer"===n.$case){const e=xs(n.offer);this.onOffer&&this.onOffer(e)}else if("trickle"===n.$case){const e=JSON.parse(n.trickle.candidateInit);this.onTrickle&&this.onTrickle(e,n.trickle.target)}else"update"===n.$case?this.onParticipantUpdate&&this.onParticipantUpdate(null!==(t=n.update.participants)&&void 0!==t?t:[]):"trackPublished"===n.$case?this.onLocalTrackPublished&&this.onLocalTrackPublished(n.trackPublished):"speakersChanged"===n.$case?this.onSpeakersChanged&&this.onSpeakersChanged(null!==(i=n.speakersChanged.speakers)&&void 0!==i?i:[]):"leave"===n.$case?this.onLeave&&this.onLeave(n.leave):"mute"===n.$case?this.onRemoteMuteChanged&&this.onRemoteMuteChanged(n.mute.sid,n.mute.muted):"roomUpdate"===n.$case?this.onRoomUpdate&&n.roomUpdate.room&&this.onRoomUpdate(n.roomUpdate.room):"connectionQuality"===n.$case?this.onConnectionQuality&&this.onConnectionQuality(n.connectionQuality):"streamStateUpdate"===n.$case?this.onStreamStateUpdate&&this.onStreamStateUpdate(n.streamStateUpdate):"subscribedQualityUpdate"===n.$case?this.onSubscribedQualityUpdate&&this.onSubscribedQualityUpdate(n.subscribedQualityUpdate):"subscriptionPermissionUpdate"===n.$case?this.onSubscriptionPermissionUpdate&&this.onSubscriptionPermissionUpdate(n.subscriptionPermissionUpdate):"refreshToken"===n.$case?this.onTokenRefresh&&this.onTokenRefresh(n.refreshToken):"trackUnpublished"===n.$case?this.onLocalTrackUnpublished&&this.onLocalTrackUnpublished(n.trackUnpublished):"pong"===n.$case?this.resetPingTimeout():a.debug("unsupported message",n)}setReconnected(){for(;this.queuedRequests.length>0;){const e=this.queuedRequests.shift();e&&this.requestQueue.run(e)}this.isReconnecting=!1}handleWSError(e){a.error("websocket error",e)}resetPingTimeout(){this.clearPingTimeout(),this.pingTimeoutDuration?this.pingTimeout=setTimeout((()=>{a.warn("ping timeout triggered. last pong received at: ".concat(new Date(Date.now()-1e3*this.pingTimeoutDuration).toUTCString())),this.onClose&&this.onClose("ping timeout")}),1e3*this.pingTimeoutDuration):a.warn("ping timeout duration not set")}clearPingTimeout(){this.pingTimeout&&clearTimeout(this.pingTimeout)}startPingInterval(){this.clearPingInterval(),this.resetPingTimeout(),this.pingIntervalDuration?(a.debug("start ping interval"),this.pingInterval=setInterval((()=>{this.sendPing()}),1e3*this.pingIntervalDuration)):a.warn("ping interval duration not set")}clearPingInterval(){a.debug("clearing ping interval"),this.clearPingTimeout(),this.pingInterval&&clearInterval(this.pingInterval)}}function xs(e){const t={type:"offer",sdp:e.sdp};switch(e.type){case"answer":case"offer":case"pranswer":case"rollback":t.type=e.type}return t}function Ms(e){return{sdp:e.sdp,type:e.type}}const _s={audioBitrate:e.AudioPresets.music.maxBitrate,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:fs.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:"vp8",backupCodec:{codec:"vp8",encoding:ms.h540.encoding}},Js={autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0},$s={resolution:ms.h720.resolution},Bs={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new $t,expWebAudioMix:!1},js={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3};var Vs={},Fs={},qs={get exports(){return Fs},set exports(e){Fs=e}}.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(qs).forEach((function(e){qs[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},i=function(e,i,n){var r=e.name&&e.names;e.push&&!i[e.push]?i[e.push]=[]:r&&!i[e.name]&&(i[e.name]={});var s=e.push?{}:r?i[e.name]:i;!function(e,i,n,r){if(r&&!n)i[r]=t(e[1]);else for(var s=0;s<n.length;s+=1)null!=e[s+1]&&(i[n[s]]=t(e[s+1]))}(n.match(e.reg),s,e.names,e.name),e.push&&i[e.push].push(s)},n=Fs,r=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},s=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(r).forEach((function(e){var t=e[0],r=e.slice(2);"m"===t&&(s.push({rtp:[],fmtp:[]}),a=s[s.length-1]);for(var o=0;o<(n[t]||[]).length;o+=1){var c=n[t][o];if(c.reg.test(r))return i(c,a,r)}})),t.media=s,t};var s=function(e,i){var n=i.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&i.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 i=[],n=e.split(" ").map(t),r=0;r<n.length;r+=3)i.push({component:n[r],ip:n[r+1],port:n[r+2]});return i},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 i,n=!1;return"~"!==e[0]?i=t(e):(i=t(e.substring(1,e.length)),n=!0),{scid:i,paused:n}}))}))}}(Vs);var Ws=Fs,Gs=/%[sdv%]/g,Qs=function(e){var t=1,i=arguments,n=i.length;return e.replace(Gs,(function(e){if(t>=n)return e;var r=i[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},zs=function(e,t,i){var n=[e+"="+(t.format instanceof Function?t.format(t.push?i:i[t.name]):t.format)];if(t.names)for(var r=0;r<t.names.length;r+=1){var s=t.names[r];t.name?n.push(i[t.name][s]):n.push(i[t.names[r]])}else n.push(i[t.name]);return Qs.apply(null,n)},Hs=["v","o","s","i","u","e","p","c","b","t","r","z","a"],Zs=["i","c","b","a"],Ks=Vs,Ys=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 i=t.outerOrder||Hs,n=t.innerOrder||Zs,r=[];return i.forEach((function(t){Ws[t].forEach((function(i){i.name in e&&null!=e[i.name]?r.push(zs(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){r.push(zs(t,i,e))}))}))})),e.media.forEach((function(e){r.push(zs("m",Ws.m[0],e)),n.forEach((function(t){Ws[t].forEach((function(i){i.name in e&&null!=e[i.name]?r.push(zs(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){r.push(zs(t,i,e))}))}))}))})),r.join("\r\n")+"\r\n"},Xs=Ys,ea=Ks.parse;const ta="negotiationStarted",ia="negotiationComplete";class na extends Ir{constructor(e){super(),this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate=!1,this.trackBitrates=[],this.remoteStereoMids=[],this.negotiate=ss((e=>{this.emit(ta);try{this.createAndSendOffer()}catch(t){if(!e)throw t;e(t)}}),100),this.pc=new RTCPeerConnection(e)}get isICEConnected(){return"connected"===this.pc.iceConnectionState||"completed"===this.pc.iceConnectionState}async addIceCandidate(e){if(this.pc.remoteDescription&&!this.restartingIce)return this.pc.addIceCandidate(e);this.pendingCandidates.push(e)}async setRemoteDescription(e){"offer"===e.type&&(this.remoteStereoMids=function(e){var t;const i=[],n=ea(null!==(t=e.sdp)&&void 0!==t?t:"");let r=0;return n.media.forEach((e=>{"audio"===e.type&&(e.rtp.some((e=>"opus"===e.codec&&(r=e.payload,!0))),e.fmtp.some((t=>t.payload===r&&(t.config.includes("sprop-stereo=1")&&i.push(e.mid),!0))))})),i}(e)),await this.pc.setRemoteDescription(e),this.pendingCandidates.forEach((e=>{this.pc.addIceCandidate(e)})),this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate?(this.renegotiate=!1,this.createAndSendOffer()):"answer"===e.type&&this.emit(ia)}async createAndSendOffer(e){var t;if(void 0===this.onOffer)return;if((null==e?void 0:e.iceRestart)&&(a.debug("restarting ICE"),this.restartingIce=!0),"have-local-offer"===this.pc.signalingState){const t=this.pc.remoteDescription;if(!(null==e?void 0:e.iceRestart)||!t)return void(this.renegotiate=!0);await this.pc.setRemoteDescription(t)}else if("closed"===this.pc.signalingState)return void a.warn("could not createOffer with closed peer connection");a.debug("starting to negotiate");const i=await this.pc.createOffer(e),n=ea(null!==(t=i.sdp)&&void 0!==t?t:"");n.media.forEach((e=>{"audio"===e.type?ra(e,[]):"video"===e.type&&this.trackBitrates.some((t=>{if(!e.msid||!e.msid.includes(t.sid))return!1;let i=0;return e.rtp.some((e=>e.codec.toUpperCase()===t.codec.toUpperCase()&&(i=e.payload,!0))),i>0&&(e.fmtp.some((e=>e.payload===i&&(e.config.includes("x-google-max-bitrate")||(e.config+=";x-google-max-bitrate=".concat(t.maxbr)),!0)))||e.fmtp.push({payload:i,config:"x-google-max-bitrate=".concat(t.maxbr)})),!0}))})),this.trackBitrates=[],await this.setMungedLocalDescription(i,Xs(n)),this.onOffer(i)}async createAndSetAnswer(){var e;const t=await this.pc.createAnswer(),i=ea(null!==(e=t.sdp)&&void 0!==e?e:"");return i.media.forEach((e=>{"audio"===e.type&&ra(e,this.remoteStereoMids)})),await this.setMungedLocalDescription(t,Xs(i)),t}setTrackCodecBitrate(e,t,i){this.trackBitrates.push({sid:e,codec:t,maxbr:i})}close(){this.pc.close()}async setMungedLocalDescription(e,t){const i=e.sdp;e.sdp=t;try{return a.debug("setting munged local description"),void await this.pc.setLocalDescription(e)}catch(t){a.warn("not able to set ".concat(e.type,", falling back to unmodified sdp"),{error:t}),e.sdp=i}try{await this.pc.setLocalDescription(e)}catch(e){let t="unknown error";throw e instanceof Error?t=e.message:"string"==typeof e&&(t=e),new Qn(t)}}}function ra(e,t){let i=0;e.rtp.some((e=>"opus"===e.codec&&(i=e.payload,!0))),i>0&&(e.rtcpFb||(e.rtcpFb=[]),e.rtcpFb.some((e=>e.payload===i&&"nack"===e.type))||e.rtcpFb.push({payload:i,type:"nack"}),t.includes(e.mid)&&e.fmtp.some((e=>e.payload===i&&(e.config.includes("stereo=1")||(e.config+=";stereo=1"),!0))))}const sa="_lossy",aa="_reliable",oa="leave-reconnect";var ca,da;!function(e){e[e.New=0]="New",e[e.Connected=1]="Connected",e[e.Disconnected=2]="Disconnected",e[e.Reconnecting=3]="Reconnecting",e[e.Closed=4]="Closed"}(ca||(ca={}));class ua extends Ir.EventEmitter{get isClosed(){return this._isClosed}constructor(t){var i;super(),i=this,this.options=t,this.rtcConfig={},this.peerConnectionTimeout=js.peerConnectionTimeout,this.subscriberPrimary=!1,this.pcState=ca.New,this._isClosed=!0,this.pendingTrackResolvers={},this.hasPublished=!1,this.reconnectAttempts=0,this.reconnectStart=0,this.fullReconnectOnNext=!1,this.attemptingReconnect=!1,this.joinAttempts=0,this.maxJoinAttempts=1,this.handleDataChannel=async e=>{let{channel:t}=e;if(t){if(t.label===aa)this.reliableDCSub=t;else{if(t.label!==sa)return;this.lossyDCSub=t}a.debug("on data channel ".concat(t.id,", ").concat(t.label)),t.onmessage=this.handleDataMessage}},this.handleDataMessage=async t=>{var i,n;let r;if(t.data instanceof ArrayBuffer)r=t.data;else{if(!(t.data instanceof Blob))return void a.error("unsupported data type",t.data);r=await t.data.arrayBuffer()}const s=wt.decode(new Uint8Array(r));"speaker"===(null===(i=s.value)||void 0===i?void 0:i.$case)?this.emit(e.EngineEvent.ActiveSpeakersUpdate,s.value.speaker.speakers):"user"===(null===(n=s.value)||void 0===n?void 0:n.$case)&&this.emit(e.EngineEvent.DataPacketReceived,s.value.user,s.kind)},this.handleDataError=e=>{const t=0===e.currentTarget.maxRetransmits?"lossy":"reliable";if(e instanceof ErrorEvent){const{error:i}=e.error;a.error("DataChannel error on ".concat(t,": ").concat(e.message),i)}else a.error("Unknown DataChannel Error on ".concat(t),e)},this.handleDisconnect=function(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(i._isClosed)return;a.debug("".concat(t," disconnected")),0===i.reconnectAttempts&&(i.reconnectStart=Date.now());const r=t=>{a.info("could not recover connection after ".concat(i.reconnectAttempts," attempts, ").concat(t,"ms. giving up")),i.emit(e.EngineEvent.Disconnected),i.close()},s=Date.now()-i.reconnectStart;let o=i.getNextRetryDelay({elapsedMs:s,retryCount:i.reconnectAttempts});null!==o?(t===oa&&(o=0),a.debug("reconnecting in ".concat(o,"ms")),i.reconnectTimeout&&clearTimeout(i.reconnectTimeout),i.reconnectTimeout=setTimeout((()=>i.attemptReconnect(n)),o)):r(s)},this.handleBrowserOnLine=()=>{this.client.isReconnecting&&(this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.attemptReconnect(!0))},this.client=new Ls,this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.registerOnLineListener(),this.closingLock=new Pr}async join(e,t,i,n){this.url=e,this.token=t,this.signalOpts=i;try{this.joinAttempts+=1;const r=await this.client.join(e,t,i,n);return this._isClosed=!1,this.subscriberPrimary=r.subscriberPrimary,this.publisher||this.configure(r),this.subscriberPrimary||this.negotiate(),this.clientConfiguration=r.clientConfiguration,r}catch(r){if(r instanceof Fn&&1===r.reason&&(a.warn("Couldn't connect to server, attempt ".concat(this.joinAttempts," of ").concat(this.maxJoinAttempts)),this.joinAttempts<this.maxJoinAttempts))return this.join(e,t,i,n);throw r}}async close(){const t=await this.closingLock.lock();if(this.isClosed)t();else try{this._isClosed=!0,this.emit(e.EngineEvent.Closing),this.removeAllListeners(),this.deregisterOnLineListener(),this.clearPendingReconnect(),this.publisher&&"closed"!==this.publisher.pc.signalingState&&(this.publisher.pc.getSenders().forEach((e=>{var t,i;try{(null===(t=this.publisher)||void 0===t?void 0:t.pc.removeTrack)&&(null===(i=this.publisher)||void 0===i||i.pc.removeTrack(e))}catch(e){a.warn("could not removeTrack",{error:e})}})),this.publisher.close(),this.publisher=void 0),this.subscriber&&(this.subscriber.close(),this.subscriber=void 0),await this.client.close()}finally{t()}}addTrack(e){if(this.pendingTrackResolvers[e.cid])throw new qn("a track with the same ID has already been published");return new Promise(((t,i)=>{const n=setTimeout((()=>{delete this.pendingTrackResolvers[e.cid],i(new Fn("publication of local track timed out, no response from server"))}),1e4);this.pendingTrackResolvers[e.cid]={resolve:e=>{clearTimeout(n),t(e)},reject:()=>{clearTimeout(n),i(new Error("Cancelled publication by calling unpublish"))}},this.client.sendAddTrack(e)}))}removeTrack(e){var t;if(e.track&&this.pendingTrackResolvers[e.track.id]){const{reject:t}=this.pendingTrackResolvers[e.track.id];t&&t(),delete this.pendingTrackResolvers[e.track.id]}try{null===(t=this.publisher)||void 0===t||t.pc.removeTrack(e)}catch(e){a.warn("failed to remove track",{error:e,method:"removeTrack"})}}updateMuteStatus(e,t){this.client.sendMuteTrack(e,t)}get dataSubscriberReadyState(){var e;return null===(e=this.reliableDCSub)||void 0===e?void 0:e.readyState}get connectedServerAddress(){return this.connectedServerAddr}configure(t){var i;if(this.publisher||this.subscriber)return;this.participantSid=null===(i=t.participant)||void 0===i?void 0:i.sid;const n=Ft({},this.rtcConfig);if(t.iceServers&&!n.iceServers){const e=[];t.iceServers.forEach((t=>{const i={urls:t.urls};t.username&&(i.username=t.username),t.credential&&(i.credential=t.credential),e.push(i)})),n.iceServers=e}t.clientConfiguration&&t.clientConfiguration.forceRelay===Qe.ENABLED&&(n.iceTransportPolicy="relay"),n.sdpSemantics="unified-plan",n.continualGatheringPolicy="gather_continually",this.publisher=new na(n),this.subscriber=new na(n),this.emit(e.EngineEvent.TransportsCreated,this.publisher,this.subscriber),this.publisher.pc.onicecandidate=e=>{e.candidate&&(a.trace("adding ICE candidate for peer",e.candidate),this.client.sendIceCandidate(e.candidate,zi.PUBLISHER))},this.subscriber.pc.onicecandidate=e=>{e.candidate&&this.client.sendIceCandidate(e.candidate,zi.SUBSCRIBER)},this.publisher.onOffer=e=>{this.client.sendOffer(e)};let r=this.publisher.pc,s=this.subscriber.pc;t.subscriberPrimary&&(r=this.subscriber.pc,s=this.publisher.pc,this.subscriber.pc.ondatachannel=this.handleDataChannel),this.primaryPC=r,r.onconnectionstatechange=async()=>{if(a.debug("primary PC state changed ".concat(r.connectionState)),"connected"===r.connectionState){try{this.connectedServerAddr=await la(r)}catch(e){a.warn("could not get connected server address",{error:e})}const i=this.pcState===ca.New;this.pcState=ca.Connected,i&&this.emit(e.EngineEvent.Connected,t)}else"failed"===r.connectionState&&this.pcState===ca.Connected&&(this.pcState=ca.Disconnected,this.handleDisconnect("primary peerconnection"))},s.onconnectionstatechange=async()=>{a.debug("secondary PC state changed ".concat(s.connectionState)),"failed"===s.connectionState&&this.handleDisconnect("secondary peerconnection")},this.subscriber.pc.ontrack=t=>{this.emit(e.EngineEvent.MediaTrackAdded,t.track,t.streams[0],t.receiver)},this.createDataChannels(),this.client.onAnswer=async e=>{this.publisher&&(a.debug("received server answer",{RTCSdpType:e.type,signalingState:this.publisher.pc.signalingState}),await this.publisher.setRemoteDescription(e))},this.client.onTrickle=(e,t)=>{this.publisher&&this.subscriber&&(a.trace("got ICE candidate from peer",{candidate:e,target:t}),t===zi.PUBLISHER?this.publisher.addIceCandidate(e):this.subscriber.addIceCandidate(e))},this.client.onOffer=async e=>{if(!this.subscriber)return;a.debug("received server offer",{RTCSdpType:e.type,signalingState:this.subscriber.pc.signalingState}),await this.subscriber.setRemoteDescription(e);const t=await this.subscriber.createAndSetAnswer();this.client.sendAnswer(t)},this.client.onLocalTrackPublished=e=>{a.debug("received trackPublishedResponse",e);const{resolve:t}=this.pendingTrackResolvers[e.cid];t?(delete this.pendingTrackResolvers[e.cid],t(e.track)):a.error("missing track resolver for ".concat(e.cid))},this.client.onTokenRefresh=e=>{this.token=e},this.client.onClose=()=>{this.handleDisconnect("signal")},this.client.onLeave=t=>{(null==t?void 0:t.canReconnect)?(this.fullReconnectOnNext=!0,this.primaryPC=void 0,this.handleDisconnect(oa)):(this.emit(e.EngineEvent.Disconnected,null==t?void 0:t.reason),this.close()),a.trace("leave request",{leave:t})}}createDataChannels(){this.publisher&&(this.lossyDC&&(this.lossyDC.onmessage=null,this.lossyDC.onerror=null),this.reliableDC&&(this.reliableDC.onmessage=null,this.reliableDC.onerror=null),this.lossyDC=this.publisher.pc.createDataChannel(sa,{ordered:!0,maxRetransmits:0}),this.reliableDC=this.publisher.pc.createDataChannel(aa,{ordered:!0}),this.lossyDC.onmessage=this.handleDataMessage,this.reliableDC.onmessage=this.handleDataMessage,this.lossyDC.onerror=this.handleDataError,this.reliableDC.onerror=this.handleDataError)}setPreferredCodec(e,t,i){if(!("getCapabilities"in RTCRtpSender))return;const n=RTCRtpSender.getCapabilities(t);if(!n)return;a.debug("get capabilities",n);const r=[],s=[],o=[];n.codecs.forEach((e=>{const t=e.mimeType.toLowerCase();if("audio/opus"===t)return void r.push(e);t==="video/".concat(i)?"h264"!==i||e.sdpFmtpLine&&e.sdpFmtpLine.includes("profile-level-id=42e01f")?r.push(e):s.push(e):o.push(e)})),dr(e)&&e.setCodecPreferences(r.concat(s,o))}async createSender(e,t,i){if(rr())return this.createTransceiverRTCRtpSender(e,t,i);if(sr())return a.debug("using add-track fallback"),this.createRTCRtpSender(e.mediaStreamTrack);throw new Gn("Required webRTC APIs not supported on this device")}async createSimulcastSender(e,t,i,n){if(rr())return this.createSimulcastTransceiverSender(e,t,i,n);if(sr())return a.debug("using add-track fallback"),this.createRTCRtpSender(e.mediaStreamTrack);throw new Gn("Cannot stream on this device")}async createTransceiverRTCRtpSender(e,t,i){if(!this.publisher)throw new Gn("publisher is closed");const n={direction:"sendonly"};i&&(n.sendEncodings=i);const r=await this.publisher.pc.addTransceiver(e.mediaStreamTrack,n);return e.kind===zr.Kind.Video&&t.videoCodec&&(this.setPreferredCodec(r,e.kind,t.videoCodec),e.codec=t.videoCodec),r.sender}async createSimulcastTransceiverSender(e,t,i,n){if(!this.publisher)throw new Gn("publisher is closed");const r={direction:"sendonly"};n&&(r.sendEncodings=n);const s=await this.publisher.pc.addTransceiver(t.mediaStreamTrack,r);if(i.videoCodec)return this.setPreferredCodec(s,e.kind,i.videoCodec),e.setSimulcastTrackSender(i.videoCodec,s.sender),s.sender}async createRTCRtpSender(e){if(!this.publisher)throw new Gn("publisher is closed");return this.publisher.pc.addTrack(e)}async attemptReconnect(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];var i,n,r;if(!this._isClosed&&!this.attemptingReconnect){(null===(i=this.clientConfiguration)||void 0===i?void 0:i.resumeConnection)!==Qe.DISABLED&&"closed"!==(null!==(r=null===(n=this.primaryPC)||void 0===n?void 0:n.signalingState)&&void 0!==r?r:"closed")||(this.fullReconnectOnNext=!0);try{this.attemptingReconnect=!0,this.fullReconnectOnNext?await this.restartConnection(t):await this.resumeConnection(t),this.reconnectAttempts=0,this.fullReconnectOnNext=!1,this.reconnectTimeout&&clearTimeout(this.reconnectTimeout)}catch(t){this.reconnectAttempts+=1;let i=!1,n=!0,r=!1;t instanceof Gn?(a.debug("received unrecoverable error",{error:t}),n=!1):t instanceof ha||(i=!0),i&&!this.fullReconnectOnNext&&(this.fullReconnectOnNext=!0,r=!0),n?this.handleDisconnect("reconnect",r):(a.info("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(Date.now()-this.reconnectStart,"ms. giving up")),this.emit(e.EngineEvent.Disconnected),this.close())}finally{this.attemptingReconnect=!1}}}getNextRetryDelay(e){try{return this.reconnectPolicy.nextRetryDelayInMs(e)}catch(e){a.warn("encountered error in reconnect policy",{error:e})}return null}async restartConnection(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];var i,n;if(!this.url||!this.token)throw new Gn("could not reconnect, url or token not saved");let r;a.info("reconnecting, attempt: ".concat(this.reconnectAttempts)),(t||0===this.reconnectAttempts)&&this.emit(e.EngineEvent.Restarting),this.client.isConnected&&await this.client.sendLeave(),await this.client.close(),this.primaryPC=void 0,null===(i=this.publisher)||void 0===i||i.close(),this.publisher=void 0,null===(n=this.subscriber)||void 0===n||n.close(),this.subscriber=void 0;try{if(!this.signalOpts)throw a.warn("attempted connection restart, without signal options present"),new ha;r=await this.join(this.url,this.token,this.signalOpts)}catch(e){throw new ha}await this.waitForPCConnected(),this.client.setReconnected(),this.emit(e.EngineEvent.Restarted,r)}async resumeConnection(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];var i;if(!this.url||!this.token)throw new Gn("could not reconnect, url or token not saved");if(!this.publisher||!this.subscriber)throw new Gn("publisher and subscriber connections unset");a.info("resuming signal connection, attempt ".concat(this.reconnectAttempts)),(t||0===this.reconnectAttempts)&&this.emit(e.EngineEvent.Resuming);try{await this.client.reconnect(this.url,this.token,this.participantSid)}catch(e){let t="";throw e instanceof Error&&(t=e.message),new ha(t)}this.emit(e.EngineEvent.SignalResumed),this.subscriber.restartingIce=!0,this.hasPublished&&await this.publisher.createAndSendOffer({iceRestart:!0}),await this.waitForPCConnected(),this.client.setReconnected(),"open"===(null===(i=this.reliableDC)||void 0===i?void 0:i.readyState)&&null===this.reliableDC.id&&this.createDataChannels(),this.emit(e.EngineEvent.Resumed)}async waitForPCConnected(){var e;const t=Date.now();let i=t;for(this.pcState=ca.Reconnecting,a.debug("waiting for peer connection to reconnect");i-t<this.peerConnectionTimeout&&void 0!==this.primaryPC;){if(i-t>2e3&&"connected"===(null===(e=this.primaryPC)||void 0===e?void 0:e.connectionState)){this.pcState=ca.Connected;try{this.connectedServerAddr=await la(this.primaryPC)}catch(e){a.warn("could not get connected server address",{error:e})}}if(this.pcState===ca.Connected)return;await nr(100),i=Date.now()}throw new Fn("could not establish PC connection")}async sendDataPacket(t,i){const n=wt.encode(t).finish();await this.ensurePublisherConnected(i),i===e.DataPacket_Kind.LOSSY&&this.lossyDC?this.lossyDC.send(n):i===e.DataPacket_Kind.RELIABLE&&this.reliableDC&&this.reliableDC.send(n)}async ensureDataTransportConnected(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscriberPrimary;var i,n,r;const s=t?this.subscriber:this.publisher,a=t?"Subscriber":"Publisher";if(!s)throw new Fn("".concat(a," connection not set"));t||(null===(i=this.publisher)||void 0===i?void 0:i.isICEConnected)||"checking"===(null===(n=this.publisher)||void 0===n?void 0:n.pc.iceConnectionState)||this.negotiate();const o=this.dataChannelForKind(e,t);if("open"===(null==o?void 0:o.readyState))return;const c=(new Date).getTime()+this.peerConnectionTimeout;for(;(new Date).getTime()<c;){if(s.isICEConnected&&"open"===(null===(r=this.dataChannelForKind(e,t))||void 0===r?void 0:r.readyState))return;await nr(50)}throw new Fn("could not establish ".concat(a," connection, state: ").concat(s.pc.iceConnectionState))}async ensurePublisherConnected(e){await this.ensureDataTransportConnected(e,!1)}negotiate(){return new Promise(((t,i)=>{if(!this.publisher)return void i(new Qn("publisher is not defined"));this.hasPublished=!0;const n=()=>{a.debug("engine disconnected while negotiation was ongoing"),s(),t()};this.on(e.EngineEvent.Closing,n);const r=setTimeout((()=>{i("negotiation timed out"),this.handleDisconnect("negotiation")}),this.peerConnectionTimeout),s=()=>{clearTimeout(r),this.off(e.EngineEvent.Closing,n)};this.publisher.once(ta,(()=>{var e;null===(e=this.publisher)||void 0===e||e.once(ia,(()=>{s(),t()}))})),this.publisher.negotiate((e=>{s(),i(e),e instanceof Qn&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation")}))}))}dataChannelForKind(t,i){if(i){if(t===e.DataPacket_Kind.LOSSY)return this.lossyDCSub;if(t===e.DataPacket_Kind.RELIABLE)return this.reliableDCSub}else{if(t===e.DataPacket_Kind.LOSSY)return this.lossyDC;if(t===e.DataPacket_Kind.RELIABLE)return this.reliableDC}}clearPendingReconnect(){this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.reconnectAttempts=0}registerOnLineListener(){pr()&&window.addEventListener("online",this.handleBrowserOnLine)}deregisterOnLineListener(){pr()&&window.removeEventListener("online",this.handleBrowserOnLine)}}async function la(e){var t;let i="";const n=new Map,r=new Map;if((await e.getStats()).forEach((e=>{switch(e.type){case"transport":i=e.selectedCandidatePairId;break;case"candidate-pair":""===i&&e.selected&&(i=e.id),n.set(e.id,e);break;case"remote-candidate":r.set(e.id,"".concat(e.address,":").concat(e.port))}})),""===i)return;const s=null===(t=n.get(i))||void 0===t?void 0:t.remoteCandidateId;return void 0!==s?r.get(s):void 0}class ha extends Error{}e.ConnectionState=void 0,(da=e.ConnectionState||(e.ConnectionState={})).Disconnected="disconnected",da.Connecting="connecting",da.Connected="connected",da.Reconnecting="reconnecting";const pa=e.ConnectionState;class ma extends Ir.EventEmitter{constructor(t){var i;super(),i=this,this.state=e.ConnectionState.Disconnected,this.activeSpeakers=[],this.sid="",this.name="",this.metadata=void 0,this._isRecording=!1,this.audioEnabled=!0,this.connect=async(t,i,n)=>{const r=await this.disconnectLock.lock();if(this.state===e.ConnectionState.Connected)return a.info("already connected to room ".concat(this.name)),r(),Promise.resolve();if(this.connectFuture)return r(),this.connectFuture.promise;this.setAndEmitConnectionState(e.ConnectionState.Connecting);return this.connectFuture=new Er((async(s,o)=>{var c,d;this.abortController&&!this.abortController.signal.aborted||(this.abortController=new AbortController),r(),this.state===e.ConnectionState.Reconnecting?(a.info("Reconnection attempt replaced by new connection attempt"),this.recreateEngine()):this.maybeCreateEngine(),this.acquireAudioContext(),this.connOptions=Ft(Ft({},js),n),this.connOptions.rtcConfig&&(this.engine.rtcConfig=this.connOptions.rtcConfig),this.connOptions.peerConnectionTimeout&&(this.engine.peerConnectionTimeout=this.connOptions.peerConnectionTimeout);try{const n=await this.engine.join(t,i,{autoSubscribe:this.connOptions.autoSubscribe,publishOnly:this.connOptions.publishOnly,adaptiveStream:"object"==typeof this.options.adaptiveStream||this.options.adaptiveStream,maxRetries:this.connOptions.maxRetries},this.abortController.signal);let r=n.serverInfo;if(r||(r={version:n.serverVersion,region:n.serverRegion}),a.debug("connected to Livekit Server ".concat(Object.entries(r).map((e=>{let[t,i]=e;return"".concat(t,": ").concat(i)})).join(", "))),!n.serverVersion)throw new Wn("unknown server version");"0.15.1"===n.serverVersion&&this.options.dynacast&&(a.debug("disabling dynacast due to server version"),this.options.dynacast=!1);const s=n.participant;this.localParticipant.sid=s.sid,this.localParticipant.identity=s.identity,this.localParticipant.updateInfo(s),this.setupLocalParticipantEvents(),n.otherParticipants.forEach((e=>{e.sid!==this.localParticipant.sid&&e.identity!==this.localParticipant.identity?this.getOrCreateParticipant(e.sid,e):a.warn("received info to create local participant as remote participant",{info:e,localParticipant:this.localParticipant})})),this.name=n.room.name,this.sid=n.room.sid,this.metadata=n.room.metadata,this._isRecording!==n.room.activeRecording&&(this._isRecording=n.room.activeRecording,this.emit(e.RoomEvent.RecordingStatusChanged,n.room.activeRecording)),this.emit(e.RoomEvent.SignalConnected)}catch(e){this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);let t="";return e instanceof Error&&(t=e.message,a.debug("error trying to establish signal connection",{error:e})),void o(new Fn("could not establish signal connection: ".concat(t)))}const u=setTimeout((()=>{this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),o(new Fn("could not connect PeerConnection after timeout"))}),this.connOptions.peerConnectionTimeout),l=()=>{a.warn("closing engine"),clearTimeout(u),this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),o(new Fn("room connection has been cancelled"))};(null===(c=this.abortController)||void 0===c?void 0:c.signal.aborted)&&l(),null===(d=this.abortController)||void 0===d||d.signal.addEventListener("abort",l),this.engine.once(e.EngineEvent.Connected,(()=>{var t,i;clearTimeout(u),null===(t=this.abortController)||void 0===t||t.signal.removeEventListener("abort",l),pr()&&(window.addEventListener("beforeunload",this.onBeforeUnload),null===(i=navigator.mediaDevices)||void 0===i||i.addEventListener("devicechange",this.handleDeviceChange)),this.setAndEmitConnectionState(e.ConnectionState.Connected),this.emit(e.RoomEvent.Connected),s()}))}),(()=>{this.clearConnectionFutures()})),this.connectFuture.promise},this.disconnect=async function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];var n,r,s,o;const c=await i.disconnectLock.lock();try{if(i.state===e.ConnectionState.Disconnected)return void a.debug("already disconnected");a.info("disconnect from room",{identity:i.localParticipant.identity}),i.state!==e.ConnectionState.Connecting&&i.state!==e.ConnectionState.Reconnecting||(a.warn("abort connection attempt"),null===(n=i.abortController)||void 0===n||n.abort(),null===(s=null===(r=i.connectFuture)||void 0===r?void 0:r.reject)||void 0===s||s.call(r,new Fn("Client initiated disconnect")),i.connectFuture=void 0),(null===(o=i.engine)||void 0===o?void 0:o.client.isConnected)&&await i.engine.client.sendLeave(),i.engine&&await i.engine.close(),i.handleDisconnect(t,e.DisconnectReason.CLIENT_INITIATED),i.engine=void 0}finally{c()}},this.onBeforeUnload=async()=>{await this.disconnect()},this.handleRestarting=()=>{for(const e of this.participants.values())this.handleParticipantDisconnected(e.sid,e);this.setAndEmitConnectionState(e.ConnectionState.Reconnecting)&&this.emit(e.RoomEvent.Reconnecting)},this.handleRestarted=async t=>{a.debug("reconnected to server",{region:t.serverRegion}),this.setAndEmitConnectionState(e.ConnectionState.Connected),this.emit(e.RoomEvent.Reconnected),t.participant&&(this.localParticipant.sid=t.participant.sid,this.handleParticipantUpdates([t.participant])),this.handleParticipantUpdates(t.otherParticipants);const i=[];this.localParticipant.tracks.forEach((e=>{e.track&&i.push(e)})),await Promise.all(i.map((async e=>{const t=e.track;this.localParticipant.unpublishTrack(t,!1),t.isMuted||((t instanceof Yr||t instanceof Xr)&&!t.isUserProvided&&(a.debug("restarting existing track",{track:e.trackSid}),await t.restartTrack()),await this.localParticipant.publishTrack(t,e.options))})))},this.handleParticipantUpdates=e=>{e.forEach((e=>{if(e.sid===this.localParticipant.sid||e.identity===this.localParticipant.identity)return void this.localParticipant.updateInfo(e);const t=this.identityToSid.get(e.identity);t&&t!==e.sid&&this.handleParticipantDisconnected(t,this.participants.get(t));let i=this.participants.get(e.sid);const n=!i;i=this.getOrCreateParticipant(e.sid,e),e.state===He.DISCONNECTED?this.handleParticipantDisconnected(e.sid,i):n||i.updateInfo(e)}))},this.handleActiveSpeakersUpdate=t=>{const i=[],n={};t.forEach((e=>{if(n[e.sid]=!0,e.sid===this.localParticipant.sid)this.localParticipant.audioLevel=e.level,this.localParticipant.setIsSpeaking(!0),i.push(this.localParticipant);else{const t=this.participants.get(e.sid);t&&(t.audioLevel=e.level,t.setIsSpeaking(!0),i.push(t))}})),n[this.localParticipant.sid]||(this.localParticipant.audioLevel=0,this.localParticipant.setIsSpeaking(!1)),this.participants.forEach((e=>{n[e.sid]||(e.audioLevel=0,e.setIsSpeaking(!1))})),this.activeSpeakers=i,this.emitWhenConnected(e.RoomEvent.ActiveSpeakersChanged,i)},this.handleSpeakersChanged=t=>{const i=new Map;this.activeSpeakers.forEach((e=>{i.set(e.sid,e)})),t.forEach((e=>{let t=this.participants.get(e.sid);e.sid===this.localParticipant.sid&&(t=this.localParticipant),t&&(t.audioLevel=e.level,t.setIsSpeaking(e.active),e.active?i.set(e.sid,t):i.delete(e.sid))}));const n=Array.from(i.values());n.sort(((e,t)=>t.audioLevel-e.audioLevel)),this.activeSpeakers=n,this.emitWhenConnected(e.RoomEvent.ActiveSpeakersChanged,n)},this.handleStreamStateUpdate=t=>{t.streamStates.forEach((t=>{const i=this.participants.get(t.participantSid);if(!i)return;const n=i.getTrackPublication(t.trackSid);n&&n.track&&(n.track.streamState=zr.streamStateFromProto(t.state),i.emit(e.ParticipantEvent.TrackStreamStateChanged,n,n.track.streamState),this.emitWhenConnected(e.RoomEvent.TrackStreamStateChanged,n,n.track.streamState,i))}))},this.handleSubscriptionPermissionUpdate=e=>{const t=this.participants.get(e.participantSid);if(!t)return;const i=t.getTrackPublication(e.trackSid);i&&i.setAllowed(e.allowed)},this.handleDataPacket=(t,i)=>{const n=this.participants.get(t.participantSid);this.emit(e.RoomEvent.DataReceived,t.payload,n,i),null==n||n.emit(e.ParticipantEvent.DataReceived,t.payload,i)},this.handleAudioPlaybackStarted=()=>{this.canPlaybackAudio||(this.audioEnabled=!0,this.emit(e.RoomEvent.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=t=>{a.warn("could not playback audio",t),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(e.RoomEvent.AudioPlaybackStatusChanged,!1))},this.handleDeviceChange=async()=>{this.emit(e.RoomEvent.MediaDevicesChanged)},this.handleRoomUpdate=t=>{this._isRecording!==t.activeRecording&&(this._isRecording=t.activeRecording,this.emit(e.RoomEvent.RecordingStatusChanged,t.activeRecording)),this.metadata!==t.metadata&&(this.metadata=t.metadata,this.emitWhenConnected(e.RoomEvent.RoomMetadataChanged,t.metadata))},this.handleConnectionQualityUpdate=e=>{e.updates.forEach((e=>{if(e.participantSid===this.localParticipant.sid)return void this.localParticipant.setConnectionQuality(e.quality);const t=this.participants.get(e.participantSid);t&&t.setConnectionQuality(e.quality)}))},this.onLocalParticipantMetadataChanged=t=>{this.emit(e.RoomEvent.ParticipantMetadataChanged,t,this.localParticipant)},this.onLocalTrackMuted=t=>{this.emit(e.RoomEvent.TrackMuted,t,this.localParticipant)},this.onLocalTrackUnmuted=t=>{this.emit(e.RoomEvent.TrackUnmuted,t,this.localParticipant)},this.onLocalTrackPublished=t=>{this.emit(e.RoomEvent.LocalTrackPublished,t,this.localParticipant)},this.onLocalTrackUnpublished=t=>{this.emit(e.RoomEvent.LocalTrackUnpublished,t,this.localParticipant)},this.onLocalConnectionQualityChanged=t=>{this.emit(e.RoomEvent.ConnectionQualityChanged,t,this.localParticipant)},this.onMediaDevicesError=t=>{this.emit(e.RoomEvent.MediaDevicesError,t)},this.onLocalParticipantPermissionsChanged=t=>{this.emit(e.RoomEvent.ParticipantPermissionsChanged,t,this.localParticipant)},this.setMaxListeners(100),this.participants=new Map,this.identityToSid=new Map,this.options=Ft(Ft({},Bs),t),this.options.audioCaptureDefaults=Ft(Ft({},Js),null==t?void 0:t.audioCaptureDefaults),this.options.videoCaptureDefaults=Ft(Ft({},$s),null==t?void 0:t.videoCaptureDefaults),this.options.publishDefaults=Ft(Ft({},_s),null==t?void 0:t.publishDefaults),this.maybeCreateEngine(),this.disconnectLock=new Pr,this.localParticipant=new As("","",this.engine,this.options)}maybeCreateEngine(){this.engine||(this.engine=new ua(this.options),this.engine.client.onParticipantUpdate=this.handleParticipantUpdates,this.engine.client.onRoomUpdate=this.handleRoomUpdate,this.engine.client.onSpeakersChanged=this.handleSpeakersChanged,this.engine.client.onStreamStateUpdate=this.handleStreamStateUpdate,this.engine.client.onSubscriptionPermissionUpdate=this.handleSubscriptionPermissionUpdate,this.engine.client.onConnectionQuality=this.handleConnectionQualityUpdate,this.engine.on(e.EngineEvent.MediaTrackAdded,((e,t,i)=>{this.onTrackAdded(e,t,i)})).on(e.EngineEvent.Disconnected,(e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)})).on(e.EngineEvent.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(e.EngineEvent.DataPacketReceived,this.handleDataPacket).on(e.EngineEvent.Resuming,(()=>{this.setAndEmitConnectionState(e.ConnectionState.Reconnecting)&&this.emit(e.RoomEvent.Reconnecting)})).on(e.EngineEvent.Resumed,(()=>{this.setAndEmitConnectionState(e.ConnectionState.Connected),this.emit(e.RoomEvent.Reconnected),this.updateSubscriptions()})).on(e.EngineEvent.SignalResumed,(()=>{this.state===e.ConnectionState.Reconnecting&&this.sendSyncState()})).on(e.EngineEvent.Restarting,this.handleRestarting).on(e.EngineEvent.Restarted,this.handleRestarted),this.localParticipant&&this.localParticipant.setupEngine(this.engine))}static getLocalDevices(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Nr.getInstance().getDevices(e,t)}async prepareConnection(e){await fetch("http".concat(e.substring(2)),{method:"HEAD"})}getParticipantByIdentity(e){if(this.localParticipant.identity===e)return this.localParticipant;const t=this.identityToSid.get(e);return t?this.participants.get(t):void 0}clearConnectionFutures(){this.connectFuture=void 0}get isRecording(){return this._isRecording}async simulateScenario(t){let i,n=()=>{};switch(t){case"signal-reconnect":await this.engine.client.close(),this.engine.client.onClose&&this.engine.client.onClose("simulate disconnect");break;case"speaker":i=Un.fromPartial({scenario:{$case:"speakerUpdate",speakerUpdate:3}});break;case"node-failure":i=Un.fromPartial({scenario:{$case:"nodeFailure",nodeFailure:!0}});break;case"server-leave":i=Un.fromPartial({scenario:{$case:"serverLeave",serverLeave:!0}});break;case"migration":i=Un.fromPartial({scenario:{$case:"migration",migration:!0}});break;case"force-tcp":case"force-tls":i=Un.fromPartial({scenario:{$case:"switchCandidateProtocol",switchCandidateProtocol:"force-tls"===t?2:1}}),n=async()=>{const t=this.engine.client.onLeave;t&&t({reason:e.DisconnectReason.CLIENT_INITIATED,canReconnect:!0})}}i&&(this.engine.client.sendSimulateScenario(i),n())}async startAudio(){await this.acquireAudioContext();const e=[];this.participants.forEach((t=>{t.audioTracks.forEach((t=>{t.track&&t.track.attachedElements.forEach((t=>{e.push(t)}))}))}));try{await Promise.all(e.map((e=>(e.muted=!1,e.play())))),this.handleAudioPlaybackStarted()}catch(e){throw this.handleAudioPlaybackFailed(e),e}}get canPlaybackAudio(){return this.audioEnabled}getActiveAudioOutputDevice(){var e,t;return null!==(t=null===(e=this.options.audioOutput)||void 0===e?void 0:e.deviceId)&&void 0!==t?t:""}async switchActiveDevice(e,t){var i,n;if("audioinput"===e){const e=this.options.audioCaptureDefaults.deviceId;this.options.audioCaptureDefaults.deviceId=t;const i=Array.from(this.localParticipant.audioTracks.values()).filter((e=>e.source===zr.Source.Microphone));try{await Promise.all(i.map((e=>{var i;return null===(i=e.audioTrack)||void 0===i?void 0:i.setDeviceId(t)})))}catch(t){throw this.options.audioCaptureDefaults.deviceId=e,t}}else if("videoinput"===e){const e=this.options.videoCaptureDefaults.deviceId;this.options.videoCaptureDefaults.deviceId=t;const i=Array.from(this.localParticipant.videoTracks.values()).filter((e=>e.source===zr.Source.Camera));try{await Promise.all(i.map((e=>{var i;return null===(i=e.videoTrack)||void 0===i?void 0:i.setDeviceId(t)})))}catch(t){throw this.options.videoCaptureDefaults.deviceId=e,t}}else if("audiooutput"===e){if(!or())throw new Error("cannot switch audio output, setSinkId not supported");null!==(i=(n=this.options).audioOutput)&&void 0!==i||(n.audioOutput={});const e=this.options.audioOutput.deviceId;this.options.audioOutput.deviceId=t;try{await Promise.all(Array.from(this.participants.values()).map((e=>e.setAudioOutput({deviceId:t}))))}catch(t){throw this.options.audioOutput.deviceId=e,t}}}setupLocalParticipantEvents(){this.localParticipant.on(e.ParticipantEvent.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(e.ParticipantEvent.TrackMuted,this.onLocalTrackMuted).on(e.ParticipantEvent.TrackUnmuted,this.onLocalTrackUnmuted).on(e.ParticipantEvent.LocalTrackPublished,this.onLocalTrackPublished).on(e.ParticipantEvent.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(e.ParticipantEvent.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(e.ParticipantEvent.MediaDevicesError,this.onMediaDevicesError).on(e.ParticipantEvent.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged)}recreateEngine(){var e;null===(e=this.engine)||void 0===e||e.close(),this.engine=void 0,this.participants.clear(),this.maybeCreateEngine()}onTrackAdded(t,i,n){if(this.state===e.ConnectionState.Connecting||this.state===e.ConnectionState.Reconnecting){const r=()=>{this.onTrackAdded(t,i,n),s()},s=()=>{this.off(e.RoomEvent.Reconnected,r),this.off(e.RoomEvent.Connected,r),this.off(e.RoomEvent.Disconnected,s)};return this.once(e.RoomEvent.Reconnected,r),this.once(e.RoomEvent.Connected,r),void this.once(e.RoomEvent.Disconnected,s)}if(this.state===e.ConnectionState.Disconnected)return void a.warn("skipping incoming track after Room disconnected");const r=function(e){const t=e.split("|");return t.length>1?[t[0],e.substr(t[0].length+1)]:[e,""]}(i.id),s=r[0];let o=r[1];if(o&&""!==o||(o=t.id),s===this.localParticipant.sid)return void a.warn("tried to create RemoteParticipant for local participant");const c=this.getOrCreateParticipant(s);let d;this.options.adaptiveStream&&(d="object"==typeof this.options.adaptiveStream?this.options.adaptiveStream:{}),c.addSubscribedMediaTrack(t,o,i,n,d)}handleDisconnect(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],i=arguments.length>1?arguments[1]:void 0;var n;this.state!==e.ConnectionState.Disconnected&&(this.participants.forEach((e=>{e.tracks.forEach((t=>{e.unpublishTrack(t.trackSid)}))})),this.localParticipant.tracks.forEach((e=>{var i,n;e.track&&this.localParticipant.unpublishTrack(e.track,t),t&&(null===(i=e.track)||void 0===i||i.detach(),null===(n=e.track)||void 0===n||n.stop())})),this.localParticipant.off(e.ParticipantEvent.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(e.ParticipantEvent.TrackMuted,this.onLocalTrackMuted).off(e.ParticipantEvent.TrackUnmuted,this.onLocalTrackUnmuted).off(e.ParticipantEvent.LocalTrackPublished,this.onLocalTrackPublished).off(e.ParticipantEvent.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(e.ParticipantEvent.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(e.ParticipantEvent.MediaDevicesError,this.onMediaDevicesError).off(e.ParticipantEvent.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged),this.localParticipant.tracks.clear(),this.localParticipant.videoTracks.clear(),this.localParticipant.audioTracks.clear(),this.participants.clear(),this.activeSpeakers=[],this.audioContext&&"boolean"==typeof this.options.expWebAudioMix&&(this.audioContext.close(),this.audioContext=void 0),pr()&&(window.removeEventListener("beforeunload",this.onBeforeUnload),null===(n=navigator.mediaDevices)||void 0===n||n.removeEventListener("devicechange",this.handleDeviceChange)),this.setAndEmitConnectionState(e.ConnectionState.Disconnected),this.emit(e.RoomEvent.Disconnected,i))}handleParticipantDisconnected(t,i){this.participants.delete(t),i&&(this.identityToSid.delete(i.identity),i.tracks.forEach((e=>{i.unpublishTrack(e.trackSid,!0)})),this.emitWhenConnected(e.RoomEvent.ParticipantDisconnected,i))}async acquireAudioContext(){var t,i;"boolean"!=typeof this.options.expWebAudioMix&&this.options.expWebAudioMix.audioContext?(this.audioContext=this.options.expWebAudioMix.audioContext,await this.audioContext.resume()):this.audioContext=null!==(t=ir())&&void 0!==t?t:void 0,this.options.expWebAudioMix&&this.participants.forEach((e=>e.setAudioContext(this.audioContext)));const n="running"===(null===(i=this.audioContext)||void 0===i?void 0:i.state);n!==this.canPlaybackAudio&&(this.audioEnabled=n,this.emit(e.RoomEvent.AudioPlaybackStatusChanged,n))}createParticipant(e,t){let i;return i=t?Is.fromParticipantInfo(this.engine.client,t):new Is(this.engine.client,e,"",void 0,void 0),this.options.expWebAudioMix&&i.setAudioContext(this.audioContext),i}getOrCreateParticipant(t,i){if(this.participants.has(t))return this.participants.get(t);const n=this.createParticipant(t,i);return this.participants.set(t,n),i&&(this.identityToSid.set(i.identity,i.sid),this.emitWhenConnected(e.RoomEvent.ParticipantConnected,n)),n.on(e.ParticipantEvent.TrackPublished,(t=>{this.emitWhenConnected(e.RoomEvent.TrackPublished,t,n)})).on(e.ParticipantEvent.TrackSubscribed,((t,i)=>{t.kind===zr.Kind.Audio&&(t.on(e.TrackEvent.AudioPlaybackStarted,this.handleAudioPlaybackStarted),t.on(e.TrackEvent.AudioPlaybackFailed,this.handleAudioPlaybackFailed)),this.emit(e.RoomEvent.TrackSubscribed,t,i,n)})).on(e.ParticipantEvent.TrackUnpublished,(t=>{this.emitWhenConnected(e.RoomEvent.TrackUnpublished,t,n)})).on(e.ParticipantEvent.TrackUnsubscribed,((t,i)=>{this.emit(e.RoomEvent.TrackUnsubscribed,t,i,n)})).on(e.ParticipantEvent.TrackSubscriptionFailed,(t=>{this.emit(e.RoomEvent.TrackSubscriptionFailed,t,n)})).on(e.ParticipantEvent.TrackMuted,(t=>{this.emitWhenConnected(e.RoomEvent.TrackMuted,t,n)})).on(e.ParticipantEvent.TrackUnmuted,(t=>{this.emitWhenConnected(e.RoomEvent.TrackUnmuted,t,n)})).on(e.ParticipantEvent.ParticipantMetadataChanged,(t=>{this.emitWhenConnected(e.RoomEvent.ParticipantMetadataChanged,t,n)})).on(e.ParticipantEvent.ConnectionQualityChanged,(t=>{this.emitWhenConnected(e.RoomEvent.ConnectionQualityChanged,t,n)})).on(e.ParticipantEvent.ParticipantPermissionsChanged,(t=>{this.emitWhenConnected(e.RoomEvent.ParticipantPermissionsChanged,t,n)})).on(e.ParticipantEvent.TrackSubscriptionStatusChanged,((t,i)=>{this.emitWhenConnected(e.RoomEvent.TrackSubscriptionStatusChanged,t,i,n)})).on(e.ParticipantEvent.TrackSubscriptionPermissionChanged,((t,i)=>{this.emitWhenConnected(e.RoomEvent.TrackSubscriptionPermissionChanged,t,i,n)})),i&&n.updateInfo(i),n}sendSyncState(){var e,t;if(void 0===this.engine.subscriber||null===this.engine.subscriber.pc.localDescription)return;const i=this.engine.subscriber.pc.localDescription,n=this.engine.subscriber.pc.remoteDescription,r=null===(t=null===(e=this.connOptions)||void 0===e?void 0:e.autoSubscribe)||void 0===t||t,s=new Array;this.participants.forEach((e=>{e.tracks.forEach((e=>{e.isDesired!==r&&s.push(e.trackSid)}))})),this.engine.client.sendSyncState({answer:Ms({sdp:i.sdp,type:i.type}),offer:n?Ms({sdp:n.sdp,type:n.type}):void 0,subscription:{trackSids:s,subscribe:!r,participantTracks:[]},publishTracks:this.localParticipant.publishedTracksInfo(),dataChannels:this.localParticipant.dataChannelsInfo()})}updateSubscriptions(){for(const e of this.participants.values())for(const t of e.videoTracks.values())t.isSubscribed&&t instanceof Ds&&t.emitTrackUpdate()}setAndEmitConnectionState(t){return t!==this.state&&(this.state=t,this.emit(e.RoomEvent.ConnectionStateChanged,this.state),!0)}emitWhenConnected(t){if(this.state===e.ConnectionState.Connected){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return this.emit(t,...n)}return!1}async simulateParticipants(t){var i,n;const r=Ft({audio:!0,video:!0,useRealTracks:!1},t.publish),s=Ft({count:9,audio:!1,video:!0,aspectRatios:[1.66,1.7,1.3]},t.participants);if(this.handleDisconnect(),this.name="simulated-room",this.localParticipant.updateInfo(bt.fromPartial({identity:"simulated-local",name:"local-name"})),this.setupLocalParticipantEvents(),this.emit(e.RoomEvent.SignalConnected),this.emit(e.RoomEvent.Connected),this.setAndEmitConnectionState(e.ConnectionState.Connected),r.video){const t=new ds(zr.Kind.Video,yt.fromPartial({source:qe.CAMERA,sid:Math.floor(1e4*Math.random()).toString(),type:Fe.AUDIO,name:"video-dummy"}),new Xr(r.useRealTracks?(await navigator.mediaDevices.getUserMedia({video:!0})).getVideoTracks()[0]:Cr(null!==(i=160*s.aspectRatios[0])&&void 0!==i?i:1,160,!0,!0)));this.localParticipant.addTrackPublication(t),this.localParticipant.emit(e.ParticipantEvent.LocalTrackPublished,t)}if(r.audio){const t=new ds(zr.Kind.Audio,yt.fromPartial({source:qe.MICROPHONE,sid:Math.floor(1e4*Math.random()).toString(),type:Fe.AUDIO}),new Yr(r.useRealTracks?(await navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:Tr()));this.localParticipant.addTrackPublication(t),this.localParticipant.emit(e.ParticipantEvent.LocalTrackPublished,t)}for(let e=0;e<s.count-1;e+=1){let t=bt.fromPartial({sid:Math.floor(1e4*Math.random()).toString(),identity:"simulated-".concat(e),state:He.ACTIVE,tracks:[],joinedAt:Date.now()});const i=this.getOrCreateParticipant(t.identity,t);if(s.video){const r=Cr(null!==(n=160*s.aspectRatios[e%s.aspectRatios.length])&&void 0!==n?n:1,160,!1,!0),a=yt.fromPartial({source:qe.CAMERA,sid:Math.floor(1e4*Math.random()).toString(),type:Fe.AUDIO});i.addSubscribedMediaTrack(r,a.sid,new MediaStream([r])),t.tracks=[...t.tracks,a]}if(s.audio){const e=Tr(),n=yt.fromPartial({source:qe.MICROPHONE,sid:Math.floor(1e4*Math.random()).toString(),type:Fe.AUDIO});i.addSubscribedMediaTrack(e,n.sid,new MediaStream([e])),t.tracks=[...t.tracks,n]}i.updateInfo(t)}}emit(t){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return t!==e.RoomEvent.ActiveSpeakersChanged&&a.debug("room event ".concat(t),{event:t,args:n}),super.emit(t,...n)}}async function va(e){var t,i;null!=e||(e={}),null!==(t=e.audio)&&void 0!==t||(e.audio=!0),null!==(i=e.video)&&void 0!==i||(e.video=!0);const n=tr(Xn(e,Js,$s)),r=navigator.mediaDevices.getUserMedia(n);e.audio&&(Nr.userMediaPromiseMap.set("audioinput",r),r.catch((()=>Nr.userMediaPromiseMap.delete("audioinput")))),e.video&&(Nr.userMediaPromiseMap.set("videoinput",r),r.catch((()=>Nr.userMediaPromiseMap.delete("videoinput"))));const s=await r;return s.getTracks().map((t=>{const i="audio"===t.kind;let r;i?e.audio:e.video;const a=i?n.audio:n.video;"boolean"!=typeof a&&(r=a);const o=bs(t,r);return o.kind===zr.Kind.Video?o.source=zr.Source.Camera:o.kind===zr.Kind.Audio&&(o.source=zr.Source.Microphone),o.mediaStream=s,o}))}async function fa(e){return(await va({audio:!1,video:e}))[0]}async function ga(e){return(await va({audio:e,video:!1}))[0]}var ba;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.SKIPPED=2]="SKIPPED",e[e.SUCCESS=3]="SUCCESS",e[e.FAILED=4]="FAILED"}(ba||(ba={}));class ka extends Ir.EventEmitter{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(),this.status=ba.IDLE,this.logs=[],this.errorsAsWarnings=!1,this.url=e,this.token=t,this.name=this.constructor.name,this.room=new ma(i.roomOptions),this.connectOptions=i.connectOptions,i.errorsAsWarnings&&(this.errorsAsWarnings=i.errorsAsWarnings)}async run(e){if(this.status!==ba.IDLE)throw Error("check is running already");this.setStatus(ba.RUNNING),this.appendMessage("".concat(this.name," started."));try{await this.perform()}catch(e){e instanceof Error&&(this.errorsAsWarnings?this.appendWarning(e.message):this.appendError(e.message))}return await this.disconnect(),await new Promise((e=>setTimeout(e,500))),this.status!==ba.SKIPPED&&this.setStatus(this.isSuccess()?ba.SUCCESS:ba.FAILED),e&&e(),this.getInfo()}isSuccess(){return!this.logs.some((e=>"error"===e.level))}async connect(){return this.room.state===e.ConnectionState.Connected||await this.room.connect(this.url,this.token),this.room}async disconnect(){this.room&&this.room.state!==e.ConnectionState.Disconnected&&(await this.room.disconnect(),await new Promise((e=>setTimeout(e,500))))}skip(){this.setStatus(ba.SKIPPED)}appendMessage(e){this.logs.push({level:"info",message:e}),this.emit("update",this.getInfo())}appendWarning(e){this.logs.push({level:"warning",message:e}),this.emit("update",this.getInfo())}appendError(e){this.logs.push({level:"error",message:e}),this.emit("update",this.getInfo())}setStatus(e){this.status=e,this.emit("update",this.getInfo())}get engine(){var e;return null===(e=this.room)||void 0===e?void 0:e.engine}getInfo(){return{logs:this.logs,name:this.name,status:this.status,description:this.description}}}class ya extends ka{get description(){return"Can publish audio"}async perform(){var e;const t=await this.connect(),i=await ga();t.localParticipant.publishTrack(i),await new Promise((e=>setTimeout(e,3e3)));const n=await(null===(e=i.sender)||void 0===e?void 0:e.getStats());if(!n)throw new Error("Could not get RTCStats");let r=0;if(n.forEach((e=>{"outbound-rtp"===e.type&&"audio"===e.mediaType&&(r=e.packetsSent)})),0===r)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(r," audio packets"))}}class Sa extends ka{get description(){return"Can publish video"}async perform(){var e;const t=await this.connect(),i=await fa();t.localParticipant.publishTrack(i),await new Promise((e=>setTimeout(e,3e3)));const n=await(null===(e=i.sender)||void 0===e?void 0:e.getStats());if(!n)throw new Error("Could not get RTCStats");let r=0;if(n.forEach((e=>{"outbound-rtp"===e.type&&"video"===e.mediaType&&(r=e.packetsSent)})),0===r)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(r," video packets"))}}class wa extends ka{get description(){return"Resuming connection after interruption"}async perform(){var t;const i=await this.connect();let n,r=!1,s=!1;const a=new Promise((e=>{setTimeout(e,5e3),n=e}));i.on(e.RoomEvent.Reconnecting,(()=>{r=!0})).on(e.RoomEvent.Reconnected,(()=>{s=!0,n(!0)})),null===(t=i.engine.client.ws)||void 0===t||t.close();const o=i.engine.client.onClose;if(o&&o(""),await a,!r)throw new Error("Did not attempt to reconnect");if(!s||i.state!==e.ConnectionState.Connected)throw this.appendWarning("reconnection is only possible in Redis-based configurations"),new Error("Not able to reconnect")}}class Ca extends ka{get description(){return"Can connect via TURN"}async perform(){var e,t;const i=new Ls,n=await i.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0});let r=!1,s=!1,a=!1;for(let e of n.iceServers)for(let t of e.urls)t.startsWith("turn:")?(s=!0,a=!0):t.startsWith("turns:")&&(s=!0,a=!0,r=!0),t.startsWith("stun:")&&(a=!0);a?s&&!r&&this.appendWarning("TURN is configured server side, but TURN/TLS is unavailable."):this.appendWarning("No STUN servers configured on server side."),await i.close(),(null===(t=null===(e=this.connectOptions)||void 0===e?void 0:e.rtcConfig)||void 0===t?void 0:t.iceServers)||s?await this.room.connect(this.url,this.token,{rtcConfig:{iceTransportPolicy:"relay"}}):(this.appendWarning("No TURN servers configured."),this.skip(),await new Promise((e=>setTimeout(e,0))))}}class Ta extends ka{get description(){return"Establishing WebRTC connection"}async perform(){try{console.log("initiating room connection"),this.room=await this.connect(),console.log("now the room is connected")}catch(e){throw this.appendWarning("ports need to be open on firewall in order to connect."),e}}}class Ea extends ka{get description(){return"Connecting to signal connection via WebSocket"}async perform(){(this.url.startsWith("ws:")||this.url.startsWith("http:"))&&this.appendWarning("Server is insecure, clients may block connections to it");let e=new Ls;const t=await e.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0});this.appendMessage("Connected to server, version ".concat(t.serverVersion,".")),await e.close()}}e.ConnectionCheck=class extends Ir{constructor(e,t){super(),this.checkResults=new Map,this.url=e,this.token=t}getNextCheckId(){const e=this.checkResults.size;return this.checkResults.set(e,{logs:[],status:ba.IDLE,name:"",description:""}),e}updateCheck(e,t){this.checkResults.set(e,t),this.emit("checkUpdate",e,t)}isSuccess(){return Array.from(this.checkResults.values()).every((e=>e.status!==ba.FAILED))}getResults(){return Array.from(this.checkResults.values())}async createAndRunCheck(e){const t=this.getNextCheckId(),i=new e(this.url,this.token),n=e=>{this.updateCheck(t,e)};i.on("update",n);const r=await i.run();return i.off("update",n),r}async checkWebsocket(){return this.createAndRunCheck(Ea)}async checkWebRTC(){return this.createAndRunCheck(Ta)}async checkTURN(){return this.createAndRunCheck(Ca)}async checkReconnect(){return this.createAndRunCheck(wa)}async checkPublishAudio(){return this.createAndRunCheck(ya)}async checkPublishVideo(){return this.createAndRunCheck(Sa)}},e.ConnectionError=Fn,e.DefaultReconnectPolicy=$t,e.LivekitError=Vn,e.LocalAudioTrack=Yr,e.LocalParticipant=As,e.LocalTrack=Kr,e.LocalTrackPublication=ds,e.LocalVideoTrack=Xr,e.NegotiationError=Qn,e.Participant=gs,e.PublishDataError=class extends Vn{constructor(e){super(13,null!=e?e:"unable to publish data")}},e.RemoteAudioTrack=rs,e.RemoteParticipant=Is,e.RemoteTrack=ns,e.RemoteTrackPublication=Ds,e.RemoteVideoTrack=as,e.Room=ma,e.RoomState=pa,e.ScreenSharePresets=fs,e.Track=zr,e.TrackInvalidError=qn,e.TrackPublication=cs,e.UnexpectedConnectionState=Gn,e.UnsupportedServer=Wn,e.VideoPreset=us,e.VideoPresets=ms,e.VideoPresets43=vs,e.attachToElement=Hr,e.createAudioAnalyser=function(e,t){const i=Ft({cloneTrack:!1,fftSize:2048,smoothingTimeConstant:.8,minDecibels:-100,maxDecibels:-80},t),n=ir();if(!n)throw new Error("Audio Context not supported on this browser");const r=i.cloneTrack?e.mediaStreamTrack.clone():e.mediaStreamTrack,s=n.createMediaStreamSource(new MediaStream([r])),a=n.createAnalyser();a.minDecibels=i.minDecibels,a.maxDecibels=i.maxDecibels,a.fftSize=i.fftSize,a.smoothingTimeConstant=i.smoothingTimeConstant,s.connect(a);const o=new Uint8Array(a.frequencyBinCount);return{calculateVolume:()=>{a.getByteFrequencyData(o);let e=0;for(const t of o)e+=Math.pow(t/255,2);return Math.sqrt(e/o.length)},analyser:a,cleanup:()=>{n.close(),i.cloneTrack&&r.stop()}}},e.createLocalAudioTrack=ga,e.createLocalScreenTracks=async function(e){var t;void 0===e&&(e={}),void 0===e.resolution&&(e.resolution=ms.h1080.resolution);let i=!0;e.resolution&&(i={width:e.resolution.width,height:e.resolution.height});const n=await navigator.mediaDevices.getDisplayMedia({audio:null!==(t=e.audio)&&void 0!==t&&t,video:i}),r=n.getVideoTracks();if(0===r.length)throw new qn("no video track found");const s=new Xr(r[0],void 0,!1);s.source=zr.Source.ScreenShare;const a=[s];if(n.getAudioTracks().length>0){const e=new Yr(n.getAudioTracks()[0],void 0,!1);e.source=zr.Source.ScreenShareAudio,a.push(e)}return a},e.createLocalTracks=va,e.createLocalVideoTrack=fa,e.detachTrack=Zr,e.getEmptyAudioStreamTrack=Tr,e.getEmptyVideoStreamTrack=wr,e.isBackupCodec=hs,e.isBrowserSupported=function(){return rr()||sr()},e.protocolVersion=8,e.setLogExtension=function(t){const i=a.methodFactory;a.methodFactory=(n,r,s)=>{const o=i(n,r,s),c=a.getLevel(),d=r>=c&&r<e.LogLevel.silent;return(e,i)=>{i?o(e,i):o(e),d&&t(r,e,i)}},a.setLevel(a.getLevel())},e.setLogLevel=function(e){a.setLevel(e)},e.supportsAV1=ar,e.supportsAdaptiveStream=function(){return void 0!==typeof ResizeObserver&&void 0!==typeof IntersectionObserver},e.supportsDynacast=function(){return rr()},e.version=Yn}));
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LivekitClient={})}(this,(function(e){"use strict";function t(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(i){if("default"!==i&&!(i in e)){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}}))})),Object.freeze(e)}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,s={};!function(e){var t,n;t=i,n=function(){var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function r(e,t){var i=e[t];if("function"==typeof i.bind)return i.bind(e);try{return Function.prototype.bind.call(i,e)}catch(t){return function(){return Function.prototype.apply.apply(i,[e,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function a(n){return"debug"===n&&(n="log"),typeof console!==t&&("trace"===n&&i?s:void 0!==console[n]?r(console,n):void 0!==console.log?r(console,"log"):e)}function o(t,i){for(var r=0;r<n.length;r++){var s=n[r];this[s]=r<t?e:this.methodFactory(s,t,i)}this.log=this.debug}function c(e,i,n){return function(){typeof console!==t&&(o.call(this,i,n),this[e].apply(this,arguments))}}function d(e,t,i){return a(e)||c.apply(this,arguments)}function u(e,i,r){var s,a=this;i=null==i?"WARN":i;var c="loglevel";function u(){var e;if(typeof window!==t&&c){try{e=window.localStorage[c]}catch(e){}if(typeof e===t)try{var i=window.document.cookie,n=i.indexOf(encodeURIComponent(c)+"=");-1!==n&&(e=/^([^;]+)/.exec(i.slice(n))[1])}catch(e){}return void 0===a.levels[e]&&(e=void 0),e}}"string"==typeof e?c+=":"+e:"symbol"==typeof e&&(c=void 0),a.name=e,a.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},a.methodFactory=r||d,a.getLevel=function(){return s},a.setLevel=function(i,r){if("string"==typeof i&&void 0!==a.levels[i.toUpperCase()]&&(i=a.levels[i.toUpperCase()]),!("number"==typeof i&&i>=0&&i<=a.levels.SILENT))throw"log.setLevel() called with invalid level: "+i;if(s=i,!1!==r&&function(e){var i=(n[e]||"silent").toUpperCase();if(typeof window!==t&&c){try{return void(window.localStorage[c]=i)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+i+";"}catch(e){}}}(i),o.call(a,i,e),typeof console===t&&i<a.levels.SILENT)return"No console available for logging"},a.setDefaultLevel=function(e){i=e,u()||a.setLevel(e,!1)},a.resetLevel=function(){a.setLevel(i,!1),function(){if(typeof window!==t&&c){try{return void window.localStorage.removeItem(c)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},a.enableAll=function(e){a.setLevel(a.levels.TRACE,e)},a.disableAll=function(e){a.setLevel(a.levels.SILENT,e)};var l=u();null==l&&(l=i),a.setLevel(l,!1)}var l=new u,h={};l.getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=h[e];return t||(t=h[e]=new u(e,l.getLevel(),l.methodFactory)),t};var p=typeof window!==t?window.log:void 0;return l.noConflict=function(){return typeof window!==t&&window.log===l&&(window.log=p),l},l.getLoggers=function(){return h},l.default=l,l},e.exports?e.exports=n():t.log=n()}({get exports(){return s},set exports(e){s=e}}),e.LogLevel=void 0,(r=e.LogLevel||(e.LogLevel={}))[r.trace=0]="trace",r[r.debug=1]="debug",r[r.info=2]="info",r[r.warn=3]="warn",r[r.error=4]="error",r[r.silent=5]="silent";const a=s.getLogger("livekit");a.setLevel(e.LogLevel.info);var o=d,c=null;try{c=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function d(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function u(e){return!0===(e&&e.__isLong__)}d.prototype.__isLong__,Object.defineProperty(d.prototype,"__isLong__",{value:!0}),d.isLong=u;var l={},h={};function p(e,t){var i,n,r;return t?(r=0<=(e>>>=0)&&e<256)&&(n=h[e])?n:(i=v(e,(0|e)<0?-1:0,!0),r&&(h[e]=i),i):(r=-128<=(e|=0)&&e<128)&&(n=l[e])?n:(i=v(e,e<0?-1:0,!1),r&&(l[e]=i),i)}function m(e,t){if(isNaN(e))return t?T:C;if(t){if(e<0)return T;if(e>=y)return N}else{if(e<=-S)return D;if(e+1>=S)return O}return e<0?m(-e,t).neg():v(e%k|0,e/k|0,t)}function v(e,t,i){return new d(e,t,i)}d.fromInt=p,d.fromNumber=m,d.fromBits=v;var f=Math.pow;function g(e,t,i){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return C;if("number"==typeof t?(i=t,t=!1):t=!!t,(i=i||10)<2||36<i)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===n)return g(e.substring(1),t,i).neg();for(var r=m(f(i,8)),s=C,a=0;a<e.length;a+=8){var o=Math.min(8,e.length-a),c=parseInt(e.substring(a,a+o),i);if(o<8){var d=m(f(i,o));s=s.mul(d).add(m(c))}else s=(s=s.mul(r)).add(m(c))}return s.unsigned=t,s}function b(e,t){return"number"==typeof e?m(e,t):"string"==typeof e?g(e,t):v(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}d.fromString=g,d.fromValue=b;var k=4294967296,y=k*k,S=y/2,w=p(1<<24),C=p(0);d.ZERO=C;var T=p(0,!0);d.UZERO=T;var E=p(1);d.ONE=E;var P=p(1,!0);d.UONE=P;var R=p(-1);d.NEG_ONE=R;var O=v(-1,2147483647,!1);d.MAX_VALUE=O;var N=v(-1,-1,!0);d.MAX_UNSIGNED_VALUE=N;var D=v(0,-2147483648,!1);d.MIN_VALUE=D;var I=d.prototype;I.toInt=function(){return this.unsigned?this.low>>>0:this.low},I.toNumber=function(){return this.unsigned?(this.high>>>0)*k+(this.low>>>0):this.high*k+(this.low>>>0)},I.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(D)){var t=m(e),i=this.div(t),n=i.mul(t).sub(this);return i.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var r=m(f(e,6),this.unsigned),s=this,a="";;){var o=s.div(r),c=(s.sub(o.mul(r)).toInt()>>>0).toString(e);if((s=o).isZero())return c+a;for(;c.length<6;)c="0"+c;a=""+c+a}},I.getHighBits=function(){return this.high},I.getHighBitsUnsigned=function(){return this.high>>>0},I.getLowBits=function(){return this.low},I.getLowBitsUnsigned=function(){return this.low>>>0},I.getNumBitsAbs=function(){if(this.isNegative())return this.eq(D)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},I.isZero=function(){return 0===this.high&&0===this.low},I.eqz=I.isZero,I.isNegative=function(){return!this.unsigned&&this.high<0},I.isPositive=function(){return this.unsigned||this.high>=0},I.isOdd=function(){return 1==(1&this.low)},I.isEven=function(){return 0==(1&this.low)},I.equals=function(e){return u(e)||(e=b(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},I.eq=I.equals,I.notEquals=function(e){return!this.eq(e)},I.neq=I.notEquals,I.ne=I.notEquals,I.lessThan=function(e){return this.comp(e)<0},I.lt=I.lessThan,I.lessThanOrEqual=function(e){return this.comp(e)<=0},I.lte=I.lessThanOrEqual,I.le=I.lessThanOrEqual,I.greaterThan=function(e){return this.comp(e)>0},I.gt=I.greaterThan,I.greaterThanOrEqual=function(e){return this.comp(e)>=0},I.gte=I.greaterThanOrEqual,I.ge=I.greaterThanOrEqual,I.compare=function(e){if(u(e)||(e=b(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},I.comp=I.compare,I.negate=function(){return!this.unsigned&&this.eq(D)?D:this.not().add(E)},I.neg=I.negate,I.add=function(e){u(e)||(e=b(e));var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,r=65535&this.low,s=e.high>>>16,a=65535&e.high,o=e.low>>>16,c=0,d=0,l=0,h=0;return l+=(h+=r+(65535&e.low))>>>16,d+=(l+=n+o)>>>16,c+=(d+=i+a)>>>16,c+=t+s,v((l&=65535)<<16|(h&=65535),(c&=65535)<<16|(d&=65535),this.unsigned)},I.subtract=function(e){return u(e)||(e=b(e)),this.add(e.neg())},I.sub=I.subtract,I.multiply=function(e){if(this.isZero())return C;if(u(e)||(e=b(e)),c)return v(c.mul(this.low,this.high,e.low,e.high),c.get_high(),this.unsigned);if(e.isZero())return C;if(this.eq(D))return e.isOdd()?D:C;if(e.eq(D))return this.isOdd()?D:C;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(w)&&e.lt(w))return m(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,r=65535&this.low,s=e.high>>>16,a=65535&e.high,o=e.low>>>16,d=65535&e.low,l=0,h=0,p=0,f=0;return p+=(f+=r*d)>>>16,h+=(p+=n*d)>>>16,p&=65535,h+=(p+=r*o)>>>16,l+=(h+=i*d)>>>16,h&=65535,l+=(h+=n*o)>>>16,h&=65535,l+=(h+=r*a)>>>16,l+=t*d+i*o+n*a+r*s,v((p&=65535)<<16|(f&=65535),(l&=65535)<<16|(h&=65535),this.unsigned)},I.mul=I.multiply,I.divide=function(e){if(u(e)||(e=b(e)),e.isZero())throw Error("division by zero");var t,i,n;if(c)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?v((this.unsigned?c.div_u:c.div_s)(this.low,this.high,e.low,e.high),c.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?T:C;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return T;if(e.gt(this.shru(1)))return P;n=T}else{if(this.eq(D))return e.eq(E)||e.eq(R)?D:e.eq(D)?E:(t=this.shr(1).div(e).shl(1)).eq(C)?e.isNegative()?E:R:(i=this.sub(e.mul(t)),n=t.add(i.div(e)));if(e.eq(D))return this.unsigned?T:C;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=C}for(i=this;i.gte(e);){t=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var r=Math.ceil(Math.log(t)/Math.LN2),s=r<=48?1:f(2,r-48),a=m(t),o=a.mul(e);o.isNegative()||o.gt(i);)o=(a=m(t-=s,this.unsigned)).mul(e);a.isZero()&&(a=E),n=n.add(a),i=i.sub(o)}return n},I.div=I.divide,I.modulo=function(e){return u(e)||(e=b(e)),c?v((this.unsigned?c.rem_u:c.rem_s)(this.low,this.high,e.low,e.high),c.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},I.mod=I.modulo,I.rem=I.modulo,I.not=function(){return v(~this.low,~this.high,this.unsigned)},I.and=function(e){return u(e)||(e=b(e)),v(this.low&e.low,this.high&e.high,this.unsigned)},I.or=function(e){return u(e)||(e=b(e)),v(this.low|e.low,this.high|e.high,this.unsigned)},I.xor=function(e){return u(e)||(e=b(e)),v(this.low^e.low,this.high^e.high,this.unsigned)},I.shiftLeft=function(e){return u(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?v(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):v(0,this.low<<e-32,this.unsigned)},I.shl=I.shiftLeft,I.shiftRight=function(e){return u(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?v(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):v(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},I.shr=I.shiftRight,I.shiftRightUnsigned=function(e){if(u(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?v(this.low>>>e|t<<32-e,t>>>e,this.unsigned):v(32===e?t:t>>>e-32,0,this.unsigned)},I.shru=I.shiftRightUnsigned,I.shr_u=I.shiftRightUnsigned,I.toSigned=function(){return this.unsigned?v(this.low,this.high,!1):this},I.toUnsigned=function(){return this.unsigned?this:v(this.low,this.high,!0)},I.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},I.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},I.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},d.fromBytes=function(e,t,i){return i?d.fromBytesLE(e,t):d.fromBytesBE(e,t)},d.fromBytesLE=function(e,t){return new d(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},d.fromBytesBE=function(e,t){return new d(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};var A,U,M={},L={get exports(){return M},set exports(e){M=e}},x={},_={};var J,$,B,j,V,F,q,W={};var G,Q,z,H,Z,K,Y={};function X(){return K||(K=1,function(e){var t=e;function n(e,t,i){for(var n=Object.keys(t),r=0;r<n.length;++r)void 0!==e[n[r]]&&i||(e[n[r]]=t[n[r]]);return e}function r(e){function t(e,i){if(!(this instanceof t))return new t(e,i);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),i&&n(this,i)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:()=>e,set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}t.asPromise=(U||(U=1,A=function(e,t){for(var i=new Array(arguments.length-1),n=0,r=2,s=!0;r<arguments.length;)i[n++]=arguments[r++];return new Promise((function(r,a){i[n]=function(e){if(s)if(s=!1,e)a(e);else{for(var t=new Array(arguments.length-1),i=0;i<t.length;)t[i++]=arguments[i];r.apply(null,t)}};try{e.apply(t||null,i)}catch(e){s&&(s=!1,a(e))}}))}),A),t.base64=(J||(J=1,function(e){var t=e;t.length=function(e){var t=e.length;if(!t)return 0;for(var i=0;--t%4>1&&"="===e.charAt(t);)++i;return Math.ceil(3*e.length)/4-i};for(var i=new Array(64),n=new Array(123),r=0;r<64;)n[i[r]=r<26?r+65:r<52?r+71:r<62?r-4:r-59|43]=r++;t.encode=function(e,t,n){for(var r,s=null,a=[],o=0,c=0;t<n;){var d=e[t++];switch(c){case 0:a[o++]=i[d>>2],r=(3&d)<<4,c=1;break;case 1:a[o++]=i[r|d>>4],r=(15&d)<<2,c=2;break;case 2:a[o++]=i[r|d>>6],a[o++]=i[63&d],c=0}o>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,a)),o=0)}return c&&(a[o++]=i[r],a[o++]=61,1===c&&(a[o++]=61)),s?(o&&s.push(String.fromCharCode.apply(String,a.slice(0,o))),s.join("")):String.fromCharCode.apply(String,a.slice(0,o))};var s="invalid encoding";t.decode=function(e,t,i){for(var r,a=i,o=0,c=0;c<e.length;){var d=e.charCodeAt(c++);if(61===d&&o>1)break;if(void 0===(d=n[d]))throw Error(s);switch(o){case 0:r=d,o=1;break;case 1:t[i++]=r<<2|(48&d)>>4,r=d,o=2;break;case 2:t[i++]=(15&r)<<4|(60&d)>>2,r=d,o=3;break;case 3:t[i++]=(3&r)<<6|d,o=0}}if(1===o)throw Error(s);return i-a},t.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}}(W)),W),t.EventEmitter=function(){if(B)return $;function e(){this._listeners={}}return B=1,$=e,e.prototype.on=function(e,t,i){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:i||this}),this},e.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var i=this._listeners[e],n=0;n<i.length;)i[n].fn===t?i.splice(n,1):++n;return this},e.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var i=[],n=1;n<arguments.length;)i.push(arguments[n++]);for(n=0;n<t.length;)t[n].fn.apply(t[n++].ctx,i)}return this},$}(),t.float=function(){if(V)return j;function e(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),i=new Uint8Array(t.buffer),n=128===i[3];function r(e,n,r){t[0]=e,n[r]=i[0],n[r+1]=i[1],n[r+2]=i[2],n[r+3]=i[3]}function s(e,n,r){t[0]=e,n[r]=i[3],n[r+1]=i[2],n[r+2]=i[1],n[r+3]=i[0]}function a(e,n){return i[0]=e[n],i[1]=e[n+1],i[2]=e[n+2],i[3]=e[n+3],t[0]}function o(e,n){return i[3]=e[n],i[2]=e[n+1],i[1]=e[n+2],i[0]=e[n+3],t[0]}e.writeFloatLE=n?r:s,e.writeFloatBE=n?s:r,e.readFloatLE=n?a:o,e.readFloatBE=n?o:a}():function(){function s(e,t,i,n){var r=t<0?1:0;if(r&&(t=-t),0===t)e(1/t>0?0:2147483648,i,n);else if(isNaN(t))e(2143289344,i,n);else if(t>34028234663852886e22)e((r<<31|2139095040)>>>0,i,n);else if(t<11754943508222875e-54)e((r<<31|Math.round(t/1401298464324817e-60))>>>0,i,n);else{var s=Math.floor(Math.log(t)/Math.LN2);e((r<<31|s+127<<23|8388607&Math.round(t*Math.pow(2,-s)*8388608))>>>0,i,n)}}function a(e,t,i){var n=e(t,i),r=2*(n>>31)+1,s=n>>>23&255,a=8388607&n;return 255===s?a?NaN:r*(1/0):0===s?1401298464324817e-60*r*a:r*Math.pow(2,s-150)*(a+8388608)}e.writeFloatLE=s.bind(null,t),e.writeFloatBE=s.bind(null,i),e.readFloatLE=a.bind(null,n),e.readFloatBE=a.bind(null,r)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),i=new Uint8Array(t.buffer),n=128===i[7];function r(e,n,r){t[0]=e,n[r]=i[0],n[r+1]=i[1],n[r+2]=i[2],n[r+3]=i[3],n[r+4]=i[4],n[r+5]=i[5],n[r+6]=i[6],n[r+7]=i[7]}function s(e,n,r){t[0]=e,n[r]=i[7],n[r+1]=i[6],n[r+2]=i[5],n[r+3]=i[4],n[r+4]=i[3],n[r+5]=i[2],n[r+6]=i[1],n[r+7]=i[0]}function a(e,n){return i[0]=e[n],i[1]=e[n+1],i[2]=e[n+2],i[3]=e[n+3],i[4]=e[n+4],i[5]=e[n+5],i[6]=e[n+6],i[7]=e[n+7],t[0]}function o(e,n){return i[7]=e[n],i[6]=e[n+1],i[5]=e[n+2],i[4]=e[n+3],i[3]=e[n+4],i[2]=e[n+5],i[1]=e[n+6],i[0]=e[n+7],t[0]}e.writeDoubleLE=n?r:s,e.writeDoubleBE=n?s:r,e.readDoubleLE=n?a:o,e.readDoubleBE=n?o:a}():function(){function s(e,t,i,n,r,s){var a=n<0?1:0;if(a&&(n=-n),0===n)e(0,r,s+t),e(1/n>0?0:2147483648,r,s+i);else if(isNaN(n))e(0,r,s+t),e(2146959360,r,s+i);else if(n>17976931348623157e292)e(0,r,s+t),e((a<<31|2146435072)>>>0,r,s+i);else{var o;if(n<22250738585072014e-324)e((o=n/5e-324)>>>0,r,s+t),e((a<<31|o/4294967296)>>>0,r,s+i);else{var c=Math.floor(Math.log(n)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(o=n*Math.pow(2,-c))>>>0,r,s+t),e((a<<31|c+1023<<20|1048576*o&1048575)>>>0,r,s+i)}}}function a(e,t,i,n,r){var s=e(n,r+t),a=e(n,r+i),o=2*(a>>31)+1,c=a>>>20&2047,d=4294967296*(1048575&a)+s;return 2047===c?d?NaN:o*(1/0):0===c?5e-324*o*d:o*Math.pow(2,c-1075)*(d+4503599627370496)}e.writeDoubleLE=s.bind(null,t,0,4),e.writeDoubleBE=s.bind(null,i,4,0),e.readDoubleLE=a.bind(null,n,0,4),e.readDoubleBE=a.bind(null,r,4,0)}(),e}function t(e,t,i){t[i]=255&e,t[i+1]=e>>>8&255,t[i+2]=e>>>16&255,t[i+3]=e>>>24}function i(e,t,i){t[i]=e>>>24,t[i+1]=e>>>16&255,t[i+2]=e>>>8&255,t[i+3]=255&e}function n(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function r(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}return V=1,j=e(e)}(),t.inquire=q?F:(q=1,F=function(e){return null}),t.utf8=(G||(G=1,function(e){var t=e;t.length=function(e){for(var t=0,i=0,n=0;n<e.length;++n)(i=e.charCodeAt(n))<128?t+=1:i<2048?t+=2:55296==(64512&i)&&56320==(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t},t.read=function(e,t,i){if(i-t<1)return"";for(var n,r=null,s=[],a=0;t<i;)(n=e[t++])<128?s[a++]=n:n>191&&n<224?s[a++]=(31&n)<<6|63&e[t++]:n>239&&n<365?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,s[a++]=55296+(n>>10),s[a++]=56320+(1023&n)):s[a++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],a>8191&&((r||(r=[])).push(String.fromCharCode.apply(String,s)),a=0);return r?(a&&r.push(String.fromCharCode.apply(String,s.slice(0,a))),r.join("")):String.fromCharCode.apply(String,s.slice(0,a))},t.write=function(e,t,i){for(var n,r,s=i,a=0;a<e.length;++a)(n=e.charCodeAt(a))<128?t[i++]=n:n<2048?(t[i++]=n>>6|192,t[i++]=63&n|128):55296==(64512&n)&&56320==(64512&(r=e.charCodeAt(a+1)))?(n=65536+((1023&n)<<10)+(1023&r),++a,t[i++]=n>>18|240,t[i++]=n>>12&63|128,t[i++]=n>>6&63|128,t[i++]=63&n|128):(t[i++]=n>>12|224,t[i++]=n>>6&63|128,t[i++]=63&n|128);return i-s}}(Y)),Y),t.pool=z?Q:(z=1,Q=function(e,t,i){var n=i||8192,r=n>>>1,s=null,a=n;return function(i){if(i<1||i>r)return e(i);a+i>n&&(s=e(n),a=0);var o=t.call(s,a,a+=i);return 7&a&&(a=1+(7|a)),o}}),t.LongBits=function(){if(Z)return H;Z=1,H=t;var e=X();function t(e,t){this.lo=e>>>0,this.hi=t>>>0}var i=t.zero=new t(0,0);i.toNumber=function(){return 0},i.zzEncode=i.zzDecode=function(){return this},i.length=function(){return 1};var n=t.zeroHash="\0\0\0\0\0\0\0\0";t.fromNumber=function(e){if(0===e)return i;var n=e<0;n&&(e=-e);var r=e>>>0,s=(e-r)/4294967296>>>0;return n&&(s=~s>>>0,r=~r>>>0,++r>4294967295&&(r=0,++s>4294967295&&(s=0))),new t(r,s)},t.from=function(n){if("number"==typeof n)return t.fromNumber(n);if(e.isString(n)){if(!e.Long)return t.fromNumber(parseInt(n,10));n=e.Long.fromString(n)}return n.low||n.high?new t(n.low>>>0,n.high>>>0):i},t.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,i=~this.hi>>>0;return t||(i=i+1>>>0),-(t+4294967296*i)}return this.lo+4294967296*this.hi},t.prototype.toLong=function(t){return e.Long?new e.Long(0|this.lo,0|this.hi,Boolean(t)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(t)}};var r=String.prototype.charCodeAt;return t.fromHash=function(e){return e===n?i:new t((r.call(e,0)|r.call(e,1)<<8|r.call(e,2)<<16|r.call(e,3)<<24)>>>0,(r.call(e,4)|r.call(e,5)<<8|r.call(e,6)<<16|r.call(e,7)<<24)>>>0)},t.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},t.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},t.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},t.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return 0===i?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:i<128?9:10},H}(),t.isNode=Boolean(void 0!==i&&i&&i.process&&i.process.versions&&i.process.versions.node),t.global=t.isNode&&i||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||i,t.emptyArray=Object.freeze?Object.freeze([]):[],t.emptyObject=Object.freeze?Object.freeze({}):{},t.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},t.isString=function(e){return"string"==typeof e||e instanceof String},t.isObject=function(e){return e&&"object"==typeof e},t.isset=t.isSet=function(e,t){var i=e[t];return!(null==i||!e.hasOwnProperty(t))&&("object"!=typeof i||(Array.isArray(i)?i.length:Object.keys(i).length)>0)},t.Buffer=function(){try{var e=t.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),t._Buffer_from=null,t._Buffer_allocUnsafe=null,t.newBuffer=function(e){return"number"==typeof e?t.Buffer?t._Buffer_allocUnsafe(e):new t.Array(e):t.Buffer?t._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},t.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,t.Long=t.global.dcodeIO&&t.global.dcodeIO.Long||t.global.Long||t.inquire("long"),t.key2Re=/^true|false|0|1$/,t.key32Re=/^-?(?:0|[1-9][0-9]*)$/,t.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,t.longToHash=function(e){return e?t.LongBits.from(e).toHash():t.LongBits.zeroHash},t.longFromHash=function(e,i){var n=t.LongBits.fromHash(e);return t.Long?t.Long.fromBits(n.lo,n.hi,i):n.toNumber(Boolean(i))},t.merge=n,t.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},t.newError=r,t.ProtocolError=r("ProtocolError"),t.oneOfGetter=function(e){for(var t={},i=0;i<e.length;++i)t[e[i]]=1;return function(){for(var e=Object.keys(this),i=e.length-1;i>-1;--i)if(1===t[e[i]]&&void 0!==this[e[i]]&&null!==this[e[i]])return e[i]}},t.oneOfSetter=function(e){return function(t){for(var i=0;i<e.length;++i)e[i]!==t&&delete this[e[i]]}},t.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},t._configure=function(){var e=t.Buffer;e?(t._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,i){return new e(t,i)},t._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):t._Buffer_from=t._Buffer_allocUnsafe=null}}(_)),_}var ee,te=de,ie=X(),ne=ie.LongBits,re=ie.base64,se=ie.utf8;function ae(e,t,i){this.fn=e,this.len=t,this.next=void 0,this.val=i}function oe(){}function ce(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function de(){this.len=0,this.head=new ae(oe,0,0),this.tail=this.head,this.states=null}var ue=function(){return ie.Buffer?function(){return(de.create=function(){return new ee})()}:function(){return new de}};function le(e,t,i){t[i]=255&e}function he(e,t){this.len=e,this.next=void 0,this.val=t}function pe(e,t,i){for(;e.hi;)t[i++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[i++]=127&e.lo|128,e.lo=e.lo>>>7;t[i++]=e.lo}function me(e,t,i){t[i]=255&e,t[i+1]=e>>>8&255,t[i+2]=e>>>16&255,t[i+3]=e>>>24}de.create=ue(),de.alloc=function(e){return new ie.Array(e)},ie.Array!==Array&&(de.alloc=ie.pool(de.alloc,ie.Array.prototype.subarray)),de.prototype._push=function(e,t,i){return this.tail=this.tail.next=new ae(e,t,i),this.len+=t,this},he.prototype=Object.create(ae.prototype),he.prototype.fn=function(e,t,i){for(;e>127;)t[i++]=127&e|128,e>>>=7;t[i]=e},de.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new he((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},de.prototype.int32=function(e){return e<0?this._push(pe,10,ne.fromNumber(e)):this.uint32(e)},de.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},de.prototype.uint64=function(e){var t=ne.from(e);return this._push(pe,t.length(),t)},de.prototype.int64=de.prototype.uint64,de.prototype.sint64=function(e){var t=ne.from(e).zzEncode();return this._push(pe,t.length(),t)},de.prototype.bool=function(e){return this._push(le,1,e?1:0)},de.prototype.fixed32=function(e){return this._push(me,4,e>>>0)},de.prototype.sfixed32=de.prototype.fixed32,de.prototype.fixed64=function(e){var t=ne.from(e);return this._push(me,4,t.lo)._push(me,4,t.hi)},de.prototype.sfixed64=de.prototype.fixed64,de.prototype.float=function(e){return this._push(ie.float.writeFloatLE,4,e)},de.prototype.double=function(e){return this._push(ie.float.writeDoubleLE,8,e)};var ve=ie.Array.prototype.set?function(e,t,i){t.set(e,i)}:function(e,t,i){for(var n=0;n<e.length;++n)t[i+n]=e[n]};de.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(le,1,0);if(ie.isString(e)){var i=de.alloc(t=re.length(e));re.decode(e,i,0),e=i}return this.uint32(t)._push(ve,t,e)},de.prototype.string=function(e){var t=se.length(e);return t?this.uint32(t)._push(se.write,t,e):this._push(le,1,0)},de.prototype.fork=function(){return this.states=new ce(this),this.head=this.tail=new ae(oe,0,0),this.len=0,this},de.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new ae(oe,0,0),this.len=0),this},de.prototype.ldelim=function(){var e=this.head,t=this.tail,i=this.len;return this.reset().uint32(i),i&&(this.tail.next=e.next,this.tail=t,this.len+=i),this},de.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),i=0;e;)e.fn(e.val,t,i),i+=e.len,e=e.next;return t},de._configure=function(e){ee=e,de.create=ue(),ee._configure()};var fe=ke,ge=te;(ke.prototype=Object.create(ge.prototype)).constructor=ke;var be=X();function ke(){ge.call(this)}function ye(e,t,i){e.length<40?be.utf8.write(e,t,i):t.utf8Write?t.utf8Write(e,i):t.write(e,i)}ke._configure=function(){ke.alloc=be._Buffer_allocUnsafe,ke.writeBytesBuffer=be.Buffer&&be.Buffer.prototype instanceof Uint8Array&&"set"===be.Buffer.prototype.set.name?function(e,t,i){t.set(e,i)}:function(e,t,i){if(e.copy)e.copy(t,i,0,e.length);else for(var n=0;n<e.length;)t[i++]=e[n++]}},ke.prototype.bytes=function(e){be.isString(e)&&(e=be._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(ke.writeBytesBuffer,t,e),this},ke.prototype.string=function(e){var t=be.Buffer.byteLength(e);return this.uint32(t),t&&this._push(ye,t,e),this},ke._configure();var Se,we=Re,Ce=X(),Te=Ce.LongBits,Ee=Ce.utf8;function Pe(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function Re(e){this.buf=e,this.pos=0,this.len=e.length}var Oe,Ne="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new Re(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new Re(e);throw Error("illegal buffer")},De=function(){return Ce.Buffer?function(e){return(Re.create=function(e){return Ce.Buffer.isBuffer(e)?new Se(e):Ne(e)})(e)}:Ne};function Ie(){var e=new Te(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw Pe(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Pe(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function Ae(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function Ue(){if(this.pos+8>this.len)throw Pe(this,8);return new Te(Ae(this.buf,this.pos+=4),Ae(this.buf,this.pos+=4))}Re.create=De(),Re.prototype._slice=Ce.Array.prototype.subarray||Ce.Array.prototype.slice,Re.prototype.uint32=(Oe=4294967295,function(){if(Oe=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return Oe;if(Oe=(Oe|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return Oe;if(Oe=(Oe|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return Oe;if(Oe=(Oe|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return Oe;if(Oe=(Oe|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return Oe;if((this.pos+=5)>this.len)throw this.pos=this.len,Pe(this,10);return Oe}),Re.prototype.int32=function(){return 0|this.uint32()},Re.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},Re.prototype.bool=function(){return 0!==this.uint32()},Re.prototype.fixed32=function(){if(this.pos+4>this.len)throw Pe(this,4);return Ae(this.buf,this.pos+=4)},Re.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Pe(this,4);return 0|Ae(this.buf,this.pos+=4)},Re.prototype.float=function(){if(this.pos+4>this.len)throw Pe(this,4);var e=Ce.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},Re.prototype.double=function(){if(this.pos+8>this.len)throw Pe(this,4);var e=Ce.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},Re.prototype.bytes=function(){var e=this.uint32(),t=this.pos,i=this.pos+e;if(i>this.len)throw Pe(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,i):t===i?new this.buf.constructor(0):this._slice.call(this.buf,t,i)},Re.prototype.string=function(){var e=this.bytes();return Ee.read(e,0,e.length)},Re.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw Pe(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw Pe(this)}while(128&this.buf[this.pos++]);return this},Re.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},Re._configure=function(e){Se=e,Re.create=De(),Se._configure();var t=Ce.Long?"toLong":"toNumber";Ce.merge(Re.prototype,{int64:function(){return Ie.call(this)[t](!1)},uint64:function(){return Ie.call(this)[t](!0)},sint64:function(){return Ie.call(this).zzDecode()[t](!1)},fixed64:function(){return Ue.call(this)[t](!0)},sfixed64:function(){return Ue.call(this)[t](!1)}})};var Me=_e,Le=we;(_e.prototype=Object.create(Le.prototype)).constructor=_e;var xe=X();function _e(e){Le.call(this,e)}_e._configure=function(){xe.Buffer&&(_e.prototype._slice=xe.Buffer.prototype.slice)},_e.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},_e._configure();var Je={},$e=je,Be=X();function je(e,t,i){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");Be.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(i)}(je.prototype=Object.create(Be.EventEmitter.prototype)).constructor=je,je.prototype.rpcCall=function e(t,i,n,r,s){if(!r)throw TypeError("request must be specified");var a=this;if(!s)return Be.asPromise(e,a,t,i,n,r);if(a.rpcImpl)try{return a.rpcImpl(t,i[a.requestDelimited?"encodeDelimited":"encode"](r).finish(),(function(e,i){if(e)return a.emit("error",e,t),s(e);if(null!==i){if(!(i instanceof n))try{i=n[a.responseDelimited?"decodeDelimited":"decode"](i)}catch(e){return a.emit("error",e,t),s(e)}return a.emit("data",i,t),s(null,i)}a.end(!0)}))}catch(e){return a.emit("error",e,t),void setTimeout((function(){s(e)}),0)}else setTimeout((function(){s(Error("already ended"))}),0)},je.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},function(e){e.Service=$e}(Je);var Ve={};!function(e){var t=e;function i(){t.util._configure(),t.Writer._configure(t.BufferWriter),t.Reader._configure(t.BufferReader)}t.build="minimal",t.Writer=te,t.BufferWriter=fe,t.Reader=we,t.BufferReader=Me,t.util=X(),t.rpc=Je,t.roots=Ve,t.configure=i,i()}(x),function(e){e.exports=x}(L);var Fe,qe,We,Ge,Qe,ze,He,Ze,Ke,Ye,Xe,et=n(M);function tt(e){switch(e){case 0:case"AUDIO":return Fe.AUDIO;case 1:case"VIDEO":return Fe.VIDEO;case 2:case"DATA":return Fe.DATA;default:return Fe.UNRECOGNIZED}}function it(e){switch(e){case Fe.AUDIO:return"AUDIO";case Fe.VIDEO:return"VIDEO";case Fe.DATA:return"DATA";case Fe.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function nt(e){switch(e){case 0:case"UNKNOWN":return qe.UNKNOWN;case 1:case"CAMERA":return qe.CAMERA;case 2:case"MICROPHONE":return qe.MICROPHONE;case 3:case"SCREEN_SHARE":return qe.SCREEN_SHARE;case 4:case"SCREEN_SHARE_AUDIO":return qe.SCREEN_SHARE_AUDIO;default:return qe.UNRECOGNIZED}}function rt(e){switch(e){case qe.UNKNOWN:return"UNKNOWN";case qe.CAMERA:return"CAMERA";case qe.MICROPHONE:return"MICROPHONE";case qe.SCREEN_SHARE:return"SCREEN_SHARE";case qe.SCREEN_SHARE_AUDIO:return"SCREEN_SHARE_AUDIO";case qe.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function st(t){switch(t){case 0:case"LOW":return e.VideoQuality.LOW;case 1:case"MEDIUM":return e.VideoQuality.MEDIUM;case 2:case"HIGH":return e.VideoQuality.HIGH;case 3:case"OFF":return e.VideoQuality.OFF;default:return e.VideoQuality.UNRECOGNIZED}}function at(t){switch(t){case e.VideoQuality.LOW:return"LOW";case e.VideoQuality.MEDIUM:return"MEDIUM";case e.VideoQuality.HIGH:return"HIGH";case e.VideoQuality.OFF:return"OFF";case e.VideoQuality.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function ot(e){switch(e){case 0:case"POOR":return Ge.POOR;case 1:case"GOOD":return Ge.GOOD;case 2:case"EXCELLENT":return Ge.EXCELLENT;default:return Ge.UNRECOGNIZED}}function ct(e){switch(e){case 0:case"UNSET":return Qe.UNSET;case 1:case"DISABLED":return Qe.DISABLED;case 2:case"ENABLED":return Qe.ENABLED;default:return Qe.UNRECOGNIZED}}function dt(e){switch(e){case Qe.UNSET:return"UNSET";case Qe.DISABLED:return"DISABLED";case Qe.ENABLED:return"ENABLED";case Qe.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function ut(t){switch(t){case 0:case"UNKNOWN_REASON":return e.DisconnectReason.UNKNOWN_REASON;case 1:case"CLIENT_INITIATED":return e.DisconnectReason.CLIENT_INITIATED;case 2:case"DUPLICATE_IDENTITY":return e.DisconnectReason.DUPLICATE_IDENTITY;case 3:case"SERVER_SHUTDOWN":return e.DisconnectReason.SERVER_SHUTDOWN;case 4:case"PARTICIPANT_REMOVED":return e.DisconnectReason.PARTICIPANT_REMOVED;case 5:case"ROOM_DELETED":return e.DisconnectReason.ROOM_DELETED;case 6:case"STATE_MISMATCH":return e.DisconnectReason.STATE_MISMATCH;case 7:case"JOIN_FAILURE":return e.DisconnectReason.JOIN_FAILURE;default:return e.DisconnectReason.UNRECOGNIZED}}function lt(e){switch(e){case 0:case"JOINING":return He.JOINING;case 1:case"JOINED":return He.JOINED;case 2:case"ACTIVE":return He.ACTIVE;case 3:case"DISCONNECTED":return He.DISCONNECTED;default:return He.UNRECOGNIZED}}function ht(e){switch(e){case 0:case"NONE":return Ze.NONE;case 1:case"GCM":return Ze.GCM;case 2:case"CUSTOM":return Ze.CUSTOM;default:return Ze.UNRECOGNIZED}}function pt(e){switch(e){case Ze.NONE:return"NONE";case Ze.GCM:return"GCM";case Ze.CUSTOM:return"CUSTOM";case Ze.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function mt(t){switch(t){case 0:case"RELIABLE":return e.DataPacket_Kind.RELIABLE;case 1:case"LOSSY":return e.DataPacket_Kind.LOSSY;default:return e.DataPacket_Kind.UNRECOGNIZED}}function vt(e){switch(e){case 0:case"Standard":return Ye.Standard;case 1:case"Cloud":return Ye.Cloud;default:return Ye.UNRECOGNIZED}}function ft(e){switch(e){case 0:case"UNKNOWN":return Xe.UNKNOWN;case 1:case"JS":return Xe.JS;case 2:case"SWIFT":return Xe.SWIFT;case 3:case"ANDROID":return Xe.ANDROID;case 4:case"FLUTTER":return Xe.FLUTTER;case 5:case"GO":return Xe.GO;case 6:case"UNITY":return Xe.UNITY;default:return Xe.UNRECOGNIZED}}(()=>{if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw"Unable to locate global object"})(),et.util.Long!==o&&(et.util.Long=o,et.configure()),function(e){e[e.AUDIO=0]="AUDIO",e[e.VIDEO=1]="VIDEO",e[e.DATA=2]="DATA",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Fe||(Fe={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.CAMERA=1]="CAMERA",e[e.MICROPHONE=2]="MICROPHONE",e[e.SCREEN_SHARE=3]="SCREEN_SHARE",e[e.SCREEN_SHARE_AUDIO=4]="SCREEN_SHARE_AUDIO",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(qe||(qe={})),e.VideoQuality=void 0,(We=e.VideoQuality||(e.VideoQuality={}))[We.LOW=0]="LOW",We[We.MEDIUM=1]="MEDIUM",We[We.HIGH=2]="HIGH",We[We.OFF=3]="OFF",We[We.UNRECOGNIZED=-1]="UNRECOGNIZED",function(e){e[e.POOR=0]="POOR",e[e.GOOD=1]="GOOD",e[e.EXCELLENT=2]="EXCELLENT",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ge||(Ge={})),function(e){e[e.UNSET=0]="UNSET",e[e.DISABLED=1]="DISABLED",e[e.ENABLED=2]="ENABLED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Qe||(Qe={})),e.DisconnectReason=void 0,(ze=e.DisconnectReason||(e.DisconnectReason={}))[ze.UNKNOWN_REASON=0]="UNKNOWN_REASON",ze[ze.CLIENT_INITIATED=1]="CLIENT_INITIATED",ze[ze.DUPLICATE_IDENTITY=2]="DUPLICATE_IDENTITY",ze[ze.SERVER_SHUTDOWN=3]="SERVER_SHUTDOWN",ze[ze.PARTICIPANT_REMOVED=4]="PARTICIPANT_REMOVED",ze[ze.ROOM_DELETED=5]="ROOM_DELETED",ze[ze.STATE_MISMATCH=6]="STATE_MISMATCH",ze[ze.JOIN_FAILURE=7]="JOIN_FAILURE",ze[ze.UNRECOGNIZED=-1]="UNRECOGNIZED",function(e){e[e.JOINING=0]="JOINING",e[e.JOINED=1]="JOINED",e[e.ACTIVE=2]="ACTIVE",e[e.DISCONNECTED=3]="DISCONNECTED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(He||(He={})),function(e){e[e.NONE=0]="NONE",e[e.GCM=1]="GCM",e[e.CUSTOM=2]="CUSTOM",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ze||(Ze={})),e.DataPacket_Kind=void 0,(Ke=e.DataPacket_Kind||(e.DataPacket_Kind={}))[Ke.RELIABLE=0]="RELIABLE",Ke[Ke.LOSSY=1]="LOSSY",Ke[Ke.UNRECOGNIZED=-1]="UNRECOGNIZED",function(e){e[e.Standard=0]="Standard",e[e.Cloud=1]="Cloud",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ye||(Ye={})),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.JS=1]="JS",e[e.SWIFT=2]="SWIFT",e[e.ANDROID=3]="ANDROID",e[e.FLUTTER=4]="FLUTTER",e[e.GO=5]="GO",e[e.UNITY=6]="UNITY",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Xe||(Xe={}));const gt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();""!==e.sid&&t.uint32(10).string(e.sid),""!==e.name&&t.uint32(18).string(e.name),0!==e.emptyTimeout&&t.uint32(24).uint32(e.emptyTimeout),0!==e.maxParticipants&&t.uint32(32).uint32(e.maxParticipants),0!==e.creationTime&&t.uint32(40).int64(e.creationTime),""!==e.turnPassword&&t.uint32(50).string(e.turnPassword);for(const i of e.enabledCodecs)bt.encode(i,t.uint32(58).fork()).ldelim();return""!==e.metadata&&t.uint32(66).string(e.metadata),0!==e.numParticipants&&t.uint32(72).uint32(e.numParticipants),!0===e.activeRecording&&t.uint32(80).bool(e.activeRecording),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={sid:"",name:"",emptyTimeout:0,maxParticipants:0,creationTime:0,turnPassword:"",enabledCodecs:[],metadata:"",numParticipants:0,activeRecording:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.sid=i.string();break;case 2:r.name=i.string();break;case 3:r.emptyTimeout=i.uint32();break;case 4:r.maxParticipants=i.uint32();break;case 5:r.creationTime=_t(i.int64());break;case 6:r.turnPassword=i.string();break;case 7:r.enabledCodecs.push(bt.decode(i,i.uint32()));break;case 8:r.metadata=i.string();break;case 9:r.numParticipants=i.uint32();break;case 10:r.activeRecording=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({sid:Jt(e.sid)?String(e.sid):"",name:Jt(e.name)?String(e.name):"",emptyTimeout:Jt(e.emptyTimeout)?Number(e.emptyTimeout):0,maxParticipants:Jt(e.maxParticipants)?Number(e.maxParticipants):0,creationTime:Jt(e.creationTime)?Number(e.creationTime):0,turnPassword:Jt(e.turnPassword)?String(e.turnPassword):"",enabledCodecs:Array.isArray(null==e?void 0:e.enabledCodecs)?e.enabledCodecs.map((e=>bt.fromJSON(e))):[],metadata:Jt(e.metadata)?String(e.metadata):"",numParticipants:Jt(e.numParticipants)?Number(e.numParticipants):0,activeRecording:!!Jt(e.activeRecording)&&Boolean(e.activeRecording)}),toJSON(e){const t={};return void 0!==e.sid&&(t.sid=e.sid),void 0!==e.name&&(t.name=e.name),void 0!==e.emptyTimeout&&(t.emptyTimeout=Math.round(e.emptyTimeout)),void 0!==e.maxParticipants&&(t.maxParticipants=Math.round(e.maxParticipants)),void 0!==e.creationTime&&(t.creationTime=Math.round(e.creationTime)),void 0!==e.turnPassword&&(t.turnPassword=e.turnPassword),e.enabledCodecs?t.enabledCodecs=e.enabledCodecs.map((e=>e?bt.toJSON(e):void 0)):t.enabledCodecs=[],void 0!==e.metadata&&(t.metadata=e.metadata),void 0!==e.numParticipants&&(t.numParticipants=Math.round(e.numParticipants)),void 0!==e.activeRecording&&(t.activeRecording=e.activeRecording),t},fromPartial(e){var t,i,n,r,s,a,o,c,d,u;const l={sid:"",name:"",emptyTimeout:0,maxParticipants:0,creationTime:0,turnPassword:"",enabledCodecs:[],metadata:"",numParticipants:0,activeRecording:!1};return l.sid=null!==(t=e.sid)&&void 0!==t?t:"",l.name=null!==(i=e.name)&&void 0!==i?i:"",l.emptyTimeout=null!==(n=e.emptyTimeout)&&void 0!==n?n:0,l.maxParticipants=null!==(r=e.maxParticipants)&&void 0!==r?r:0,l.creationTime=null!==(s=e.creationTime)&&void 0!==s?s:0,l.turnPassword=null!==(a=e.turnPassword)&&void 0!==a?a:"",l.enabledCodecs=(null===(o=e.enabledCodecs)||void 0===o?void 0:o.map((e=>bt.fromPartial(e))))||[],l.metadata=null!==(c=e.metadata)&&void 0!==c?c:"",l.numParticipants=null!==(d=e.numParticipants)&&void 0!==d?d:0,l.activeRecording=null!==(u=e.activeRecording)&&void 0!==u&&u,l}};const bt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.mime&&t.uint32(10).string(e.mime),""!==e.fmtpLine&&t.uint32(18).string(e.fmtpLine),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={mime:"",fmtpLine:""};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.mime=i.string();break;case 2:r.fmtpLine=i.string();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({mime:Jt(e.mime)?String(e.mime):"",fmtpLine:Jt(e.fmtpLine)?String(e.fmtpLine):""}),toJSON(e){const t={};return void 0!==e.mime&&(t.mime=e.mime),void 0!==e.fmtpLine&&(t.fmtpLine=e.fmtpLine),t},fromPartial(e){var t,i;const n={mime:"",fmtpLine:""};return n.mime=null!==(t=e.mime)&&void 0!==t?t:"",n.fmtpLine=null!==(i=e.fmtpLine)&&void 0!==i?i:"",n}};const kt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();!0===e.canSubscribe&&t.uint32(8).bool(e.canSubscribe),!0===e.canPublish&&t.uint32(16).bool(e.canPublish),!0===e.canPublishData&&t.uint32(24).bool(e.canPublishData),t.uint32(74).fork();for(const i of e.canPublishSources)t.int32(i);return t.ldelim(),!0===e.hidden&&t.uint32(56).bool(e.hidden),!0===e.recorder&&t.uint32(64).bool(e.recorder),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={canSubscribe:!1,canPublish:!1,canPublishData:!1,canPublishSources:[],hidden:!1,recorder:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.canSubscribe=i.bool();break;case 2:r.canPublish=i.bool();break;case 3:r.canPublishData=i.bool();break;case 9:if(2==(7&e)){const e=i.uint32()+i.pos;for(;i.pos<e;)r.canPublishSources.push(i.int32())}else r.canPublishSources.push(i.int32());break;case 7:r.hidden=i.bool();break;case 8:r.recorder=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({canSubscribe:!!Jt(e.canSubscribe)&&Boolean(e.canSubscribe),canPublish:!!Jt(e.canPublish)&&Boolean(e.canPublish),canPublishData:!!Jt(e.canPublishData)&&Boolean(e.canPublishData),canPublishSources:Array.isArray(null==e?void 0:e.canPublishSources)?e.canPublishSources.map((e=>nt(e))):[],hidden:!!Jt(e.hidden)&&Boolean(e.hidden),recorder:!!Jt(e.recorder)&&Boolean(e.recorder)}),toJSON(e){const t={};return void 0!==e.canSubscribe&&(t.canSubscribe=e.canSubscribe),void 0!==e.canPublish&&(t.canPublish=e.canPublish),void 0!==e.canPublishData&&(t.canPublishData=e.canPublishData),e.canPublishSources?t.canPublishSources=e.canPublishSources.map((e=>rt(e))):t.canPublishSources=[],void 0!==e.hidden&&(t.hidden=e.hidden),void 0!==e.recorder&&(t.recorder=e.recorder),t},fromPartial(e){var t,i,n,r,s,a;const o={canSubscribe:!1,canPublish:!1,canPublishData:!1,canPublishSources:[],hidden:!1,recorder:!1};return o.canSubscribe=null!==(t=e.canSubscribe)&&void 0!==t&&t,o.canPublish=null!==(i=e.canPublish)&&void 0!==i&&i,o.canPublishData=null!==(n=e.canPublishData)&&void 0!==n&&n,o.canPublishSources=(null===(r=e.canPublishSources)||void 0===r?void 0:r.map((e=>e)))||[],o.hidden=null!==(s=e.hidden)&&void 0!==s&&s,o.recorder=null!==(a=e.recorder)&&void 0!==a&&a,o}};const yt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();""!==e.sid&&t.uint32(10).string(e.sid),""!==e.identity&&t.uint32(18).string(e.identity),0!==e.state&&t.uint32(24).int32(e.state);for(const i of e.tracks)wt.encode(i,t.uint32(34).fork()).ldelim();return""!==e.metadata&&t.uint32(42).string(e.metadata),0!==e.joinedAt&&t.uint32(48).int64(e.joinedAt),""!==e.name&&t.uint32(74).string(e.name),0!==e.version&&t.uint32(80).uint32(e.version),void 0!==e.permission&&kt.encode(e.permission,t.uint32(90).fork()).ldelim(),""!==e.region&&t.uint32(98).string(e.region),!0===e.isPublisher&&t.uint32(104).bool(e.isPublisher),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={sid:"",identity:"",state:0,tracks:[],metadata:"",joinedAt:0,name:"",version:0,permission:void 0,region:"",isPublisher:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.sid=i.string();break;case 2:r.identity=i.string();break;case 3:r.state=i.int32();break;case 4:r.tracks.push(wt.decode(i,i.uint32()));break;case 5:r.metadata=i.string();break;case 6:r.joinedAt=_t(i.int64());break;case 9:r.name=i.string();break;case 10:r.version=i.uint32();break;case 11:r.permission=kt.decode(i,i.uint32());break;case 12:r.region=i.string();break;case 13:r.isPublisher=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({sid:Jt(e.sid)?String(e.sid):"",identity:Jt(e.identity)?String(e.identity):"",state:Jt(e.state)?lt(e.state):0,tracks:Array.isArray(null==e?void 0:e.tracks)?e.tracks.map((e=>wt.fromJSON(e))):[],metadata:Jt(e.metadata)?String(e.metadata):"",joinedAt:Jt(e.joinedAt)?Number(e.joinedAt):0,name:Jt(e.name)?String(e.name):"",version:Jt(e.version)?Number(e.version):0,permission:Jt(e.permission)?kt.fromJSON(e.permission):void 0,region:Jt(e.region)?String(e.region):"",isPublisher:!!Jt(e.isPublisher)&&Boolean(e.isPublisher)}),toJSON(e){const t={};return void 0!==e.sid&&(t.sid=e.sid),void 0!==e.identity&&(t.identity=e.identity),void 0!==e.state&&(t.state=function(e){switch(e){case He.JOINING:return"JOINING";case He.JOINED:return"JOINED";case He.ACTIVE:return"ACTIVE";case He.DISCONNECTED:return"DISCONNECTED";case He.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.state)),e.tracks?t.tracks=e.tracks.map((e=>e?wt.toJSON(e):void 0)):t.tracks=[],void 0!==e.metadata&&(t.metadata=e.metadata),void 0!==e.joinedAt&&(t.joinedAt=Math.round(e.joinedAt)),void 0!==e.name&&(t.name=e.name),void 0!==e.version&&(t.version=Math.round(e.version)),void 0!==e.permission&&(t.permission=e.permission?kt.toJSON(e.permission):void 0),void 0!==e.region&&(t.region=e.region),void 0!==e.isPublisher&&(t.isPublisher=e.isPublisher),t},fromPartial(e){var t,i,n,r,s,a,o,c,d,u;const l={sid:"",identity:"",state:0,tracks:[],metadata:"",joinedAt:0,name:"",version:0,permission:void 0,region:"",isPublisher:!1};return l.sid=null!==(t=e.sid)&&void 0!==t?t:"",l.identity=null!==(i=e.identity)&&void 0!==i?i:"",l.state=null!==(n=e.state)&&void 0!==n?n:0,l.tracks=(null===(r=e.tracks)||void 0===r?void 0:r.map((e=>wt.fromPartial(e))))||[],l.metadata=null!==(s=e.metadata)&&void 0!==s?s:"",l.joinedAt=null!==(a=e.joinedAt)&&void 0!==a?a:0,l.name=null!==(o=e.name)&&void 0!==o?o:"",l.version=null!==(c=e.version)&&void 0!==c?c:0,l.permission=void 0!==e.permission&&null!==e.permission?kt.fromPartial(e.permission):void 0,l.region=null!==(d=e.region)&&void 0!==d?d:"",l.isPublisher=null!==(u=e.isPublisher)&&void 0!==u&&u,l}};const St={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();""!==e.mimeType&&t.uint32(10).string(e.mimeType),""!==e.mid&&t.uint32(18).string(e.mid),""!==e.cid&&t.uint32(26).string(e.cid);for(const i of e.layers)Ct.encode(i,t.uint32(34).fork()).ldelim();return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={mimeType:"",mid:"",cid:"",layers:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.mimeType=i.string();break;case 2:r.mid=i.string();break;case 3:r.cid=i.string();break;case 4:r.layers.push(Ct.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({mimeType:Jt(e.mimeType)?String(e.mimeType):"",mid:Jt(e.mid)?String(e.mid):"",cid:Jt(e.cid)?String(e.cid):"",layers:Array.isArray(null==e?void 0:e.layers)?e.layers.map((e=>Ct.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.mimeType&&(t.mimeType=e.mimeType),void 0!==e.mid&&(t.mid=e.mid),void 0!==e.cid&&(t.cid=e.cid),e.layers?t.layers=e.layers.map((e=>e?Ct.toJSON(e):void 0)):t.layers=[],t},fromPartial(e){var t,i,n,r;const s={mimeType:"",mid:"",cid:"",layers:[]};return s.mimeType=null!==(t=e.mimeType)&&void 0!==t?t:"",s.mid=null!==(i=e.mid)&&void 0!==i?i:"",s.cid=null!==(n=e.cid)&&void 0!==n?n:"",s.layers=(null===(r=e.layers)||void 0===r?void 0:r.map((e=>Ct.fromPartial(e))))||[],s}};const wt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();""!==e.sid&&t.uint32(10).string(e.sid),0!==e.type&&t.uint32(16).int32(e.type),""!==e.name&&t.uint32(26).string(e.name),!0===e.muted&&t.uint32(32).bool(e.muted),0!==e.width&&t.uint32(40).uint32(e.width),0!==e.height&&t.uint32(48).uint32(e.height),!0===e.simulcast&&t.uint32(56).bool(e.simulcast),!0===e.disableDtx&&t.uint32(64).bool(e.disableDtx),0!==e.source&&t.uint32(72).int32(e.source);for(const i of e.layers)Ct.encode(i,t.uint32(82).fork()).ldelim();""!==e.mimeType&&t.uint32(90).string(e.mimeType),""!==e.mid&&t.uint32(98).string(e.mid);for(const i of e.codecs)St.encode(i,t.uint32(106).fork()).ldelim();return!0===e.stereo&&t.uint32(112).bool(e.stereo),!0===e.disableRed&&t.uint32(120).bool(e.disableRed),0!==e.encryption&&t.uint32(128).int32(e.encryption),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={sid:"",type:0,name:"",muted:!1,width:0,height:0,simulcast:!1,disableDtx:!1,source:0,layers:[],mimeType:"",mid:"",codecs:[],stereo:!1,disableRed:!1,encryption:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.sid=i.string();break;case 2:r.type=i.int32();break;case 3:r.name=i.string();break;case 4:r.muted=i.bool();break;case 5:r.width=i.uint32();break;case 6:r.height=i.uint32();break;case 7:r.simulcast=i.bool();break;case 8:r.disableDtx=i.bool();break;case 9:r.source=i.int32();break;case 10:r.layers.push(Ct.decode(i,i.uint32()));break;case 11:r.mimeType=i.string();break;case 12:r.mid=i.string();break;case 13:r.codecs.push(St.decode(i,i.uint32()));break;case 14:r.stereo=i.bool();break;case 15:r.disableRed=i.bool();break;case 16:r.encryption=i.int32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({sid:Jt(e.sid)?String(e.sid):"",type:Jt(e.type)?tt(e.type):0,name:Jt(e.name)?String(e.name):"",muted:!!Jt(e.muted)&&Boolean(e.muted),width:Jt(e.width)?Number(e.width):0,height:Jt(e.height)?Number(e.height):0,simulcast:!!Jt(e.simulcast)&&Boolean(e.simulcast),disableDtx:!!Jt(e.disableDtx)&&Boolean(e.disableDtx),source:Jt(e.source)?nt(e.source):0,layers:Array.isArray(null==e?void 0:e.layers)?e.layers.map((e=>Ct.fromJSON(e))):[],mimeType:Jt(e.mimeType)?String(e.mimeType):"",mid:Jt(e.mid)?String(e.mid):"",codecs:Array.isArray(null==e?void 0:e.codecs)?e.codecs.map((e=>St.fromJSON(e))):[],stereo:!!Jt(e.stereo)&&Boolean(e.stereo),disableRed:!!Jt(e.disableRed)&&Boolean(e.disableRed),encryption:Jt(e.encryption)?ht(e.encryption):0}),toJSON(e){const t={};return void 0!==e.sid&&(t.sid=e.sid),void 0!==e.type&&(t.type=it(e.type)),void 0!==e.name&&(t.name=e.name),void 0!==e.muted&&(t.muted=e.muted),void 0!==e.width&&(t.width=Math.round(e.width)),void 0!==e.height&&(t.height=Math.round(e.height)),void 0!==e.simulcast&&(t.simulcast=e.simulcast),void 0!==e.disableDtx&&(t.disableDtx=e.disableDtx),void 0!==e.source&&(t.source=rt(e.source)),e.layers?t.layers=e.layers.map((e=>e?Ct.toJSON(e):void 0)):t.layers=[],void 0!==e.mimeType&&(t.mimeType=e.mimeType),void 0!==e.mid&&(t.mid=e.mid),e.codecs?t.codecs=e.codecs.map((e=>e?St.toJSON(e):void 0)):t.codecs=[],void 0!==e.stereo&&(t.stereo=e.stereo),void 0!==e.disableRed&&(t.disableRed=e.disableRed),void 0!==e.encryption&&(t.encryption=pt(e.encryption)),t},fromPartial(e){var t,i,n,r,s,a,o,c,d,u,l,h,p,m,v,f;const g={sid:"",type:0,name:"",muted:!1,width:0,height:0,simulcast:!1,disableDtx:!1,source:0,layers:[],mimeType:"",mid:"",codecs:[],stereo:!1,disableRed:!1,encryption:0};return g.sid=null!==(t=e.sid)&&void 0!==t?t:"",g.type=null!==(i=e.type)&&void 0!==i?i:0,g.name=null!==(n=e.name)&&void 0!==n?n:"",g.muted=null!==(r=e.muted)&&void 0!==r&&r,g.width=null!==(s=e.width)&&void 0!==s?s:0,g.height=null!==(a=e.height)&&void 0!==a?a:0,g.simulcast=null!==(o=e.simulcast)&&void 0!==o&&o,g.disableDtx=null!==(c=e.disableDtx)&&void 0!==c&&c,g.source=null!==(d=e.source)&&void 0!==d?d:0,g.layers=(null===(u=e.layers)||void 0===u?void 0:u.map((e=>Ct.fromPartial(e))))||[],g.mimeType=null!==(l=e.mimeType)&&void 0!==l?l:"",g.mid=null!==(h=e.mid)&&void 0!==h?h:"",g.codecs=(null===(p=e.codecs)||void 0===p?void 0:p.map((e=>St.fromPartial(e))))||[],g.stereo=null!==(m=e.stereo)&&void 0!==m&&m,g.disableRed=null!==(v=e.disableRed)&&void 0!==v&&v,g.encryption=null!==(f=e.encryption)&&void 0!==f?f:0,g}};const Ct={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return 0!==e.quality&&t.uint32(8).int32(e.quality),0!==e.width&&t.uint32(16).uint32(e.width),0!==e.height&&t.uint32(24).uint32(e.height),0!==e.bitrate&&t.uint32(32).uint32(e.bitrate),0!==e.ssrc&&t.uint32(40).uint32(e.ssrc),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={quality:0,width:0,height:0,bitrate:0,ssrc:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.quality=i.int32();break;case 2:r.width=i.uint32();break;case 3:r.height=i.uint32();break;case 4:r.bitrate=i.uint32();break;case 5:r.ssrc=i.uint32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({quality:Jt(e.quality)?st(e.quality):0,width:Jt(e.width)?Number(e.width):0,height:Jt(e.height)?Number(e.height):0,bitrate:Jt(e.bitrate)?Number(e.bitrate):0,ssrc:Jt(e.ssrc)?Number(e.ssrc):0}),toJSON(e){const t={};return void 0!==e.quality&&(t.quality=at(e.quality)),void 0!==e.width&&(t.width=Math.round(e.width)),void 0!==e.height&&(t.height=Math.round(e.height)),void 0!==e.bitrate&&(t.bitrate=Math.round(e.bitrate)),void 0!==e.ssrc&&(t.ssrc=Math.round(e.ssrc)),t},fromPartial(e){var t,i,n,r,s;const a={quality:0,width:0,height:0,bitrate:0,ssrc:0};return a.quality=null!==(t=e.quality)&&void 0!==t?t:0,a.width=null!==(i=e.width)&&void 0!==i?i:0,a.height=null!==(n=e.height)&&void 0!==n?n:0,a.bitrate=null!==(r=e.bitrate)&&void 0!==r?r:0,a.ssrc=null!==(s=e.ssrc)&&void 0!==s?s:0,a}};const Tt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();var i,n;return 0!==e.kind&&t.uint32(8).int32(e.kind),"user"===(null===(i=e.value)||void 0===i?void 0:i.$case)&&Ot.encode(e.value.user,t.uint32(18).fork()).ldelim(),"speaker"===(null===(n=e.value)||void 0===n?void 0:n.$case)&&Et.encode(e.value.speaker,t.uint32(26).fork()).ldelim(),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={kind:0,value:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.kind=i.int32();break;case 2:r.value={$case:"user",user:Ot.decode(i,i.uint32())};break;case 3:r.value={$case:"speaker",speaker:Et.decode(i,i.uint32())};break;default:i.skipType(7&e)}}return r},fromJSON:e=>({kind:Jt(e.kind)?mt(e.kind):0,value:Jt(e.user)?{$case:"user",user:Ot.fromJSON(e.user)}:Jt(e.speaker)?{$case:"speaker",speaker:Et.fromJSON(e.speaker)}:void 0}),toJSON(t){var i,n,r,s,a,o;const c={};return void 0!==t.kind&&(c.kind=function(t){switch(t){case e.DataPacket_Kind.RELIABLE:return"RELIABLE";case e.DataPacket_Kind.LOSSY:return"LOSSY";case e.DataPacket_Kind.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(t.kind)),"user"===(null===(i=t.value)||void 0===i?void 0:i.$case)&&(c.user=(null===(n=t.value)||void 0===n?void 0:n.user)?Ot.toJSON(null===(r=t.value)||void 0===r?void 0:r.user):void 0),"speaker"===(null===(s=t.value)||void 0===s?void 0:s.$case)&&(c.speaker=(null===(a=t.value)||void 0===a?void 0:a.speaker)?Et.toJSON(null===(o=t.value)||void 0===o?void 0:o.speaker):void 0),c},fromPartial(e){var t,i,n,r,s,a,o;const c={kind:0,value:void 0};return c.kind=null!==(t=e.kind)&&void 0!==t?t:0,"user"===(null===(i=e.value)||void 0===i?void 0:i.$case)&&void 0!==(null===(n=e.value)||void 0===n?void 0:n.user)&&null!==(null===(r=e.value)||void 0===r?void 0:r.user)&&(c.value={$case:"user",user:Ot.fromPartial(e.value.user)}),"speaker"===(null===(s=e.value)||void 0===s?void 0:s.$case)&&void 0!==(null===(a=e.value)||void 0===a?void 0:a.speaker)&&null!==(null===(o=e.value)||void 0===o?void 0:o.speaker)&&(c.value={$case:"speaker",speaker:Et.fromPartial(e.value.speaker)}),c}};const Et={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();for(const i of e.speakers)Pt.encode(i,t.uint32(10).fork()).ldelim();return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={speakers:[]};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.speakers.push(Pt.decode(i,i.uint32()));else i.skipType(7&e)}return r},fromJSON:e=>({speakers:Array.isArray(null==e?void 0:e.speakers)?e.speakers.map((e=>Pt.fromJSON(e))):[]}),toJSON(e){const t={};return e.speakers?t.speakers=e.speakers.map((e=>e?Pt.toJSON(e):void 0)):t.speakers=[],t},fromPartial(e){var t;const i={speakers:[]};return i.speakers=(null===(t=e.speakers)||void 0===t?void 0:t.map((e=>Pt.fromPartial(e))))||[],i}};const Pt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.sid&&t.uint32(10).string(e.sid),0!==e.level&&t.uint32(21).float(e.level),!0===e.active&&t.uint32(24).bool(e.active),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={sid:"",level:0,active:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.sid=i.string();break;case 2:r.level=i.float();break;case 3:r.active=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({sid:Jt(e.sid)?String(e.sid):"",level:Jt(e.level)?Number(e.level):0,active:!!Jt(e.active)&&Boolean(e.active)}),toJSON(e){const t={};return void 0!==e.sid&&(t.sid=e.sid),void 0!==e.level&&(t.level=e.level),void 0!==e.active&&(t.active=e.active),t},fromPartial(e){var t,i,n;const r={sid:"",level:0,active:!1};return r.sid=null!==(t=e.sid)&&void 0!==t?t:"",r.level=null!==(i=e.level)&&void 0!==i?i:0,r.active=null!==(n=e.active)&&void 0!==n&&n,r}};function Rt(){return{participantSid:"",payload:new Uint8Array,destinationSids:[]}}const Ot={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();""!==e.participantSid&&t.uint32(10).string(e.participantSid),0!==e.payload.length&&t.uint32(18).bytes(e.payload);for(const i of e.destinationSids)t.uint32(26).string(i);return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r=Rt();for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.participantSid=i.string();break;case 2:r.payload=i.bytes();break;case 3:r.destinationSids.push(i.string());break;default:i.skipType(7&e)}}return r},fromJSON:e=>({participantSid:Jt(e.participantSid)?String(e.participantSid):"",payload:Jt(e.payload)?xt(e.payload):new Uint8Array,destinationSids:Array.isArray(null==e?void 0:e.destinationSids)?e.destinationSids.map((e=>String(e))):[]}),toJSON(e){const t={};return void 0!==e.participantSid&&(t.participantSid=e.participantSid),void 0!==e.payload&&(t.payload=function(e){if(Lt.Buffer)return Lt.Buffer.from(e).toString("base64");{const t=[];return e.forEach((e=>{t.push(String.fromCharCode(e))})),Lt.btoa(t.join(""))}}(void 0!==e.payload?e.payload:new Uint8Array)),e.destinationSids?t.destinationSids=e.destinationSids.map((e=>e)):t.destinationSids=[],t},fromPartial(e){var t,i,n;const r=Rt();return r.participantSid=null!==(t=e.participantSid)&&void 0!==t?t:"",r.payload=null!==(i=e.payload)&&void 0!==i?i:new Uint8Array,r.destinationSids=(null===(n=e.destinationSids)||void 0===n?void 0:n.map((e=>e)))||[],r}};const Nt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();""!==e.participantSid&&t.uint32(10).string(e.participantSid);for(const i of e.trackSids)t.uint32(18).string(i);return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={participantSid:"",trackSids:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.participantSid=i.string();break;case 2:r.trackSids.push(i.string());break;default:i.skipType(7&e)}}return r},fromJSON:e=>({participantSid:Jt(e.participantSid)?String(e.participantSid):"",trackSids:Array.isArray(null==e?void 0:e.trackSids)?e.trackSids.map((e=>String(e))):[]}),toJSON(e){const t={};return void 0!==e.participantSid&&(t.participantSid=e.participantSid),e.trackSids?t.trackSids=e.trackSids.map((e=>e)):t.trackSids=[],t},fromPartial(e){var t,i;const n={participantSid:"",trackSids:[]};return n.participantSid=null!==(t=e.participantSid)&&void 0!==t?t:"",n.trackSids=(null===(i=e.trackSids)||void 0===i?void 0:i.map((e=>e)))||[],n}};const Dt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return 0!==e.edition&&t.uint32(8).int32(e.edition),""!==e.version&&t.uint32(18).string(e.version),0!==e.protocol&&t.uint32(24).int32(e.protocol),""!==e.region&&t.uint32(34).string(e.region),""!==e.nodeId&&t.uint32(42).string(e.nodeId),""!==e.debugInfo&&t.uint32(50).string(e.debugInfo),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={edition:0,version:"",protocol:0,region:"",nodeId:"",debugInfo:""};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.edition=i.int32();break;case 2:r.version=i.string();break;case 3:r.protocol=i.int32();break;case 4:r.region=i.string();break;case 5:r.nodeId=i.string();break;case 6:r.debugInfo=i.string();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({edition:Jt(e.edition)?vt(e.edition):0,version:Jt(e.version)?String(e.version):"",protocol:Jt(e.protocol)?Number(e.protocol):0,region:Jt(e.region)?String(e.region):"",nodeId:Jt(e.nodeId)?String(e.nodeId):"",debugInfo:Jt(e.debugInfo)?String(e.debugInfo):""}),toJSON(e){const t={};return void 0!==e.edition&&(t.edition=function(e){switch(e){case Ye.Standard:return"Standard";case Ye.Cloud:return"Cloud";case Ye.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.edition)),void 0!==e.version&&(t.version=e.version),void 0!==e.protocol&&(t.protocol=Math.round(e.protocol)),void 0!==e.region&&(t.region=e.region),void 0!==e.nodeId&&(t.nodeId=e.nodeId),void 0!==e.debugInfo&&(t.debugInfo=e.debugInfo),t},fromPartial(e){var t,i,n,r,s,a;const o={edition:0,version:"",protocol:0,region:"",nodeId:"",debugInfo:""};return o.edition=null!==(t=e.edition)&&void 0!==t?t:0,o.version=null!==(i=e.version)&&void 0!==i?i:"",o.protocol=null!==(n=e.protocol)&&void 0!==n?n:0,o.region=null!==(r=e.region)&&void 0!==r?r:"",o.nodeId=null!==(s=e.nodeId)&&void 0!==s?s:"",o.debugInfo=null!==(a=e.debugInfo)&&void 0!==a?a:"",o}};const It={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return 0!==e.sdk&&t.uint32(8).int32(e.sdk),""!==e.version&&t.uint32(18).string(e.version),0!==e.protocol&&t.uint32(24).int32(e.protocol),""!==e.os&&t.uint32(34).string(e.os),""!==e.osVersion&&t.uint32(42).string(e.osVersion),""!==e.deviceModel&&t.uint32(50).string(e.deviceModel),""!==e.browser&&t.uint32(58).string(e.browser),""!==e.browserVersion&&t.uint32(66).string(e.browserVersion),""!==e.address&&t.uint32(74).string(e.address),""!==e.network&&t.uint32(82).string(e.network),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={sdk:0,version:"",protocol:0,os:"",osVersion:"",deviceModel:"",browser:"",browserVersion:"",address:"",network:""};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.sdk=i.int32();break;case 2:r.version=i.string();break;case 3:r.protocol=i.int32();break;case 4:r.os=i.string();break;case 5:r.osVersion=i.string();break;case 6:r.deviceModel=i.string();break;case 7:r.browser=i.string();break;case 8:r.browserVersion=i.string();break;case 9:r.address=i.string();break;case 10:r.network=i.string();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({sdk:Jt(e.sdk)?ft(e.sdk):0,version:Jt(e.version)?String(e.version):"",protocol:Jt(e.protocol)?Number(e.protocol):0,os:Jt(e.os)?String(e.os):"",osVersion:Jt(e.osVersion)?String(e.osVersion):"",deviceModel:Jt(e.deviceModel)?String(e.deviceModel):"",browser:Jt(e.browser)?String(e.browser):"",browserVersion:Jt(e.browserVersion)?String(e.browserVersion):"",address:Jt(e.address)?String(e.address):"",network:Jt(e.network)?String(e.network):""}),toJSON(e){const t={};return void 0!==e.sdk&&(t.sdk=function(e){switch(e){case Xe.UNKNOWN:return"UNKNOWN";case Xe.JS:return"JS";case Xe.SWIFT:return"SWIFT";case Xe.ANDROID:return"ANDROID";case Xe.FLUTTER:return"FLUTTER";case Xe.GO:return"GO";case Xe.UNITY:return"UNITY";case Xe.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.sdk)),void 0!==e.version&&(t.version=e.version),void 0!==e.protocol&&(t.protocol=Math.round(e.protocol)),void 0!==e.os&&(t.os=e.os),void 0!==e.osVersion&&(t.osVersion=e.osVersion),void 0!==e.deviceModel&&(t.deviceModel=e.deviceModel),void 0!==e.browser&&(t.browser=e.browser),void 0!==e.browserVersion&&(t.browserVersion=e.browserVersion),void 0!==e.address&&(t.address=e.address),void 0!==e.network&&(t.network=e.network),t},fromPartial(e){var t,i,n,r,s,a,o,c,d,u;const l={sdk:0,version:"",protocol:0,os:"",osVersion:"",deviceModel:"",browser:"",browserVersion:"",address:"",network:""};return l.sdk=null!==(t=e.sdk)&&void 0!==t?t:0,l.version=null!==(i=e.version)&&void 0!==i?i:"",l.protocol=null!==(n=e.protocol)&&void 0!==n?n:0,l.os=null!==(r=e.os)&&void 0!==r?r:"",l.osVersion=null!==(s=e.osVersion)&&void 0!==s?s:"",l.deviceModel=null!==(a=e.deviceModel)&&void 0!==a?a:"",l.browser=null!==(o=e.browser)&&void 0!==o?o:"",l.browserVersion=null!==(c=e.browserVersion)&&void 0!==c?c:"",l.address=null!==(d=e.address)&&void 0!==d?d:"",l.network=null!==(u=e.network)&&void 0!==u?u:"",l}};const At={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return void 0!==e.video&&Ut.encode(e.video,t.uint32(10).fork()).ldelim(),void 0!==e.screen&&Ut.encode(e.screen,t.uint32(18).fork()).ldelim(),0!==e.resumeConnection&&t.uint32(24).int32(e.resumeConnection),void 0!==e.disabledCodecs&&Mt.encode(e.disabledCodecs,t.uint32(34).fork()).ldelim(),0!==e.forceRelay&&t.uint32(40).int32(e.forceRelay),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={video:void 0,screen:void 0,resumeConnection:0,disabledCodecs:void 0,forceRelay:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.video=Ut.decode(i,i.uint32());break;case 2:r.screen=Ut.decode(i,i.uint32());break;case 3:r.resumeConnection=i.int32();break;case 4:r.disabledCodecs=Mt.decode(i,i.uint32());break;case 5:r.forceRelay=i.int32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({video:Jt(e.video)?Ut.fromJSON(e.video):void 0,screen:Jt(e.screen)?Ut.fromJSON(e.screen):void 0,resumeConnection:Jt(e.resumeConnection)?ct(e.resumeConnection):0,disabledCodecs:Jt(e.disabledCodecs)?Mt.fromJSON(e.disabledCodecs):void 0,forceRelay:Jt(e.forceRelay)?ct(e.forceRelay):0}),toJSON(e){const t={};return void 0!==e.video&&(t.video=e.video?Ut.toJSON(e.video):void 0),void 0!==e.screen&&(t.screen=e.screen?Ut.toJSON(e.screen):void 0),void 0!==e.resumeConnection&&(t.resumeConnection=dt(e.resumeConnection)),void 0!==e.disabledCodecs&&(t.disabledCodecs=e.disabledCodecs?Mt.toJSON(e.disabledCodecs):void 0),void 0!==e.forceRelay&&(t.forceRelay=dt(e.forceRelay)),t},fromPartial(e){var t,i;const n={video:void 0,screen:void 0,resumeConnection:0,disabledCodecs:void 0,forceRelay:0};return n.video=void 0!==e.video&&null!==e.video?Ut.fromPartial(e.video):void 0,n.screen=void 0!==e.screen&&null!==e.screen?Ut.fromPartial(e.screen):void 0,n.resumeConnection=null!==(t=e.resumeConnection)&&void 0!==t?t:0,n.disabledCodecs=void 0!==e.disabledCodecs&&null!==e.disabledCodecs?Mt.fromPartial(e.disabledCodecs):void 0,n.forceRelay=null!==(i=e.forceRelay)&&void 0!==i?i:0,n}};const Ut={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return 0!==e.hardwareEncoder&&t.uint32(8).int32(e.hardwareEncoder),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={hardwareEncoder:0};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.hardwareEncoder=i.int32();else i.skipType(7&e)}return r},fromJSON:e=>({hardwareEncoder:Jt(e.hardwareEncoder)?ct(e.hardwareEncoder):0}),toJSON(e){const t={};return void 0!==e.hardwareEncoder&&(t.hardwareEncoder=dt(e.hardwareEncoder)),t},fromPartial(e){var t;const i={hardwareEncoder:0};return i.hardwareEncoder=null!==(t=e.hardwareEncoder)&&void 0!==t?t:0,i}};const Mt={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();for(const i of e.codecs)bt.encode(i,t.uint32(10).fork()).ldelim();return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={codecs:[]};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.codecs.push(bt.decode(i,i.uint32()));else i.skipType(7&e)}return r},fromJSON:e=>({codecs:Array.isArray(null==e?void 0:e.codecs)?e.codecs.map((e=>bt.fromJSON(e))):[]}),toJSON(e){const t={};return e.codecs?t.codecs=e.codecs.map((e=>e?bt.toJSON(e):void 0)):t.codecs=[],t},fromPartial(e){var t;const i={codecs:[]};return i.codecs=(null===(t=e.codecs)||void 0===t?void 0:t.map((e=>bt.fromPartial(e))))||[],i}};var Lt=(()=>{if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw"Unable to locate global object"})();function xt(e){if(Lt.Buffer)return Uint8Array.from(Lt.Buffer.from(e,"base64"));{const t=Lt.atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;++e)i[e]=t.charCodeAt(e);return i}}function _t(e){if(e.gt(Number.MAX_SAFE_INTEGER))throw new Lt.Error("Value is larger than Number.MAX_SAFE_INTEGER");return e.toNumber()}function Jt(e){return null!=e}et.util.Long!==o&&(et.util.Long=o,et.configure());const $t=7e3,Bt=[0,300,1200,2700,4800,$t,$t,$t,$t,$t];class jt{constructor(e){this._retryDelays=void 0!==e?[...e]:Bt}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;const t=this._retryDelays[e.retryCount];return e.retryCount<=1?t:t+1e3*Math.random()}}function Vt(e){var t,i,n,r=2;for("undefined"!=typeof Symbol&&(i=Symbol.asyncIterator,n=Symbol.iterator);r--;){if(i&&null!=(t=e[i]))return t.call(e);if(n&&null!=(t=e[n]))return new Ft(t.call(e));i="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function Ft(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return Ft=function(e){this.s=e,this.n=e.next},Ft.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var i=this.s.return;return void 0===i?Promise.resolve({value:e,done:!0}):t(i.apply(this.s,arguments))},throw:function(e){var i=this.s.return;return void 0===i?Promise.reject(e):t(i.apply(this.s,arguments))}},new Ft(e)}function qt(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Wt(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?qt(Object(i),!0).forEach((function(t){Gt(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):qt(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Gt(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}let Qt=!0,zt=!0;function Ht(e,t,i){const n=e.match(t);return n&&n.length>=i&&parseInt(n[i],10)}function Zt(e,t,i){if(!e.RTCPeerConnection)return;const n=e.RTCPeerConnection.prototype,r=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return r.apply(this,arguments);const s=e=>{const t=i(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(n,s),r.apply(this,[e,s])};const s=n.removeEventListener;n.removeEventListener=function(e,i){if(e!==t||!this._eventMap||!this._eventMap[t])return s.apply(this,arguments);if(!this._eventMap[t].has(i))return s.apply(this,arguments);const n=this._eventMap[t].get(i);return this._eventMap[t].delete(i),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,s.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function Kt(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(Qt=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function Yt(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(zt=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Xt(){if("object"==typeof window){if(Qt)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function ei(e,t){zt&&console.warn(e+" is deprecated, please use "+t+" instead.")}function ti(e){const t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;const{navigator:i}=e;if(i.mozGetUserMedia)t.browser="firefox",t.version=Ht(i.userAgent,/Firefox\/(\d+)\./,1);else if(i.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=Ht(i.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!i.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=Ht(i.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function ii(e){return"[object Object]"===Object.prototype.toString.call(e)}function ni(e){return ii(e)?Object.keys(e).reduce((function(t,i){const n=ii(e[i]),r=n?ni(e[i]):e[i],s=n&&!Object.keys(r).length;return void 0===r||s?t:Object.assign(t,{[i]:r})}),{}):e}function ri(e,t,i){t&&!i.has(t.id)&&(i.set(t.id,t),Object.keys(t).forEach((n=>{n.endsWith("Id")?ri(e,e.get(t[n]),i):n.endsWith("Ids")&&t[n].forEach((t=>{ri(e,e.get(t),i)}))})))}function si(e,t,i){const n=i?"outbound-rtp":"inbound-rtp",r=new Map;if(null===t)return r;const s=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&s.push(e)})),s.forEach((t=>{e.forEach((i=>{i.type===n&&i.trackId===t.id&&ri(e,i,r)}))})),r}const ai=Xt;function oi(e,t){const i=e&&e.navigator;if(!i.mediaDevices)return;const n=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((i=>{if("require"===i||"advanced"===i||"mediaSource"===i)return;const n="object"==typeof e[i]?e[i]:{ideal:e[i]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const r=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[r("min",i)]=n.ideal,t.optional.push(e),e={},e[r("max",i)]=n.ideal,t.optional.push(e)):(e[r("",i)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[r("",i)]=n.exact):["min","max"].forEach((e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[r(e,i)]=n[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},r=function(e,r){if(t.version>=61)return r(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"==typeof e.video){let s=e.video.facingMode;s=s&&("object"==typeof s?s:{ideal:s});const a=t.version<66;if(s&&("user"===s.exact||"environment"===s.exact||"user"===s.ideal||"environment"===s.ideal)&&(!i.mediaDevices.getSupportedConstraints||!i.mediaDevices.getSupportedConstraints().facingMode||a)){let t;if(delete e.video.facingMode,"environment"===s.exact||"environment"===s.ideal?t=["back","rear"]:"user"!==s.exact&&"user"!==s.ideal||(t=["front"]),t)return i.mediaDevices.enumerateDevices().then((i=>{let a=(i=i.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!a&&i.length&&t.includes("back")&&(a=i[i.length-1]),a&&(e.video.deviceId=s.exact?{exact:a.deviceId}:{ideal:a.deviceId}),e.video=n(e.video),ai("chrome: "+JSON.stringify(e)),r(e)}))}e.video=n(e.video)}return ai("chrome: "+JSON.stringify(e)),r(e)},s=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(i.getUserMedia=function(e,t,n){r(e,(e=>{i.webkitGetUserMedia(e,t,(e=>{n&&n(s(e))}))}))}.bind(i),i.mediaDevices.getUserMedia){const e=i.mediaDevices.getUserMedia.bind(i.mediaDevices);i.mediaDevices.getUserMedia=function(t){return r(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(s(e))))))}}}function ci(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function di(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(i=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.track.id)):{track:i.track};const r=new Event("track");r.track=i.track,r.receiver=n,r.transceiver={receiver:n},r.streams=[t.stream],this.dispatchEvent(r)})),t.stream.getTracks().forEach((i=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.id)):{track:i};const r=new Event("track");r.track=i,r.receiver=n,r.transceiver={receiver:n},r.streams=[t.stream],this.dispatchEvent(r)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else Zt(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function ui(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){let r=i.apply(this,arguments);return r||(r=t(this,e),this._senders.push(r)),r};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function li(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,n]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const r=function(e){const t={};return e.result().forEach((e=>{const i={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{i[t]=e.stat(t)})),t[i.id]=i})),t},s=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const n=function(e){i(s(r(e)))};return t.apply(this,[n,e])}return new Promise(((e,i)=>{t.apply(this,[function(t){e(s(r(t)))},i])})).then(i,n)}}function hi(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>si(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),Zt(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>si(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,i,n;return this.getSenders().forEach((i=>{i.track===e&&(t?n=!0:t=i)})),this.getReceivers().forEach((t=>(t.track===e&&(i?n=!0:i=t),t.track===e))),n||t&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function pi(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){if(!i)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const n=t.apply(this,arguments);return this._shimmedLocalStreams[i.id]?-1===this._shimmedLocalStreams[i.id].indexOf(n)&&this._shimmedLocalStreams[i.id].push(n):this._shimmedLocalStreams[i.id]=[i,n],n};const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();i.apply(this,arguments);const n=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(n)};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const i=this._shimmedLocalStreams[t].indexOf(e);-1!==i&&this._shimmedLocalStreams[t].splice(i,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),r.apply(this,arguments)}}function mi(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return pi(e);const i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=i.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};const r=e.RTCPeerConnection.prototype.removeStream;function s(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const n=e._reverseStreams[t],r=e._streams[n.id];i=i.replace(new RegExp(r.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:i})}function a(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const n=e._reverseStreams[t],r=e._streams[n.id];i=i.replace(new RegExp(n.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:i})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,i){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");const r=this.getSenders().find((e=>e.track===t));if(r)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const s=this._streams[i.id];if(s)s.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const n=new e.MediaStream([t]);this._streams[i.id]=n,this._reverseStreams[n.id]=i,this.addStream(n)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],n={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?i.apply(this,[t=>{const i=s(this,t);e[0].apply(null,[i])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):i.apply(this,arguments).then((e=>s(this,e)))}};e.RTCPeerConnection.prototype[t]=n[t]}));const o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=a(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};const c=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=c.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((i=>{this._streams[i].getTracks().find((t=>e.track===t))&&(t=this._streams[i])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function vi(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}))}function fi(e,t){Zt(e,"negotiationneeded",(e=>{const i=e.target;if(!(t.version<72||i.getConfiguration&&"plan-b"===i.getConfiguration().sdpSemantics)||"stable"===i.signalingState)return e}))}var gi=Object.freeze({__proto__:null,fixNegotiationNeeded:fi,shimAddTrackRemoveTrack:mi,shimAddTrackRemoveTrackWithNative:pi,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then((t=>{const n=i.video&&i.video.width,r=i.video&&i.video.height,s=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:s||3}},n&&(i.video.mandatory.maxWidth=n),r&&(i.video.mandatory.maxHeight=r),e.navigator.mediaDevices.getUserMedia(i)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))},shimGetSendersWithDtmf:ui,shimGetStats:li,shimGetUserMedia:oi,shimMediaStream:ci,shimOnTrack:di,shimPeerConnection:vi,shimSenderReceiverGetStats:hi});function bi(e,t){const i=e&&e.navigator,n=e&&e.MediaStreamTrack;if(i.getUserMedia=function(e,t,n){ei("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),i.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in i.mediaDevices.getSupportedConstraints())){const e=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])},t=i.mediaDevices.getUserMedia.bind(i.mediaDevices);if(i.mediaDevices.getUserMedia=function(i){return"object"==typeof i&&"object"==typeof i.audio&&(i=JSON.parse(JSON.stringify(i)),e(i.audio,"autoGainControl","mozAutoGainControl"),e(i.audio,"noiseSuppression","mozNoiseSuppression")),t(i)},n&&n.prototype.getSettings){const t=n.prototype.getSettings;n.prototype.getSettings=function(){const i=t.apply(this,arguments);return e(i,"mozAutoGainControl","autoGainControl"),e(i,"mozNoiseSuppression","noiseSuppression"),i}}if(n&&n.prototype.applyConstraints){const t=n.prototype.applyConstraints;n.prototype.applyConstraints=function(i){return"audio"===this.kind&&"object"==typeof i&&(i=JSON.parse(JSON.stringify(i)),e(i,"autoGainControl","mozAutoGainControl"),e(i,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[i])}}}}function ki(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function yi(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}));const i={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,s]=arguments;return n.apply(this,[e||null]).then((e=>{if(t.version<53&&!r)try{e.forEach((e=>{e.type=i[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach(((t,n)=>{e.set(n,Object.assign({},t,{type:i[t.type]||t.type}))}))}return e})).then(r,s)}}function Si(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function wi(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),Zt(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Ci(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){ei("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function Ti(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function Ei(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],i=e&&"sendEncodings"in e;i&&e.sendEncodings.forEach((e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const n=t.apply(this,arguments);if(i){const{sender:t}=n,i=t.getParameters();(!("encodings"in i)||1===i.encodings.length&&0===Object.keys(i.encodings[0]).length)&&(i.encodings=e.sendEncodings,t.sendEncodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(i).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return n})}function Pi(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function Ri(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function Oi(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}var Ni=Object.freeze({__proto__:null,shimAddTransceiver:Ei,shimCreateAnswer:Oi,shimCreateOffer:Ri,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(i){if(!i||!i.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===i.video?i.video={mediaSource:t}:i.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(i)})},shimGetParameters:Pi,shimGetUserMedia:bi,shimOnTrack:ki,shimPeerConnection:yi,shimRTCDataChannel:Ti,shimReceiverGetStats:wi,shimRemoveStream:Ci,shimSenderGetStats:Si});function Di(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((i=>t.call(this,i,e))),e.getVideoTracks().forEach((i=>t.call(this,i,e)))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return n&&n.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const i=e.getTracks();this.getSenders().forEach((e=>{i.includes(e.track)&&this.removeTrack(e)}))})}}function Ii(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const i=new Event("addstream");i.stream=t,e.dispatchEvent(i)}))}),t.apply(e,arguments)}}}function Ai(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,i=t.createOffer,n=t.createAnswer,r=t.setLocalDescription,s=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],r=i.apply(this,[n]);return t?(r.then(e,t),Promise.resolve()):r},t.createAnswer=function(e,t){const i=arguments.length>=2?arguments[2]:arguments[0],r=n.apply(this,[i]);return t?(r.then(e,t),Promise.resolve()):r};let o=function(e,t,i){const n=r.apply(this,[e]);return i?(n.then(t,i),Promise.resolve()):n};t.setLocalDescription=o,o=function(e,t,i){const n=s.apply(this,[e]);return i?(n.then(t,i),Promise.resolve()):n},t.setRemoteDescription=o,o=function(e,t,i){const n=a.apply(this,[e]);return i?(n.then(t,i),Promise.resolve()):n},t.addIceCandidate=o}function Ui(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,i=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>i(Mi(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,i,n){t.mediaDevices.getUserMedia(e).then(i,n)}.bind(t))}function Mi(e){return e&&void 0!==e.video?Object.assign({},e,{video:ni(e.video)}):e}function Li(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,i){if(e&&e.iceServers){const t=[];for(let i=0;i<e.iceServers.length;i++){let n=e.iceServers[i];!n.hasOwnProperty("urls")&&n.hasOwnProperty("url")?(ei("RTCIceServer.url","RTCIceServer.urls"),n=JSON.parse(JSON.stringify(n)),n.urls=n.url,delete n.url,t.push(n)):t.push(e.iceServers[i])}e.iceServers=t}return new t(e,i)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function xi(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function _i(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const i=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0!==e.offerToReceiveVideo||i||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function Ji(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var $i=Object.freeze({__proto__:null,shimAudioContext:Ji,shimCallbacksAPI:Ai,shimConstraints:Mi,shimCreateOfferLegacy:_i,shimGetUserMedia:Ui,shimLocalStreamsAPI:Di,shimRTCIceServerUrls:Li,shimRemoteStreamsAPI:Ii,shimTrackEventTransceiver:xi}),Bi={};!function(e){const t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((e=>e.trim()))},t.splitSections=function(e){return e.split("\nm=").map(((e,t)=>(t>0?"m="+e:e).trim()+"\r\n"))},t.getDescription=function(e){const i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){const i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter((e=>0===e.indexOf(i)))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const i={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let e=8;e<t.length;e+=2)switch(t[e]){case"raddr":i.relatedAddress=t[e+1];break;case"rport":i.relatedPort=parseInt(t[e+1],10);break;case"tcptype":i.tcpType=t[e+1];break;case"ufrag":i.ufrag=t[e+1],i.usernameFragment=t[e+1];break;default:void 0===i[t[e]]&&(i[t[e]]=t[e+1])}return i},t.writeCandidate=function(e){const t=[];t.push(e.foundation);const i=e.component;"rtp"===i?t.push(1):"rtcp"===i?t.push(2):t.push(i),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);const n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substr(14).split(" ")},t.parseRtpMap=function(e){let t=e.substr(9).split(" ");const i={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),i.name=t[0],i.clockRate=parseInt(t[1],10),i.channels=3===t.length?parseInt(t[2],10):1,i.numChannels=i.channels,i},t.writeRtpMap=function(e){let t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);const i=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==i?"/"+i:"")+"\r\n"},t.parseExtmap=function(e){const t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},t.parseFmtp=function(e){const t={};let i;const n=e.substr(e.indexOf(" ")+1).split(";");for(let e=0;e<n.length;e++)i=n[e].trim().split("="),t[i[0].trim()]=i[1];return t},t.writeFmtp=function(e){let t="",i=e.payloadType;if(void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){const n=[];Object.keys(e.parameters).forEach((t=>{void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+i+" "+n.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",i=e.payloadType;return void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((e=>{t+="a=rtcp-fb:"+i+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),i={ssrc:parseInt(e.substr(7,t-7),10)},n=e.indexOf(":",t);return n>-1?(i.attribute=e.substr(t+1,n-t-1),i.value=e.substr(n+1)):i.attribute=e.substr(t+1),i},t.parseSsrcGroup=function(e){const t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((e=>parseInt(e,10)))}},t.getMid=function(e){const i=t.matchPrefix(e,"a=mid:")[0];if(i)return i.substr(6)},t.parseFingerprint=function(e){const t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,i){return{role:"auto",fingerprints:t.matchPrefix(e+i,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let i="a=setup:"+t+"\r\n";return e.fingerprints.forEach((e=>{i+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),i},t.parseCryptoLine=function(e){const t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;const t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,i){return t.matchPrefix(e+i,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,i){const n=t.matchPrefix(e+i,"a=ice-ufrag:")[0],r=t.matchPrefix(e+i,"a=ice-pwd:")[0];return n&&r?{usernameFragment:n.substr(12),password:r.substr(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=t.splitLines(e)[0].split(" ");for(let r=3;r<n.length;r++){const s=n[r],a=t.matchPrefix(e,"a=rtpmap:"+s+" ")[0];if(a){const n=t.parseRtpMap(a),r=t.matchPrefix(e,"a=fmtp:"+s+" ");switch(n.parameters=r.length?t.parseFmtp(r[0]):{},n.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+s+" ").map(t.parseRtcpFb),i.codecs.push(n),n.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(n.name.toUpperCase())}}}return t.matchPrefix(e,"a=extmap:").forEach((e=>{i.headerExtensions.push(t.parseExtmap(e))})),i},t.writeRtpDescription=function(e,i){let n="";n+="m="+e+" ",n+=i.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=i.codecs.map((e=>void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType)).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",i.codecs.forEach((e=>{n+=t.writeRtpMap(e),n+=t.writeFmtp(e),n+=t.writeRtcpFb(e)}));let r=0;return i.codecs.forEach((e=>{e.maxptime>r&&(r=e.maxptime)})),r>0&&(n+="a=maxptime:"+r+"\r\n"),i.headerExtensions&&i.headerExtensions.forEach((e=>{n+=t.writeExtmap(e)})),n},t.parseRtpEncodingParameters=function(e){const i=[],n=t.parseRtpParameters(e),r=-1!==n.fecMechanisms.indexOf("RED"),s=-1!==n.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute)),o=a.length>0&&a[0].ssrc;let c;const d=t.matchPrefix(e,"a=ssrc-group:FID").map((e=>e.substr(17).split(" ").map((e=>parseInt(e,10)))));d.length>0&&d[0].length>1&&d[0][0]===o&&(c=d[0][1]),n.codecs.forEach((e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:o,codecPayloadType:parseInt(e.parameters.apt,10)};o&&c&&(t.rtx={ssrc:c}),i.push(t),r&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:o,mechanism:s?"red+ulpfec":"red"},i.push(t))}})),0===i.length&&o&&i.push({ssrc:o});let u=t.matchPrefix(e,"b=");return u.length&&(u=0===u[0].indexOf("b=TIAS:")?parseInt(u[0].substr(7),10):0===u[0].indexOf("b=AS:")?1e3*parseInt(u[0].substr(5),10)*.95-16e3:void 0,i.forEach((e=>{e.maxBitrate=u}))),i},t.parseRtcpParameters=function(e){const i={},n=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute))[0];n&&(i.cname=n.value,i.ssrc=n.ssrc);const r=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=r.length>0,i.compound=0===r.length;const s=t.matchPrefix(e,"a=rtcp-mux");return i.mux=s.length>0,i},t.writeRtcpParameters=function(e){let t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){let i;const n=t.matchPrefix(e,"a=msid:");if(1===n.length)return i=n[0].substr(7).split(" "),{stream:i[0],track:i[1]};const r=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return r.length>0?(i=r[0].value.split(" "),{stream:i[0],track:i[1]}):void 0},t.parseSctpDescription=function(e){const i=t.parseMLine(e),n=t.matchPrefix(e,"a=max-message-size:");let r;n.length>0&&(r=parseInt(n[0].substr(19),10)),isNaN(r)&&(r=65536);const s=t.matchPrefix(e,"a=sctp-port:");if(s.length>0)return{port:parseInt(s[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};const a=t.matchPrefix(e,"a=sctpmap:");if(a.length>0){const e=a[0].substr(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:r}}},t.writeSctpDescription=function(e,t){let i=[];return i="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&i.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),i.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(e,i,n){let r;const s=void 0!==i?i:2;r=e||t.generateSessionId();return"v=0\r\no="+(n||"thisisadapterortc")+" "+r+" "+s+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,i){const n=t.splitLines(e);for(let e=0;e<n.length;e++)switch(n[e]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[e].substr(2)}return i?t.getDirection(i):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substr(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){const i=t.splitLines(e)[0].substr(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},t.parseOLine=function(e){const i=t.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;const i=t.splitLines(e);for(let e=0;e<i.length;e++)if(i[e].length<2||"="!==i[e].charAt(1))return!1;return!0},e.exports=t}({get exports(){return Bi},set exports(e){Bi=e}});var ji=Bi,Vi=t({__proto__:null,default:ji},[Bi]);function Fi(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const i=new t(e),n=ji.parseCandidate(e.candidate),r=Object.assign(i,n);return r.toJSON=function(){return{candidate:r.candidate,sdpMid:r.sdpMid,sdpMLineIndex:r.sdpMLineIndex,usernameFragment:r.usernameFragment}},r}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,Zt(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function qi(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const i=function(e){if(!e||!e.sdp)return!1;const t=ji.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=ji.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))},n=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const i=parseInt(t[1],10);return i!=i?-1:i},r=function(e){let i=65536;return"firefox"===t.browser&&(i=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),i},s=function(e,i){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const r=ji.matchPrefix(e.sdp,"a=max-message-size:");return r.length>0?n=parseInt(r[0].substr(19),10):"firefox"===t.browser&&-1!==i&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(i(arguments[0])){const e=n(arguments[0]),t=r(e),i=s(arguments[0],e);let a;a=0===t&&0===i?Number.POSITIVE_INFINITY:0===t||0===i?Math.max(t,i):Math.min(t,i);const o={};Object.defineProperty(o,"maxMessageSize",{get:()=>a}),this._sctp=o}return a.apply(this,arguments)}}function Wi(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const i=e.send;e.send=function(){const n=arguments[0],r=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&r>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return i.apply(e,arguments)}}const i=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=i.apply(this,arguments);return t(e,this),e},Zt(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function Gi(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const i=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const i=new Event("connectionstatechange",e);t.dispatchEvent(i)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}}))}function Qi(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const i=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:i}):t.sdp=i}return i.apply(this,arguments)}}function zi(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.addIceCandidate;i&&0!==i.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():i.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function Hi(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.setLocalDescription;i&&0!==i.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if("object"!=typeof e||e.type&&e.sdp)return i.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":e.type="offer";break;default:e.type="answer"}if(e.sdp||"offer"!==e.type&&"answer"!==e.type)return i.apply(this,[e]);const t="offer"===e.type?this.createOffer:this.createAnswer;return t.apply(this).then((e=>i.apply(this,[e])))})}var Zi,Ki,Yi,Xi=Object.freeze({__proto__:null,removeExtmapAllowMixed:Qi,shimAddIceCandidateNullOrEmpty:zi,shimConnectionState:Gi,shimMaxMessageSize:qi,shimParameterlessSetLocalDescription:Hi,shimRTCIceCandidate:Fi,shimSendThrowTypeError:Wi});function en(e){switch(e){case 0:case"PUBLISHER":return Zi.PUBLISHER;case 1:case"SUBSCRIBER":return Zi.SUBSCRIBER;default:return Zi.UNRECOGNIZED}}function tn(e){switch(e){case Zi.PUBLISHER:return"PUBLISHER";case Zi.SUBSCRIBER:return"SUBSCRIBER";case Zi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}function nn(e){switch(e){case 0:case"ACTIVE":return Ki.ACTIVE;case 1:case"PAUSED":return Ki.PAUSED;default:return Ki.UNRECOGNIZED}}function rn(e){switch(e){case 0:case"UDP":return Yi.UDP;case 1:case"TCP":return Yi.TCP;case 2:case"TLS":return Yi.TLS;default:return Yi.UNRECOGNIZED}}!function(){let{window:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0};const i=Xt,n=ti(e),r={browserDetails:n,commonShim:Xi,extractVersion:Ht,disableLog:Kt,disableWarnings:Yt,sdp:Vi};switch(n.browser){case"chrome":if(!gi||!vi||!t.shimChrome)return i("Chrome shim is not included in this adapter release."),r;if(null===n.version)return i("Chrome shim can not determine version, not shimming."),r;i("adapter.js shimming chrome."),r.browserShim=gi,zi(e,n),Hi(e),oi(e,n),ci(e),vi(e,n),di(e),mi(e,n),ui(e),li(e),hi(e),fi(e,n),Fi(e),Gi(e),qi(e,n),Wi(e),Qi(e,n);break;case"firefox":if(!Ni||!yi||!t.shimFirefox)return i("Firefox shim is not included in this adapter release."),r;i("adapter.js shimming firefox."),r.browserShim=Ni,zi(e,n),Hi(e),bi(e,n),yi(e,n),ki(e),Ci(e),Si(e),wi(e),Ti(e),Ei(e),Pi(e),Ri(e),Oi(e),Fi(e),Gi(e),qi(e,n),Wi(e);break;case"safari":if(!$i||!t.shimSafari)return i("Safari shim is not included in this adapter release."),r;i("adapter.js shimming safari."),r.browserShim=$i,zi(e,n),Hi(e),Li(e),_i(e),Ai(e),Di(e),Ii(e),xi(e),Ui(e),Ji(e),Fi(e),qi(e,n),Wi(e),Qi(e,n);break;default:i("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),function(e){e[e.PUBLISHER=0]="PUBLISHER",e[e.SUBSCRIBER=1]="SUBSCRIBER",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Zi||(Zi={})),function(e){e[e.ACTIVE=0]="ACTIVE",e[e.PAUSED=1]="PAUSED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Ki||(Ki={})),function(e){e[e.UDP=0]="UDP",e[e.TCP=1]="TCP",e[e.TLS=2]="TLS",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED"}(Yi||(Yi={}));const sn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();var i,n,r,s,a,o,c,d,u,l,h,p,m,v;return"offer"===(null===(i=e.message)||void 0===i?void 0:i.$case)&&vn.encode(e.message.offer,t.uint32(10).fork()).ldelim(),"answer"===(null===(n=e.message)||void 0===n?void 0:n.$case)&&vn.encode(e.message.answer,t.uint32(18).fork()).ldelim(),"trickle"===(null===(r=e.message)||void 0===r?void 0:r.$case)&&dn.encode(e.message.trickle,t.uint32(26).fork()).ldelim(),"addTrack"===(null===(s=e.message)||void 0===s?void 0:s.$case)&&cn.encode(e.message.addTrack,t.uint32(34).fork()).ldelim(),"mute"===(null===(a=e.message)||void 0===a?void 0:a.$case)&&un.encode(e.message.mute,t.uint32(42).fork()).ldelim(),"subscription"===(null===(o=e.message)||void 0===o?void 0:o.$case)&&gn.encode(e.message.subscription,t.uint32(50).fork()).ldelim(),"trackSetting"===(null===(c=e.message)||void 0===c?void 0:c.$case)&&bn.encode(e.message.trackSetting,t.uint32(58).fork()).ldelim(),"leave"===(null===(d=e.message)||void 0===d?void 0:d.$case)&&kn.encode(e.message.leave,t.uint32(66).fork()).ldelim(),"updateLayers"===(null===(u=e.message)||void 0===u?void 0:u.$case)&&yn.encode(e.message.updateLayers,t.uint32(82).fork()).ldelim(),"subscriptionPermission"===(null===(l=e.message)||void 0===l?void 0:l.$case)&&Un.encode(e.message.subscriptionPermission,t.uint32(90).fork()).ldelim(),"syncState"===(null===(h=e.message)||void 0===h?void 0:h.$case)&&Ln.encode(e.message.syncState,t.uint32(98).fork()).ldelim(),"simulate"===(null===(p=e.message)||void 0===p?void 0:p.$case)&&_n.encode(e.message.simulate,t.uint32(106).fork()).ldelim(),"ping"===(null===(m=e.message)||void 0===m?void 0:m.$case)&&t.uint32(112).int64(e.message.ping),"updateMetadata"===(null===(v=e.message)||void 0===v?void 0:v.$case)&&Sn.encode(e.message.updateMetadata,t.uint32(122).fork()).ldelim(),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={message:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.message={$case:"offer",offer:vn.decode(i,i.uint32())};break;case 2:r.message={$case:"answer",answer:vn.decode(i,i.uint32())};break;case 3:r.message={$case:"trickle",trickle:dn.decode(i,i.uint32())};break;case 4:r.message={$case:"addTrack",addTrack:cn.decode(i,i.uint32())};break;case 5:r.message={$case:"mute",mute:un.decode(i,i.uint32())};break;case 6:r.message={$case:"subscription",subscription:gn.decode(i,i.uint32())};break;case 7:r.message={$case:"trackSetting",trackSetting:bn.decode(i,i.uint32())};break;case 8:r.message={$case:"leave",leave:kn.decode(i,i.uint32())};break;case 10:r.message={$case:"updateLayers",updateLayers:yn.decode(i,i.uint32())};break;case 11:r.message={$case:"subscriptionPermission",subscriptionPermission:Un.decode(i,i.uint32())};break;case 12:r.message={$case:"syncState",syncState:Ln.decode(i,i.uint32())};break;case 13:r.message={$case:"simulate",simulate:_n.decode(i,i.uint32())};break;case 14:r.message={$case:"ping",ping:qn(i.int64())};break;case 15:r.message={$case:"updateMetadata",updateMetadata:Sn.decode(i,i.uint32())};break;default:i.skipType(7&e)}}return r},fromJSON:e=>({message:Wn(e.offer)?{$case:"offer",offer:vn.fromJSON(e.offer)}:Wn(e.answer)?{$case:"answer",answer:vn.fromJSON(e.answer)}:Wn(e.trickle)?{$case:"trickle",trickle:dn.fromJSON(e.trickle)}:Wn(e.addTrack)?{$case:"addTrack",addTrack:cn.fromJSON(e.addTrack)}:Wn(e.mute)?{$case:"mute",mute:un.fromJSON(e.mute)}:Wn(e.subscription)?{$case:"subscription",subscription:gn.fromJSON(e.subscription)}:Wn(e.trackSetting)?{$case:"trackSetting",trackSetting:bn.fromJSON(e.trackSetting)}:Wn(e.leave)?{$case:"leave",leave:kn.fromJSON(e.leave)}:Wn(e.updateLayers)?{$case:"updateLayers",updateLayers:yn.fromJSON(e.updateLayers)}:Wn(e.subscriptionPermission)?{$case:"subscriptionPermission",subscriptionPermission:Un.fromJSON(e.subscriptionPermission)}:Wn(e.syncState)?{$case:"syncState",syncState:Ln.fromJSON(e.syncState)}:Wn(e.simulate)?{$case:"simulate",simulate:_n.fromJSON(e.simulate)}:Wn(e.ping)?{$case:"ping",ping:Number(e.ping)}:Wn(e.updateMetadata)?{$case:"updateMetadata",updateMetadata:Sn.fromJSON(e.updateMetadata)}:void 0}),toJSON(e){var t,i,n,r,s,a,o,c,d,u,l,h,p,m,v,f,g,b,k,y,S,w,C,T,E,P,R,O,N,D,I,A,U,M,L,x,_,J,$,B,j;const V={};return"offer"===(null===(t=e.message)||void 0===t?void 0:t.$case)&&(V.offer=(null===(i=e.message)||void 0===i?void 0:i.offer)?vn.toJSON(null===(n=e.message)||void 0===n?void 0:n.offer):void 0),"answer"===(null===(r=e.message)||void 0===r?void 0:r.$case)&&(V.answer=(null===(s=e.message)||void 0===s?void 0:s.answer)?vn.toJSON(null===(a=e.message)||void 0===a?void 0:a.answer):void 0),"trickle"===(null===(o=e.message)||void 0===o?void 0:o.$case)&&(V.trickle=(null===(c=e.message)||void 0===c?void 0:c.trickle)?dn.toJSON(null===(d=e.message)||void 0===d?void 0:d.trickle):void 0),"addTrack"===(null===(u=e.message)||void 0===u?void 0:u.$case)&&(V.addTrack=(null===(l=e.message)||void 0===l?void 0:l.addTrack)?cn.toJSON(null===(h=e.message)||void 0===h?void 0:h.addTrack):void 0),"mute"===(null===(p=e.message)||void 0===p?void 0:p.$case)&&(V.mute=(null===(m=e.message)||void 0===m?void 0:m.mute)?un.toJSON(null===(v=e.message)||void 0===v?void 0:v.mute):void 0),"subscription"===(null===(f=e.message)||void 0===f?void 0:f.$case)&&(V.subscription=(null===(g=e.message)||void 0===g?void 0:g.subscription)?gn.toJSON(null===(b=e.message)||void 0===b?void 0:b.subscription):void 0),"trackSetting"===(null===(k=e.message)||void 0===k?void 0:k.$case)&&(V.trackSetting=(null===(y=e.message)||void 0===y?void 0:y.trackSetting)?bn.toJSON(null===(S=e.message)||void 0===S?void 0:S.trackSetting):void 0),"leave"===(null===(w=e.message)||void 0===w?void 0:w.$case)&&(V.leave=(null===(C=e.message)||void 0===C?void 0:C.leave)?kn.toJSON(null===(T=e.message)||void 0===T?void 0:T.leave):void 0),"updateLayers"===(null===(E=e.message)||void 0===E?void 0:E.$case)&&(V.updateLayers=(null===(P=e.message)||void 0===P?void 0:P.updateLayers)?yn.toJSON(null===(R=e.message)||void 0===R?void 0:R.updateLayers):void 0),"subscriptionPermission"===(null===(O=e.message)||void 0===O?void 0:O.$case)&&(V.subscriptionPermission=(null===(N=e.message)||void 0===N?void 0:N.subscriptionPermission)?Un.toJSON(null===(D=e.message)||void 0===D?void 0:D.subscriptionPermission):void 0),"syncState"===(null===(I=e.message)||void 0===I?void 0:I.$case)&&(V.syncState=(null===(A=e.message)||void 0===A?void 0:A.syncState)?Ln.toJSON(null===(U=e.message)||void 0===U?void 0:U.syncState):void 0),"simulate"===(null===(M=e.message)||void 0===M?void 0:M.$case)&&(V.simulate=(null===(L=e.message)||void 0===L?void 0:L.simulate)?_n.toJSON(null===(x=e.message)||void 0===x?void 0:x.simulate):void 0),"ping"===(null===(_=e.message)||void 0===_?void 0:_.$case)&&(V.ping=Math.round(null===(J=e.message)||void 0===J?void 0:J.ping)),"updateMetadata"===(null===($=e.message)||void 0===$?void 0:$.$case)&&(V.updateMetadata=(null===(B=e.message)||void 0===B?void 0:B.updateMetadata)?Sn.toJSON(null===(j=e.message)||void 0===j?void 0:j.updateMetadata):void 0),V},fromPartial(e){var t,i,n,r,s,a,o,c,d,u,l,h,p,m,v,f,g,b,k,y,S,w,C,T,E,P,R,O,N,D,I,A,U,M,L,x,_,J,$,B,j,V;const F={message:void 0};return"offer"===(null===(t=e.message)||void 0===t?void 0:t.$case)&&void 0!==(null===(i=e.message)||void 0===i?void 0:i.offer)&&null!==(null===(n=e.message)||void 0===n?void 0:n.offer)&&(F.message={$case:"offer",offer:vn.fromPartial(e.message.offer)}),"answer"===(null===(r=e.message)||void 0===r?void 0:r.$case)&&void 0!==(null===(s=e.message)||void 0===s?void 0:s.answer)&&null!==(null===(a=e.message)||void 0===a?void 0:a.answer)&&(F.message={$case:"answer",answer:vn.fromPartial(e.message.answer)}),"trickle"===(null===(o=e.message)||void 0===o?void 0:o.$case)&&void 0!==(null===(c=e.message)||void 0===c?void 0:c.trickle)&&null!==(null===(d=e.message)||void 0===d?void 0:d.trickle)&&(F.message={$case:"trickle",trickle:dn.fromPartial(e.message.trickle)}),"addTrack"===(null===(u=e.message)||void 0===u?void 0:u.$case)&&void 0!==(null===(l=e.message)||void 0===l?void 0:l.addTrack)&&null!==(null===(h=e.message)||void 0===h?void 0:h.addTrack)&&(F.message={$case:"addTrack",addTrack:cn.fromPartial(e.message.addTrack)}),"mute"===(null===(p=e.message)||void 0===p?void 0:p.$case)&&void 0!==(null===(m=e.message)||void 0===m?void 0:m.mute)&&null!==(null===(v=e.message)||void 0===v?void 0:v.mute)&&(F.message={$case:"mute",mute:un.fromPartial(e.message.mute)}),"subscription"===(null===(f=e.message)||void 0===f?void 0:f.$case)&&void 0!==(null===(g=e.message)||void 0===g?void 0:g.subscription)&&null!==(null===(b=e.message)||void 0===b?void 0:b.subscription)&&(F.message={$case:"subscription",subscription:gn.fromPartial(e.message.subscription)}),"trackSetting"===(null===(k=e.message)||void 0===k?void 0:k.$case)&&void 0!==(null===(y=e.message)||void 0===y?void 0:y.trackSetting)&&null!==(null===(S=e.message)||void 0===S?void 0:S.trackSetting)&&(F.message={$case:"trackSetting",trackSetting:bn.fromPartial(e.message.trackSetting)}),"leave"===(null===(w=e.message)||void 0===w?void 0:w.$case)&&void 0!==(null===(C=e.message)||void 0===C?void 0:C.leave)&&null!==(null===(T=e.message)||void 0===T?void 0:T.leave)&&(F.message={$case:"leave",leave:kn.fromPartial(e.message.leave)}),"updateLayers"===(null===(E=e.message)||void 0===E?void 0:E.$case)&&void 0!==(null===(P=e.message)||void 0===P?void 0:P.updateLayers)&&null!==(null===(R=e.message)||void 0===R?void 0:R.updateLayers)&&(F.message={$case:"updateLayers",updateLayers:yn.fromPartial(e.message.updateLayers)}),"subscriptionPermission"===(null===(O=e.message)||void 0===O?void 0:O.$case)&&void 0!==(null===(N=e.message)||void 0===N?void 0:N.subscriptionPermission)&&null!==(null===(D=e.message)||void 0===D?void 0:D.subscriptionPermission)&&(F.message={$case:"subscriptionPermission",subscriptionPermission:Un.fromPartial(e.message.subscriptionPermission)}),"syncState"===(null===(I=e.message)||void 0===I?void 0:I.$case)&&void 0!==(null===(A=e.message)||void 0===A?void 0:A.syncState)&&null!==(null===(U=e.message)||void 0===U?void 0:U.syncState)&&(F.message={$case:"syncState",syncState:Ln.fromPartial(e.message.syncState)}),"simulate"===(null===(M=e.message)||void 0===M?void 0:M.$case)&&void 0!==(null===(L=e.message)||void 0===L?void 0:L.simulate)&&null!==(null===(x=e.message)||void 0===x?void 0:x.simulate)&&(F.message={$case:"simulate",simulate:_n.fromPartial(e.message.simulate)}),"ping"===(null===(_=e.message)||void 0===_?void 0:_.$case)&&void 0!==(null===(J=e.message)||void 0===J?void 0:J.ping)&&null!==(null===($=e.message)||void 0===$?void 0:$.ping)&&(F.message={$case:"ping",ping:e.message.ping}),"updateMetadata"===(null===(B=e.message)||void 0===B?void 0:B.$case)&&void 0!==(null===(j=e.message)||void 0===j?void 0:j.updateMetadata)&&null!==(null===(V=e.message)||void 0===V?void 0:V.updateMetadata)&&(F.message={$case:"updateMetadata",updateMetadata:Sn.fromPartial(e.message.updateMetadata)}),F}};const an={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();var i,n,r,s,a,o,c,d,u,l,h,p,m,v,f,g,b,k;return"join"===(null===(i=e.message)||void 0===i?void 0:i.$case)&&ln.encode(e.message.join,t.uint32(10).fork()).ldelim(),"answer"===(null===(n=e.message)||void 0===n?void 0:n.$case)&&vn.encode(e.message.answer,t.uint32(18).fork()).ldelim(),"offer"===(null===(r=e.message)||void 0===r?void 0:r.$case)&&vn.encode(e.message.offer,t.uint32(26).fork()).ldelim(),"trickle"===(null===(s=e.message)||void 0===s?void 0:s.$case)&&dn.encode(e.message.trickle,t.uint32(34).fork()).ldelim(),"update"===(null===(a=e.message)||void 0===a?void 0:a.$case)&&fn.encode(e.message.update,t.uint32(42).fork()).ldelim(),"trackPublished"===(null===(o=e.message)||void 0===o?void 0:o.$case)&&pn.encode(e.message.trackPublished,t.uint32(50).fork()).ldelim(),"leave"===(null===(c=e.message)||void 0===c?void 0:c.$case)&&kn.encode(e.message.leave,t.uint32(66).fork()).ldelim(),"mute"===(null===(d=e.message)||void 0===d?void 0:d.$case)&&un.encode(e.message.mute,t.uint32(74).fork()).ldelim(),"speakersChanged"===(null===(u=e.message)||void 0===u?void 0:u.$case)&&Cn.encode(e.message.speakersChanged,t.uint32(82).fork()).ldelim(),"roomUpdate"===(null===(l=e.message)||void 0===l?void 0:l.$case)&&Tn.encode(e.message.roomUpdate,t.uint32(90).fork()).ldelim(),"connectionQuality"===(null===(h=e.message)||void 0===h?void 0:h.$case)&&Pn.encode(e.message.connectionQuality,t.uint32(98).fork()).ldelim(),"streamStateUpdate"===(null===(p=e.message)||void 0===p?void 0:p.$case)&&On.encode(e.message.streamStateUpdate,t.uint32(106).fork()).ldelim(),"subscribedQualityUpdate"===(null===(m=e.message)||void 0===m?void 0:m.$case)&&In.encode(e.message.subscribedQualityUpdate,t.uint32(114).fork()).ldelim(),"subscriptionPermissionUpdate"===(null===(v=e.message)||void 0===v?void 0:v.$case)&&Mn.encode(e.message.subscriptionPermissionUpdate,t.uint32(122).fork()).ldelim(),"refreshToken"===(null===(f=e.message)||void 0===f?void 0:f.$case)&&t.uint32(130).string(e.message.refreshToken),"trackUnpublished"===(null===(g=e.message)||void 0===g?void 0:g.$case)&&mn.encode(e.message.trackUnpublished,t.uint32(138).fork()).ldelim(),"pong"===(null===(b=e.message)||void 0===b?void 0:b.$case)&&t.uint32(144).int64(e.message.pong),"reconnect"===(null===(k=e.message)||void 0===k?void 0:k.$case)&&hn.encode(e.message.reconnect,t.uint32(154).fork()).ldelim(),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={message:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.message={$case:"join",join:ln.decode(i,i.uint32())};break;case 2:r.message={$case:"answer",answer:vn.decode(i,i.uint32())};break;case 3:r.message={$case:"offer",offer:vn.decode(i,i.uint32())};break;case 4:r.message={$case:"trickle",trickle:dn.decode(i,i.uint32())};break;case 5:r.message={$case:"update",update:fn.decode(i,i.uint32())};break;case 6:r.message={$case:"trackPublished",trackPublished:pn.decode(i,i.uint32())};break;case 8:r.message={$case:"leave",leave:kn.decode(i,i.uint32())};break;case 9:r.message={$case:"mute",mute:un.decode(i,i.uint32())};break;case 10:r.message={$case:"speakersChanged",speakersChanged:Cn.decode(i,i.uint32())};break;case 11:r.message={$case:"roomUpdate",roomUpdate:Tn.decode(i,i.uint32())};break;case 12:r.message={$case:"connectionQuality",connectionQuality:Pn.decode(i,i.uint32())};break;case 13:r.message={$case:"streamStateUpdate",streamStateUpdate:On.decode(i,i.uint32())};break;case 14:r.message={$case:"subscribedQualityUpdate",subscribedQualityUpdate:In.decode(i,i.uint32())};break;case 15:r.message={$case:"subscriptionPermissionUpdate",subscriptionPermissionUpdate:Mn.decode(i,i.uint32())};break;case 16:r.message={$case:"refreshToken",refreshToken:i.string()};break;case 17:r.message={$case:"trackUnpublished",trackUnpublished:mn.decode(i,i.uint32())};break;case 18:r.message={$case:"pong",pong:qn(i.int64())};break;case 19:r.message={$case:"reconnect",reconnect:hn.decode(i,i.uint32())};break;default:i.skipType(7&e)}}return r},fromJSON:e=>({message:Wn(e.join)?{$case:"join",join:ln.fromJSON(e.join)}:Wn(e.answer)?{$case:"answer",answer:vn.fromJSON(e.answer)}:Wn(e.offer)?{$case:"offer",offer:vn.fromJSON(e.offer)}:Wn(e.trickle)?{$case:"trickle",trickle:dn.fromJSON(e.trickle)}:Wn(e.update)?{$case:"update",update:fn.fromJSON(e.update)}:Wn(e.trackPublished)?{$case:"trackPublished",trackPublished:pn.fromJSON(e.trackPublished)}:Wn(e.leave)?{$case:"leave",leave:kn.fromJSON(e.leave)}:Wn(e.mute)?{$case:"mute",mute:un.fromJSON(e.mute)}:Wn(e.speakersChanged)?{$case:"speakersChanged",speakersChanged:Cn.fromJSON(e.speakersChanged)}:Wn(e.roomUpdate)?{$case:"roomUpdate",roomUpdate:Tn.fromJSON(e.roomUpdate)}:Wn(e.connectionQuality)?{$case:"connectionQuality",connectionQuality:Pn.fromJSON(e.connectionQuality)}:Wn(e.streamStateUpdate)?{$case:"streamStateUpdate",streamStateUpdate:On.fromJSON(e.streamStateUpdate)}:Wn(e.subscribedQualityUpdate)?{$case:"subscribedQualityUpdate",subscribedQualityUpdate:In.fromJSON(e.subscribedQualityUpdate)}:Wn(e.subscriptionPermissionUpdate)?{$case:"subscriptionPermissionUpdate",subscriptionPermissionUpdate:Mn.fromJSON(e.subscriptionPermissionUpdate)}:Wn(e.refreshToken)?{$case:"refreshToken",refreshToken:String(e.refreshToken)}:Wn(e.trackUnpublished)?{$case:"trackUnpublished",trackUnpublished:mn.fromJSON(e.trackUnpublished)}:Wn(e.pong)?{$case:"pong",pong:Number(e.pong)}:Wn(e.reconnect)?{$case:"reconnect",reconnect:hn.fromJSON(e.reconnect)}:void 0}),toJSON(e){var t,i,n,r,s,a,o,c,d,u,l,h,p,m,v,f,g,b,k,y,S,w,C,T,E,P,R,O,N,D,I,A,U,M,L,x,_,J,$,B,j,V,F,q,W,G,Q,z,H,Z,K,Y;const X={};return"join"===(null===(t=e.message)||void 0===t?void 0:t.$case)&&(X.join=(null===(i=e.message)||void 0===i?void 0:i.join)?ln.toJSON(null===(n=e.message)||void 0===n?void 0:n.join):void 0),"answer"===(null===(r=e.message)||void 0===r?void 0:r.$case)&&(X.answer=(null===(s=e.message)||void 0===s?void 0:s.answer)?vn.toJSON(null===(a=e.message)||void 0===a?void 0:a.answer):void 0),"offer"===(null===(o=e.message)||void 0===o?void 0:o.$case)&&(X.offer=(null===(c=e.message)||void 0===c?void 0:c.offer)?vn.toJSON(null===(d=e.message)||void 0===d?void 0:d.offer):void 0),"trickle"===(null===(u=e.message)||void 0===u?void 0:u.$case)&&(X.trickle=(null===(l=e.message)||void 0===l?void 0:l.trickle)?dn.toJSON(null===(h=e.message)||void 0===h?void 0:h.trickle):void 0),"update"===(null===(p=e.message)||void 0===p?void 0:p.$case)&&(X.update=(null===(m=e.message)||void 0===m?void 0:m.update)?fn.toJSON(null===(v=e.message)||void 0===v?void 0:v.update):void 0),"trackPublished"===(null===(f=e.message)||void 0===f?void 0:f.$case)&&(X.trackPublished=(null===(g=e.message)||void 0===g?void 0:g.trackPublished)?pn.toJSON(null===(b=e.message)||void 0===b?void 0:b.trackPublished):void 0),"leave"===(null===(k=e.message)||void 0===k?void 0:k.$case)&&(X.leave=(null===(y=e.message)||void 0===y?void 0:y.leave)?kn.toJSON(null===(S=e.message)||void 0===S?void 0:S.leave):void 0),"mute"===(null===(w=e.message)||void 0===w?void 0:w.$case)&&(X.mute=(null===(C=e.message)||void 0===C?void 0:C.mute)?un.toJSON(null===(T=e.message)||void 0===T?void 0:T.mute):void 0),"speakersChanged"===(null===(E=e.message)||void 0===E?void 0:E.$case)&&(X.speakersChanged=(null===(P=e.message)||void 0===P?void 0:P.speakersChanged)?Cn.toJSON(null===(R=e.message)||void 0===R?void 0:R.speakersChanged):void 0),"roomUpdate"===(null===(O=e.message)||void 0===O?void 0:O.$case)&&(X.roomUpdate=(null===(N=e.message)||void 0===N?void 0:N.roomUpdate)?Tn.toJSON(null===(D=e.message)||void 0===D?void 0:D.roomUpdate):void 0),"connectionQuality"===(null===(I=e.message)||void 0===I?void 0:I.$case)&&(X.connectionQuality=(null===(A=e.message)||void 0===A?void 0:A.connectionQuality)?Pn.toJSON(null===(U=e.message)||void 0===U?void 0:U.connectionQuality):void 0),"streamStateUpdate"===(null===(M=e.message)||void 0===M?void 0:M.$case)&&(X.streamStateUpdate=(null===(L=e.message)||void 0===L?void 0:L.streamStateUpdate)?On.toJSON(null===(x=e.message)||void 0===x?void 0:x.streamStateUpdate):void 0),"subscribedQualityUpdate"===(null===(_=e.message)||void 0===_?void 0:_.$case)&&(X.subscribedQualityUpdate=(null===(J=e.message)||void 0===J?void 0:J.subscribedQualityUpdate)?In.toJSON(null===($=e.message)||void 0===$?void 0:$.subscribedQualityUpdate):void 0),"subscriptionPermissionUpdate"===(null===(B=e.message)||void 0===B?void 0:B.$case)&&(X.subscriptionPermissionUpdate=(null===(j=e.message)||void 0===j?void 0:j.subscriptionPermissionUpdate)?Mn.toJSON(null===(V=e.message)||void 0===V?void 0:V.subscriptionPermissionUpdate):void 0),"refreshToken"===(null===(F=e.message)||void 0===F?void 0:F.$case)&&(X.refreshToken=null===(q=e.message)||void 0===q?void 0:q.refreshToken),"trackUnpublished"===(null===(W=e.message)||void 0===W?void 0:W.$case)&&(X.trackUnpublished=(null===(G=e.message)||void 0===G?void 0:G.trackUnpublished)?mn.toJSON(null===(Q=e.message)||void 0===Q?void 0:Q.trackUnpublished):void 0),"pong"===(null===(z=e.message)||void 0===z?void 0:z.$case)&&(X.pong=Math.round(null===(H=e.message)||void 0===H?void 0:H.pong)),"reconnect"===(null===(Z=e.message)||void 0===Z?void 0:Z.$case)&&(X.reconnect=(null===(K=e.message)||void 0===K?void 0:K.reconnect)?hn.toJSON(null===(Y=e.message)||void 0===Y?void 0:Y.reconnect):void 0),X},fromPartial(e){var t,i,n,r,s,a,o,c,d,u,l,h,p,m,v,f,g,b,k,y,S,w,C,T,E,P,R,O,N,D,I,A,U,M,L,x,_,J,$,B,j,V,F,q,W,G,Q,z,H,Z,K,Y,X,ee;const te={message:void 0};return"join"===(null===(t=e.message)||void 0===t?void 0:t.$case)&&void 0!==(null===(i=e.message)||void 0===i?void 0:i.join)&&null!==(null===(n=e.message)||void 0===n?void 0:n.join)&&(te.message={$case:"join",join:ln.fromPartial(e.message.join)}),"answer"===(null===(r=e.message)||void 0===r?void 0:r.$case)&&void 0!==(null===(s=e.message)||void 0===s?void 0:s.answer)&&null!==(null===(a=e.message)||void 0===a?void 0:a.answer)&&(te.message={$case:"answer",answer:vn.fromPartial(e.message.answer)}),"offer"===(null===(o=e.message)||void 0===o?void 0:o.$case)&&void 0!==(null===(c=e.message)||void 0===c?void 0:c.offer)&&null!==(null===(d=e.message)||void 0===d?void 0:d.offer)&&(te.message={$case:"offer",offer:vn.fromPartial(e.message.offer)}),"trickle"===(null===(u=e.message)||void 0===u?void 0:u.$case)&&void 0!==(null===(l=e.message)||void 0===l?void 0:l.trickle)&&null!==(null===(h=e.message)||void 0===h?void 0:h.trickle)&&(te.message={$case:"trickle",trickle:dn.fromPartial(e.message.trickle)}),"update"===(null===(p=e.message)||void 0===p?void 0:p.$case)&&void 0!==(null===(m=e.message)||void 0===m?void 0:m.update)&&null!==(null===(v=e.message)||void 0===v?void 0:v.update)&&(te.message={$case:"update",update:fn.fromPartial(e.message.update)}),"trackPublished"===(null===(f=e.message)||void 0===f?void 0:f.$case)&&void 0!==(null===(g=e.message)||void 0===g?void 0:g.trackPublished)&&null!==(null===(b=e.message)||void 0===b?void 0:b.trackPublished)&&(te.message={$case:"trackPublished",trackPublished:pn.fromPartial(e.message.trackPublished)}),"leave"===(null===(k=e.message)||void 0===k?void 0:k.$case)&&void 0!==(null===(y=e.message)||void 0===y?void 0:y.leave)&&null!==(null===(S=e.message)||void 0===S?void 0:S.leave)&&(te.message={$case:"leave",leave:kn.fromPartial(e.message.leave)}),"mute"===(null===(w=e.message)||void 0===w?void 0:w.$case)&&void 0!==(null===(C=e.message)||void 0===C?void 0:C.mute)&&null!==(null===(T=e.message)||void 0===T?void 0:T.mute)&&(te.message={$case:"mute",mute:un.fromPartial(e.message.mute)}),"speakersChanged"===(null===(E=e.message)||void 0===E?void 0:E.$case)&&void 0!==(null===(P=e.message)||void 0===P?void 0:P.speakersChanged)&&null!==(null===(R=e.message)||void 0===R?void 0:R.speakersChanged)&&(te.message={$case:"speakersChanged",speakersChanged:Cn.fromPartial(e.message.speakersChanged)}),"roomUpdate"===(null===(O=e.message)||void 0===O?void 0:O.$case)&&void 0!==(null===(N=e.message)||void 0===N?void 0:N.roomUpdate)&&null!==(null===(D=e.message)||void 0===D?void 0:D.roomUpdate)&&(te.message={$case:"roomUpdate",roomUpdate:Tn.fromPartial(e.message.roomUpdate)}),"connectionQuality"===(null===(I=e.message)||void 0===I?void 0:I.$case)&&void 0!==(null===(A=e.message)||void 0===A?void 0:A.connectionQuality)&&null!==(null===(U=e.message)||void 0===U?void 0:U.connectionQuality)&&(te.message={$case:"connectionQuality",connectionQuality:Pn.fromPartial(e.message.connectionQuality)}),"streamStateUpdate"===(null===(M=e.message)||void 0===M?void 0:M.$case)&&void 0!==(null===(L=e.message)||void 0===L?void 0:L.streamStateUpdate)&&null!==(null===(x=e.message)||void 0===x?void 0:x.streamStateUpdate)&&(te.message={$case:"streamStateUpdate",streamStateUpdate:On.fromPartial(e.message.streamStateUpdate)}),"subscribedQualityUpdate"===(null===(_=e.message)||void 0===_?void 0:_.$case)&&void 0!==(null===(J=e.message)||void 0===J?void 0:J.subscribedQualityUpdate)&&null!==(null===($=e.message)||void 0===$?void 0:$.subscribedQualityUpdate)&&(te.message={$case:"subscribedQualityUpdate",subscribedQualityUpdate:In.fromPartial(e.message.subscribedQualityUpdate)}),"subscriptionPermissionUpdate"===(null===(B=e.message)||void 0===B?void 0:B.$case)&&void 0!==(null===(j=e.message)||void 0===j?void 0:j.subscriptionPermissionUpdate)&&null!==(null===(V=e.message)||void 0===V?void 0:V.subscriptionPermissionUpdate)&&(te.message={$case:"subscriptionPermissionUpdate",subscriptionPermissionUpdate:Mn.fromPartial(e.message.subscriptionPermissionUpdate)}),"refreshToken"===(null===(F=e.message)||void 0===F?void 0:F.$case)&&void 0!==(null===(q=e.message)||void 0===q?void 0:q.refreshToken)&&null!==(null===(W=e.message)||void 0===W?void 0:W.refreshToken)&&(te.message={$case:"refreshToken",refreshToken:e.message.refreshToken}),"trackUnpublished"===(null===(G=e.message)||void 0===G?void 0:G.$case)&&void 0!==(null===(Q=e.message)||void 0===Q?void 0:Q.trackUnpublished)&&null!==(null===(z=e.message)||void 0===z?void 0:z.trackUnpublished)&&(te.message={$case:"trackUnpublished",trackUnpublished:mn.fromPartial(e.message.trackUnpublished)}),"pong"===(null===(H=e.message)||void 0===H?void 0:H.$case)&&void 0!==(null===(Z=e.message)||void 0===Z?void 0:Z.pong)&&null!==(null===(K=e.message)||void 0===K?void 0:K.pong)&&(te.message={$case:"pong",pong:e.message.pong}),"reconnect"===(null===(Y=e.message)||void 0===Y?void 0:Y.$case)&&void 0!==(null===(X=e.message)||void 0===X?void 0:X.reconnect)&&null!==(null===(ee=e.message)||void 0===ee?void 0:ee.reconnect)&&(te.message={$case:"reconnect",reconnect:hn.fromPartial(e.message.reconnect)}),te}};const on={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.codec&&t.uint32(10).string(e.codec),""!==e.cid&&t.uint32(18).string(e.cid),!0===e.enableSimulcastLayers&&t.uint32(24).bool(e.enableSimulcastLayers),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={codec:"",cid:"",enableSimulcastLayers:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.codec=i.string();break;case 2:r.cid=i.string();break;case 3:r.enableSimulcastLayers=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({codec:Wn(e.codec)?String(e.codec):"",cid:Wn(e.cid)?String(e.cid):"",enableSimulcastLayers:!!Wn(e.enableSimulcastLayers)&&Boolean(e.enableSimulcastLayers)}),toJSON(e){const t={};return void 0!==e.codec&&(t.codec=e.codec),void 0!==e.cid&&(t.cid=e.cid),void 0!==e.enableSimulcastLayers&&(t.enableSimulcastLayers=e.enableSimulcastLayers),t},fromPartial(e){var t,i,n;const r={codec:"",cid:"",enableSimulcastLayers:!1};return r.codec=null!==(t=e.codec)&&void 0!==t?t:"",r.cid=null!==(i=e.cid)&&void 0!==i?i:"",r.enableSimulcastLayers=null!==(n=e.enableSimulcastLayers)&&void 0!==n&&n,r}};const cn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();""!==e.cid&&t.uint32(10).string(e.cid),""!==e.name&&t.uint32(18).string(e.name),0!==e.type&&t.uint32(24).int32(e.type),0!==e.width&&t.uint32(32).uint32(e.width),0!==e.height&&t.uint32(40).uint32(e.height),!0===e.muted&&t.uint32(48).bool(e.muted),!0===e.disableDtx&&t.uint32(56).bool(e.disableDtx),0!==e.source&&t.uint32(64).int32(e.source);for(const i of e.layers)Ct.encode(i,t.uint32(74).fork()).ldelim();for(const i of e.simulcastCodecs)on.encode(i,t.uint32(82).fork()).ldelim();return""!==e.sid&&t.uint32(90).string(e.sid),!0===e.stereo&&t.uint32(96).bool(e.stereo),!0===e.disableRed&&t.uint32(104).bool(e.disableRed),0!==e.encryption&&t.uint32(112).int32(e.encryption),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={cid:"",name:"",type:0,width:0,height:0,muted:!1,disableDtx:!1,source:0,layers:[],simulcastCodecs:[],sid:"",stereo:!1,disableRed:!1,encryption:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.cid=i.string();break;case 2:r.name=i.string();break;case 3:r.type=i.int32();break;case 4:r.width=i.uint32();break;case 5:r.height=i.uint32();break;case 6:r.muted=i.bool();break;case 7:r.disableDtx=i.bool();break;case 8:r.source=i.int32();break;case 9:r.layers.push(Ct.decode(i,i.uint32()));break;case 10:r.simulcastCodecs.push(on.decode(i,i.uint32()));break;case 11:r.sid=i.string();break;case 12:r.stereo=i.bool();break;case 13:r.disableRed=i.bool();break;case 14:r.encryption=i.int32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({cid:Wn(e.cid)?String(e.cid):"",name:Wn(e.name)?String(e.name):"",type:Wn(e.type)?tt(e.type):0,width:Wn(e.width)?Number(e.width):0,height:Wn(e.height)?Number(e.height):0,muted:!!Wn(e.muted)&&Boolean(e.muted),disableDtx:!!Wn(e.disableDtx)&&Boolean(e.disableDtx),source:Wn(e.source)?nt(e.source):0,layers:Array.isArray(null==e?void 0:e.layers)?e.layers.map((e=>Ct.fromJSON(e))):[],simulcastCodecs:Array.isArray(null==e?void 0:e.simulcastCodecs)?e.simulcastCodecs.map((e=>on.fromJSON(e))):[],sid:Wn(e.sid)?String(e.sid):"",stereo:!!Wn(e.stereo)&&Boolean(e.stereo),disableRed:!!Wn(e.disableRed)&&Boolean(e.disableRed),encryption:Wn(e.encryption)?ht(e.encryption):0}),toJSON(e){const t={};return void 0!==e.cid&&(t.cid=e.cid),void 0!==e.name&&(t.name=e.name),void 0!==e.type&&(t.type=it(e.type)),void 0!==e.width&&(t.width=Math.round(e.width)),void 0!==e.height&&(t.height=Math.round(e.height)),void 0!==e.muted&&(t.muted=e.muted),void 0!==e.disableDtx&&(t.disableDtx=e.disableDtx),void 0!==e.source&&(t.source=rt(e.source)),e.layers?t.layers=e.layers.map((e=>e?Ct.toJSON(e):void 0)):t.layers=[],e.simulcastCodecs?t.simulcastCodecs=e.simulcastCodecs.map((e=>e?on.toJSON(e):void 0)):t.simulcastCodecs=[],void 0!==e.sid&&(t.sid=e.sid),void 0!==e.stereo&&(t.stereo=e.stereo),void 0!==e.disableRed&&(t.disableRed=e.disableRed),void 0!==e.encryption&&(t.encryption=pt(e.encryption)),t},fromPartial(e){var t,i,n,r,s,a,o,c,d,u,l,h,p,m;const v={cid:"",name:"",type:0,width:0,height:0,muted:!1,disableDtx:!1,source:0,layers:[],simulcastCodecs:[],sid:"",stereo:!1,disableRed:!1,encryption:0};return v.cid=null!==(t=e.cid)&&void 0!==t?t:"",v.name=null!==(i=e.name)&&void 0!==i?i:"",v.type=null!==(n=e.type)&&void 0!==n?n:0,v.width=null!==(r=e.width)&&void 0!==r?r:0,v.height=null!==(s=e.height)&&void 0!==s?s:0,v.muted=null!==(a=e.muted)&&void 0!==a&&a,v.disableDtx=null!==(o=e.disableDtx)&&void 0!==o&&o,v.source=null!==(c=e.source)&&void 0!==c?c:0,v.layers=(null===(d=e.layers)||void 0===d?void 0:d.map((e=>Ct.fromPartial(e))))||[],v.simulcastCodecs=(null===(u=e.simulcastCodecs)||void 0===u?void 0:u.map((e=>on.fromPartial(e))))||[],v.sid=null!==(l=e.sid)&&void 0!==l?l:"",v.stereo=null!==(h=e.stereo)&&void 0!==h&&h,v.disableRed=null!==(p=e.disableRed)&&void 0!==p&&p,v.encryption=null!==(m=e.encryption)&&void 0!==m?m:0,v}};const dn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.candidateInit&&t.uint32(10).string(e.candidateInit),0!==e.target&&t.uint32(16).int32(e.target),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={candidateInit:"",target:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.candidateInit=i.string();break;case 2:r.target=i.int32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({candidateInit:Wn(e.candidateInit)?String(e.candidateInit):"",target:Wn(e.target)?en(e.target):0}),toJSON(e){const t={};return void 0!==e.candidateInit&&(t.candidateInit=e.candidateInit),void 0!==e.target&&(t.target=tn(e.target)),t},fromPartial(e){var t,i;const n={candidateInit:"",target:0};return n.candidateInit=null!==(t=e.candidateInit)&&void 0!==t?t:"",n.target=null!==(i=e.target)&&void 0!==i?i:0,n}};const un={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.sid&&t.uint32(10).string(e.sid),!0===e.muted&&t.uint32(16).bool(e.muted),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={sid:"",muted:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.sid=i.string();break;case 2:r.muted=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({sid:Wn(e.sid)?String(e.sid):"",muted:!!Wn(e.muted)&&Boolean(e.muted)}),toJSON(e){const t={};return void 0!==e.sid&&(t.sid=e.sid),void 0!==e.muted&&(t.muted=e.muted),t},fromPartial(e){var t,i;const n={sid:"",muted:!1};return n.sid=null!==(t=e.sid)&&void 0!==t?t:"",n.muted=null!==(i=e.muted)&&void 0!==i&&i,n}};const ln={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();void 0!==e.room&>.encode(e.room,t.uint32(10).fork()).ldelim(),void 0!==e.participant&&yt.encode(e.participant,t.uint32(18).fork()).ldelim();for(const i of e.otherParticipants)yt.encode(i,t.uint32(26).fork()).ldelim();""!==e.serverVersion&&t.uint32(34).string(e.serverVersion);for(const i of e.iceServers)wn.encode(i,t.uint32(42).fork()).ldelim();return!0===e.subscriberPrimary&&t.uint32(48).bool(e.subscriberPrimary),""!==e.alternativeUrl&&t.uint32(58).string(e.alternativeUrl),void 0!==e.clientConfiguration&&At.encode(e.clientConfiguration,t.uint32(66).fork()).ldelim(),""!==e.serverRegion&&t.uint32(74).string(e.serverRegion),0!==e.pingTimeout&&t.uint32(80).int32(e.pingTimeout),0!==e.pingInterval&&t.uint32(88).int32(e.pingInterval),void 0!==e.serverInfo&&Dt.encode(e.serverInfo,t.uint32(98).fork()).ldelim(),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={room:void 0,participant:void 0,otherParticipants:[],serverVersion:"",iceServers:[],subscriberPrimary:!1,alternativeUrl:"",clientConfiguration:void 0,serverRegion:"",pingTimeout:0,pingInterval:0,serverInfo:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.room=gt.decode(i,i.uint32());break;case 2:r.participant=yt.decode(i,i.uint32());break;case 3:r.otherParticipants.push(yt.decode(i,i.uint32()));break;case 4:r.serverVersion=i.string();break;case 5:r.iceServers.push(wn.decode(i,i.uint32()));break;case 6:r.subscriberPrimary=i.bool();break;case 7:r.alternativeUrl=i.string();break;case 8:r.clientConfiguration=At.decode(i,i.uint32());break;case 9:r.serverRegion=i.string();break;case 10:r.pingTimeout=i.int32();break;case 11:r.pingInterval=i.int32();break;case 12:r.serverInfo=Dt.decode(i,i.uint32());break;default:i.skipType(7&e)}}return r},fromJSON:e=>({room:Wn(e.room)?gt.fromJSON(e.room):void 0,participant:Wn(e.participant)?yt.fromJSON(e.participant):void 0,otherParticipants:Array.isArray(null==e?void 0:e.otherParticipants)?e.otherParticipants.map((e=>yt.fromJSON(e))):[],serverVersion:Wn(e.serverVersion)?String(e.serverVersion):"",iceServers:Array.isArray(null==e?void 0:e.iceServers)?e.iceServers.map((e=>wn.fromJSON(e))):[],subscriberPrimary:!!Wn(e.subscriberPrimary)&&Boolean(e.subscriberPrimary),alternativeUrl:Wn(e.alternativeUrl)?String(e.alternativeUrl):"",clientConfiguration:Wn(e.clientConfiguration)?At.fromJSON(e.clientConfiguration):void 0,serverRegion:Wn(e.serverRegion)?String(e.serverRegion):"",pingTimeout:Wn(e.pingTimeout)?Number(e.pingTimeout):0,pingInterval:Wn(e.pingInterval)?Number(e.pingInterval):0,serverInfo:Wn(e.serverInfo)?Dt.fromJSON(e.serverInfo):void 0}),toJSON(e){const t={};return void 0!==e.room&&(t.room=e.room?gt.toJSON(e.room):void 0),void 0!==e.participant&&(t.participant=e.participant?yt.toJSON(e.participant):void 0),e.otherParticipants?t.otherParticipants=e.otherParticipants.map((e=>e?yt.toJSON(e):void 0)):t.otherParticipants=[],void 0!==e.serverVersion&&(t.serverVersion=e.serverVersion),e.iceServers?t.iceServers=e.iceServers.map((e=>e?wn.toJSON(e):void 0)):t.iceServers=[],void 0!==e.subscriberPrimary&&(t.subscriberPrimary=e.subscriberPrimary),void 0!==e.alternativeUrl&&(t.alternativeUrl=e.alternativeUrl),void 0!==e.clientConfiguration&&(t.clientConfiguration=e.clientConfiguration?At.toJSON(e.clientConfiguration):void 0),void 0!==e.serverRegion&&(t.serverRegion=e.serverRegion),void 0!==e.pingTimeout&&(t.pingTimeout=Math.round(e.pingTimeout)),void 0!==e.pingInterval&&(t.pingInterval=Math.round(e.pingInterval)),void 0!==e.serverInfo&&(t.serverInfo=e.serverInfo?Dt.toJSON(e.serverInfo):void 0),t},fromPartial(e){var t,i,n,r,s,a,o,c;const d={room:void 0,participant:void 0,otherParticipants:[],serverVersion:"",iceServers:[],subscriberPrimary:!1,alternativeUrl:"",clientConfiguration:void 0,serverRegion:"",pingTimeout:0,pingInterval:0,serverInfo:void 0};return d.room=void 0!==e.room&&null!==e.room?gt.fromPartial(e.room):void 0,d.participant=void 0!==e.participant&&null!==e.participant?yt.fromPartial(e.participant):void 0,d.otherParticipants=(null===(t=e.otherParticipants)||void 0===t?void 0:t.map((e=>yt.fromPartial(e))))||[],d.serverVersion=null!==(i=e.serverVersion)&&void 0!==i?i:"",d.iceServers=(null===(n=e.iceServers)||void 0===n?void 0:n.map((e=>wn.fromPartial(e))))||[],d.subscriberPrimary=null!==(r=e.subscriberPrimary)&&void 0!==r&&r,d.alternativeUrl=null!==(s=e.alternativeUrl)&&void 0!==s?s:"",d.clientConfiguration=void 0!==e.clientConfiguration&&null!==e.clientConfiguration?At.fromPartial(e.clientConfiguration):void 0,d.serverRegion=null!==(a=e.serverRegion)&&void 0!==a?a:"",d.pingTimeout=null!==(o=e.pingTimeout)&&void 0!==o?o:0,d.pingInterval=null!==(c=e.pingInterval)&&void 0!==c?c:0,d.serverInfo=void 0!==e.serverInfo&&null!==e.serverInfo?Dt.fromPartial(e.serverInfo):void 0,d}};const hn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();for(const i of e.iceServers)wn.encode(i,t.uint32(10).fork()).ldelim();return void 0!==e.clientConfiguration&&At.encode(e.clientConfiguration,t.uint32(18).fork()).ldelim(),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={iceServers:[],clientConfiguration:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.iceServers.push(wn.decode(i,i.uint32()));break;case 2:r.clientConfiguration=At.decode(i,i.uint32());break;default:i.skipType(7&e)}}return r},fromJSON:e=>({iceServers:Array.isArray(null==e?void 0:e.iceServers)?e.iceServers.map((e=>wn.fromJSON(e))):[],clientConfiguration:Wn(e.clientConfiguration)?At.fromJSON(e.clientConfiguration):void 0}),toJSON(e){const t={};return e.iceServers?t.iceServers=e.iceServers.map((e=>e?wn.toJSON(e):void 0)):t.iceServers=[],void 0!==e.clientConfiguration&&(t.clientConfiguration=e.clientConfiguration?At.toJSON(e.clientConfiguration):void 0),t},fromPartial(e){var t;const i={iceServers:[],clientConfiguration:void 0};return i.iceServers=(null===(t=e.iceServers)||void 0===t?void 0:t.map((e=>wn.fromPartial(e))))||[],i.clientConfiguration=void 0!==e.clientConfiguration&&null!==e.clientConfiguration?At.fromPartial(e.clientConfiguration):void 0,i}};const pn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.cid&&t.uint32(10).string(e.cid),void 0!==e.track&&wt.encode(e.track,t.uint32(18).fork()).ldelim(),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={cid:"",track:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.cid=i.string();break;case 2:r.track=wt.decode(i,i.uint32());break;default:i.skipType(7&e)}}return r},fromJSON:e=>({cid:Wn(e.cid)?String(e.cid):"",track:Wn(e.track)?wt.fromJSON(e.track):void 0}),toJSON(e){const t={};return void 0!==e.cid&&(t.cid=e.cid),void 0!==e.track&&(t.track=e.track?wt.toJSON(e.track):void 0),t},fromPartial(e){var t;const i={cid:"",track:void 0};return i.cid=null!==(t=e.cid)&&void 0!==t?t:"",i.track=void 0!==e.track&&null!==e.track?wt.fromPartial(e.track):void 0,i}};const mn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.trackSid&&t.uint32(10).string(e.trackSid),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={trackSid:""};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.trackSid=i.string();else i.skipType(7&e)}return r},fromJSON:e=>({trackSid:Wn(e.trackSid)?String(e.trackSid):""}),toJSON(e){const t={};return void 0!==e.trackSid&&(t.trackSid=e.trackSid),t},fromPartial(e){var t;const i={trackSid:""};return i.trackSid=null!==(t=e.trackSid)&&void 0!==t?t:"",i}};const vn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.type&&t.uint32(10).string(e.type),""!==e.sdp&&t.uint32(18).string(e.sdp),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={type:"",sdp:""};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.type=i.string();break;case 2:r.sdp=i.string();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({type:Wn(e.type)?String(e.type):"",sdp:Wn(e.sdp)?String(e.sdp):""}),toJSON(e){const t={};return void 0!==e.type&&(t.type=e.type),void 0!==e.sdp&&(t.sdp=e.sdp),t},fromPartial(e){var t,i;const n={type:"",sdp:""};return n.type=null!==(t=e.type)&&void 0!==t?t:"",n.sdp=null!==(i=e.sdp)&&void 0!==i?i:"",n}};const fn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();for(const i of e.participants)yt.encode(i,t.uint32(10).fork()).ldelim();return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={participants:[]};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.participants.push(yt.decode(i,i.uint32()));else i.skipType(7&e)}return r},fromJSON:e=>({participants:Array.isArray(null==e?void 0:e.participants)?e.participants.map((e=>yt.fromJSON(e))):[]}),toJSON(e){const t={};return e.participants?t.participants=e.participants.map((e=>e?yt.toJSON(e):void 0)):t.participants=[],t},fromPartial(e){var t;const i={participants:[]};return i.participants=(null===(t=e.participants)||void 0===t?void 0:t.map((e=>yt.fromPartial(e))))||[],i}};const gn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();for(const i of e.trackSids)t.uint32(10).string(i);!0===e.subscribe&&t.uint32(16).bool(e.subscribe);for(const i of e.participantTracks)Nt.encode(i,t.uint32(26).fork()).ldelim();return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={trackSids:[],subscribe:!1,participantTracks:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.trackSids.push(i.string());break;case 2:r.subscribe=i.bool();break;case 3:r.participantTracks.push(Nt.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({trackSids:Array.isArray(null==e?void 0:e.trackSids)?e.trackSids.map((e=>String(e))):[],subscribe:!!Wn(e.subscribe)&&Boolean(e.subscribe),participantTracks:Array.isArray(null==e?void 0:e.participantTracks)?e.participantTracks.map((e=>Nt.fromJSON(e))):[]}),toJSON(e){const t={};return e.trackSids?t.trackSids=e.trackSids.map((e=>e)):t.trackSids=[],void 0!==e.subscribe&&(t.subscribe=e.subscribe),e.participantTracks?t.participantTracks=e.participantTracks.map((e=>e?Nt.toJSON(e):void 0)):t.participantTracks=[],t},fromPartial(e){var t,i,n;const r={trackSids:[],subscribe:!1,participantTracks:[]};return r.trackSids=(null===(t=e.trackSids)||void 0===t?void 0:t.map((e=>e)))||[],r.subscribe=null!==(i=e.subscribe)&&void 0!==i&&i,r.participantTracks=(null===(n=e.participantTracks)||void 0===n?void 0:n.map((e=>Nt.fromPartial(e))))||[],r}};const bn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();for(const i of e.trackSids)t.uint32(10).string(i);return!0===e.disabled&&t.uint32(24).bool(e.disabled),0!==e.quality&&t.uint32(32).int32(e.quality),0!==e.width&&t.uint32(40).uint32(e.width),0!==e.height&&t.uint32(48).uint32(e.height),0!==e.fps&&t.uint32(56).uint32(e.fps),0!==e.priority&&t.uint32(64).uint32(e.priority),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={trackSids:[],disabled:!1,quality:0,width:0,height:0,fps:0,priority:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.trackSids.push(i.string());break;case 3:r.disabled=i.bool();break;case 4:r.quality=i.int32();break;case 5:r.width=i.uint32();break;case 6:r.height=i.uint32();break;case 7:r.fps=i.uint32();break;case 8:r.priority=i.uint32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({trackSids:Array.isArray(null==e?void 0:e.trackSids)?e.trackSids.map((e=>String(e))):[],disabled:!!Wn(e.disabled)&&Boolean(e.disabled),quality:Wn(e.quality)?st(e.quality):0,width:Wn(e.width)?Number(e.width):0,height:Wn(e.height)?Number(e.height):0,fps:Wn(e.fps)?Number(e.fps):0,priority:Wn(e.priority)?Number(e.priority):0}),toJSON(e){const t={};return e.trackSids?t.trackSids=e.trackSids.map((e=>e)):t.trackSids=[],void 0!==e.disabled&&(t.disabled=e.disabled),void 0!==e.quality&&(t.quality=at(e.quality)),void 0!==e.width&&(t.width=Math.round(e.width)),void 0!==e.height&&(t.height=Math.round(e.height)),void 0!==e.fps&&(t.fps=Math.round(e.fps)),void 0!==e.priority&&(t.priority=Math.round(e.priority)),t},fromPartial(e){var t,i,n,r,s,a,o;const c={trackSids:[],disabled:!1,quality:0,width:0,height:0,fps:0,priority:0};return c.trackSids=(null===(t=e.trackSids)||void 0===t?void 0:t.map((e=>e)))||[],c.disabled=null!==(i=e.disabled)&&void 0!==i&&i,c.quality=null!==(n=e.quality)&&void 0!==n?n:0,c.width=null!==(r=e.width)&&void 0!==r?r:0,c.height=null!==(s=e.height)&&void 0!==s?s:0,c.fps=null!==(a=e.fps)&&void 0!==a?a:0,c.priority=null!==(o=e.priority)&&void 0!==o?o:0,c}};const kn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return!0===e.canReconnect&&t.uint32(8).bool(e.canReconnect),0!==e.reason&&t.uint32(16).int32(e.reason),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={canReconnect:!1,reason:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.canReconnect=i.bool();break;case 2:r.reason=i.int32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({canReconnect:!!Wn(e.canReconnect)&&Boolean(e.canReconnect),reason:Wn(e.reason)?ut(e.reason):0}),toJSON(t){const i={};return void 0!==t.canReconnect&&(i.canReconnect=t.canReconnect),void 0!==t.reason&&(i.reason=function(t){switch(t){case e.DisconnectReason.UNKNOWN_REASON:return"UNKNOWN_REASON";case e.DisconnectReason.CLIENT_INITIATED:return"CLIENT_INITIATED";case e.DisconnectReason.DUPLICATE_IDENTITY:return"DUPLICATE_IDENTITY";case e.DisconnectReason.SERVER_SHUTDOWN:return"SERVER_SHUTDOWN";case e.DisconnectReason.PARTICIPANT_REMOVED:return"PARTICIPANT_REMOVED";case e.DisconnectReason.ROOM_DELETED:return"ROOM_DELETED";case e.DisconnectReason.STATE_MISMATCH:return"STATE_MISMATCH";case e.DisconnectReason.JOIN_FAILURE:return"JOIN_FAILURE";case e.DisconnectReason.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(t.reason)),i},fromPartial(e){var t,i;const n={canReconnect:!1,reason:0};return n.canReconnect=null!==(t=e.canReconnect)&&void 0!==t&&t,n.reason=null!==(i=e.reason)&&void 0!==i?i:0,n}};const yn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();""!==e.trackSid&&t.uint32(10).string(e.trackSid);for(const i of e.layers)Ct.encode(i,t.uint32(18).fork()).ldelim();return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={trackSid:"",layers:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.trackSid=i.string();break;case 2:r.layers.push(Ct.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({trackSid:Wn(e.trackSid)?String(e.trackSid):"",layers:Array.isArray(null==e?void 0:e.layers)?e.layers.map((e=>Ct.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.trackSid&&(t.trackSid=e.trackSid),e.layers?t.layers=e.layers.map((e=>e?Ct.toJSON(e):void 0)):t.layers=[],t},fromPartial(e){var t,i;const n={trackSid:"",layers:[]};return n.trackSid=null!==(t=e.trackSid)&&void 0!==t?t:"",n.layers=(null===(i=e.layers)||void 0===i?void 0:i.map((e=>Ct.fromPartial(e))))||[],n}};const Sn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.metadata&&t.uint32(10).string(e.metadata),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={metadata:""};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.metadata=i.string();else i.skipType(7&e)}return r},fromJSON:e=>({metadata:Wn(e.metadata)?String(e.metadata):""}),toJSON(e){const t={};return void 0!==e.metadata&&(t.metadata=e.metadata),t},fromPartial(e){var t;const i={metadata:""};return i.metadata=null!==(t=e.metadata)&&void 0!==t?t:"",i}};const wn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();for(const i of e.urls)t.uint32(10).string(i);return""!==e.username&&t.uint32(18).string(e.username),""!==e.credential&&t.uint32(26).string(e.credential),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={urls:[],username:"",credential:""};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.urls.push(i.string());break;case 2:r.username=i.string();break;case 3:r.credential=i.string();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({urls:Array.isArray(null==e?void 0:e.urls)?e.urls.map((e=>String(e))):[],username:Wn(e.username)?String(e.username):"",credential:Wn(e.credential)?String(e.credential):""}),toJSON(e){const t={};return e.urls?t.urls=e.urls.map((e=>e)):t.urls=[],void 0!==e.username&&(t.username=e.username),void 0!==e.credential&&(t.credential=e.credential),t},fromPartial(e){var t,i,n;const r={urls:[],username:"",credential:""};return r.urls=(null===(t=e.urls)||void 0===t?void 0:t.map((e=>e)))||[],r.username=null!==(i=e.username)&&void 0!==i?i:"",r.credential=null!==(n=e.credential)&&void 0!==n?n:"",r}};const Cn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();for(const i of e.speakers)Pt.encode(i,t.uint32(10).fork()).ldelim();return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={speakers:[]};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.speakers.push(Pt.decode(i,i.uint32()));else i.skipType(7&e)}return r},fromJSON:e=>({speakers:Array.isArray(null==e?void 0:e.speakers)?e.speakers.map((e=>Pt.fromJSON(e))):[]}),toJSON(e){const t={};return e.speakers?t.speakers=e.speakers.map((e=>e?Pt.toJSON(e):void 0)):t.speakers=[],t},fromPartial(e){var t;const i={speakers:[]};return i.speakers=(null===(t=e.speakers)||void 0===t?void 0:t.map((e=>Pt.fromPartial(e))))||[],i}};const Tn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return void 0!==e.room&>.encode(e.room,t.uint32(10).fork()).ldelim(),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={room:void 0};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.room=gt.decode(i,i.uint32());else i.skipType(7&e)}return r},fromJSON:e=>({room:Wn(e.room)?gt.fromJSON(e.room):void 0}),toJSON(e){const t={};return void 0!==e.room&&(t.room=e.room?gt.toJSON(e.room):void 0),t},fromPartial(e){const t={room:void 0};return t.room=void 0!==e.room&&null!==e.room?gt.fromPartial(e.room):void 0,t}};const En={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.participantSid&&t.uint32(10).string(e.participantSid),0!==e.quality&&t.uint32(16).int32(e.quality),0!==e.score&&t.uint32(29).float(e.score),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={participantSid:"",quality:0,score:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.participantSid=i.string();break;case 2:r.quality=i.int32();break;case 3:r.score=i.float();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({participantSid:Wn(e.participantSid)?String(e.participantSid):"",quality:Wn(e.quality)?ot(e.quality):0,score:Wn(e.score)?Number(e.score):0}),toJSON(e){const t={};return void 0!==e.participantSid&&(t.participantSid=e.participantSid),void 0!==e.quality&&(t.quality=function(e){switch(e){case Ge.POOR:return"POOR";case Ge.GOOD:return"GOOD";case Ge.EXCELLENT:return"EXCELLENT";case Ge.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.quality)),void 0!==e.score&&(t.score=e.score),t},fromPartial(e){var t,i,n;const r={participantSid:"",quality:0,score:0};return r.participantSid=null!==(t=e.participantSid)&&void 0!==t?t:"",r.quality=null!==(i=e.quality)&&void 0!==i?i:0,r.score=null!==(n=e.score)&&void 0!==n?n:0,r}};const Pn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();for(const i of e.updates)En.encode(i,t.uint32(10).fork()).ldelim();return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={updates:[]};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.updates.push(En.decode(i,i.uint32()));else i.skipType(7&e)}return r},fromJSON:e=>({updates:Array.isArray(null==e?void 0:e.updates)?e.updates.map((e=>En.fromJSON(e))):[]}),toJSON(e){const t={};return e.updates?t.updates=e.updates.map((e=>e?En.toJSON(e):void 0)):t.updates=[],t},fromPartial(e){var t;const i={updates:[]};return i.updates=(null===(t=e.updates)||void 0===t?void 0:t.map((e=>En.fromPartial(e))))||[],i}};const Rn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.participantSid&&t.uint32(10).string(e.participantSid),""!==e.trackSid&&t.uint32(18).string(e.trackSid),0!==e.state&&t.uint32(24).int32(e.state),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={participantSid:"",trackSid:"",state:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.participantSid=i.string();break;case 2:r.trackSid=i.string();break;case 3:r.state=i.int32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({participantSid:Wn(e.participantSid)?String(e.participantSid):"",trackSid:Wn(e.trackSid)?String(e.trackSid):"",state:Wn(e.state)?nn(e.state):0}),toJSON(e){const t={};return void 0!==e.participantSid&&(t.participantSid=e.participantSid),void 0!==e.trackSid&&(t.trackSid=e.trackSid),void 0!==e.state&&(t.state=function(e){switch(e){case Ki.ACTIVE:return"ACTIVE";case Ki.PAUSED:return"PAUSED";case Ki.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(e.state)),t},fromPartial(e){var t,i,n;const r={participantSid:"",trackSid:"",state:0};return r.participantSid=null!==(t=e.participantSid)&&void 0!==t?t:"",r.trackSid=null!==(i=e.trackSid)&&void 0!==i?i:"",r.state=null!==(n=e.state)&&void 0!==n?n:0,r}};const On={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();for(const i of e.streamStates)Rn.encode(i,t.uint32(10).fork()).ldelim();return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={streamStates:[]};for(;i.pos<n;){const e=i.uint32();if(e>>>3==1)r.streamStates.push(Rn.decode(i,i.uint32()));else i.skipType(7&e)}return r},fromJSON:e=>({streamStates:Array.isArray(null==e?void 0:e.streamStates)?e.streamStates.map((e=>Rn.fromJSON(e))):[]}),toJSON(e){const t={};return e.streamStates?t.streamStates=e.streamStates.map((e=>e?Rn.toJSON(e):void 0)):t.streamStates=[],t},fromPartial(e){var t;const i={streamStates:[]};return i.streamStates=(null===(t=e.streamStates)||void 0===t?void 0:t.map((e=>Rn.fromPartial(e))))||[],i}};const Nn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return 0!==e.quality&&t.uint32(8).int32(e.quality),!0===e.enabled&&t.uint32(16).bool(e.enabled),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={quality:0,enabled:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.quality=i.int32();break;case 2:r.enabled=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({quality:Wn(e.quality)?st(e.quality):0,enabled:!!Wn(e.enabled)&&Boolean(e.enabled)}),toJSON(e){const t={};return void 0!==e.quality&&(t.quality=at(e.quality)),void 0!==e.enabled&&(t.enabled=e.enabled),t},fromPartial(e){var t,i;const n={quality:0,enabled:!1};return n.quality=null!==(t=e.quality)&&void 0!==t?t:0,n.enabled=null!==(i=e.enabled)&&void 0!==i&&i,n}};const Dn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();""!==e.codec&&t.uint32(10).string(e.codec);for(const i of e.qualities)Nn.encode(i,t.uint32(18).fork()).ldelim();return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={codec:"",qualities:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.codec=i.string();break;case 2:r.qualities.push(Nn.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({codec:Wn(e.codec)?String(e.codec):"",qualities:Array.isArray(null==e?void 0:e.qualities)?e.qualities.map((e=>Nn.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.codec&&(t.codec=e.codec),e.qualities?t.qualities=e.qualities.map((e=>e?Nn.toJSON(e):void 0)):t.qualities=[],t},fromPartial(e){var t,i;const n={codec:"",qualities:[]};return n.codec=null!==(t=e.codec)&&void 0!==t?t:"",n.qualities=(null===(i=e.qualities)||void 0===i?void 0:i.map((e=>Nn.fromPartial(e))))||[],n}};const In={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();""!==e.trackSid&&t.uint32(10).string(e.trackSid);for(const i of e.subscribedQualities)Nn.encode(i,t.uint32(18).fork()).ldelim();for(const i of e.subscribedCodecs)Dn.encode(i,t.uint32(26).fork()).ldelim();return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={trackSid:"",subscribedQualities:[],subscribedCodecs:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.trackSid=i.string();break;case 2:r.subscribedQualities.push(Nn.decode(i,i.uint32()));break;case 3:r.subscribedCodecs.push(Dn.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({trackSid:Wn(e.trackSid)?String(e.trackSid):"",subscribedQualities:Array.isArray(null==e?void 0:e.subscribedQualities)?e.subscribedQualities.map((e=>Nn.fromJSON(e))):[],subscribedCodecs:Array.isArray(null==e?void 0:e.subscribedCodecs)?e.subscribedCodecs.map((e=>Dn.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.trackSid&&(t.trackSid=e.trackSid),e.subscribedQualities?t.subscribedQualities=e.subscribedQualities.map((e=>e?Nn.toJSON(e):void 0)):t.subscribedQualities=[],e.subscribedCodecs?t.subscribedCodecs=e.subscribedCodecs.map((e=>e?Dn.toJSON(e):void 0)):t.subscribedCodecs=[],t},fromPartial(e){var t,i,n;const r={trackSid:"",subscribedQualities:[],subscribedCodecs:[]};return r.trackSid=null!==(t=e.trackSid)&&void 0!==t?t:"",r.subscribedQualities=(null===(i=e.subscribedQualities)||void 0===i?void 0:i.map((e=>Nn.fromPartial(e))))||[],r.subscribedCodecs=(null===(n=e.subscribedCodecs)||void 0===n?void 0:n.map((e=>Dn.fromPartial(e))))||[],r}};const An={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();""!==e.participantSid&&t.uint32(10).string(e.participantSid),!0===e.allTracks&&t.uint32(16).bool(e.allTracks);for(const i of e.trackSids)t.uint32(26).string(i);return""!==e.participantIdentity&&t.uint32(34).string(e.participantIdentity),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={participantSid:"",allTracks:!1,trackSids:[],participantIdentity:""};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.participantSid=i.string();break;case 2:r.allTracks=i.bool();break;case 3:r.trackSids.push(i.string());break;case 4:r.participantIdentity=i.string();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({participantSid:Wn(e.participantSid)?String(e.participantSid):"",allTracks:!!Wn(e.allTracks)&&Boolean(e.allTracks),trackSids:Array.isArray(null==e?void 0:e.trackSids)?e.trackSids.map((e=>String(e))):[],participantIdentity:Wn(e.participantIdentity)?String(e.participantIdentity):""}),toJSON(e){const t={};return void 0!==e.participantSid&&(t.participantSid=e.participantSid),void 0!==e.allTracks&&(t.allTracks=e.allTracks),e.trackSids?t.trackSids=e.trackSids.map((e=>e)):t.trackSids=[],void 0!==e.participantIdentity&&(t.participantIdentity=e.participantIdentity),t},fromPartial(e){var t,i,n,r;const s={participantSid:"",allTracks:!1,trackSids:[],participantIdentity:""};return s.participantSid=null!==(t=e.participantSid)&&void 0!==t?t:"",s.allTracks=null!==(i=e.allTracks)&&void 0!==i&&i,s.trackSids=(null===(n=e.trackSids)||void 0===n?void 0:n.map((e=>e)))||[],s.participantIdentity=null!==(r=e.participantIdentity)&&void 0!==r?r:"",s}};const Un={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();!0===e.allParticipants&&t.uint32(8).bool(e.allParticipants);for(const i of e.trackPermissions)An.encode(i,t.uint32(18).fork()).ldelim();return t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={allParticipants:!1,trackPermissions:[]};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.allParticipants=i.bool();break;case 2:r.trackPermissions.push(An.decode(i,i.uint32()));break;default:i.skipType(7&e)}}return r},fromJSON:e=>({allParticipants:!!Wn(e.allParticipants)&&Boolean(e.allParticipants),trackPermissions:Array.isArray(null==e?void 0:e.trackPermissions)?e.trackPermissions.map((e=>An.fromJSON(e))):[]}),toJSON(e){const t={};return void 0!==e.allParticipants&&(t.allParticipants=e.allParticipants),e.trackPermissions?t.trackPermissions=e.trackPermissions.map((e=>e?An.toJSON(e):void 0)):t.trackPermissions=[],t},fromPartial(e){var t,i;const n={allParticipants:!1,trackPermissions:[]};return n.allParticipants=null!==(t=e.allParticipants)&&void 0!==t&&t,n.trackPermissions=(null===(i=e.trackPermissions)||void 0===i?void 0:i.map((e=>An.fromPartial(e))))||[],n}};const Mn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.participantSid&&t.uint32(10).string(e.participantSid),""!==e.trackSid&&t.uint32(18).string(e.trackSid),!0===e.allowed&&t.uint32(24).bool(e.allowed),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={participantSid:"",trackSid:"",allowed:!1};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.participantSid=i.string();break;case 2:r.trackSid=i.string();break;case 3:r.allowed=i.bool();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({participantSid:Wn(e.participantSid)?String(e.participantSid):"",trackSid:Wn(e.trackSid)?String(e.trackSid):"",allowed:!!Wn(e.allowed)&&Boolean(e.allowed)}),toJSON(e){const t={};return void 0!==e.participantSid&&(t.participantSid=e.participantSid),void 0!==e.trackSid&&(t.trackSid=e.trackSid),void 0!==e.allowed&&(t.allowed=e.allowed),t},fromPartial(e){var t,i,n;const r={participantSid:"",trackSid:"",allowed:!1};return r.participantSid=null!==(t=e.participantSid)&&void 0!==t?t:"",r.trackSid=null!==(i=e.trackSid)&&void 0!==i?i:"",r.allowed=null!==(n=e.allowed)&&void 0!==n&&n,r}};const Ln={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();void 0!==e.answer&&vn.encode(e.answer,t.uint32(10).fork()).ldelim(),void 0!==e.subscription&&gn.encode(e.subscription,t.uint32(18).fork()).ldelim();for(const i of e.publishTracks)pn.encode(i,t.uint32(26).fork()).ldelim();for(const i of e.dataChannels)xn.encode(i,t.uint32(34).fork()).ldelim();return void 0!==e.offer&&vn.encode(e.offer,t.uint32(42).fork()).ldelim(),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={answer:void 0,subscription:void 0,publishTracks:[],dataChannels:[],offer:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.answer=vn.decode(i,i.uint32());break;case 2:r.subscription=gn.decode(i,i.uint32());break;case 3:r.publishTracks.push(pn.decode(i,i.uint32()));break;case 4:r.dataChannels.push(xn.decode(i,i.uint32()));break;case 5:r.offer=vn.decode(i,i.uint32());break;default:i.skipType(7&e)}}return r},fromJSON:e=>({answer:Wn(e.answer)?vn.fromJSON(e.answer):void 0,subscription:Wn(e.subscription)?gn.fromJSON(e.subscription):void 0,publishTracks:Array.isArray(null==e?void 0:e.publishTracks)?e.publishTracks.map((e=>pn.fromJSON(e))):[],dataChannels:Array.isArray(null==e?void 0:e.dataChannels)?e.dataChannels.map((e=>xn.fromJSON(e))):[],offer:Wn(e.offer)?vn.fromJSON(e.offer):void 0}),toJSON(e){const t={};return void 0!==e.answer&&(t.answer=e.answer?vn.toJSON(e.answer):void 0),void 0!==e.subscription&&(t.subscription=e.subscription?gn.toJSON(e.subscription):void 0),e.publishTracks?t.publishTracks=e.publishTracks.map((e=>e?pn.toJSON(e):void 0)):t.publishTracks=[],e.dataChannels?t.dataChannels=e.dataChannels.map((e=>e?xn.toJSON(e):void 0)):t.dataChannels=[],void 0!==e.offer&&(t.offer=e.offer?vn.toJSON(e.offer):void 0),t},fromPartial(e){var t,i;const n={answer:void 0,subscription:void 0,publishTracks:[],dataChannels:[],offer:void 0};return n.answer=void 0!==e.answer&&null!==e.answer?vn.fromPartial(e.answer):void 0,n.subscription=void 0!==e.subscription&&null!==e.subscription?gn.fromPartial(e.subscription):void 0,n.publishTracks=(null===(t=e.publishTracks)||void 0===t?void 0:t.map((e=>pn.fromPartial(e))))||[],n.dataChannels=(null===(i=e.dataChannels)||void 0===i?void 0:i.map((e=>xn.fromPartial(e))))||[],n.offer=void 0!==e.offer&&null!==e.offer?vn.fromPartial(e.offer):void 0,n}};const xn={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();return""!==e.label&&t.uint32(10).string(e.label),0!==e.id&&t.uint32(16).uint32(e.id),0!==e.target&&t.uint32(24).int32(e.target),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={label:"",id:0,target:0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.label=i.string();break;case 2:r.id=i.uint32();break;case 3:r.target=i.int32();break;default:i.skipType(7&e)}}return r},fromJSON:e=>({label:Wn(e.label)?String(e.label):"",id:Wn(e.id)?Number(e.id):0,target:Wn(e.target)?en(e.target):0}),toJSON(e){const t={};return void 0!==e.label&&(t.label=e.label),void 0!==e.id&&(t.id=Math.round(e.id)),void 0!==e.target&&(t.target=tn(e.target)),t},fromPartial(e){var t,i,n;const r={label:"",id:0,target:0};return r.label=null!==(t=e.label)&&void 0!==t?t:"",r.id=null!==(i=e.id)&&void 0!==i?i:0,r.target=null!==(n=e.target)&&void 0!==n?n:0,r}};const _n={encode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:et.Writer.create();var i,n,r,s,a;return"speakerUpdate"===(null===(i=e.scenario)||void 0===i?void 0:i.$case)&&t.uint32(8).int32(e.scenario.speakerUpdate),"nodeFailure"===(null===(n=e.scenario)||void 0===n?void 0:n.$case)&&t.uint32(16).bool(e.scenario.nodeFailure),"migration"===(null===(r=e.scenario)||void 0===r?void 0:r.$case)&&t.uint32(24).bool(e.scenario.migration),"serverLeave"===(null===(s=e.scenario)||void 0===s?void 0:s.$case)&&t.uint32(32).bool(e.scenario.serverLeave),"switchCandidateProtocol"===(null===(a=e.scenario)||void 0===a?void 0:a.$case)&&t.uint32(40).int32(e.scenario.switchCandidateProtocol),t},decode(e,t){const i=e instanceof et.Reader?e:new et.Reader(e);let n=void 0===t?i.len:i.pos+t;const r={scenario:void 0};for(;i.pos<n;){const e=i.uint32();switch(e>>>3){case 1:r.scenario={$case:"speakerUpdate",speakerUpdate:i.int32()};break;case 2:r.scenario={$case:"nodeFailure",nodeFailure:i.bool()};break;case 3:r.scenario={$case:"migration",migration:i.bool()};break;case 4:r.scenario={$case:"serverLeave",serverLeave:i.bool()};break;case 5:r.scenario={$case:"switchCandidateProtocol",switchCandidateProtocol:i.int32()};break;default:i.skipType(7&e)}}return r},fromJSON:e=>({scenario:Wn(e.speakerUpdate)?{$case:"speakerUpdate",speakerUpdate:Number(e.speakerUpdate)}:Wn(e.nodeFailure)?{$case:"nodeFailure",nodeFailure:Boolean(e.nodeFailure)}:Wn(e.migration)?{$case:"migration",migration:Boolean(e.migration)}:Wn(e.serverLeave)?{$case:"serverLeave",serverLeave:Boolean(e.serverLeave)}:Wn(e.switchCandidateProtocol)?{$case:"switchCandidateProtocol",switchCandidateProtocol:rn(e.switchCandidateProtocol)}:void 0}),toJSON(e){var t,i,n,r,s,a,o,c,d,u,l;const h={};return"speakerUpdate"===(null===(t=e.scenario)||void 0===t?void 0:t.$case)&&(h.speakerUpdate=Math.round(null===(i=e.scenario)||void 0===i?void 0:i.speakerUpdate)),"nodeFailure"===(null===(n=e.scenario)||void 0===n?void 0:n.$case)&&(h.nodeFailure=null===(r=e.scenario)||void 0===r?void 0:r.nodeFailure),"migration"===(null===(s=e.scenario)||void 0===s?void 0:s.$case)&&(h.migration=null===(a=e.scenario)||void 0===a?void 0:a.migration),"serverLeave"===(null===(o=e.scenario)||void 0===o?void 0:o.$case)&&(h.serverLeave=null===(c=e.scenario)||void 0===c?void 0:c.serverLeave),"switchCandidateProtocol"===(null===(d=e.scenario)||void 0===d?void 0:d.$case)&&(h.switchCandidateProtocol=void 0!==(null===(u=e.scenario)||void 0===u?void 0:u.switchCandidateProtocol)?function(e){switch(e){case Yi.UDP:return"UDP";case Yi.TCP:return"TCP";case Yi.TLS:return"TLS";case Yi.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(null===(l=e.scenario)||void 0===l?void 0:l.switchCandidateProtocol):void 0),h},fromPartial(e){var t,i,n,r,s,a,o,c,d,u,l,h,p,m,v;const f={scenario:void 0};return"speakerUpdate"===(null===(t=e.scenario)||void 0===t?void 0:t.$case)&&void 0!==(null===(i=e.scenario)||void 0===i?void 0:i.speakerUpdate)&&null!==(null===(n=e.scenario)||void 0===n?void 0:n.speakerUpdate)&&(f.scenario={$case:"speakerUpdate",speakerUpdate:e.scenario.speakerUpdate}),"nodeFailure"===(null===(r=e.scenario)||void 0===r?void 0:r.$case)&&void 0!==(null===(s=e.scenario)||void 0===s?void 0:s.nodeFailure)&&null!==(null===(a=e.scenario)||void 0===a?void 0:a.nodeFailure)&&(f.scenario={$case:"nodeFailure",nodeFailure:e.scenario.nodeFailure}),"migration"===(null===(o=e.scenario)||void 0===o?void 0:o.$case)&&void 0!==(null===(c=e.scenario)||void 0===c?void 0:c.migration)&&null!==(null===(d=e.scenario)||void 0===d?void 0:d.migration)&&(f.scenario={$case:"migration",migration:e.scenario.migration}),"serverLeave"===(null===(u=e.scenario)||void 0===u?void 0:u.$case)&&void 0!==(null===(l=e.scenario)||void 0===l?void 0:l.serverLeave)&&null!==(null===(h=e.scenario)||void 0===h?void 0:h.serverLeave)&&(f.scenario={$case:"serverLeave",serverLeave:e.scenario.serverLeave}),"switchCandidateProtocol"===(null===(p=e.scenario)||void 0===p?void 0:p.$case)&&void 0!==(null===(m=e.scenario)||void 0===m?void 0:m.switchCandidateProtocol)&&null!==(null===(v=e.scenario)||void 0===v?void 0:v.switchCandidateProtocol)&&(f.scenario={$case:"switchCandidateProtocol",switchCandidateProtocol:e.scenario.switchCandidateProtocol}),f}};var Jn,$n,Bn,jn,Vn,Fn=(()=>{if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw"Unable to locate global object"})();function qn(e){if(e.gt(Number.MAX_SAFE_INTEGER))throw new Fn.Error("Value is larger than Number.MAX_SAFE_INTEGER");return e.toNumber()}function Wn(e){return null!=e}et.util.Long!==o&&(et.util.Long=o,et.configure());class Gn extends Error{constructor(e,t){super(t||"an error has occured"),this.code=e}}class Qn extends Gn{constructor(e,t,i){super(1,e),this.status=i,this.reason=t}}class zn extends Gn{constructor(e){super(21,null!=e?e:"device is unsupported")}}class Hn extends Gn{constructor(e){super(20,null!=e?e:"track is invalid")}}class Zn extends Gn{constructor(e){super(10,null!=e?e:"unsupported server")}}class Kn extends Gn{constructor(e){super(12,null!=e?e:"unexpected connection state")}}class Yn extends Gn{constructor(e){super(13,null!=e?e:"unable to negotiate")}}e.MediaDeviceFailure=void 0,(Jn=e.MediaDeviceFailure||(e.MediaDeviceFailure={})).PermissionDenied="PermissionDenied",Jn.NotFound="NotFound",Jn.DeviceInUse="DeviceInUse",Jn.Other="Other",function(e){e.getFailure=function(t){if(t&&"name"in t)return"NotFoundError"===t.name||"DevicesNotFoundError"===t.name?e.NotFound:"NotAllowedError"===t.name||"PermissionDeniedError"===t.name?e.PermissionDenied:"NotReadableError"===t.name||"TrackStartError"===t.name?e.DeviceInUse:e.Other}}(e.MediaDeviceFailure||(e.MediaDeviceFailure={})),e.RoomEvent=void 0,($n=e.RoomEvent||(e.RoomEvent={})).Connected="connected",$n.Reconnecting="reconnecting",$n.Reconnected="reconnected",$n.Disconnected="disconnected",$n.ConnectionStateChanged="connectionStateChanged",$n.StateChanged="connectionStateChanged",$n.MediaDevicesChanged="mediaDevicesChanged",$n.ParticipantConnected="participantConnected",$n.ParticipantDisconnected="participantDisconnected",$n.TrackPublished="trackPublished",$n.TrackSubscribed="trackSubscribed",$n.TrackSubscriptionFailed="trackSubscriptionFailed",$n.TrackUnpublished="trackUnpublished",$n.TrackUnsubscribed="trackUnsubscribed",$n.TrackMuted="trackMuted",$n.TrackUnmuted="trackUnmuted",$n.LocalTrackPublished="localTrackPublished",$n.LocalTrackUnpublished="localTrackUnpublished",$n.ActiveSpeakersChanged="activeSpeakersChanged",$n.ParticipantMetadataChanged="participantMetadataChanged",$n.RoomMetadataChanged="roomMetadataChanged",$n.DataReceived="dataReceived",$n.ConnectionQualityChanged="connectionQualityChanged",$n.TrackStreamStateChanged="trackStreamStateChanged",$n.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",$n.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",$n.AudioPlaybackStatusChanged="audioPlaybackChanged",$n.MediaDevicesError="mediaDevicesError",$n.ParticipantPermissionsChanged="participantPermissionsChanged",$n.SignalConnected="signalConnected",$n.RecordingStatusChanged="recordingStatusChanged",e.ParticipantEvent=void 0,(Bn=e.ParticipantEvent||(e.ParticipantEvent={})).TrackPublished="trackPublished",Bn.TrackSubscribed="trackSubscribed",Bn.TrackSubscriptionFailed="trackSubscriptionFailed",Bn.TrackUnpublished="trackUnpublished",Bn.TrackUnsubscribed="trackUnsubscribed",Bn.TrackMuted="trackMuted",Bn.TrackUnmuted="trackUnmuted",Bn.LocalTrackPublished="localTrackPublished",Bn.LocalTrackUnpublished="localTrackUnpublished",Bn.ParticipantMetadataChanged="participantMetadataChanged",Bn.DataReceived="dataReceived",Bn.IsSpeakingChanged="isSpeakingChanged",Bn.ConnectionQualityChanged="connectionQualityChanged",Bn.TrackStreamStateChanged="trackStreamStateChanged",Bn.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",Bn.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",Bn.MediaDevicesError="mediaDevicesError",Bn.ParticipantPermissionsChanged="participantPermissionsChanged",e.EngineEvent=void 0,(jn=e.EngineEvent||(e.EngineEvent={})).TransportsCreated="transportsCreated",jn.Connected="connected",jn.Disconnected="disconnected",jn.Resuming="resuming",jn.Resumed="resumed",jn.Restarting="restarting",jn.Restarted="restarted",jn.SignalResumed="signalResumed",jn.Closing="closing",jn.MediaTrackAdded="mediaTrackAdded",jn.ActiveSpeakersUpdate="activeSpeakersUpdate",jn.DataPacketReceived="dataPacketReceived",e.TrackEvent=void 0,(Vn=e.TrackEvent||(e.TrackEvent={})).Message="message",Vn.Muted="muted",Vn.Unmuted="unmuted",Vn.Restarted="restarted",Vn.Ended="ended",Vn.Subscribed="subscribed",Vn.Unsubscribed="unsubscribed",Vn.UpdateSettings="updateSettings",Vn.UpdateSubscription="updateSubscription",Vn.AudioPlaybackStarted="audioPlaybackStarted",Vn.AudioPlaybackFailed="audioPlaybackFailed",Vn.AudioSilenceDetected="audioSilenceDetected",Vn.VisibilityChanged="visibilityChanged",Vn.VideoDimensionsChanged="videoDimensionsChanged",Vn.ElementAttached="elementAttached",Vn.ElementDetached="elementDetached",Vn.UpstreamPaused="upstreamPaused",Vn.UpstreamResumed="upstreamResumed",Vn.SubscriptionPermissionChanged="subscriptionPermissionChanged",Vn.SubscriptionStatusChanged="subscriptionStatusChanged";const Xn=2e3;function er(e,t){if(!t)return 0;let i,n;return"bytesReceived"in e?(i=e.bytesReceived,n=t.bytesReceived):"bytesSent"in e&&(i=e.bytesSent,n=t.bytesSent),void 0===i||void 0===n||void 0===e.timestamp||void 0===t.timestamp?0:8*(i-n)*1e3/(e.timestamp-t.timestamp)}var tr={};!function(e,t){!function(i,n){var r="function",s="undefined",a="object",o="string",c="model",d="name",u="type",l="vendor",h="version",p="architecture",m="console",v="mobile",f="tablet",g="smarttv",b="wearable",k="embedded",y="Amazon",S="Apple",w="ASUS",C="BlackBerry",T="Firefox",E="Google",P="Huawei",R="LG",O="Microsoft",N="Motorola",D="Opera",I="Samsung",A="Sharp",U="Sony",M="Xiaomi",L="Zebra",x="Facebook",_=function(e){for(var t={},i=0;i<e.length;i++)t[e[i].toUpperCase()]=e[i];return t},J=function(e,t){return typeof e===o&&-1!==$(t).indexOf($(e))},$=function(e){return e.toLowerCase()},B=function(e,t){if(typeof e===o)return e=e.replace(/^\s\s*/,""),typeof t===s?e:e.substring(0,350)},j=function(e,t){for(var i,s,o,c,d,u,l=0;l<t.length&&!d;){var h=t[l],p=t[l+1];for(i=s=0;i<h.length&&!d;)if(d=h[i++].exec(e))for(o=0;o<p.length;o++)u=d[++s],typeof(c=p[o])===a&&c.length>0?2===c.length?typeof c[1]==r?this[c[0]]=c[1].call(this,u):this[c[0]]=c[1]:3===c.length?typeof c[1]!==r||c[1].exec&&c[1].test?this[c[0]]=u?u.replace(c[1],c[2]):n:this[c[0]]=u?c[1].call(this,u,c[2]):n:4===c.length&&(this[c[0]]=u?c[3].call(this,u.replace(c[1],c[2])):n):this[c]=u||n;l+=2}},V=function(e,t){for(var i in t)if(typeof t[i]===a&&t[i].length>0){for(var r=0;r<t[i].length;r++)if(J(t[i][r],e))return"?"===i?n:i}else if(J(t[i],e))return"?"===i?n:i;return e},F={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},q={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[h,[d,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[h,[d,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[d,h],[/opios[\/ ]+([\w\.]+)/i],[h,[d,"Opera Mini"]],[/\bopr\/([\w\.]+)/i],[h,[d,D]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(weibo)__([\d\.]+)/i],[d,h],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[h,[d,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[h,[d,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[h,[d,"WeChat"]],[/konqueror\/([\w\.]+)/i],[h,[d,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[h,[d,"IE"]],[/yabrowser\/([\w\.]+)/i],[h,[d,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[d,/(.+)/,"$1 Secure Browser"],h],[/\bfocus\/([\w\.]+)/i],[h,[d,"Firefox Focus"]],[/\bopt\/([\w\.]+)/i],[h,[d,"Opera Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[h,[d,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[h,[d,"Dolphin"]],[/coast\/([\w\.]+)/i],[h,[d,"Opera Coast"]],[/miuibrowser\/([\w\.]+)/i],[h,[d,"MIUI Browser"]],[/fxios\/([-\w\.]+)/i],[h,[d,T]],[/\bqihu|(qi?ho?o?|360)browser/i],[[d,"360 Browser"]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[d,/(.+)/,"$1 Browser"],h],[/(comodo_dragon)\/([\w\.]+)/i],[[d,/_/g," "],h],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[d,h],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[d],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[d,x],h],[/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[d,h],[/\bgsa\/([\w\.]+) .*safari\//i],[h,[d,"GSA"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[h,[d,"Chrome Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[d,"Chrome WebView"],h],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[h,[d,"Android Browser"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[d,h],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[h,[d,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[h,d],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[d,[h,V,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[d,h],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[d,"Netscape"],h],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[h,[d,"Firefox Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[d,h],[/(cobalt)\/([\w\.]+)/i],[d,[h,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[p,"amd64"]],[/(ia32(?=;))/i],[[p,$]],[/((?:i[346]|x)86)[;\)]/i],[[p,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[p,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[p,"armhf"]],[/windows (ce|mobile); ppc;/i],[[p,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[p,/ower/,"",$]],[/(sun4\w)[;\)]/i],[[p,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[p,$]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[c,[l,I],[u,f]],[/\b((?:s[cgp]h|gt|sm)-\w+|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[c,[l,I],[u,v]],[/\((ip(?:hone|od)[\w ]*);/i],[c,[l,S],[u,v]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[c,[l,S],[u,f]],[/(macintosh);/i],[c,[l,S]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[c,[l,P],[u,f]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[c,[l,P],[u,v]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[c,/_/g," "],[l,M],[u,v]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[c,/_/g," "],[l,M],[u,f]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[c,[l,"OPPO"],[u,v]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[c,[l,"Vivo"],[u,v]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[c,[l,"Realme"],[u,v]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[c,[l,N],[u,v]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[c,[l,N],[u,f]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[c,[l,R],[u,f]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[c,[l,R],[u,v]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[c,[l,"Lenovo"],[u,f]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[c,/_/g," "],[l,"Nokia"],[u,v]],[/(pixel c)\b/i],[c,[l,E],[u,f]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[c,[l,E],[u,v]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[c,[l,U],[u,v]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[c,"Xperia Tablet"],[l,U],[u,f]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[c,[l,"OnePlus"],[u,v]],[/(alexa)webm/i,/(kf[a-z]{2}wi)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[c,[l,y],[u,f]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[c,/(.+)/g,"Fire Phone $1"],[l,y],[u,v]],[/(playbook);[-\w\),; ]+(rim)/i],[c,l,[u,f]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[c,[l,C],[u,v]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[c,[l,w],[u,f]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[c,[l,w],[u,v]],[/(nexus 9)/i],[c,[l,"HTC"],[u,f]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic|sony(?!-bra))[-_ ]?([-\w]*)/i],[l,[c,/_/g," "],[u,v]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[c,[l,"Acer"],[u,f]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[c,[l,"Meizu"],[u,v]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[c,[l,A],[u,v]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[l,c,[u,v]],[/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[l,c,[u,f]],[/(surface duo)/i],[c,[l,O],[u,f]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[c,[l,"Fairphone"],[u,v]],[/(u304aa)/i],[c,[l,"AT&T"],[u,v]],[/\bsie-(\w*)/i],[c,[l,"Siemens"],[u,v]],[/\b(rct\w+) b/i],[c,[l,"RCA"],[u,f]],[/\b(venue[\d ]{2,7}) b/i],[c,[l,"Dell"],[u,f]],[/\b(q(?:mv|ta)\w+) b/i],[c,[l,"Verizon"],[u,f]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[c,[l,"Barnes & Noble"],[u,f]],[/\b(tm\d{3}\w+) b/i],[c,[l,"NuVision"],[u,f]],[/\b(k88) b/i],[c,[l,"ZTE"],[u,f]],[/\b(nx\d{3}j) b/i],[c,[l,"ZTE"],[u,v]],[/\b(gen\d{3}) b.+49h/i],[c,[l,"Swiss"],[u,v]],[/\b(zur\d{3}) b/i],[c,[l,"Swiss"],[u,f]],[/\b((zeki)?tb.*\b) b/i],[c,[l,"Zeki"],[u,f]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[l,"Dragon Touch"],c,[u,f]],[/\b(ns-?\w{0,9}) b/i],[c,[l,"Insignia"],[u,f]],[/\b((nxa|next)-?\w{0,9}) b/i],[c,[l,"NextBook"],[u,f]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[l,"Voice"],c,[u,v]],[/\b(lvtel\-)?(v1[12]) b/i],[[l,"LvTel"],c,[u,v]],[/\b(ph-1) /i],[c,[l,"Essential"],[u,v]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[c,[l,"Envizen"],[u,f]],[/\b(trio[-\w\. ]+) b/i],[c,[l,"MachSpeed"],[u,f]],[/\btu_(1491) b/i],[c,[l,"Rotor"],[u,f]],[/(shield[\w ]+) b/i],[c,[l,"Nvidia"],[u,f]],[/(sprint) (\w+)/i],[l,c,[u,v]],[/(kin\.[onetw]{3})/i],[[c,/\./g," "],[l,O],[u,v]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[c,[l,L],[u,f]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[c,[l,L],[u,v]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[l,c,[u,m]],[/droid.+; (shield) bui/i],[c,[l,"Nvidia"],[u,m]],[/(playstation [345portablevi]+)/i],[c,[l,U],[u,m]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[c,[l,O],[u,m]],[/smart-tv.+(samsung)/i],[l,[u,g]],[/hbbtv.+maple;(\d+)/i],[[c,/^/,"SmartTV"],[l,I],[u,g]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[l,R],[u,g]],[/(apple) ?tv/i],[l,[c,"Apple TV"],[u,g]],[/crkey/i],[[c,"Chromecast"],[l,E],[u,g]],[/droid.+aft(\w)( bui|\))/i],[c,[l,y],[u,g]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[c,[l,A],[u,g]],[/(bravia[\w ]+)( bui|\))/i],[c,[l,U],[u,g]],[/(mitv-\w{5}) bui/i],[c,[l,M],[u,g]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w ]*; *(\w[^;]*);([^;]*)/i],[[l,B],[c,B],[u,g]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[u,g]],[/((pebble))app/i],[l,c,[u,b]],[/droid.+; (glass) \d/i],[c,[l,E],[u,b]],[/droid.+; (wt63?0{2,3})\)/i],[c,[l,L],[u,b]],[/(quest( 2)?)/i],[c,[l,x],[u,b]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[l,[u,k]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[c,[u,v]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[c,[u,f]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[u,f]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[u,v]],[/(android[-\w\. ]{0,9});.+buil/i],[c,[l,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[h,[d,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[h,[d,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i],[d,h],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[h,d]],os:[[/microsoft (windows) (vista|xp)/i],[d,h],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[d,[h,V,F]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[d,"Windows"],[h,V,F]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/cfnetwork\/.+darwin/i],[[h,/_/g,"."],[d,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[d,"Mac OS"],[h,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[h,d],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[d,h],[/\(bb(10);/i],[h,[d,C]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[h,[d,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[h,[d,"Firefox OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[h,[d,"webOS"]],[/crkey\/([\d\.]+)/i],[h,[d,"Chromecast"]],[/(cros) [\w]+ ([\w\.]+\w)/i],[[d,"Chromium OS"],h],[/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[d,h],[/(sunos) ?([\w\.\d]*)/i],[[d,"Solaris"],h],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux)/i,/(unix) ?([\w\.]*)/i],[d,h]]},W=function(e,t){if(typeof e===a&&(t=e,e=n),!(this instanceof W))return new W(e,t).getResult();var r=e||(typeof i!==s&&i.navigator&&i.navigator.userAgent?i.navigator.userAgent:""),c=t?function(e,t){var i={};for(var n in e)t[n]&&t[n].length%2==0?i[n]=t[n].concat(e[n]):i[n]=e[n];return i}(q,t):q;return this.getBrowser=function(){var e={};return e.name=n,e.version=n,j.call(e,r,c.browser),e.major=function(e){return typeof e===o?e.replace(/[^\d\.]/g,"").split(".")[0]:n}(e.version),e},this.getCPU=function(){var e={};return e.architecture=n,j.call(e,r,c.cpu),e},this.getDevice=function(){var e={};return e.vendor=n,e.model=n,e.type=n,j.call(e,r,c.device),e},this.getEngine=function(){var e={};return e.name=n,e.version=n,j.call(e,r,c.engine),e},this.getOS=function(){var e={};return e.name=n,e.version=n,j.call(e,r,c.os),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return r},this.setUA=function(e){return r=typeof e===o&&e.length>350?B(e,350):e,this},this.setUA(r),this};W.VERSION="1.0.33",W.BROWSER=_([d,h,"major"]),W.CPU=_([p]),W.DEVICE=_([c,l,u,m,v,g,f,b,k]),W.ENGINE=W.OS=_([d,h]),e.exports&&(t=e.exports=W),t.UAParser=W;var G=typeof i!==s&&(i.jQuery||i.Zepto);if(G&&!G.ua){var Q=new W;G.ua=Q.getResult(),G.ua.get=function(){return Q.getUA()},G.ua.set=function(e){Q.setUA(e);var t=Q.getResult();for(var i in t)G.ua[i]=t[i]}}}("object"==typeof window?window:i)}({get exports(){return tr},set exports(e){tr=e}},tr);var ir=tr;const nr="1.6.4";function rr(e,t,i){const n=Wt({},e);return!0===n.audio&&(n.audio={}),!0===n.video&&(n.video={}),n.audio&&sr(n.audio,t),n.video&&sr(n.video,i),n}function sr(e,t){return Object.keys(t).forEach((i=>{void 0===e[i]&&(e[i]=t[i])})),e}function ar(e){const t={};if(e.video)if("object"==typeof e.video){const i={},n=i,r=e.video;Object.keys(r).forEach((e=>{if("resolution"===e)sr(n,r.resolution);else n[e]=r[e]})),t.video=i}else t.video=e.video;else t.video=!1;return e.audio?"object"==typeof e.audio?t.audio=e.audio:t.audio=!0:t.audio=!1,t}function or(){const e=window.AudioContext||window.webkitAudioContext;if(e)return new e({latencyHint:"interactive"})}async function cr(e){return new Promise((t=>setTimeout(t,e)))}function dr(){return"addTransceiver"in RTCPeerConnection.prototype}function ur(){return"addTrack"in RTCPeerConnection.prototype}function lr(){const e=RTCRtpReceiver.getCapabilities("video");let t=!1,i=!1;if(e){for(const i of e.codecs)if("video/AV1"===i.mimeType){t=!0;break}for(const t of e.headerExtensions)if("https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension"===t.uri){i=!0;break}}return t&&i}function hr(e){return!!document&&(e||(e=document.createElement("audio")),"setSinkId"in e)}const pr={Chrome:"100",Chromium:"100",Safari:"15",Firefox:"100",Edge:"100",Brave:"1.40"};function mr(e){if(!br())return!1;if(!("setCodecPreferences"in e))return!1;const t=ir();if(!t.browser.name||!t.browser.version)return!1;const i=pr[t.browser.name];return!!i&&function(e,t){const i=e.split("."),n=t.split("."),r=Math.min(e.length,t.length);for(let e=0;e<r;++e){const t=parseInt(i[e],10),r=parseInt(n[e],10);if(t>r)return 1;if(t<r)return-1}return i.length==n.length?0:i.length<n.length?-1:1}(t.browser.version,i)>=0}function vr(){return!!br()&&-1!==navigator.userAgent.indexOf("Firefox")}function fr(){return!!br()&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function gr(){return!!br()&&/Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent)}function br(){return"undefined"!=typeof document}function kr(e){for(const t of e)t.target.handleResize(t)}function yr(e){for(const t of e)t.target.handleVisibilityChanged(t)}let Sr=null;const wr=()=>(Sr||(Sr=new ResizeObserver(kr)),Sr);let Cr=null;const Tr=()=>(Cr||(Cr=new IntersectionObserver(yr,{root:document,rootMargin:"0px"})),Cr);let Er,Pr;function Rr(){return Er||(Er=Or()),Er}function Or(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r=document.createElement("canvas");r.width=e,r.height=t;const s=r.getContext("2d");null==s||s.fillRect(0,0,r.width,r.height),n&&s&&(s.beginPath(),s.arc(e/2,t/2,50,0,2*Math.PI,!0),s.closePath(),s.fillStyle="grey",s.fill());const a=r.captureStream(),[o]=a.getTracks();if(!o)throw Error("Could not get empty media stream video track");return o.enabled=i,o}function Nr(){if(!Pr){const e=new AudioContext,t=e.createOscillator(),i=e.createMediaStreamDestination();if(t.connect(i),t.start(),[Pr]=i.stream.getAudioTracks(),!Pr)throw Error("Could not get empty media stream audio track");Pr.enabled=!1}return Pr}class Dr{constructor(e,t){this.onFinally=t,this.promise=new Promise((async(t,i)=>{this.resolve=t,this.reject=i,e&&await e(t,i)})).finally((()=>{var e;return null===(e=this.onFinally)||void 0===e?void 0:e.call(this)}))}}class Ir{constructor(){this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){let e;this._locks+=1;const t=new Promise((t=>e=()=>{this._locks-=1,t()})),i=this._locking.then((()=>e));return this._locking=this._locking.then((()=>t)),i}}class Ar{constructor(e,t){this.maxConcurrent=e||1,this.minCycle=t||0,this.queueRunning=[],this.queueWaiting={},this.lastRun=0}dequeue(e){const t=this.queueRunning,i=t.findIndex((t=>t.hash===e));if(-1==i)throw"queue desync";const n=t[i];return t.splice(i,1),n}getFirstWaiting(){for(let e of Object.keys(this.queueWaiting).sort(((e,t)=>e-t)))if(void 0!==this.queueWaiting[e]&&this.queueWaiting[e].length>0)return this.queueWaiting[e]}end(e){this.dequeue(e).resolve();const t=this.getFirstWaiting();if(void 0!==t){t.shift().resolve()}}async wait(e,t){const i=void 0===t?0:t;let n={hash:e,priority:i};for(null==this.queueWaiting[i]&&(this.queueWaiting[i]=[]),this.queueRunning.length>=this.maxConcurrent&&(n.promise=new Promise((e=>{n.resolve=e})),this.queueWaiting[i].push(n),await n.promise),this.queueRunning.push(n),n.promise=new Promise((e=>{n.resolve=e}));Date.now()-this.lastRun<this.minCycle;)await new Promise((e=>setTimeout(e,this.minCycle-Date.now()+this.lastRun)));this.lastRun=Date.now()}run(e,t){const i=void 0===t?0:t,n=Symbol();return this.wait(n,i).then((()=>e())).finally((()=>{this.end(n)}))}stat(){return{running:this.queueRunning.length,waiting:Object.keys(this.queueWaiting).reduce(((e,t)=>e+this.queueWaiting[t].length),0),last:this.lastRun}}async flush(){for(;this.stat().waiting>0;)for(let e of Object.keys(this.queueWaiting).sort(((e,t)=>t-e))){const t=this.queueWaiting[e];void 0!==t&&t.length>0&&await t[t.length-1].promise}for(;this.queueRunning.length>0;)await Promise.allSettled(this.queueRunning.map((e=>e.promise)))}}const Ur="default";class Mr{static getInstance(){return void 0===this.instance&&(this.instance=new Mr),this.instance}async getDevices(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];var i;if((null===(i=Mr.userMediaPromiseMap)||void 0===i?void 0:i.size)>0){a.debug("awaiting getUserMedia promise");try{e?await Mr.userMediaPromiseMap.get(e):await Promise.all(Mr.userMediaPromiseMap.values())}catch(e){a.warn("error waiting for media permissons")}}let n=await navigator.mediaDevices.enumerateDevices();if(t&&e&&(!Mr.userMediaPromiseMap.get(e)||!fr())){if(0===n.length||n.some((t=>{const i=""===t.label,n=!e||t.kind===e;return i&&n}))){const t={video:"audioinput"!==e&&"audiooutput"!==e,audio:"videoinput"!==e},i=await navigator.mediaDevices.getUserMedia(t);n=await navigator.mediaDevices.enumerateDevices(),i.getTracks().forEach((e=>{e.stop()}))}}return e&&(n=n.filter((t=>t.kind===e))),n}async normalizeDeviceId(e,t,i){if(t!==Ur)return t;const n=(await this.getDevices(e)).find((e=>e.groupId===i&&e.deviceId!==Ur));return null==n?void 0:n.deviceId}}Mr.mediaDeviceKinds=["audioinput","audiooutput","videoinput"],Mr.userMediaPromiseMap=new Map;var Lr,xr={},_r={get exports(){return xr},set exports(e){xr=e}},Jr="object"==typeof Reflect?Reflect:null,$r=Jr&&"function"==typeof Jr.apply?Jr.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};Lr=Jr&&"function"==typeof Jr.ownKeys?Jr.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var Br=Number.isNaN||function(e){return e!=e};function jr(){jr.init.call(this)}_r.exports=jr,xr.once=function(e,t){return new Promise((function(i,n){function r(i){e.removeListener(t,s),n(i)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",r),i([].slice.call(arguments))}Kr(e,t,s,{once:!0}),"error"!==t&&function(e,t,i){"function"==typeof e.on&&Kr(e,"error",t,i)}(e,r,{once:!0})}))},jr.EventEmitter=jr,jr.prototype._events=void 0,jr.prototype._eventsCount=0,jr.prototype._maxListeners=void 0;var Vr=10;function Fr(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function qr(e){return void 0===e._maxListeners?jr.defaultMaxListeners:e._maxListeners}function Wr(e,t,i,n){var r,s,a,o;if(Fr(i),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),s=e._events),a=s[t]),void 0===a)a=s[t]=i,++e._eventsCount;else if("function"==typeof a?a=s[t]=n?[i,a]:[a,i]:n?a.unshift(i):a.push(i),(r=qr(e))>0&&a.length>r&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,o=c,console&&console.warn&&console.warn(o)}return e}function Gr(){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 Qr(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=Gr.bind(n);return r.listener=i,n.wrapFn=r,r}function zr(e,t,i){var n=e._events;if(void 0===n)return[];var r=n[t];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(e){for(var t=new Array(e.length),i=0;i<t.length;++i)t[i]=e[i].listener||e[i];return t}(r):Zr(r,r.length)}function Hr(e){var t=this._events;if(void 0!==t){var i=t[e];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function Zr(e,t){for(var i=new Array(t),n=0;n<t;++n)i[n]=e[n];return i}function Kr(e,t,i,n){if("function"==typeof e.on)n.once?e.once(t,i):e.on(t,i);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 r(s){n.once&&e.removeEventListener(t,r),i(s)}))}}Object.defineProperty(jr,"defaultMaxListeners",{enumerable:!0,get:function(){return Vr},set:function(e){if("number"!=typeof e||e<0||Br(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Vr=e}}),jr.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},jr.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||Br(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},jr.prototype.getMaxListeners=function(){return qr(this)},jr.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var n="error"===e,r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var o=r[e];if(void 0===o)return!1;if("function"==typeof o)$r(o,this,t);else{var c=o.length,d=Zr(o,c);for(i=0;i<c;++i)$r(d[i],this,t)}return!0},jr.prototype.addListener=function(e,t){return Wr(this,e,t,!1)},jr.prototype.on=jr.prototype.addListener,jr.prototype.prependListener=function(e,t){return Wr(this,e,t,!0)},jr.prototype.once=function(e,t){return Fr(t),this.on(e,Qr(this,e,t)),this},jr.prototype.prependOnceListener=function(e,t){return Fr(t),this.prependListener(e,Qr(this,e,t)),this},jr.prototype.removeListener=function(e,t){var i,n,r,s,a;if(Fr(t),void 0===(n=this._events))return this;if(void 0===(i=n[e]))return this;if(i===t||i.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if("function"!=typeof i){for(r=-1,s=i.length-1;s>=0;s--)if(i[s]===t||i[s].listener===t){a=i[s].listener,r=s;break}if(r<0)return this;0===r?i.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(i,r),1===i.length&&(n[e]=i[0]),void 0!==n.removeListener&&this.emit("removeListener",e,a||t)}return this},jr.prototype.off=jr.prototype.removeListener,jr.prototype.removeAllListeners=function(e){var t,i,n;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[e]),this;if(0===arguments.length){var r,s=Object.keys(i);for(n=0;n<s.length;++n)"removeListener"!==(r=s[n])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=i[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},jr.prototype.listeners=function(e){return zr(this,e,!0)},jr.prototype.rawListeners=function(e){return zr(this,e,!1)},jr.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Hr.call(e,t)},jr.prototype.listenerCount=Hr,jr.prototype.eventNames=function(){return this._eventsCount>0?Lr(this._events):[]};const Yr=[];class Xr extends xr.EventEmitter{constructor(e,t){super(),this.attachedElements=[],this.isMuted=!1,this.streamState=Xr.StreamState.Active,this._currentBitrate=0,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),"hidden"===document.visibilityState?this.backgroundTimeout=setTimeout((()=>this.handleAppVisibilityChanged()),5e3):this.handleAppVisibilityChanged()},this.setMaxListeners(100),this.kind=t,this._mediaStreamTrack=e,this._mediaStreamID=e.id,this.source=Xr.Source.Unknown,br()?(this.isInBackground="hidden"===document.visibilityState,document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(t){let i="audio";this.kind===Xr.Kind.Video&&(i="video"),t||("audio"===i&&(Yr.forEach((e=>{null!==e.parentElement||t||(t=e)})),t&&Yr.splice(Yr.indexOf(t),1)),t||(t=document.createElement(i))),this.attachedElements.includes(t)||this.attachedElements.push(t),es(this._mediaStreamTrack,t);const n=t.srcObject.getTracks();return n.some((e=>"audio"===e.kind))&&t.play().then((()=>{this.emit(e.TrackEvent.AudioPlaybackStarted)})).catch((i=>{this.emit(e.TrackEvent.AudioPlaybackFailed,i),t&&n.some((e=>"video"===e.kind))&&"NotAllowedError"===i.name&&(t.muted=!0,t.play().catch((()=>{})))})),this.emit(e.TrackEvent.ElementAttached,t),t}detach(t){if(t){ts(this._mediaStreamTrack,t);const i=this.attachedElements.indexOf(t);return i>=0&&(this.attachedElements.splice(i,1),this.recycleElement(t),this.emit(e.TrackEvent.ElementDetached,t)),t}const i=[];return this.attachedElements.forEach((t=>{ts(this._mediaStreamTrack,t),i.push(t),this.recycleElement(t),this.emit(e.TrackEvent.ElementDetached,t)})),this.attachedElements=[],i}stop(){this.stopMonitor(),this._mediaStreamTrack.stop(),br()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}enable(){this._mediaStreamTrack.enabled=!0}disable(){this._mediaStreamTrack.enabled=!1}stopMonitor(){this.monitorInterval&&clearInterval(this.monitorInterval)}recycleElement(e){if(e instanceof HTMLAudioElement){let t=!0;e.pause(),Yr.forEach((e=>{e.parentElement||(t=!1)})),t&&Yr.push(e)}}async handleAppVisibilityChanged(){this.isInBackground="hidden"===document.visibilityState}}function es(e,t){let i,n;i=t.srcObject instanceof MediaStream?t.srcObject:new MediaStream,n="audio"===e.kind?i.getAudioTracks():i.getVideoTracks(),n.includes(e)||(n.forEach((e=>{i.removeTrack(e)})),i.addTrack(e)),t.autoplay=!0,t.muted=0===i.getAudioTracks().length,t instanceof HTMLVideoElement&&(t.playsInline=!0),t.srcObject!==i&&(t.srcObject=i,(fr()||vr())&&t instanceof HTMLVideoElement&&setTimeout((()=>{t.srcObject=i,t.play().catch((()=>{}))}),0))}function ts(e,t){if(t.srcObject instanceof MediaStream){const i=t.srcObject;i.removeTrack(e),i.getTracks().length>0?t.srcObject=i:t.srcObject=null}}!function(e){let t,i,n;!function(e){e.Audio="audio",e.Video="video",e.Unknown="unknown"}(t=e.Kind||(e.Kind={})),function(e){e.Camera="camera",e.Microphone="microphone",e.ScreenShare="screen_share",e.ScreenShareAudio="screen_share_audio",e.Unknown="unknown"}(i=e.Source||(e.Source={})),function(e){e.Active="active",e.Paused="paused",e.Unknown="unknown"}(n=e.StreamState||(e.StreamState={})),e.kindToProto=function(e){switch(e){case t.Audio:return Fe.AUDIO;case t.Video:return Fe.VIDEO;default:return Fe.UNRECOGNIZED}},e.kindFromProto=function(e){switch(e){case Fe.AUDIO:return t.Audio;case Fe.VIDEO:return t.Video;default:return t.Unknown}},e.sourceToProto=function(e){switch(e){case i.Camera:return qe.CAMERA;case i.Microphone:return qe.MICROPHONE;case i.ScreenShare:return qe.SCREEN_SHARE;case i.ScreenShareAudio:return qe.SCREEN_SHARE_AUDIO;default:return qe.UNRECOGNIZED}},e.sourceFromProto=function(e){switch(e){case qe.CAMERA:return i.Camera;case qe.MICROPHONE:return i.Microphone;case qe.SCREEN_SHARE:return i.ScreenShare;case qe.SCREEN_SHARE_AUDIO:return i.ScreenShareAudio;default:return i.Unknown}},e.streamStateFromProto=function(e){switch(e){case Ki.ACTIVE:return n.Active;case Ki.PAUSED:return n.Paused;default:return n.Unknown}}}(Xr||(Xr={}));class is extends Xr{constructor(t,i,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];super(t,i),this._isUpstreamPaused=!1,this.handleEnded=()=>{this.isInBackground&&(this.reacquireTrack=!0),this.emit(e.TrackEvent.Ended,this)},this._mediaStreamTrack.addEventListener("ended",this.handleEnded),this.constraints=null!=n?n:t.getConstraints(),this.reacquireTrack=!1,this.providedByUser=r,this.muteQueue=new Ar}get id(){return this._mediaStreamTrack.id}get dimensions(){if(this.kind!==Xr.Kind.Video)return;const{width:e,height:t}=this._mediaStreamTrack.getSettings();return e&&t?{width:e,height:t}:void 0}get isUpstreamPaused(){return this._isUpstreamPaused}get isUserProvided(){return this.providedByUser}async waitForDimensions(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;if(this.kind===Xr.Kind.Audio)throw new Error("cannot get dimensions for audio tracks");const t=Date.now();for(;Date.now()-t<e;){const e=this.dimensions;if(e)return e;await cr(50)}throw new Hn("unable to get track dimensions after timeout")}async getDeviceId(){if(this.source===Xr.Source.ScreenShare)return;const{deviceId:e,groupId:t}=this._mediaStreamTrack.getSettings(),i=this.kind===Xr.Kind.Audio?"audioinput":"videoinput";return Mr.getInstance().normalizeDeviceId(i,e,t)}async mute(){return this.setTrackMuted(!0),this}async unmute(){return this.setTrackMuted(!1),this}async replaceTrack(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this.sender)throw new Hn("unable to replace an unpublished track");return this.attachedElements.forEach((e=>{ts(this._mediaStreamTrack,e)})),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this.providedByUser||this._mediaStreamTrack.stop(),e.addEventListener("ended",this.handleEnded),a.debug("replace MediaStreamTrack"),this.sender&&await this.sender.replaceTrack(e),this._mediaStreamTrack=e,this._mediaStreamTrack.enabled=!this.isMuted,await this.resumeUpstream(),this.attachedElements.forEach((t=>{es(e,t)})),this.mediaStream=new MediaStream([e]),this.providedByUser=t,this}async restart(t){t||(t=this.constraints),a.debug("restarting track with constraints",t);const i={audio:!1,video:!1};this.kind===Xr.Kind.Video?i.video=t:i.audio=t,this.attachedElements.forEach((e=>{ts(this._mediaStreamTrack,e)})),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.stop();const n=await navigator.mediaDevices.getUserMedia(i),r=n.getTracks()[0];return r.addEventListener("ended",this.handleEnded),a.debug("re-acquired MediaStreamTrack"),this.sender&&await this.sender.replaceTrack(r),this._mediaStreamTrack=r,await this.resumeUpstream(),this.attachedElements.forEach((e=>{es(r,e)})),this.mediaStream=n,this.constraints=t,this.emit(e.TrackEvent.Restarted,this),this}setTrackMuted(t){a.debug("setting ".concat(this.kind," track ").concat(t?"muted":"unmuted")),this.isMuted===t&&this._mediaStreamTrack.enabled!==t||(this.isMuted=t,this._mediaStreamTrack.enabled=!t,this.emit(t?e.TrackEvent.Muted:e.TrackEvent.Unmuted,this))}get needsReAcquisition(){return"live"!==this._mediaStreamTrack.readyState||this._mediaStreamTrack.muted||!this._mediaStreamTrack.enabled||this.reacquireTrack}async handleAppVisibilityChanged(){await super.handleAppVisibilityChanged(),gr()&&(a.debug("visibility changed, is in Background: ".concat(this.isInBackground)),this.isInBackground||!this.needsReAcquisition||this.isUserProvided||this.isMuted||(a.debug("track needs to be reaquired, restarting ".concat(this.source)),await this.restart(),this.reacquireTrack=!1))}async pauseUpstream(){this.muteQueue.run((async()=>{if(!0===this._isUpstreamPaused)return;if(!this.sender)return void a.warn("unable to pause upstream for an unpublished track");this._isUpstreamPaused=!0,this.emit(e.TrackEvent.UpstreamPaused,this);const t=this.kind===Xr.Kind.Audio?Nr():Rr();await this.sender.replaceTrack(t)}))}async resumeUpstream(){this.muteQueue.run((async()=>{!1!==this._isUpstreamPaused&&(this.sender?(this._isUpstreamPaused=!1,this.emit(e.TrackEvent.UpstreamResumed,this),await this.sender.replaceTrack(this._mediaStreamTrack)):a.warn("unable to resume upstream for an unpublished track"))}))}}class ns extends is{constructor(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];super(e,Xr.Kind.Audio,t,i),this.stopOnMute=!1,this.monitorSender=async()=>{if(!this.sender)return void(this._currentBitrate=0);let e;try{e=await this.getSenderStats()}catch(e){return void a.error("could not get audio sender stats",{error:e})}e&&this.prevStats&&(this._currentBitrate=er(e,this.prevStats)),this.prevStats=e},this.checkForSilence()}async setDeviceId(e){this.constraints.deviceId!==e&&(this.constraints.deviceId=e,this.isMuted||await this.restartTrack())}async mute(){return await this.muteQueue.run((async()=>{this.source===Xr.Source.Microphone&&this.stopOnMute&&!this.isUserProvided&&(a.debug("stopping mic track"),this._mediaStreamTrack.stop()),await super.mute()})),this}async unmute(){return await this.muteQueue.run((async()=>{this.source===Xr.Source.Microphone&&this.stopOnMute&&!this.isUserProvided&&(a.debug("reacquiring mic track"),await this.restartTrack()),await super.unmute()})),this}async restartTrack(e){let t;if(e){const i=ar({audio:e});"boolean"!=typeof i.audio&&(t=i.audio)}await this.restart(t)}async restart(e){const t=await super.restart(e);return this.checkForSilence(),t}startMonitor(){br()&&(this.monitorInterval||(this.monitorInterval=setInterval((()=>{this.monitorSender()}),Xn)))}async getSenderStats(){var e;if(!(null===(e=this.sender)||void 0===e?void 0:e.getStats))return;let t;return(await this.sender.getStats()).forEach((e=>{"outbound-rtp"===e.type&&(t={type:"audio",streamId:e.id,packetsSent:e.packetsSent,packetsLost:e.packetsLost,bytesSent:e.bytesSent,timestamp:e.timestamp,roundTripTime:e.roundTripTime,jitter:e.jitter})})),t}async checkForSilence(){const t=await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200;const i=or();if(i){const n=i.createAnalyser();n.fftSize=2048;const r=n.frequencyBinCount,s=new Uint8Array(r);i.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(n),await cr(t),n.getByteTimeDomainData(s);const a=s.some((e=>128!==e&&0!==e));return i.close(),!a}return!1}(this);t&&(this.isMuted||a.warn("silence detected on local audio track"),this.emit(e.TrackEvent.AudioSilenceDetected))}}class rs extends is{constructor(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];super(e,Xr.Kind.Video,t,i),this.simulcastCodecs=new Map,this.monitorSender=async()=>{if(!this.sender)return void(this._currentBitrate=0);let e;try{e=await this.getSenderStats()}catch(e){return void a.error("could not get audio sender stats",{error:e})}const t=new Map(e.map((e=>[e.rid,e])));if(this.prevStats){let e=0;t.forEach(((t,i)=>{var n;const r=null===(n=this.prevStats)||void 0===n?void 0:n.get(i);e+=er(t,r)})),this._currentBitrate=e}this.prevStats=t}}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){var t;if(this.signalClient=e,!br())return;const i=null===(t=this.sender)||void 0===t?void 0:t.getParameters();i&&(this.encodings=i.encodings),this.monitorInterval||(this.monitorInterval=setInterval((()=>{this.monitorSender()}),Xn))}stop(){this._mediaStreamTrack.getConstraints(),this.simulcastCodecs.forEach((e=>{e.mediaStreamTrack.stop()})),super.stop()}async mute(){return await this.muteQueue.run((async()=>{this.source!==Xr.Source.Camera||this.isUserProvided||(a.debug("stopping camera track"),this._mediaStreamTrack.stop()),await super.mute()})),this}async unmute(){return await this.muteQueue.run((async()=>{this.source!==Xr.Source.Camera||this.isUserProvided||(a.debug("reacquiring camera track"),await this.restartTrack()),await super.unmute()})),this}async getSenderStats(){var e;if(!(null===(e=this.sender)||void 0===e?void 0:e.getStats))return[];const t=[],i=await this.sender.getStats();return i.forEach((e=>{var n;if("outbound-rtp"===e.type){const r={type:"video",streamId:e.id,frameHeight:e.frameHeight,frameWidth:e.frameWidth,firCount:e.firCount,pliCount:e.pliCount,nackCount:e.nackCount,packetsSent:e.packetsSent,bytesSent:e.bytesSent,framesSent:e.framesSent,timestamp:e.timestamp,rid:null!==(n=e.rid)&&void 0!==n?n:e.id,retransmittedPacketsSent:e.retransmittedPacketsSent,qualityLimitationReason:e.qualityLimitationReason,qualityLimitationResolutionChanges:e.qualityLimitationResolutionChanges},s=i.get(e.remoteId);s&&(r.jitter=s.jitter,r.packetsLost=s.packetsLost,r.roundTripTime=s.roundTripTime),t.push(r)}})),t}setPublishingQuality(t){const i=[];for(let n=e.VideoQuality.LOW;n<=e.VideoQuality.HIGH;n+=1)i.push({quality:n,enabled:n<=t});a.debug("setting publishing quality. max quality ".concat(t)),this.setPublishingLayers(i)}async setDeviceId(e){this.constraints.deviceId!==e&&(this.constraints.deviceId=e,this.isMuted||await this.restartTrack())}async restartTrack(e){let t;if(e){const i=ar({video:e});"boolean"!=typeof i.video&&(t=i.video)}await this.restart(t)}addSimulcastTrack(e,t){if(this.simulcastCodecs.has(e))throw new Error("".concat(e," already added"));const i={codec:e,mediaStreamTrack:this.mediaStreamTrack.clone(),sender:void 0,encodings:t};return this.simulcastCodecs.set(e,i),i}setSimulcastTrackSender(e,t){const i=this.simulcastCodecs.get(e);i&&(i.sender=t,setTimeout((()=>{this.subscribedCodecs&&this.setPublishingCodecs(this.subscribedCodecs)}),5e3))}async setPublishingCodecs(e){if(a.debug("setting publishing codecs",{codecs:e,currentCodec:this.codec}),!this.codec&&e.length>0)return await this.setPublishingLayers(e[0].qualities),[];this.subscribedCodecs=e;const t=[];var i,n=!1,r=!1;try{for(var s,o=Vt(e);n=!(s=await o.next()).done;n=!1){const e=s.value;if(this.codec&&this.codec!==e.codec){const i=this.simulcastCodecs.get(e.codec);if(a.debug("try setPublishingCodec for ".concat(e.codec),i),i&&i.sender)i.encodings&&(a.debug("try setPublishingLayersForSender ".concat(e.codec)),await ss(i.sender,i.encodings,e.qualities));else for(const i of e.qualities)if(i.enabled){t.push(e.codec);break}}else await this.setPublishingLayers(e.qualities)}}catch(e){r=!0,i=e}finally{try{n&&null!=o.return&&await o.return()}finally{if(r)throw i}}return t}async setPublishingLayers(e){a.debug("setting publishing layers",e),this.sender&&this.encodings&&await ss(this.sender,this.encodings,e)}async handleAppVisibilityChanged(){await super.handleAppVisibilityChanged(),gr()&&this.isInBackground&&this.source===Xr.Source.Camera&&(this._mediaStreamTrack.enabled=!1)}}async function ss(e,t,i){a.debug("setPublishingLayersForSender",{sender:e,qualities:i,senderEncodings:t});const n=e.getParameters(),{encodings:r}=n;if(!r)return;if(r.length!==t.length)return void a.warn("cannot set publishing layers, encodings mismatch");let s=!1;r.forEach(((e,n)=>{var r;let o=null!==(r=e.rid)&&void 0!==r?r:"";""===o&&(o="q");const c=as(o),d=i.find((e=>e.quality===c));d&&e.active!==d.enabled&&(s=!0,e.active=d.enabled,a.debug("setting layer ".concat(d.quality," to ").concat(e.active?"enabled":"disabled")),vr()&&(d.enabled?(e.scaleResolutionDownBy=t[n].scaleResolutionDownBy,e.maxBitrate=t[n].maxBitrate,e.maxFrameRate=t[n].maxFrameRate):(e.scaleResolutionDownBy=4,e.maxBitrate=10,e.maxFrameRate=2)))})),s&&(n.encodings=r,await e.setParameters(n))}function as(t){switch(t){case"f":return e.VideoQuality.HIGH;case"h":return e.VideoQuality.MEDIUM;case"q":return e.VideoQuality.LOW;default:return e.VideoQuality.UNRECOGNIZED}}function os(t,i,n){return n?n.map((r=>{var s,a,o;const c=null!==(s=r.scaleResolutionDownBy)&&void 0!==s?s:1;let d=as(null!==(a=r.rid)&&void 0!==a?a:"");return d===e.VideoQuality.UNRECOGNIZED&&1===n.length&&(d=e.VideoQuality.HIGH),{quality:d,width:t/c,height:i/c,bitrate:null!==(o=r.maxBitrate)&&void 0!==o?o:0,ssrc:0}})):[{quality:e.VideoQuality.HIGH,width:t,height:i,bitrate:0,ssrc:0}]}class cs extends Xr{constructor(e,t,i,n){super(e,i),this.sid=t,this.receiver=n}setMuted(t){this.isMuted!==t&&(this.isMuted=t,this._mediaStreamTrack.enabled=!t,this.emit(t?e.TrackEvent.Muted:e.TrackEvent.Unmuted,this))}setMediaStream(t){this.mediaStream=t,t.onremovetrack=()=>{this.receiver=void 0,this._currentBitrate=0,this.emit(e.TrackEvent.Ended,this)}}start(){this.startMonitor(),super.enable()}stop(){this.stopMonitor(),super.disable()}startMonitor(){this.monitorInterval||(this.monitorInterval=setInterval((()=>this.monitorReceiver()),Xn))}}class ds extends cs{constructor(e,t,i,n,r){super(e,t,Xr.Kind.Audio,i),this.monitorReceiver=async()=>{if(!this.receiver)return void(this._currentBitrate=0);const e=await this.getReceiverStats();e&&this.prevStats&&this.receiver&&(this._currentBitrate=er(e,this.prevStats)),this.prevStats=e},this.audioContext=n,this.webAudioPluginNodes=[],r&&(this.sinkId=r.deviceId)}setVolume(e){var t;for(const i of this.attachedElements)this.audioContext?null===(t=this.gainNode)||void 0===t||t.gain.setTargetAtTime(e,0,.1):i.volume=e;this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;let e=0;return this.attachedElements.forEach((t=>{t.volume>e&&(e=t.volume)})),e}async setSinkId(e){this.sinkId=e,await Promise.all(this.attachedElements.map((t=>{if(hr(t))return t.setSinkId(e)})))}attach(e){const t=0===this.attachedElements.length;return e?super.attach(e):e=super.attach(),this.elementVolume&&(e.volume=this.elementVolume),this.sinkId&&hr(e)&&e.setSinkId(this.sinkId),this.audioContext&&t&&(a.debug("using audio context mapping"),this.connectWebAudio(this.audioContext,e),e.volume=0,e.muted=!0),e}detach(e){let t;return e?(t=super.detach(e),this.audioContext&&(this.attachedElements.length>0?this.connectWebAudio(this.audioContext,this.attachedElements[0]):this.disconnectWebAudio())):(t=super.detach(),this.disconnectWebAudio()),t}setAudioContext(e){this.audioContext=e,e&&this.attachedElements.length>0?this.connectWebAudio(e,this.attachedElements[0]):e||this.disconnectWebAudio()}setWebAudioPlugins(e){this.webAudioPluginNodes=e,this.attachedElements.length>0&&this.audioContext&&this.connectWebAudio(this.audioContext,this.attachedElements[0])}connectWebAudio(t,i){this.disconnectWebAudio(),this.sourceNode=t.createMediaStreamSource(i.srcObject);let n=this.sourceNode;this.webAudioPluginNodes.forEach((e=>{n.connect(e),n=e})),this.gainNode=t.createGain(),n.connect(this.gainNode),this.gainNode.connect(t.destination),this.elementVolume&&this.gainNode.gain.setTargetAtTime(this.elementVolume,0,.1),"running"!==t.state&&t.resume().then((()=>{"running"!==t.state&&this.emit(e.TrackEvent.AudioPlaybackFailed,new Error("Audio Context couldn't be started automatically"))})).catch((t=>{this.emit(e.TrackEvent.AudioPlaybackFailed,t)}))}disconnectWebAudio(){var e,t;null===(e=this.gainNode)||void 0===e||e.disconnect(),null===(t=this.sourceNode)||void 0===t||t.disconnect(),this.gainNode=void 0,this.sourceNode=void 0}async getReceiverStats(){if(!this.receiver||!this.receiver.getStats)return;let e;return(await this.receiver.getStats()).forEach((t=>{"inbound-rtp"===t.type&&(e={type:"audio",timestamp:t.timestamp,jitter:t.jitter,bytesReceived:t.bytesReceived,concealedSamples:t.concealedSamples,concealmentEvents:t.concealmentEvents,silentConcealedSamples:t.silentConcealedSamples,silentConcealmentEvents:t.silentConcealmentEvents,totalAudioEnergy:t.totalAudioEnergy,totalSamplesDuration:t.totalSamplesDuration})})),e}}function us(e,t,i){var n,r,s;void 0===t&&(t=50),void 0===i&&(i={});var a=null!=(n=i.isImmediate)&&n,o=null!=(r=i.callback)&&r,c=i.maxWait,d=Date.now(),u=[];function l(){if(void 0!==c){var e=Date.now()-d;if(e+t>=c)return c-e}return t}var h=function(){var t=[].slice.call(arguments),i=this;return new Promise((function(n,r){var c=a&&void 0===s;if(void 0!==s&&clearTimeout(s),s=setTimeout((function(){if(s=void 0,d=Date.now(),!a){var n=e.apply(i,t);o&&o(n),u.forEach((function(e){return(0,e.resolve)(n)})),u=[]}}),l()),c){var h=e.apply(i,t);return o&&o(h),n(h)}u.push({resolve:n,reject:r})}))};return h.cancel=function(e){void 0!==s&&clearTimeout(s),u.forEach((function(t){return(0,t.reject)(e)})),u=[]},h}class ls{}ls.setTimeout=function(){return setTimeout(...arguments)},ls.setInterval=function(){return setInterval(...arguments)},ls.clearTimeout=function(){return clearTimeout(...arguments)},ls.clearInterval=function(){return clearInterval(...arguments)};class hs extends cs{constructor(e,t,i,n){super(e,t,Xr.Kind.Video,i),this.elementInfos=[],this.hasUsedAttach=!1,this.monitorReceiver=async()=>{if(!this.receiver)return void(this._currentBitrate=0);const e=await this.getReceiverStats();e&&this.prevStats&&this.receiver&&(this._currentBitrate=er(e,this.prevStats)),this.prevStats=e},this.debouncedHandleResize=us((()=>{this.updateDimensions()}),100),this.adaptiveStreamSettings=n,this.isAdaptiveStream&&(this.streamState=Xr.StreamState.Paused)}get isAdaptiveStream(){return void 0!==this.adaptiveStreamSettings}get mediaStreamTrack(){return this.isAdaptiveStream&&!this.hasUsedAttach&&a.warn("When using adaptiveStream, you need to use remoteVideoTrack.attach() to add the track to a HTMLVideoElement, otherwise your video tracks might never start"),this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach((t=>{e?ts(this._mediaStreamTrack,t):es(this._mediaStreamTrack,t)}))}attach(e){if(e?super.attach(e):e=super.attach(),this.adaptiveStreamSettings&&void 0===this.elementInfos.find((t=>t.element===e))){const t=new ps(e);this.observeElementInfo(t)}return this.hasUsedAttach=!0,e}observeElementInfo(e){this.adaptiveStreamSettings&&void 0===this.elementInfos.find((t=>t===e))?(e.handleResize=()=>{this.debouncedHandleResize()},e.handleVisibilityChanged=()=>{this.updateVisibility()},this.elementInfos.push(e),e.observe(),this.debouncedHandleResize(),this.updateVisibility()):a.warn("visibility resize observer not triggered")}stopObservingElementInfo(e){if(!this.isAdaptiveStream)return void a.warn("stopObservingElementInfo ignored");const t=this.elementInfos.filter((t=>t===e));for(const e of t)e.stopObserving();this.elementInfos=this.elementInfos.filter((t=>t!==e)),this.updateVisibility()}detach(e){let t=[];if(e)return this.stopObservingElement(e),super.detach(e);t=super.detach();for(const e of t)this.stopObservingElement(e);return t}getDecoderImplementation(){var e;return null===(e=this.prevStats)||void 0===e?void 0:e.decoderImplementation}async getReceiverStats(){if(!this.receiver||!this.receiver.getStats)return;let e;return(await this.receiver.getStats()).forEach((t=>{"inbound-rtp"===t.type&&(e={type:"video",framesDecoded:t.framesDecoded,framesDropped:t.framesDropped,framesReceived:t.framesReceived,packetsReceived:t.packetsReceived,packetsLost:t.packetsLost,frameWidth:t.frameWidth,frameHeight:t.frameHeight,pliCount:t.pliCount,firCount:t.firCount,nackCount:t.nackCount,jitter:t.jitter,timestamp:t.timestamp,bytesReceived:t.bytesReceived,decoderImplementation:t.decoderImplementation})})),e}stopObservingElement(e){const t=this.elementInfos.filter((t=>t.element===e));for(const e of t)e.stopObserving();this.elementInfos=this.elementInfos.filter((t=>t.element!==e))}async handleAppVisibilityChanged(){await super.handleAppVisibilityChanged(),this.isAdaptiveStream&&this.updateVisibility()}updateVisibility(){var t,i;const n=this.elementInfos.reduce(((e,t)=>Math.max(e,t.visibilityChangedAt||0)),0),r=!(null!==(i=null===(t=this.adaptiveStreamSettings)||void 0===t?void 0:t.pauseVideoInBackground)&&void 0!==i&&!i)&&this.isInBackground,s=this.elementInfos.some((e=>e.visible))&&!r;this.lastVisible!==s&&(!s&&Date.now()-n<100?ls.setTimeout((()=>{this.updateVisibility()}),100):(this.lastVisible=s,this.emit(e.TrackEvent.VisibilityChanged,s,this)))}updateDimensions(){var t,i,n,r;let s=0,a=0;for(const e of this.elementInfos){const n=null!==(i=null===(t=this.adaptiveStreamSettings)||void 0===t?void 0:t.pixelDensity)&&void 0!==i?i:1,r="screen"===n?window.devicePixelRatio:n,o=e.width()*r,c=e.height()*r;o+c>s+a&&(s=o,a=c)}(null===(n=this.lastDimensions)||void 0===n?void 0:n.width)===s&&(null===(r=this.lastDimensions)||void 0===r?void 0:r.height)===a||(this.lastDimensions={width:s,height:a},this.emit(e.TrackEvent.VideoDimensionsChanged,this.lastDimensions,this))}}class ps{constructor(e,t){this.onVisibilityChanged=e=>{var t;const{target:i,isIntersecting:n}=e;i===this.element&&(this.visible=n,this.visibilityChangedAt=Date.now(),null===(t=this.handleVisibilityChanged)||void 0===t||t.call(this))},this.element=e,this.visible=null!=t?t:function(e){let t=e.offsetTop,i=e.offsetLeft;const n=e.offsetWidth,r=e.offsetHeight,{hidden:s}=e,{opacity:a,display:o}=getComputedStyle(e);for(;e.offsetParent;)t+=(e=e.offsetParent).offsetTop,i+=e.offsetLeft;return t<window.pageYOffset+window.innerHeight&&i<window.pageXOffset+window.innerWidth&&t+r>window.pageYOffset&&i+n>window.pageXOffset&&!s&&(""===a||parseFloat(a)>0)&&"none"!==o}(e),this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){this.element.handleResize=()=>{var e;null===(e=this.handleResize)||void 0===e||e.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,Tr().observe(this.element),wr().observe(this.element)}stopObserving(){var e,t;null===(e=Tr())||void 0===e||e.unobserve(this.element),null===(t=wr())||void 0===t||t.unobserve(this.element)}}class ms extends xr.EventEmitter{constructor(t,i,n){super(),this.metadataMuted=!1,this.handleMuted=()=>{this.emit(e.TrackEvent.Muted)},this.handleUnmuted=()=>{this.emit(e.TrackEvent.Unmuted)},this.setMaxListeners(100),this.kind=t,this.trackSid=i,this.trackName=n,this.source=Xr.Source.Unknown}setTrack(t){this.track&&(this.track.off(e.TrackEvent.Muted,this.handleMuted),this.track.off(e.TrackEvent.Unmuted,this.handleUnmuted)),this.track=t,t&&(t.on(e.TrackEvent.Muted,this.handleMuted),t.on(e.TrackEvent.Unmuted,this.handleUnmuted))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return void 0!==this.track}get audioTrack(){if(this.track instanceof ns||this.track instanceof ds)return this.track}get videoTrack(){if(this.track instanceof rs||this.track instanceof hs)return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=Xr.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===Xr.Kind.Video&&e.width>0&&(this.dimensions={width:e.width,height:e.height},this.simulcasted=e.simulcast),this.trackInfo=e,a.trace("update publication info",{info:e})}}!function(e){var t,i;(t=e.SubscriptionStatus||(e.SubscriptionStatus={})).Desired="desired",t.Subscribed="subscribed",t.Unsubscribed="unsubscribed",(i=e.PermissionStatus||(e.PermissionStatus={})).Allowed="allowed",i.NotAllowed="not_allowed"}(ms||(ms={}));class vs extends ms{get isUpstreamPaused(){var e;return null===(e=this.track)||void 0===e?void 0:e.isUpstreamPaused}constructor(t,i,n){super(t,i.sid,i.name),this.track=void 0,this.handleTrackEnded=()=>{this.emit(e.TrackEvent.Ended)},this.updateInfo(i),this.setTrack(n)}setTrack(t){this.track&&this.track.off(e.TrackEvent.Ended,this.handleTrackEnded),super.setTrack(t),t&&t.on(e.TrackEvent.Ended,this.handleTrackEnded)}get isMuted(){return this.track?this.track.isMuted:super.isMuted}get audioTrack(){return super.audioTrack}get videoTrack(){return super.videoTrack}async mute(){var e;return null===(e=this.track)||void 0===e?void 0:e.mute()}async unmute(){var e;return null===(e=this.track)||void 0===e?void 0:e.unmute()}async pauseUpstream(){var e;await(null===(e=this.track)||void 0===e?void 0:e.pauseUpstream())}async resumeUpstream(){var e;await(null===(e=this.track)||void 0===e?void 0:e.resumeUpstream())}}class fs{constructor(e,t,i,n){this.width=e,this.height=t,this.encoding={maxBitrate:i,maxFramerate:n}}get resolution(){return{width:this.width,height:this.height,frameRate:this.encoding.maxFramerate,aspectRatio:this.width/this.height}}}const gs=["vp8","h264"];function bs(e){return!!gs.find((t=>t===e))}var ks;e.AudioPresets=void 0,(ks=e.AudioPresets||(e.AudioPresets={})).telephone={maxBitrate:12e3},ks.speech={maxBitrate:2e4},ks.music={maxBitrate:32e3},ks.musicStereo={maxBitrate:48e3},ks.musicHighQuality={maxBitrate:64e3},ks.musicHighQualityStereo={maxBitrate:96e3};const ys={h90:new fs(160,90,6e4,15),h180:new fs(320,180,12e4,15),h216:new fs(384,216,18e4,15),h360:new fs(640,360,3e5,20),h540:new fs(960,540,6e5,25),h720:new fs(1280,720,17e5,30),h1080:new fs(1920,1080,3e6,30),h1440:new fs(2560,1440,5e6,30),h2160:new fs(3840,2160,8e6,30)},Ss={h120:new fs(160,120,8e4,15),h180:new fs(240,180,1e5,15),h240:new fs(320,240,15e4,15),h360:new fs(480,360,225e3,20),h480:new fs(640,480,3e5,20),h540:new fs(720,540,45e4,25),h720:new fs(960,720,15e5,30),h1080:new fs(1440,1080,25e5,30),h1440:new fs(1920,1440,35e5,30)},ws={h360fps3:new fs(640,360,2e5,3),h720fps5:new fs(1280,720,4e5,5),h720fps15:new fs(1280,720,1e6,15),h1080fps15:new fs(1920,1080,15e5,15),h1080fps30:new fs(1920,1080,3e6,30)};e.ConnectionQuality=void 0,function(e){e.Excellent="excellent",e.Good="good",e.Poor="poor",e.Unknown="unknown"}(e.ConnectionQuality||(e.ConnectionQuality={}));class Cs extends xr.EventEmitter{constructor(t,i,n,r){super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=e.ConnectionQuality.Unknown,this.setMaxListeners(100),this.sid=t,this.identity=i,this.name=n,this.metadata=r,this.audioTracks=new Map,this.videoTracks=new Map,this.tracks=new Map}getTracks(){return Array.from(this.tracks.values())}getTrack(e){if(e!==Xr.Source.Unknown)for(const[,t]of this.tracks)if(t.source===e)return t}getTrackByName(e){for(const[,t]of this.tracks)if(t.trackName===e)return t}get connectionQuality(){return this._connectionQuality}get isCameraEnabled(){var e;const t=this.getTrack(Xr.Source.Camera);return!(null===(e=null==t?void 0:t.isMuted)||void 0===e||e)}get isMicrophoneEnabled(){var e;const t=this.getTrack(Xr.Source.Microphone);return!(null===(e=null==t?void 0:t.isMuted)||void 0===e||e)}get isScreenShareEnabled(){return!!this.getTrack(Xr.Source.ScreenShare)}get isLocal(){return!1}get joinedAt(){return this.participantInfo?new Date(1e3*this.participantInfo.joinedAt):new Date}updateInfo(e){this.identity=e.identity,this.sid=e.sid,this.name=e.name,this.setMetadata(e.metadata),e.permission&&this.setPermissions(e.permission),this.participantInfo=e,a.trace("update participant info",{info:e})}setMetadata(t){const i=this.metadata!==t,n=this.metadata;this.metadata=t,i&&this.emit(e.ParticipantEvent.ParticipantMetadataChanged,n)}setPermissions(t){var i,n,r,s,a;const o=this.permissions,c=t.canPublish!==(null===(i=this.permissions)||void 0===i?void 0:i.canPublish)||t.canSubscribe!==(null===(n=this.permissions)||void 0===n?void 0:n.canSubscribe)||t.canPublishData!==(null===(r=this.permissions)||void 0===r?void 0:r.canPublishData)||t.hidden!==(null===(s=this.permissions)||void 0===s?void 0:s.hidden)||t.recorder!==(null===(a=this.permissions)||void 0===a?void 0:a.recorder)||t.canPublishSources.length!==this.permissions.canPublishSources.length||t.canPublishSources.some(((e,t)=>{var i;return e!==(null===(i=this.permissions)||void 0===i?void 0:i.canPublishSources[t])}));return this.permissions=t,c&&this.emit(e.ParticipantEvent.ParticipantPermissionsChanged,o),c}setIsSpeaking(t){t!==this.isSpeaking&&(this.isSpeaking=t,t&&(this.lastSpokeAt=new Date),this.emit(e.ParticipantEvent.IsSpeakingChanged,t))}setConnectionQuality(t){const i=this._connectionQuality;this._connectionQuality=function(t){switch(t){case Ge.EXCELLENT:return e.ConnectionQuality.Excellent;case Ge.GOOD:return e.ConnectionQuality.Good;case Ge.POOR:return e.ConnectionQuality.Poor;default:return e.ConnectionQuality.Unknown}}(t),i!==this._connectionQuality&&this.emit(e.ParticipantEvent.ConnectionQualityChanged,this._connectionQuality)}addTrackPublication(t){t.on(e.TrackEvent.Muted,(()=>{this.emit(e.ParticipantEvent.TrackMuted,t)})),t.on(e.TrackEvent.Unmuted,(()=>{this.emit(e.ParticipantEvent.TrackUnmuted,t)}));const i=t;switch(i.track&&(i.track.sid=t.trackSid),this.tracks.set(t.trackSid,t),t.kind){case Xr.Kind.Audio:this.audioTracks.set(t.trackSid,t);break;case Xr.Kind.Video:this.videoTracks.set(t.trackSid,t)}}}function Ts(e,t){switch(e.kind){case"audio":return new ns(e,t,!1);case"video":return new rs(e,t,!1);default:throw new Hn("unsupported track type: ".concat(e.kind))}}const Es=Object.values(ys),Ps=Object.values(Ss),Rs=Object.values(ws),Os=[ys.h180,ys.h360],Ns=[Ss.h180,Ss.h360],Ds=["q","h","f"];function Is(e,t,i,n){var r,s;let o=null==n?void 0:n.videoEncoding;e&&(o=null==n?void 0:n.screenShareEncoding);const c=null==n?void 0:n.simulcast,d=null==n?void 0:n.scalabilityMode,u=null==n?void 0:n.videoCodec;if(!o&&!c&&!d||!t||!i)return[{}];o||(o=function(e,t,i,n){const r=function(e,t,i){if(e)return Rs;const n=t>i?t/i:i/t;if(Math.abs(n-16/9)<Math.abs(n-4/3))return Es;return Ps}(e,t,i);let{encoding:s}=r[0];const a=Math.max(t,i);for(let e=0;e<r.length;e+=1){const t=r[e];if(s=t.encoding,t.width>=a)break}if(n&&"av1"===n)s.maxBitrate=.7*s.maxBitrate;return s}(e,t,i,u),a.debug("using video encoding",o));const l=new fs(t,i,o.maxBitrate,o.maxFramerate);if(d&&"av1"===u){a.debug("using svc with scalabilityMode ".concat(d));const e=[];if("L3T3"===d){for(let t=0;t<3;t+=1)e.push({rid:Ds[2-t],scaleResolutionDownBy:2**t,maxBitrate:o.maxBitrate/3**t,maxFramerate:l.encoding.maxFramerate,scalabilityMode:"L3T3"});return a.debug("encodings",e),e}throw new Error("unsupported scalabilityMode: ".concat(d))}if(!c)return[o];let h,p=[];if(p=e?null!==(r=Ls(null==n?void 0:n.screenShareSimulcastLayers))&&void 0!==r?r:Us(e,l):null!==(s=Ls(null==n?void 0:n.videoSimulcastLayers))&&void 0!==s?s:Us(e,l),p.length>0){const e=p[0];p.length>1&&([,h]=p);const n=Math.max(t,i);if(n>=960&&h)return Ms(t,i,[e,h,l]);if(n>=480)return Ms(t,i,[e,l])}return Ms(t,i,[l])}function As(e,t,i){var n,r,s,o;if(!i.backupCodec||i.backupCodec.codec===i.videoCodec)return;t!==i.backupCodec.codec&&a.warn("requested a different codec than specified as backup",{serverRequested:t,backup:i.backupCodec.codec}),i.videoCodec=t,i.videoEncoding=i.backupCodec.encoding;const c=e.mediaStreamTrack.getSettings(),d=null!==(n=c.width)&&void 0!==n?n:null===(r=e.dimensions)||void 0===r?void 0:r.width,u=null!==(s=c.height)&&void 0!==s?s:null===(o=e.dimensions)||void 0===o?void 0:o.height;return Is(e.source===Xr.Source.ScreenShare,d,u,i)}function Us(e,t){if(e)return i=t,[{scaleResolutionDownBy:2,fps:3}].map((e=>{var t;return new fs(Math.floor(i.width/e.scaleResolutionDownBy),Math.floor(i.height/e.scaleResolutionDownBy),Math.max(15e4,Math.floor(i.encoding.maxBitrate/(e.scaleResolutionDownBy**2*((null!==(t=i.encoding.maxFramerate)&&void 0!==t?t:30)/e.fps)))),e.fps)}));var i;const{width:n,height:r}=t,s=n>r?n/r:r/n;return Math.abs(s-16/9)<Math.abs(s-4/3)?Os:Ns}function Ms(e,t,i){const n=[];return i.forEach(((i,r)=>{if(r>=Ds.length)return;const s=Math.min(e,t),a=Ds[r];n.push({rid:a,scaleResolutionDownBy:Math.max(1,s/Math.min(i.width,i.height)),maxBitrate:i.encoding.maxBitrate,maxFramerate:i.encoding.maxFramerate})})),n}function Ls(e){if(e)return e.sort(((e,t)=>{const{encoding:i}=e,{encoding:n}=t;return i.maxBitrate>n.maxBitrate?1:i.maxBitrate<n.maxBitrate?-1:i.maxBitrate===n.maxBitrate&&i.maxFramerate&&n.maxFramerate?i.maxFramerate>n.maxFramerate?1:-1:0}))}class xs extends ms{constructor(t,i,n,r){super(t,i,n),this.track=void 0,this.allowed=!0,this.disabled=!1,this.currentVideoQuality=e.VideoQuality.HIGH,this.handleEnded=t=>{this.setTrack(void 0),this.emit(e.TrackEvent.Ended,t)},this.handleVisibilityChange=e=>{a.debug("adaptivestream video visibility ".concat(this.trackSid,", visible=").concat(e),{trackSid:this.trackSid}),this.disabled=!e,this.emitTrackUpdate()},this.handleVideoDimensionsChange=e=>{a.debug("adaptivestream video dimensions ".concat(e.width,"x").concat(e.height),{trackSid:this.trackSid}),this.videoDimensions=e,this.emitTrackUpdate()},this.subscribed=r}setSubscribed(t){const i=this.subscriptionStatus,n=this.permissionStatus;this.subscribed=t,t&&(this.allowed=!0);const r={trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[{participantSid:"",trackSids:[this.trackSid]}]};this.emit(e.TrackEvent.UpdateSubscription,r),this.emitSubscriptionUpdateIfChanged(i),this.emitPermissionUpdateIfChanged(n)}get subscriptionStatus(){return!1===this.subscribed?ms.SubscriptionStatus.Unsubscribed:super.isSubscribed?ms.SubscriptionStatus.Subscribed:ms.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?ms.PermissionStatus.Allowed:ms.PermissionStatus.NotAllowed}get isSubscribed(){return!1!==this.subscribed&&super.isSubscribed}get isDesired(){return!1!==this.subscribed}get isEnabled(){return!this.disabled}setEnabled(e){this.isManualOperationAllowed()&&this.disabled!==!e&&(this.disabled=!e,this.emitTrackUpdate())}setVideoQuality(e){this.isManualOperationAllowed()&&this.currentVideoQuality!==e&&(this.currentVideoQuality=e,this.videoDimensions=void 0,this.emitTrackUpdate())}setVideoDimensions(e){var t,i;this.isManualOperationAllowed()&&((null===(t=this.videoDimensions)||void 0===t?void 0:t.width)===e.width&&(null===(i=this.videoDimensions)||void 0===i?void 0:i.height)===e.height||(this.track instanceof hs&&(this.videoDimensions=e),this.currentVideoQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&this.track instanceof hs&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){return this.currentVideoQuality}setTrack(t){const i=this.subscriptionStatus,n=this.permissionStatus,r=this.track;r!==t&&(r&&(r.off(e.TrackEvent.VideoDimensionsChanged,this.handleVideoDimensionsChange),r.off(e.TrackEvent.VisibilityChanged,this.handleVisibilityChange),r.off(e.TrackEvent.Ended,this.handleEnded),r.detach(),this.emit(e.TrackEvent.Unsubscribed,r)),super.setTrack(t),t&&(t.sid=this.trackSid,t.on(e.TrackEvent.VideoDimensionsChanged,this.handleVideoDimensionsChange),t.on(e.TrackEvent.VisibilityChanged,this.handleVisibilityChange),t.on(e.TrackEvent.Ended,this.handleEnded),this.emit(e.TrackEvent.Subscribed,t)),this.emitPermissionUpdateIfChanged(n),this.emitSubscriptionUpdateIfChanged(i))}setAllowed(e){const t=this.subscriptionStatus,i=this.permissionStatus;this.allowed=e,this.emitPermissionUpdateIfChanged(i),this.emitSubscriptionUpdateIfChanged(t)}updateInfo(e){var t;super.updateInfo(e),this.metadataMuted=e.muted,null===(t=this.track)||void 0===t||t.setMuted(e.muted)}emitSubscriptionUpdateIfChanged(t){const i=this.subscriptionStatus;t!==i&&this.emit(e.TrackEvent.SubscriptionStatusChanged,i,t)}emitPermissionUpdateIfChanged(t){this.permissionStatus!==t&&this.emit(e.TrackEvent.SubscriptionPermissionChanged,this.permissionStatus,t)}isManualOperationAllowed(){return this.isAdaptiveStream?(a.warn("adaptive stream is enabled, cannot change track settings",{trackSid:this.trackSid}),!1):!!this.isDesired||(a.warn("cannot update track settings when not subscribed",{trackSid:this.trackSid}),!1)}get isAdaptiveStream(){return this.track instanceof hs&&this.track.isAdaptiveStream}emitTrackUpdate(){const t=bn.fromPartial({trackSids:[this.trackSid],disabled:this.disabled,fps:this.fps});this.videoDimensions?(t.width=this.videoDimensions.width,t.height=this.videoDimensions.height):void 0!==this.currentVideoQuality?t.quality=this.currentVideoQuality:t.quality=e.VideoQuality.HIGH,this.emit(e.TrackEvent.UpdateSettings,t)}}class _s extends Cs{static fromParticipantInfo(e,t){return new _s(e,t.sid,t.identity,t.name,t.metadata)}constructor(e,t,i,n,r){super(t,i||"",n,r),this.signalClient=e,this.tracks=new Map,this.audioTracks=new Map,this.videoTracks=new Map}addTrackPublication(t){super.addTrackPublication(t),t.on(e.TrackEvent.UpdateSettings,(e=>{a.debug("send update settings",e),this.signalClient.sendUpdateTrackSettings(e)})),t.on(e.TrackEvent.UpdateSubscription,(e=>{e.participantTracks.forEach((e=>{e.participantSid=this.sid})),this.signalClient.sendUpdateSubscription(e)})),t.on(e.TrackEvent.SubscriptionPermissionChanged,(i=>{this.emit(e.ParticipantEvent.TrackSubscriptionPermissionChanged,t,i)})),t.on(e.TrackEvent.SubscriptionStatusChanged,(i=>{this.emit(e.ParticipantEvent.TrackSubscriptionStatusChanged,t,i)})),t.on(e.TrackEvent.Subscribed,(i=>{this.emit(e.ParticipantEvent.TrackSubscribed,i,t)})),t.on(e.TrackEvent.Unsubscribed,(i=>{this.emit(e.ParticipantEvent.TrackUnsubscribed,i,t)}))}getTrack(e){const t=super.getTrack(e);if(t)return t}getTrackByName(e){const t=super.getTrackByName(e);if(t)return t}setVolume(e){this.volume=e;const t=this.getTrack(Xr.Source.Microphone);t&&t.track&&t.track.setVolume(e)}getVolume(){const e=this.getTrack(Xr.Source.Microphone);return e&&e.track?e.track.getVolume():this.volume}addSubscribedMediaTrack(t,i,n,r,s,o){let c=this.getTrackPublication(i);if(c||i.startsWith("TR")||this.tracks.forEach((e=>{c||t.kind!==e.kind.toString()||(c=e)})),!c)return 0===o?(a.error("could not find published track",{participant:this.sid,trackSid:i}),void this.emit(e.ParticipantEvent.TrackSubscriptionFailed,i)):(void 0===o&&(o=20),void setTimeout((()=>{this.addSubscribedMediaTrack(t,i,n,r,s,o-1)}),150));if("ended"===t.readyState)return a.error("unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()",{participant:this.sid,trackSid:i}),void this.emit(e.ParticipantEvent.TrackSubscriptionFailed,i);let d;return d="video"===t.kind?new hs(t,i,r,s):new ds(t,i,r,this.audioContext,this.audioOutput),d.source=c.source,d.isMuted=c.isMuted,d.setMediaStream(n),d.start(),c.setTrack(d),void 0!==this.volume&&d instanceof ds&&d.source===Xr.Source.Microphone&&d.setVolume(this.volume),c}get hasMetadata(){return!!this.participantInfo}getTrackPublication(e){return this.tracks.get(e)}updateInfo(t){super.updateInfo(t);const i=new Map,n=new Map;t.tracks.forEach((e=>{var r;let s=this.getTrackPublication(e.sid);if(s)s.updateInfo(e);else{const i=Xr.kindFromProto(e.type);if(!i)return;s=new xs(i,e.sid,e.name,null===(r=this.signalClient.connectOptions)||void 0===r?void 0:r.autoSubscribe),s.updateInfo(e),n.set(e.sid,s);const o=Array.from(this.tracks.values()).find((e=>e.source===(null==s?void 0:s.source)));o&&s.source!==Xr.Source.Unknown&&a.warn("received a second track publication for ".concat(this.identity," with the same source: ").concat(s.source),{oldTrack:o,newTrack:s,participant:this,participantInfo:t}),this.addTrackPublication(s)}i.set(e.sid,s)})),this.tracks.forEach((e=>{i.has(e.trackSid)||(a.trace("detected removed track on remote participant, unpublishing",{publication:e,participantSid:this.sid}),this.unpublishTrack(e.trackSid,!0))})),n.forEach((t=>{this.emit(e.ParticipantEvent.TrackPublished,t)}))}unpublishTrack(t,i){const n=this.tracks.get(t);if(!n)return;switch(this.tracks.delete(t),n.kind){case Xr.Kind.Audio:this.audioTracks.delete(t);break;case Xr.Kind.Video:this.videoTracks.delete(t)}const{track:r}=n;r&&(r.stop(),n.setTrack(void 0)),i&&this.emit(e.ParticipantEvent.TrackUnpublished,n)}setAudioContext(e){this.audioContext=e,this.audioTracks.forEach((t=>t.track instanceof ds&&t.track.setAudioContext(e)))}async setAudioOutput(e){this.audioOutput=e;const t=[];this.audioTracks.forEach((i=>{var n;i.track instanceof ds&&t.push(i.track.setSinkId(null!==(n=e.deviceId)&&void 0!==n?n:"default"))})),await Promise.all(t)}emit(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return a.trace("participant event",{participant:this.sid,event:e,args:i}),super.emit(e,...i)}}class Js extends Cs{constructor(e,t,i,n){super(e,t),this.pendingPublishing=new Set,this.participantTrackPermissions=[],this.allParticipantsAllowedToSubscribe=!0,this.updateTrackSubscriptionPermissions=()=>{a.debug("updating track subscription permissions",{allParticipantsAllowed:this.allParticipantsAllowedToSubscribe,participantTrackPermissions:this.participantTrackPermissions}),this.engine.client.sendUpdateSubscriptionPermissions(this.allParticipantsAllowedToSubscribe,this.participantTrackPermissions.map((e=>function(e){var t,i,n;if(!e.participantSid&&!e.participantIdentity)throw new Error("Invalid track permission, must provide at least one of participantIdentity and participantSid");return{participantIdentity:null!==(t=e.participantIdentity)&&void 0!==t?t:"",participantSid:null!==(i=e.participantSid)&&void 0!==i?i:"",allTracks:null!==(n=e.allowAll)&&void 0!==n&&n,trackSids:e.allowedTrackSids||[]}}(e))))},this.onTrackUnmuted=e=>{this.onTrackMuted(e,e.isUpstreamPaused)},this.onTrackMuted=(e,t)=>{void 0===t&&(t=!0),e.sid?this.engine.updateMuteStatus(e.sid,t):a.error("could not update mute status for unpublished track",e)},this.onTrackUpstreamPaused=e=>{a.debug("upstream paused"),this.onTrackMuted(e,!0)},this.onTrackUpstreamResumed=e=>{a.debug("upstream resumed"),this.onTrackMuted(e,e.isMuted)},this.handleSubscribedQualityUpdate=async e=>{var t,i;if(!(null===(t=this.roomOptions)||void 0===t?void 0:t.dynacast))return;const n=this.videoTracks.get(e.trackSid);if(n)if(e.subscribedCodecs.length>0){if(!n.videoTrack)return;const t=await n.videoTrack.setPublishingCodecs(e.subscribedCodecs);var r,s=!1,o=!1;try{for(var c,d=Vt(t);s=!(c=await d.next()).done;s=!1){const e=c.value;bs(e)&&(a.debug("publish ".concat(e," for ").concat(n.videoTrack.sid)),await this.publishAdditionalCodecForTrack(n.videoTrack,e,n.options))}}catch(e){o=!0,r=e}finally{try{s&&null!=d.return&&await d.return()}finally{if(o)throw r}}}else e.subscribedQualities.length>0&&(null===(i=n.videoTrack)||void 0===i||i.setPublishingLayers(e.subscribedQualities));else a.warn("received subscribed quality update for unknown track",{method:"handleSubscribedQualityUpdate",sid:e.trackSid})},this.handleLocalTrackUnpublished=e=>{const t=this.tracks.get(e.trackSid);t?this.unpublishTrack(t.track):a.warn("received unpublished event for unknown track",{method:"handleLocalTrackUnpublished",trackSid:e.trackSid})},this.handleTrackEnded=async e=>{if(e.source===Xr.Source.ScreenShare||e.source===Xr.Source.ScreenShareAudio)a.debug("unpublishing local track due to TrackEnded",{track:e.sid}),this.unpublishTrack(e);else if(e.isUserProvided)await e.mute();else if(e instanceof ns||e instanceof rs)try{if(br())try{const t=await(null===navigator||void 0===navigator?void 0:navigator.permissions.query({name:e.source===Xr.Source.Camera?"camera":"microphone"}));if(t&&"denied"===t.state)throw a.warn("user has revoked access to ".concat(e.source)),t.onchange=()=>{"denied"!==t.state&&(e.restartTrack(),t.onchange=null)},new Error("GetUserMedia Permission denied")}catch(e){}a.debug("track ended, attempting to use a different device"),await e.restartTrack()}catch(t){a.warn("could not restart track, muting instead"),await e.mute()}},this.audioTracks=new Map,this.videoTracks=new Map,this.tracks=new Map,this.engine=i,this.roomOptions=n,this.setupEngine(i)}get lastCameraError(){return this.cameraError}get lastMicrophoneError(){return this.microphoneError}getTrack(e){const t=super.getTrack(e);if(t)return t}getTrackByName(e){const t=super.getTrackByName(e);if(t)return t}setupEngine(t){this.engine=t,this.engine.client.onRemoteMuteChanged=(e,t)=>{const i=this.tracks.get(e);i&&i.track&&(t?i.mute():i.unmute())},this.engine.client.onSubscribedQualityUpdate=this.handleSubscribedQualityUpdate,this.engine.client.onLocalTrackUnpublished=this.handleLocalTrackUnpublished,this.engine.on(e.EngineEvent.Connected,this.updateTrackSubscriptionPermissions).on(e.EngineEvent.Restarted,this.updateTrackSubscriptionPermissions).on(e.EngineEvent.Resumed,this.updateTrackSubscriptionPermissions)}setCameraEnabled(e,t,i){return this.setTrackEnabled(Xr.Source.Camera,e,t,i)}setMicrophoneEnabled(e,t,i){return this.setTrackEnabled(Xr.Source.Microphone,e,t,i)}setScreenShareEnabled(e,t,i){return this.setTrackEnabled(Xr.Source.ScreenShare,e,t,i)}async setTrackEnabled(t,i,n,r){var s,o;a.debug("setTrackEnabled",{source:t,enabled:i});let c=this.getTrack(t);if(i)if(c)await c.unmute();else{let i;if(this.pendingPublishing.has(t))return void a.info("skipping duplicate published source",{source:t});this.pendingPublishing.add(t);try{switch(t){case Xr.Source.Camera:i=await this.createTracks({video:null===(s=n)||void 0===s||s});break;case Xr.Source.Microphone:i=await this.createTracks({audio:null===(o=n)||void 0===o||o});break;case Xr.Source.ScreenShare:i=await this.createScreenTracks(Wt({},n));break;default:throw new Hn(t)}const e=[];for(const t of i)a.info("publishing track",{localTrack:t}),e.push(this.publishTrack(t,r));const d=await Promise.all(e);[c]=d}catch(t){throw t instanceof Error&&!(t instanceof Hn)&&this.emit(e.ParticipantEvent.MediaDevicesError,t),t}finally{this.pendingPublishing.delete(t)}}else if(c&&c.track)if(t===Xr.Source.ScreenShare){c=await this.unpublishTrack(c.track);const e=this.getTrack(Xr.Source.ScreenShareAudio);e&&e.track&&this.unpublishTrack(e.track)}else await c.mute();return c}async enableCameraAndMicrophone(){if(!this.pendingPublishing.has(Xr.Source.Camera)&&!this.pendingPublishing.has(Xr.Source.Microphone)){this.pendingPublishing.add(Xr.Source.Camera),this.pendingPublishing.add(Xr.Source.Microphone);try{const e=await this.createTracks({audio:!0,video:!0});await Promise.all(e.map((e=>this.publishTrack(e))))}finally{this.pendingPublishing.delete(Xr.Source.Camera),this.pendingPublishing.delete(Xr.Source.Microphone)}}}async createTracks(e){var t,i;const n=ar(rr(e,null===(t=this.roomOptions)||void 0===t?void 0:t.audioCaptureDefaults,null===(i=this.roomOptions)||void 0===i?void 0:i.videoCaptureDefaults));let r;try{r=await navigator.mediaDevices.getUserMedia(n)}catch(e){throw e instanceof Error&&(n.audio&&(this.microphoneError=e),n.video&&(this.cameraError=e)),e}return n.audio&&(this.microphoneError=void 0),n.video&&(this.cameraError=void 0),r.getTracks().map((t=>{const i="audio"===t.kind;let s;i?e.audio:e.video;const a=i?n.audio:n.video;"boolean"!=typeof a&&(s=a);const o=Ts(t,s);return o.kind===Xr.Kind.Video?o.source=Xr.Source.Camera:o.kind===Xr.Kind.Audio&&(o.source=Xr.Source.Microphone),o.mediaStream=r,o}))}async createScreenTracks(e){var t;void 0===e&&(e={}),void 0===e.resolution&&(e.resolution=ws.h1080fps15.resolution);let i=!0;if(e.resolution&&(i=fr()?{width:{max:e.resolution.width},height:{max:e.resolution.height},frameRate:e.resolution.frameRate}:{width:{ideal:e.resolution.width},height:{ideal:e.resolution.height},frameRate:e.resolution.frameRate}),void 0===navigator.mediaDevices.getDisplayMedia)throw new zn("getDisplayMedia not supported");const n=await navigator.mediaDevices.getDisplayMedia({audio:null!==(t=e.audio)&&void 0!==t&&t,video:i}),r=n.getVideoTracks();if(0===r.length)throw new Hn("no video track found");const s=new rs(r[0],void 0,!1);s.source=Xr.Source.ScreenShare;const a=[s];if(n.getAudioTracks().length>0){const e=new ns(n.getAudioTracks()[0],void 0,!1);e.source=Xr.Source.ScreenShareAudio,a.push(e)}return a}async publishTrack(t,i){var n,r,s,o,c;if(t instanceof MediaStreamTrack)switch(t.kind){case"audio":t=new ns(t,void 0,!0);break;case"video":t=new rs(t,void 0,!0);break;default:throw new Hn("unsupported MediaStreamTrack kind ".concat(t.kind))}const d=(null==i?void 0:i.forceStereo)||"channelCount"in t.mediaStreamTrack.getSettings()&&2===t.mediaStreamTrack.getSettings().channelCount||2===t.mediaStreamTrack.getConstraints().channelCount;d&&(i||(i={}),void 0===i.dtx&&a.info("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work."),null!==(n=i.dtx)&&void 0!==n||(i.dtx=!1));const u=Wt(Wt({},this.roomOptions.publishDefaults),i);let l;if(this.tracks.forEach((e=>{e.track&&e.track===t&&(l=e)})),l)return l;u.source&&(t.source=u.source);const h=Array.from(this.tracks.values()).find((e=>t instanceof is&&e.source===t.source));if(h&&t.source!==Xr.Source.Unknown)try{throw Error("publishing a second track with the same source: ".concat(t.source))}catch(e){e instanceof Error&&a.warn(e.message,{oldTrack:h,newTrack:t,trace:e.stack})}u.stopMicTrackOnMute&&t instanceof ns&&(t.stopOnMute=!0),t.source===Xr.Source.ScreenShare&&vr()&&(u.simulcast=!1),"av1"!==u.videoCodec||lr()||(u.videoCodec=void 0),t.on(e.TrackEvent.Muted,this.onTrackMuted),t.on(e.TrackEvent.Unmuted,this.onTrackUnmuted),t.on(e.TrackEvent.Ended,this.handleTrackEnded),t.on(e.TrackEvent.UpstreamPaused,this.onTrackUpstreamPaused),t.on(e.TrackEvent.UpstreamResumed,this.onTrackUpstreamResumed);const p=cn.fromPartial({cid:t.mediaStreamTrack.id,name:null==i?void 0:i.name,type:Xr.kindToProto(t.kind),muted:t.isMuted,source:Xr.sourceToProto(t.source),disableDtx:!(null===(r=u.dtx)||void 0===r||r),stereo:d,disableRed:!(null===(s=u.red)||void 0===s||s)});let m,v;if(t.kind===Xr.Kind.Video){let e={width:0,height:0};try{e=await t.waitForDimensions()}catch(e){a.error("could not determine track dimensions")}if(p.width=e.width,p.height=e.height,t instanceof rs&&("av1"===(null==u?void 0:u.videoCodec)&&(u.scalabilityMode=null!==(o=u.scalabilityMode)&&void 0!==o?o:"L3T3"),u.videoCodec&&u.backupCodec&&u.videoCodec!==u.backupCodec.codec)){const e=Wt({},u);e.simulcast=!0,v=As(t,u.backupCodec.codec,e),p.simulcastCodecs=[{codec:u.videoCodec,cid:t.mediaStreamTrack.id,enableSimulcastLayers:!0},{codec:u.backupCodec.codec,cid:"",enableSimulcastLayers:!0}]}m=Is(t.source===Xr.Source.ScreenShare,e.width,e.height,u),p.layers=os(p.width,p.height,null!=v?v:m)}else t.kind===Xr.Kind.Audio&&u.audioBitrate&&(m=[{maxBitrate:u.audioBitrate}]);if(!this.engine||this.engine.isClosed)throw new Kn("cannot publish track when not connected");const f=await this.engine.addTrack(p),g=new vs(t.kind,f,t);if(g.options=u,t.sid=f.sid,!this.engine.publisher)throw new Kn("publisher is closed");return a.debug("publishing ".concat(t.kind," with encodings"),{encodings:m,trackInfo:f}),t.sender=await this.engine.createSender(t,u,m),"av1"===t.codec&&m&&(null===(c=m[0])||void 0===c?void 0:c.maxBitrate)&&this.engine.publisher.setTrackCodecBitrate(p.cid,t.codec,m[0].maxBitrate/1e3),this.engine.negotiate(),t instanceof rs?t.startMonitor(this.engine.client):t instanceof ns&&t.startMonitor(),this.addTrackPublication(g),this.emit(e.ParticipantEvent.LocalTrackPublished,g),g}get isLocal(){return!0}async publishAdditionalCodecForTrack(e,t,i){var n;let r;if(this.tracks.forEach((t=>{t.track&&t.track===e&&(r=t)})),!r)throw new Hn("track is not published");if(!(e instanceof rs))throw new Hn("track is not a video track");const s=Wt(Wt({},null===(n=this.roomOptions)||void 0===n?void 0:n.publishDefaults),i),o=As(e,t,s);if(!o)return void a.info("backup codec has been disabled, ignoring request to add additional codec for track");const c=e.addSimulcastTrack(t,o),d=cn.fromPartial({cid:c.mediaStreamTrack.id,type:Xr.kindToProto(e.kind),muted:e.isMuted,source:Xr.sourceToProto(e.source),sid:e.sid,simulcastCodecs:[{codec:s.videoCodec,cid:c.mediaStreamTrack.id,enableSimulcastLayers:s.simulcast}]});if(d.layers=os(d.width,d.height,o),!this.engine||this.engine.isClosed)throw new Kn("cannot publish track when not connected");const u=await this.engine.addTrack(d);await this.engine.createSimulcastSender(e,c,s,o),this.engine.negotiate(),a.debug("published ".concat(t," for track ").concat(e.sid),{encodings:o,trackInfo:u})}async unpublishTrack(t,i){var n,r;const s=this.getPublicationForTrack(t);if(a.debug("unpublishing track",{track:t,method:"unpublishTrack"}),s&&s.track){if((t=s.track).off(e.TrackEvent.Muted,this.onTrackMuted),t.off(e.TrackEvent.Unmuted,this.onTrackUnmuted),t.off(e.TrackEvent.Ended,this.handleTrackEnded),t.off(e.TrackEvent.UpstreamPaused,this.onTrackUpstreamPaused),t.off(e.TrackEvent.UpstreamResumed,this.onTrackUpstreamResumed),void 0===i&&(i=null===(r=null===(n=this.roomOptions)||void 0===n?void 0:n.stopLocalTrackOnUnpublish)||void 0===r||r),i&&t.stop(),this.engine.publisher&&"closed"!==this.engine.publisher.pc.connectionState&&t.sender)try{if(this.engine.removeTrack(t.sender),t instanceof rs){for(const[,e]of t.simulcastCodecs)e.sender&&(this.engine.removeTrack(e.sender),e.sender=void 0);t.simulcastCodecs.clear()}}catch(e){a.warn("failed to unpublish track",{error:e,method:"unpublishTrack"})}finally{await this.engine.negotiate()}switch(t.sender=void 0,this.tracks.delete(s.trackSid),s.kind){case Xr.Kind.Audio:this.audioTracks.delete(s.trackSid);break;case Xr.Kind.Video:this.videoTracks.delete(s.trackSid)}return this.emit(e.ParticipantEvent.LocalTrackUnpublished,s),s.setTrack(void 0),s}a.warn("track was not unpublished because no publication was found",{track:t,method:"unpublishTrack"})}async unpublishTracks(e){return(await Promise.all(e.map((e=>this.unpublishTrack(e))))).filter((e=>e instanceof vs))}async republishAllTracks(e){const t=[];this.tracks.forEach((i=>{i.track&&(e&&(i.options=Wt(Wt({},i.options),e)),t.push(i))})),await Promise.all(t.map((async e=>{const t=e.track;await this.unpublishTrack(t,!1),await this.publishTrack(t,e.options)})))}async publishData(e,t,i){const n=[];void 0!==i&&i.forEach((e=>{e instanceof _s?n.push(e.sid):n.push(e)}));const r={kind:t,value:{$case:"user",user:{participantSid:this.sid,payload:e,destinationSids:n}}};await this.engine.sendDataPacket(r,t)}setTrackSubscriptionPermissions(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];this.participantTrackPermissions=t,this.allParticipantsAllowedToSubscribe=e,this.engine.client.isConnected&&this.updateTrackSubscriptionPermissions()}updateInfo(e){e.sid===this.sid&&(super.updateInfo(e),e.tracks.forEach((e=>{var t,i;const n=this.tracks.get(e.sid);if(n){const r=n.isMuted||null!==(i=null===(t=n.track)||void 0===t?void 0:t.isUpstreamPaused)&&void 0!==i&&i;r!==e.muted&&(a.debug("updating server mute state after reconcile",{sid:e.sid,muted:r}),this.engine.client.sendMuteTrack(e.sid,r))}})))}getPublicationForTrack(e){let t;return this.tracks.forEach((i=>{const n=i.track;n&&(e instanceof MediaStreamTrack?(n instanceof ns||n instanceof rs)&&n.mediaStreamTrack===e&&(t=i):e===n&&(t=i))})),t}publishedTracksInfo(){const e=[];return this.tracks.forEach((t=>{void 0!==t.track&&e.push({cid:t.track.mediaStreamID,track:t.trackInfo})})),e}dataChannelsInfo(){const t=[],i=(e,i)=>{void 0!==(null==e?void 0:e.id)&&null!==e.id&&t.push({label:e.label,id:e.id,target:i})};return i(this.engine.dataChannelForKind(e.DataPacket_Kind.LOSSY),Zi.PUBLISHER),i(this.engine.dataChannelForKind(e.DataPacket_Kind.RELIABLE),Zi.PUBLISHER),i(this.engine.dataChannelForKind(e.DataPacket_Kind.LOSSY,!0),Zi.SUBSCRIBER),i(this.engine.dataChannelForKind(e.DataPacket_Kind.RELIABLE,!0),Zi.SUBSCRIBER),t}}const $s=["syncState","trickle","offer","answer","simulate","leave"];class Bs{constructor(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isConnected=!1,this.isReconnecting=!1,this.useJSON=e,this.requestQueue=new Ar,this.queuedRequests=[],this.closingLock=new Ir}async join(e,t,i,n){this.isConnected=!1,this.options=i;return await this.connect(e,t,i,n)}async reconnect(e,t,i){if(!this.options)return void a.warn("attempted to reconnect without signal options being set, ignoring");this.isReconnecting=!0,this.clearPingInterval();return await this.connect(e,t,Wt(Wt({},this.options),{},{reconnect:!0,sid:i}))}connect(e,t,i,n){this.connectOptions=i,e.startsWith("http")&&(e=e.replace("http","ws")),e=e.replace(/\/$/,""),e+="/rtc";const r=function(e,t,i){var n;const r=new URLSearchParams;r.set("access_token",e),i.reconnect&&(r.set("reconnect","1"),i.sid&&r.set("sid",i.sid));r.set("auto_subscribe",i.autoSubscribe?"1":"0"),r.set("sdk","js"),r.set("version",t.version),r.set("protocol",t.protocol.toString()),t.deviceModel&&r.set("device_model",t.deviceModel);t.os&&r.set("os",t.os);t.osVersion&&r.set("os_version",t.osVersion);t.browser&&r.set("browser",t.browser);t.browserVersion&&r.set("browser_version",t.browserVersion);void 0!==i.publishOnly&&r.set("publish",i.publishOnly);i.adaptiveStream&&r.set("adaptive_stream","1");(null===(n=navigator.connection)||void 0===n?void 0:n.type)&&r.set("network",navigator.connection.type);return"?".concat(r.toString())}(t,It.fromPartial({sdk:Xe.JS,protocol:8,version:nr}),i);return new Promise((async(t,s)=>{const o=async()=>{await this.close(),s(new Qn("room connection has been cancelled"))};(null==n?void 0:n.aborted)&&o(),null==n||n.addEventListener("abort",o),a.debug("connecting to ".concat(e+r)),this.ws&&await this.close(),this.ws=new WebSocket(e+r),this.ws.binaryType="arraybuffer",this.ws.onerror=async t=>{if(this.isConnected)this.handleWSError(t);else try{const t=await fetch("http".concat(e.substring(2),"/validate").concat(r));if(t.ok)s(new Qn("Internal error",2,t.status));else{const e=await t.text();s(new Qn(e,0,t.status))}}catch(e){s(new Qn("server was not reachable",1))}},this.ws.onmessage=async e=>{var r,c,d,u;let l;if("string"==typeof e.data){const t=JSON.parse(e.data);l=an.fromJSON(t)}else{if(!(e.data instanceof ArrayBuffer))return void a.error("could not decode websocket message: ".concat(typeof e.data));l=an.decode(new Uint8Array(e.data))}if(!this.isConnected){let e=!1;if("join"===(null===(r=l.message)||void 0===r?void 0:r.$case)?(this.isConnected=!0,null==n||n.removeEventListener("abort",o),this.pingTimeoutDuration=l.message.join.pingTimeout,this.pingIntervalDuration=l.message.join.pingInterval,this.pingTimeoutDuration&&this.pingTimeoutDuration>0&&(a.debug("ping config",{timeout:this.pingTimeoutDuration,interval:this.pingIntervalDuration}),this.startPingInterval()),t(l.message.join)):i.reconnect?(this.isConnected=!0,null==n||n.removeEventListener("abort",o),this.startPingInterval(),"reconnect"===(null===(c=l.message)||void 0===c?void 0:c.$case)?t(null===(d=l.message)||void 0===d?void 0:d.reconnect):(t(),e=!0)):i.reconnect||s(new Qn("did not receive join response, got ".concat(null===(u=l.message)||void 0===u?void 0:u.$case," instead"))),!e)return}this.signalLatency&&await cr(this.signalLatency),this.handleSignalResponse(l)},this.ws.onclose=e=>{this.isConnected&&(a.debug("websocket connection closed: ".concat(e.reason)),this.isConnected=!1,this.onClose&&this.onClose(e.reason),this.ws=void 0)}}))}async close(){const e=await this.closingLock.lock();try{if(this.isConnected=!1,this.ws){this.ws.onclose=null,this.ws.onmessage=null,this.ws.onopen=null;const e=new Promise((e=>{this.ws?this.ws.onclose=e:e(!0)}));this.ws.close(),await Promise.race([e,cr(250)])}this.ws=void 0,this.clearPingInterval()}finally{e()}}sendOffer(e){a.debug("sending offer",e),this.sendRequest({$case:"offer",offer:Vs(e)})}sendAnswer(e){a.debug("sending answer"),this.sendRequest({$case:"answer",answer:Vs(e)})}sendIceCandidate(e,t){a.trace("sending ice candidate",e),this.sendRequest({$case:"trickle",trickle:{candidateInit:JSON.stringify(e),target:t}})}sendMuteTrack(e,t){this.sendRequest({$case:"mute",mute:{sid:e,muted:t}})}sendAddTrack(e){this.sendRequest({$case:"addTrack",addTrack:cn.fromPartial(e)})}sendUpdateTrackSettings(e){this.sendRequest({$case:"trackSetting",trackSetting:e})}sendUpdateSubscription(e){this.sendRequest({$case:"subscription",subscription:e})}sendSyncState(e){this.sendRequest({$case:"syncState",syncState:e})}sendUpdateVideoLayers(e,t){this.sendRequest({$case:"updateLayers",updateLayers:{trackSid:e,layers:t}})}sendUpdateSubscriptionPermissions(e,t){this.sendRequest({$case:"subscriptionPermission",subscriptionPermission:{allParticipants:e,trackPermissions:t}})}sendSimulateScenario(e){this.sendRequest({$case:"simulate",simulate:e})}sendPing(){this.sendRequest({$case:"ping",ping:Date.now()})}async sendLeave(){await this.sendRequest({$case:"leave",leave:{canReconnect:!1,reason:e.DisconnectReason.CLIENT_INITIATED}})}async sendRequest(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=!t&&!function(e){const t=$s.includes(e.$case);return a.trace("request allowed to bypass queue:",{canPass:t,req:e}),t}(e);if(i&&this.isReconnecting)return void this.queuedRequests.push((async()=>{await this.sendRequest(e,!0)}));if(t||await this.requestQueue.flush(),this.signalLatency&&await cr(this.signalLatency),!this.ws||this.ws.readyState!==this.ws.OPEN)return void a.error("cannot send signal request before connected, type: ".concat(null==e?void 0:e.$case));const n={message:e};try{this.useJSON?this.ws.send(JSON.stringify(sn.toJSON(n))):this.ws.send(sn.encode(n).finish())}catch(e){a.error("error sending signal message",{error:e})}}handleSignalResponse(e){var t,i;const n=e.message;if(null!=n)if("answer"===n.$case){const e=js(n.answer);this.onAnswer&&this.onAnswer(e)}else if("offer"===n.$case){const e=js(n.offer);this.onOffer&&this.onOffer(e)}else if("trickle"===n.$case){const e=JSON.parse(n.trickle.candidateInit);this.onTrickle&&this.onTrickle(e,n.trickle.target)}else"update"===n.$case?this.onParticipantUpdate&&this.onParticipantUpdate(null!==(t=n.update.participants)&&void 0!==t?t:[]):"trackPublished"===n.$case?this.onLocalTrackPublished&&this.onLocalTrackPublished(n.trackPublished):"speakersChanged"===n.$case?this.onSpeakersChanged&&this.onSpeakersChanged(null!==(i=n.speakersChanged.speakers)&&void 0!==i?i:[]):"leave"===n.$case?this.onLeave&&this.onLeave(n.leave):"mute"===n.$case?this.onRemoteMuteChanged&&this.onRemoteMuteChanged(n.mute.sid,n.mute.muted):"roomUpdate"===n.$case?this.onRoomUpdate&&n.roomUpdate.room&&this.onRoomUpdate(n.roomUpdate.room):"connectionQuality"===n.$case?this.onConnectionQuality&&this.onConnectionQuality(n.connectionQuality):"streamStateUpdate"===n.$case?this.onStreamStateUpdate&&this.onStreamStateUpdate(n.streamStateUpdate):"subscribedQualityUpdate"===n.$case?this.onSubscribedQualityUpdate&&this.onSubscribedQualityUpdate(n.subscribedQualityUpdate):"subscriptionPermissionUpdate"===n.$case?this.onSubscriptionPermissionUpdate&&this.onSubscriptionPermissionUpdate(n.subscriptionPermissionUpdate):"refreshToken"===n.$case?this.onTokenRefresh&&this.onTokenRefresh(n.refreshToken):"trackUnpublished"===n.$case?this.onLocalTrackUnpublished&&this.onLocalTrackUnpublished(n.trackUnpublished):"pong"===n.$case?this.resetPingTimeout():a.debug("unsupported message",n);else a.debug("received unsupported message")}setReconnected(){for(;this.queuedRequests.length>0;){const e=this.queuedRequests.shift();e&&this.requestQueue.run(e)}this.isReconnecting=!1}handleWSError(e){a.error("websocket error",e)}resetPingTimeout(){this.clearPingTimeout(),this.pingTimeoutDuration?this.pingTimeout=ls.setTimeout((()=>{a.warn("ping timeout triggered. last pong received at: ".concat(new Date(Date.now()-1e3*this.pingTimeoutDuration).toUTCString())),this.onClose&&this.onClose("ping timeout")}),1e3*this.pingTimeoutDuration):a.warn("ping timeout duration not set")}clearPingTimeout(){this.pingTimeout&&ls.clearTimeout(this.pingTimeout)}startPingInterval(){this.clearPingInterval(),this.resetPingTimeout(),this.pingIntervalDuration?(a.debug("start ping interval"),this.pingInterval=ls.setInterval((()=>{this.sendPing()}),1e3*this.pingIntervalDuration)):a.warn("ping interval duration not set")}clearPingInterval(){a.debug("clearing ping interval"),this.clearPingTimeout(),this.pingInterval&&ls.clearInterval(this.pingInterval)}}function js(e){const t={type:"offer",sdp:e.sdp};switch(e.type){case"answer":case"offer":case"pranswer":case"rollback":t.type=e.type}return t}function Vs(e){return{sdp:e.sdp,type:e.type}}const Fs={audioBitrate:e.AudioPresets.music.maxBitrate,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:ws.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:"vp8",backupCodec:{codec:"vp8",encoding:ys.h540.encoding}},qs={autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0},Ws={resolution:ys.h720.resolution},Gs={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new jt,expWebAudioMix:!1},Qs={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3};var zs={},Hs={},Zs={get exports(){return Hs},set exports(e){Hs=e}}.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(Zs).forEach((function(e){Zs[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},i=function(e,i,n){var r=e.name&&e.names;e.push&&!i[e.push]?i[e.push]=[]:r&&!i[e.name]&&(i[e.name]={});var s=e.push?{}:r?i[e.name]:i;!function(e,i,n,r){if(r&&!n)i[r]=t(e[1]);else for(var s=0;s<n.length;s+=1)null!=e[s+1]&&(i[n[s]]=t(e[s+1]))}(n.match(e.reg),s,e.names,e.name),e.push&&i[e.push].push(s)},n=Hs,r=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},s=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(r).forEach((function(e){var t=e[0],r=e.slice(2);"m"===t&&(s.push({rtp:[],fmtp:[]}),a=s[s.length-1]);for(var o=0;o<(n[t]||[]).length;o+=1){var c=n[t][o];if(c.reg.test(r))return i(c,a,r)}})),t.media=s,t};var s=function(e,i){var n=i.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&i.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 i=[],n=e.split(" ").map(t),r=0;r<n.length;r+=3)i.push({component:n[r],ip:n[r+1],port:n[r+2]});return i},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 i,n=!1;return"~"!==e[0]?i=t(e):(i=t(e.substring(1,e.length)),n=!0),{scid:i,paused:n}}))}))}}(zs);var Ks=Hs,Ys=/%[sdv%]/g,Xs=function(e){var t=1,i=arguments,n=i.length;return e.replace(Ys,(function(e){if(t>=n)return e;var r=i[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},ea=function(e,t,i){var n=[e+"="+(t.format instanceof Function?t.format(t.push?i:i[t.name]):t.format)];if(t.names)for(var r=0;r<t.names.length;r+=1){var s=t.names[r];t.name?n.push(i[t.name][s]):n.push(i[t.names[r]])}else n.push(i[t.name]);return Xs.apply(null,n)},ta=["v","o","s","i","u","e","p","c","b","t","r","z","a"],ia=["i","c","b","a"],na=zs,ra=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 i=t.outerOrder||ta,n=t.innerOrder||ia,r=[];return i.forEach((function(t){Ks[t].forEach((function(i){i.name in e&&null!=e[i.name]?r.push(ea(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){r.push(ea(t,i,e))}))}))})),e.media.forEach((function(e){r.push(ea("m",Ks.m[0],e)),n.forEach((function(t){Ks[t].forEach((function(i){i.name in e&&null!=e[i.name]?r.push(ea(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){r.push(ea(t,i,e))}))}))}))})),r.join("\r\n")+"\r\n"},sa=ra,aa=na.parse;const oa="negotiationStarted",ca="negotiationComplete";class da extends xr{constructor(e){super(),this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate=!1,this.trackBitrates=[],this.remoteStereoMids=[],this.remoteNackMids=[],this.negotiate=us((e=>{this.emit(oa);try{this.createAndSendOffer()}catch(t){if(!e)throw t;e(t)}}),100),this.pc=new RTCPeerConnection(e)}get isICEConnected(){return"connected"===this.pc.iceConnectionState||"completed"===this.pc.iceConnectionState}async addIceCandidate(e){if(this.pc.remoteDescription&&!this.restartingIce)return this.pc.addIceCandidate(e);this.pendingCandidates.push(e)}async setRemoteDescription(e){if("offer"===e.type){let{stereoMids:t,nackMids:i}=function(e){var t;const i=[],n=[],r=aa(null!==(t=e.sdp)&&void 0!==t?t:"");let s=0;return r.media.forEach((e=>{var t;"audio"===e.type&&(e.rtp.some((e=>"opus"===e.codec&&(s=e.payload,!0))),(null===(t=e.rtcpFb)||void 0===t?void 0:t.some((e=>e.payload===s&&"nack"===e.type)))&&n.push(e.mid),e.fmtp.some((t=>t.payload===s&&(t.config.includes("sprop-stereo=1")&&i.push(e.mid),!0))))})),{stereoMids:i,nackMids:n}}(e);this.remoteStereoMids=t,this.remoteNackMids=i}await this.pc.setRemoteDescription(e),this.pendingCandidates.forEach((e=>{this.pc.addIceCandidate(e)})),this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate?(this.renegotiate=!1,this.createAndSendOffer()):"answer"===e.type&&this.emit(ca)}async createAndSendOffer(e){var t;if(void 0===this.onOffer)return;if((null==e?void 0:e.iceRestart)&&(a.debug("restarting ICE"),this.restartingIce=!0),"have-local-offer"===this.pc.signalingState){const t=this.pc.remoteDescription;if(!(null==e?void 0:e.iceRestart)||!t)return void(this.renegotiate=!0);await this.pc.setRemoteDescription(t)}else if("closed"===this.pc.signalingState)return void a.warn("could not createOffer with closed peer connection");a.debug("starting to negotiate");const i=await this.pc.createOffer(e),n=aa(null!==(t=i.sdp)&&void 0!==t?t:"");n.media.forEach((e=>{"audio"===e.type?ua(e,[],[]):"video"===e.type&&this.trackBitrates.some((t=>{if(!e.msid||!e.msid.includes(t.sid))return!1;let i=0;return e.rtp.some((e=>e.codec.toUpperCase()===t.codec.toUpperCase()&&(i=e.payload,!0))),i>0&&(e.fmtp.some((e=>e.payload===i&&(e.config.includes("x-google-max-bitrate")||(e.config+=";x-google-max-bitrate=".concat(t.maxbr)),!0)))||e.fmtp.push({payload:i,config:"x-google-max-bitrate=".concat(t.maxbr)})),!0}))})),this.trackBitrates=[],await this.setMungedLocalDescription(i,sa(n)),this.onOffer(i)}async createAndSetAnswer(){var e;const t=await this.pc.createAnswer(),i=aa(null!==(e=t.sdp)&&void 0!==e?e:"");return i.media.forEach((e=>{"audio"===e.type&&ua(e,this.remoteStereoMids,this.remoteNackMids)})),await this.setMungedLocalDescription(t,sa(i)),t}setTrackCodecBitrate(e,t,i){this.trackBitrates.push({sid:e,codec:t,maxbr:i})}close(){this.pc.close()}async setMungedLocalDescription(e,t){const i=e.sdp;e.sdp=t;try{return a.debug("setting munged local description"),void await this.pc.setLocalDescription(e)}catch(t){a.warn("not able to set ".concat(e.type,", falling back to unmodified sdp"),{error:t}),e.sdp=i}try{await this.pc.setLocalDescription(e)}catch(e){let t="unknown error";throw e instanceof Error?t=e.message:"string"==typeof e&&(t=e),new Yn(t)}}}function ua(e,t,i){let n=0;e.rtp.some((e=>"opus"===e.codec&&(n=e.payload,!0))),n>0&&(e.rtcpFb||(e.rtcpFb=[]),i.includes(e.mid)&&!e.rtcpFb.some((e=>e.payload===n&&"nack"===e.type))&&e.rtcpFb.push({payload:n,type:"nack"}),t.includes(e.mid)&&e.fmtp.some((e=>e.payload===n&&(e.config.includes("stereo=1")||(e.config+=";stereo=1"),!0))))}const la="_lossy",ha="_reliable",pa="leave-reconnect";var ma,va;!function(e){e[e.New=0]="New",e[e.Connected=1]="Connected",e[e.Disconnected=2]="Disconnected",e[e.Reconnecting=3]="Reconnecting",e[e.Closed=4]="Closed"}(ma||(ma={}));class fa extends xr.EventEmitter{get isClosed(){return this._isClosed}constructor(t){var i;super(),i=this,this.options=t,this.rtcConfig={},this.peerConnectionTimeout=Qs.peerConnectionTimeout,this.subscriberPrimary=!1,this.pcState=ma.New,this._isClosed=!0,this.pendingTrackResolvers={},this.hasPublished=!1,this.reconnectAttempts=0,this.reconnectStart=0,this.fullReconnectOnNext=!1,this.attemptingReconnect=!1,this.joinAttempts=0,this.maxJoinAttempts=1,this.handleDataChannel=async e=>{let{channel:t}=e;if(t){if(t.label===ha)this.reliableDCSub=t;else{if(t.label!==la)return;this.lossyDCSub=t}a.debug("on data channel ".concat(t.id,", ").concat(t.label)),t.onmessage=this.handleDataMessage}},this.handleDataMessage=async t=>{var i,n;let r;if(t.data instanceof ArrayBuffer)r=t.data;else{if(!(t.data instanceof Blob))return void a.error("unsupported data type",t.data);r=await t.data.arrayBuffer()}const s=Tt.decode(new Uint8Array(r));"speaker"===(null===(i=s.value)||void 0===i?void 0:i.$case)?this.emit(e.EngineEvent.ActiveSpeakersUpdate,s.value.speaker.speakers):"user"===(null===(n=s.value)||void 0===n?void 0:n.$case)&&this.emit(e.EngineEvent.DataPacketReceived,s.value.user,s.kind)},this.handleDataError=e=>{const t=0===e.currentTarget.maxRetransmits?"lossy":"reliable";if(e instanceof ErrorEvent){const{error:i}=e.error;a.error("DataChannel error on ".concat(t,": ").concat(e.message),i)}else a.error("Unknown DataChannel Error on ".concat(t),e)},this.handleDisconnect=function(t){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(i._isClosed)return;a.warn("".concat(t," disconnected")),0===i.reconnectAttempts&&(i.reconnectStart=Date.now());const r=t=>{a.warn("could not recover connection after ".concat(i.reconnectAttempts," attempts, ").concat(t,"ms. giving up")),i.emit(e.EngineEvent.Disconnected),i.close()},s=Date.now()-i.reconnectStart;let o=i.getNextRetryDelay({elapsedMs:s,retryCount:i.reconnectAttempts});null!==o?(t===pa&&(o=0),a.debug("reconnecting in ".concat(o,"ms")),i.clearReconnectTimeout(),i.reconnectTimeout=ls.setTimeout((()=>i.attemptReconnect(n)),o)):r(s)},this.handleBrowserOnLine=()=>{this.client.isReconnecting&&(this.clearReconnectTimeout(),this.attemptReconnect(!0))},this.client=new Bs,this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.registerOnLineListener(),this.closingLock=new Ir}async join(e,t,i,n){this.url=e,this.token=t,this.signalOpts=i;try{this.joinAttempts+=1;const r=await this.client.join(e,t,i,n);return this._isClosed=!1,this.subscriberPrimary=r.subscriberPrimary,this.publisher||this.configure(r),this.subscriberPrimary||this.negotiate(),this.clientConfiguration=r.clientConfiguration,r}catch(r){if(r instanceof Qn&&1===r.reason&&(a.warn("Couldn't connect to server, attempt ".concat(this.joinAttempts," of ").concat(this.maxJoinAttempts)),this.joinAttempts<this.maxJoinAttempts))return this.join(e,t,i,n);throw r}}async close(){const t=await this.closingLock.lock();if(this.isClosed)t();else try{this._isClosed=!0,this.emit(e.EngineEvent.Closing),this.removeAllListeners(),this.deregisterOnLineListener(),this.clearPendingReconnect(),this.publisher&&"closed"!==this.publisher.pc.signalingState&&(this.publisher.pc.getSenders().forEach((e=>{var t,i;try{(null===(t=this.publisher)||void 0===t?void 0:t.pc.removeTrack)&&(null===(i=this.publisher)||void 0===i||i.pc.removeTrack(e))}catch(e){a.warn("could not removeTrack",{error:e})}})),this.publisher.close(),this.publisher=void 0),this.subscriber&&(this.subscriber.close(),this.subscriber=void 0),await this.client.close()}finally{t()}}addTrack(e){if(this.pendingTrackResolvers[e.cid])throw new Hn("a track with the same ID has already been published");return new Promise(((t,i)=>{const n=setTimeout((()=>{delete this.pendingTrackResolvers[e.cid],i(new Qn("publication of local track timed out, no response from server"))}),1e4);this.pendingTrackResolvers[e.cid]={resolve:e=>{clearTimeout(n),t(e)},reject:()=>{clearTimeout(n),i(new Error("Cancelled publication by calling unpublish"))}},this.client.sendAddTrack(e)}))}removeTrack(e){var t;if(e.track&&this.pendingTrackResolvers[e.track.id]){const{reject:t}=this.pendingTrackResolvers[e.track.id];t&&t(),delete this.pendingTrackResolvers[e.track.id]}try{null===(t=this.publisher)||void 0===t||t.pc.removeTrack(e)}catch(e){a.warn("failed to remove track",{error:e,method:"removeTrack"})}}updateMuteStatus(e,t){this.client.sendMuteTrack(e,t)}get dataSubscriberReadyState(){var e;return null===(e=this.reliableDCSub)||void 0===e?void 0:e.readyState}get connectedServerAddress(){return this.connectedServerAddr}configure(t){var i;if(this.publisher||this.subscriber)return;this.participantSid=null===(i=t.participant)||void 0===i?void 0:i.sid;const n=this.makeRTCConfiguration(t);this.publisher=new da(n),this.subscriber=new da(n),this.emit(e.EngineEvent.TransportsCreated,this.publisher,this.subscriber),this.publisher.pc.onicecandidate=e=>{e.candidate&&(a.trace("adding ICE candidate for peer",e.candidate),this.client.sendIceCandidate(e.candidate,Zi.PUBLISHER))},this.subscriber.pc.onicecandidate=e=>{e.candidate&&this.client.sendIceCandidate(e.candidate,Zi.SUBSCRIBER)},this.publisher.onOffer=e=>{this.client.sendOffer(e)};let r=this.publisher.pc,s=this.subscriber.pc;t.subscriberPrimary&&(r=this.subscriber.pc,s=this.publisher.pc,this.subscriber.pc.ondatachannel=this.handleDataChannel),this.primaryPC=r,r.onconnectionstatechange=async()=>{if(a.debug("primary PC state changed ".concat(r.connectionState)),"connected"===r.connectionState){try{this.connectedServerAddr=await ga(r)}catch(e){a.warn("could not get connected server address",{error:e})}const i=this.pcState===ma.New;this.pcState=ma.Connected,i&&this.emit(e.EngineEvent.Connected,t)}else"failed"===r.connectionState&&this.pcState===ma.Connected&&(this.pcState=ma.Disconnected,this.handleDisconnect("primary peerconnection"))},s.onconnectionstatechange=async()=>{a.debug("secondary PC state changed ".concat(s.connectionState)),"failed"===s.connectionState&&this.handleDisconnect("secondary peerconnection")},this.subscriber.pc.ontrack=t=>{this.emit(e.EngineEvent.MediaTrackAdded,t.track,t.streams[0],t.receiver)},this.createDataChannels(),this.client.onAnswer=async e=>{this.publisher&&(a.debug("received server answer",{RTCSdpType:e.type,signalingState:this.publisher.pc.signalingState}),await this.publisher.setRemoteDescription(e))},this.client.onTrickle=(e,t)=>{this.publisher&&this.subscriber&&(a.trace("got ICE candidate from peer",{candidate:e,target:t}),t===Zi.PUBLISHER?this.publisher.addIceCandidate(e):this.subscriber.addIceCandidate(e))},this.client.onOffer=async e=>{if(!this.subscriber)return;a.debug("received server offer",{RTCSdpType:e.type,signalingState:this.subscriber.pc.signalingState}),await this.subscriber.setRemoteDescription(e);const t=await this.subscriber.createAndSetAnswer();this.client.sendAnswer(t)},this.client.onLocalTrackPublished=e=>{a.debug("received trackPublishedResponse",e);const{resolve:t}=this.pendingTrackResolvers[e.cid];t?(delete this.pendingTrackResolvers[e.cid],t(e.track)):a.error("missing track resolver for ".concat(e.cid))},this.client.onTokenRefresh=e=>{this.token=e},this.client.onClose=()=>{this.handleDisconnect("signal")},this.client.onLeave=t=>{(null==t?void 0:t.canReconnect)?(this.fullReconnectOnNext=!0,this.primaryPC=void 0,this.handleDisconnect(pa)):(this.emit(e.EngineEvent.Disconnected,null==t?void 0:t.reason),this.close()),a.trace("leave request",{leave:t})}}makeRTCConfiguration(e){const t=Wt({},this.rtcConfig);if(e.iceServers&&!t.iceServers){const i=[];e.iceServers.forEach((e=>{const t={urls:e.urls};e.username&&(t.username=e.username),e.credential&&(t.credential=e.credential),i.push(t)})),t.iceServers=i}return e.clientConfiguration&&e.clientConfiguration.forceRelay===Qe.ENABLED&&(t.iceTransportPolicy="relay"),t.sdpSemantics="unified-plan",t.continualGatheringPolicy="gather_continually",t}createDataChannels(){this.publisher&&(this.lossyDC&&(this.lossyDC.onmessage=null,this.lossyDC.onerror=null),this.reliableDC&&(this.reliableDC.onmessage=null,this.reliableDC.onerror=null),this.lossyDC=this.publisher.pc.createDataChannel(la,{ordered:!0,maxRetransmits:0}),this.reliableDC=this.publisher.pc.createDataChannel(ha,{ordered:!0}),this.lossyDC.onmessage=this.handleDataMessage,this.reliableDC.onmessage=this.handleDataMessage,this.lossyDC.onerror=this.handleDataError,this.reliableDC.onerror=this.handleDataError)}setPreferredCodec(e,t,i){if(!("getCapabilities"in RTCRtpSender))return;const n=RTCRtpSender.getCapabilities(t);if(!n)return;a.debug("get capabilities",n);const r=[],s=[],o=[];n.codecs.forEach((e=>{const t=e.mimeType.toLowerCase();if("audio/opus"===t)return void r.push(e);t==="video/".concat(i)?"h264"!==i||e.sdpFmtpLine&&e.sdpFmtpLine.includes("profile-level-id=42e01f")?r.push(e):s.push(e):o.push(e)})),mr(e)&&e.setCodecPreferences(r.concat(s,o))}async createSender(e,t,i){if(dr())return this.createTransceiverRTCRtpSender(e,t,i);if(ur())return a.debug("using add-track fallback"),this.createRTCRtpSender(e.mediaStreamTrack);throw new Kn("Required webRTC APIs not supported on this device")}async createSimulcastSender(e,t,i,n){if(dr())return this.createSimulcastTransceiverSender(e,t,i,n);if(ur())return a.debug("using add-track fallback"),this.createRTCRtpSender(e.mediaStreamTrack);throw new Kn("Cannot stream on this device")}async createTransceiverRTCRtpSender(e,t,i){if(!this.publisher)throw new Kn("publisher is closed");const n={direction:"sendonly"};i&&(n.sendEncodings=i);const r=await this.publisher.pc.addTransceiver(e.mediaStreamTrack,n);return e.kind===Xr.Kind.Video&&t.videoCodec&&(this.setPreferredCodec(r,e.kind,t.videoCodec),e.codec=t.videoCodec),r.sender}async createSimulcastTransceiverSender(e,t,i,n){if(!this.publisher)throw new Kn("publisher is closed");const r={direction:"sendonly"};n&&(r.sendEncodings=n);const s=await this.publisher.pc.addTransceiver(t.mediaStreamTrack,r);if(i.videoCodec)return this.setPreferredCodec(s,e.kind,i.videoCodec),e.setSimulcastTrackSender(i.videoCodec,s.sender),s.sender}async createRTCRtpSender(e){if(!this.publisher)throw new Kn("publisher is closed");return this.publisher.pc.addTrack(e)}async attemptReconnect(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];var i,n,r;if(!this._isClosed&&!this.attemptingReconnect){(null===(i=this.clientConfiguration)||void 0===i?void 0:i.resumeConnection)!==Qe.DISABLED&&"closed"!==(null!==(r=null===(n=this.primaryPC)||void 0===n?void 0:n.signalingState)&&void 0!==r?r:"closed")||(this.fullReconnectOnNext=!0);try{this.attemptingReconnect=!0,this.fullReconnectOnNext?await this.restartConnection(t):await this.resumeConnection(t),this.clearPendingReconnect(),this.fullReconnectOnNext=!1}catch(t){this.reconnectAttempts+=1;let i=!1,n=!0,r=!1;t instanceof Kn?(a.debug("received unrecoverable error",{error:t}),n=!1):t instanceof ba||(i=!0),i&&!this.fullReconnectOnNext&&(this.fullReconnectOnNext=!0,r=!0),n?this.handleDisconnect("reconnect",r):(a.info("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(Date.now()-this.reconnectStart,"ms. giving up")),this.emit(e.EngineEvent.Disconnected),this.close())}finally{this.attemptingReconnect=!1}}}getNextRetryDelay(e){try{return this.reconnectPolicy.nextRetryDelayInMs(e)}catch(e){a.warn("encountered error in reconnect policy",{error:e})}return null}async restartConnection(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];var i,n;if(!this.url||!this.token)throw new Kn("could not reconnect, url or token not saved");let r;a.info("reconnecting, attempt: ".concat(this.reconnectAttempts)),(t||0===this.reconnectAttempts)&&this.emit(e.EngineEvent.Restarting),this.client.isConnected&&await this.client.sendLeave(),await this.client.close(),this.primaryPC=void 0,null===(i=this.publisher)||void 0===i||i.close(),this.publisher=void 0,null===(n=this.subscriber)||void 0===n||n.close(),this.subscriber=void 0;try{if(!this.signalOpts)throw a.warn("attempted connection restart, without signal options present"),new ba;r=await this.join(this.url,this.token,this.signalOpts)}catch(e){throw new ba}await this.waitForPCConnected(),this.client.setReconnected(),this.emit(e.EngineEvent.Restarted,r)}async resumeConnection(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];var i;if(!this.url||!this.token)throw new Kn("could not reconnect, url or token not saved");if(!this.publisher||!this.subscriber)throw new Kn("publisher and subscriber connections unset");a.info("resuming signal connection, attempt ".concat(this.reconnectAttempts)),(t||0===this.reconnectAttempts)&&this.emit(e.EngineEvent.Resuming);try{const e=await this.client.reconnect(this.url,this.token,this.participantSid);if(e){const t=this.makeRTCConfiguration(e);this.publisher.pc.setConfiguration(t),this.subscriber.pc.setConfiguration(t)}}catch(e){let t="";throw e instanceof Error&&(t=e.message),new ba(t)}this.emit(e.EngineEvent.SignalResumed),this.subscriber.restartingIce=!0,this.hasPublished&&await this.publisher.createAndSendOffer({iceRestart:!0}),await this.waitForPCConnected(),this.client.setReconnected(),"open"===(null===(i=this.reliableDC)||void 0===i?void 0:i.readyState)&&null===this.reliableDC.id&&this.createDataChannels(),this.emit(e.EngineEvent.Resumed)}async waitForPCConnected(){var e;const t=Date.now();let i=t;for(this.pcState=ma.Reconnecting,a.debug("waiting for peer connection to reconnect");i-t<this.peerConnectionTimeout&&void 0!==this.primaryPC;){if(i-t>2e3&&"connected"===(null===(e=this.primaryPC)||void 0===e?void 0:e.connectionState)){this.pcState=ma.Connected;try{this.connectedServerAddr=await ga(this.primaryPC)}catch(e){a.warn("could not get connected server address",{error:e})}}if(this.pcState===ma.Connected)return;await cr(100),i=Date.now()}throw new Qn("could not establish PC connection")}async sendDataPacket(t,i){const n=Tt.encode(t).finish();await this.ensurePublisherConnected(i),i===e.DataPacket_Kind.LOSSY&&this.lossyDC?this.lossyDC.send(n):i===e.DataPacket_Kind.RELIABLE&&this.reliableDC&&this.reliableDC.send(n)}async ensureDataTransportConnected(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscriberPrimary;var i,n,r;const s=t?this.subscriber:this.publisher,a=t?"Subscriber":"Publisher";if(!s)throw new Qn("".concat(a," connection not set"));t||(null===(i=this.publisher)||void 0===i?void 0:i.isICEConnected)||"checking"===(null===(n=this.publisher)||void 0===n?void 0:n.pc.iceConnectionState)||this.negotiate();const o=this.dataChannelForKind(e,t);if("open"===(null==o?void 0:o.readyState))return;const c=(new Date).getTime()+this.peerConnectionTimeout;for(;(new Date).getTime()<c;){if(s.isICEConnected&&"open"===(null===(r=this.dataChannelForKind(e,t))||void 0===r?void 0:r.readyState))return;await cr(50)}throw new Qn("could not establish ".concat(a," connection, state: ").concat(s.pc.iceConnectionState))}async ensurePublisherConnected(e){await this.ensureDataTransportConnected(e,!1)}negotiate(){return new Promise(((t,i)=>{if(!this.publisher)return void i(new Yn("publisher is not defined"));this.hasPublished=!0;const n=()=>{a.debug("engine disconnected while negotiation was ongoing"),s(),t()};this.on(e.EngineEvent.Closing,n);const r=setTimeout((()=>{i("negotiation timed out"),this.handleDisconnect("negotiation")}),this.peerConnectionTimeout),s=()=>{clearTimeout(r),this.off(e.EngineEvent.Closing,n)};this.publisher.once(oa,(()=>{var e;null===(e=this.publisher)||void 0===e||e.once(ca,(()=>{s(),t()}))})),this.publisher.negotiate((e=>{s(),i(e),e instanceof Yn&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation")}))}))}dataChannelForKind(t,i){if(i){if(t===e.DataPacket_Kind.LOSSY)return this.lossyDCSub;if(t===e.DataPacket_Kind.RELIABLE)return this.reliableDCSub}else{if(t===e.DataPacket_Kind.LOSSY)return this.lossyDC;if(t===e.DataPacket_Kind.RELIABLE)return this.reliableDC}}clearReconnectTimeout(){this.reconnectTimeout&&ls.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){br()&&window.addEventListener("online",this.handleBrowserOnLine)}deregisterOnLineListener(){br()&&window.removeEventListener("online",this.handleBrowserOnLine)}}async function ga(e){var t;let i="";const n=new Map,r=new Map;if((await e.getStats()).forEach((e=>{switch(e.type){case"transport":i=e.selectedCandidatePairId;break;case"candidate-pair":""===i&&e.selected&&(i=e.id),n.set(e.id,e);break;case"remote-candidate":r.set(e.id,"".concat(e.address,":").concat(e.port))}})),""===i)return;const s=null===(t=n.get(i))||void 0===t?void 0:t.remoteCandidateId;return void 0!==s?r.get(s):void 0}class ba extends Error{}e.ConnectionState=void 0,(va=e.ConnectionState||(e.ConnectionState={})).Disconnected="disconnected",va.Connecting="connecting",va.Connected="connected",va.Reconnecting="reconnecting";const ka=e.ConnectionState;class ya extends xr.EventEmitter{constructor(t){var i;super(),i=this,this.state=e.ConnectionState.Disconnected,this.activeSpeakers=[],this.sid="",this.name="",this.metadata=void 0,this._isRecording=!1,this.audioEnabled=!0,this.connect=async(t,i,n)=>{const r=await this.disconnectLock.lock();if(this.state===e.ConnectionState.Connected)return a.info("already connected to room ".concat(this.name)),r(),Promise.resolve();if(this.connectFuture)return r(),this.connectFuture.promise;this.setAndEmitConnectionState(e.ConnectionState.Connecting);return this.connectFuture=new Dr((async(s,o)=>{var c,d;this.abortController&&!this.abortController.signal.aborted||(this.abortController=new AbortController),r(),this.state===e.ConnectionState.Reconnecting?(a.info("Reconnection attempt replaced by new connection attempt"),this.recreateEngine()):this.maybeCreateEngine(),this.acquireAudioContext(),this.connOptions=Wt(Wt({},Qs),n),this.connOptions.rtcConfig&&(this.engine.rtcConfig=this.connOptions.rtcConfig),this.connOptions.peerConnectionTimeout&&(this.engine.peerConnectionTimeout=this.connOptions.peerConnectionTimeout);try{const n=await this.engine.join(t,i,{autoSubscribe:this.connOptions.autoSubscribe,publishOnly:this.connOptions.publishOnly,adaptiveStream:"object"==typeof this.options.adaptiveStream||this.options.adaptiveStream,maxRetries:this.connOptions.maxRetries},this.abortController.signal);let r=n.serverInfo;if(r||(r={version:n.serverVersion,region:n.serverRegion}),a.debug("connected to Livekit Server ".concat(Object.entries(r).map((e=>{let[t,i]=e;return"".concat(t,": ").concat(i)})).join(", "))),!n.serverVersion)throw new Zn("unknown server version");"0.15.1"===n.serverVersion&&this.options.dynacast&&(a.debug("disabling dynacast due to server version"),this.options.dynacast=!1);const s=n.participant;this.localParticipant.sid=s.sid,this.localParticipant.identity=s.identity,this.localParticipant.updateInfo(s),this.setupLocalParticipantEvents(),n.otherParticipants.forEach((e=>{e.sid!==this.localParticipant.sid&&e.identity!==this.localParticipant.identity?this.getOrCreateParticipant(e.sid,e):a.warn("received info to create local participant as remote participant",{info:e,localParticipant:this.localParticipant})})),this.name=n.room.name,this.sid=n.room.sid,this.metadata=n.room.metadata,this._isRecording!==n.room.activeRecording&&(this._isRecording=n.room.activeRecording,this.emit(e.RoomEvent.RecordingStatusChanged,n.room.activeRecording)),this.emit(e.RoomEvent.SignalConnected)}catch(e){this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);let t="";return e instanceof Error&&(t=e.message,a.debug("error trying to establish signal connection",{error:e})),void o(new Qn("could not establish signal connection: ".concat(t)))}const u=ls.setTimeout((()=>{this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),o(new Qn("could not connect PeerConnection after timeout"))}),this.connOptions.peerConnectionTimeout),l=()=>{a.warn("closing engine"),ls.clearTimeout(u),this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),o(new Qn("room connection has been cancelled"))};(null===(c=this.abortController)||void 0===c?void 0:c.signal.aborted)&&l(),null===(d=this.abortController)||void 0===d||d.signal.addEventListener("abort",l),this.engine.once(e.EngineEvent.Connected,(()=>{var t,i;ls.clearTimeout(u),null===(t=this.abortController)||void 0===t||t.signal.removeEventListener("abort",l),br()&&(window.addEventListener("beforeunload",this.onBeforeUnload),null===(i=navigator.mediaDevices)||void 0===i||i.addEventListener("devicechange",this.handleDeviceChange)),this.setAndEmitConnectionState(e.ConnectionState.Connected),this.emit(e.RoomEvent.Connected),s()}))}),(()=>{this.clearConnectionFutures()})),this.connectFuture.promise},this.disconnect=async function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];var n,r,s,o;const c=await i.disconnectLock.lock();try{if(i.state===e.ConnectionState.Disconnected)return void a.debug("already disconnected");a.info("disconnect from room",{identity:i.localParticipant.identity}),i.state!==e.ConnectionState.Connecting&&i.state!==e.ConnectionState.Reconnecting||(a.warn("abort connection attempt"),null===(n=i.abortController)||void 0===n||n.abort(),null===(s=null===(r=i.connectFuture)||void 0===r?void 0:r.reject)||void 0===s||s.call(r,new Qn("Client initiated disconnect")),i.connectFuture=void 0),(null===(o=i.engine)||void 0===o?void 0:o.client.isConnected)&&await i.engine.client.sendLeave(),i.engine&&await i.engine.close(),i.handleDisconnect(t,e.DisconnectReason.CLIENT_INITIATED),i.engine=void 0}finally{c()}},this.onBeforeUnload=async()=>{await this.disconnect()},this.handleRestarting=()=>{for(const e of this.participants.values())this.handleParticipantDisconnected(e.sid,e);this.setAndEmitConnectionState(e.ConnectionState.Reconnecting)&&this.emit(e.RoomEvent.Reconnecting)},this.handleRestarted=async t=>{a.debug("reconnected to server",{region:t.serverRegion}),this.setAndEmitConnectionState(e.ConnectionState.Connected),this.emit(e.RoomEvent.Reconnected),t.participant&&(this.localParticipant.sid=t.participant.sid,this.handleParticipantUpdates([t.participant])),this.handleParticipantUpdates(t.otherParticipants);const i=[];this.localParticipant.tracks.forEach((e=>{e.track&&i.push(e)})),await Promise.all(i.map((async e=>{const t=e.track;this.localParticipant.unpublishTrack(t,!1),t.isMuted||((t instanceof ns||t instanceof rs)&&!t.isUserProvided&&(a.debug("restarting existing track",{track:e.trackSid}),await t.restartTrack()),await this.localParticipant.publishTrack(t,e.options))})))},this.handleParticipantUpdates=e=>{e.forEach((e=>{if(e.identity===this.localParticipant.identity)return void this.localParticipant.updateInfo(e);const t=this.identityToSid.get(e.identity);t&&t!==e.sid&&this.handleParticipantDisconnected(t,this.participants.get(t));let i=this.participants.get(e.sid);const n=!i;i=this.getOrCreateParticipant(e.sid,e),e.state===He.DISCONNECTED?this.handleParticipantDisconnected(e.sid,i):n||i.updateInfo(e)}))},this.handleActiveSpeakersUpdate=t=>{const i=[],n={};t.forEach((e=>{if(n[e.sid]=!0,e.sid===this.localParticipant.sid)this.localParticipant.audioLevel=e.level,this.localParticipant.setIsSpeaking(!0),i.push(this.localParticipant);else{const t=this.participants.get(e.sid);t&&(t.audioLevel=e.level,t.setIsSpeaking(!0),i.push(t))}})),n[this.localParticipant.sid]||(this.localParticipant.audioLevel=0,this.localParticipant.setIsSpeaking(!1)),this.participants.forEach((e=>{n[e.sid]||(e.audioLevel=0,e.setIsSpeaking(!1))})),this.activeSpeakers=i,this.emitWhenConnected(e.RoomEvent.ActiveSpeakersChanged,i)},this.handleSpeakersChanged=t=>{const i=new Map;this.activeSpeakers.forEach((e=>{i.set(e.sid,e)})),t.forEach((e=>{let t=this.participants.get(e.sid);e.sid===this.localParticipant.sid&&(t=this.localParticipant),t&&(t.audioLevel=e.level,t.setIsSpeaking(e.active),e.active?i.set(e.sid,t):i.delete(e.sid))}));const n=Array.from(i.values());n.sort(((e,t)=>t.audioLevel-e.audioLevel)),this.activeSpeakers=n,this.emitWhenConnected(e.RoomEvent.ActiveSpeakersChanged,n)},this.handleStreamStateUpdate=t=>{t.streamStates.forEach((t=>{const i=this.participants.get(t.participantSid);if(!i)return;const n=i.getTrackPublication(t.trackSid);n&&n.track&&(n.track.streamState=Xr.streamStateFromProto(t.state),i.emit(e.ParticipantEvent.TrackStreamStateChanged,n,n.track.streamState),this.emitWhenConnected(e.RoomEvent.TrackStreamStateChanged,n,n.track.streamState,i))}))},this.handleSubscriptionPermissionUpdate=e=>{const t=this.participants.get(e.participantSid);if(!t)return;const i=t.getTrackPublication(e.trackSid);i&&i.setAllowed(e.allowed)},this.handleDataPacket=(t,i)=>{const n=this.participants.get(t.participantSid);this.emit(e.RoomEvent.DataReceived,t.payload,n,i),null==n||n.emit(e.ParticipantEvent.DataReceived,t.payload,i)},this.handleAudioPlaybackStarted=()=>{this.canPlaybackAudio||(this.audioEnabled=!0,this.emit(e.RoomEvent.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=t=>{a.warn("could not playback audio",t),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(e.RoomEvent.AudioPlaybackStatusChanged,!1))},this.handleDeviceChange=async()=>{this.emit(e.RoomEvent.MediaDevicesChanged)},this.handleRoomUpdate=t=>{this._isRecording!==t.activeRecording&&(this._isRecording=t.activeRecording,this.emit(e.RoomEvent.RecordingStatusChanged,t.activeRecording)),this.metadata!==t.metadata&&(this.metadata=t.metadata,this.emitWhenConnected(e.RoomEvent.RoomMetadataChanged,t.metadata))},this.handleConnectionQualityUpdate=e=>{e.updates.forEach((e=>{if(e.participantSid===this.localParticipant.sid)return void this.localParticipant.setConnectionQuality(e.quality);const t=this.participants.get(e.participantSid);t&&t.setConnectionQuality(e.quality)}))},this.onLocalParticipantMetadataChanged=t=>{this.emit(e.RoomEvent.ParticipantMetadataChanged,t,this.localParticipant)},this.onLocalTrackMuted=t=>{this.emit(e.RoomEvent.TrackMuted,t,this.localParticipant)},this.onLocalTrackUnmuted=t=>{this.emit(e.RoomEvent.TrackUnmuted,t,this.localParticipant)},this.onLocalTrackPublished=t=>{this.emit(e.RoomEvent.LocalTrackPublished,t,this.localParticipant)},this.onLocalTrackUnpublished=t=>{this.emit(e.RoomEvent.LocalTrackUnpublished,t,this.localParticipant)},this.onLocalConnectionQualityChanged=t=>{this.emit(e.RoomEvent.ConnectionQualityChanged,t,this.localParticipant)},this.onMediaDevicesError=t=>{this.emit(e.RoomEvent.MediaDevicesError,t)},this.onLocalParticipantPermissionsChanged=t=>{this.emit(e.RoomEvent.ParticipantPermissionsChanged,t,this.localParticipant)},this.setMaxListeners(100),this.participants=new Map,this.identityToSid=new Map,this.options=Wt(Wt({},Gs),t),this.options.audioCaptureDefaults=Wt(Wt({},qs),null==t?void 0:t.audioCaptureDefaults),this.options.videoCaptureDefaults=Wt(Wt({},Ws),null==t?void 0:t.videoCaptureDefaults),this.options.publishDefaults=Wt(Wt({},Fs),null==t?void 0:t.publishDefaults),this.maybeCreateEngine(),this.disconnectLock=new Ir,this.localParticipant=new Js("","",this.engine,this.options)}maybeCreateEngine(){this.engine||(this.engine=new fa(this.options),this.engine.client.onParticipantUpdate=this.handleParticipantUpdates,this.engine.client.onRoomUpdate=this.handleRoomUpdate,this.engine.client.onSpeakersChanged=this.handleSpeakersChanged,this.engine.client.onStreamStateUpdate=this.handleStreamStateUpdate,this.engine.client.onSubscriptionPermissionUpdate=this.handleSubscriptionPermissionUpdate,this.engine.client.onConnectionQuality=this.handleConnectionQualityUpdate,this.engine.on(e.EngineEvent.MediaTrackAdded,((e,t,i)=>{this.onTrackAdded(e,t,i)})).on(e.EngineEvent.Disconnected,(e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)})).on(e.EngineEvent.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(e.EngineEvent.DataPacketReceived,this.handleDataPacket).on(e.EngineEvent.Resuming,(()=>{this.setAndEmitConnectionState(e.ConnectionState.Reconnecting)&&this.emit(e.RoomEvent.Reconnecting)})).on(e.EngineEvent.Resumed,(()=>{this.setAndEmitConnectionState(e.ConnectionState.Connected),this.emit(e.RoomEvent.Reconnected),this.updateSubscriptions()})).on(e.EngineEvent.SignalResumed,(()=>{this.state===e.ConnectionState.Reconnecting&&this.sendSyncState()})).on(e.EngineEvent.Restarting,this.handleRestarting).on(e.EngineEvent.Restarted,this.handleRestarted),this.localParticipant&&this.localParticipant.setupEngine(this.engine))}static getLocalDevices(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Mr.getInstance().getDevices(e,t)}async prepareConnection(e){await fetch("http".concat(e.substring(2)),{method:"HEAD"})}getParticipantByIdentity(e){if(this.localParticipant.identity===e)return this.localParticipant;const t=this.identityToSid.get(e);return t?this.participants.get(t):void 0}clearConnectionFutures(){this.connectFuture=void 0}get isRecording(){return this._isRecording}async simulateScenario(t){let i,n=()=>{};switch(t){case"signal-reconnect":await this.engine.client.close(),this.engine.client.onClose&&this.engine.client.onClose("simulate disconnect");break;case"speaker":i=_n.fromPartial({scenario:{$case:"speakerUpdate",speakerUpdate:3}});break;case"node-failure":i=_n.fromPartial({scenario:{$case:"nodeFailure",nodeFailure:!0}});break;case"server-leave":i=_n.fromPartial({scenario:{$case:"serverLeave",serverLeave:!0}});break;case"migration":i=_n.fromPartial({scenario:{$case:"migration",migration:!0}});break;case"force-tcp":case"force-tls":i=_n.fromPartial({scenario:{$case:"switchCandidateProtocol",switchCandidateProtocol:"force-tls"===t?2:1}}),n=async()=>{const t=this.engine.client.onLeave;t&&t({reason:e.DisconnectReason.CLIENT_INITIATED,canReconnect:!0})}}i&&(this.engine.client.sendSimulateScenario(i),n())}async startAudio(){await this.acquireAudioContext();const e=[];this.participants.forEach((t=>{t.audioTracks.forEach((t=>{t.track&&t.track.attachedElements.forEach((t=>{e.push(t)}))}))}));try{await Promise.all(e.map((e=>(e.muted=!1,e.play())))),this.handleAudioPlaybackStarted()}catch(e){throw this.handleAudioPlaybackFailed(e),e}}get canPlaybackAudio(){return this.audioEnabled}getActiveAudioOutputDevice(){var e,t;return null!==(t=null===(e=this.options.audioOutput)||void 0===e?void 0:e.deviceId)&&void 0!==t?t:""}async switchActiveDevice(e,t){var i,n;if("audioinput"===e){const e=this.options.audioCaptureDefaults.deviceId;this.options.audioCaptureDefaults.deviceId=t;const i=Array.from(this.localParticipant.audioTracks.values()).filter((e=>e.source===Xr.Source.Microphone));try{await Promise.all(i.map((e=>{var i;return null===(i=e.audioTrack)||void 0===i?void 0:i.setDeviceId(t)})))}catch(t){throw this.options.audioCaptureDefaults.deviceId=e,t}}else if("videoinput"===e){const e=this.options.videoCaptureDefaults.deviceId;this.options.videoCaptureDefaults.deviceId=t;const i=Array.from(this.localParticipant.videoTracks.values()).filter((e=>e.source===Xr.Source.Camera));try{await Promise.all(i.map((e=>{var i;return null===(i=e.videoTrack)||void 0===i?void 0:i.setDeviceId(t)})))}catch(t){throw this.options.videoCaptureDefaults.deviceId=e,t}}else if("audiooutput"===e){if(!hr())throw new Error("cannot switch audio output, setSinkId not supported");null!==(i=(n=this.options).audioOutput)&&void 0!==i||(n.audioOutput={});const e=this.options.audioOutput.deviceId;this.options.audioOutput.deviceId=t;try{await Promise.all(Array.from(this.participants.values()).map((e=>e.setAudioOutput({deviceId:t}))))}catch(t){throw this.options.audioOutput.deviceId=e,t}}}setupLocalParticipantEvents(){this.localParticipant.on(e.ParticipantEvent.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(e.ParticipantEvent.TrackMuted,this.onLocalTrackMuted).on(e.ParticipantEvent.TrackUnmuted,this.onLocalTrackUnmuted).on(e.ParticipantEvent.LocalTrackPublished,this.onLocalTrackPublished).on(e.ParticipantEvent.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(e.ParticipantEvent.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(e.ParticipantEvent.MediaDevicesError,this.onMediaDevicesError).on(e.ParticipantEvent.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged)}recreateEngine(){var e;null===(e=this.engine)||void 0===e||e.close(),this.engine=void 0,this.participants.clear(),this.maybeCreateEngine()}onTrackAdded(t,i,n){if(this.state===e.ConnectionState.Connecting||this.state===e.ConnectionState.Reconnecting){const r=()=>{this.onTrackAdded(t,i,n),s()},s=()=>{this.off(e.RoomEvent.Reconnected,r),this.off(e.RoomEvent.Connected,r),this.off(e.RoomEvent.Disconnected,s)};return this.once(e.RoomEvent.Reconnected,r),this.once(e.RoomEvent.Connected,r),void this.once(e.RoomEvent.Disconnected,s)}if(this.state===e.ConnectionState.Disconnected)return void a.warn("skipping incoming track after Room disconnected");const r=function(e){const t=e.split("|");return t.length>1?[t[0],e.substr(t[0].length+1)]:[e,""]}(i.id),s=r[0];let o=r[1];if(o&&""!==o||(o=t.id),s===this.localParticipant.sid)return void a.warn("tried to create RemoteParticipant for local participant");const c=this.getOrCreateParticipant(s);let d;this.options.adaptiveStream&&(d="object"==typeof this.options.adaptiveStream?this.options.adaptiveStream:{}),c.addSubscribedMediaTrack(t,o,i,n,d)}handleDisconnect(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],i=arguments.length>1?arguments[1]:void 0;var n;this.state!==e.ConnectionState.Disconnected&&(this.participants.forEach((e=>{e.tracks.forEach((t=>{e.unpublishTrack(t.trackSid)}))})),this.localParticipant.tracks.forEach((e=>{var i,n;e.track&&this.localParticipant.unpublishTrack(e.track,t),t&&(null===(i=e.track)||void 0===i||i.detach(),null===(n=e.track)||void 0===n||n.stop())})),this.localParticipant.off(e.ParticipantEvent.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(e.ParticipantEvent.TrackMuted,this.onLocalTrackMuted).off(e.ParticipantEvent.TrackUnmuted,this.onLocalTrackUnmuted).off(e.ParticipantEvent.LocalTrackPublished,this.onLocalTrackPublished).off(e.ParticipantEvent.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(e.ParticipantEvent.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(e.ParticipantEvent.MediaDevicesError,this.onMediaDevicesError).off(e.ParticipantEvent.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged),this.localParticipant.tracks.clear(),this.localParticipant.videoTracks.clear(),this.localParticipant.audioTracks.clear(),this.participants.clear(),this.activeSpeakers=[],this.audioContext&&"boolean"==typeof this.options.expWebAudioMix&&(this.audioContext.close(),this.audioContext=void 0),br()&&(window.removeEventListener("beforeunload",this.onBeforeUnload),null===(n=navigator.mediaDevices)||void 0===n||n.removeEventListener("devicechange",this.handleDeviceChange)),this.setAndEmitConnectionState(e.ConnectionState.Disconnected),this.emit(e.RoomEvent.Disconnected,i))}handleParticipantDisconnected(t,i){this.participants.delete(t),i&&(this.identityToSid.delete(i.identity),i.tracks.forEach((e=>{i.unpublishTrack(e.trackSid,!0)})),this.emitWhenConnected(e.RoomEvent.ParticipantDisconnected,i))}async acquireAudioContext(){var t,i;"boolean"!=typeof this.options.expWebAudioMix&&this.options.expWebAudioMix.audioContext?(this.audioContext=this.options.expWebAudioMix.audioContext,await this.audioContext.resume()):this.audioContext=null!==(t=or())&&void 0!==t?t:void 0,this.options.expWebAudioMix&&this.participants.forEach((e=>e.setAudioContext(this.audioContext)));const n="running"===(null===(i=this.audioContext)||void 0===i?void 0:i.state);n!==this.canPlaybackAudio&&(this.audioEnabled=n,this.emit(e.RoomEvent.AudioPlaybackStatusChanged,n))}createParticipant(e,t){let i;return i=t?_s.fromParticipantInfo(this.engine.client,t):new _s(this.engine.client,e,"",void 0,void 0),this.options.expWebAudioMix&&i.setAudioContext(this.audioContext),i}getOrCreateParticipant(t,i){if(this.participants.has(t))return this.participants.get(t);const n=this.createParticipant(t,i);return this.participants.set(t,n),i&&(this.identityToSid.set(i.identity,i.sid),this.emitWhenConnected(e.RoomEvent.ParticipantConnected,n)),n.on(e.ParticipantEvent.TrackPublished,(t=>{this.emitWhenConnected(e.RoomEvent.TrackPublished,t,n)})).on(e.ParticipantEvent.TrackSubscribed,((t,i)=>{t.kind===Xr.Kind.Audio&&(t.on(e.TrackEvent.AudioPlaybackStarted,this.handleAudioPlaybackStarted),t.on(e.TrackEvent.AudioPlaybackFailed,this.handleAudioPlaybackFailed)),this.emit(e.RoomEvent.TrackSubscribed,t,i,n)})).on(e.ParticipantEvent.TrackUnpublished,(t=>{this.emitWhenConnected(e.RoomEvent.TrackUnpublished,t,n)})).on(e.ParticipantEvent.TrackUnsubscribed,((t,i)=>{this.emit(e.RoomEvent.TrackUnsubscribed,t,i,n)})).on(e.ParticipantEvent.TrackSubscriptionFailed,(t=>{this.emit(e.RoomEvent.TrackSubscriptionFailed,t,n)})).on(e.ParticipantEvent.TrackMuted,(t=>{this.emitWhenConnected(e.RoomEvent.TrackMuted,t,n)})).on(e.ParticipantEvent.TrackUnmuted,(t=>{this.emitWhenConnected(e.RoomEvent.TrackUnmuted,t,n)})).on(e.ParticipantEvent.ParticipantMetadataChanged,(t=>{this.emitWhenConnected(e.RoomEvent.ParticipantMetadataChanged,t,n)})).on(e.ParticipantEvent.ConnectionQualityChanged,(t=>{this.emitWhenConnected(e.RoomEvent.ConnectionQualityChanged,t,n)})).on(e.ParticipantEvent.ParticipantPermissionsChanged,(t=>{this.emitWhenConnected(e.RoomEvent.ParticipantPermissionsChanged,t,n)})).on(e.ParticipantEvent.TrackSubscriptionStatusChanged,((t,i)=>{this.emitWhenConnected(e.RoomEvent.TrackSubscriptionStatusChanged,t,i,n)})).on(e.ParticipantEvent.TrackSubscriptionPermissionChanged,((t,i)=>{this.emitWhenConnected(e.RoomEvent.TrackSubscriptionPermissionChanged,t,i,n)})),i&&n.updateInfo(i),n}sendSyncState(){var e,t;if(void 0===this.engine.subscriber||null===this.engine.subscriber.pc.localDescription)return;const i=this.engine.subscriber.pc.localDescription,n=this.engine.subscriber.pc.remoteDescription,r=null===(t=null===(e=this.connOptions)||void 0===e?void 0:e.autoSubscribe)||void 0===t||t,s=new Array;this.participants.forEach((e=>{e.tracks.forEach((e=>{e.isDesired!==r&&s.push(e.trackSid)}))})),this.engine.client.sendSyncState({answer:Vs({sdp:i.sdp,type:i.type}),offer:n?Vs({sdp:n.sdp,type:n.type}):void 0,subscription:{trackSids:s,subscribe:!r,participantTracks:[]},publishTracks:this.localParticipant.publishedTracksInfo(),dataChannels:this.localParticipant.dataChannelsInfo()})}updateSubscriptions(){for(const e of this.participants.values())for(const t of e.videoTracks.values())t.isSubscribed&&t instanceof xs&&t.emitTrackUpdate()}setAndEmitConnectionState(t){return t!==this.state&&(this.state=t,this.emit(e.RoomEvent.ConnectionStateChanged,this.state),!0)}emitWhenConnected(t){if(this.state===e.ConnectionState.Connected){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return this.emit(t,...n)}return!1}async simulateParticipants(t){var i,n;const r=Wt({audio:!0,video:!0,useRealTracks:!1},t.publish),s=Wt({count:9,audio:!1,video:!0,aspectRatios:[1.66,1.7,1.3]},t.participants);if(this.handleDisconnect(),this.name="simulated-room",this.localParticipant.updateInfo(yt.fromPartial({identity:"simulated-local",name:"local-name"})),this.setupLocalParticipantEvents(),this.emit(e.RoomEvent.SignalConnected),this.emit(e.RoomEvent.Connected),this.setAndEmitConnectionState(e.ConnectionState.Connected),r.video){const t=new vs(Xr.Kind.Video,wt.fromPartial({source:qe.CAMERA,sid:Math.floor(1e4*Math.random()).toString(),type:Fe.AUDIO,name:"video-dummy"}),new rs(r.useRealTracks?(await navigator.mediaDevices.getUserMedia({video:!0})).getVideoTracks()[0]:Or(null!==(i=160*s.aspectRatios[0])&&void 0!==i?i:1,160,!0,!0)));this.localParticipant.addTrackPublication(t),this.localParticipant.emit(e.ParticipantEvent.LocalTrackPublished,t)}if(r.audio){const t=new vs(Xr.Kind.Audio,wt.fromPartial({source:qe.MICROPHONE,sid:Math.floor(1e4*Math.random()).toString(),type:Fe.AUDIO}),new ns(r.useRealTracks?(await navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:Nr()));this.localParticipant.addTrackPublication(t),this.localParticipant.emit(e.ParticipantEvent.LocalTrackPublished,t)}for(let e=0;e<s.count-1;e+=1){let t=yt.fromPartial({sid:Math.floor(1e4*Math.random()).toString(),identity:"simulated-".concat(e),state:He.ACTIVE,tracks:[],joinedAt:Date.now()});const i=this.getOrCreateParticipant(t.identity,t);if(s.video){const r=Or(null!==(n=160*s.aspectRatios[e%s.aspectRatios.length])&&void 0!==n?n:1,160,!1,!0),a=wt.fromPartial({source:qe.CAMERA,sid:Math.floor(1e4*Math.random()).toString(),type:Fe.AUDIO});i.addSubscribedMediaTrack(r,a.sid,new MediaStream([r])),t.tracks=[...t.tracks,a]}if(s.audio){const e=Nr(),n=wt.fromPartial({source:qe.MICROPHONE,sid:Math.floor(1e4*Math.random()).toString(),type:Fe.AUDIO});i.addSubscribedMediaTrack(e,n.sid,new MediaStream([e])),t.tracks=[...t.tracks,n]}i.updateInfo(t)}}emit(t){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];return t!==e.RoomEvent.ActiveSpeakersChanged&&a.debug("room event ".concat(t),{event:t,args:n}),super.emit(t,...n)}}async function Sa(e){var t,i;null!=e||(e={}),null!==(t=e.audio)&&void 0!==t||(e.audio=!0),null!==(i=e.video)&&void 0!==i||(e.video=!0);const n=ar(rr(e,qs,Ws)),r=navigator.mediaDevices.getUserMedia(n);e.audio&&(Mr.userMediaPromiseMap.set("audioinput",r),r.catch((()=>Mr.userMediaPromiseMap.delete("audioinput")))),e.video&&(Mr.userMediaPromiseMap.set("videoinput",r),r.catch((()=>Mr.userMediaPromiseMap.delete("videoinput"))));const s=await r;return s.getTracks().map((t=>{const i="audio"===t.kind;let r;i?e.audio:e.video;const a=i?n.audio:n.video;"boolean"!=typeof a&&(r=a);const o=Ts(t,r);return o.kind===Xr.Kind.Video?o.source=Xr.Source.Camera:o.kind===Xr.Kind.Audio&&(o.source=Xr.Source.Microphone),o.mediaStream=s,o}))}async function wa(e){return(await Sa({audio:!1,video:e}))[0]}async function Ca(e){return(await Sa({audio:e,video:!1}))[0]}var Ta;!function(e){e[e.IDLE=0]="IDLE",e[e.RUNNING=1]="RUNNING",e[e.SKIPPED=2]="SKIPPED",e[e.SUCCESS=3]="SUCCESS",e[e.FAILED=4]="FAILED"}(Ta||(Ta={}));class Ea extends xr.EventEmitter{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(),this.status=Ta.IDLE,this.logs=[],this.errorsAsWarnings=!1,this.url=e,this.token=t,this.name=this.constructor.name,this.room=new ya(i.roomOptions),this.connectOptions=i.connectOptions,i.errorsAsWarnings&&(this.errorsAsWarnings=i.errorsAsWarnings)}async run(e){if(this.status!==Ta.IDLE)throw Error("check is running already");this.setStatus(Ta.RUNNING),this.appendMessage("".concat(this.name," started."));try{await this.perform()}catch(e){e instanceof Error&&(this.errorsAsWarnings?this.appendWarning(e.message):this.appendError(e.message))}return await this.disconnect(),await new Promise((e=>setTimeout(e,500))),this.status!==Ta.SKIPPED&&this.setStatus(this.isSuccess()?Ta.SUCCESS:Ta.FAILED),e&&e(),this.getInfo()}isSuccess(){return!this.logs.some((e=>"error"===e.level))}async connect(){return this.room.state===e.ConnectionState.Connected||await this.room.connect(this.url,this.token),this.room}async disconnect(){this.room&&this.room.state!==e.ConnectionState.Disconnected&&(await this.room.disconnect(),await new Promise((e=>setTimeout(e,500))))}skip(){this.setStatus(Ta.SKIPPED)}appendMessage(e){this.logs.push({level:"info",message:e}),this.emit("update",this.getInfo())}appendWarning(e){this.logs.push({level:"warning",message:e}),this.emit("update",this.getInfo())}appendError(e){this.logs.push({level:"error",message:e}),this.emit("update",this.getInfo())}setStatus(e){this.status=e,this.emit("update",this.getInfo())}get engine(){var e;return null===(e=this.room)||void 0===e?void 0:e.engine}getInfo(){return{logs:this.logs,name:this.name,status:this.status,description:this.description}}}class Pa extends Ea{get description(){return"Can publish audio"}async perform(){var e;const t=await this.connect(),i=await Ca();t.localParticipant.publishTrack(i),await new Promise((e=>setTimeout(e,3e3)));const n=await(null===(e=i.sender)||void 0===e?void 0:e.getStats());if(!n)throw new Error("Could not get RTCStats");let r=0;if(n.forEach((e=>{"outbound-rtp"===e.type&&"audio"===e.mediaType&&(r=e.packetsSent)})),0===r)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(r," audio packets"))}}class Ra extends Ea{get description(){return"Can publish video"}async perform(){var e;const t=await this.connect(),i=await wa();t.localParticipant.publishTrack(i),await new Promise((e=>setTimeout(e,3e3)));const n=await(null===(e=i.sender)||void 0===e?void 0:e.getStats());if(!n)throw new Error("Could not get RTCStats");let r=0;if(n.forEach((e=>{"outbound-rtp"===e.type&&"video"===e.mediaType&&(r=e.packetsSent)})),0===r)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(r," video packets"))}}class Oa extends Ea{get description(){return"Resuming connection after interruption"}async perform(){var t;const i=await this.connect();let n,r=!1,s=!1;const a=new Promise((e=>{setTimeout(e,5e3),n=e}));i.on(e.RoomEvent.Reconnecting,(()=>{r=!0})).on(e.RoomEvent.Reconnected,(()=>{s=!0,n(!0)})),null===(t=i.engine.client.ws)||void 0===t||t.close();const o=i.engine.client.onClose;if(o&&o(""),await a,!r)throw new Error("Did not attempt to reconnect");if(!s||i.state!==e.ConnectionState.Connected)throw this.appendWarning("reconnection is only possible in Redis-based configurations"),new Error("Not able to reconnect")}}class Na extends Ea{get description(){return"Can connect via TURN"}async perform(){var e,t;const i=new Bs,n=await i.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0});let r=!1,s=!1,a=!1;for(let e of n.iceServers)for(let t of e.urls)t.startsWith("turn:")?(s=!0,a=!0):t.startsWith("turns:")&&(s=!0,a=!0,r=!0),t.startsWith("stun:")&&(a=!0);a?s&&!r&&this.appendWarning("TURN is configured server side, but TURN/TLS is unavailable."):this.appendWarning("No STUN servers configured on server side."),await i.close(),(null===(t=null===(e=this.connectOptions)||void 0===e?void 0:e.rtcConfig)||void 0===t?void 0:t.iceServers)||s?await this.room.connect(this.url,this.token,{rtcConfig:{iceTransportPolicy:"relay"}}):(this.appendWarning("No TURN servers configured."),this.skip(),await new Promise((e=>setTimeout(e,0))))}}class Da extends Ea{get description(){return"Establishing WebRTC connection"}async perform(){try{console.log("initiating room connection"),this.room=await this.connect(),console.log("now the room is connected")}catch(e){throw this.appendWarning("ports need to be open on firewall in order to connect."),e}}}class Ia extends Ea{get description(){return"Connecting to signal connection via WebSocket"}async perform(){(this.url.startsWith("ws:")||this.url.startsWith("http:"))&&this.appendWarning("Server is insecure, clients may block connections to it");let e=new Bs;const t=await e.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0});this.appendMessage("Connected to server, version ".concat(t.serverVersion,".")),await e.close()}}e.ConnectionCheck=class extends xr{constructor(e,t){super(),this.checkResults=new Map,this.url=e,this.token=t}getNextCheckId(){const e=this.checkResults.size;return this.checkResults.set(e,{logs:[],status:Ta.IDLE,name:"",description:""}),e}updateCheck(e,t){this.checkResults.set(e,t),this.emit("checkUpdate",e,t)}isSuccess(){return Array.from(this.checkResults.values()).every((e=>e.status!==Ta.FAILED))}getResults(){return Array.from(this.checkResults.values())}async createAndRunCheck(e){const t=this.getNextCheckId(),i=new e(this.url,this.token),n=e=>{this.updateCheck(t,e)};i.on("update",n);const r=await i.run();return i.off("update",n),r}async checkWebsocket(){return this.createAndRunCheck(Ia)}async checkWebRTC(){return this.createAndRunCheck(Da)}async checkTURN(){return this.createAndRunCheck(Na)}async checkReconnect(){return this.createAndRunCheck(Oa)}async checkPublishAudio(){return this.createAndRunCheck(Pa)}async checkPublishVideo(){return this.createAndRunCheck(Ra)}},e.ConnectionError=Qn,e.CriticalTimers=ls,e.DefaultReconnectPolicy=jt,e.DeviceUnsupportedError=zn,e.LivekitError=Gn,e.LocalAudioTrack=ns,e.LocalParticipant=Js,e.LocalTrack=is,e.LocalTrackPublication=vs,e.LocalVideoTrack=rs,e.NegotiationError=Yn,e.Participant=Cs,e.PublishDataError=class extends Gn{constructor(e){super(13,null!=e?e:"unable to publish data")}},e.RemoteAudioTrack=ds,e.RemoteParticipant=_s,e.RemoteTrack=cs,e.RemoteTrackPublication=xs,e.RemoteVideoTrack=hs,e.Room=ya,e.RoomState=ka,e.ScreenSharePresets=ws,e.Track=Xr,e.TrackInvalidError=Hn,e.TrackPublication=ms,e.UnexpectedConnectionState=Kn,e.UnsupportedServer=Zn,e.VideoPreset=fs,e.VideoPresets=ys,e.VideoPresets43=Ss,e.attachToElement=es,e.createAudioAnalyser=function(e,t){const i=Wt({cloneTrack:!1,fftSize:2048,smoothingTimeConstant:.8,minDecibels:-100,maxDecibels:-80},t),n=or();if(!n)throw new Error("Audio Context not supported on this browser");const r=i.cloneTrack?e.mediaStreamTrack.clone():e.mediaStreamTrack,s=n.createMediaStreamSource(new MediaStream([r])),a=n.createAnalyser();a.minDecibels=i.minDecibels,a.maxDecibels=i.maxDecibels,a.fftSize=i.fftSize,a.smoothingTimeConstant=i.smoothingTimeConstant,s.connect(a);const o=new Uint8Array(a.frequencyBinCount);return{calculateVolume:()=>{a.getByteFrequencyData(o);let e=0;for(const t of o)e+=Math.pow(t/255,2);return Math.sqrt(e/o.length)},analyser:a,cleanup:()=>{n.close(),i.cloneTrack&&r.stop()}}},e.createLocalAudioTrack=Ca,e.createLocalScreenTracks=async function(e){var t;void 0===e&&(e={}),void 0===e.resolution&&(e.resolution=ys.h1080.resolution);let i=!0;if(e.resolution&&(i={width:e.resolution.width,height:e.resolution.height}),void 0===navigator.mediaDevices.getDisplayMedia)throw new zn("getDisplayMedia not supported");const n=await navigator.mediaDevices.getDisplayMedia({audio:null!==(t=e.audio)&&void 0!==t&&t,video:i}),r=n.getVideoTracks();if(0===r.length)throw new Hn("no video track found");const s=new rs(r[0],void 0,!1);s.source=Xr.Source.ScreenShare;const a=[s];if(n.getAudioTracks().length>0){const e=new ns(n.getAudioTracks()[0],void 0,!1);e.source=Xr.Source.ScreenShareAudio,a.push(e)}return a},e.createLocalTracks=Sa,e.createLocalVideoTrack=wa,e.detachTrack=ts,e.getEmptyAudioStreamTrack=Nr,e.getEmptyVideoStreamTrack=Rr,e.isBackupCodec=bs,e.isBrowserSupported=function(){return dr()||ur()},e.protocolVersion=8,e.setLogExtension=function(t){const i=a.methodFactory;a.methodFactory=(n,r,s)=>{const o=i(n,r,s),c=a.getLevel(),d=r>=c&&r<e.LogLevel.silent;return(e,i)=>{i?o(e,i):o(e),d&&t(r,e,i)}},a.setLevel(a.getLevel())},e.setLogLevel=function(e){a.setLevel(e)},e.supportsAV1=lr,e.supportsAdaptiveStream=function(){return void 0!==typeof ResizeObserver&&void 0!==typeof IntersectionObserver},e.supportsDynacast=function(){return dr()},e.version=nr}));
|
2
2
|
//# sourceMappingURL=livekit-client.umd.js.map
|