@rongcloud/plugin-call 5.2.5 → 5.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@rongcloud/engine"),t=require("@rongcloud/plugin-rtc"),r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(e,t)};var o=function(){return o=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},o.apply(this,arguments)};function n(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((o=o.apply(e,t||[])).next())}))}function i(e,t){var r,o,n,i,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[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(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,o&&(n=2&a[0]?o.return:a[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,a[1])).done)return n;switch(o=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],o=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)s.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return s}function a(e,t,r){if(r||2===arguments.length)for(var o,n=0,i=t.length;n<i;n++)!o&&n in t||(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var l,c,u,d,C=function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));return e="".concat(e.replace(/-/g,""),"0"),(e=function(e){var t="0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ+/".split(""),r=t.length+1,o=+e,n=[];do{var i=o%r;o=(o-i)/r,n.unshift(t[i])}while(o);return n.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},_=function(){var e=Math.floor(1e3*Math.random()),t=C();return[t=t.replace(/\//g,"0"),Date.now(),e].join("_")},h=new e.EventEmitter,f=function(e){var t="RCCallDeviceId",r=e.sessionStorage.getItem(t);return r||(r=C(),e.sessionStorage.setItem(t,r)),r};!function(e){e[e.OUTGOING=1]="OUTGOING",e[e.INCOMING=2]="INCOMING",e[e.RINGING=3]="RINGING",e[e.CONNECTED=4]="CONNECTED",e[e.IDLE=5]="IDLE",e[e.ACCEPTED=6]="ACCEPTED"}(l||(l={})),exports.RCCallErrorCode=void 0,(c=exports.RCCallErrorCode||(exports.RCCallErrorCode={}))[c.SUCCESS=1e4]="SUCCESS",c[c.STATE_MACHINE_EXIT=53200]="STATE_MACHINE_EXIT",c[c.SEND_MSG_ERROR=53201]="SEND_MSG_ERROR",c[c.REJECTED_BY_BLACKLIST=53202]="REJECTED_BY_BLACKLIST",c[c.NOT_IN_GROUP=53203]="NOT_IN_GROUP",c[c.GET_LOCAL_AUDIO_TRACK_ERROR=53301]="GET_LOCAL_AUDIO_TRACK_ERROR",c[c.GET_LOCAL_VIDEO_TRACK_ERROR=53302]="GET_LOCAL_VIDEO_TRACK_ERROR",c[c.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR=53303]="GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR",c[c.JOIN_ROOM_ERROR=53304]="JOIN_ROOM_ERROR",c[c.AUDIO_PUBLISH_ERROR=53305]="AUDIO_PUBLISH_ERROR",c[c.VIDEO_PUBLISH_ERROR=53306]="VIDEO_PUBLISH_ERROR",c[c.AUDIO_AND_VIDEO_PUBLISH_ERROR=53307]="AUDIO_AND_VIDEO_PUBLISH_ERROR",c[c.QUERY_JOINED_USER_INFO_ERROR=53308]="QUERY_JOINED_USER_INFO_ERROR",c[c.MISSING_VIDEO_TRACK_ERROR=53309]="MISSING_VIDEO_TRACK_ERROR",c[c.UNPUBLISH_VIDEO_ERROR=53310]="UNPUBLISH_VIDEO_ERROR",c[c.CONVERSATION_NOT_GROUP_ERROR=53311]="CONVERSATION_NOT_GROUP_ERROR",c[c.NOT_IN_ROOM_ERROR=53312]="NOT_IN_ROOM_ERROR",c[c.PARAM_ERROR=53313]="PARAM_ERROR",c[c.MISSING_AUDIO_TRACK_ERROR=53314]="MISSING_AUDIO_TRACK_ERROR",exports.RCCallEndReason=void 0,(d=exports.RCCallEndReason||(exports.RCCallEndReason={}))[d.CANCEL=1]="CANCEL",d[d.REJECT=2]="REJECT",d[d.HANGUP=3]="HANGUP",d[d.BUSY_LINE=4]="BUSY_LINE",d[d.NO_RESPONSE=5]="NO_RESPONSE",d[d.ENGINE_UNSUPPORTED=6]="ENGINE_UNSUPPORTED",d[d.NETWORK_ERROR=7]="NETWORK_ERROR",d[d.GET_MEDIA_RESOURCES_ERROR=8]="GET_MEDIA_RESOURCES_ERROR",d[d.PUBLISH_ERROR=9]="PUBLISH_ERROR",d[d.SUBSCRIBE_ERROR=10]="SUBSCRIBE_ERROR",d[d.REMOTE_CANCEL=11]="REMOTE_CANCEL",d[d.REMOTE_REJECT=12]="REMOTE_REJECT",d[d.REMOTE_HANGUP=13]="REMOTE_HANGUP",d[d.REMOTE_BUSY_LINE=14]="REMOTE_BUSY_LINE",d[d.REMOTE_NO_RESPONSE=15]="REMOTE_NO_RESPONSE",d[d.REMOTE_ENGINE_UNSUPPORTED=16]="REMOTE_ENGINE_UNSUPPORTED",d[d.REMOTE_NETWORK_ERROR=17]="REMOTE_NETWORK_ERROR",d[d.REMOTE_GET_MEDIA_RESOURCE_ERROR=18]="REMOTE_GET_MEDIA_RESOURCE_ERROR",d[d.REMOTE_PUBLISH_ERROR=19]="REMOTE_PUBLISH_ERROR",d[d.REMOTE_SUBSCRIBE_ERROR=20]="REMOTE_SUBSCRIBE_ERROR",d[d.OTHER_CLIENT_JOINED_CALL=21]="OTHER_CLIENT_JOINED_CALL",d[d.OTHER_CLIENT_IN_CALL=22]="OTHER_CLIENT_IN_CALL",d[d.KICKED_BY_SERVER=23]="KICKED_BY_SERVER",d[d.ACCEPT_SYSTEM_CALL=24]="ACCEPT_SYSTEM_CALL",d[d.REMOTE_OTHER_CLIENT_JOINED_CALL=31]="REMOTE_OTHER_CLIENT_JOINED_CALL",d[d.REMOTE_OTHER_CLIENT_IN_CALL=32]="REMOTE_OTHER_CLIENT_IN_CALL",d[d.REMOTE_KICKED_BY_SERVER=33]="REMOTE_KICKED_BY_SERVER",d[d.REMOTE_ACCEPT_SYSTEM_CALL=34]="REMOTE_ACCEPT_SYSTEM_CALL",d[d.ACCEPT_BY_OTHER_CLIENT=101]="ACCEPT_BY_OTHER_CLIENT",d[d.HANGUP_BY_OTHER_CLIENT=102]="HANGUP_BY_OTHER_CLIENT",d[d.ADDED_TO_BLACKLIST=103]="ADDED_TO_BLACKLIST",d[d.SERVICE_NOT_OPENED=104]="SERVICE_NOT_OPENED";var p,g,R,b,E=((u={})[exports.RCCallEndReason.CANCEL]=exports.RCCallEndReason.REMOTE_CANCEL,u[exports.RCCallEndReason.REJECT]=exports.RCCallEndReason.REMOTE_REJECT,u[exports.RCCallEndReason.HANGUP]=exports.RCCallEndReason.REMOTE_HANGUP,u[exports.RCCallEndReason.BUSY_LINE]=exports.RCCallEndReason.REMOTE_BUSY_LINE,u[exports.RCCallEndReason.NO_RESPONSE]=exports.RCCallEndReason.REMOTE_NO_RESPONSE,u[exports.RCCallEndReason.ENGINE_UNSUPPORTED]=exports.RCCallEndReason.REMOTE_ENGINE_UNSUPPORTED,u[exports.RCCallEndReason.NETWORK_ERROR]=exports.RCCallEndReason.REMOTE_NETWORK_ERROR,u[exports.RCCallEndReason.GET_MEDIA_RESOURCES_ERROR]=exports.RCCallEndReason.REMOTE_GET_MEDIA_RESOURCE_ERROR,u[exports.RCCallEndReason.PUBLISH_ERROR]=exports.RCCallEndReason.REMOTE_PUBLISH_ERROR,u[exports.RCCallEndReason.SUBSCRIBE_ERROR]=exports.RCCallEndReason.REMOTE_SUBSCRIBE_ERROR,u[exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL]=exports.RCCallEndReason.REMOTE_OTHER_CLIENT_JOINED_CALL,u[exports.RCCallEndReason.OTHER_CLIENT_IN_CALL]=exports.RCCallEndReason.REMOTE_OTHER_CLIENT_IN_CALL,u[exports.RCCallEndReason.KICKED_BY_SERVER]=exports.RCCallEndReason.REMOTE_KICKED_BY_SERVER,u[exports.RCCallEndReason.REMOTE_NO_RESPONSE]=exports.RCCallEndReason.NO_RESPONSE,u[exports.RCCallEndReason.ACCEPT_SYSTEM_CALL]=exports.RCCallEndReason.REMOTE_ACCEPT_SYSTEM_CALL,u);!function(e){e.VCInvite="RC:VCInvite",e.VCRinging="RC:VCRinging",e.VCAccept="RC:VCAccept",e.VCHangup="RC:VCHangup",e.VCModifyMem="RC:VCModifyMem",e.VCModifyMedia="RC:VCModifyMedia"}(p||(p={})),exports.RCCallSessionState=void 0,(g=exports.RCCallSessionState||(exports.RCCallSessionState={}))[g.WAITING=0]="WAITING",g[g.KEEPING=1]="KEEPING",g[g.END=2]="END",exports.RCCallUserState=void 0,(R=exports.RCCallUserState||(exports.RCCallUserState={}))[R.NONE=0]="NONE",R[R.WAITING=1]="WAITING",R[R.KEEPING=2]="KEEPING",function(e){
2
+ /*!
3
+ 同App通话
4
+ */
5
+ e[e.RCCallRoomTypeNormalCall=0]="RCCallRoomTypeNormalCall",
6
+ /*!
7
+ 跨App通话
8
+ */
9
+ e[e.RCCallRoomTypeAcrossCall=7]="RCCallRoomTypeAcrossCall"}(b||(b={}));var I,y,m,v=function(){function e(e,t){Object.defineProperty(this,"_timerId",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_startTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),e&&(this._timerId=function(e,t){return setTimeout(e,t)}((function(){e()}),t)),this._startTime=Date.now()}return Object.defineProperty(e.prototype,"stop",{enumerable:!1,configurable:!0,writable:!0,value:function(){clearTimeout(this._timerId);var e=Date.now(),t=e-this._startTime;return 0===this._startTime&&(t=0),{startTime:this._startTime,endTime:e,duration:t}}}),Object.defineProperty(e.prototype,"reset",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._startTime=0}}),e}(),O=function(){function t(e,t,r,o,n,i,s,a,l){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_callMsgHandler",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_channelId",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_conversationType",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_targetId",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"_sessionState",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_userInfo",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_userTimers",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_callTimeout",{enumerable:!0,configurable:!0,writable:!0,value:6e4}),Object.defineProperty(this,"_beginTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_endTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_endReason",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_inviterId",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_isCrossAppkey",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_hungupPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._callMsgHandler.registerStateMachineEvent(this._callId,"onRinging",this._onRinging.bind(this)),this._callMsgHandler.registerStateMachineEvent(this._callId,"onAccept",this._onAccept.bind(this)),this._callMsgHandler.registerStateMachineEvent(this._callId,"onMediaModify",this._onMediaModify.bind(this)),this._callMsgHandler.registerStateMachineEvent(this._callId,"onHungup",this._onHungup.bind(this))}return Object.defineProperty(t.prototype,"_getTimeout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._context.getServerTime()-e;t<0&&(t=500);var r=this._callTimeout-t;return this._logger.warn("_","_getTimeout -> timeout: ".concat(r)),r}}),Object.defineProperty(t.prototype,"_clearTimerById",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.debug("_","[RCCallStateMachine] before _clearTimerById -> userId: ".concat(e," userTimers: ").concat(JSON.stringify(this._userTimers))),this._userTimers[e]&&(this._userTimers[e].stop(),delete this._userTimers[e]),this._logger.debug("_","[RCCallStateMachine] after _clearTimerById -> userTimers: ".concat(JSON.stringify(this._userTimers)))}}),Object.defineProperty(t.prototype,"_notifyStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;this._logger.warn("_","[RCCallStateMachine] notifyStateChange -> info: ".concat(JSON.stringify({state:e,reason:t}))),this._endReason=t||null,this._sessionState!==e&&(this._sessionState=e,null===(r=this._watchers)||void 0===r||r.onStateChange({state:e,reason:t})),e===exports.RCCallSessionState.END&&(h.emit("onStateMachineClose",this._callId),this._callMsgHandler.unregisterStateMachineEvent(this._callId))}}),Object.defineProperty(t.prototype,"_notifyUserStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;this._logger.warn("_","[RCCallStateMachine] notifyUserStateChange -> info: ".concat(JSON.stringify({user:e,reason:t}))),null===(r=this._watchers)||void 0===r||r.onUserStateChange({user:e,reason:t})}}),Object.defineProperty(t.prototype,"_otherClientHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,r=e.content,o=r.user,n=r.reason,i=e.messageType;for(var s in this._userInfo[t]={userId:t,state:exports.RCCallUserState.NONE,isCaller:!1,isRemote:!1},this._userTimers)this._clearTimerById(s);var a=exports.RCCallEndReason.ACCEPT_BY_OTHER_CLIENT;i===p.VCHangup&&(a=n===exports.RCCallEndReason.BUSY_LINE?exports.RCCallEndReason.OTHER_CLIENT_IN_CALL:n===exports.RCCallEndReason.NO_RESPONSE?exports.RCCallEndReason.NO_RESPONSE:exports.RCCallEndReason.HANGUP_BY_OTHER_CLIENT),Object.assign(this._userInfo[t],o),this._notifyUserStateChange(this._userInfo[t],a),this._notifyStateChange(exports.RCCallSessionState.END,a)}}),Object.defineProperty(t.prototype,"_isRemoteInvalidMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!!this._userInfo[e]&&(!(!this._userInfo[e].deviceId||!t)&&(this._userInfo[e].state===exports.RCCallUserState.KEEPING&&this._userInfo[e].deviceId!==t))}}),Object.defineProperty(t.prototype,"_onRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,r=e.content,n=r.user,i=r.deviceId,s=this._isCrossAppkey?t.split("_")[1]:t;this._isRemoteInvalidMsg(s,i)?this._logger.debug("_","[RCCallStateMachine] onRinging -> not the remote device that is currently talking"):this._context.getCurrentId()!==s&&this._watchers.onRinging(o({userId:s},n))}}),Object.defineProperty(t.prototype,"_onAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=this,o=t.senderUserId,n=t.content,i=n.user,s=n.deviceId;t.sentTime;var a=this._isCrossAppkey?o.split("_")[1]:o,l=this._context.getCurrentId();this._isRemoteInvalidMsg(a,s)?this._logger.debug("_","[RCCallStateMachine] _onAccept -> not the remote device that is currently talking"):l!==a?(this._userTimers[a]&&this._clearTimerById(a),(this._conversationType===e.ConversationType.PRIVATE?[l,a]:[a]).forEach((function(e){var t=e===l;r._userInfo[e]={userId:e,state:exports.RCCallUserState.KEEPING,isCaller:t,isRemote:t,deviceId:t?f(r._runtime):s},t||(r._beginTimestamp=Date.now(),Object.assign(r._userInfo[a],i)),r._notifyUserStateChange(r._userInfo[e])})),this.getCallerId()===l&&this._notifyStateChange(exports.RCCallSessionState.KEEPING),this._watchers.onAccept({userId:a})):this._otherClientHandle(t)}}),Object.defineProperty(t.prototype,"_onMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,r=e.content,n=r.mediaType,i=r.user,s=r.deviceId;this._isRemoteInvalidMsg(t,s)?this._logger.debug("_","[RCCallStateMachine] _onMediaModify -> not the remote device that is currently talking"):this._context.getCurrentId()!==t&&(this._mediaType=n,this._watchers.onMediaModify({sender:o({userId:t},i),mediaType:n}))}}),Object.defineProperty(t.prototype,"_onHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,r=e.content,n=this._isCrossAppkey?t.split("_")[1]:t,i=r,s=i.reason,a=i.user,l=i.deviceId,c=this._context.getCurrentId();if(this._isRemoteInvalidMsg(n,l))this._logger.debug("_","[RCCallStateMachine] _onHungup -> not the remote device that is currently talking");else if(c!==n)if(this._sessionState!==exports.RCCallSessionState.END){this._userInfo[n]&&(this._userInfo[n].state=exports.RCCallUserState.NONE,this._endTimestamp=Date.now(),Object.assign(this._userInfo[n],a),this._notifyUserStateChange(this._userInfo[n],E[s]),delete this._userInfo[n]),E[s]===exports.RCCallEndReason.REMOTE_CANCEL?this.getRemoteUserIds().length<1&&this._clearTimerById(c):this.getInviterId()===c?this._clearTimerById(n):this.getRemoteUserIds().length<1&&this._clearTimerById(c);var u=Object.keys(this._userInfo).length<2,d=this._inviterId===n,C=Object.values(this._userInfo).every((function(e){return e.state!==exports.RCCallUserState.KEEPING}));(u||d&&C)&&this._notifyStateChange(exports.RCCallSessionState.END,E[s]),this._watchers.onHungup(o({userId:n},a),E[s])}else this._logger.info("_","[RCCallStateMachine] Invalid hang up message, current room status has ended -> sessionState: ".concat(this._sessionState));else this._otherClientHandle(e)}}),Object.defineProperty(t.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._watchers=e}}),Object.defineProperty(t.prototype,"__onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r,o=this,n=e.senderUserId,i=e.content,l=e.sentTime,c=i,u=c.inviteUserIds,d=c.user,C=c.deviceId;c.roomType===b.RCCallRoomTypeAcrossCall?(t=s(n.split("_"),2),r=t[1],this._watchers.crossAppkey(!0),this._isCrossAppkey=!0):r=n;var _=this._context.getCurrentId();if(this._isRemoteInvalidMsg(r,C))this._logger.debug("_","[RCCallStateMachine] __onInvite -> not the remote device that is currently talking");else if(_!==r){this._callerId=this._inviterId=r;var h=a([n],s(u),!1);this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:h.filter((function(e){return o._isCrossAppkey?e.split("_")[1]!==_:e!==_}))});var f=this._isCrossAppkey?[u[0].split("_")[1]]:u;a([r],s(f),!1).forEach((function(e){o._userInfo[e]={userId:e,state:exports.RCCallUserState.WAITING,isCaller:e===r,isRemote:e!==_},e===r&&Object.assign(o._userInfo[e],d,{deviceId:C}),o._notifyUserStateChange(o._userInfo[e]),e!==r&&(o._userTimers[e]=new v((function(){var t=e===_?exports.RCCallEndReason.NO_RESPONSE:exports.RCCallEndReason.REMOTE_NO_RESPONSE;e===_?o._hungupHandle(t,!1):(o._userInfo[e]&&(o._userInfo[e].state=exports.RCCallUserState.NONE),o._notifyUserStateChange(o._userInfo[e]),o._watchers.onHungup(o._userInfo[e],t),delete o._userInfo[e]),o._clearTimerById(e)}),o._getTimeout(l)))})),this._notifyStateChange(exports.RCCallSessionState.WAITING)}}}),Object.defineProperty(t.prototype,"__onMemberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,r=e.senderUserId,n=e.content,i=e.sentTime,s=n,a=s.user,c=s.existedUserPofiles,u=s.caller,d=s.deviceId,C=s.inviteUserIds,_=s.mediaType,h=this._context.getCurrentId();if(this._isRemoteInvalidMsg(r,d))this._logger.debug("_","[RCCallStateMachine] __onMemberModify -> not the remote device that is currently talking");else if(h!==r){if(this._callerId=u,this._inviterId=r,C.forEach((function(e){c.push({userId:e,mediaType:_,callStatus:l.INCOMING})})),C.includes(h)){var f=[];c.forEach((function(e){e.userId!==h&&f.push(e.userId)})),this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:f}),this._notifyStateChange(exports.RCCallSessionState.WAITING)}else this._watchers.onMemberModify({sender:o({userId:r},a),invitedUsers:C.map((function(e){return{userId:e}}))});c.forEach((function(e){var o=e.userId,n=e.callStatus;if(n!==l.IDLE&&(t._userInfo[o]={userId:o,state:n!==l.CONNECTED?exports.RCCallUserState.WAITING:exports.RCCallUserState.KEEPING,isCaller:r===o,isRemote:h!==o},o===r&&Object.assign(t._userInfo[o],a,{deviceId:d}),t._notifyUserStateChange(t._userInfo[o]),n!==l.CONNECTED&&!t._userTimers[o])){if(!C.includes(o))return;t._userTimers[o]=new v((function(){t._userInfo[o]&&(t._userInfo[o].state=exports.RCCallUserState.NONE);var e=o===h?exports.RCCallEndReason.NO_RESPONSE:exports.RCCallEndReason.REMOTE_NO_RESPONSE;t._notifyUserStateChange(t._userInfo[o],e);try{t._watchers.onHungup(t._userInfo[o],e)}catch(e){t._logger.error("_","[RCCallStateMachine] call onhungup error -> ".concat(null==e?void 0:e.stack))}delete t._userInfo[o],(Object.keys(t._userInfo).length<2||o===h)&&t._notifyStateChange(exports.RCCallSessionState.END,e),t._clearTimerById(o)}),t._getTimeout(i))}}))}}}),Object.defineProperty(t.prototype,"__handleInviteInSession",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var e in this._logger.info("_","StateMachine -> __handleInviteInSession"),this._userInfo)this._userInfo[e].state&&(this._userInfo[e].state=exports.RCCallUserState.NONE),this._notifyUserStateChange(this._userInfo[e]),this._clearTimerById(e);this._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.BUSY_LINE),this._callMsgHandler.sendHungup({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:exports.RCCallEndReason.BUSY_LINE,userIds:this.getRemoteUserIds()})}}),Object.defineProperty(t.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,r,o){return void 0===t&&(t=""),void 0===o&&(o=!1),n(this,void 0,void 0,(function(){var n,l,c,u,d,C,_=this;return i(this,(function(i){switch(i.label){case 0:return this._logger.debug("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(e))),n=this._callerId=this._inviterId=this._context.getCurrentId(),[4,this._callMsgHandler.sendInvite({roomType:o?b.RCCallRoomTypeAcrossCall:b.RCCallRoomTypeNormalCall,channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:t,pushConfig:r,mediaType:this._mediaType,inviteUserIds:e.filter((function(e){return e!==n}))})];case 1:return l=i.sent(),c=l.code,u=l.message,this._isCrossAppkey=o,c===exports.RCCallErrorCode.SUCCESS?(d=u.sentTime,a([n],o?[e[0].split("_")[1]]:s(e),!1).forEach((function(e){var t=e===n;_._userInfo[e]={userId:e,state:exports.RCCallUserState.WAITING,isCaller:t,isRemote:!t},_._notifyUserStateChange(_._userInfo[e]),t||(_._userTimers[e]=new v((function(){_._userInfo[e]&&(_._userInfo[e].state=exports.RCCallUserState.NONE),_._notifyUserStateChange(_._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),_._watchers.onHungup(_._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),delete _._userInfo[e],Object.keys(_._userInfo).length<2&&_._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_NO_RESPONSE),0===_.getRemoteUserIds().length&&_._userInfo[n].state!==exports.RCCallUserState.KEEPING&&_._hungupHandle(exports.RCCallEndReason.REMOTE_NO_RESPONSE)}),_._getTimeout(d)))})),this._notifyStateChange(exports.RCCallSessionState.WAITING)):(C=c===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR,this._notifyStateChange(exports.RCCallSessionState.END,C)),[2,{code:c}]}}))}))}}),Object.defineProperty(t.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,t,r,o,n;return i(this,(function(i){switch(i.label){case 0:return this._logger.debug("_","[RCCallStateMachine] accept"),e=this._context.getCurrentId(),[4,this._callMsgHandler.sendAccept({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,mediaType:this._mediaType,userIds:this.getRemoteUserIds()})];case 1:return t=i.sent(),r=t.code,o=t.message,this._clearTimerById(e),r===exports.RCCallErrorCode.SUCCESS?(o.sentTime,this._userInfo[e]&&(this._userInfo[e].state=exports.RCCallUserState.KEEPING),this._beginTimestamp=Date.now(),this._notifyUserStateChange(this._userInfo[e]),this._notifyStateChange(exports.RCCallSessionState.KEEPING)):(this._userInfo[e]&&(this._userInfo[e].state=exports.RCCallUserState.NONE),this._notifyUserStateChange(this._userInfo[e]),n=r===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR,this._notifyStateChange(exports.RCCallSessionState.END,n)),[2,{code:r}]}}))}))}}),Object.defineProperty(t.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r){return void 0===r&&(r={}),n(this,void 0,void 0,(function(){var o,n,c,u,d,C,_,h,f,p,g=this;return i(this,(function(i){switch(i.label){case 0:return this._conversationType!==e.ConversationType.GROUP?[2,{code:exports.RCCallErrorCode.CONVERSATION_NOT_GROUP_ERROR}]:(this._logger.debug("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(t))),o=this._context.getCurrentId(),n=Object.keys(this._userInfo),c=n.map((function(e){var r=l.CONNECTED;return(t.includes(e)||g._userInfo[e].state===exports.RCCallUserState.WAITING)&&(r=l.RINGING),{userId:e,mediaType:g._mediaType,callStatus:r,mediaId:e}})),u=r.extra,d=void 0===u?"":u,C=r.pushConfig,[4,this._callMsgHandler.sendMemeberModify({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:d,pushConfig:C,mediaType:this._mediaType,inviteUserIds:t.filter((function(e){return e!==o})),callerId:this.getCallerId(),existedUserPofiles:c,directionalUserIdList:a(a([],s(n),!1),s(t),!1).filter((function(e){return e!==o}))})]);case 1:return _=i.sent(),h=_.code,f=_.message,h===exports.RCCallErrorCode.SUCCESS?(p=f.sentTime,t.forEach((function(e){g._userInfo[e]={userId:e,state:exports.RCCallUserState.WAITING,isCaller:!1,isRemote:!0},g._notifyUserStateChange(g._userInfo[e]),g._userTimers[e]=new v((function(){g._userInfo[e]&&(g._userInfo[e].state=exports.RCCallUserState.NONE),g._notifyUserStateChange(g._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),g._watchers.onHungup(g._userInfo[e],exports.RCCallEndReason.REMOTE_NO_RESPONSE),delete g._userInfo[e],Object.keys(g._userInfo).length<2&&g._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_NO_RESPONSE)}),g._getTimeout(p))}))):t.forEach((function(e){g._userInfo[e]={userId:e,state:exports.RCCallUserState.NONE,isCaller:!1,isRemote:!0};var t=h===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR;g._notifyUserStateChange(g._userInfo[e],t)})),[2,{code:h}]}}))}))}}),Object.defineProperty(t.prototype,"_hungupHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t=!0),n(this,void 0,void 0,(function(){var r,o,n,s,a;return i(this,(function(i){switch(i.label){case 0:return r=this._context.getCurrentId(),o=exports.RCCallErrorCode.SUCCESS,t?(n={channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:e,userIds:this.getRemoteUserIds(),pushConfig:this._hungupPushConfig},e!==exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL?[3,1]:(this._callMsgHandler.sendHungup(n),[3,3])):[3,3];case 1:return[4,this._callMsgHandler.sendHungup(n)];case 2:s=i.sent().code,o=s,i.label=3;case 3:for(a in this._endTimestamp=Date.now(),this._userInfo)this._userInfo[a].state=exports.RCCallUserState.NONE,a===r?this._notifyUserStateChange(this._userInfo[a],e):this._notifyUserStateChange(this._userInfo[a]),delete this._userInfo[a];return Object.keys(this._userInfo).length<2&&this._notifyStateChange(exports.RCCallSessionState.END,e),[2,{code:o}]}}))}))}}),Object.defineProperty(t.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,t,r;return i(this,(function(o){for(r in this._logger.debug("_","[RCCallStateMachine] hungup"),e=this._context.getCurrentId(),t=exports.RCCallEndReason.HANGUP,Object.keys(this._userTimers).length>0&&(this._userInfo[e].isCaller?t=exports.RCCallEndReason.CANCEL:this._userInfo[e].state===exports.RCCallUserState.WAITING&&(t=exports.RCCallEndReason.REJECT)),this._userTimers)this._clearTimerById(r);return[2,this._hungupHandle(t)]}))}))}}),Object.defineProperty(t.prototype,"changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return this._logger.debug("_","[RCCallStateMachine] changeMediaType -> mediaType: ".concat(e)),[4,this._callMsgHandler.sendMediaModify({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,mediaType:e,userIds:this.getRemoteUserIds()})];case 1:return(t=r.sent().code)===exports.RCCallErrorCode.SUCCESS&&(this._mediaType=e),[2,{code:t}]}}))}))}}),Object.defineProperty(t.prototype,"userJoin",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this._logger.debug("_","[RCCallStateMachine] userJoin -> userIds: ".concat(JSON.stringify(e))),setTimeout((function(){e.forEach((function(e){var r=t._userInfo[e];r&&r.state!==exports.RCCallUserState.KEEPING&&(r.state=exports.RCCallUserState.KEEPING,t._notifyUserStateChange(r)),t._sessionState!==exports.RCCallSessionState.KEEPING&&t._notifyStateChange(exports.RCCallSessionState.KEEPING),t._clearTimerById(e)}))}),300)}}),Object.defineProperty(t.prototype,"userLeave",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this._logger.debug("_","[RCCallStateMachine] userLeave -> userIds: ".concat(JSON.stringify(e))),setTimeout((function(){e.forEach((function(e){var r=t._userInfo[e];r&&r.state!==exports.RCCallUserState.NONE&&(r.state=exports.RCCallUserState.NONE,t._notifyUserStateChange(r,exports.RCCallEndReason.REMOTE_HANGUP),t._watchers.onHungup(r,exports.RCCallEndReason.REMOTE_HANGUP),delete t._userInfo[e]),new v((function(){var e=t.getRemoteUsers();1===e.length&&1===e[0].state&&t._hungupHandle(exports.RCCallEndReason.REMOTE_NETWORK_ERROR)}),6e4),Object.keys(t._userInfo).length<2&&t._sessionState!==exports.RCCallSessionState.END&&(t._endTimestamp=Date.now(),t._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_HANGUP))}))}),300)}}),Object.defineProperty(t.prototype,"close",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hungupHandle(e)}}),Object.defineProperty(t.prototype,"setHungupPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hungupPushConfig=e}}),Object.defineProperty(t.prototype,"getCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(t.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._channelId}}),Object.defineProperty(t.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._targetId}}),Object.defineProperty(t.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._conversationType}}),Object.defineProperty(t.prototype,"getRemoteUserIds",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return Object.keys(this._userInfo).filter((function(t){return e._context.getCurrentId()!==t}))}}),Object.defineProperty(t.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[],t=this._context.getCurrentId();for(var r in this._userInfo){this._userInfo[r].userId!==t&&e.push(this._userInfo[r])}return e}}),Object.defineProperty(t.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null===this._sessionState?exports.RCCallSessionState.END:this._sessionState}}),Object.defineProperty(t.prototype,"getUserState",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t;return null===(t=this._userInfo[e])||void 0===t?void 0:t.state}}),Object.defineProperty(t.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callerId}}),Object.defineProperty(t.prototype,"getInviterId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._inviterId}}),Object.defineProperty(t.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mediaType}}),Object.defineProperty(t.prototype,"getSummary",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._beginTimestamp,t=this._endTimestamp,r=0;t>e&&0!==e&&(r=t-e);var o={conversationType:this._conversationType,channelId:this._channelId,targetId:this._targetId,mediaType:this._mediaType,beginTimestamp:e,endTimestamp:t,duration:r,endReason:this._endReason};return this._logger.debug("_","[RCCallStateMachine] getSummary -> summary: ".concat(JSON.stringify(o))),o}}),t}();exports.RCCallMediaType=void 0,(I=exports.RCCallMediaType||(exports.RCCallMediaType={}))[I.AUDIO=1]="AUDIO",I[I.AUDIO_VIDEO=2]="AUDIO_VIDEO",function(e){e[e.ADD=1]="ADD",e[e.REMOVE=2]="REMOVE"}(y||(y={})),function(e){e.WEB="Web",e.IOS="iOS",e.ANDROID="Android"}(m||(m={}));var T,S,M=function(){function e(e,t,r){Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_onRecord",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_messages",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_channelId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_conversationType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_targetId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_callerId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_inviterId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_endReason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_beginTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_endTimestamp",{enumerable:!0,configurable:!0,writable:!0,value:0})}return Object.defineProperty(e.prototype,"_doInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._context.getCurrentId();var t=e.channelId,r=e.conversationType,o=e.targetId,n=e.senderUserId,i=e.content,s=i.callId,a=i.mediaType;this._channelId=t,this._conversationType=r,this._targetId=o,this._callId=s,this._mediaType=a;this._inviterId=n,this._endReason=exports.RCCallEndReason.REMOTE_NO_RESPONSE,this._canGenRecord()}}),Object.defineProperty(e.prototype,"_doMemberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._doInvite(e)}}),Object.defineProperty(e.prototype,"_doRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._canGenRecord()}}),Object.defineProperty(e.prototype,"_doAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._endReason=exports.RCCallEndReason.HANGUP,this._beginTimestamp=e.sentTime,this._canGenRecord()}}),Object.defineProperty(e.prototype,"_doHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.content,r=e.sentTime,o=e.senderUserId,n=t.reason,i=o===this._context.getCurrentId();this._endReason=i?n:E[n],this._endTimestamp=r,this._canGenRecord()}}),Object.defineProperty(e.prototype,"_doMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.content.mediaType;this._mediaType=t,this._canGenRecord()}}),Object.defineProperty(e.prototype,"_canGenRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(0===this._messages.length){var e=0;[exports.RCCallEndReason.HANGUP,exports.RCCallEndReason.REMOTE_HANGUP,exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL,exports.RCCallEndReason.REMOTE_OTHER_CLIENT_JOINED_CALL,exports.RCCallEndReason.KICKED_BY_SERVER,exports.RCCallEndReason.REMOTE_KICKED_BY_SERVER,exports.RCCallEndReason.ACCEPT_SYSTEM_CALL,exports.RCCallEndReason.REMOTE_ACCEPT_SYSTEM_CALL].includes(this._endReason)&&(e=this._endTimestamp-this._beginTimestamp),this._onRecord({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,inviterId:this._inviterId,mediaType:this._mediaType,endReason:this._endReason,beginTimestamp:this._beginTimestamp,endTimestamp:this._endTimestamp,duration:e})}}}),Object.defineProperty(e.prototype,"onRecvOfflineMsgs",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._messages=e;do{var t=this._messages.shift(),r=t.messageType;switch(t.content.callId,r){case p.VCInvite:this._doInvite(t);break;case p.VCRinging:this._doRinging(t);break;case p.VCAccept:this._doAccept(t);break;case p.VCModifyMem:this._doMemberModify(t);break;case p.VCModifyMedia:this._doMediaModify(t);break;case p.VCHangup:this._doHungup(t);break;default:this._logger.debug("_","[OfflineRecorder] onRecvOfflineMsgs -> unexpected message: ".concat(JSON.stringify(t)))}}while(this._messages.length>0)}}),e}(),x=["RC:VCAccept","RC:VCRinging","RC:VCSummary","RC:VCHangup","RC:VCInvite","RC:VCModifyMedia","RC:VCModifyMem"],P=((T={})[e.ErrorCode.REJECTED_BY_BLACKLIST]=exports.RCCallErrorCode.REJECTED_BY_BLACKLIST,T[e.ErrorCode.NOT_IN_GROUP]=exports.RCCallErrorCode.NOT_IN_GROUP,T),w=function(t){function o(e,r,o,n,i){void 0===n&&(n=6e4);var s=t.call(this)||this;return Object.defineProperty(s,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(s,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(s,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(s,"_offlineMsgItv",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(s,"_getStateMachine",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(s,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(s,"_userInfo",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(s,"_msgBufferList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(s,"_hadHandleMsgTimer",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(s,"_offlineRecorder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(s,"_deviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),s._deviceId=f(r),s._context.onmessage=s._onMessage.bind(s),s._offlineRecorder=new M(s._context,s._logger,(function(e){s._logger.info("_","[CallMessageHandler] offlineRecorder -> ".concat(JSON.stringify(e))),s._watchers.onOfflineRecord&&s._watchers.onOfflineRecord(e)})),s}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}(o,t),Object.defineProperty(o.prototype,"_onMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(x.includes(e.messageType)){this._logger.debug("_","[CallMessageHandler] _onMessage -> call message: ".concat(JSON.stringify(e)));try{var t=Date.now(),r=e.sentTime,o=0;this._msgBufferList.forEach((function(e,t){var n=e.msg.sentTime;r>=n&&(o=t+1)})),this._msgBufferList.splice(o,0,{markTime:t,msg:e}),this._logger.warn("_","onMessage -> msgBufferList: ".concat(this._msgBufferList.length))}catch(e){this._logger.error("_","[CallMessageHandler] splice buffer msg error -> ".concat(e.message))}return this._handleBufferMsgs(),!0}return!1}}),Object.defineProperty(o.prototype,"_onRecvOnlineCallMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.info("_","onMessage -> _onRecvOnlineCallMsg: ".concat(e.messageType));var r=e.content.callId;switch(e.messageType){case p.VCInvite:this._watchers.onInvite&&this._watchers.onInvite(e);break;case p.VCRinging:t.prototype.emit.call(this,"".concat(r,"onRinging"),e);break;case p.VCAccept:t.prototype.emit.call(this,"".concat(r,"onAccept"),e);break;case p.VCModifyMem:this._watchers.onInvite&&this._watchers.onInvite(e);break;case p.VCModifyMedia:t.prototype.emit.call(this,"".concat(r,"onMediaModify"),e);break;case p.VCHangup:t.prototype.emit.call(this,"".concat(r,"onHungup"),e);break;default:this._logger.warn("_","[CallMessageHandler] onRecvOnlineCallMsg -> unexpected message: ".concat(JSON.stringify(e)))}}}),Object.defineProperty(o.prototype,"_handleBufferMsgs",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;0===this._msgBufferList.length||this._hadHandleMsgTimer?this._logger.warn("_","_handleBufferMsgs return"):(this._hadHandleMsgTimer=!0,setTimeout((function(){var r=Date.now(),o=t._msgBufferList.filter((function(e){return r-e.markTime>=200}));if(t._logger.debug("_","[CallMessageHandler] handleBufferMsgs -> lists over 200ms : ".concat(JSON.stringify(o.map((function(e){var t=e.msg;return{messageUId:t.messageUId,isOffLineMessage:t.isOffLineMessage,callId:t.content.callId}}))))),0===o.length)return t._hadHandleMsgTimer=!1,void t._handleBufferMsgs();if(o[0].msg.isOffLineMessage){var n=t._msgBufferList.filter((function(e){return e.msg.isOffLineMessage})),i=function(){var r=n[0].msg,o=r.conversationType,i=r.messageType,l=r.sentTime,c=r.senderUserId,u=r.content,d=u.callId,C=u.inviteUserIds,_=[p.VCInvite,p.VCModifyMem].includes(i),h=t._context.getServerTime()-l,f=h<t._offlineMsgItv;if(f||t._logger.warn("_","offline msg delayTime: ".concat(h,"ms")),_){for(var g=[],R=0;R<n.length;R++){var b=n[R].msg;if(d!==b.content.callId)break;g.push(b)}if(t._logger.warn("_","taskMsgList length: ".concat(g.length)),g.length>0){var E=t._msgBufferList.findIndex((function(e){return e.msg.messageUId===g[g.length-1].messageUId}));t._msgBufferList=t._msgBufferList.slice(E+1);var I=n.findIndex((function(e){return e.msg.messageUId===g[g.length-1].messageUId}));n=n.slice(I+1)}var y=function(){if(o!==e.ConversationType.PRIVATE)return!1;var t=1===g.length,r=g.every((function(e){return[p.VCInvite,p.VCModifyMedia,p.VCRinging].includes(e.messageType)}));return t||r}(),m=function(){if(o!==e.ConversationType.GROUP)return!1;for(var r=!1,n=!0,i=a([c],s(C),!1),l=!1,u=function(e){var r=g[e],o=r.senderUserId,s=r.messageType;if(s===p.VCHangup&&o===t._context.getCurrentId())return"break";s===p.VCHangup&&(l=c===o,i=i.filter((function(e){return o!==e}))),s===p.VCAccept&&(n=!1)},d=0;d<g.length;d++){if("break"===u(d))break}return n&&l||!(i.length>1)||(r=!0),r}();f&&(y||m)&&g.forEach(t._onRecvOnlineCallMsg,t),t._offlineRecorder.onRecvOfflineMsgs(g)}else f&&t._getStateMachine(d)?t._onRecvOnlineCallMsg(n[0].msg):t._logger.debug("_","[CallMessageHandler] unexcepted offline msg -> ".concat(JSON.stringify(n[0].msg))),n.shift(),t._msgBufferList.shift()};do{i()}while(n.length>0)}else{o.forEach((function(e){var r=e.msg;t._onRecvOnlineCallMsg(r)}));var l=o.length;t._msgBufferList.splice(0,l),t._logger.debug("_","timer online msg handle -> delCount: ".concat(l," msgBufferList: ").concat(t._msgBufferList.length))}t._hadHandleMsgTimer=!1,t._handleBufferMsgs()}),20))}}),Object.defineProperty(o.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){Object.assign(this._watchers,e)}}),Object.defineProperty(o.prototype,"registerStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,o){var n=e+r;t.prototype.on.call(this,n,o)}}),Object.defineProperty(o.prototype,"unregisterStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var r=this;["onRinging","onAccept","onHungup","onMediaModify"].forEach((function(o){var n=e+o;t.prototype.removeAll.call(r,n)}))}}),Object.defineProperty(o.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._userInfo=e}}),Object.defineProperty(o.prototype,"_sendCallMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return n(this,void 0,void 0,(function(){var r,o,n,s,a,l,c,u,d,C,_,h;return i(this,(function(i){switch(i.label){case 0:return this._logger.debug("_","CallMessageHandler] sendCallMesage -> message: ".concat(JSON.stringify(t))),r=t.channelId,o=t.conversationType,n=t.targetId,s=t.content,a=t.messageType,l=t.directionalUserIdList,c=t.pushConfig,u={channelId:r,messageType:a,content:s,directionalUserIdList:l},[p.VCInvite,p.VCModifyMem,p.VCHangup].includes(a)&&((d=c||{pushTitle:"",pushContent:"",pushData:""}).androidConfig=Object.assign((null==c?void 0:c.androidConfig)||{},{categoryHW:"VOIP",categoryVivo:"IM"}),d.iOSConfig=Object.assign(d.iOSConfig||{},{apnsCollapseId:s.callId}),d.disablePushTitle=!1,d.forceShowDetailContent=!1,u.pushConfig=d),[4,this._context.sendMessage(o,n,u)];case 1:return C=i.sent(),_=C.code,h=C.data,_!==e.ErrorCode.SUCCESS?(this._logger.error("_","CallMessageHandler] sendCallMesage error -> code: ".concat(_)),[2,{code:P[_]||exports.RCCallErrorCode.SEND_MSG_ERROR}]):[2,{code:exports.RCCallErrorCode.SUCCESS,message:h}]}}))}))}}),Object.defineProperty(o.prototype,"sendInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return n(this,void 0,void 0,(function(){var r,o,n,s,a,l,c,u,d,C;return i(this,(function(i){return r=t.roomType,o=t.channelId,n=t.conversationType,s=t.targetId,a=t.callId,l=t.mediaType,c=t.inviteUserIds,u=t.extra,d=t.pushConfig,this._logger.warn("_","CallMessageHandler] sendCallMesage sendInvite",JSON.stringify(t)),this._watchers.sendAccept&&this._watchers.sendAccept({callId:a}),C={platform:m.WEB,deviceId:this._deviceId,callId:a,roomType:r,extra:u,engineType:4,channelInfo:{Id:a,Key:""},mediaType:l,inviteUserIds:c,observerUserIds:[],user:this._userInfo},d&&(d.pushData=JSON.stringify({mediaType:l,userIdList:c,callId:a})),[2,this._sendCallMessage({channelId:o,conversationType:n,targetId:s,content:C,messageType:p.VCInvite,directionalUserIdList:n===e.ConversationType.GROUP?c:void 0,pushConfig:d})]}))}))}}),Object.defineProperty(o.prototype,"sendMemeberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){var t,r,o,n,s,a,l,c,u,d,C,_;return i(this,(function(i){return t=e.channelId,r=e.conversationType,o=e.targetId,n=e.callId,s=e.mediaType,a=e.inviteUserIds,l=e.callerId,c=e.existedUserPofiles,u=e.directionalUserIdList,d=e.extra,C=e.pushConfig,_={platform:m.WEB,deviceId:this._deviceId,callId:n,extra:d,engineType:4,channelInfo:{Id:n,Key:""},mediaType:s,inviteUserIds:a,observerUserIds:[],user:this._userInfo,caller:l,modifyMemType:y.ADD,existedUserPofiles:c},C&&(C.pushData=JSON.stringify({mediaType:s,userIdList:a,callId:n})),[2,this._sendCallMessage({channelId:t,conversationType:r,targetId:o,content:_,messageType:p.VCModifyMem,directionalUserIdList:u,pushConfig:C})]}))}))}}),Object.defineProperty(o.prototype,"sendRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,o=t.conversationType,n=t.targetId,i=t.callId,s=t.userIds,a={platform:m.WEB,deviceId:this._deviceId,callId:i,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:a,messageType:p.VCRinging,directionalUserIdList:o===e.ConversationType.GROUP?s:void 0})}}),Object.defineProperty(o.prototype,"sendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,o=t.conversationType,n=t.targetId,i=t.callId,s=t.mediaType,a=t.userIds,l={platform:m.WEB,deviceId:this._deviceId,callId:i,mediaType:s,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:l,messageType:p.VCAccept,directionalUserIdList:o===e.ConversationType.GROUP?a:void 0})}}),Object.defineProperty(o.prototype,"sendHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,o=t.conversationType,n=t.targetId,i=t.callId,s=t.reason,a=t.userIds,l=t.pushConfig,c={platform:m.WEB,deviceId:this._deviceId,callId:i,reason:s,user:this._userInfo};return l&&(l.pushData=JSON.stringify({callId:i,reason:s})),this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:c,messageType:p.VCHangup,pushConfig:l,directionalUserIdList:o===e.ConversationType.GROUP?a:void 0})}}),Object.defineProperty(o.prototype,"sendMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var r=t.channelId,o=t.conversationType,n=t.targetId,i=t.callId,s=t.mediaType,a=t.userIds,l={platform:m.WEB,deviceId:this._deviceId,callId:i,mediaType:s,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:l,messageType:p.VCModifyMedia,directionalUserIdList:o===e.ConversationType.GROUP?a:void 0})}}),o}(e.EventEmitter);exports.RCCallLanguage=void 0,(S=exports.RCCallLanguage||(exports.RCCallLanguage={})).ZH="zh",S.EN="en";var A,N={PushTitle:{AUDIO:"You have a voice call",VIDEO:"You have a video call"}},U={PushTitle:{AUDIO:"您有一条音频通话",VIDEO:"您有一条视频通话"}},L=function(){function e(){}return Object.defineProperty(e,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._lang=e}}),Object.defineProperty(e,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._lang===exports.RCCallLanguage.EN?N:U}}),Object.defineProperty(e,"_lang",{enumerable:!0,configurable:!0,writable:!0,value:exports.RCCallLanguage.ZH}),e}(),j=function(){function t(e,t,r,o,n){var i=this;Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_stateMachine",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"_callMsgHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._logger.warn("_","RCCallEngine Version: ".concat("5.2.7"," CommitId: ").concat("8e146acd55898ff5e053f17a48c4e7dbcef8d4de")),f(t),this._callMsgHandler=new w(this._context,this._runtime,this._logger,this._options.offlineMsgItv,this._getStateMachine.bind(this)),this._callMsgHandler.registerEventListener({onInvite:this._onInvite.bind(this),sendAccept:this._handleSendAccept.bind(this),onOfflineRecord:this._watchers.onOfflineRecord}),h.on("onStateMachineClose",(function(e){delete i._stateMachine[e]})),L.set(n.lang)}return Object.defineProperty(t.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.channelId,r=e.conversationType,o=e.targetId,n=e.content,i=e.messageType,a=e.senderUserId;e.pushConfig,this._logger.warn("_","RCCallEngine _onInvite:targetId ".concat(o," senderUserId: ").concat(a));var l,c=n,u=c.mediaType,d=c.callId,C=c.extra;l=c.roomType!==b.RCCallRoomTypeAcrossCall?a:s(a.split("_"),2)[1];var _=this._context.getCurrentId();if(this._context.getCurrentId()!==l){if(i===p.VCModifyMem)if(n.existedUserPofiles.some((function(e){return e.userId===_}))&&!this._stateMachine[d])return;if(this._stateMachine[d])i===p.VCModifyMem&&this._stateMachine[d].__onMemberModify(e);else this._stateMachine[d]=new O(this._context,this._runtime,this._logger,this._callMsgHandler,t,r,o,u,d),this._logger.info("_","[RCCallEngine] RCCallStateMachine successfully created -> callId: ".concat(d)),i===p.VCInvite?this._stateMachine[d].__onInvite(e):i===p.VCModifyMem&&this._stateMachine[d].__onMemberModify(e),this._watchers.onInvite(this._stateMachine[d],C),Object.keys(this._stateMachine).filter((function(e){return d!==e})).length>0&&!this._options.isAllowAcceptNewCall&&this._stateMachine[d].__handleInviteInSession()}}}),Object.defineProperty(t.prototype,"_handleSendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this._options.isAllowAcceptNewCall){var t=e.callId;for(var r in this._stateMachine)t!==r&&(this._stateMachine[r].hungup(),delete this._stateMachine[r])}}}),Object.defineProperty(t.prototype,"_getStateMachine",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._stateMachine[e]}}),Object.defineProperty(t.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._logger.debug("_","[RCCallEngine] registerUserInfo -> userInfo: ".concat(JSON.stringify(e))),this._callMsgHandler.registerUserInfo(e)}}),Object.defineProperty(t.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,o,s,a,l){return void 0===s&&(s=""),void 0===l&&(l=!1),n(this,void 0,void 0,(function(){var n,c;return i(this,(function(i){switch(i.label){case 0:return this._logger.debug("_","[RCCallEngine] call -> args: ".concat(JSON.stringify({channelId:t,targetId:r,mediaType:o,extra:s,pushConfig:a}))),n=_(),Object.keys(this._stateMachine).length>0?[2,{code:exports.RCCallErrorCode.STATE_MACHINE_EXIT}]:(this._stateMachine[n]=new O(this._context,this._runtime,this._logger,this._callMsgHandler,t,e.ConversationType.PRIVATE,r,o,n),[4,this._stateMachine[n].__call([r],s,a,l)]);case 1:return(c=i.sent().code)===exports.RCCallErrorCode.SUCCESS?[2,{code:exports.RCCallErrorCode.SUCCESS,stateMachine:this._stateMachine[n]}]:[2,{code:c}]}}))}))}}),Object.defineProperty(t.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(t,r,o,s,a,l){return void 0===a&&(a=""),n(this,void 0,void 0,(function(){var n,c;return i(this,(function(i){switch(i.label){case 0:return this._logger.debug("_","[RCCallEngine] callInGroup -> args: ".concat(JSON.stringify({channelId:t,targetId:r,mediaType:o}))),n=_(),Object.keys(this._stateMachine).length>0?[2,{code:exports.RCCallErrorCode.STATE_MACHINE_EXIT}]:(this._stateMachine[n]=new O(this._context,this._runtime,this._logger,this._callMsgHandler,t,e.ConversationType.GROUP,r,o,n),[4,this._stateMachine[n].__call(s,a,l)]);case 1:return(c=i.sent().code)===exports.RCCallErrorCode.SUCCESS?[2,{code:exports.RCCallErrorCode.SUCCESS,stateMachine:this._stateMachine[n]}]:[2,{code:c}]}}))}))}}),Object.defineProperty(t.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._logger.debug("_","[RCCallEngine] destroy"),this._stateMachine={}}}),t}();!function(e){e[e.CALLER=1]="CALLER",e[e.CALLEE=2]="CALLEE"}(A||(A={}));var k=new(function(){function e(){Object.defineProperty(this,"list",{enumerable:!0,configurable:!0,writable:!0,value:{}})}return Object.defineProperty(e.prototype,"on",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return(this.list[e]||(this.list[e]=[])).push(t),this}}),Object.defineProperty(e.prototype,"once",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,o=function(n){r.off(e,o),t.call(r,n)};o.fun=t,this.on(e,o)}}),Object.defineProperty(e.prototype,"off",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this.list[e];if(!r)return!1;if(t){for(var o=void 0,n=0,i=r.length;n<i;n++)if((o=r[n])===t||o.fun===t){r.splice(n,1);break}}else r&&(r.length=0)}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r=this,o=a([],s(this.list[e]),!1);if(!o||0===o.length)return!1;o.forEach((function(e){e.call(r,t)}))}}),e}());var D=function(t){if(!t)return{ok:!1,msg:"Initialization missing parameter -> options"};if("object"!=typeof t)return{ok:!1,msg:"Initialization options must be an object"};var r,o=Object.keys(t),n=[];return["rtcClient","onSession","onSessionClose"].forEach((function(e){o.includes(e)||n.push(e)})),n.length?{ok:!1,msg:'Initialization missing parameter -> "'.concat(n.join(","),'"')}:"object"!=typeof t.rtcClient?{ok:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:"function"!=typeof t.onSession?{ok:!1,msg:"Initialization 'onSession' parameter must be of type 'function'"}:"function"!=typeof t.onSessionClose?{ok:!1,msg:"Initialization 'onSessionClose' parameter must be of type 'function'"}:void 0!==t.isAllowSubscribeRetry&&"boolean"!=typeof t.isAllowSubscribeRetry?{ok:!1,msg:"Initialization 'isAllowSubscribeRetry' parameter must be of type 'boolean'"}:void 0!==t.isAllowPublishRetry&&"boolean"!=typeof t.isAllowPublishRetry?{ok:!1,msg:"Initialization 'isAllowPublishRetry' parameter must be of type 'boolean'"}:void 0!==t.isOffCameraWhenVideoDisable&&"boolean"!=typeof t.isOffCameraWhenVideoDisable?{ok:!1,msg:"Initialization 'isOffCameraWhenVideoDisable' parameter must be of type 'boolean'"}:void 0===t.joinType||(r=t.joinType,Object.values(e.RTCJoinType).includes(r))?void 0!==t.isAllowDemotionGetStream&&"boolean"!=typeof t.isAllowDemotionGetStream?{ok:!1,msg:"Initialization 'isAllowDemotionGetStream' parameter must be of type 'boolean'"}:void 0===t.lang||function(e){return Object.values(exports.RCCallLanguage).includes(e)}(t.lang)?void 0===t.logOutputLevel||function(t){return[e.LogL.DEBUG,e.LogL.INFO,e.LogL.WARN,e.LogL.ERROR].includes(t)}(t.logOutputLevel)?{ok:!0}:{ok:!1,msg:"Initialization 'logOutputLevel' parameter must be of type correct type"}:{ok:!1,msg:"Initialization 'lang' parameter must be of type correct type"}:{ok:!1,msg:"Initialization 'joinType' parameter must be of type correct type"}},H=function(e){if(!e)return{ok:!1,msg:"missing parameter -> listener"};if("object"!=typeof e)return{ok:!1,msg:"listener must be an object"};var t=Object.keys(e),r=[];return["onRinging","onAccept","onHungup","onTrackReady"].forEach((function(e){t.includes(e)||r.push(e)})),r.length?{ok:!1,msg:'missing parameter -> "'.concat(r.join(","),'"')}:"function"!=typeof e.onRinging?{ok:!1,msg:"'onRinging' parameter must be of type 'function'"}:"function"!=typeof e.onAccept?{ok:!1,msg:"'onAccept' parameter must be of type 'function'"}:"function"!=typeof e.onHungup?{ok:!1,msg:"'onHungup' parameter must be of type 'function'"}:"function"!=typeof e.onTrackReady?{ok:!1,msg:"'onTrackReady' parameter must be of type 'function'"}:{ok:!0}},V=function(e){return e&&"string"==typeof e?{ok:!0}:{ok:!1,msg:"'targetId' parameter is required, must be of type 'string'"}},G=function(e){return e===exports.RCCallMediaType.AUDIO||e===exports.RCCallMediaType.AUDIO_VIDEO?{ok:!0}:{ok:!1,msg:"'mediaType' parameter is required, must be of type 'RCCallMediaType'"}},B=function(e){return"string"==typeof e?{ok:!0}:{ok:!1,msg:"'extra' parameter must be of type 'string'"}},K=function(t){var r=["pushTitle","pushContent","pushData","iOSConfig","androidConfig","disablePushTitle","templateId"],o=Object.keys(t).every((function(e){return r.includes(e)}));if(!o)return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"right key: ".concat(r.join(","))};for(var n=0;n<r.length;n++){var i=r[n];if("disablePushTitle"===i){if(!e.isUndefined(t[i])&&!e.isBoolean(t[i]))return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"".concat(i," type is boolean")}}else if(("pushTitle"===i||"templateId"===i)&&t[i]&&!e.isString(t[i]))return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"".concat(i," type is string")}}var s=t.iOSConfig,a=t.androidConfig,l=J(s||{});if(l.code!==exports.RCCallErrorCode.SUCCESS)return l;var c=W(a||{});return c.code!==exports.RCCallErrorCode.SUCCESS?c:{code:exports.RCCallErrorCode.SUCCESS}},J=function(t){var r=t||{},o=r.threadId,n=r.richMediaUri;return o&&!e.isString(o)?{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:n&&!e.isString(n)?{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:exports.RCCallErrorCode.SUCCESS}},W=function(t){var r=["notificationId","channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"],o=Object.keys(t).every((function(e){return r.includes(e)}));if(!o)return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"right key: ".concat(r.join(","))};for(var n=0;n<r.length;n++){var i=r[n];if("importanceHW"===i||"importanceHonor"===i){if(t[i]&&"LOW"!==t[i]&&"NORMAL"!==t[i])return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"androidConfig.".concat(i," value is NORMAL|LOW")}}else if(t[i]&&!e.isString(t[i]))return{code:exports.RCCallErrorCode.PARAM_ERROR,errorMsg:"androidConfig.".concat(i," type is string")}}return{code:exports.RCCallErrorCode.SUCCESS}},Y=function(e){return Array.isArray(e)&&e.length?e.every((function(e){return"string"==typeof e&&e.length>0}))?{ok:!0}:{ok:!1,msg:"'userIds' parameter is required"}:{ok:!1,msg:"'userIds' parameter is required, must be of type 'string[]'"}};var F=function(e){return e&&e.audio&&void 0!==e.audio.micphoneId&&"string"!=typeof e.audio.micphoneId?{ok:!1,msg:"'constraints.audio.micphoneId' must be of type 'string'"}:e&&e.audio&&void 0!==e.audio.sampleRate&&"number"!=typeof e.audio.sampleRate?{ok:!1,msg:"'constraints.audio.sampleRate' must be of type 'number'"}:e&&e.video&&void 0!==e.video.cameraId&&"string"!=typeof e.video.cameraId?{ok:!1,msg:"'constraints.video.cameraId' must be of type 'string'"}:e&&e.video&&void 0!==e.video.frameRate&&"string"!=typeof e.video.frameRate?{ok:!1,msg:"'constraints.video.frameRate' must be of type 'string'"}:e&&e.video&&void 0!==e.video.frameRate&&(r=e.video.frameRate,!["FPS_10","FPS_15","FPS_24","FPS_30"].includes(r))?{ok:!1,msg:"'frameRate' value is out of range"}:e&&e.video&&void 0!==e.video.resolution&&"string"!=typeof e.video.resolution?{ok:!1,msg:"'constraints.video.frameRate' must be of type 'string'"}:e&&e.video&&void 0!==e.video.resolution&&(o=e.video.resolution,!t.RCResolution[o])?{ok:!1,msg:"'resolution' value is out of range"}:!e||!e.video||e.video.frameRate&&e.video.resolution?{ok:!0}:{ok:!1,msg:"'resolution' and 'resolution' is required"};var r,o},z=function(){function e(e,t){Object.defineProperty(this,"_timerId",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_startTime",{enumerable:!0,configurable:!0,writable:!0,value:0}),e&&(this._timerId=function(e,t){return setTimeout(e,t)}((function(){e()}),t)),this._startTime=Date.now()}return Object.defineProperty(e.prototype,"stop",{enumerable:!1,configurable:!0,writable:!0,value:function(){clearTimeout(this._timerId);var e=Date.now(),t=e-this._startTime;return 0===this._startTime&&(t=0),{startTime:this._startTime,endTime:e,duration:t}}}),Object.defineProperty(e.prototype,"reset",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._startTime=0}}),e}(),q=function(){function r(e,t,r,o){void 0===o&&(o={});var s=this;Object.defineProperty(this,"_stateMachine",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_room",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_listener",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_RETRYCOUNT",{enumerable:!0,configurable:!0,writable:!0,value:2}),Object.defineProperty(this,"joinRoomTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),this._stateMachine.registerEventListener({onUserStateChange:function(e){var t=e.user,r=e.reason;s._logger.info("_","[RCCallSession onUserStateChange] userId->".concat(null==t?void 0:t.userId," state->").concat(null==t?void 0:t.state," reason->").concat(r))},onStateChange:function(e){return n(s,void 0,void 0,(function(){var t,r,o,n,s;return i(this,(function(i){switch(i.label){case 0:if(t=e.state,r=e.reason,this._logger.info("_","[RCCallSession onStateChange] : state->".concat(t," reason->").concat(r)),t!==exports.RCCallSessionState.KEEPING)return[3,5];o=this._stateMachine.getCallId(),this._logger.info("_","[RCCallSession onStateChange] roomId: ".concat(o)),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this._joinRoom(o)];case 2:return i.sent(),[3,4];case 3:return n=i.sent(),this._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR),this._logger.error("_","[RCCallSession onStateChange] joinRoom throw exception roomId -> ".concat(o)),console.error(n),[3,4];case 4:return[3,6];case 5:if(t===exports.RCCallSessionState.END){if(!this._room)return this._options.localTracks&&this._destroyTracks(this._options.localTracks),s=this._stateMachine.getSummary(),k.emit("sessionClose",{session:this,summaryInfo:s}),[2];this._options.localTracks&&this._destroyTracks(this._options.localTracks),this._logger.info("_","[RCCallSession onStateChange] localTracks destroyed"),this._leaveRoom(),this._room=null}i.label=6;case 6:return[2]}}))}))},onRinging:function(e){s._logger.info("_","[RCCallSession onRinging]sender: sender.userId -> ".concat(e.userId));try{s._listener.onRinging(e,s)}catch(e){s._logger.error("_","[RCCallSession onRinging] method exception -> onRinging"),console.error(e)}},onAccept:function(e){s._logger.info("_","[RCCallSession onAccept]sender: sender.userId -> ".concat(e.userId));try{s._listener.onAccept(e,s)}catch(e){s._logger.error("_","[RCCallSession onAccept] method exception -> onAccept"),console.error(e)}},onHungup:function(e,t){s._logger.info("_","[RCCallSession onHungup]sender: sender.userId -> ".concat(e.userId," reason->").concat(t));try{s._listener.onHungup(e,t,s)}catch(e){s._logger.error("_","[RCCallSession onHungup] method exception -> onHungup"),console.error(e)}},onMemberModify:function(e){var t=e.sender,r=e.invitedUsers;s._logger.info("_","[RCCallSession onMemberModify] sender.userId -> ".concat(t.userId));try{s._listener.onMemberModify(t,r,s)}catch(e){s._logger.error("_","[RCCallSession onMemberModify] method exception -> onMemberModify"),console.error(e)}},onMediaModify:function(e){var t=e.sender,r=e.mediaType;s._logger.info("_","[RCCallSession onMediaModify]sender: sender.userId -> ".concat(t.userId," mediaType: ").concat(r)),r===exports.RCCallMediaType.AUDIO&&s._setMediaTypeToAudio();try{s._listener.onMediaModify(t,r,s)}catch(e){s._logger.error("_","[RCCallSession onMediaModify] method exception -> onMediaModify"),console.error(e)}},crossAppkey:function(e){s._logger.info("_","[RCCallSession crossAppkey] 是否跨 appkey: ".concat(e)),s._options.isCrossAppkey=e}}),this._stateMachine.setHungupPushConfig(this._options.hungupPushConfig||{pushTitle:"",pushContent:""})}return Object.defineProperty(r.prototype,"_joinRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(r){return n(this,void 0,void 0,(function(){var o,n,s,a,l,c,u,d=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,7,,8]),this._options.isCrossAppkey?[4,this._rtcClient.joinCrossRTCRoom(r,this._options.joinType)]:[3,2];case 1:return o=i.sent(),[3,4];case 2:return[4,this._rtcClient.joinRTCRoom(r,this._options.joinType)];case 3:o=i.sent(),i.label=4;case 4:return n=o.code,s=o.userIds,a=o.room,n!==t.RCRTCCode.SUCCESS?(n===t.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER&&this._exceptionClose(exports.RCCallEndReason.SERVICE_NOT_OPENED),n===t.RCRTCCode.SIGNAL_JOIN_RTC_ROOM_REFUSED?this._exceptionClose(exports.RCCallEndReason.OTHER_CLIENT_IN_CALL):this._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR),this._logger.info("_","[RCCallClient _joinRoom] join room failed: roomId -> ".concat(r," RCRTCCode -> ").concat(n)),[2,{code:exports.RCCallErrorCode.JOIN_ROOM_ERROR}]):(this._stateMachine.getConversationType()===e.ConversationType.GROUP&&this._stateMachine.userJoin([this._rtcClient.getCurrentId()]),this._stateMachine.getState()!==exports.RCCallSessionState.END?[3,6]:[4,this._rtcClient.leaveRoom(a)]);case 5:return i.sent(),this._room=null,[2,{code:exports.RCCallErrorCode.SUCCESS}];case 6:return s.length<1&&(this.joinRoomTimer=new z((function(){d._exceptionClose(exports.RCCallEndReason.REMOTE_NETWORK_ERROR)}),6e4)),this._room=a,[3,8];case 7:return l=i.sent(),this._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ".concat(r)),console.error(l),[2,{code:exports.RCCallErrorCode.JOIN_ROOM_ERROR}];case 8:this._registerRoomEventListener(),this._registerReportListener(),i.label=9;case 9:return i.trys.push([9,11,,12]),[4,this._subscribeInRoomRemoteTrack()];case 10:return i.sent(),[3,12];case 11:return c=i.sent(),this._exceptionClose(exports.RCCallEndReason.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ".concat(r)),console.error(c),[2,{code:exports.RCCallErrorCode.JOIN_ROOM_ERROR}];case 12:return i.trys.push([12,14,,15]),[4,this._publish()];case 13:return i.sent(),[3,15];case 14:return u=i.sent(),this._exceptionClose(exports.RCCallEndReason.PUBLISH_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _publish Exception roomId -> ".concat(r)),console.error(u),[2,{code:exports.RCCallErrorCode.JOIN_ROOM_ERROR}];case 15:return[2,{code:exports.RCCallErrorCode.SUCCESS}]}}))}))}}),Object.defineProperty(r.prototype,"_subscribeInRoomRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return(e=this._room.getRemoteTracks()).length?[4,this._subscribeRetry(e,this._options.isAllowSubscribeRetry,this._RETRYCOUNT)]:[3,2];case 1:(r=o.sent().code)!==t.RCRTCCode.SUCCESS&&(this._exceptionClose(exports.RCCallEndReason.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ".concat(this._stateMachine.getCallId()," RTC code -> ").concat(r))),o.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(r.prototype,"_subscribeRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,o){return void 0===r&&(r=!1),void 0===o&&(o=0),n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return[4,this._room.subscribe(e)];case 1:if((n=i.sent().code)!==t.RCRTCCode.SUCCESS){try{this._listener.onTrackSubscribeFail&&this._listener.onTrackSubscribeFail(n,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackSubscribeFail exception"),console.error(e)}if(!r)return[2,{code:n}];if(o>0)return o--,[2,this._subscribeRetry(e,r,o)]}return[2,{code:n}]}}))}))}}),Object.defineProperty(r.prototype,"_publish",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return e=this._options.localTracks,[4,this._publishRetry(e,this._options.isAllowPublishRetry,this._RETRYCOUNT)];case 1:return(r=o.sent().code)!==t.RCRTCCode.SUCCESS?(this._exceptionClose(exports.RCCallEndReason.PUBLISH_ERROR),this._logger.info("_","[RCCallSession _publist] Resource publishing failed: roomId -> ".concat(this._stateMachine.getCallId()," RCRTCCode -> ").concat(r)),[2]):(this._options.produceType===A.CALLEE&&this._notifyTrackReady(e),[2])}}))}))}}),Object.defineProperty(r.prototype,"_publishRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,o){return void 0===r&&(r=!1),void 0===o&&(o=0),n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return[4,this._room.publish(e)];case 1:if((n=i.sent().code)!==t.RCRTCCode.SUCCESS){try{this._listener.onTrackPublishFail&&this._listener.onTrackPublishFail(n,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackPublishFail exception"),console.error(e)}if(!r)return[2,{code:n}];if(o>0)return o--,[2,this._publishRetry(e,r,o)]}return[2,{code:n}]}}))}))}}),Object.defineProperty(r.prototype,"_leaveRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,t,r;return i(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,3,4]),[4,this._rtcClient.leaveRoom(this._room)];case 1:return e=o.sent(),this._logger.info("_","[RCCallSession _leaveRoom] Successfully exited the room code: ".concat(e.code)),[3,4];case 2:return t=o.sent(),this._logger.error("_","[RCCallSession _leaveRoom] leaveRoom throw exception"),console.error(t),[3,4];case 3:return r=this._stateMachine.getSummary(),k.emit("sessionClose",{session:this,summaryInfo:r}),[7];case 4:return[2]}}))}))}}),Object.defineProperty(r.prototype,"_exceptionClose",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._options.localTracks&&this._destroyTracks(this._options.localTracks),this._stateMachine.close(e)}}),Object.defineProperty(r.prototype,"registerSessionListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=H(e);if(!t.ok)throw new Error("[RCCallSession registerSessionListener] ".concat(t.msg));this._listener=o({},e)}}),Object.defineProperty(r.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return n(this,void 0,void 0,(function(){var n,s,a,l,c,u;return i(this,(function(i){switch(i.label){case 0:return e!==exports.RCCallMediaType.AUDIO?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",r&&r.audio&&o({},r.audio))];case 1:return n=i.sent(),s=n.code,a=n.track,s!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ".concat(s)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get Audio local tracks"),[2,{code:exports.RCCallErrorCode.SUCCESS,tracks:[a]}]);case 2:return[4,this._rtcClient.createMicrophoneAndCameraTracks("RongCloudRTC",r&&o({},r))];case 3:return l=i.sent(),c=l.code,u=l.tracks,c!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio and Video local tracks failed RCT code -> ".concat(c)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]):(this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get audio and video local tracks"),[2,{code:exports.RCCallErrorCode.SUCCESS,tracks:u}])}}))}))}}),Object.defineProperty(r.prototype,"_getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return n(this,void 0,void 0,(function(){var r,o,n,s,a,l,c,u,d;return i(this,(function(i){switch(i.label){case 0:return this._options.isAllowDemotionGetStream&&e===exports.RCCallMediaType.AUDIO_VIDEO?[4,this._getLocalTrackCore(exports.RCCallMediaType.AUDIO_VIDEO,t)]:[3,4];case 1:return r=i.sent(),o=r.code,n=r.tracks,o===exports.RCCallErrorCode.SUCCESS?[3,3]:[4,this._getLocalTrackCore(exports.RCCallMediaType.AUDIO,t)];case 2:return s=i.sent(),a=s.code,l=s.tracks,a!==exports.RCCallErrorCode.SUCCESS?(this._exceptionClose(exports.RCCallEndReason.GET_MEDIA_RESOURCES_ERROR),[2,{code:a}]):[2,{code:a,tracks:l}];case 3:return[2,{code:o,tracks:n}];case 4:return[4,this._getLocalTrackCore(e,t)];case 5:return c=i.sent(),u=c.code,d=c.tracks,u!==exports.RCCallErrorCode.SUCCESS?(this._exceptionClose(exports.RCCallEndReason.GET_MEDIA_RESOURCES_ERROR),[2,{code:u}]):[2,{code:u,tracks:d}]}}))}))}}),Object.defineProperty(r.prototype,"changeAudioDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){var r,o,n,s,a;return i(this,(function(i){switch(i.label){case 0:return r=[],o=[],[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",e)];case 1:return n=i.sent(),s=n.code,a=n.track,s!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ".concat(s)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isAudioTrack()||o.push(e)})),r.push(a),o.push(a),this._options.localTracks=o,this._notifyTrackReady(r),this._room?[4,this._room.publish(r)]:[3,3]);case 2:if(i.sent().code!==t.RCRTCCode.SUCCESS)return[2,{code:exports.RCCallErrorCode.AUDIO_PUBLISH_ERROR}];i.label=3;case 3:return[2,{code:exports.RCCallErrorCode.SUCCESS}]}}))}))}}),Object.defineProperty(r.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t={}),n(this,void 0,void 0,(function(){var r,o,n,s,a,l,c,u;return i(this,(function(i){switch(i.label){case 0:if(r=t.extra,o=void 0===r?"":r,n=this._options.callPushConfig?this._options.callPushConfig:t.pushConfig,s=[Y(e),B(o)],n&&(a=K(n),l=a.code,c=a.errorMsg,l!==exports.RCCallErrorCode.SUCCESS))return this._logger.error("_","[RCCallSession invite] param error, errorMsg: ".concat(c)),[2,{code:l}];if(u=[],!s.every((function(e){return!e.ok&&u.push(e.msg),e.ok})))throw new Error("[RCCallClient invite] ".concat(u.join("\n")));return[4,this._stateMachine.invite(e,{extra:o,pushConfig:n})];case 1:return[2,{code:i.sent().code}]}}))}))}}),Object.defineProperty(r.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){var t,r,o,n,s,a;return i(this,(function(i){switch(i.label){case 0:if(!(t=F(e)).ok)throw new Error("[RCCallSession accept] ".concat(t.msg));return k.emit("hungupOtherSession",{session:this}),r=this._stateMachine.getMediaType(),[4,this._getLocalTrack(r,e)];case 1:return o=i.sent(),n=o.code,s=o.tracks,n!==exports.RCCallErrorCode.SUCCESS?[2,{code:n}]:(this._options.localTracks=s,[4,this._stateMachine.accept()]);case 2:return(a=i.sent().code)!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallSession accept]Send accept message failed -> code: ".concat(a)),[2,{code:a}]):[2,{code:a}]}}))}))}}),Object.defineProperty(r.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this._stateMachine.hungup()]}))}))}}),Object.defineProperty(r.prototype,"_changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return[4,this._stateMachine.changeMediaType(e)];case 1:return(t=r.sent().code)!==exports.RCCallErrorCode.SUCCESS&&this._logger.error("_","[RCCallSession _changeMediaType] change media type fail code-> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(r.prototype,"_getLocalVideoTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[];return this._room?(this._options.localTracks&&(e=this._options.localTracks.filter((function(e){return e.isVideoTrack()}))),e):e}}),Object.defineProperty(r.prototype,"_getLocalAudioTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[];return this._room?(this._options.localTracks&&(e=this._options.localTracks.filter((function(e){return e.isAudioTrack()}))),e):e}}),Object.defineProperty(r.prototype,"_setMediaTypeToAudioAndVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r,o;return i(this,(function(n){switch(n.label){case 0:return[4,this._rtcClient.createCameraVideoTrack()];case 1:return e=n.sent(),r=e.code,o=e.track,r!==t.RCRTCCode.SUCCESS?[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]:[4,this._room.publish([o])];case 2:return n.sent().code!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ".concat(r)),[2]):(this._notifyTrackReady([o]),this._changeMediaType(exports.RCCallMediaType.AUDIO_VIDEO),[2])}}))}))}}),Object.defineProperty(r.prototype,"_setMediaTypeToAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return(e=this._getLocalVideoTracks()).length?(e.forEach((function(e){e.mute()})),[4,this._room.unpublish(e)]):[3,2];case 1:(r=o.sent().code)!==t.RCRTCCode.SUCCESS&&this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(r)),this._destroyTracks(e),o.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(r.prototype,"descendAbility",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return[4,this._changeMediaType(exports.RCCallMediaType.AUDIO)];case 1:return(e=t.sent().code)===exports.RCCallErrorCode.SUCCESS&&this._setMediaTypeToAudio(),[2,{code:e}]}}))}))}}),Object.defineProperty(r.prototype,"disableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return this._room?(e=this._getLocalVideoTracks()).length?(e.forEach((function(e){e.mute()})),this._options.isOffCameraWhenVideoDisable?[4,this._room.unpublish(e)]:[2,{code:exports.RCCallErrorCode.SUCCESS}]):(this._logger.error("_","[RCCallSession disableVideoTrack] Room missing video track -> ".concat(exports.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR)),[2,{code:exports.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession disableVideoTrack] Not in room"),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return(r=o.sent().code)!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(r)),[2,{code:exports.RCCallErrorCode.UNPUBLISH_VIDEO_ERROR}]):(e.forEach((function(e){e.destroy()})),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"enableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r,o,n,s;return i(this,(function(i){switch(i.label){case 0:return this._room?this._options.isOffCameraWhenVideoDisable?[4,this._rtcClient.createCameraVideoTrack()]:(e=this._getLocalVideoTracks()).length?(e.forEach((function(e){e.unmute()})),[2,{code:exports.RCCallErrorCode.SUCCESS}]):(this._logger.error("_","[RCCallSession enableVideoTrack] Room missing video track -> ".concat(exports.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR)),[2,{code:exports.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession enableVideoTrack] Not in room -> ".concat(exports.RCCallErrorCode.NOT_IN_ROOM_ERROR)),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return r=i.sent(),o=r.code,n=r.track,o!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ".concat(o)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR}]):(s=[],this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isVideoTrack()?e.destroy():s.push(e)})),s.push(n),this._options.localTracks=s,n.mute(),[4,this._room.publish([n])]);case 2:return i.sent().code!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ".concat(o)),[2,{code:exports.RCCallErrorCode.VIDEO_PUBLISH_ERROR}]):(n.unmute(),this._notifyTrackReady([n]),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"disableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return this._room?(e=this._getLocalAudioTracks()[0])?[4,e.mute()]:(this._logger.warn("_","[RCCallSession disableAudioTrack] Room missing audio track -> ".concat(exports.RCCallErrorCode.MISSING_AUDIO_TRACK_ERROR)),[2,{code:exports.RCCallErrorCode.MISSING_AUDIO_TRACK_ERROR}]):(this._logger.warn("_","[RCCallSession disableAudioTrack] Not in room -> ".concat(exports.RCCallErrorCode.NOT_IN_ROOM_ERROR)),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return(r=o.sent())!==t.RCRTCCode.SUCCESS&&this._logger.warn("_","[RCCallSession disableAudioTrack] mute failed -> ".concat(r)),[2,{code:r}]}}))}))}}),Object.defineProperty(r.prototype,"enableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return this._room?(e=this._getLocalAudioTracks()[0])?[4,e.unmute()]:(this._logger.error("_","[RCCallSession enableAudioTrack] Room missing audio track -> ".concat(exports.RCCallErrorCode.MISSING_AUDIO_TRACK_ERROR)),[2,{code:exports.RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession enableAudioTrack] Not in room -> ".concat(exports.RCCallErrorCode.NOT_IN_ROOM_ERROR)),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return(r=o.sent())!==t.RCRTCCode.SUCCESS&&this._logger.error("_","[RCCallSession enableAudioTrack] unmute failed -> ".concat(r)),[2,{code:r}]}}))}))}}),Object.defineProperty(r.prototype,"_destroyTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e.forEach((function(e){e.destroy()}))}}),Object.defineProperty(r.prototype,"_notifyTrackReady",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.forEach((function(e){try{t._listener.onTrackReady(e,t)}catch(e){t._logger.error("_","[RCCallSession _notifyTrackReady] _listener onTrackReady exception"),console.error(e)}}))}}),Object.defineProperty(r.prototype,"_registerRoomEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._room.registerRoomEventListener({onKickOff:function(r,o){var n=e._rtcClient.getCurrentId();e._stateMachine.userLeave([n]),r?(o===t.RCKickReason.SERVER_KICK&&e._exceptionClose(exports.RCCallEndReason.KICKED_BY_SERVER),o===t.RCKickReason.OTHER_KICK&&e._exceptionClose(exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL)):e._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR)},onMessageReceive:function(e,t,r,o){},onRoomAttributeChange:function(e,t){},onAudioMuteChange:function(t){e._logger.info("_","[RCCallSession onAudioMuteChange] userId->".concat(t.getUserId()," muted -> ").concat(t.isOwnerMuted()));var r={userId:t.getUserId(),muted:t.isOwnerMuted(),kind:"audio",trackId:t.getTrackId()};try{e._listener.onAudioMuteChange(r,e)}catch(t){e._logger.error("_","[RCCallSession onAudioMuteChange] Missing listening method -> onAudioMuteChange"),console.error(t)}},onVideoMuteChange:function(t){e._logger.info("_","[RCCallSession onVideoMuteChange]userId->".concat(t.getUserId()," muted -> ").concat(t.isOwnerMuted()));var r={userId:t.getUserId(),muted:t.isOwnerMuted(),kind:"video",trackId:t.getTrackId()};try{e._listener.onVideoMuteChange(r,e)}catch(t){e._logger.error("_","[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange"),console.error(t)}},onTrackPublish:function(r){return n(e,void 0,void 0,(function(){var e;return i(this,(function(o){switch(o.label){case 0:return this._room?[4,this._room.subscribe(r)]:[3,2];case 1:(e=o.sent().code)!==t.RCRTCCode.SUCCESS&&this._logger.error("_","[RCCallSession onTrackPublish] subscribe failed RTCCode ->".concat(e)),o.label=2;case 2:return[2]}}))}))},onTrackUnpublish:function(e){},onTrackReady:function(t){e._stateMachine.getMediaType()===exports.RCCallMediaType.AUDIO&&t.isVideoTrack()||e._notifyTrackReady([t])},onUserJoin:function(t){e.joinRoomTimer&&e.joinRoomTimer.stop(),e._stateMachine.userJoin(t)},onUserLeave:function(t){e._logger.info("_","[RCCallSession onUserLeave] listening onUserLeave userIds -> ".concat(null==t?void 0:t.join(","))),e._stateMachine.userLeave(t)},onPing:function(t){e._logger.info("_","[RCCallSession onPing]".concat(t));try{e._listener.onPing&&e._listener.onPing(t,e)}catch(t){e._logger.error("_","[RCCallSession onPing] listening onPing exception"),console.error(t)}}})}}),Object.defineProperty(r.prototype,"_registerReportListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._room.registerReportListener({onStateReport:function(t){try{e._listener.onRTCStateReport&&e._listener.onRTCStateReport(t,e)}catch(t){e._logger.error("_","[RCCallSession onStateReport] listener onStateReport exception"),console.error(t)}},onICEConnectionStateChange:function(t){var r,o;try{null===(o=null===(r=e._listener)||void 0===r?void 0:r.onICEConnectionStateChange)||void 0===o||o.call(r,t,e)}catch(t){e._logger.error("_","[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception"),console.error(t)}}})}}),Object.defineProperty(r.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getCallId()}}),Object.defineProperty(r.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._room?this._room.getSessionId():null}}),Object.defineProperty(r.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getTargetId()}}),Object.defineProperty(r.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getConversationType()}}),Object.defineProperty(r.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getChannelId()}}),Object.defineProperty(r.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getRemoteUsers()}}),Object.defineProperty(r.prototype,"getUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getRemoteUsers()}}),Object.defineProperty(r.prototype,"getUserState",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!e||"string"!=typeof e)throw new Error("userId is required, must be of type 'string'");return this._stateMachine.getUserState(e)}}),Object.defineProperty(r.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getState()}}),Object.defineProperty(r.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getCallerId()}}),Object.defineProperty(r.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getMediaType()}}),r}(),X=function(){function r(t,r,n,i){var s=this;Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_rtcClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_callEngine",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_sessionList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_callPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_hungupPushConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._rtcClient=i.rtcClient,this._options=o({isAllowPublishRetry:!1,isAllowSubscribeRetry:!1,isOffCameraWhenVideoDisable:!0,joinType:e.RTCJoinType.COEXIST,isAllowDemotionGetStream:!1,lang:exports.RCCallLanguage.ZH},i),this._callEngine=new j(this._context,r,this._logger,{onInvite:this._onInvite.bind(this),onOfflineRecord:this._onOfflineRecord.bind(this)},{lang:this._options.lang||exports.RCCallLanguage.ZH}),k.on("sessionClose",(function(e){var t=e.session,r=e.summaryInfo;s._removeSession(t);try{s._options.onSessionClose(t,r)}catch(e){s._logger.error("_","[RCCCallClient] options.onSessionClose exception"),console.log(e)}})),k.on("hungupOtherSession",(function(e){var t=e.session.getSessionId();s._logger.info("_","[RCCallClient hungupOtherSession] sessionId ready to accept -> ".concat(t)),s._logger.info("_","[RCCallClient hungupOtherSession] sessionList ->".concat(s._sessionList.map((function(e){return e.getSessionId()})).join(",")));for(var r=0;s._sessionList.length>1;)s._sessionList[r].getSessionId()!==t?(s._sessionList[r].hungup(),s._sessionList.splice(r,1)):r++;s._logger.info("_","[RCCallClient hungupOtherSession] current sessionList length ->".concat(s._sessionList.length))}))}return Object.defineProperty(r.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info("_","[RCCallClient _onInvite] Received invite message");var r=new q(e,this._rtcClient,this._logger,{isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:A.CALLEE,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig});this._logger.info("_","[RCCallClient _onInvite] Received invite message, successfully created session"),this._sessionList.push(r);try{this._options.onSession(r,t)}catch(e){this._logger.error("_","[RCCallClient _options.onSession] onSession exception"),console.log(e)}if(!r._listener)throw this._logger.error("_","[RCCallClient _options.onSession] session Must Have Listener"),new Error("[RCCallSession _options.onSession] session Must Have Listener");var o=H(r._listener);if(!o.ok)throw new Error(o.msg)}}),Object.defineProperty(r.prototype,"_onOfflineRecord",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{this._options.onOfflineRecord&&this._options.onOfflineRecord(e)}catch(e){this._logger.error("_","[RCCallClient _options.onOfflineRecord] onOfflineRecord exception"),console.log(e)}}}),Object.defineProperty(r.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e={}),this._callEngine.registerUserInfo(e),this._logger.info("_","[RCCallClient registerUserInfo] successfully register user info data")}}),Object.defineProperty(r.prototype,"startCrossCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,r=e.mediaType,o=void 0===r?exports.RCCallMediaType.AUDIO:r,s=e.listener,a=e.constraints,l=e.channelId,c=void 0===l?"":l,u=e.extra,d=void 0===u?"":u,C=e.pushTitle,_=void 0===C?"":C,h=e.pushContent,f=void 0===h?"":h,p=e.bitrate;return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.__call({targetId:t,mediaType:o,listener:s,constraints:a,channelId:c,extra:d,pushTitle:_,pushContent:f,bitrate:p,isCrossAppkey:!0})]}))}))}}),Object.defineProperty(r.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,r=e.mediaType,o=void 0===r?exports.RCCallMediaType.AUDIO:r,s=e.listener,a=e.constraints,l=e.channelId,c=void 0===l?"":l,u=e.extra,d=void 0===u?"":u,C=e.pushTitle,_=void 0===C?"":C,h=e.pushContent,f=void 0===h?"":h,p=e.bitrate;return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.__call({targetId:t,mediaType:o,listener:s,constraints:a,channelId:c,extra:d,pushTitle:_,pushContent:f,bitrate:p})]}))}))}}),Object.defineProperty(r.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,r=e.mediaType,o=void 0===r?exports.RCCallMediaType.AUDIO:r,s=e.listener,a=e.constraints,l=e.channelId,c=void 0===l?"":l,u=e.extra,d=void 0===u?"":u,C=e.pushTitle,_=void 0===C?"":C,h=e.pushContent,f=void 0===h?"":h,p=e.bitrate,g=e.isCrossAppkey,R=void 0!==g&&g;return n(this,void 0,void 0,(function(){var e,r,n,l,u,C,h,g,b,E,I,y,m,v;return i(this,(function(i){switch(i.label){case 0:return e=this._callPushConfig?this._callPushConfig:{pushTitle:_,pushContent:f},this._logger.info("_","[RCCallClient call] targetId: ".concat(t,", mediaType: ").concat(o)),t===this._context.getCurrentId()?(this._logger.error("_","[RCCallClient call] targetId is equal to currentId"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):(r=[V(t),G(o),H(s),B(d)],n=[],r.every((function(e){return!e.ok&&n.push(e.msg),e.ok}))?(l=K(e),u=l.code,C=l.errorMsg,u!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(C)),[2,{code:u}]):(h=[],[4,this._getLocalTrack(o,a)])):(console.error(n.join("\n")),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]));case 1:return g=i.sent(),b=g.code,E=g.tracks,b!==exports.RCCallErrorCode.SUCCESS?[2,{code:b}]:((h=E).forEach((function(e){var t,r,o;e.isAudioTrack()&&(null==p?void 0:p.audio)&&e.setBitrate(null==p?void 0:p.audio),e.isVideoTrack()&&(null==p?void 0:p.video)&&e.setBitrate(null===(t=null==p?void 0:p.video)||void 0===t?void 0:t.max,null===(r=null==p?void 0:p.video)||void 0===r?void 0:r.min,null===(o=null==p?void 0:p.video)||void 0===o?void 0:o.start),s.onTrackReady(e)})),[4,this._callEngine.call(c,t,o,d,e,R)]);case 2:return I=i.sent(),y=I.code,m=I.stateMachine,y===exports.RCCallErrorCode.SUCCESS&&m?(this._logger.info("_","[RCCallClient call] successfully created state machine"),(v=new q(m,this._rtcClient,this._logger,{localTracks:h,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:A.CALLER,isCrossAppkey:R,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig})).registerSessionListener(s),this._sessionList.push(v),this._logger.info("_","[RCCallClient call] successfully created session object, sessionId: ".concat(v.getSessionId())),[2,{code:y,session:v}]):(this._logger.error("_","[RCCallClient call] call failed code ->: ".concat(y)),h.forEach((function(e){e.mute(),e.destroy()})),[2,{code:y}])}}))}))}}),Object.defineProperty(r.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,r=e.userIds,o=e.mediaType,s=void 0===o?exports.RCCallMediaType.AUDIO:o,a=e.listener,l=e.constraints,c=e.channelId,u=void 0===c?"":c,d=e.extra,C=void 0===d?"":d,_=e.pushTitle,h=void 0===_?"":_,f=e.pushContent,p=void 0===f?"":f,g=e.bitrate;return n(this,void 0,void 0,(function(){var e,o,n,c,d,_,f,R,b,E,I,y,m,v,O;return i(this,(function(i){switch(i.label){case 0:return e=this._callPushConfig?this._callPushConfig:{pushTitle:h,pushContent:p},o=[V(t),Y(r),G(s),H(a),B(C)],n=[],c=o.every((function(e){return!e.ok&&n.push(e.msg),e.ok})),r.includes(this._context.getCurrentId())?(console.error("[RCCallClient callInGroup] userIds includes currentId"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):c?(d=K(e),_=d.code,f=d.errorMsg,_!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(f)),[2,{code:_}]):(R=[],[4,this._getLocalTrack(s,l)])):(console.error("[RCCallClient callInGroup] ".concat(n.join("\n"))),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]);case 1:return b=i.sent(),E=b.code,I=b.tracks,E!==exports.RCCallErrorCode.SUCCESS?[2,{code:E}]:((R=I).forEach((function(e){var t,r,o;e.isAudioTrack()&&(null==g?void 0:g.audio)&&e.setBitrate(null==g?void 0:g.audio),e.isVideoTrack()&&(null==g?void 0:g.video)&&e.setBitrate(null===(t=null==g?void 0:g.video)||void 0===t?void 0:t.max,null===(r=null==g?void 0:g.video)||void 0===r?void 0:r.min,null===(o=null==g?void 0:g.video)||void 0===o?void 0:o.start),a.onTrackReady(e)})),[4,this._callEngine.callInGroup(u,t,s,r,C,e)]);case 2:return y=i.sent(),m=y.code,v=y.stateMachine,m===exports.RCCallErrorCode.SUCCESS&&v?(this._logger.info("_","[RCCallClient callInGroup] successfully created state machine"),(O=new q(v,this._rtcClient,this._logger,{localTracks:R,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:A.CALLER,callPushConfig:this._callPushConfig,hungupPushConfig:this._hungupPushConfig})).registerSessionListener(a),this._sessionList.push(O),this._logger.info("_","[RCCallClient callInGroup] successfully created session object, sessionId: ".concat(O.getSessionId())),[2,{code:m,session:O}]):(this._logger.info("_","[RCCallClient callInGroup] callInGroup failed code -> ".concat(m)),R.forEach((function(e){e.mute(),e.destroy()})),[2,{code:m}])}}))}))}}),Object.defineProperty(r.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r){return n(this,void 0,void 0,(function(){var n,s,a,l,c,u;return i(this,(function(i){switch(i.label){case 0:return e!==exports.RCCallMediaType.AUDIO?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",r&&r.audio&&o({},r.audio))];case 1:return n=i.sent(),s=n.code,a=n.track,s!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ".concat(s)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._logger.info("_","[RCCallClient _getTrack] successfully get Audio local tracks"),[2,{code:exports.RCCallErrorCode.SUCCESS,tracks:[a]}]);case 2:return[4,this._rtcClient.createMicrophoneAndCameraTracks("RongCloudRTC",r&&o({},r))];case 3:return l=i.sent(),c=l.code,u=l.tracks,c!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ".concat(c)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]):(this._logger.info("_","[RCCallClient _getTrack] successfully get audio and video local tracks"),[2,{code:exports.RCCallErrorCode.SUCCESS,tracks:u}])}}))}))}}),Object.defineProperty(r.prototype,"_getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return n(this,void 0,void 0,(function(){var r,o,n,s,a,l,c,u,d;return i(this,(function(i){switch(i.label){case 0:return this._options.isAllowDemotionGetStream&&e===exports.RCCallMediaType.AUDIO_VIDEO?[4,this._getLocalTrackCore(exports.RCCallMediaType.AUDIO_VIDEO,t)]:[3,4];case 1:return r=i.sent(),o=r.code,n=r.tracks,o===exports.RCCallErrorCode.SUCCESS?[3,3]:[4,this._getLocalTrackCore(exports.RCCallMediaType.AUDIO,t)];case 2:return s=i.sent(),a=s.code,l=s.tracks,a!==exports.RCCallErrorCode.SUCCESS?[2,{code:a}]:[2,{code:a,tracks:l}];case 3:return[2,{code:o,tracks:n}];case 4:return[4,this._getLocalTrackCore(e,t)];case 5:return c=i.sent(),u=c.code,d=c.tracks,u!==exports.RCCallErrorCode.SUCCESS?[2,{code:u}]:[2,{code:u,tracks:d}]}}))}))}}),Object.defineProperty(r.prototype,"_removeSession",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.getSessionId();this._sessionList=this._sessionList.filter((function(e){return e.getSessionId()!==t}))}}),Object.defineProperty(r.prototype,"getJoinedRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var t,r,o;return i(this,(function(n){switch(n.label){case 0:return[4,this._context.getRTCJoinedUserInfo(this._context.getCurrentId())];case 1:return t=n.sent(),r=t.code,o=t.data,r!==e.ErrorCode.SUCCESS?(this._logger.error("_","getJoinedUserInfo error code: ".concat(r)),[2,{code:exports.RCCallErrorCode.QUERY_JOINED_USER_INFO_ERROR}]):[2,{code:exports.RCCallErrorCode.SUCCESS,data:o}]}}))}))}}),Object.defineProperty(r.prototype,"setPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r,o,n=[e,t].map((function(e){return K(e)}));try{for(var i=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],o=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(n),s=i.next();!s.done;s=i.next()){var a=s.value,l=a.code,c=a.errorMsg;if(l!==exports.RCCallErrorCode.SUCCESS)return this._logger.error("_","[RCCallClient setPushConfig] param error, errorMsg: ".concat(c)),{code:l}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}this._callPushConfig=e,this._hungupPushConfig=t}}),r}();e.VersionManage.add("plugin-call","5.2.7");var Z={tag:"RCCall",verify:function(e){return"browser"===e.tag},setup:function(t,r,o){var n=D(o);if(!n.ok)throw new Error("[RCCallLib installer steup]".concat(n.msg));if(!e.VersionManage.validEngine("5.9.0"))throw new Error("The current engine version '".concat(e.VersionManage.getInfo().engine,"' error, plugin-call required engine version at least '").concat("5.9.0","'."));var i=t.createLogger("RCCall","RTC");return o.logOutputLevel&&i.setOutputLevel(o.logOutputLevel),void 0!==o.logLevel&&i.warn("_","The 'logLevel' parameter is deprecated, please use 'logOutputLevel' instead."),i.warn("_","RCCall Version: ".concat("5.2.7",", Commit: ").concat("8e146acd55898ff5e053f17a48c4e7dbcef8d4de")),new X(t,r,i,o)}};exports.RCCallClient=X,exports.RCCallSession=q,exports.installer=Z;
package/dist/index.d.ts CHANGED
@@ -88,7 +88,11 @@ declare enum RCCallErrorCode {
88
88
  /**
89
89
  * 参数错误
90
90
  */
91
- PARAM_ERROR = 53313
91
+ PARAM_ERROR = 53313,
92
+ /**
93
+ * 缺少本地音频流
94
+ */
95
+ MISSING_AUDIO_TRACK_ERROR = 53314
92
96
  }
93
97
 
94
98
  /**
@@ -462,13 +466,13 @@ declare class RCCallSession {
462
466
  */
463
467
  disableAudioTrack(): Promise<{
464
468
  code: RCCallErrorCode;
465
- } | undefined>;
469
+ }>;
466
470
  /**
467
471
  * 启用音频track
468
472
  */
469
473
  enableAudioTrack(): Promise<{
470
474
  code: RCCallErrorCode;
471
- } | undefined>;
475
+ }>;
472
476
  /**
473
477
  * 销毁本地流
474
478
  */
@@ -639,56 +643,56 @@ interface ISessionListener {
639
643
  /**
640
644
  * 当对方已响铃
641
645
  */
642
- onRinging: (sender: ISender, session: RCCallSession) => void;
646
+ onRinging(sender: ISender, session: RCCallSession): void;
643
647
  /**
644
648
  * 当对方已同意
645
649
  */
646
- onAccept: (sender: ISender, session: RCCallSession) => void;
650
+ onAccept(sender: ISender, session: RCCallSession): void;
647
651
  /**
648
652
  * 当对方已挂断
649
653
  */
650
- onHungup: (sender: ISender, reason: RCCallEndReason, session: RCCallSession) => void;
654
+ onHungup(sender: ISender, reason: RCCallEndReason, session: RCCallSession): void;
651
655
  /**
652
656
  * 群组通话,人员改变
653
657
  */
654
- onMemberModify: (sender: ISender, invitedUsers: IInvitedUsers[], session: RCCallSession) => void;
658
+ onMemberModify(sender: ISender, invitedUsers: IInvitedUsers[], session: RCCallSession): void;
655
659
  /**
656
660
  * 通话降级
657
661
  */
658
- onMediaModify: (sender: ISender, mediaType: RCCallMediaType, session: RCCallSession) => void;
662
+ onMediaModify(sender: ISender, mediaType: RCCallMediaType, session: RCCallSession): void;
659
663
  /**
660
664
  * 当接到流
661
665
  */
662
- onTrackReady: (track: RCTrack, session?: RCCallSession) => void;
666
+ onTrackReady(track: RCTrack, session?: RCCallSession): void;
663
667
  /**
664
668
  * 关闭 或 开启 音频
665
669
  */
666
- onAudioMuteChange: (muteUser: IMuteUser, session: RCCallSession) => void;
670
+ onAudioMuteChange(muteUser: IMuteUser, session: RCCallSession): void;
667
671
  /**
668
672
  * 关闭 或 开启 视频
669
673
  */
670
- onVideoMuteChange: (muteUser: IMuteUser, session: RCCallSession) => void;
674
+ onVideoMuteChange(muteUser: IMuteUser, session: RCCallSession): void;
671
675
  /**
672
676
  * 资源订阅失败
673
677
  */
674
- onTrackSubscribeFail?: (code: RCRTCCode, session: RCCallSession) => void;
678
+ onTrackSubscribeFail?(code: RCRTCCode, session: RCCallSession): void;
675
679
  /**
676
680
  * 资源发布失败
677
681
  */
678
- onTrackPublishFail?: (code: RCRTCCode, session: RCCallSession) => void;
682
+ onTrackPublishFail?(code: RCRTCCode, session: RCCallSession): void;
679
683
  /**
680
684
  * 用于接收RTC状态数据报告
681
685
  */
682
- onRTCStateReport?: (report: IRCRTCStateReport, session: RCCallSession) => void;
686
+ onRTCStateReport?(report: IRCRTCStateReport, session: RCCallSession): void;
683
687
  /**
684
688
  * RTC 每次 Ping 结果
685
689
  */
686
- onPing?: (result: RCRTCPingResult, session: RCCallSession) => void;
690
+ onPing?(result: RCRTCPingResult, session: RCCallSession): void;
687
691
  /**
688
692
  * ~ICE 连接状态变更通知~
689
693
  * @since version 5.1.5
690
694
  */
691
- onICEConnectionStateChange?: (state: RTCIceConnectionState, session: RCCallSession) => void;
695
+ onICEConnectionStateChange?(state: RTCIceConnectionState, session: RCCallSession): void;
692
696
  }
693
697
  /**
694
698
  * 创建session的options
@@ -776,10 +780,12 @@ interface IRCCallParams {
776
780
  extra?: string;
777
781
  /**
778
782
  * 对方显示通知的标题
783
+ * @deprecated - version 5.1.2
779
784
  */
780
785
  pushTitle?: string;
781
786
  /**
782
787
  * 对方显示的通知内容
788
+ * @deprecated - version 5.1.2
783
789
  */
784
790
  pushContent?: string;
785
791
  /**
@@ -823,10 +829,12 @@ interface IRCCallInGroupParams {
823
829
  extra?: string;
824
830
  /**
825
831
  * 对方显示通知的标题
832
+ * @deprecated - version 5.1.2
826
833
  */
827
834
  pushTitle?: string;
828
835
  /**
829
836
  * 对方显示的通知内容
837
+ * @deprecated - version 5.1.2
830
838
  */
831
839
  pushContent?: string;
832
840
  /**
@@ -837,10 +845,6 @@ interface IRCCallInGroupParams {
837
845
  audio?: number;
838
846
  };
839
847
  }
840
- interface IDeviceChangeParams {
841
- audio?: IMicphoneAudioProfile;
842
- video?: ICameraVideoProfile;
843
- }
844
848
 
845
849
  interface IEndSummary {
846
850
  /**
@@ -1538,6 +1542,7 @@ declare class RCCallClient {
1538
1542
  /**
1539
1543
  * 监听离线消息报告
1540
1544
  * @param record
1545
+ * @private
1541
1546
  */
1542
1547
  _onOfflineRecord(record: IOfflineRecord): void;
1543
1548
  /**
@@ -1552,34 +1557,28 @@ declare class RCCallClient {
1552
1557
  extra?: string;
1553
1558
  }): void;
1554
1559
  /**
1555
- * 跨App单呼,发送invite消息,回调回来接收stateMachine, 建session
1556
- * @param params.targetId 被呼叫一方的用户 id 必填
1557
- * @param params.mediaType 音频呼叫 or 音视频呼叫 必填
1558
- * @param params.listener (session上的监听) 必填
1559
- * @param params.constraints 获取音频或音视频资源时的参数 可选
1560
- * @param params.channelId 组织 Id 可选
1561
- * @param params.extra 消息扩展信息
1562
- * @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
1563
- * @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
1564
- * @param params.bitrate 需要设置的码率参数
1565
- *
1566
- */
1560
+ * 跨 App 单呼,发送invite消息,回调回来接收stateMachine, 建session
1561
+ * @param params.targetId 被呼叫一方的用户 id 必填
1562
+ * @param params.mediaType 音频呼叫 or 音视频呼叫 必填
1563
+ * @param params.listener (session上的监听) 必填
1564
+ * @param params.constraints 获取音频或音视频资源时的参数 可选
1565
+ * @param params.channelId 组织 Id 可选
1566
+ * @param params.extra 消息扩展信息
1567
+ * @param params.bitrate 需要设置的码率参数
1568
+ */
1567
1569
  startCrossCall({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle, pushContent, bitrate, }: IRCCallParams): Promise<{
1568
1570
  code: RCCallErrorCode;
1569
1571
  session?: RCCallSession;
1570
1572
  }>;
1571
1573
  /**
1572
- * 单呼,发送invite消息,回调回来接收stateMachine, 建session
1574
+ * 发起单人呼叫
1573
1575
  * @param params.targetId 被呼叫一方的用户 id 必填
1574
1576
  * @param params.mediaType 音频呼叫 or 音视频呼叫 必填
1575
1577
  * @param params.listener (session上的监听) 必填
1576
1578
  * @param params.constraints 获取音频或音视频资源时的参数 可选
1577
1579
  * @param params.channelId 组织 Id 可选
1578
1580
  * @param params.extra 消息扩展信息
1579
- * @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
1580
- * @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
1581
1581
  * @param params.bitrate 需要设置的码率参数
1582
- *
1583
1582
  */
1584
1583
  call({ targetId, mediaType, listener, constraints, channelId, extra, pushTitle, pushContent, bitrate, }: IRCCallParams): Promise<{
1585
1584
  code: RCCallErrorCode;
@@ -1595,8 +1594,6 @@ declare class RCCallClient {
1595
1594
  * @param params.constraints 获取音频或音视频资源时的参数 可选
1596
1595
  * @param params.channelId 组织 Id 可选
1597
1596
  * @param params.extra 消息扩展信息 可选
1598
- * @deprecated 5.1.2 版本废弃 params.pushTitle 通知的标题
1599
- * @deprecated 5.1.2 版本废弃 params.pushContent 通知的内容
1600
1597
  * @param params.bitrate 需要设置的码率参数
1601
1598
  */
1602
1599
  callInGroup({ targetId, userIds, mediaType, listener, constraints, channelId, extra, pushTitle, pushContent, bitrate, }: IRCCallInGroupParams): Promise<{
@@ -1626,10 +1623,10 @@ declare class RCCallClient {
1626
1623
  * @description callLib 会内置 IPushConfig 中 pushData 的赋值,业务层无需关注 pushData 字段值
1627
1624
  */
1628
1625
  setPushConfig(callPushConfig: IPushConfig, hungupPushConfig: IPushConfig): {
1629
- code: RCCallErrorCode.STATE_MACHINE_EXIT | RCCallErrorCode.SEND_MSG_ERROR | RCCallErrorCode.REJECTED_BY_BLACKLIST | RCCallErrorCode.NOT_IN_GROUP | RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR | RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR | RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR | RCCallErrorCode.JOIN_ROOM_ERROR | RCCallErrorCode.AUDIO_PUBLISH_ERROR | RCCallErrorCode.VIDEO_PUBLISH_ERROR | RCCallErrorCode.AUDIO_AND_VIDEO_PUBLISH_ERROR | RCCallErrorCode.QUERY_JOINED_USER_INFO_ERROR | RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR | RCCallErrorCode.UNPUBLISH_VIDEO_ERROR | RCCallErrorCode.CONVERSATION_NOT_GROUP_ERROR | RCCallErrorCode.NOT_IN_ROOM_ERROR | RCCallErrorCode.PARAM_ERROR;
1626
+ code: RCCallErrorCode.STATE_MACHINE_EXIT | RCCallErrorCode.SEND_MSG_ERROR | RCCallErrorCode.REJECTED_BY_BLACKLIST | RCCallErrorCode.NOT_IN_GROUP | RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR | RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR | RCCallErrorCode.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR | RCCallErrorCode.JOIN_ROOM_ERROR | RCCallErrorCode.AUDIO_PUBLISH_ERROR | RCCallErrorCode.VIDEO_PUBLISH_ERROR | RCCallErrorCode.AUDIO_AND_VIDEO_PUBLISH_ERROR | RCCallErrorCode.QUERY_JOINED_USER_INFO_ERROR | RCCallErrorCode.MISSING_VIDEO_TRACK_ERROR | RCCallErrorCode.UNPUBLISH_VIDEO_ERROR | RCCallErrorCode.CONVERSATION_NOT_GROUP_ERROR | RCCallErrorCode.NOT_IN_ROOM_ERROR | RCCallErrorCode.PARAM_ERROR | RCCallErrorCode.MISSING_AUDIO_TRACK_ERROR;
1630
1627
  } | undefined;
1631
1628
  }
1632
1629
 
1633
1630
  declare const installer: IPluginGenerator<RCCallClient, IRCCallInitOptions>;
1634
1631
 
1635
- export { IDeviceChangeParams, IEndSummary, IInvitedUsers, IMediaStreamConstraints, IMuteUser, IOfflineRecord, IPushConfig, IRCCallInGroupParams, IRCCallInitOptions, IRCCallParams, ISenderInfo, ISessionListener, RCCallClient, RCCallEndReason, RCCallErrorCode, RCCallLanguage, RCCallMediaType, RCCallSession, RCCallSessionState, RCCallUserState, installer };
1632
+ export { IEndSummary, IInvitedUsers, IMediaStreamConstraints, IMuteUser, IOfflineRecord, IPushConfig, IRCCallInGroupParams, IRCCallInitOptions, IRCCallParams, ISenderInfo, ISessionListener, RCCallClient, RCCallEndReason, RCCallErrorCode, RCCallLanguage, RCCallMediaType, RCCallSession, RCCallSessionState, RCCallUserState, installer };