UNPKG

@millicast/sdk

Version:

SDK for building a realtime broadcaster using the Millicast platform.

5 lines 410 kB
"use strict";var Bi=Object.defineProperty,Gi=Object.defineProperties;var Xi=Object.getOwnPropertyDescriptors;var nr=Object.getOwnPropertySymbols;var ts=Object.prototype.hasOwnProperty,rs=Object.prototype.propertyIsEnumerable;var es=(r,e,t)=>e in r?Bi(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,J=(r,e)=>{for(var t in e||(e={}))ts.call(e,t)&&es(r,t,e[t]);if(nr)for(var t of nr(e))rs.call(e,t)&&es(r,t,e[t]);return r},ke=(r,e)=>Gi(r,Xi(e));var rt=(r,e)=>{var t={};for(var s in r)ts.call(r,s)&&e.indexOf(s)<0&&(t[s]=r[s]);if(r!=null&&nr)for(var s of nr(r))e.indexOf(s)<0&&rs.call(r,s)&&(t[s]=r[s]);return t};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var br=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Et(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Zs={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(r){(function(e){var t={};t.VERSION="1.6.1";var s,d={},p=function(h,a){return function(){return a.apply(h,arguments)}},f=function(){var h=arguments,a=h[0],c,l;for(l=1;l<h.length;l++)for(c in h[l])!(c in a)&&h[l].hasOwnProperty(c)&&(a[c]=h[l][c]);return a},n=function(h,a){return{value:h,name:a}};t.TRACE=n(1,"TRACE"),t.DEBUG=n(2,"DEBUG"),t.INFO=n(3,"INFO"),t.TIME=n(4,"TIME"),t.WARN=n(5,"WARN"),t.ERROR=n(8,"ERROR"),t.OFF=n(99,"OFF");var b=function(h){this.context=h,this.setLevel(h.filterLevel),this.log=this.info};b.prototype={setLevel:function(h){h&&"value"in h&&(this.context.filterLevel=h)},getLevel:function(){return this.context.filterLevel},enabledFor:function(h){var a=this.context.filterLevel;return h.value>=a.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(h){typeof h=="string"&&h.length>0&&this.invoke(t.TIME,[h,"start"])},timeEnd:function(h){typeof h=="string"&&h.length>0&&this.invoke(t.TIME,[h,"end"])},invoke:function(h,a){s&&this.enabledFor(h)&&s(a,f({level:h},this.context))}};var y=new b({filterLevel:t.OFF});(function(){var h=t;h.enabledFor=p(y,y.enabledFor),h.trace=p(y,y.trace),h.debug=p(y,y.debug),h.time=p(y,y.time),h.timeEnd=p(y,y.timeEnd),h.info=p(y,y.info),h.warn=p(y,y.warn),h.error=p(y,y.error),h.log=h.info})(),t.setHandler=function(h){s=h},t.setLevel=function(h){y.setLevel(h);for(var a in d)d.hasOwnProperty(a)&&d[a].setLevel(h)},t.getLevel=function(){return y.getLevel()},t.get=function(h){return d[h]||(d[h]=new b(f({name:h},y.context)))},t.createDefaultHandler=function(h){h=h||{},h.formatter=h.formatter||function(i,o){o.name&&i.unshift("["+o.name+"]")};var a={},c=function(l,i){Function.prototype.apply.call(l,console,i)};return typeof console>"u"?function(){}:function(l,i){l=Array.prototype.slice.call(l);var o=console.log,m;i.level===t.TIME?(m=(i.name?"["+i.name+"] ":"")+l[0],l[1]==="start"?console.time?console.time(m):a[m]=new Date().getTime():console.timeEnd?console.timeEnd(m):c(o,[m+": "+(new Date().getTime()-a[m])+"ms"])):(i.level===t.WARN&&console.warn?o=console.warn:i.level===t.ERROR&&console.error?o=console.error:i.level===t.INFO&&console.info?o=console.info:i.level===t.DEBUG&&console.debug?o=console.debug:i.level===t.TRACE&&console.trace&&(o=console.trace),h.formatter(l,i),c(o,l))}},t.useDefaults=function(h){t.setLevel(h&&h.defaultLevel||t.DEBUG),t.setHandler(t.createDefaultHandler(h))},t.setDefaults=t.useDefaults,r.exports?r.exports=t:(t._prevLogger=e.Logger,t.noConflict=function(){return e.Logger=t._prevLogger,t},e.Logger=t)})(br)})(Zs);var Yi=Zs.exports;const ct=Et(Yi),Fs="0.4.0",sr=60;var Ds;const zi=((Ds=window==null?void 0:window.navigator)==null?void 0:Ds.userAgent)||"No user agent available";let ir="",or="",ar="",Tt="",At="",ns="",cr="",lr=0;const ur=[];function Ki(r){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 r.stats=r.stats.reduce((t,s)=>{const d=s.audio.inbounds.length!==0?s.audio.inbounds.map(f=>e("audio",f)):s.audio.outbounds.map(f=>e("audio",f)),p=s.video.inbounds.length!==0?s.video.inbounds.map(f=>e("video",f)):s.video.outbounds.map(f=>e("video",f));return t.concat([...d,...p])},[]),r}const Ee={initAccountId:r=>{ir=ir===""?r:ir},initStreamName:r=>{or=or===""?r:or},initSubscriberId:r=>{ar=ar===""?r:ar},initStreamViewId:r=>{Tt=Tt===""?r:Tt},initFeedId:r=>{At=At===""?r:At},setConnectionTime:r=>{lr=lr===0?r:lr},setConnectionState:r=>{ns=r},setClusterId:r=>{cr=cr===""?r:cr},addStats:r=>{ur.length===sr&&ur.shift(),ur.push(r)},get:(r=sr,e="JSON")=>{let t;!Number.isInteger(r)||r>sr||r<=0?t=sr:t=r;const s={client:"@millicast/millicast-sdk",version:Fs,timestamp:new Date().toISOString(),userAgent:zi,clusterId:cr,accountId:ir,streamName:or,subscriberId:ar,connection:ns,stats:ur.slice(-t),connectionDurationMs:new Date().getTime()-lr};return At!==""?s.feedId=At:Tt!==""&&(s.streamViewId=Tt),e==="CMCD"?Ki(s):s}};ct.useDefaults({defaultLevel:ct.TRACE});const dr=["TRACE","DEBUG","INFO","WARN","ERROR"],Vs=(r,e)=>{r.unshift("[".concat(e.name||"Global","] ").concat(new Date().toISOString()," - ").concat(e.level.name," -"))},Ns=(r,e)=>e?r.value>=nt[e].value:r.value>=hr.value,Hi=(r,e)=>{r=Array.prototype.slice.call(r),r=r.map(t=>typeof t=="object"?JSON.stringify(t):t),Vs(r,e),Nt!==0?(vt.push(r.join(" ")),vt.length>=Nt&&(vt=vt.slice(-Nt))):vt=[]},Ji=ct.createDefaultHandler({formatter:Vs});ct.setHandler((r,e)=>{Hi(r,e),Ns(e.level,e.name)&&Ji(r,e);for(const{handler:t,level:s}of Os)e.level.value>=s.value&&t(r,e)});const Qi=1e4;let Nt=Qi,vt=[],hr=ct.OFF;const nt={},Os=[],Be=ke(J({},ct),{enabledFor:Ns,getHistory:()=>vt,getHistoryMaxSize:()=>Nt,setHistoryMaxSize:r=>{Nt=r},setLevel:r=>{hr=r;for(const e in nt)nt[e]=r},getLevel:()=>hr,get:r=>{nt[r]||(nt[r]=hr);const e=ct.get(r);return e.setLevel=t=>{nt[r]=t},e.getLevel=()=>nt[r],e},setHandler:(r,e)=>{Os.push({handler:r,level:e})},diagnose:(r={})=>{let e;const t={statsCount:60,historySize:1e3,minLogLevel:"TRACE",statsFormat:"JSON"};typeof r=="number"?(t.statsCount=r,e=t):e=J(J({},t),r);const{statsCount:s,historySize:d,minLogLevel:p,statsFormat:f}=e,n=Ee.get(s,f),b=Be.getHistory();if(!Number.isInteger(d)||d<=0)throw new Error("Invalid Argument Exception : historySize must be a positive integer.");if(!dr.includes(p.toUpperCase()))throw new Error('Invalid Argument Exception : the minLogLevel parameter only excepts "trace", "debug", "info", "warn", and "error" as arguments.');if(dr.includes(p.toUpperCase())){const y=dr.slice(dr.indexOf(p.toUpperCase())),h=b.filter(a=>y.some(c=>a.includes(c)));n.history=h.slice(-d)}return n},JSON:"JSON",CMCD:"CMCD",VERSION:Fs});var hn={exports:{}},xt=typeof Reflect=="object"?Reflect:null,ss=xt&&typeof xt.apply=="function"?xt.apply:function(e,t,s){return Function.prototype.apply.call(e,t,s)},pr;xt&&typeof xt.ownKeys=="function"?pr=xt.ownKeys:Object.getOwnPropertySymbols?pr=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:pr=function(e){return Object.getOwnPropertyNames(e)};function qi(r){console&&console.warn&&console.warn(r)}var Us=Number.isNaN||function(e){return e!==e};function ne(){ne.init.call(this)}hn.exports=ne;hn.exports.once=no;ne.EventEmitter=ne;ne.prototype._events=void 0;ne.prototype._eventsCount=0;ne.prototype._maxListeners=void 0;var is=10;function kr(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(ne,"defaultMaxListeners",{enumerable:!0,get:function(){return is},set:function(r){if(typeof r!="number"||r<0||Us(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");is=r}});ne.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};ne.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Us(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 Ps(r){return r._maxListeners===void 0?ne.defaultMaxListeners:r._maxListeners}ne.prototype.getMaxListeners=function(){return Ps(this)};ne.prototype.emit=function(e){for(var t=[],s=1;s<arguments.length;s++)t.push(arguments[s]);var d=e==="error",p=this._events;if(p!==void 0)d=d&&p.error===void 0;else if(!d)return!1;if(d){var f;if(t.length>0&&(f=t[0]),f instanceof Error)throw f;var n=new Error("Unhandled error."+(f?" ("+f.message+")":""));throw n.context=f,n}var b=p[e];if(b===void 0)return!1;if(typeof b=="function")ss(b,this,t);else for(var y=b.length,h=Gs(b,y),s=0;s<y;++s)ss(h[s],this,t);return!0};function js(r,e,t,s){var d,p,f;if(kr(t),p=r._events,p===void 0?(p=r._events=Object.create(null),r._eventsCount=0):(p.newListener!==void 0&&(r.emit("newListener",e,t.listener?t.listener:t),p=r._events),f=p[e]),f===void 0)f=p[e]=t,++r._eventsCount;else if(typeof f=="function"?f=p[e]=s?[t,f]:[f,t]:s?f.unshift(t):f.push(t),d=Ps(r),d>0&&f.length>d&&!f.warned){f.warned=!0;var n=new Error("Possible EventEmitter memory leak detected. "+f.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");n.name="MaxListenersExceededWarning",n.emitter=r,n.type=e,n.count=f.length,qi(n)}return r}ne.prototype.addListener=function(e,t){return js(this,e,t,!1)};ne.prototype.on=ne.prototype.addListener;ne.prototype.prependListener=function(e,t){return js(this,e,t,!0)};function eo(){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 $s(r,e,t){var s={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},d=eo.bind(s);return d.listener=t,s.wrapFn=d,d}ne.prototype.once=function(e,t){return kr(t),this.on(e,$s(this,e,t)),this};ne.prototype.prependOnceListener=function(e,t){return kr(t),this.prependListener(e,$s(this,e,t)),this};ne.prototype.removeListener=function(e,t){var s,d,p,f,n;if(kr(t),d=this._events,d===void 0)return this;if(s=d[e],s===void 0)return this;if(s===t||s.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete d[e],d.removeListener&&this.emit("removeListener",e,s.listener||t));else if(typeof s!="function"){for(p=-1,f=s.length-1;f>=0;f--)if(s[f]===t||s[f].listener===t){n=s[f].listener,p=f;break}if(p<0)return this;p===0?s.shift():to(s,p),s.length===1&&(d[e]=s[0]),d.removeListener!==void 0&&this.emit("removeListener",e,n||t)}return this};ne.prototype.off=ne.prototype.removeListener;ne.prototype.removeAllListeners=function(e){var t,s,d;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 p=Object.keys(s),f;for(d=0;d<p.length;++d)f=p[d],f!=="removeListener"&&this.removeAllListeners(f);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(d=t.length-1;d>=0;d--)this.removeListener(e,t[d]);return this};function Ws(r,e,t){var s=r._events;if(s===void 0)return[];var d=s[e];return d===void 0?[]:typeof d=="function"?t?[d.listener||d]:[d]:t?ro(d):Gs(d,d.length)}ne.prototype.listeners=function(e){return Ws(this,e,!0)};ne.prototype.rawListeners=function(e){return Ws(this,e,!1)};ne.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):Bs.call(r,e)};ne.prototype.listenerCount=Bs;function Bs(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}ne.prototype.eventNames=function(){return this._eventsCount>0?pr(this._events):[]};function Gs(r,e){for(var t=new Array(e),s=0;s<e;++s)t[s]=r[s];return t}function to(r,e){for(;e+1<r.length;e++)r[e]=r[e+1];r.pop()}function ro(r){for(var e=new Array(r.length),t=0;t<e.length;++t)e[t]=r[t].listener||r[t];return e}function no(r,e){return new Promise(function(t,s){function d(f){r.removeListener(e,p),s(f)}function p(){typeof r.removeListener=="function"&&r.removeListener("error",d),t([].slice.call(arguments))}Xs(r,e,p,{once:!0}),e!=="error"&&so(r,d,{once:!0})})}function so(r,e,t){typeof r.on=="function"&&Xs(r,"error",e,t)}function Xs(r,e,t,s){if(typeof r.on=="function")s.once?r.once(e,t):r.on(e,t);else if(typeof r.addEventListener=="function")r.addEventListener(e,function d(p){s.once&&r.removeEventListener(e,d),t(p)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof r)}var pn=hn.exports;const Cr=Et(pn);var mn={exports:{}};mn.exports=Ys;mn.exports.filter=oo;var io=pn.EventEmitter;function Ys(r,e,t){Array.isArray(t)||(t=[t]);var s=[];return t.forEach(function(d){var p=function(){var f=[].slice.call(arguments);f.unshift(d),e.emit.apply(e,f)};s.push(p),r.on(d,p)}),function(){t.forEach(function(p,f){r.removeListener(p,s[f])})}}function oo(r,e){var t=new io;return Ys(r,t,e),t}var ao=mn.exports;const vr=Et(ao);var zs={exports:{}};/*! For license information please see webrtc-stats.js.LICENSE.txt */(function(r,e){(function(t,s){r.exports=s()})(self,()=>{return t={7:d=>{var p,f=typeof Reflect=="object"?Reflect:null,n=f&&typeof f.apply=="function"?f.apply:function(S,R,E){return Function.prototype.apply.call(S,R,E)};p=f&&typeof f.ownKeys=="function"?f.ownKeys:Object.getOwnPropertySymbols?function(S){return Object.getOwnPropertyNames(S).concat(Object.getOwnPropertySymbols(S))}:function(S){return Object.getOwnPropertyNames(S)};var b=Number.isNaN||function(S){return S!=S};function y(){y.init.call(this)}d.exports=y,d.exports.once=function(S,R){return new Promise(function(E,T){function x(_){S.removeListener(R,k),T(_)}function k(){typeof S.removeListener=="function"&&S.removeListener("error",x),E([].slice.call(arguments))}w(S,R,k,{once:!0}),R!=="error"&&function(_,M){typeof _.on=="function"&&w(_,"error",M,{once:!0})}(S,x)})},y.EventEmitter=y,y.prototype._events=void 0,y.prototype._eventsCount=0,y.prototype._maxListeners=void 0;var h=10;function a(S){if(typeof S!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof S)}function c(S){return S._maxListeners===void 0?y.defaultMaxListeners:S._maxListeners}function l(S,R,E,T){var x,k,_,M;if(a(E),(k=S._events)===void 0?(k=S._events=Object.create(null),S._eventsCount=0):(k.newListener!==void 0&&(S.emit("newListener",R,E.listener?E.listener:E),k=S._events),_=k[R]),_===void 0)_=k[R]=E,++S._eventsCount;else if(typeof _=="function"?_=k[R]=T?[E,_]:[_,E]:T?_.unshift(E):_.push(E),(x=c(S))>0&&_.length>x&&!_.warned){_.warned=!0;var O=new Error("Possible EventEmitter memory leak detected. "+_.length+" "+String(R)+" listeners added. Use emitter.setMaxListeners() to increase limit");O.name="MaxListenersExceededWarning",O.emitter=S,O.type=R,O.count=_.length,M=O,console&&console.warn&&console.warn(M)}return S}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 o(S,R,E){var T={fired:!1,wrapFn:void 0,target:S,type:R,listener:E},x=i.bind(T);return x.listener=E,T.wrapFn=x,x}function m(S,R,E){var T=S._events;if(T===void 0)return[];var x=T[R];return x===void 0?[]:typeof x=="function"?E?[x.listener||x]:[x]:E?function(k){for(var _=new Array(k.length),M=0;M<_.length;++M)_[M]=k[M].listener||k[M];return _}(x):g(x,x.length)}function u(S){var R=this._events;if(R!==void 0){var E=R[S];if(typeof E=="function")return 1;if(E!==void 0)return E.length}return 0}function g(S,R){for(var E=new Array(R),T=0;T<R;++T)E[T]=S[T];return E}function w(S,R,E,T){if(typeof S.on=="function")T.once?S.once(R,E):S.on(R,E);else{if(typeof S.addEventListener!="function")throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof S);S.addEventListener(R,function x(k){T.once&&S.removeEventListener(R,x),E(k)})}}Object.defineProperty(y,"defaultMaxListeners",{enumerable:!0,get:function(){return h},set:function(S){if(typeof S!="number"||S<0||b(S))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+S+".");h=S}}),y.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},y.prototype.setMaxListeners=function(S){if(typeof S!="number"||S<0||b(S))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+S+".");return this._maxListeners=S,this},y.prototype.getMaxListeners=function(){return c(this)},y.prototype.emit=function(S){for(var R=[],E=1;E<arguments.length;E++)R.push(arguments[E]);var T=S==="error",x=this._events;if(x!==void 0)T=T&&x.error===void 0;else if(!T)return!1;if(T){var k;if(R.length>0&&(k=R[0]),k instanceof Error)throw k;var _=new Error("Unhandled error."+(k?" ("+k.message+")":""));throw _.context=k,_}var M=x[S];if(M===void 0)return!1;if(typeof M=="function")n(M,this,R);else{var O=M.length,U=g(M,O);for(E=0;E<O;++E)n(U[E],this,R)}return!0},y.prototype.addListener=function(S,R){return l(this,S,R,!1)},y.prototype.on=y.prototype.addListener,y.prototype.prependListener=function(S,R){return l(this,S,R,!0)},y.prototype.once=function(S,R){return a(R),this.on(S,o(this,S,R)),this},y.prototype.prependOnceListener=function(S,R){return a(R),this.prependListener(S,o(this,S,R)),this},y.prototype.removeListener=function(S,R){var E,T,x,k,_;if(a(R),(T=this._events)===void 0)return this;if((E=T[S])===void 0)return this;if(E===R||E.listener===R)--this._eventsCount==0?this._events=Object.create(null):(delete T[S],T.removeListener&&this.emit("removeListener",S,E.listener||R));else if(typeof E!="function"){for(x=-1,k=E.length-1;k>=0;k--)if(E[k]===R||E[k].listener===R){_=E[k].listener,x=k;break}if(x<0)return this;x===0?E.shift():function(M,O){for(;O+1<M.length;O++)M[O]=M[O+1];M.pop()}(E,x),E.length===1&&(T[S]=E[0]),T.removeListener!==void 0&&this.emit("removeListener",S,_||R)}return this},y.prototype.off=y.prototype.removeListener,y.prototype.removeAllListeners=function(S){var R,E,T;if((E=this._events)===void 0)return this;if(E.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):E[S]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete E[S]),this;if(arguments.length===0){var x,k=Object.keys(E);for(T=0;T<k.length;++T)(x=k[T])!=="removeListener"&&this.removeAllListeners(x);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(typeof(R=E[S])=="function")this.removeListener(S,R);else if(R!==void 0)for(T=R.length-1;T>=0;T--)this.removeListener(S,R[T]);return this},y.prototype.listeners=function(S){return m(this,S,!0)},y.prototype.rawListeners=function(S){return m(this,S,!1)},y.listenerCount=function(S,R){return typeof S.listenerCount=="function"?S.listenerCount(R):u.call(S,R)},y.prototype.listenerCount=u,y.prototype.eventNames=function(){return this._eventsCount>0?p(this._events):[]}},156:function(d,p,f){var n=this&&this.__createBinding||(Object.create?function(a,c,l,i){i===void 0&&(i=l);var o=Object.getOwnPropertyDescriptor(c,l);o&&!("get"in o?!c.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return c[l]}}),Object.defineProperty(a,i,o)}:function(a,c,l,i){i===void 0&&(i=l),a[i]=c[l]}),b=this&&this.__exportStar||function(a,c){for(var l in a)l==="default"||Object.prototype.hasOwnProperty.call(c,l)||n(c,a,l)},y=this&&this.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(p,"__esModule",{value:!0}),p.Logger=void 0;var h=f(586);Object.defineProperty(p,"Logger",{enumerable:!0,get:function(){return y(h).default}}),b(f(284),p),b(f(280),p),b(f(738),p),b(f(767),p)},185:(d,p)=>{Object.defineProperty(p,"__esModule",{value:!0}),p.calculatePacketsLostRatio=p.calculateRate=p.getMediaKind=void 0,p.getMediaKind=f=>{let n=f.kind||f.mediaType;return["audio","video"].includes(n)||f.type!=="inbound-rtp"||(n=f.id.toLocaleLowerCase().includes("video")?"video":"audio"),n},p.calculateRate=(f,n,b,y)=>b&&y?(n-y)/((f-b)/1e3):0,p.calculatePacketsLostRatio=(f,n,b,y)=>{const h=f-(b!=null?b:0),a=h+(n-(y!=null?y:0));return a===0?0:h/a}},280:(d,p)=>{Object.defineProperty(p,"__esModule",{value:!0})},284:function(d,p,f){var n,b,y,h,a,c,l,i,o,m,u,g,w,S,R,E,T=this&&this.__awaiter||function(W,N,P,Y){return new(P||(P=Promise))(function(G,B){function z(re){try{te(Y.next(re))}catch(fe){B(fe)}}function q(re){try{te(Y.throw(re))}catch(fe){B(fe)}}function te(re){var fe;re.done?G(re.value):(fe=re.value,fe instanceof P?fe:new P(function(ve){ve(fe)})).then(z,q)}te((Y=Y.apply(W,N||[])).next())})},x=this&&this.__classPrivateFieldSet||function(W,N,P,Y,G){if(Y==="m")throw new TypeError("Private method is not writable");if(Y==="a"&&!G)throw new TypeError("Private accessor was defined without a setter");if(typeof N=="function"?W!==N||!G:!N.has(W))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Y==="a"?G.call(W,P):G?G.value=P:N.set(W,P),P},k=this&&this.__classPrivateFieldGet||function(W,N,P,Y){if(P==="a"&&!Y)throw new TypeError("Private accessor was defined without a getter");if(typeof N=="function"?W!==N||!Y:!N.has(W))throw new TypeError("Cannot read private member from an object whose class did not declare it");return P==="m"?Y:P==="a"?Y.call(W):Y?Y.value:N.get(W)},_=this&&this.__importDefault||function(W){return W&&W.__esModule?W:{default:W}};Object.defineProperty(p,"__esModule",{value:!0}),p.WebRTCStats=void 0;const M=f(7),O=_(f(586)),U=f(738),j=f(185);class X extends M.EventEmitter{constructor(N){super(),n.add(this),b.set(this,void 0),y.set(this,void 0),h.set(this,void 0),a.set(this,null),c.set(this,void 0),l.set(this,null),this.start=()=>{k(this,c,"f").info("WebRTC statistics collection is starting..."),x(this,l,null,"f"),x(this,a,setInterval(k(this,i,"f"),k(this,y,"f")),"f")},this.stop=()=>{k(this,a,"f")&&(clearInterval(k(this,a,"f")),x(this,a,null,"f"),k(this,c,"f").info("WebRTC statistics collection has stopped."))},i.set(this,()=>T(this,void 0,void 0,function*(){let P,Y;try{k(this,c,"f").trace("Requesting WebRTC statistics..."),P=yield k(this,b,"f").call(this),Y=new Date().toISOString()}catch(z){return k(this,c,"f").error("Problem collecting the WebRTC statistics.",z),void this.emit("error","Problem collecting the WebRTC statistics - ".concat(z))}const G=Array.from(P.values()),B={timestamp:Y,input:{audio:[],video:[]},output:{audio:[],video:[]}};k(this,h,"f")&&(B.rawStats=P);for(let z=0;z<Object.keys(G).length;z++){const q=G[z];switch(q.type){case"outbound-rtp":const te=q,re=(0,j.getMediaKind)(te);re==="audio"?yield k(this,n,"m",u).call(this,P,te,B):re==="video"&&(yield k(this,n,"m",g).call(this,P,te,B));break;case"inbound-rtp":const fe=q;let ve=(0,j.getMediaKind)(fe);ve==="audio"?yield k(this,n,"m",S).call(this,P,fe,B):ve==="video"&&(yield k(this,n,"m",R).call(this,P,fe,B));break;case"candidate-pair":const De=q;De.nominated&&k(this,n,"m",E).call(this,De,B)}}x(this,l,B,"f"),this.emit("stats",B)})),x(this,c,O.default.get("WebRTCStats"),"f"),x(this,b,N.getStats,"f"),x(this,y,N.getStatsInterval||1e3,"f"),x(this,h,!!N.includeRawStats,"f")}}p.WebRTCStats=X,b=new WeakMap,y=new WeakMap,h=new WeakMap,a=new WeakMap,c=new WeakMap,l=new WeakMap,i=new WeakMap,n=new WeakSet,o=function(W,N){if(N){const P=W.get(N);if(P)return{mimeType:P.mimeType}}return{}},m=function(W,N,P){return T(this,void 0,void 0,function*(){var Y,G,B,z;const q=(0,j.calculateRate)(N.timestamp,N.bytesSent,P==null?void 0:P.timestamp,P==null?void 0:P.totalBytesSent),te=(0,j.calculateRate)(N.timestamp,N.packetsSent,P==null?void 0:P.timestamp,P==null?void 0:P.totalPacketsSent),re=k(this,n,"m",o).call(this,W,N.codecId);return Object.assign({id:N.id,timestamp:N.timestamp,mid:N.mid,totalBytesSent:N.bytesSent,bytesSentDelta:N.bytesSent-((Y=P==null?void 0:P.totalBytesSent)!==null&&Y!==void 0?Y:0),totalPacketsSent:N.packetsSent,packetsSentDelta:N.packetsSent-((G=P==null?void 0:P.totalPacketsSent)!==null&&G!==void 0?G:0),bitrate:q,packetRate:te,targetBitrate:N.targetBitrate,retransmittedPacketsSent:N.retransmittedPacketsSent,retransmittedPacketsSentDelta:N.retransmittedPacketsSent-((B=P==null?void 0:P.retransmittedPacketsSent)!==null&&B!==void 0?B:0),retransmittedBytesSent:N.retransmittedBytesSent,retransmittedBytesSentDelta:N.retransmittedBytesSent-((z=P==null?void 0:P.retransmittedBytesSent)!==null&&z!==void 0?z:0)},re)})},u=function(W,N,P){return T(this,void 0,void 0,function*(){var Y;const G=(Y=k(this,l,"f"))===null||Y===void 0?void 0:Y.output.audio.find(q=>q.id===N.id);if(G&&N.timestamp-G.timestamp<=0)return;const B=yield k(this,n,"m",m).call(this,W,N,G),z=Object.assign({},B);P.output.audio.push(z)})},g=function(W,N,P){return T(this,void 0,void 0,function*(){var Y;const G=(Y=k(this,l,"f"))===null||Y===void 0?void 0:Y.output.video.find(te=>te.id===N.id);if(G&&N.timestamp-G.timestamp<=0)return;const B=yield k(this,n,"m",m).call(this,W,N,G);let z=U.QualityLimitationReason.none;N.qualityLimitationReason&&(z=N.qualityLimitationReason);const q=Object.assign(Object.assign({},B),{frameWidth:N.frameWidth,frameHeight:N.frameHeight,framesPerSecond:N.framesPerSecond,framesSent:N.framesSent,qualityLimitationReason:z,qualityLimitationDurations:N.qualityLimitationDurations});P.output.video.push(q)})},w=function(W,N,P){return T(this,void 0,void 0,function*(){var Y,G;const B=(0,j.calculateRate)(N.timestamp,N.bytesReceived,P==null?void 0:P.timestamp,P==null?void 0:P.totalBytesReceived),z=(0,j.calculateRate)(N.timestamp,N.packetsReceived,P==null?void 0:P.timestamp,P==null?void 0:P.totalPacketsReceived),q=(0,j.calculatePacketsLostRatio)(N.packetsLost,N.packetsReceived,P==null?void 0:P.totalPacketsLost,P==null?void 0:P.totalPacketsReceived),te=((Y=N.packetsLost)!==null&&Y!==void 0?Y:0)-((G=P==null?void 0:P.totalPacketsLost)!==null&&G!==void 0?G:0),re=k(this,n,"m",o).call(this,W,N.codecId);return Object.assign({id:N.id,timestamp:N.timestamp,mid:N.mid,trackIdentifier:N.trackIdentifier,jitter:N.jitter,jitterBufferDelay:N.jitterBufferDelay,jitterBufferEmittedCount:N.jitterBufferEmittedCount,totalBytesReceived:N.bytesReceived,totalPacketsReceived:N.packetsReceived,totalPacketsLost:N.packetsLost,bitrate:B,packetRate:z,packetLossRatio:q,packetLossDelta:te},re)})},S=function(W,N,P){return T(this,void 0,void 0,function*(){var Y;const G=(Y=k(this,l,"f"))===null||Y===void 0?void 0:Y.input.audio.find(z=>z.id===N.id);if(G&&N.timestamp-G.timestamp<=0)return;const B=yield k(this,n,"m",w).call(this,W,N,G);P.input.audio.push(B)})},R=function(W,N,P){return T(this,void 0,void 0,function*(){var Y;const G=(Y=k(this,l,"f"))===null||Y===void 0?void 0:Y.input.video.find(q=>q.id===N.id);if(G&&N.timestamp-G.timestamp<=0)return;const B=yield k(this,n,"m",w).call(this,W,N,G),z=Object.assign(Object.assign({},B),{keyFramesDecoded:N.keyFramesDecoded,frameHeight:N.frameHeight,frameWidth:N.frameWidth,framesDecoded:N.framesDecoded,framesDropped:N.framesDropped,framesPerSecond:N.framesPerSecond,framesReceived:N.framesReceived});P.input.video.push(z)})},E=function(W,N){N.totalRoundTripTime=W.totalRoundTripTime,N.currentRoundTripTime=W.currentRoundTripTime,N.responsesReceived=W.responsesReceived,N.availableOutgoingBitrate=W.availableOutgoingBitrate,N.availableIncomingBitrate=W.availableIncomingBitrate}},586:function(d,p,f){var n,b;(function(){var y,h={VERSION:"1.6.1"},a={},c=function(g,w){return function(){return w.apply(g,arguments)}},l=function(){var g,w,S=arguments,R=S[0];for(w=1;w<S.length;w++)for(g in S[w])!(g in R)&&S[w].hasOwnProperty(g)&&(R[g]=S[w][g]);return R},i=function(g,w){return{value:g,name:w}};h.TRACE=i(1,"TRACE"),h.DEBUG=i(2,"DEBUG"),h.INFO=i(3,"INFO"),h.TIME=i(4,"TIME"),h.WARN=i(5,"WARN"),h.ERROR=i(8,"ERROR"),h.OFF=i(99,"OFF");var o=function(g){this.context=g,this.setLevel(g.filterLevel),this.log=this.info};o.prototype={setLevel:function(g){g&&"value"in g&&(this.context.filterLevel=g)},getLevel:function(){return this.context.filterLevel},enabledFor:function(g){var w=this.context.filterLevel;return g.value>=w.value},trace:function(){this.invoke(h.TRACE,arguments)},debug:function(){this.invoke(h.DEBUG,arguments)},info:function(){this.invoke(h.INFO,arguments)},warn:function(){this.invoke(h.WARN,arguments)},error:function(){this.invoke(h.ERROR,arguments)},time:function(g){typeof g=="string"&&g.length>0&&this.invoke(h.TIME,[g,"start"])},timeEnd:function(g){typeof g=="string"&&g.length>0&&this.invoke(h.TIME,[g,"end"])},invoke:function(g,w){y&&this.enabledFor(g)&&y(w,l({level:g},this.context))}};var m,u=new o({filterLevel:h.OFF});(m=h).enabledFor=c(u,u.enabledFor),m.trace=c(u,u.trace),m.debug=c(u,u.debug),m.time=c(u,u.time),m.timeEnd=c(u,u.timeEnd),m.info=c(u,u.info),m.warn=c(u,u.warn),m.error=c(u,u.error),m.log=m.info,h.setHandler=function(g){y=g},h.setLevel=function(g){for(var w in u.setLevel(g),a)a.hasOwnProperty(w)&&a[w].setLevel(g)},h.getLevel=function(){return u.getLevel()},h.get=function(g){return a[g]||(a[g]=new o(l({name:g},u.context)))},h.createDefaultHandler=function(g){(g=g||{}).formatter=g.formatter||function(R,E){E.name&&R.unshift("["+E.name+"]")};var w={},S=function(R,E){Function.prototype.apply.call(R,console,E)};return typeof console>"u"?function(){}:function(R,E){R=Array.prototype.slice.call(R);var T,x=console.log;E.level===h.TIME?(T=(E.name?"["+E.name+"] ":"")+R[0],R[1]==="start"?console.time?console.time(T):w[T]=new Date().getTime():console.timeEnd?console.timeEnd(T):S(x,[T+": "+(new Date().getTime()-w[T])+"ms"])):(E.level===h.WARN&&console.warn?x=console.warn:E.level===h.ERROR&&console.error?x=console.error:E.level===h.INFO&&console.info?x=console.info:E.level===h.DEBUG&&console.debug?x=console.debug:E.level===h.TRACE&&console.trace&&(x=console.trace),g.formatter(R,E),S(x,R))}},h.useDefaults=function(g){h.setLevel(g&&g.defaultLevel||h.DEBUG),h.setHandler(h.createDefaultHandler(g))},h.setDefaults=h.useDefaults,(b=typeof(n=h)=="function"?n.call(p,f,p,d):n)===void 0||(d.exports=b)})()},738:(d,p)=>{var f;Object.defineProperty(p,"__esModule",{value:!0}),p.QualityLimitationReason=void 0,function(n){n[n.none=0]="none",n[n.cpu=1]="cpu",n[n.bandwidth=2]="bandwidth",n[n.other=3]="other"}(f||(p.QualityLimitationReason=f={}))},767:(d,p)=>{Object.defineProperty(p,"__esModule",{value:!0})}},s={},function d(p){var f=s[p];if(f!==void 0)return f.exports;var n=s[p]={exports:{}};return t[p].call(n.exports,n,n.exports,d),n.exports}(156);var t,s})})(zs);var co=zs.exports;const Mt=Be.get("PeerConnectionStats"),Ks={stats:"stats"},lo=r=>{const f=r,{input:e,output:t,rawStats:s}=f,d=rt(f,["input","output","rawStats"]);return ke(J({},d),{audio:{inbounds:r.input.audio.map(a=>{var c=a,{packetLossRatio:n,packetLossDelta:b,bitrate:y}=c,h=rt(c,["packetLossRatio","packetLossDelta","bitrate"]);return J({packetsLostRatioPerSecond:n,packetsLostDeltaPerSecond:b,bitrateBitsPerSecond:y*8,bitrate:y},h)}),outbounds:r.output.audio.map(a=>{var c=a,{packetLossRatio:n,packetLossDelta:b,bitrate:y}=c,h=rt(c,["packetLossRatio","packetLossDelta","bitrate"]);return J({packetsLostRatioPerSecond:n,packetsLostDeltaPerSecond:b,bitrateBitsPerSecond:y*8,bitrate:y},h)})},video:{inbounds:r.input.video.map(a=>{var c=a,{packetLossRatio:n,packetLossDelta:b,bitrate:y}=c,h=rt(c,["packetLossRatio","packetLossDelta","bitrate"]);return J({packetsLostRatioPerSecond:n,packetsLostDeltaPerSecond:b,bitrateBitsPerSecond:y*8,bitrate:y},h)}),outbounds:r.output.video.map(a=>{var c=a,{packetLossRatio:n,packetLossDelta:b,bitrate:y}=c,h=rt(c,["packetLossRatio","packetLossDelta","bitrate"]);return J({packetsLostRatioPerSecond:n,packetsLostDeltaPerSecond:b,bitrateBitsPerSecond:y*8,bitrate:y},h)})},raw:r.rawStats})};class uo extends Cr{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){Mt.warn("PeerConnectionStats.init() has already been called. Automatic initialization occurs when the PeerConnectionStats object is constructed.");return}Mt.info("Initializing peer connection stats");const t=this.peer;try{this.collection=new co.WebRTCStats({getStatsInterval:e,getStats:()=>t.getStats(),includeRawStats:!0}),this.collection.on("stats",s=>{const d=lo(s);Ee.addStats(d),this.emit(Ks.stats,d)}),this.collection.start(),this.initialized=!0}catch(s){Mt.error(s)}}parseStats(e){return Mt.warn("The parseStats method is deprecated and will be removed in future releases."),null}stop(){Mt.info("Stopping peer connection stats"),this.collection.stop()}}var ye={},Xe={},Hs={},Js={exports:{}},os=Js.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(r){return r.encoding?"rtpmap:%d %s/%s/%s":r.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(r){return r.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(r){return r.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(r){return"extmap:%d"+(r.direction?"/%s":"%v")+(r["encrypt-uri"]?" %s":"%v")+" %s"+(r.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(r){return r.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(r){var e="candidate:%s %d %s %d %s %d typ %s";return e+=r.raddr!=null?" raddr %s rport %d":"%v%v",e+=r.tcptype!=null?" tcptype %s":"%v",r.generation!=null&&(e+=" generation %d"),e+=r["network-id"]!=null?" network-id %d":"%v",e+=r["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(r){var e="ssrc:%d";return r.attribute!=null&&(e+=" %s",r.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(r){return r.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(r){return r.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(r){return"imageattr:%s %s %s"+(r.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(r){return"simulcast:%s %s"+(r.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(r){return"ts-refclk:%s"+(r.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(r){var e="mediaclk:";return e+=r.id!=null?"id=%s %s":"%v%s",e+=r.mediaClockValue!=null?"=%s":"",e+=r.rateNumerator!=null?" rate=%s":"",e+=r.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(os).forEach(function(r){var e=os[r];e.forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})});var Qs=Js.exports;(function(r){var e=function(n){return String(Number(n))===n?Number(n):n},t=function(n,b,y,h){if(h&&!y)b[h]=e(n[1]);else for(var a=0;a<y.length;a+=1)n[a+1]!=null&&(b[y[a]]=e(n[a+1]))},s=function(n,b,y){var h=n.name&&n.names;n.push&&!b[n.push]?b[n.push]=[]:h&&!b[n.name]&&(b[n.name]={});var a=n.push?{}:h?b[n.name]:b;t(y.match(n.reg),a,n.names,n.name),n.push&&b[n.push].push(a)},d=Qs,p=RegExp.prototype.test.bind(/^([a-z])=(.*)/);r.parse=function(n){var b={},y=[],h=b;return n.split(/(\r\n|\r|\n)/).filter(p).forEach(function(a){var c=a[0],l=a.slice(2);c==="m"&&(y.push({rtp:[],fmtp:[]}),h=y[y.length-1]);for(var i=0;i<(d[c]||[]).length;i+=1){var o=d[c][i];if(o.reg.test(l))return s(o,h,l)}}),b.media=y,b};var f=function(n,b){var y=b.split(/=(.+)/,2);return y.length===2?n[y[0]]=e(y[1]):y.length===1&&b.length>1&&(n[y[0]]=void 0),n};r.parseParams=function(n){return n.split(/;\s?/).reduce(f,{})},r.parseFmtpConfig=r.parseParams,r.parsePayloads=function(n){return n.toString().split(" ").map(Number)},r.parseRemoteCandidates=function(n){for(var b=[],y=n.split(" ").map(e),h=0;h<y.length;h+=3)b.push({component:y[h],ip:y[h+1],port:y[h+2]});return b},r.parseImageAttributes=function(n){return n.split(" ").map(function(b){return b.substring(1,b.length-1).split(",").reduce(f,{})})},r.parseSimulcastStreamList=function(n){return n.split(";").map(function(b){return b.split(",").map(function(y){var h,a=!1;return y[0]!=="~"?h=e(y):(h=e(y.substring(1,y.length)),a=!0),{scid:h,paused:a}})})}})(Hs);var Nr=Qs,fo=/%[sdv%]/g,ho=function(r){var e=1,t=arguments,s=t.length;return r.replace(fo,function(d){if(e>=s)return d;var p=t[e];switch(e+=1,d){case"%%":return"%";case"%s":return String(p);case"%d":return Number(p);case"%v":return""}})},Lt=function(r,e,t){var s=e.format instanceof Function?e.format(e.push?t:t[e.name]):e.format,d=[r+"="+s];if(e.names)for(var p=0;p<e.names.length;p+=1){var f=e.names[p];e.name?d.push(t[e.name][f]):d.push(t[e.names[p]])}else d.push(t[e.name]);return ho.apply(null,d)},po=["v","o","s","i","u","e","p","c","b","t","r","z","a"],mo=["i","c","b","a"],go=function(r,e){e=e||{},r.version==null&&(r.version=0),r.name==null&&(r.name=" "),r.media.forEach(function(p){p.payloads==null&&(p.payloads="")});var t=e.outerOrder||po,s=e.innerOrder||mo,d=[];return t.forEach(function(p){Nr[p].forEach(function(f){f.name in r&&r[f.name]!=null?d.push(Lt(p,f,r)):f.push in r&&r[f.push]!=null&&r[f.push].forEach(function(n){d.push(Lt(p,f,n))})})}),r.media.forEach(function(p){d.push(Lt("m",Nr.m[0],p)),s.forEach(function(f){Nr[f].forEach(function(n){n.name in p&&p[n.name]!=null?d.push(Lt(f,n,p)):n.push in p&&p[n.push]!=null&&p[n.push].forEach(function(b){d.push(Lt(f,n,b))})})})}),d.join("\r\n")+"\r\n"},ht=Hs,yo=go;Xe.write=yo;Xe.parse=ht.parse;Xe.parseParams=ht.parseParams;Xe.parseFmtpConfig=ht.parseFmtpConfig;Xe.parsePayloads=ht.parsePayloads;Xe.parseRemoteCandidates=ht.parseRemoteCandidates;Xe.parseImageAttributes=ht.parseImageAttributes;Xe.parseSimulcastStreamList=ht.parseSimulcastStreamList;var bo=function(r){const e=new Intl.Collator(r,{sensitivity:"base"});return(t,s)=>e.compare(t,s)==0};let Pt=class qs{constructor(e,t,s,d,p,f,n,b,y){this.foundation=e,this.componentId=t,this.transport=s,this.priority=d,this.address=p,this.port=f,this.type=n,this.relAddr=b,this.relPort=y}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 qs(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}};Pt.expand=function(r){return r.constructor.name==="CandidateInfo"?r:(r=r,new Pt(r.foundation,r.componentId,r.transport,r.priority,r.address,r.port,r.type,r.relAddr,r.relPort))};Pt.clone=function(r){return r.constructor.name==="CandidateInfo"?r.clone():Pt.expand(r)};var ei=Pt;let jt=class ti{constructor(e,t){this.id=e,this.params=t||[]}clone(){return new ti(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}};jt.expand=function(r){return r.constructor.name==="RTCPFeedbackInfo"?r:(r=r,new jt(r.id,r.params))};jt.clone=function(r){return r.constructor.name==="RTCPFeedbackInfo"?r.clone():jt.expand(r)};var gn=jt;const ri=gn;let lt=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 ".concat(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}};lt.expand=function(r){if(r.constructor.name==="CodecInfo")return r;r=r;const e=new lt(r.codec,r.type,r.params);r.rtx&&e.setRTX(r.rtx),r.channels&&e.setChannels(r.channels);for(const t of r.rtcpfbs||[]){const s=ri.expand(t);e.addRTCPFeedback(s)}return e};lt.clone=function(r){return r.constructor.name==="CodecInfo"?r.clone():lt.expand(r)};lt.MapFromNames=function(r,e,t){var s;const d=new Map;let p=96;for(const f of r){let n;const b=f.split(";"),y=b.shift().toLowerCase().trim();y==="pcmu"?n=0:y==="pcma"?n=8:n=++p;const h=new lt(y,n);y==="opus"?h.setChannels(2):y==="multiopus"&&h.setChannels(6),e&&y!=="ulpfec"&&y!=="flexfec-03"&&y!=="red"&&h.setRTX(++p);for(const a of t||[])h.addRTCPFeedback(new ri(a.id,a.params));for(const a of b){let c=a.split("=");h.addParam(c[0].trim(),(s=c[1])===null||s===void 0?void 0:s.trim())}d.set(n,h)}return d};var Er=lt;function zr(){var r=this;if(!(this instanceof zr))return new(Function.prototype.bind.apply(zr,[null].concat(Array.prototype.slice.call(arguments))));Array.from(arguments).forEach(function(e){r[e]=Symbol.for("MEDOOZE_SEMANTIC_SDP_"+e)})}var yn=zr;const vo=yn,me=vo("ACTIVE","PASSIVE","ACTPASS","INACTIVE");me.byValue=function(r){switch(r){case me.ACTIVE:case me.PASSIVE:case me.ACTPASS:case me.INACTIVE:return r}return me[r.toUpperCase()]};me.toString=function(r){switch(r){case me.ACTIVE:return"active";case me.PASSIVE:return"passive";case me.ACTPASS:return"actpass";case me.INACTIVE:return"inactive"}};me.reverse=function(r,e){switch(r){case me.ACTIVE:return me.PASSIVE;case me.PASSIVE:return me.ACTIVE;case me.ACTPASS:return e?me.ACTIVE:me.PASSIVE;case me.INACTIVE:return me.INACTIVE}};var bn=me;const Kr=bn;let $t=class si{constructor(e,t,s){this.setup=e,this.hash=t,this.fingerprint=s}clone(){return new si(this.setup,this.hash,this.fingerprint)}plain(){return{setup:Kr.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}};$t.expand=function(r){return r.constructor.name==="DTLSInfo"?r:(r=r,new $t(r.setup?Kr.byValue(r.setup):Kr.ACTPASS,r.hash,r.fingerprint))};$t.clone=function(r){return r.constructor.name==="DTLSInfo"?r.clone():$t.expand(r)};var ii=$t;let Wt=class oi{constructor(e,t,s,d){this.tag=e,this.suite=t,this.keyParams=s,this.sessionParams=d}clone(){return new oi(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}};Wt.expand=function(r){return r.constructor.name==="CryptoInfo"?r:(r=r,new Wt(r.tag,r.suite,r.keyParams,r.sessionParams))};Wt.clone=function(r){return r.constructor.name==="CryptoInfo"?r.clone():Wt.expand(r)};var ai=Wt,Hr={exports:{}},Jr={exports:{}},ci={},_r={};_r.byteLength=xo;_r.toByteArray=Ro;_r.fromByteArray=Eo;var je=[],Fe=[],wo=typeof Uint8Array<"u"?Uint8Array:Array,Or="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var gt=0,So=Or.length;gt<So;++gt)je[gt]=Or[gt],Fe[Or.charCodeAt(gt)]=gt;Fe[45]=62;Fe[95]=63;function li(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var s=t===e?0:4-t%4;return[t,s]}function xo(r){var e=li(r),t=e[0],s=e[1];ret