1 |
- !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),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 C})),n.d(e,"TimeUtil",(function(){return v})),n.d(e,"stringifyError",(function(){return E})),n.d(e,"map2String",(function(){return T})),n.d(e,"randomString",(function(){return L})),n.d(e,"isValidType",(function(){return A})),n.d(e,"mapKeys",(function(){return D})),n.d(e,"mapValues",(function(){return b})),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"===C(t)},s=function(t){return"set"===C(t)},o=function(t){return"file"===C(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"===C(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},C=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()};let m=0;Date.now||(Date.now=function(){return(new Date).getTime()});const v={now(){0===m&&(m=Date.now()-1);const t=Date.now()-m;return t>4294967295?(m+=4294967295,Date.now()-m):t},utc:()=>Math.round(Date.now()/1e3)},E=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",S=y.length,L=function(){let t="";for(let e=32;e>0;--e)t+=y[Math.floor(Math.random()*S)];return t},A=function(t,e){for(const n in t)if(t[n]===e)return!0;return!1};function D(t,e){const n={};return Object.keys(t).forEach(i=>{n[e(t[i],i)]=t[i]}),n}function b(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 w(t){return t<10?"0"+t:t}function N(t){if(t<60)return"00:00:"+w(t);if(t<3600){const e=parseInt(t/60),n=t-60*e;return`00:${w(e)}:${w(n)}`}const e=parseInt(t/3600),n=t-3600*e,i=parseInt(n/60),r=n-60*i;return`${w(e)}:${w(i)}:${w(r)}`}function U(t,e){t=t.split("."),e=e.split(".");const n=Math.max(t.length,e.length);for(;t.length<n;)t.push("0");for(;e.length<n;)e.push("0");for(let i=0;i<n;i++){const n=parseInt(t[i]),r=parseInt(e[i]);if(n>r)return 1;if(n<r)return-1}return 0}const R=function(){const t=new Date,e=t.toISOString(),n=t.getTimezoneOffset()/60;let i="";return i=n<0?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";n.r(e);var i=n(3),r=n(0);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;n<i;n++)Object(r.isArrayOrObject)(t[n])?Object(r.isInstanceOfError)(t[n])?e+=Object(r.stringifyError)(t[n]):e+=JSON.stringify(t[n]):e+=t[n],e+=" "}return e},debug(){if(s<=-1){const t=this.arguments2String(arguments);l.record(t,"debug"),i.a.debug(t)}},log(){if(s<=0){const t=this.arguments2String(arguments);l.record(t,"log"),i.a.log(t)}},info(){if(s<=1){const t=this.arguments2String(arguments);l.record(t,"info"),i.a.info(t)}},warn(){if(s<=2){const t=this.arguments2String(arguments);l.record(t,"warn"),i.a.warn(t)}},error(){if(s<=3){const t=this.arguments2String(arguments);l.record(t,"error"),i.a.error(t)}},time(t){o.set(t,r.TimeUtil.now())},timeEnd(t){if(o.has(t)){const e=r.TimeUtil.now()-o.get(t);return o.delete(t),e}return i.a.warn(`未找到对应label: ${t}, 请在调用 logger.timeEnd 前,调用 logger.time`),0},setLevel(t){t<4&&i.a.log(`${a()}set level from ${s} to ${t}`),s=t},getLevel:()=>s,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";var i=n(12),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<i;n++)e.call(null,t[n],n,t);else for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.call(null,t[r],r,t)}t.exports={isArray:s,isArrayBuffer:function(t){return"[object ArrayBuffer]"===r.call(t)},isBuffer:function(t){return null!==t&&!o(t)&&null!==t.constructor&&!o(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:a,isPlainObject:l,isUndefined:o,isDate:function(t){return"[object Date]"===r.call(t)},isFile:function(t){return"[object File]"===r.call(t)},isBlob:function(t){return"[object Blob]"===r.call(t)},isFunction:u,isStream:function(t){return a(t)&&u(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:c,merge:function t(){var e={};function n(n,i){l(e[i])&&l(n)?e[i]=t(e[i],n):l(n)?e[i]=t({},n):s(n)?e[i]=n.slice():e[i]=n}for(var i=0,r=arguments.length;i<r;i++)c(arguments[i],n);return e},extend:function(t,e,n){return c(e,(function(e,r){t[r]=n&&"function"==typeof e?i(e,n):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}}},function(t,e,n){"use strict";(function(t){let n,i;n="undefined"!=typeof console?console:void 0!==t&&t.console?t.console:"undefined"!=typeof window&&window.console?window.console:{};const r=function(){},s=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let{length:o}=s;for(;o--;)i=s[o],console[i]||(n[i]=r);n.methods=s,e.a=n}).call(this,n(26))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default={UNKNOWN:65535,NO_SDK_APPID:2e3,NO_ACCOUNT_TYPE:2001,NO_IDENTIFIER:2002,NO_USER_SIG:2003,NO_TINY_ID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,NO_NETWORK:2805,FAILURE_SWITCH_TO_AUDIO:60001,FAILURE_SWITCH_TO_VIDEO:60002,NOT_MICROPHONE_LIST:60003,NOT_CAMERA_LIST:60004,NOT_MEDIA_ACCESS:60005}},function(t,e,n){"use strict";n.r(e),n.d(e,"IN_Browser",(function(){return i})),n.d(e,"IN_WXMiniProgram",(function(){return r})),n.d(e,"USER_AGENT",(function(){return s})),n.d(e,"IS_IPAD",(function(){return l})),n.d(e,"IS_IPHONE",(function(){return u})),n.d(e,"IS_IPOD",(function(){return c})),n.d(e,"IS_IOS",(function(){return d})),n.d(e,"IOS_VERSION",(function(){return h})),n.d(e,"IS_ANDROID",(function(){return f})),n.d(e,"ANDROID_VERSION",(function(){return p})),n.d(e,"IS_OLD_ANDROID",(function(){return _})),n.d(e,"IS_NATIVE_ANDROID",(function(){return g})),n.d(e,"IS_FIREFOX",(function(){return I})),n.d(e,"FIREFOX_VERSION",(function(){return C})),n.d(e,"IS_EDGE",(function(){return m})),n.d(e,"IS_EDG",(function(){return v})),n.d(e,"EDG_VERSION",(function(){return E})),n.d(e,"IS_CHROME",(function(){return T})),n.d(e,"CHROME_MAJOR_VERSION",(function(){return y})),n.d(e,"CHROME_VERSION",(function(){return S})),n.d(e,"IS_IE8",(function(){return L})),n.d(e,"IE_VERSION",(function(){return A})),n.d(e,"IS_SAFARI",(function(){return D})),n.d(e,"IS_ANY_SAFARI",(function(){return b})),n.d(e,"SAFARI_VERSION",(function(){return O})),n.d(e,"IS_TBS",(function(){return w})),n.d(e,"TBS_VERSION",(function(){return N})),n.d(e,"IS_MQQB",(function(){return U})),n.d(e,"IS_QQB",(function(){return R})),n.d(e,"IS_WECHAT",(function(){return V})),n.d(e,"IS_WIN",(function(){return M})),n.d(e,"IS_MAC",(function(){return j})),n.d(e,"IS_LINUX",(function(){return x})),n.d(e,"IS_WX",(function(){return P})),n.d(e,"IS_UCBROWSER",(function(){return k})),n.d(e,"IS_MIUIBROWSER",(function(){return G})),n.d(e,"IS_HUAWEIBROWSER",(function(){return B})),n.d(e,"BROWSER_VERSION",(function(){return H})),n.d(e,"IS_LOCAL",(function(){return J}));const i="undefined"!=typeof window,r="undefined"!=typeof wx,s=window.navigator&&window.navigator.userAgent||"",o=/AppleWebKit\/([\d.]+)/i.exec(s),a=o?parseFloat(o.pop()):null,l=/iPad/i.test(s),u=/iPhone/i.test(s)&&!l,c=/iPod/i.test(s),d=u||l||c,h=function(){const t=s.match(/OS (\d+)_/i);return t&&t[1]?t[1]:null}(),f=/Android/i.test(s),p=function(){const t=s.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!t)return null;const e=t[1]&&parseFloat(t[1]),n=t[2]&&parseFloat(t[2]);return e&&n?parseFloat(`${t[1]}.${t[2]}`):e||null}(),_=f&&/webkit/i.test(s)&&p<2.3,g=f&&p<5&&a<537,I=/Firefox/i.test(s),C=function(){const t=s.match(/Firefox\/(\d+)/);return t&&t[1]?parseFloat(t[1]):null}(),m=/Edge\//i.test(s),v=/Edg\//i.test(s),E=function(){const t=s.match(/Edg\/(\d+)/);return t&&t[1]?parseFloat(t[1]):null}(),T=!m&&/Chrome/i.test(s),y=function(){const t=s.match(/Chrome\/(\d+)/);return t&&t[1]?parseFloat(t[1]):null}(),S=function(){const t=s.match(/Chrome\/([\d.]+)/);return t&&t[1]?t[1]:null}(),L=/MSIE\s8\.0/.test(s),A=function(){const t=/MSIE\s(\d+)\.\d/.exec(s);let e=t&&parseFloat(t[1]);return!e&&/Trident\/7.0/i.test(s)&&/rv:11.0/.test(s)&&(e=11),e}(),D=/Safari/i.test(s)&&!T&&!f&&!m,b=D||d,O=function(){const t=s.match(/Version\/([\d.]+)/);return t&&t[1]?t[1]:null}(),w=/TBS\/\d+/i.test(s),N=function(){const t=s.match(/TBS\/(\d+)/i);if(t&&t[1])return t[1]}(),U=!w&&/MQQBrowser\/\d+/i.test(s),R=!w&&/ QQBrowser\/\d+/i.test(s),V=/(micromessenger|webbrowser)/i.test(s),M=/Windows/i.test(s),j=/MAC OS X/i.test(s),x=/Linux/i.test(s),P=/MicroMessenger/i.test(s),k=/UCBrowser/i.test(s),G=/MiuiBrowser/i.test(s),B=/HuaweiBrowser/i.test(s),H=T?"Chrome/"+S:D?"Safari/"+O:"NotSupportedBrowser",J="file:"===location.protocol||"localhost"===location.hostname||/^\d+\.\d+\.\d+\.\d+$/.test(location.hostname)},function(t,e,n){"use strict";n.r(e);var i=n(0),r=n(1),s=n(4),o=n.n(s),a=n(21),l=n.n(a);class u{constructor(t){this.sdkappid="",this.version="",this.userid="",this.platform="",this.useragent="",this.method=t,this.codeint=1,this.calltype=1,this.talktime=0,this.message="",this.text="",this.startts=Date.now(),this.endts=0,this.timespan=0,this.time="",this.networktype="",this.host=Object(i.getHostType)()}static bindController(t){u.prototype._eventStatController=t}setCommonInfo(t){const{SDKAppID:e,version:n,userID:r,platform:s,scene:o}=t;this.sdkappid=e,this.version=""+n,this.userid=r,this.platform=s,this.scene=o,this.time=Object(i.date2ISOString)(),this.startts&&this.endts&&!this.timespan&&(this.timespan=Math.abs(this.endts-this.startts))}setEnd(t=!1){this.endts=Date.now(),t?this._eventStatController.pushIn(this):setTimeout(()=>{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.MODE_TYPE=e.VALID_VIDEO_PROFILE_LIST=e.BUSINESS_ID=e.ACTION_TYPE=e.CALL_STATUS=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.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=["480p","720p","1080p"],function(t){t.AUDIO="audio",t.VIDEO="video"}(e.MODE_TYPE||(e.MODE_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",KICKED_OUT:"kickedOut",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",REJECT:"reject",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",GROUP_CALL_INVITEE_LIST_UPDATE:"group_call_invitee_list_update"}},function(t,e,n){"use strict";n.r(e),n.d(e,"default",(function(){return p}));var i=n(1),r=n(0);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(10),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()<this._lastReportTime+this.WAITING_TIME||this._reportBody.isEmpty()||this._report()},this.INTERVAL)}_stopReportTimer(){this._timerID>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){t.exports=JSON.parse('{"name":"trtc-calling-js","version":"1.0.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.7.0"},"devDependencies":{"@babel/preset-typescript":"^7.12.7","@typescript-eslint/eslint-plugin":"^4.26.0","@typescript-eslint/parser":"^4.26.0","docdash-blue":"^1.1.3","eslint":"^7.27.0","eslint-config-google":"^0.14.0","fs-extra":"^9.0.1","jsdoc":"^3.6.5","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 ../TIM-demo-web/node_modules/trtc-calling-js/trtc-calling-js.js","build_withcopy2":"npm run build && cp dist/npm/trtc-calling-js.js ../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<n.length;i++)n[i]=arguments[i];return t.apply(e,n)}}},function(t,e,n){"use strict";var i=n(2);function r(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}t.exports=function(t,e,n){if(!e)return t;var s;if(n)s=n(e);else if(i.isURLSearchParams(e))s=e.toString();else{var o=[];i.forEach(e,(function(t,e){null!=t&&(i.isArray(t)?e+="[]":t=[t],i.forEach(t,(function(t){i.isDate(t)?t=t.toISOString():i.isObject(t)&&(t=JSON.stringify(t)),o.push(r(e)+"="+r(t))})))})),s=o.join("&")}if(s){var a=t.indexOf("#");-1!==a&&(t=t.slice(0,a)),t+=(-1===t.indexOf("?")?"?":"&")+s}return t}},function(t,e,n){"use strict";t.exports=function(t){return!(!t||!t.__CANCEL__)}},function(t,e,n){"use strict";(function(e){var i=n(2),r=n(33),s={"Content-Type":"application/x-www-form-urlencoded"};function o(t,e){!i.isUndefined(t)&&i.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var a,l={adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==e&&"[object process]"===Object.prototype.toString.call(e))&&(a=n(16)),a),transformRequest:[function(t,e){return r(e,"Accept"),r(e,"Content-Type"),i.isFormData(t)||i.isArrayBuffer(t)||i.isBuffer(t)||i.isStream(t)||i.isFile(t)||i.isBlob(t)?t:i.isArrayBufferView(t)?t.buffer:i.isURLSearchParams(t)?(o(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):i.isObject(t)?(o(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=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(13),a=n(37),l=n(40),u=n(41),c=n(17);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"}},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:"未连接到网络"}},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;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},r=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())}))},s=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]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},o=this&&this.__spreadArrays||function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var i=Array(t),r=0;for(e=0;e<n;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,r++)i[r]=s[o];return i};Object.defineProperty(e,"__esModule",{value:!0});var a=n(24),l=n(0),u=n(25),c=n(11),d=n(45),h=n(46),f=n(48),p=n(20),_=n(6),g=n(8),I=n(9),C=n(5),m=n(49),v=n(1),E=n(7),T=n(50),y=n(51),S=n(4),L=n(10),A="TRTCCalling",D=function(){function t(t){this._sdkAppID=t.SDKAppID,this._trtcClient=null,this._userID="",this._userSig="",this._switchCallModeStatus=!0,this._inviterInviteID=[],this._callTimeout=30,this._callStatus=E.CALL_STATUS.IDLE,this._callType=E.CALL_TYPE.UNKNOWN,this._roomID=0,this._isInviter=!1,this._isGroupCall=!1,this._groupCallStatus=!1,this._inviteeList=[],this._unHandledInviteeList=[],sessionStorage.setItem("sdkAppId",""+this._sdkAppID),this._netMonitor=new m.default,this._outerEmitter=new a.default,this._delegate=new f.default(this._outerEmitter),this.tim=t.tim||d.create(t),this._tsignalingClient=new h.default(this,i({tim:this.tim},t)),this._quality="480p";var e=new _.default(g.default.SDK_CONSTRUCT);this._eventStatController=new I.default,_.default.bindController(this._eventStatController),e.setText("version="+L.version+"-ua="+C.USER_AGENT).setEnd(),v.default.info(A+" SDK Version:"+L.version+", SDKAppID:"+t.SDKAppID+", UserAgent:"+C.USER_AGENT)}return t.prototype.getUserID=function(){return this._userID},t.prototype.getCallType=function(){return this._callType},t.prototype.setCallType=function(t){this._callType=t},t.prototype.isInviter=function(){return this._isInviter},t.prototype.getInviteeList=function(){return this._inviteeList},t.prototype.setInviteeList=function(t){this._inviteeList=o(t)},t.prototype.getUnHandledInviteeList=function(){return this._unHandledInviteeList},t.prototype.setUnHandledInviteeList=function(t){this._unHandledInviteeList=o(t),v.default.debug(A+".setUnHandledInviteeList",this._unHandledInviteeList)},t.prototype.isGroupCall=function(){return this._isGroupCall},t.prototype.setIsGroupCall=function(t){this._isGroupCall=t},t.prototype.getGroupID=function(){return this._groupID},t.prototype.setGroupID=function(t){this._groupID=t},t.prototype.hasRemoteConnectedUsers=function(){return this.getRemoteStreamCount()>0},t.prototype.getRemoteStreamCount=function(){return this._trtcClient?this._trtcClient.getRemoteStreams().length:0},t.prototype.setLogLevel=function(t){v.default.setLevel(t),this._tsignalingClient.setLogLevel(t),c.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;return s(this,(function(r){switch(r.label){case 0:v.default.debug(A+".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),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._tsignalingClient.login({userID:e,userSig:n})];case 2:return r.sent(),this._setInterfaceUpLoad(g.default.LOGIN).setText("userId: "+this._userID+" login succeeded").setEnd(),[3,4];case 3:return i=r.sent(),console.log(i),this._setInterfaceUpLoad(g.default.LOGIN).setText("userId: "+this._userID+" login failed, error: "+i).setEnd(),[3,4];case 4:return[2]}}))}))},t.prototype.logout=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){return v.default.debug(A+".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(this._callStatus!==E.CALL_STATUS.IDLE)throw new Error(A+".call - CALL_STATUS: "+this._callStatus);this._callStatus=E.CALL_STATUS.CALLING,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({audio:!0,video:t.type===E.CALL_TYPE.VIDEO_CALL})];case 2:return e=s.sent(),this._trtcClient.releaseStream(e),[3,4];case 3:throw n=s.sent(),this._callStatus=E.CALL_STATUS.IDLE,this._delegate.onError(S.default.NOT_MEDIA_ACCESS,JSON.stringify(n)),new Error(A+".call - 获取用户设备权限失败");case 4:return v.default.log(A+".call - params:",t),i=t.userID,r=t.type,o=t.offlinePushInfo,this._callType=r,this._isInviter=!0,this._inviterID=this._userID,this._inviteeID=i,this._isGroupCall=!1,this._groupID="",this._roomID=l.generateRandomRoomID(),[4,this._tsignalingClient.invite({userID:i,type:r,roomID:this._roomID,timeout:this._callTimeout,offlinePushInfo:o})];case 5:return a=s.sent(),u="callType: "+(r+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(r+1).setText(u+" succeeded").setEnd()):this._setInterfaceUpLoad(g.default.CALL).setCallType(r+1).setText(u+" failed").setEnd(),[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 v.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){return r(this,void 0,void 0,(function(){var e,n,i,r,o,a,u,c,d=this;return s(this,(function(s){switch(s.label){case 0:if(this._groupCallStatus)throw new Error(A+".call - CALL_STATUS: "+this._callStatus);s.label=1;case 1:return s.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({audio:!0,video:t.type===E.CALL_TYPE.VIDEO_CALL})];case 2:return e=s.sent(),this._trtcClient.releaseStream(e),[3,4];case 3:throw n=s.sent(),this._delegate.onError(S.default.NOT_MEDIA_ACCESS,JSON.stringify(n)),new Error(A+".call - 获取用户设备权限失败");case 4:return this._groupCallStatus=!0,v.default.debug(A+".groupCall - params:",t),i=t.userIDList,r=t.type,o=t.groupID,a=t.offlinePushInfo,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=l.generateRandomRoomID(),this._callStatus=E.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 u=s.sent(),v.default.log("groupCall res",u),o?(c="callType: "+(r+1)+",\n conversationType: "+u.data.message.conversationType+",\n userId:{ "+u.data.message.from+" } invite { "+u.data.message.to+": "+i+" }",0===u.code?(this.setInviterInviteID(u.inviteID),this._setInterfaceUpLoad(g.default.GROUP_CALL).setCallType(r+1).setText(c+" succeeded").setEnd()):this._setInterfaceUpLoad(g.default.GROUP_CALL).setCallType(r+1).setText(c+" failed").setEnd()):(c="callType: "+(r+1)+",\n result: "+JSON.stringify(u),0===u.code?(u.data.map((function(t){d.setInviterInviteID(t.inviteID)})),this._setInterfaceUpLoad(g.default.GROUP_CALL).setCallType(r+1).setText(c+" succeeded").setEnd()):this._setInterfaceUpLoad(g.default.GROUP_CALL).setCallType(r+1).setText(c+" failed").setEnd()),this._groupCallStatus=!1,[2,u]}}))}))},t.prototype.accept=function(){return r(this,void 0,void 0,(function(){var t,e,n,i,r,o,a,l,u,c=this;return s(this,(function(s){switch(s.label){case 0:if(v.default.debug(A+".accept"),!this._tsignalingClient.getInviteData())return v.default.warn(A+".accept - there are no calls to accept"),[2];t=this._tsignalingClient.getInviteData(),e=t.inviteID,n=t.inviteData,i=n.roomID,r=n.callType,v.default.debug(A+".accept - params","inviteID: "+e+",callType: "+r+",roomID: "+i+"."),this._callType=r,this._callStatus=E.CALL_STATUS.CALLING,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._trtcClient.join(i)];case 2:return s.sent(),this._roomID=i,this._tsignalingClient.setInviteData(null),this.changeCallStatus(E.CALL_STATUS.CONNECTED),[3,4];case 3:throw s.sent(),this._resetTRTCClient(),new Error(A+".accept - join room failed");case 4:return s.trys.push([4,6,,7]),[4,this._tsignalingClient.accept({inviteID:e,callType:r})];case 5:return o=s.sent(),u="callType: "+(r+1)+",\n conversationType: "+o.data.message.conversationType+",\n userId:{ "+this._userID+" } accept userId:{ "+o.data.message.to+" } succeeded",this._setInterfaceUpLoad(g.default.ACCEPT).setCallType(r+1).setText(""+u).setEnd(),[3,7];case 6:return a=s.sent(),v.default.error(a),u="callType: "+(r+1)+",\n conversationType: "+o.data.message.conversationType+",\n userId:{ "+this._userID+" } accept userId:{ "+o.data.message.to+" } failed",this._setInterfaceUpLoad(g.default.ACCEPT).setCallType(r+1).setText(""+u).setEnd(),[2];case 7:return this.isGroupCall()&&(l=this._unHandledInviteeList.filter((function(t){return t!==c._userID})),this.setUnHandledInviteeList(l),u="callType: "+(r+1)+",\n conversationType: "+o.data.message.conversationType+",\n userId:{ "+this._userID+" } accept userId:{ "+o.data.message.to+" } succeeded",this._setInterfaceUpLoad(g.default.ACCEPT).setCallType(r+1).setText(u).setEnd()),[2,o]}}))}))},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 v.default.debug(A+".reject"),this._tsignalingClient.getInviteData()?(t=this._callStatus===E.CALL_STATUS.CONNECTED,v.default.log(A+".reject - status:"+t),e=this._tsignalingClient.getInviteData(),n=e.inviteID,i=e.inviteData,r=i.callType,v.default.debug(A+".reject - params","inviteID: "+n+",callType: "+r+",isBusy: "+t+"."),[4,this._tsignalingClient.reject({inviteID:n,callType:r,isBusy:t})]):(v.default.warn(A+".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(v.default.log(A+". - callStatus:"+this._callStatus+" inviteID:"+this._inviterInviteID),this._callStatus===E.CALL_STATUS.CALLING&&0===this._inviterInviteID.length)throw new Error(A+".call/groupCall incomplete。please wait cancel");i.label=1;case 1:return i.trys.push([1,3,,5]),[4,this._cancel()];case 2:return t=i.sent(),[3,5];case 3:return e=i.sent(),[4,this._resetTRTCClient()];case 4:throw i.sent(),v.default.error("leave _cancel",e),new Error(e);case 5:if(this._callStatus!==E.CALL_STATUS.CONNECTED)return[3,11];i.label=6;case 6:return i.trys.push([6,8,,10]),[4,this._trtcClient.leave()];case 7:return t=i.sent(),[3,10];case 8:return n=i.sent(),[4,this._resetTRTCClient()];case 9:throw i.sent(),console.error("hangup leave error",n),new Error(n);case 10:this._setInterfaceUpLoad(g.default.REJECT).setText("userId: "+this._userID+" hangup succeeded").setEnd(),i.label=11;case 11:return[4,this._resetTRTCClient()];case 12: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(v.default.log("_cancel _inviterInviteID",this._inviterInviteID),0===this._inviterInviteID.length)return[2];t=[],s.label=1;case 1:s.trys.push([1,6,,7]),e=0,s.label=2;case 2:return e<this._inviterInviteID.length?(n=this._inviterInviteID[e],[4,this._tsignalingClient.cancel({inviteID:n})]):[3,5];case 3:i=s.sent(),t.push(i),s.label=4;case 4:return e++,[3,2];case 5:return[3,7];case 6:throw r=s.sent(),new Error(r);case 7:return o="cancel "+JSON.stringify(t)+" succeeded",v.default.log(A+"._cancel "+o),this._setInterfaceUpLoad(g.default.CALLING_CANCEL).setText(o).setEnd(),[2,t]}}))}))},t.prototype.startRemoteView=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){return v.default.debug(A+".startRemoteView - params:",t),e=t.userID,n=t.videoViewDomID,this._setInterfaceUpLoad(g.default.START_REMOTE_VIEW).setText("remote userId:{ "+e+" } startRemoveView succeeded").setEnd(),[2,this._trtcClient.playVideo({domID:n,type:"remote",userID:e})]}))}))},t.prototype.stopRemoteView=function(t){v.default.debug(A+".stopRemoteView - params:",t);var e=t.userID;this._setInterfaceUpLoad(g.default.STOP_REMOTE_VIEW).setText("remote userId:{ "+e+" } stopRemoveView succeeded").setEnd(),this._trtcClient.stopVideo({type:"remote",userID:e})},t.prototype.startLocalView=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){return v.default.debug(A+".startLocalView - params:",t),e=t.userID,n=t.videoViewDomID,this._setInterfaceUpLoad(g.default.START_LOCAL_VIEW).setText("remote userId:{ "+e+" } startLocalView succeeded").setEnd(),[2,this._trtcClient.playVideo({domID:n,type:"local",userID:e})]}))}))},t.prototype.stopLocalView=function(t){v.default.debug(A+".stopLocalView - params:",t);var e=t.userID;this._setInterfaceUpLoad(g.default.STOP_LOCAL_VIEW).setText("remote userId:{ "+e+" } stopLocalView succeeded").setEnd(),this._trtcClient.stopVideo({type:"local",userID:e})},t.prototype.openCamera=function(){v.default.debug(A+".openCamera"),this._setInterfaceUpLoad(g.default.OPEN_CAMERA).setText("open camera").setEnd(),this._trtcClient.unMuteLocalVideo()},t.prototype.closeCamera=function(){v.default.debug(A+".closeCamera"),this._setInterfaceUpLoad(g.default.CLOSE_CAMERA).setText("close camera").setEnd(),this._trtcClient.muteLocalVideo()},t.prototype.setMicMute=function(t){v.default.debug(A+".setMicMute - isMute:"+t),this._setInterfaceUpLoad(g.default.SET_MIC_MUTE).setText("setMicMute: "+t).setEnd(),t?this._trtcClient.muteLocalAudio():this._trtcClient.unMuteLocalAudio()},t.prototype.setVideoQuality=function(t){if(!T.isString(t)&&!T.isPlainObject(t)||T.isString(t)&&-1===E.VALID_VIDEO_PROFILE_LIST.indexOf(t.toString())){throw new y.default({message:"params validate failed."})}v.default.debug(A+".setVideoQuality - quality:"+JSON.stringify(t)),this._setInterfaceUpLoad(g.default.SET_VIDEO_QUALITY).setText("setVideoQuality: "+JSON.stringify(t)).setEnd(),this._quality=t||"480p"},t.prototype.getVideoQuality=function(){return this._quality},t.prototype.switchToAudioCall=function(){this._callStatus===E.CALL_STATUS.CONNECTED?this._isGroupCall?v.default.warn(A+".switchToAudioCall is not applicable to groupCall."):this._callType!==E.CALL_TYPE.AUDIO_CALL?this._switchCallModeStatus?(v.default.log(A+".switchToAudioCall",this._inviterID,this._inviteeID),this._setInterfaceUpLoad(g.default.SWITCH_TO_AUDIO_CALL).setText("switchToAudioCall").setEnd(),this._tsignalingClient.switchCallMode({userID:this._isInviter?this._inviteeID:this._inviterID,call_type:this._callType,roomID:this._roomID,timeout:this._callTimeout,mode:E.MODE_TYPE.AUDIO}),this.setSwitchCallModeStatus(!1)):v.default.warn(A+" audio and video call switching."):v.default.warn(A+" Now the call mode is audio call."):v.default.warn(A+".switchToAudioCall is applicable to connected.")},t.prototype.setSwitchCallModeStatus=function(t){this._switchCallModeStatus=t},t.prototype.getSwitchCallModeStatus=function(){return this._switchCallModeStatus},t.prototype.switchToVideoCall=function(){this._callStatus===E.CALL_STATUS.CONNECTED?this._isGroupCall?v.default.warn(A+".switchToVideoCall is not applicable to groupCall."):this._callType!==E.CALL_TYPE.VIDEO_CALL?this._switchCallModeStatus?(v.default.log(A+".switchToVideoCall",this._inviterID,this._inviteeID),this._setInterfaceUpLoad(g.default.SWITCH_TO_VIDEO_CALL).setText("switchToVideoCall").setEnd(),this._tsignalingClient.switchCallMode({userID:this._isInviter?this._inviteeID:this._inviterID,call_type:this._callType,roomID:this._roomID,timeout:this._callTimeout,mode:E.MODE_TYPE.VIDEO}),this.setSwitchCallModeStatus(!1)):v.default.warn(A+" audio and video call switching."):v.default.warn(A+" Now the call mode is video call."):v.default.warn(A+".switchToVideoCall is applicable to connected.")},t.prototype.getCameras=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){return v.default.log(A+".getCameras"),[2,this._trtcClient.getCamera()]}))}))},t.prototype.getMicrophones=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){return v.default.log(A+".getCameras"),[2,this._trtcClient.getMicrophone()]}))}))},t.prototype.switchDevice=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){return e=t.deviceType,n=t.deviceId,v.default.debug(A+".switchDevice -params: deviceType:"+e+",deviceID:"+n),[2,this._trtcClient.switchDevice(e,n)]}))}))},t.prototype._resetTRTCClient=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return v.default.debug(A+"._resetTRTCClient"),this._roomID=null,this._isInviter=!1,this._isGroupCall=!1,this.setSwitchCallModeStatus(!0),this._groupID="",this._callStatus=E.CALL_STATUS.IDLE,this._inviteeList=[],this._unHandledInviteeList=[],this._inviterInviteID=[],[4,this._trtcClient.reset()];case 1:return e.sent(),this._tsignalingClient.setInviteData(null),this._tsignalingClient.resetJoined(),(t=document.getElementById("_trtc_calling_layer"))&&(t.innerHTML=""),[2]}}))}))},t.prototype.getCallStatus=function(){return this._callStatus},t.prototype.changeCallStatus=function(t){this._callStatus!==t&&(v.default.debug(A+".changeCallStatus from "+this._callStatus+" to "+t),this._setInterfaceUpLoad(g.default.CHANGE_CALL_STATUS).setText("changeCallStatus from "+this._callStatus+" to "+t).setEnd(),this._callStatus=t)},t.prototype.extractCallingInfoFromMessage=function(t){if(!t)return"";if("TIMCustomElem"!==t.type)return"";var e=JSON.parse(t.payload.data);if(v.default.debug(A+".extractCallingInfoFromMessage - signalingData:",t.payload.data),e.businessID!==E.BUSINESS_ID.SIGNAL)return"";switch(e.actionType){case E.ACTION_TYPE.INVITE:var n=JSON.parse(e.data);return n.call_end>0?"结束通话,通话时长:"+l.formatDuration(n.call_end):0!==n.call_end&&n.room_id?"发起通话":"结束群聊";case E.ACTION_TYPE.CANCEL_INVITE:return"取消通话";case E.ACTION_TYPE.ACCEPT_INVITE:return"已接听";case E.ACTION_TYPE.REJECT_INVITE:return"拒绝通话";case E.ACTION_TYPE.INVITE_TIMEOUT:return"无应答";default:return""}},t.EVENT=p.EVENT,t.CALL_TYPE=E.CALL_TYPE,t}();e.default=D},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]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},s=this&&this.__spreadArrays||function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var i=Array(t),r=0;for(e=0;e<n;e++)for(var s=arguments[e],o=0,a=s.length;o<a;o++,r++)i[r]=s[o];return i};Object.defineProperty(e,"__esModule",{value:!0});var o=n(11),a=n(1),l=n(7),u=n(0),c=n(6),d=n(8),h=n(9),f=n(4),p="TRTCClient",_=function(){function t(t){this._sdkAppID=t.sdkAppID,this._userID=t.userID,this._userSig=t.userSig,this._trtcCalling=t.trtcCalling,this._connectStartTime=0,this._isJoined=!1,this._isPublished=!1,this._localStream=null,this._remoteStreams=[],this._device={video:null,audio:null},this._eventStatController=new h.default,c.default.bindController(this._eventStatController);var e=o.VERSION;u.compareVersion(e,"4.7.0")>=0?o.checkSystemRequirements().then((function(t){t.result||a.default.log(p+".您的浏览器不兼容此应用!\n建议下载最新版Chrome浏览器")})):o.checkSystemRequirements().then((function(t){t||a.default.log(p+".您的浏览器不兼容此应用!\n建议下载最新版Chrome浏览器")})),this.init()}return t.prototype.init=function(){this._client=o.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.getCamera=function(){return i(this,void 0,void 0,(function(){var t,e=this;return r(this,(function(n){switch(n.label){case 0:return[4,o.getCameras()];case 1:return t=n.sent(),a.default.log(p+".getCamera - "+JSON.stringify(t)),t.length>0?this._device.video&&t.some((function(t){return t.deviceId===e._device.video.deviceId}))||(this._device.video=t[0]):this._device.video=null,[2,t]}}))}))},t.prototype.getMicrophone=function(){return i(this,void 0,void 0,(function(){var t,e=this;return r(this,(function(n){switch(n.label){case 0:return[4,o.getMicrophones()];case 1:return t=n.sent(),a.default.log(p+".getMicrophone - "+JSON.stringify(t)),t.length>0?this._device.audio&&t.some((function(t){return t.deviceId===e._device.audio.deviceId}))||(this._device.audio=t[0]):this._device.audio=null,[2,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(p+".switchDevice - params: deviceType:"+t+",deviceID:"+e),this._localStream?this._localStream.switchDevice(t,e):(n={deviceType:t,deviceId:e},this._device[t]=n),[2]}))}))},t.prototype.join=function(t){return i(this,void 0,void 0,(function(){var e,n,i,s,u,c;return r(this,(function(r){switch(r.label){case 0:return[4,this.getCamera()];case 1:return r.sent(),[4,this.getMicrophone()];case 2:if(r.sent(),e=this.getCallType(),!this._device.audio)return a.default.warn(p+".join - invalid microphone"),this._trtcCalling._delegate.onError(f.default.NOT_MICROPHONE_LIST,"invalid microphone"),this._trtcCalling._resetTRTCClient(),[2];if(!this._device.video&&e===l.CALL_TYPE.VIDEO_CALL)return a.default.warn(p+".join - invalid camera"),this._trtcCalling._delegate.onError(f.default.NOT_CAMERA_LIST,"invalid camera"),this._trtcCalling._resetTRTCClient(),[2];if(this._isJoined)return a.default.warn(p+".join - duplicate RtcClient.join() observed"),[2];r.label=3;case 3:return r.trys.push([3,14,,15]),[4,this._client.join({roomId:t})];case 4:if(r.sent(),this._isJoined=!0,this._trtcCalling.getCallStatus()===l.CALL_STATUS.IDLE)return a.default.warn(p+".join - early hangup"),this._trtcCalling.hangup(),[2];if(a.default.log(p+".join - join room success, callType:"+e),e!==l.CALL_TYPE.AUDIO_CALL&&e!==l.CALL_TYPE.VIDEO_CALL)return a.default.log(p+".join - invalid callType"),[2];n={audio:!0,video:!1,userId:this._userID,microphoneId:this._device.audio.deviceId},e===l.CALL_TYPE.VIDEO_CALL&&(n.video=!0,n.cameraId=this._device.video.deviceId),this._localStream=o.createStream(n),this._localStream.setVideoProfile(this._trtcCalling.getVideoQuality()),r.label=5;case 5:return r.trys.push([5,8,,13]),[4,this._localStream.initialize()];case 6:return r.sent(),a.default.log(p+".join - initialize local stream success"),this._localStream.on("player-state-changed",(function(t){a.default.log(p+".join - local stream "+t.type+" player is "+t.state)})),[4,this.publish()];case 7:return r.sent(),a.default.log(p+".publish success"),this._joinedTimestamp=new Date,[3,13];case 8:i=r.sent(),a.default.error(p+".join - failed to initialize local stream - "+i),r.label=9;case 9:return r.trys.push([9,11,,12]),[4,navigator.mediaDevices.getUserMedia({audio:!0,video:!0})];case 10:return s=r.sent(),this.releaseStream(s),[3,12];case 11:return u=r.sent(),this._trtcCalling._delegate.onError(f.default.NOT_MEDIA_ACCESS,JSON.stringify(u)),[3,12];case 12:return[3,13];case 13:return[3,15];case 14:return c=r.sent(),a.default.error(p+".join - join room failed! "+c),[3,15];case 15:return[2]}}))}))},t.prototype.playVideo=function(t){a.default.debug(p+".playVideo - params:",t);var e=t.domID,n=t.type,i=t.userID;if("local"===n&&this._localStream.play(e),"remote"===n){var r=this._remoteStreams.find((function(t){return t.getUserId()===i}));r&&r.play(e)}},t.prototype.stopVideo=function(t){a.default.debug(p+".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(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return a.default.log(p+"-leave._isJoined:"+this._isJoined),a.default.log(p+"-leave._localStream:"+this._localStream),this._isJoined?this._localStream?[4,this.unpublish()]:[3,2]:(a.default.warn(p+".leave - please join() firstly"),[2]);case 1:e.sent(),this._localStream&&this._localStream.stop(),this._localStream&&this._localStream.close(),this._localStream=null,e.label=2;case 2:return e.trys.push([2,4,,5]),[4,this._client.leave()];case 3:return e.sent(),this._isJoined=!1,this._leaveTimestamp=new Date,t=Math.floor((this._leaveTimestamp-this._joinedTimestamp)/1e3),new c.default(d.default.TALK_TIME).setTalkTime(t).setText("talkTime record").setEnd(),[3,5];case 4:throw e.sent(),new Error("leave room error");case 5:return[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(p+".publish - please join() firstly"),[2];if(this._isPublished)return a.default.warn(p+".publish - duplicate RtcClient.publish() observed"),[2];if(this._trtcCalling.getCallStatus()===l.CALL_STATUS.IDLE)return a.default.warn(p+".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(p+".publish - success"),[3,4];case 3:return t=e.sent(),a.default.error(p+".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(){var t;return r(this,(function(e){switch(e.label){case 0:if(!this._isJoined)return a.default.warn(p+".unpublish - please join() firstly"),[2];if(!this._isPublished)return a.default.warn(p+".unpublish - RtcClient.unpublish() called but not published yet"),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this._client.unpublish(this._localStream)];case 2:return e.sent(),a.default.log(p+".unpublish - success"),[3,4];case 3:return t=e.sent(),a.default.error(p+".unpublish - failed to publish local stream "+t),[3,4];case 4:return this._isPublished=!1,[2]}}))}))},t.prototype.handleEvents=function(){var t=this;this._client.on("error",(function(e){a.default.error(p+".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(t){a.default.error(p+".handleEvents - client has been banned for "+t)})),this._client.on("peer-join",(function(e){var n=e.userId;if(a.default.debug(p+".handleEvents - peer-join "+n),t._connectStartTime||(t._connectStartTime=Date.now()),t._trtcCalling.isGroupCall()){var i=t._trtcCalling.getUnHandledInviteeList(),r=s(i,[n]);t._trtcCalling.setUnHandledInviteeList(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.getUnHandledInviteeList(),s=this._trtcCalling.isGroupCall(),a.default.log(p+".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,3]:[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:r.sent(),this._trtcCalling._resetTRTCClient(),this._connectStartTime=0,r.label=3;case 3: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(p+".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,u,c;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(p+".handleEvents - stream subscribed, _remoteStreams:"+this._remoteStreams),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),(u=document.createElement("button")).onclick=function(){a.default.log(p+".remoteStream - resume"),t.resume()},u.setAttribute("class","resume"),u.style.display="none",document.body.appendChild(u),t.play(i),c=setTimeout((function(){u.click(),clearTimeout(c),document.body.removeChild(u)}),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.debug(p+".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(p+".handleEvents - stream-updated, type:"+n+" hasAudio:"+i+" hasVideo:"+r)})),this._client.on("mute-audio",(function(e){a.default.debug(p+".handleEvents - "+e.userId+" mute audio"),t._trtcCalling._delegate.onUserAudioAvailable({userID:e.userId,isAudioAvailable:!1})})),this._client.on("unmute-audio",(function(e){a.default.debug(p+".handleEvents - "+e.userId+" unmute audio"),t._trtcCalling._delegate.onUserAudioAvailable({userID:e.userId,isAudioAvailable:!0})})),this._client.on("mute-video",(function(e){a.default.debug(p+".handleEvents - "+e.userId+" mute video"),t._trtcCalling._delegate.onUserVideoAvailable({userID:e.userId,isVideoAvailable:!1})})),this._client.on("unmute-video",(function(e){a.default.debug(p+".handleEvents - "+e.userId+" unmute video"),t._trtcCalling._delegate.onUserVideoAvailable({userID:e.userId,isVideoAvailable:!0})})),this._client.on("connection-state-changed",(function(t){a.default.log(p+".handleEvents - RtcClient state changed from "+t.prevState+" to "+t.state)}))},t.prototype.muteLocalVideo=function(){this._localStream.muteVideo()},t.prototype.unMuteLocalVideo=function(){this._localStream.unmuteVideo()},t.prototype.muteLocalAudio=function(){this._localStream.muteAudio()},t.prototype.unMuteLocalAudio=function(){this._localStream.unmuteAudio()},t.prototype.switchCallMode=function(t){a.default.log(p+".switchCallMode - type",t);var e=this._localStream.getVideoTrack();switch(t){case l.CALL_TYPE.VIDEO_CALL:this.removeTrack(e),this._trtcCalling.setSwitchCallModeStatus(!0);break;case l.CALL_TYPE.AUDIO_CALL:this.addTrack(e),this._trtcCalling.setSwitchCallModeStatus(!0)}},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(p+".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(),this._trtcCalling.setCallType(l.CALL_TYPE.AUDIO_CALL),[3,4];case 3:return e=n.sent(),a.default.error(p+".removeTrack - failed to removeTrack local stream "+e),this._trtcCalling._delegate.onError(f.default.FAILURE_SWITCH_TO_AUDIO,"switch to audio call error'"),[3,4];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(p+".addTrack ",!t),t?[3,5]:[4,(e=o.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(),this._trtcCalling.setCallType(l.CALL_TYPE.VIDEO_CALL),[3,5];case 4:return i=r.sent(),a.default.error(p+".addTrack - failed to addTrack local stream "+i),this._trtcCalling._delegate.onError(f.default.FAILURE_SWITCH_TO_VIDEO,"switch to video call error'"),[3,5];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 console.log(p+"._isJoined:"+this._isJoined+",_localStream:"+this._localStream),[4,this.leave()];case 1:return t.sent(),[2]}}))}))},t.prototype.releaseStream=function(t){for(var e=t.getTracks(),n=0;n<e.length;n++)e[n].stop()},t}();e.default=_},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";var i=n(2),r=n(12),s=n(28),o=n(18);function a(t){var e=new s(t),n=r(s.prototype.request,e);return i.extend(n,s.prototype,e),i.extend(n,e),n}var l=a(n(15));l.Axios=s,l.create=function(t){return a(o(l.defaults,t))},l.Cancel=n(19),l.CancelToken=n(42),l.isCancel=n(14),l.all=function(t){return Promise.all(t)},l.spread=n(43),l.isAxiosError=n(44),t.exports=l,t.exports.default=l},function(t,e,n){"use strict";var i=n(2),r=n(13),s=n(29),o=n(30),a=n(18);function l(t){this.defaults=t,this.interceptors={request:new s,response:new s}}l.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=a(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[o,void 0],n=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)n=n.then(e.shift(),e.shift());return n},l.prototype.getUri=function(t){return t=a(this.defaults,t),r(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},i.forEach(["delete","get","head","options"],(function(t){l.prototype[t]=function(e,n){return this.request(a(n||{},{method:t,url:e,data:(n||{}).data}))}})),i.forEach(["post","put","patch"],(function(t){l.prototype[t]=function(e,n,i){return this.request(a(i||{},{method:t,url:e,data:n}))}})),t.exports=l},function(t,e,n){"use strict";var i=n(2);function r(){this.handlers=[]}r.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},r.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},r.prototype.forEach=function(t){i.forEach(this.handlers,(function(e){null!==e&&t(e)}))},t.exports=r},function(t,e,n){"use strict";var i=n(2),r=n(31),s=n(14),o=n(15);function a(t){t.cancelToken&&t.cancelToken.throwIfRequested()}t.exports=function(t){return a(t),t.headers=t.headers||{},t.data=r(t.data,t.headers,t.transformRequest),t.headers=i.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),i.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||o.adapter)(t).then((function(e){return a(t),e.data=r(e.data,e.headers,t.transformResponse),e}),(function(e){return s(e)||(a(t),e&&e.response&&(e.response.data=r(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))}},function(t,e,n){"use strict";var i=n(2);t.exports=function(t,e,n){return i.forEach(n,(function(n){t=n(t,e)})),t}},function(t,e){var n,i,r=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(n===setTimeout)return setTimeout(t,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(t){n=s}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(t){i=o}}();var l,u=[],c=!1,d=-1;function h(){c&&l&&(c=!1,l.length?u=l.concat(u):d=-1,u.length&&f())}function f(){if(!c){var t=a(h);c=!0;for(var e=u.length;e;){for(l=u,u=[];++d<e;)l&&l[d].run();d=-1,e=u.length}l=null,c=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===o||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function _(){}r.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];u.push(new p(t,e)),1!==u.length||c||a(f)},p.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=_,r.addListener=_,r.once=_,r.off=_,r.removeListener=_,r.removeAllListeners=_,r.emit=_,r.prependListener=_,r.prependOnceListener=_,r.listeners=function(t){return[]},r.binding=function(t){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(t){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},function(t,e,n){"use strict";var i=n(2);t.exports=function(t,e){i.forEach(t,(function(n,i){i!==e&&i.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[i])}))}},function(t,e,n){"use strict";var i=n(17);t.exports=function(t,e,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?e(i("Request failed with status code "+n.status,n.config,null,n.request,n)):t(n)}},function(t,e,n){"use strict";t.exports=function(t,e,n,i,r){return t.config=e,n&&(t.code=n),t.request=i,t.response=r,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},t}},function(t,e,n){"use strict";var i=n(2);t.exports=i.isStandardBrowserEnv()?{write:function(t,e,n,r,s,o){var a=[];a.push(t+"="+encodeURIComponent(e)),i.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),i.isString(r)&&a.push("path="+r),i.isString(s)&&a.push("domain="+s),!0===o&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(t,e,n){"use strict";var i=n(38),r=n(39);t.exports=function(t,e){return t&&!i(e)?r(t,e):e}},function(t,e,n){"use strict";t.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},function(t,e,n){"use strict";t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},function(t,e,n){"use strict";var i=n(2),r=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,n,s,o={};return t?(i.forEach(t.split("\n"),(function(t){if(s=t.indexOf(":"),e=i.trim(t.substr(0,s)).toLowerCase(),n=i.trim(t.substr(s+1)),e){if(o[e]&&r.indexOf(e)>=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(19);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;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},r=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())}))},s=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]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},o=this&&this.__rest||function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n};Object.defineProperty(e,"__esModule",{value:!0});var a=n(47),l=n(1),u=n(7),c=n(0),d=n(4),h="TSignalClient",f=function(){function t(t,e){this._trtcCalling=t,this._tsignaling=new a(e),this._tsignalingReady=!1,this._joined=!1,this._newInvitationData=null,this.initEvents()}return t.prototype.setLogLevel=function(t){this._tsignaling.setLogLevel(t)},t.prototype.initEvents=function(){var t=this._tsignaling;t.on(a.EVENT.SDK_READY,this.onSdkReady,this),t.on(a.EVENT.SDK_NOT_READY,this.onSdkNotReady,this),t.on(a.EVENT.NEW_INVITATION_RECEIVED,this.onNewInvitationReceived,this),t.on(a.EVENT.INVITEE_ACCEPTED,this.onInviteeAccepted,this),t.on(a.EVENT.INVITEE_REJECTED,this.onInviteeRejected,this),t.on(a.EVENT.INVITATION_CANCELLED,this.onInvitationCancelled,this),t.on(a.EVENT.INVITATION_TIMEOUT,this.onInvitationTimeout,this),t.on(a.EVENT.KICKED_OUT,this.onKickedOut,this),t.on(a.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this)},t.prototype.onSdkReady=function(t){this._tsignalingReady=!0,this._trtcCalling._delegate.onSdkReady(t)},t.prototype.onSdkNotReady=function(t){this._tsignalingReady=!1},t.prototype.onNewInvitationReceived=function(t){return r(this,void 0,void 0,(function(){var e,n,i,r,o,a,f,p,_,g,I;return s(this,(function(s){switch(s.label){case 0:if(e=this._trtcCalling.getCallStatus(),l.default.log(h+".onNewInvitationReceived - params:",t,"currentCallStatus:"+e),n=t.data,i=n.inviter,r=n.inviteeList,o=n.data,a=n.inviteID,f=n.groupID,p=JSON.parse(o),_=!!(f||r.length>=2||p.data&&p.data.userIDs)){if(!p.room_id||0===p.call_end)return this._trtcCalling._delegate.onCallEnd(i,p.call_end||0),[2]}else if(c.isNumber(p.call_end)&&p.call_end>=0)return this._trtcCalling._delegate.onCallEnd(i,p.call_end),[2];if(!f&&this._isOnACall()&&this.judgeSwitchCallMode(p))return this.handleSwitchCallMode(a,p),[2];if(this._isOnACall()||e===u.CALL_STATUS.CALLING)return this.reject({inviteID:a,callType:p.call_type,isBusy:!0}),this._trtcCalling.setSwitchCallModeStatus(!0),this._trtcCalling._delegate.onLineBusy(i,this._trtcCalling.getUserID()),[2];this._trtcCalling.setInviterID(i),_&&(this._trtcCalling.setIsGroupCall(_),this._trtcCalling.setInviteeList(r),this._trtcCalling.setUnHandledInviteeList(r),this._trtcCalling.setGroupID(f)),this._trtcCalling.changeCallStatus(u.CALL_STATUS.CALLING),this._newInvitationData={sponsor:i,userIDList:r,isFromGroup:_,inviteID:a,inviteData:{version:p.version,callType:p.call_type,callEnd:0,roomID:p.room_id}},s.label=1;case 1:return s.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({audio:!0,video:p.call_type===u.CALL_TYPE.VIDEO_CALL})];case 2:return g=s.sent(),l.default.log("getUserMedia info",JSON.stringify(g)),this._trtcCalling._trtcClient.releaseStream(g),this._trtcCalling._delegate.onInvited(this._newInvitationData),[3,4];case 3:return I=s.sent(),this._trtcCalling._delegate.onError(d.default.NOT_MEDIA_ACCESS,JSON.stringify(I)),l.default.error("onNewInvitationReceived getUserMedia failure "+JSON.stringify(I)+". reject remote invite"),this._trtcCalling.reject(),[3,4];case 4:return[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},i={cmd:"switchToVideo"};e.call_type===u.CALL_TYPE.VIDEO_CALL&&(n.switch_to_audio_call="switch_to_audio_call",i.cmd="switchToAudio"),this.accept(n,i),this._trtcCalling.setSwitchCallModeStatus(!1),this._trtcCalling._trtcClient.switchCallMode(this._trtcCalling.getCallType())},t.prototype.judgeSwitchCallMode=function(t){return t.switch_to_audio_call&&"switch_to_audio_call"===t.switch_to_audio_call||t.data&&"switchToAudio"===t.data.cmd||t.data&&"switchToVideo"===t.data.cmd},t.prototype.onInviteeAccepted=function(t){l.default.log(h+".onInviteeAccepted - params:",t);var e=JSON.parse(t.data.data);if(this._trtcCalling.isGroupCall()||!this._isOnACall()||!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){if(!this._trtcCalling.isGroupCall()&&!this._trtcCalling.getSwitchCallModeStatus())return l.default.log(h+".onInviteeRejected - Audio and video switching is not available"),void this._trtcCalling.setSwitchCallModeStatus(!0);l.default.log(h+".onInviteeRejected - params:",t);var e=t.data.invitee,n=t.data.inviter,i=t.data.inviteID,r=JSON.parse(t.data.data);if("line_busy"===r.line_busy||""===r.line_busy||r.data&&r.data.message&&"lineBusy"===r.data.message?this._trtcCalling._delegate.onLineBusy(n,e):this._trtcCalling._delegate.onReject(e),this._trtcCalling.delInviterInviteID(i),this._trtcCalling.isGroupCall()){var s=this._trtcCalling.getUnHandledInviteeList();s=s.filter((function(t){return t!==e})),this._trtcCalling.setUnHandledInviteeList(s),0===s.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(e,0),this._trtcCalling._resetTRTCClient())))}else this._trtcCalling._resetTRTCClient()},t.prototype.onInvitationCancelled=function(t){l.default.log(h+".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(),d=this._trtcCalling.getRemoteStreamCount();if(l.default.log(h+".onInvitationTimeout - params:",t,"currentUserID:"+s+" isInviter:"+a+" isGroupCall:"+o+" isOnACall:"+c+" remoteStreamCount:"+d),this._trtcCalling.delInviterInviteID(t.data.inviteID),r&&a)return this._trtcCalling._delegate.onNoResp(n,i),void(o&&0!==d||(this._trtcCalling._resetTRTCClient(),this._trtcCalling._delegate.onCallEnd(n,0)));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===d&&0===p.length&&(c?this.lastOneHangup({userIDList:[n],callType:this._trtcCalling.getCallType(),callEnd:0}):(this._trtcCalling._delegate.onCallEnd(n,0),this._trtcCalling.changeCallStatus(u.CALL_STATUS.IDLE)),this._trtcCalling._resetTRTCClient())}else this._trtcCalling._delegate.onCallEnd(n,0),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(h+".onKickedOut"),this._trtcCalling._delegate.onKickedOut(),this._trtcCalling.changeCallStatus(u.CALL_STATUS.IDLE)},t.prototype.onNetStateChange=function(){l.default.debug(h+".onNetStateChange")},t.prototype.login=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2,this._tsignaling.login(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,i,r,o,a,l;return s(this,(function(s){switch(s.label){case 0:return e=t.userID,n=t.type,i=t.roomID,r=t.timeout,o=t.offlinePushInfo,a=t.userIDList,[4,this._tsignaling.invite({userID:e,data:JSON.stringify(this.handleNewSignaling({version:0,call_type:n,room_id:i},{userIDs:a})),timeout:r,offlinePushInfo:o})];case 1:return l=s.sent(),this._trtcCalling.isGroupCall()||!this._trtcCalling.isInviter()||this._joined||this._trtcCalling.getCallStatus()!==u.CALL_STATUS.CALLING?[3,3]:[4,this._trtcCalling._trtcClient.join(this._trtcCalling._roomID)];case 2:s.sent(),this._trtcCalling.changeCallStatus(u.CALL_STATUS.CONNECTED),this._joined=!0,s.label=3;case 3:return[2,l]}}))}))},t.prototype.inviteInGroup=function(t){return r(this,void 0,void 0,(function(){var e,n,i,r,o,a,l;return s(this,(function(s){switch(s.label){case 0:return e=t.groupID,n=t.userIDList,i=t.roomID,r=t.type,o=t.timeout,a=t.offlinePushInfo,l=null,e?[3,2]:[4,this.inviteInGroupTRTC(t)];case 1:return l=s.sent(),[3,4];case 2:return[4,this._tsignaling.inviteInGroup({groupID:e,inviteeList:n,data:JSON.stringify(this.handleNewSignaling({version:0,call_type:r,room_id:i})),timeout:o,offlinePushInfo:a})];case 3:l=s.sent(),s.label=4;case 4:return!this._trtcCalling.isInviter()||this._joined||this._trtcCalling.getCallStatus()!==u.CALL_STATUS.CALLING?[3,6]:[4,this._trtcCalling._trtcClient.join(this._trtcCalling._roomID)];case 5:s.sent(),this._trtcCalling.changeCallStatus(u.CALL_STATUS.CONNECTED),this._joined=!0,s.label=6;case 6:return[2,l]}}))}))},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:[]},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,[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(h+".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:"hangup"})),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:"hangup"})),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},l={cmd:"switchToVideo"},o===u.MODE_TYPE.AUDIO&&(a.switch_to_audio_call="switch_to_audio_call",l.cmd="switchToAudio"),[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=f},function(t,e){t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(20),r=n(1),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}();e.default=u},function(t,e,n){"use strict";n.r(e);var i=n(1);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;var e=Object.getPrototypeOf(t);if(null===e)return!0;var 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}));
|