UNPKG

@millicast/sdk

Version:

SDK for building a realtime broadcaster using the Millicast platform.

7 lines 2.19 MB
(function(Ye,_e){typeof exports=="object"&&typeof module<"u"?_e(exports):typeof define=="function"&&define.amd?define(["exports"],_e):(Ye=typeof globalThis<"u"?globalThis:Ye||self,_e(Ye["millicast-debug"]={}))})(this,function(Ye){"use strict";var Fi;var _e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ut(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Pr={exports:{}};/*! * js-logger - http://github.com/jonnyreeves/js-logger * Jonny Reeves, http://jonnyreeves.co.uk/ * js-logger may be freely distributed under the MIT license. */(function(n){(function(e){var t={};t.VERSION="1.6.1";var s,V={},u=function(p,o){return function(){return o.apply(p,arguments)}},h=function(){var p=arguments,o=p[0],l,c;for(c=1;c<p.length;c++)for(l in p[c])!(l in o)&&p[c].hasOwnProperty(l)&&(o[l]=p[c][l]);return o},r=function(p,o){return{value:p,name:o}};t.TRACE=r(1,"TRACE"),t.DEBUG=r(2,"DEBUG"),t.INFO=r(3,"INFO"),t.TIME=r(4,"TIME"),t.WARN=r(5,"WARN"),t.ERROR=r(8,"ERROR"),t.OFF=r(99,"OFF");var U=function(p){this.context=p,this.setLevel(p.filterLevel),this.log=this.info};U.prototype={setLevel:function(p){p&&"value"in p&&(this.context.filterLevel=p)},getLevel:function(){return this.context.filterLevel},enabledFor:function(p){var o=this.context.filterLevel;return p.value>=o.value},trace:function(){this.invoke(t.TRACE,arguments)},debug:function(){this.invoke(t.DEBUG,arguments)},info:function(){this.invoke(t.INFO,arguments)},warn:function(){this.invoke(t.WARN,arguments)},error:function(){this.invoke(t.ERROR,arguments)},time:function(p){typeof p=="string"&&p.length>0&&this.invoke(t.TIME,[p,"start"])},timeEnd:function(p){typeof p=="string"&&p.length>0&&this.invoke(t.TIME,[p,"end"])},invoke:function(p,o){s&&this.enabledFor(p)&&s(o,h({level:p},this.context))}};var f=new U({filterLevel:t.OFF});(function(){var p=t;p.enabledFor=u(f,f.enabledFor),p.trace=u(f,f.trace),p.debug=u(f,f.debug),p.time=u(f,f.time),p.timeEnd=u(f,f.timeEnd),p.info=u(f,f.info),p.warn=u(f,f.warn),p.error=u(f,f.error),p.log=p.info})(),t.setHandler=function(p){s=p},t.setLevel=function(p){f.setLevel(p);for(var o in V)V.hasOwnProperty(o)&&V[o].setLevel(p)},t.getLevel=function(){return f.getLevel()},t.get=function(p){return V[p]||(V[p]=new U(h({name:p},f.context)))},t.createDefaultHandler=function(p){p=p||{},p.formatter=p.formatter||function(i,a){a.name&&i.unshift("["+a.name+"]")};var o={},l=function(c,i){Function.prototype.apply.call(c,console,i)};return typeof console>"u"?function(){}:function(c,i){c=Array.prototype.slice.call(c);var a=console.log,m;i.level===t.TIME?(m=(i.name?"["+i.name+"] ":"")+c[0],c[1]==="start"?console.time?console.time(m):o[m]=new Date().getTime():console.timeEnd?console.timeEnd(m):l(a,[m+": "+(new Date().getTime()-o[m])+"ms"])):(i.level===t.WARN&&console.warn?a=console.warn:i.level===t.ERROR&&console.error?a=console.error:i.level===t.INFO&&console.info?a=console.info:i.level===t.DEBUG&&console.debug?a=console.debug:i.level===t.TRACE&&console.trace&&(a=console.trace),p.formatter(c,i),l(a,c))}},t.useDefaults=function(p){t.setLevel(p&&p.defaultLevel||t.DEBUG),t.setHandler(t.createDefaultHandler(p))},t.setDefaults=t.useDefaults,n.exports?n.exports=t:(t._prevLogger=e.Logger,t.noConflict=function(){return e.Logger=t._prevLogger,t},e.Logger=t)})(_e)})(Pr);var Ci=Pr.exports;const qe=ut(Ci),$r="0.4.0",qt=60,Ii=((Fi=window==null?void 0:window.navigator)==null?void 0:Fi.userAgent)||"No user agent available";let en="",tn="",nn="",gt="",yt="",qr="",rn="",sn=0;const an=[];function ji(n){function e(t,s){return{ts:Math.round(s.timestamp)||"",ot:t==="audio"?"a":"v",bl:s.jitterBufferDelay||0,br:Math.round(s.bitrateBitsPerSecond||0),pld:s.packetsLostDeltaPerSecond||0,j:s.jitter||0,mtp:s.packetRate||0,mid:s.mid||"",mimeType:s.mimeType||""}}return n.stats=n.stats.reduce((t,s)=>{const V=s.audio.inbounds.length!==0?s.audio.inbounds.map(h=>e("audio",h)):s.audio.outbounds.map(h=>e("audio",h)),u=s.video.inbounds.length!==0?s.video.inbounds.map(h=>e("video",h)):s.video.outbounds.map(h=>e("video",h));return t.concat([...V,...u])},[]),n}const Ne={initAccountId:n=>{en=en===""?n:en},initStreamName:n=>{tn=tn===""?n:tn},initSubscriberId:n=>{nn=nn===""?n:nn},initStreamViewId:n=>{gt=gt===""?n:gt},initFeedId:n=>{yt=yt===""?n:yt},setConnectionTime:n=>{sn=sn===0?n:sn},setConnectionState:n=>{qr=n},setClusterId:n=>{rn=rn===""?n:rn},addStats:n=>{an.length===qt&&an.shift(),an.push(n)},get:(n=qt,e="JSON")=>{let t;!Number.isInteger(n)||n>qt||n<=0?t=qt:t=n;const s={client:"@millicast/millicast-sdk",version:$r,timestamp:new Date().toISOString(),userAgent:Ii,clusterId:rn,accountId:en,streamName:tn,subscriberId:nn,connection:qr,stats:an.slice(-t),connectionDurationMs:new Date().getTime()-sn};return yt!==""?s.feedId=yt:gt!==""&&(s.streamViewId=gt),e==="CMCD"?ji(s):s}};qe.useDefaults({defaultLevel:qe.TRACE});const on=["TRACE","DEBUG","INFO","WARN","ERROR"],es=(n,e)=>{n.unshift(`[${e.name||"Global"}] ${new Date().toISOString()} - ${e.level.name} -`)},ts=(n,e)=>e?n.value>=et[e].value:n.value>=ln.value,Xi=(n,e)=>{n=Array.prototype.slice.call(n),n=n.map(t=>typeof t=="object"?JSON.stringify(t):t),es(n,e),Jt!==0?(mt.push(n.join(" ")),mt.length>=Jt&&(mt=mt.slice(-Jt))):mt=[]},Bi=qe.createDefaultHandler({formatter:es});qe.setHandler((n,e)=>{Xi(n,e),ts(e.level,e.name)&&Bi(n,e);for(const{handler:t,level:s}of ns)e.level.value>=s.value&&t(n,e)});let Jt=1e4,mt=[],ln=qe.OFF;const et={},ns=[],je={...qe,enabledFor:ts,getHistory:()=>mt,getHistoryMaxSize:()=>Jt,setHistoryMaxSize:n=>{Jt=n},setLevel:n=>{ln=n;for(const e in et)et[e]=n},getLevel:()=>ln,get:n=>{et[n]||(et[n]=ln);const e=qe.get(n);return e.setLevel=t=>{et[n]=t},e.getLevel=()=>et[n],e},setHandler:(n,e)=>{ns.push({handler:n,level:e})},diagnose:(n={})=>{let e;const t={statsCount:60,historySize:1e3,minLogLevel:"TRACE",statsFormat:"JSON"};typeof n=="number"?(t.statsCount=n,e=t):e={...t,...n};const{statsCount:s,historySize:V,minLogLevel:u,statsFormat:h}=e,r=Ne.get(s,h),U=je.getHistory();if(!Number.isInteger(V)||V<=0)throw new Error("Invalid Argument Exception : historySize must be a positive integer.");if(!on.includes(u.toUpperCase()))throw new Error('Invalid Argument Exception : the minLogLevel parameter only excepts "trace", "debug", "info", "warn", and "error" as arguments.');if(on.includes(u.toUpperCase())){const f=on.slice(on.indexOf(u.toUpperCase())),p=U.filter(o=>f.some(l=>o.includes(l)));r.history=p.slice(-V)}return r},JSON:"JSON",CMCD:"CMCD",VERSION:$r};var xn={exports:{}},pt=typeof Reflect=="object"?Reflect:null,rs=pt&&typeof pt.apply=="function"?pt.apply:function(e,t,s){return Function.prototype.apply.call(e,t,s)},cn;pt&&typeof pt.ownKeys=="function"?cn=pt.ownKeys:Object.getOwnPropertySymbols?cn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:cn=function(e){return Object.getOwnPropertyNames(e)};function Di(n){console&&console.warn&&console.warn(n)}var ss=Number.isNaN||function(e){return e!==e};function ee(){ee.init.call(this)}xn.exports=ee,xn.exports.once=_i,ee.EventEmitter=ee,ee.prototype._events=void 0,ee.prototype._eventsCount=0,ee.prototype._maxListeners=void 0;var is=10;function dn(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(ee,"defaultMaxListeners",{enumerable:!0,get:function(){return is},set:function(n){if(typeof n!="number"||n<0||ss(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");is=n}}),ee.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},ee.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||ss(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};function as(n){return n._maxListeners===void 0?ee.defaultMaxListeners:n._maxListeners}ee.prototype.getMaxListeners=function(){return as(this)},ee.prototype.emit=function(e){for(var t=[],s=1;s<arguments.length;s++)t.push(arguments[s]);var V=e==="error",u=this._events;if(u!==void 0)V=V&&u.error===void 0;else if(!V)return!1;if(V){var h;if(t.length>0&&(h=t[0]),h instanceof Error)throw h;var r=new Error("Unhandled error."+(h?" ("+h.message+")":""));throw r.context=h,r}var U=u[e];if(U===void 0)return!1;if(typeof U=="function")rs(U,this,t);else for(var f=U.length,p=Vs(U,f),s=0;s<f;++s)rs(p[s],this,t);return!0};function os(n,e,t,s){var V,u,h;if(dn(t),u=n._events,u===void 0?(u=n._events=Object.create(null),n._eventsCount=0):(u.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),u=n._events),h=u[e]),h===void 0)h=u[e]=t,++n._eventsCount;else if(typeof h=="function"?h=u[e]=s?[t,h]:[h,t]:s?h.unshift(t):h.push(t),V=as(n),V>0&&h.length>V&&!h.warned){h.warned=!0;var r=new Error("Possible EventEmitter memory leak detected. "+h.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");r.name="MaxListenersExceededWarning",r.emitter=n,r.type=e,r.count=h.length,Di(r)}return n}ee.prototype.addListener=function(e,t){return os(this,e,t,!1)},ee.prototype.on=ee.prototype.addListener,ee.prototype.prependListener=function(e,t){return os(this,e,t,!0)};function zi(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ls(n,e,t){var s={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},V=zi.bind(s);return V.listener=t,s.wrapFn=V,V}ee.prototype.once=function(e,t){return dn(t),this.on(e,ls(this,e,t)),this},ee.prototype.prependOnceListener=function(e,t){return dn(t),this.prependListener(e,ls(this,e,t)),this},ee.prototype.removeListener=function(e,t){var s,V,u,h,r;if(dn(t),V=this._events,V===void 0)return this;if(s=V[e],s===void 0)return this;if(s===t||s.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete V[e],V.removeListener&&this.emit("removeListener",e,s.listener||t));else if(typeof s!="function"){for(u=-1,h=s.length-1;h>=0;h--)if(s[h]===t||s[h].listener===t){r=s[h].listener,u=h;break}if(u<0)return this;u===0?s.shift():Hi(s,u),s.length===1&&(V[e]=s[0]),V.removeListener!==void 0&&this.emit("removeListener",e,r||t)}return this},ee.prototype.off=ee.prototype.removeListener,ee.prototype.removeAllListeners=function(e){var t,s,V;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[e]),this;if(arguments.length===0){var u=Object.keys(s),h;for(V=0;V<u.length;++V)h=u[V],h!=="removeListener"&&this.removeAllListeners(h);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=s[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(V=t.length-1;V>=0;V--)this.removeListener(e,t[V]);return this};function cs(n,e,t){var s=n._events;if(s===void 0)return[];var V=s[e];return V===void 0?[]:typeof V=="function"?t?[V.listener||V]:[V]:t?Oi(V):Vs(V,V.length)}ee.prototype.listeners=function(e){return cs(this,e,!0)},ee.prototype.rawListeners=function(e){return cs(this,e,!1)},ee.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):ds.call(n,e)},ee.prototype.listenerCount=ds;function ds(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}ee.prototype.eventNames=function(){return this._eventsCount>0?cn(this._events):[]};function Vs(n,e){for(var t=new Array(e),s=0;s<e;++s)t[s]=n[s];return t}function Hi(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function Oi(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function _i(n,e){return new Promise(function(t,s){function V(h){n.removeListener(e,u),s(h)}function u(){typeof n.removeListener=="function"&&n.removeListener("error",V),t([].slice.call(arguments))}hs(n,e,u,{once:!0}),e!=="error"&&Li(n,V,{once:!0})})}function Li(n,e,t){typeof n.on=="function"&&hs(n,"error",e,t)}function hs(n,e,t,s){if(typeof n.on=="function")s.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function V(u){s.once&&n.removeEventListener(e,V),t(u)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}var Yn=xn.exports;const Vn=ut(Yn);var vn={exports:{}};vn.exports=us,vn.exports.filter=Ki;var Ai=Yn.EventEmitter;function us(n,e,t){Array.isArray(t)||(t=[t]);var s=[];return t.forEach(function(V){var u=function(){var h=[].slice.call(arguments);h.unshift(V),e.emit.apply(e,h)};s.push(u),n.on(V,u)}),function(){t.forEach(function(u,h){n.removeListener(u,s[h])})}}function Ki(n,e){var t=new Ai;return us(n,t,e),t}var Pi=vn.exports;const hn=ut(Pi);var ms={exports:{}};/*! For license information please see webrtc-stats.js.LICENSE.txt */(function(n,e){(function(t,s){n.exports=s()})(self,()=>{return t={7:V=>{var u,h=typeof Reflect=="object"?Reflect:null,r=h&&typeof h.apply=="function"?h.apply:function(b,E,g){return Function.prototype.apply.call(b,E,g)};u=h&&typeof h.ownKeys=="function"?h.ownKeys:Object.getOwnPropertySymbols?function(b){return Object.getOwnPropertyNames(b).concat(Object.getOwnPropertySymbols(b))}:function(b){return Object.getOwnPropertyNames(b)};var U=Number.isNaN||function(b){return b!=b};function f(){f.init.call(this)}V.exports=f,V.exports.once=function(b,E){return new Promise(function(g,J){function F(y){b.removeListener(E,N),J(y)}function N(){typeof b.removeListener=="function"&&b.removeListener("error",F),g([].slice.call(arguments))}Z(b,E,N,{once:!0}),E!=="error"&&function(y,M){typeof y.on=="function"&&Z(y,"error",M,{once:!0})}(b,F)})},f.EventEmitter=f,f.prototype._events=void 0,f.prototype._eventsCount=0,f.prototype._maxListeners=void 0;var p=10;function o(b){if(typeof b!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof b)}function l(b){return b._maxListeners===void 0?f.defaultMaxListeners:b._maxListeners}function c(b,E,g,J){var F,N,y,M;if(o(g),(N=b._events)===void 0?(N=b._events=Object.create(null),b._eventsCount=0):(N.newListener!==void 0&&(b.emit("newListener",E,g.listener?g.listener:g),N=b._events),y=N[E]),y===void 0)y=N[E]=g,++b._eventsCount;else if(typeof y=="function"?y=N[E]=J?[g,y]:[y,g]:J?y.unshift(g):y.push(g),(F=l(b))>0&&y.length>F&&!y.warned){y.warned=!0;var C=new Error("Possible EventEmitter memory leak detected. "+y.length+" "+String(E)+" listeners added. Use emitter.setMaxListeners() to increase limit");C.name="MaxListenersExceededWarning",C.emitter=b,C.type=E,C.count=y.length,M=C,console&&console.warn&&console.warn(M)}return b}function i(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function a(b,E,g){var J={fired:!1,wrapFn:void 0,target:b,type:E,listener:g},F=i.bind(J);return F.listener=g,J.wrapFn=F,F}function m(b,E,g){var J=b._events;if(J===void 0)return[];var F=J[E];return F===void 0?[]:typeof F=="function"?g?[F.listener||F]:[F]:g?function(N){for(var y=new Array(N.length),M=0;M<y.length;++M)y[M]=N[M].listener||N[M];return y}(F):R(F,F.length)}function d(b){var E=this._events;if(E!==void 0){var g=E[b];if(typeof g=="function")return 1;if(g!==void 0)return g.length}return 0}function R(b,E){for(var g=new Array(E),J=0;J<E;++J)g[J]=b[J];return g}function Z(b,E,g,J){if(typeof b.on=="function")J.once?b.once(E,g):b.on(E,g);else{if(typeof b.addEventListener!="function")throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof b);b.addEventListener(E,function F(N){J.once&&b.removeEventListener(E,F),g(N)})}}Object.defineProperty(f,"defaultMaxListeners",{enumerable:!0,get:function(){return p},set:function(b){if(typeof b!="number"||b<0||U(b))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+b+".");p=b}}),f.init=function(){this._events!==void 0&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},f.prototype.setMaxListeners=function(b){if(typeof b!="number"||b<0||U(b))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+b+".");return this._maxListeners=b,this},f.prototype.getMaxListeners=function(){return l(this)},f.prototype.emit=function(b){for(var E=[],g=1;g<arguments.length;g++)E.push(arguments[g]);var J=b==="error",F=this._events;if(F!==void 0)J=J&&F.error===void 0;else if(!J)return!1;if(J){var N;if(E.length>0&&(N=E[0]),N instanceof Error)throw N;var y=new Error("Unhandled error."+(N?" ("+N.message+")":""));throw y.context=N,y}var M=F[b];if(M===void 0)return!1;if(typeof M=="function")r(M,this,E);else{var C=M.length,I=R(M,C);for(g=0;g<C;++g)r(I[g],this,E)}return!0},f.prototype.addListener=function(b,E){return c(this,b,E,!1)},f.prototype.on=f.prototype.addListener,f.prototype.prependListener=function(b,E){return c(this,b,E,!0)},f.prototype.once=function(b,E){return o(E),this.on(b,a(this,b,E)),this},f.prototype.prependOnceListener=function(b,E){return o(E),this.prependListener(b,a(this,b,E)),this},f.prototype.removeListener=function(b,E){var g,J,F,N,y;if(o(E),(J=this._events)===void 0)return this;if((g=J[b])===void 0)return this;if(g===E||g.listener===E)--this._eventsCount==0?this._events=Object.create(null):(delete J[b],J.removeListener&&this.emit("removeListener",b,g.listener||E));else if(typeof g!="function"){for(F=-1,N=g.length-1;N>=0;N--)if(g[N]===E||g[N].listener===E){y=g[N].listener,F=N;break}if(F<0)return this;F===0?g.shift():function(M,C){for(;C+1<M.length;C++)M[C]=M[C+1];M.pop()}(g,F),g.length===1&&(J[b]=g[0]),J.removeListener!==void 0&&this.emit("removeListener",b,y||E)}return this},f.prototype.off=f.prototype.removeListener,f.prototype.removeAllListeners=function(b){var E,g,J;if((g=this._events)===void 0)return this;if(g.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):g[b]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete g[b]),this;if(arguments.length===0){var F,N=Object.keys(g);for(J=0;J<N.length;++J)(F=N[J])!=="removeListener"&&this.removeAllListeners(F);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(typeof(E=g[b])=="function")this.removeListener(b,E);else if(E!==void 0)for(J=E.length-1;J>=0;J--)this.removeListener(b,E[J]);return this},f.prototype.listeners=function(b){return m(this,b,!0)},f.prototype.rawListeners=function(b){return m(this,b,!1)},f.listenerCount=function(b,E){return typeof b.listenerCount=="function"?b.listenerCount(E):d.call(b,E)},f.prototype.listenerCount=d,f.prototype.eventNames=function(){return this._eventsCount>0?u(this._events):[]}},156:function(V,u,h){var r=this&&this.__createBinding||(Object.create?function(o,l,c,i){i===void 0&&(i=c);var a=Object.getOwnPropertyDescriptor(l,c);a&&!("get"in a?!l.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return l[c]}}),Object.defineProperty(o,i,a)}:function(o,l,c,i){i===void 0&&(i=c),o[i]=l[c]}),U=this&&this.__exportStar||function(o,l){for(var c in o)c==="default"||Object.prototype.hasOwnProperty.call(l,c)||r(l,o,c)},f=this&&this.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(u,"__esModule",{value:!0}),u.Logger=void 0;var p=h(586);Object.defineProperty(u,"Logger",{enumerable:!0,get:function(){return f(p).default}}),U(h(284),u),U(h(280),u),U(h(738),u),U(h(767),u)},185:(V,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.calculatePacketsLostRatio=u.calculateRate=u.getMediaKind=void 0,u.getMediaKind=h=>{let r=h.kind||h.mediaType;return["audio","video"].includes(r)||h.type!=="inbound-rtp"||(r=h.id.toLocaleLowerCase().includes("video")?"video":"audio"),r},u.calculateRate=(h,r,U,f)=>U&&f?(r-f)/((h-U)/1e3):0,u.calculatePacketsLostRatio=(h,r,U,f)=>{const p=h-(U??0),o=p+(r-(f??0));return o===0?0:p/o}},280:(V,u)=>{Object.defineProperty(u,"__esModule",{value:!0})},284:function(V,u,h){var r,U,f,p,o,l,c,i,a,m,d,R,Z,b,E,g,J=this&&this.__awaiter||function(B,Q,j,O){return new(j||(j=Promise))(function(z,D){function _(ne){try{te(O.next(ne))}catch(Ve){D(Ve)}}function q(ne){try{te(O.throw(ne))}catch(Ve){D(Ve)}}function te(ne){var Ve;ne.done?z(ne.value):(Ve=ne.value,Ve instanceof j?Ve:new j(function(be){be(Ve)})).then(_,q)}te((O=O.apply(B,Q||[])).next())})},F=this&&this.__classPrivateFieldSet||function(B,Q,j,O,z){if(O==="m")throw new TypeError("Private method is not writable");if(O==="a"&&!z)throw new TypeError("Private accessor was defined without a setter");if(typeof Q=="function"?B!==Q||!z:!Q.has(B))throw new TypeError("Cannot write private member to an object whose class did not declare it");return O==="a"?z.call(B,j):z?z.value=j:Q.set(B,j),j},N=this&&this.__classPrivateFieldGet||function(B,Q,j,O){if(j==="a"&&!O)throw new TypeError("Private accessor was defined without a getter");if(typeof Q=="function"?B!==Q||!O:!Q.has(B))throw new TypeError("Cannot read private member from an object whose class did not declare it");return j==="m"?O:j==="a"?O.call(B):O?O.value:Q.get(B)},y=this&&this.__importDefault||function(B){return B&&B.__esModule?B:{default:B}};Object.defineProperty(u,"__esModule",{value:!0}),u.WebRTCStats=void 0;const M=h(7),C=y(h(586)),I=h(738),X=h(185);class H extends M.EventEmitter{constructor(Q){super(),r.add(this),U.set(this,void 0),f.set(this,void 0),p.set(this,void 0),o.set(this,null),l.set(this,void 0),c.set(this,null),this.start=()=>{N(this,l,"f").info("WebRTC statistics collection is starting..."),F(this,c,null,"f"),F(this,o,setInterval(N(this,i,"f"),N(this,f,"f")),"f")},this.stop=()=>{N(this,o,"f")&&(clearInterval(N(this,o,"f")),F(this,o,null,"f"),N(this,l,"f").info("WebRTC statistics collection has stopped."))},i.set(this,()=>J(this,void 0,void 0,function*(){let j,O;try{N(this,l,"f").trace("Requesting WebRTC statistics..."),j=yield N(this,U,"f").call(this),O=new Date().toISOString()}catch(_){return N(this,l,"f").error("Problem collecting the WebRTC statistics.",_),void this.emit("error",`Problem collecting the WebRTC statistics - ${_}`)}const z=Array.from(j.values()),D={timestamp:O,input:{audio:[],video:[]},output:{audio:[],video:[]}};N(this,p,"f")&&(D.rawStats=j);for(let _=0;_<Object.keys(z).length;_++){const q=z[_];switch(q.type){case"outbound-rtp":const te=q,ne=(0,X.getMediaKind)(te);ne==="audio"?yield N(this,r,"m",d).call(this,j,te,D):ne==="video"&&(yield N(this,r,"m",R).call(this,j,te,D));break;case"inbound-rtp":const Ve=q;let be=(0,X.getMediaKind)(Ve);be==="audio"?yield N(this,r,"m",b).call(this,j,Ve,D):be==="video"&&(yield N(this,r,"m",E).call(this,j,Ve,D));break;case"candidate-pair":const xe=q;xe.nominated&&N(this,r,"m",g).call(this,xe,D)}}F(this,c,D,"f"),this.emit("stats",D)})),F(this,l,C.default.get("WebRTCStats"),"f"),F(this,U,Q.getStats,"f"),F(this,f,Q.getStatsInterval||1e3,"f"),F(this,p,!!Q.includeRawStats,"f")}}u.WebRTCStats=H,U=new WeakMap,f=new WeakMap,p=new WeakMap,o=new WeakMap,l=new WeakMap,c=new WeakMap,i=new WeakMap,r=new WeakSet,a=function(B,Q){if(Q){const j=B.get(Q);if(j)return{mimeType:j.mimeType}}return{}},m=function(B,Q,j){return J(this,void 0,void 0,function*(){var O,z,D,_;const q=(0,X.calculateRate)(Q.timestamp,Q.bytesSent,j==null?void 0:j.timestamp,j==null?void 0:j.totalBytesSent),te=(0,X.calculateRate)(Q.timestamp,Q.packetsSent,j==null?void 0:j.timestamp,j==null?void 0:j.totalPacketsSent),ne=N(this,r,"m",a).call(this,B,Q.codecId);return Object.assign({id:Q.id,timestamp:Q.timestamp,mid:Q.mid,totalBytesSent:Q.bytesSent,bytesSentDelta:Q.bytesSent-((O=j==null?void 0:j.totalBytesSent)!==null&&O!==void 0?O:0),totalPacketsSent:Q.packetsSent,packetsSentDelta:Q.packetsSent-((z=j==null?void 0:j.totalPacketsSent)!==null&&z!==void 0?z:0),bitrate:q,packetRate:te,targetBitrate:Q.targetBitrate,retransmittedPacketsSent:Q.retransmittedPacketsSent,retransmittedPacketsSentDelta:Q.retransmittedPacketsSent-((D=j==null?void 0:j.retransmittedPacketsSent)!==null&&D!==void 0?D:0),retransmittedBytesSent:Q.retransmittedBytesSent,retransmittedBytesSentDelta:Q.retransmittedBytesSent-((_=j==null?void 0:j.retransmittedBytesSent)!==null&&_!==void 0?_:0)},ne)})},d=function(B,Q,j){return J(this,void 0,void 0,function*(){var O;const z=(O=N(this,c,"f"))===null||O===void 0?void 0:O.output.audio.find(q=>q.id===Q.id);if(z&&Q.timestamp-z.timestamp<=0)return;const D=yield N(this,r,"m",m).call(this,B,Q,z),_=Object.assign({},D);j.output.audio.push(_)})},R=function(B,Q,j){return J(this,void 0,void 0,function*(){var O;const z=(O=N(this,c,"f"))===null||O===void 0?void 0:O.output.video.find(te=>te.id===Q.id);if(z&&Q.timestamp-z.timestamp<=0)return;const D=yield N(this,r,"m",m).call(this,B,Q,z);let _=I.QualityLimitationReason.none;Q.qualityLimitationReason&&(_=Q.qualityLimitationReason);const q=Object.assign(Object.assign({},D),{frameWidth:Q.frameWidth,frameHeight:Q.frameHeight,framesPerSecond:Q.framesPerSecond,framesSent:Q.framesSent,qualityLimitationReason:_,qualityLimitationDurations:Q.qualityLimitationDurations});j.output.video.push(q)})},Z=function(B,Q,j){return J(this,void 0,void 0,function*(){var O,z;const D=(0,X.calculateRate)(Q.timestamp,Q.bytesReceived,j==null?void 0:j.timestamp,j==null?void 0:j.totalBytesReceived),_=(0,X.calculateRate)(Q.timestamp,Q.packetsReceived,j==null?void 0:j.timestamp,j==null?void 0:j.totalPacketsReceived),q=(0,X.calculatePacketsLostRatio)(Q.packetsLost,Q.packetsReceived,j==null?void 0:j.totalPacketsLost,j==null?void 0:j.totalPacketsReceived),te=((O=Q.packetsLost)!==null&&O!==void 0?O:0)-((z=j==null?void 0:j.totalPacketsLost)!==null&&z!==void 0?z:0),ne=N(this,r,"m",a).call(this,B,Q.codecId);return Object.assign({id:Q.id,timestamp:Q.timestamp,mid:Q.mid,trackIdentifier:Q.trackIdentifier,jitter:Q.jitter,jitterBufferDelay:Q.jitterBufferDelay,jitterBufferEmittedCount:Q.jitterBufferEmittedCount,totalBytesReceived:Q.bytesReceived,totalPacketsReceived:Q.packetsReceived,totalPacketsLost:Q.packetsLost,bitrate:D,packetRate:_,packetLossRatio:q,packetLossDelta:te},ne)})},b=function(B,Q,j){return J(this,void 0,void 0,function*(){var O;const z=(O=N(this,c,"f"))===null||O===void 0?void 0:O.input.audio.find(_=>_.id===Q.id);if(z&&Q.timestamp-z.timestamp<=0)return;const D=yield N(this,r,"m",Z).call(this,B,Q,z);j.input.audio.push(D)})},E=function(B,Q,j){return J(this,void 0,void 0,function*(){var O;const z=(O=N(this,c,"f"))===null||O===void 0?void 0:O.input.video.find(q=>q.id===Q.id);if(z&&Q.timestamp-z.timestamp<=0)return;const D=yield N(this,r,"m",Z).call(this,B,Q,z),_=Object.assign(Object.assign({},D),{keyFramesDecoded:Q.keyFramesDecoded,frameHeight:Q.frameHeight,frameWidth:Q.frameWidth,framesDecoded:Q.framesDecoded,framesDropped:Q.framesDropped,framesPerSecond:Q.framesPerSecond,framesReceived:Q.framesReceived});j.input.video.push(_)})},g=function(B,Q){Q.totalRoundTripTime=B.totalRoundTripTime,Q.currentRoundTripTime=B.currentRoundTripTime,Q.responsesReceived=B.responsesReceived,Q.availableOutgoingBitrate=B.availableOutgoingBitrate,Q.availableIncomingBitrate=B.availableIncomingBitrate}},586:function(V,u,h){var r,U;(function(){var f,p={VERSION:"1.6.1"},o={},l=function(R,Z){return function(){return Z.apply(R,arguments)}},c=function(){var R,Z,b=arguments,E=b[0];for(Z=1;Z<b.length;Z++)for(R in b[Z])!(R in E)&&b[Z].hasOwnProperty(R)&&(E[R]=b[Z][R]);return E},i=function(R,Z){return{value:R,name:Z}};p.TRACE=i(1,"TRACE"),p.DEBUG=i(2,"DEBUG"),p.INFO=i(3,"INFO"),p.TIME=i(4,"TIME"),p.WARN=i(5,"WARN"),p.ERROR=i(8,"ERROR"),p.OFF=i(99,"OFF");var a=function(R){this.context=R,this.setLevel(R.filterLevel),this.log=this.info};a.prototype={setLevel:function(R){R&&"value"in R&&(this.context.filterLevel=R)},getLevel:function(){return this.context.filterLevel},enabledFor:function(R){var Z=this.context.filterLevel;return R.value>=Z.value},trace:function(){this.invoke(p.TRACE,arguments)},debug:function(){this.invoke(p.DEBUG,arguments)},info:function(){this.invoke(p.INFO,arguments)},warn:function(){this.invoke(p.WARN,arguments)},error:function(){this.invoke(p.ERROR,arguments)},time:function(R){typeof R=="string"&&R.length>0&&this.invoke(p.TIME,[R,"start"])},timeEnd:function(R){typeof R=="string"&&R.length>0&&this.invoke(p.TIME,[R,"end"])},invoke:function(R,Z){f&&this.enabledFor(R)&&f(Z,c({level:R},this.context))}};var m,d=new a({filterLevel:p.OFF});(m=p).enabledFor=l(d,d.enabledFor),m.trace=l(d,d.trace),m.debug=l(d,d.debug),m.time=l(d,d.time),m.timeEnd=l(d,d.timeEnd),m.info=l(d,d.info),m.warn=l(d,d.warn),m.error=l(d,d.error),m.log=m.info,p.setHandler=function(R){f=R},p.setLevel=function(R){for(var Z in d.setLevel(R),o)o.hasOwnProperty(Z)&&o[Z].setLevel(R)},p.getLevel=function(){return d.getLevel()},p.get=function(R){return o[R]||(o[R]=new a(c({name:R},d.context)))},p.createDefaultHandler=function(R){(R=R||{}).formatter=R.formatter||function(E,g){g.name&&E.unshift("["+g.name+"]")};var Z={},b=function(E,g){Function.prototype.apply.call(E,console,g)};return typeof console>"u"?function(){}:function(E,g){E=Array.prototype.slice.call(E);var J,F=console.log;g.level===p.TIME?(J=(g.name?"["+g.name+"] ":"")+E[0],E[1]==="start"?console.time?console.time(J):Z[J]=new Date().getTime():console.timeEnd?console.timeEnd(J):b(F,[J+": "+(new Date().getTime()-Z[J])+"ms"])):(g.level===p.WARN&&console.warn?F=console.warn:g.level===p.ERROR&&console.error?F=console.error:g.level===p.INFO&&console.info?F=console.info:g.level===p.DEBUG&&console.debug?F=console.debug:g.level===p.TRACE&&console.trace&&(F=console.trace),R.formatter(E,g),b(F,E))}},p.useDefaults=function(R){p.setLevel(R&&R.defaultLevel||p.DEBUG),p.setHandler(p.createDefaultHandler(R))},p.setDefaults=p.useDefaults,(U=typeof(r=p)=="function"?r.call(u,h,u,V):r)===void 0||(V.exports=U)})()},738:(V,u)=>{var h;Object.defineProperty(u,"__esModule",{value:!0}),u.QualityLimitationReason=void 0,function(r){r[r.none=0]="none",r[r.cpu=1]="cpu",r[r.bandwidth=2]="bandwidth",r[r.other=3]="other"}(h||(u.QualityLimitationReason=h={}))},767:(V,u)=>{Object.defineProperty(u,"__esModule",{value:!0})}},s={},function V(u){var h=s[u];if(h!==void 0)return h.exports;var r=s[u]={exports:{}};return t[u].call(r.exports,r,r.exports,V),r.exports}(156);var t,s})})(ms);var $i=ms.exports;const Tt=je.get("PeerConnectionStats"),ps={stats:"stats"},qi=n=>{const{input:e,output:t,rawStats:s,...V}=n;return{...V,audio:{inbounds:n.input.audio.map(({packetLossRatio:h,packetLossDelta:r,bitrate:U,...f})=>({packetsLostRatioPerSecond:h,packetsLostDeltaPerSecond:r,bitrateBitsPerSecond:U*8,bitrate:U,...f})),outbounds:n.output.audio.map(({packetLossRatio:h,packetLossDelta:r,bitrate:U,...f})=>({packetsLostRatioPerSecond:h,packetsLostDeltaPerSecond:r,bitrateBitsPerSecond:U*8,bitrate:U,...f}))},video:{inbounds:n.input.video.map(({packetLossRatio:h,packetLossDelta:r,bitrate:U,...f})=>({packetsLostRatioPerSecond:h,packetsLostDeltaPerSecond:r,bitrateBitsPerSecond:U*8,bitrate:U,...f})),outbounds:n.output.video.map(({packetLossRatio:h,packetLossDelta:r,bitrate:U,...f})=>({packetsLostRatioPerSecond:h,packetsLostDeltaPerSecond:r,bitrateBitsPerSecond:U*8,bitrate:U,...f}))},raw:n.rawStats}};class ea extends Vn{constructor(e,t={statsIntervalMs:1e3,autoInitStats:!0}){super(),this.peer=e,this.collection=null,this.initialized=!1,t.autoInitStats&&this.init(t.statsIntervalMs)}init(e){if(this.initialized){Tt.warn("PeerConnectionStats.init() has already been called. Automatic initialization occurs when the PeerConnectionStats object is constructed.");return}Tt.info("Initializing peer connection stats");const t=this.peer;try{this.collection=new $i.WebRTCStats({getStatsInterval:e,getStats:()=>t.getStats(),includeRawStats:!0}),this.collection.on("stats",s=>{const V=qi(s);Ne.addStats(V),this.emit(ps.stats,V)}),this.collection.start(),this.initialized=!0}catch(s){Tt.error(s)}}parseStats(e){return Tt.warn("The parseStats method is deprecated and will be removed in future releases."),null}stop(){Tt.info("Stopping peer connection stats"),this.collection.stop()}}var Re={},ze={},Rs={},fs={exports:{}},Us=fs.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(n){return n.encoding?"rtpmap:%d %s/%s/%s":n.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(n){return n.address!=null?"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(n){return n.subtype!=null?"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(n){return"extmap:%d"+(n.direction?"/%s":"%v")+(n["encrypt-uri"]?" %s":"%v")+" %s"+(n.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(n){return n.sessionConfig!=null?"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(n){var e="candidate:%s %d %s %d %s %d typ %s";return e+=n.raddr!=null?" raddr %s rport %d":"%v%v",e+=n.tcptype!=null?" tcptype %s":"%v",n.generation!=null&&(e+=" generation %d"),e+=n["network-id"]!=null?" network-id %d":"%v",e+=n["network-cost"]!=null?" network-cost %d":"%v",e}},{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(n){var e="ssrc:%d";return n.attribute!=null&&(e+=" %s",n.value!=null&&(e+=":%s")),e}},{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(n){return n.maxMessageSize!=null?"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(n){return n.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(n){return"imageattr:%s %s %s"+(n.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(n){return"simulcast:%s %s"+(n.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(n){return"ts-refclk:%s"+(n.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(n){var e="mediaclk:";return e+=n.id!=null?"id=%s %s":"%v%s",e+=n.mediaClockValue!=null?"=%s":"",e+=n.rateNumerator!=null?" rate=%s":"",e+=n.rateDenominator!=null?"/%s":"",e}},{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(Us).forEach(function(n){var e=Us[n];e.forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})});var Ws=fs.exports;(function(n){var e=function(r){return String(Number(r))===r?Number(r):r},t=function(r,U,f,p){if(p&&!f)U[p]=e(r[1]);else for(var o=0;o<f.length;o+=1)r[o+1]!=null&&(U[f[o]]=e(r[o+1]))},s=function(r,U,f){var p=r.name&&r.names;r.push&&!U[r.push]?U[r.push]=[]:p&&!U[r.name]&&(U[r.name]={});var o=r.push?{}:p?U[r.name]:U;t(f.match(r.reg),o,r.names,r.name),r.push&&U[r.push].push(o)},V=Ws,u=RegExp.prototype.test.bind(/^([a-z])=(.*)/);n.parse=function(r){var U={},f=[],p=U;return r.split(/(\r\n|\r|\n)/).filter(u).forEach(function(o){var l=o[0],c=o.slice(2);l==="m"&&(f.push({rtp:[],fmtp:[]}),p=f[f.length-1]);for(var i=0;i<(V[l]||[]).length;i+=1){var a=V[l][i];if(a.reg.test(c))return s(a,p,c)}}),U.media=f,U};var h=function(r,U){var f=U.split(/=(.+)/,2);return f.length===2?r[f[0]]=e(f[1]):f.length===1&&U.length>1&&(r[f[0]]=void 0),r};n.parseParams=function(r){return r.split(/;\s?/).reduce(h,{})},n.parseFmtpConfig=n.parseParams,n.parsePayloads=function(r){return r.toString().split(" ").map(Number)},n.parseRemoteCandidates=function(r){for(var U=[],f=r.split(" ").map(e),p=0;p<f.length;p+=3)U.push({component:f[p],ip:f[p+1],port:f[p+2]});return U},n.parseImageAttributes=function(r){return r.split(" ").map(function(U){return U.substring(1,U.length-1).split(",").reduce(h,{})})},n.parseSimulcastStreamList=function(r){return r.split(";").map(function(U){return U.split(",").map(function(f){var p,o=!1;return f[0]!=="~"?p=e(f):(p=e(f.substring(1,f.length)),o=!0),{scid:p,paused:o}})})}})(Rs);var Qn=Ws,ta=/%[sdv%]/g,na=function(n){var e=1,t=arguments,s=t.length;return n.replace(ta,function(V){if(e>=s)return V;var u=t[e];switch(e+=1,V){case"%%":return"%";case"%s":return String(u);case"%d":return Number(u);case"%v":return""}})},Mt=function(n,e,t){var s=e.format instanceof Function?e.format(e.push?t:t[e.name]):e.format,V=[n+"="+s];if(e.names)for(var u=0;u<e.names.length;u+=1){var h=e.names[u];e.name?V.push(t[e.name][h]):V.push(t[e.names[u]])}else V.push(t[e.name]);return na.apply(null,V)},ra=["v","o","s","i","u","e","p","c","b","t","r","z","a"],sa=["i","c","b","a"],ia=function(n,e){e=e||{},n.version==null&&(n.version=0),n.name==null&&(n.name=" "),n.media.forEach(function(u){u.payloads==null&&(u.payloads="")});var t=e.outerOrder||ra,s=e.innerOrder||sa,V=[];return t.forEach(function(u){Qn[u].forEach(function(h){h.name in n&&n[h.name]!=null?V.push(Mt(u,h,n)):h.push in n&&n[h.push]!=null&&n[h.push].forEach(function(r){V.push(Mt(u,h,r))})})}),n.media.forEach(function(u){V.push(Mt("m",Qn.m[0],u)),s.forEach(function(h){Qn[h].forEach(function(r){r.name in u&&u[r.name]!=null?V.push(Mt(h,r,u)):r.push in u&&u[r.push]!=null&&u[r.push].forEach(function(U){V.push(Mt(h,r,U))})})})}),V.join(`\r `)+`\r `},tt=Rs,aa=ia;ze.write=aa,ze.parse=tt.parse,ze.parseParams=tt.parseParams,ze.parseFmtpConfig=tt.parseFmtpConfig,ze.parsePayloads=tt.parsePayloads,ze.parseRemoteCandidates=tt.parseRemoteCandidates,ze.parseImageAttributes=tt.parseImageAttributes,ze.parseSimulcastStreamList=tt.parseSimulcastStreamList;var oa=function(n){const e=new Intl.Collator(n,{sensitivity:"base"});return(t,s)=>e.compare(t,s)==0};let wt=class Si{constructor(e,t,s,V,u,h,r,U,f){this.foundation=e,this.componentId=t,this.transport=s,this.priority=V,this.address=u,this.port=h,this.type=r,this.relAddr=U,this.relPort=f}equals(e){return e.foundation===this.foundation&&e.componentId===this.componentId&&e.transport===this.transport&&e.priority===this.priority&&e.address===this.address&&e.port===this.port&&e.type===this.type&&e.relAddr===this.relAddr&&e.relPort===this.relPort}clone(){return new Si(this.foundation,this.componentId,this.transport,this.priority,this.address,this.port,this.type,this.relAddr,this.relPort)}plain(){const e={foundation:this.foundation,componentId:this.componentId,transport:this.transport,priority:this.priority,address:this.address,port:this.port,type:this.type};return this.relAddr&&(e.relAddr=this.relAddr),this.relPort&&(e.relPort=this.relPort),e}getFoundation(){return this.foundation}getComponentId(){return this.componentId}getTransport(){return this.transport}getPriority(){return this.priority}getAddress(){return this.address}getPort(){return this.port}getType(){return this.type}getRelAddr(){return this.relAddr}getRelPort(){return this.relPort}};wt.expand=function(n){return n.constructor.name==="CandidateInfo"?n:(n=n,new wt(n.foundation,n.componentId,n.transport,n.priority,n.address,n.port,n.type,n.relAddr,n.relPort))},wt.clone=function(n){return n.constructor.name==="CandidateInfo"?n.clone():wt.expand(n)};var Zs=wt;let Gt=class Ei{constructor(e,t){this.id=e,this.params=t||[]}clone(){return new Ei(this.id,this.params)}plain(){return this.params.length?{id:this.id,params:this.params}:{id:this.id}}getId(){return this.id}getParams(){return this.params}};Gt.expand=function(n){return n.constructor.name==="RTCPFeedbackInfo"?n:(n=n,new Gt(n.id,n.params))},Gt.clone=function(n){return n.constructor.name==="RTCPFeedbackInfo"?n.clone():Gt.expand(n)};var Cn=Gt;const bs=Cn;let nt=class Ni{constructor(e,t,s){this.codec=e,this.type=t,this.params={},this.rtcpfbs=new Set,s&&this.addParams(s)}clone(){const e=new Ni(this.codec,this.type,this.params);this.hasRTX()&&e.setRTX(this.getRTX());for(const t of this.rtcpfbs)e.addRTCPFeedback(t.clone());return this.hasChannels()&&e.setChannels(this.getChannels()),e}plain(){const e={codec:this.codec,type:this.type};this.rtx&&(e.rtx=this.rtx),this.channels&&(e.channels=this.channels),Object.keys(this.params).length&&(e.params=this.params);for(const t of this.rtcpfbs)e.rtcpfbs||(e.rtcpfbs=[]),e.rtcpfbs.push(t.plain());return e}setRTX(e){this.rtx=e}getType(){return this.type}setType(e){this.type=e}getCodec(){return this.codec}getParams(){return this.params}addParams(e){for(const t in e)this.params[t]=e[t]}addParam(e,t){this.params[e]=t}hasParam(e){return Object.hasOwnProperty.call(this.params,e)}getParam(e,t=void 0){if(this.hasParam(e))return this.params[e];if(t===void 0)throw new Error(`param ${e} not found and no default value provided`);return""+t}hasRTX(){return this.rtx}getRTX(){return this.rtx}hasChannels(){return this.channels}getChannels(){return this.channels}setChannels(e){this.channels=e}addRTCPFeedback(e){this.rtcpfbs.add(e)}getRTCPFeedbacks(){return this.rtcpfbs}};nt.expand=function(n){if(n.constructor.name==="CodecInfo")return n;n=n;const e=new nt(n.codec,n.type,n.params);n.rtx&&e.setRTX(n.rtx),n.channels&&e.setChannels(n.channels);for(const t of n.rtcpfbs||[]){const s=bs.expand(t);e.addRTCPFeedback(s)}return e},nt.clone=function(n){return n.constructor.name==="CodecInfo"?n.clone():nt.expand(n)},nt.MapFromNames=function(n,e,t){var s;const V=new Map;let u=96;for(const h of n){let r;const U=h.split(";"),f=U.shift().toLowerCase().trim();f==="pcmu"?r=0:f==="pcma"?r=8:r=++u;const p=new nt(f,r);f==="opus"?p.setChannels(2):f==="multiopus"&&p.setChannels(6),e&&f!=="ulpfec"&&f!=="flexfec-03"&&f!=="red"&&p.setRTX(++u);for(const o of t||[])p.addRTCPFeedback(new bs(o.id,o.params));for(const o of U){let l=o.split("=");p.addParam(l[0].trim(),(s=l[1])===null||s===void 0?void 0:s.trim())}V.set(r,p)}return V};var un=nt;function In(){var n=this;if(!(this instanceof In))return new(Function.prototype.bind.apply(In,[null].concat(Array.prototype.slice.call(arguments))));Array.from(arguments).forEach(function(e){n[e]=Symbol.for("MEDOOZE_SEMANTIC_SDP_"+e)})}var jn=In;const he=jn("ACTIVE","PASSIVE","ACTPASS","INACTIVE");he.byValue=function(n){switch(n){case he.ACTIVE:case he.PASSIVE:case he.ACTPASS:case he.INACTIVE:return n}return he[n.toUpperCase()]},he.toString=function(n){switch(n){case he.ACTIVE:return"active";case he.PASSIVE:return"passive";case he.ACTPASS:return"actpass";case he.INACTIVE:return"inactive"}},he.reverse=function(n,e){switch(n){case he.ACTIVE:return he.PASSIVE;case he.PASSIVE:return he.ACTIVE;case he.ACTPASS:return e?he.ACTIVE:he.PASSIVE;case he.INACTIVE:return he.INACTIVE}};var Xn=he;const Bn=Xn;let xt=class ki{constructor(e,t,s){this.setup=e,this.hash=t,this.fingerprint=s}clone(){return new ki(this.setup,this.hash,this.fingerprint)}plain(){return{setup:Bn.toString(this.setup),hash:this.hash,fingerprint:this.fingerprint}}getFingerprint(){return this.fingerprint}getHash(){return this.hash}getSetup(){return this.setup}setSetup(e){this.setup=e}};xt.expand=function(n){return n.constructor.name==="DTLSInfo"?n:(n=n,new xt(n.setup?Bn.byValue(n.setup):Bn.ACTPASS,n.hash,n.fingerprint))},xt.clone=function(n){return n.constructor.name==="DTLSInfo"?n.clone():xt.expand(n)};var Fs=xt;let Yt=class gi{constructor(e,t,s,V){this.tag=e,this.suite=t,this.keyParams=s,this.sessionParams=V}clone(){return new gi(this.tag,this.suite,this.keyParams,this.sessionParams)}plain(){return{tag:this.tag,suite:this.suite,keyParams:this.keyParams,sessionParams:this.sessionParams}}getSessionParams(){return this.sessionParams}getKeyParams(){return this.keyParams}getSuite(){return this.suite}getTag(){return this.tag}};Yt.expand=function(n){return n.constructor.name==="CryptoInfo"?n:(n=n,new Yt(n.tag,n.suite,n.keyParams,n.sessionParams))},Yt.clone=function(n){return n.constructor.name==="CryptoInfo"?n.clone():Yt.expand(n)};var Ss=Yt,Dn={exports:{}},zn={exports:{}},Es={},mn={};mn.byteLength=da,mn.toByteArray=ha,mn.fromByteArray=pa;for(var Xe=[],Me=[],la=typeof Uint8Array<"u"?Uint8Array:Array,Hn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rt=0,ca=Hn.length;Rt<ca;++Rt)Xe[Rt]=Hn[Rt],Me[Hn.charCodeAt(Rt)]=Rt;Me[45]=62,Me[95]=63;function Ns(n){var e=n.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");t===-1&&(t=e);var s=t===e?0:4-t%4;return[t,s]}function da(n){var e=Ns(n),t=e[0],s=e[1];return(t+s)*3/4-s}function Va(n,e,t){return(e+t)*3/4-t}function ha(n){var e,t=Ns(n),s=t[0],V=t[1],u=new la(Va(n,s,V)),h=0,r=V>0?s-4:s,U;for(U=0;U<r;U+=4)e=Me[n.charCodeAt(U)]<<18|Me[n.charCodeAt(U+1)]<<12|Me[n.charCodeAt(U+2)]<<6|Me[n.charCodeAt(U+3)],u[h++]=e>>16&255,u[h++]=e>>8&255,u[h++]=e&255;return V===2&&(e=Me[n.charCodeAt(U)]<<2|Me[n.charCodeAt(U+1)]>>4,u[h++]=e&255),V===1&&(e=Me[n.charCodeAt(U)]<<10|Me[n.charCodeAt(U+1)]<<4|Me[n.charCodeAt(U+2)]>>2,u[h++]=e>>8&255,u[h++]=e&255),u}function ua(n){return Xe[n>>18&63]+Xe[n>>12&63]+Xe[n>>6&63]+Xe[n&63]}function ma(n,e,t){for(var s,V=[],u=e;u<t;u+=3)s=(n[u]<<16&16711680)+(n[u+1]<<8&65280)+(n[u+2]&255),V.push(ua(s));return V.join("")}function pa(n){for(var e,t=n.length,s=t%3,V=[],u=16383,h=0,r=t-s;h<r;h+=u)V.push(ma(n,h,h+u>r?r:h+u));return s===1?(e=n[t-1],V.push(Xe[e>>2]+Xe[e<<4&63]+"==")):s===2&&(e=(