@rongcloud/plugin-call 5.34.0 → 5.36.0
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.
- package/dist/index.cjs.js +2 -2
- package/dist/index.d.ts +165 -1
- package/dist/index.esm.js +2 -2
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
|
|
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 a(e){try{l(o.next(e))}catch(e){i(e)}}function s(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(a,s)}l((o=o.apply(e,t||[])).next())}))}function i(e,t){var r,o,n,i,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,o&&(n=2&s[0]?o.return:s[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,s[1])).done)return n;switch(o=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(n=a.trys,(n=n.length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){a.label=s[1];break}if(6===s[0]&&a.label<n[1]){a.label=n[1],n=s;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(s);break}n[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],o=0}finally{r=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function a(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)a.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 a}function s(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("_")},R=new e.EventEmitter,h=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",c[c.SESSION_ENDED=53315]="SESSION_ENDED",c[c.SWITCH_VIDEO_DEVICE_ERROR=53316]="SWITCH_VIDEO_DEVICE_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 f,p,g,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"}(f||(f={})),exports.RCCallSessionState=void 0,(p=exports.RCCallSessionState||(exports.RCCallSessionState={}))[p.WAITING=0]="WAITING",p[p.KEEPING=1]="KEEPING",p[p.END=2]="END",exports.RCCallUserState=void 0,(g=exports.RCCallUserState||(exports.RCCallUserState={}))[g.NONE=0]="NONE",g[g.WAITING=1]="WAITING",g[g.KEEPING=2]="KEEPING",function(e){
|
|
2
2
|
/*!
|
|
3
3
|
同App通话
|
|
4
4
|
*/
|
|
@@ -6,4 +6,4 @@ e[e.RCCallRoomTypeNormalCall=0]="RCCallRoomTypeNormalCall",
|
|
|
6
6
|
/*!
|
|
7
7
|
跨App通话
|
|
8
8
|
*/
|
|
9
|
-
e[e.RCCallRoomTypeAcrossCall=7]="RCCallRoomTypeAcrossCall"}(b||(b={}));var y,I,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}();!function(e){e[e.CALLER=1]="CALLER",e[e.CALLEE=2]="CALLEE"}(y||(y={})),exports.RCCallBusyCallPolicy=void 0,(I=exports.RCCallBusyCallPolicy||(exports.RCCallBusyCallPolicy={}))[I.HANGUP=1]="HANGUP",I[I.IGNORE=2]="IGNORE";var m,O,S,T=function(){function t(e,t,r,o,n,i,s,a,l,c){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,"_options",{enumerable:!0,configurable:!0,writable:!0,value:c}),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;if(this._options.busyCallPolicy!==exports.RCCallBusyCallPolicy.IGNORE||s!==exports.RCCallEndReason.BUSY_LINE){var 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,R,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.info("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(t))),o=this._context.getCurrentId(),n=Object.keys(this._userInfo),0===(c=t.filter((function(e){return e!==o&&!n.includes(e)}))).length?(this._logger.warn("_","[RCCallStateMachine] invite -> all userId is in calling now!"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):(u=n.map((function(e){var t=l.CONNECTED;return g._userInfo[e].state===exports.RCCallUserState.WAITING&&(t=l.RINGING),{userId:e,mediaType:g._mediaType,callStatus:t,mediaId:e}})),d=r.extra,C=void 0===d?"":d,_=r.pushConfig,[4,this._callMsgHandler.sendMemeberModify({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:C,pushConfig:_,mediaType:this._mediaType,inviteUserIds:c,callerId:this.getCallerId(),existedUserPofiles:u,directionalUserIdList:a(a([],s(n),!1),s(c),!1).filter((function(e){return e!==o}))})]));case 1:return h=i.sent(),f=h.code,p=h.message,f===exports.RCCallErrorCode.SUCCESS?(R=p.sentTime,c.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(R))}))):c.forEach((function(e){g._userInfo[e]={userId:e,state:exports.RCCallUserState.NONE,isCaller:!1,isRemote:!0};var t=f===exports.RCCallErrorCode.REJECTED_BY_BLACKLIST?exports.RCCallEndReason.ADDED_TO_BLACKLIST:exports.RCCallEndReason.NETWORK_ERROR;g._notifyUserStateChange(g._userInfo[e],t)})),[2,{code:f}]}}))}))}}),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,n,s,a,l;return i(this,(function(i){switch(i.label){case 0:return r=this._context.getCurrentId(),n=exports.RCCallErrorCode.SUCCESS,t?(s={channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:e,userIds:this.getRemoteUserIds(),pushConfig:o({},this._hungupPushConfig)},e!==exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL?[3,1]:(this._callMsgHandler.sendHungup(s),[3,3])):[3,3];case 1:return[4,this._callMsgHandler.sendHungup(s)];case 2:a=i.sent().code,n=a,i.label=3;case 3:for(l in this._endTimestamp=Date.now(),this._userInfo)this._userInfo[l].state=exports.RCCallUserState.NONE,l===r?this._notifyUserStateChange(this._userInfo[l],e):this._notifyUserStateChange(this._userInfo[l]),delete this._userInfo[l];return Object.keys(this._userInfo).length<2&&this._notifyStateChange(exports.RCCallSessionState.END,e),[2,{code:n}]}}))}))}}),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,"userOffline",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this._logger.debug("_","[RCCallStateMachine] userOffline -> userIds: ".concat(JSON.stringify(e))),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_NETWORK_ERROR),t._watchers.onHungup(r,exports.RCCallEndReason.REMOTE_NETWORK_ERROR),delete t._userInfo[e]),Object.keys(t._userInfo).length<2&&t._sessionState!==exports.RCCallSessionState.END&&(t._endTimestamp=Date.now(),t._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_NETWORK_ERROR))}))}}),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,(m=exports.RCCallMediaType||(exports.RCCallMediaType={}))[m.AUDIO=1]="AUDIO",m[m.AUDIO_VIDEO=2]="AUDIO_VIDEO",function(e){e[e.ADD=1]="ADD",e[e.REMOVE=2]="REMOVE"}(O||(O={})),function(e){e.WEB="Web",e.IOS="iOS",e.ANDROID="Android"}(S||(S={}));var M,x,P=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}(),N=["RC:VCAccept","RC:VCRinging","RC:VCSummary","RC:VCHangup","RC:VCInvite","RC:VCModifyMedia","RC:VCModifyMem"],w=((M={})[e.ErrorCode.REJECTED_BY_BLACKLIST]=exports.RCCallErrorCode.REJECTED_BY_BLACKLIST,M[e.ErrorCode.NOT_IN_GROUP]=exports.RCCallErrorCode.NOT_IN_GROUP,M),A=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 P(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(N.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){var r=e.content.callId;switch(this._logger.info("_","recv -> senderId: ".concat(e.senderUserId,", type: ").concat(e.messageType,", callId: ").concat(r)),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("_","recv -> unexpected message: ".concat(e.messageType))}}}),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 R=[],g=0;g<n.length;g++){var b=n[g].msg;if(d!==b.content.callId)break;R.push(b)}if(t._logger.warn("_","taskMsgList length: ".concat(R.length)),R.length>0){var E=t._msgBufferList.findIndex((function(e){return e.msg.messageUId===R[R.length-1].messageUId}));t._msgBufferList=t._msgBufferList.slice(E+1);var y=n.findIndex((function(e){return e.msg.messageUId===R[R.length-1].messageUId}));n=n.slice(y+1)}var I=function(){if(o!==e.ConversationType.PRIVATE)return!1;var t=1===R.length,r=R.every((function(e){return[p.VCInvite,p.VCModifyMedia,p.VCRinging].includes(e.messageType)}));return t||r}(),v=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=R[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<R.length;d++){if("break"===u(d))break}return n&&l||!(i.length>1)||(r=!0),r}();f&&(I||v)&&R.forEach(t._onRecvOnlineCallMsg,t),t._offlineRecorder.onRecvOfflineMsgs(R)}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:w[_]||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:S.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:S.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:O.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:S.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:S.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:S.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:S.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,(x=exports.RCCallLanguage||(exports.RCCallLanguage={})).ZH="zh",x.EN="en";var U={PushTitle:{AUDIO:"You have a voice call",VIDEO:"You have a video call"}},L={PushTitle:{AUDIO:"您有一条音频通话",VIDEO:"您有一条视频通话"}},k=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?U:L}}),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.34.0"," CommitId: ").concat("f4d67407490db4a47885c96a876f71cb2ff56b30")),f(t),this._callMsgHandler=new A(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]})),k.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;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 T(this._context,this._runtime,this._logger,this._callMsgHandler,t,r,o,u,d,{busyCallPolicy:this._options.busyCallPolicy}),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 T(this._context,this._runtime,this._logger,this._callMsgHandler,t,e.ConversationType.PRIVATE,r,o,n,{busyCallPolicy:this._options.busyCallPolicy}),[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 T(this._context,this._runtime,this._logger,this._callMsgHandler,t,e.ConversationType.GROUP,r,o,n,{busyCallPolicy:this._options.busyCallPolicy}),[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}(),D=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 V=function(r){if(!r)return{ok:!1,msg:"Initialization missing parameter -> options"};if("object"!=typeof r)return{ok:!1,msg:"Initialization options must be an object"};var o,n=Object.keys(r),i=[];return["rtcClient","onSession","onSessionClose"].forEach((function(e){n.includes(e)||i.push(e)})),i.length?{ok:!1,msg:'Initialization missing parameter -> "'.concat(i.join(","),'"')}:"object"!=typeof r.rtcClient?{ok:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:"function"!=typeof r.onSession?{ok:!1,msg:"Initialization 'onSession' parameter must be of type 'function'"}:"function"!=typeof r.onSessionClose?{ok:!1,msg:"Initialization 'onSessionClose' parameter must be of type 'function'"}:void 0!==r.isAllowSubscribeRetry&&"boolean"!=typeof r.isAllowSubscribeRetry?{ok:!1,msg:"Initialization 'isAllowSubscribeRetry' parameter must be of type 'boolean'"}:void 0!==r.isAllowPublishRetry&&"boolean"!=typeof r.isAllowPublishRetry?{ok:!1,msg:"Initialization 'isAllowPublishRetry' parameter must be of type 'boolean'"}:void 0!==r.isOffCameraWhenVideoDisable&&"boolean"!=typeof r.isOffCameraWhenVideoDisable?{ok:!1,msg:"Initialization 'isOffCameraWhenVideoDisable' parameter must be of type 'boolean'"}:void 0===r.joinType||(o=r.joinType,Object.values(t.RTCJoinType).includes(o))?void 0!==r.isAllowDemotionGetStream&&"boolean"!=typeof r.isAllowDemotionGetStream?{ok:!1,msg:"Initialization 'isAllowDemotionGetStream' parameter must be of type 'boolean'"}:void 0===r.lang||function(e){return Object.values(exports.RCCallLanguage).includes(e)}(r.lang)?void 0===r.logOutputLevel||function(t){return[e.LogL.DEBUG,e.LogL.INFO,e.LogL.WARN,e.LogL.ERROR].includes(t)}(r.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}},G=function(e){return e&&"string"==typeof e?{ok:!0}:{ok:!1,msg:"'targetId' parameter is required, must be of type 'string'"}},B=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'"}},K=function(e){return"string"==typeof e?{ok:!0}:{ok:!1,msg:"'extra' parameter must be of type 'string'"}},J=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=W(s||{});if(l.code!==exports.RCCallErrorCode.SUCCESS)return l;var c=Y(a||{});return c.code!==exports.RCCallErrorCode.SUCCESS?c:{code:exports.RCCallErrorCode.SUCCESS}},W=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}},Y=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}},F=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 z=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:"'frameRate' and 'resolution' is required"};var r,o},q=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}(),X=function(){function r(e,t,r,s){void 0===s&&(s={});var a=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:s}),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;a._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(a,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(),D.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){a._logger.info("_","[RCCallSession onRinging]sender: sender.userId -> ".concat(e.userId));try{a._listener.onRinging(e,a)}catch(e){a._logger.error("_","[RCCallSession onRinging] method exception -> onRinging"),console.error(e)}},onAccept:function(e){a._logger.info("_","[RCCallSession onAccept]sender: sender.userId -> ".concat(e.userId));try{a._listener.onAccept(e,a)}catch(e){a._logger.error("_","[RCCallSession onAccept] method exception -> onAccept"),console.error(e)}},onHungup:function(e,t){a._logger.info("_","[RCCallSession onHungup]sender: sender.userId -> ".concat(e.userId," reason->").concat(t));try{a._listener.onHungup(e,t,a)}catch(e){a._logger.error("_","[RCCallSession onHungup] method exception -> onHungup"),console.error(e)}},onMemberModify:function(e){var t=e.sender,r=e.invitedUsers;a._logger.info("_","[RCCallSession onMemberModify] sender.userId -> ".concat(t.userId));try{a._listener.onMemberModify(t,r,a)}catch(e){a._logger.error("_","[RCCallSession onMemberModify] method exception -> onMemberModify"),console.error(e)}},onMediaModify:function(e){var t=e.sender,r=e.mediaType;a._logger.info("_","[RCCallSession onMediaModify]sender: sender.userId -> ".concat(t.userId," mediaType: ").concat(r)),r===exports.RCCallMediaType.AUDIO&&a._setMediaTypeToAudio();try{a._listener.onMediaModify(t,r,a)}catch(e){a._logger.error("_","[RCCallSession onMediaModify] method exception -> onMediaModify"),console.error(e)}},crossAppkey:function(e){a._logger.info("_","[RCCallSession crossAppkey] 是否跨 appkey: ".concat(e)),a._options.isCrossAppkey=e}}),this._stateMachine.setHungupPushConfig(o({},this._options.hungupPushConfig))}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 q((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===y.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(),D.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,l,c,u,d,C;return i(this,(function(i){switch(i.label){case 0:return n=this._getLocalAudioTracks(),l=this._getLocalVideoTracks(),n.length?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",r&&r.audio&&o({},r.audio))];case 1:if(c=i.sent(),d=c.code,C=c.track,d!==t.RCRTCCode.SUCCESS)return this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ".concat(d)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR}];n.push(C),i.label=2;case 2:return e===exports.RCCallMediaType.AUDIO?(this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get Audio local tracks"),[2,{code:exports.RCCallErrorCode.SUCCESS,tracks:n}]):l.length?[3,4]:[4,this._rtcClient.createCameraVideoTrack("RongCloudRTC",r&&r.video&&o({},r.video))];case 3:if(u=i.sent(),d=u.code,C=u.track,d!==t.RCRTCCode.SUCCESS)return this._logger.error("_","[RCCallSession _getLocalTrackCore] get Video local track failed RCT code -> ".concat(d)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR}];l.push(C),i.label=4;case 4:return this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get video local track"),[2,{code:exports.RCCallErrorCode.SUCCESS,tracks:a(a([],s(n),!1),s(l),!1)}]}}))}))}}),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()?e.destroy():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,"changeVideoDevice",{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 this._room?[4,this._rtcClient.createCameraVideoTrack("RongCloudRTC",e)]:(this._logger.error("_","[RCCallSession changeVideoDevice] not in room"),[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 changeDevice] get local Video track failed RCTLib code -> ".concat(o)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR}]):(s=this._getLocalVideoTracks()[0],[4,this._room.changeMediaDevice(s,n)]);case 2:return(a=i.sent().code)!==t.RCRTCCode.SUCCESS?(null==n||n.destroy(),this._logger.error("_","[RCCallSession changeDevice] change video device failed RCTLib code -> ".concat(a)),[2,{code:exports.RCCallErrorCode.SWITCH_VIDEO_DEVICE_ERROR}]):(this._options.localTracks=this._options.localTracks.filter((function(e){return!e.isVideoTrack()})),this._options.localTracks.push(n),this._notifyTrackReady([n]),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return void 0===t&&(t={}),n(this,void 0,void 0,(function(){var n,s,a,l,c,u,d,C;return i(this,(function(i){switch(i.label){case 0:if(n=t.extra,s=void 0===n?"":n,a=(null===(r=this._options.callPushConfig)||void 0===r?void 0:r.pushTitle)?o({},this._options.callPushConfig):t.pushConfig,l=[F(e),K(s)],a&&(c=J(a),u=c.code,d=c.errorMsg,u!==exports.RCCallErrorCode.SUCCESS))return this._logger.error("_","[RCCallSession invite] param error, errorMsg: ".concat(d)),[2,{code:u}];if(C=[],!l.every((function(e){return!e.ok&&C.push(e.msg),e.ok})))throw new Error("[RCCallClient invite] ".concat(C.join("\n")));return[4,this._stateMachine.invite(e,{extra:s,pushConfig:a})];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=z(e)).ok)throw new Error("[RCCallSession accept] ".concat(t.msg));return D.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._stateMachine.getState()===exports.RCCallSessionState.END?(this._destroyTracks(s),[2,{code:exports.RCCallErrorCode.SESSION_ENDED}]):(this._options.localTracks=s,[4,this._stateMachine.accept()]);case 2:return a=i.sent().code,this._stateMachine.getState()===exports.RCCallSessionState.END?(this._destroyTracks(s),[2,{code:exports.RCCallErrorCode.SESSION_ENDED}]):a!==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._options.localTracks&&(e=this._options.localTracks.filter((function(e){return e.isVideoTrack()}))),e}}),Object.defineProperty(r.prototype,"_getLocalAudioTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[];return this._options.localTracks&&(e=this._options.localTracks.filter((function(e){return e.isAudioTrack()}))),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)},onUserOffline:function(t){e._logger.info("_","[RCCallSession onUserOffline] listening onUserOffline userIds -> ".concat(null==t?void 0:t.join(","))),e._stateMachine.userOffline(t)},onPing:function(t){var r,o;try{null===(o=null===(r=e._listener)||void 0===r?void 0:r.onPing)||void 0===o||o.call(r,t,e)}catch(e){console.error(e)}}})}}),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}(),Z=function(){function r(e,r,n,i){var s=this;Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),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:t.RTCJoinType.KICK,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,busyCallPolicy:this._options.busyCallPolicy||exports.RCCallBusyCallPolicy.HANGUP}),D.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)}})),D.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 X(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:y.CALLEE,callPushConfig:o({},this._callPushConfig),hungupPushConfig:o({},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 n=H(r._listener);if(!n.ok)throw new Error(n.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,r=e.targetId,s=e.mediaType,a=void 0===s?exports.RCCallMediaType.AUDIO:s,l=e.listener,c=e.constraints,u=e.channelId,d=void 0===u?"":u,C=e.extra,_=void 0===C?"":C,h=e.pushTitle,f=void 0===h?"":h,p=e.pushContent,R=void 0===p?"":p,g=e.bitrate,b=e.isCrossAppkey,E=void 0!==b&&b;return n(this,void 0,void 0,(function(){var e,n,s,u,C,h,p,b,I,v,m,O,S,T;return i(this,(function(i){switch(i.label){case 0:return e=o({},null!==(t=this._callPushConfig)&&void 0!==t?t:{pushTitle:f,pushContent:R}),this._logger.info("_","[RCCallClient call] targetId: ".concat(r,", mediaType: ").concat(a)),r===this._context.getCurrentId()?(this._logger.error("_","[RCCallClient call] targetId is equal to currentId"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):(n=[G(r),B(a),H(l),K(_)],s=[],n.every((function(e){return!e.ok&&s.push(e.msg),e.ok}))?(u=J(e),C=u.code,h=u.errorMsg,C!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(h)),[2,{code:C}]):(p=[],[4,this._getLocalTrack(a,c)])):(console.error(s.join("\n")),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]));case 1:return b=i.sent(),I=b.code,v=b.tracks,I!==exports.RCCallErrorCode.SUCCESS?[2,{code:I}]:((p=v).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),l.onTrackReady(e)})),[4,this._callEngine.call(d,r,a,_,e,E)]);case 2:return m=i.sent(),O=m.code,S=m.stateMachine,O===exports.RCCallErrorCode.SUCCESS&&S?(this._logger.info("_","[RCCallClient call] successfully created state machine"),(T=new X(S,this._rtcClient,this._logger,{localTracks:p,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:y.CALLER,isCrossAppkey:E,callPushConfig:o({},this._callPushConfig),hungupPushConfig:o({},this._hungupPushConfig)})).registerSessionListener(l),this._sessionList.push(T),this._logger.info("_","[RCCallClient call] successfully created session object, sessionId: ".concat(T.getSessionId())),[2,{code:O,session:T}]):(this._logger.error("_","[RCCallClient call] call failed code ->: ".concat(O)),p.forEach((function(e){e.mute(),e.destroy()})),[2,{code:O}])}}))}))}}),Object.defineProperty(r.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=e.targetId,s=e.userIds,a=e.mediaType,l=void 0===a?exports.RCCallMediaType.AUDIO:a,c=e.listener,u=e.constraints,d=e.channelId,C=void 0===d?"":d,_=e.extra,h=void 0===_?"":_,f=e.pushTitle,p=void 0===f?"":f,R=e.pushContent,g=void 0===R?"":R,b=e.bitrate;return n(this,void 0,void 0,(function(){var e,n,a,d,_,f,R,E,I,v,m,O,S,T,M;return i(this,(function(i){switch(i.label){case 0:return e=o({},null!==(t=this._callPushConfig)&&void 0!==t?t:{pushTitle:p,pushContent:g}),n=[G(r),F(s),B(l),H(c),K(h)],a=[],d=n.every((function(e){return!e.ok&&a.push(e.msg),e.ok})),s.includes(this._context.getCurrentId())?(console.error("[RCCallClient callInGroup] userIds includes currentId"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):d?(_=J(e),f=_.code,R=_.errorMsg,f!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(R)),[2,{code:f}]):(E=[],[4,this._getLocalTrack(l,u)])):(console.error("[RCCallClient callInGroup] ".concat(a.join("\n"))),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]);case 1:return I=i.sent(),v=I.code,m=I.tracks,v!==exports.RCCallErrorCode.SUCCESS?[2,{code:v}]:((E=m).forEach((function(e){var t,r,o;e.isAudioTrack()&&(null==b?void 0:b.audio)&&e.setBitrate(null==b?void 0:b.audio),e.isVideoTrack()&&(null==b?void 0:b.video)&&e.setBitrate(null===(t=null==b?void 0:b.video)||void 0===t?void 0:t.max,null===(r=null==b?void 0:b.video)||void 0===r?void 0:r.min,null===(o=null==b?void 0:b.video)||void 0===o?void 0:o.start),c.onTrackReady(e)})),[4,this._callEngine.callInGroup(C,r,l,s,h,e)]);case 2:return O=i.sent(),S=O.code,T=O.stateMachine,S===exports.RCCallErrorCode.SUCCESS&&T?(this._logger.info("_","[RCCallClient callInGroup] successfully created state machine"),(M=new X(T,this._rtcClient,this._logger,{localTracks:E,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:y.CALLER,callPushConfig:o({},this._callPushConfig),hungupPushConfig:o({},this._hungupPushConfig)})).registerSessionListener(c),this._sessionList.push(M),this._logger.info("_","[RCCallClient callInGroup] successfully created session object, sessionId: ".concat(M.getSessionId())),[2,{code:S,session:M}]):(this._logger.info("_","[RCCallClient callInGroup] callInGroup failed code -> ".concat(S)),E.forEach((function(e){e.mute(),e.destroy()})),[2,{code:S}])}}))}))}}),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 J(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("calllib","5.34.0");var Q={tag:"RCCall",verify:function(e){return"browser"===e.tag},setup:function(t,r,o){var n=V(o);if(!n.ok)throw new Error("[RCCallLib installer steup]".concat(n.msg));if(!e.VersionManage.validEngine("5.34.0"))throw new Error("The current engine version '".concat(e.VersionManage.getInfo().engine,"' error, plugin-call required engine version at least '").concat("5.34.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.34.0",", Commit: ").concat("f4d67407490db4a47885c96a876f71cb2ff56b30")),new Z(t,r,i,o)}};exports.RCCallClient=Z,exports.RCCallSession=X,exports.installer=Q;
|
|
9
|
+
e[e.RCCallRoomTypeAcrossCall=7]="RCCallRoomTypeAcrossCall"}(b||(b={}));var m,v,y=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}();!function(e){e[e.CALLER=1]="CALLER",e[e.CALLEE=2]="CALLEE"}(m||(m={})),exports.RCCallBusyCallPolicy=void 0,(v=exports.RCCallBusyCallPolicy||(exports.RCCallBusyCallPolicy={}))[v.HANGUP=1]="HANGUP",v[v.IGNORE=2]="IGNORE";var S,I,O,T=function(){function t(e,t,r,o,n,i,a,s,l,c){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:a}),Object.defineProperty(this,"_mediaType",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_callId",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:c}),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&&(R.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 a in this._userInfo[t]={userId:t,state:exports.RCCallUserState.NONE,isCaller:!1,isRemote:!1},this._userTimers)this._clearTimerById(a);var s=exports.RCCallEndReason.ACCEPT_BY_OTHER_CLIENT;i===f.VCHangup&&(s=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],s),this._notifyStateChange(exports.RCCallSessionState.END,s)}}),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,a=this._isCrossAppkey?t.split("_")[1]:t;this._isRemoteInvalidMsg(a,i)?this._logger.debug("_","[RCCallStateMachine] onRinging -> not the remote device that is currently talking"):this._context.getCurrentId()!==a&&this._watchers.onRinging(o({userId:a},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,a=n.deviceId;t.sentTime;var s=this._isCrossAppkey?o.split("_")[1]:o,l=this._context.getCurrentId();this._isRemoteInvalidMsg(s,a)?this._logger.debug("_","[RCCallStateMachine] _onAccept -> not the remote device that is currently talking"):l!==s?(this._userTimers[s]&&this._clearTimerById(s),(this._conversationType===e.ConversationType.PRIVATE?[l,s]:[s]).forEach((function(e){var t=e===l;r._userInfo[e]={userId:e,state:exports.RCCallUserState.KEEPING,isCaller:t,isRemote:t,deviceId:t?h(r._runtime):a},t||(r._beginTimestamp=Date.now(),Object.assign(r._userInfo[s],i)),r._notifyUserStateChange(r._userInfo[e])})),this.getCallerId()===l&&this._notifyStateChange(exports.RCCallSessionState.KEEPING),this._watchers.onAccept({userId:s})):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,a=r.deviceId;this._isRemoteInvalidMsg(t,a)?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,a=i.reason,s=i.user,l=i.deviceId;if(this._options.busyCallPolicy!==exports.RCCallBusyCallPolicy.IGNORE||a!==exports.RCCallEndReason.BUSY_LINE){var 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],s),this._notifyUserStateChange(this._userInfo[n],E[a]),delete this._userInfo[n]),E[a]===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[a]),this._watchers.onHungup(o({userId:n},s),E[a])}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=a(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 R=s([n],a(u),!1);this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:R.filter((function(e){return o._isCrossAppkey?e.split("_")[1]!==_:e!==_}))});var h=this._isCrossAppkey?[u[0].split("_")[1]]:u;s([r],a(h),!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 y((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,a=n,s=a.user,c=a.existedUserPofiles,u=a.caller,d=a.deviceId,C=a.inviteUserIds,_=a.mediaType,R=this._context.getCurrentId();if(this._isRemoteInvalidMsg(r,d))this._logger.debug("_","[RCCallStateMachine] __onMemberModify -> not the remote device that is currently talking");else if(R!==r){if(this._callerId=u,this._inviterId=r,C.forEach((function(e){c.push({userId:e,mediaType:_,callStatus:l.INCOMING})})),C.includes(R)){var h=[];c.forEach((function(e){e.userId!==R&&h.push(e.userId)})),this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:h}),this._notifyStateChange(exports.RCCallSessionState.WAITING)}else this._watchers.onMemberModify({sender:o({userId:r},s),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:R!==o},o===r&&Object.assign(t._userInfo[o],s,{deviceId:d}),t._notifyUserStateChange(t._userInfo[o]),n!==l.CONNECTED&&!t._userTimers[o])){if(!C.includes(o))return;t._userTimers[o]=new y((function(){t._userInfo[o]&&(t._userInfo[o].state=exports.RCCallUserState.NONE);var e=o===R?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===R)&&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,s([n],o?[e[0].split("_")[1]]:a(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 y((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,_,R,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.info("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(t))),o=this._context.getCurrentId(),n=Object.keys(this._userInfo),0===(c=t.filter((function(e){return e!==o&&!n.includes(e)}))).length?(this._logger.warn("_","[RCCallStateMachine] invite -> all userId is in calling now!"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):(u=n.map((function(e){var t=l.CONNECTED;return g._userInfo[e].state===exports.RCCallUserState.WAITING&&(t=l.RINGING),{userId:e,mediaType:g._mediaType,callStatus:t,mediaId:e}})),d=r.extra,C=void 0===d?"":d,_=r.pushConfig,[4,this._callMsgHandler.sendMemeberModify({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:C,pushConfig:_,mediaType:this._mediaType,inviteUserIds:c,callerId:this.getCallerId(),existedUserPofiles:u,directionalUserIdList:s(s([],a(n),!1),a(c),!1).filter((function(e){return e!==o}))})]));case 1:return R=i.sent(),h=R.code,f=R.message,h===exports.RCCallErrorCode.SUCCESS?(p=f.sentTime,c.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 y((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))}))):c.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,n,a,s,l;return i(this,(function(i){switch(i.label){case 0:return r=this._context.getCurrentId(),n=exports.RCCallErrorCode.SUCCESS,t?(a={channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:e,userIds:this.getRemoteUserIds(),pushConfig:o({},this._hungupPushConfig)},e!==exports.RCCallEndReason.OTHER_CLIENT_JOINED_CALL?[3,1]:(this._callMsgHandler.sendHungup(a),[3,3])):[3,3];case 1:return[4,this._callMsgHandler.sendHungup(a)];case 2:s=i.sent().code,n=s,i.label=3;case 3:for(l in this._endTimestamp=Date.now(),this._userInfo)this._userInfo[l].state=exports.RCCallUserState.NONE,l===r?this._notifyUserStateChange(this._userInfo[l],e):this._notifyUserStateChange(this._userInfo[l]),delete this._userInfo[l];return Object.keys(this._userInfo).length<2&&this._notifyStateChange(exports.RCCallSessionState.END,e),[2,{code:n}]}}))}))}}),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 y((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,"userOffline",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this._logger.debug("_","[RCCallStateMachine] userOffline -> userIds: ".concat(JSON.stringify(e))),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_NETWORK_ERROR),t._watchers.onHungup(r,exports.RCCallEndReason.REMOTE_NETWORK_ERROR),delete t._userInfo[e]),Object.keys(t._userInfo).length<2&&t._sessionState!==exports.RCCallSessionState.END&&(t._endTimestamp=Date.now(),t._notifyStateChange(exports.RCCallSessionState.END,exports.RCCallEndReason.REMOTE_NETWORK_ERROR))}))}}),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,(S=exports.RCCallMediaType||(exports.RCCallMediaType={}))[S.AUDIO=1]="AUDIO",S[S.AUDIO_VIDEO=2]="AUDIO_VIDEO",function(e){e[e.ADD=1]="ADD",e[e.REMOVE=2]="REMOVE"}(I||(I={})),function(e){e.WEB="Web",e.IOS="iOS",e.ANDROID="Android"}(O||(O={}));var M,x,P=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,a=i.callId,s=i.mediaType;this._channelId=t,this._conversationType=r,this._targetId=o,this._callId=a,this._mediaType=s;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 f.VCInvite:this._doInvite(t);break;case f.VCRinging:this._doRinging(t);break;case f.VCAccept:this._doAccept(t);break;case f.VCModifyMem:this._doMemberModify(t);break;case f.VCModifyMedia:this._doMediaModify(t);break;case f.VCHangup:this._doHungup(t);break;default:this._logger.debug("_","[OfflineRecorder] onRecvOfflineMsgs -> unexpected message: ".concat(JSON.stringify(t)))}}while(this._messages.length>0)}}),e}(),A=["RC:VCAccept","RC:VCRinging","RC:VCSummary","RC:VCHangup","RC:VCInvite","RC:VCModifyMedia","RC:VCModifyMem"],N=((M={})[e.ErrorCode.REJECTED_BY_BLACKLIST]=exports.RCCallErrorCode.REJECTED_BY_BLACKLIST,M[e.ErrorCode.NOT_IN_GROUP]=exports.RCCallErrorCode.NOT_IN_GROUP,M),w=function(t){function o(e,r,o,n,i){void 0===n&&(n=6e4);var a=t.call(this)||this;return Object.defineProperty(a,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(a,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(a,"_offlineMsgItv",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_getStateMachine",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(a,"_userInfo",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(a,"_msgBufferList",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(a,"_hadHandleMsgTimer",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(a,"_offlineRecorder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_deviceId",{enumerable:!0,configurable:!0,writable:!0,value:""}),a._deviceId=h(r),a._context.onmessage=a._onMessage.bind(a),a._offlineRecorder=new P(a._context,a._logger,(function(e){a._logger.info("_","[CallMessageHandler] offlineRecorder -> ".concat(JSON.stringify(e))),a._watchers.onOfflineRecord&&a._watchers.onOfflineRecord(e)})),a}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(A.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){var r=e.content.callId;switch(this._logger.info("_","recv -> senderId: ".concat(e.senderUserId,", type: ").concat(e.messageType,", callId: ").concat(r)),e.messageType){case f.VCInvite:this._watchers.onInvite&&this._watchers.onInvite(e);break;case f.VCRinging:t.prototype.emit.call(this,"".concat(r,"onRinging"),e);break;case f.VCAccept:t.prototype.emit.call(this,"".concat(r,"onAccept"),e);break;case f.VCModifyMem:this._watchers.onInvite&&this._watchers.onInvite(e);break;case f.VCModifyMedia:t.prototype.emit.call(this,"".concat(r,"onMediaModify"),e);break;case f.VCHangup:t.prototype.emit.call(this,"".concat(r,"onHungup"),e);break;default:this._logger.warn("_","recv -> unexpected message: ".concat(e.messageType))}}}),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,_=[f.VCInvite,f.VCModifyMem].includes(i),R=t._context.getServerTime()-l,h=R<t._offlineMsgItv;if(h||t._logger.warn("_","offline msg delayTime: ".concat(R,"ms")),_){for(var p=[],g=0;g<n.length;g++){var b=n[g].msg;if(d!==b.content.callId)break;p.push(b)}if(t._logger.warn("_","taskMsgList length: ".concat(p.length)),p.length>0){var E=t._msgBufferList.findIndex((function(e){return e.msg.messageUId===p[p.length-1].messageUId}));t._msgBufferList=t._msgBufferList.slice(E+1);var m=n.findIndex((function(e){return e.msg.messageUId===p[p.length-1].messageUId}));n=n.slice(m+1)}var v=function(){if(o!==e.ConversationType.PRIVATE)return!1;var t=1===p.length,r=p.every((function(e){return[f.VCInvite,f.VCModifyMedia,f.VCRinging].includes(e.messageType)}));return t||r}(),y=function(){if(o!==e.ConversationType.GROUP)return!1;for(var r=!1,n=!0,i=s([c],a(C),!1),l=!1,u=function(e){var r=p[e],o=r.senderUserId,a=r.messageType;if(a===f.VCHangup&&o===t._context.getCurrentId())return"break";a===f.VCHangup&&(l=c===o,i=i.filter((function(e){return o!==e}))),a===f.VCAccept&&(n=!1)},d=0;d<p.length;d++){if("break"===u(d))break}return n&&l||!(i.length>1)||(r=!0),r}();h&&(v||y)&&p.forEach(t._onRecvOnlineCallMsg,t),t._offlineRecorder.onRecvOfflineMsgs(p)}else h&&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,a,s,l,c,u,d,C,_,R;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,a=t.content,s=t.messageType,l=t.directionalUserIdList,c=t.pushConfig,u={channelId:r,messageType:s,content:a,directionalUserIdList:l},[f.VCInvite,f.VCModifyMem,f.VCHangup].includes(s)&&((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:a.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,R=C.data,_!==e.ErrorCode.SUCCESS?(this._logger.error("_","CallMessageHandler] sendCallMesage error -> code: ".concat(_)),[2,{code:N[_]||exports.RCCallErrorCode.SEND_MSG_ERROR}]):[2,{code:exports.RCCallErrorCode.SUCCESS,message:R}]}}))}))}}),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,a,s,l,c,u,d,C;return i(this,(function(i){return r=t.roomType,o=t.channelId,n=t.conversationType,a=t.targetId,s=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:s}),C={platform:O.WEB,deviceId:this._deviceId,callId:s,roomType:r,extra:u,engineType:4,channelInfo:{Id:s,Key:""},mediaType:l,inviteUserIds:c,observerUserIds:[],user:this._userInfo},d&&(d.pushData=JSON.stringify({mediaType:l,userIdList:c,callId:s})),[2,this._sendCallMessage({channelId:o,conversationType:n,targetId:a,content:C,messageType:f.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,a,s,l,c,u,d,C,_;return i(this,(function(i){return t=e.channelId,r=e.conversationType,o=e.targetId,n=e.callId,a=e.mediaType,s=e.inviteUserIds,l=e.callerId,c=e.existedUserPofiles,u=e.directionalUserIdList,d=e.extra,C=e.pushConfig,_={platform:O.WEB,deviceId:this._deviceId,callId:n,extra:d,engineType:4,channelInfo:{Id:n,Key:""},mediaType:a,inviteUserIds:s,observerUserIds:[],user:this._userInfo,caller:l,modifyMemType:I.ADD,existedUserPofiles:c},C&&(C.pushData=JSON.stringify({mediaType:a,userIdList:s,callId:n})),[2,this._sendCallMessage({channelId:t,conversationType:r,targetId:o,content:_,messageType:f.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,a=t.userIds,s={platform:O.WEB,deviceId:this._deviceId,callId:i,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:s,messageType:f.VCRinging,directionalUserIdList:o===e.ConversationType.GROUP?a: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,a=t.mediaType,s=t.userIds,l={platform:O.WEB,deviceId:this._deviceId,callId:i,mediaType:a,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:l,messageType:f.VCAccept,directionalUserIdList:o===e.ConversationType.GROUP?s: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,a=t.reason,s=t.userIds,l=t.pushConfig,c={platform:O.WEB,deviceId:this._deviceId,callId:i,reason:a,user:this._userInfo};return l&&(l.pushData=JSON.stringify({callId:i,reason:a})),this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:c,messageType:f.VCHangup,pushConfig:l,directionalUserIdList:o===e.ConversationType.GROUP?s: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,a=t.mediaType,s=t.userIds,l={platform:O.WEB,deviceId:this._deviceId,callId:i,mediaType:a,user:this._userInfo};return this._sendCallMessage({channelId:r,conversationType:o,targetId:n,content:l,messageType:f.VCModifyMedia,directionalUserIdList:o===e.ConversationType.GROUP?s:void 0})}}),o}(e.EventEmitter);exports.RCCallLanguage=void 0,(x=exports.RCCallLanguage||(exports.RCCallLanguage={})).ZH="zh",x.EN="en";var U={PushTitle:{AUDIO:"You have a voice call",VIDEO:"You have a video call"}},L={PushTitle:{AUDIO:"您有一条音频通话",VIDEO:"您有一条视频通话"}},k=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?U:L}}),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.36.0"," CommitId: ").concat("d8b9ac7b0c1524c64f9de2808bbaf27adbc54715")),h(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}),R.on("onStateMachineClose",(function(e){delete i._stateMachine[e]})),k.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,s=e.senderUserId;e.pushConfig;var l,c=n,u=c.mediaType,d=c.callId,C=c.extra;l=c.roomType!==b.RCCallRoomTypeAcrossCall?s:a(s.split("_"),2)[1];var _=this._context.getCurrentId();if(this._context.getCurrentId()!==l){if(i===f.VCModifyMem)if(n.existedUserPofiles.some((function(e){return e.userId===_}))&&!this._stateMachine[d])return;if(this._stateMachine[d])i===f.VCModifyMem&&this._stateMachine[d].__onMemberModify(e);else this._stateMachine[d]=new T(this._context,this._runtime,this._logger,this._callMsgHandler,t,r,o,u,d,{busyCallPolicy:this._options.busyCallPolicy}),this._logger.info("_","[RCCallEngine] RCCallStateMachine successfully created -> callId: ".concat(d)),i===f.VCInvite?this._stateMachine[d].__onInvite(e):i===f.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,a,s,l){return void 0===a&&(a=""),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:a,pushConfig:s}))),n=_(),Object.keys(this._stateMachine).length>0?[2,{code:exports.RCCallErrorCode.STATE_MACHINE_EXIT}]:(this._stateMachine[n]=new T(this._context,this._runtime,this._logger,this._callMsgHandler,t,e.ConversationType.PRIVATE,r,o,n,{busyCallPolicy:this._options.busyCallPolicy}),[4,this._stateMachine[n].__call([r],a,s,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,a,s,l){return void 0===s&&(s=""),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 T(this._context,this._runtime,this._logger,this._callMsgHandler,t,e.ConversationType.GROUP,r,o,n,{busyCallPolicy:this._options.busyCallPolicy}),[4,this._stateMachine[n].__call(a,s,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}(),D=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=s([],a(this.list[e]),!1);if(!o||0===o.length)return!1;o.forEach((function(e){e.call(r,t)}))}}),e}());var V=function(r){if(!r)return{ok:!1,msg:"Initialization missing parameter -> options"};if("object"!=typeof r)return{ok:!1,msg:"Initialization options must be an object"};var o,n=Object.keys(r),i=[];return["rtcClient","onSession","onSessionClose"].forEach((function(e){n.includes(e)||i.push(e)})),i.length?{ok:!1,msg:'Initialization missing parameter -> "'.concat(i.join(","),'"')}:"object"!=typeof r.rtcClient?{ok:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:"function"!=typeof r.onSession?{ok:!1,msg:"Initialization 'onSession' parameter must be of type 'function'"}:"function"!=typeof r.onSessionClose?{ok:!1,msg:"Initialization 'onSessionClose' parameter must be of type 'function'"}:void 0!==r.isAllowSubscribeRetry&&"boolean"!=typeof r.isAllowSubscribeRetry?{ok:!1,msg:"Initialization 'isAllowSubscribeRetry' parameter must be of type 'boolean'"}:void 0!==r.isAllowPublishRetry&&"boolean"!=typeof r.isAllowPublishRetry?{ok:!1,msg:"Initialization 'isAllowPublishRetry' parameter must be of type 'boolean'"}:void 0!==r.isOffCameraWhenVideoDisable&&"boolean"!=typeof r.isOffCameraWhenVideoDisable?{ok:!1,msg:"Initialization 'isOffCameraWhenVideoDisable' parameter must be of type 'boolean'"}:void 0===r.joinType||(o=r.joinType,Object.values(t.RTCJoinType).includes(o))?void 0!==r.isAllowDemotionGetStream&&"boolean"!=typeof r.isAllowDemotionGetStream?{ok:!1,msg:"Initialization 'isAllowDemotionGetStream' parameter must be of type 'boolean'"}:void 0===r.lang||function(e){return Object.values(exports.RCCallLanguage).includes(e)}(r.lang)?void 0===r.logOutputLevel||function(t){return[e.LogL.DEBUG,e.LogL.INFO,e.LogL.WARN,e.LogL.ERROR].includes(t)}(r.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}},G=function(e){return e&&"string"==typeof e?{ok:!0}:{ok:!1,msg:"'targetId' parameter is required, must be of type 'string'"}},B=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'"}},K=function(e){return"string"==typeof e?{ok:!0}:{ok:!1,msg:"'extra' parameter must be of type 'string'"}},J=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 a=t.iOSConfig,s=t.androidConfig,l=W(a||{});if(l.code!==exports.RCCallErrorCode.SUCCESS)return l;var c=Y(s||{});return c.code!==exports.RCCallErrorCode.SUCCESS?c:{code:exports.RCCallErrorCode.SUCCESS}},W=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}},Y=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}},z=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:"'frameRate' and 'resolution' is required"};var r,o},q=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}(),X=function(){function r(e,t,r,a){void 0===a&&(a={});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:a}),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,"_callAsrListener",{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}),Object.defineProperty(this,"_nickName",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"_srcLanguage",{enumerable:!0,configurable:!0,writable:!0,value:""}),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,a;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),a=this._stateMachine.getSummary(),D.emit("sessionClose",{session:this,summaryInfo:a}),[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(o({},this._options.hungupPushConfig))}return Object.defineProperty(r.prototype,"_joinRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var o,a;return n(this,void 0,void 0,(function(){var n,s,l,c,u,d,C,_=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 n=i.sent(),[3,4];case 2:return[4,this._rtcClient.joinRTCRoomWithOptions(r,{joinType:this._options.joinType,nickName:this._nickName,srcLanguage:this._srcLanguage})];case 3:n=i.sent(),i.label=4;case 4:return s=n.code,l=n.userIds,c=n.room,s!==t.RCRTCCode.SUCCESS?(s===t.RCRTCCode.NOT_OPEN_VIDEO_AUDIO_SERVER&&this._exceptionClose(exports.RCCallEndReason.SERVICE_NOT_OPENED),s===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(s)),[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(c)]);case 5:return i.sent(),this._room=null,[2,{code:exports.RCCallErrorCode.SUCCESS}];case 6:return l.length<1&&(this.joinRoomTimer=new q((function(){_._exceptionClose(exports.RCCallEndReason.REMOTE_NETWORK_ERROR)}),6e4)),this._room=c,null===(a=null===(o=this._listener)||void 0===o?void 0:o.onConnected)||void 0===a||a.call(o,this),[3,8];case 7:return u=i.sent(),this._exceptionClose(exports.RCCallEndReason.NETWORK_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ".concat(r)),console.error(u),[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 d=i.sent(),this._exceptionClose(exports.RCCallEndReason.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ".concat(r)),console.error(d),[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 C=i.sent(),this._exceptionClose(exports.RCCallEndReason.PUBLISH_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _publish Exception roomId -> ".concat(r)),console.error(C),[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===m.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(),D.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,"registerCallASRListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._callAsrListener=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,l,c,u,d,C;return i(this,(function(i){switch(i.label){case 0:return n=this._getLocalAudioTracks(),l=this._getLocalVideoTracks(),n.length?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",r&&r.audio&&o({},r.audio))];case 1:if(c=i.sent(),d=c.code,C=c.track,d!==t.RCRTCCode.SUCCESS)return this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ".concat(d)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR}];n.push(C),i.label=2;case 2:return e===exports.RCCallMediaType.AUDIO?(this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get Audio local tracks"),[2,{code:exports.RCCallErrorCode.SUCCESS,tracks:n}]):l.length?[3,4]:[4,this._rtcClient.createCameraVideoTrack("RongCloudRTC",r&&r.video&&o({},r.video))];case 3:if(u=i.sent(),d=u.code,C=u.track,d!==t.RCRTCCode.SUCCESS)return this._logger.error("_","[RCCallSession _getLocalTrackCore] get Video local track failed RCT code -> ".concat(d)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR}];l.push(C),i.label=4;case 4:return this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get video local track"),[2,{code:exports.RCCallErrorCode.SUCCESS,tracks:s(s([],a(n),!1),a(l),!1)}]}}))}))}}),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,a,s,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 a=i.sent(),s=a.code,l=a.tracks,s!==exports.RCCallErrorCode.SUCCESS?(this._exceptionClose(exports.RCCallEndReason.GET_MEDIA_RESOURCES_ERROR),[2,{code:s}]):[2,{code:s,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,a,s;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(),a=n.code,s=n.track,a!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ".concat(a)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isAudioTrack()?e.destroy():o.push(e)})),r.push(s),o.push(s),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,"changeVideoDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){var r,o,n,a,s;return i(this,(function(i){switch(i.label){case 0:return this._room?[4,this._rtcClient.createCameraVideoTrack("RongCloudRTC",e)]:(this._logger.error("_","[RCCallSession changeVideoDevice] not in room"),[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 changeDevice] get local Video track failed RCTLib code -> ".concat(o)),[2,{code:exports.RCCallErrorCode.GET_LOCAL_VIDEO_TRACK_ERROR}]):(a=this._getLocalVideoTracks()[0],[4,this._room.changeMediaDevice(a,n)]);case 2:return(s=i.sent().code)!==t.RCRTCCode.SUCCESS?(null==n||n.destroy(),this._logger.error("_","[RCCallSession changeDevice] change video device failed RCTLib code -> ".concat(s)),[2,{code:exports.RCCallErrorCode.SWITCH_VIDEO_DEVICE_ERROR}]):(this._options.localTracks=this._options.localTracks.filter((function(e){return!e.isVideoTrack()})),this._options.localTracks.push(n),this._notifyTrackReady([n]),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var r;return void 0===t&&(t={}),n(this,void 0,void 0,(function(){var n,a,s,l,c,u,d,C;return i(this,(function(i){switch(i.label){case 0:if(n=t.extra,a=void 0===n?"":n,s=(null===(r=this._options.callPushConfig)||void 0===r?void 0:r.pushTitle)?o({},this._options.callPushConfig):t.pushConfig,l=[z(e),K(a)],s&&(c=J(s),u=c.code,d=c.errorMsg,u!==exports.RCCallErrorCode.SUCCESS))return this._logger.error("_","[RCCallSession invite] param error, errorMsg: ".concat(d)),[2,{code:u}];if(C=[],!l.every((function(e){return!e.ok&&C.push(e.msg),e.ok})))throw new Error("[RCCallClient invite] ".concat(C.join("\n")));return[4,this._stateMachine.invite(e,{extra:a,pushConfig:s})];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,a,s;return i(this,(function(i){switch(i.label){case 0:if(!(t=F(e)).ok)throw new Error("[RCCallSession accept] ".concat(t.msg));return D.emit("hungupOtherSession",{session:this}),r=this._stateMachine.getMediaType(),[4,this._getLocalTrack(r,e)];case 1:return o=i.sent(),n=o.code,a=o.tracks,n!==exports.RCCallErrorCode.SUCCESS?[2,{code:n}]:this._stateMachine.getState()===exports.RCCallSessionState.END?(this._destroyTracks(a),[2,{code:exports.RCCallErrorCode.SESSION_ENDED}]):(this._options.localTracks=a,[4,this._stateMachine.accept()]);case 2:return s=i.sent().code,this._stateMachine.getState()===exports.RCCallSessionState.END?(this._destroyTracks(a),[2,{code:exports.RCCallErrorCode.SESSION_ENDED}]):s!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallSession accept]Send accept message failed -> code: ".concat(s)),[2,{code:s}]):[2,{code:s}]}}))}))}}),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._options.localTracks&&(e=this._options.localTracks.filter((function(e){return e.isVideoTrack()}))),e}}),Object.defineProperty(r.prototype,"_getLocalAudioTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[];return this._options.localTracks&&(e=this._options.localTracks.filter((function(e){return e.isAudioTrack()}))),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,a;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}]):(a=[],this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isVideoTrack()?e.destroy():a.push(e)})),a.push(n),this._options.localTracks=a,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)},onUserOffline:function(t){e._logger.info("_","[RCCallSession onUserOffline] listening onUserOffline userIds -> ".concat(null==t?void 0:t.join(","))),e._stateMachine.userOffline(t)},onPing:function(t){var r,o;try{null===(o=null===(r=e._listener)||void 0===r?void 0:r.onPing)||void 0===o||o.call(r,t,e)}catch(e){console.error(e)}},onReceiveStartASR:function(){var t,r;null===(r=null===(t=e._callAsrListener)||void 0===t?void 0:t.onReceiveStartASR)||void 0===r||r.call(t)},onReceiveStopASR:function(){var t,r;null===(r=null===(t=e._callAsrListener)||void 0===t?void 0:t.onReceiveStopASR)||void 0===r||r.call(t)},onReceiveASRContent:function(t){var r,o;null===(o=null===(r=e._callAsrListener)||void 0===r?void 0:r.onReceiveASRContent)||void 0===o||o.call(r,t)},onReceiveRealtimeTranslationContent:function(t){var r,o;null===(o=null===(r=e._callAsrListener)||void 0===r?void 0:r.onReceiveRealtimeTranslationContent)||void 0===o||o.call(r,t)},onReceiveStartSummarization:function(t){var r,o;null===(o=null===(r=e._callAsrListener)||void 0===r?void 0:r.onReceiveStartSummarization)||void 0===o||o.call(r,t)},onReceiveStopSummarization:function(t){var r,o;null===(o=null===(r=e._callAsrListener)||void 0===r?void 0:r.onReceiveStopSummarization)||void 0===o||o.call(r,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()}}),Object.defineProperty(r.prototype,"setSrcLanguageCode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){return i(this,(function(t){return this._logger.info("_","[RCCallSession setSrcLanguageCode] languageCode: ".concat(e)),this._room?(this._srcLanguage=e,this._logger.info("_","[RCCallSession setSrcLanguageCode] success"),[2,{code:exports.RCCallErrorCode.SUCCESS}]):(this._logger.error("_","[RCCallSession setSrcLanguageCode] not in room"),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}])}))}))}}),Object.defineProperty(r.prototype,"startASR",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return this._logger.info("_","[RCCallSession startASR]"),this._room?[4,this._room.startASR()]:(this._logger.error("_","[RCCallSession startASR] not in room"),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return(e=r.sent().code)!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession startASR] startASR failed RTCCode -> ".concat(e)),[2,{code:e}]):(this._logger.info("_","[RCCallSession startASR] success"),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"asrIsAvailable",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!this._room&&this._room.asrIsAvailable()}}),Object.defineProperty(r.prototype,"stopASR",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return this._logger.info("_","[RCCallSession stopASR]"),this._room?[4,this._room.stopASR()]:(this._logger.error("_","[RCCallSession stopASR] not in room"),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return(e=r.sent().code)!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession stopASR] stopASR failed RTCCode -> ".concat(e)),[2,{code:e}]):(this._logger.info("_","[RCCallSession stopASR] success"),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"setEnableASR",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return this._logger.info("_","[RCCallSession setEnableASR] enable: ".concat(e)),this._room?[4,this._room.setEnableASR(e)]:(this._logger.error("_","[RCCallSession setEnableASR] 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 setEnableASR] setEnableASR failed RTCCode -> ".concat(r)),[2,{code:r}]):(this._logger.info("_","[RCCallSession setEnableASR] success"),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"startRealtimeTranslation",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return this._logger.info("_","[RCCallSession startRealtimeTranslation] destLangCode: ".concat(e)),this._room?[4,this._room.startRealtimeTranslation(e)]:(this._logger.error("_","[RCCallSession startRealtimeTranslation] 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 startRealtimeTranslation] startRealtimeTranslation failed RTCCode -> ".concat(r)),[2,{code:r}]):(this._logger.info("_","[RCCallSession startRealtimeTranslation] success"),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"stopRealtimeTranslation",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return this._logger.info("_","[RCCallSession stopRealtimeTranslation]"),this._room?[4,this._room.stopRealtimeTranslation()]:(this._logger.error("_","[RCCallSession stopRealtimeTranslation] not in room"),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return(e=r.sent().code)!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession stopRealtimeTranslation] stopRealtimeTranslation failed RTCCode -> ".concat(e)),[2,{code:e}]):(this._logger.info("_","[RCCallSession stopRealtimeTranslation] success"),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"startSummarization",{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 this._logger.info("_","[RCCallSession startSummarization]"),this._room?[4,this._room.startSummarization()]:(this._logger.error("_","[RCCallSession startSummarization] not in room"),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return e=n.sent(),r=e.code,o=e.taskId,r!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession startSummarization] startSummarization failed RTCCode -> ".concat(r)),[2,{code:r}]):(this._logger.info("_","[RCCallSession startSummarization] success"),[2,{code:exports.RCCallErrorCode.SUCCESS,taskId:o}])}}))}))}}),Object.defineProperty(r.prototype,"stopSummarization",{enumerable:!1,configurable:!0,writable:!0,value:function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return this._logger.info("_","[RCCallSession stopSummarization]"),this._room?[4,this._room.stopSummarization()]:(this._logger.error("_","[RCCallSession stopSummarization] not in room"),[2,{code:exports.RCCallErrorCode.NOT_IN_ROOM_ERROR}]);case 1:return(e=r.sent().code)!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallSession stopSummarization] stopSummarization failed RTCCode -> ".concat(e)),[2,{code:e}]):(this._logger.info("_","[RCCallSession stopSummarization] success"),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"setNickName",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._logger.info("_","[RCCallSession setNickName] nickName: ".concat(t)),!e.validate("nickName",t,e.notEmptyString,!0)||t.length>64?(this._logger.error("_","[RCCallSession setNickName] param error"),{code:exports.RCCallErrorCode.PARAM_ERROR}):(this._nickName=t,this._logger.info("_","[RCCallSession setNickName] success"),{code:exports.RCCallErrorCode.SUCCESS})}}),r}(),Z=function(){function r(e,r,n,i){var a=this;Object.defineProperty(this,"_context",{enumerable:!0,configurable:!0,writable:!0,value:e}),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:t.RTCJoinType.KICK,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,busyCallPolicy:this._options.busyCallPolicy||exports.RCCallBusyCallPolicy.HANGUP}),D.on("sessionClose",(function(e){var t=e.session,r=e.summaryInfo;a._removeSession(t);try{a._options.onSessionClose(t,r)}catch(e){a._logger.error("_","[RCCCallClient] options.onSessionClose exception"),console.log(e)}})),D.on("hungupOtherSession",(function(e){var t=e.session.getSessionId();a._logger.info("_","[RCCallClient hungupOtherSession] sessionId ready to accept -> ".concat(t)),a._logger.info("_","[RCCallClient hungupOtherSession] sessionList ->".concat(a._sessionList.map((function(e){return e.getSessionId()})).join(",")));for(var r=0;a._sessionList.length>1;)a._sessionList[r].getSessionId()!==t?(a._sessionList[r].hungup(),a._sessionList.splice(r,1)):r++;a._logger.info("_","[RCCallClient hungupOtherSession] current sessionList length ->".concat(a._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 X(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:m.CALLEE,callPushConfig:o({},this._callPushConfig),hungupPushConfig:o({},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 n=H(r._listener);if(!n.ok)throw new Error(n.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,a=e.listener,s=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,R=e.pushContent,h=void 0===R?"":R,f=e.bitrate;return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.__call({targetId:t,mediaType:o,listener:a,constraints:s,channelId:c,extra:d,pushTitle:_,pushContent:h,bitrate:f,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,a=e.listener,s=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,R=e.pushContent,h=void 0===R?"":R,f=e.bitrate;return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.__call({targetId:t,mediaType:o,listener:a,constraints:s,channelId:c,extra:d,pushTitle:_,pushContent:h,bitrate:f})]}))}))}}),Object.defineProperty(r.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=e.targetId,a=e.mediaType,s=void 0===a?exports.RCCallMediaType.AUDIO:a,l=e.listener,c=e.constraints,u=e.channelId,d=void 0===u?"":u,C=e.extra,_=void 0===C?"":C,R=e.pushTitle,h=void 0===R?"":R,f=e.pushContent,p=void 0===f?"":f,g=e.bitrate,b=e.isCrossAppkey,E=void 0!==b&&b;return n(this,void 0,void 0,(function(){var e,n,a,u,C,R,f,b,v,y,S,I,O,T;return i(this,(function(i){switch(i.label){case 0:return e=o({},null!==(t=this._callPushConfig)&&void 0!==t?t:{pushTitle:h,pushContent:p}),this._logger.info("_","[RCCallClient call] targetId: ".concat(r,", mediaType: ").concat(s)),r===this._context.getCurrentId()?(this._logger.error("_","[RCCallClient call] targetId is equal to currentId"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):(n=[G(r),B(s),H(l),K(_)],a=[],n.every((function(e){return!e.ok&&a.push(e.msg),e.ok}))?(u=J(e),C=u.code,R=u.errorMsg,C!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(R)),[2,{code:C}]):(f=[],[4,this._getLocalTrack(s,c)])):(console.error(a.join("\n")),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]));case 1:return b=i.sent(),v=b.code,y=b.tracks,v!==exports.RCCallErrorCode.SUCCESS?[2,{code:v}]:((f=y).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),l.onTrackReady(e)})),[4,this._callEngine.call(d,r,s,_,e,E)]);case 2:return S=i.sent(),I=S.code,O=S.stateMachine,I===exports.RCCallErrorCode.SUCCESS&&O?(this._logger.info("_","[RCCallClient call] successfully created state machine"),(T=new X(O,this._rtcClient,this._logger,{localTracks:f,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:m.CALLER,isCrossAppkey:E,callPushConfig:o({},this._callPushConfig),hungupPushConfig:o({},this._hungupPushConfig)})).registerSessionListener(l),this._sessionList.push(T),this._logger.info("_","[RCCallClient call] successfully created session object, sessionId: ".concat(T.getSessionId())),[2,{code:I,session:T}]):(this._logger.error("_","[RCCallClient call] call failed code ->: ".concat(I)),f.forEach((function(e){e.mute(),e.destroy()})),[2,{code:I}])}}))}))}}),Object.defineProperty(r.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,r=e.targetId,a=e.userIds,s=e.mediaType,l=void 0===s?exports.RCCallMediaType.AUDIO:s,c=e.listener,u=e.constraints,d=e.channelId,C=void 0===d?"":d,_=e.extra,R=void 0===_?"":_,h=e.pushTitle,f=void 0===h?"":h,p=e.pushContent,g=void 0===p?"":p,b=e.bitrate;return n(this,void 0,void 0,(function(){var e,n,s,d,_,h,p,E,v,y,S,I,O,T,M;return i(this,(function(i){switch(i.label){case 0:return e=o({},null!==(t=this._callPushConfig)&&void 0!==t?t:{pushTitle:f,pushContent:g}),n=[G(r),z(a),B(l),H(c),K(R)],s=[],d=n.every((function(e){return!e.ok&&s.push(e.msg),e.ok})),a.includes(this._context.getCurrentId())?(console.error("[RCCallClient callInGroup] userIds includes currentId"),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]):d?(_=J(e),h=_.code,p=_.errorMsg,h!==exports.RCCallErrorCode.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(p)),[2,{code:h}]):(E=[],[4,this._getLocalTrack(l,u)])):(console.error("[RCCallClient callInGroup] ".concat(s.join("\n"))),[2,{code:exports.RCCallErrorCode.PARAM_ERROR}]);case 1:return v=i.sent(),y=v.code,S=v.tracks,y!==exports.RCCallErrorCode.SUCCESS?[2,{code:y}]:((E=S).forEach((function(e){var t,r,o;e.isAudioTrack()&&(null==b?void 0:b.audio)&&e.setBitrate(null==b?void 0:b.audio),e.isVideoTrack()&&(null==b?void 0:b.video)&&e.setBitrate(null===(t=null==b?void 0:b.video)||void 0===t?void 0:t.max,null===(r=null==b?void 0:b.video)||void 0===r?void 0:r.min,null===(o=null==b?void 0:b.video)||void 0===o?void 0:o.start),c.onTrackReady(e)})),[4,this._callEngine.callInGroup(C,r,l,a,R,e)]);case 2:return I=i.sent(),O=I.code,T=I.stateMachine,O===exports.RCCallErrorCode.SUCCESS&&T?(this._logger.info("_","[RCCallClient callInGroup] successfully created state machine"),(M=new X(T,this._rtcClient,this._logger,{localTracks:E,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:m.CALLER,callPushConfig:o({},this._callPushConfig),hungupPushConfig:o({},this._hungupPushConfig)})).registerSessionListener(c),this._sessionList.push(M),this._logger.info("_","[RCCallClient callInGroup] successfully created session object, sessionId: ".concat(M.getSessionId())),[2,{code:O,session:M}]):(this._logger.info("_","[RCCallClient callInGroup] callInGroup failed code -> ".concat(O)),E.forEach((function(e){e.mute(),e.destroy()})),[2,{code:O}])}}))}))}}),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,a,s,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(),a=n.code,s=n.track,a!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ".concat(a)),[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:[s]}]);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,a,s,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 a=i.sent(),s=a.code,l=a.tracks,s!==exports.RCCallErrorCode.SUCCESS?[2,{code:s}]:[2,{code:s,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 J(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),a=i.next();!a.done;a=i.next()){var s=a.value,l=s.code,c=s.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{a&&!a.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}this._callPushConfig=e,this._hungupPushConfig=t}}),Object.defineProperty(r.prototype,"generateSummarization",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,o,a,s,l){return n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return this._logger.info("_","[RCCallClient generateSummarization] callId: ".concat(e,", taskId: ").concat(r,", startTime: ").concat(o,", endTime: ").concat(a)),[4,this._rtcClient.generateSummarization(e,r,o,a,s,l)];case 1:return(n=i.sent().code)!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallClient generateSummarization] generateSummarization failed RTCCode -> ".concat(n)),[2,{code:n}]):(this._logger.info("_","[RCCallClient generateSummarization] generateSummarization success"),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),Object.defineProperty(r.prototype,"getASRContent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,r,o,a,s,l){return n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return this._logger.info("_","[RCCallClient getASRContent] callId: ".concat(e,", taskId: ").concat(r,", startTime: ").concat(o,", endTime: ").concat(a,", destLang: ").concat(l)),[4,this._rtcClient.getASRContent(e,r,o,a,s,l)];case 1:return(n=i.sent().code)!==t.RCRTCCode.SUCCESS?(this._logger.error("_","[RCCallClient getASRContent] getASRContent failed RTCCode -> ".concat(n)),[2,{code:n}]):(this._logger.info("_","[RCCallClient getASRContent] getASRContent success"),[2,{code:exports.RCCallErrorCode.SUCCESS}])}}))}))}}),r}();e.VersionManage.add("calllib","5.36.0");var Q={tag:"RCCall",verify:function(e){return"browser"===e.tag},setup:function(t,r,o){var n=V(o);if(!n.ok)throw new Error("[RCCallLib installer steup]".concat(n.msg));if(!e.VersionManage.validEngine("5.36.1"))throw new Error("The current engine version '".concat(e.VersionManage.getInfo().engine,"' error, plugin-call required engine version at least '").concat("5.36.1","'."));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.36.0",", Commit: ").concat("d8b9ac7b0c1524c64f9de2808bbaf27adbc54715")),new Z(t,r,i,o)}};exports.RCCallClient=Z,exports.RCCallSession=X,exports.installer=Q;
|