!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("trtc-js-sdk"),require("tim-js-sdk"),require("tsignaling")):"function"==typeof define&&define.amd?define(["trtc-js-sdk","tim-js-sdk","tsignaling"],e):"object"==typeof exports?exports.TRTCCalling=e(require("trtc-js-sdk"),require("tim-js-sdk"),require("tsignaling")):t.TRTCCalling=e(t.TRTC,t.TIM,t.TSignaling)}(window,(function(t,e,n){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=23)}([function(t,e,n){"use strict";n.r(e);var i=n(3),r=n(1);let s=0;const o=new Map;function a(){const t=new Date;return`TRTCCalling ${t.toLocaleTimeString("en-US",{hour12:!1})}.${function(t){let e;switch(t.toString().length){case 1:e="00"+t;break;case 2:e="0"+t;break;default:e=t}return e}(t.getMilliseconds())}:`}const l={_data:[],_length:0,_visible:!1,arguments2String(t){let e;if(1===t.length)e=a()+t[0];else{e=a();for(let n=0,{length:i}=t;ns,record(t,e){1100===l._length&&(l._data.splice(0,100),l._length=1e3),l._length++,l._data.push(`${t} [${e}] \n`)},getLog:()=>l._data};e.default=l},function(t,e,n){"use strict";n.r(e),n.d(e,"isMap",(function(){return r})),n.d(e,"isSet",(function(){return s})),n.d(e,"isFile",(function(){return o})),n.d(e,"isNumber",(function(){return a})),n.d(e,"isString",(function(){return l})),n.d(e,"isObject",(function(){return u})),n.d(e,"isPlainObject",(function(){return c})),n.d(e,"isArray",(function(){return d})),n.d(e,"isUndefined",(function(){return h})),n.d(e,"isNativeClass",(function(){return p})),n.d(e,"isArrayOrObject",(function(){return _})),n.d(e,"isFunction",(function(){return g})),n.d(e,"isInstanceOfError",(function(){return I})),n.d(e,"getType",(function(){return v})),n.d(e,"TimeUtil",(function(){return E})),n.d(e,"stringifyError",(function(){return m})),n.d(e,"map2String",(function(){return T})),n.d(e,"randomString",(function(){return D})),n.d(e,"isValidType",(function(){return S})),n.d(e,"mapKeys",(function(){return A})),n.d(e,"mapValues",(function(){return w})),n.d(e,"generateRandomRoomID",(function(){return O})),n.d(e,"formatDuration",(function(){return N})),n.d(e,"compareVersion",(function(){return U})),n.d(e,"date2ISOString",(function(){return R})),n.d(e,"getHostType",(function(){return V}));var i=n(5);const r=function(t){return"map"===v(t)},s=function(t){return"set"===v(t)},o=function(t){return"file"===v(t)},a=function(t){return null!==t&&("number"==typeof t&&!isNaN(t-0)||"object"==typeof t&&t.constructor===Number)},l=function(t){return"string"==typeof t},u=function(t){return null!==t&&"object"==typeof t},c=function(t){if("object"!=typeof t||null===t)return!1;const e=Object.getPrototypeOf(t);if(null===e)return!0;let n=e;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return e===n},d=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"array"===v(t)},h=function(t){return void 0===t},f=/^class\s/,p=function(t){return"function"==typeof t&&f.test(t.toString())},_=function(t){return d(t)||u(t)},g=function(t){return"function"==typeof t},I=function(t){return t instanceof Error},v=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()};let C=0;Date.now||(Date.now=function(){return(new Date).getTime()});const E={now(){0===C&&(C=Date.now()-1);const t=Date.now()-C;return t>4294967295?(C+=4294967295,Date.now()-C):t},utc:()=>Math.round(Date.now()/1e3)},m=function(t){return JSON.stringify(t,["message","code"])},T=function(t){if(!r(t))return"not a map!!!";let e="";for(const[n,i]of t.entries()){if(r(i))return`[k=${n} -> ${T(i)}`;e+=`[k=${n} v=${i}] `}return e},y="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",L=y.length,D=function(){let t="";for(let e=32;e>0;--e)t+=y[Math.floor(Math.random()*L)];return t},S=function(t,e){for(const n in t)if(t[n]===e)return!0;return!1};function A(t,e){const n={};return Object.keys(t).forEach(i=>{n[e(t[i],i)]=t[i]}),n}function w(t,e){const n={};return Object.keys(t).forEach(i=>{n[i]=e(t[i],i)}),n}function O(){return Math.round(1e8*Math.random())}function b(t){return t<10?"0"+t:t}function N(t){if(t<60)return"00:00:"+b(t);if(t<3600){const e=parseInt(t/60),n=t-60*e;return`00:${b(e)}:${b(n)}`}const e=parseInt(t/3600),n=t-3600*e,i=parseInt(n/60),r=n-60*i;return`${b(e)}:${b(i)}:${b(r)}`}function U(t,e){t=t.split("."),e=e.split(".");const n=Math.max(t.length,e.length);for(;t.lengthr)return 1;if(n-10?"+0"+Math.abs(100*n):"+"+Math.abs(100*n):n>=10?"-"+100*n:"-0"+100*n,e.replace("Z",i)};function V(){let t="unknown";return i.IS_MAC&&(t="mac"),i.IS_WIN&&(t="windows"),i.IS_IOS&&(t="ios"),i.IS_ANDROID&&(t="android"),t}},function(t,e,n){"use strict";var i=n(13),r=Object.prototype.toString;function s(t){return"[object Array]"===r.call(t)}function o(t){return void 0===t}function a(t){return null!==t&&"object"==typeof t}function l(t){if("[object Object]"!==r.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function u(t){return"[object Function]"===r.call(t)}function c(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),s(t))for(var n=0,i=t.length;n{this._eventStatController.pushIn(this)},0)}setError(t,e,n){return this.setNetworkType(n),e?(t.code&&this.setCode(t.code),t.message&&this.setMessage(t.message)):(this.setCode(o.a.NO_NETWORK),this.setMessage(l.a.NO_NETWORK)),this}setCode(t){return"ECONNABORTED"===t&&(this.codeint=103),Object(i.isNumber)(t)?this.codeint=t:r.default.warn("SSOLogData.setCode value not a number, please check!",t,typeof t),this}setMessage(t){return Object(i.isString)(t)?(this.message=t,this):this}setText(t){return Object(i.isNumber)(t)?this.text=t.toString():Object(i.isString)(t)&&(this.text=t),this}setTalkTime(t){return this.talktime=t,this}setMessageType(t){return this.msgType=t,this}setCallType(t){return this.calltype=t,this}setNetworkType(t){return Object(i.isUndefined)(t)?r.default.warn("SSOLogData.setNetworkType value is undefined, please check!"):this.networktype=t,this}}e.default=u},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.DEVICEID_TYPE=e.DEVICE_TYPE=e.MODE_TYPE=e.VALID_VIDEO_PROFILE_LIST=e.BUSINESS_ID=e.ACTION_TYPE=e.CALL_STATUS=e.CMD_TYPE=e.CMD_TYPE_LIST=e.CALL_TYPE=void 0,function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.AUDIO_CALL=1]="AUDIO_CALL",t[t.VIDEO_CALL=2]="VIDEO_CALL"}(e.CALL_TYPE||(e.CALL_TYPE={})),e.CMD_TYPE_LIST=["","audioCall","videoCall"],function(t){t.AUDIO_CALL="audioCall",t.VIDEO_CALL="videoCall",t.HANG_UP="hangup",t.SWITCH_TO_AUDIO="switchToAudio",t.SWITCH_TO_AUDIO_CALL="switch_to_audio_call",t.SWITCH_TO_VIDEO="switchToVideo"}(e.CMD_TYPE||(e.CMD_TYPE={})),function(t){t.IDLE="idle",t.CALLING="calling",t.CONNECTED="connected"}(e.CALL_STATUS||(e.CALL_STATUS={})),function(t){t[t.INVITE=1]="INVITE",t[t.CANCEL_INVITE=2]="CANCEL_INVITE",t[t.ACCEPT_INVITE=3]="ACCEPT_INVITE",t[t.REJECT_INVITE=4]="REJECT_INVITE",t[t.INVITE_TIMEOUT=5]="INVITE_TIMEOUT"}(e.ACTION_TYPE||(e.ACTION_TYPE={})),function(t){t[t.SIGNAL=1]="SIGNAL"}(e.BUSINESS_ID||(e.BUSINESS_ID={})),e.VALID_VIDEO_PROFILE_LIST=["240p","360p","480p","720p","1080p"],function(t){t.AUDIO="audio",t.VIDEO="video"}(e.MODE_TYPE||(e.MODE_TYPE={})),function(t){t.AUDIO="audio",t.VIDEO="video"}(e.DEVICE_TYPE||(e.DEVICE_TYPE={})),function(t){t.audio="microphoneId",t.video="cameraId"}(e.DEVICEID_TYPE||(e.DEVICEID_TYPE={}))},function(t,e,n){"use strict";n.r(e);e.default={SDK_CONSTRUCT:"sdkConstruct",SDK_READY:"sdkReady",SDK_NOT_READY:"sdkNotReady",LOGIN:"login",LOGOUT:"logout",CALL:"call",GROUP_CALL:"groupCall",ACCEPT:"accept",REJECT:"reject",HANGUP:"hangup",START_REMOTE_VIEW:"startRemoteView",STOP_REMOTE_VIEW:"stopRemoteView",START_LOCAL_VIEW:"startLocalView",STOP_LOCAL_VIEW:"stopLocalView",OPEN_CAMERA:"openCamera",CLOSE_CAMERA:"closeCamera",SET_MIC_MUTE:"setMicMute",SET_VIDEO_QUALITY:"setVideoQuality",SWITCH_TO_AUDIO_CALL:"switchToAudioCall",SWITCH_TO_VIDEO_CALL:"switchToVideoCall",CHANGE_CALL_STATUS:"changeCallStatus",TALK_TIME:"talktime",ERROR:"error",INVITED:"invited",GROUP_CALL_INVITEE_LIST_UPDATE:"group_call_invitee_list_update",USER_ENTER:"user_enter",USER_LEAVE:"user_leave",NO_RESP:"no_resp",LINE_BUSY:"line_busy",CALLING_CANCEL:"calling_cancel",KICKED_OUT:"kicked_out",CALLING_TIMEOUT:"calling_timeout",CALLING_END:"calling_end",USER_VIDEO_AVAILABLE:"user_video_available",USER_AUDIO_AVAILABLE:"user_audio_available",USER_VOICE_VOLUME:"user_voice_volume",CALL_TYPE_CHANGED:"call_type_changed",DEVICED_UPDATED:"deviced_updated"}},function(t,e,n){"use strict";n.r(e),n.d(e,"default",(function(){return p}));var i=n(0),r=n(1);class s{constructor(){this._table="timweb-trtccalling",this._report=[]}pushIn(t){i.default.debug("SSOLogBody.pushIn",this._report.length,t),this._report.push(t)}backfill(t){Object(r.isArray)(t)&&0!==t.length&&(i.default.debug("SSOLogBody.backfill",this._report.length,t.length),this._report.unshift(...t))}getLogsNumInMemory(){return this._report.length}isEmpty(){return 0===this._report.length}_reset(){this._report.length=0,this._report=[]}getTable(){return this._table}getLogsInMemory(){const t=this._report.slice();return this._reset(),t}}var o=n(6),a=n(11),l=n(22),u=n.n(l);const c={CURRENT:{COMMON:"https://webim.tim.qq.com"},PRODUCTION:{COMMON:"https://webim.tim.qq.com"},OVERSEA_PRODUCTION:{COMMON:"https://api.im.qcloud.com"},SANDBOX:{COMMON:"https://events.tim.qq.com"},TEST:{COMMON:"https://test.tim.qq.com"}},d={IM_OPEN_STAT:"imopenstat"},h={TIM_WEB_TRTCCALLING_REPORT:"tweb_trtccalling_report"},f={imopenstat:"v4"};class p{constructor(){this.TAG="trtccalling-ssolog-event",this._reportBody=new s,this._version=a.version||"",this.MIN_THRESHOLD=20,this.MAX_THRESHOLD=100,this.WAITING_TIME=6e4,this.INTERVAL=2e4,this._timerID=0,this._resetLastReportTime(),this._startReportTimer(),this._retryCount=0,this.MAX_RETRY_COUNT=3}reportAtOnce(){i.default.debug("EventStatController.reportAtOnce"),this._report()}pushIn(t){t instanceof o.default&&(t.setCommonInfo({SDKAppID:Number(sessionStorage.getItem("sdkAppId")),version:this._version,userID:sessionStorage.getItem("userId")}),this._reportBody.pushIn(t),this._report())}_resetLastReportTime(){this._lastReportTime=Date.now()}_startReportTimer(){this._timerID=setInterval(()=>{Date.now()0&&(clearInterval(this._timerID),this._timerID=0)}_report(){if(this._reportBody.isEmpty())return;const t=Math.ceil(+new Date/1e3),e=sessionStorage.getItem("sdkAppId"),n=this._reportBody.getLogsInMemory(),s={table:this._reportBody.getTable(),report:n},o=`${c.CURRENT.COMMON}/${f.imopenstat}/${d.IM_OPEN_STAT}/${h.TIM_WEB_TRTCCALLING_REPORT}/?sdkappid=${e}&reqtime=${t}`;u.a.post(o,JSON.stringify(s)).then(()=>{this._resetLastReportTime(),this._retryCount>0&&(i.default.debug("EventStatController.report retry success"),this._retryCount=0)}).catch(t=>{i.default.warn("EventStatController.report, error:"+Object(r.stringifyError)(t)),this._reportBody.backfill(n);this._reportBody.getLogsNumInMemory()>this.MAX_THRESHOLD||this._retryCount===this.MAX_RETRY_COUNT||0===this._timerID?this._retryCount=0:this._retryCount+=1})}reset(){i.default.log("EventStatController.reset"),this._stopReportTimer(),this._report()}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default={NO_SDK_APPID:"无 SDKAppID",NO_ACCOUNT_TYPE:"无 accountType",NO_IDENTIFIER:"无 userID",NO_USER_SIG:"无 userSig",NO_NETWORK:"未连接到网络",FAILURE_SWITCH_TO_AUDIO:"switch to audio call error",FAILURE_SWITCH_TO_VIDEO:"switch to video call error",NOT_MICROPHONE_LIST:"No microphone or microphone permission denied",NOT_CAMERA_LIST:"No camera or camera permission denied"}},function(t){t.exports=JSON.parse('{"name":"trtc-calling-js","version":"1.1.1","description":"腾讯云 TRTC CALLING SDK","main":"index","dependencies":{"axios":"^0.21.0","EventEmitter":"^1.0.0","tim-js-sdk":"^2.13.1","trtc-js-sdk":"^4.11.5","tsignaling":"^0.9.0"},"devDependencies":{"@babel/preset-typescript":"^7.12.7","@tencent/eslint-config-tencent":"^0.16.0","@typescript-eslint/eslint-plugin":"^4.33.0","@typescript-eslint/parser":"^4.33.0","docdash-blue":"^1.1.3","eslint":"^7.27.0","eslint-config-google":"^0.14.0","eslint-plugin-prettier":"^4.0.0","fs-extra":"^9.0.1","jsdoc":"^3.6.5","prettier":"^2.5.0","pretty":"^2.0.0","replace":"^1.2.0","ts-loader":"^8.0.2","typescript":"^3.9.7","webpack":"^4.44.1","webpack-cli":"^3.3.12"},"scripts":{"build":"webpack --config webpack.config.js","build_withcopy":"npm run build && cp dist/npm/trtc-calling-js.js ../../github/TUICalling/Web/node_modules/trtc-calling-js/trtc-calling-js.js","build_withcopy2":"npm run build && cp dist/npm/trtc-calling-js.js ../../demo/trtc-calling-webrtc-demo/node_modules/trtc-calling-js/trtc-calling-js.js","build:package":"node build/package-bundle.js","lint":"./node_modules/.bin/eslint ./src; exit 0","fix":"./node_modules/.bin/eslint --fix ./src; exit 0","prerelease":"npm run lint && npm run build && npm run doc && npm run build:package","ts2js":"tsc src/index.ts --outDir build/ts2js --lib es2015,DOM","doc":"npm run ts2js && npm run doc:clean && npm run doc:build","doc:build":"./node_modules/.bin/jsdoc -c build/jsdoc/jsdoc.json && node ./build/jsdoc/fix-doc.js","doc:clean":"node ./build/jsdoc/clean-doc.js","changelog":"cp CHANGELOG.md build/jsdoc/tutorials/CHANGELOG.md"},"repository":{"type":"git","url":"git@git.code.oa.com:TRDCWeb/trtc-calling-webrtc.git"},"author":"Tencent Cloud Terminal R&D Center","license":"ISC"}')},function(e,n){e.exports=t},function(t,e,n){"use strict";t.exports=function(t,e){return function(){for(var n=new Array(arguments.length),i=0;i=200&&t<300}};l.headers={common:{Accept:"application/json, text/plain, */*"}},i.forEach(["delete","get","head"],(function(t){l.headers[t]={}})),i.forEach(["post","put","patch"],(function(t){l.headers[t]=i.merge(s)})),t.exports=l}).call(this,n(32))},function(t,e,n){"use strict";var i=n(2),r=n(34),s=n(36),o=n(14),a=n(37),l=n(40),u=n(41),c=n(18);t.exports=function(t){return new Promise((function(e,n){var d=t.data,h=t.headers;i.isFormData(d)&&delete h["Content-Type"];var f=new XMLHttpRequest;if(t.auth){var p=t.auth.username||"",_=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";h.Authorization="Basic "+btoa(p+":"+_)}var g=a(t.baseURL,t.url);if(f.open(t.method.toUpperCase(),o(g,t.params,t.paramsSerializer),!0),f.timeout=t.timeout,f.onreadystatechange=function(){if(f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))){var i="getAllResponseHeaders"in f?l(f.getAllResponseHeaders()):null,s={data:t.responseType&&"text"!==t.responseType?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:i,config:t,request:f};r(e,n,s),f=null}},f.onabort=function(){f&&(n(c("Request aborted",t,"ECONNABORTED",f)),f=null)},f.onerror=function(){n(c("Network Error",t,null,f)),f=null},f.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),n(c(e,t,"ECONNABORTED",f)),f=null},i.isStandardBrowserEnv()){var I=(t.withCredentials||u(g))&&t.xsrfCookieName?s.read(t.xsrfCookieName):void 0;I&&(h[t.xsrfHeaderName]=I)}if("setRequestHeader"in f&&i.forEach(h,(function(t,e){void 0===d&&"content-type"===e.toLowerCase()?delete h[e]:f.setRequestHeader(e,t)})),i.isUndefined(t.withCredentials)||(f.withCredentials=!!t.withCredentials),t.responseType)try{f.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&f.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&f.upload&&f.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){f&&(f.abort(),n(t),f=null)})),d||(d=null),f.send(d)}))}},function(t,e,n){"use strict";var i=n(35);t.exports=function(t,e,n,r,s){var o=new Error(t);return i(o,e,n,r,s)}},function(t,e,n){"use strict";var i=n(2);t.exports=function(t,e){e=e||{};var n={},r=["url","method","data"],s=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function l(t,e){return i.isPlainObject(t)&&i.isPlainObject(e)?i.merge(t,e):i.isPlainObject(e)?i.merge({},e):i.isArray(e)?e.slice():e}function u(r){i.isUndefined(e[r])?i.isUndefined(t[r])||(n[r]=l(void 0,t[r])):n[r]=l(t[r],e[r])}i.forEach(r,(function(t){i.isUndefined(e[t])||(n[t]=l(void 0,e[t]))})),i.forEach(s,u),i.forEach(o,(function(r){i.isUndefined(e[r])?i.isUndefined(t[r])||(n[r]=l(void 0,t[r])):n[r]=l(void 0,e[r])})),i.forEach(a,(function(i){i in e?n[i]=l(t[i],e[i]):i in t&&(n[i]=l(void 0,t[i]))}));var c=r.concat(s).concat(o).concat(a),d=Object.keys(t).concat(Object.keys(e)).filter((function(t){return-1===c.indexOf(t)}));return i.forEach(d,u),n}},function(t,e,n){"use strict";function i(t){this.message=t}i.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},i.prototype.__CANCEL__=!0,t.exports=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.EVENT=void 0,e.EVENT={ERROR:"onError",SDK_READY:"sdkReady",INVITED:"onInvited",USER_ACCEPT:"onUserAccept",USER_ENTER:"onUserEnter",USER_LEAVE:"onUserLeave",REJECT:"onReject",NO_RESP:"onNoResp",LINE_BUSY:"onLineBusy",CALLING_CANCEL:"onCallingCancel",KICKED_OUT:"onKickedOut",CALLING_TIMEOUT:"onCallingTimeout",CALL_END:"onCallEnd",CALLING_END:"onCallEnd",USER_VIDEO_AVAILABLE:"onUserVideoAvailable",USER_AUDIO_AVAILABLE:"onUserAudioAvailable",USER_VOICE_VOLUME:"onUserVoiceVolume",GROUP_CALL_INVITEE_LIST_UPDATE:"onGroupCallInviteeListUpdate",CALL_TYPE_CHANGED:"onCallTypeChanged",DEVICED_UPDATED:"onDeviceUpdated"}},function(t,e,n){t.exports=n(27)},function(t,e,n){"use strict";var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]0},t.prototype.getRemoteStreamCount=function(){return this._trtcClient?this._trtcClient.getRemoteStreams().length:0},t.prototype.setLogLevel=function(t){E.default.setLevel(t),this._tsignalingClient.setLogLevel(t),A.Logger.setLogLevel(t+1)},t.prototype.on=function(t,e,n){this._outerEmitter.on(t,e,n||this)},t.prototype.off=function(t,e,n){this._outerEmitter.off(t,e,n||this)},t.prototype.login=function(t){return r(this,void 0,void 0,(function(){var e,n,i,r;return s(this,(function(s){switch(s.label){case 0:E.default.debug(S+".login - params:",t),this._netMonitor.start(),e=t.userID,n=t.userSig,this._userID=e,this._userSig=n,this._trtcClient=new u.default({sdkAppID:this._sdkAppID,userID:e,userSig:n,trtcCalling:this}),sessionStorage.setItem("userId",""+this._userID),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._tsignalingClient.login({userID:e,userSig:n})];case 2:return i=s.sent(),this._setInterfaceUpLoad(g.default.LOGIN).setText("userId: "+this._userID+" login succeeded").setEnd(),[3,4];case 3:throw r=s.sent(),this._setInterfaceUpLoad(g.default.LOGIN).setText("userId: "+this._userID+" login failed, error: "+r).setEnd(),new Error(S+".login - userId: "+this._userID+" login failed, error: "+r+" ");case 4:return[2,i]}}))}))},t.prototype.logout=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){return E.default.debug(S+".logout"),this._setInterfaceUpLoad(g.default.LOGOUT).setText("userId: "+this._userID+" logout").setEnd(),this._userID="",this._userSig="",this._resetTRTCClient(),this._trtcClient=null,[2,this._tsignalingClient.logout()]}))}))},t.prototype.call=function(t){return r(this,void 0,void 0,(function(){var e,n,i,r,o,a,u;return s(this,(function(s){switch(s.label){case 0:if(!t.type||!t.userID)throw new Error(S+".call - params error:"+JSON.stringify(t));if(!this._trtcClient)throw new Error(S+".calling - not login,please use "+S+".login");if(this._callStatus!==m.CALL_STATUS.IDLE)throw new Error(S+".call - CALL_STATUS: "+this._callStatus);if(this.getDevicePermission().audio)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._trtcClient.getMediaDevicesAuth({audio:!0})];case 2:return s.sent(),[3,4];case 3:throw e=s.sent(),this._delegate.onError(L.default.NOT_MEDIA_ACCESS,JSON.stringify(e)),new Error(S+".auth - 获取用户设备权限失败,可以通过 https://web.sdk.qcloud.com/trtc/webrtc/demo/detect/index.html 进行trtc能力测试。");case 4:return this._callStatus=m.CALL_STATUS.CALLING,E.default.log(S+".call - params:",t),n=t.userID,i=t.type,r=t.offlinePushInfo,o=t.roomID,this._callType=i,this._isInviter=!0,this._inviterID=this._userID,this._inviteeID=n,this._isGroupCall=!1,this._groupID="",this._roomID=o||l.generateRandomRoomID(),[4,this._tsignalingClient.invite({userID:n,type:i,roomID:this._roomID,timeout:this._callTimeout,offlinePushInfo:r,userIDList:[n]})];case 5:return a=s.sent(),u="callType: "+(i+1)+", \n conversationType: "+a.data.message.conversationType+", \n userId:{ "+a.data.message.from+" } invite userId:{ "+a.data.message.to+" }",0===a.code?(this.setInviterInviteID(a.inviteID),this._setInterfaceUpLoad(g.default.CALL).setCallType(i+1).setText(u+" succeeded").setEnd()):(this._setInterfaceUpLoad(g.default.CALL).setCallType(i+1).setText(u+" failed").setEnd(),this._resetTRTCClient()),[2,a]}}))}))},t.prototype.setInviterInviteID=function(t){this._inviterInviteID.push(t),this._inviterInviteID=Array.from(new Set(this._inviterInviteID))},t.prototype.getInviterInviteID=function(){return this._inviterInviteID},t.prototype.delInviterInviteID=function(t){this._inviterInviteID=this._inviterInviteID.filter((function(e){return e!==t}))},t.prototype._setInterfaceUpLoad=function(t){return E.default.time(t),new _.default(t)},t.prototype.getInviterID=function(){return this._inviterID},t.prototype.setInviterID=function(t){this._inviterID=t},t.prototype.groupCall=function(t){var e;return r(this,void 0,void 0,(function(){var n,i,r,o,a,u,c,d,h=this;return s(this,(function(s){switch(s.label){case 0:if(!(null==t?void 0:t.type)||0===(null===(e=null==t?void 0:t.userIDList)||void 0===e?void 0:e.length))throw new Error(S+".groupCall - params error:"+JSON.stringify(t));if(this._groupCallStatus)throw new Error(S+".groupCall - CALL_STATUS: "+this._callStatus);if(!this._trtcClient)throw new Error(S+".groupCall - not login,please use "+S+".login");if(this.getDevicePermission().audio)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._trtcClient.getMediaDevicesAuth({audio:!0})];case 2:return s.sent(),[3,4];case 3:throw n=s.sent(),this._delegate.onError(L.default.NOT_MEDIA_ACCESS,JSON.stringify(n)),new Error(S+".auth - 获取用户设备权限失败,可以通过 https://web.sdk.qcloud.com/trtc/webrtc/demo/detect/index.html 进行trtc能力测试。");case 4:return this._groupCallStatus=!0,E.default.debug(S+".groupCall - params:",t),i=t.userIDList,r=t.type,o=t.groupID,a=t.offlinePushInfo,u=t.roomID,this._callType=r,this._isInviter=!0,this._isGroupCall=!0,this._inviterID=this._userID,this._groupID=o||"",this.setInviteeList(i),this.setUnHandledInviteeList(i),this._roomID||(this._roomID=u||l.generateRandomRoomID(),this._callStatus=m.CALL_STATUS.CALLING),[4,this._tsignalingClient.inviteInGroup({groupID:this._groupID,userIDList:i,type:r,roomID:this._roomID,timeout:this._callTimeout,offlinePushInfo:a})];case 5:return c=s.sent(),E.default.log("groupCall res",c),o?(d="callType: "+(r+1)+",\n conversationType: "+c.data.message.conversationType+",\n userId:{ "+c.data.message.from+" } invite { "+c.data.message.to+": "+i+" }",0===c.code?(this.setInviterInviteID(c.inviteID),this._setInterfaceUpLoad(g.default.GROUP_CALL).setCallType(r+1).setText(d+" succeeded").setEnd()):this._setInterfaceUpLoad(g.default.GROUP_CALL).setCallType(r+1).setText(d+" failed").setEnd()):(d="callType: "+(r+1)+",\n result: "+JSON.stringify(c),0===c.code?(c.data.map((function(t){h.setInviterInviteID(t.inviteID)})),this._setInterfaceUpLoad(g.default.GROUP_CALL).setCallType(r+1).setText(d+" succeeded").setEnd()):(this._setInterfaceUpLoad(g.default.GROUP_CALL).setCallType(r+1).setText(d+" failed").setEnd(),this._resetTRTCClient())),this._groupCallStatus=!1,[2,c]}}))}))},t.prototype.accept=function(){return r(this,void 0,void 0,(function(){var t,e,n,r,o,a,l,u,c,d,h=this;return s(this,(function(s){switch(s.label){case 0:if(E.default.debug(S+".accept"),!this._tsignalingClient.getInviteData())return E.default.warn(S+".accept - there are no calls to accept"),[2];t=this._tsignalingClient.getInviteData(),e=t.inviteID,n=t.inviteData,r=n.roomID,o=n.callType,E.default.debug(S+".accept - params","inviteID: "+e+",callType: "+o+",roomID: "+r+"."),this._callType=o,this._callStatus=m.CALL_STATUS.CALLING,a={},s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._trtcClient.join(r)];case 2:return a=s.sent(),this._roomID=r,this._tsignalingClient.setInviteData(null),this.changeCallStatus(m.CALL_STATUS.CONNECTED),[3,4];case 3:throw s.sent(),this._resetTRTCClient(),new Error(S+".accept - join room failed");case 4:a=i(i({},a),{roomID:r,callType:o}),s.label=5;case 5:return s.trys.push([5,7,,8]),[4,this._tsignalingClient.accept({inviteID:e,callType:o})];case 6:return l=s.sent(),d="callType: "+(o+1)+",\n conversationType: "+l.data.message.conversationType+",\n userId:{ "+this._userID+" } accept userId:{ "+l.data.message.to+" } succeeded",this._setInterfaceUpLoad(g.default.ACCEPT).setCallType(o+1).setText(""+d).setEnd(),[3,8];case 7:return u=s.sent(),E.default.error(u),this._resetTRTCClient(),d="callType: "+(o+1)+",\n conversationType: "+l.data.message.conversationType+",\n userId:{ "+this._userID+" } accept userId:{ "+l.data.message.to+" } failed",this._setInterfaceUpLoad(g.default.ACCEPT).setCallType(o+1).setText(""+d).setEnd(),[2];case 8:return this.isGroupCall()&&(c=this._unHandledInviteeList.filter((function(t){return t!==h._userID})),this.setUnHandledInviteeList(c),d="callType: "+(o+1)+",\n conversationType: "+l.data.message.conversationType+",\n userId:{ "+this._userID+" } accept userId:{ "+l.data.message.to+" } succeeded",this._setInterfaceUpLoad(g.default.ACCEPT).setCallType(o+1).setText(d).setEnd()),[2,i(i({},a),l)]}}))}))},t.prototype.reject=function(){return r(this,void 0,void 0,(function(){var t,e,n,i,r,o,a;return s(this,(function(s){switch(s.label){case 0:return E.default.debug(S+".reject"),this._tsignalingClient.getInviteData()?(t=this._callStatus===m.CALL_STATUS.CONNECTED,E.default.log(S+".reject - status:"+t),e=this._tsignalingClient.getInviteData(),n=e.inviteID,i=e.inviteData,r=i.callType,E.default.debug(S+".reject - params","inviteID: "+n+",callType: "+r+",isBusy: "+t+"."),[4,this._tsignalingClient.reject({inviteID:n,callType:r,isBusy:t})]):(E.default.warn(S+".reject - there are no calls to reject"),[2]);case 1:return o=s.sent(),a="callType: "+(r+1)+",\n conversationType: "+o.data.message.conversationType+",\n userId:{ "+this._userID+" } reject userId:{ "+o.data.message.to+" } succeeded",this._setInterfaceUpLoad(g.default.REJECT).setCallType(r+1).setText(a).setEnd(),t||this._resetTRTCClient(),[2,o]}}))}))},t.prototype.hangup=function(){return r(this,void 0,void 0,(function(){var t,e,n;return s(this,(function(i){switch(i.label){case 0:if(E.default.log(S+". - callStatus:"+this._callStatus+" inviteID:"+this._inviterInviteID),this._callStatus===m.CALL_STATUS.CALLING&&0===this._inviterInviteID.length)throw new Error(S+".call/groupCall incomplete。please wait cancel");if(this._callStatus!==m.CALL_STATUS.CONNECTED)return[3,6];i.label=1;case 1:return i.trys.push([1,3,,5]),[4,this._trtcClient.leave()];case 2:return i.sent(),[3,5];case 3:return e=i.sent(),[4,this._resetTRTCClient()];case 4:throw i.sent(),console.error("hangup leave error",e),new Error(e);case 5:this._setInterfaceUpLoad(g.default.REJECT).setText("userId: "+this._userID+" hangup succeeded").setEnd(),i.label=6;case 6:return i.trys.push([6,8,,10]),[4,this._cancel()];case 7:return t=i.sent(),[3,10];case 8:return n=i.sent(),[4,this._resetTRTCClient()];case 9:throw i.sent(),E.default.error("leave _cancel",n),new Error(n);case 10:return[4,this._resetTRTCClient()];case 11:return i.sent(),[2,t]}}))}))},t.prototype._cancel=function(){return r(this,void 0,void 0,(function(){var t,e,n,i,r,o;return s(this,(function(s){switch(s.label){case 0:if(E.default.log("_cancel _inviterInviteID",this._inviterInviteID),0===this._inviterInviteID.length)return[2,{code:0,msg:"ok"}];t=[],s.label=1;case 1:s.trys.push([1,6,,7]),e=0,s.label=2;case 2:return e0?"结束通话,通话时长:"+l.formatDuration(n.call_end):0!==n.call_end&&n.room_id?"发起通话":"结束群聊";case m.ACTION_TYPE.CANCEL_INVITE:return"取消通话";case m.ACTION_TYPE.ACCEPT_INVITE:return"已接听";case m.ACTION_TYPE.REJECT_INVITE:return"拒绝通话";case m.ACTION_TYPE.INVITE_TIMEOUT:return"无应答";default:return""}},t.EVENT=p.EVENT,t.CALL_TYPE=m.CALL_TYPE,t}();e.default=w},function(t,e,n){"use strict";n.r(e),n.d(e,"default",(function(){return o}));const i=Function.prototype.apply,r=new WeakMap;function s(t){return r.has(t)||r.set(t,{}),r.get(t)}class o{constructor(t=null,e=console){const n=s(this);return n._events=new Set,n._callbacks={},n._console=e,n._maxListeners=null===t?null:parseInt(t,10),this}_addCallback(t,e,n,i){return this._getCallbacks(t).push({callback:e,context:n,weight:i}),this._getCallbacks(t).sort((t,e)=>t.weight>e.weight),this}_getCallbacks(t){return s(this)._callbacks[t]}_getCallbackIndex(t,e){return this._has(t)?this._getCallbacks(t).findIndex(t=>t.callback===e):null}_achieveMaxListener(t){return null!==s(this)._maxListeners&&s(this)._maxListeners<=this.listenersNumber(t)}_callbackIsExists(t,e,n){const i=this._getCallbackIndex(t,e),r=-1!==i?this._getCallbacks(t)[i]:void 0;return-1!==i&&r&&r.context===n}_has(t){return s(this)._events.has(t)}on(t,e,n=null,i=1){const r=s(this);if("function"!=typeof e)throw new TypeError(e+" is not a function");return this._has(t)?(this._achieveMaxListener(t)&&r._console.warn(`Max listeners (${r._maxListeners}) for event "${t}" is reached!`),this._callbackIsExists(...arguments)&&r._console.warn(`Event "${t}" already has the callback ${e}.`)):(r._events.add(t),r._callbacks[t]=[]),this._addCallback(...arguments),this}once(t,e,n=null,r=1){const s=(...r)=>(this.off(t,s),i.call(e,n,r));return this.on(t,s,n,r)}off(t,e=null){const n=s(this);let i;return this._has(t)&&(null===e?(n._events.delete(t),n._callbacks[t]=null):(i=this._getCallbackIndex(t,e),-1!==i&&(n._callbacks[t].splice(i,1),this.off(...arguments)))),this}emit(t,...e){return this._has(t)&&this._getCallbacks(t).forEach(t=>i.call(t.callback,t.context,e)),this}clear(){const t=s(this);return t._events.clear(),t._callbacks={},this}listenersNumber(t){return this._has(t)?this._getCallbacks(t).length:null}}},function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}l((i=i.apply(t,e||[])).next())}))},r=this&&this.__generator||function(t,e){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)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 o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]=0?g.checkSystemRequirements().then((function(t){if(!t.result)throw e._trtcCalling._delegate.onError(f.default.NOT_SUPPORT,t),new Error(_+".当前页面不具备 webRTC 能力"+JSON.stringify(t))})):g.checkSystemRequirements().then((function(t){if(!t)throw e._trtcCalling._delegate.onError(f.default.NOT_SUPPORT,t),new Error(_+".当前页面不具备 webRTC 能力"+JSON.stringify(t))})),this.init()}return t.prototype.init=function(){this._client=g.createClient({mode:"rtc",sdkAppId:this._sdkAppID,userId:this._userID,userSig:this._userSig,frameWorkType:32}),this.handleEvents()},t.prototype.getRemoteStreams=function(){return this._remoteStreams},t.prototype.getMicrophoneList=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return[4,g.getMicrophones()];case 1:return t=e.sent(),this._device.microphoneList=t,[2]}}))}))},t.prototype.getCamerasList=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return[4,g.getCameras()];case 1:return t=e.sent(),this._device.cameraList=t,[2]}}))}))},t.prototype.getDevices=function(t){return i(this,void 0,void 0,(function(){var e=this;return r(this,(function(n){switch(n.label){case 0:return[4,this.getMicrophoneList()];case 1:return n.sent(),0===this._device.microphoneList.length?(this._trtcCalling._delegate.onError(f.default.NOT_MICROPHONE_LIST,p.default.NOT_MICROPHONE_LIST),this._trtcCalling._resetTRTCClient(),[2]):(this._device.audio=JSON.parse(JSON.stringify(this._device.microphoneList[0])),t===l.CALL_TYPE.VIDEO_CALL&&this._trtcCalling.getDevicePermission().video?[4,this.getCamerasList()]:[3,3]);case 2:n.sent(),this._device.video=JSON.parse(JSON.stringify(this._device.cameraList[0])),n.label=3;case 3:return this._prevDevices.length>0||(this._prevDevices=s(this._device.microphoneList,this._device.cameraList),navigator.mediaDevices.addEventListener("devicechange",(function(){return i(e,void 0,void 0,(function(){var t,e,n,i,o,a=this;return r(this,(function(r){switch(r.label){case 0:return[4,g.getMicrophones()];case 1:return t=r.sent(),[4,g.getCameras()];case 2:return e=r.sent(),n=s(t,e),this.setDevcies(n),i=n.filter((function(t){return a._prevDevices.findIndex((function(e){var n=e.deviceId;return t.deviceId===n}))<0})),o=this._prevDevices.filter((function(t){return n.findIndex((function(e){var n=e.deviceId;return t.deviceId===n}))<0})),i.length>0&&this.handleDevices(i),o.length>0&&this.handleDevicesRemoved(o),this._trtcCalling._delegate.onDeviceUpdated(this._device.microphoneList,this._device.cameraList,this._device.audio,this._device.video),this._prevDevices=n,[2]}}))}))}))),[2]}}))}))},t.prototype.setDevcies=function(t){this._device.microphoneList=t.filter((function(t){return"audioinput"===t.kind}))||[],this._device.cameraList=t.filter((function(t){return"videoinput"===t.kind}))||[]},t.prototype.handleDevices=function(t,e){var n=this;t.forEach((function(t){"audioinput"===t.kind?n.switchDevice(l.DEVICE_TYPE.AUDIO,t.deviceId):"videoinput"===t.kind&&e&&n.switchDevice(l.DEVICE_TYPE.VIDEO,t.deviceId)}))},t.prototype.handleDevicesRemoved=function(t){var e=this;t.forEach((function(t){"audioinput"===t.kind?e.isCurrentMicrophoneRemoved(t.deviceId)&&e.handleDevices(e._prevDevices):"videoinput"===t.kind&&e.isCurrentCameraRemoved(t.deviceId)&&e.handleDevices(e._prevDevices,!0)}))},t.prototype.isCurrentMicrophoneRemoved=function(t){var e=this._localStream.getAudioTrack();return!(!e||e.getSettings().deviceId!==t)},t.prototype.isCurrentCameraRemoved=function(t){var e=this._localStream.getVideoTrack();return!(!e||e.getSettings().deviceId!==t)},t.prototype.switchDevice=function(t,e){return i(this,void 0,void 0,(function(){var n;return r(this,(function(i){return a.default.log(_+".switchDevice - params: deviceType:"+t+",deviceID:"+e),this._localStream&&this._localStream.switchDevice(t,e),n={deviceType:t,deviceId:e},this._device[t]=n,this._trtcCalling._delegate.onDeviceUpdated(this._device.microphoneList,this._device.cameraList,this._device.audio,this._device.video),[2]}))}))},t.prototype.join=function(t){var e,n;return i(this,void 0,void 0,(function(){var i,s,o,u;return r(this,(function(r){switch(r.label){case 0:return(i=this.getCallType())!==l.CALL_TYPE.VIDEO_CALL||this._trtcCalling.getDevicePermission().video?[3,2]:[4,this.getMediaDevicesAuth({video:!0})];case 1:r.sent(),r.label=2;case 2:return[4,this.getDevices(i)];case 3:if(r.sent(),this._isJoined)return a.default.warn(_+".join - duplicate RtcClient.join() observed"),[2];r.label=4;case 4:return r.trys.push([4,6,,7]),[4,this._client.join({roomId:~~t})];case 5:return r.sent(),this._isJoined=!0,a.default.log(_+".join - join room success, callType:"+i),[3,7];case 6:throw s=r.sent(),a.default.error(_+".join - join room failed! "+s),new Error(_+".join - join room failed! "+s);case 7:if(this._trtcCalling.getCallStatus()===l.CALL_STATUS.IDLE)return a.default.warn(_+".join - early hangup"),[2,this._trtcCalling.hangup()];o={audio:!0,video:!1,userId:this._userID},i===l.CALL_TYPE.VIDEO_CALL&&(null===(n=null===(e=this._device)||void 0===e?void 0:e.video)||void 0===n?void 0:n.deviceId)&&(o.video=!0),this._localStream=g.createStream(o),this._localStream.setVideoProfile(this._trtcCalling.getVideoQuality()),r.label=8;case 8:return r.trys.push([8,11,,12]),[4,this._localStream.initialize()];case 9:return r.sent(),a.default.log(_+".join - initialize local stream success"),this._localStream.on("player-state-changed",(function(t){a.default.log(_+".join - local stream "+t.type+" player is "+t.state)})),[4,this.publish()];case 10:return r.sent(),a.default.log(_+".publish success"),this._joinedTimestamp=new Date,[2,{audio:o.audio,video:o.video,userId:o.userId}];case 11:throw u=r.sent(),a.default.error(_+".join - failed to initialize local stream - "+u),new Error(_+".join - failed to initialize local stream - "+u);case 12:return[2]}}))}))},t.prototype.playVideo=function(t){var e,n;a.default.debug(_+".playVideo - params:",t);var i=t.domID,r=t.type,s=t.userID,o=t.options;if("local"===r&&(null===(e=null==this?void 0:this._localStream)||void 0===e||e.on("player-state-changed",(function(t){console.warn(t.type+" player is "+t.state+" because of "+t.reason)})),null===(n=null==this?void 0:this._localStream)||void 0===n||n.play(i,o)),"remote"===r){var l=this._remoteStreams.find((function(t){return t.getUserId()===s}));l&&(null==l||l.play(i,o))}},t.prototype.stopVideo=function(t){a.default.debug(_+".stopVideo - params:",t);var e=t.type,n=t.userID;if("local"===e&&this._localStream.stop(),"remote"===e){var i=this._remoteStreams.find((function(t){return t.getUserId()===n}));i&&i.stop()}},t.prototype.getCallType=function(){return this._trtcCalling.getCallType()},t.prototype.leave=function(){var t,e;return i(this,void 0,void 0,(function(){var n;return r(this,(function(i){switch(i.label){case 0:return a.default.log(_+"-leave._isJoined:"+this._isJoined),a.default.log(_+"-leave._localStream:"+this._localStream),this._isJoined?[4,this.unpublish()]:(a.default.warn(_+".leave - please join() firstly"),[2]);case 1:return i.sent(),[4,this._client.leave()];case 2:return i.sent(),this._isJoined=!1,null===(t=null==this?void 0:this._localStream)||void 0===t||t.close(),null===(e=null==this?void 0:this._localStream)||void 0===e||e.stop(),this._localStream=null,this._leaveTimestamp=new Date,this._client.enableAudioVolumeEvaluation(-1),n=Math.floor((this._leaveTimestamp-this._joinedTimestamp)/1e3),new c.default(d.default.TALK_TIME).setTalkTime(n).setText("talkTime record").setEnd(),[2]}}))}))},t.prototype.publish=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:if(!this._isJoined)return a.default.warn(_+".publish - please join() firstly"),[2];if(this._isPublished)return a.default.warn(_+".publish - duplicate RtcClient.publish() observed"),[2];if(this._trtcCalling.getCallStatus()===l.CALL_STATUS.IDLE)return a.default.warn(_+".join - early hangup"),this._trtcCalling.hangup(),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this._client.publish(this._localStream)];case 2:return e.sent(),a.default.log(_+".publish - success"),[3,4];case 3:return t=e.sent(),a.default.error(_+".publish - failed to publish local stream "+t),this._isPublished=!1,[3,4];case 4:return this._isPublished=!0,[2]}}))}))},t.prototype.unpublish=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return this._isPublished?this._localStream?this._unpublishing?(a.default.log(_+".unpublish - _unpublishing"),[2]):(this._unpublishing=!0,[4,this._client.unpublish(this._localStream)]):(a.default.warn(_+".unpublish - RtcClient._localStream is null"),[2]):(a.default.warn(_+".unpublish - RtcClient.unpublish() called but not published yet"),[2]);case 1:return t.sent(),a.default.log(_+".unpublish - complete"),this._unpublishing=!1,this._isPublished=!1,[2]}}))}))},t.prototype.handleEvents=function(){var t=this;this._client.on("error",(function(e){a.default.error(_+".handleEvents - client on error "+e);var n=e.getCode(),i=JSON.stringify({name:"TRTC",error:e});t._trtcCalling._delegate.onError(n,i)})),this._client.on("client-banned",(function(e){a.default.error(_+".handleEvents - client has been banned for "+e);var n=e.getCode(),i=JSON.stringify({name:"TRTC",error:e});t._trtcCalling._delegate.onError(n,i),t._trtcCalling.hangup()})),this._client.on("peer-join",(function(e){var n=e.userId;if(a.default.log(_+".handleEvents - peer-join "+n),t._connectStartTime||(t._connectStartTime=Date.now(),t._client.enableAudioVolumeEvaluation(1e3)),t._trtcCalling.isGroupCall()){var i=t._trtcCalling.getHandledInviteeList(),r=s(i,[n]);t._trtcCalling.setHandledInviteeList(r),t._trtcCalling._delegate.onGroupCallInviteeListUpdate(r)}})),this._client.on("peer-leave",(function(e){return i(t,void 0,void 0,(function(){var t,n,i,s,o;return r(this,(function(r){switch(r.label){case 0:return t=e.userId,n=this._remoteStreams.filter((function(e){return e.getUserId()!==t})),i=this._trtcCalling.getHandledInviteeList(),s=this._trtcCalling.isGroupCall(),a.default.log(_+".handleEvents - peer-leave isGroupCall:"+s+" userID:"+t+",\n remainStreamsCount:"+n.length+" unHandledListLength:"+i.length),s&&0!==i.length&&(o=i.filter((function(e){return e!==t})),this._trtcCalling.setUnHandledInviteeList(o),this._trtcCalling._delegate.onGroupCallInviteeListUpdate(o)),0!==n.length?[3,4]:[4,this.leave()];case 1:return r.sent(),[4,this._trtcCalling._tsignalingClient.lastOneHangup({userIDList:[t],callType:this.getCallType(),callEnd:Math.round((Date.now()-this._connectStartTime)/1e3)})];case 2:return r.sent(),[4,this._trtcCalling._resetTRTCClient()];case 3:r.sent(),this._connectStartTime=0,r.label=4;case 4:return[2]}}))}))})),this._client.on("stream-added",(function(e){return i(t,void 0,void 0,(function(){var t,n,i;return r(this,(function(r){switch(r.label){case 0:t=e.stream,n=t.getId(),i=t.getUserId(),a.default.log(_+".handleEvents - remote stream added, userID:"+i+" streamID:"+n+" type:"+t.getType()),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._client.subscribe(t)];case 2:return r.sent(),[3,4];case 3:return r.sent(),0===this._remoteStreams.length&&this._trtcCalling.hangup(),[3,4];case 4:return[2]}}))}))})),this._client.on("stream-subscribed",(function(e){return i(t,void 0,void 0,(function(){var t,n,i,s,o;return r(this,(function(r){return t=e.stream,this._remoteStreams.push(t),n=t.getUserId(),this._trtcCalling._delegate.onUserEnter(n),i="_trtc_calling_audio_call-"+n,a.default.log(_+".handleEvents - stream subscribed, _remoteStreams:"+this._remoteStreams),a.default.log(_+".handleEvents - stream subscribed, userID:"+n),this.getCallType()===l.CALL_TYPE.AUDIO_CALL&&((s=document.getElementById("_trtc_calling_layer"))||((s=document.createElement("div")).setAttribute("id","_trtc_calling_layer"),s.style.display="none",document.body.appendChild(s)),(o=document.createElement("div")).setAttribute("id",i),s.appendChild(o),null==t||t.play(i),t.on("error",(function(e){if(16451===e.getCode()){var n=document.createElement("button");n.onclick=function(){a.default.log(_+".remoteStream - resume"),t.resume()},n.style.display="none",document.body.appendChild(n);var i=setTimeout((function(){n.click(),clearTimeout(i),document.body.removeChild(n)}),0)}}))),[2]}))}))})),this._client.on("stream-removed",(function(e){var n=e.stream,i=n.getId(),r=n.getUserId(),s="_trtc_calling_audio_call-"+r;if(n.stop(),n.close(),t._remoteStreams=t._remoteStreams.filter((function(t){return t.getId()!==i})),t._trtcCalling._delegate.onUserLeave(r),t.getCallType()===l.CALL_TYPE.AUDIO_CALL){var o=document.getElementById("_trtc_calling_layer"),u=document.getElementById(s);o&&u&&o.removeChild(u)}a.default.log(_+".handleEvents - remote stream-removed, streamID:"+i+" type:"+n.getType())})),this._client.on("stream-updated",(function(t){var e=t.stream,n=e.getType(),i=e.hasAudio(),r=e.hasVideo();a.default.log(_+".handleEvents - stream-updated, type:"+n+" hasAudio:"+i+" hasVideo:"+r)})),this._client.on("mute-audio",(function(e){a.default.debug(_+".handleEvents - "+e.userId+" mute audio"),t._trtcCalling._delegate.onUserAudioAvailable({userID:e.userId,isAudioAvailable:!1})})),this._client.on("unmute-audio",(function(e){a.default.debug(_+".handleEvents - "+e.userId+" unmute audio"),t._trtcCalling._delegate.onUserAudioAvailable({userID:e.userId,isAudioAvailable:!0})})),this._client.on("mute-video",(function(e){a.default.debug(_+".handleEvents - "+e.userId+" mute video"),t._trtcCalling._delegate.onUserVideoAvailable({userID:e.userId,isVideoAvailable:!1})})),this._client.on("unmute-video",(function(e){a.default.debug(_+".handleEvents - "+e.userId+" unmute video"),t._trtcCalling._delegate.onUserVideoAvailable({userID:e.userId,isVideoAvailable:!0})})),this._client.on("audio-volume",(function(e){a.default.debug(_+".handleEvents - "+e+" audio volume"),t._trtcCalling._delegate.onUserVoiceVolume(e.result)})),this._client.on("connection-state-changed",(function(t){a.default.log(_+".handleEvents - RtcClient state changed from "+t.prevState+" to "+t.state)}))},t.prototype.muteLocalVideo=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){return[2,this._localStream.muteVideo()]}))}))},t.prototype.unMuteLocalVideo=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:if(t=this._localStream.getVideoTrack())return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.addTrack(t)];case 2:return e.sent(),[2,!0];case 3:return e.sent(),this._trtcCalling._delegate.onError(f.default.NOT_CAMERA_LIST,p.default.NOT_CAMERA_LIST),[3,4];case 4:return[3,6];case 5:return[2,this._localStream.unmuteVideo()];case 6:return[2]}}))}))},t.prototype.muteLocalAudio=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){return[2,this._localStream.muteAudio()]}))}))},t.prototype.unMuteLocalAudio=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){return[2,this._localStream.unmuteAudio()]}))}))},t.prototype.switchCallMode=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:switch(a.default.log(_+".switchCallMode - type",t),e=this._localStream.getVideoTrack(),t){case l.CALL_TYPE.VIDEO_CALL:return[3,1];case l.CALL_TYPE.AUDIO_CALL:return[3,2]}return[3,6];case 1:try{this.removeTrack(e),this._trtcCalling.setCallType(l.CALL_TYPE.AUDIO_CALL),this._trtcCalling.setSwitchCallModeStatus(!0),this._trtcCalling._delegate.onCallTypeChanged(l.CALL_TYPE.VIDEO_CALL,l.CALL_TYPE.AUDIO_CALL)}catch(t){this._trtcCalling._delegate.onError(f.default.FAILURE_SWITCH_TO_AUDIO,p.default.FAILURE_SWITCH_TO_AUDIO)}return[3,6];case 2:return n.trys.push([2,4,,5]),[4,this.addTrack(e)];case 3:return n.sent(),this._trtcCalling.setCallType(l.CALL_TYPE.VIDEO_CALL),this._trtcCalling.setSwitchCallModeStatus(!0),this._trtcCalling._delegate.onCallTypeChanged(l.CALL_TYPE.AUDIO_CALL,l.CALL_TYPE.VIDEO_CALL),[3,5];case 4:return n.sent(),this._trtcCalling._delegate.onError(f.default.FAILURE_SWITCH_TO_VIDEO,p.default.FAILURE_SWITCH_TO_VIDEO),[3,5];case 5:return[3,6];case 6:return[2]}}))}))},t.prototype.removeTrack=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:if(a.default.log(_+".removeTrack ",!!t),!t)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._localStream.removeTrack(t)];case 2:return n.sent(),t.stop(),[3,4];case 3:throw e=n.sent(),a.default.error(_+".removeTrack - failed to removeTrack local stream "+e),new Error(e);case 4:return[2]}}))}))},t.prototype.addTrack=function(t){return i(this,void 0,void 0,(function(){var e,n,i;return r(this,(function(r){switch(r.label){case 0:return a.default.log(_+".addTrack ",!t),t?[3,5]:[4,(e=g.createStream({userId:this._trtcCalling.getUserID(),audio:!1,video:!0})).initialize()];case 1:r.sent(),n=e.getVideoTrack(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this._localStream.addTrack(n)];case 3:return r.sent(),[3,5];case 4:throw i=r.sent(),a.default.error(_+".addTrack - failed to addTrack local stream "+i),new Error(i);case 5:return[2]}}))}))},t.prototype.reset=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return this._isJoined?[4,this.leave()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.getMediaDevicesAuth=function(t){return i(this,void 0,void 0,(function(){var e,n,i;return r(this,(function(r){switch(r.label){case 0:if(!t.audio)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({audio:!0,video:!1})];case 2:return n=r.sent(),this.releaseStream(n),this._trtcCalling.setDevicePermission(l.DEVICE_TYPE.AUDIO,!0),[3,4];case 3:throw e=r.sent(),this._trtcCalling.setDevicePermission(l.DEVICE_TYPE.AUDIO,!1),new Error(e);case 4:if(!t.video)return[3,8];r.label=5;case 5:return r.trys.push([5,7,,8]),[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 6:return n=r.sent(),this.releaseStream(n),this._trtcCalling.setDevicePermission(l.DEVICE_TYPE.VIDEO,!0),[3,8];case 7:if(i=r.sent(),this._trtcCalling.setDevicePermission(l.DEVICE_TYPE.VIDEO,!1),a.default.error(_+".getMediaDevicesAuth - failed to get user video steam - "+i),t.isThrowVideoError)throw new Error(i);return[3,8];case 8:return[2]}}))}))},t.prototype.releaseStream=function(t){for(var e=t.getTracks(),n=0;n1)for(var n=1;n=0)return;o[e]="set-cookie"===e?(o[e]?o[e]:[]).concat([n]):o[e]?o[e]+", "+n:n}})),o):o}},function(t,e,n){"use strict";var i=n(2);t.exports=i.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(t){var i=t;return e&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=r(window.location.href),function(e){var n=i.isString(e)?r(e):e;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0}},function(t,e,n){"use strict";var i=n(20);function r(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var n=this;t((function(t){n.reason||(n.reason=new i(t),e(n.reason))}))}r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var t;return{token:new r((function(e){t=e})),cancel:t}},t.exports=r},function(t,e,n){"use strict";t.exports=function(t){return function(e){return t.apply(null,e)}}},function(t,e,n){"use strict";t.exports=function(t){return"object"==typeof t&&!0===t.isAxiosError}},function(t,n){t.exports=e},function(t,e,n){"use strict";var i=this&&this.__assign||function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]=2||(null===(e=null==_?void 0:_.data)||void 0===e?void 0:e.userIDs)&&_.data.userIDs.length>=2),(null===(n=null==_?void 0:_.data)||void 0===n?void 0:n.cmd)===u.CMD_TYPE.HANG_UP)return l.default.log(d+".hangup - params:",_),0===this._trtcCalling.getHandledInviteeList().length&&this._trtcCalling._delegate.onCallEnd(o,_.call_end||0),[2];if(!p&&this.judgeSwitchCallMode(_))return this.handleSwitchCallMode(f,_),[2];if(this._isOnACall()||i===u.CALL_STATUS.CALLING)return this.reject({inviteID:f,callType:_.call_type,isBusy:!0}),[2];if(this._trtcCalling.setInviterID(o),g&&(this._trtcCalling.setIsGroupCall(g),this._trtcCalling.setInviteeList(a),this._trtcCalling.setUnHandledInviteeList(a),this._trtcCalling.setGroupID(p)),this._trtcCalling.changeCallStatus(u.CALL_STATUS.CALLING),this._newInvitationData={sponsor:o,userIDList:a,isFromGroup:g,inviteID:f,inviteData:{version:_.version,callType:_.call_type,callEnd:0,roomID:_.room_id}},this._trtcCalling.getDevicePermission().audio)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._trtcCalling._trtcClient.getMediaDevicesAuth({audio:!0})];case 2:return s.sent(),[3,4];case 3:throw I=s.sent(),this._trtcCalling._delegate.onError(c.default.NOT_MEDIA_ACCESS,JSON.stringify(I)),l.default.error("onNewInvitationReceived getUserMedia failure "+JSON.stringify(I)+". reject remote invite"),this._trtcCalling.reject();case 4:return this._trtcCalling._delegate.onInvited(this._newInvitationData),[2]}}))}))},t.prototype.getInviteData=function(){return this._newInvitationData},t.prototype.setInviteData=function(t){this._newInvitationData=t},t.prototype.handleSwitchCallMode=function(t,e){var n={inviteID:t,callType:e.call_type,switch_to_audio_call:null},i={cmd:u.CMD_TYPE.SWITCH_TO_VIDEO};if(e.call_type===u.CALL_TYPE.VIDEO_CALL?(n.switch_to_audio_call=u.CMD_TYPE.SWITCH_TO_AUDIO_CALL,i.cmd=u.CMD_TYPE.SWITCH_TO_AUDIO):delete n.switch_to_audio_call,this.accept(n,i),this._trtcCalling.getCallStatus()===u.CALL_STATUS.CALLING){var r=e.call_type===u.CALL_TYPE.VIDEO_CALL?u.CALL_TYPE.AUDIO_CALL:u.CALL_TYPE.VIDEO_CALL;this._newInvitationData.inviteData.callType=r}else this._isOnACall()&&(this._trtcCalling.setSwitchCallModeStatus(!1),this._trtcCalling._trtcClient.switchCallMode(this._trtcCalling.getCallType()))},t.prototype.judgeSwitchCallMode=function(t){var e=t.switch_to_audio_call&&t.switch_to_audio_call===u.CMD_TYPE.SWITCH_TO_AUDIO_CALL||t.data&&t.data.cmd===u.CMD_TYPE.SWITCH_TO_AUDIO||t.data&&t.data.cmd===u.CMD_TYPE.SWITCH_TO_VIDEO;return l.default.log(d+".switchCallMode:",t,"isSwitchCallMode-"+e),e},t.prototype.onInviteeAccepted=function(t){l.default.log(d+".onInviteeAccepted - params:",t);var e=JSON.parse(t.data.data);if(this._trtcCalling.isGroupCall()||!this.judgeSwitchCallMode(e)||this._trtcCalling.getSwitchCallModeStatus()){this._trtcCalling._delegate.onUserAccept(this._trtcCalling.getUserID()),this._trtcCalling.delInviterInviteID(t.data.inviteID);var n=t.data.invitee;if(this._trtcCalling.isGroupCall()){var i=this._trtcCalling.getUnHandledInviteeList().filter((function(t){return t!==n}));this._trtcCalling.setUnHandledInviteeList(i)}return n===this._trtcCalling.getUserID()&&this._trtcCalling.getCallStatus()===u.CALL_STATUS.CONNECTED?(this._trtcCalling._resetTRTCClient(),void this._trtcCalling._delegate.onReject(this._trtcCalling.getInviterID())):void 0}this._trtcCalling._trtcClient.switchCallMode(this._trtcCalling.getCallType())},t.prototype.onInviteeRejected=function(t){var e;if(!this._trtcCalling.isGroupCall()&&!this._trtcCalling.getSwitchCallModeStatus())return l.default.log(d+".onInviteeRejected - Audio and video switching is not available"),void this._trtcCalling.setSwitchCallModeStatus(!0);l.default.log(d+".onInviteeRejected - params:",t);var n=t.data.invitee,i=t.data.inviter,r=t.data.inviteID,s=JSON.parse(t.data.data);if("line_busy"===s.line_busy||""===s.line_busy||(null===(e=null==s?void 0:s.data)||void 0===e?void 0:e.message)&&"lineBusy"===s.data.message?this._trtcCalling._delegate.onLineBusy(i,n):this._trtcCalling._delegate.onReject(n),this._trtcCalling.delInviterInviteID(r),this._trtcCalling.isGroupCall()){var o=this._trtcCalling.getUnHandledInviteeList();o=o.filter((function(t){return t!==n})),this._trtcCalling.setUnHandledInviteeList(o),0===o.length&&(this._trtcCalling.getCallStatus()===u.CALL_STATUS.CALLING&&this._trtcCalling._resetTRTCClient(),this._trtcCalling.getCallStatus()===u.CALL_STATUS.CONNECTED&&(this._trtcCalling.hasRemoteConnectedUsers()||(this._trtcCalling._delegate.onCallEnd(n,0),this._trtcCalling._resetTRTCClient())))}else this._trtcCalling._resetTRTCClient()},t.prototype.onInvitationCancelled=function(t){l.default.log(d+".onInvitationCancelled - params:",t),this._trtcCalling._delegate.onCallingCancel(),this._trtcCalling._resetTRTCClient()},t.prototype.onInvitationTimeout=function(t){var e=t.data,n=e.inviter,i=e.inviteeList,r=e.isSelfTimeout,s=this._trtcCalling.getUserID(),o=this._trtcCalling.isGroupCall(),a=n===s,c=this._isOnACall(),h=this._trtcCalling.getRemoteStreamCount();if(l.default.log(d+".onInvitationTimeout - params:",t,"currentUserID:"+s+" isInviter:"+a+" isGroupCall:"+o+" isOnACall:"+c+" remoteStreamCount:"+h),this._trtcCalling.delInviterInviteID(t.data.inviteID),r&&a)return this._trtcCalling._delegate.onNoResp(n,i),void(o&&0!==h||this._trtcCalling._resetTRTCClient());if(this._trtcCalling._delegate.onCallingTimeout(n,i),o){var f=this._trtcCalling.getUnHandledInviteeList(),p=[];f.forEach((function(t){-1===i.indexOf(t)&&p.push(t)})),this._trtcCalling.setUnHandledInviteeList(p),0===h&&0===p.length&&(c?this.lastOneHangup({userIDList:[n],callType:this._trtcCalling.getCallType(),callEnd:0}):this._trtcCalling.changeCallStatus(u.CALL_STATUS.IDLE),this._trtcCalling._resetTRTCClient())}else this._trtcCalling._resetTRTCClient(),this._trtcCalling.changeCallStatus(u.CALL_STATUS.IDLE)},t.prototype._isOnACall=function(){return this._trtcCalling.getCallStatus()===u.CALL_STATUS.CONNECTED},t.prototype.onKickedOut=function(){l.default.debug(d+".onKickedOut"),this._trtcCalling._delegate.onKickedOut(),this._trtcCalling.changeCallStatus(u.CALL_STATUS.IDLE)},t.prototype.onNetStateChange=function(){l.default.debug(d+".onNetStateChange")},t.prototype.login=function(t){return r(this,void 0,void 0,(function(){var e=this;return s(this,(function(n){return[2,new Promise((function(n,i){e._tsignaling.login(t).then((function(t){e._resolveMap.set("login",{resolve:n,value:t})})).catch((function(t){i(t)}))}))]}))}))},t.prototype.logout=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){return this._joined=!1,[2,this._tsignaling.logout()]}))}))},t.prototype.invite=function(t){return r(this,void 0,void 0,(function(){var e,n,r,o,a,l,c,d;return s(this,(function(s){switch(s.label){case 0:return e=t.userID,n=t.type,r=t.roomID,o=t.timeout,a=t.offlinePushInfo,l=t.userIDList,c={},this._trtcCalling.isGroupCall()||!this._trtcCalling.isInviter()||this._joined||this._trtcCalling.getCallStatus()!==u.CALL_STATUS.CALLING?[3,2]:[4,this._trtcCalling._trtcClient.join(this._trtcCalling._roomID)];case 1:c=s.sent(),this._trtcCalling.changeCallStatus(u.CALL_STATUS.CONNECTED),this._joined=!0,s.label=2;case 2:return[4,this._tsignaling.invite({userID:e,data:JSON.stringify(this.handleNewSignaling({version:0,call_type:n,room_id:r},{userIDs:l})),timeout:o,offlinePushInfo:a})];case 3:return d=s.sent(),[2,i(i(i({},c),d),{roomID:r,userID:e})]}}))}))},t.prototype.inviteInGroup=function(t){return r(this,void 0,void 0,(function(){var e,n,r,o,a,l,c,d;return s(this,(function(s){switch(s.label){case 0:return e=t.groupID,n=t.userIDList,r=t.roomID,o=t.type,a=t.timeout,l=t.offlinePushInfo,c={},!this._trtcCalling.isInviter()||this._joined||this._trtcCalling.getCallStatus()!==u.CALL_STATUS.CALLING?[3,2]:[4,this._trtcCalling._trtcClient.join(this._trtcCalling._roomID)];case 1:c=s.sent(),this._trtcCalling.changeCallStatus(u.CALL_STATUS.CONNECTED),this._joined=!0,s.label=2;case 2:return d=null,e?[3,4]:[4,this.inviteInGroupTRTC(t)];case 3:return d=s.sent(),[3,6];case 4:return[4,this._tsignaling.inviteInGroup({groupID:e,inviteeList:n,data:JSON.stringify(this.handleNewSignaling({version:0,call_type:o,room_id:r})),timeout:a,offlinePushInfo:l})];case 5:d=s.sent(),s.label=6;case 6:return[2,i(i(i({},c),d),{roomID:r,groupID:e})]}}))}))},t.prototype.inviteInGroupTRTC=function(t){return r(this,void 0,void 0,(function(){var e,n,i,r,o,a,l,u,c,d=this;return s(this,(function(s){switch(s.label){case 0:e=t.userIDList,n=t.roomID,i=t.type,r=t.timeout,o=t.offlinePushInfo,a={code:0,data:[],error:null},s.label=1;case 1:return s.trys.push([1,3,,4]),l=e.map((function(t){return d.invite({userID:t,type:i,roomID:n,timeout:r,offlinePushInfo:o,userIDList:e})})),[4,Promise.all(l)];case 2:return u=s.sent(),a.data=u,delete a.error,[3,4];case 3:return c=s.sent(),a.code=1,a.error=c,[3,4];case 4:return[2,a]}}))}))},t.prototype.lastOneHangup=function(t){return r(this,void 0,void 0,(function(){var e,n,i;return s(this,(function(r){switch(r.label){case 0:return l.default.log(d+".lastOneHangup - params:",t),e=t.userIDList,n=t.callType,i=t.callEnd,this._trtcCalling.isGroupCall()&&this._trtcCalling.getGroupID()?[4,this._tsignaling.inviteInGroup({inviteeList:e,groupID:this._trtcCalling.getGroupID(),data:JSON.stringify(this.handleNewSignaling({version:0,call_type:n,call_end:i},{cmd:u.CMD_TYPE.HANG_UP})),timeout:0})]:[3,2];case 1:return r.sent(),[3,4];case 2:return[4,this._tsignaling.invite({userID:e[0],data:JSON.stringify(this.handleNewSignaling({version:0,call_type:n,call_end:i},{cmd:u.CMD_TYPE.HANG_UP})),timeout:0})];case 3:r.sent(),r.label=4;case 4:return this._joined=!1,this._trtcCalling._delegate.onCallEnd(this._trtcCalling.getInviterID(),i),[2]}}))}))},t.prototype.accept=function(t,e){return r(this,void 0,void 0,(function(){var n,r,a;return s(this,(function(s){switch(s.label){case 0:return n=t.inviteID,r=t.callType,a=o(t,["inviteID","callType"]),[4,this._tsignaling.accept({inviteID:n,data:JSON.stringify(this.handleNewSignaling(i({version:0,call_type:r},a),e))})];case 1:return[2,s.sent()]}}))}))},t.prototype.reject=function(t){return r(this,void 0,void 0,(function(){var e,n,i,r;return s(this,(function(s){return e=t.inviteID,n=t.callType,i=t.isBusy,r={version:0,call_type:n},i&&(r.line_busy="line_busy"),[2,this._tsignaling.reject({inviteID:e,data:JSON.stringify(this.handleNewSignaling(r,{message:i?"lineBusy":""}))})]}))}))},t.prototype.cancel=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){return e=t.inviteID,[2,this._tsignaling.cancel({inviteID:e,data:JSON.stringify(this.handleNewSignaling({version:4,businessID:"av_call",call_type:this._trtcCalling.getCallType()}))})]}))}))},t.prototype.resetJoined=function(){this._joined=!1},t.prototype.switchCallMode=function(t){return r(this,void 0,void 0,(function(){var e,n,i,r,o,a,l;return s(this,(function(s){return e=t.userID,n=t.call_type,i=t.roomID,r=t.timeout,o=t.mode,a={version:0,call_type:n,room_id:i,switch_to_audio_call:null},l={cmd:u.CMD_TYPE.SWITCH_TO_VIDEO},o===u.MODE_TYPE.AUDIO?(a.switch_to_audio_call=u.CMD_TYPE.SWITCH_TO_AUDIO_CALL,l.cmd=u.CMD_TYPE.SWITCH_TO_AUDIO):delete a.switch_to_audio_call,[2,this._tsignaling.invite({userID:e,data:JSON.stringify(this.handleNewSignaling(a,l)),timeout:r})]}))}))},t.prototype.handleNewSignaling=function(t,e){return i(i({extraInfo:""},t),{version:4,businessID:"av_call",platform:"Web",data:i({cmd:u.CMD_TYPE_LIST[t.call_type],room_id:t.room_id,message:""},e)})},t}();e.default=h},function(t,e){t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(21),r=n(0),s=n(6),o=n(8),a=n(9),l="TRTCCallingDelegate",u=function(){function t(t){this._eventEmitter=t,this._eventStatController=new a.default,s.default.bindController(this._eventStatController)}return t.prototype._setInterfaceUpLoad=function(t){return r.default.time(t),new s.default(t)},t.prototype.onError=function(t,e){r.default.debug(l+".onError code:"+t+" msg:"+e),this._eventEmitter.emit(i.EVENT.ERROR,{code:t,msg:e}),this._setInterfaceUpLoad(o.default.ERROR).setText("").setEnd()},t.prototype.onSdkReady=function(t){r.default.debug(l+".onSdkReady params:"+t),this._eventEmitter.emit(i.EVENT.SDK_READY,t),this._setInterfaceUpLoad(o.default.SDK_READY).setText("").setEnd()},t.prototype.onInvited=function(t){r.default.debug(l+".onInvited params:",t);var e=t.sponsor,n=t.userIDList,s=t.isFromGroup,a=t.inviteData,u=t.inviteID;this._eventEmitter.emit(i.EVENT.INVITED,{sponsor:e,userIDList:n,isFromGroup:s,inviteData:a,inviteID:u}),this._setInterfaceUpLoad(o.default.INVITED).setText("EVENT.INVITED emitted").setEnd()},t.prototype.onUserAccept=function(t){r.default.debug(l+".onUserAccept userID:"+t),this._eventEmitter.emit(i.EVENT.USER_ACCEPT,{userID:t})},t.prototype.onUserEnter=function(t){r.default.debug(l+".onUserEnter userID:"+t),this._eventEmitter.emit(i.EVENT.USER_ENTER,{userID:t}),this._setInterfaceUpLoad(o.default.USER_ENTER).setText("EVENT.USER_ENTER emitted").setEnd()},t.prototype.onUserLeave=function(t){r.default.debug(l+".onUserLeave userID:"+t),this._eventEmitter.emit(i.EVENT.USER_LEAVE,{userID:t}),this._setInterfaceUpLoad(o.default.USER_LEAVE).setText("EVENT.USER_LEAVE emitted").setEnd()},t.prototype.onReject=function(t){r.default.debug(l+".onReject userID:"+t),this._eventEmitter.emit(i.EVENT.REJECT,{userID:t}),this._setInterfaceUpLoad(o.default.REJECT).setText("EVENT.REJECT emitted").setEnd()},t.prototype.onNoResp=function(t,e){r.default.debug(l+".onNoResp userIDList:",e),this._eventEmitter.emit(i.EVENT.NO_RESP,{sponsor:t,userIDList:e}),this._setInterfaceUpLoad(o.default.NO_RESP).setText("EVENT.NO_RESP emitted").setEnd()},t.prototype.onLineBusy=function(t,e){r.default.debug(l+".onLineBusy sponsor:"+t+" userID:"+e),this._eventEmitter.emit(i.EVENT.LINE_BUSY,{sponsor:t,userID:e}),this._setInterfaceUpLoad(o.default.LINE_BUSY).setText("EVENT.LINE_BUSY emitted").setEnd()},t.prototype.onCallingCancel=function(){r.default.debug(l+".onCallingCancel"),this._eventEmitter.emit(i.EVENT.CALLING_CANCEL,{}),this._setInterfaceUpLoad(o.default.CALLING_CANCEL).setText("EVENT.CALLING_CANCEL emitted").setEnd()},t.prototype.onKickedOut=function(){r.default.debug(l+".onKickedOut"),this._eventEmitter.emit(i.EVENT.KICKED_OUT,{}),this._setInterfaceUpLoad(o.default.KICKED_OUT).setText("EVENT.KICKED_OUT emitted").setEnd()},t.prototype.onCallingTimeout=function(t,e){r.default.debug(l+".onCallingTimeout userIDList:",e),this._eventEmitter.emit(i.EVENT.CALLING_TIMEOUT,{sponsor:t,userIDList:e}),this._setInterfaceUpLoad(o.default.CALLING_TIMEOUT).setText("EVENT.CALLING_TIMEOUT emitted").setEnd()},t.prototype.onCallEnd=function(t,e){r.default.debug(l+".onCallEnd userID:"+t+" callEnd:"+e),this._eventEmitter.emit(i.EVENT.CALLING_END,{userID:t,callEnd:e}),this._setInterfaceUpLoad(o.default.CALLING_END).setText("EVENT.CALLING_END emitted").setEnd()},t.prototype.onUserVideoAvailable=function(t){r.default.debug(l+".onUserVideoAvailable params:",t);var e=t.userID,n=t.isVideoAvailable;this._eventEmitter.emit(i.EVENT.USER_VIDEO_AVAILABLE,{userID:e,isVideoAvailable:n});var s="EVENT.USER_VIDEO_AVAILABLE emitted, userID: "+e+", video: "+n;this._setInterfaceUpLoad(o.default.USER_VIDEO_AVAILABLE).setText(s).setEnd()},t.prototype.onUserAudioAvailable=function(t){r.default.debug(l+".onUserAudioAvailable params:",t);var e=t.userID,n=t.isAudioAvailable;this._eventEmitter.emit(i.EVENT.USER_AUDIO_AVAILABLE,{userID:e,isAudioAvailable:n});var s="EVENT.USER_AUDIO_AVAILABLE emitted, userID: "+e+", mic: "+n;this._setInterfaceUpLoad(o.default.USER_AUDIO_AVAILABLE).setText(s).setEnd()},t.prototype.onUserVoiceVolume=function(t){this._eventEmitter.emit(i.EVENT.USER_VOICE_VOLUME,{volumeMap:t}),this._setInterfaceUpLoad(o.default.USER_VOICE_VOLUME).setText("EVENT.USER_VOICE_VOLUME emitted").setEnd()},t.prototype.onGroupCallInviteeListUpdate=function(t){this._eventEmitter.emit(i.EVENT.GROUP_CALL_INVITEE_LIST_UPDATE,{userIDList:t}),this._setInterfaceUpLoad(o.default.GROUP_CALL_INVITEE_LIST_UPDATE).setText("EVENT.GROUP_CALL_INVITEE_LIST_UPDATE emitted").setEnd()},t.prototype.onCallTypeChanged=function(t,e){this._eventEmitter.emit(i.EVENT.CALL_TYPE_CHANGED,{oldCallType:t,newCallType:e}),this._setInterfaceUpLoad(o.default.CALL_TYPE_CHANGED).setText("EVENT.CALL_TYPE_CHANGED "+e).setEnd()},t.prototype.onDeviceUpdated=function(t,e,n,r){this._eventEmitter.emit(i.EVENT.DEVICED_UPDATED,{microphoneList:t,cameraList:e,currentMicrophone:n,currentCamera:r}),this._setInterfaceUpLoad(o.default.DEVICED_UPDATED).setText("EVENT.GROUP_CALL_INVITEE_LIST_UPDATE emitted").setEnd()},t}();e.default=u},function(t,e,n){"use strict";n.r(e);var i=n(0);const r="none",s="online",o=function(){let t=window.location.protocol;return["http:","https:"].indexOf(t)<0&&(t="http:"),t};e.default=class{constructor(){this._networkType="",this.maxWaitTime=3e3}start(){this._networkType=s}_onNetworkStatusChange(t){this._networkType=t.networkType,t.isConnected?i.default.info("NetMonitor networkType:"+t.networkType):i.default.warn("NetMonitor no network, please check!")}probe(){return new Promise(t=>{if(window&&window.fetch)fetch(`${o()}//webim-1252463788.file.myqcloud.com/assets/test/speed.xml?random=${Math.random()}`).then(e=>{e.ok?t([!0,s]):t([!1,r])}).catch(()=>{t([!1,r])});else{const e=new XMLHttpRequest,n=setTimeout(()=>{i.default.warn("NetMonitor fetch timeout. Probably no network, please check!"),e.abort(),this._networkType=r,t([!1,r])},this.maxWaitTime);e.onreadystatechange=function(){4===e.readyState&&(clearTimeout(n),200===e.status||304===e.status?(this._networkType=s,t([!0,s])):(i.default.warn(`NetMonitor fetch status:${e.status}. Probably no network, please check!`),this._networkType=r,t([!1,r])))},e.open("GET",`${o()}//webim-1252463788.file.myqcloud.com/assets/test/speed.xml?random=${Math.random()}`),e.send()}})}getNetworkType(){return this._networkType}reset(){this._networkType=""}}},function(t,e,n){"use strict";n.r(e),n.d(e,"isFunction",(function(){return i})),n.d(e,"isUndefined",(function(){return r})),n.d(e,"isString",(function(){return s})),n.d(e,"isNumber",(function(){return o})),n.d(e,"isBoolean",(function(){return a})),n.d(e,"isPlainObject",(function(){return l}));const i=t=>"function"==typeof t,r=t=>void 0===t,s=t=>"string"==typeof t,o=t=>"number"==typeof t,a=t=>"boolean"==typeof t,l=function(t){if(!t||"object"!=typeof t||"[object Object]"!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);if(null===e)return!0;const n=Object.prototype.hasOwnProperty.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)}},function(t,e,n){"use strict";var i,r=this&&this.__extends||(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var s=n(4),o=function(t){function e(e){var n=e.message,i=e.code,r=void 0===i?s.default.UNKNOWN:i,o=t.call(this,n+" <"+function(t){for(var e in s.default)if(s.default[e]===t)return e;return"UNKNOWN"}(r)+" "+r+">")||this;return o.code_=r,o.name="TRTCCallingError",o.message_=n,o}return r(e,t),e.prototype.getCode=function(){return this.code_},e}(Error);e.default=o}]).default}));