"use strict";const l=require("../../../common/vendor.js");exports.CallkitPluginServer=class{constructor(){l.R.registerEvent(l.E.TUILogin.EVENT.LOGIN_STATE_CHANGED,l.E.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS,this),l.R.registerService(l.E.TUICalling.SERVICE.NAME,this),l.R.registerExtension(l.E.TUIChat.EXTENSION.INPUT_MORE.EXT_ID,this)}onNotifyEvent(e,o){if(e===l.E.TUILogin.EVENT.LOGIN_STATE_CHANGED){let e,i,s,t;if(o===l.E.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS)t=l.A.getContext(),e=t.SDKAppID,i=t.userID,s=t.userSig,l.i.$TUICallKit&&l.i.$TUICallKit.login({SDKAppID:e,userID:i,userSig:s},(e=>{0===e.code?(console.log("TUICallkit login success!"),l.i.$TUICallKit.enableFloatWindow(!0)):console.error(`TUICallkit login failed,${e.msg}`)}))}}onGetExtension(e,o){if(!l.i.$TUICallKit)return console.warn("请检查原生插件 TencentCloud-TUICallKit 是否已集成"),[];if(e===l.E.TUIChat.EXTENSION.INPUT_MORE.EXT_ID){const l=[],e={weight:1e3,text:"语音通话",icon:"https://web.sdk.qcloud.com/component/TUIKit/assets/call.png",data:{name:"voiceCall"},listener:{onClicked:l=>{this.setCallExtension(l)}}},i={weight:900,text:"视频通话",icon:"https://web.sdk.qcloud.com/component/TUIKit/assets/call-video-reverse.svg",data:{name:"videoCall"},listener:{onClicked:l=>{this.setCallExtension(l)}}};return(null==o?void 0:o.filterVoice)||l.push(e),(null==o?void 0:o.filterVideo)||l.push(i),l}}onCall(e,o){if(l.i.$TUICallKit){if(e===l.E.TUICalling.SERVICE.METHOD.START_CALL){const{groupID:e,userIDList:i=[],type:s,callParams:t}=o;e?l.i.$TUICallKit.groupCall({groupID:e,userIDList:i,callMediaType:s,callParams:t},(l=>{0===l.code?console.log("TUICallkit groupCall success"):console.error(`TUICallkit groupCall failed,${l.msg}`)})):1===i.length&&l.i.$TUICallKit.call({userID:i[0],callMediaType:s,callParams:t},(l=>{0===l.code?console.log("TUICallkit call success"):console.log(`TUICallkit call failed,${l.msg}`)}))}}else console.warn("请检查原生插件 TencentCloud-TUICallKit 是否已集成")}setCallExtension(e){const{groupID:o,userIDList:i=[],type:s,callParams:t}=e;try{o?l.i.$TUICallKit.groupCall({groupID:o,userIDList:i,callMediaType:s,callParams:t},(l=>{0===l.code?console.log("TUICallkit groupCall success"):console.log(`TUICallkit groupCall failed,${l.msg}`)})):1===i.length&&l.i.$TUICallKit.call({userID:i[0],callMediaType:s,callParams:t},(l=>{0===l.code?console.log("TUICallkit call success"):console.log(`TUICallkit call failed,${l.msg}`)}))}catch(a){l.i.showToast({title:"拨打失败！",icon:"error"})}}};
