"use strict";function _typeof(e){return _typeof="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},_typeof(e)}!function(e,t){"object"==("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).MiniappRtc=t()}(void 0,function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};function t(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return(n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s}function o(e,t,n,r){return new(n||(n=Promise))(function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(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())})}function i(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1] ",e,t);var r=Date.now();this._data.push(n(n({event_key:e},t),{message:JSON.stringify(t.message),event_type:"event",report_id:this._reportId++,time:r,rtc_time:r}))},e.prototype.resume=function(){this._ongoing||(this._ongoing=!0,this._send2server())},e.prototype.stop=function(){this._ongoing=!1},e.prototype._send2server=function(){var e=this;if(this._data.length){var t=this._data.splice(0,1e3);this._header.report_time=Date.now(),this._header.report_log_count=t.length,p("https://log.snssdk.com/video/v1/webrtc_log/",{method:"POST",body:{data:t,header:this._header,os:"miniapp",from:"miniapp",version:"3"}}).then(function(){}).catch(function(){e._data=[].concat(t,e._data)})}this._ongoing&&(this._reportTimer=setTimeout(this._send2server.bind(this),5e3))},e}());wx.__monitor=v;var g=100001,y=100002,b=100003,I=100004,S=100005,k=100007,w=100008,R=200001,C=200003,E=300001,T=300002,A=300003,O=300004,D=300005,N=300006,P=300007,U=300008,M=300009,L=300010,x=300011,j=300012,q=300013,V=300014,K=500001,B=500002,F=Object.freeze({__proto__:null,INVALID_PARAMS:g,NOT_IN_ROOM:y,ALREADY_IN_ROOM:b,CONNECTING:I,ALREADY_PUBLISHED:S,NOT_PUBLISHED:100006,UID_NOT_FOUND:k,HAS_INITED:w,STREAM_ID_NOT_FOUND:R,GET_CONFIG_ERROR:200002,NO_WEBSOCLET_URL:C,SUBSCRIBE_FAILED:E,UNSUBSCRIBE_FAILED:T,MUTE_LOCAL_ERROR:A,MUTE_REMOTE_ERROR:O,LEAVE_ERROR:D,PUBLISH_ERROR:N,UNPUBLISH_ERROR:P,JOIN_ROOM_ERROR:U,SIGNALING_TIMEOUT:M,WEBSOCKET_NOT_CONNECTED:L,KICKED_OUT:x,DUPLICATE_LOGIN:j,ROOM_DISMISS:q,SERVER_ERROR:V,WEBSOCKET_FAILED:K,DOMAIN_IN_BLACKLIST:B}),H=function(e){function r(t){var n=e.call(this)||this;n._pingInterval=5e3,n._pingTimeout=1e4,n._pingTimer=null,n._ackTimeout=1e4,n._maxRetryTime=3,n._signalingResolveCallbacks={},n._signalingRejectCallbacks={},n._signalingTimer={},n._requestId=-1,n._reqSigMap={};var r=t.appId,o=t.roomId,i=t.userId,s=t.token,a=t.role;return n._clsName="Signaling",n._appId=r,n._roomId=o,n._userId=i,n._token=s,n._role=a,n._sessionId=u(),wx.__test__1006=function(){n._socketTask.close({success:function(){n.emit("@signaling/onClose",{code:1006,reason:""})}})},n}return t(r,e),r.prototype.connect=function(e){var t=this;return this._url=e,new Promise(function(r,o){var i=u(),s=e+"?wsid="+i+"&appid="+t._appId+"&ua=miniapp-3.0.1&EIO=3&transport=websocket";t._report("rtc_invoke_status",{sdk_api_name:"websocket url",message:s}),t._report("rtc_websocket",{error_code:0,signaling_server:s,message:s,signaling_event:"connecting"});var a=wx.connectSocket({url:s});a.onError(function(e){o({code:K,reason:e.errMsg}),t.emit("@signaling/error",n(n({},e),{code:e.code||K}))}),a.onOpen(function(e){t._socketTask=a,t._ping(),t._report("rtc_websocket",{error_code:0,signaling_server:s,message:s,signaling_event:"connected"}),r()}),a.onClose(function(e){t._report("rtc_websocket",{error_code:e.code,signaling_server:s,message:JSON.stringify(e),signaling_event:"failed"}),t.emit("@signaling/onClose",e)}),a.onMessage(function(e){"string"==typeof(null==e?void 0:e.data)&&t._handleMessage(e.data)})})},r.prototype.disconnect=function(){var e=this;return new Promise(function(t,n){if(e._socketTask.readyState!==e._socketTask.OPEN)return t();e._socketTask.close({success:t,fail:n})})},r.prototype.sendSignaling=function(e,t,n){return void 0===n&&(n=0),o(this,void 0,void 0,function(){var r;return i(this,function(o){switch(o.label){case 0:return[4,this._sendSignaling(e,t)];case 1:return r=o.sent(),n0?(t=r[0],o=this,[4,this._connectSignaling(t.host)]):[3,10];case 9:o._signaling=i.sent(),i.label=10;case 10:return[3,11];case 11:return this._wsDoamin=t,this._handleSignaling(),[3,13];case 12:throw s=i.sent(),this._state=m.Disconnected,s;case 13:return[2]}})})},r.prototype._connectSignaling=function(e){return o(this,void 0,void 0,function(){var t,n;return i(this,function(r){switch(r.label){case 0:return t="wss://"+e+"/rtmp_socket/",[4,(n=new H(this._options)).connect(t)];case 1:return r.sent(),[2,n]}})})},r.prototype.join=function(e){return void 0===e&&(e=!1),o(this,void 0,void 0,function(){var t,n,r,o,s,a,c,u=this;return i(this,function(i){return t=this._systemInfo,n=t.system,r=t.model,o=t.version,s=t.SDKVersion,a=t.platform,c=t.brand,this._checkConnect(),[2,this._signaling.sendSignaling(e?"reconnected":"joinRoom",{roomId:this._roomId,userAttributes:{role:this._role},params:{deviceType:"miniapp",userAgent:"system: "+n+", model: "+r+", version: "+o+", SDKVersion: "+s+", platform: "+a+", brand: "+c,sdkVersion:"3.0.1",deviceId:h(),appId:this._appId,roomId:this._roomId,userId:this._userId,businessId:"",rtcSid:""},Authorization:this._token.startsWith("Basic")?this._token:"Bearer "+this._token,_userAgentIP:this._userAgentIP||"",_lambdaAddr:this._lambdaAddr||""}).then(function(e){if(200!==(null==e?void 0:e.code))throw{code:U,reason:"joinRoom failed",detail:null==e?void 0:e.message};return u._state=m.Connected,u._handleJoinRoomACK(e),e}).catch(function(e){throw u._state=m.Disconnected,e})]})})},r.prototype.leave=function(){return o(this,void 0,void 0,function(){var e=this;return i(this,function(t){return this._checkConnect(),[2,this._signaling.sendSignaling("leaveRoom",{roomId:this._roomId,Authorization:this._token.startsWith("Basic")?this._token:"Bearer "+this._token}).then(function(t){var n,r;if(200!==(null==t?void 0:t.code))throw{code:D,reason:null==t?void 0:t.message};return e._state=m.Disconnected,null===(n=e._signaling)||void 0===n||n.disconnect(),null===(r=e._signaling)||void 0===r||r.removeAllListeners(),t}).catch(function(e){throw e})]})})},r.prototype.getLocalStreamId=function(){return this._publishStreamId},r.prototype.getRemoteStreamId=function(e,t){var n,r,o=this._remoteClients.get(e);return t?null===(n=null==o?void 0:o.screenStream)||void 0===n?void 0:n.streamId:null===(r=null==o?void 0:o.stream)||void 0===r?void 0:r.streamId},r.prototype.destroy=function(){var e;this.leave().catch(function(){}),this._servers=[],this._appId="",this._roomId="",this._userId="",this._token="",this._role="normalUser",null===(e=this._signaling)||void 0===e||e.removeAllListeners(),this._state=m.Init,this._remoteClients.clear(),this._publishRtmp="",this._publishStreamId="",this._enableCamera=!0,this._enableMic=!0,this._reconnectFailed=!1,this._reconnectTimer&&(clearTimeout(this._reconnectTimer),delete this._reconnectTimer)},r.prototype.publish=function(e){return void 0===e&&(e=!1),o(this,void 0,void 0,function(){var t,n;return i(this,function(r){switch(r.label){case 0:this._publishing=!0,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._publish(e)];case 2:return t=r.sent(),this._publishing=!1,[2,t];case 3:throw n=r.sent(),this._publishing=!1,n;case 4:return[2]}})})},r.prototype._publish=function(e){return void 0===e&&(e=!1),o(this,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:if(this._checkConnect(),!e&&this._publishRtmp)throw{code:S,reason:"published"};return[4,this._signaling.sendSignaling("publish",{roomId:this._roomId,screen:!1,streamId:this._publishStreamId||"",eventSessionId:u(),attributes:{audiostream:this._enableMic,videostream:this._enableCamera},_expectedMSAddr:this._options._expectedMSAddr})];case 1:if(200!==(null==(t=n.sent())?void 0:t.code))throw{code:N,reason:"publish failed",detail:null==t?void 0:t.message};return this._publishRtmp=t.publishRtmpAddr,this._publishStreamId=t.streamId,[2,{rtmp:this._publishRtmp,streamId:this._publishStreamId}]}})})},r.prototype.unpublish=function(){return o(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return this._publishRtmp?(this._checkConnect(),[4,this._signaling.sendSignaling("unpublish",{roomId:this._roomId,streamId:this._publishStreamId,eventSessionId:u()})]):[2];case 1:if(200!==(null==(e=t.sent())?void 0:e.code))throw{code:P,reason:"unpublish failed"};return this._publishRtmp="",this._publishStreamId="",[2]}})})},r.prototype.subscribe=function(e,t){return o(this,void 0,void 0,function(){var n=this;return i(this,function(r){return this._checkConnect(),[2,new Promise(function(r,o){var i,s=n._remoteClients.get(e);if(!s)return o({code:k,reason:"uid not found"});var a=t.audio,c=t.video,d=t.screen,l=d?s.screenStream:s.stream;if(!l)return o({code:R,reason:"stream not found"});l.subOption=t,d?("boolean"==typeof s.recvScreenVideo?c=s.recvScreenVideo:"boolean"!=typeof c&&(c=!0),a=c):("boolean"==typeof s.recvAudio?a=s.recvAudio:"boolean"!=typeof a&&(a=!0),"boolean"==typeof s.recvVideo?c=s.recvVideo:"boolean"!=typeof c&&(c=!0)),null===(i=n._signaling)||void 0===i||i.sendSignaling("subscribe",{roomId:n._roomId,streamUserId:e,screen:!!d,uniqueKey:l.uniqueKey,eventSessionId:u(),config:{enableMediaType:{audio:a,video:c}},_expectedMSAddr:n._options._expectedMSAddr}).then(function(e){if(200!==(null==e?void 0:e.code))throw{code:E,reason:"subscribe failed"};t.screen?s.screenStream&&(s.screenStream.rtmp=e.subscribeRtmpAddr,s.screenStream.streamId=e.streamId):s.stream&&(s.stream.rtmp=e.subscribeRtmpAddr,s.stream.streamId=e.streamId),r({rtmp:e.subscribeRtmpAddr,streamId:e.streamId})}).catch(function(e){return o(e)})})]})})},r.prototype.unsubscribe=function(e,t){return o(this,void 0,void 0,function(){var n=this;return i(this,function(r){return this._checkConnect(),[2,new Promise(function(r,o){var i,s,a,c=n._remoteClients.get(e),d="";return c?(d=(null==t?void 0:t.screen)?null===(i=null==c?void 0:c.screenStream)||void 0===i?void 0:i.streamId:null===(s=null==c?void 0:c.stream)||void 0===s?void 0:s.streamId)?void(null===(a=n._signaling)||void 0===a||a.sendSignaling("unsubscribe",{roomId:n._roomId,streamId:d,eventSessionId:u()}).then(function(e){if(200!==(null==e?void 0:e.code))throw{code:T,reason:"unsubscribe failed"};r()}).catch(function(e){return o(e)})):o({code:R,reason:"stream not found"}):o({code:k,reason:"uid not found"})})]})})},r.prototype.muteLocal=function(e){return o(this,void 0,void 0,function(){var t=this;return i(this,function(n){return this._checkConnect(),[2,new Promise(function(n,r){if("boolean"==typeof e.audio&&(t._enableMic=e.audio),"boolean"==typeof e.video&&(t._enableCamera=e.video),!t._publishRtmp&&!t._publishing)return n();var o={};"boolean"==typeof e.audio&&(o.audiostream=e.audio),"boolean"==typeof e.video&&(o.videostream=e.video),t._signaling.sendSignaling("updateStreamAttributes",{roomId:t._roomId,streamId:t._publishStreamId,attributes:o,eventSessionId:u()}).then(function(e){if(200!==(null==e?void 0:e.code))throw{code:A,reason:"muteLocal/unmuteLocal failed"};n()}).catch(function(e){return r(e)})})]})})},r.prototype.muteRemote=function(e,t){return o(this,void 0,void 0,function(){var n=this;return i(this,function(r){return this._checkConnect(),[2,new Promise(function(r,o){var i,s,a,c,d=n._remoteClients.get(e);return d?(c=t.screen?null===(i=null==d?void 0:d.screenStream)||void 0===i?void 0:i.streamId:null===(s=null==d?void 0:d.stream)||void 0===s?void 0:s.streamId,t.screen?("boolean"==typeof t.video?d.recvScreenVideo=t.video:t.video=!!d.recvScreenVideo,t.audio=t.video):("boolean"==typeof t.audio?d.recvAudio=t.audio:t.audio="boolean"!=typeof d.recvAudio||d.recvAudio,"boolean"==typeof t.video?d.recvVideo=t.video:t.video="boolean"!=typeof d.recvVideo||d.recvVideo),c?(delete t.screen,void(null===(a=n._signaling)||void 0===a||a.sendSignaling("updateSubscribe",{roomId:n._roomId,streamId:c,config:{enableMediaType:{audio:t.audio,video:t.video}},eventSessionId:u()}).then(function(e){if(200!==(null==e?void 0:e.code))throw{code:O,reason:"mute/unmute failed"};r()}).catch(function(e){return o(e)}))):r()):o({code:k,reason:"uid not found"})})]})})},r.prototype.updateUserAttributes=function(e){return o(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return this._checkConnect(),this._role=e.role,[4,this._signaling.sendSignaling("updateUserAttributes",{roomId:this._roomId,attributes:e,eventSessionId:u()})];case 1:return t.sent(),[2]}})})},r.prototype.getStreamInfo=function(e){var t,n,r={streamId:"",rtmp:""},o=this._remoteClients.get(e);return(null==o?void 0:o.stream)&&(r.streamId=null===(t=o.stream)||void 0===t?void 0:t.streamId,r.rtmp=null===(n=o.stream)||void 0===n?void 0:n.rtmp),r},r.prototype._getKeepAliveUrlsAndCache=function(e){return o(this,void 0,void 0,function(){var t,n=this;return i(this,function(r){return t=e.map(function(t){var r={appID:n._appId,roomID:n._roomId,keys:["multiDomain"],labelSelector:"serviceType=rtmp",sdkVersion:"3.0.1",deviceType:"miniapp"};return v.report("rtc_get_config",{error_code:0,host:e,type:"request",message:JSON.stringify(r)}),p("https://"+t+"/decision/v1/multi",{method:"POST",body:r})}),[2,f(t).then(function(e){var t;void 0===e&&(e={});var r=e.multiDomain,o=e.domainBlacklist;return v.report("rtc_get_config",{error_code:0,message:JSON.stringify(e),type:"response"}),d.setCacheSync(l,r),Array.isArray(o)&&o.find(function(e){var t;return e===(null===(t=n._wsDoamin)||void 0===t?void 0:t.host)})&&n._clientEmit(ne,{code:B,reason:"current websocket domain "+(null===(t=n._wsDoamin)||void 0===t?void 0:t.host)+" in blacklist"}),r}).catch(function(e){throw v.report("rtc_get_config",{error_code:e.code,message:e.reason,type:"response"}),e})]})})},r.prototype._handleSignaling=function(){var e,t,n,r,o,i,s,a,c=this;null===(e=this._signaling)||void 0===e||e.on("@signaling/onClose",function(e){var t,n;if(1006===e.code)return v.report("rtc_invoke_status",{sdk_api_name:"1006"}),null===(t=c._signaling)||void 0===t||t.destroy(),c._signaling=new H({appId:c._appId,roomId:c._roomId,userId:c._userId,token:c._token,role:c._role}),c._handleSignaling(),void(c._reconnectTimer=setTimeout(function(){var e,t="wss://"+c._wsDoamin.host+c._wsDoamin.path;v.report("rtc_invoke_status",{sdk_api_name:"socket_reconnect",message:"start"}),null===(e=c._signaling)||void 0===e||e.connect(t).then(function(){c.join(!0).then(c._reconnectSuccess.bind(c)),c._reconnectFailed=!1,delete c._reconnectTimer,v.report("rtc_invoke_status",{sdk_api_name:"socket_reconnect",message:"success"})}).catch(function(){c._reconnectFailed=!0,delete c._reconnectTimer,v.report("rtc_invoke_status",{sdk_api_name:"socket_reconnect",message:"failed"})})},c._reconnectFailed?3e3:0));c._state=m.Disconnected,null===(n=c._signaling)||void 0===n||n.destroy(),delete c._signaling,c._clientEmit(ee,e)}),null===(t=this._signaling)||void 0===t||t.on("@signaling/error",function(e){var t;v.report("rtc_error",{error_code:e.code,message:{from:"wx.socket onerror",reason:e.reason}}),null===(t=c._signaling)||void 0===t||t.destroy(),delete c._signaling,c._state=m.Disconnected,c._clientEmit(te,e)}),null===(n=this._signaling)||void 0===n||n.on("@signaling/userConnection",this._onUserConnect.bind(this)),null===(r=this._signaling)||void 0===r||r.on("@signaling/userDisconnection",this._onUserDisconnect.bind(this)),null===(o=this._signaling)||void 0===o||o.on("@signaling/onAddStream",this._onAddStream.bind(this)),null===(i=this._signaling)||void 0===i||i.on("@signaling/onRemoveStream",this._onRemoveStream.bind(this)),null===(s=this._signaling)||void 0===s||s.on("@signaling/streamFailed",this._onStreamFailed.bind(this)),null===(a=this._signaling)||void 0===a||a.on("@signaling/onUpdateStreamAttributes",this._onUpdateStreamAttributes.bind(this))},r.prototype._handleJoinRoomACK=function(e){var t=this,n=e.clients,r=e.streams,o=new Map(this._remoteClients);Array.isArray(n)&&n.forEach(function(e){o.has(e)?o.delete(e):t._onUserConnect({clientId:e})}),o.forEach(function(e){t._onUserDisconnect({clientId:e.clientId})}),Array.isArray(r)&&r.forEach(this._onAddStream.bind(this))},r.prototype._reconnectSuccess=function(){return o(this,void 0,void 0,function(){var e,t;return i(this,function(n){switch(n.label){case 0:if(!this._publishRtmp)return[3,4];e=this._publishRtmp,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.publish(!0)];case 2:return(t=n.sent().rtmp)!==e&&this._clientEmit(re,{uid:this._userId,screen:!1,url:t}),[3,4];case 3:return n.sent(),this._clientEmit(oe,{uid:this._userId,screen:!1,reason:"publish failed after reconnection"}),[3,4];case 4:return[2]}})})},r.prototype._onUserConnect=function(e){var t=e.clientId;t!==this._userId&&(this._remoteClients.set(t,{clientId:t}),this._clientEmit(J,{uid:t}))},r.prototype._onUserDisconnect=function(e){var t=e.clientId,n=e.tag;if(t===this._userId){var r=null;n===s.kickedByAdmin?r=x:n===s.roomDismissed?r=q:n===s.userDuplicateLogin?r=j:n===s.serverError&&(r=V),r&&(this._clientEmit(z,{errorCode:r}),this.emit("@room/client-banned",{errorCode:r}))}else this._onRemoveStream({clientId:t,screen:!0,roomId:this._roomId}),this._onRemoveStream({clientId:t,screen:!1,roomId:this._roomId}),this._clientEmit(G,{uid:t}),this._remoteClients.delete(t)},r.prototype._onAddStream=function(e){var t,n;return o(this,void 0,void 0,function(){var r,o,s,a,c;return i(this,function(i){switch(i.label){case 0:return r=this._remoteClients.get(e.streamUserId),o=e.screen?"screenStream":"stream",r?(s=r[o])?[3,1]:(r[o]={uniqueKey:e.uniqueKey,attributes:e.attributes},this._clientEmit(W,{uid:e.streamUserId,screen:e.screen}),[3,6]):[3,6];case 1:if(s.uniqueKey===e.uniqueKey)return[3,6];v.report("rtc_invoke_status",{sdk_api_name:"uniqueKey.change",message:JSON.stringify({stream:s,uniqueKey:e.uniqueKey})}),s.uniqueKey=e.uniqueKey,a="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.subscribe(e.streamUserId,{screen:e.screen,audio:null===(t=s.subOption)||void 0===t?void 0:t.audio,video:null===(n=s.subOption)||void 0===n?void 0:n.video})];case 3:return c=i.sent(),a=c.rtmp,[3,5];case 4:return i.sent(),[3,5];case 5:a?this._clientEmit(re,{uid:e.streamUserId,screen:e.screen,url:a}):this._clientEmit(oe,{uid:e.streamUserId,screen:e.screen,reason:"re-subscribe failed."}),i.label=6;case 6:return[2]}})})},r.prototype._onRemoveStream=function(e){var t=e.clientId,n=e.screen;if(t!==this._userId){var r=this._remoteClients.get(t);if(r){if(n){if(!r.screenStream)return;delete r.screenStream}else{if(!r.stream)return;delete r.stream}this._clientEmit(Y,{uid:t,screen:n})}}},r.prototype._onStreamFailed=function(e){var t,n,r,s;return o(this,void 0,void 0,function(){var o,a,c,u,d,l,_,h,p;return i(this,function(i){switch(i.label){case 0:if(o=/4[0-9][0-9]/.test(e.code.toString()),e.streamId!==this._publishStreamId)return[3,6];this._publishRtmp="",h="",i.label=1;case 1:return i.trys.push([1,4,,5]),o?[3,3]:[4,this.publish()];case 2:p=i.sent(),h=p.rtmp,i.label=3;case 3:return[3,5];case 4:return i.sent(),[3,5];case 5:return h?this._clientEmit(re,{uid:this._userId,screen:!1,url:h}):this._clientEmit(oe,{uid:this._userId,screen:!1,reason:e.message}),[3,12];case 6:for(a=void 0,c=!1,u=this._remoteClients.values(),d=0;d