trtc-sdk-v5 5.15.1-beta.8 → 5.15.1-wasm.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ var Xu=Object.create;var pr=Object.defineProperty,Qu=Object.defineProperties,ui=Object.getOwnPropertyDescriptor,zu=Object.getOwnPropertyDescriptors,Zu=Object.getOwnPropertyNames,mr=Object.getOwnPropertySymbols,ec=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty,ci=Object.prototype.propertyIsEnumerable;var _n=(n,t,e)=>t in n?pr(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,Mt=(n,t)=>{for(var e in t||(t={}))fn.call(t,e)&&_n(n,e,t[e]);if(mr)for(var e of mr(t))ci.call(t,e)&&_n(n,e,t[e]);return n},li=(n,t)=>Qu(n,zu(t));var di=(n,t)=>{var e={};for(var r in n)fn.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&mr)for(var r of mr(n))t.indexOf(r)<0&&ci.call(n,r)&&(e[r]=n[r]);return e};var tc=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var rc=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Zu(t))!fn.call(n,s)&&s!==e&&pr(n,s,{get:()=>t[s],enumerable:!(r=ui(t,s))||r.enumerable});return n};var _r=(n,t,e)=>(e=n!=null?Xu(ec(n)):{},rc(t||!n||!n.__esModule?pr(e,"default",{value:n,enumerable:!0}):e,n));var le=(n,t,e,r)=>{for(var s=r>1?void 0:r?ui(t,e):t,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=(r?u(t,e,s):u(s))||s);return r&&s&&pr(t,e,s),s};var d=(n,t,e)=>_n(n,typeof t!="symbol"?t+"":t,e);var qt=tc((Km,gs)=>{"use strict";var el=Object.prototype.hasOwnProperty,pe="~";function Ht(){}Object.create&&(Ht.prototype=Object.create(null),new Ht().__proto__||(pe=!1));function tl(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function lo(n,t,e,r,s){if(typeof e!="function")throw new TypeError("The listener must be a function");var o=new tl(e,r||n,s),u=pe?pe+t:t;return n._events[u]?n._events[u].fn?n._events[u]=[n._events[u],o]:n._events[u].push(o):(n._events[u]=o,n._eventsCount++),n}function Mr(n,t){--n._eventsCount===0?n._events=new Ht:delete n._events[t]}function ue(){this._events=new Ht,this._eventsCount=0}ue.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)el.call(e,r)&&t.push(pe?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};ue.prototype.listeners=function(t){var e=pe?pe+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var s=0,o=r.length,u=new Array(o);s<o;s++)u[s]=r[s].fn;return u};ue.prototype.listenerCount=function(t){var e=pe?pe+t:t,r=this._events[e];return r?r.fn?1:r.length:0};ue.prototype.emit=function(t,e,r,s,o,u){var p=pe?pe+t:t;if(!this._events[p])return!1;var l=this._events[p],m=arguments.length,h,f;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),m){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,r),!0;case 4:return l.fn.call(l.context,e,r,s),!0;case 5:return l.fn.call(l.context,e,r,s,o),!0;case 6:return l.fn.call(l.context,e,r,s,o,u),!0}for(f=1,h=new Array(m-1);f<m;f++)h[f-1]=arguments[f];l.fn.apply(l.context,h)}else{var g=l.length,y;for(f=0;f<g;f++)switch(l[f].once&&this.removeListener(t,l[f].fn,void 0,!0),m){case 1:l[f].fn.call(l[f].context);break;case 2:l[f].fn.call(l[f].context,e);break;case 3:l[f].fn.call(l[f].context,e,r);break;case 4:l[f].fn.call(l[f].context,e,r,s);break;default:if(!h)for(y=1,h=new Array(m-1);y<m;y++)h[y-1]=arguments[y];l[f].fn.apply(l[f].context,h)}}return!0};ue.prototype.on=function(t,e,r){return lo(this,t,e,r,!1)};ue.prototype.once=function(t,e,r){return lo(this,t,e,r,!0)};ue.prototype.removeListener=function(t,e,r,s){var o=pe?pe+t:t;if(!this._events[o])return this;if(!e)return Mr(this,o),this;var u=this._events[o];if(u.fn)u.fn===e&&(!s||u.once)&&(!r||u.context===r)&&Mr(this,o);else{for(var p=0,l=[],m=u.length;p<m;p++)(u[p].fn!==e||s&&!u[p].once||r&&u[p].context!==r)&&l.push(u[p]);l.length?this._events[o]=l.length===1?l[0]:l:Mr(this,o)}return this};ue.prototype.removeAllListeners=function(t){var e;return t?(e=pe?pe+t:t,this._events[e]&&Mr(this,e)):(this._events=new Ht,this._eventsCount=0),this};ue.prototype.off=ue.prototype.removeListener;ue.prototype.addListener=ue.prototype.on;ue.prefixed=pe;ue.EventEmitter=ue;typeof gs!="undefined"&&(gs.exports=ue)});function $(...n){}var nc=n=>n();function bn(){this.dispose()}var sc=()=>typeof __FASTRX_DEVTOOLS__!="undefined",ic=1,Ne=class extends Function{toString(){return`${this.name}(${this.args.length?[...this.args].join(", "):""})`}subscribe(t){let e=new hn(t,this,this.streamId++);return ee.subscribe({id:this.id,end:!1},{nodeId:e.sourceId,streamId:e.id}),this(e),e}},ht=class{constructor(){this.defers=new Set,this.disposed=!1}next(t){}complete(){this.dispose()}error(t){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=$,this.error=$,this.next=$,this.dispose=$,this.subscribe=$,this.doDefer()}subscribe(t){return t instanceof Ne?t.subscribe(this):t(this),this}get bindSubscribe(){return t=>this.subscribe(t)}doDefer(){this.defers.forEach(nc),this.defers.clear()}defer(t){this.defers.add(t)}removeDefer(t){this.defers.delete(t)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},N=class extends ht{constructor(t){super(),this.sink=t,t.defer(this.bindDispose)}next(t){this.sink.next(t)}complete(){this.sink.complete()}error(t){this.sink.error(t)}},fr=class extends ht{constructor(t,e=$,r=$,s=$){if(super(),this._next=e,this._error=r,this._complete=s,this.then=$,t instanceof Ne){let o={toString:()=>"subscribe",id:0,source:t};this.defer(()=>{ee.defer(o,0)}),ee.create(o),ee.pipe(o),this.sourceId=o.id,this.subscribe(t),ee.subscribe({id:o.id,end:!0}),e==$?this._next=u=>ee.next(o,0,u):this.next=u=>{ee.next(o,0,u),e(u)},s==$?this._complete=()=>ee.complete(o,0):this.complete=()=>{this.dispose(),ee.complete(o,0),s()},r==$?this._error=u=>ee.complete(o,0,u):this.error=u=>{this.dispose(),ee.complete(o,0,u),r(u)}}else this.subscribe(t)}next(t){this._next(t)}complete(){this.dispose(),this._complete()}error(t){this.dispose(),this._error(t)}};function H(n,...t){return t.reduce((e,r)=>r(e),n)}function de(n,t,e){if(sc()){let r=Object.defineProperties(Object.setPrototypeOf(n,Ne.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:e,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});ee.create(r);for(let s=0;s<e.length;s++){let o=e[s];typeof o=="function"&&o instanceof Ne&&ee.addSource(r,o)}return r}return n}function L(n,t){return function(...e){return r=>{if(r instanceof Ne){let s=de(o=>{let u=new n(o,...e);u.sourceId=s.id,u.subscribe(r)},t,arguments);return s.source=r,ee.pipe(s),s}else return s=>r(new n(s,...e))}}}function Ge(n,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:n,payload:t}})}var hn=class extends N{constructor(t,e,r){super(t),this.source=e,this.id=r,this.sourceId=t.sourceId,this.defer(()=>{ee.defer(this.source,this.id)})}next(t){ee.next(this.source,this.id,t),this.sink.next(t)}complete(){ee.complete(this.source,this.id),this.sink.complete()}error(t){ee.complete(this.source,this.id,t),this.sink.error(t)}},ee={addSource(n,t){Ge("addSource",{id:n.id,name:n.toString(),source:{id:t.id,name:t.toString()}})},next(n,t,e){Ge("next",{id:n.id,streamId:t,data:e&&e.toString()})},subscribe({id:n,end:t},e){Ge("subscribe",{id:n,end:t,sink:{nodeId:e&&e.nodeId,streamId:e&&e.streamId}})},complete(n,t,e){Ge("complete",{id:n.id,streamId:t,err:e?e.toString():null})},defer(n,t){Ge("defer",{id:n.id,streamId:t})},pipe(n){Ge("pipe",{name:n.toString(),id:n.id,source:{id:n.source.id,name:n.source.toString()}})},update(n){Ge("update",{id:n.id,name:n.toString()})},create(n){n.id||(n.id=ic++),Ge("create",{name:n.toString(),id:n.id})}},hr=class extends Error{constructor(t){super(`timeout after ${t}ms`),this.timeout=t}};var gn=class extends ht{constructor(t){super(),this.source=t,this.sinks=new Set}add(t){t.defer(()=>this.remove(t)),this.sinks.add(t).size===1&&(this.reset(),this.subscribe(this.source))}remove(t){this.sinks.delete(t),this.sinks.size===0&&this.dispose()}next(t){this.sinks.forEach(e=>e.next(t))}complete(){this.sinks.forEach(t=>t.complete()),this.sinks.clear()}error(t){this.sinks.forEach(e=>e.error(t)),this.sinks.clear()}};function We(){return n=>{let t=new gn(n);if(n instanceof Ne){let e=de(r=>{t.add(r)},"share",arguments);return t.sourceId=e.id,e.source=n,ee.pipe(e),e}return de(t.add.bind(t),"share",arguments)}}function mi(...n){return de(t=>{let e=new N(t),r=n.length;e.complete=()=>{--r===0&&t.complete()},n.forEach(e.bindSubscribe)},"merge",arguments)}function oc(...n){return de(t=>{let e=n.length,r=e,s=e,o=new Array(e),u=()=>{--s===0&&t.complete()},p=(l,m)=>{let h=new N(t);h.next=f=>{r--,h.next=g=>{o[m]=g,r===0&&t.next(o)},h.next(f)},h.complete=u,h.subscribe(l)};n.forEach(p)},"combineLatest",arguments)}function pi(...n){return de(t=>{let e=n.length,r=e,s=new Array(e),o=()=>{--r===0&&t.complete()},u=(p,l)=>{let m=new N(t),h=[];s[l]=h,m.next=f=>{h.push(f),s.every(g=>g.length)&&t.next(s.map(g=>g.shift()))},m.complete=o,m.subscribe(p)};n.forEach(u)},"zip",arguments)}var En=class extends N{constructor(t,...e){super(t);let r=new N(this.sink);r.next=s=>this.buffer=s,r.complete=$,r.subscribe(oc(...e))}next(t){this.buffer&&this.sink.next([t,...this.buffer])}},Ml=L(En,"withLatestFrom"),Tn=class extends N{constructor(t,e,r){super(t),this.bufferSize=e,this.startBufferEvery=r,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(t){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach(e=>{e.push(t)}),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(t),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach(t=>this.sink.next(t)),super.complete()}},kl=L(Tn,"bufferCount"),In=class extends N{constructor(t,e){super(t),this.buffer=[];let r=new N(t);r.next=s=>{t.next(this.buffer),this.buffer=[]},r.complete=$,r.subscribe(e)}next(t){this.buffer.push(t)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},Bl=L(In,"buffer");function ze(n){let t=arguments,e=We()(de(r=>{e.next=s=>r.next(s),e.complete=()=>r.complete(),e.error=s=>r.error(s),n&&r.subscribe(n)},"subject",t));return e.next=$,e.complete=$,e.error=$,e}var br={promise:n=>{Promise.resolve().then(n)},setImmediate:typeof setImmediate!="undefined"?n=>setImmediate(n):null,setTimeout:n=>setTimeout(n,0)},ac=()=>typeof Promise!="undefined"?br.promise:br.setImmediate?br.setImmediate:br.setTimeout,ql=ac();function bt(n){return de(t=>{let e=0,r=setInterval(()=>t.next(e++),n);return t.defer(()=>{clearInterval(r)}),"interval"},"interval",arguments)}function _i(n,t){return de(e=>{let r=0,s=setTimeout(()=>{if(e.removeDefer(o),e.next(r++),t){let u=setInterval(()=>e.next(r++),t);e.defer(()=>{clearInterval(u)})}else e.complete()},n),o=()=>clearTimeout(s);e.defer(o)},"timer",arguments)}function Sn(n,t){return e=>{let r=s=>e.next(s);e.defer(()=>t(r)),n(r)}}function Se(n,t){if("on"in n&&"off"in n)return de(Sn(e=>n.on(t,e),e=>n.off(t,e)),"fromEvent",arguments);if("addListener"in n&&"removeListener"in n)return de(Sn(e=>n.addListener(t,e),e=>n.removeListener(t,e)),"fromEvent",arguments);if("addEventListener"in n)return de(Sn(e=>n.addEventListener(t,e),e=>n.removeEventListener(t,e)),"fromEvent",arguments);throw"target is not a EventDispachter"}var An=class extends N{constructor(t,e,r){super(t),this.f=e;let s=()=>{this.sink.next(this.acc),this.sink.complete()};typeof r=="undefined"?this.next=o=>{this.acc=o,this.complete=s,this.resetNext()}:(this.acc=r,this.complete=s)}next(t){this.acc=this.f(this.acc,t)}},uc=L(An,"reduce");var yn=class extends N{constructor(t,e,r){super(t),this.filter=e,this.thisArg=r}next(t){this.filter.call(this.thisArg,t)&&this.sink.next(t)}},gt=L(yn,"filter"),Rn=class extends N{next(t){}},Jl=L(Rn,"ignoreElements"),Un=class extends N{constructor(t,e){super(t),this.count=e}next(t){this.sink.next(t),--this.count===0&&(this.doDefer(),this.complete())}},Er=L(Un,"take"),On=class extends N{constructor(t,e){super(t);let r=new N(t);r.next=()=>{r.doDefer(),t.complete()},r.complete=bn,r.subscribe(e)}},Oe=L(On,"takeUntil"),xn=class extends N{constructor(t,e){super(t),this.f=e}next(t){this.f(t)?this.sink.next(t):(this.doDefer(),this.complete())}},Fn=L(xn,"takeWhile");var Pn=class extends N{constructor(t,e){super(t),this.count=e}next(t){--this.count===0&&(this.next=super.next)}},Xl=L(Pn,"skip"),vn=class extends N{constructor(t,e){super(t),t.next=$;let r=new N(t);r.next=()=>{r.doDefer(),t.resetNext()},r.complete=bn,r.subscribe(e)}},Ql=L(vn,"skipUntil"),Dn=class extends N{constructor(t,e){super(t),this.f=e}next(t){this.f(t)||(this.next=super.next,this.next(t))}},fi=L(Dn,"skipWhile"),cc={leading:!0,trailing:!1},Nn=class extends N{constructor(t,e,r){super(t),this.durationSelector=e,this.trailing=r}cacheValue(t){this.last=t,this.disposed&&this.throttle(t)}send(t){this.sink.next(t),this.throttle(t)}throttle(t){this.reset(),this.subscribe(this.durationSelector(t))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},Cn=class extends N{constructor(t,e,r=cc){super(t),this.durationSelector=e,this.config=r,this._throttle=new Nn(this.sink,this.durationSelector,this.config.trailing),this._throttle.dispose()}next(t){this._throttle.disposed&&this.config.leading?this._throttle.send(t):this._throttle.cacheValue(t)}complete(){this._throttle.throttle=$,this._throttle.complete(),super.complete()}},hi=L(Cn,"throttle");var wn=class extends N{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},gr=class extends N{constructor(t,e){super(t),this.durationSelector=e,this._debounce=new wn(this.sink),this._debounce.dispose()}next(t){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=t,this._debounce.subscribe(this.durationSelector(t))}complete(){this._debounce.complete(),super.complete()}},bi=L(gr,"debounce"),gi=n=>L(gr,"debounceTime")(t=>_i(n)),Ln=class extends N{constructor(t,e,r){super(t),this.count=e,this.defaultValue=r}next(t){this.count--===0&&(this.defaultValue=t,this.doDefer(),this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("not enough elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},zl=L(Ln,"elementAt");var Mn=class extends N{constructor(t,e){super(t),this.f=e,this.i=0}next(t){this.f(t)?(this.sink.next(this.i++),this.doDefer(),this.complete()):++this.i}},Zl=L(Mn,"findIndex"),kn=class extends N{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t,this.doDefer(),this.complete())}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},ed=L(kn,"first"),Bn=class extends N{constructor(t,e,r){super(t),this.f=e,this.defaultValue=r,this.index=0}next(t){(!this.f||this.f(t,this.index++))&&(this.defaultValue=t)}complete(){if(this.defaultValue===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.defaultValue);super.complete()}},td=L(Bn,"last"),Vn=class extends N{constructor(t,e){super(t),this.predicate=e,this.index=0}next(t){this.predicate(t,this.index++)?this.result=!0:(this.result=!1,this.doDefer(),this.complete())}complete(){if(this.result===void 0){this.error(new Error("no elements in sequence"));return}else this.sink.next(this.result);super.complete()}},rd=L(Vn,"every");var Hn=class extends N{constructor(t,e,r){super(t),this.f=e,typeof r=="undefined"?this.next=s=>{this.acc=s,this.resetNext(),this.sink.next(this.acc)}:this.acc=r}next(t){this.sink.next(this.acc=this.f(this.acc,t))}},od=L(Hn,"scan"),qn=class extends N{constructor(){super(...arguments),this.hasLast=!1}next(t){this.hasLast?this.sink.next([this.last,t]):this.hasLast=!0,this.last=t}},ad=L(qn,"pairwise"),Tr=class extends N{constructor(t,e,r){super(t),this.mapper=e,this.thisArg=r}next(t){super.next(this.mapper.call(this.thisArg,t))}},tt=L(Tr,"map"),Zn=n=>L(Tr,"mapTo")(t=>n),Ze=class extends N{constructor(t,e,r){super(t),this.data=e,this.context=r}next(t){let e=this.context.combineResults;e?this.sink.next(e(this.data,t)):this.sink.next(t)}tryComplete(){this.context.resetComplete(),this.dispose()}},et=class n extends N{constructor(t,e,r){super(t),this.makeSource=e,this.combineResults=r,this.index=0}subInner(t,e){let r=this.currentSink=new e(this.sink,t,this);this.complete===n.prototype.complete&&(this.complete=this.tryComplete),r.complete=r.tryComplete,r.subscribe(this.makeSource(t,this.index++))}complete(){this.sink.complete()}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},Ir=class extends Ze{},Sr=class extends et{next(t){this.subInner(t,Ir),this.next=e=>{this.currentSink.dispose(),this.subInner(e,Ir)}}},es=L(Sr,"switchMap");function Ur(n){return(t,e)=>n(()=>t,e)}var kt=Ur(L(Sr,"switchMapTo")),Gn=class extends Ze{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},Ar=class extends et{constructor(){super(...arguments),this.sources=[],this.next2=this.sources.push.bind(this.sources)}next(t){this.next2(t),this.subNext()}subNext(){this.next=this.next2,this.subInner(this.sources.shift(),Gn),this.disposed&&this.sources.length===0&&this.currentSink.resetComplete()}tryComplete(){this.sources.length===0&&this.currentSink.resetComplete(),this.dispose()}},ud=L(Ar,"concatMap"),cd=Ur(L(Ar,"concatMapTo")),Wn=class extends Ze{tryComplete(){this.context.inners.delete(this),super.dispose(),this.context.inners.size===0&&this.context.resetComplete()}},yr=class extends et{constructor(){super(...arguments),this.inners=new Set}next(t){this.subInner(t,Wn),this.inners.add(this.currentSink)}tryComplete(){this.inners.size===1?this.inners.forEach(t=>t.resetComplete()):this.dispose()}},ld=L(yr,"mergeMap"),dd=Ur(L(yr,"mergeMapTo")),jn=class extends Ze{dispose(){this.context.resetNext(),super.dispose()}},Rr=class extends et{next(t){this.next=$,this.subInner(t,jn)}},md=L(Rr,"exhaustMap"),pd=Ur(L(Rr,"exhaustMapTo")),$n=class extends N{constructor(t,e){super(t),this.f=e,this.groups=new Map}next(t){let e=this.f(t),r=this.groups.get(e);typeof r=="undefined"&&(r=ze(),r.key=e,this.groups.set(e,r),super.next(r)),r.next(t)}complete(){this.groups.forEach(t=>t.complete()),super.complete()}error(t){this.groups.forEach(e=>e.error(t)),super.error(t)}},_d=L($n,"groupBy"),Yn=class extends N{constructor(){super(...arguments),this.start=new Date}next(t){this.sink.next({value:t,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},fd=L(Yn,"timeInterval"),Kn=class extends N{constructor(t,e){super(t),this.miniseconds=e,this.buffer=[],this.id=setInterval(()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0},this.miniseconds)}next(t){this.buffer.push(t)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},hd=L(Kn,"bufferTime"),Jn=class extends N{constructor(t,e){super(t),this.buffer=[],this.delayTime=e}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(t){this.timeoutId=setTimeout(()=>{let e=this.buffer.shift();if(e){let{time:r,data:s}=e;super.next(s),this.buffer.length&&this.delay(Number(this.buffer[0].time)-Number(r))}},t)}next(t){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:t})}complete(){this.timeoutId=setTimeout(()=>super.complete(),this.delayTime)}},bd=L(Jn,"delay"),Xn=class extends N{constructor(t,e){super(t),this.selector=e}error(t){this.dispose(),this.selector(t)(this.sink)}},gd=L(Xn,"catchError"),Qn=class extends Ze{tryComplete(){let t=this.context.inners.delete(this);super.dispose(),t&&this.context.checkComplete()}next(t){this.sink.next(t),this.context.expandValue(t)}},zn=class extends et{constructor(t,e){super(t,e),this.project=e,this.inners=new Set,this.sourceCompleted=!1}next(t){this.sink.next(t),this.expandValue(t)}expandValue(t){let e=new Qn(this.sink,t,this);this.currentSink=e,this.complete=this.tryComplete,e.complete=e.tryComplete,this.inners.add(e),e.subscribe(this.makeSource(t,this.index++))}complete(){this.sourceCompleted=!0,this.checkComplete()}checkComplete(){this.sourceCompleted&&this.inners.size===0&&(this.resetComplete(),super.complete())}tryComplete(){this.sourceCompleted=!0,this.checkComplete()}},Ed=L(zn,"expand");var X=(n=$,t=$,e=$)=>r=>new fr(r,n,t,e),ts=class extends N{constructor(t,e){super(t),e instanceof Function?this.next=r=>{e(r),t.next(r)}:(e.next&&(this.next=r=>{e.next(r),t.next(r)}),e.complete&&(this.complete=()=>{e.complete(),t.complete()}),e.error&&(this.error=r=>{e.error(r),t.error(r)}))}},Or=L(ts,"tap"),rs=class extends N{constructor(t,e){super(t),this.timeout=e,this.id=setTimeout(()=>this.error(new hr(this.timeout)),this.timeout)}next(t){super.next(t),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},Sd=L(rs,"timeout");var rt="5.0.0";var Ei=typeof importScripts!="undefined",xr=typeof registerProcessor!="undefined";var ns="";var lc="web.sdk.qcloud.com";var dc=`https://${lc}/trtc/webrtc/doc`,Nd=`${dc}/zh-cn/`;var Ti="https://yun.tim.qq.com",Ii="https://apisgp.my-imcloud.com";var Si={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"};var Be=(u=>(u[u.TRACE=0]="TRACE",u[u.DEBUG=1]="DEBUG",u[u.INFO=2]="INFO",u[u.WARN=3]="WARN",u[u.ERROR=4]="ERROR",u[u.NONE=5]="NONE",u))(Be||{}),Ai=18e3;var Cd=168*3600*1e3;var yi={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},wd=yi["480p_2"],Ld=yi["120p_2"];var Bt={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADSTART:"loadstart",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture",FULLSCREEN_CHANGE:"fullscreenchange",RESIZE:"resize",TIME_UPDATE:"timeupdate"};var Et=1,Pr=2,vr=4,Tt=8,It=64,St=16;var Ri=256;var Md=Bt.MAIN,kd=Bt.AUXILIARY;var Ui=30;var Bd=Bt.BIG,Vd=Bt.SMALL,Fd=10*1e3;var Hd=Object.keys(Be),Oi=["normal leave","timeout leave","kick","role change"];var qd=10*1e3,xi=14;var pc=function(n,t,e,r){function s(o){return o instanceof e?o:new e(function(u){u(o)})}return new(e||(e=Promise))(function(o,u){function p(h){try{m(r.next(h))}catch(f){u(f)}}function l(h){try{m(r.throw(h))}catch(f){u(f)}}function m(h){h.done?o(h.value):s(h.value).then(p,l)}m((r=r.apply(n,t||[])).next())})},ss=Symbol(32),is=Symbol(16),os=Symbol(8),me=class{constructor(t){this.g=t,this.consumed=0,t&&(this.need=t.next().value)}setG(t){this.g=t,this.demand(t.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(t,e){return e&&this.consume(),this.need=t,this.flush()}read(t){return pc(this,void 0,void 0,function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise((e,r)=>{var s;this.reject=r,this.resolve=u=>{delete this.lastReadPromise,delete this.resolve,delete this.need,e(u)},this.demand(t,!0)||(s=this.pull)===null||s===void 0||s.call(this,t)})})}readU32(){return this.read(ss)}readU16(){return this.read(is)}readU8(){return this.read(os)}close(){var t;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),(t=this.reject)===null||t===void 0||t.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let t=null,e=this.buffer.subarray(this.consumed),r=0,s=o=>e.length<(r=o);if(typeof this.need=="number"){if(s(this.need))return;t=e.subarray(0,r)}else if(this.need===ss){if(s(4))return;t=e[0]<<24|e[1]<<16|e[2]<<8|e[3]}else if(this.need===is){if(s(2))return;t=e[0]<<8|e[1]}else if(this.need===os){if(s(1))return;t=e[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(s(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(e.subarray(0,r)),t=this.need}else if(this.g){this.g.throw(new Error("Unsupported type"));return}}else{if(s(this.need.byteLength))return;new Uint8Array(this.need).set(e.subarray(0,r)),t=this.need}return this.consumed+=r,this.g?this.demand(this.g.next(t).value,!0):this.resolve&&this.resolve(t),t}write(t){if(t instanceof Uint8Array?this.malloc(t.length).set(t):"buffer"in t?this.malloc(t.byteLength).set(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)):this.malloc(t.byteLength).set(new Uint8Array(t)),this.g||this.resolve)this.flush();else return new Promise(e=>this.pull=e)}writeU32(t){this.malloc(4).set([t>>24&255,t>>16&255,t>>8&255,t&255]),this.flush()}writeU16(t){this.malloc(2).set([t>>8&255,t&255]),this.flush()}writeU8(t){this.malloc(1)[0]=t,this.flush()}malloc(t){if(this.buffer){let e=this.buffer.length,r=e+t;if(r<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,r);else{let s=new Uint8Array(r);s.set(this.buffer),this.buffer=s}return this.buffer.subarray(e,r)}else return this.buffer=new Uint8Array(t),this.buffer}};me.U32=ss;me.U16=is;me.U8=os;var _c=128,fc=127,Xd=~fc,Qd=Math.pow(2,31);function as(n){let t=new me;for(;n>=128;)t.malloc(1)[0]=n&255|_c,n>>>=7;return t.malloc(1)[0]=n&255,t.buffer||new Uint8Array(0)}function Dr(n,t=0){let e=new me,r=t<<3;switch(typeof n){case"boolean":let s=e.malloc(2);s[0]=r,s[1]=n?1:0;break;case"number":e.malloc(1)[0]=r,e.write(as(n));break;case"string":e.malloc(1)[0]=r|2;let o=new TextEncoder().encode(n);e.write(as(o.length));let u=e.malloc(o.length);for(let l=0;l<o.length;l++)u[l]=o[l];break;case"object":let p=new me;if(Array.isArray(n))for(let l=0;l<n.length;l++){let m=Dr(n[l],l+1);m&&p.write(m)}else{let l=1;for(let m in n){let h=Dr(n[m],l++);h&&p.write(h)}}t===0?p.buffer&&e.write(p.buffer):(e.malloc(1)[0]=r|2,p.buffer&&(e.write(as(p.buffer.length)),e.write(p.buffer)))}return e.buffer||new Uint8Array(0)}var Vt=class{constructor(){d(this,"buffer");this.buffer=[]}get data(){return this.buffer}get length(){return this.buffer.length}writeInt32(t){this.buffer.push(t>>>24&255),this.buffer.push(t>>>16&255),this.buffer.push(t>>>8&255),this.buffer.push(t&255)}writeInt16(t){this.buffer.push(t>>>8&255),this.buffer.push(t&255)}writeByte(t){this.buffer.push(t&255)}writeBytes(t){for(let e=0;e<t.length;e++)this.buffer.push(t[e])}};function us(n,t,e){n[e]=t>>>24&255,n[e+1]=t>>>16&255,n[e+2]=t>>>8&255,n[e+3]=t&255}function ae(n,t){return n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3]}function cs(n,t){return n[t]}function At(n,t,e){return new TextDecoder().decode(hc(n,t,e))}function hc(n,t,e){return n.slice(t,t+e)}var ls=0,Nr=2654435769,Cr=16,ms=4,yt=2,Rt=7;function bc(n,t,e,r="AVQualityReportSvc.C2S",s=2e3,o=2,u=30){return{version:s,encryption:o,d2:"",d2Len:0,uinType:u,uin:"",uinLen:0,reqHead:{seqNumber:e,appId:n,appidAtThird:new Uint8Array(0),a2:"",a2Len:0,serviceCmd:r,serviceCmdLen:0,cookie:"",cookieLen:0,imei:"",imeiLen:0,ksid:"",ksidLen:0,clientVersionInfo:"",clientVersionInfoLen:0},busiBuff:t}}function Pi(n,t){let e=new Vt,r=bc(t,n,ls);ls=ls+1&2147483647,e.writeInt32(0),e.writeInt32(r.version),e.writeByte(r.encryption);let s=new TextEncoder().encode(r.d2);e.writeInt32(s.length+4),s&&e.writeBytes(s),e.writeByte(r.uinType);let o=new TextEncoder().encode(r.uin);e.writeInt32(o.length+4),o.length&&e.writeBytes(o);let u=new Vt;u.writeInt32(0),u.writeInt32(r.reqHead.seqNumber),u.writeInt32(r.reqHead.appId),u.writeByte(r.reqHead.appId>>>24&255),u.writeByte(r.reqHead.appId>>>16&255),u.writeByte(r.reqHead.appId>>>8&255),u.writeByte(r.reqHead.appId&255);for(let G=4;G<16;G++)u.writeByte(0);let p=new TextEncoder().encode(r.reqHead.a2);u.writeInt32(p.length+4),p.length&&u.writeBytes(p);let l=new TextEncoder().encode(r.reqHead.serviceCmd);u.writeInt32(l.length+4),l.length&&u.writeBytes(l);let m=new TextEncoder().encode(r.reqHead.cookie);u.writeInt32(m.length+4),m.length&&u.writeBytes(m);let h=new TextEncoder().encode(r.reqHead.imei);u.writeInt32(h.length+4),h.length&&u.writeBytes(h);let f=new TextEncoder().encode(r.reqHead.ksid);u.writeInt32(f.length+4),f.length&&u.writeBytes(f);let g=new TextEncoder().encode(r.reqHead.clientVersionInfo);u.writeInt16(g.length+2),g.length&&u.writeBytes(g);let y=u.length;u.data[0]=y>>>24&255,u.data[1]=y>>>16&255,u.data[2]=y>>>8&255,u.data[3]=y&255,Ft(n)&&(n=new TextEncoder().encode(n)),u.writeInt32(n.length+4),n.length&&u.writeBytes(n);let R=new Uint8Array(u.data),w=null;r.encryption===1?w=new TextEncoder().encode(r.uin):r.encryption===2&&(w=new Uint8Array(16)),w&&(R=gc(R,w)),e.writeBytes(R);let U=new Uint8Array(e.data),D=U.length;return U[0]=D>>>24&255,U[1]=D>>>16&255,U[2]=D>>>8&255,U[3]=D&255,U}function gc(n,t){let e=n.length,s=(e+1+yt+Rt)%8;s&&(s=8-s);let o=e+1+yt+Rt+s,u=new Uint8Array(o),p=0,l=new Uint8Array(8),m=new Uint8Array(8),h=new Uint8Array(8),f=0;l[0]=Math.floor(Math.random()*256)&248|s,f=1;for(let y=0;y<s;y++)l[f]=Math.floor(Math.random()*256)&255,f+=1;for(let y=0;y<yt;)if(f<8&&(l[f]=Math.floor(Math.random()*256)&255,f+=1,y+=1),f===8){ds(l,t,m,h,u,p),p+=8,f=0;for(let R=0;R<8;R++)h[R]=u[p-8+R]}let g=0;for(;g<e;)if(f<8&&(l[f]=n[g],f+=1,g+=1),f===8){ds(l,t,m,h,u,p),p+=8,f=0;for(let y=0;y<8;y++)h[y]=u[p-8+y]}for(let y=0;y<Rt;)if(f<8&&(l[f]=0,f+=1,y+=1),f===8){ds(l,t,m,h,u,p),p+=8,f=0;for(let R=0;R<8;R++)h[R]=u[p-8+R]}return u}function ds(n,t,e,r,s,o){for(let u=0;u<8;u++)n[u]^=r[u];Ec(n,t,s,o);for(let u=0;u<8;u++)s[o+u]^=e[u];for(let u=0;u<8;u++)e[u]=n[u]}function Ec(n,t,e,r){let s=ae(n,0),o=ae(n,4),u=[];for(let l=0;l<4;l++)u[l]=ae(t,l*4);let p=0;for(let l=0;l<Cr;l++)p+=Nr,p=p>>>0,s+=(o<<4)+u[0]^o+p^(o>>>5)+u[1],s=s>>>0,o+=(s<<4)+u[2]^s+p^(s>>>5)+u[3],o=o>>>0;us(e,s,r),us(e,o,r+4)}var Tc=0;var ps=function(){return Date.now()+Tc},vi=function(){let n=new Date;return n.setTime(ps()),n.toLocaleString()},Di=function(n){let t=String(n.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),`${n.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1")}:${t}`};function Ni(n){let t=Ic(n);return t==null?void 0:t.busiBuff}function Ic(n){try{let t={},e=0;t.totalLength=ae(n,e),e+=4,t.version=ae(n,e),e+=4,t.encryption=cs(n,e),e+=1,t.uinType=cs(n,e),e+=1,t.uinLength=ae(n,e),e+=4,t.uin=t.uinLength>4?At(n,e,t.uinLength-4):"",e+=t.uinLength-4;let r=n.slice(e);if(t.encryption===2){let s=new Uint8Array(16).fill(0);n=Sc(r,s),t.decrypted=!0,e=0}else n=r,e=0;return t.rspHeadLength=ae(n,e),e+=4,t.seqNo=ae(n,e),e+=4,t.retCode=ae(n,e),e+=4,t.retStrLength=ae(n,e),e+=4,t.retStr=t.retStrLength?At(n,e,t.retStrLength-4):"",e+=t.retStrLength-4,t.serviceCmdLength=ae(n,e),e+=4,t.serviceCmd=t.serviceCmdLength?At(n,e,t.serviceCmdLength-4):"",e+=t.serviceCmdLength-4,t.cookieLength=ae(n,e),e+=4,t.cookie=t.cookieLength?At(n,e,t.cookieLength-4):"",e+=t.cookieLength-4,t.flag=ae(n,e),e+=4,t.busiBuffLength=ae(n,e),e+=4,t.busiBuff=t.busiBuffLength?At(n,e,t.busiBuffLength-4):"",e+=t.busiBuffLength-4,t}catch(t){}}function Ci(n,t){let e=n[0]<<24|n[1]<<16|n[2]<<8|n[3],r=n[4]<<24|n[5]<<16|n[6]<<8|n[7];e=e>>>0,r=r>>>0;let s=Nr*Cr>>>0;for(let o=0;o<Cr;o++)r-=(e<<ms)+t[2]^e+s^(e>>>5)+t[3],r=r>>>0,e-=(r<<ms)+t[0]^r+s^(r>>>5)+t[1],e=e>>>0,s-=Nr,s=s>>>0;return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,e&255,r>>>24&255,r>>>16&255,r>>>8&255,r&255])}function Sc(n,t){let e=0,r=new Uint8Array(8).fill(0),s=new Uint8Array(n.slice(0,8)),o=Ci(s,t),u=o[0]&7,p=n.length-1-u-yt-Rt,l=new Uint8Array(p),m=0,h=r,f=n.slice(0,8);e=8;let g=1;g+=u;for(let R=1;R<=yt;)if(g<8)g++,R++;else if(g===8){let w=_s(n,e,h,f,o,t);h=w.ivPreCrypt,f=w.ivCurCrypt,o=w.debiBuf,e=w.bufPos,g=0}let y=p;for(;y>0;)if(g<8)l[m++]=o[g]^h[g],g++,y--;else if(g===8){let R=_s(n,e,h,f,o,t);h=R.ivPreCrypt,f=R.ivCurCrypt,o=R.debiBuf,e=R.bufPos,g=0}for(let R=1;R<=Rt;)if(g<8)o[g]^h[g],g++,R++;else if(g===8){if(e>=n.length)break;let w=_s(n,e,h,f,o,t);if(!w.success)break;h=w.ivPreCrypt,f=w.ivCurCrypt,o=w.debiBuf,e=w.bufPos,g=0}return l}function _s(n,t,e,r,s,o){if(t+8>n.length)return{success:!1};let u=new Uint8Array(r),p=n.slice(t,t+8),l=new Uint8Array(8);for(let h=0;h<8;h++)l[h]=s[h]^p[h];let m=Ci(l,o);return{success:!0,ivPreCrypt:u,ivCurCrypt:p,debiBuf:m,bufPos:t+8}}var wi=typeof TextDecoder!="undefined"?new TextDecoder:void 0;function Li({url:n,body:t,method:e="POST",timeout:r,priority:s}){return new Promise((o,u)=>{if("fetch"in window)return fetch(n,{method:e,body:t,priority:s}).then(l=>l.clone().json().then(m=>({data:m}),()=>l.arrayBuffer().then(m=>({data:Ni(new Uint8Array(m))||(wi?wi.decode(m):m)})))).then(o,u);let p=new XMLHttpRequest;p.onreadystatechange=()=>{if(p.readyState===4)if(p.status>=200&&p.status<300)try{let l=JSON.parse(p.response);o({data:l})}catch(l){o({data:p.response})}else u({status:p.status,statusText:p.statusText||"request failed!"})},p.timeout=r||5e3,p.open(e,n,!0),p.send(t)})}var Ac=Object.prototype.hasOwnProperty;var Ut=n=>typeof n=="function",st=n=>typeof n=="undefined";var Mi=n=>typeof n=="boolean";var yc=function(n){if(!n||typeof n!="object"||Object.prototype.toString.call(n)!="[object Object]")return!1;let t=Object.getPrototypeOf(n);if(t===null)return!0;let e=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Function.prototype.toString.call(e)===Function.prototype.toString.call(Object)};function ki(n){if(n==null)return!0;if(typeof n=="boolean")return!1;if(typeof n=="number")return n===0;if(typeof n=="string"||typeof n=="function"||Array.isArray(n))return n.length===0;if(n instanceof Error)return n.message==="";if(yc(n))switch(Object.prototype.toString.call(n)){case"[object File]":case"[object Map]":case"[object Set]":return n.size===0;case"[object Object]":{for(let t in n)if(Ac.call(n,t))return!1;return!0}}return!1}var Rc=0,Uc=1,Bi=2;function Oc({retryFunction:n,settings:t,onError:e,onRetrying:r,onRetryFailed:s,onRetrySuccess:o,context:u}){return function(...p){let{retries:l=5,timeout:m=1e3}=t,h=0,f=-1,g=Rc,y=async(R,w)=>{let U=u||this;try{let D=await n.apply(U,p);h>0&&o&&o.call(this,h),h=0,R(D)}catch(D){let G=()=>{clearTimeout(f),h=0,g=Bi,w(D)},Ae=()=>{g!==Bi&&h<(Ut(l)?l():l)?(h++,g=Uc,Ut(r)&&r.call(this,h,G),f=window.setTimeout(()=>{f=-1,y(R,w)},Ut(m)?m(h):m)):(G(),Ut(s)&&s.call(this,D))};Ut(e)?e.call(this,{error:D,retry:Ae,reject:w,retryFuncArgs:p,retriedCount:h}):Ae()}};return new Promise(y)}}var Vi=Oc;var it=class n{constructor(t){d(this,"_parentPath");d(this,"userId");d(this,"remoteUserId");d(this,"id");d(this,"sdkAppId");d(this,"type");d(this,"isLocal");this.id=t.id,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.remoteUserId=t.remoteUserId,this.isLocal=Mi(t.isLocal)?t.isLocal:!0,this.type=this.isLocal?"":t.type}getFullId(){return this._parentPath&&this.id?`${this._parentPath}-${this.id}`:this._parentPath?this._parentPath:this.id}createChild(t){let e=new n({id:t.id,userId:st(t.userId)?this.userId:t.userId,sdkAppId:st(t.sdkAppId)?this.sdkAppId:t.sdkAppId,type:st(t.type)?this.type:t.type,isLocal:st(t.isLocal)?this.isLocal:t.isLocal,remoteUserId:st(t.remoteUserId)?this.remoteUserId:t.remoteUserId});return e.bindParent(this),e}bindParent(t){let e=t.getFullId();this._parentPath!==e&&(this.debug(`bind logger parent: ${t.id}`),this._parentPath=e,this.userId=t.userId||this.userId,this.sdkAppId=t.sdkAppId||this.sdkAppId)}setUserId(t){this.userId=t}setSdkAppId(t){this.sdkAppId=t}log(t,e){let r=this.isLocal?this.userId:this.remoteUserId,s=this.getFullId();e.unshift(`[${this.isLocal?"\u2191":"\u2193"}${this.type&&this.type!=="main"?"*":""}${s}${r?`|${r}`:""}]`),nt.log(t,e,st(this.userId)||ki(this.userId),this.userId,this.sdkAppId)}info(...t){this.log(2,t)}debug(...t){this.log(1,t)}warn(...t){this.log(3,t)}error(...t){this.log(4,t)}};var Ce=typeof navigator=="undefined"?"":navigator.userAgent,M=n=>new RegExp(n,"i").test(Ce),te=n=>{if(M(n)){let t=new RegExp(`${n}\\/([\\d.]+)`),e=Ce.match(t);if(e&&e[1])return e[1]}return""},wr=n=>{if(M(n)){let t=new RegExp(`${n}\\/(\\d+)`),e=Ce.match(t);if(e&&e[1])return parseFloat(e[1])}return NaN},Fi=/AppleWebKit\/([\d.]+)/i.exec(Ce),xc=Fi?parseFloat(Fi[1]):NaN,Wi=M("iPad"),ji=typeof navigator!="undefined"&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&M("Macintosh"),$i=M("iPhone")&&!Wi,Pc=M("iPod"),Lr=$i||Wi||Pc||ji;var Ot=M("Android"),Yi=(function(){if(Ot){let n=Ce.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(n){let t=n[1]&&parseFloat(n[1]),e=n[2]&&parseFloat(n[2]);if(t&&e)return parseFloat(`${n[1]}.${n[2]}`);if(t)return t}}return NaN})(),Am=Ot&&M("webkit")&&Yi<2.3,ym=Ot&&Yi<5&&xc<537,vc=M("Firefox"),Dc=te("Firefox"),Rm=wr("Firefox"),Ki=M("Edge"),Nc=te("Edge"),Ji=M("Edg"),Cc=te("Edg"),Um=wr("Edg"),Xi=M("SogouMobileBrowser"),wc=te("SogouMobileBrowser"),Qi=M("MetaSr\\s"),Lc=te("MetaSr\\s"),ot=M("TBS"),Mc=te("TBS"),zi=M("XWEB"),kc=te("XWEB"),Om=M("MSIE\\s8\\.0"),Bc=M("MSIE\\/\\d+"),xm=(function(){if(Bc){let n=/MSIE\s(\d+)\.\d/.exec(Ce),t=n&&parseFloat(n[1]);return!t&&/Trident\/7.0/i.test(Ce)&&/rv:11.0/.test(Ce)&&(t=11),t}return NaN})(),Vc=M("(micromessenger|webbrowser)"),Fc=te("MicroMessenger"),fs=!ot&&M("MQQBrowser")&&M("COVC"),hs=!ot&&M("MQQBrowser")&&!M("COVC"),Hi=hs||fs?te("MQQBrowser"):"",Zi=!ot&&M(" QQBrowser"),Hc=te(" QQBrowser"),eo=!ot&&M("QQBrowserLite"),qc=te("QQBrowserLite"),to=!ot&&M("MQBHD"),Gc=te("MQBHD"),Pm=M("Windows"),vm=!Lr&&M("MAC OS X"),Dm=!Ot&&M("Linux"),Nm=M("CrOS"),Cm=M("MicroMessenger"),wm=M("UCBrowser"),Lm=M("Electron"),ro=M("MiuiBrowser"),Wc=te("MiuiBrowser"),no=M("HuaweiBrowser"),Mm=M("Huawei")||M("HUAWEI"),km=M("Honor")||M("HONOR"),jc=te("HuaweiBrowser"),so=M("SamsungBrowser"),$c=te("SamsungBrowser"),io=M("HeyTapBrowser"),Yc=te("HeyTapBrowser"),oo=M("VivoBrowser"),Kc=te("VivoBrowser"),Bm=M("OpenHarmony"),Vm=te("OpenHarmony"),Jc=()=>wr("Chrome"),qi=M("CriOS"),bs=M("Chrome"),Xc=!Ki&&!Qi&&!Xi&&!ot&&!zi&&!Ji&&!Zi&&!ro&&!no&&!so&&!io&&!oo&&bs,ao=M("HeadlessChrome"),Gi=Jc(),Fm=bs&&Gi>=128&&Gi<=143,Qc=te("Chrome"),Hm=wr("Electron"),zc=!bs&&!hs&&!fs&&!eo&&!to&&M("Safari");var uo=te("Version"),qm=/Android.*(wv|.0.0.0)/.test(Ce),co=(()=>{if(ji)return uo;if(Lr){let n=Ce.match(/OS (\d+)_(\d+)/i);if(n&&n[1]){let t=n[1];return n[2]&&(t+=`.${n[2]}`),t}}return""})();var Gm=Number(co.split(".")[0]);var Wm=(()=>{let n=Number(co.split(".")[0]);return n===14||n===13})();var jm=typeof location=="undefined"?!1:location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1";var $m=Zc();function Zc(){let n=new Map([[vc,["Firefox",Dc]],[Ji,["Edg",Cc]],[Xc,["Chrome",Qc]],[qi,["ChiOS",te("CriOS")]],[zc&&!qi,["Safari",uo]],[ot,["TBS",Mc]],[zi,["XWEB",kc]],[Vc&&$i,["WeChat",Fc]],[Zi,["QQ(Win)",Hc]],[hs,["QQ(Mobile)",Hi]],[fs,["QQ(Mobile X5)",Hi]],[eo,["QQ(Mac)",qc]],[to,["QQ(iPad)",Gc]],[ro,["MI",Wc]],[no,["HW",jc]],[so,["Samsung",$c]],[io,["OPPO",Yc]],[oo,["VIVO",Kc]],[Ki,["EDGE",Nc]],[Xi,["SogouMobile",wc]],[Qi,["Sogou",Lc]]]),t="unknown",e="unknown";return n.has(!0)&&([t,e]=n.get(!0)),{name:t,version:e}}var mo=_r(qt(),1),rl=new mo.default,we=rl;var kr=(v=>(v.ROOM_DESTROY="1",v.JOIN_START="21",v.JOIN_SCHEDULE_SUCCESS="22",v.JOIN_SIGNAL_CONNECTION_START="23",v.JOIN_SIGNAL_CONNECTION_END="24",v.JOIN_SEND_CMD="25",v.JOIN_RECEIVED_CMD_RES="26",v.JOIN_SUCCESS="27",v.JOIN_FAILED="28",v.LEAVE_START="51",v.LEAVE_SEND_CMD="52",v.LEAVE_SUCCESS="53",v.PUBLISH_START="61",v.SEND_FIRST_VIDEO_FRAME="62",v.PUBLISH_FAILED="63",v.SUBSCRIBE_START="81",v.SUBSCRIBE_SUCCESS="82",v.SUBSCRIBE_FAILED="84",v.UNSUBSCRIBE_SUCCESS="83",v.LOCAL_TRACK_CAPTURE_START="101",v.LOCAL_TRACK_CAPTURE_SUCCESS="102",v.LOCAL_TRACK_CAPTURE_FAILED="103",v.LOCAL_TRACK_PUBLISHED="104",v.LOCAL_TRACK_UNPUBLISHED="105",v.LOCAL_TRACK_REPLACED="106",v.SWITCH_DEVICE_SUCCESS="107",v.TRACK_MUTED="108",v.TRACK_UNMUTED="109",v.REMOTE_TRACK_SUBSCRIBED="110",v.REMOTE_TRACK_UNSUBSCRIBED="111",v.LOCAL_TRACK_RECAPTURE="112",v.LOCAL_AUDIO_STARTED="113",v.LOCAL_AUDIO_STOPPED="114",v.REMOTE_AUDIO_STARTED="115",v.REMOTE_AUDIO_STOPPED="116",v.PLAY_TRACK_START="151",v.PLAYER_STATE_CHANGED="152",v.VIDEO_LOADED_DATA="153",v.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",v.AUDIO_CONTEXT_LONG_SUSPENDED="155",v.REMOTE_VIDEO_PLAY_START="156",v.REMOTE_VIDEO_PLAY_FINISH="157",v.SIGNAL_CONNECTION_STATE_CHANGED="201",v.PEER_CONNECTION_STATE_CHANGED="202",v.SINGLE_CONNECTION_STAT="203",v.SPC_RECONNECTED="204",v.HEARTBEAT_REPORT="251",v.RECEIVED_PUBLISHED_USER_LIST="252",v.REMOTE_PUBLISH_STATE_CHANGED="253",v.AUDIO_LEVEL_INTERVAL="260",v.NETWORK_QUALITY="261",v.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",v.QUALITY_LIMITATION_CHANGED="263",v.LOG="264",v.AUDIO_PROCESSOR_DEBUG="265",v.SSO_SWITCH="266",v.SEI_MESSAGE="267",v.USER_PAUSE_IN_PIP="268",v.USER_RESUME_IN_PIP="269",v.ENTER_PICTURE_IN_PICTURE="270",v.LEAVE_PICTURE_IN_PICTURE="271",v.SWITCH_ROOM_START="401",v.SWITCH_ROOM_SUCCESS="407",v.SWITCH_ROOM_FAILED="408",v))(kr||{});var at=kr;var Es=class{constructor(){d(this,"enable",!1);d(this,"ssoFailCount",0);we.on("22",({schedule:t})=>{var e;(e=t==null?void 0:t.config)!=null&&e.sso&&we.emit("266",{enable:!0})}),we.on("266",({enable:t})=>{this.enable=t})}handleUploadFailed(){this.ssoFailCount++,this.ssoFailCount>3&&we.emit("266",{enable:!1})}},Ts=new Es;var nl="%cTRTC%c%s",sl="padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;",il="display: inline",Br=class Br{constructor(){d(this,"_isEnableUploadLog",!0);d(this,"_localJoinedUser",new Map);d(this,"_queue",[]);d(this,"_timeoutId",-1);d(this,"_logLevel",1);d(this,"_logLevelToUpload",2);!Ei&&!xr&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&this._timeoutId!==-1}installEvents(){we.on(at.JOIN_SCHEDULE_SUCCESS,({schedule:t})=>{var e;(e=t==null?void 0:t.config)!=null&&e.logLevelToUpload&&Be[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)}),we.on(at.JOIN_START,({params:t})=>{this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()}),we.on(at.LEAVE_SUCCESS,({room:t})=>{this.deleteJoinedUser(t.userId)})}startUpload(){this._timeoutId===-1&&this.uploadInterval()}addJoinedUser(t){this._localJoinedUser.set(t.userId,t),this.startUpload()}deleteJoinedUser(t){this._localJoinedUser.delete(t)}uploadInterval(){this.upload().catch(()=>{}),this._timeoutId=window.setTimeout(()=>this.uploadInterval(),5e3)}getLogsToUpload(){let t={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&this._localJoinedUser.size===0)return t;let e=0;for(;e<this._queue.length&&e!==50;e++){let r=this._queue[e];if(r.forAllJoinedClients)this._localJoinedUser.forEach(({userId:s,sdkAppId:o})=>{t.map.has(s)?t.map.get(s).logs.push(r):t.map.set(s,{userId:s,sdkAppId:o,logs:[r]})});else if(Ft(r.userId)&&_o(r.sdkAppId)){let{userId:s,sdkAppId:o}=r;t.map.has(s)?t.map.get(s).logs.push(r):t.map.set(s,{userId:s,sdkAppId:o,logs:[r]})}}return t.map.size>0&&(t.splicedQueue=this._queue.splice(0,e)),t}async upload(){if(this._queue.length===0||!this._isEnableUploadLog)return;let{map:t,splicedQueue:e}=this.getLogsToUpload();if(t.size===0)return;try{let s=[...t.values()];for(let o=0;o<s.length;o++){let{userId:u,sdkAppId:p,logs:l}=s[o],m={timestamp:vi(),sdkAppId:String(p),userId:u,version:rt,log:l.map(g=>g.log).join(`
2
+ `)},h=JSON.stringify(m),f=Ts.enable?fo(m,2002,p):h;await this.uploadLogWithRetry(f,p,f instanceof Uint8Array,h),l.forEach(g=>g.uploaded=!0)}}catch(s){}let r=e.filter(s=>!s.uploaded);r.length>0&&(this._queue=r.concat(this._queue))}uploadLogWithRetry(t,e,r,s){return Vi({retryFunction:()=>Li({url:po(e,Si.LOG),body:t,timeout:5e3,priority:"low"}).then(o=>{r&&o.data!=="ok"&&(Ts.handleUploadFailed(),this.uploadLogWithRetry(s,e,!1,s))}),settings:{retries:3,timeout:2e3},onError:({retry:o})=>{o()}})()}getPrefix(t){let e=new Date;return e.setTime(ps()),`[${Di(e)}] <${Be[t]}>`}getLogLevel(){return this._logLevel}setLogLevel(t){Gt(Be[t])||(this._logLevel!==t&&this.info("setLogLevel",t),this._logLevel=t)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(t){if(Ft(t))return t;try{return t instanceof Error?t.toString():JSON.stringify(t)}catch(e){return""}}addLogToQueue(t,e,r=!0,s,o){let u={log:e.reduce((p,l)=>`${p} ${this.logChunkToString(l)}`.trim(),""),level:t,userId:s,sdkAppId:o,forAllJoinedClients:r};we.emit(at.LOG,{log:u}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(u)}log(t,e,r=!0,s,o){var p;if(e.unshift(this.getPrefix(t)),this.addLogToQueue(t,e,r,s,o),t<this._logLevel)return;let u=((p=Be[t])==null?void 0:p.toLowerCase())||"info";Br.PRINT_LOG_TAG?console[u](nl,sl,il,...e):console[u](...e)}debug(...t){this.log(1,t)}info(...t){this.log(2,t)}warn(...t){this.log(3,t)}error(...t){this.log(4,t)}createLogger(t){if(t.parent instanceof it){let e=t,{parent:r}=e,s=di(e,["parent"]),o=new it(s);return o.bindParent(r),o}return new it(t)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),r=e?Number(e):-1;Be[r]&&(this._logLevelToUpload=r)}getQueue(){return this._queue}};d(Br,"PRINT_LOG_TAG",!(Lr||Ot||ao));var Is=Br,nt=new Is;var ol=n=>Number(n)<14e8,po=function(n,t){let e;ns?e=ns:e=ol(n)?Ii:Ti;let r=Math.floor(Math.random()*2**31);return`${e}/v5/AVQualityReportSvc/C2S?random=${r}&sdkappid=${n}&cmdtype=${t}`};var yp=typeof window!="undefined"&&typeof window.glog=="function"?window.glog:()=>{};var Gt=n=>typeof n=="undefined",Ft=n=>typeof n=="string",_o=n=>typeof n=="number";var Rp=typeof HTMLMediaElement!="undefined"&&"setSinkId"in HTMLMediaElement.prototype;var{toString:Up}=Object.prototype;function Ss(n,t){return{userId:t,hasAudio:!!(n&Tt),hasVideo:!!(n&Et),hasAuxiliary:!!(n&vr),hasSmall:!!(n&Pr),audioMuted:!!(n&It),videoMuted:!!(n&St),audioAvailable:!!(n&Tt)&&!(n&It),videoAvailable:!!(n&Et)&&!(n&St),hasDatachannel:!!(n&Ri)}}function al(n,t,e,r){let s={data:n,random:Math.floor(Math.random()*2147483648),sdkAppId:e};return Gt(r)||(s=li(Mt({},s),{gzip:+r})),{uint32_sdkappid:0,uint64_from_uin:0,uint32_timestamp:0,uint32_seq:0,msg_common_info:{msg_device_info:{enum_device_type:0,str_device_brand:"",str_device_model:"",str_device_board:"",str_device_cpu_abi:""},msg_system_info:{enum_os_type:0,str_os_version:"",msg_network_info:0},msg_network_info:{enum_network_type:0}},msg_report_content:{uint32_type:t,bytes_report_data:JSON.stringify(s)}}}function fo(n,t,e,r){try{let s=al(n,t,e,r),o=Dr(s);return Pi(o,e)}catch(s){return JSON.stringify(n)}}function Wt(n,t=!1){let e=Object.defineProperties(ze(),{postMessage:{value:n.postMessage.bind(n)},port:{get(){return n},set(s){n.onmessage=$,n.onmessageerror=$,n=s,r()}}});function r(){n.onmessage=s=>{s.data?s.ports.length||t?e.next(s):e.next(s.data):(e.complete(),n.close())},n.onmessageerror=s=>{e.error(s),n.close()}}return r(),e}var As=class extends N{constructor(t,e){super(t);let r=new N(t);r.next=$,e(r)}},Ve=L(As,"takeUntilComplete");var ne={useWt:!0,useAINS:!0,useHardDecoder:"prefer-software",useHardEncoder:"prefer-software",unreliable:!1,debug:!1,assetsPath:"",enableUpload:!0},ul="__INLINE__WORKER__",cl="__INLINE__WASM__",{debug:Vr}=console;ne.debug||(console.debug=()=>{});var Vp=!ul.startsWith("__"),Fp=!cl.startsWith("__");var ho=H(bt(250),tt(()=>performance.now()),We()),xe=n=>t=>{let e=0,r=performance.now();H(ho,tt(s=>(s-r)/n>>0),gt(s=>s!=e?(e=s,!0):!1))(t)},je=n=>t=>{let e=performance.now();H(ho,fi(r=>r-e<n),Er(1))(t)};function $e(n,t,e){let r=t.aborted?Promise.reject(t.reason):new Promise((s,o)=>{t.addEventListener("abort",()=>o(t.reason),{once:!0}),typeof n=="function"?n(s,o):n.then(s,o)});return e?r.catch(e):r}var ll=new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}),ut=()=>ll.format(new Date),se=(O=>(O[O.JOIN_ROOM=0]="JOIN_ROOM",O[O.LEAVE_ROOM=1]="LEAVE_ROOM",O[O.PUBLISH=2]="PUBLISH",O[O.UNPUBLISH=3]="UNPUBLISH",O[O.SUBSCRIBE=4]="SUBSCRIBE",O[O.UNSUBSCRIBE=5]="UNSUBSCRIBE",O[O.GET_WHOLE_LIST=6]="GET_WHOLE_LIST",O[O.QUALITY_REPORT=7]="QUALITY_REPORT",O[O.MUTE=8]="MUTE",O[O.UNMUTE=9]="UNMUTE",O[O.CONFIG=10]="CONFIG",O[O.REQUEST_PLI=11]="REQUEST_PLI",O[O.HEARTBEAT=12]="HEARTBEAT",O[O.START_PUSH_CDN=13]="START_PUSH_CDN",O[O.STOP_PUSH_CDN=14]="STOP_PUSH_CDN",O[O.START_MCU_MIX=15]="START_MCU_MIX",O[O.STOP_MCU_MIX=16]="STOP_MCU_MIX",O[O.UDPATE_TRACK=17]="UDPATE_TRACK",O[O.START_PUSHING=18]="START_PUSHING",O[O.STOP_PUSHING=19]="STOP_PUSHING",O[O.SWITCH_ROLE=20]="SWITCH_ROLE",O[O.WHOLE_LIST_UPDATE=255]="WHOLE_LIST_UPDATE",O[O.PEER_JOINED=256]="PEER_JOINED",O[O.PEER_LEFT=257]="PEER_LEFT",O[O.PEER_UDPATED_TRACK=258]="PEER_UDPATED_TRACK",O[O.SELECT_ABILITY=259]="SELECT_ABILITY",O[O.PEER_REQUEST_PLI=260]="PEER_REQUEST_PLI",O[O.AUDIO_DATA=4095]="AUDIO_DATA",O[O.VIDEO_DATA=4096]="VIDEO_DATA",O[O.SCREEN_DATA=4097]="SCREEN_DATA",O[O.NACK=4098]="NACK",O[O.ACK=4099]="ACK",O[O.REQUEST_RTT=4100]="REQUEST_RTT",O[O.RESPONSE_RTT=4101]="RESPONSE_RTT",O[O.PIP_DATA=4102]="PIP_DATA",O[O.LAYER_DATA=4103]="LAYER_DATA",O[O.MAX_FORCE=65535]="MAX_FORCE",O))(se||{});function ys(n,t,e){let r=t>65535?1:0;return e.setUint8(0,0<<4|r),e.setUint16(1,n),r?e.setUint32(3,t):e.setUint16(3,t),r?7:5}function jt(n,t){let e=n>=255&&n<4095;e&&(t+=4);let s=(t>65535?1:0)?7:5,o=new DataView(new ArrayBuffer(s+t));ys(n,t,o),e&&(o.setUint32(s,0),s+=4),o=new DataView(o.buffer,s),s=0;let u=g=>{o.setUint8(s,g),s++},p=g=>{o.setUint16(s,g),s+=2},l=(g,y=!1)=>{o.setUint32(s,g,y),s+=4},m=g=>{o.setBigUint64(s,g),s+=8},h=g=>{let y=new Uint8Array(o.buffer,o.byteOffset+s,g);return s+=g,y};return{write8:u,write32:l,write16:p,write64:m,writeData:g=>h(g.length).set(g),dv:o,next:h}}function Fr(n,t,e){let r=JSON.stringify(t),{writeData:s,dv:o}=jt(n,r.length+16);switch(s(e.split("").map(u=>u.charCodeAt(0))),s(r.split("").map(u=>u.charCodeAt(0))),n){case 11:case 12:case 7:console.debug("send",se[n],e,t,o.buffer);break;default:n<255&&console.log(ut(),"send",se[n],e,t,o.buffer)}return o.buffer}var bo=_r(qt()),ge=class extends bo.EventEmitter{constructor(e){super();this.io=e}get statReportReq(){return this.io.statReportReq.stat}get qualityReport(){return this.io.qualityReportReq.report}get appId(){return this.io.joinReq.sdkAppID}get roomId(){return this.io.joinReq.roomid}get userId(){return this.io.joinRes.openid}get userMap_(){return this.io.userManager.remotePublishedUserMap}send(e,r){return this.io.sendReq(e,r)}post(e,r){return this.io.postReq(e,r)}postMessage(e,r){this.io.postMessage({cmd:e,payload:r})}createResposeOb(e){return Se(this.io,se[e])}glog(e){self.postMessage({type:"glog",payload:e})}};var $t=class{constructor(){d(this,"arguments");d(this,"environment");d(this,"preInit");d(this,"preRun");d(this,"postRun");d(this,"onAbort");d(this,"preinitializedWebGLContext");d(this,"noInitialRun");d(this,"noExitRuntime");d(this,"logReadFiles");d(this,"filePackagePrefixURL");d(this,"wasmBinary");d(this,"HEAP");d(this,"IHEAP");d(this,"FHEAP");d(this,"HEAP8");d(this,"HEAP16");d(this,"HEAP32");d(this,"HEAPU8");d(this,"HEAPU16");d(this,"HEAPU32");d(this,"HEAPF32");d(this,"HEAPF64");d(this,"TOTAL_STACK");d(this,"TOTAL_MEMORY");d(this,"FAST_MEMORY");d(this,"preloadedImages");d(this,"preloadedAudios");d(this,"_GetEncodedFrame");d(this,"_ReceivedAudioPacket");d(this,"_CreateUdtPacketizer");d(this,"_PacketizeVideoUdt");d(this,"udtver",3)}onRuntimeInitialized(){}print(t){console.debug(t)}printErr(t){console.debug(t)}},ce=new $t,B=class{constructor(t,e){this.size=t;d(this,"point");this.point=ce._malloc(t),e&&this.set(e)}set(t){t.length>this.size&&this.grow(t.length),ce.HEAPU8.set(t,this.point)}setUint32(t,e){new DataView(ce.HEAPU8.buffer).setUint32(this.point+t,e)}setBigUint64(t,e){new DataView(ce.HEAPU8.buffer).setBigUint64(this.point+t,e)}getBigUint64(t){return new DataView(ce.HEAPU8.buffer).getBigUint64(this.point+t)}getUint32(t){return ce.HEAPU8[this.point+t]|ce.HEAPU8[this.point+t+1]<<8|ce.HEAPU8[this.point+t+2]<<16|ce.HEAPU8[this.point+t+3]<<24}getInt8(t){return ce.HEAPU8[this.point+t]}uint8Array(t=NaN){return new Uint8Array(ce.HEAPU8.buffer,this.point,t>=0?t:this.size)}uint8Slice(t=NaN){return ce.HEAPU8.slice(this.point,this.point+(t>=0?t:this.size))}fill(t=0,e=this.point,r=this.point+this.size){ce.HEAPU8.fill(t,e,r)}free(){ce._free(this.point)}grow(t){t>this.size&&(this.free(),this.size=t,this.point=ce._malloc(t))}};d(B,"global");var V=ce;var Hr=class{constructor(t){d(this,"lastReceiveTime",-1);d(this,"blocking",!1);d(this,"blockCnt",0);d(this,"blockTime",0);d(this,"received",ze());let e=je(t);H(this.received,bi(()=>(this.blockDone(),this.lastReceiveTime=Date.now(),e)),X(()=>{this.blocking=!0},$,()=>{this.blockDone()}))}blockDone(){this.blocking&&(this.blockCnt++,this.blockTime+=Date.now()-this.lastReceiveTime,this.blocking=!1)}clear(){this.blockCnt=0,this.blockTime=0}},jr=class jr{constructor(t=2){d(this,"videoStatus",{uint32_video_stream_type:2,uint32_video_codec_fps:0,uint32_video_capture_fps:0,uint32_video_receive_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_type:0,uint32_video_gop:0,uint32_video_rps_open:0,uint32_video_rps_interval:0,uint32_video_codec_bitrate:0,uint32_video_total_bitrate:0,uint32_video_fec_ratio:0,uint32_video_fec_recover:0,uint32_video_arq_request:0,uint32_video_arq_recover:0,uint32_video_arq_packets:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_final_lost:0,uint32_video_block_cnt:0,uint32_video_cache_ms:0,uint32_video_total_frame:0,uint32_video_decode_frame:0,uint32_video_block_time:0,uint32_video_quality:0,uint32_video_jitter_fps:0});d(this,"videoPort");d(this,"control");d(this,"lastReceiveTime",-1);d(this,"vBlock",new Hr(500));d(this,"ssrc",jr.g_ssrc++);d(this,"framesFromStartPull",0);this.videoStatus.uint32_video_stream_type=t}getVideoStatus(){let t=Mt({},this.videoStatus);return t.uint32_video_block_cnt=this.vBlock.blockCnt,t.uint32_video_block_time=this.vBlock.blockTime,t.uint32_video_codec_bitrate>>=1,t.uint32_video_total_bitrate>>=1,t.uint32_video_receive_fps>>=1,t.uint32_video_capture_fps>>=1,t.uint32_video_codec_fps>>=1,this.videoStatus.uint32_video_codec_bitrate=0,this.videoStatus.uint32_video_total_bitrate=0,this.videoStatus.uint32_video_receive_fps=0,this.videoStatus.uint32_video_capture_fps=0,this.videoStatus.uint32_video_codec_fps=0,this.vBlock.clear(),t}demuxPacket(t){let e=t.length,{ssrc:r,videoStatus:s,vBlock:o}=this;s.uint32_video_receive++;let u=Date.now();s.uint32_video_total_bitrate+=e<<3,B.global.set(t);let p=V._ReceivedVideoPacket(B.global.point,e,u/1e3,u%1e3,r);p==0&&(this.lastReceiveTime>0&&u-this.lastReceiveTime>500&&console.debug("demuxPacket",u-this.lastReceiveTime),this.lastReceiveTime=u),o.received.next(p)}gotVideoFrame(t){var r;this.videoStatus.uint32_video_total_frame++,this.videoStatus.uint32_video_codec_bitrate+=t.length<<3,this.videoStatus.uint32_video_receive_fps++,this.videoStatus.uint32_video_capture_fps++;let e=t.slice();(r=this.videoPort)==null||r.postMessage({data:e,packetsReceived:this.videoStatus.uint32_video_receive},[e.buffer])}};d(jr,"g_ssrc",1);var qr=jr,Gr=class{constructor(t,e){this.writer=t;this.ssrc=e;d(this,"buffer",new B(960));d(this,"timestamp",0);V._AddAudioChannel(e,e)}feed(){this.writer.write(new AudioData({format:"s16",numberOfChannels:1,numberOfFrames:480,sampleRate:48e3,timestamp:this.timestamp+=1e4,data:this.buffer.uint8Array()}))}close(){V._DelAudioChannel(this.ssrc),this.buffer.free()}},Wr=class{constructor(t,e){this.io=e;d(this,"userId");d(this,"tinyId");d(this,"role");d(this,"terminalType");d(this,"lastCapNtpMs",-1);d(this,"startTimestamp",Date.now());d(this,"alastReceivedTimestamp",-1);d(this,"lengthPoint",new B(4));d(this,"audioPuller");d(this,"mainPuller",new qr(2));d(this,"screenPuller",new qr(7));d(this,"aBlock",new Hr(250));d(this,"events",[]);d(this,"msg_audio_status",{uint32_audio_format:0,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_aec:0,uint32_audio_fec_ratio:0,uint32_audio_fec_recover:0,uint32_audio_arq_request:0,uint32_audio_arq_recover:0,uint32_audio_arq_packets:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0,uint32_audio_cache_ms:0,uint32_audio_capture_state:0,uint32_audio_filtered_max_cache_ms:0,uint32_audio_filtered_avg_cache_ms:0,uint32_audio_target_max_cache_ms:0,uint32_audio_target_avg_cache_ms:0,uint32_audio_delay_peak_count:0,uint32_audio_speed_percent:0,uint32_audio_quality:0,uint32_audio_block_time:0,uint32_audio_block_cnt:0,uint32_audio_level:0});d(this,"subscribe",0);d(this,"removing",!1);d(this,"isKeyPoint");Object.defineProperties(this,Object.getOwnPropertyDescriptors(t))}remove(){var t;this.lengthPoint.free(),(t=this.audioPuller)==null||t.close()}toDownStreamInfo(t,e){let r=[this.mainPuller.getVideoStatus()];r[0].uint32_video_stream_type=this.subscribe&8?3:2,this.screenPuller.videoPort&&r.push(this.screenPuller.getVideoStatus());let s=Mt({},this.msg_audio_status);return s.uint32_audio_codec_bitrate>>=1,s.uint32_audio_total_bitrate>>=1,s.uint32_audio_block_cnt=this.aBlock.blockCnt,s.uint32_audio_block_time=this.aBlock.blockTime,e&&console.log(new Date().toLocaleString(),t.userId,r.map(o=>({t:o.uint32_video_stream_type,r_fps:o.uint32_video_receive_fps,c_fps:o.uint32_video_codec_fps,c_bps:o.uint32_video_codec_bitrate})),s.uint32_audio_codec_bitrate),this.msg_audio_status.uint32_audio_total_bitrate=0,this.msg_audio_status.uint32_audio_codec_bitrate=0,this.aBlock.clear(),{msg_user_info:{str_identifier:this.userId,uint64_tinyid:Number(this.tinyId)},msg_audio_status:s,msg_video_status:r,msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0,uint32_jitter:0}}}getNextVideoFrame(t){this.lengthPoint.setUint32(0,B.global.size),this.isKeyPoint||(this.isKeyPoint=new B(1));let e=V._GetEncodedFrame(B.global.point,this.lengthPoint.point,this.isKeyPoint.point,t.ssrc),r=this.lengthPoint.getUint32(0);if(e==-1||r==0)return 10;let s=B.global.uint8Array(r);return t.videoStatus.uint32_video_total_frame||console.timeEnd(`${this.userId}${t==this.mainPuller?"big":"aux"}`),t.gotVideoFrame(s),e}startPullOnlyAudio(t,e,r){this.io.log_.info("start pull only audio",t),V._AddAudioChannel(t.ssrc,t.ssrc)}startPull(t,e,r){this.io.log_.info("start pull",t,r);let s=t===this.mainPuller;if(t.videoPort){t.framesFromStartPull=0,t.videoPort.port=e.port;return}let o=s?[2,1]:[7];t.videoPort=e,console.time(`${this.userId}${r.mediaType&2?"aux":"big"}`),H(e,X(({width:h,height:f})=>{t.videoStatus.uint32_video_width=h,t.videoStatus.uint32_video_height=f,t.videoStatus.uint32_video_decode_frame++,t.videoStatus.uint32_video_codec_fps++}));let u=h=>{delete t.videoPort,h?this.io.log_.error("stop pull",h):this.io.log_.info("stop pull",t),V._DelVideoChannel(t.ssrc),t.vBlock.received.complete(),s&&this.aBlock.received.complete()};V._AddVideoChannel(t.ssrc,t.ssrc);let p=0,l=0,m=()=>{Date.now()-l>2e3&&(l=Date.now(),this.io.sendReq(11,r))};H(this.io.wh.interval10ms,gt(h=>(p<=0&&(p=this.getNextVideoFrame(t),p>500&&(p=20)),p-=10,ne.useWt&&(h&1)==0&&!o.every(f=>{let g=V._CheckMissingPacket(B.global.point,B.global.size,f,t.ssrc,this.io.rtt);return g>0&&(B.global.setBigUint64(5,BigInt(this.tinyId)),this.io.send(B.global.uint8Array(g))),g>=0}))),Ve(e),X(m,u,u)),m(),H(xe(5e3),Ve(e),X(m))}};var dl=1e8;function ml(){let n=new B(500,[0]);return V._GetAudioEnergy(n.point,100),n}var xt=class xt extends ge{constructor(){super(...arguments);d(this,"audioReceivedBuff",new B(2048));d(this,"levelsMap",new Map);d(this,"timestampBuff",new B(12))}decodeAudio(e,r){H(this.createResposeOb(4095),Ve(r),X(({data:s})=>{let u=new DataView(s.buffer,s.byteOffset,s.byteLength).getBigUint64(9).toString();this.userMap_.has(u)&&(this.statReportReq.msg_net_stat_report.uint32_down_real_pkg++,this.statReportReq.msg_net_stat_report.uint32_down_recv_br+=s.byteLength,this.demuxPacket(s,this.userMap_.get(u),e&&r))})),e&&H(r,X(({timestamp:s,rtpTimestamp:o,seqNum:u,ssrc:p,data:l})=>{this.audioReceivedBuff.set(l),V._ReceivedRawAudioPacket(this.audioReceivedBuff.point,l.byteLength,s,o,u,p)}))}pullAudio({tinyId:e,writable:r}){let s=this.userMap_.get(e);s&&(s.audioPuller=new Gr(r.getWriter(),s.mainPuller.ssrc))}getAudioEnergy(e,r){xt.energys||(xt.energys=ml());let{energys:s}=xt;H(xe(e),Ve(r),X(()=>{let o=s.getInt8(0);for(let u=1;u<5*o;u+=5)this.levelsMap.set(s.getUint32(u),s.getInt8(u+4));if(this.userMap_.size>0){let u=[...this.userMap_.values()];r.postMessage(u.map(p=>{let l=Math.min(100,(this.levelsMap.get(p.mainPuller.ssrc)||0)*2);return p.msg_audio_status.uint32_audio_level=l*dl/100>>0,{userId:p.userId,volume:l}}))}else r.postMessage([])}))}demuxPacket(e,r,s){let{aBlock:o,msg_audio_status:u}=r;o.received.next(!0),u.uint32_audio_total_bitrate+=e.byteLength<<3,u.uint32_audio_codec_bitrate=u.uint32_audio_total_bitrate-31,this.audioReceivedBuff.set(e);let p=Date.now(),l=p/1e3,m=p%1e3;if(s){let h=V._ParseUdtAudioPacket(this.audioReceivedBuff.point,e.length,this.timestampBuff.point,this.timestampBuff.point+4,this.timestampBuff.point+8,this.audioReceivedBuff.point,r.mainPuller.ssrc);if(h>0){let f=this.audioReceivedBuff.getUint32(0),g=V.HEAPU8.slice(f,f+h);s.postMessage({timestamp:this.timestampBuff.getUint32(0),rtpTimestamp:this.timestampBuff.getUint32(4),seqNum:this.timestampBuff.getUint32(8),data:g,ssrc:r.mainPuller.ssrc,userId:r.userId},[g.buffer])}}else V._ReceivedAudioUdtPacket(this.audioReceivedBuff.point,e.length,l,m,r.mainPuller.ssrc)}};d(xt,"energys");var Yt=xt;var Eo=_r(qt(),1),go=Symbol("instance"),D_=Symbol("abortCtrl"),Kr=Symbol("cacheResult"),Kt=class{constructor(t,e,r){this.oldState=t,this.newState=e,this.action=r,this.aborted=!1}abort(t){this.aborted=!0,Xt.call(t,this.oldState,new Error(`action '${this.action}' aborted`))}toString(){return`${this.action}ing`}},ct=class extends Error{constructor(t,e,r){super(e),this.state=t,this.message=e,this.cause=r}};function pl(n){return typeof n=="object"&&n&&"then"in n}var Jt=new Map;function _e(n,t,e={}){return(r,s,o)=>{let u=e.action||s;if(!e.context){let l=Jt.get(r)||[];Jt.has(r)||Jt.set(r,l),l.push({from:n,to:t,action:u})}let p=o.value;o.value=function(...l){let m=this;if(e.context&&(m=Z.get(typeof e.context=="function"?e.context.call(this,...l):e.context)),m.state===t)return e.sync?m[Kr]:Promise.resolve(m[Kr]);m.state instanceof Kt&&m.state.action==e.abortAction&&m.state.abort(m);let h=null;Array.isArray(n)?n.length==0?m.state instanceof Kt&&m.state.abort(m):(typeof m.state!="string"||!n.includes(m.state))&&(h=new ct(m._state,`${m.name} ${u} to ${t} failed: current state ${m._state} not from ${n.join("|")}`)):n!==m.state&&(h=new ct(m._state,`${m.name} ${u} to ${t} failed: current state ${m._state} not from ${n}`));let f=U=>{if(e.fail&&e.fail.call(this,U),e.sync){if(e.ignoreError)return U;throw U}else return e.ignoreError?Promise.resolve(U):Promise.reject(U)};if(h)return f(h);let g=m.state,y=new Kt(g,t,u);Xt.call(m,y);let R=U=>{var D;return m[Kr]=U,y.aborted||(Xt.call(m,t),(D=e.success)===null||D===void 0||D.call(this,m[Kr])),U},w=U=>(Xt.call(m,g,U),f(U));try{let U=p.apply(this,l);return pl(U)?U.then(R).catch(w):e.sync?R(U):Promise.resolve(R(U))}catch(U){return w(new ct(m._state,`${m.name} ${u} from ${n} to ${t} failed: ${U}`,U instanceof Error?U:new Error(String(U))))}}}}var _l=typeof window!="undefined"&&window.__AFSM__?(e,r)=>{window.dispatchEvent(new CustomEvent(e,{detail:r}))}:typeof importScripts!="undefined"?(e,r)=>{postMessage({type:e,payload:r})}:()=>{};function Xt(n,t){let e=this._state;this._state=n;let r=n.toString();n&&this.emit(r,e),this.emit(Z.STATECHANGED,n,e,t),this.updateDevTools({value:n,old:e,err:t instanceof Error?t.message:String(t)})}var Z=class n extends Eo.default{constructor(t,e,r){super(),this.name=t,this.groupName=e,this._state=n.INIT,t||(t=Date.now().toString(36)),r?Object.setPrototypeOf(this,r):r=Object.getPrototypeOf(this),e||(this.groupName=this.constructor.name);let s=r[go];s?this.name=s.name+"-"+s.count++:r[go]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let t=Object.getPrototypeOf(this),e=Jt.get(t)||[],r=new Set,s=[],o=[],u=new Set,p=Object.getPrototypeOf(t);Jt.has(p)&&(p.stateDiagram.forEach(m=>r.add(m)),p.allStates.forEach(m=>u.add(m))),e.forEach(({from:m,to:h,action:f})=>{typeof m=="string"?s.push({from:m,to:h,action:f}):m.length?m.forEach(g=>{s.push({from:g,to:h,action:f})}):o.push({to:h,action:f})}),s.forEach(({from:m,to:h,action:f})=>{u.add(m),u.add(h),u.add(f+"ing"),r.add(`${m} --> ${f}ing : ${f}`),r.add(`${f}ing --> ${h} : ${f} \u{1F7E2}`),r.add(`${f}ing --> ${m} : ${f} \u{1F534}`)}),o.forEach(({to:m,action:h})=>{r.add(`${h}ing --> ${m} : ${h} \u{1F7E2}`),u.forEach(f=>{f!==m&&r.add(`${f} --> ${h}ing : ${h}`)})});let l=[...r];return Object.defineProperties(t,{stateDiagram:{value:l},allStates:{value:u}}),l}static get(t){let e;return typeof t=="string"?(e=n.instances.get(t),e||n.instances.set(t,e=new n(t,void 0,Object.create(n.prototype)))):(e=n.instances2.get(t),e||n.instances2.set(t,e=new n(t.constructor.name,void 0,Object.create(n.prototype)))),e}static getState(t){var e;return(e=n.get(t))===null||e===void 0?void 0:e.state}updateDevTools(t={}){_l(n.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(t){Xt.call(this,t)}};Z.STATECHANGED="stateChanged";Z.UPDATEAFSM="updateAFSM";Z.INIT="[*]";Z.ON="on";Z.OFF="off";Z.instances=new Map;Z.instances2=new WeakMap;var Ye=class extends Z{constructor(e){super(e.params.userId,"WebSocket");this.connectFSM=e;d(this,"ws")}connect(){this.connectFSM.log_.info("connect to",this.connectFSM.wsUrl);let e=new WebSocket(this.connectFSM.wsUrl);return console.time("WebSocket connect"),e.binaryType="arraybuffer",$e((r,s)=>{e.onerror=o=>{e.onmessage=null,this.connectFSM.log_.error("websocket onerror",o),s(o.type)},e.onclose=o=>{e.onmessage=null,s(o),this.connectFSM.log_.info("websocket onclose",o),this.disconnect(o.reason,o.code)},e.onopen=o=>{console.timeEnd("WebSocket connect"),this.connectFSM.log_.info("websocket onopen")},e.onmessage=o=>{try{let u=JSON.parse(String(o.data));if(this.connectFSM.log_.info("websocket verify",u),u.err!==0)throw u.err;this.connectFSM.verify(u.verify,u.rebuild),this.ws=e,r(e);let p=this.connectFSM.createOputReceiver("w");e.onmessage=l=>p.write(l.data)}catch(u){s(u)}}},this.connectFSM.abortCtrl.signal)}disconnect(e="",r=0){return r===0&&this.ws&&(this.ws.onmessage=null,this.ws.close(1e3,e)),this.connectFSM.log_.warn("websocket disconnected :",r,e),this.connectFSM.disconnect(e)}close(){this.ws&&(this.ws.onmessage=null,this.ws.close(1e3,"close"))}sendReq(e,r,s){this.send(Fr(e,r,s||this.connectFSM.generateUUID()))}send(e){var r;this.state=="CONNECTED"&&((r=this.ws)==null||r.send(e))}};le([_e(["DISCONNECTED",Z.INIT],"CONNECTED")],Ye.prototype,"connect",1),le([_e("CONNECTED","DISCONNECTED",{sync:!0,ignoreError:!0})],Ye.prototype,"disconnect",1),le([_e([],Z.INIT,{sync:!0})],Ye.prototype,"close",1);var J_=new Uint32Array([Date.now()]),fl=H(bt(20),tt(()=>performance.now()),We()),Us=class{constructor(t){this.wt=t;d(this,"chunk",new Map);d(this,"timestamp",performance.now());d(this,"groupId");d(this,"resentCount",0);this.groupId=t.groupid,t.groupid=t.groupid+1&127,t.sentCache.has(this.groupId)&&t.sentCache.get(this.groupId).chunk.clear(),t.sentCache.set(this.groupId,this),H(fl,Fn(()=>this.chunk.size>0&&this.resentCount<20),Oe(Se(t,"DISCONNECTED")),X(e=>{e-this.timestamp>2*t.connectFSM.rtt+10&&(this.chunk.forEach((r,s)=>this.wt.send(r.buffer)),console.debug("resent",this.groupId,this.chunk.size,"after",e-this.timestamp,"ms",++this.resentCount),this.timestamp=e)},console.error,()=>{this.wt.sentCache.delete(this.groupId)}))}ack(t){this.chunk.delete(t)}},Ke=class extends Z{constructor(e){super(e.params.userId,"WebTransport");this.connectFSM=e;d(this,"wt");d(this,"writer");d(this,"dw");d(this,"sentCache",new Map);d(this,"groupid",0);d(this,"mtu",1e3)}async connect(){this.connectFSM.log_.info("connect to",this.connectFSM.wtUrl);let e=new WebTransport(this.connectFSM.wtUrl);console.time("WebTransport connect"),e.ready.then(()=>console.timeEnd("WebTransport connect"));let r=this.connectFSM.abortCtrl.signal,{value:s,stream:o}=await Promise.race([(async()=>{await $e(e.ready,r);let p=await $e(e.createBidirectionalStream(),r),l=p.readable.getReader();return this.writer=p.writable.getWriter(),this.dw=e.datagrams.writable.getWriter(),$e(l.read(),r).then(({value:m})=>(l.releaseLock(),{value:m,stream:p}))})(),new Promise((p,l)=>setTimeout(()=>l(new Error("WebTransport connect timeout")),1e3))]),u=JSON.parse(String.fromCharCode(...s));if(this.connectFSM.log_.info("WebTransport connect result:",u),u.err!==0)throw u.err;this.connectFSM.verify(u.verify,u.rebuild),this.wt=e,H(Se(this.connectFSM,se[4099]),Oe(Se(this,"DISCONNECTED")),X(({data:p})=>{let l=p[0]&127,m=this.sentCache.get(l);m&&m.ack(p[1])})),Promise.race([e.datagrams.readable.pipeTo(new WritableStream(this.connectFSM.createOputReceiver("d"))),o.readable.pipeTo(new WritableStream(this.connectFSM.createOputReceiver("s"))),e.closed]).then(()=>this.disconnect(),this.disconnect.bind(this))}disconnect(e=""){var r;return(r=this.wt)==null||r.close(),this.connectFSM.disconnect(e)}close(){var e;return(e=this.wt)==null?void 0:e.close()}async sendReq(e,r,s){if(s||(s=this.connectFSM.generateUUID()),!this.wt)return new Error("WebTransport not connected");if(!ne.unreliable){let y=Fr(e,r,s);return this.writer.write(y).then(()=>!0).catch(this.catchError)}let o=e>=255&&e<4095,u=JSON.stringify(r),p=0,l=u.length+(o?20:16),h=(l>65535?1:0)?7:5,f=Math.ceil(l/this.mtu),g=new Us(this);console.debug("WebTransport send:",o?"ack":"",se[e],s,"chunks:",f,g.groupId);for(let y=0;y<f;y++){let R=l-y*this.mtu,w=Math.min(this.mtu,R),U=new Uint8Array(h+4+w),D=ys(e,U.length-h,new DataView(U.buffer));if(U[0]|=2,U.set([1,2,(y==f-1?128:0)|g.groupId,y],D),D+=4,y==0){o&&(U.set([0,0,0,0],D),D+=4);for(let G=0;G<16;G++)U[D++]=s.charCodeAt(G)}for(let G=0;D<U.length;G++)U[D++]=u.charCodeAt(p++);g.chunk.set(y,U),this.send(U.buffer)}}async send(e){if(!(!this.wt||!this.dw)){if(e instanceof ArrayBuffer){if(!e.byteLength)throw To}else{if(!e.length)throw To;e=e.slice(0)}return this.dw.write(e).catch(this.catchError)}}catchError(e){}};le([_e(["DISCONNECTED",Z.INIT],"CONNECTED")],Ke.prototype,"connect",1),le([_e("CONNECTED","DISCONNECTED",{sync:!0,ignoreError:!0})],Ke.prototype,"disconnect",1),le([_e([],Z.INIT,{sync:!0})],Ke.prototype,"close",1);var To=new Error("WebTransport send empty datagram");var Io=_r(qt(),1);var Jr=class extends Io.EventEmitter{constructor(e,r,s="userId"){super();this.mySelfId=e;this._log=r;this.key=s;d(this,"userMap",new Map);d(this,"remotePublishedUserMap",new Map);d(this,"asrRobotUserMap",new Map)}get hasRobotUser(){return!![...this.remotePublishedUserMap.values()].find(e=>e.isRobot)}getPublishedUser(e){return this.remotePublishedUserMap.get(e)}addUser(e){let r=e[this.key],{userId:s,tinyId:o,role:u,fromType:p}=e;if(p===xi){this.addAsrRobotUser(e);return}if(this.userMap.has(r))return;let l={userId:s,tinyId:o,role:u===20?"anchor":"audience"};this.userMap.set(r,l),this.emit("1",l)}addAsrRobotUser(e){let r=e[this.key],{userId:s,tinyId:o,role:u}=e;if(this.asrRobotUserMap.has(r))return;let p={userId:s,tinyId:o,role:u===20?"anchor":"audience"};this.asrRobotUserMap.set(r,p),this.emit("8",p)}deleteUser(e,r){let s=this.userMap.get(e);if(!s)return;if(this.asrRobotUserMap.has(e)){this.deleteAsrRobotUser(e);return}let u=`peer leave [${e}]`;Gt(r)||(u+=`:${Oi[r]}`),this._log.info(u);let p=this.remotePublishedUserMap.get(e);if(p){let l=p.muteState;p.flag=0,this.emit("5",p.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:l,muteState:p.muteState,flag:0})}this.userMap.delete(e),this.emit("2",{userId:s.userId,reason:r})}deleteAsrRobotUser(e){if(!this.asrRobotUserMap.has(e))return;let r=this.asrRobotUserMap.get(e);r&&(this.asrRobotUserMap.delete(e),this.emit("9",r))}setUserList(e){this.userMap.forEach(r=>{e.findIndex(s=>s[this.key]===r[this.key])<0&&this.deleteUser(r[this.key],0)}),e.forEach(r=>{!this.userMap.has(r[this.key])&&r[this.key]!==this.mySelfId&&this.addUser(r)})}addRemotePublishedUser(e){this.remotePublishedUserMap.has(e[this.key])||this.remotePublishedUserMap.set(e[this.key],e)}deleteRemotePublishedUser(e){this.remotePublishedUserMap.has(e)&&this.remotePublishedUserMap.delete(e)}setRemotePublishedUserList(e){this.remotePublishedUserMap.forEach(r=>{let s=r[this.key];if(e.findIndex(o=>o[this.key]===r[this.key])<0){this._log.info(`remote [${s}] unpublish`);let o=r.muteState;r.flag=0,this.emit("5",r.userId),this.deleteRemotePublishedUser(s),this.emit("6",{prevMuteState:o,muteState:r.muteState,flag:0})}}),e.forEach(r=>{var f;let s=r[this.key];if(s===this.mySelfId){this.emit("7",r);return}let{flag:o,userId:u,tinyId:p,fromType:l}=r,m=Ss(o,u),h=(f=this.remotePublishedUserMap.get(s))==null?void 0:f.muteState;if(h){let g=this.remotePublishedUserMap.get(s);g&&g.flag!==o&&(g.flag=o,this._log.info(`remote publish updated: ${JSON.stringify(g.muteState)}`),this.emit("6",{prevMuteState:h,muteState:m,flag:o}))}else this._log.info(`remote publish. state: ${JSON.stringify(m)}`),this.addUser({userId:u,tinyId:p,role:20,fromType:l}),this.emit("3",r),this.emit("6",{prevMuteState:Ss(0,u),muteState:m,flag:o})})}clear(){this.userMap.clear(),this.remotePublishedUserMap.clear()}};function So(n,t=1,e=1){return n<=1?e:So(n-1,e,t+e)}function El(n){return n>8?30*1e3:So(n)*1e3}function Tl(n,t){return{userId:t,hasAudio:!!(n&Tt),hasVideo:!!(n&Et),hasAuxiliary:!!(n&vr),hasSmall:!!(n&Pr),audioMuted:!!(n&It),videoMuted:!!(n&St),audioAvailable:!!(n&Tt)&&!(n&It),videoAvailable:!!(n&Et)&&!(n&St)}}var Os=class{constructor(t){this.connect=t;d(this,"publishReq");d(this,"recovering",!1);d(this,"pingCount",0)}async recoverLocal(){return this.recovering=!0,this.publishReq?this.connect._sendReq(2,this.publishReq).then(t=>{this.connect.log_.info("republish",t)}):!1}recoverRemote(t){this.recovering=!1,t.forEach((e,r)=>{this.connect.sendSubscribe(e)})}onSendReq(t,e){switch(t){case 2:this.publishReq?this.publishReq.mediaType|=e.mediaType:this.publishReq=e;break;case 3:this.publishReq=void 0;break;case 8:this.publishReq&&(this.publishReq.mediaType&=~e.mediaType);break;case 9:this.publishReq&&(this.publishReq.mediaType|=e.mediaType);break;case 12:this.connect.updateDevTools({note:`ping${this.pingCount++}`});break}}},Ee=class Ee extends Z{constructor(e,r,s){super(s.joinReq.roomid,"Connection");this.id=e;this.port=r;d(this,"signalInfo_");d(this,"reqUser_");d(this,"joinReq");d(this,"frameWorkType");d(this,"userManager");d(this,"joinRes");d(this,"statReportReq");d(this,"qualityReportReq");d(this,"wFSM");d(this,"rtt",50);d(this,"recovery",new Os(this));d(this,"reqPromise",new Map);d(this,"rebuild");d(this,"osName");d(this,"browserInfo");d(this,"tinyId_",new B(32));d(this,"tinyId");d(this,"domains");d(this,"log_");d(this,"params");d(this,"proxy_ws");d(this,"proxy_wt");d(this,"proxy_cloud");d(this,"proxy_unified");d(this,"env");d(this,"wh");d(this,"abortCtrl",new AbortController);d(this,"firstReceiveUserlist");d(this,"connectParams");d(this,"selectDomain",0);d(this,"selectCloudDomain",0);d(this,"abort",this.abortCtrl.abort.bind(this.abortCtrl));d(this,"reconnectedOB",Se(this,"RECONNECTED"));d(this,"reconnectOB",e=>{this.reconnect().then(()=>{this.postMessage({cmd:"signal-connection-state-changed",payload:{prevState:"RECONNECTING",state:"CONNECTED"}}),this.rejoinRoom()},r=>{e.next(r),this.selectDomain=1-this.selectDomain})});console.log(this),Object.assign(this,s),this.connectParams=new URLSearchParams({sdkAppid:this.params.sdkAppId.toString(),userSig:this.params.userSig,identifier:this.params.userId}),this.tinyId&&this.connectParams.append("tinyId",this.tinyId),this.log_=nt.createLogger({id:`wc${e}`,userId:this.params.userId,sdkAppId:this.params.sdkAppId}),this.proxy_unified?ne.useWt=!1:(this.proxy_ws||this.proxy_wt)&&(ne.useWt=!!this.proxy_wt),ne.useWt?this.wFSM=new Ke(this):this.wFSM=new Ye(this),this.userManager=new Jr("",this.log_,"tinyId");let o=u=>this.userManager.on(u,p=>this.postMessage({cmd:u,payload:p}));this.userManager.on("3",({flag:u,userId:p,tinyId:l})=>{let m={flag:u,userId:p,tinyId:l,get muteState(){return Tl(this.flag,this.userId)},subscribe:0,removing:!1};this.log_.debug("create user",m),this.postMessage({cmd:"3",payload:m}),this.userManager.addRemotePublishedUser(new Wr(m,this))}),o("6"),o("5"),o("1"),o("2"),o("7"),this.statReportReq={tinyid:"",stat:{msg_audio_stat_report:{msg_audio_enc_stat:{uint32_audio_enc_br:0,uint32_audio_frame_interval:0},msg_audio_send_stat:{uint32_audio_send_br:0,uint32_audio_fec_br:0,uint32_audio_arq_br:0}},rpt_msg_video_stat_report:[{uint32_video_type:2,msg_video_enc_stat:{uint32_video_enc_fps:0,uint32_video_enc_br:0,uint32_video_encrd:1},msg_video_send_stat:{uint32_video_send_br:0,uint32_video_fec_br:0,uint32_video_arq_br:0}}],msg_net_stat_report:{uint32_total_send_br:0,uint32_rtt:0,uint32_down_expect_pkg:0,uint32_down_real_pkg:0,uint32_down_recv_br:0},msg_rtt_info_req:{uint64_last_server_timestamp_ms:0,uint32_delay_since_last_server_timestamp_ms:0,uint64_client_timestamp_ms:0},msg_system_load_report:{uint32_total_cpu_rate:0},msg_down_bandwidth_est:{uint32_bandwidth_br:0,uint32_avg_bandwidth_br:0,uint32_jitter:0,uint32_jitter_in_frm:0},msg_play_report:{uint32_video_jitter_receive_fps_ratio:0}}},this.qualityReportReq={tinyid:"",report:{str_sdk_version:this.joinReq.jsSdkVersion,uint32_groupid:0,uint64_datetime:Date.now(),msg_user_info:{str_identifier:"",uint64_tinyid:0},msg_device_info:{uint32_terminal_type:this.joinReq.AbilityOption.GeneralLimit.uint32_terminal_type,str_device_name:this.browserInfo.browserName,str_os_version:this.osName,uint32_net_type:this.joinReq.AbilityOption.GeneralLimit.uint32_net_type,uint32_app_cpu:0,uint32_system_cpu:0,uint32_app_memory:0,uint32_background:0,uint32_headset:0},msg_up_stream_info:{msg_audio_status:{uint32_audio_format:11,uint32_audio_sample_rate:48e3,uint32_audio_codec_bitrate:0,uint32_audio_receive:0},msg_video_status:[{uint32_video_stream_type:2,uint32_video_decode_frame:0,uint32_video_total_frame:0,uint32_video_capture_fps:0,uint32_video_codec_fps:0,uint32_video_enc_fps:0,uint32_video_codec_bitrate:0,uint32_video_total_bitrate:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0,uint32_jitter:0},msg_qos:[]},msg_down_stream_info:[],msg_event_msg:[],str_acc_ip:"",str_client_ip:"",str_groupid:""}}}get aborted(){return this.abortCtrl.signal.aborted}get wtDomain(){return this.env?`${this.env}.rtc.qq.com:8080`:this.proxy_wt?this.proxy_wt:this.domains.length?`${this.domains[this.selectDomain]}:80`:"wasm.rtc.qq.com:80"}get wsDomain(){return this.env?`${this.env}.rtc.qq.com:8687`:this.proxy_cloud.length?this.proxy_cloud[this.selectCloudDomain].replace("wss://",""):this.proxy_ws?this.proxy_ws:this.domains.length?this.domains[this.selectDomain]:"wasm.rtc.qq.com"}get wtUrl(){return`${/^https?:/.test(this.wtDomain)?"":"https://"}${this.wtDomain}/v1/wt?${this.connectParams}`}get wsUrl(){var r;let e=((r=this.domains)==null?void 0:r[this.selectDomain])||"wasm.rtc.qq.com";return`${/^wss?:/.test(this.wsDomain)?"":"wss://"}${this.wsDomain}/v1/ws?${this.connectParams}&realHost=${e}`}async connect(){let e=this.wFSM.connect(),r=(s,o=!1)=>u=>{if(this.aborted||typeof u=="number")throw u;return this.selectDomain=s,this.wFSM=o?new Ke(this):new Ye(this),console.warn(u),console.warn("downgrade to",o?"WebTransport":"WebSocket",this.selectDomain?"\u5907\u7528\u57DF\u540D":"\u4E3B\u57DF\u540D"),this.wFSM.connect()};return ne.useWt&&(this.proxy_ws||!this.proxy_wt)&&(e=e.catch(r(0))),!this.proxy_wt&&!this.proxy_ws&&(e=e.catch(r(1,ne.useWt)),ne.useWt&&(e=e.catch(r(1)))),e}async joinRoom(){let{dataport:e,stunport:r,relayip:s,socketid:o,checkSigSeq:u}=this.signalInfo_,p=await this.sendReq(0,Object.assign(this.joinReq,{dataport:e,stunport:r,relayip:s,socketid:o,checkSigSeq:u}));if(p.err===0)this.setJoinRes(p.data);else throw p.err;return p}async leaveRoom(){return await this.sendReq(1,{}),this.close()}async rejoinRoom(){if(!this.rebuild){let e=await this.sendReq(0,this.joinReq);if(e.err===0)this.setJoinRes(e.data);else return}return this.recovery.recoverLocal()}async reconnect(){return this.postMessage({cmd:"signal-connection-state-changed",payload:{prevState:"DISCONNECTED",state:"RECONNECTING"}}),this.wFSM.connect()}retry(e=0){if(console.log(ut(),"retry",e),e>Ui){this.close();return}let r=je(El(e));H(e?pi(r,this.reconnectOB):this.reconnectOB,Er(1),Oe(this.reconnectedOB),X(s=>{typeof s!="number"&&this.state==="DISCONNECTED"&&this.retry(e+1)}))}disconnect(e){this.log_.warn("connection lost:",e),this.postMessage({cmd:"signal-connection-state-changed",payload:{prevState:"CONNECTED",state:"DISCONNECTED"}}),this.retry()}close(){this.userManager.clear(),this.port.postMessage(null),this.port.close(),this.wFSM.close()}postMessage(e,r){this.port.postMessage(e,r)}verify(e,r){this.signalInfo_=e,this.rebuild=r,this.reqUser_={openid:e.openid,tinyid:e.tinyid}}async _sendReq(e,r){r.tinyid||(r.reqUser=this.reqUser_);let s=this.generateUUID();return await this.wFSM.sendReq(e,r,s),$e((o,u)=>this.reqPromise.set(s,{resolve:o,reject:u,startTime:Date.now()}),this.abortCtrl.signal,o=>(console.log("abort",se[e]),{err:o}))}postReq(e,r){return this.wFSM.sendReq(e,r,this.generateUUID())}async sendReq(e,r){return this.recovery.onSendReq(e,r),this._sendReq(e,r)}send(e){return this.wFSM.send(e)}setJoinRes(e){this.joinRes=e,this.userManager.mySelfId=e.tinyid,this.statReportReq.tinyid=e.tinyid,this.qualityReportReq.tinyid=e.tinyid,this.qualityReportReq.report.str_acc_ip=e.relayip,this.qualityReportReq.report.str_client_ip=e.clientip,this.qualityReportReq.report.msg_user_info.str_identifier=e.openid,this.qualityReportReq.report.msg_user_info.uint64_tinyid=Number(e.tinyid),this.tinyId_.set([...e.tinyid].map(r=>r.charCodeAt(0)).concat(0)),[1,2,3,7].forEach(r=>{V._CreateUdtPacketizer(e.roomid,this.tinyId_.point,e.locationid,r,V.udtver,this.id)}),this.wFSM.sendReq(6,{})}onReceive(e,r,s){let o="",u=0,p=new DataView(s.buffer,s.byteOffset);r<255&&(u=p.getUint32(0),s=s.subarray(4)),r<4095&&(o=String.fromCharCode(...s.subarray(0,16)),s=s.subarray(16));let l=s;if(!o)p=new DataView(s.buffer,s.byteOffset,s.byteLength);else{let h="";for(let f=0,g=s.length,y=32768;f<g;f+=y)h+=String.fromCharCode.apply(null,s.subarray(f,Math.min(f+y,g)));if(u)l=h;else try{l=JSON.parse(h)}catch(f){l=h}}let m=se[r];switch(r){case 259:this.joinRes&&this.wFSM.sendReq(r,{tinyid:this.joinRes.tinyid}),console.debug(e,"receive:",m,o,l);break;case 256:l.userlist.forEach(U=>{if(this.userManager.addUser({userId:U.userid,tinyId:U.srctinyid,role:U.role}),this.joinRes&&U.srctinyid!=this.joinRes.tinyid&&this.userManager.userMap.has(U.srctinyid)){let D=this.userManager.userMap.get(U.srctinyid);this.sendSubscribe(D)}}),this.log_.info(e,"receive:",m,o,l),this.wFSM.sendReq(r,{count:this.userManager.userMap.size});break;case 257:this.userManager.deleteUser(l.userlist.srctinyid),this.log_.info(e,"receive:",m,o,l),this.wFSM.sendReq(r,{count:this.userManager.userMap.size});break;case 6:this.userManager.setUserList(l.userlist.map(U=>({userId:U.userid,tinyId:U.srctinyid,role:U.role})));break;case 255:this.wFSM.sendReq(r,{count:this.userManager.userMap.size});{let U=l.userlist.map(D=>({userId:D.userid,tinyId:D.srctinyid,flag:D.flag,terminalType:D.terminaltype}));this.firstReceiveUserlist||(this.firstReceiveUserlist=!0,this.postMessage({cmd:at.RECEIVED_PUBLISHED_USER_LIST,payload:{publishedUserList:U}})),this.userManager.setRemotePublishedUserList(U),this.recovery.recovering&&this.recovery.recoverRemote(this.userManager.remotePublishedUserMap)}break;case 4100:this.rtt=p.getUint32(4),console.debug(e,"receive:",m,o,l,this.rtt);let{dv:h,writeData:f}=jt(4101,8);f(s.subarray(0,4)),this.send(h.buffer);break;case 12:this.reqPromise.forEach(U=>{Date.now()-U.startTime>5e3&&(U.reject(new Error("heartbeat timeout")),this.reqPromise.delete(U.uuid))}),self.postMessage({type:"glog",payload:{heartbeatReceive:1}});case 11:case 260:console.debug(e,"receive:",m,o,l);case 7:case 4095:break;case 4096:case 4097:{let U=s.length;this.statReportReq.stat.msg_net_stat_report.uint32_down_real_pkg++,this.statReportReq.stat.msg_net_stat_report.uint32_down_recv_br+=U<<3;let D=p.getBigUint64(9).toString(),G=this.userManager.getPublishedUser(D);G?r===4096?(G.mainPuller.videoStatus.uint32_video_receive||console.timeLog(`${G.userId}big`,"first video data"),G.mainPuller.demuxPacket(s)):(G.screenPuller.videoStatus.uint32_video_receive||console.timeLog(`${G.userId}aux`,"first video data"),G.screenPuller.demuxPacket(s)):console.warn(e,"receive:",m,o,l,"user not found")}break;case 4102:case 4103:case 4099:break;case 4103:V.HEAPU8.set(s,B.global.point+8);let g=V._ParseUdtMousePacket(B.global.point+8,s.length,B.global.point),y=s.subarray(g),R=B.global.getBigUint64(0).toString(),w=this.userManager.userMap.get(R);w&&this.postMessage({cmd:"layerData",payload:{userId:w.userId,tinyId:R,layerData:y}}),console.debug(e,"receive:",m,g,l,R,y);break;case 4098:{let U=p.getUint8(8);for(let D=9;D<s.length;D+=6){let G=p.getUint32(D),Ae=p.getUint16(D+4);for(let ye=0;ye<=16;ye++){if(ye>0&&(Ae>>16-ye&1)==0)continue;let Re=V._GetRetransPacket(U,G+ye,B.global.point,this.id),ie=B.global.getUint32(0),fe=V.HEAPU8.subarray(ie,ie+Re);Re>0&&this.send(fe)}}}break;case 1:this.log_.info(e,"receive:",m,o,l),l>0&&l!==3&&(this.postMessage({cmd:"banned",payload:l}),this.close());break;case 258:this.log_.info(e,"receive:",m,o||"",l);break;default:this.log_.info(e,"receive:",m||r,o||"",l)}this.reqPromise.has(o)&&(u&&this.log_.warn(u,l,o),this.reqPromise.get(o).resolve({err:u,data:l,uuid:o}),this.reqPromise.delete(o)),this.emit(m,o?{uuid:o,err:u,data:l}:{data:l})}sendSubscribe(e){let r=e.subscribe;if(r==0)return;let s={mediaType:r,mediaDescription:{audioParam:r&1?{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]}:void 0,videoParam:[4,8,2].filter(o=>r&o).map(o=>({mediaType:o,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]}))},userId:e.userId,srctinyid:e.tinyId};this._sendReq(4,s)}createOputReceiver(e){return new me(this.unMarshal(e))}*unMarshal(e){let r=null,s=new Map;for(;;){let o=0,u=0;try{r=yield 1;let p=r[0]>>4,l=r[0]&2,m=r[0]&1;r=yield 4+m*2;let h=new DataView(r.buffer,r.byteOffset);if(u=h.getUint16(0),o=m==1?h.getUint32(2):h.getUint16(2),r=yield o,l){let f=r[0]&63,g=r[1],y=r.subarray(2,2+g);switch(f){case 1:let R=y[0]>>7,w=y[0]&127,U=y[1],{dv:D,write8:G}=jt(4099,2);G(w),G(U),this.send(D.buffer);let Ae=w%64;for(let Re=0;Re<64;Re++){let ie=w-Re;ie<0&&(ie+=64);let fe=Ae-Re;fe<0&&(fe+=64),s.has(fe)&&s.get(fe).groupId!=ie&&s.delete(fe)}let ye=s.get(Ae);if(ye||s.set(Ae,ye=new xs(w)),r=ye.push(U,r.slice(2+g),R!=0),r)s.delete(Ae);else continue}}this.onReceive(e,u,r)}catch(p){this.log_.error(e,p,o,u,r)}}}generateUUID(){return"xxxxxxxxxxxxxxxx".replace(/[xy]/g,e=>{let r=Math.random()*16|0;return(e=="x"?r:r&3|8).toString(16)})}};d(Ee,"JOINED","joined"),d(Ee,"CLOSED","closed"),le([_e(Z.INIT,"CONNECTED")],Ee.prototype,"connect",1),le([_e("CONNECTED",Ee.JOINED)],Ee.prototype,"joinRoom",1),le([_e("RECONNECTED",Ee.JOINED,{fail(){this.close()}})],Ee.prototype,"rejoinRoom",1),le([_e("DISCONNECTED","RECONNECTED")],Ee.prototype,"reconnect",1),le([_e([],"DISCONNECTED",{sync:!0})],Ee.prototype,"disconnect",1),le([_e([],Ee.CLOSED,{sync:!0})],Ee.prototype,"close",1);var Je=Ee,xs=class{constructor(t){this.groupId=t;d(this,"chunks",[]);d(this,"totalLen",0);d(this,"marker",!1)}push(t,e,r){if(this.chunks[t])return null;if(this.chunks[t]=e,this.totalLen+=e.length,r&&(this.chunks.length=t+1,this.marker=!0),this.marker){for(let o=0;o<this.chunks.length;o++)if(!this.chunks[o])return null;let s=new Uint8Array(this.totalLen);for(;this.chunks.length;){let o=this.chunks.pop();s.set(o,this.totalLen-=o.length)}return s}return null}};var Qt=class extends ge{publishCdn(t,e){return"request_time"in t?(console.info("startPublishTXCDN:",t),this.send(18,t).then(e.postMessage)):(console.info("startPublishCDN:",t),this.send(13,t).then(e.postMessage))}stopPublishCdn(t,e){return"request_time"in t?(console.info("stopPublishTXCDN:",t),this.send(19,t).then(e.postMessage)):(console.info("stopPublishCDN:",t),this.send(14,t).then(e.postMessage))}startMcuMix(t,e){let{inputParam:r,outputParam:s}=t,o={mcuMix:{reqUser:this.io.reqUser_,roomid:t.roomId,sdkAppID:this.appId,socketid:this.io.joinRes.socketid,mcuRequestTime:t.mcuRequestTime,outputSessionId:t.outputSessionId},inputParam:r.map(u=>({userid:u.userId,width:u.width,height:u.height,locationX:u.locationX,locationY:u.locationY,zOrder:u.zOrder,streamType:u.streamType,inputType:u.inputType})),outputParam:{streamId:s.streamId,streamType:s.streamType,videoWidth:s.width,videoHeight:s.height,videoBitrate:s.videoBps,videoFramerate:s.fps,vidoeGOP:s.gop,audioSampleRate:s.audioSampleRate,audioBitrate:s.audioBps,audioChannels:s.audioChannels,backgroundColor:s.backgroundColor,backgroundImage:s.backgroundImg,extraInfo:s.extraInfo,VCodec:s.videoCodec,ACodec:s.audioCodec}};return this.send(15,o).then(e.postMessage)}stopMcuMix(t,e){let r={mcuMix:{reqUser:this.io.reqUser_,roomid:this.roomId,sdkAppID:this.appId,socketid:this.io.joinRes.socketid,mcuRequestTime:t.mcuRequestTime,outputSessionId:t.outputSessionId},userid:this.userId,streamType:t.streamType};return console.info("stop mcuMix:",t),this.send(16,r).then(e.postMessage)}};var Il=1200;var Sl=31,Al=6,yl=6;var Ao={1:1,audio:1,video:4,2:4,auxVideo:2,7:2,3:8};var Wf=Date.now(),jf=Sl+Al+6+yl+Il+1;var zt=class extends ge{constructor(){super(...arguments);d(this,"videoEncBuffer_",new B(1920*1080*3>>1));d(this,"videoStats",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0});d(this,"audioStats",{bytesSent:0,packetsSent:0});d(this,"videoTypeIndexMap",new Map([[2,0]]));d(this,"requestTypeMap",new Map([[0,4096]]))}getLocalVideoStats(e){e.postMessage({[this.io.joinRes.openid]:this.videoStats})}getLocalAudioStats(e){e.postMessage({[this.io.joinRes.openid]:this.audioStats})}pushAudio({sampleRate:e,channelCount:r,bitrate:s,index:o},u,p){var y;let l=new B(e*r*2),m=R=>{this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_level=R.volume*1e8/100>>0;let{data:w}=R,U=w.length;l.set(w),this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_enc_br+=U<<3,this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_frame_interval++,this.audioStats.packetsSent++;let D=V._PacketizeAudioUdt(l.point,U,R.timestamp,e,r,R.energy,B.global.point,B.global.size,this.io.id,!!p);if(D<=0){console.warn("audio pack len is 0");return}this.io.send(B.global.uint8Array(D)),this.audioStats.bytesSent+=D,this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br+=D<<3,this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_receive++},h=R=>{l.free(),this.send(3,{mediaType:1})},f=new MessageChannel;(y=this.io.wh.playPort)==null||y.postMessage({cmd:"pushAudio",payload:{numberOfChannels:r,bitrate:s},encrypt:!!p,index:o},[f.port2,u.port]);let g=Wt(f.port1);p&&H(g,X()),H(p||g,X(m,h,h))}createSelectAbilityOb(e,r){let s=r.bitrate;return H(this.createResposeOb(259),hi(()=>je(2e3)),tt(o=>{var u;return(u=o.data.ability.rpt_msg_video_control_info)==null?void 0:u.find(p=>p.uint32_video_type===e)}),gt(o=>{if(!o)return!1;let u=o.uint32_video_enc_br,p=u*Math.pow(1-this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost/100,2),l=Math.min(s,p);o.uint32_video_enc_br=l,this.glog({[`confBr${e}`]:[u,p,l]});let m=!1;return((f,g)=>{o[g]&&o[g]!==r[f]&&(m=!0,r[f]=o[g])})("bitrate","uint32_video_enc_br"),m}),Zn(r))}pushVideo({profile:{width:e,height:r,frameRate:s,bitrate:o},type:u,trackType:p,crypto:l},m){this.videoStats.frameWidth=e,this.videoStats.frameHeight=r;let h=0,f=Ao[u];this.videoTypeIndexMap.has(u)?h=this.videoTypeIndexMap.get(u):(h=this.statReportReq.rpt_msg_video_stat_report.length,this.requestTypeMap.set(h,u===7?4097:4096),this.videoTypeIndexMap.set(u,h),this.statReportReq.rpt_msg_video_stat_report.push({uint32_video_type:u,msg_video_enc_stat:{uint32_video_enc_fps:0,uint32_video_enc_br:0,uint32_video_encrd:1},msg_video_send_stat:{uint32_video_send_br:0,uint32_video_fec_br:0,uint32_video_arq_br:0}}),this.qualityReport.msg_up_stream_info.msg_video_status.push({uint32_video_codec_bitrate:0,uint32_video_total_bitrate:0,uint32_video_enc_fps:0,uint32_video_capture_fps:0,uint32_video_codec_fps:0,uint32_video_stream_type:u,uint32_video_codec_type:0,uint32_video_decode_frame:0,uint32_video_total_frame:0,uint32_video_width:e,uint32_video_height:r}));let g={width:e,height:r,bitrate:o*1e3,framerate:s};Object.assign(this.qualityReport.msg_up_stream_info.msg_video_status[h],{uint32_video_width:e,uint32_video_height:r});let y=0,R=!1,w=D=>{this.send(3,{mediaType:f})};H(this.createSelectAbilityOb(u,g),X(()=>{m.postMessage(g)}));let U=m;p!="camera"&&(this.io.log_.info(`push ${p} track`),U=mi(m,H(m,gi(2e3),es(D=>(this.io.log_.warn("start push last video frame"),H(xe(2e3),Zn(D),Oe(m),Or({complete:()=>this.io.log_.warn("stop push last video frame")})))),Ve(m)))),H(U,X(D=>{let G=this.getVideoStatus(h);G.uint32_video_total_frame++,y++,this.videoStats.framesSent++,G.uint32_video_capture_fps++,y%300==0&&m.postMessage(260),this.handleVideoEncoded(D,u,l)},w,w)),H(this.createResposeOb(260),Ve(m),X(()=>m.postMessage(260)))}getVideoStatus(e){return this.qualityReport.msg_up_stream_info.msg_video_status[e]}handleVideoEncoded(e,r,s){let{chunk:o,timestamp:u}=e;this.videoStats.framesEncoded++;let p=this.videoTypeIndexMap.get(r),l=this.getVideoStatus(p);l.uint32_video_decode_frame++,l.uint32_video_codec_fps++,l.uint32_video_enc_fps++,this.statReportReq.rpt_msg_video_stat_report[p].msg_video_enc_stat.uint32_video_enc_fps++;let m="byteLength"in o?o.byteLength:o.data.length;if(this.statReportReq.rpt_msg_video_stat_report[p].msg_video_enc_stat.uint32_video_enc_br+=m<<3,m>this.videoEncBuffer_.size){console.log("buffer too small!");return}"byteLength"in o?o.copyTo(this.videoEncBuffer_.uint8Array(m)):this.videoEncBuffer_.set(o.data),B.global.fill();let h=V._PacketizeVideoUdt(this.videoEncBuffer_.point,m,u,o.type=="key"?1:0,r,B.global.point,this.io.id,s);this.sendUdtv3Video(h,p)}sendUdtv3Video(e,r){let s=0,o=B.global.uint8Array();for(let u=0;u<e;u++){let p=B.global.getUint32(s);if(p<=0){this.io.log_.warn("sendUdtv3Video pktSize is ",p);continue}this.io.send(o.subarray(s+=4,s+=p)),this.statReportReq.rpt_msg_video_stat_report[r].msg_video_send_stat.uint32_video_send_br+=p<<3,this.videoStats.bytesSent+=p,this.videoStats.packetsSent++}}mute(e){if(this.send(8,e),e.userId!==this.io.joinRes.openid){let r=this.userMap_.get(e.srctinyid);r&&(r.subscribe&=~e.mediaType)}}unmute(e){if(this.send(9,e),e.userId!==this.io.joinRes.openid){let r=this.userMap_.get(e.srctinyid);r&&(r.subscribe|=e.mediaType)}}waitKeyFrame(e){this.send(11,e)}publish(e,r){this.audioStats.bytesSent=0,this.audioStats.packetsSent=0,this.videoStats.framesSent=0,this.videoStats.bytesSent=0,this.videoStats.packetsSent=0,this.videoStats.framesEncoded=0;let s={mediaType:e,mediaDescription:{audioParam:e&1?{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]}:void 0,videoParam:[4,8,2].filter(o=>e&o).map(o=>({mediaType:o,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]}))}};this.send(2,s).then(o=>{r.postMessage(o),r.postMessage(null)})}};var Rl=2,Zt=class extends ge{addEventMsgs(t){this.qualityReport.msg_event_msg=t}constructor(t){super(t);let e,r=Se(t,Je.JOINED),s=Se(t,Je.CLOSED),o={};H(r,kt(xe(1e3)),Oe(s),X(l=>{let m=Date.now();this.statReportReq.msg_down_bandwidth_est.uint32_avg_bandwidth_br=this.statReportReq.msg_down_bandwidth_est.uint32_bandwidth_br=this.statReportReq.msg_net_stat_report.uint32_down_recv_br,this.statReportReq.msg_rtt_info_req.uint64_client_timestamp_ms=m,this.statReportReq.msg_rtt_info_req.uint32_delay_since_last_server_timestamp_ms=e&&m-e||0,this.statReportReq.msg_net_stat_report.uint32_down_expect_pkg=this.statReportReq.msg_net_stat_report.uint32_down_real_pkg,this.statReportReq.msg_net_stat_report.uint32_total_send_br=this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br+this.statReportReq.rpt_msg_video_stat_report.reduce((f,g)=>f+g.msg_video_send_stat.uint32_video_send_br,0),o.bandwidth=this.statReportReq.msg_down_bandwidth_est.uint32_avg_bandwidth_br,o.heartbeatSend=1;let h=[this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_codec_bitrate=this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_enc_br];this.qualityReport.msg_up_stream_info.msg_video_status.forEach((f,g)=>{let y=this.statReportReq.rpt_msg_video_stat_report[g];f.uint32_video_total_bitrate=y.msg_video_send_stat.uint32_video_send_br,h[y.uint32_video_type==7?3:y.uint32_video_type-1]=f.uint32_video_codec_bitrate=y.msg_video_enc_stat.uint32_video_enc_br}),o.localBr=h,this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_total_bitrate=this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br,l%2&&this.post(12,this.io.statReportReq),this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_frame_interval=0,this.statReportReq.msg_audio_stat_report.msg_audio_send_stat.uint32_audio_send_br=0,this.statReportReq.msg_audio_stat_report.msg_audio_enc_stat.uint32_audio_enc_br=0,this.statReportReq.rpt_msg_video_stat_report.forEach(f=>{f.msg_video_send_stat.uint32_video_send_br=0,f.msg_video_enc_stat.uint32_video_enc_br=0,f.msg_video_enc_stat.uint32_video_enc_fps=0}),this.statReportReq.msg_net_stat_report.uint32_down_recv_br=0}));let u=H(this.createResposeOb(12),Or(l=>{l.err||!l.data||(this.statReportReq.msg_rtt_info_req.uint64_last_server_timestamp_ms=l.data.msg_rtt_info_res.uint64_server_timestamp_ms,e=Date.now(),this.statReportReq.msg_net_stat_report.uint32_rtt=e-l.data.msg_rtt_info_res.uint64_last_client_timestamp_ms-l.data.msg_rtt_info_res.uint32_delay_since_last_client_timestamp_ms,this.statReportReq.msg_net_stat_report.uint32_rtt<0&&(this.statReportReq.msg_net_stat_report.uint32_rtt=30),this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost=Math.max(0,(l.data.uint32_up_expect_pkg-l.data.uint32_up_real_pkg)*100/l.data.uint32_up_expect_pkg>>0))}));H(r,kt(u),kt(je(Ai)),Oe(s),X(()=>{this.io.log_.warn("ping timeout,lastrecv:",e,"now:",Date.now()),this.io.state==Je.JOINED&&this.io.wFSM.disconnect("ping timeout")}));let p=new B(52);H(r,kt(xe(Rl*1e3)),Oe(s),X(l=>{let m=[...this.userMap_.values()];this.qualityReport.uint64_datetime=Date.now(),this.qualityReport.msg_up_stream_info.msg_network_status.uint32_bitrate=this.statReportReq.msg_net_stat_report.uint32_total_send_br,this.qualityReport.msg_up_stream_info.msg_network_status.uint32_rtt=this.statReportReq.msg_net_stat_report.uint32_rtt,this.qualityReport.msg_down_stream_info=m.map(R=>{var D,G;let w=R.toDownStreamInfo(R,l%10===0),U=[w.msg_audio_status.uint32_audio_codec_bitrate];return U[1]=w.msg_video_status[0].uint32_video_codec_bitrate,U[2]=((D=w.msg_video_status[1])==null?void 0:D.uint32_video_codec_bitrate)||0,o[`RemoteBr_${R.userId}`]=U,o[`RemoteBlock_${R.userId}`]=[w.msg_audio_status.uint32_audio_block_cnt,w.msg_video_status[0].uint32_video_block_cnt,((G=w.msg_video_status[1])==null?void 0:G.uint32_video_block_cnt)||0],w}),this.glog(o),o={};let h=this.qualityReport.msg_down_stream_info.map(R=>({userId:R.msg_user_info.str_identifier,rtt:R.msg_network_status.uint32_rtt,loss:R.msg_network_status.uint32_lost})),f=Ul(h),g=this.qualityReport.msg_up_stream_info.msg_network_status.uint32_rtt,y=this.qualityReport.msg_up_stream_info.msg_network_status.uint32_lost;this.postMessage("network-quality",{uplinkNetworkQuality:this.io.state!="DISCONNECTED"?yo(y,g):6,downlinkNetworkQuality:yo(f.loss,f.rtt),uplinkInfo:this.qualityReport.msg_up_stream_info,msg_down_stream_info:this.qualityReport.msg_down_stream_info,downlinkInfo:h,uplinkRTT:g,uplinkLoss:y,downlinkRTT:f.rtt,downlinkLoss:f.loss}),this.qualityReport.msg_up_stream_info.msg_video_status.forEach(R=>{R.uint32_video_capture_fps>>=1,R.uint32_video_codec_fps>>=1,l%10===0&&console.log(ut(),"video uplink fps:",R.uint32_video_stream_type,R.uint32_video_capture_fps,R.uint32_video_codec_fps)}),this.post(7,this.io.qualityReportReq),this.qualityReport.msg_event_msg=[],this.qualityReport.msg_up_stream_info.msg_audio_status.uint32_audio_level=0,this.qualityReport.msg_up_stream_info.msg_video_status.forEach(R=>{R.uint32_video_capture_fps=0,R.uint32_video_codec_fps=0,R.uint32_video_enc_fps=0})},l=>{},()=>{this.qualityReport.msg_down_stream_info=[...this.userMap_.values()].map(l=>l.toDownStreamInfo(l,!1)),this.post(7,this.io.qualityReportReq),p.free()}))}};function Ul(n){let t={rtt:0,loss:0};return Array.isArray(n)&&n.length>0&&(n.forEach(e=>{t.rtt+=e.rtt,t.loss+=e.loss}),Object.keys(t).forEach(e=>{t[e]=Math.round(t[e]/n.length)})),t}function yo(n,t){return n>50||t>500?5:n>30||t>350?4:n>20||t>200?3:n>10||t>100?2:n>=0||t>=0?1:0}var er=class extends ge{async subscribe(t,e){let{mediaType:r,srctinyid:s}=t,o=this.userMap_.get(s);if(o){if(o.subscribe|=t.mediaType,t.mediaType=o.subscribe,e)e.postMessage(await this.send(4,t));else return this.send(4,t);r===1&&o.startPullOnlyAudio(o.mainPuller,e,{mediaType:r,srctinyid:s})}}async unSubscribe(t,e){let{mediaType:r,srctinyid:s}=t,o=this.userMap_.get(s);if(o){let u=o.subscribe;o.subscribe&=~r,u!==o.subscribe&&e.postMessage(await(o.subscribe===0?this.send(5,t):this.io.sendSubscribe(o)))}}pullVideo({mediaType:t,tinyId:e},r){let s=this.userMap_.get(e);s&&s.startPull(t===2?s.screenPuller:s.mainPuller,r,{mediaType:t,srctinyid:e})}changetype(t){let{mediaType:e,srctinyid:r}=t,s=this.userMap_.get(r);if(s){let o=s.subscribe;e===8?(s.subscribe|=8,s.subscribe&=-5):e===4&&(s.subscribe|=4,s.subscribe&=-9),o!=s.subscribe&&(t.mediaType=s.subscribe,this.send(4,t))}}};var Ps=class extends $t{constructor(e,r,s,o){super();this.seq=e;this.player=r;this.numberOfChannels=s;this.bitrate=o;d(this,"aecPtr");d(this,"encodePrt");d(this,"tenms",sampleRate/100);d(this,"numberOfFrames",this.tenms<<1);d(this,"float32Array");d(this,"pos",0);d(this,"bufferLen",0);d(this,"outputPort");d(this,"mainPort");d(this,"workerPort");d(this,"outPrt");d(this,"audioCaptBuff");d(this,"oput");d(this,"first10ms");d(this,"dumpPort");d(this,"encodeCount",0);d(this,"startTs");d(this,"startTime");this.wasmBinary=r.wasm,this.startTs=currentTime,this.startTime=Date.now()}locateFile(){return this.wasmBinary}reset(){this.encodeCount=0}print(e){console.debug(e)}printErr(e){console.debug(e)}onRuntimeInitialized(){this.aecPtr=this._malloc(1920*10),this.encodePrt=this._malloc(1920*4),this.outPrt=this._malloc(1920*4),this.float32Array=new Float32Array(this.HEAPU8.buffer,this.encodePrt),this._CreateMediaProcessing(0,1,0,!1),this._UseAINS(ne.useAINS),this._SetAudioFrameFormat(sampleRate,this.numberOfChannels),this._InitOpusEncoder(sampleRate,this.numberOfChannels,1),this.bitrate&&this._SetOpusEncBitrate(this.bitrate*1e3),console.log(rt,"audio worklet initialized",sampleRate,this.numberOfChannels,this.seq),this.oput=new me,this.oput.buffer=new Uint8Array(this.HEAPU8.buffer,this.encodePrt),this.player.encoders[this.seq]=this}aec(e){return this.HEAPU8.set(e,this.aecPtr),this._AudioReverseProcessFloat(this.aecPtr,e.length>>2),this.HEAPU8.subarray(this.aecPtr,this.aecPtr+e.length)}encode(...e){if(!this.bitrate)return;let r=this.encodePrt;for(let s of e){this.float32Array.set(s,this.bufferLen),this.bufferLen+=s.length;let o=0;for(;this.bufferLen-this.pos>=this.tenms;){let u=this.player.delay+(this.bufferLen-this.pos)/(sampleRate/1e3)+20>>0,p=this._AudioProcessFloat(this.encodePrt+this.pos*4,this.tenms,u);if(o<p&&(o=p),this.pos+=this.tenms,this.pos>=this.numberOfFrames){if(this.dumpPort){let f=this.float32Array.slice(0,this.numberOfFrames);this.dumpPort.postMessage({data:f},[f.buffer])}let l=this._OpusEncode(this.encodePrt,this.numberOfFrames,this.outPrt);this.encodeCount++,this.encodeCount<10&&console.log("audio encoded",this.encodeCount,l);let m=this.HEAPU8.slice(this.outPrt,this.outPrt+l),h=o*100/32768;this.mainPort.postMessage(h),this.outputPort.postMessage({data:m,volume:h,energy:o,timestamp:(currentTime-this.startTs)*1e3+this.startTime&4294967295},[m.buffer]),o=0,this.float32Array.copyWithin(0,this.numberOfFrames,this.bufferLen),this.bufferLen-=this.numberOfFrames,this.pos-=this.numberOfFrames}}break}}close(){this._free(this.aecPtr),this._free(this.encodePrt)}};function Ro(n){class t extends AudioWorkletProcessor{constructor(s){super();d(this,"oput",new me);d(this,"wasm");d(this,"encoders",[]);d(this,"useAINS",!0);console.log("worklet created:",sampleRate),this.wasm=s.processorOptions.wasm,Object.assign(ne,s.processorOptions.flag),this.port.onmessage=o=>{o.ports[0].onmessage=u=>this.pushAudio(u)}}get delay(){var s;return(((s=this.oput.buffer)==null?void 0:s.length)||0)/(sampleRate*4/1e3)}process(s,o){return this.oput.demand(o[0][0],!0),this.encoders.forEach((u,p)=>u.encode(...s[p])),!0}pushAudio(s){if(s.data instanceof Uint8Array){let{data:o}=s;this.encoders.forEach(u=>o=u.aec(s.data)),this.oput.malloc(o.length).set(o);return}switch(console.log("worklet receive",s.data.cmd),s.data.cmd){case"dump":switch(s.data.payload){case"mic0":this.encoders[0].dumpPort=s.ports[0];break}break;case"useAINS":ne.useAINS=s.data.payload,this.encoders.forEach(o=>o._UseAINS(s.data.payload));break;case"enableAEC":this.encoders.forEach(o=>o._EnableAEC(s.data.payload));break;case"enableDebug":console.debug=s.data.payload?Vr:()=>{};break;case"pushAudio":{let[o,u]=s.ports,{payload:{numberOfChannels:p,bitrate:l},encrypt:m,index:h}=s.data,f=this.encoders[h]||new Ps(h,this,p,l);this.encoders[h]?(f.bitrate=l,f._SetOpusEncBitrate(l*1e3)):n(f),f.reset(),f.mainPort=u,f.workerPort=o,f.outputPort=m?u:o,u.onmessage=g=>{g.data?f.encode(g.data):(console.log(ut(),"encoder",h,"stopped"),o.postMessage(null))}}}}}registerProcessor("global-audio-player",t)}var vs=class{constructor(){d(this,"playPort");d(this,"dumpPort");d(this,"downlinkAudioCount",0);d(this,"interval10ms",H(bt(10),We()));d(this,"ios")}glog(t){self.postMessage({type:"glog",payload:t})}async joinRoom(t){let{data:{id:e,payload:r},ports:s}=t,o=new Je(e,s[0],r);o.wh=this;let u=[new zt(o),new er(o),new Yt(o),new Zt(o),new Qt(o)],p=(m="leave room")=>{o.leaveRoom().catch(),o.abort(m),this.ios.delete(o)},l=setTimeout(o.abort,5e3,"timeout");H(Wt(o.port,!0),X(({data:{cmd:m,payload:h},ports:f})=>{switch(console.log(self.name,"received message",m),m){case"setAudioWorkletPort":this.playPort=f[0];break;case"switchRole":o.sendReq(20,{role:h,privateMapKey:o.params.privateMapKey}).then(y=>f[0].postMessage(y));break;default:let g=f.map(y=>Wt(y));typeof h!="undefined"&&g.unshift(h),u.forEach(y=>{var R;(R=y[m])==null||R.call(y,...g)})}},p,p));try{await o.connect(),postMessage({id:e,payload:await o.joinRoom()}),clearTimeout(l),this.ios.add(o)}catch(m){m instanceof WebTransportError?m=`Transport initialization failed.
3
+ Reason: ${m.message}.
4
+ Source: ${m.source}.
5
+ Error code: ${m.streamErrorCode}.`:m instanceof ct?m=m.cause:m instanceof Event&&(m=m.type),postMessage({id:e,payload:{err:m}}),o.close()}}};function xl(n){self.onmessage=async t=>{let e=setTimeout(()=>{self.postMessage({type:"error",payload:"timeout"})},5e3);try{t.data.wasm&&(V.wasmBinary=t.data.wasm),V.locateFile=()=>t.data.wasm,Object.assign(ne,t.data.flag),console.time(`Worker[${self.name}${rt}]`),V.postRun=[()=>{B.global=new B(1920*1080*3>>1),V._CreateMediaProcessing(0,1,0,!1),console.timeEnd(`Worker[${self.name}${rt}]`),V._UseAINS(ne.useAINS),this.ios=new Set,t.ports[0].onmessage=m=>{var g,y,R;let[h,f]=m.data;switch(h){case"dump":switch(f){case"audio":this.dumpPort=m.ports[0];break;case"mic0":(g=this.playPort)==null||g.postMessage({cmd:h,payload:f},m.ports);break}break;case"useAINS":V._UseAINS(f),(y=this.playPort)==null||y.postMessage({cmd:h,payload:f});break;case"enableDebug":console.debug=f?Vr:()=>{},(R=this.playPort)==null||R.postMessage({cmd:h,payload:f});break;case"useV2":V.udtver=f?2:3;break;case"useWt":ne.useWt=f;break;case"enableAEC":V._EnableAEC(f);break}};let r=0,s=Date.now(),o=0;H(xe(1e3),X(()=>{let f=(Date.now()-s)/10-r;console.debug("interval10ms:",f,f-o),o=f,V._UpdateStreamSync()})),V._SetAudioOutStreamFormat(48e3,1);let u=V._malloc(12),p=new B(1920),l=0;H(this.interval10ms,X(()=>{r++;let m=r%20===0;this.ios.forEach(h=>h.userManager.remotePublishedUserMap.forEach(f=>{let g=f.audioPuller;if(!g)return;let y=V._GetAudioFrame(g.buffer.point,48e3,g.ssrc);l=Math.max(l,y),m&&(l=0),g.feed()}))})),self.onmessage=this.joinRoom.bind(this),clearTimeout(e),self.postMessage({type:"ready"})}],n(V)}catch(r){self.postMessage({type:"error",payload:r})}}}var Uo=xr?Ro:xl.bind(new vs);var Oo={},Pl=(function(){var n=Oo.url;return(function(e){e=e||{};var e=typeof e!="undefined"?e:{},r,s;e.ready=new Promise(function(i,a){r=i,s=a});var o={},u;for(u in e)e.hasOwnProperty(u)&&(o[u]=e[u]);var p=[],l="./this.program",m=function(i,a){throw a},h=typeof window=="object",f=typeof importScripts=="function",g=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",y=!h&&!g&&!f,R="";function w(i){return e.locateFile?e.locateFile(i,R):R+i}var U,D,G,Ae;function ye(i){if(!(i instanceof Ku)){var a=i;ie("exiting due to exception: "+a)}}y?(typeof read!="undefined"&&(U=function(a){return read(a)}),G=function(a){var c;return typeof readbuffer=="function"?new Uint8Array(readbuffer(a)):(c=read(a,"binary"),Ns(typeof c=="object"),c)},D=function(a,c,_){setTimeout(function(){c(G(a))},0)},typeof scriptArgs!="undefined"?p=scriptArgs:typeof arguments!="undefined"&&(p=arguments),typeof quit=="function"&&(m=function(i,a){ye(a),quit(i)}),typeof print!="undefined"&&(typeof console=="undefined"&&(console={}),console.log=print,console.warn=console.error=typeof printErr!="undefined"?printErr:print)):(h||f)&&(f?R=self.location.href:typeof document!="undefined"&&document.currentScript&&(R=document.currentScript.src),n&&(R=n),R.indexOf("blob:")!==0?R=R.substr(0,R.replace(/[?#].*/,"").lastIndexOf("/")+1):R="",U=function(i){var a=new XMLHttpRequest;return a.open("GET",i,!1),a.send(null),a.responseText},f&&(G=function(i){var a=new XMLHttpRequest;return a.open("GET",i,!1),a.responseType="arraybuffer",a.send(null),new Uint8Array(a.response)}),D=function(i,a,c){var _=new XMLHttpRequest;_.open("GET",i,!0),_.responseType="arraybuffer",_.onload=function(){if(_.status==200||_.status==0&&_.response){a(_.response);return}c()},_.onerror=c,_.send(null)},Ae=function(i){document.title=i});var Re=e.print||console.log.bind(console),ie=e.printErr||console.warn.bind(console);for(u in o)o.hasOwnProperty(u)&&(e[u]=o[u]);o=null,e.arguments&&(p=e.arguments),e.thisProgram&&(l=e.thisProgram),e.quit&&(m=e.quit);function fe(i){fe.shown||(fe.shown={}),fe.shown[i]||(fe.shown[i]=1,ie(i))}function Po(i,a){if(typeof WebAssembly.Function=="function"){for(var c={i:"i32",j:"i64",f:"f32",d:"f64"},_={parameters:[],results:a[0]=="v"?[]:[c[a[0]]]},b=1;b<a.length;++b)_.parameters.push(c[a[b]]);return new WebAssembly.Function(_,i)}var T=[1,0,1,96],I=a.slice(0,1),A=a.slice(1),S={i:127,j:126,f:125,d:124};T.push(A.length);for(var b=0;b<A.length;++b)T.push(S[A[b]]);I=="v"?T.push(0):T=T.concat([1,S[I]]),T[1]=T.length-2;var x=new Uint8Array([0,97,115,109,1,0,0,0].concat(T,[2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0])),q=new WebAssembly.Module(x),K=new WebAssembly.Instance(q,{e:{f:i}}),W=K.exports.f;return W}var Xr=[],Xe;function vo(){if(Xr.length)return Xr.pop();try{dt.grow(1)}catch(i){throw i instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":i}return dt.length-1}function Do(i,a){for(var c=i;c<i+a;c++){var _=nr(c);_&&Xe.set(_,c)}}function No(i,a){if(Xe||(Xe=new WeakMap,Do(0,dt.length)),Xe.has(i))return Xe.get(i);var c=vo();try{Ys(c,i)}catch(b){if(!(b instanceof TypeError))throw b;var _=Po(i,a);Ys(c,_)}return Xe.set(i,c),c}function Co(i){Xe.delete(nr(i)),Xr.push(i)}var vt;e.wasmBinary&&(vt=e.wasmBinary);var vl=e.noExitRuntime||!1;typeof WebAssembly!="object"&&mt("no native wasm support detected");var tr,Ds=!1,wo;function Ns(i,a){i||mt("Assertion failed: "+a)}function O(i){var a=e["_"+i];return Ns(a,"Cannot call unknown function "+i+", make sure it is exported"),a}function Cs(i,a,c,_,b){var T={string:function(j){var re=0;if(j!=null&&j!==0){var Y=(j.length<<2)+1;re=dn(Y),Ms(j,re,Y)}return re},array:function(j){var re=dn(j.length);return Vs(j,re),re}};function I(j){return a==="string"?Dt(j):a==="boolean"?!!j:j}var A=O(i),S=[],x=0;if(_)for(var q=0;q<_.length;q++){var K=T[c[q]];K?(x===0&&(x=si()),S[q]=K(_[q])):S[q]=_[q]}var W=A.apply(null,S);function Q(j){return x!==0&&ii(x),I(j)}return W=Q(W),W}function Lo(i,a,c,_){c=c||[];var b=c.every(function(I){return I==="number"}),T=a!=="string";return T&&b&&!_?O(i):function(){return Cs(i,a,c,arguments,_)}}var ws=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):void 0;function Qr(i,a,c){for(var _=a+c,b=a;i[b]&&!(b>=_);)++b;if(b-a>16&&i.subarray&&ws)return ws.decode(i.subarray(a,b));for(var T="";a<b;){var I=i[a++];if(!(I&128)){T+=String.fromCharCode(I);continue}var A=i[a++]&63;if((I&224)==192){T+=String.fromCharCode((I&31)<<6|A);continue}var S=i[a++]&63;if((I&240)==224?I=(I&15)<<12|A<<6|S:I=(I&7)<<18|A<<12|S<<6|i[a++]&63,I<65536)T+=String.fromCharCode(I);else{var x=I-65536;T+=String.fromCharCode(55296|x>>10,56320|x&1023)}}return T}function Dt(i,a){return i?Qr(oe,i,a):""}function Ls(i,a,c,_){if(!(_>0))return 0;for(var b=c,T=c+_-1,I=0;I<i.length;++I){var A=i.charCodeAt(I);if(A>=55296&&A<=57343){var S=i.charCodeAt(++I);A=65536+((A&1023)<<10)|S&1023}if(A<=127){if(c>=T)break;a[c++]=A}else if(A<=2047){if(c+1>=T)break;a[c++]=192|A>>6,a[c++]=128|A&63}else if(A<=65535){if(c+2>=T)break;a[c++]=224|A>>12,a[c++]=128|A>>6&63,a[c++]=128|A&63}else{if(c+3>=T)break;a[c++]=240|A>>18,a[c++]=128|A>>12&63,a[c++]=128|A>>6&63,a[c++]=128|A&63}}return a[c]=0,c-b}function Ms(i,a,c){return Ls(i,oe,a,c)}function ks(i){for(var a=0,c=0;c<i.length;++c){var _=i.charCodeAt(c);_>=55296&&_<=57343&&(_=65536+((_&1023)<<10)|i.charCodeAt(++c)&1023),_<=127?++a:_<=2047?a+=2:_<=65535?a+=3:a+=4}return a}var Bs=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):void 0;function Mo(i,a){for(var c=i,_=c>>1,b=_+a/2;!(_>=b)&&rr[_];)++_;if(c=_<<1,c-i>32&&Bs)return Bs.decode(oe.subarray(i,c));for(var T="",I=0;!(I>=a/2);++I){var A=lt[i+I*2>>1];if(A==0)break;T+=String.fromCharCode(A)}return T}function ko(i,a,c){if(c===void 0&&(c=2147483647),c<2)return 0;c-=2;for(var _=a,b=c<i.length*2?c/2:i.length,T=0;T<b;++T){var I=i.charCodeAt(T);lt[a>>1]=I,a+=2}return lt[a>>1]=0,a-_}function Bo(i){return i.length*2}function Vo(i,a){for(var c=0,_="";!(c>=a/4);){var b=k[i+c*4>>2];if(b==0)break;if(++c,b>=65536){var T=b-65536;_+=String.fromCharCode(55296|T>>10,56320|T&1023)}else _+=String.fromCharCode(b)}return _}function Fo(i,a,c){if(c===void 0&&(c=2147483647),c<4)return 0;for(var _=a,b=_+c-4,T=0;T<i.length;++T){var I=i.charCodeAt(T);if(I>=55296&&I<=57343){var A=i.charCodeAt(++T);I=65536+((I&1023)<<10)|A&1023}if(k[a>>2]=I,a+=4,a+4>b)break}return k[a>>2]=0,a-_}function Ho(i){for(var a=0,c=0;c<i.length;++c){var _=i.charCodeAt(c);_>=55296&&_<=57343&&++c,a+=4}return a}function Vs(i,a){z.set(i,a)}function qo(i,a,c){for(var _=0;_<i.length;++_)z[a++>>0]=i.charCodeAt(_);c||(z[a>>0]=0)}function Go(i,a){return i%a>0&&(i+=a-i%a),i}var zr,z,oe,lt,rr,k,Le,Fs,v;function Hs(i){zr=i,e.HEAP8=z=new Int8Array(i),e.HEAP16=lt=new Int16Array(i),e.HEAP32=k=new Int32Array(i),e.HEAPU8=oe=new Uint8Array(i),e.HEAPU16=rr=new Uint16Array(i),e.HEAPU32=Le=new Uint32Array(i),e.HEAPF32=Fs=new Float32Array(i),e.HEAPF64=v=new Float64Array(i)}var Dl=e.INITIAL_MEMORY||134217728,dt,qs=[],Gs=[],Wo=[],Ws=[],jo=!1;function $o(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Jo(e.preRun.shift());en(qs)}function Yo(){jo=!0,en(Gs)}function Ko(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Qo(e.postRun.shift());en(Ws)}function Jo(i){qs.unshift(i)}function Xo(i){Gs.unshift(i)}function Qo(i){Ws.unshift(i)}var Qe=0,Zr=null,Nt=null;function zo(i){Qe++,e.monitorRunDependencies&&e.monitorRunDependencies(Qe)}function Zo(i){if(Qe--,e.monitorRunDependencies&&e.monitorRunDependencies(Qe),Qe==0&&(Zr!==null&&(clearInterval(Zr),Zr=null),Nt)){var a=Nt;Nt=null,a()}}e.preloadedImages={},e.preloadedAudios={};function mt(i){e.onAbort&&e.onAbort(i),i="Aborted("+i+")",ie(i),Ds=!0,wo=1,i+=". Build with -s ASSERTIONS=1 for more info.";var a=new WebAssembly.RuntimeError(i);throw s(a),a}var ea="data:application/octet-stream;base64,";function js(i){return i.startsWith(ea)}var Te;e.locateFile?(Te="av_processing.wasm",js(Te)||(Te=w(Te))):Te=new URL("av_processing.wasm",Oo.url).toString();function $s(i){try{if(i==Te&&vt)return new Uint8Array(vt);if(G)return G(i);throw"both async and sync fetching of the wasm failed"}catch(a){mt(a)}}function ta(){return!vt&&(h||f)&&typeof fetch=="function"?fetch(Te,{credentials:"same-origin"}).then(function(i){if(!i.ok)throw"failed to load wasm binary file at '"+Te+"'";return i.arrayBuffer()}).catch(function(){return $s(Te)}):Promise.resolve().then(function(){return $s(Te)})}function ra(){var i={a:iu};function a(I,A){var S=I.exports;e.asm=S,tr=e.asm.B,Hs(tr.buffer),dt=e.asm.na,Xo(e.asm.C),Zo("wasm-instantiate")}zo("wasm-instantiate");function c(I){a(I.instance)}function _(I){return ta().then(function(A){return WebAssembly.instantiate(A,i)}).then(function(A){return A}).then(I,function(A){ie("failed to asynchronously prepare wasm: "+A),mt(A)})}function b(){return!vt&&typeof WebAssembly.instantiateStreaming=="function"&&!js(Te)&&typeof fetch=="function"?fetch(Te,{credentials:"same-origin"}).then(function(I){var A=WebAssembly.instantiateStreaming(I,i);return A.then(c,function(S){return ie("wasm streaming compile failed: "+S),ie("falling back to ArrayBuffer instantiation"),_(c)})}):_(c)}if(e.instantiateWasm)try{var T=e.instantiateWasm(i,a);return T}catch(I){return ie("Module.instantiateWasm callback failed with error: "+I),!1}return b().catch(s),{}}function en(i){for(;i.length>0;){var a=i.shift();if(typeof a=="function"){a(e);continue}var c=a.func;typeof c=="number"?a.arg===void 0?nr(c)():nr(c)(a.arg):c(a.arg===void 0?null:a.arg)}}function nr(i){return dt.get(i)}function na(){var i=new Error;if(!i.stack){try{throw new Error}catch(a){i=a}if(!i.stack)return"(no stack trace available)"}return i.stack.toString()}function Ys(i,a){dt.set(i,a)}function sa(i){return cr(i+16)+16}function ia(i,a){Wo.unshift({func:i,arg:a})}function oa(i,a){return ia(i,a)}function aa(i){this.excPtr=i,this.ptr=i-16,this.set_type=function(a){k[this.ptr+4>>2]=a},this.get_type=function(){return k[this.ptr+4>>2]},this.set_destructor=function(a){k[this.ptr+8>>2]=a},this.get_destructor=function(){return k[this.ptr+8>>2]},this.set_refcount=function(a){k[this.ptr>>2]=a},this.set_caught=function(a){a=a?1:0,z[this.ptr+12>>0]=a},this.get_caught=function(){return z[this.ptr+12>>0]!=0},this.set_rethrown=function(a){a=a?1:0,z[this.ptr+13>>0]=a},this.get_rethrown=function(){return z[this.ptr+13>>0]!=0},this.init=function(a,c){this.set_type(a),this.set_destructor(c),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var a=k[this.ptr>>2];k[this.ptr>>2]=a+1},this.release_ref=function(){var a=k[this.ptr>>2];return k[this.ptr>>2]=a-1,a===1}}var ua=0,ca=0;function la(i,a,c){var _=new aa(i);throw _.init(a,c),ua=i,ca++,i}function da(i,a,c,_,b){}function tn(i){switch(i){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+i)}}function ma(){for(var i=new Array(256),a=0;a<256;++a)i[a]=String.fromCharCode(a);Ks=i}var Ks=void 0;function Fe(i){for(var a="",c=i;oe[c];)a+=Ks[oe[c++]];return a}var rn={},Js={},pa={},_a=48,fa=57;function ha(i){if(i===void 0)return"_unknown";i=i.replace(/[^a-zA-Z0-9_]/g,"$");var a=i.charCodeAt(0);return a>=_a&&a<=fa?"_"+i:i}function ba(i,a){return i=ha(i),new Function("body","return function "+i+`() {
6
+ "use strict"; return body.apply(this, arguments);
7
+ };
8
+ `)(a)}function Xs(i,a){var c=ba(a,function(_){this.name=a,this.message=_;var b=new Error(_).stack;b!==void 0&&(this.stack=this.toString()+`
9
+ `+b.replace(/^Error(:[^\n]*)?\n/,""))});return c.prototype=Object.create(i.prototype),c.prototype.constructor=c,c.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},c}var Qs=void 0;function pt(i){throw new Qs(i)}var ga=void 0;function He(i,a,c){if(c=c||{},!("argPackAdvance"in a))throw new TypeError("registerType registeredInstance requires argPackAdvance");var _=a.name;if(i||pt('type "'+_+'" must have a positive integer typeid pointer'),Js.hasOwnProperty(i)){if(c.ignoreDuplicateRegistrations)return;pt("Cannot register type '"+_+"' twice")}if(Js[i]=a,delete pa[i],rn.hasOwnProperty(i)){var b=rn[i];delete rn[i],b.forEach(function(T){T()})}}function Ea(i,a,c,_,b){var T=tn(c);a=Fe(a),He(i,{name:a,fromWireType:function(I){return!!I},toWireType:function(I,A){return A?_:b},argPackAdvance:8,readValueFromPointer:function(I){var A;if(c===1)A=z;else if(c===2)A=lt;else if(c===4)A=k;else throw new TypeError("Unknown boolean type size: "+a);return this.fromWireType(A[I>>T])},destructorFunction:null})}var nn=[],Pe=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Ta(i){i>4&&--Pe[i].refcount===0&&(Pe[i]=void 0,nn.push(i))}function Ia(){for(var i=0,a=5;a<Pe.length;++a)Pe[a]!==void 0&&++i;return i}function Sa(){for(var i=5;i<Pe.length;++i)if(Pe[i]!==void 0)return Pe[i];return null}function Aa(){e.count_emval_handles=Ia,e.get_first_emval=Sa}var zs={toValue:function(i){return i||pt("Cannot use deleted val. handle = "+i),Pe[i].value},toHandle:function(i){switch(i){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var a=nn.length?nn.pop():Pe.length;return Pe[a]={refcount:1,value:i},a}}}};function sn(i){return this.fromWireType(Le[i>>2])}function ya(i,a){a=Fe(a),He(i,{name:a,fromWireType:function(c){var _=zs.toValue(c);return Ta(c),_},toWireType:function(c,_){return zs.toHandle(_)},argPackAdvance:8,readValueFromPointer:sn,destructorFunction:null})}function on(i){if(i===null)return"null";var a=typeof i;return a==="object"||a==="array"||a==="function"?i.toString():""+i}function Ra(i,a){switch(a){case 2:return function(c){return this.fromWireType(Fs[c>>2])};case 3:return function(c){return this.fromWireType(v[c>>3])};default:throw new TypeError("Unknown float type: "+i)}}function Ua(i,a,c){var _=tn(c);a=Fe(a),He(i,{name:a,fromWireType:function(b){return b},toWireType:function(b,T){if(typeof T!="number"&&typeof T!="boolean")throw new TypeError('Cannot convert "'+on(T)+'" to '+this.name);return T},argPackAdvance:8,readValueFromPointer:Ra(a,_),destructorFunction:null})}function Oa(i,a,c){switch(a){case 0:return c?function(b){return z[b]}:function(b){return oe[b]};case 1:return c?function(b){return lt[b>>1]}:function(b){return rr[b>>1]};case 2:return c?function(b){return k[b>>2]}:function(b){return Le[b>>2]};default:throw new TypeError("Unknown integer type: "+i)}}function xa(i,a,c,_,b){a=Fe(a),b===-1&&(b=4294967295);var T=tn(c),I=function(x){return x};if(_===0){var A=32-8*c;I=function(x){return x<<A>>>A}}var S=a.includes("unsigned");He(i,{name:a,fromWireType:I,toWireType:function(x,q){if(typeof q!="number"&&typeof q!="boolean")throw new TypeError('Cannot convert "'+on(q)+'" to '+this.name);if(q<_||q>b)throw new TypeError('Passing a number "'+on(q)+'" from JS side to C/C++ side to an argument of type "'+a+'", which is outside the valid range ['+_+", "+b+"]!");return S?q>>>0:q|0},argPackAdvance:8,readValueFromPointer:Oa(a,T,_!==0),destructorFunction:null})}function Pa(i,a,c){var _=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],b=_[a];function T(I){I=I>>2;var A=Le,S=A[I],x=A[I+1];return new b(zr,x,S)}c=Fe(c),He(i,{name:c,fromWireType:T,argPackAdvance:8,readValueFromPointer:T},{ignoreDuplicateRegistrations:!0})}function va(i,a){a=Fe(a);var c=a==="std::string";He(i,{name:a,fromWireType:function(_){var b=Le[_>>2],T;if(c)for(var I=_+4,A=0;A<=b;++A){var S=_+4+A;if(A==b||oe[S]==0){var x=S-I,q=Dt(I,x);T===void 0?T=q:(T+="\0",T+=q),I=S+1}}else{for(var K=new Array(b),A=0;A<b;++A)K[A]=String.fromCharCode(oe[_+4+A]);T=K.join("")}return qe(_),T},toWireType:function(_,b){b instanceof ArrayBuffer&&(b=new Uint8Array(b));var T,I=typeof b=="string";I||b instanceof Uint8Array||b instanceof Uint8ClampedArray||b instanceof Int8Array||pt("Cannot pass non-string to std::string"),c&&I?T=function(){return ks(b)}:T=function(){return b.length};var A=T(),S=cr(4+A+1);if(Le[S>>2]=A,c&&I)Ms(b,S+4,A+1);else if(I)for(var x=0;x<A;++x){var q=b.charCodeAt(x);q>255&&(qe(S),pt("String has UTF-16 code units that do not fit in 8 bits")),oe[S+4+x]=q}else for(var x=0;x<A;++x)oe[S+4+x]=b[x];return _!==null&&_.push(qe,S),S},argPackAdvance:8,readValueFromPointer:sn,destructorFunction:function(_){qe(_)}})}function Da(i,a,c){c=Fe(c);var _,b,T,I,A;a===2?(_=Mo,b=ko,I=Bo,T=function(){return rr},A=1):a===4&&(_=Vo,b=Fo,I=Ho,T=function(){return Le},A=2),He(i,{name:c,fromWireType:function(S){for(var x=Le[S>>2],q=T(),K,W=S+4,Q=0;Q<=x;++Q){var j=S+4+Q*a;if(Q==x||q[j>>A]==0){var re=j-W,Y=_(W,re);K===void 0?K=Y:(K+="\0",K+=Y),W=j+a}}return qe(S),K},toWireType:function(S,x){typeof x!="string"&&pt("Cannot pass non-string to C++ string type "+c);var q=I(x),K=cr(4+q+a);return Le[K>>2]=q>>A,b(x,K+4,q+a),S!==null&&S.push(qe,K),K},argPackAdvance:8,readValueFromPointer:sn,destructorFunction:function(S){qe(S)}})}function Na(i,a){a=Fe(a),He(i,{isVoid:!0,name:a,argPackAdvance:0,fromWireType:function(){},toWireType:function(c,_){}})}function Ca(){mt("")}var an;typeof dateNow!="undefined"?an=dateNow:an=function(){return performance.now()};var wa=!0;function La(i){return k[ni()>>2]=i,i}function Ma(i,a){var c;if(i===0)c=Date.now();else if((i===1||i===4)&&wa)c=an();else return La(28),-1;return k[a>>2]=c/1e3|0,k[a+4>>2]=c%1e3*1e3*1e3|0,0}function ka(i){return i<0||i===0&&1/i===-1/0}function Ba(i,a){return(i>>>0)+a*4294967296}function Va(i,a){return(i>>>0)+(a>>>0)*4294967296}function Zs(i,a){if(i<=0)return i;var c=a<=32?Math.abs(1<<a-1):Math.pow(2,a-1);return i>=c&&(a<=32||i>c)&&(i=-2*c+i),i}function ei(i,a){return i>=0?i:a<=32?2*Math.abs(1<<a-1)+i:Math.pow(2,a)+i}function ti(i){for(var a=i;oe[a];)++a;return a-i}e._strlen=ti;function Fa(i,a){var c=i,_=a;function b(De,ke){return(ke==="double"||ke==="i64")&&De&7&&(De+=4),De}function T(De){var ke;return _=b(_,De),De==="double"?(ke=Number(v[_>>3]),_+=8):De=="i64"?(ke=[k[_>>2],k[_+4>>2]],_+=8):(De="i32",ke=k[_>>2],_+=4),ke}for(var I=[],A,S,x;;){var q=c;if(A=z[c>>0],A===0)break;if(S=z[c+1>>0],A==37){var K=!1,W=!1,Q=!1,j=!1,re=!1;e:for(;;){switch(S){case 43:K=!0;break;case 45:W=!0;break;case 35:Q=!0;break;case 48:if(j)break e;j=!0;break;case 32:re=!0;break;default:break e}c++,S=z[c+1>>0]}var Y=0;if(S==42)Y=T("i32"),c++,S=z[c+1>>0];else for(;S>=48&&S<=57;)Y=Y*10+(S-48),c++,S=z[c+1>>0];var be=!1,E=-1;if(S==46){if(E=0,be=!0,c++,S=z[c+1>>0],S==42)E=T("i32"),c++;else for(;;){var C=z[c+1>>0];if(C<48||C>57)break;E=E*10+(C-48),c++}S=z[c+1>>0]}E<0&&(E=6,be=!1);var F;switch(String.fromCharCode(S)){case"h":var J=z[c+2>>0];J==104?(c++,F=1):F=2;break;case"l":var J=z[c+2>>0];J==108?(c++,F=8):F=4;break;case"L":case"q":case"j":F=8;break;case"z":case"t":case"I":F=4;break;default:F=null}switch(F&&c++,S=z[c+1>>0],String.fromCharCode(S)){case"d":case"i":case"u":case"o":case"x":case"X":case"p":{var Ie=S==100||S==105;F=F||4,x=T("i"+F*8);var P;if(F==8&&(x=S==117?Va(x[0],x[1]):Ba(x[0],x[1])),F<=4){var Me=Math.pow(256,F)-1;x=(Ie?Zs:ei)(x&Me,F*8)}var wt=Math.abs(x),he="";if(S==100||S==105)P=Zs(x,8*F,1).toString(10);else if(S==117)P=ei(x,8*F,1).toString(10),x=Math.abs(x);else if(S==111)P=(Q?"0":"")+wt.toString(8);else if(S==120||S==88){if(he=Q&&x!=0?"0x":"",x<0){x=-x,P=(wt-1).toString(16);for(var oi=[],ve=0;ve<P.length;ve++)oi.push((15-parseInt(P[ve],16)).toString(16));for(P=oi.join("");P.length<F*2;)P="f"+P}else P=wt.toString(16);S==88&&(he=he.toUpperCase(),P=P.toUpperCase())}else S==112&&(wt===0?P="(nil)":(he="0x",P=wt.toString(16)));if(be)for(;P.length<E;)P="0"+P;for(x>=0&&(K?he="+"+he:re&&(he=" "+he)),P.charAt(0)=="-"&&(he="-"+he,P=P.substr(1));he.length+P.length<Y;)W?P+=" ":j?P="0"+P:he=" "+he;P=he+P,P.split("").forEach(function(De){I.push(De.charCodeAt(0))});break}case"f":case"F":case"e":case"E":case"g":case"G":{x=T("double");var P;if(isNaN(x))P="nan",j=!1;else if(!isFinite(x))P=(x<0?"-":"")+"inf",j=!1;else{var ai=!1,Lt=Math.min(E,20);if(S==103||S==71){ai=!0,E=E||1;var pn=parseInt(x.toExponential(Lt).split("e")[1],10);E>pn&&pn>=-4?(S=(S==103?"f":"F").charCodeAt(0),E-=pn+1):(S=(S==103?"e":"E").charCodeAt(0),E--),Lt=Math.min(E,20)}S==101||S==69?(P=x.toExponential(Lt),/[eE][-+]\d$/.test(P)&&(P=P.slice(0,-1)+"0"+P.slice(-1))):(S==102||S==70)&&(P=x.toFixed(Lt),x===0&&ka(x)&&(P="-"+P));var Ue=P.split("e");if(ai&&!Q)for(;Ue[0].length>1&&Ue[0].includes(".")&&(Ue[0].slice(-1)=="0"||Ue[0].slice(-1)==".");)Ue[0]=Ue[0].slice(0,-1);else for(Q&&P.indexOf(".")==-1&&(Ue[0]+=".");E>Lt++;)Ue[0]+="0";P=Ue[0]+(Ue.length>1?"e"+Ue[1]:""),S==69&&(P=P.toUpperCase()),x>=0&&(K?P="+"+P:re&&(P=" "+P))}for(;P.length<Y;)W?P+=" ":j&&(P[0]=="-"||P[0]=="+")?P=P[0]+"0"+P.slice(1):P=(j?"0":" ")+P;S<97&&(P=P.toUpperCase()),P.split("").forEach(function(ke){I.push(ke.charCodeAt(0))});break}case"s":{var dr=T("i8*"),ft=dr?ti(dr):6;if(be&&(ft=Math.min(ft,E)),!W)for(;ft<Y--;)I.push(32);if(dr)for(var ve=0;ve<ft;ve++)I.push(oe[dr++>>0]);else I=I.concat(ri("(null)".substr(0,ft),!0));if(W)for(;ft<Y--;)I.push(32);break}case"c":{for(W&&I.push(T("i8"));--Y>0;)I.push(32);W||I.push(T("i8"));break}case"n":{var Ju=T("i32*");k[Ju>>2]=I.length;break}case"%":{I.push(A);break}default:for(var ve=q;ve<c+2;ve++)I.push(z[ve>>0])}c+=2}else I.push(A),c+=1}return I}function un(i){if(!i||!i.callee||!i.callee.name)return[null,"",""];var a=i.callee.toString(),c=i.callee.name,_="(",b=!0;for(var T in i){var I=i[T];b||(_+=", "),b=!1,typeof I=="number"||typeof I=="string"?_+=I:_+="("+typeof I+")"}_+=")";var A=i.callee.caller;return i=A?A.arguments:[],b&&(_=""),[i,c,_]}function Ha(i){var a=na(),c=a.lastIndexOf("_emscripten_log"),_=a.lastIndexOf("_emscripten_get_callstack"),b=a.indexOf(`
10
+ `,Math.max(c,_))+1;a=a.slice(b),i&32&&fe("EM_LOG_DEMANGLE is deprecated; ignoring"),i&8&&typeof emscripten_source_map=="undefined"&&(fe('Source map information is not available, emscripten_log with EM_LOG_C_STACK will be ignored. Build with "--pre-js $EMSCRIPTEN/src/emscripten-source-map.min.js" linker flag to add source map loading to code.'),i^=8,i|=16);var T=null;if(i&128)for(T=un(arguments);T[1].includes("_emscripten_");)T=un(T[0]);var I=a.split(`
11
+ `);a="";var A=new RegExp("\\s*(.*?)@(.*?):([0-9]+):([0-9]+)"),S=new RegExp("\\s*(.*?)@(.*):(.*)(:(.*))?"),x=new RegExp("\\s*at (.*?) \\((.*):(.*):(.*)\\)");for(var q in I){var K=I[q],W="",Q="",j=0,re=0,Y=x.exec(K);if(Y&&Y.length==5)W=Y[1],Q=Y[2],j=Y[3],re=Y[4];else if(Y=A.exec(K),Y||(Y=S.exec(K)),Y&&Y.length>=4)W=Y[1],Q=Y[2],j=Y[3],re=Y[4]|0;else{a+=K+`
12
+ `;continue}var be=!1;if(i&8){var E=emscripten_source_map.originalPositionFor({line:j,column:re});be=E&&E.source,be&&(i&64&&(E.source=E.source.substring(E.source.replace(/\\/g,"/").lastIndexOf("/")+1)),a+=" at "+W+" ("+E.source+":"+E.line+":"+E.column+`)
13
+ `)}(i&16||!be)&&(i&64&&(Q=Q.substring(Q.replace(/\\/g,"/").lastIndexOf("/")+1)),a+=(be?" = "+W:" at "+W)+" ("+Q+":"+j+":"+re+`)
14
+ `),i&128&&T[0]&&(T[1]==W&&T[2].length>0&&(a=a.replace(/\s+$/,""),a+=" with values: "+T[1]+T[2]+`
15
+ `),T=un(T[0]))}return a=a.replace(/\s+$/,""),a}function qa(i,a){i&24&&(a=a.replace(/\s+$/,""),a+=(a.length>0?`
16
+ `:"")+Ha(i)),i&1?i&4?ie(a):i&2?console.warn(a):i&512?console.info(a):i&256?console.debug(a):Re(a):i&6?ie(a):Re(a)}function Ga(i,a,c){var _=Fa(a,c),b=Qr(_,0);qa(i,b)}function Wa(i,a,c){oe.copyWithin(i,a,a+c)}function ja(i){try{return tr.grow(i-zr.byteLength+65535>>>16),Hs(tr.buffer),1}catch(a){}}function $a(i){var a=oe.length;i=i>>>0;var c=1073741824;if(i>c)return!1;for(var _=1;_<=4;_*=2){var b=a*(1+.2/_);b=Math.min(b,i+100663296);var T=Math.min(c,Go(Math.max(i,b),65536)),I=ja(T);if(I)return!0}return!1}var cn={};function Ya(){return l||"./this.program"}function Ct(){if(!Ct.strings){var i=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:i,_:Ya()};for(var c in cn)cn[c]===void 0?delete a[c]:a[c]=cn[c];var _=[];for(var c in a)_.push(c+"="+a[c]);Ct.strings=_}return Ct.strings}var _t={mappings:{},buffers:[null,[],[]],printChar:function(i,a){var c=_t.buffers[i];a===0||a===10?((i===1?Re:ie)(Qr(c,0)),c.length=0):c.push(a)},varargs:void 0,get:function(){_t.varargs+=4;var i=k[_t.varargs-4>>2];return i},getStr:function(i){var a=Dt(i);return a},get64:function(i,a){return i}};function Ka(i,a){var c=0;return Ct().forEach(function(_,b){var T=a+c;k[i+b*4>>2]=T,qo(_,T),c+=_.length+1}),0}function Ja(i,a){var c=Ct();k[i>>2]=c.length;var _=0;return c.forEach(function(b){_+=b.length+1}),k[a>>2]=_,0}function Xa(i){return 0}function Qa(i,a,c,_){var b=_t.getStreamFromFD(i),T=_t.doReadv(b,a,c);return k[_>>2]=T,0}function za(i,a,c,_,b){}function Za(i,a,c,_){for(var b=0,T=0;T<c;T++){var I=k[a>>2],A=k[a+4>>2];a+=8;for(var S=0;S<A;S++)_t.printChar(i,oe[I+S]);b+=A}return k[_>>2]=b,0}function eu(){if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function"){var i=new Uint8Array(1);return function(){return crypto.getRandomValues(i),i[0]}}else return function(){mt("randomDevice")}}function sr(i,a){sr.randomDevice||(sr.randomDevice=eu());for(var c=0;c<a;c++)z[i+c>>0]=sr.randomDevice();return 0}function tu(i){var a=Date.now();return k[i>>2]=a/1e3|0,k[i+4>>2]=a%1e3*1e3|0,0}function ir(i){return i%4===0&&(i%100!==0||i%400===0)}function ln(i,a){for(var c=0,_=0;_<=a;c+=i[_++]);return c}var or=[31,29,31,30,31,30,31,31,30,31,30,31],ar=[31,28,31,30,31,30,31,31,30,31,30,31];function ur(i,a){for(var c=new Date(i.getTime());a>0;){var _=ir(c.getFullYear()),b=c.getMonth(),T=(_?or:ar)[b];if(a>T-c.getDate())a-=T-c.getDate()+1,c.setDate(1),b<11?c.setMonth(b+1):(c.setMonth(0),c.setFullYear(c.getFullYear()+1));else return c.setDate(c.getDate()+a),c}return c}function ru(i,a,c,_){var b=k[_+40>>2],T={tm_sec:k[_>>2],tm_min:k[_+4>>2],tm_hour:k[_+8>>2],tm_mday:k[_+12>>2],tm_mon:k[_+16>>2],tm_year:k[_+20>>2],tm_wday:k[_+24>>2],tm_yday:k[_+28>>2],tm_isdst:k[_+32>>2],tm_gmtoff:k[_+36>>2],tm_zone:b?Dt(b):""},I=Dt(c),A={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var S in A)I=I.replace(new RegExp(S,"g"),A[S]);var x=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],q=["January","February","March","April","May","June","July","August","September","October","November","December"];function K(E,C,F){for(var J=typeof E=="number"?E.toString():E||"";J.length<C;)J=F[0]+J;return J}function W(E,C){return K(E,C,"0")}function Q(E,C){function F(Ie){return Ie<0?-1:Ie>0?1:0}var J;return(J=F(E.getFullYear()-C.getFullYear()))===0&&(J=F(E.getMonth()-C.getMonth()))===0&&(J=F(E.getDate()-C.getDate())),J}function j(E){switch(E.getDay()){case 0:return new Date(E.getFullYear()-1,11,29);case 1:return E;case 2:return new Date(E.getFullYear(),0,3);case 3:return new Date(E.getFullYear(),0,2);case 4:return new Date(E.getFullYear(),0,1);case 5:return new Date(E.getFullYear()-1,11,31);case 6:return new Date(E.getFullYear()-1,11,30)}}function re(E){var C=ur(new Date(E.tm_year+1900,0,1),E.tm_yday),F=new Date(C.getFullYear(),0,4),J=new Date(C.getFullYear()+1,0,4),Ie=j(F),P=j(J);return Q(Ie,C)<=0?Q(P,C)<=0?C.getFullYear()+1:C.getFullYear():C.getFullYear()-1}var Y={"%a":function(E){return x[E.tm_wday].substring(0,3)},"%A":function(E){return x[E.tm_wday]},"%b":function(E){return q[E.tm_mon].substring(0,3)},"%B":function(E){return q[E.tm_mon]},"%C":function(E){var C=E.tm_year+1900;return W(C/100|0,2)},"%d":function(E){return W(E.tm_mday,2)},"%e":function(E){return K(E.tm_mday,2," ")},"%g":function(E){return re(E).toString().substring(2)},"%G":function(E){return re(E)},"%H":function(E){return W(E.tm_hour,2)},"%I":function(E){var C=E.tm_hour;return C==0?C=12:C>12&&(C-=12),W(C,2)},"%j":function(E){return W(E.tm_mday+ln(ir(E.tm_year+1900)?or:ar,E.tm_mon-1),3)},"%m":function(E){return W(E.tm_mon+1,2)},"%M":function(E){return W(E.tm_min,2)},"%n":function(){return`
17
+ `},"%p":function(E){return E.tm_hour>=0&&E.tm_hour<12?"AM":"PM"},"%S":function(E){return W(E.tm_sec,2)},"%t":function(){return" "},"%u":function(E){return E.tm_wday||7},"%U":function(E){var C=new Date(E.tm_year+1900,0,1),F=C.getDay()===0?C:ur(C,7-C.getDay()),J=new Date(E.tm_year+1900,E.tm_mon,E.tm_mday);if(Q(F,J)<0){var Ie=ln(ir(J.getFullYear())?or:ar,J.getMonth()-1)-31,P=31-F.getDate(),Me=P+Ie+J.getDate();return W(Math.ceil(Me/7),2)}return Q(F,C)===0?"01":"00"},"%V":function(E){var C=new Date(E.tm_year+1900,0,4),F=new Date(E.tm_year+1901,0,4),J=j(C),Ie=j(F),P=ur(new Date(E.tm_year+1900,0,1),E.tm_yday);if(Q(P,J)<0)return"53";if(Q(Ie,P)<=0)return"01";var Me;return J.getFullYear()<E.tm_year+1900?Me=E.tm_yday+32-J.getDate():Me=E.tm_yday+1-J.getDate(),W(Math.ceil(Me/7),2)},"%w":function(E){return E.tm_wday},"%W":function(E){var C=new Date(E.tm_year,0,1),F=C.getDay()===1?C:ur(C,C.getDay()===0?1:7-C.getDay()+1),J=new Date(E.tm_year+1900,E.tm_mon,E.tm_mday);if(Q(F,J)<0){var Ie=ln(ir(J.getFullYear())?or:ar,J.getMonth()-1)-31,P=31-F.getDate(),Me=P+Ie+J.getDate();return W(Math.ceil(Me/7),2)}return Q(F,C)===0?"01":"00"},"%y":function(E){return(E.tm_year+1900).toString().substring(2)},"%Y":function(E){return E.tm_year+1900},"%z":function(E){var C=E.tm_gmtoff,F=C>=0;return C=Math.abs(C)/60,C=C/60*100+C%60,(F?"+":"-")+("0000"+C).slice(-4)},"%Z":function(E){return E.tm_zone},"%%":function(){return"%"}};for(var S in Y)I.includes(S)&&(I=I.replace(new RegExp(S,"g"),Y[S](T)));var be=ri(I,!1);return be.length>a?0:(Vs(be,i),be.length-1)}function nu(i,a,c,_){return ru(i,a,c,_)}function su(i){var a=Date.now()/1e3|0;return i&&(k[i>>2]=a),a}ma(),Qs=e.BindingError=Xs(Error,"BindingError"),ga=e.InternalError=Xs(Error,"InternalError"),Aa();function ri(i,a,c){var _=c>0?c:ks(i)+1,b=new Array(_),T=Ls(i,b,0,b.length);return a&&(b.length=T),b}var iu={i:sa,a:oa,g:la,r:da,n:Ea,A:ya,l:Ua,d:xa,c:Pa,m:va,h:Da,o:Na,e:Ca,j:Ma,b:Ga,s:Wa,t:$a,x:Ka,y:Ja,z:Xa,u:Qa,q:za,k:Za,v:sr,f:tu,w:nu,p:su},Nl=ra(),ou=e.___wasm_call_ctors=function(){return(ou=e.___wasm_call_ctors=e.asm.C).apply(null,arguments)},au=e._CreateMediaProcessing=function(){return(au=e._CreateMediaProcessing=e.asm.D).apply(null,arguments)},uu=e._ReleaseMediaProcessing=function(){return(uu=e._ReleaseMediaProcessing=e.asm.E).apply(null,arguments)},cu=e._AddAudioChannel=function(){return(cu=e._AddAudioChannel=e.asm.F).apply(null,arguments)},lu=e._DelAudioChannel=function(){return(lu=e._DelAudioChannel=e.asm.G).apply(null,arguments)},du=e._AddVideoChannel=function(){return(du=e._AddVideoChannel=e.asm.H).apply(null,arguments)},mu=e._DelVideoChannel=function(){return(mu=e._DelVideoChannel=e.asm.I).apply(null,arguments)},pu=e._ReceivedRawAudioPacket=function(){return(pu=e._ReceivedRawAudioPacket=e.asm.J).apply(null,arguments)},_u=e._ParseUdtMousePacket=function(){return(_u=e._ParseUdtMousePacket=e.asm.K).apply(null,arguments)},fu=e._ReceivedAudioUdtPacket=function(){return(fu=e._ReceivedAudioUdtPacket=e.asm.L).apply(null,arguments)},hu=e._ParseUdtAudioPacket=function(){return(hu=e._ParseUdtAudioPacket=e.asm.M).apply(null,arguments)},bu=e._ReceivedVideoPacket=function(){return(bu=e._ReceivedVideoPacket=e.asm.N).apply(null,arguments)},gu=e._SetAudioBuffer10Ms=function(){return(gu=e._SetAudioBuffer10Ms=e.asm.O).apply(null,arguments)},Eu=e._SetAudioVolume=function(){return(Eu=e._SetAudioVolume=e.asm.P).apply(null,arguments)},Tu=e._GetAudioFrame=function(){return(Tu=e._GetAudioFrame=e.asm.Q).apply(null,arguments)},Iu=e._GetAudioFrameFloat=function(){return(Iu=e._GetAudioFrameFloat=e.asm.R).apply(null,arguments)},Su=e._GetAudioMixed=function(){return(Su=e._GetAudioMixed=e.asm.S).apply(null,arguments)},Au=e._GetAudioMixedFloat=function(){return(Au=e._GetAudioMixedFloat=e.asm.T).apply(null,arguments)},yu=e._GetAudioEnergy=function(){return(yu=e._GetAudioEnergy=e.asm.U).apply(null,arguments)},Ru=e._SetAudioFrameFormat=function(){return(Ru=e._SetAudioFrameFormat=e.asm.V).apply(null,arguments)},Uu=e._SetAudioOutStreamFormat=function(){return(Uu=e._SetAudioOutStreamFormat=e.asm.W).apply(null,arguments)},Ou=e._AudioProcess=function(){return(Ou=e._AudioProcess=e.asm.X).apply(null,arguments)},xu=e._AudioProcessFloat=function(){return(xu=e._AudioProcessFloat=e.asm.Y).apply(null,arguments)},Pu=e._AudioReverseProcess=function(){return(Pu=e._AudioReverseProcess=e.asm.Z).apply(null,arguments)},vu=e._AudioReverseProcessFloat=function(){return(vu=e._AudioReverseProcessFloat=e.asm._).apply(null,arguments)},Du=e._InitOpusEncoder=function(){return(Du=e._InitOpusEncoder=e.asm.$).apply(null,arguments)},Nu=e._SetOpusEncBitrate=function(){return(Nu=e._SetOpusEncBitrate=e.asm.aa).apply(null,arguments)},Cu=e._OpusEncode=function(){return(Cu=e._OpusEncode=e.asm.ba).apply(null,arguments)},wu=e._UpdateStreamSync=function(){return(wu=e._UpdateStreamSync=e.asm.ca).apply(null,arguments)},Lu=e._GetEncodedFrame=function(){return(Lu=e._GetEncodedFrame=e.asm.da).apply(null,arguments)},Mu=e._GetReceivedVideoStat=function(){return(Mu=e._GetReceivedVideoStat=e.asm.ea).apply(null,arguments)},ku=e._CreateUdtPacketizer=function(){return(ku=e._CreateUdtPacketizer=e.asm.fa).apply(null,arguments)},Bu=e._PacketizeVideoUdt=function(){return(Bu=e._PacketizeVideoUdt=e.asm.ga).apply(null,arguments)},Vu=e._PacketizeAudioUdt=function(){return(Vu=e._PacketizeAudioUdt=e.asm.ha).apply(null,arguments)},Fu=e._GetRetransPacket=function(){return(Fu=e._GetRetransPacket=e.asm.ia).apply(null,arguments)},Hu=e._CheckMissingPacket=function(){return(Hu=e._CheckMissingPacket=e.asm.ja).apply(null,arguments)},qu=e._UseAINS=function(){return(qu=e._UseAINS=e.asm.ka).apply(null,arguments)},Gu=e._EnableAEC=function(){return(Gu=e._EnableAEC=e.asm.la).apply(null,arguments)},Wu=e._SetCrypto=function(){return(Wu=e._SetCrypto=e.asm.ma).apply(null,arguments)},cr=e._malloc=function(){return(cr=e._malloc=e.asm.oa).apply(null,arguments)},qe=e._free=function(){return(qe=e._free=e.asm.pa).apply(null,arguments)},ni=e.___errno_location=function(){return(ni=e.___errno_location=e.asm.qa).apply(null,arguments)},ju=e.___getTypeName=function(){return(ju=e.___getTypeName=e.asm.ra).apply(null,arguments)},$u=e.___embind_register_native_and_builtin_types=function(){return($u=e.___embind_register_native_and_builtin_types=e.asm.sa).apply(null,arguments)},si=e.stackSave=function(){return(si=e.stackSave=e.asm.ta).apply(null,arguments)},ii=e.stackRestore=function(){return(ii=e.stackRestore=e.asm.ua).apply(null,arguments)},dn=e.stackAlloc=function(){return(dn=e.stackAlloc=e.asm.va).apply(null,arguments)},Yu=e._emscripten_stack_init=function(){return(Yu=e._emscripten_stack_init=e.asm.wa).apply(null,arguments)};e.ccall=Cs,e.cwrap=Lo,e.addFunction=No,e.removeFunction=Co;var lr;function Ku(i){this.name="ExitStatus",this.message="Program terminated with exit("+i+")",this.status=i}Nt=function i(){lr||mn(),lr||(Nt=i)};function mn(i){if(i=i||p,Qe>0||($o(),Qe>0))return;function a(){lr||(lr=!0,e.calledRun=!0,!Ds&&(Yo(),r(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),Ko()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),a()},1)):a()}if(e.run=mn,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return mn(),e.ready})})(),xo=Pl;Uo(xo);
package/index.d.ts CHANGED
@@ -14,17 +14,12 @@ import { RealtimeTranscriber, StartRealtimeTranscriberOption, StopRealtimeTransc
14
14
 
15
15
  export { CDNStreamingOptions, DeviceDetectorOptions, VirtualBackgroundOptions, UpdateVirtualBackgroundOptions, WatermarkOptions, BeautyOptions, UpdateBeautyOptions, BasicBeautyOptions, StartCrossRoomOption, UpdateCrossRoomOption, StopCrossRoomOption, SmallStreamAutoSwitcherOptions, VideoMixerOptions, UpdateVideoMixerOptions, StartRealtimeTranscriberOption, StopRealtimeTranscriberOption };
16
16
  type TRTCPlugin = typeof CrossRoom | typeof CDNStreaming | typeof DeviceDetector | typeof VirtualBackground | typeof Watermark | typeof Beauty | typeof BasicBeauty | typeof CustomEncryption | typeof SmallStreamAutoSwitcher | typeof VideoMixer | typeof Chorus | typeof LEBPlayer | typeof RealtimeTranscriber;
17
-
18
17
  export type ExperimentalAPIFunctionMap = {
19
18
  'enableAudioFrameEvent': EnableAudioFrameEventOptions;
20
19
  'resumeRemotePlayer': RemotePlayerOptions;
21
20
  'pauseRemotePlayer': RemotePlayerOptions;
22
- 'requestPictureInPicture': RequestPictureInPictureOptions;
23
- 'requestFullScreen': RequestFullScreenOptions;
24
21
  }
25
22
 
26
- export interface RequestPictureInPictureOptions { enable: boolean }
27
- export interface RequestFullScreenOptions { enable: boolean }
28
23
  export interface RemotePlayerOptions { userId: string, streamType?: TRTCStreamType }
29
24
 
30
25
  export declare type PluginStartOptionsMap = {
@@ -344,12 +339,11 @@ export declare const enum BannedReason {
344
339
  }
345
340
 
346
341
  export declare const enum PEER_LEAVE_REASON {
347
- NORMAL_LEAVE = 'normal leave',
348
- TIMEOUT_LEAVE = 'timeout leave',
349
- KICK = 'kick',
350
- ROLE_CHANGE = 'role change'
342
+ NORMAL_LEAVE = 0,
343
+ TIMEOUT_LEAVE = 1,
344
+ KICK = 2,
345
+ ROLE_CHANGE = 3
351
346
  }
352
-
353
347
  export declare type PluginWithAssets = {
354
348
  plugin: TRTCPlugin;
355
349
  assetsPath?: string;
@@ -1369,7 +1363,7 @@ export declare interface TRTCEventTypes {
1369
1363
  }];
1370
1364
  [TRTCEvent.REMOTE_USER_EXIT]: [{
1371
1365
  userId: string;
1372
- reason?: keyof typeof PEER_LEAVE_REASON;
1366
+ reason?: PEER_LEAVE_REASON;
1373
1367
  }];
1374
1368
  [TRTCEvent.REMOTE_AUDIO_AVAILABLE]: [{
1375
1369
  userId: string;
package/package.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "name": "trtc-sdk-v5",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "Tencent Cloud RTC SDK for Web",
5
- "main": "trtc.js",
5
+ "module": "trtc.esm.js",
6
+ "type": "module",
6
7
  "types": "index.d.ts",
7
- "dependencies": {
8
- "webrtc-adapter": "^8.2.3"
9
- },
10
8
  "keywords": [
11
9
  "webrtc",
12
10
  "TRTC",
@@ -29,4 +27,4 @@
29
27
  },
30
28
  "author": "Tencent Cloud Client R&D Center",
31
29
  "license": "ISC"
32
- }
30
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cdn-streaming",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "TRTC Web SDK 5.x CDN streaming plugin",
5
5
  "main": "./cdn-streaming.esm.js",
6
6
  "module": "./cdn-streaming.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/chorus",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "TRTC Web SDK 5.x Chorus plugin",
5
5
  "main": "./chorus.esm.js",
6
6
  "module": "./chorus.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/cross-room",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "TRTC Web SDK 5.x Cross Room plugin",
5
5
  "main": "./cross-room.esm.js",
6
6
  "module": "./cross-room.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/custom-encryption",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "main": "./custom-encryption.esm.js",
5
5
  "module": "./custom-encryption.esm.js",
6
6
  "types": "./custom-encryption.esm.d.ts"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/device-detector",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "TRTC Web SDK 5.x device detector plugin",
5
5
  "main": "./device-detector.esm.js",
6
6
  "module": "./device-detector.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/lebplayer",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "TRTC Web SDK 5.x LEBPlayer plugin",
5
5
  "main": "./lebplayer.esm.js",
6
6
  "module": "./lebplayer.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/realtime-transcriber",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "TRTC Web SDK 5.x Realtime Transcriber plugin",
5
5
  "main": "./realtime-transcriber.esm.js",
6
6
  "module": "./realtime-transcriber.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/small-stream-auto-switcher",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "",
5
5
  "main": "./small-stream-auto-switcher.esm.js",
6
6
  "keywords": [],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/video-decoder",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "Video decoder plugin for TRTC",
5
5
  "main": "./video-decoder.esm.js",
6
6
  "module": "./video-decoder.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/basic-beauty",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "TRTC Web SDK 5.x basic-beauty plugin",
5
5
  "main": "./basic-beauty.esm.js",
6
6
  "module": "./basic-beauty.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/beauty",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "TRTC Web SDK 5.x beauty plugin",
5
5
  "main": "./beauty.esm.js",
6
6
  "module": "./beauty.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/face-detection",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "TRTC Web SDK 5.x face detection plugin",
5
5
  "main": "./face-detection.esm.js",
6
6
  "module": "./face-detection.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/video-mixer",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "TRTC Web SDK 5.x videoMixer plugin",
5
5
  "main": "./video-mixer.esm.js",
6
6
  "module": "./video-mixer.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/virtual-background",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "TRTC Web SDK 5.x virtual background plugin",
5
5
  "main": "./virtual-background.esm.js",
6
6
  "module": "./virtual-background.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/watermark",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "TRTC Web SDK 5.x watermark plugin",
5
5
  "main": "./watermark.esm.js",
6
6
  "module": "./watermark.esm.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtc-plugin/voice-changer",
3
- "version": "5.15.1-beta.8",
3
+ "version": "5.15.1-wasm.2",
4
4
  "description": "",
5
5
  "main": "./voice-changer.esm.js",
6
6
  "keywords": [],