@rongcloud/plugin-call 5.32.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.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{EventEmitter as e,ConversationType as t,ErrorCode as n,isUndefined as i,isBoolean as r,isString as o,LogL as a,VersionManage as
|
|
1
|
+
import{EventEmitter as e,ConversationType as t,ErrorCode as n,isUndefined as i,isBoolean as r,isString as o,LogL as a,validate as s,notEmptyString as l,VersionManage as c}from"@rongcloud/engine";import{RTCJoinType as u,RCResolution as d,RCKickReason as _,RCRTCCode as h}from"@rongcloud/plugin-rtc";var f=function(e,t){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},f(e,t)};var g=function(){return g=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},g.apply(this,arguments)};function p(e,t,n,i){return new(n||(n=Promise))((function(r,o){function a(e){try{l(i.next(e))}catch(e){o(e)}}function s(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((i=i.apply(e,t||[])).next())}))}function C(e,t){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,i=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function b(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return a}function R(e,t,n){if(n||2===arguments.length)for(var i,r=0,o=t.length;r<o;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var m,v,I,E,y=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(""),n=t.length+1,i=+e,r=[];do{var o=i%n;i=(i-o)/n,r.unshift(t[o])}while(i);return r.join("")}(e=parseInt(e,16))).length>22&&(e=e.slice(0,22)),e},O=function(){var e=Math.floor(1e3*Math.random()),t=y();return[t=t.replace(/\//g,"0"),Date.now(),e].join("_")},S=new e,T=function(e){var t="RCCallDeviceId",n=e.sessionStorage.getItem(t);return n||(n=y(),e.sessionStorage.setItem(t,n)),n};!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"}(m||(m={})),function(e){e[e.SUCCESS=1e4]="SUCCESS",e[e.STATE_MACHINE_EXIT=53200]="STATE_MACHINE_EXIT",e[e.SEND_MSG_ERROR=53201]="SEND_MSG_ERROR",e[e.REJECTED_BY_BLACKLIST=53202]="REJECTED_BY_BLACKLIST",e[e.NOT_IN_GROUP=53203]="NOT_IN_GROUP",e[e.GET_LOCAL_AUDIO_TRACK_ERROR=53301]="GET_LOCAL_AUDIO_TRACK_ERROR",e[e.GET_LOCAL_VIDEO_TRACK_ERROR=53302]="GET_LOCAL_VIDEO_TRACK_ERROR",e[e.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR=53303]="GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR",e[e.JOIN_ROOM_ERROR=53304]="JOIN_ROOM_ERROR",e[e.AUDIO_PUBLISH_ERROR=53305]="AUDIO_PUBLISH_ERROR",e[e.VIDEO_PUBLISH_ERROR=53306]="VIDEO_PUBLISH_ERROR",e[e.AUDIO_AND_VIDEO_PUBLISH_ERROR=53307]="AUDIO_AND_VIDEO_PUBLISH_ERROR",e[e.QUERY_JOINED_USER_INFO_ERROR=53308]="QUERY_JOINED_USER_INFO_ERROR",e[e.MISSING_VIDEO_TRACK_ERROR=53309]="MISSING_VIDEO_TRACK_ERROR",e[e.UNPUBLISH_VIDEO_ERROR=53310]="UNPUBLISH_VIDEO_ERROR",e[e.CONVERSATION_NOT_GROUP_ERROR=53311]="CONVERSATION_NOT_GROUP_ERROR",e[e.NOT_IN_ROOM_ERROR=53312]="NOT_IN_ROOM_ERROR",e[e.PARAM_ERROR=53313]="PARAM_ERROR",e[e.MISSING_AUDIO_TRACK_ERROR=53314]="MISSING_AUDIO_TRACK_ERROR",e[e.SESSION_ENDED=53315]="SESSION_ENDED",e[e.SWITCH_VIDEO_DEVICE_ERROR=53316]="SWITCH_VIDEO_DEVICE_ERROR"}(v||(v={})),function(e){e[e.CANCEL=1]="CANCEL",e[e.REJECT=2]="REJECT",e[e.HANGUP=3]="HANGUP",e[e.BUSY_LINE=4]="BUSY_LINE",e[e.NO_RESPONSE=5]="NO_RESPONSE",e[e.ENGINE_UNSUPPORTED=6]="ENGINE_UNSUPPORTED",e[e.NETWORK_ERROR=7]="NETWORK_ERROR",e[e.GET_MEDIA_RESOURCES_ERROR=8]="GET_MEDIA_RESOURCES_ERROR",e[e.PUBLISH_ERROR=9]="PUBLISH_ERROR",e[e.SUBSCRIBE_ERROR=10]="SUBSCRIBE_ERROR",e[e.REMOTE_CANCEL=11]="REMOTE_CANCEL",e[e.REMOTE_REJECT=12]="REMOTE_REJECT",e[e.REMOTE_HANGUP=13]="REMOTE_HANGUP",e[e.REMOTE_BUSY_LINE=14]="REMOTE_BUSY_LINE",e[e.REMOTE_NO_RESPONSE=15]="REMOTE_NO_RESPONSE",e[e.REMOTE_ENGINE_UNSUPPORTED=16]="REMOTE_ENGINE_UNSUPPORTED",e[e.REMOTE_NETWORK_ERROR=17]="REMOTE_NETWORK_ERROR",e[e.REMOTE_GET_MEDIA_RESOURCE_ERROR=18]="REMOTE_GET_MEDIA_RESOURCE_ERROR",e[e.REMOTE_PUBLISH_ERROR=19]="REMOTE_PUBLISH_ERROR",e[e.REMOTE_SUBSCRIBE_ERROR=20]="REMOTE_SUBSCRIBE_ERROR",e[e.OTHER_CLIENT_JOINED_CALL=21]="OTHER_CLIENT_JOINED_CALL",e[e.OTHER_CLIENT_IN_CALL=22]="OTHER_CLIENT_IN_CALL",e[e.KICKED_BY_SERVER=23]="KICKED_BY_SERVER",e[e.ACCEPT_SYSTEM_CALL=24]="ACCEPT_SYSTEM_CALL",e[e.REMOTE_OTHER_CLIENT_JOINED_CALL=31]="REMOTE_OTHER_CLIENT_JOINED_CALL",e[e.REMOTE_OTHER_CLIENT_IN_CALL=32]="REMOTE_OTHER_CLIENT_IN_CALL",e[e.REMOTE_KICKED_BY_SERVER=33]="REMOTE_KICKED_BY_SERVER",e[e.REMOTE_ACCEPT_SYSTEM_CALL=34]="REMOTE_ACCEPT_SYSTEM_CALL",e[e.ACCEPT_BY_OTHER_CLIENT=101]="ACCEPT_BY_OTHER_CLIENT",e[e.HANGUP_BY_OTHER_CLIENT=102]="HANGUP_BY_OTHER_CLIENT",e[e.ADDED_TO_BLACKLIST=103]="ADDED_TO_BLACKLIST",e[e.SERVICE_NOT_OPENED=104]="SERVICE_NOT_OPENED"}(E||(E={}));var M,P,A,N,w=((I={})[E.CANCEL]=E.REMOTE_CANCEL,I[E.REJECT]=E.REMOTE_REJECT,I[E.HANGUP]=E.REMOTE_HANGUP,I[E.BUSY_LINE]=E.REMOTE_BUSY_LINE,I[E.NO_RESPONSE]=E.REMOTE_NO_RESPONSE,I[E.ENGINE_UNSUPPORTED]=E.REMOTE_ENGINE_UNSUPPORTED,I[E.NETWORK_ERROR]=E.REMOTE_NETWORK_ERROR,I[E.GET_MEDIA_RESOURCES_ERROR]=E.REMOTE_GET_MEDIA_RESOURCE_ERROR,I[E.PUBLISH_ERROR]=E.REMOTE_PUBLISH_ERROR,I[E.SUBSCRIBE_ERROR]=E.REMOTE_SUBSCRIBE_ERROR,I[E.OTHER_CLIENT_JOINED_CALL]=E.REMOTE_OTHER_CLIENT_JOINED_CALL,I[E.OTHER_CLIENT_IN_CALL]=E.REMOTE_OTHER_CLIENT_IN_CALL,I[E.KICKED_BY_SERVER]=E.REMOTE_KICKED_BY_SERVER,I[E.REMOTE_NO_RESPONSE]=E.NO_RESPONSE,I[E.ACCEPT_SYSTEM_CALL]=E.REMOTE_ACCEPT_SYSTEM_CALL,I);!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"}(M||(M={})),function(e){e[e.WAITING=0]="WAITING",e[e.KEEPING=1]="KEEPING",e[e.END=2]="END"}(P||(P={})),function(e){e[e.NONE=0]="NONE",e[e.WAITING=1]="WAITING",e[e.KEEPING=2]="KEEPING"}(A||(A={})),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"}(P||(P={}));var w,A,U=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"}(w||(w={})),function(e){e[e.HANGUP=1]="HANGUP",e[e.IGNORE=2]="IGNORE"}(A||(A={}));var L,k,j,D=function(){function e(e,t,n,i,r,o,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:n}),Object.defineProperty(this,"_callMsgHandler",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_channelId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_conversationType",{enumerable:!0,configurable:!0,writable:!0,value:o}),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(e.prototype,"_getTimeout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._context.getServerTime()-e;t<0&&(t=500);var n=this._callTimeout-t;return this._logger.warn("_","_getTimeout -> timeout: ".concat(n)),n}}),Object.defineProperty(e.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(e.prototype,"_notifyStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n;this._logger.warn("_","[RCCallStateMachine] notifyStateChange -> info: ".concat(JSON.stringify({state:e,reason:t}))),this._endReason=t||null,this._sessionState!==e&&(this._sessionState=e,null===(n=this._watchers)||void 0===n||n.onStateChange({state:e,reason:t})),e===S.END&&(v.emit("onStateMachineClose",this._callId),this._callMsgHandler.unregisterStateMachineEvent(this._callId))}}),Object.defineProperty(e.prototype,"_notifyUserStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n;this._logger.warn("_","[RCCallStateMachine] notifyUserStateChange -> info: ".concat(JSON.stringify({user:e,reason:t}))),null===(n=this._watchers)||void 0===n||n.onUserStateChange({user:e,reason:t})}}),Object.defineProperty(e.prototype,"_otherClientHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,i=n.user,r=n.reason,o=e.messageType;for(var a in this._userInfo[t]={userId:t,state:M.NONE,isCaller:!1,isRemote:!1},this._userTimers)this._clearTimerById(a);var s=E.ACCEPT_BY_OTHER_CLIENT;o===T.VCHangup&&(s=r===E.BUSY_LINE?E.OTHER_CLIENT_IN_CALL:r===E.NO_RESPONSE?E.NO_RESPONSE:E.HANGUP_BY_OTHER_CLIENT),Object.assign(this._userInfo[t],i),this._notifyUserStateChange(this._userInfo[t],s),this._notifyStateChange(S.END,s)}}),Object.defineProperty(e.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===M.KEEPING&&this._userInfo[e].deviceId!==t))}}),Object.defineProperty(e.prototype,"_onRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,i=n.user,r=n.deviceId,o=this._isCrossAppkey?t.split("_")[1]:t;this._isRemoteInvalidMsg(o,r)?this._logger.debug("_","[RCCallStateMachine] onRinging -> not the remote device that is currently talking"):this._context.getCurrentId()!==o&&this._watchers.onRinging(h({userId:o},i))}}),Object.defineProperty(e.prototype,"_onAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=this,i=e.senderUserId,r=e.content,o=r.user,a=r.deviceId;e.sentTime;var s=this._isCrossAppkey?i.split("_")[1]:i,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===t.PRIVATE?[l,s]:[s]).forEach((function(e){var t=e===l;n._userInfo[e]={userId:e,state:M.KEEPING,isCaller:t,isRemote:t,deviceId:t?O(n._runtime):a},t||(n._beginTimestamp=Date.now(),Object.assign(n._userInfo[s],o)),n._notifyUserStateChange(n._userInfo[e])})),this.getCallerId()===l&&this._notifyStateChange(S.KEEPING),this._watchers.onAccept({userId:s})):this._otherClientHandle(e)}}),Object.defineProperty(e.prototype,"_onMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,i=n.mediaType,r=n.user,o=n.deviceId;this._isRemoteInvalidMsg(t,o)?this._logger.debug("_","[RCCallStateMachine] _onMediaModify -> not the remote device that is currently talking"):this._context.getCurrentId()!==t&&(this._mediaType=i,this._watchers.onMediaModify({sender:h({userId:t},r),mediaType:i}))}}),Object.defineProperty(e.prototype,"_onHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,i=this._isCrossAppkey?t.split("_")[1]:t,r=n,o=r.reason,a=r.user,s=r.deviceId;if(this._options.busyCallPolicy!==A.IGNORE||o!==E.BUSY_LINE){var l=this._context.getCurrentId();if(this._isRemoteInvalidMsg(i,s))this._logger.debug("_","[RCCallStateMachine] _onHungup -> not the remote device that is currently talking");else if(l!==i)if(this._sessionState!==S.END){this._userInfo[i]&&(this._userInfo[i].state=M.NONE,this._endTimestamp=Date.now(),Object.assign(this._userInfo[i],a),this._notifyUserStateChange(this._userInfo[i],N[o]),delete this._userInfo[i]),N[o]===E.REMOTE_CANCEL?this.getRemoteUserIds().length<1&&this._clearTimerById(l):this.getInviterId()===l?this._clearTimerById(i):this.getRemoteUserIds().length<1&&this._clearTimerById(l);var c=Object.keys(this._userInfo).length<2,u=this._inviterId===i,d=Object.values(this._userInfo).every((function(e){return e.state!==M.KEEPING}));(c||u&&d)&&this._notifyStateChange(S.END,N[o]),this._watchers.onHungup(h({userId:i},a),N[o])}else this._logger.info("_","[RCCallStateMachine] Invalid hang up message, current room status has ended -> sessionState: ".concat(this._sessionState));else this._otherClientHandle(e)}}}),Object.defineProperty(e.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._watchers=e}}),Object.defineProperty(e.prototype,"__onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,n,i=this,r=e.senderUserId,o=e.content,a=e.sentTime,s=o,l=s.inviteUserIds,c=s.user,u=s.deviceId;s.roomType===P.RCCallRoomTypeAcrossCall?(t=p(r.split("_"),2),n=t[1],this._watchers.crossAppkey(!0),this._isCrossAppkey=!0):n=r;var d=this._context.getCurrentId();if(this._isRemoteInvalidMsg(n,u))this._logger.debug("_","[RCCallStateMachine] __onInvite -> not the remote device that is currently talking");else if(d!==n){this._callerId=this._inviterId=n;var _=b([r],p(l),!1);this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:_.filter((function(e){return i._isCrossAppkey?e.split("_")[1]!==d:e!==d}))});var h=this._isCrossAppkey?[l[0].split("_")[1]]:l;b([n],p(h),!1).forEach((function(e){i._userInfo[e]={userId:e,state:M.WAITING,isCaller:e===n,isRemote:e!==d},e===n&&Object.assign(i._userInfo[e],c,{deviceId:u}),i._notifyUserStateChange(i._userInfo[e]),e!==n&&(i._userTimers[e]=new U((function(){var t=e===d?E.NO_RESPONSE:E.REMOTE_NO_RESPONSE;e===d?i._hungupHandle(t,!1):(i._userInfo[e]&&(i._userInfo[e].state=M.NONE),i._notifyUserStateChange(i._userInfo[e]),i._watchers.onHungup(i._userInfo[e],t),delete i._userInfo[e]),i._clearTimerById(e)}),i._getTimeout(a)))})),this._notifyStateChange(S.WAITING)}}}),Object.defineProperty(e.prototype,"__onMemberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,n=e.senderUserId,i=e.content,r=e.sentTime,o=i,a=o.user,s=o.existedUserPofiles,l=o.caller,c=o.deviceId,u=o.inviteUserIds,d=o.mediaType,_=this._context.getCurrentId();if(this._isRemoteInvalidMsg(n,c))this._logger.debug("_","[RCCallStateMachine] __onMemberModify -> not the remote device that is currently talking");else if(_!==n){if(this._callerId=l,this._inviterId=n,u.forEach((function(e){s.push({userId:e,mediaType:d,callStatus:C.INCOMING})})),u.includes(_)){var f=[];s.forEach((function(e){e.userId!==_&&f.push(e.userId)})),this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:f}),this._notifyStateChange(S.WAITING)}else this._watchers.onMemberModify({sender:h({userId:n},a),invitedUsers:u.map((function(e){return{userId:e}}))});s.forEach((function(e){var i=e.userId,o=e.callStatus;if(o!==C.IDLE&&(t._userInfo[i]={userId:i,state:o!==C.CONNECTED?M.WAITING:M.KEEPING,isCaller:n===i,isRemote:_!==i},i===n&&Object.assign(t._userInfo[i],a,{deviceId:c}),t._notifyUserStateChange(t._userInfo[i]),o!==C.CONNECTED&&!t._userTimers[i])){if(!u.includes(i))return;t._userTimers[i]=new U((function(){t._userInfo[i]&&(t._userInfo[i].state=M.NONE);var e=i===_?E.NO_RESPONSE:E.REMOTE_NO_RESPONSE;t._notifyUserStateChange(t._userInfo[i],e);try{t._watchers.onHungup(t._userInfo[i],e)}catch(e){t._logger.error("_","[RCCallStateMachine] call onhungup error -> ".concat(null==e?void 0:e.stack))}delete t._userInfo[i],(Object.keys(t._userInfo).length<2||i===_)&&t._notifyStateChange(S.END,e),t._clearTimerById(i)}),t._getTimeout(r))}}))}}}),Object.defineProperty(e.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=M.NONE),this._notifyUserStateChange(this._userInfo[e]),this._clearTimerById(e);this._notifyStateChange(S.END,E.BUSY_LINE),this._callMsgHandler.sendHungup({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:E.BUSY_LINE,userIds:this.getRemoteUserIds()})}}),Object.defineProperty(e.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,i){return void 0===t&&(t=""),void 0===i&&(i=!1),f(this,void 0,void 0,(function(){var r,o,a,s,l,c,u=this;return g(this,(function(d){switch(d.label){case 0:return this._logger.debug("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(e))),r=this._callerId=this._inviterId=this._context.getCurrentId(),[4,this._callMsgHandler.sendInvite({roomType:i?P.RCCallRoomTypeAcrossCall:P.RCCallRoomTypeNormalCall,channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:t,pushConfig:n,mediaType:this._mediaType,inviteUserIds:e.filter((function(e){return e!==r}))})];case 1:return o=d.sent(),a=o.code,s=o.message,this._isCrossAppkey=i,a===R.SUCCESS?(l=s.sentTime,b([r],i?[e[0].split("_")[1]]:p(e),!1).forEach((function(e){var t=e===r;u._userInfo[e]={userId:e,state:M.WAITING,isCaller:t,isRemote:!t},u._notifyUserStateChange(u._userInfo[e]),t||(u._userTimers[e]=new U((function(){u._userInfo[e]&&(u._userInfo[e].state=M.NONE),u._notifyUserStateChange(u._userInfo[e],E.REMOTE_NO_RESPONSE),u._watchers.onHungup(u._userInfo[e],E.REMOTE_NO_RESPONSE),delete u._userInfo[e],Object.keys(u._userInfo).length<2&&u._notifyStateChange(S.END,E.REMOTE_NO_RESPONSE),0===u.getRemoteUserIds().length&&u._userInfo[r].state!==M.KEEPING&&u._hungupHandle(E.REMOTE_NO_RESPONSE)}),u._getTimeout(l)))})),this._notifyStateChange(S.WAITING)):(c=a===R.REJECTED_BY_BLACKLIST?E.ADDED_TO_BLACKLIST:E.NETWORK_ERROR,this._notifyStateChange(S.END,c)),[2,{code:a}]}}))}))}}),Object.defineProperty(e.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t,n,i,r;return g(this,(function(o){switch(o.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=o.sent(),n=t.code,i=t.message,this._clearTimerById(e),n===R.SUCCESS?(i.sentTime,this._userInfo[e]&&(this._userInfo[e].state=M.KEEPING),this._beginTimestamp=Date.now(),this._notifyUserStateChange(this._userInfo[e]),this._notifyStateChange(S.KEEPING)):(this._userInfo[e]&&(this._userInfo[e].state=M.NONE),this._notifyUserStateChange(this._userInfo[e]),r=n===R.REJECTED_BY_BLACKLIST?E.ADDED_TO_BLACKLIST:E.NETWORK_ERROR,this._notifyStateChange(S.END,r)),[2,{code:n}]}}))}))}}),Object.defineProperty(e.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){return void 0===n&&(n={}),f(this,void 0,void 0,(function(){var i,r,o,a,s,l,c,u,d,_,h,f=this;return g(this,(function(g){switch(g.label){case 0:return this._conversationType!==t.GROUP?[2,{code:R.CONVERSATION_NOT_GROUP_ERROR}]:(this._logger.info("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(e))),i=this._context.getCurrentId(),r=Object.keys(this._userInfo),0===(o=e.filter((function(e){return e!==i&&!r.includes(e)}))).length?(this._logger.warn("_","[RCCallStateMachine] invite -> all userId is in calling now!"),[2,{code:R.PARAM_ERROR}]):(a=r.map((function(e){var t=C.CONNECTED;return f._userInfo[e].state===M.WAITING&&(t=C.RINGING),{userId:e,mediaType:f._mediaType,callStatus:t,mediaId:e}})),s=n.extra,l=void 0===s?"":s,c=n.pushConfig,[4,this._callMsgHandler.sendMemeberModify({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:l,pushConfig:c,mediaType:this._mediaType,inviteUserIds:o,callerId:this.getCallerId(),existedUserPofiles:a,directionalUserIdList:b(b([],p(r),!1),p(o),!1).filter((function(e){return e!==i}))})]));case 1:return u=g.sent(),d=u.code,_=u.message,d===R.SUCCESS?(h=_.sentTime,o.forEach((function(e){f._userInfo[e]={userId:e,state:M.WAITING,isCaller:!1,isRemote:!0},f._notifyUserStateChange(f._userInfo[e]),f._userTimers[e]=new U((function(){f._userInfo[e]&&(f._userInfo[e].state=M.NONE),f._notifyUserStateChange(f._userInfo[e],E.REMOTE_NO_RESPONSE),f._watchers.onHungup(f._userInfo[e],E.REMOTE_NO_RESPONSE),delete f._userInfo[e],Object.keys(f._userInfo).length<2&&f._notifyStateChange(S.END,E.REMOTE_NO_RESPONSE)}),f._getTimeout(h))}))):o.forEach((function(e){f._userInfo[e]={userId:e,state:M.NONE,isCaller:!1,isRemote:!0};var t=d===R.REJECTED_BY_BLACKLIST?E.ADDED_TO_BLACKLIST:E.NETWORK_ERROR;f._notifyUserStateChange(f._userInfo[e],t)})),[2,{code:d}]}}))}))}}),Object.defineProperty(e.prototype,"_hungupHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t=!0),f(this,void 0,void 0,(function(){var n,i,r,o,a;return g(this,(function(s){switch(s.label){case 0:return n=this._context.getCurrentId(),i=R.SUCCESS,t?(r={channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:e,userIds:this.getRemoteUserIds(),pushConfig:h({},this._hungupPushConfig)},e!==E.OTHER_CLIENT_JOINED_CALL?[3,1]:(this._callMsgHandler.sendHungup(r),[3,3])):[3,3];case 1:return[4,this._callMsgHandler.sendHungup(r)];case 2:o=s.sent().code,i=o,s.label=3;case 3:for(a in this._endTimestamp=Date.now(),this._userInfo)this._userInfo[a].state=M.NONE,a===n?this._notifyUserStateChange(this._userInfo[a],e):this._notifyUserStateChange(this._userInfo[a]),delete this._userInfo[a];return Object.keys(this._userInfo).length<2&&this._notifyStateChange(S.END,e),[2,{code:i}]}}))}))}}),Object.defineProperty(e.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t,n;return g(this,(function(i){for(n in this._logger.debug("_","[RCCallStateMachine] hungup"),e=this._context.getCurrentId(),t=E.HANGUP,Object.keys(this._userTimers).length>0&&(this._userInfo[e].isCaller?t=E.CANCEL:this._userInfo[e].state===M.WAITING&&(t=E.REJECT)),this._userTimers)this._clearTimerById(n);return[2,this._hungupHandle(t)]}))}))}}),Object.defineProperty(e.prototype,"changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.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=n.sent().code)===R.SUCCESS&&(this._mediaType=e),[2,{code:t}]}}))}))}}),Object.defineProperty(e.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 n=t._userInfo[e];n&&n.state!==M.KEEPING&&(n.state=M.KEEPING,t._notifyUserStateChange(n)),t._sessionState!==S.KEEPING&&t._notifyStateChange(S.KEEPING),t._clearTimerById(e)}))}),300)}}),Object.defineProperty(e.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 n=t._userInfo[e];n&&n.state!==M.NONE&&(n.state=M.NONE,t._notifyUserStateChange(n,E.REMOTE_HANGUP),t._watchers.onHungup(n,E.REMOTE_HANGUP),delete t._userInfo[e]),new U((function(){var e=t.getRemoteUsers();1===e.length&&1===e[0].state&&t._hungupHandle(E.REMOTE_NETWORK_ERROR)}),6e4),Object.keys(t._userInfo).length<2&&t._sessionState!==S.END&&(t._endTimestamp=Date.now(),t._notifyStateChange(S.END,E.REMOTE_HANGUP))}))}),300)}}),Object.defineProperty(e.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 n=t._userInfo[e];n&&n.state!==M.NONE&&(n.state=M.NONE,t._notifyUserStateChange(n,E.REMOTE_NETWORK_ERROR),t._watchers.onHungup(n,E.REMOTE_NETWORK_ERROR),delete t._userInfo[e]),Object.keys(t._userInfo).length<2&&t._sessionState!==S.END&&(t._endTimestamp=Date.now(),t._notifyStateChange(S.END,E.REMOTE_NETWORK_ERROR))}))}}),Object.defineProperty(e.prototype,"close",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hungupHandle(e)}}),Object.defineProperty(e.prototype,"setHungupPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hungupPushConfig=e}}),Object.defineProperty(e.prototype,"getCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(e.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._channelId}}),Object.defineProperty(e.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._targetId}}),Object.defineProperty(e.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._conversationType}}),Object.defineProperty(e.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(e.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[],t=this._context.getCurrentId();for(var n in this._userInfo){this._userInfo[n].userId!==t&&e.push(this._userInfo[n])}return e}}),Object.defineProperty(e.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null===this._sessionState?S.END:this._sessionState}}),Object.defineProperty(e.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(e.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callerId}}),Object.defineProperty(e.prototype,"getInviterId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._inviterId}}),Object.defineProperty(e.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mediaType}}),Object.defineProperty(e.prototype,"getSummary",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._beginTimestamp,t=this._endTimestamp,n=0;t>e&&0!==e&&(n=t-e);var i={conversationType:this._conversationType,channelId:this._channelId,targetId:this._targetId,mediaType:this._mediaType,beginTimestamp:e,endTimestamp:t,duration:n,endReason:this._endReason};return this._logger.debug("_","[RCCallStateMachine] getSummary -> summary: ".concat(JSON.stringify(i))),i}}),e}();!function(e){e[e.AUDIO=1]="AUDIO",e[e.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(L||(L={})),function(e){e[e.ADD=1]="ADD",e[e.REMOVE=2]="REMOVE"}(k||(k={})),function(e){e.WEB="Web",e.IOS="iOS",e.ANDROID="Android"}(j||(j={}));var V,H,G=function(){function e(e,t,n){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:n}),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,n=e.conversationType,i=e.targetId,r=e.senderUserId,o=e.content,a=o.callId,s=o.mediaType;this._channelId=t,this._conversationType=n,this._targetId=i,this._callId=a,this._mediaType=s;this._inviterId=r,this._endReason=E.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=E.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,n=e.sentTime,i=e.senderUserId,r=t.reason,o=i===this._context.getCurrentId();this._endReason=o?r:N[r],this._endTimestamp=n,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;[E.HANGUP,E.REMOTE_HANGUP,E.OTHER_CLIENT_JOINED_CALL,E.REMOTE_OTHER_CLIENT_JOINED_CALL,E.KICKED_BY_SERVER,E.REMOTE_KICKED_BY_SERVER,E.ACCEPT_SYSTEM_CALL,E.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(),n=t.messageType;switch(t.content.callId,n){case T.VCInvite:this._doInvite(t);break;case T.VCRinging:this._doRinging(t);break;case T.VCAccept:this._doAccept(t);break;case T.VCModifyMem:this._doMemberModify(t);break;case T.VCModifyMedia:this._doMediaModify(t);break;case T.VCHangup:this._doHungup(t);break;default:this._logger.debug("_","[OfflineRecorder] onRecvOfflineMsgs -> unexpected message: ".concat(JSON.stringify(t)))}}while(this._messages.length>0)}}),e}(),x=["RC:VCAccept","RC:VCRinging","RC:VCSummary","RC:VCHangup","RC:VCInvite","RC:VCModifyMedia","RC:VCModifyMem"],B=((V={})[n.REJECTED_BY_BLACKLIST]=R.REJECTED_BY_BLACKLIST,V[n.NOT_IN_GROUP]=R.NOT_IN_GROUP,V),K=function(e){function i(t,n,i,r,o){void 0===r&&(r=6e4);var a=e.call(this)||this;return Object.defineProperty(a,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"_offlineMsgItv",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_getStateMachine",{enumerable:!0,configurable:!0,writable:!0,value:o}),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=O(n),a._context.onmessage=a._onMessage.bind(a),a._offlineRecorder=new G(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 n(){this.constructor=e}_(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(i,e),Object.defineProperty(i.prototype,"_onMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(x.includes(e.messageType)){this._logger.debug("_","[CallMessageHandler] _onMessage -> call message: ".concat(JSON.stringify(e)));try{var t=Date.now(),n=e.sentTime,i=0;this._msgBufferList.forEach((function(e,t){var r=e.msg.sentTime;n>=r&&(i=t+1)})),this._msgBufferList.splice(i,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(i.prototype,"_onRecvOnlineCallMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t.content.callId;switch(this._logger.info("_","recv -> senderId: ".concat(t.senderUserId,", type: ").concat(t.messageType,", callId: ").concat(n)),t.messageType){case T.VCInvite:this._watchers.onInvite&&this._watchers.onInvite(t);break;case T.VCRinging:e.prototype.emit.call(this,"".concat(n,"onRinging"),t);break;case T.VCAccept:e.prototype.emit.call(this,"".concat(n,"onAccept"),t);break;case T.VCModifyMem:this._watchers.onInvite&&this._watchers.onInvite(t);break;case T.VCModifyMedia:e.prototype.emit.call(this,"".concat(n,"onMediaModify"),t);break;case T.VCHangup:e.prototype.emit.call(this,"".concat(n,"onHungup"),t);break;default:this._logger.warn("_","recv -> unexpected message: ".concat(t.messageType))}}}),Object.defineProperty(i.prototype,"_handleBufferMsgs",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;0===this._msgBufferList.length||this._hadHandleMsgTimer?this._logger.warn("_","_handleBufferMsgs return"):(this._hadHandleMsgTimer=!0,setTimeout((function(){var n=Date.now(),i=e._msgBufferList.filter((function(e){return n-e.markTime>=200}));if(e._logger.debug("_","[CallMessageHandler] handleBufferMsgs -> lists over 200ms : ".concat(JSON.stringify(i.map((function(e){var t=e.msg;return{messageUId:t.messageUId,isOffLineMessage:t.isOffLineMessage,callId:t.content.callId}}))))),0===i.length)return e._hadHandleMsgTimer=!1,void e._handleBufferMsgs();if(i[0].msg.isOffLineMessage){var r=e._msgBufferList.filter((function(e){return e.msg.isOffLineMessage})),o=function(){var n=r[0].msg,i=n.conversationType,o=n.messageType,a=n.sentTime,s=n.senderUserId,l=n.content,c=l.callId,u=l.inviteUserIds,d=[T.VCInvite,T.VCModifyMem].includes(o),_=e._context.getServerTime()-a,h=_<e._offlineMsgItv;if(h||e._logger.warn("_","offline msg delayTime: ".concat(_,"ms")),d){for(var f=[],g=0;g<r.length;g++){var C=r[g].msg;if(c!==C.content.callId)break;f.push(C)}if(e._logger.warn("_","taskMsgList length: ".concat(f.length)),f.length>0){var R=e._msgBufferList.findIndex((function(e){return e.msg.messageUId===f[f.length-1].messageUId}));e._msgBufferList=e._msgBufferList.slice(R+1);var I=r.findIndex((function(e){return e.msg.messageUId===f[f.length-1].messageUId}));r=r.slice(I+1)}var E=function(){if(i!==t.PRIVATE)return!1;var e=1===f.length,n=f.every((function(e){return[T.VCInvite,T.VCModifyMedia,T.VCRinging].includes(e.messageType)}));return e||n}(),y=function(){if(i!==t.GROUP)return!1;for(var n=!1,r=!0,o=b([s],p(u),!1),a=!1,l=function(t){var n=f[t],i=n.senderUserId,l=n.messageType;if(l===T.VCHangup&&i===e._context.getCurrentId())return"break";l===T.VCHangup&&(a=s===i,o=o.filter((function(e){return i!==e}))),l===T.VCAccept&&(r=!1)},c=0;c<f.length;c++){if("break"===l(c))break}return r&&a||!(o.length>1)||(n=!0),n}();h&&(E||y)&&f.forEach(e._onRecvOnlineCallMsg,e),e._offlineRecorder.onRecvOfflineMsgs(f)}else h&&e._getStateMachine(c)?e._onRecvOnlineCallMsg(r[0].msg):e._logger.debug("_","[CallMessageHandler] unexcepted offline msg -> ".concat(JSON.stringify(r[0].msg))),r.shift(),e._msgBufferList.shift()};do{o()}while(r.length>0)}else{i.forEach((function(t){var n=t.msg;e._onRecvOnlineCallMsg(n)}));var a=i.length;e._msgBufferList.splice(0,a),e._logger.debug("_","timer online msg handle -> delCount: ".concat(a," msgBufferList: ").concat(e._msgBufferList.length))}e._hadHandleMsgTimer=!1,e._handleBufferMsgs()}),20))}}),Object.defineProperty(i.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){Object.assign(this._watchers,e)}}),Object.defineProperty(i.prototype,"registerStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i){var r=t+n;e.prototype.on.call(this,r,i)}}),Object.defineProperty(i.prototype,"unregisterStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;["onRinging","onAccept","onHungup","onMediaModify"].forEach((function(i){var r=t+i;e.prototype.removeAll.call(n,r)}))}}),Object.defineProperty(i.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._userInfo=e}}),Object.defineProperty(i.prototype,"_sendCallMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t,i,r,o,a,s,l,c,u,d,_,h;return g(this,(function(f){switch(f.label){case 0:return this._logger.debug("_","CallMessageHandler] sendCallMesage -> message: ".concat(JSON.stringify(e))),t=e.channelId,i=e.conversationType,r=e.targetId,o=e.content,a=e.messageType,s=e.directionalUserIdList,l=e.pushConfig,c={channelId:t,messageType:a,content:o,directionalUserIdList:s},[T.VCInvite,T.VCModifyMem,T.VCHangup].includes(a)&&((u=l||{pushTitle:"",pushContent:"",pushData:""}).androidConfig=Object.assign((null==l?void 0:l.androidConfig)||{},{categoryHW:"VOIP",categoryVivo:"IM"}),u.iOSConfig=Object.assign(u.iOSConfig||{},{apnsCollapseId:o.callId}),u.disablePushTitle=!1,u.forceShowDetailContent=!1,c.pushConfig=u),[4,this._context.sendMessage(i,r,c)];case 1:return d=f.sent(),_=d.code,h=d.data,_!==n.SUCCESS?(this._logger.error("_","CallMessageHandler] sendCallMesage error -> code: ".concat(_)),[2,{code:B[_]||R.SEND_MSG_ERROR}]):[2,{code:R.SUCCESS,message:h}]}}))}))}}),Object.defineProperty(i.prototype,"sendInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var n,i,r,o,a,s,l,c,u,d;return g(this,(function(_){return n=e.roomType,i=e.channelId,r=e.conversationType,o=e.targetId,a=e.callId,s=e.mediaType,l=e.inviteUserIds,c=e.extra,u=e.pushConfig,this._logger.warn("_","CallMessageHandler] sendCallMesage sendInvite",JSON.stringify(e)),this._watchers.sendAccept&&this._watchers.sendAccept({callId:a}),d={platform:j.WEB,deviceId:this._deviceId,callId:a,roomType:n,extra:c,engineType:4,channelInfo:{Id:a,Key:""},mediaType:s,inviteUserIds:l,observerUserIds:[],user:this._userInfo},u&&(u.pushData=JSON.stringify({mediaType:s,userIdList:l,callId:a})),[2,this._sendCallMessage({channelId:i,conversationType:r,targetId:o,content:d,messageType:T.VCInvite,directionalUserIdList:r===t.GROUP?l:void 0,pushConfig:u})]}))}))}}),Object.defineProperty(i.prototype,"sendMemeberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t,n,i,r,o,a,s,l,c,u,d,_;return g(this,(function(h){return t=e.channelId,n=e.conversationType,i=e.targetId,r=e.callId,o=e.mediaType,a=e.inviteUserIds,s=e.callerId,l=e.existedUserPofiles,c=e.directionalUserIdList,u=e.extra,d=e.pushConfig,_={platform:j.WEB,deviceId:this._deviceId,callId:r,extra:u,engineType:4,channelInfo:{Id:r,Key:""},mediaType:o,inviteUserIds:a,observerUserIds:[],user:this._userInfo,caller:s,modifyMemType:k.ADD,existedUserPofiles:l},d&&(d.pushData=JSON.stringify({mediaType:o,userIdList:a,callId:r})),[2,this._sendCallMessage({channelId:t,conversationType:n,targetId:i,content:_,messageType:T.VCModifyMem,directionalUserIdList:c,pushConfig:d})]}))}))}}),Object.defineProperty(i.prototype,"sendRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,i=e.conversationType,r=e.targetId,o=e.callId,a=e.userIds,s={platform:j.WEB,deviceId:this._deviceId,callId:o,user:this._userInfo};return this._sendCallMessage({channelId:n,conversationType:i,targetId:r,content:s,messageType:T.VCRinging,directionalUserIdList:i===t.GROUP?a:void 0})}}),Object.defineProperty(i.prototype,"sendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,i=e.conversationType,r=e.targetId,o=e.callId,a=e.mediaType,s=e.userIds,l={platform:j.WEB,deviceId:this._deviceId,callId:o,mediaType:a,user:this._userInfo};return this._sendCallMessage({channelId:n,conversationType:i,targetId:r,content:l,messageType:T.VCAccept,directionalUserIdList:i===t.GROUP?s:void 0})}}),Object.defineProperty(i.prototype,"sendHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,i=e.conversationType,r=e.targetId,o=e.callId,a=e.reason,s=e.userIds,l=e.pushConfig,c={platform:j.WEB,deviceId:this._deviceId,callId:o,reason:a,user:this._userInfo};return l&&(l.pushData=JSON.stringify({callId:o,reason:a})),this._sendCallMessage({channelId:n,conversationType:i,targetId:r,content:c,messageType:T.VCHangup,pushConfig:l,directionalUserIdList:i===t.GROUP?s:void 0})}}),Object.defineProperty(i.prototype,"sendMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,i=e.conversationType,r=e.targetId,o=e.callId,a=e.mediaType,s=e.userIds,l={platform:j.WEB,deviceId:this._deviceId,callId:o,mediaType:a,user:this._userInfo};return this._sendCallMessage({channelId:n,conversationType:i,targetId:r,content:l,messageType:T.VCModifyMedia,directionalUserIdList:i===t.GROUP?s:void 0})}}),i}(e);!function(e){e.ZH="zh",e.EN="en"}(H||(H={}));var J={PushTitle:{AUDIO:"You have a voice call",VIDEO:"You have a video call"}},W={PushTitle:{AUDIO:"您有一条音频通话",VIDEO:"您有一条视频通话"}},Y=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===H.EN?J:W}}),Object.defineProperty(e,"_lang",{enumerable:!0,configurable:!0,writable:!0,value:H.ZH}),e}(),F=function(){function e(e,t,n,i,r){var o=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:n}),Object.defineProperty(this,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:r}),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.32.0"," CommitId: ").concat("43e468accff6143b6f05d14bdbf7582805c86783")),O(t),this._callMsgHandler=new K(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}),v.on("onStateMachineClose",(function(e){delete o._stateMachine[e]})),Y.set(r.lang)}return Object.defineProperty(e.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.channelId,n=e.conversationType,i=e.targetId,r=e.content,o=e.messageType,a=e.senderUserId;e.pushConfig;var s,l=r,c=l.mediaType,u=l.callId,d=l.extra;s=l.roomType!==P.RCCallRoomTypeAcrossCall?a:p(a.split("_"),2)[1];var _=this._context.getCurrentId();if(this._context.getCurrentId()!==s){if(o===T.VCModifyMem)if(r.existedUserPofiles.some((function(e){return e.userId===_}))&&!this._stateMachine[u])return;if(this._stateMachine[u])o===T.VCModifyMem&&this._stateMachine[u].__onMemberModify(e);else this._stateMachine[u]=new D(this._context,this._runtime,this._logger,this._callMsgHandler,t,n,i,c,u,{busyCallPolicy:this._options.busyCallPolicy}),this._logger.info("_","[RCCallEngine] RCCallStateMachine successfully created -> callId: ".concat(u)),o===T.VCInvite?this._stateMachine[u].__onInvite(e):o===T.VCModifyMem&&this._stateMachine[u].__onMemberModify(e),this._watchers.onInvite(this._stateMachine[u],d),Object.keys(this._stateMachine).filter((function(e){return u!==e})).length>0&&!this._options.isAllowAcceptNewCall&&this._stateMachine[u].__handleInviteInSession()}}}),Object.defineProperty(e.prototype,"_handleSendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this._options.isAllowAcceptNewCall){var t=e.callId;for(var n in this._stateMachine)t!==n&&(this._stateMachine[n].hungup(),delete this._stateMachine[n])}}}),Object.defineProperty(e.prototype,"_getStateMachine",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._stateMachine[e]}}),Object.defineProperty(e.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(e.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n,i,r,o,a){return void 0===r&&(r=""),void 0===a&&(a=!1),f(this,void 0,void 0,(function(){var s,l;return g(this,(function(c){switch(c.label){case 0:return this._logger.debug("_","[RCCallEngine] call -> args: ".concat(JSON.stringify({channelId:e,targetId:n,mediaType:i,extra:r,pushConfig:o}))),s=m(),Object.keys(this._stateMachine).length>0?[2,{code:R.STATE_MACHINE_EXIT}]:(this._stateMachine[s]=new D(this._context,this._runtime,this._logger,this._callMsgHandler,e,t.PRIVATE,n,i,s,{busyCallPolicy:this._options.busyCallPolicy}),[4,this._stateMachine[s].__call([n],r,o,a)]);case 1:return(l=c.sent().code)===R.SUCCESS?[2,{code:R.SUCCESS,stateMachine:this._stateMachine[s]}]:[2,{code:l}]}}))}))}}),Object.defineProperty(e.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n,i,r,o,a){return void 0===o&&(o=""),f(this,void 0,void 0,(function(){var s,l;return g(this,(function(c){switch(c.label){case 0:return this._logger.debug("_","[RCCallEngine] callInGroup -> args: ".concat(JSON.stringify({channelId:e,targetId:n,mediaType:i}))),s=m(),Object.keys(this._stateMachine).length>0?[2,{code:R.STATE_MACHINE_EXIT}]:(this._stateMachine[s]=new D(this._context,this._runtime,this._logger,this._callMsgHandler,e,t.GROUP,n,i,s,{busyCallPolicy:this._options.busyCallPolicy}),[4,this._stateMachine[s].__call(r,o,a)]);case 1:return(l=c.sent().code)===R.SUCCESS?[2,{code:R.SUCCESS,stateMachine:this._stateMachine[s]}]:[2,{code:l}]}}))}))}}),Object.defineProperty(e.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._logger.debug("_","[RCCallEngine] destroy"),this._stateMachine={}}}),e}(),z=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 n=this,i=function(r){n.off(e,i),t.call(n,r)};i.fun=t,this.on(e,i)}}),Object.defineProperty(e.prototype,"off",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this.list[e];if(!n)return!1;if(t){for(var i=void 0,r=0,o=n.length;r<o;r++)if((i=n[r])===t||i.fun===t){n.splice(r,1);break}}else n&&(n.length=0)}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this,i=b([],p(this.list[e]),!1);if(!i||0===i.length)return!1;i.forEach((function(e){e.call(n,t)}))}}),e}());var q=function(e){if(!e)return{ok:!1,msg:"Initialization missing parameter -> options"};if("object"!=typeof e)return{ok:!1,msg:"Initialization options must be an object"};var t,n=Object.keys(e),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 e.rtcClient?{ok:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:"function"!=typeof e.onSession?{ok:!1,msg:"Initialization 'onSession' parameter must be of type 'function'"}:"function"!=typeof e.onSessionClose?{ok:!1,msg:"Initialization 'onSessionClose' parameter must be of type 'function'"}:void 0!==e.isAllowSubscribeRetry&&"boolean"!=typeof e.isAllowSubscribeRetry?{ok:!1,msg:"Initialization 'isAllowSubscribeRetry' parameter must be of type 'boolean'"}:void 0!==e.isAllowPublishRetry&&"boolean"!=typeof e.isAllowPublishRetry?{ok:!1,msg:"Initialization 'isAllowPublishRetry' parameter must be of type 'boolean'"}:void 0!==e.isOffCameraWhenVideoDisable&&"boolean"!=typeof e.isOffCameraWhenVideoDisable?{ok:!1,msg:"Initialization 'isOffCameraWhenVideoDisable' parameter must be of type 'boolean'"}:void 0===e.joinType||(t=e.joinType,Object.values(l).includes(t))?void 0!==e.isAllowDemotionGetStream&&"boolean"!=typeof e.isAllowDemotionGetStream?{ok:!1,msg:"Initialization 'isAllowDemotionGetStream' parameter must be of type 'boolean'"}:void 0===e.lang||function(e){return Object.values(H).includes(e)}(e.lang)?void 0===e.logOutputLevel||function(e){return[a.DEBUG,a.INFO,a.WARN,a.ERROR].includes(e)}(e.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"}},X=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),n=[];return["onRinging","onAccept","onHungup","onTrackReady"].forEach((function(e){t.includes(e)||n.push(e)})),n.length?{ok:!1,msg:'missing parameter -> "'.concat(n.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}},Z=function(e){return e&&"string"==typeof e?{ok:!0}:{ok:!1,msg:"'targetId' parameter is required, must be of type 'string'"}},Q=function(e){return e===L.AUDIO||e===L.AUDIO_VIDEO?{ok:!0}:{ok:!1,msg:"'mediaType' parameter is required, must be of type 'RCCallMediaType'"}},$=function(e){return"string"==typeof e?{ok:!0}:{ok:!1,msg:"'extra' parameter must be of type 'string'"}},ee=function(e){var t=["pushTitle","pushContent","pushData","iOSConfig","androidConfig","disablePushTitle","templateId"],n=Object.keys(e).every((function(e){return t.includes(e)}));if(!n)return{code:R.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var a=0;a<t.length;a++){var s=t[a];if("disablePushTitle"===s){if(!i(e[s])&&!r(e[s]))return{code:R.PARAM_ERROR,errorMsg:"".concat(s," type is boolean")}}else if(("pushTitle"===s||"templateId"===s)&&e[s]&&!o(e[s]))return{code:R.PARAM_ERROR,errorMsg:"".concat(s," type is string")}}var l=e.iOSConfig,c=e.androidConfig,u=te(l||{});if(u.code!==R.SUCCESS)return u;var d=ne(c||{});return d.code!==R.SUCCESS?d:{code:R.SUCCESS}},te=function(e){var t=e||{},n=t.threadId,i=t.richMediaUri;return n&&!o(n)?{code:R.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:i&&!o(i)?{code:R.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:R.SUCCESS}},ne=function(e){var t=["notificationId","channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"],n=Object.keys(e).every((function(e){return t.includes(e)}));if(!n)return{code:R.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var i=0;i<t.length;i++){var r=t[i];if("importanceHW"===r||"importanceHonor"===r){if(e[r]&&"LOW"!==e[r]&&"NORMAL"!==e[r])return{code:R.PARAM_ERROR,errorMsg:"androidConfig.".concat(r," value is NORMAL|LOW")}}else if(e[r]&&!o(e[r]))return{code:R.PARAM_ERROR,errorMsg:"androidConfig.".concat(r," type is string")}}return{code:R.SUCCESS}},ie=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 re=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&&(t=e.video.frameRate,!["FPS_10","FPS_15","FPS_24","FPS_30"].includes(t))?{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&&(n=e.video.resolution,!c[n])?{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 t,n},oe=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}(),ae=function(){function e(e,t,n,i){void 0===i&&(i={});var r=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:n}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,n=e.reason;r._logger.info("_","[RCCallSession onUserStateChange] userId->".concat(null==t?void 0:t.userId," state->").concat(null==t?void 0:t.state," reason->").concat(n))},onStateChange:function(e){return f(r,void 0,void 0,(function(){var t,n,i,r,o;return g(this,(function(a){switch(a.label){case 0:if(t=e.state,n=e.reason,this._logger.info("_","[RCCallSession onStateChange] : state->".concat(t," reason->").concat(n)),t!==S.KEEPING)return[3,5];i=this._stateMachine.getCallId(),this._logger.info("_","[RCCallSession onStateChange] roomId: ".concat(i)),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this._joinRoom(i)];case 2:return a.sent(),[3,4];case 3:return r=a.sent(),this._exceptionClose(E.NETWORK_ERROR),this._logger.error("_","[RCCallSession onStateChange] joinRoom throw exception roomId -> ".concat(i)),console.error(r),[3,4];case 4:return[3,6];case 5:if(t===S.END){if(!this._room)return this._options.localTracks&&this._destroyTracks(this._options.localTracks),o=this._stateMachine.getSummary(),z.emit("sessionClose",{session:this,summaryInfo:o}),[2];this._options.localTracks&&this._destroyTracks(this._options.localTracks),this._logger.info("_","[RCCallSession onStateChange] localTracks destroyed"),this._leaveRoom(),this._room=null}a.label=6;case 6:return[2]}}))}))},onRinging:function(e){r._logger.info("_","[RCCallSession onRinging]sender: sender.userId -> ".concat(e.userId));try{r._listener.onRinging(e,r)}catch(e){r._logger.error("_","[RCCallSession onRinging] method exception -> onRinging"),console.error(e)}},onAccept:function(e){r._logger.info("_","[RCCallSession onAccept]sender: sender.userId -> ".concat(e.userId));try{r._listener.onAccept(e,r)}catch(e){r._logger.error("_","[RCCallSession onAccept] method exception -> onAccept"),console.error(e)}},onHungup:function(e,t){r._logger.info("_","[RCCallSession onHungup]sender: sender.userId -> ".concat(e.userId," reason->").concat(t));try{r._listener.onHungup(e,t,r)}catch(e){r._logger.error("_","[RCCallSession onHungup] method exception -> onHungup"),console.error(e)}},onMemberModify:function(e){var t=e.sender,n=e.invitedUsers;r._logger.info("_","[RCCallSession onMemberModify] sender.userId -> ".concat(t.userId));try{r._listener.onMemberModify(t,n,r)}catch(e){r._logger.error("_","[RCCallSession onMemberModify] method exception -> onMemberModify"),console.error(e)}},onMediaModify:function(e){var t=e.sender,n=e.mediaType;r._logger.info("_","[RCCallSession onMediaModify]sender: sender.userId -> ".concat(t.userId," mediaType: ").concat(n)),n===L.AUDIO&&r._setMediaTypeToAudio();try{r._listener.onMediaModify(t,n,r)}catch(e){r._logger.error("_","[RCCallSession onMediaModify] method exception -> onMediaModify"),console.error(e)}},crossAppkey:function(e){r._logger.info("_","[RCCallSession crossAppkey] 是否跨 appkey: ".concat(e)),r._options.isCrossAppkey=e}}),this._stateMachine.setHungupPushConfig(h({},this._options.hungupPushConfig))}return Object.defineProperty(e.prototype,"_joinRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var n,i,r,o,a,s,l,c=this;return g(this,(function(u){switch(u.label){case 0:return u.trys.push([0,7,,8]),this._options.isCrossAppkey?[4,this._rtcClient.joinCrossRTCRoom(e,this._options.joinType)]:[3,2];case 1:return n=u.sent(),[3,4];case 2:return[4,this._rtcClient.joinRTCRoom(e,this._options.joinType)];case 3:n=u.sent(),u.label=4;case 4:return i=n.code,r=n.userIds,o=n.room,i!==d.SUCCESS?(i===d.NOT_OPEN_VIDEO_AUDIO_SERVER&&this._exceptionClose(E.SERVICE_NOT_OPENED),i===d.SIGNAL_JOIN_RTC_ROOM_REFUSED?this._exceptionClose(E.OTHER_CLIENT_IN_CALL):this._exceptionClose(E.NETWORK_ERROR),this._logger.info("_","[RCCallClient _joinRoom] join room failed: roomId -> ".concat(e," RCRTCCode -> ").concat(i)),[2,{code:R.JOIN_ROOM_ERROR}]):(this._stateMachine.getConversationType()===t.GROUP&&this._stateMachine.userJoin([this._rtcClient.getCurrentId()]),this._stateMachine.getState()!==S.END?[3,6]:[4,this._rtcClient.leaveRoom(o)]);case 5:return u.sent(),this._room=null,[2,{code:R.SUCCESS}];case 6:return r.length<1&&(this.joinRoomTimer=new oe((function(){c._exceptionClose(E.REMOTE_NETWORK_ERROR)}),6e4)),this._room=o,[3,8];case 7:return a=u.sent(),this._exceptionClose(E.NETWORK_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ".concat(e)),console.error(a),[2,{code:R.JOIN_ROOM_ERROR}];case 8:this._registerRoomEventListener(),this._registerReportListener(),u.label=9;case 9:return u.trys.push([9,11,,12]),[4,this._subscribeInRoomRemoteTrack()];case 10:return u.sent(),[3,12];case 11:return s=u.sent(),this._exceptionClose(E.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ".concat(e)),console.error(s),[2,{code:R.JOIN_ROOM_ERROR}];case 12:return u.trys.push([12,14,,15]),[4,this._publish()];case 13:return u.sent(),[3,15];case 14:return l=u.sent(),this._exceptionClose(E.PUBLISH_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _publish Exception roomId -> ".concat(e)),console.error(l),[2,{code:R.JOIN_ROOM_ERROR}];case 15:return[2,{code:R.SUCCESS}]}}))}))}}),Object.defineProperty(e.prototype,"_subscribeInRoomRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t;return g(this,(function(n){switch(n.label){case 0:return(e=this._room.getRemoteTracks()).length?[4,this._subscribeRetry(e,this._options.isAllowSubscribeRetry,this._RETRYCOUNT)]:[3,2];case 1:(t=n.sent().code)!==d.SUCCESS&&(this._exceptionClose(E.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ".concat(this._stateMachine.getCallId()," RTC code -> ").concat(t))),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(e.prototype,"_subscribeRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=0),f(this,void 0,void 0,(function(){var i;return g(this,(function(r){switch(r.label){case 0:return[4,this._room.subscribe(e)];case 1:if((i=r.sent().code)!==d.SUCCESS){try{this._listener.onTrackSubscribeFail&&this._listener.onTrackSubscribeFail(i,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackSubscribeFail exception"),console.error(e)}if(!t)return[2,{code:i}];if(n>0)return n--,[2,this._subscribeRetry(e,t,n)]}return[2,{code:i}]}}))}))}}),Object.defineProperty(e.prototype,"_publish",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t;return g(this,(function(n){switch(n.label){case 0:return e=this._options.localTracks,[4,this._publishRetry(e,this._options.isAllowPublishRetry,this._RETRYCOUNT)];case 1:return(t=n.sent().code)!==d.SUCCESS?(this._exceptionClose(E.PUBLISH_ERROR),this._logger.info("_","[RCCallSession _publist] Resource publishing failed: roomId -> ".concat(this._stateMachine.getCallId()," RCRTCCode -> ").concat(t)),[2]):(this._options.produceType===w.CALLEE&&this._notifyTrackReady(e),[2])}}))}))}}),Object.defineProperty(e.prototype,"_publishRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=0),f(this,void 0,void 0,(function(){var i;return g(this,(function(r){switch(r.label){case 0:return[4,this._room.publish(e)];case 1:if((i=r.sent().code)!==d.SUCCESS){try{this._listener.onTrackPublishFail&&this._listener.onTrackPublishFail(i,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackPublishFail exception"),console.error(e)}if(!t)return[2,{code:i}];if(n>0)return n--,[2,this._publishRetry(e,t,n)]}return[2,{code:i}]}}))}))}}),Object.defineProperty(e.prototype,"_leaveRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t,n;return g(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),[4,this._rtcClient.leaveRoom(this._room)];case 1:return e=i.sent(),this._logger.info("_","[RCCallSession _leaveRoom] Successfully exited the room code: ".concat(e.code)),[3,4];case 2:return t=i.sent(),this._logger.error("_","[RCCallSession _leaveRoom] leaveRoom throw exception"),console.error(t),[3,4];case 3:return n=this._stateMachine.getSummary(),z.emit("sessionClose",{session:this,summaryInfo:n}),[7];case 4:return[2]}}))}))}}),Object.defineProperty(e.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(e.prototype,"registerSessionListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=X(e);if(!t.ok)throw new Error("[RCCallSession registerSessionListener] ".concat(t.msg));this._listener=h({},e)}}),Object.defineProperty(e.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return f(this,void 0,void 0,(function(){var n,i,r,o,a,s;return g(this,(function(l){switch(l.label){case 0:return n=this._getLocalAudioTracks(),i=this._getLocalVideoTracks(),n.length?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",t&&t.audio&&h({},t.audio))];case 1:if(r=l.sent(),a=r.code,s=r.track,a!==d.SUCCESS)return this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ".concat(a)),[2,{code:R.GET_LOCAL_AUDIO_TRACK_ERROR}];n.push(s),l.label=2;case 2:return e===L.AUDIO?(this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get Audio local tracks"),[2,{code:R.SUCCESS,tracks:n}]):i.length?[3,4]:[4,this._rtcClient.createCameraVideoTrack("RongCloudRTC",t&&t.video&&h({},t.video))];case 3:if(o=l.sent(),a=o.code,s=o.track,a!==d.SUCCESS)return this._logger.error("_","[RCCallSession _getLocalTrackCore] get Video local track failed RCT code -> ".concat(a)),[2,{code:R.GET_LOCAL_VIDEO_TRACK_ERROR}];i.push(s),l.label=4;case 4:return this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get video local track"),[2,{code:R.SUCCESS,tracks:b(b([],p(n),!1),p(i),!1)}]}}))}))}}),Object.defineProperty(e.prototype,"_getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return f(this,void 0,void 0,(function(){var n,i,r,o,a,s,l,c,u;return g(this,(function(d){switch(d.label){case 0:return this._options.isAllowDemotionGetStream&&e===L.AUDIO_VIDEO?[4,this._getLocalTrackCore(L.AUDIO_VIDEO,t)]:[3,4];case 1:return n=d.sent(),i=n.code,r=n.tracks,i===R.SUCCESS?[3,3]:[4,this._getLocalTrackCore(L.AUDIO,t)];case 2:return o=d.sent(),a=o.code,s=o.tracks,a!==R.SUCCESS?(this._exceptionClose(E.GET_MEDIA_RESOURCES_ERROR),[2,{code:a}]):[2,{code:a,tracks:s}];case 3:return[2,{code:i,tracks:r}];case 4:return[4,this._getLocalTrackCore(e,t)];case 5:return l=d.sent(),c=l.code,u=l.tracks,c!==R.SUCCESS?(this._exceptionClose(E.GET_MEDIA_RESOURCES_ERROR),[2,{code:c}]):[2,{code:c,tracks:u}]}}))}))}}),Object.defineProperty(e.prototype,"changeAudioDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t,n,i,r,o;return g(this,(function(a){switch(a.label){case 0:return t=[],n=[],[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",e)];case 1:return i=a.sent(),r=i.code,o=i.track,r!==d.SUCCESS?(this._logger.error("_","[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ".concat(r)),[2,{code:R.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isAudioTrack()?e.destroy():n.push(e)})),t.push(o),n.push(o),this._options.localTracks=n,this._notifyTrackReady(t),this._room?[4,this._room.publish(t)]:[3,3]);case 2:if(a.sent().code!==d.SUCCESS)return[2,{code:R.AUDIO_PUBLISH_ERROR}];a.label=3;case 3:return[2,{code:R.SUCCESS}]}}))}))}}),Object.defineProperty(e.prototype,"changeVideoDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t,n,i,r,o;return g(this,(function(a){switch(a.label){case 0:return this._room?[4,this._rtcClient.createCameraVideoTrack("RongCloudRTC",e)]:(this._logger.error("_","[RCCallSession changeVideoDevice] not in room"),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return t=a.sent(),n=t.code,i=t.track,n!==d.SUCCESS?(this._logger.error("_","[RCCallSession changeDevice] get local Video track failed RCTLib code -> ".concat(n)),[2,{code:R.GET_LOCAL_VIDEO_TRACK_ERROR}]):(r=this._getLocalVideoTracks()[0],[4,this._room.changeMediaDevice(r,i)]);case 2:return(o=a.sent().code)!==d.SUCCESS?(null==i||i.destroy(),this._logger.error("_","[RCCallSession changeDevice] change video device failed RCTLib code -> ".concat(o)),[2,{code:R.SWITCH_VIDEO_DEVICE_ERROR}]):(this._options.localTracks=this._options.localTracks.filter((function(e){return!e.isVideoTrack()})),this._options.localTracks.push(i),this._notifyTrackReady([i]),[2,{code:R.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n;return void 0===t&&(t={}),f(this,void 0,void 0,(function(){var i,r,o,a,s,l,c,u;return g(this,(function(d){switch(d.label){case 0:if(i=t.extra,r=void 0===i?"":i,o=(null===(n=this._options.callPushConfig)||void 0===n?void 0:n.pushTitle)?h({},this._options.callPushConfig):t.pushConfig,a=[ie(e),$(r)],o&&(s=ee(o),l=s.code,c=s.errorMsg,l!==R.SUCCESS))return this._logger.error("_","[RCCallSession invite] param error, errorMsg: ".concat(c)),[2,{code:l}];if(u=[],!a.every((function(e){return!e.ok&&u.push(e.msg),e.ok})))throw new Error("[RCCallClient invite] ".concat(u.join("\n")));return[4,this._stateMachine.invite(e,{extra:r,pushConfig:o})];case 1:return[2,{code:d.sent().code}]}}))}))}}),Object.defineProperty(e.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t,n,i,r,o,a;return g(this,(function(s){switch(s.label){case 0:if(!(t=re(e)).ok)throw new Error("[RCCallSession accept] ".concat(t.msg));return z.emit("hungupOtherSession",{session:this}),n=this._stateMachine.getMediaType(),[4,this._getLocalTrack(n,e)];case 1:return i=s.sent(),r=i.code,o=i.tracks,r!==R.SUCCESS?[2,{code:r}]:this._stateMachine.getState()===S.END?(this._destroyTracks(o),[2,{code:R.SESSION_ENDED}]):(this._options.localTracks=o,[4,this._stateMachine.accept()]);case 2:return a=s.sent().code,this._stateMachine.getState()===S.END?(this._destroyTracks(o),[2,{code:R.SESSION_ENDED}]):a!==R.SUCCESS?(this._logger.error("_","[RCCallSession accept]Send accept message failed -> code: ".concat(a)),[2,{code:a}]):[2,{code:a}]}}))}))}}),Object.defineProperty(e.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){return g(this,(function(e){return[2,this._stateMachine.hungup()]}))}))}}),Object.defineProperty(e.prototype,"_changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return f(this,void 0,void 0,(function(){var t;return g(this,(function(n){switch(n.label){case 0:return[4,this._stateMachine.changeMediaType(e)];case 1:return(t=n.sent().code)!==R.SUCCESS&&this._logger.error("_","[RCCallSession _changeMediaType] change media type fail code-> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(e.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(e.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(e.prototype,"_setMediaTypeToAudioAndVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t,n;return g(this,(function(i){switch(i.label){case 0:return[4,this._rtcClient.createCameraVideoTrack()];case 1:return e=i.sent(),t=e.code,n=e.track,t!==d.SUCCESS?[2,{code:R.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]:[4,this._room.publish([n])];case 2:return i.sent().code!==d.SUCCESS?(this._logger.error("_","[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ".concat(t)),[2]):(this._notifyTrackReady([n]),this._changeMediaType(L.AUDIO_VIDEO),[2])}}))}))}}),Object.defineProperty(e.prototype,"_setMediaTypeToAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t;return g(this,(function(n){switch(n.label){case 0:return(e=this._getLocalVideoTracks()).length?(e.forEach((function(e){e.mute()})),[4,this._room.unpublish(e)]):[3,2];case 1:(t=n.sent().code)!==d.SUCCESS&&this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(t)),this._destroyTracks(e),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(e.prototype,"descendAbility",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e;return g(this,(function(t){switch(t.label){case 0:return[4,this._changeMediaType(L.AUDIO)];case 1:return(e=t.sent().code)===R.SUCCESS&&this._setMediaTypeToAudio(),[2,{code:e}]}}))}))}}),Object.defineProperty(e.prototype,"disableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t;return g(this,(function(n){switch(n.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:R.SUCCESS}]):(this._logger.error("_","[RCCallSession disableVideoTrack] Room missing video track -> ".concat(R.MISSING_VIDEO_TRACK_ERROR)),[2,{code:R.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession disableVideoTrack] Not in room"),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent().code)!==d.SUCCESS?(this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(t)),[2,{code:R.UNPUBLISH_VIDEO_ERROR}]):(e.forEach((function(e){e.destroy()})),[2,{code:R.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"enableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t,n,i,r;return g(this,(function(o){switch(o.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:R.SUCCESS}]):(this._logger.error("_","[RCCallSession enableVideoTrack] Room missing video track -> ".concat(R.MISSING_VIDEO_TRACK_ERROR)),[2,{code:R.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession enableVideoTrack] Not in room -> ".concat(R.NOT_IN_ROOM_ERROR)),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return t=o.sent(),n=t.code,i=t.track,n!==d.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ".concat(n)),[2,{code:R.GET_LOCAL_VIDEO_TRACK_ERROR}]):(r=[],this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isVideoTrack()?e.destroy():r.push(e)})),r.push(i),this._options.localTracks=r,i.mute(),[4,this._room.publish([i])]);case 2:return o.sent().code!==d.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ".concat(n)),[2,{code:R.VIDEO_PUBLISH_ERROR}]):(i.unmute(),this._notifyTrackReady([i]),[2,{code:R.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"disableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t;return g(this,(function(n){switch(n.label){case 0:return this._room?(e=this._getLocalAudioTracks()[0])?[4,e.mute()]:(this._logger.warn("_","[RCCallSession disableAudioTrack] Room missing audio track -> ".concat(R.MISSING_AUDIO_TRACK_ERROR)),[2,{code:R.MISSING_AUDIO_TRACK_ERROR}]):(this._logger.warn("_","[RCCallSession disableAudioTrack] Not in room -> ".concat(R.NOT_IN_ROOM_ERROR)),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent())!==d.SUCCESS&&this._logger.warn("_","[RCCallSession disableAudioTrack] mute failed -> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(e.prototype,"enableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t;return g(this,(function(n){switch(n.label){case 0:return this._room?(e=this._getLocalAudioTracks()[0])?[4,e.unmute()]:(this._logger.error("_","[RCCallSession enableAudioTrack] Room missing audio track -> ".concat(R.MISSING_AUDIO_TRACK_ERROR)),[2,{code:R.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession enableAudioTrack] Not in room -> ".concat(R.NOT_IN_ROOM_ERROR)),[2,{code:R.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent())!==d.SUCCESS&&this._logger.error("_","[RCCallSession enableAudioTrack] unmute failed -> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(e.prototype,"_destroyTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e.forEach((function(e){e.destroy()}))}}),Object.defineProperty(e.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(e.prototype,"_registerRoomEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._room.registerRoomEventListener({onKickOff:function(t,n){var i=e._rtcClient.getCurrentId();e._stateMachine.userLeave([i]),t?(n===u.SERVER_KICK&&e._exceptionClose(E.KICKED_BY_SERVER),n===u.OTHER_KICK&&e._exceptionClose(E.OTHER_CLIENT_JOINED_CALL)):e._exceptionClose(E.NETWORK_ERROR)},onMessageReceive:function(e,t,n,i){},onRoomAttributeChange:function(e,t){},onAudioMuteChange:function(t){e._logger.info("_","[RCCallSession onAudioMuteChange] userId->".concat(t.getUserId()," muted -> ").concat(t.isOwnerMuted()));var n={userId:t.getUserId(),muted:t.isOwnerMuted(),kind:"audio",trackId:t.getTrackId()};try{e._listener.onAudioMuteChange(n,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 n={userId:t.getUserId(),muted:t.isOwnerMuted(),kind:"video",trackId:t.getTrackId()};try{e._listener.onVideoMuteChange(n,e)}catch(t){e._logger.error("_","[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange"),console.error(t)}},onTrackPublish:function(t){return f(e,void 0,void 0,(function(){var e;return g(this,(function(n){switch(n.label){case 0:return this._room?[4,this._room.subscribe(t)]:[3,2];case 1:(e=n.sent().code)!==d.SUCCESS&&this._logger.error("_","[RCCallSession onTrackPublish] subscribe failed RTCCode ->".concat(e)),n.label=2;case 2:return[2]}}))}))},onTrackUnpublish:function(e){},onTrackReady:function(t){e._stateMachine.getMediaType()===L.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 n,i;try{null===(i=null===(n=e._listener)||void 0===n?void 0:n.onPing)||void 0===i||i.call(n,t,e)}catch(e){console.error(e)}}})}}),Object.defineProperty(e.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 n,i;try{null===(i=null===(n=e._listener)||void 0===n?void 0:n.onICEConnectionStateChange)||void 0===i||i.call(n,t,e)}catch(t){e._logger.error("_","[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception"),console.error(t)}}})}}),Object.defineProperty(e.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getCallId()}}),Object.defineProperty(e.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._room?this._room.getSessionId():null}}),Object.defineProperty(e.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getTargetId()}}),Object.defineProperty(e.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getConversationType()}}),Object.defineProperty(e.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getChannelId()}}),Object.defineProperty(e.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getRemoteUsers()}}),Object.defineProperty(e.prototype,"getUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getRemoteUsers()}}),Object.defineProperty(e.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(e.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getState()}}),Object.defineProperty(e.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getCallerId()}}),Object.defineProperty(e.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getMediaType()}}),e}(),se=function(){function e(e,t,n,i){var r=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: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=h({isAllowPublishRetry:!1,isAllowSubscribeRetry:!1,isOffCameraWhenVideoDisable:!0,joinType:l.KICK,isAllowDemotionGetStream:!1,lang:H.ZH},i),this._callEngine=new F(this._context,t,this._logger,{onInvite:this._onInvite.bind(this),onOfflineRecord:this._onOfflineRecord.bind(this)},{lang:this._options.lang||H.ZH,busyCallPolicy:this._options.busyCallPolicy||A.HANGUP}),z.on("sessionClose",(function(e){var t=e.session,n=e.summaryInfo;r._removeSession(t);try{r._options.onSessionClose(t,n)}catch(e){r._logger.error("_","[RCCCallClient] options.onSessionClose exception"),console.log(e)}})),z.on("hungupOtherSession",(function(e){var t=e.session.getSessionId();r._logger.info("_","[RCCallClient hungupOtherSession] sessionId ready to accept -> ".concat(t)),r._logger.info("_","[RCCallClient hungupOtherSession] sessionList ->".concat(r._sessionList.map((function(e){return e.getSessionId()})).join(",")));for(var n=0;r._sessionList.length>1;)r._sessionList[n].getSessionId()!==t?(r._sessionList[n].hungup(),r._sessionList.splice(n,1)):n++;r._logger.info("_","[RCCallClient hungupOtherSession] current sessionList length ->".concat(r._sessionList.length))}))}return Object.defineProperty(e.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info("_","[RCCallClient _onInvite] Received invite message");var n=new ae(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:w.CALLEE,callPushConfig:h({},this._callPushConfig),hungupPushConfig:h({},this._hungupPushConfig)});this._logger.info("_","[RCCallClient _onInvite] Received invite message, successfully created session"),this._sessionList.push(n);try{this._options.onSession(n,t)}catch(e){this._logger.error("_","[RCCallClient _options.onSession] onSession exception"),console.log(e)}if(!n._listener)throw this._logger.error("_","[RCCallClient _options.onSession] session Must Have Listener"),new Error("[RCCallSession _options.onSession] session Must Have Listener");var i=X(n._listener);if(!i.ok)throw new Error(i.msg)}}),Object.defineProperty(e.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(e.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(e.prototype,"startCrossCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.mediaType,i=void 0===n?L.AUDIO:n,r=e.listener,o=e.constraints,a=e.channelId,s=void 0===a?"":a,l=e.extra,c=void 0===l?"":l,u=e.pushTitle,d=void 0===u?"":u,_=e.pushContent,h=void 0===_?"":_,p=e.bitrate;return f(this,void 0,void 0,(function(){return g(this,(function(e){return[2,this.__call({targetId:t,mediaType:i,listener:r,constraints:o,channelId:s,extra:c,pushTitle:d,pushContent:h,bitrate:p,isCrossAppkey:!0})]}))}))}}),Object.defineProperty(e.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.mediaType,i=void 0===n?L.AUDIO:n,r=e.listener,o=e.constraints,a=e.channelId,s=void 0===a?"":a,l=e.extra,c=void 0===l?"":l,u=e.pushTitle,d=void 0===u?"":u,_=e.pushContent,h=void 0===_?"":_,p=e.bitrate;return f(this,void 0,void 0,(function(){return g(this,(function(e){return[2,this.__call({targetId:t,mediaType:i,listener:r,constraints:o,channelId:s,extra:c,pushTitle:d,pushContent:h,bitrate:p})]}))}))}}),Object.defineProperty(e.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,n=e.targetId,i=e.mediaType,r=void 0===i?L.AUDIO:i,o=e.listener,a=e.constraints,s=e.channelId,l=void 0===s?"":s,c=e.extra,u=void 0===c?"":c,d=e.pushTitle,_=void 0===d?"":d,p=e.pushContent,b=void 0===p?"":p,C=e.bitrate,I=e.isCrossAppkey,E=void 0!==I&&I;return f(this,void 0,void 0,(function(){var e,i,s,c,d,f,p,I,y,m,v,O,T,S;return g(this,(function(g){switch(g.label){case 0:return e=h({},null!==(t=this._callPushConfig)&&void 0!==t?t:{pushTitle:_,pushContent:b}),this._logger.info("_","[RCCallClient call] targetId: ".concat(n,", mediaType: ").concat(r)),n===this._context.getCurrentId()?(this._logger.error("_","[RCCallClient call] targetId is equal to currentId"),[2,{code:R.PARAM_ERROR}]):(i=[Z(n),Q(r),X(o),$(u)],s=[],i.every((function(e){return!e.ok&&s.push(e.msg),e.ok}))?(c=ee(e),d=c.code,f=c.errorMsg,d!==R.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(f)),[2,{code:d}]):(p=[],[4,this._getLocalTrack(r,a)])):(console.error(s.join("\n")),[2,{code:R.PARAM_ERROR}]));case 1:return I=g.sent(),y=I.code,m=I.tracks,y!==R.SUCCESS?[2,{code:y}]:((p=m).forEach((function(e){var t,n,i;e.isAudioTrack()&&(null==C?void 0:C.audio)&&e.setBitrate(null==C?void 0:C.audio),e.isVideoTrack()&&(null==C?void 0:C.video)&&e.setBitrate(null===(t=null==C?void 0:C.video)||void 0===t?void 0:t.max,null===(n=null==C?void 0:C.video)||void 0===n?void 0:n.min,null===(i=null==C?void 0:C.video)||void 0===i?void 0:i.start),o.onTrackReady(e)})),[4,this._callEngine.call(l,n,r,u,e,E)]);case 2:return v=g.sent(),O=v.code,T=v.stateMachine,O===R.SUCCESS&&T?(this._logger.info("_","[RCCallClient call] successfully created state machine"),(S=new ae(T,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:w.CALLER,isCrossAppkey:E,callPushConfig:h({},this._callPushConfig),hungupPushConfig:h({},this._hungupPushConfig)})).registerSessionListener(o),this._sessionList.push(S),this._logger.info("_","[RCCallClient call] successfully created session object, sessionId: ".concat(S.getSessionId())),[2,{code:O,session:S}]):(this._logger.error("_","[RCCallClient call] call failed code ->: ".concat(O)),p.forEach((function(e){e.mute(),e.destroy()})),[2,{code:O}])}}))}))}}),Object.defineProperty(e.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,n=e.targetId,i=e.userIds,r=e.mediaType,o=void 0===r?L.AUDIO:r,a=e.listener,s=e.constraints,l=e.channelId,c=void 0===l?"":l,u=e.extra,d=void 0===u?"":u,_=e.pushTitle,p=void 0===_?"":_,b=e.pushContent,C=void 0===b?"":b,I=e.bitrate;return f(this,void 0,void 0,(function(){var e,r,l,u,_,f,b,E,y,m,v,O,T,S,M;return g(this,(function(g){switch(g.label){case 0:return e=h({},null!==(t=this._callPushConfig)&&void 0!==t?t:{pushTitle:p,pushContent:C}),r=[Z(n),ie(i),Q(o),X(a),$(d)],l=[],u=r.every((function(e){return!e.ok&&l.push(e.msg),e.ok})),i.includes(this._context.getCurrentId())?(console.error("[RCCallClient callInGroup] userIds includes currentId"),[2,{code:R.PARAM_ERROR}]):u?(_=ee(e),f=_.code,b=_.errorMsg,f!==R.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(b)),[2,{code:f}]):(E=[],[4,this._getLocalTrack(o,s)])):(console.error("[RCCallClient callInGroup] ".concat(l.join("\n"))),[2,{code:R.PARAM_ERROR}]);case 1:return y=g.sent(),m=y.code,v=y.tracks,m!==R.SUCCESS?[2,{code:m}]:((E=v).forEach((function(e){var t,n,i;e.isAudioTrack()&&(null==I?void 0:I.audio)&&e.setBitrate(null==I?void 0:I.audio),e.isVideoTrack()&&(null==I?void 0:I.video)&&e.setBitrate(null===(t=null==I?void 0:I.video)||void 0===t?void 0:t.max,null===(n=null==I?void 0:I.video)||void 0===n?void 0:n.min,null===(i=null==I?void 0:I.video)||void 0===i?void 0:i.start),a.onTrackReady(e)})),[4,this._callEngine.callInGroup(c,n,o,i,d,e)]);case 2:return O=g.sent(),T=O.code,S=O.stateMachine,T===R.SUCCESS&&S?(this._logger.info("_","[RCCallClient callInGroup] successfully created state machine"),(M=new ae(S,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:w.CALLER,callPushConfig:h({},this._callPushConfig),hungupPushConfig:h({},this._hungupPushConfig)})).registerSessionListener(a),this._sessionList.push(M),this._logger.info("_","[RCCallClient callInGroup] successfully created session object, sessionId: ".concat(M.getSessionId())),[2,{code:T,session:M}]):(this._logger.info("_","[RCCallClient callInGroup] callInGroup failed code -> ".concat(T)),E.forEach((function(e){e.mute(),e.destroy()})),[2,{code:T}])}}))}))}}),Object.defineProperty(e.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return f(this,void 0,void 0,(function(){var n,i,r,o,a,s;return g(this,(function(l){switch(l.label){case 0:return e!==L.AUDIO?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",t&&t.audio&&h({},t.audio))];case 1:return n=l.sent(),i=n.code,r=n.track,i!==d.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ".concat(i)),[2,{code:R.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._logger.info("_","[RCCallClient _getTrack] successfully get Audio local tracks"),[2,{code:R.SUCCESS,tracks:[r]}]);case 2:return[4,this._rtcClient.createMicrophoneAndCameraTracks("RongCloudRTC",t&&h({},t))];case 3:return o=l.sent(),a=o.code,s=o.tracks,a!==d.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ".concat(a)),[2,{code:R.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]):(this._logger.info("_","[RCCallClient _getTrack] successfully get audio and video local tracks"),[2,{code:R.SUCCESS,tracks:s}])}}))}))}}),Object.defineProperty(e.prototype,"_getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return f(this,void 0,void 0,(function(){var n,i,r,o,a,s,l,c,u;return g(this,(function(d){switch(d.label){case 0:return this._options.isAllowDemotionGetStream&&e===L.AUDIO_VIDEO?[4,this._getLocalTrackCore(L.AUDIO_VIDEO,t)]:[3,4];case 1:return n=d.sent(),i=n.code,r=n.tracks,i===R.SUCCESS?[3,3]:[4,this._getLocalTrackCore(L.AUDIO,t)];case 2:return o=d.sent(),a=o.code,s=o.tracks,a!==R.SUCCESS?[2,{code:a}]:[2,{code:a,tracks:s}];case 3:return[2,{code:i,tracks:r}];case 4:return[4,this._getLocalTrackCore(e,t)];case 5:return l=d.sent(),c=l.code,u=l.tracks,c!==R.SUCCESS?[2,{code:c}]:[2,{code:c,tracks:u}]}}))}))}}),Object.defineProperty(e.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(e.prototype,"getJoinedRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return f(this,void 0,void 0,(function(){var e,t,i;return g(this,(function(r){switch(r.label){case 0:return[4,this._context.getRTCJoinedUserInfo(this._context.getCurrentId())];case 1:return e=r.sent(),t=e.code,i=e.data,t!==n.SUCCESS?(this._logger.error("_","getJoinedUserInfo error code: ".concat(t)),[2,{code:R.QUERY_JOINED_USER_INFO_ERROR}]):[2,{code:R.SUCCESS,data:i}]}}))}))}}),Object.defineProperty(e.prototype,"setPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n,i,r=[e,t].map((function(e){return ee(e)}));try{for(var o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(r),a=o.next();!a.done;a=o.next()){var s=a.value,l=s.code,c=s.errorMsg;if(l!==R.SUCCESS)return this._logger.error("_","[RCCallClient setPushConfig] param error, errorMsg: ".concat(c)),{code:l}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}this._callPushConfig=e,this._hungupPushConfig=t}}),e}();s.add("calllib","5.32.0");var le={tag:"RCCall",verify:function(e){return"browser"===e.tag},setup:function(e,t,n){var i=q(n);if(!i.ok)throw new Error("[RCCallLib installer steup]".concat(i.msg));if(!s.validEngine("5.32.0"))throw new Error("The current engine version '".concat(s.getInfo().engine,"' error, plugin-call required engine version at least '").concat("5.32.0","'."));var r=e.createLogger("RCCall","RTC");return n.logOutputLevel&&r.setOutputLevel(n.logOutputLevel),void 0!==n.logLevel&&r.warn("_","The 'logLevel' parameter is deprecated, please use 'logOutputLevel' instead."),r.warn("_","RCCall Version: ".concat("5.32.0",", Commit: ").concat("43e468accff6143b6f05d14bdbf7582805c86783")),new se(e,t,r,n)}};export{A as RCCallBusyCallPolicy,se as RCCallClient,E as RCCallEndReason,R as RCCallErrorCode,H as RCCallLanguage,L as RCCallMediaType,ae as RCCallSession,S as RCCallSessionState,M as RCCallUserState,le as installer};
|
|
9
|
+
e[e.RCCallRoomTypeAcrossCall=7]="RCCallRoomTypeAcrossCall"}(N||(N={}));var U,L,k=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"}(U||(U={})),function(e){e[e.HANGUP=1]="HANGUP",e[e.IGNORE=2]="IGNORE"}(L||(L={}));var j,D,V,H=function(){function e(e,t,n,i,r,o,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:n}),Object.defineProperty(this,"_callMsgHandler",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_channelId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_conversationType",{enumerable:!0,configurable:!0,writable:!0,value:o}),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(e.prototype,"_getTimeout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._context.getServerTime()-e;t<0&&(t=500);var n=this._callTimeout-t;return this._logger.warn("_","_getTimeout -> timeout: ".concat(n)),n}}),Object.defineProperty(e.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(e.prototype,"_notifyStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n;this._logger.warn("_","[RCCallStateMachine] notifyStateChange -> info: ".concat(JSON.stringify({state:e,reason:t}))),this._endReason=t||null,this._sessionState!==e&&(this._sessionState=e,null===(n=this._watchers)||void 0===n||n.onStateChange({state:e,reason:t})),e===P.END&&(S.emit("onStateMachineClose",this._callId),this._callMsgHandler.unregisterStateMachineEvent(this._callId))}}),Object.defineProperty(e.prototype,"_notifyUserStateChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n;this._logger.warn("_","[RCCallStateMachine] notifyUserStateChange -> info: ".concat(JSON.stringify({user:e,reason:t}))),null===(n=this._watchers)||void 0===n||n.onUserStateChange({user:e,reason:t})}}),Object.defineProperty(e.prototype,"_otherClientHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,i=n.user,r=n.reason,o=e.messageType;for(var a in this._userInfo[t]={userId:t,state:A.NONE,isCaller:!1,isRemote:!1},this._userTimers)this._clearTimerById(a);var s=E.ACCEPT_BY_OTHER_CLIENT;o===M.VCHangup&&(s=r===E.BUSY_LINE?E.OTHER_CLIENT_IN_CALL:r===E.NO_RESPONSE?E.NO_RESPONSE:E.HANGUP_BY_OTHER_CLIENT),Object.assign(this._userInfo[t],i),this._notifyUserStateChange(this._userInfo[t],s),this._notifyStateChange(P.END,s)}}),Object.defineProperty(e.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===A.KEEPING&&this._userInfo[e].deviceId!==t))}}),Object.defineProperty(e.prototype,"_onRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,i=n.user,r=n.deviceId,o=this._isCrossAppkey?t.split("_")[1]:t;this._isRemoteInvalidMsg(o,r)?this._logger.debug("_","[RCCallStateMachine] onRinging -> not the remote device that is currently talking"):this._context.getCurrentId()!==o&&this._watchers.onRinging(g({userId:o},i))}}),Object.defineProperty(e.prototype,"_onAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=this,i=e.senderUserId,r=e.content,o=r.user,a=r.deviceId;e.sentTime;var s=this._isCrossAppkey?i.split("_")[1]:i,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===t.PRIVATE?[l,s]:[s]).forEach((function(e){var t=e===l;n._userInfo[e]={userId:e,state:A.KEEPING,isCaller:t,isRemote:t,deviceId:t?T(n._runtime):a},t||(n._beginTimestamp=Date.now(),Object.assign(n._userInfo[s],o)),n._notifyUserStateChange(n._userInfo[e])})),this.getCallerId()===l&&this._notifyStateChange(P.KEEPING),this._watchers.onAccept({userId:s})):this._otherClientHandle(e)}}),Object.defineProperty(e.prototype,"_onMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,i=n.mediaType,r=n.user,o=n.deviceId;this._isRemoteInvalidMsg(t,o)?this._logger.debug("_","[RCCallStateMachine] _onMediaModify -> not the remote device that is currently talking"):this._context.getCurrentId()!==t&&(this._mediaType=i,this._watchers.onMediaModify({sender:g({userId:t},r),mediaType:i}))}}),Object.defineProperty(e.prototype,"_onHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.senderUserId,n=e.content,i=this._isCrossAppkey?t.split("_")[1]:t,r=n,o=r.reason,a=r.user,s=r.deviceId;if(this._options.busyCallPolicy!==L.IGNORE||o!==E.BUSY_LINE){var l=this._context.getCurrentId();if(this._isRemoteInvalidMsg(i,s))this._logger.debug("_","[RCCallStateMachine] _onHungup -> not the remote device that is currently talking");else if(l!==i)if(this._sessionState!==P.END){this._userInfo[i]&&(this._userInfo[i].state=A.NONE,this._endTimestamp=Date.now(),Object.assign(this._userInfo[i],a),this._notifyUserStateChange(this._userInfo[i],w[o]),delete this._userInfo[i]),w[o]===E.REMOTE_CANCEL?this.getRemoteUserIds().length<1&&this._clearTimerById(l):this.getInviterId()===l?this._clearTimerById(i):this.getRemoteUserIds().length<1&&this._clearTimerById(l);var c=Object.keys(this._userInfo).length<2,u=this._inviterId===i,d=Object.values(this._userInfo).every((function(e){return e.state!==A.KEEPING}));(c||u&&d)&&this._notifyStateChange(P.END,w[o]),this._watchers.onHungup(g({userId:i},a),w[o])}else this._logger.info("_","[RCCallStateMachine] Invalid hang up message, current room status has ended -> sessionState: ".concat(this._sessionState));else this._otherClientHandle(e)}}}),Object.defineProperty(e.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._watchers=e}}),Object.defineProperty(e.prototype,"__onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,n,i=this,r=e.senderUserId,o=e.content,a=e.sentTime,s=o,l=s.inviteUserIds,c=s.user,u=s.deviceId;s.roomType===N.RCCallRoomTypeAcrossCall?(t=b(r.split("_"),2),n=t[1],this._watchers.crossAppkey(!0),this._isCrossAppkey=!0):n=r;var d=this._context.getCurrentId();if(this._isRemoteInvalidMsg(n,u))this._logger.debug("_","[RCCallStateMachine] __onInvite -> not the remote device that is currently talking");else if(d!==n){this._callerId=this._inviterId=n;var _=R([r],b(l),!1);this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:_.filter((function(e){return i._isCrossAppkey?e.split("_")[1]!==d:e!==d}))});var h=this._isCrossAppkey?[l[0].split("_")[1]]:l;R([n],b(h),!1).forEach((function(e){i._userInfo[e]={userId:e,state:A.WAITING,isCaller:e===n,isRemote:e!==d},e===n&&Object.assign(i._userInfo[e],c,{deviceId:u}),i._notifyUserStateChange(i._userInfo[e]),e!==n&&(i._userTimers[e]=new k((function(){var t=e===d?E.NO_RESPONSE:E.REMOTE_NO_RESPONSE;e===d?i._hungupHandle(t,!1):(i._userInfo[e]&&(i._userInfo[e].state=A.NONE),i._notifyUserStateChange(i._userInfo[e]),i._watchers.onHungup(i._userInfo[e],t),delete i._userInfo[e]),i._clearTimerById(e)}),i._getTimeout(a)))})),this._notifyStateChange(P.WAITING)}}}),Object.defineProperty(e.prototype,"__onMemberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,n=e.senderUserId,i=e.content,r=e.sentTime,o=i,a=o.user,s=o.existedUserPofiles,l=o.caller,c=o.deviceId,u=o.inviteUserIds,d=o.mediaType,_=this._context.getCurrentId();if(this._isRemoteInvalidMsg(n,c))this._logger.debug("_","[RCCallStateMachine] __onMemberModify -> not the remote device that is currently talking");else if(_!==n){if(this._callerId=l,this._inviterId=n,u.forEach((function(e){s.push({userId:e,mediaType:d,callStatus:m.INCOMING})})),u.includes(_)){var h=[];s.forEach((function(e){e.userId!==_&&h.push(e.userId)})),this._callMsgHandler.sendRinging({conversationType:this._conversationType,targetId:this._targetId,channelId:this._channelId,callId:this._callId,userIds:h}),this._notifyStateChange(P.WAITING)}else this._watchers.onMemberModify({sender:g({userId:n},a),invitedUsers:u.map((function(e){return{userId:e}}))});s.forEach((function(e){var i=e.userId,o=e.callStatus;if(o!==m.IDLE&&(t._userInfo[i]={userId:i,state:o!==m.CONNECTED?A.WAITING:A.KEEPING,isCaller:n===i,isRemote:_!==i},i===n&&Object.assign(t._userInfo[i],a,{deviceId:c}),t._notifyUserStateChange(t._userInfo[i]),o!==m.CONNECTED&&!t._userTimers[i])){if(!u.includes(i))return;t._userTimers[i]=new k((function(){t._userInfo[i]&&(t._userInfo[i].state=A.NONE);var e=i===_?E.NO_RESPONSE:E.REMOTE_NO_RESPONSE;t._notifyUserStateChange(t._userInfo[i],e);try{t._watchers.onHungup(t._userInfo[i],e)}catch(e){t._logger.error("_","[RCCallStateMachine] call onhungup error -> ".concat(null==e?void 0:e.stack))}delete t._userInfo[i],(Object.keys(t._userInfo).length<2||i===_)&&t._notifyStateChange(P.END,e),t._clearTimerById(i)}),t._getTimeout(r))}}))}}}),Object.defineProperty(e.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=A.NONE),this._notifyUserStateChange(this._userInfo[e]),this._clearTimerById(e);this._notifyStateChange(P.END,E.BUSY_LINE),this._callMsgHandler.sendHungup({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:E.BUSY_LINE,userIds:this.getRemoteUserIds()})}}),Object.defineProperty(e.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,i){return void 0===t&&(t=""),void 0===i&&(i=!1),p(this,void 0,void 0,(function(){var r,o,a,s,l,c,u=this;return C(this,(function(d){switch(d.label){case 0:return this._logger.debug("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(e))),r=this._callerId=this._inviterId=this._context.getCurrentId(),[4,this._callMsgHandler.sendInvite({roomType:i?N.RCCallRoomTypeAcrossCall:N.RCCallRoomTypeNormalCall,channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:t,pushConfig:n,mediaType:this._mediaType,inviteUserIds:e.filter((function(e){return e!==r}))})];case 1:return o=d.sent(),a=o.code,s=o.message,this._isCrossAppkey=i,a===v.SUCCESS?(l=s.sentTime,R([r],i?[e[0].split("_")[1]]:b(e),!1).forEach((function(e){var t=e===r;u._userInfo[e]={userId:e,state:A.WAITING,isCaller:t,isRemote:!t},u._notifyUserStateChange(u._userInfo[e]),t||(u._userTimers[e]=new k((function(){u._userInfo[e]&&(u._userInfo[e].state=A.NONE),u._notifyUserStateChange(u._userInfo[e],E.REMOTE_NO_RESPONSE),u._watchers.onHungup(u._userInfo[e],E.REMOTE_NO_RESPONSE),delete u._userInfo[e],Object.keys(u._userInfo).length<2&&u._notifyStateChange(P.END,E.REMOTE_NO_RESPONSE),0===u.getRemoteUserIds().length&&u._userInfo[r].state!==A.KEEPING&&u._hungupHandle(E.REMOTE_NO_RESPONSE)}),u._getTimeout(l)))})),this._notifyStateChange(P.WAITING)):(c=a===v.REJECTED_BY_BLACKLIST?E.ADDED_TO_BLACKLIST:E.NETWORK_ERROR,this._notifyStateChange(P.END,c)),[2,{code:a}]}}))}))}}),Object.defineProperty(e.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t,n,i,r;return C(this,(function(o){switch(o.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=o.sent(),n=t.code,i=t.message,this._clearTimerById(e),n===v.SUCCESS?(i.sentTime,this._userInfo[e]&&(this._userInfo[e].state=A.KEEPING),this._beginTimestamp=Date.now(),this._notifyUserStateChange(this._userInfo[e]),this._notifyStateChange(P.KEEPING)):(this._userInfo[e]&&(this._userInfo[e].state=A.NONE),this._notifyUserStateChange(this._userInfo[e]),r=n===v.REJECTED_BY_BLACKLIST?E.ADDED_TO_BLACKLIST:E.NETWORK_ERROR,this._notifyStateChange(P.END,r)),[2,{code:n}]}}))}))}}),Object.defineProperty(e.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n){return void 0===n&&(n={}),p(this,void 0,void 0,(function(){var i,r,o,a,s,l,c,u,d,_,h,f=this;return C(this,(function(g){switch(g.label){case 0:return this._conversationType!==t.GROUP?[2,{code:v.CONVERSATION_NOT_GROUP_ERROR}]:(this._logger.info("_","[RCCallStateMachine] invite -> userIds: ".concat(JSON.stringify(e))),i=this._context.getCurrentId(),r=Object.keys(this._userInfo),0===(o=e.filter((function(e){return e!==i&&!r.includes(e)}))).length?(this._logger.warn("_","[RCCallStateMachine] invite -> all userId is in calling now!"),[2,{code:v.PARAM_ERROR}]):(a=r.map((function(e){var t=m.CONNECTED;return f._userInfo[e].state===A.WAITING&&(t=m.RINGING),{userId:e,mediaType:f._mediaType,callStatus:t,mediaId:e}})),s=n.extra,l=void 0===s?"":s,c=n.pushConfig,[4,this._callMsgHandler.sendMemeberModify({channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,extra:l,pushConfig:c,mediaType:this._mediaType,inviteUserIds:o,callerId:this.getCallerId(),existedUserPofiles:a,directionalUserIdList:R(R([],b(r),!1),b(o),!1).filter((function(e){return e!==i}))})]));case 1:return u=g.sent(),d=u.code,_=u.message,d===v.SUCCESS?(h=_.sentTime,o.forEach((function(e){f._userInfo[e]={userId:e,state:A.WAITING,isCaller:!1,isRemote:!0},f._notifyUserStateChange(f._userInfo[e]),f._userTimers[e]=new k((function(){f._userInfo[e]&&(f._userInfo[e].state=A.NONE),f._notifyUserStateChange(f._userInfo[e],E.REMOTE_NO_RESPONSE),f._watchers.onHungup(f._userInfo[e],E.REMOTE_NO_RESPONSE),delete f._userInfo[e],Object.keys(f._userInfo).length<2&&f._notifyStateChange(P.END,E.REMOTE_NO_RESPONSE)}),f._getTimeout(h))}))):o.forEach((function(e){f._userInfo[e]={userId:e,state:A.NONE,isCaller:!1,isRemote:!0};var t=d===v.REJECTED_BY_BLACKLIST?E.ADDED_TO_BLACKLIST:E.NETWORK_ERROR;f._notifyUserStateChange(f._userInfo[e],t)})),[2,{code:d}]}}))}))}}),Object.defineProperty(e.prototype,"_hungupHandle",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return void 0===t&&(t=!0),p(this,void 0,void 0,(function(){var n,i,r,o,a;return C(this,(function(s){switch(s.label){case 0:return n=this._context.getCurrentId(),i=v.SUCCESS,t?(r={channelId:this._channelId,conversationType:this._conversationType,targetId:this._targetId,callId:this._callId,reason:e,userIds:this.getRemoteUserIds(),pushConfig:g({},this._hungupPushConfig)},e!==E.OTHER_CLIENT_JOINED_CALL?[3,1]:(this._callMsgHandler.sendHungup(r),[3,3])):[3,3];case 1:return[4,this._callMsgHandler.sendHungup(r)];case 2:o=s.sent().code,i=o,s.label=3;case 3:for(a in this._endTimestamp=Date.now(),this._userInfo)this._userInfo[a].state=A.NONE,a===n?this._notifyUserStateChange(this._userInfo[a],e):this._notifyUserStateChange(this._userInfo[a]),delete this._userInfo[a];return Object.keys(this._userInfo).length<2&&this._notifyStateChange(P.END,e),[2,{code:i}]}}))}))}}),Object.defineProperty(e.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t,n;return C(this,(function(i){for(n in this._logger.debug("_","[RCCallStateMachine] hungup"),e=this._context.getCurrentId(),t=E.HANGUP,Object.keys(this._userTimers).length>0&&(this._userInfo[e].isCaller?t=E.CANCEL:this._userInfo[e].state===A.WAITING&&(t=E.REJECT)),this._userTimers)this._clearTimerById(n);return[2,this._hungupHandle(t)]}))}))}}),Object.defineProperty(e.prototype,"changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return p(this,void 0,void 0,(function(){var t;return C(this,(function(n){switch(n.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=n.sent().code)===v.SUCCESS&&(this._mediaType=e),[2,{code:t}]}}))}))}}),Object.defineProperty(e.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 n=t._userInfo[e];n&&n.state!==A.KEEPING&&(n.state=A.KEEPING,t._notifyUserStateChange(n)),t._sessionState!==P.KEEPING&&t._notifyStateChange(P.KEEPING),t._clearTimerById(e)}))}),300)}}),Object.defineProperty(e.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 n=t._userInfo[e];n&&n.state!==A.NONE&&(n.state=A.NONE,t._notifyUserStateChange(n,E.REMOTE_HANGUP),t._watchers.onHungup(n,E.REMOTE_HANGUP),delete t._userInfo[e]),new k((function(){var e=t.getRemoteUsers();1===e.length&&1===e[0].state&&t._hungupHandle(E.REMOTE_NETWORK_ERROR)}),6e4),Object.keys(t._userInfo).length<2&&t._sessionState!==P.END&&(t._endTimestamp=Date.now(),t._notifyStateChange(P.END,E.REMOTE_HANGUP))}))}),300)}}),Object.defineProperty(e.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 n=t._userInfo[e];n&&n.state!==A.NONE&&(n.state=A.NONE,t._notifyUserStateChange(n,E.REMOTE_NETWORK_ERROR),t._watchers.onHungup(n,E.REMOTE_NETWORK_ERROR),delete t._userInfo[e]),Object.keys(t._userInfo).length<2&&t._sessionState!==P.END&&(t._endTimestamp=Date.now(),t._notifyStateChange(P.END,E.REMOTE_NETWORK_ERROR))}))}}),Object.defineProperty(e.prototype,"close",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hungupHandle(e)}}),Object.defineProperty(e.prototype,"setHungupPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hungupPushConfig=e}}),Object.defineProperty(e.prototype,"getCallId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callId}}),Object.defineProperty(e.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._channelId}}),Object.defineProperty(e.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._targetId}}),Object.defineProperty(e.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._conversationType}}),Object.defineProperty(e.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(e.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[],t=this._context.getCurrentId();for(var n in this._userInfo){this._userInfo[n].userId!==t&&e.push(this._userInfo[n])}return e}}),Object.defineProperty(e.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null===this._sessionState?P.END:this._sessionState}}),Object.defineProperty(e.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(e.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._callerId}}),Object.defineProperty(e.prototype,"getInviterId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._inviterId}}),Object.defineProperty(e.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._mediaType}}),Object.defineProperty(e.prototype,"getSummary",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this._beginTimestamp,t=this._endTimestamp,n=0;t>e&&0!==e&&(n=t-e);var i={conversationType:this._conversationType,channelId:this._channelId,targetId:this._targetId,mediaType:this._mediaType,beginTimestamp:e,endTimestamp:t,duration:n,endReason:this._endReason};return this._logger.debug("_","[RCCallStateMachine] getSummary -> summary: ".concat(JSON.stringify(i))),i}}),e}();!function(e){e[e.AUDIO=1]="AUDIO",e[e.AUDIO_VIDEO=2]="AUDIO_VIDEO"}(j||(j={})),function(e){e[e.ADD=1]="ADD",e[e.REMOVE=2]="REMOVE"}(D||(D={})),function(e){e.WEB="Web",e.IOS="iOS",e.ANDROID="Android"}(V||(V={}));var G,x,B=function(){function e(e,t,n){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:n}),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,n=e.conversationType,i=e.targetId,r=e.senderUserId,o=e.content,a=o.callId,s=o.mediaType;this._channelId=t,this._conversationType=n,this._targetId=i,this._callId=a,this._mediaType=s;this._inviterId=r,this._endReason=E.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=E.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,n=e.sentTime,i=e.senderUserId,r=t.reason,o=i===this._context.getCurrentId();this._endReason=o?r:w[r],this._endTimestamp=n,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;[E.HANGUP,E.REMOTE_HANGUP,E.OTHER_CLIENT_JOINED_CALL,E.REMOTE_OTHER_CLIENT_JOINED_CALL,E.KICKED_BY_SERVER,E.REMOTE_KICKED_BY_SERVER,E.ACCEPT_SYSTEM_CALL,E.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(),n=t.messageType;switch(t.content.callId,n){case M.VCInvite:this._doInvite(t);break;case M.VCRinging:this._doRinging(t);break;case M.VCAccept:this._doAccept(t);break;case M.VCModifyMem:this._doMemberModify(t);break;case M.VCModifyMedia:this._doMediaModify(t);break;case M.VCHangup:this._doHungup(t);break;default:this._logger.debug("_","[OfflineRecorder] onRecvOfflineMsgs -> unexpected message: ".concat(JSON.stringify(t)))}}while(this._messages.length>0)}}),e}(),K=["RC:VCAccept","RC:VCRinging","RC:VCSummary","RC:VCHangup","RC:VCInvite","RC:VCModifyMedia","RC:VCModifyMem"],J=((G={})[n.REJECTED_BY_BLACKLIST]=v.REJECTED_BY_BLACKLIST,G[n.NOT_IN_GROUP]=v.NOT_IN_GROUP,G),W=function(e){function i(t,n,i,r,o){void 0===r&&(r=6e4);var a=e.call(this)||this;return Object.defineProperty(a,"_context",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"_runtime",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_logger",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(a,"_offlineMsgItv",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_getStateMachine",{enumerable:!0,configurable:!0,writable:!0,value:o}),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=T(n),a._context.onmessage=a._onMessage.bind(a),a._offlineRecorder=new B(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 n(){this.constructor=e}f(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(i,e),Object.defineProperty(i.prototype,"_onMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(K.includes(e.messageType)){this._logger.debug("_","[CallMessageHandler] _onMessage -> call message: ".concat(JSON.stringify(e)));try{var t=Date.now(),n=e.sentTime,i=0;this._msgBufferList.forEach((function(e,t){var r=e.msg.sentTime;n>=r&&(i=t+1)})),this._msgBufferList.splice(i,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(i.prototype,"_onRecvOnlineCallMsg",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t.content.callId;switch(this._logger.info("_","recv -> senderId: ".concat(t.senderUserId,", type: ").concat(t.messageType,", callId: ").concat(n)),t.messageType){case M.VCInvite:this._watchers.onInvite&&this._watchers.onInvite(t);break;case M.VCRinging:e.prototype.emit.call(this,"".concat(n,"onRinging"),t);break;case M.VCAccept:e.prototype.emit.call(this,"".concat(n,"onAccept"),t);break;case M.VCModifyMem:this._watchers.onInvite&&this._watchers.onInvite(t);break;case M.VCModifyMedia:e.prototype.emit.call(this,"".concat(n,"onMediaModify"),t);break;case M.VCHangup:e.prototype.emit.call(this,"".concat(n,"onHungup"),t);break;default:this._logger.warn("_","recv -> unexpected message: ".concat(t.messageType))}}}),Object.defineProperty(i.prototype,"_handleBufferMsgs",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;0===this._msgBufferList.length||this._hadHandleMsgTimer?this._logger.warn("_","_handleBufferMsgs return"):(this._hadHandleMsgTimer=!0,setTimeout((function(){var n=Date.now(),i=e._msgBufferList.filter((function(e){return n-e.markTime>=200}));if(e._logger.debug("_","[CallMessageHandler] handleBufferMsgs -> lists over 200ms : ".concat(JSON.stringify(i.map((function(e){var t=e.msg;return{messageUId:t.messageUId,isOffLineMessage:t.isOffLineMessage,callId:t.content.callId}}))))),0===i.length)return e._hadHandleMsgTimer=!1,void e._handleBufferMsgs();if(i[0].msg.isOffLineMessage){var r=e._msgBufferList.filter((function(e){return e.msg.isOffLineMessage})),o=function(){var n=r[0].msg,i=n.conversationType,o=n.messageType,a=n.sentTime,s=n.senderUserId,l=n.content,c=l.callId,u=l.inviteUserIds,d=[M.VCInvite,M.VCModifyMem].includes(o),_=e._context.getServerTime()-a,h=_<e._offlineMsgItv;if(h||e._logger.warn("_","offline msg delayTime: ".concat(_,"ms")),d){for(var f=[],g=0;g<r.length;g++){var p=r[g].msg;if(c!==p.content.callId)break;f.push(p)}if(e._logger.warn("_","taskMsgList length: ".concat(f.length)),f.length>0){var C=e._msgBufferList.findIndex((function(e){return e.msg.messageUId===f[f.length-1].messageUId}));e._msgBufferList=e._msgBufferList.slice(C+1);var m=r.findIndex((function(e){return e.msg.messageUId===f[f.length-1].messageUId}));r=r.slice(m+1)}var v=function(){if(i!==t.PRIVATE)return!1;var e=1===f.length,n=f.every((function(e){return[M.VCInvite,M.VCModifyMedia,M.VCRinging].includes(e.messageType)}));return e||n}(),I=function(){if(i!==t.GROUP)return!1;for(var n=!1,r=!0,o=R([s],b(u),!1),a=!1,l=function(t){var n=f[t],i=n.senderUserId,l=n.messageType;if(l===M.VCHangup&&i===e._context.getCurrentId())return"break";l===M.VCHangup&&(a=s===i,o=o.filter((function(e){return i!==e}))),l===M.VCAccept&&(r=!1)},c=0;c<f.length;c++){if("break"===l(c))break}return r&&a||!(o.length>1)||(n=!0),n}();h&&(v||I)&&f.forEach(e._onRecvOnlineCallMsg,e),e._offlineRecorder.onRecvOfflineMsgs(f)}else h&&e._getStateMachine(c)?e._onRecvOnlineCallMsg(r[0].msg):e._logger.debug("_","[CallMessageHandler] unexcepted offline msg -> ".concat(JSON.stringify(r[0].msg))),r.shift(),e._msgBufferList.shift()};do{o()}while(r.length>0)}else{i.forEach((function(t){var n=t.msg;e._onRecvOnlineCallMsg(n)}));var a=i.length;e._msgBufferList.splice(0,a),e._logger.debug("_","timer online msg handle -> delCount: ".concat(a," msgBufferList: ").concat(e._msgBufferList.length))}e._hadHandleMsgTimer=!1,e._handleBufferMsgs()}),20))}}),Object.defineProperty(i.prototype,"registerEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){Object.assign(this._watchers,e)}}),Object.defineProperty(i.prototype,"registerStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i){var r=t+n;e.prototype.on.call(this,r,i)}}),Object.defineProperty(i.prototype,"unregisterStateMachineEvent",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;["onRinging","onAccept","onHungup","onMediaModify"].forEach((function(i){var r=t+i;e.prototype.removeAll.call(n,r)}))}}),Object.defineProperty(i.prototype,"registerUserInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._userInfo=e}}),Object.defineProperty(i.prototype,"_sendCallMessage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return p(this,void 0,void 0,(function(){var t,i,r,o,a,s,l,c,u,d,_,h;return C(this,(function(f){switch(f.label){case 0:return this._logger.debug("_","CallMessageHandler] sendCallMesage -> message: ".concat(JSON.stringify(e))),t=e.channelId,i=e.conversationType,r=e.targetId,o=e.content,a=e.messageType,s=e.directionalUserIdList,l=e.pushConfig,c={channelId:t,messageType:a,content:o,directionalUserIdList:s},[M.VCInvite,M.VCModifyMem,M.VCHangup].includes(a)&&((u=l||{pushTitle:"",pushContent:"",pushData:""}).androidConfig=Object.assign((null==l?void 0:l.androidConfig)||{},{categoryHW:"VOIP",categoryVivo:"IM"}),u.iOSConfig=Object.assign(u.iOSConfig||{},{apnsCollapseId:o.callId}),u.disablePushTitle=!1,u.forceShowDetailContent=!1,c.pushConfig=u),[4,this._context.sendMessage(i,r,c)];case 1:return d=f.sent(),_=d.code,h=d.data,_!==n.SUCCESS?(this._logger.error("_","CallMessageHandler] sendCallMesage error -> code: ".concat(_)),[2,{code:J[_]||v.SEND_MSG_ERROR}]):[2,{code:v.SUCCESS,message:h}]}}))}))}}),Object.defineProperty(i.prototype,"sendInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return p(this,void 0,void 0,(function(){var n,i,r,o,a,s,l,c,u,d;return C(this,(function(_){return n=e.roomType,i=e.channelId,r=e.conversationType,o=e.targetId,a=e.callId,s=e.mediaType,l=e.inviteUserIds,c=e.extra,u=e.pushConfig,this._logger.warn("_","CallMessageHandler] sendCallMesage sendInvite",JSON.stringify(e)),this._watchers.sendAccept&&this._watchers.sendAccept({callId:a}),d={platform:V.WEB,deviceId:this._deviceId,callId:a,roomType:n,extra:c,engineType:4,channelInfo:{Id:a,Key:""},mediaType:s,inviteUserIds:l,observerUserIds:[],user:this._userInfo},u&&(u.pushData=JSON.stringify({mediaType:s,userIdList:l,callId:a})),[2,this._sendCallMessage({channelId:i,conversationType:r,targetId:o,content:d,messageType:M.VCInvite,directionalUserIdList:r===t.GROUP?l:void 0,pushConfig:u})]}))}))}}),Object.defineProperty(i.prototype,"sendMemeberModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return p(this,void 0,void 0,(function(){var t,n,i,r,o,a,s,l,c,u,d,_;return C(this,(function(h){return t=e.channelId,n=e.conversationType,i=e.targetId,r=e.callId,o=e.mediaType,a=e.inviteUserIds,s=e.callerId,l=e.existedUserPofiles,c=e.directionalUserIdList,u=e.extra,d=e.pushConfig,_={platform:V.WEB,deviceId:this._deviceId,callId:r,extra:u,engineType:4,channelInfo:{Id:r,Key:""},mediaType:o,inviteUserIds:a,observerUserIds:[],user:this._userInfo,caller:s,modifyMemType:D.ADD,existedUserPofiles:l},d&&(d.pushData=JSON.stringify({mediaType:o,userIdList:a,callId:r})),[2,this._sendCallMessage({channelId:t,conversationType:n,targetId:i,content:_,messageType:M.VCModifyMem,directionalUserIdList:c,pushConfig:d})]}))}))}}),Object.defineProperty(i.prototype,"sendRinging",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,i=e.conversationType,r=e.targetId,o=e.callId,a=e.userIds,s={platform:V.WEB,deviceId:this._deviceId,callId:o,user:this._userInfo};return this._sendCallMessage({channelId:n,conversationType:i,targetId:r,content:s,messageType:M.VCRinging,directionalUserIdList:i===t.GROUP?a:void 0})}}),Object.defineProperty(i.prototype,"sendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,i=e.conversationType,r=e.targetId,o=e.callId,a=e.mediaType,s=e.userIds,l={platform:V.WEB,deviceId:this._deviceId,callId:o,mediaType:a,user:this._userInfo};return this._sendCallMessage({channelId:n,conversationType:i,targetId:r,content:l,messageType:M.VCAccept,directionalUserIdList:i===t.GROUP?s:void 0})}}),Object.defineProperty(i.prototype,"sendHungup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,i=e.conversationType,r=e.targetId,o=e.callId,a=e.reason,s=e.userIds,l=e.pushConfig,c={platform:V.WEB,deviceId:this._deviceId,callId:o,reason:a,user:this._userInfo};return l&&(l.pushData=JSON.stringify({callId:o,reason:a})),this._sendCallMessage({channelId:n,conversationType:i,targetId:r,content:c,messageType:M.VCHangup,pushConfig:l,directionalUserIdList:i===t.GROUP?s:void 0})}}),Object.defineProperty(i.prototype,"sendMediaModify",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=e.channelId,i=e.conversationType,r=e.targetId,o=e.callId,a=e.mediaType,s=e.userIds,l={platform:V.WEB,deviceId:this._deviceId,callId:o,mediaType:a,user:this._userInfo};return this._sendCallMessage({channelId:n,conversationType:i,targetId:r,content:l,messageType:M.VCModifyMedia,directionalUserIdList:i===t.GROUP?s:void 0})}}),i}(e);!function(e){e.ZH="zh",e.EN="en"}(x||(x={}));var Y={PushTitle:{AUDIO:"You have a voice call",VIDEO:"You have a video call"}},z={PushTitle:{AUDIO:"您有一条音频通话",VIDEO:"您有一条视频通话"}},F=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===x.EN?Y:z}}),Object.defineProperty(e,"_lang",{enumerable:!0,configurable:!0,writable:!0,value:x.ZH}),e}(),q=function(){function e(e,t,n,i,r){var o=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:n}),Object.defineProperty(this,"_watchers",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:r}),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")),T(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}),S.on("onStateMachineClose",(function(e){delete o._stateMachine[e]})),F.set(r.lang)}return Object.defineProperty(e.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.channelId,n=e.conversationType,i=e.targetId,r=e.content,o=e.messageType,a=e.senderUserId;e.pushConfig;var s,l=r,c=l.mediaType,u=l.callId,d=l.extra;s=l.roomType!==N.RCCallRoomTypeAcrossCall?a:b(a.split("_"),2)[1];var _=this._context.getCurrentId();if(this._context.getCurrentId()!==s){if(o===M.VCModifyMem)if(r.existedUserPofiles.some((function(e){return e.userId===_}))&&!this._stateMachine[u])return;if(this._stateMachine[u])o===M.VCModifyMem&&this._stateMachine[u].__onMemberModify(e);else this._stateMachine[u]=new H(this._context,this._runtime,this._logger,this._callMsgHandler,t,n,i,c,u,{busyCallPolicy:this._options.busyCallPolicy}),this._logger.info("_","[RCCallEngine] RCCallStateMachine successfully created -> callId: ".concat(u)),o===M.VCInvite?this._stateMachine[u].__onInvite(e):o===M.VCModifyMem&&this._stateMachine[u].__onMemberModify(e),this._watchers.onInvite(this._stateMachine[u],d),Object.keys(this._stateMachine).filter((function(e){return u!==e})).length>0&&!this._options.isAllowAcceptNewCall&&this._stateMachine[u].__handleInviteInSession()}}}),Object.defineProperty(e.prototype,"_handleSendAccept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this._options.isAllowAcceptNewCall){var t=e.callId;for(var n in this._stateMachine)t!==n&&(this._stateMachine[n].hungup(),delete this._stateMachine[n])}}}),Object.defineProperty(e.prototype,"_getStateMachine",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._stateMachine[e]}}),Object.defineProperty(e.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(e.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n,i,r,o,a){return void 0===r&&(r=""),void 0===a&&(a=!1),p(this,void 0,void 0,(function(){var s,l;return C(this,(function(c){switch(c.label){case 0:return this._logger.debug("_","[RCCallEngine] call -> args: ".concat(JSON.stringify({channelId:e,targetId:n,mediaType:i,extra:r,pushConfig:o}))),s=O(),Object.keys(this._stateMachine).length>0?[2,{code:v.STATE_MACHINE_EXIT}]:(this._stateMachine[s]=new H(this._context,this._runtime,this._logger,this._callMsgHandler,e,t.PRIVATE,n,i,s,{busyCallPolicy:this._options.busyCallPolicy}),[4,this._stateMachine[s].__call([n],r,o,a)]);case 1:return(l=c.sent().code)===v.SUCCESS?[2,{code:v.SUCCESS,stateMachine:this._stateMachine[s]}]:[2,{code:l}]}}))}))}}),Object.defineProperty(e.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e,n,i,r,o,a){return void 0===o&&(o=""),p(this,void 0,void 0,(function(){var s,l;return C(this,(function(c){switch(c.label){case 0:return this._logger.debug("_","[RCCallEngine] callInGroup -> args: ".concat(JSON.stringify({channelId:e,targetId:n,mediaType:i}))),s=O(),Object.keys(this._stateMachine).length>0?[2,{code:v.STATE_MACHINE_EXIT}]:(this._stateMachine[s]=new H(this._context,this._runtime,this._logger,this._callMsgHandler,e,t.GROUP,n,i,s,{busyCallPolicy:this._options.busyCallPolicy}),[4,this._stateMachine[s].__call(r,o,a)]);case 1:return(l=c.sent().code)===v.SUCCESS?[2,{code:v.SUCCESS,stateMachine:this._stateMachine[s]}]:[2,{code:l}]}}))}))}}),Object.defineProperty(e.prototype,"destroy",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._logger.debug("_","[RCCallEngine] destroy"),this._stateMachine={}}}),e}(),X=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 n=this,i=function(r){n.off(e,i),t.call(n,r)};i.fun=t,this.on(e,i)}}),Object.defineProperty(e.prototype,"off",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this.list[e];if(!n)return!1;if(t){for(var i=void 0,r=0,o=n.length;r<o;r++)if((i=n[r])===t||i.fun===t){n.splice(r,1);break}}else n&&(n.length=0)}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this,i=R([],b(this.list[e]),!1);if(!i||0===i.length)return!1;i.forEach((function(e){e.call(n,t)}))}}),e}());var Z=function(e){if(!e)return{ok:!1,msg:"Initialization missing parameter -> options"};if("object"!=typeof e)return{ok:!1,msg:"Initialization options must be an object"};var t,n=Object.keys(e),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 e.rtcClient?{ok:!1,msg:"Initialization 'rtcClient' parameter must be of type 'object'"}:"function"!=typeof e.onSession?{ok:!1,msg:"Initialization 'onSession' parameter must be of type 'function'"}:"function"!=typeof e.onSessionClose?{ok:!1,msg:"Initialization 'onSessionClose' parameter must be of type 'function'"}:void 0!==e.isAllowSubscribeRetry&&"boolean"!=typeof e.isAllowSubscribeRetry?{ok:!1,msg:"Initialization 'isAllowSubscribeRetry' parameter must be of type 'boolean'"}:void 0!==e.isAllowPublishRetry&&"boolean"!=typeof e.isAllowPublishRetry?{ok:!1,msg:"Initialization 'isAllowPublishRetry' parameter must be of type 'boolean'"}:void 0!==e.isOffCameraWhenVideoDisable&&"boolean"!=typeof e.isOffCameraWhenVideoDisable?{ok:!1,msg:"Initialization 'isOffCameraWhenVideoDisable' parameter must be of type 'boolean'"}:void 0===e.joinType||(t=e.joinType,Object.values(u).includes(t))?void 0!==e.isAllowDemotionGetStream&&"boolean"!=typeof e.isAllowDemotionGetStream?{ok:!1,msg:"Initialization 'isAllowDemotionGetStream' parameter must be of type 'boolean'"}:void 0===e.lang||function(e){return Object.values(x).includes(e)}(e.lang)?void 0===e.logOutputLevel||function(e){return[a.DEBUG,a.INFO,a.WARN,a.ERROR].includes(e)}(e.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"}},Q=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),n=[];return["onRinging","onAccept","onHungup","onTrackReady"].forEach((function(e){t.includes(e)||n.push(e)})),n.length?{ok:!1,msg:'missing parameter -> "'.concat(n.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}},$=function(e){return e&&"string"==typeof e?{ok:!0}:{ok:!1,msg:"'targetId' parameter is required, must be of type 'string'"}},ee=function(e){return e===j.AUDIO||e===j.AUDIO_VIDEO?{ok:!0}:{ok:!1,msg:"'mediaType' parameter is required, must be of type 'RCCallMediaType'"}},te=function(e){return"string"==typeof e?{ok:!0}:{ok:!1,msg:"'extra' parameter must be of type 'string'"}},ne=function(e){var t=["pushTitle","pushContent","pushData","iOSConfig","androidConfig","disablePushTitle","templateId"],n=Object.keys(e).every((function(e){return t.includes(e)}));if(!n)return{code:v.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var a=0;a<t.length;a++){var s=t[a];if("disablePushTitle"===s){if(!i(e[s])&&!r(e[s]))return{code:v.PARAM_ERROR,errorMsg:"".concat(s," type is boolean")}}else if(("pushTitle"===s||"templateId"===s)&&e[s]&&!o(e[s]))return{code:v.PARAM_ERROR,errorMsg:"".concat(s," type is string")}}var l=e.iOSConfig,c=e.androidConfig,u=ie(l||{});if(u.code!==v.SUCCESS)return u;var d=re(c||{});return d.code!==v.SUCCESS?d:{code:v.SUCCESS}},ie=function(e){var t=e||{},n=t.threadId,i=t.richMediaUri;return n&&!o(n)?{code:v.PARAM_ERROR,errorMsg:"iOSConfig.threadId type is string"}:i&&!o(i)?{code:v.PARAM_ERROR,errorMsg:"iOSConfig.richMediaUri type is string"}:{code:v.SUCCESS}},re=function(e){var t=["notificationId","channelIdMi","channelIdHW","categoryHW","importanceHW","imageUrlHW","channelIdOPPO","typeVivo","categoryVivo","fcmChannelId","fcmCollapseKey","fcmImageUrl","importanceHonor","imageUrlHonor"],n=Object.keys(e).every((function(e){return t.includes(e)}));if(!n)return{code:v.PARAM_ERROR,errorMsg:"right key: ".concat(t.join(","))};for(var i=0;i<t.length;i++){var r=t[i];if("importanceHW"===r||"importanceHonor"===r){if(e[r]&&"LOW"!==e[r]&&"NORMAL"!==e[r])return{code:v.PARAM_ERROR,errorMsg:"androidConfig.".concat(r," value is NORMAL|LOW")}}else if(e[r]&&!o(e[r]))return{code:v.PARAM_ERROR,errorMsg:"androidConfig.".concat(r," type is string")}}return{code:v.SUCCESS}},oe=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 ae=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&&(t=e.video.frameRate,!["FPS_10","FPS_15","FPS_24","FPS_30"].includes(t))?{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&&(n=e.video.resolution,!d[n])?{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 t,n},se=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}(),le=function(){function e(e,t,n,i){void 0===i&&(i={});var r=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:n}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:i}),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,n=e.reason;r._logger.info("_","[RCCallSession onUserStateChange] userId->".concat(null==t?void 0:t.userId," state->").concat(null==t?void 0:t.state," reason->").concat(n))},onStateChange:function(e){return p(r,void 0,void 0,(function(){var t,n,i,r,o;return C(this,(function(a){switch(a.label){case 0:if(t=e.state,n=e.reason,this._logger.info("_","[RCCallSession onStateChange] : state->".concat(t," reason->").concat(n)),t!==P.KEEPING)return[3,5];i=this._stateMachine.getCallId(),this._logger.info("_","[RCCallSession onStateChange] roomId: ".concat(i)),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this._joinRoom(i)];case 2:return a.sent(),[3,4];case 3:return r=a.sent(),this._exceptionClose(E.NETWORK_ERROR),this._logger.error("_","[RCCallSession onStateChange] joinRoom throw exception roomId -> ".concat(i)),console.error(r),[3,4];case 4:return[3,6];case 5:if(t===P.END){if(!this._room)return this._options.localTracks&&this._destroyTracks(this._options.localTracks),o=this._stateMachine.getSummary(),X.emit("sessionClose",{session:this,summaryInfo:o}),[2];this._options.localTracks&&this._destroyTracks(this._options.localTracks),this._logger.info("_","[RCCallSession onStateChange] localTracks destroyed"),this._leaveRoom(),this._room=null}a.label=6;case 6:return[2]}}))}))},onRinging:function(e){r._logger.info("_","[RCCallSession onRinging]sender: sender.userId -> ".concat(e.userId));try{r._listener.onRinging(e,r)}catch(e){r._logger.error("_","[RCCallSession onRinging] method exception -> onRinging"),console.error(e)}},onAccept:function(e){r._logger.info("_","[RCCallSession onAccept]sender: sender.userId -> ".concat(e.userId));try{r._listener.onAccept(e,r)}catch(e){r._logger.error("_","[RCCallSession onAccept] method exception -> onAccept"),console.error(e)}},onHungup:function(e,t){r._logger.info("_","[RCCallSession onHungup]sender: sender.userId -> ".concat(e.userId," reason->").concat(t));try{r._listener.onHungup(e,t,r)}catch(e){r._logger.error("_","[RCCallSession onHungup] method exception -> onHungup"),console.error(e)}},onMemberModify:function(e){var t=e.sender,n=e.invitedUsers;r._logger.info("_","[RCCallSession onMemberModify] sender.userId -> ".concat(t.userId));try{r._listener.onMemberModify(t,n,r)}catch(e){r._logger.error("_","[RCCallSession onMemberModify] method exception -> onMemberModify"),console.error(e)}},onMediaModify:function(e){var t=e.sender,n=e.mediaType;r._logger.info("_","[RCCallSession onMediaModify]sender: sender.userId -> ".concat(t.userId," mediaType: ").concat(n)),n===j.AUDIO&&r._setMediaTypeToAudio();try{r._listener.onMediaModify(t,n,r)}catch(e){r._logger.error("_","[RCCallSession onMediaModify] method exception -> onMediaModify"),console.error(e)}},crossAppkey:function(e){r._logger.info("_","[RCCallSession crossAppkey] 是否跨 appkey: ".concat(e)),r._options.isCrossAppkey=e}}),this._stateMachine.setHungupPushConfig(g({},this._options.hungupPushConfig))}return Object.defineProperty(e.prototype,"_joinRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n,i;return p(this,void 0,void 0,(function(){var r,o,a,s,l,c,u,d=this;return C(this,(function(_){switch(_.label){case 0:return _.trys.push([0,7,,8]),this._options.isCrossAppkey?[4,this._rtcClient.joinCrossRTCRoom(e,this._options.joinType)]:[3,2];case 1:return r=_.sent(),[3,4];case 2:return[4,this._rtcClient.joinRTCRoomWithOptions(e,{joinType:this._options.joinType,nickName:this._nickName,srcLanguage:this._srcLanguage})];case 3:r=_.sent(),_.label=4;case 4:return o=r.code,a=r.userIds,s=r.room,o!==h.SUCCESS?(o===h.NOT_OPEN_VIDEO_AUDIO_SERVER&&this._exceptionClose(E.SERVICE_NOT_OPENED),o===h.SIGNAL_JOIN_RTC_ROOM_REFUSED?this._exceptionClose(E.OTHER_CLIENT_IN_CALL):this._exceptionClose(E.NETWORK_ERROR),this._logger.info("_","[RCCallClient _joinRoom] join room failed: roomId -> ".concat(e," RCRTCCode -> ").concat(o)),[2,{code:v.JOIN_ROOM_ERROR}]):(this._stateMachine.getConversationType()===t.GROUP&&this._stateMachine.userJoin([this._rtcClient.getCurrentId()]),this._stateMachine.getState()!==P.END?[3,6]:[4,this._rtcClient.leaveRoom(s)]);case 5:return _.sent(),this._room=null,[2,{code:v.SUCCESS}];case 6:return a.length<1&&(this.joinRoomTimer=new se((function(){d._exceptionClose(E.REMOTE_NETWORK_ERROR)}),6e4)),this._room=s,null===(i=null===(n=this._listener)||void 0===n?void 0:n.onConnected)||void 0===i||i.call(n,this),[3,8];case 7:return l=_.sent(),this._exceptionClose(E.NETWORK_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _rtcClient.joinRTCRoom throw exception roomId -> ".concat(e)),console.error(l),[2,{code:v.JOIN_ROOM_ERROR}];case 8:this._registerRoomEventListener(),this._registerReportListener(),_.label=9;case 9:return _.trys.push([9,11,,12]),[4,this._subscribeInRoomRemoteTrack()];case 10:return _.sent(),[3,12];case 11:return c=_.sent(),this._exceptionClose(E.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _subscribeInRoomRemoteTrack Exception roomId -> ".concat(e)),console.error(c),[2,{code:v.JOIN_ROOM_ERROR}];case 12:return _.trys.push([12,14,,15]),[4,this._publish()];case 13:return _.sent(),[3,15];case 14:return u=_.sent(),this._exceptionClose(E.PUBLISH_ERROR),this._logger.error("_","[RCCallSession _joinRoom] _publish Exception roomId -> ".concat(e)),console.error(u),[2,{code:v.JOIN_ROOM_ERROR}];case 15:return[2,{code:v.SUCCESS}]}}))}))}}),Object.defineProperty(e.prototype,"_subscribeInRoomRemoteTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t;return C(this,(function(n){switch(n.label){case 0:return(e=this._room.getRemoteTracks()).length?[4,this._subscribeRetry(e,this._options.isAllowSubscribeRetry,this._RETRYCOUNT)]:[3,2];case 1:(t=n.sent().code)!==h.SUCCESS&&(this._exceptionClose(E.SUBSCRIBE_ERROR),this._logger.error("_","[RCCallSession _subscribeInRoomRemoteTrack] Resource subscription failed roomId -> ".concat(this._stateMachine.getCallId()," RTC code -> ").concat(t))),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(e.prototype,"_subscribeRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=0),p(this,void 0,void 0,(function(){var i;return C(this,(function(r){switch(r.label){case 0:return[4,this._room.subscribe(e)];case 1:if((i=r.sent().code)!==h.SUCCESS){try{this._listener.onTrackSubscribeFail&&this._listener.onTrackSubscribeFail(i,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackSubscribeFail exception"),console.error(e)}if(!t)return[2,{code:i}];if(n>0)return n--,[2,this._subscribeRetry(e,t,n)]}return[2,{code:i}]}}))}))}}),Object.defineProperty(e.prototype,"_publish",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t;return C(this,(function(n){switch(n.label){case 0:return e=this._options.localTracks,[4,this._publishRetry(e,this._options.isAllowPublishRetry,this._RETRYCOUNT)];case 1:return(t=n.sent().code)!==h.SUCCESS?(this._exceptionClose(E.PUBLISH_ERROR),this._logger.info("_","[RCCallSession _publist] Resource publishing failed: roomId -> ".concat(this._stateMachine.getCallId()," RCRTCCode -> ").concat(t)),[2]):(this._options.produceType===U.CALLEE&&this._notifyTrackReady(e),[2])}}))}))}}),Object.defineProperty(e.prototype,"_publishRetry",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=0),p(this,void 0,void 0,(function(){var i;return C(this,(function(r){switch(r.label){case 0:return[4,this._room.publish(e)];case 1:if((i=r.sent().code)!==h.SUCCESS){try{this._listener.onTrackPublishFail&&this._listener.onTrackPublishFail(i,this)}catch(e){this._logger.error("_","[RCCallSession] _listener.onTrackPublishFail exception"),console.error(e)}if(!t)return[2,{code:i}];if(n>0)return n--,[2,this._publishRetry(e,t,n)]}return[2,{code:i}]}}))}))}}),Object.defineProperty(e.prototype,"_leaveRoom",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t,n;return C(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),[4,this._rtcClient.leaveRoom(this._room)];case 1:return e=i.sent(),this._logger.info("_","[RCCallSession _leaveRoom] Successfully exited the room code: ".concat(e.code)),[3,4];case 2:return t=i.sent(),this._logger.error("_","[RCCallSession _leaveRoom] leaveRoom throw exception"),console.error(t),[3,4];case 3:return n=this._stateMachine.getSummary(),X.emit("sessionClose",{session:this,summaryInfo:n}),[7];case 4:return[2]}}))}))}}),Object.defineProperty(e.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(e.prototype,"registerSessionListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=Q(e);if(!t.ok)throw new Error("[RCCallSession registerSessionListener] ".concat(t.msg));this._listener=g({},e)}}),Object.defineProperty(e.prototype,"registerCallASRListener",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._callAsrListener=e}}),Object.defineProperty(e.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return p(this,void 0,void 0,(function(){var n,i,r,o,a,s;return C(this,(function(l){switch(l.label){case 0:return n=this._getLocalAudioTracks(),i=this._getLocalVideoTracks(),n.length?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",t&&t.audio&&g({},t.audio))];case 1:if(r=l.sent(),a=r.code,s=r.track,a!==h.SUCCESS)return this._logger.error("_","[RCCallSession _getLocalTrackCore] get Audio local tracks failed RCT code -> ".concat(a)),[2,{code:v.GET_LOCAL_AUDIO_TRACK_ERROR}];n.push(s),l.label=2;case 2:return e===j.AUDIO?(this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get Audio local tracks"),[2,{code:v.SUCCESS,tracks:n}]):i.length?[3,4]:[4,this._rtcClient.createCameraVideoTrack("RongCloudRTC",t&&t.video&&g({},t.video))];case 3:if(o=l.sent(),a=o.code,s=o.track,a!==h.SUCCESS)return this._logger.error("_","[RCCallSession _getLocalTrackCore] get Video local track failed RCT code -> ".concat(a)),[2,{code:v.GET_LOCAL_VIDEO_TRACK_ERROR}];i.push(s),l.label=4;case 4:return this._logger.info("_","[RCCallSession _getLocalTrackCore] successfully get video local track"),[2,{code:v.SUCCESS,tracks:R(R([],b(n),!1),b(i),!1)}]}}))}))}}),Object.defineProperty(e.prototype,"_getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return p(this,void 0,void 0,(function(){var n,i,r,o,a,s,l,c,u;return C(this,(function(d){switch(d.label){case 0:return this._options.isAllowDemotionGetStream&&e===j.AUDIO_VIDEO?[4,this._getLocalTrackCore(j.AUDIO_VIDEO,t)]:[3,4];case 1:return n=d.sent(),i=n.code,r=n.tracks,i===v.SUCCESS?[3,3]:[4,this._getLocalTrackCore(j.AUDIO,t)];case 2:return o=d.sent(),a=o.code,s=o.tracks,a!==v.SUCCESS?(this._exceptionClose(E.GET_MEDIA_RESOURCES_ERROR),[2,{code:a}]):[2,{code:a,tracks:s}];case 3:return[2,{code:i,tracks:r}];case 4:return[4,this._getLocalTrackCore(e,t)];case 5:return l=d.sent(),c=l.code,u=l.tracks,c!==v.SUCCESS?(this._exceptionClose(E.GET_MEDIA_RESOURCES_ERROR),[2,{code:c}]):[2,{code:c,tracks:u}]}}))}))}}),Object.defineProperty(e.prototype,"changeAudioDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return p(this,void 0,void 0,(function(){var t,n,i,r,o;return C(this,(function(a){switch(a.label){case 0:return t=[],n=[],[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",e)];case 1:return i=a.sent(),r=i.code,o=i.track,r!==h.SUCCESS?(this._logger.error("_","[RCCallSession changeDevice] get local Audio tracks failed RCTLib code -> ".concat(r)),[2,{code:v.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isAudioTrack()?e.destroy():n.push(e)})),t.push(o),n.push(o),this._options.localTracks=n,this._notifyTrackReady(t),this._room?[4,this._room.publish(t)]:[3,3]);case 2:if(a.sent().code!==h.SUCCESS)return[2,{code:v.AUDIO_PUBLISH_ERROR}];a.label=3;case 3:return[2,{code:v.SUCCESS}]}}))}))}}),Object.defineProperty(e.prototype,"changeVideoDevice",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return p(this,void 0,void 0,(function(){var t,n,i,r,o;return C(this,(function(a){switch(a.label){case 0:return this._room?[4,this._rtcClient.createCameraVideoTrack("RongCloudRTC",e)]:(this._logger.error("_","[RCCallSession changeVideoDevice] not in room"),[2,{code:v.NOT_IN_ROOM_ERROR}]);case 1:return t=a.sent(),n=t.code,i=t.track,n!==h.SUCCESS?(this._logger.error("_","[RCCallSession changeDevice] get local Video track failed RCTLib code -> ".concat(n)),[2,{code:v.GET_LOCAL_VIDEO_TRACK_ERROR}]):(r=this._getLocalVideoTracks()[0],[4,this._room.changeMediaDevice(r,i)]);case 2:return(o=a.sent().code)!==h.SUCCESS?(null==i||i.destroy(),this._logger.error("_","[RCCallSession changeDevice] change video device failed RCTLib code -> ".concat(o)),[2,{code:v.SWITCH_VIDEO_DEVICE_ERROR}]):(this._options.localTracks=this._options.localTracks.filter((function(e){return!e.isVideoTrack()})),this._options.localTracks.push(i),this._notifyTrackReady([i]),[2,{code:v.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"invite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n;return void 0===t&&(t={}),p(this,void 0,void 0,(function(){var i,r,o,a,s,l,c,u;return C(this,(function(d){switch(d.label){case 0:if(i=t.extra,r=void 0===i?"":i,o=(null===(n=this._options.callPushConfig)||void 0===n?void 0:n.pushTitle)?g({},this._options.callPushConfig):t.pushConfig,a=[oe(e),te(r)],o&&(s=ne(o),l=s.code,c=s.errorMsg,l!==v.SUCCESS))return this._logger.error("_","[RCCallSession invite] param error, errorMsg: ".concat(c)),[2,{code:l}];if(u=[],!a.every((function(e){return!e.ok&&u.push(e.msg),e.ok})))throw new Error("[RCCallClient invite] ".concat(u.join("\n")));return[4,this._stateMachine.invite(e,{extra:r,pushConfig:o})];case 1:return[2,{code:d.sent().code}]}}))}))}}),Object.defineProperty(e.prototype,"accept",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return p(this,void 0,void 0,(function(){var t,n,i,r,o,a;return C(this,(function(s){switch(s.label){case 0:if(!(t=ae(e)).ok)throw new Error("[RCCallSession accept] ".concat(t.msg));return X.emit("hungupOtherSession",{session:this}),n=this._stateMachine.getMediaType(),[4,this._getLocalTrack(n,e)];case 1:return i=s.sent(),r=i.code,o=i.tracks,r!==v.SUCCESS?[2,{code:r}]:this._stateMachine.getState()===P.END?(this._destroyTracks(o),[2,{code:v.SESSION_ENDED}]):(this._options.localTracks=o,[4,this._stateMachine.accept()]);case 2:return a=s.sent().code,this._stateMachine.getState()===P.END?(this._destroyTracks(o),[2,{code:v.SESSION_ENDED}]):a!==v.SUCCESS?(this._logger.error("_","[RCCallSession accept]Send accept message failed -> code: ".concat(a)),[2,{code:a}]):[2,{code:a}]}}))}))}}),Object.defineProperty(e.prototype,"hungup",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){return C(this,(function(e){return[2,this._stateMachine.hungup()]}))}))}}),Object.defineProperty(e.prototype,"_changeMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return p(this,void 0,void 0,(function(){var t;return C(this,(function(n){switch(n.label){case 0:return[4,this._stateMachine.changeMediaType(e)];case 1:return(t=n.sent().code)!==v.SUCCESS&&this._logger.error("_","[RCCallSession _changeMediaType] change media type fail code-> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(e.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(e.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(e.prototype,"_setMediaTypeToAudioAndVideo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t,n;return C(this,(function(i){switch(i.label){case 0:return[4,this._rtcClient.createCameraVideoTrack()];case 1:return e=i.sent(),t=e.code,n=e.track,t!==h.SUCCESS?[2,{code:v.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]:[4,this._room.publish([n])];case 2:return i.sent().code!==h.SUCCESS?(this._logger.error("_","[RCCallSession _enableVideo] Resource publishing failed: RCRTCCode -> ".concat(t)),[2]):(this._notifyTrackReady([n]),this._changeMediaType(j.AUDIO_VIDEO),[2])}}))}))}}),Object.defineProperty(e.prototype,"_setMediaTypeToAudio",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t;return C(this,(function(n){switch(n.label){case 0:return(e=this._getLocalVideoTracks()).length?(e.forEach((function(e){e.mute()})),[4,this._room.unpublish(e)]):[3,2];case 1:(t=n.sent().code)!==h.SUCCESS&&this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(t)),this._destroyTracks(e),n.label=2;case 2:return[2]}}))}))}}),Object.defineProperty(e.prototype,"descendAbility",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e;return C(this,(function(t){switch(t.label){case 0:return[4,this._changeMediaType(j.AUDIO)];case 1:return(e=t.sent().code)===v.SUCCESS&&this._setMediaTypeToAudio(),[2,{code:e}]}}))}))}}),Object.defineProperty(e.prototype,"disableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t;return C(this,(function(n){switch(n.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:v.SUCCESS}]):(this._logger.error("_","[RCCallSession disableVideoTrack] Room missing video track -> ".concat(v.MISSING_VIDEO_TRACK_ERROR)),[2,{code:v.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession disableVideoTrack] Not in room"),[2,{code:v.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent().code)!==h.SUCCESS?(this._logger.error("_","[RCCallSession disableVideo] unpublish failed -> ".concat(t)),[2,{code:v.UNPUBLISH_VIDEO_ERROR}]):(e.forEach((function(e){e.destroy()})),[2,{code:v.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"enableVideoTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t,n,i,r;return C(this,(function(o){switch(o.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:v.SUCCESS}]):(this._logger.error("_","[RCCallSession enableVideoTrack] Room missing video track -> ".concat(v.MISSING_VIDEO_TRACK_ERROR)),[2,{code:v.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession enableVideoTrack] Not in room -> ".concat(v.NOT_IN_ROOM_ERROR)),[2,{code:v.NOT_IN_ROOM_ERROR}]);case 1:return t=o.sent(),n=t.code,i=t.track,n!==h.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Get Resource failed: RCRTCCode -> ".concat(n)),[2,{code:v.GET_LOCAL_VIDEO_TRACK_ERROR}]):(r=[],this._options.localTracks&&this._options.localTracks.forEach((function(e){e.isVideoTrack()?e.destroy():r.push(e)})),r.push(i),this._options.localTracks=r,i.mute(),[4,this._room.publish([i])]);case 2:return o.sent().code!==h.SUCCESS?(this._logger.error("_","[RCCallSession EnableVideoTrack] Resource publishing failed: RCRTCCode -> ".concat(n)),[2,{code:v.VIDEO_PUBLISH_ERROR}]):(i.unmute(),this._notifyTrackReady([i]),[2,{code:v.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"disableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t;return C(this,(function(n){switch(n.label){case 0:return this._room?(e=this._getLocalAudioTracks()[0])?[4,e.mute()]:(this._logger.warn("_","[RCCallSession disableAudioTrack] Room missing audio track -> ".concat(v.MISSING_AUDIO_TRACK_ERROR)),[2,{code:v.MISSING_AUDIO_TRACK_ERROR}]):(this._logger.warn("_","[RCCallSession disableAudioTrack] Not in room -> ".concat(v.NOT_IN_ROOM_ERROR)),[2,{code:v.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent())!==h.SUCCESS&&this._logger.warn("_","[RCCallSession disableAudioTrack] mute failed -> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(e.prototype,"enableAudioTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t;return C(this,(function(n){switch(n.label){case 0:return this._room?(e=this._getLocalAudioTracks()[0])?[4,e.unmute()]:(this._logger.error("_","[RCCallSession enableAudioTrack] Room missing audio track -> ".concat(v.MISSING_AUDIO_TRACK_ERROR)),[2,{code:v.MISSING_VIDEO_TRACK_ERROR}]):(this._logger.error("_","[RCCallSession enableAudioTrack] Not in room -> ".concat(v.NOT_IN_ROOM_ERROR)),[2,{code:v.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent())!==h.SUCCESS&&this._logger.error("_","[RCCallSession enableAudioTrack] unmute failed -> ".concat(t)),[2,{code:t}]}}))}))}}),Object.defineProperty(e.prototype,"_destroyTracks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e.forEach((function(e){e.destroy()}))}}),Object.defineProperty(e.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(e.prototype,"_registerRoomEventListener",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._room.registerRoomEventListener({onKickOff:function(t,n){var i=e._rtcClient.getCurrentId();e._stateMachine.userLeave([i]),t?(n===_.SERVER_KICK&&e._exceptionClose(E.KICKED_BY_SERVER),n===_.OTHER_KICK&&e._exceptionClose(E.OTHER_CLIENT_JOINED_CALL)):e._exceptionClose(E.NETWORK_ERROR)},onMessageReceive:function(e,t,n,i){},onRoomAttributeChange:function(e,t){},onAudioMuteChange:function(t){e._logger.info("_","[RCCallSession onAudioMuteChange] userId->".concat(t.getUserId()," muted -> ").concat(t.isOwnerMuted()));var n={userId:t.getUserId(),muted:t.isOwnerMuted(),kind:"audio",trackId:t.getTrackId()};try{e._listener.onAudioMuteChange(n,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 n={userId:t.getUserId(),muted:t.isOwnerMuted(),kind:"video",trackId:t.getTrackId()};try{e._listener.onVideoMuteChange(n,e)}catch(t){e._logger.error("_","[RCCallSession onVideoMuteChange] Missing listening method -> onVideoMuteChange"),console.error(t)}},onTrackPublish:function(t){return p(e,void 0,void 0,(function(){var e;return C(this,(function(n){switch(n.label){case 0:return this._room?[4,this._room.subscribe(t)]:[3,2];case 1:(e=n.sent().code)!==h.SUCCESS&&this._logger.error("_","[RCCallSession onTrackPublish] subscribe failed RTCCode ->".concat(e)),n.label=2;case 2:return[2]}}))}))},onTrackUnpublish:function(e){},onTrackReady:function(t){e._stateMachine.getMediaType()===j.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 n,i;try{null===(i=null===(n=e._listener)||void 0===n?void 0:n.onPing)||void 0===i||i.call(n,t,e)}catch(e){console.error(e)}},onReceiveStartASR:function(){var t,n;null===(n=null===(t=e._callAsrListener)||void 0===t?void 0:t.onReceiveStartASR)||void 0===n||n.call(t)},onReceiveStopASR:function(){var t,n;null===(n=null===(t=e._callAsrListener)||void 0===t?void 0:t.onReceiveStopASR)||void 0===n||n.call(t)},onReceiveASRContent:function(t){var n,i;null===(i=null===(n=e._callAsrListener)||void 0===n?void 0:n.onReceiveASRContent)||void 0===i||i.call(n,t)},onReceiveRealtimeTranslationContent:function(t){var n,i;null===(i=null===(n=e._callAsrListener)||void 0===n?void 0:n.onReceiveRealtimeTranslationContent)||void 0===i||i.call(n,t)},onReceiveStartSummarization:function(t){var n,i;null===(i=null===(n=e._callAsrListener)||void 0===n?void 0:n.onReceiveStartSummarization)||void 0===i||i.call(n,t)},onReceiveStopSummarization:function(t){var n,i;null===(i=null===(n=e._callAsrListener)||void 0===n?void 0:n.onReceiveStopSummarization)||void 0===i||i.call(n,t)}})}}),Object.defineProperty(e.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 n,i;try{null===(i=null===(n=e._listener)||void 0===n?void 0:n.onICEConnectionStateChange)||void 0===i||i.call(n,t,e)}catch(t){e._logger.error("_","[RCCallSession onICEConnectionStateChange] onICEConnectionStateChange exception"),console.error(t)}}})}}),Object.defineProperty(e.prototype,"getSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getCallId()}}),Object.defineProperty(e.prototype,"getRTCSessionId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._room?this._room.getSessionId():null}}),Object.defineProperty(e.prototype,"getTargetId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getTargetId()}}),Object.defineProperty(e.prototype,"getConversationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getConversationType()}}),Object.defineProperty(e.prototype,"getChannelId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getChannelId()}}),Object.defineProperty(e.prototype,"getRemoteUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getRemoteUsers()}}),Object.defineProperty(e.prototype,"getUsers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getRemoteUsers()}}),Object.defineProperty(e.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(e.prototype,"getState",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getState()}}),Object.defineProperty(e.prototype,"getCallerId",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getCallerId()}}),Object.defineProperty(e.prototype,"getMediaType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._stateMachine.getMediaType()}}),Object.defineProperty(e.prototype,"setSrcLanguageCode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return p(this,void 0,void 0,(function(){return C(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:v.SUCCESS}]):(this._logger.error("_","[RCCallSession setSrcLanguageCode] not in room"),[2,{code:v.NOT_IN_ROOM_ERROR}])}))}))}}),Object.defineProperty(e.prototype,"startASR",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e;return C(this,(function(t){switch(t.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:v.NOT_IN_ROOM_ERROR}]);case 1:return(e=t.sent().code)!==h.SUCCESS?(this._logger.error("_","[RCCallSession startASR] startASR failed RTCCode -> ".concat(e)),[2,{code:e}]):(this._logger.info("_","[RCCallSession startASR] success"),[2,{code:v.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"asrIsAvailable",{enumerable:!1,configurable:!0,writable:!0,value:function(){return!!this._room&&this._room.asrIsAvailable()}}),Object.defineProperty(e.prototype,"stopASR",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e;return C(this,(function(t){switch(t.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:v.NOT_IN_ROOM_ERROR}]);case 1:return(e=t.sent().code)!==h.SUCCESS?(this._logger.error("_","[RCCallSession stopASR] stopASR failed RTCCode -> ".concat(e)),[2,{code:e}]):(this._logger.info("_","[RCCallSession stopASR] success"),[2,{code:v.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"setEnableASR",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return p(this,void 0,void 0,(function(){var t;return C(this,(function(n){switch(n.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:v.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent().code)!==h.SUCCESS?(this._logger.error("_","[RCCallSession setEnableASR] setEnableASR failed RTCCode -> ".concat(t)),[2,{code:t}]):(this._logger.info("_","[RCCallSession setEnableASR] success"),[2,{code:v.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"startRealtimeTranslation",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return p(this,void 0,void 0,(function(){var t;return C(this,(function(n){switch(n.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:v.NOT_IN_ROOM_ERROR}]);case 1:return(t=n.sent().code)!==h.SUCCESS?(this._logger.error("_","[RCCallSession startRealtimeTranslation] startRealtimeTranslation failed RTCCode -> ".concat(t)),[2,{code:t}]):(this._logger.info("_","[RCCallSession startRealtimeTranslation] success"),[2,{code:v.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"stopRealtimeTranslation",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e;return C(this,(function(t){switch(t.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:v.NOT_IN_ROOM_ERROR}]);case 1:return(e=t.sent().code)!==h.SUCCESS?(this._logger.error("_","[RCCallSession stopRealtimeTranslation] stopRealtimeTranslation failed RTCCode -> ".concat(e)),[2,{code:e}]):(this._logger.info("_","[RCCallSession stopRealtimeTranslation] success"),[2,{code:v.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"startSummarization",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t,n;return C(this,(function(i){switch(i.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:v.NOT_IN_ROOM_ERROR}]);case 1:return e=i.sent(),t=e.code,n=e.taskId,t!==h.SUCCESS?(this._logger.error("_","[RCCallSession startSummarization] startSummarization failed RTCCode -> ".concat(t)),[2,{code:t}]):(this._logger.info("_","[RCCallSession startSummarization] success"),[2,{code:v.SUCCESS,taskId:n}])}}))}))}}),Object.defineProperty(e.prototype,"stopSummarization",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e;return C(this,(function(t){switch(t.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:v.NOT_IN_ROOM_ERROR}]);case 1:return(e=t.sent().code)!==h.SUCCESS?(this._logger.error("_","[RCCallSession stopSummarization] stopSummarization failed RTCCode -> ".concat(e)),[2,{code:e}]):(this._logger.info("_","[RCCallSession stopSummarization] success"),[2,{code:v.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"setNickName",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._logger.info("_","[RCCallSession setNickName] nickName: ".concat(e)),!s("nickName",e,l,!0)||e.length>64?(this._logger.error("_","[RCCallSession setNickName] param error"),{code:v.PARAM_ERROR}):(this._nickName=e,this._logger.info("_","[RCCallSession setNickName] success"),{code:v.SUCCESS})}}),e}(),ce=function(){function e(e,t,n,i){var r=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: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=g({isAllowPublishRetry:!1,isAllowSubscribeRetry:!1,isOffCameraWhenVideoDisable:!0,joinType:u.KICK,isAllowDemotionGetStream:!1,lang:x.ZH},i),this._callEngine=new q(this._context,t,this._logger,{onInvite:this._onInvite.bind(this),onOfflineRecord:this._onOfflineRecord.bind(this)},{lang:this._options.lang||x.ZH,busyCallPolicy:this._options.busyCallPolicy||L.HANGUP}),X.on("sessionClose",(function(e){var t=e.session,n=e.summaryInfo;r._removeSession(t);try{r._options.onSessionClose(t,n)}catch(e){r._logger.error("_","[RCCCallClient] options.onSessionClose exception"),console.log(e)}})),X.on("hungupOtherSession",(function(e){var t=e.session.getSessionId();r._logger.info("_","[RCCallClient hungupOtherSession] sessionId ready to accept -> ".concat(t)),r._logger.info("_","[RCCallClient hungupOtherSession] sessionList ->".concat(r._sessionList.map((function(e){return e.getSessionId()})).join(",")));for(var n=0;r._sessionList.length>1;)r._sessionList[n].getSessionId()!==t?(r._sessionList[n].hungup(),r._sessionList.splice(n,1)):n++;r._logger.info("_","[RCCallClient hungupOtherSession] current sessionList length ->".concat(r._sessionList.length))}))}return Object.defineProperty(e.prototype,"_onInvite",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._logger.info("_","[RCCallClient _onInvite] Received invite message");var n=new le(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:U.CALLEE,callPushConfig:g({},this._callPushConfig),hungupPushConfig:g({},this._hungupPushConfig)});this._logger.info("_","[RCCallClient _onInvite] Received invite message, successfully created session"),this._sessionList.push(n);try{this._options.onSession(n,t)}catch(e){this._logger.error("_","[RCCallClient _options.onSession] onSession exception"),console.log(e)}if(!n._listener)throw this._logger.error("_","[RCCallClient _options.onSession] session Must Have Listener"),new Error("[RCCallSession _options.onSession] session Must Have Listener");var i=Q(n._listener);if(!i.ok)throw new Error(i.msg)}}),Object.defineProperty(e.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(e.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(e.prototype,"startCrossCall",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.mediaType,i=void 0===n?j.AUDIO:n,r=e.listener,o=e.constraints,a=e.channelId,s=void 0===a?"":a,l=e.extra,c=void 0===l?"":l,u=e.pushTitle,d=void 0===u?"":u,_=e.pushContent,h=void 0===_?"":_,f=e.bitrate;return p(this,void 0,void 0,(function(){return C(this,(function(e){return[2,this.__call({targetId:t,mediaType:i,listener:r,constraints:o,channelId:s,extra:c,pushTitle:d,pushContent:h,bitrate:f,isCrossAppkey:!0})]}))}))}}),Object.defineProperty(e.prototype,"call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e.targetId,n=e.mediaType,i=void 0===n?j.AUDIO:n,r=e.listener,o=e.constraints,a=e.channelId,s=void 0===a?"":a,l=e.extra,c=void 0===l?"":l,u=e.pushTitle,d=void 0===u?"":u,_=e.pushContent,h=void 0===_?"":_,f=e.bitrate;return p(this,void 0,void 0,(function(){return C(this,(function(e){return[2,this.__call({targetId:t,mediaType:i,listener:r,constraints:o,channelId:s,extra:c,pushTitle:d,pushContent:h,bitrate:f})]}))}))}}),Object.defineProperty(e.prototype,"__call",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,n=e.targetId,i=e.mediaType,r=void 0===i?j.AUDIO:i,o=e.listener,a=e.constraints,s=e.channelId,l=void 0===s?"":s,c=e.extra,u=void 0===c?"":c,d=e.pushTitle,_=void 0===d?"":d,h=e.pushContent,f=void 0===h?"":h,b=e.bitrate,R=e.isCrossAppkey,m=void 0!==R&&R;return p(this,void 0,void 0,(function(){var e,i,s,c,d,h,p,R,I,E,y,O,S,T;return C(this,(function(C){switch(C.label){case 0:return e=g({},null!==(t=this._callPushConfig)&&void 0!==t?t:{pushTitle:_,pushContent:f}),this._logger.info("_","[RCCallClient call] targetId: ".concat(n,", mediaType: ").concat(r)),n===this._context.getCurrentId()?(this._logger.error("_","[RCCallClient call] targetId is equal to currentId"),[2,{code:v.PARAM_ERROR}]):(i=[$(n),ee(r),Q(o),te(u)],s=[],i.every((function(e){return!e.ok&&s.push(e.msg),e.ok}))?(c=ne(e),d=c.code,h=c.errorMsg,d!==v.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(h)),[2,{code:d}]):(p=[],[4,this._getLocalTrack(r,a)])):(console.error(s.join("\n")),[2,{code:v.PARAM_ERROR}]));case 1:return R=C.sent(),I=R.code,E=R.tracks,I!==v.SUCCESS?[2,{code:I}]:((p=E).forEach((function(e){var t,n,i;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===(n=null==b?void 0:b.video)||void 0===n?void 0:n.min,null===(i=null==b?void 0:b.video)||void 0===i?void 0:i.start),o.onTrackReady(e)})),[4,this._callEngine.call(l,n,r,u,e,m)]);case 2:return y=C.sent(),O=y.code,S=y.stateMachine,O===v.SUCCESS&&S?(this._logger.info("_","[RCCallClient call] successfully created state machine"),(T=new le(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:U.CALLER,isCrossAppkey:m,callPushConfig:g({},this._callPushConfig),hungupPushConfig:g({},this._hungupPushConfig)})).registerSessionListener(o),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(e.prototype,"callInGroup",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,n=e.targetId,i=e.userIds,r=e.mediaType,o=void 0===r?j.AUDIO:r,a=e.listener,s=e.constraints,l=e.channelId,c=void 0===l?"":l,u=e.extra,d=void 0===u?"":u,_=e.pushTitle,h=void 0===_?"":_,f=e.pushContent,b=void 0===f?"":f,R=e.bitrate;return p(this,void 0,void 0,(function(){var e,r,l,u,_,f,p,m,I,E,y,O,S,T,M;return C(this,(function(C){switch(C.label){case 0:return e=g({},null!==(t=this._callPushConfig)&&void 0!==t?t:{pushTitle:h,pushContent:b}),r=[$(n),oe(i),ee(o),Q(a),te(d)],l=[],u=r.every((function(e){return!e.ok&&l.push(e.msg),e.ok})),i.includes(this._context.getCurrentId())?(console.error("[RCCallClient callInGroup] userIds includes currentId"),[2,{code:v.PARAM_ERROR}]):u?(_=ne(e),f=_.code,p=_.errorMsg,f!==v.SUCCESS?(this._logger.error("_","[RCCallClient call] param error, errorMsg: ".concat(p)),[2,{code:f}]):(m=[],[4,this._getLocalTrack(o,s)])):(console.error("[RCCallClient callInGroup] ".concat(l.join("\n"))),[2,{code:v.PARAM_ERROR}]);case 1:return I=C.sent(),E=I.code,y=I.tracks,E!==v.SUCCESS?[2,{code:E}]:((m=y).forEach((function(e){var t,n,i;e.isAudioTrack()&&(null==R?void 0:R.audio)&&e.setBitrate(null==R?void 0:R.audio),e.isVideoTrack()&&(null==R?void 0:R.video)&&e.setBitrate(null===(t=null==R?void 0:R.video)||void 0===t?void 0:t.max,null===(n=null==R?void 0:R.video)||void 0===n?void 0:n.min,null===(i=null==R?void 0:R.video)||void 0===i?void 0:i.start),a.onTrackReady(e)})),[4,this._callEngine.callInGroup(c,n,o,i,d,e)]);case 2:return O=C.sent(),S=O.code,T=O.stateMachine,S===v.SUCCESS&&T?(this._logger.info("_","[RCCallClient callInGroup] successfully created state machine"),(M=new le(T,this._rtcClient,this._logger,{localTracks:m,isAllowSubscribeRetry:this._options.isAllowSubscribeRetry,isAllowPublishRetry:this._options.isAllowPublishRetry,isOffCameraWhenVideoDisable:this._options.isOffCameraWhenVideoDisable,joinType:this._options.joinType,isAllowDemotionGetStream:this._options.isAllowDemotionGetStream,produceType:U.CALLER,callPushConfig:g({},this._callPushConfig),hungupPushConfig:g({},this._hungupPushConfig)})).registerSessionListener(a),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)),m.forEach((function(e){e.mute(),e.destroy()})),[2,{code:S}])}}))}))}}),Object.defineProperty(e.prototype,"_getLocalTrackCore",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return p(this,void 0,void 0,(function(){var n,i,r,o,a,s;return C(this,(function(l){switch(l.label){case 0:return e!==j.AUDIO?[3,2]:[4,this._rtcClient.createMicrophoneAudioTrack("RongCloudRTC",t&&t.audio&&g({},t.audio))];case 1:return n=l.sent(),i=n.code,r=n.track,i!==h.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio local tracks failed RCT code -> ".concat(i)),[2,{code:v.GET_LOCAL_AUDIO_TRACK_ERROR}]):(this._logger.info("_","[RCCallClient _getTrack] successfully get Audio local tracks"),[2,{code:v.SUCCESS,tracks:[r]}]);case 2:return[4,this._rtcClient.createMicrophoneAndCameraTracks("RongCloudRTC",t&&g({},t))];case 3:return o=l.sent(),a=o.code,s=o.tracks,a!==h.SUCCESS?(this._logger.error("_","[RCCallClient _getTrack] get Audio and Video local tracks failed RCT code -> ".concat(a)),[2,{code:v.GET_LOCAL_AUDIO_AND_VIDEO_TRACK_ERROR}]):(this._logger.info("_","[RCCallClient _getTrack] successfully get audio and video local tracks"),[2,{code:v.SUCCESS,tracks:s}])}}))}))}}),Object.defineProperty(e.prototype,"_getLocalTrack",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return p(this,void 0,void 0,(function(){var n,i,r,o,a,s,l,c,u;return C(this,(function(d){switch(d.label){case 0:return this._options.isAllowDemotionGetStream&&e===j.AUDIO_VIDEO?[4,this._getLocalTrackCore(j.AUDIO_VIDEO,t)]:[3,4];case 1:return n=d.sent(),i=n.code,r=n.tracks,i===v.SUCCESS?[3,3]:[4,this._getLocalTrackCore(j.AUDIO,t)];case 2:return o=d.sent(),a=o.code,s=o.tracks,a!==v.SUCCESS?[2,{code:a}]:[2,{code:a,tracks:s}];case 3:return[2,{code:i,tracks:r}];case 4:return[4,this._getLocalTrackCore(e,t)];case 5:return l=d.sent(),c=l.code,u=l.tracks,c!==v.SUCCESS?[2,{code:c}]:[2,{code:c,tracks:u}]}}))}))}}),Object.defineProperty(e.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(e.prototype,"getJoinedRoomInfo",{enumerable:!1,configurable:!0,writable:!0,value:function(){return p(this,void 0,void 0,(function(){var e,t,i;return C(this,(function(r){switch(r.label){case 0:return[4,this._context.getRTCJoinedUserInfo(this._context.getCurrentId())];case 1:return e=r.sent(),t=e.code,i=e.data,t!==n.SUCCESS?(this._logger.error("_","getJoinedUserInfo error code: ".concat(t)),[2,{code:v.QUERY_JOINED_USER_INFO_ERROR}]):[2,{code:v.SUCCESS,data:i}]}}))}))}}),Object.defineProperty(e.prototype,"setPushConfig",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n,i,r=[e,t].map((function(e){return ne(e)}));try{for(var o=function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(r),a=o.next();!a.done;a=o.next()){var s=a.value,l=s.code,c=s.errorMsg;if(l!==v.SUCCESS)return this._logger.error("_","[RCCallClient setPushConfig] param error, errorMsg: ".concat(c)),{code:l}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}this._callPushConfig=e,this._hungupPushConfig=t}}),Object.defineProperty(e.prototype,"generateSummarization",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,i,r,o){return p(this,void 0,void 0,(function(){var a;return C(this,(function(s){switch(s.label){case 0:return this._logger.info("_","[RCCallClient generateSummarization] callId: ".concat(e,", taskId: ").concat(t,", startTime: ").concat(n,", endTime: ").concat(i)),[4,this._rtcClient.generateSummarization(e,t,n,i,r,o)];case 1:return(a=s.sent().code)!==h.SUCCESS?(this._logger.error("_","[RCCallClient generateSummarization] generateSummarization failed RTCCode -> ".concat(a)),[2,{code:a}]):(this._logger.info("_","[RCCallClient generateSummarization] generateSummarization success"),[2,{code:v.SUCCESS}])}}))}))}}),Object.defineProperty(e.prototype,"getASRContent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,i,r,o){return p(this,void 0,void 0,(function(){var a;return C(this,(function(s){switch(s.label){case 0:return this._logger.info("_","[RCCallClient getASRContent] callId: ".concat(e,", taskId: ").concat(t,", startTime: ").concat(n,", endTime: ").concat(i,", destLang: ").concat(o)),[4,this._rtcClient.getASRContent(e,t,n,i,r,o)];case 1:return(a=s.sent().code)!==h.SUCCESS?(this._logger.error("_","[RCCallClient getASRContent] getASRContent failed RTCCode -> ".concat(a)),[2,{code:a}]):(this._logger.info("_","[RCCallClient getASRContent] getASRContent success"),[2,{code:v.SUCCESS}])}}))}))}}),e}();c.add("calllib","5.36.0");var ue={tag:"RCCall",verify:function(e){return"browser"===e.tag},setup:function(e,t,n){var i=Z(n);if(!i.ok)throw new Error("[RCCallLib installer steup]".concat(i.msg));if(!c.validEngine("5.36.1"))throw new Error("The current engine version '".concat(c.getInfo().engine,"' error, plugin-call required engine version at least '").concat("5.36.1","'."));var r=e.createLogger("RCCall","RTC");return n.logOutputLevel&&r.setOutputLevel(n.logOutputLevel),void 0!==n.logLevel&&r.warn("_","The 'logLevel' parameter is deprecated, please use 'logOutputLevel' instead."),r.warn("_","RCCall Version: ".concat("5.36.0",", Commit: ").concat("d8b9ac7b0c1524c64f9de2808bbaf27adbc54715")),new ce(e,t,r,n)}};export{L as RCCallBusyCallPolicy,ce as RCCallClient,E as RCCallEndReason,v as RCCallErrorCode,x as RCCallLanguage,j as RCCallMediaType,le as RCCallSession,P as RCCallSessionState,A as RCCallUserState,ue as installer};
|
package/package.json
CHANGED
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"license": "LGPL 2.1",
|
|
27
27
|
"description": "@rongcloud/plugin-call",
|
|
28
28
|
"homepage": "https://www.rongcloud.cn",
|
|
29
|
-
"version": "5.
|
|
29
|
+
"version": "5.36.0",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@rongcloud/engine": "~5.
|
|
32
|
-
"@rongcloud/plugin-rtc": "~5.
|
|
31
|
+
"@rongcloud/engine": "~5.36.1",
|
|
32
|
+
"@rongcloud/plugin-rtc": "~5.36.0"
|
|
33
33
|
}
|
|
34
34
|
}
|