/*! For license information please see agora-miniapp-sdk.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("AgoraSDK",[],t):"object"==typeof exports?exports.AgoraSDK=t():e.AgoraSDK=t()}(self,(()=>(()=>{var __webpack_modules__={537:e=>{"use strict";e.exports=function(e,t){for(var n=new Array(arguments.length-1),r=0,i=2,o=!0;i{"use strict";var n=t;n.length=function(e){var t=e.length;if(!t)return 0;for(var n=0;--t%4>1&&"="===e.charAt(t);)++n;return Math.ceil(3*e.length)/4-n};for(var r=new Array(64),i=new Array(123),o=0;o<64;)i[r[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;n.encode=function(e,t,n){for(var i,o=null,s=[],a=0,c=0;t>2],i=(3&l)<<4,c=1;break;case 1:s[a++]=r[i|l>>4],i=(15&l)<<2,c=2;break;case 2:s[a++]=r[i|l>>6],s[a++]=r[63&l],c=0}a>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),a=0)}return c&&(s[a++]=r[i],s[a++]=61,1===c&&(s[a++]=61)),o?(a&&o.push(String.fromCharCode.apply(String,s.slice(0,a))),o.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var s="invalid encoding";n.decode=function(e,t,n){for(var r,o=n,a=0,c=0;c1)break;if(void 0===(l=i[l]))throw Error(s);switch(a){case 0:r=l,a=1;break;case 1:t[n++]=r<<2|(48&l)>>4,r=l,a=2;break;case 2:t[n++]=(15&r)<<4|(60&l)>>2,r=l,a=3;break;case 3:t[n++]=(3&r)<<6|l,a=0}}if(1===a)throw Error(s);return n-o},n.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},211:e=>{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var n=this._listeners[e],r=0;r{"use strict";function t(e){return"undefined"!=typeof Float32Array?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),r=128===n[3];function i(e,r,i){t[0]=e,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3]}function o(e,r,i){t[0]=e,r[i]=n[3],r[i+1]=n[2],r[i+2]=n[1],r[i+3]=n[0]}function s(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],t[0]}function a(e,r){return n[3]=e[r],n[2]=e[r+1],n[1]=e[r+2],n[0]=e[r+3],t[0]}e.writeFloatLE=r?i:o,e.writeFloatBE=r?o:i,e.readFloatLE=r?s:a,e.readFloatBE=r?a:s}():function(){function t(e,t,n,r){var i=t<0?1:0;if(i&&(t=-t),0===t)e(1/t>0?0:2147483648,n,r);else if(isNaN(t))e(2143289344,n,r);else if(t>34028234663852886e22)e((i<<31|2139095040)>>>0,n,r);else if(t<11754943508222875e-54)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,n,r);else{var o=Math.floor(Math.log(t)/Math.LN2);e((i<<31|o+127<<23|8388607&Math.round(t*Math.pow(2,-o)*8388608))>>>0,n,r)}}function s(e,t,n){var r=e(t,n),i=2*(r>>31)+1,o=r>>>23&255,s=8388607&r;return 255===o?s?NaN:i*(1/0):0===o?1401298464324817e-60*i*s:i*Math.pow(2,o-150)*(s+8388608)}e.writeFloatLE=t.bind(null,n),e.writeFloatBE=t.bind(null,r),e.readFloatLE=s.bind(null,i),e.readFloatBE=s.bind(null,o)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),r=128===n[7];function i(e,r,i){t[0]=e,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3],r[i+4]=n[4],r[i+5]=n[5],r[i+6]=n[6],r[i+7]=n[7]}function o(e,r,i){t[0]=e,r[i]=n[7],r[i+1]=n[6],r[i+2]=n[5],r[i+3]=n[4],r[i+4]=n[3],r[i+5]=n[2],r[i+6]=n[1],r[i+7]=n[0]}function s(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],n[4]=e[r+4],n[5]=e[r+5],n[6]=e[r+6],n[7]=e[r+7],t[0]}function a(e,r){return n[7]=e[r],n[6]=e[r+1],n[5]=e[r+2],n[4]=e[r+3],n[3]=e[r+4],n[2]=e[r+5],n[1]=e[r+6],n[0]=e[r+7],t[0]}e.writeDoubleLE=r?i:o,e.writeDoubleBE=r?o:i,e.readDoubleLE=r?s:a,e.readDoubleBE=r?a:s}():function(){function t(e,t,n,r,i,o){var s=r<0?1:0;if(s&&(r=-r),0===r)e(0,i,o+t),e(1/r>0?0:2147483648,i,o+n);else if(isNaN(r))e(0,i,o+t),e(2146959360,i,o+n);else if(r>17976931348623157e292)e(0,i,o+t),e((s<<31|2146435072)>>>0,i,o+n);else{var a;if(r<22250738585072014e-324)e((a=r/5e-324)>>>0,i,o+t),e((s<<31|a/4294967296)>>>0,i,o+n);else{var c=Math.floor(Math.log(r)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(a=r*Math.pow(2,-c))>>>0,i,o+t),e((s<<31|c+1023<<20|1048576*a&1048575)>>>0,i,o+n)}}}function s(e,t,n,r,i){var o=e(r,i+t),s=e(r,i+n),a=2*(s>>31)+1,c=s>>>20&2047,l=4294967296*(1048575&s)+o;return 2047===c?l?NaN:a*(1/0):0===c?5e-324*a*l:a*Math.pow(2,c-1075)*(l+4503599627370496)}e.writeDoubleLE=t.bind(null,n,0,4),e.writeDoubleBE=t.bind(null,r,4,0),e.readDoubleLE=s.bind(null,i,0,4),e.readDoubleBE=s.bind(null,o,4,0)}(),e}function n(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function r(e,t,n){t[n]=e>>>24,t[n+1]=e>>>16&255,t[n+2]=e>>>8&255,t[n+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function o(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},199:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},662:e=>{"use strict";e.exports=function(e,t,n){var r=n||8192,i=r>>>1,o=null,s=r;return function(n){if(n<1||n>i)return e(n);s+n>r&&(o=e(r),s=0);var a=t.call(o,s,s+=n);return 7&s&&(s=1+(7|s)),a}}},997:(e,t)=>{"use strict";var n=t;n.length=function(e){for(var t=0,n=0,r=0;r191&&r<224?o[s++]=(31&r)<<6|63&e[t++]:r>239&&r<365?(r=((7&r)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,o[s++]=55296+(r>>10),o[s++]=56320+(1023&r)):o[s++]=(15&r)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i?(s&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))},n.write=function(e,t,n){for(var r,i,o=n,s=0;s>6|192,t[n++]=63&r|128):55296==(64512&r)&&56320==(64512&(i=e.charCodeAt(s+1)))?(r=65536+((1023&r)<<10)+(1023&i),++s,t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=63&r|128):(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=63&r|128);return n-o}},699:(e,t,n)=>{"use strict";var r,i,o,s,a,c=n(100),l=c.Writer,u=c.util,p=c.roots.default||(c.roots.default={});p.io=((a={}).agora=((s={}).pb=((o={}).CounterCompact=function(){function e(e){if(this.items=[],e)for(var t=Object.keys(e),n=0;n{"use strict";n.r(t),n.d(t,{DOMAIN_NAME:()=>o,SDK_VERSION:()=>i,VERSION:()=>r});var r="1.1.0",i="2.6.4",o="mini-app.broadcastapp.agoraio.cn"},426:(e,t,n)=>{"use strict";n.r(t),n.d(t,{generateSessionId:()=>s,is32Uint:()=>l,isWeiXin:()=>c,random:()=>o,shouldUseHttps:()=>a});var r=n(171),i=n.n(r),o=function(e){isNaN(e)&&(e=1e3);var t=+new Date,n=(t=(9301*t+49297)%233280)/233280;return Math.ceil(n*e)},s=function(){return i()().replace(/-/g,"").toUpperCase()},a=function(){return"https:"==document.location.protocol},c=function(){try{return wx,!0}catch(e){return!1}},l=function(e){return!!(0<=e&&e<=4294967295)}},186:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>u});var r=n(861),i=n(671),o=n(144),s=n(687),a=n.n(s),c=(n(568),n(446)),l=function(){function e(t){var n=t.appId,r=t.content,o=t.ts;(0,i.Z)(this,e),this.appId=n,this.content=r,this.ts=o}return(0,o.Z)(e,[{key:"upload",value:function(){var e=this;return new Promise((function(t,n){wx.request({url:"https://report-ad.agoralab.co/v1/log/report",method:"post",data:{data:e.content,appId:e.appId,ts:e.ts,src:"miniapp",version:c.SDK_VERSION},success:function(){t()},fail:function(e){n(e)}})}))}}]),e}();const u=new(function(){function e(){(0,i.Z)(this,e),this.level=3,this.onLog=null,this.logItems=[],this.appId="",this.sid=""}return(0,o.Z)(e,[{key:"setOptions",value:function(e){var t=e.appId,n=void 0===t?"":t,r=e.sid,i=void 0===r?"":r;this.appId=n,this.sid=i}},{key:"setLogLevel",value:function(e){if("number"!=typeof e||!(e<=4&&e>=-1))throw Error("Invalid level");this.level=e}},{key:"_storeLog",value:function(e){this.logItems.push({msg:e,sid:this.sid}),this.logItems.length>5e4&&this.logItems.shift()}},{key:"_log",value:function(){for(var e="",t=arguments.length,n=new Array(t),r=0;r{"use strict";n.r(t),n.d(t,{checkValidBoolean:()=>l,checkValidEnum:()=>i,checkValidFloatNumber:()=>c,checkValidNumber:()=>a,checkValidObject:()=>o,checkValidString:()=>s,getServerUrlIp:()=>b,isASCII:()=>_,isArray:()=>w,isEmpty:()=>O,isInteger:()=>g,isNumber:()=>v,isString:()=>m,isValidBoolean:()=>d,isValidChannelName:()=>y,isValidNumber:()=>p,isValidString:()=>u,isValidToken:()=>f,stringifyErr:()=>E,throttle:()=>S,transformElapseStr:()=>R});var r=n(2),i=function(e,t,n){for(var r=0;r=t&&e.length<=n},p=function(e,t,n){return g(e)&&e>=t&&e<=n},h=function(e,t,n){return v(e)&&e>=t&&e<=n},d=function(e){return"boolean"==typeof e},f=function(e){return u(e,1,2047)},y=function(e){return m(e)&&/^[a-zA-Z0-9 \!\#\$\%\&\(\)\+\-\:\;\<\=\.\>\?\@\[\]\^\_\{\}\|\~\,]{1,64}$/.test(e)},_=function(e){if("string"==typeof e){for(var t=0;t255)return!1}return!0}},g=function(e){return"number"==typeof e&&e%1==0},v=function(e){return"number"==typeof e},m=function(e){return"string"==typeof e},w=function(e){return e instanceof Array},O=function(e){return null==e},E=function(e){return e instanceof Error||e.message?e.message:JSON.stringify(e)},b=function(e){var t=/wss:\/\/miniapp.agoraio.cn\/(\S+)\/api/g.exec(e);return t instanceof Array&&t[1]||""},R=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return(e=Number(e))<=0?"<0ms":e>0&&e<=50?"0~50ms":e>50&&e<=100?"50~100ms":e>100&&e<=200?"100~200ms":e>200&&e<=300?"200~300ms":e>300&&e<=500?"300~500ms":e>500&&e<=800?"500~800ms":e>800&&e<=1e3?"800~1000ms":e>1e3&&e<=1500?"1~1.5s":e>1500&&e<=2e3?"1.5~2s":e>2e3&&e<=3e3?"2~3s":e>3e3&&e<=5e3?"3~5s":e>5e3&&e<=8e3?"5~8s":e>8e3&&e<=1e4?"8~10s":">10s"},S=function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return function(){for(var i=arguments.length,o=new Array(i),s=0;s{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n{var t,n;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n>>6*(3-o)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var n=[],r=0,i=0;r>>6-2*i);return n}},e.exports=n},738:e=>{function t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},568:(e,t,n)=>{var r,i,o,s,a;r=n(12),i=n(487).utf8,o=n(738),s=n(487).bin,(a=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?s.stringToBytes(e):i.stringToBytes(e):o(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=r.bytesToWords(e),c=8*e.length,l=1732584193,u=-271733879,p=-1732584194,h=271733878,d=0;d>>24)|4278255360&(n[d]<<24|n[d]>>>8);n[c>>>5]|=128<>>9<<4)]=c;var f=a._ff,y=a._gg,_=a._hh,g=a._ii;for(d=0;d>>0,u=u+m>>>0,p=p+w>>>0,h=h+O>>>0}return r.endian([l,u,p,h])})._ff=function(e,t,n,r,i,o,s){var a=e+(t&n|~t&r)+(i>>>0)+s;return(a<>>32-o)+t},a._gg=function(e,t,n,r,i,o,s){var a=e+(t&r|n&~r)+(i>>>0)+s;return(a<>>32-o)+t},a._hh=function(e,t,n,r,i,o,s){var a=e+(t^n^r)+(i>>>0)+s;return(a<>>32-o)+t},a._ii=function(e,t,n,r,i,o,s){var a=e+(n^(t|~r))+(i>>>0)+s;return(a<>>32-o)+t},a._blocksize=16,a._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var n=r.wordsToBytes(a(e,t));return t&&t.asBytes?n:t&&t.asString?s.bytesToString(n):r.bytesToHex(n)}},100:(e,t,n)=>{"use strict";e.exports=n(482)},482:(e,t,n)=>{"use strict";var r=t;function i(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}r.build="minimal",r.Writer=n(173),r.BufferWriter=n(155),r.Reader=n(408),r.BufferReader=n(593),r.util=n(693),r.rpc=n(994),r.roots=n(54),r.configure=i,i()},408:(e,t,n)=>{"use strict";e.exports=c;var r,i=n(693),o=i.LongBits,s=i.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function c(e){this.buf=e,this.pos=0,this.len=e.length}var l,u="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new c(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new c(e);throw Error("illegal buffer")},p=function(){return i.Buffer?function(e){return(c.create=function(e){return i.Buffer.isBuffer(e)?new r(e):u(e)})(e)}:u};function h(){var e=new o(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function d(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw a(this,8);return new o(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}c.create=p(),c.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,c.prototype.uint32=(l=4294967295,function(){if(l=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return l;if(l=(l|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return l;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return l}),c.prototype.int32=function(){return 0|this.uint32()},c.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},c.prototype.bool=function(){return 0!==this.uint32()},c.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return d(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|d(this.buf,this.pos+=4)},c.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},c.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},c.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw a(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,n):t===n?new this.buf.constructor(0):this._slice.call(this.buf,t,n)},c.prototype.string=function(){var e=this.bytes();return s.read(e,0,e.length)},c.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},c.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},c._configure=function(e){r=e,c.create=p(),r._configure();var t=i.Long?"toLong":"toNumber";i.merge(c.prototype,{int64:function(){return h.call(this)[t](!1)},uint64:function(){return h.call(this)[t](!0)},sint64:function(){return h.call(this).zzDecode()[t](!1)},fixed64:function(){return f.call(this)[t](!0)},sfixed64:function(){return f.call(this)[t](!1)}})}},593:(e,t,n)=>{"use strict";e.exports=o;var r=n(408);(o.prototype=Object.create(r.prototype)).constructor=o;var i=n(693);function o(e){r.call(this,e)}o._configure=function(){i.Buffer&&(o.prototype._slice=i.Buffer.prototype.slice)},o.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},o._configure()},54:e=>{"use strict";e.exports={}},994:(e,t,n)=>{"use strict";t.Service=n(948)},948:(e,t,n)=>{"use strict";e.exports=i;var r=n(693);function i(e,t,n){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");r.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(n)}(i.prototype=Object.create(r.EventEmitter.prototype)).constructor=i,i.prototype.rpcCall=function e(t,n,i,o,s){if(!o)throw TypeError("request must be specified");var a=this;if(!s)return r.asPromise(e,a,t,n,i,o);if(a.rpcImpl)try{return a.rpcImpl(t,n[a.requestDelimited?"encodeDelimited":"encode"](o).finish(),(function(e,n){if(e)return a.emit("error",e,t),s(e);if(null!==n){if(!(n instanceof i))try{n=i[a.responseDelimited?"decodeDelimited":"decode"](n)}catch(e){return a.emit("error",e,t),s(e)}return a.emit("data",n,t),s(null,n)}a.end(!0)}))}catch(e){return a.emit("error",e,t),void setTimeout((function(){s(e)}),0)}else setTimeout((function(){s(Error("already ended"))}),0)},i.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},630:(e,t,n)=>{"use strict";e.exports=i;var r=n(693);function i(e,t){this.lo=e>>>0,this.hi=t>>>0}var o=i.zero=new i(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var s=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(e){if(0===e)return o;var t=e<0;t&&(e=-e);var n=e>>>0,r=(e-n)/4294967296>>>0;return t&&(r=~r>>>0,n=~n>>>0,++n>4294967295&&(n=0,++r>4294967295&&(r=0))),new i(n,r)},i.from=function(e){if("number"==typeof e)return i.fromNumber(e);if(r.isString(e)){if(!r.Long)return i.fromNumber(parseInt(e,10));e=r.Long.fromString(e)}return e.low||e.high?new i(e.low>>>0,e.high>>>0):o},i.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,n=~this.hi>>>0;return t||(n=n+1>>>0),-(t+4294967296*n)}return this.lo+4294967296*this.hi},i.prototype.toLong=function(e){return r.Long?new r.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var a=String.prototype.charCodeAt;i.fromHash=function(e){return e===s?o:new i((a.call(e,0)|a.call(e,1)<<8|a.call(e,2)<<16|a.call(e,3)<<24)>>>0,(a.call(e,4)|a.call(e,5)<<8|a.call(e,6)<<16|a.call(e,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},i.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},i.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}},693:function(e,t,n){"use strict";var r=t;function i(e,t,n){for(var r=Object.keys(t),i=0;i0)},r.Buffer=function(){try{var e=r.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(e){return"number"==typeof e?r.Buffer?r._Buffer_allocUnsafe(e):new r.Array(e):r.Buffer?r._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},r.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(e){return e?r.LongBits.from(e).toHash():r.LongBits.zeroHash},r.longFromHash=function(e,t){var n=r.LongBits.fromHash(e);return r.Long?r.Long.fromBits(n.lo,n.hi,t):n.toNumber(Boolean(t))},r.merge=i,r.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},r.newError=o,r.ProtocolError=o("ProtocolError"),r.oneOfGetter=function(e){for(var t={},n=0;n-1;--n)if(1===t[e[n]]&&void 0!==this[e[n]]&&null!==this[e[n]])return e[n]}},r.oneOfSetter=function(e){return function(t){for(var n=0;n{"use strict";e.exports=p;var r,i=n(693),o=i.LongBits,s=i.base64,a=i.utf8;function c(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function l(){}function u(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function p(){this.len=0,this.head=new c(l,0,0),this.tail=this.head,this.states=null}var h=function(){return i.Buffer?function(){return(p.create=function(){return new r})()}:function(){return new p}};function d(e,t,n){t[n]=255&e}function f(e,t){this.len=e,this.next=void 0,this.val=t}function y(e,t,n){for(;e.hi;)t[n++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=127&e.lo|128,e.lo=e.lo>>>7;t[n++]=e.lo}function _(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}p.create=h(),p.alloc=function(e){return new i.Array(e)},i.Array!==Array&&(p.alloc=i.pool(p.alloc,i.Array.prototype.subarray)),p.prototype._push=function(e,t,n){return this.tail=this.tail.next=new c(e,t,n),this.len+=t,this},f.prototype=Object.create(c.prototype),f.prototype.fn=function(e,t,n){for(;e>127;)t[n++]=127&e|128,e>>>=7;t[n]=e},p.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new f((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},p.prototype.int32=function(e){return e<0?this._push(y,10,o.fromNumber(e)):this.uint32(e)},p.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},p.prototype.uint64=function(e){var t=o.from(e);return this._push(y,t.length(),t)},p.prototype.int64=p.prototype.uint64,p.prototype.sint64=function(e){var t=o.from(e).zzEncode();return this._push(y,t.length(),t)},p.prototype.bool=function(e){return this._push(d,1,e?1:0)},p.prototype.fixed32=function(e){return this._push(_,4,e>>>0)},p.prototype.sfixed32=p.prototype.fixed32,p.prototype.fixed64=function(e){var t=o.from(e);return this._push(_,4,t.lo)._push(_,4,t.hi)},p.prototype.sfixed64=p.prototype.fixed64,p.prototype.float=function(e){return this._push(i.float.writeFloatLE,4,e)},p.prototype.double=function(e){return this._push(i.float.writeDoubleLE,8,e)};var g=i.Array.prototype.set?function(e,t,n){t.set(e,n)}:function(e,t,n){for(var r=0;r>>0;if(!t)return this._push(d,1,0);if(i.isString(e)){var n=p.alloc(t=s.length(e));s.decode(e,n,0),e=n}return this.uint32(t)._push(g,t,e)},p.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(d,1,0)},p.prototype.fork=function(){return this.states=new u(this),this.head=this.tail=new c(l,0,0),this.len=0,this},p.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new c(l,0,0),this.len=0),this},p.prototype.ldelim=function(){var e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this},p.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t},p._configure=function(e){r=e,p.create=h(),r._configure()}},155:(e,t,n)=>{"use strict";e.exports=o;var r=n(173);(o.prototype=Object.create(r.prototype)).constructor=o;var i=n(693);function o(){r.call(this)}function s(e,t,n){e.length<40?i.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}o._configure=function(){o.alloc=i._Buffer_allocUnsafe,o.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(e,t,n){t.set(e,n)}:function(e,t,n){if(e.copy)e.copy(t,n,0,e.length);else for(var r=0;r>>0;return this.uint32(t),t&&this._push(o.writeBytesBuffer,t,e),this},o.prototype.string=function(e){var t=i.Buffer.byteLength(e);return this.uint32(t),t&&this._push(s,t,e),this},o._configure()},500:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]{for(var t=[],n=0;n<256;++n)t[n]=(n+256).toString(16).substr(1);e.exports=function(e,n){var r=n||0,i=t;return[i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],"-",i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]],i[e[r++]]].join("")}},217:e=>{var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var n=new Uint8Array(16);e.exports=function(){return t(n),n}}else{var r=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}},171:(e,t,n)=>{var r=n(217),i=n(327);e.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||r)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var a=0;a<16;++a)t[o+a]=s[a];return t||i(s)}},795:function(e,t,n){var r;!function(t){"use strict";function i(){}var o=i.prototype,s=t.EventEmitter;function a(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function c(e){return function(){return this[e].apply(this,arguments)}}function l(e){return"function"==typeof e||e instanceof RegExp||!(!e||"object"!=typeof e)&&l(e.listener)}o.getListeners=function(e){var t,n,r=this._getEvents();if(e instanceof RegExp)for(n in t={},r)r.hasOwnProperty(n)&&e.test(n)&&(t[n]=r[n]);else t=r[e]||(r[e]=[]);return t},o.flattenListeners=function(e){var t,n=[];for(t=0;t{var r=n(698).default;function i(){"use strict";e.exports=i=function(){return n},e.exports.__esModule=!0,e.exports.default=e.exports;var t,n={},o=Object.prototype,s=o.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},c="function"==typeof Symbol?Symbol:{},l=c.iterator||"@@iterator",u=c.asyncIterator||"@@asyncIterator",p=c.toStringTag||"@@toStringTag";function h(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(t){h=function(e,t,n){return e[t]=n}}function d(e,t,n,r){var i=t&&t.prototype instanceof w?t:w,o=Object.create(i.prototype),s=new L(r||[]);return a(o,"_invoke",{value:A(e,n,s)}),o}function f(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}n.wrap=d;var y="suspendedStart",_="suspendedYield",g="executing",v="completed",m={};function w(){}function O(){}function E(){}var b={};h(b,l,(function(){return this}));var R=Object.getPrototypeOf,S=R&&R(R(M([])));S&&S!==o&&s.call(S,l)&&(b=S);var k=E.prototype=w.prototype=Object.create(b);function P(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,o,a,c){var l=f(e[i],e,o);if("throw"!==l.type){var u=l.arg,p=u.value;return p&&"object"==r(p)&&s.call(p,"__await")?t.resolve(p.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(p).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,c)}))}c(l.arg)}var i;a(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}})}function A(e,n,r){var i=y;return function(o,s){if(i===g)throw new Error("Generator is already running");if(i===v){if("throw"===o)throw s;return{value:t,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var c=T(a,r);if(c){if(c===m)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===y)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=g;var l=f(e,n,r);if("normal"===l.type){if(i=r.done?v:_,l.arg===m)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(i=v,r.method="throw",r.arg=l.arg)}}}function T(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,T(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var o=f(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,m;var s=o.arg;return s?s.done?(n[e.resultName]=s.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function N(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function M(e){if(e||""===e){var n=e[l];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=s.call(o,"catchLoc"),l=s.call(o,"finallyLoc");if(c&&l){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&s.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),N(n),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;N(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:M(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},n}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},698:e=>{function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},687:(e,t,n)=>{var r=n(61)();e.exports=r;try{regeneratorRuntime=r}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},861:(e,t,n)=>{"use strict";function r(e,t,n,r,i,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var s=e.apply(t,n);function a(e){r(s,i,o,a,c,"next",e)}function c(e){r(s,i,o,a,c,"throw",e)}a(void 0)}))}}n.d(t,{Z:()=>i})},671:(e,t,n)=>{"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}n.d(t,{Z:()=>r})},144:(e,t,n)=>{"use strict";n.d(t,{Z:()=>o});var r=n(142);function i(e,t){for(var n=0;n{"use strict";n.d(t,{Z:()=>i});var r=n(2);function i(e){var t=function(e,t){if("object"!=(0,r.Z)(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!=(0,r.Z)(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==(0,r.Z)(t)?t:String(t)}},2:(e,t,n)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}n.d(t,{Z:()=>r})}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};return(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ChannelMediaRelayConfiguration:()=>I.ChannelMediaRelayConfiguration,Client:()=>le,LOG:()=>a.default,SDK_VERSION:()=>s.SDK_VERSION});var e=__webpack_require__(861),t=__webpack_require__(671),n=__webpack_require__(144),r=__webpack_require__(687),i=__webpack_require__.n(r),o=__webpack_require__(426),s=__webpack_require__(446),a=__webpack_require__(186);function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t0&&void 0!==u[0]?u[0]:0,o=u.length>1&&void 0!==u[1]?u[1]:{},this.vid||(this.vid=O().vid),s={m:"net_status",ls:{type:0===r?"live-pusher":"live-player",vid:String(this.vid),app_id:this.appId,version:this.sdk_version,ip:this.ip,wx_version:null===(t=this.systemInfo)||void 0===t?void 0:t.version,wx_basic_version:null===(n=this.systemInfo)||void 0===n?void 0:n.SDKVersion},vs:{videoBitrate:String(null==o?void 0:o.videoBitrate),audioBitrate:String(null==o?void 0:o.audioBitrate),videoFPS:String(null==o?void 0:o.videoFPS),videoGOP:String(null==o?void 0:o.videoGOP),netSpeed:String(null==o?void 0:o.netSpeed),netQualityLevel:String(null==o?void 0:o.netQualityLevel),netJitter:String(null==o?void 0:o.netJitter)}},this.netStatusPts.push(s),10!==this.netStatusPts.length){e.next=11;break}return a=Date.now(),c=this.netStatusPts.splice(0,10),l={pts:c,sign:h()("src=miniapp_sdk&ts=".concat(a)),src:"miniapp_sdk",ts:a},e.next=11,this.request({body:l,url:this.url});case 11:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"report",value:(o=(0,e.Z)(i().mark((function e(t){var n,r,o,s,a,l,u,p,d,y,_,g=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=g.length>1&&void 0!==g[1]?g[1]:"",s=g.length>2&&void 0!==g[2]?g[2]:"",a=g.length>3&&void 0!==g[3]?g[3]:"",l=g.length>4&&void 0!==g[4]?g[4]:{},this.vid||(this.vid=O().vid),u={m:"online_user"===t?"online_user":"event",ls:f({vid:String(this.vid),app_id:this.appId,version:this.sdk_version,ip:this.ip,wx_version:null===(n=this.systemInfo)||void 0===n?void 0:n.version,wx_basic_version:null===(r=this.systemInfo)||void 0===r?void 0:r.SDKVersion},l),vs:{count:1}},"online_user"!==t&&((p={event:t,result:"success"===o?"1":"0",err_code:s.toString()}).message="string"==typeof a?a:JSON.stringify(a),c(u.ls,p)),this.pts.push(u),10!==this.pts.length){e.next=14;break}return d=this.pts.splice(0,10),y=Date.now(),_={pts:d,sign:h()("src=miniapp_sdk&ts=".concat(y)),src:"miniapp_sdk",ts:y},e.next=14,this.request({body:_,url:this.url});case 14:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"request",value:function(e){return new Promise((function(t,n){wx.request({url:e.url,data:e.body,header:{"content-type":"application/json"},method:"POST",success:function(e){200===e.statusCode?t(e):a.default.error("grafana report fail: ".concat(e.statusCode))},fail:function(e){a.default.error("grafana report fail",JSON.stringify(e)),n(e)}})}))}}]),r}(),v=function(){function e(){(0,t.Z)(this,e),this.ts=-1}return(0,n.Z)(e,[{key:"start",value:function(){return this.ts=(new Date).getTime(),this}},{key:"elapse",value:function(){if(-1===this.ts)throw new Error("timer not started");return(new Date).getTime()-this.ts}}],[{key:"create",value:function(){return new e}}]),e}(),m=__webpack_require__(483),w={ip:"",vid:""};function O(){return w}var E=["https://uap-ap-web-1.agora.io/api/v1","https://uap-ap-web-3.agora.io/api/v1","https://uap-ap-web-2.agoraio.cn/api/v1","https://uap-ap-web-4.agoraio.cn/api/v1"],b="connected",R="disconnected";const S=function(){function e(n,r){(0,t.Z)(this,e),this.serverlist=[],this.option=n,this.index=0,this.isInit=!0,this.state=R,this.hasInvokeClose=!1,this.emitter=r,this.on=this.emitter.on,this.off=this.emitter.off,this.emit=this.emitter.emit}return(0,n.Z)(e,[{key:"connect",value:function(){var e=this,t=this.option.grafanaReport;this.state!==R&&this.close(),function(e){var t=e.grafanaReport,n=e.argusReport,r={command:"convergeAllocateEdge",sid:e.sid,appId:e.appId,token:e.appId,uid:e.uid+"",cname:e.channel,ts:Math.floor(Date.now()/1e3),version:s.VERSION,seq:0,requestId:1};return new Promise((function(i,o){var s=0,c=v.create().start(),l=function(r,i){n.reportJoinCS(e.channel,e.uid,!1,c.elapse(),JSON.stringify(r),i,null),s++,a.default.error("get server list failed, counter:".concat(s," url:").concat(i," "),JSON.stringify(r)),4===s&&(t&&t.report("get_server_list",_,null==r?void 0:r.code,null==r?void 0:r.reason),o(r))},u=function(o){wx.request({url:o,data:{service_name:"miniapp",json_body:JSON.stringify(r)},header:{"content-type":"application/json","X-Packet-URI":61,"X-Packet-Service-Type":0},method:"POST",success:function(r){var s,u,p=r.data;if(r.profile?(s=r.profile.peerIP,w.ip=s):a.default.info("skip user IP report!"),200!==r.statusCode){var h="choose server fail";l({code:r.statusCode,reason:h},o),t&&t.report("choose_server",_,r.statusCode,h)}else{var d=c.elapse(),f=(0,m.transformElapseStr)(d),g=JSON.parse(p.json_body);u=g.vid,w.vid=u;var v=function(e){if(void 0!==e)return e.map((function(e){var t=e.address.split("."),n=t.length;return"wss://miniapp.agoraio.cn/".concat(t[n-4],"-").concat(t[n-3],"-").concat(t[n-2],"-").concat(t[n-1],"/api")}));a.default.error("miniapp service is not enabled for this AppID")}(g.servers);n.reportJoinCS(e.channel,e.uid,!0,d,null,o,v.join(",")),t.report("choose_server",y,"","",{elapse:f}),a.default.info("get server list request success,url:".concat(o,",time:").concat(d,"ms,elapse:").concat(f,",serverlist:").concat(JSON.stringify(v))),i({serverlist:v,url:o})}},fail:function(e){var n=e.errMsg||"choose server fail";l({code:901,reason:n},o),t&&t.report("choose_server",_,901,n)}})};e.apUrl?u(e.apUrl):E.map((function(e,t){u(e)}))}))}(this.option).then((function(t){var n=t.serverlist,r=t.url;a.default.info("websocket get server list final success, url:".concat(r,",serverlist:").concat(JSON.stringify(n))),e.index=0,e.serverlist=n,e.option&&e.option.servers&&(e.serverlist=e.option.servers),e.connectWorker(e.serverlist[e.index])})).catch((function(n){a.default.error("websocket connect failed in get server list ".concat(JSON.stringify(n))),t&&t.report("wxsocket_connect",_,null==n?void 0:n.code,null==n?void 0:n.reason),e.emit&&e.emit("socketError",n)}))}},{key:"connectWorker",value:function(){var e=this;this.state="connecting";var t=this.serverlist[this.index];a.default.info("websocket connect server: ",t);var n=this.option,r=(n.sid,n.channel),i=n.uid,o=n.argusReport,s=n.grafanaReport,c=v.create().start();this.ws=wx.connectSocket({url:t,fail:function(n){var l=JSON.stringify(n);a.default.error("websocket connect worker failed url:".concat(t," "),l),o&&o.reportConnectWS(r,i,!1,c.elapse(),l,null,t),s&&s.report("wxsocket_connect_worker",_,n.statusCode,l,{retry:String(e.index)})},success:function(n){var l=c.elapse(),u=(0,m.transformElapseStr)(l);if(a.default.info("websocket connect worker success,url:".concat(t,",time:").concat(l,"ms,elapse:").concat(u)),e.option.grafanaReport){var p=(0,m.getServerUrlIp)(t);e.option.grafanaReport.setOptions({ip:p})}o&&o.reportConnectWS(r,i,!0,l,null,null,t),s&&s.report("wxsocket_connect_worker",y,"","".concat(t),{elapse:u,retry:String(e.index)})}}),this.ws.onOpen(this._onopen.bind(this)),this.ws.onMessage(this._onmessage.bind(this)),this.ws.onError((function(e){a.default.error("websocket onerror: "+JSON.stringify(e)),o&&o.reportConnectWS(r,i,!1,c.elapse(),JSON.stringify(e),null,t),s&&s.report("wxsocket_connect_worker_on_error",_,"",JSON.stringify(e))})),this.establishWSTimeoutTimer=setTimeout((function(){e.state!==b&&e.connectNextWorker()}),5e3)}},{key:"connectNextWorker",value:function(){var e=this,t=this.option.grafanaReport;this.close().then((function(n){if(a.default.info("websocket connect next worker current:".concat(e.index," total:").concat(e.serverlist.length)),e.index>=e.serverlist.length-1){var r={code:905,reason:"connect websocket failed"};a.default.error("websocket connect next worker failed, all serverlist tried. ",JSON.stringify(r)),e.emit&&e.emit("socketError",{code:r.code,reason:r.reason,wsurl:JSON.stringify(e.serverlist)}),t&&t.report("wxsocket_connect_next_worker",_,r.code,r.reason)}else e.index++,e.connectWorker()}))}},{key:"_onopen",value:function(){a.default.info("websocket onopen"),clearTimeout(this.establishWSTimeoutTimer),this.state=b,this.isInit=!1,this.hasInvokeClose?a.default.info("websocket already invoke ws.Close, will not throw onopen event"):(this.ws.onClose(this._onclose.bind(this)),this.emit&&this.emit("onopen"))}},{key:"_onclose",value:function(e){a.default.info("websocket onclose:"+JSON.stringify(e)),this.emitter.emit("_wsClose"),clearTimeout(this.establishWSTimeoutTimer),this.state=R,e&&"close"==e.reason||this.hasInvokeClose||(this.isInit?this.connectNextWorker():this.emit&&this.emit("onclose",e))}},{key:"_onmessage",value:function(e){if(!this.hasInvokeClose){var t=JSON.parse(null==e?void 0:e.data)||{};"pong"!==(null==t?void 0:t.command)&&a.default.info("websocket receive message: ",JSON.stringify(e)),this.isConnected()&&this.emit&&this.emit("onmessage",e)}}},{key:"isConnected",value:function(){return this.state===b}},{key:"sendMessage",value:function(e){var t=JSON.parse(e)||{};"ping"!==(null==t?void 0:t.command)&&a.default.info("websocket send message: ",e),this.isConnected()&&this.ws&&this.ws.send({data:e})}},{key:"_checkServerList",value:function(e){return e instanceof Array!=0&&0!=e.length}},{key:"destroy",value:function(e){var t=this;this.state!==R&&this.close(),this.on("_wsClose",(function n(){t.off("_wsClose",n),t.serverlist=null,t.ws=null,t.emitter=null,t.on=null,t.off=null,t.emit=null,e&&e()}))}},{key:"close",value:function(){var e=this;return new Promise((function(t,n){return e.state==R?t():(clearTimeout(e.establishWSTimeoutTimer),e.hasInvokeClose=!0,e.state=R,e.ws?void e.ws.close({reason:"close",success:function(){a.default.info("websocket close success"),t()},fail:function(t){a.default.error("websocket close failed: ",JSON.stringify(t));var r=e.option,i=(r.sid,r.channel),o=r.uid,s=r.argusReport,c=r.grafanaReport;n();var l=e.serverlist[e.index];s&&s.reportConnectWS(i,o,!1,0,JSON.stringify(t),null,l),c&&c.report("wxsocket_close",_,"",JSON.stringify(t))},complete:function(){e.ws=null}}):t())}))}}]),e}(),k=function(){function e(n){(0,t.Z)(this,e),this.appId=n.appId,this.channel=n.channel,this.uid=n.uid+"",this.sid=n.sid,this.seq=1,this.requestId=2}return(0,n.Z)(e,[{key:"setSid",value:function(e){this.sid=e}},{key:"_getWorkerManagerMsg",value:function(){return{appId:this.appId,cname:this.channel,uid:this.uid,sid:this.sid,sdkVersion:s.VERSION,seq:++this.seq,requestId:++this.requestId,ts:Math.floor(Date.now()/1e3)}}},{key:"send",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest=e,t}},{key:"updatePushUrl",value:function(){var e=this._getWorkerManagerMsg();return e.clientRequest={action:"update_url",role:"publish",uid:+this.uid},e}},{key:"ping",value:function(){return{command:"ping",requestId:++this.requestId,appId:this.appId,cname:this.channel,uid:this.uid+"",sid:this.sid,ts:Math.floor(Date.now()/1e3)}}},{key:"ping2",value:function(){var e=this._getWorkerManagerMsg();return e.clientRequest={action:"ping"},e}},{key:"setRole",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest={action:"set_role",role:e},t}},{key:"rejoin",value:function(e,t,n,r,i,o,s,a,c){var l=this._getWorkerManagerMsg();return l.clientRequest={action:"join",role:o,appId:e,customAudioCodec:a,key_vocs:r||e,key_vos:r||e,channel_name:t,uid:n+"",known_speakers:i,clientType:"undefined"==typeof qq?"wechat":"qq",audio_only:s,uidType:c},l}},{key:"join",value:function(e,t,n,r,i,o,a,c,l,u){var p=this._getWorkerManagerMsg();return p.clientRequest={action:"join",role:i,appId:e,customAudioCodec:l,key_vocs:r||e,key_vos:r||e,channel_name:t,uid:n+"",vid:O().vid.toString(),device:o,os:a,version:s.SDK_VERSION,clientType:"undefined"==typeof qq?"wechat":"qq",audio_only:c,uidType:u},p}},{key:"muteLocal",value:function(e,t){var n=this._getWorkerManagerMsg();return n.clientRequest={action:"mute_local",uid:+e,target:t,mute:!0},n}},{key:"unmuteLocal",value:function(e,t){var n=this._getWorkerManagerMsg();return n.clientRequest={action:"mute_local",uid:+e,target:t,mute:!1},n}},{key:"mute",value:function(e,t){var n=this._getWorkerManagerMsg();return n.clientRequest={action:"mute",uid:+e,target:t},n}},{key:"unmute",value:function(e,t){var n=this._getWorkerManagerMsg();return n.clientRequest={action:"unmute",uid:+e,target:t},n}},{key:"publish",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest={action:"publish",uid:+e},t}},{key:"unpublish",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest={action:"unpublish",uid:+e},t}},{key:"subscribe",value:function(e,t){var n=this._getWorkerManagerMsg();return n.clientRequest={action:"subscribe",uid:+e,options:{audio:t.audio,video:t.video}},n}},{key:"unsubscribe",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest={action:"unsubscribe",uid:[+e]},t}},{key:"setRemoteVideoStreamType",value:function(e,t){var n=this._getWorkerManagerMsg();return n.clientRequest={action:"set_remote_stream_type",uid:+e,type:t},n}},{key:"renewToken",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest={action:"update_key",key_vos:e},t}},{key:"leave",value:function(e){var t=this._getWorkerManagerMsg();return t.clientRequest={action:"leave",uid:+e},t}}]),e}();function P(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map((function(e){e(n)})),(r=e.get("*"))&&r.slice().map((function(e){e(t,n)}))}}}var I=__webpack_require__(500),A=__webpack_require__.n(I);const T=function(){function r(e,n){(0,t.Z)(this,r),this.appId=e.appId,this.channel=e.channel,this.uid=e.uid,this.sid=e.sid,this.role=e.role,this.channelKey=e.channelKey,this.clientId="client",this.option=e,this.timers=new Set,this.grafanaReport=e.grafanaReport,this.argusReport=e.argusReport,this.audioCodec=e.audioCodec,this.uidType=e.uidType,this.clientEmitter=n,this.emitter=new P,this.on=this.emitter.on,this.off=this.emitter.off,this.emit=this.emitter.emit,this.join=this.join.bind(this),this.msgManager=new k(e)}var o,s,c;return(0,n.Z)(r,[{key:"connect",value:function(){var e=this;return new Promise((function(t,n){e.ws=new S(e.option,e.emitter),e.ws.connect(),e.on("onmessage",e._onMessage.bind(e)),e.on("socketError",(function(t){n(t),a.default.error("worker socket error: ",JSON.stringify(t)),e.grafanaReport&&e.grafanaReport.report("worker_connect_socket_error",_,"",JSON.stringify(t))})),e.on("onopen",(function n(){e.off&&e.off("onopen",n),e._ping(),t()})),e.on("onclose",(function(t){a.default.error("worker on close: ",JSON.stringify(t)),e.ws=null,e.clientEmitter.emit("error",{code:904,reason:"websocket disconnected"}),e.grafanaReport&&e.grafanaReport.report("worker_connect_on_close",_,"",JSON.stringify(t))}))}))}},{key:"_onMessage",value:function(e){if(e&&e.data){var t=JSON.parse(e.data);if(t&&"pong"!==t.command&&(a.default.info("worker onmessage: ",t),this.argusReport.reportServerEvent(this.channel,this.uid,!0,0,"serverEvent",t)),t.requestId&&this.emit(t.requestId,t),"serverStatus"===t.command){if(t.code&&200!==t.code){if(this.grafanaReport&&this.grafanaReport.report("worker_on_message",_,t.code,null==t?void 0:t.reason),503===t.code)return;a.default.error("worker onmessage error: ",JSON.stringify(t)),this.clientEmitter.emit("error",{code:t.code,reason:t.reason||"server error"})}if(t.serverStatus){a.default.info("Receive message from server: ".concat(JSON.stringify(t.serverStatus)));var n=t.serverStatus.action;if("audio-mute"==n)return t.serverStatus.mute?this.clientEmitter.emit("mute-audio",{uid:t.serverStatus.uid}):this.clientEmitter.emit("unmute-audio",{uid:t.serverStatus.uid});if("video-mute"==n)return t.serverStatus.mute?this.clientEmitter.emit("mute-video",{uid:t.serverStatus.uid}):this.clientEmitter.emit("unmute-video",{uid:t.serverStatus.uid});if("key-expired"===n)return this.clientEmitter.emit("token-privilege-did-expire");if("key-will-expire"===n)return this.clientEmitter.emit("token-privilege-will-expire");if("client-is-banned-by-server"===n)return this.clientEmitter.emit("client-banned");this.clientEmitter.emit(n,t.serverStatus)}}}}},{key:"_sendMessage",value:function(e){var t=this;if(this.ws)return new Promise((function(n,r){if(!t.isWSConnected())return r({code:904,reason:"websocket disconnected",wsurl:t.getWSUrl()});"ping"!==e.command&&a.default.info("worker send message: ",e);var i,o=e?e.requestId:null,s=function e(s){if(t.ws)return t.off(o,e),clearTimeout(i),t.timers.delete(i),200==s.code?n(s.serverResponse):r({code:s.code,reason:s.msg||s.reason,serverResponse:s.serverResponse,wsurl:t.getWSUrl()})};if(!o)return r({code:902,reason:"no requestid"});t.ws.sendMessage(JSON.stringify(e)),t.on(o,s),i=setTimeout((function(){return s({code:903,reason:"time out"})}),1e4),t.timers.add(i)}))}},{key:"_ping",value:function(){var e=this;this.pingTimer=setInterval((function(){e.ws.sendMessage(JSON.stringify(e.msgManager.ping()))}),3e3)}},{key:"setRole",value:function(e){return this._sendMessage(this.msgManager.setRole(e))}},{key:"rejoin",value:function(e,t){return this._sendMessage(this.msgManager.rejoin(this.appId,this.channel,this.uid,this.channelKey,e,this.role,t,this.audioCodec,this.uidType))}},{key:"join",value:function(e,t,n){return this._sendMessage(this.msgManager.join(this.appId,this.channel,this.uid,this.channelKey,this.role,e,t,n,this.audioCodec,this.uidType))}},{key:"send",value:function(e){return this._sendMessage(this.msgManager.send(e))}},{key:"updatePushUrl",value:function(){return this._sendMessage(this.msgManager.updatePushUrl())}},{key:"publish",value:function(){return this._sendMessage(this.msgManager.publish(this.uid))}},{key:"unpublish",value:function(){return this._sendMessage(this.msgManager.unpublish(this.uid))}},{key:"subscribe",value:function(e,t){return this._sendMessage(this.msgManager.subscribe(e,t))}},{key:"unsubscribe",value:function(e){return this._sendMessage(this.msgManager.unsubscribe(e))}},{key:"setRemoteVideoStreamType",value:function(e,t){return this._sendMessage(this.msgManager.setRemoteVideoStreamType(e,t))}},{key:"mute",value:function(e,t){return this._sendMessage(this.msgManager.mute(e,t))}},{key:"unmute",value:function(e,t){return this._sendMessage(this.msgManager.unmute(e,t))}},{key:"muteLocal",value:function(e){return this._sendMessage(this.msgManager.muteLocal(this.uid,e))}},{key:"unmuteLocal",value:function(e){return this._sendMessage(this.msgManager.unmuteLocal(this.uid,e))}},{key:"renewToken",value:function(e){return this._sendMessage(this.msgManager.renewToken(e))}},{key:"leave",value:function(){return this._sendMessage(this.msgManager.leave(this.uid))}},{key:"isWSConnected",value:function(){return!!this.ws&&this.ws.isConnected()}},{key:"getWSUrl",value:function(){return this.ws?this.ws.serverlist[this.ws.index]:""}},{key:"destroy",value:function(){var e=this;return new Promise((function(t,n){clearInterval(e.pingTimer),e.timers.size&&(e.timers.forEach((function(e){clearInterval(e)})),e.timers.clear()),e.ws?e.ws.destroy((function(){e.ws=null,e.emitter=null,e.on=null,e.off=null,e.emit=null,t()})):t()}))}},{key:"startChannelMediaRelay",value:(c=(0,e.Z)(i().mark((function e(t){var n,r,o,s,c,l=this;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.channelMediaRelayController){e.next=2;break}throw new I.ChannelMediaError("RELAY_ALREADY_START","",I.CHANNEL_MEDIA_RELAY_ERROR.RELAY_ALREADY_START);case 2:return n=function(e){l.clientEmitter.emit("channel-media-relay-event",{code:e})},r=function(e,t,n){e===I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE&&t===I.CHANNEL_MEDIA_RELAY_ERROR.SERVER_CONNECTION_LOST&&(l.channelMediaRelayController.dispose(),l.channelMediaRelayController=null),l.clientEmitter.emit("channel-media-relay-state",{state:e,code:t,data:n})},o={token:this.appId,appId:this.appId,cname:this.channel,uid:this.uid,sid:this.sid,clientId:this.clientId},this.channelMediaRelayController=new(A())(o,this.clientId),this.channelMediaRelayController.on("event",n),this.channelMediaRelayController.on("state",r),e.prev=8,e.next=11,this.channelMediaRelayController.startChannelMediaRelay(t);case 11:e.next=23;break;case 13:throw e.prev=13,e.t0=e.catch(8),a.default.error("[".concat(this.clientId,"] startChannelMediaRelay exception: ").concat(JSON.stringify(e.t0))),s=I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,"",c=e.t0 instanceof I.ChannelMediaError?"SetSourceChannelStatus"===e.t0.data||e.t0.data&&e.t0.data.serverResponse&&"SetSourceChannel"===e.t0.data.serverResponse.command?"FAILED_JOIN_SRC":"SetDestChannelStatus"===e.t0.data||e.t0.data&&e.t0.data.serverResponse&&"SetDestChannel"===e.t0.data.serverResponse.command?"FAILED_JOIN_DEST":e.t0.data&&e.t0.data.serverResponse&&"StartPacketTransfer"===e.t0.data.serverResponse.command?"FAILED_PACKET_SENT_TO_DEST":e.t0.message===I.CHANNEL_MEDIA_ERROR.REQUEST_TIMEOUT||e.t0.message===I.CHANNEL_MEDIA_ERROR.WAIT_STATUS_TIMEOUT?"SERVER_NO_RESPONSE":e.t0.message===I.CHANNEL_MEDIA_ERROR.REQUEST_FAILED||e.t0.message===I.CHANNEL_MEDIA_ERROR.WAIT_STATUS_ERROR?"SERVER_ERROR_RESPONSE":e.t0.message===I.CHANNEL_MEDIA_ERROR.AP_REQUEST_TIMEOUT?"NO_RESOURCE_AVAILABLE":e.t0.message===I.CHANNEL_MEDIA_ERROR.WS_ABORT||e.t0.message===I.CHANNEL_MEDIA_ERROR.AP_REQUEST_ABORT?"OPERATION_ABORT":"INTERNAL_ERROR":"INTERNAL_ERROR",this.clientEmitter.emit("channel-media-relay-state",{state:s,code:I.CHANNEL_MEDIA_RELAY_ERROR[c]}),this.channelMediaRelayController&&(this.channelMediaRelayController.dispose(),this.channelMediaConfig=null,this.channelMediaRelayController=null),this.clientEmitter.emit("channel-media-relay-state",{state:I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE}),new I.ChannelMediaError(c,null,I.CHANNEL_MEDIA_RELAY_ERROR[c]);case 23:this.clientEmitter.emit("channel-media-relay-state",{state:I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_RUNNING,code:I.CHANNEL_MEDIA_RELAY_ERROR.RELAY_OK}),this.channelMediaConfig=t;case 25:case"end":return e.stop()}}),e,this,[[8,13]])}))),function(e){return c.apply(this,arguments)})},{key:"updateChannelMediaRelay",value:(s=(0,e.Z)(i().mark((function e(t){var n,r;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.channelMediaRelayController){e.next=2;break}throw new I.ChannelMediaError("RELAY_NOT_START",null,I.CHANNEL_MEDIA_RELAY_ERROR.RELAY_NOT_START);case 2:return e.prev=2,e.next=5,this.channelMediaRelayController.updateChannelMediaRelay(t);case 5:e.next=18;break;case 7:throw e.prev=7,e.t0=e.catch(2),a.default.debug("[".concat(this.clientId,"] updateChannelMediaRelay exception: ").concat(JSON.stringify(e.t0))),n=I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,"",r=e.t0 instanceof I.ChannelMediaError?e.t0.message===I.CHANNEL_MEDIA_ERROR.REQUEST_TIMEOUT||e.t0.message===I.CHANNEL_MEDIA_ERROR.WAIT_STATUS_TIMEOUT?"SERVER_NO_RESPONSE":e.t0.message===I.CHANNEL_MEDIA_ERROR.REQUEST_FAILED||e.t0.message===I.CHANNEL_MEDIA_ERROR.WAIT_STATUS_ERROR?"SERVER_ERROR_RESPONSE":e.t0.message===I.CHANNEL_MEDIA_ERROR.WS_ABORT||e.t0.message===I.CHANNEL_MEDIA_ERROR.AP_REQUEST_ABORT?"OPERATION_ABORT":"INTERNAL_ERROR":"INTERNAL_ERROR",this.clientEmitter.emit("channel-media-relay-event",{code:I.CHANNEL_MEDIA_RELAY_EVENT.PACKET_UPDATE_DEST_CHANNEL_REFUSED}),this.clientEmitter.emit("channel-media-relay-state",{state:n,code:I.CHANNEL_MEDIA_RELAY_ERROR[r]}),this.channelMediaRelayController&&(this.channelMediaRelayController.dispose(),this.channelMediaConfig=null,this.channelMediaRelayController=null),this.clientEmitter.emit("channel-media-relay-state",{state:I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE}),new I.ChannelMediaError(r,null,I.CHANNEL_MEDIA_RELAY_ERROR[r]);case 18:this.channelMediaConfig=t;case 19:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return s.apply(this,arguments)})},{key:"stopChannelMediaRelay",value:(o=(0,e.Z)(i().mark((function e(){var t,n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.channelMediaRelayController){e.next=2;break}throw new I.ChannelMediaError("RELAY_NOT_START",null,I.CHANNEL_MEDIA_RELAY_ERROR.RELAY_NOT_START);case 2:return e.prev=2,e.next=5,this.channelMediaRelayController.stopChannelMediaRelay();case 5:e.next=17;break;case 7:throw e.prev=7,e.t0=e.catch(2),a.default.debug("[".concat(this.clientId,"] stopChannelMediaRelay exception: ").concat(JSON.stringify(e.t0))),t=I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_FAILURE,"",n=e.t0 instanceof I.ChannelMediaError?e.t0.message===I.CHANNEL_MEDIA_ERROR.REQUEST_TIMEOUT||e.t0.message===I.CHANNEL_MEDIA_ERROR.WAIT_STATUS_TIMEOUT?"SERVER_NO_RESPONSE":e.t0.message===I.CHANNEL_MEDIA_ERROR.REQUEST_FAILED||e.t0.message===I.CHANNEL_MEDIA_ERROR.WAIT_STATUS_ERROR?"SERVER_ERROR_RESPONSE":"INTERNAL_ERROR":"INTERNAL_ERROR",this.clientEmitter.emit("channel-media-relay-state",{state:t,code:I.CHANNEL_MEDIA_RELAY_ERROR[n]}),this.channelMediaRelayController&&(this.channelMediaRelayController.dispose(),this.channelMediaConfig=null,this.channelMediaRelayController=null),this.emit("channel-media-relay-state",{state:I.CHANNEL_MEDIA_RELAY_STATE.RELAY_STATE_IDLE}),new I.ChannelMediaError(n,null,I.CHANNEL_MEDIA_RELAY_ERROR[n]);case 17:this.channelMediaConfig=null,this.channelMediaRelayController=null;case 19:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(){return o.apply(this,arguments)})}]),r}();var C={videoBitrate:"Miniapp_SDK_Pusher_Video_Bitrate",audioBitrate:"Miniapp_SDK_Pusher_Audio_Bitrate",videoFPS:"Miniapp_SDK_Pusher_Video_FPS",videoGOP:"Miniapp_SDK_Pusher_Video_GOP",netSpeed:"Miniapp_SDK_Pusher_Net_Speed",videoCache:"Miniapp_SDK_Pusher_Video_Cache",audioCache:"Miniapp_SDK_Pusher_Audio_Cache",videoWidth:"Miniapp_SDK_Pusher_Video_Width",videoHeight:"Miniapp_SDK_Pusher_Video_Height",netJitter:"Miniapp_SDK_Pusher_Net_Jitter",netQualityLevel:"Miniapp_SDK_Pusher_Net_QualityLevel"},N={videoBitrate:"Miniapp_SDK_Player_Video_Bitrate",audioBitrate:"Miniapp_SDK_Player_Audio_Bitrate",videoFPS:"Miniapp_SDK_Player_Video_FPS",videoGOP:"Miniapp_SDK_Player_Video_GOP",netSpeed:"Miniapp_SDK_Player_Net_Speed",videoCache:"Miniapp_SDK_Player_Video_Cache",audioCache:"Miniapp_SDK_Player_Audio_Cache",vDecCacheSize:"Miniapp_SDK_Player_V_Dec_Cache_Size",vSumCacheSize:"Miniapp_SDK_Player_V_Sum_Cache_Size",avPlayInterval:"Miniapp_SDK_Player_AV_Play_Interval",avRecvInterval:"Miniapp_SDK_Player_AV_Recv_Interval",audioCacheThreshold:"Miniapp_SDK_Player_Audio_Cache_Threshold",videoWidth:"Miniapp_SDK_Player_Video_Width",videoHeight:"Miniapp_SDK_Player_Video_Height",netJitter:"Miniapp_SDK_Player_Net_Jitter",netQualityLevel:"Miniapp_SDK_Player_Net_QualityLevel"},L=__webpack_require__(699),M=__webpack_require__.n(L),j=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;if("function"!=typeof e)throw Error("request must be function");var n=function(e,t){!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero")}(t);var n=[],r=[];return{concurrency:t,push:function(e,t){var r=this;n.push({task:e,callback:t}),setTimeout((function(){r.process()}),0)},process:function(){for(var e=this,t=function(){var t,i=n.shift();r.push(i),function(e,t){e(t)}(i.task,(t=function(){e.pull(i),"function"==typeof i.callback&&i.callback.apply(i,arguments),e.process()},function(){if(null===t)throw new Error("Callback was already called");var e=t;return t=null,e.apply(void 0,arguments)}))};this.concurrency>r.length&&n.length;)t()},pull:function(e){var t=r.indexOf(e);-1!==t&&r.splice(t,1)}}}(0,t);return function(t){n.push((function(n){var r=t.complete;t.complete=function(){n(),"function"==typeof r&&r.apply(void 0,arguments)},e(t)}))}}(wx.request,2);function D(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function x(e){for(var t=1;t4&&void 0!==arguments[4]&&arguments[4],c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,l=arguments.length>6?arguments[6]:void 0,u=arguments.length>7?arguments[7]:void 0;if("function"==typeof s){var p=l,h=u;l=s,u=c,s=p||!1,c=h||0}return new Promise((function(p,h){if(i._dealSid(),i.grafanaReport.onlineUser(),i.worker)return i._startNetworkJudge(),l&&l(),p();if(e){if("string"!=typeof e||"null"===e.toLowerCase()){var d=new Error("Invalid channelKey");return a.default.error("client rejoin channel failed: ".concat(d.message)),u&&u(d),void h(d)}}else e=i.appId;if(!t||"string"!=typeof t||"null"===t.toLowerCase()||t.length>128){var f=new Error("Invalid channel");return a.default.error("client rejoin channel failed: ".concat(f.message)),u&&u(f),void h(f)}if("boolean"!=typeof s){var g=new Error("isAudioOnly should be boolean");return a.default.error("client rejoin channel failed: ".concat(g.message)),u&&u(g),h(g),void i.grafanaReport.report("join",_,"",g.message)}if(1==c){if(!n.trim()){var w=new Error("uid empty");return a.default.error("client rejoin channel failed: ".concat(w.message)),u&&u(w),void h(w)}i.uid=n}else if(i.uid=n||(0,o.random)(1e7),i.uid=Number.parseInt(i.uid),!(0,o.is32Uint)(i.uid)){var O=new Error("Invalid uid type");return a.default.error("client rejoin channel failed: ".concat(O.message)),u&&u(O),void h(O)}i.channel=t,i.worker=new T({appId:i.appId,channel:i.channel,uid:i.uid,sid:i.sid,role:i.role,servers:i.servers,apUrl:i.apUrl,channelKey:e,grafanaReport:i.grafanaReport,argusReport:i.argusReport,audioCodec:i.audioCodec,uidType:c},i.emitter);var E=v.create().start();i.worker.connect().then((function(){return i.worker.rejoin(r,s)})).then((function(e){setTimeout((function(){a.default.info("client rejoin channel success"),l&&l(i.uid),p(i.uid),i.argusReport.reportRejoin(i.channel,i.uid,!0,E.elapse(),null,i.appId,i.worker&&i.worker.getWSUrl()),i.grafanaReport.report("join",y),i._startNetworkJudge()}),1),e&&e.uid&&(i.uid=e.uid,i.worker.uid=e.uid)})).catch((function(e){i.destroy(),a.default.error("client rejoin channel failed: ".concat((0,m.stringifyErr)(e))),u&&u(e),h(e),i.argusReport.reportRejoin(i.channel,i.uid,!1,E.elapse(),JSON.stringify(e),i.appId,i.worker&&i.worker.getWSUrl()),i.grafanaReport.report("join",_,e.code,null==e?void 0:e.reason)}))}))}},{key:"join",value:function(e,t,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,c=arguments.length>5?arguments[5]:void 0,l=arguments.length>6?arguments[6]:void 0;if("function"==typeof i){var u=c,p=l;c=i,l=s,i=u||!1,s=p||0}return new Promise((function(u,p){if(r._dealSid(),r.grafanaReport.onlineUser(),r.worker)return a.default.info("client join channel success"),c&&c(),r._startNetworkJudge(),u();if(e){if("string"!=typeof e||"null"===e.toLowerCase()){var h=new Error("Invalid channelKey");return a.default.error("client join channel failed: ".concat(h.message)),l&&l(h),p(h),void r.grafanaReport.report("join",_,"",h.message)}}else e=r.appId;if(!t||"string"!=typeof t||"null"===t.toLowerCase()||t.length>128){var d=new Error("Invalid channel");return a.default.error("client join channel failed: ".concat(d.message)),l&&l(d),p(d),void r.grafanaReport.report("join",_,"",d.message)}if("boolean"!=typeof i){var f=new Error("isAudioOnly should be boolean");return a.default.error("client join channel failed: ".concat(f.message)),l&&l(f),p(f),void r.grafanaReport.report("join",_,"",f.message)}if(1==s){if(!n.trim()){var g=new Error("uid empty");return a.default.error("client join channel failed: ".concat(g.message)),l&&l(g),p(g),void r.grafanaReport.report("join",_,"",g.message)}r.uid=n}else if(r.uid=n||(0,o.random)(1e7),r.uid=Number.parseInt(r.uid),!(0,o.is32Uint)(r.uid)){var w=new Error("Invalid uid type");return a.default.error("client join channel failed: ".concat(w.message)),l&&l(w),p(w),void r.grafanaReport.report("join",_,"",w.message)}r.channel=t,r.worker=new T({appId:r.appId,channel:r.channel,uid:r.uid,sid:r.sid,role:r.role,servers:r.servers,apUrl:r.apUrl,channelKey:e,grafanaReport:r.grafanaReport,argusReport:r.argusReport,audioCodec:r.audioCodec,uidType:s},r.emitter);var O=v.create().start();r.worker.connect().then((function(){return r.worker.join(r.systemInfo.model,r.systemInfo.system,i)})).then((function(e){var t=O.elapse(),n=(0,m.transformElapseStr)(t);setTimeout((function(){a.default.info("client join channel success,time:".concat(t,"ms,elapse:").concat(n)),c&&c(r.uid),u(r.uid),r._startNetworkJudge(),r.argusReport.reportJoin(r.channel,r.uid,!0,t),r.grafanaReport.report("join",y,"","",{elapse:n})}),1),e&&e.uid&&(r.uid=e.uid,r.worker.uid=e.uid)})).catch((function(e){r.destroy(),a.default.error("client join channel failed: ".concat((0,m.stringifyErr)(e))),l&&l(e),p(e),r.argusReport.reportJoin(r.channel,r.uid,!1,O.elapse(),JSON.stringify(e)),r.grafanaReport.report("join",_,null==e?void 0:e.code,null==e?void 0:e.reason)}))}))}},{key:"publish",value:function(e,t){var n=this;return new Promise((function(r,i){n._checkWorker();var o=v.create().start();n.worker.publish().then((function(t){n.pushUrl=t.url,setTimeout((function(){a.default.info("client publish url: ".concat(t.url," success")),e&&e(t.url),r(t.url),n.argusReport.reportPublish(t.url,n.channel,n.uid,!0,o.elapse()),n.grafanaReport.report("publish",y)}),1)})).catch((function(e){a.default.error("client publish failed: ".concat((0,m.stringifyErr)(e))),t&&t(e),i(e),n.argusReport.reportPublish(null,n.channel,n.uid,!1,o.elapse(),JSON.stringify(e)),n.grafanaReport.report("publish",_,e.code,null==e?void 0:e.reason)}))}))}},{key:"unpublish",value:function(e,t){var n=this;return new Promise((function(r,i){n._checkWorker();var o=v.create().start();n.worker.unpublish().then((function(t){n.pushUrl=null,setTimeout((function(){a.default.info("client unpublish success"),e&&e(),r(),n.argusReport.reportUnPublish(n.channel,n.uid,!0,o.elapse()),n.grafanaReport.report("unpublish",y)}),1)})).catch((function(e){a.default.error("client unpublish failed: ".concat((0,m.stringifyErr)(e))),t&&t(e),i(e),n.argusReport.reportUnPublish(n.channel,n.uid,!1,o.elapse(),JSON.stringify(e)),n.grafanaReport.report("unpublish",_,e.code,null==e?void 0:e.reason)}))}))}},{key:"subscribe",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0},r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;if("function"==typeof n){var o=i;i=r,r=n,n=o||{audio:!0,video:!0}}return new Promise((function(o,s){t._checkUid(e),t._checkWorker();var c=v.create().start();t.worker.subscribe(e,n).then((function(n){t.playUrls.set(e,n.url),setTimeout((function(){a.default.info("client stream ".concat(e," subscribed successful")),r&&r(n.url,n.rotation),o({url:n.url,rotation:n.rotation}),t.argusReport.reportSubscribe(n.url,e,t.channel,t.uid,!0,c.elapse()),t.grafanaReport.report("subscribe",y)}),1)})).catch((function(n){a.default.error("client stream ".concat(e," subscribed failed: ").concat((0,m.stringifyErr)(n))),i&&i(n),s(n),t.argusReport.reportSubscribe(null,e,t.channel,t.uid,!1,c.elapse(),JSON.stringify(n)),t.grafanaReport.report("subscribe",_,n.code,null==n?void 0:n.reason)}))}))}},{key:"unsubscribe",value:function(e,t,n){var r=this;return new Promise((function(i,o){r._checkUid(e),r._checkWorker();var s=v.create().start();r.worker.unsubscribe(e).then((function(n){r.playUrls.delete(e),setTimeout((function(){a.default.info("client unsubscribe ".concat(e," successful")),t&&t(),i(),r.argusReport.reportUnSubscribe(e,r.channel,r.uid,!0,s.elapse(),null),r.grafanaReport.report("unsubscribe",y)}),1)})).catch((function(t){a.default.error("client unsubscribe ".concat(e," failed: ").concat((0,m.stringifyErr)(t))),n&&n(t),o(t),r.argusReport.reportUnSubscribe(e,r.channel,r.uid,!1,s.elapse(),JSON.stringify(t)),r.grafanaReport.report("unsubscribe",_,t.code,null==t?void 0:t.reason)}))}))}},{key:"mute",value:function(e,t,n,r){var i=this;return new Promise((function(o,s){if(i._checkUid(e),i._checkWorker(),"video"!==t&&"audio"!==t&&"all"!==t){var c=new Error('target should be "video", "audio" or "all"');return a.default.error("client mute ".concat(e," failed: ").concat(c.message)),r&&r(c),void s(c)}var l=v.create().start();i.worker.mute(e,t).then((function(r){setTimeout((function(){a.default.info("client mute ".concat(e," ").concat(t," success")),n&&n(),o(),i.argusReport.reportMuteRemote(i.channel,i.uid,!0,l.elapse(),null,e,i.targetMap[t],1),i.grafanaReport.report("mute",y)}),1)})).catch((function(n){a.default.error("client mute ".concat(e," ").concat(t," failed: ").concat((0,m.stringifyErr)(n))),r&&r(n),s(n),i.argusReport.reportMuteRemote(i.channel,i.uid,!1,l.elapse(),JSON.stringify(n),e,i.targetMap[t],1),i.grafanaReport.report("mute",_,n.code,null==n?void 0:n.reason)}))}))}},{key:"unmute",value:function(e,t,n,r){var i=this;return new Promise((function(o,s){if(i._checkUid(e),i._checkWorker(),"video"!==t&&"audio"!==t&&"all"!==t){var c=new Error('target should be "video", "audio" or "all"');return a.default.error("client unmute ".concat(e," ").concat(t," failed: ").concat(c.message)),r&&r(c),void s(c)}var l=v.create().start();i.worker.unmute(e,t).then((function(r){setTimeout((function(){a.default.info("client unmute ".concat(e," ").concat(t," success")),n&&n(),o(),i.argusReport.reportMuteRemote(i.channel,i.uid,!0,l.elapse(),null,e,i.targetMap[t],-1),i.grafanaReport.report("unmute",y)}),1)})).catch((function(n){a.default.error("client unmute ".concat(e," ").concat(t," failed: ").concat((0,m.stringifyErr)(n))),r&&r(n),s(n),i.argusReport.reportMuteRemote(i.channel,i.uid,!1,l.elapse(),JSON.stringify(n),e,i.targetMap[t],-1),i.grafanaReport.report("unmute",_,n.code,null==n?void 0:n.reason)}))}))}},{key:"setRemoteVideoStreamType",value:function(e,t,n,r){var i=this;return new Promise((function(o,s){i._checkUid(e),i._checkWorker();var c=v.create().start();i.worker.setRemoteVideoStreamType(e,t).then((function(r){setTimeout((function(){a.default.info("client set remoteVideoStreamType ".concat(e," ").concat(t," success")),n&&n(),o(),i.argusReport.reportSetRemoteStreamType(i.channel,i.uid,!0,c.elapse(),null,t),i.grafanaReport.report("set_remote_stream_type",y)}),1)})).catch((function(n){a.default.error("client set remoteVideoStreamType ".concat(e," ").concat(t," failed: ").concat((0,m.stringifyErr)(n))),r&&r(n),s(n),i.argusReport.reportSetRemoteStreamType(i.channel,i.uid,!1,c.elapse(),JSON.stringify(n),t),i.grafanaReport.report("set_remote_stream_type",_,n.code,null==n?void 0:n.reason)}))}))}},{key:"renewToken",value:function(e,t,n){var r=this;return new Promise((function(i,o){r._checkWorker();var s=v.create().start();r.worker.renewToken(e).then((function(e){setTimeout((function(){a.default.info("client renew token success"),t&&t(),i(),r.argusReport.reportRenewToken(r.channel,r.uid,!0,s.elapse(),null),r.grafanaReport.report("renew_token",y)}),1)})).catch((function(e){a.default.error("client renew token failed: ".concat((0,m.stringifyErr)(e))),n&&n(e),o(e),r.argusReport.reportRenewToken(r.channel,r.uid,!1,s.elapse(),JSON.stringify(e)),r.grafanaReport.report("renew_token",_,e.code,null==e?void 0:e.reason)}))}))}},{key:"muteLocal",value:function(e,t,n){var r=this;return new Promise((function(i,o){if(r._checkWorker(),"video"!==e&&"audio"!==e&&"all"!==e){var s=new Error('target should be "video", "audio" or "all"');return a.default.error("client muteLocal failed: ".concat(s.message)),n&&n(s),void o(s)}var c=v.create().start();r.worker.muteLocal(e).then((function(n){setTimeout((function(){a.default.info("client muteLocal ".concat(e," success")),t&&t(),i(),r.argusReport.reportMuteLocal(r.channel,r.uid,!0,c.elapse(),null,r.targetMap[e],1),r.grafanaReport.report("mute_local",y)}),1)})).catch((function(t){a.default.error("client muteLocal ".concat(e," failed: ").concat((0,m.stringifyErr)(t))),n&&n(t),o(t),r.argusReport.reportMuteLocal(r.channel,r.uid,!1,c.elapse(),JSON.stringify(t),r.targetMap[e],1),r.grafanaReport.report("mute_local",_,t.code,null==t?void 0:t.reason)}))}))}},{key:"unmuteLocal",value:function(e,t,n){var r=this;return new Promise((function(i,o){if(r._checkWorker(),"video"!==e&&"audio"!==e&&"all"!==e){var s=new Error('target should be "video", "audio" or "all"');return a.default.error("client unmuteLocal failed: ".concat(s.message)),n&&n(s),void o(s)}var c=v.create().start();r.worker.unmuteLocal(e).then((function(n){setTimeout((function(){a.default.info("client unmuteLocal ".concat(e," success")),t&&t(),i(),r.argusReport.reportMuteLocal(r.channel,r.uid,!0,c.elapse(),null,r.targetMap[e],-1),r.grafanaReport.report("unmute_local",y)}),1)})).catch((function(t){a.default.error("client unmuteLocal ".concat(e," failed: ").concat((0,m.stringifyErr)(t))),n&&n(t),o(t),r.argusReport.reportMuteLocal(r.channel,r.uid,!1,c.elapse(),JSON.stringify(t),r.targetMap[e],-1),r.grafanaReport.report("unmute_local",_,t.code,null==t?void 0:t.reason)}))}))}},{key:"leave",value:function(t,n){var r=this;return new Promise((function(o,s){if(r.worker&&r.worker.isWSConnected()){var c=v.create().start();r.worker.leave().then(function(){var n=(0,e.Z)(i().mark((function e(n){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r.argusReport.reportLeave(r.channel,r.uid,!0,c.elapse()),r.grafanaReport.report("leave",y),e.next=4,r.destroy();case 4:setTimeout((function(){a.default.info("client leave success"),t&&t(),o()}),1);case 5:case"end":return e.stop()}}),e)})));return function(e){return n.apply(this,arguments)}}()).catch((function(e){a.default.error("client leave failed: ".concat((0,m.stringifyErr)(e))),n&&n(e),s(e),r.argusReport.reportLeave(r.channel,r.uid,!1,c.elapse(),JSON.stringify(e)),r.grafanaReport.report("leave",_,e.code,null==e?void 0:e.reason)}))}else a.default.info("client leave success without worker"),t&&t(),o(),r._stopNetworkJudge(),r._resetData()}))}},{key:"isConnected",value:function(){return!(!this.worker||!this.worker.isWSConnected())}},{key:"updatePusherStateChange",value:function(e){if(this.pushUrl){var t=e.detail.code,n=e.detail.message;a.default.info("client update pusher state, code:".concat(t," message:").concat(n)),this.argusReport.reportPusherStateChange(this.channel,this.uid,t>=1002,0,this.pushUrl,t,{message:n}),1002===t?this.grafanaReport.report("pusher_state_change",y,t,n):-1307===t&&this.grafanaReport.report("pusher_state_change",_,t,n)}}},{key:"updatePlayerStateChange",value:function(e,t){var n=this.playUrls.get(Number(e));if(n){var r=t.detail.code,i=t.detail.message;if(a.default.info("client update player state, uid:".concat(e," code:").concat(r," message:").concat(i)),this.argusReport.reportPlayerStateChange(e,this.channel,this.uid,r>=2002,0,n,r,{message:i}),2003===r||-2301===r){var o=2003===r?y:_;this.grafanaReport.report("player_state_change",o,r,i)}}}},{key:"updatePusherNetStatus",value:function(e){if(this.pushUrl){var t=e.detail.info;this.argusReport.setPusherNetData(t),oe(this.grafanaReport,0,t)}}},{key:"updatePlayerNetStatus",value:function(e,t){if(this.playUrls.get(Number(e))){var n=t.detail.info;this.argusReport.setPlayerNetData(e,n),se(this.grafanaReport,1,n,e)}}},{key:"send",value:function(e,t,n){var r=this;return new Promise((function(i,o){r._checkWorker(),r.worker.send(e).then((function(e){t&&t(e),i(e)})).catch((function(e){n&&n(e),o(e)}))}))}},{key:"updatePushUrl",value:function(e,t){var n=this;return new Promise((function(r,i){n._checkWorker(),n.worker.updatePushUrl().then((function(t){setTimeout((function(){a.default.info("client updatePushUrl success"),e&&e(t),r(t),n.grafanaReport.report("update_url",y)}),1)})).catch((function(e){a.default.error("client updatePushUrl failed: ".concat((0,m.stringifyErr)(e))),t&&t(e),i(e),n.grafanaReport.report("update_url",_,e.code,null==e?void 0:e.reason)}))}))}},{key:"destroy",value:function(e,t){var n=this;return new Promise((function(r,i){n.worker?n.worker.destroy().then((function(){n.pushUrl=null,n.playUrls.clear(),a.default.info("client destroy success"),e&&e(),r()})).catch((function(e){a.default.error("client destroy failed: ".concat((0,m.stringifyErr)(e))),t&&t(e),i(e)})).finally((function(){n.worker=null,n._stopNetworkJudge(),n._resetData()})):(n.pushUrl=null,n.playUrls.clear(),a.default.info("client destroy success without worker"),e&&e(),r(),n._stopNetworkJudge(),n._resetData()),n.grafanaReport.destroy(),n.argusReport.destroy()}))}},{key:"startChannelMediaRelay",value:function(e,t){if(!(e instanceof I.ChannelMediaRelayConfiguration))throw"Configration should be instance of [ChannelMediaRelayConfiguration]";var n=e.getSrcChannelMediaInfo(),r=e.getDestChannelMediaInfos();if((0,m.isEmpty)(n))throw"srcChannelMediaInfo should not be empty";if((0,m.isEmpty)(r)||0===r.length)throw"destChannelMediaInfos should not be empty";if(a.default.info("[startChannelMediaRelay]: srcInfo: ",n," destInfo: ",r),!(0,o.is32Uint)(n.uid))throw"Invalid uid in srcChannelMediaInfo";if(!(0,m.isValidChannelName)(n.channelName))throw"Invalid channelName in srcChannelMediaInfo";if(n.token&&!(0,m.isValidToken)(n.token))throw"Invalid token in srcChannelMediaInfo";if(r.forEach((function(e){if(!(0,o.is32Uint)(e.uid))throw"Invalid uid in destChannelMediaInfo";if(!(0,m.isValidChannelName)(e.channelName))throw"Invalid channelName in destChannelMediaInfo";if(e.token&&!(0,m.isValidToken)(e.token))throw"Invalid token in destChannelMediaInfo"})),!this.worker)throw"startChannelMediaRelay should be used after join";this.worker.startChannelMediaRelay(e).then((function(){a.default.info("client startChannelMediaRelay success"),t&&t()})).catch((function(e){a.default.error("client startChannelMediaRelay failed: ".concat((0,m.stringifyErr)(e))),t&&t(e)}))}},{key:"updateChannelMediaRelay",value:function(e,t){if(!(e instanceof I.ChannelMediaRelayConfiguration))throw"Configration should be instance of [ChannelMediaRelayConfiguration]";var n=e.getSrcChannelMediaInfo(),r=e.getDestChannelMediaInfos();if((0,m.isEmpty)(n))throw"srcChannelMediaInfo should not be empty";if((0,m.isEmpty)(r)||0===r.length)throw"destChannelMediaInfos should not be empty";if(a.default.info("[updateChannelMediaRelay]: srcInfo: ",n," destInfo: ",r),!(0,o.is32Uint)(n.uid))throw"Invalid uid in srcChannelMediaInfo";if(!(0,m.isValidChannelName)(n.channelName))throw"Invalid channelName in srcChannelMediaInfo";if(n.token&&!(0,m.isValidToken)(n.token))throw"Invalid token in srcChannelMediaInfo";if(r.forEach((function(e){if(!(0,o.is32Uint)(e.uid))throw"Invalid uid in destChannelMediaInfo";if(!(0,m.isValidChannelName)(e.channelName))throw"Invalid channelName in destChannelMediaInfo";if(e.token&&!(0,m.isValidToken)(e.token))throw"Invalid token in destChannelMediaInfo"})),!this.worker)throw"updateChannelMediaRelay should be used after join";this.worker.updateChannelMediaRelay(e).then((function(){a.default.info("client updateChannelMediaRelay success"),t&&t()})).catch((function(e){a.default.error("client updateChannelMediaRelay failed: ".concat((0,m.stringifyErr)(e))),t&&t(e)}))}},{key:"stopChannelMediaRelay",value:function(e){a.default.info("[stopChannelMediaRelay]"),this.worker.stopChannelMediaRelay().then((function(){a.default.info("client stopChannelMediaRelay success"),e&&e()})).catch((function(t){a.default.error("client stopChannelMediaRelay failed: ".concat((0,m.stringifyErr)(t))),e&&e(t)}))}},{key:"_checkUid",value:function(e){if(!e||"number"!=typeof e||!(0,o.is32Uint)(e)){var t=new Error("Invalid uid type");throw a.default.error("client ".concat(t.message)),t}}},{key:"_checkWorker",value:function(){if(!this.worker||!this.worker.isWSConnected()){var e=new Error("Disconnected from server");throw a.default.error("client ".concat(e.message)),e}}},{key:"_dealSid",value:function(){this.sid||(this.sid=(0,o.generateSessionId)(),this.argusReport.sid=this.sid,a.default.setOptions({appId:this.appId,sid:this.sid}),a.default.info("client sid: ".concat(this.sid)))}},{key:"_startNetworkJudge",value:function(){this.networkJudge||(this.networkJudge=!0,a.default.info("client start network judge"),wx.onNetworkStatusChange(ae),wx.onNetworkWeakChange(ce))}},{key:"_stopNetworkJudge",value:function(){this.networkJudge&&(this.networkJudge=!1,a.default.info("client stop network judge"),wx.offNetworkStatusChange(ae),wx.offNetworkWeakChange(ce))}},{key:"_resetData",value:function(){this.sid=""}}]),r}()})(),__webpack_exports__})()));