ysyt-agent-sdk 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -524,7 +524,7 @@ const xt=A=>(e,t)=>{void 0!==t?t.addInitializer(()=>{customElements.define(A,e)}
|
|
|
524
524
|
* @copyright Chen, Yi-Cyuan 2014-2023
|
|
525
525
|
* @license MIT
|
|
526
526
|
*/
|
|
527
|
-
ws=Qs,function(){var t="input is invalid type",s="object"==typeof window,i=s?window:{};i.JS_MD5_NO_WINDOW&&(s=!1);var n=!s&&"object"==typeof self,r=!i.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;r?i=Bs:n&&(i=self);var o,a=!i.JS_MD5_NO_COMMON_JS&&ws.exports,V=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,c="0123456789abcdef".split(""),l=[128,32768,8388608,-2147483648],h=[0,8,16,24],g=["hex","array","digest","buffer","arrayBuffer","base64"],q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),d=[];if(V){var p=new ArrayBuffer(68);o=new Uint8Array(p),d=new Uint32Array(p)}var u=Array.isArray;!i.JS_MD5_NO_NODE_JS&&u||(u=function(A){return"[object Array]"===Object.prototype.toString.call(A)});var m=ArrayBuffer.isView;!V||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&m||(m=function(A){return"object"==typeof A&&A.buffer&&A.buffer.constructor===ArrayBuffer});var C=function(A){var e=typeof A;if("string"===e)return[A,!0];if("object"!==e||null===A)throw new Error(t);if(V&&A.constructor===ArrayBuffer)return[new Uint8Array(A),!1];if(!u(A)&&!m(A))throw new Error(t);return[A,!1]},E=function(A){return function(e){return new w(!0).update(e)[A]()}},I=function(s){var n,r=A,o=e.Buffer;return n=o.from&&!i.JS_MD5_NO_BUFFER_FROM?o.from:function(A){return new o(A)},function(A){if("string"==typeof A)return r.createHash("md5").update(A,"utf8").digest("hex");if(null==A)throw new Error(t);return A.constructor===ArrayBuffer&&(A=new Uint8Array(A)),u(A)||m(A)||A.constructor===o?r.createHash("md5").update(n(A)).digest("hex"):s(A)}},M=function(A){return function(e,t){return new f(e,!0).update(t)[A]()}};function w(A){if(A)d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d,this.buffer8=o;else if(V){var e=new ArrayBuffer(68);this.buffer8=new Uint8Array(e),this.blocks=new Uint32Array(e)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function f(A,e){var t,s=C(A);if(A=s[0],s[1]){var i,n=[],r=A.length,o=0;for(t=0;t<r;++t)(i=A.charCodeAt(t))<128?n[o++]=i:i<2048?(n[o++]=192|i>>>6,n[o++]=128|63&i):i<55296||i>=57344?(n[o++]=224|i>>>12,n[o++]=128|i>>>6&63,n[o++]=128|63&i):(i=65536+((1023&i)<<10|1023&A.charCodeAt(++t)),n[o++]=240|i>>>18,n[o++]=128|i>>>12&63,n[o++]=128|i>>>6&63,n[o++]=128|63&i);A=n}A.length>64&&(A=new w(!0).update(A).array());var a=[],V=[];for(t=0;t<64;++t){var c=A[t]||0;a[t]=92^c,V[t]=54^c}w.call(this,e),this.update(V),this.oKeyPad=a,this.inner=!0,this.sharedMemory=e}w.prototype.update=function(A){if(this.finalized)throw new Error("finalize already called");var e=C(A);A=e[0];for(var t,s,i=e[1],n=0,r=A.length,o=this.blocks,a=this.buffer8;n<r;){if(this.hashed&&(this.hashed=!1,o[0]=o[16],o[16]=o[1]=o[2]=o[3]=o[4]=o[5]=o[6]=o[7]=o[8]=o[9]=o[10]=o[11]=o[12]=o[13]=o[14]=o[15]=0),i)if(V)for(s=this.start;n<r&&s<64;++n)(t=A.charCodeAt(n))<128?a[s++]=t:t<2048?(a[s++]=192|t>>>6,a[s++]=128|63&t):t<55296||t>=57344?(a[s++]=224|t>>>12,a[s++]=128|t>>>6&63,a[s++]=128|63&t):(t=65536+((1023&t)<<10|1023&A.charCodeAt(++n)),a[s++]=240|t>>>18,a[s++]=128|t>>>12&63,a[s++]=128|t>>>6&63,a[s++]=128|63&t);else for(s=this.start;n<r&&s<64;++n)(t=A.charCodeAt(n))<128?o[s>>>2]|=t<<h[3&s++]:t<2048?(o[s>>>2]|=(192|t>>>6)<<h[3&s++],o[s>>>2]|=(128|63&t)<<h[3&s++]):t<55296||t>=57344?(o[s>>>2]|=(224|t>>>12)<<h[3&s++],o[s>>>2]|=(128|t>>>6&63)<<h[3&s++],o[s>>>2]|=(128|63&t)<<h[3&s++]):(t=65536+((1023&t)<<10|1023&A.charCodeAt(++n)),o[s>>>2]|=(240|t>>>18)<<h[3&s++],o[s>>>2]|=(128|t>>>12&63)<<h[3&s++],o[s>>>2]|=(128|t>>>6&63)<<h[3&s++],o[s>>>2]|=(128|63&t)<<h[3&s++]);else if(V)for(s=this.start;n<r&&s<64;++n)a[s++]=A[n];else for(s=this.start;n<r&&s<64;++n)o[s>>>2]|=A[n]<<h[3&s++];this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},w.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var A=this.blocks,e=this.lastByteIndex;A[e>>>2]|=l[3&e],e>=56&&(this.hashed||this.hash(),A[0]=A[16],A[16]=A[1]=A[2]=A[3]=A[4]=A[5]=A[6]=A[7]=A[8]=A[9]=A[10]=A[11]=A[12]=A[13]=A[14]=A[15]=0),A[14]=this.bytes<<3,A[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},w.prototype.hash=function(){var A,e,t,s,i,n,r=this.blocks;this.first?e=((e=((A=((A=r[0]-680876937)<<7|A>>>25)-271733879|0)^(t=((t=(-271733879^(s=((s=(-1732584194^2004318071&A)+r[1]-117830708)<<12|s>>>20)+A|0)&(-271733879^A))+r[2]-1126478375)<<17|t>>>15)+s|0)&(s^A))+r[3]-1316259209)<<22|e>>>10)+t|0:(A=this.h0,e=this.h1,t=this.h2,e=((e+=((A=((A+=((s=this.h3)^e&(t^s))+r[0]-680876936)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[1]-389564586)<<12|s>>>20)+A|0)&(A^e))+r[2]+606105819)<<17|t>>>15)+s|0)&(s^A))+r[3]-1044525330)<<22|e>>>10)+t|0),e=((e+=((A=((A+=(s^e&(t^s))+r[4]-176418897)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[5]+1200080426)<<12|s>>>20)+A|0)&(A^e))+r[6]-1473231341)<<17|t>>>15)+s|0)&(s^A))+r[7]-45705983)<<22|e>>>10)+t|0,e=((e+=((A=((A+=(s^e&(t^s))+r[8]+1770035416)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[9]-1958414417)<<12|s>>>20)+A|0)&(A^e))+r[10]-42063)<<17|t>>>15)+s|0)&(s^A))+r[11]-1990404162)<<22|e>>>10)+t|0,e=((e+=((A=((A+=(s^e&(t^s))+r[12]+1804603682)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[13]-40341101)<<12|s>>>20)+A|0)&(A^e))+r[14]-1502002290)<<17|t>>>15)+s|0)&(s^A))+r[15]+1236535329)<<22|e>>>10)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[1]-165796510)<<5|A>>>27)+e|0)^e))+r[6]-1069501632)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[11]+643717713)<<14|t>>>18)+s|0)^s))+r[0]-373897302)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[5]-701558691)<<5|A>>>27)+e|0)^e))+r[10]+38016083)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[15]-660478335)<<14|t>>>18)+s|0)^s))+r[4]-405537848)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[9]+568446438)<<5|A>>>27)+e|0)^e))+r[14]-1019803690)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[3]-187363961)<<14|t>>>18)+s|0)^s))+r[8]+1163531501)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[13]-1444681467)<<5|A>>>27)+e|0)^e))+r[2]-51403784)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[7]+1735328473)<<14|t>>>18)+s|0)^s))+r[12]-1926607734)<<20|e>>>12)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[5]-378558)<<4|A>>>28)+e|0))+r[8]-2022574463)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[11]+1839030562)<<16|t>>>16)+s|0))+r[14]-35309556)<<23|e>>>9)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[1]-1530992060)<<4|A>>>28)+e|0))+r[4]+1272893353)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[7]-155497632)<<16|t>>>16)+s|0))+r[10]-1094730640)<<23|e>>>9)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[13]+681279174)<<4|A>>>28)+e|0))+r[0]-358537222)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[3]-722521979)<<16|t>>>16)+s|0))+r[6]+76029189)<<23|e>>>9)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[9]-640364487)<<4|A>>>28)+e|0))+r[12]-421815835)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[15]+530742520)<<16|t>>>16)+s|0))+r[2]-995338651)<<23|e>>>9)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[0]-198630844)<<6|A>>>26)+e|0)|~t))+r[7]+1126891415)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[14]-1416354905)<<15|t>>>17)+s|0)|~A))+r[5]-57434055)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[12]+1700485571)<<6|A>>>26)+e|0)|~t))+r[3]-1894986606)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[10]-1051523)<<15|t>>>17)+s|0)|~A))+r[1]-2054922799)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[8]+1873313359)<<6|A>>>26)+e|0)|~t))+r[15]-30611744)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[6]-1560198380)<<15|t>>>17)+s|0)|~A))+r[13]+1309151649)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[4]-145523070)<<6|A>>>26)+e|0)|~t))+r[11]-1120210379)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[2]+718787259)<<15|t>>>17)+s|0)|~A))+r[9]-343485551)<<21|e>>>11)+t|0,this.first?(this.h0=A+1732584193|0,this.h1=e-271733879|0,this.h2=t-1732584194|0,this.h3=s+271733878|0,this.first=!1):(this.h0=this.h0+A|0,this.h1=this.h1+e|0,this.h2=this.h2+t|0,this.h3=this.h3+s|0)},w.prototype.hex=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,s=this.h3;return c[A>>>4&15]+c[15&A]+c[A>>>12&15]+c[A>>>8&15]+c[A>>>20&15]+c[A>>>16&15]+c[A>>>28&15]+c[A>>>24&15]+c[e>>>4&15]+c[15&e]+c[e>>>12&15]+c[e>>>8&15]+c[e>>>20&15]+c[e>>>16&15]+c[e>>>28&15]+c[e>>>24&15]+c[t>>>4&15]+c[15&t]+c[t>>>12&15]+c[t>>>8&15]+c[t>>>20&15]+c[t>>>16&15]+c[t>>>28&15]+c[t>>>24&15]+c[s>>>4&15]+c[15&s]+c[s>>>12&15]+c[s>>>8&15]+c[s>>>20&15]+c[s>>>16&15]+c[s>>>28&15]+c[s>>>24&15]},w.prototype.toString=w.prototype.hex,w.prototype.digest=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,s=this.h3;return[255&A,A>>>8&255,A>>>16&255,A>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&s,s>>>8&255,s>>>16&255,s>>>24&255]},w.prototype.array=w.prototype.digest,w.prototype.arrayBuffer=function(){this.finalize();var A=new ArrayBuffer(16),e=new Uint32Array(A);return e[0]=this.h0,e[1]=this.h1,e[2]=this.h2,e[3]=this.h3,A},w.prototype.buffer=w.prototype.arrayBuffer,w.prototype.base64=function(){for(var A,e,t,s="",i=this.array(),n=0;n<15;)A=i[n++],e=i[n++],t=i[n++],s+=q[A>>>2]+q[63&(A<<4|e>>>4)]+q[63&(e<<2|t>>>6)]+q[63&t];return A=i[n],s+=q[A>>>2]+q[A<<4&63]+"=="},f.prototype=new w,f.prototype.finalize=function(){if(w.prototype.finalize.call(this),this.inner){this.inner=!1;var A=this.array();w.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(A),w.prototype.finalize.call(this)}};var B=function(){var A=E("hex");r&&(A=I(A)),A.create=function(){return new w},A.update=function(e){return A.create().update(e)};for(var e=0;e<g.length;++e){var t=g[e];A[t]=E(t)}return A}();B.md5=B,B.md5.hmac=function(){var A=M("hex");A.create=function(A){return new f(A)},A.update=function(e,t){return A.create(e).update(t)};for(var e=0;e<g.length;++e){var t=g[e];A[t]=M(t)}return A}(),a?ws.exports=B:i.md5=B}();var Ss=Qs.exports;const Ts=(A,e)=>{const t=Date.now(),s=`${A}:${t}:${Ss.md5(`${e}${t}`)}`,i=(new TextEncoder).encode(s);return btoa(String.fromCharCode(...i))},ys=A=>/^\d+$/.test(A),Ds="/v1/aicc/bmserver",Rs="/v1/aicc/ccs";let Us="",ks="",Gs="",Fs="";function Ys(){const A=Ts(ks,Gs);return fs.create({prefixUrl:`${Us}`,timeout:!1,headers:{Authorization:A},hooks:{afterResponse:[async(A,e,t)=>{if(-1!==t.url.indexOf("heartbeat"))return t;const s=await t.clone().json();if(0!==s.code)throw new Error(JSON.stringify(s)||"请求失败");return t.json=async()=>s,t}]}})}async function xs(A,e){const t=Ys(),s="api/"+A.replace(/^\/+/,"");return t.post(s,{json:e}).json()}const vs=A=>xs(`${Rs}/state/change`,A),Zs=()=>async function(A,e){const t=Ys(),s=A.replace(/^\/+/,"");return t.post(s,{json:e}).json()}("/heartbeat",{}),Os=A=>xs(`${Rs}/call/whisper`,A);class Ns{constructor(){this.roleData={agentInfo:()=>{if(!Ve.agentInfo?.agent_no)throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:A=>{if(!A.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:A=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:e}=Ve.agentInfo;if(!e.split(",").map(A=>Number(A)).includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(A,e)=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(2===A&&("通话中"===e||"整理"===e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},setAgentExplicit:A=>{const{out_display_select_switch:e,out_display_data:t}=Ve.agentInfo;if(1!==e)throw new Error(JSON.stringify({code:1,msg:"当前坐席设置未开启允许指定外显"}));if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "number" is required'}));if(!(t||"").split("#").includes(A))throw new Error(JSON.stringify({code:1,msg:"当前外显号码不存在"}))}}}formatDate(A){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")} ${String(A.getHours()).padStart(2,"0")}:${String(A.getMinutes()).padStart(2,"0")}:${String(A.getSeconds()).padStart(2,"0")}`}async _agentLogin(A){try{const t=await(e={agent_no:A},xs(`${Rs}/agent/login`,e));Ve.agentInfo=t.data}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}var e}async _changeState(A){try{Ve.autoStateTimer&&(clearTimeout(Ve.autoStateTimer),Ve.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e,{agent_no:n}=Ve.agentInfo;await vs({agent_no:n,state_name:i,state:s}),s===exports.AgentStatus.IDLE?le.updateActionConfigs(ft):s===exports.AgentStatus.BUSY&&le.updateActionConfigs(Bt),Ve.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async _getInCallCrmDetail(A){try{const{phone:e}=A.data,t={};ys(e)?t.phone=e:t.trace_id=e;const s=await(A=>xs(`${Ds}/crm/popups`,A))({...t});A.success?.(s)}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async changeDevice(A){try{if(le.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{device:s}=e;1===s&&le.updateAnswerDevice(s),this.roleData.changeDevice(s);const{agent_no:i}=Ve.agentInfo;await(A=>xs(`${Rs}/device/change`,A))({agent_no:i,answer_device:s}),le.updateAnswerDevice(s);const n=le.get("actionConfigs");le.updateActionConfigs(n),2===s&&Ve.stateObject.state===exports.AgentStatus.UNREGISTERED&&await this._changeState({data:{...Ve.stateBeforeChange,state_name:Ve.stateBeforeChange.state===exports.AgentStatus.IDLE?"空闲":"忙碌"}}),t?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async changeState(A){try{if(le.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));Ve.autoStateTimer&&(clearTimeout(Ve.autoStateTimer),Ve.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e;this.roleData.changeState(s,i);const{agent_no:n}=Ve.agentInfo;await vs({agent_no:n,state_name:i,state:s}),(Ve.stateObject.state===exports.AgentStatus.IDLE||Ve.stateObject.state===exports.AgentStatus.BUSY&&"整理"!==i)&&(Ve.stateBeforeChange=Ve.stateObject),s===exports.AgentStatus.IDLE?le.updateActionConfigs(ft):s===exports.AgentStatus.BUSY&&le.updateActionConfigs(Bt),Ve.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async getIdleAgentList(A){const{agent_no:e}=Ve.agentInfo;try{this.roleData.agentInfo();const t=await(A=>xs(`${Rs}/agent/free`,A))({agent_no:e});A.success?.(t)}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async getAgentState(A){try{const e=await xs(`${Ds}/agent/statecfg/list`,{}),t=(e.data||[]).filter(A=>0===A.enable).filter(A=>0!==A.state&&3!==A.state).filter(A=>"通话中"!==A.state_name&&"整理"!==A.state_name&&"未注册"!==A.state_name&&"离线接听"!==A.state_name).map(A=>({state:A.state,state_name:A.state_name})).reverse();A.success?.({...e,data:t})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async setAgentExplicit(A){try{this.roleData.agentInfo(),this.roleData.requestInfo(A),this.roleData.setAgentExplicit(A.data.number);const{agent_id:e}=Ve.agentInfo;await(A=>xs(`${Ds}/agent/update`,A))({agent_id:e,out_display_number:A.data.number}),le.updateSelectOutNumber(A.data.number),A.success?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async checkAgentLogin(A){try{this.roleData.requestInfo(A);const{agent_no:e}=A.data;if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "agent_no" is required'}));const t=await(A=>xs(`${Rs}/agent/islogin`,A))({agent_no:e});A.success?.(t)}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async getCallRecord(A){try{this.roleData.agentInfo();const{success:e}=A,t=new Date,s=new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0),i=new Date(t.getFullYear(),t.getMonth(),t.getDate(),23,59,59),n=[this.formatDate(s),this.formatDate(i)],{agent_no:r}=Ve.agentInfo,o=await(A=>xs(`${Ds}/agent/recordpage`,A))({start_time:n[0],end_time:n[1],page_no:1,page_size:10,agent_no:r}),{code:a,msg:V,data:c}=o;e?.({code:a,msg:V,data:c})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async logout(A){this.roleData.agentInfo();try{const{agent_no:e}=Ve.agentInfo,{data:t,success:s}=A;await(A=>xs(`${Rs}/agent/logout`,A))({...t,agent_no:e}),s?.({code:0,msg:""})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async listenCall(A){try{const{agent_no:e}=Ve.agentInfo,{data:t,success:s}=A;if(this.roleData.agentInfo(),this.roleData.requestInfo(A),!t.monitored_agent_no)throw new Error(JSON.stringify({code:1,msg:'Parameter "monitored_agent_no" is required'}));await(A=>xs(`${Rs}/call/monitor`,A))({...t,monitor_agent_no:e}),Ve.monitoredAgentNo=t.monitored_agent_no,s?.({code:0,msg:""})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async earCall(A){try{const{agentInfo:e,monitoredAgentNo:t}=Ve,{agent_no:s}=e;this.roleData.agentInfo(),this.roleData.requestInfo(A);const{success:i}=A;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await Os({monitored_agent_no:t,monitor_agent_no:s}),i?.({code:0,msg:""})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async stopEarCall(A){try{const{agentInfo:e,earSpeakAgent:t}=Ve;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前没有正在耳语的坐席"}));const{agent_no:s}=e;this.roleData.agentInfo();const{success:i}=A;await Os({monitor_agent_no:s,monitored_agent_no:t}),i?.({code:0,msg:""})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}}let Ks=class extends Et{constructor(){super(...arguments),this.type="info",this.content="",this.duration=3e3}static{this.styles=Ce`
|
|
527
|
+
ws=Qs,function(){var t="input is invalid type",s="object"==typeof window,i=s?window:{};i.JS_MD5_NO_WINDOW&&(s=!1);var n=!s&&"object"==typeof self,r=!i.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;r?i=Bs:n&&(i=self);var o,a=!i.JS_MD5_NO_COMMON_JS&&ws.exports,V=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,c="0123456789abcdef".split(""),l=[128,32768,8388608,-2147483648],h=[0,8,16,24],g=["hex","array","digest","buffer","arrayBuffer","base64"],q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),d=[];if(V){var p=new ArrayBuffer(68);o=new Uint8Array(p),d=new Uint32Array(p)}var u=Array.isArray;!i.JS_MD5_NO_NODE_JS&&u||(u=function(A){return"[object Array]"===Object.prototype.toString.call(A)});var m=ArrayBuffer.isView;!V||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&m||(m=function(A){return"object"==typeof A&&A.buffer&&A.buffer.constructor===ArrayBuffer});var C=function(A){var e=typeof A;if("string"===e)return[A,!0];if("object"!==e||null===A)throw new Error(t);if(V&&A.constructor===ArrayBuffer)return[new Uint8Array(A),!1];if(!u(A)&&!m(A))throw new Error(t);return[A,!1]},E=function(A){return function(e){return new w(!0).update(e)[A]()}},I=function(s){var n,r=A,o=e.Buffer;return n=o.from&&!i.JS_MD5_NO_BUFFER_FROM?o.from:function(A){return new o(A)},function(A){if("string"==typeof A)return r.createHash("md5").update(A,"utf8").digest("hex");if(null==A)throw new Error(t);return A.constructor===ArrayBuffer&&(A=new Uint8Array(A)),u(A)||m(A)||A.constructor===o?r.createHash("md5").update(n(A)).digest("hex"):s(A)}},M=function(A){return function(e,t){return new f(e,!0).update(t)[A]()}};function w(A){if(A)d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d,this.buffer8=o;else if(V){var e=new ArrayBuffer(68);this.buffer8=new Uint8Array(e),this.blocks=new Uint32Array(e)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function f(A,e){var t,s=C(A);if(A=s[0],s[1]){var i,n=[],r=A.length,o=0;for(t=0;t<r;++t)(i=A.charCodeAt(t))<128?n[o++]=i:i<2048?(n[o++]=192|i>>>6,n[o++]=128|63&i):i<55296||i>=57344?(n[o++]=224|i>>>12,n[o++]=128|i>>>6&63,n[o++]=128|63&i):(i=65536+((1023&i)<<10|1023&A.charCodeAt(++t)),n[o++]=240|i>>>18,n[o++]=128|i>>>12&63,n[o++]=128|i>>>6&63,n[o++]=128|63&i);A=n}A.length>64&&(A=new w(!0).update(A).array());var a=[],V=[];for(t=0;t<64;++t){var c=A[t]||0;a[t]=92^c,V[t]=54^c}w.call(this,e),this.update(V),this.oKeyPad=a,this.inner=!0,this.sharedMemory=e}w.prototype.update=function(A){if(this.finalized)throw new Error("finalize already called");var e=C(A);A=e[0];for(var t,s,i=e[1],n=0,r=A.length,o=this.blocks,a=this.buffer8;n<r;){if(this.hashed&&(this.hashed=!1,o[0]=o[16],o[16]=o[1]=o[2]=o[3]=o[4]=o[5]=o[6]=o[7]=o[8]=o[9]=o[10]=o[11]=o[12]=o[13]=o[14]=o[15]=0),i)if(V)for(s=this.start;n<r&&s<64;++n)(t=A.charCodeAt(n))<128?a[s++]=t:t<2048?(a[s++]=192|t>>>6,a[s++]=128|63&t):t<55296||t>=57344?(a[s++]=224|t>>>12,a[s++]=128|t>>>6&63,a[s++]=128|63&t):(t=65536+((1023&t)<<10|1023&A.charCodeAt(++n)),a[s++]=240|t>>>18,a[s++]=128|t>>>12&63,a[s++]=128|t>>>6&63,a[s++]=128|63&t);else for(s=this.start;n<r&&s<64;++n)(t=A.charCodeAt(n))<128?o[s>>>2]|=t<<h[3&s++]:t<2048?(o[s>>>2]|=(192|t>>>6)<<h[3&s++],o[s>>>2]|=(128|63&t)<<h[3&s++]):t<55296||t>=57344?(o[s>>>2]|=(224|t>>>12)<<h[3&s++],o[s>>>2]|=(128|t>>>6&63)<<h[3&s++],o[s>>>2]|=(128|63&t)<<h[3&s++]):(t=65536+((1023&t)<<10|1023&A.charCodeAt(++n)),o[s>>>2]|=(240|t>>>18)<<h[3&s++],o[s>>>2]|=(128|t>>>12&63)<<h[3&s++],o[s>>>2]|=(128|t>>>6&63)<<h[3&s++],o[s>>>2]|=(128|63&t)<<h[3&s++]);else if(V)for(s=this.start;n<r&&s<64;++n)a[s++]=A[n];else for(s=this.start;n<r&&s<64;++n)o[s>>>2]|=A[n]<<h[3&s++];this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},w.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var A=this.blocks,e=this.lastByteIndex;A[e>>>2]|=l[3&e],e>=56&&(this.hashed||this.hash(),A[0]=A[16],A[16]=A[1]=A[2]=A[3]=A[4]=A[5]=A[6]=A[7]=A[8]=A[9]=A[10]=A[11]=A[12]=A[13]=A[14]=A[15]=0),A[14]=this.bytes<<3,A[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},w.prototype.hash=function(){var A,e,t,s,i,n,r=this.blocks;this.first?e=((e=((A=((A=r[0]-680876937)<<7|A>>>25)-271733879|0)^(t=((t=(-271733879^(s=((s=(-1732584194^2004318071&A)+r[1]-117830708)<<12|s>>>20)+A|0)&(-271733879^A))+r[2]-1126478375)<<17|t>>>15)+s|0)&(s^A))+r[3]-1316259209)<<22|e>>>10)+t|0:(A=this.h0,e=this.h1,t=this.h2,e=((e+=((A=((A+=((s=this.h3)^e&(t^s))+r[0]-680876936)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[1]-389564586)<<12|s>>>20)+A|0)&(A^e))+r[2]+606105819)<<17|t>>>15)+s|0)&(s^A))+r[3]-1044525330)<<22|e>>>10)+t|0),e=((e+=((A=((A+=(s^e&(t^s))+r[4]-176418897)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[5]+1200080426)<<12|s>>>20)+A|0)&(A^e))+r[6]-1473231341)<<17|t>>>15)+s|0)&(s^A))+r[7]-45705983)<<22|e>>>10)+t|0,e=((e+=((A=((A+=(s^e&(t^s))+r[8]+1770035416)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[9]-1958414417)<<12|s>>>20)+A|0)&(A^e))+r[10]-42063)<<17|t>>>15)+s|0)&(s^A))+r[11]-1990404162)<<22|e>>>10)+t|0,e=((e+=((A=((A+=(s^e&(t^s))+r[12]+1804603682)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[13]-40341101)<<12|s>>>20)+A|0)&(A^e))+r[14]-1502002290)<<17|t>>>15)+s|0)&(s^A))+r[15]+1236535329)<<22|e>>>10)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[1]-165796510)<<5|A>>>27)+e|0)^e))+r[6]-1069501632)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[11]+643717713)<<14|t>>>18)+s|0)^s))+r[0]-373897302)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[5]-701558691)<<5|A>>>27)+e|0)^e))+r[10]+38016083)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[15]-660478335)<<14|t>>>18)+s|0)^s))+r[4]-405537848)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[9]+568446438)<<5|A>>>27)+e|0)^e))+r[14]-1019803690)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[3]-187363961)<<14|t>>>18)+s|0)^s))+r[8]+1163531501)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[13]-1444681467)<<5|A>>>27)+e|0)^e))+r[2]-51403784)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[7]+1735328473)<<14|t>>>18)+s|0)^s))+r[12]-1926607734)<<20|e>>>12)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[5]-378558)<<4|A>>>28)+e|0))+r[8]-2022574463)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[11]+1839030562)<<16|t>>>16)+s|0))+r[14]-35309556)<<23|e>>>9)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[1]-1530992060)<<4|A>>>28)+e|0))+r[4]+1272893353)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[7]-155497632)<<16|t>>>16)+s|0))+r[10]-1094730640)<<23|e>>>9)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[13]+681279174)<<4|A>>>28)+e|0))+r[0]-358537222)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[3]-722521979)<<16|t>>>16)+s|0))+r[6]+76029189)<<23|e>>>9)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[9]-640364487)<<4|A>>>28)+e|0))+r[12]-421815835)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[15]+530742520)<<16|t>>>16)+s|0))+r[2]-995338651)<<23|e>>>9)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[0]-198630844)<<6|A>>>26)+e|0)|~t))+r[7]+1126891415)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[14]-1416354905)<<15|t>>>17)+s|0)|~A))+r[5]-57434055)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[12]+1700485571)<<6|A>>>26)+e|0)|~t))+r[3]-1894986606)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[10]-1051523)<<15|t>>>17)+s|0)|~A))+r[1]-2054922799)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[8]+1873313359)<<6|A>>>26)+e|0)|~t))+r[15]-30611744)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[6]-1560198380)<<15|t>>>17)+s|0)|~A))+r[13]+1309151649)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[4]-145523070)<<6|A>>>26)+e|0)|~t))+r[11]-1120210379)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[2]+718787259)<<15|t>>>17)+s|0)|~A))+r[9]-343485551)<<21|e>>>11)+t|0,this.first?(this.h0=A+1732584193|0,this.h1=e-271733879|0,this.h2=t-1732584194|0,this.h3=s+271733878|0,this.first=!1):(this.h0=this.h0+A|0,this.h1=this.h1+e|0,this.h2=this.h2+t|0,this.h3=this.h3+s|0)},w.prototype.hex=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,s=this.h3;return c[A>>>4&15]+c[15&A]+c[A>>>12&15]+c[A>>>8&15]+c[A>>>20&15]+c[A>>>16&15]+c[A>>>28&15]+c[A>>>24&15]+c[e>>>4&15]+c[15&e]+c[e>>>12&15]+c[e>>>8&15]+c[e>>>20&15]+c[e>>>16&15]+c[e>>>28&15]+c[e>>>24&15]+c[t>>>4&15]+c[15&t]+c[t>>>12&15]+c[t>>>8&15]+c[t>>>20&15]+c[t>>>16&15]+c[t>>>28&15]+c[t>>>24&15]+c[s>>>4&15]+c[15&s]+c[s>>>12&15]+c[s>>>8&15]+c[s>>>20&15]+c[s>>>16&15]+c[s>>>28&15]+c[s>>>24&15]},w.prototype.toString=w.prototype.hex,w.prototype.digest=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,s=this.h3;return[255&A,A>>>8&255,A>>>16&255,A>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&s,s>>>8&255,s>>>16&255,s>>>24&255]},w.prototype.array=w.prototype.digest,w.prototype.arrayBuffer=function(){this.finalize();var A=new ArrayBuffer(16),e=new Uint32Array(A);return e[0]=this.h0,e[1]=this.h1,e[2]=this.h2,e[3]=this.h3,A},w.prototype.buffer=w.prototype.arrayBuffer,w.prototype.base64=function(){for(var A,e,t,s="",i=this.array(),n=0;n<15;)A=i[n++],e=i[n++],t=i[n++],s+=q[A>>>2]+q[63&(A<<4|e>>>4)]+q[63&(e<<2|t>>>6)]+q[63&t];return A=i[n],s+=q[A>>>2]+q[A<<4&63]+"=="},f.prototype=new w,f.prototype.finalize=function(){if(w.prototype.finalize.call(this),this.inner){this.inner=!1;var A=this.array();w.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(A),w.prototype.finalize.call(this)}};var B=function(){var A=E("hex");r&&(A=I(A)),A.create=function(){return new w},A.update=function(e){return A.create().update(e)};for(var e=0;e<g.length;++e){var t=g[e];A[t]=E(t)}return A}();B.md5=B,B.md5.hmac=function(){var A=M("hex");A.create=function(A){return new f(A)},A.update=function(e,t){return A.create(e).update(t)};for(var e=0;e<g.length;++e){var t=g[e];A[t]=M(t)}return A}(),a?ws.exports=B:i.md5=B}();var Ss=Qs.exports;const Ts=(A,e)=>{const t=Date.now(),s=`${A}:${t}:${Ss.md5(`${e}${t}`)}`,i=(new TextEncoder).encode(s);return btoa(String.fromCharCode(...i))},ys=A=>/^\d+$/.test(A),Ds="/v1/aicc/bmserver",Rs="/v1/aicc/ccs";let Us="",ks="",Gs="",Fs="";function Ys(){const A=Ts(ks,Gs);return fs.create({prefixUrl:`${Us}`,timeout:!1,headers:{Authorization:A},hooks:{afterResponse:[async(A,e,t)=>{if(-1!==t.url.indexOf("heartbeat"))return t;const s=await t.clone().json();if(0!==s.code)throw new Error(JSON.stringify(s)||"请求失败");return t.json=async()=>s,t}]}})}async function xs(A,e){const t=Ys(),s="api/"+A.replace(/^\/+/,"");return t.post(s,{json:e}).json()}const vs=A=>xs(`${Rs}/state/change`,A),Zs=()=>async function(A,e){const t=Ys(),s=A.replace(/^\/+/,"");return t.post(s,{json:e}).json()}("/heartbeat",{}),Os=A=>xs(`${Rs}/call/whisper`,A);class Ns{constructor(){this.roleData={agentInfo:()=>{if(!Ve.agentInfo?.agent_no)throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:A=>{if(!A.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:A=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:e}=Ve.agentInfo;if(!e.split(",").map(A=>Number(A)).includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(A,e)=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(2===A&&("通话中"===e||"整理"===e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},setAgentExplicit:A=>{const{out_display_select_switch:e,out_display_data:t}=Ve.agentInfo;if(1!==e)throw new Error(JSON.stringify({code:1,msg:"当前坐席设置未开启允许指定外显"}));if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "number" is required'}));if(!(t||"").split("#").includes(A))throw new Error(JSON.stringify({code:1,msg:"当前外显号码不存在"}))}}}formatDate(A){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")} ${String(A.getHours()).padStart(2,"0")}:${String(A.getMinutes()).padStart(2,"0")}:${String(A.getSeconds()).padStart(2,"0")}`}async _agentLogin(A){try{const t=await(e={agent_no:A},xs(`${Rs}/agent/login`,e));Ve.agentInfo=t.data}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}var e}async _changeState(A){try{Ve.autoStateTimer&&(clearTimeout(Ve.autoStateTimer),Ve.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e,{agent_no:n}=Ve.agentInfo;await vs({agent_no:n,state_name:i,state:s}),s===exports.AgentStatus.IDLE?le.updateActionConfigs(ft):s===exports.AgentStatus.BUSY&&le.updateActionConfigs(Bt),Ve.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async _getInCallCrmDetail(A){try{const{phone:e}=A.data,t={};ys(e)?t.phone=e:t.trace_id=e;const s=await(A=>xs(`${Ds}/crm/popups`,A))({...t});A.success?.(s)}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async changeDevice(A){try{if(le.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{device:s}=e;1===s&&le.updateAnswerDevice(s),this.roleData.changeDevice(s);const{agent_no:i}=Ve.agentInfo;await(A=>xs(`${Rs}/device/change`,A))({agent_no:i,answer_device:s}),le.updateAnswerDevice(s);const n=le.get("actionConfigs");le.updateActionConfigs(n),2===s&&Ve.stateObject.state===exports.AgentStatus.UNREGISTERED&&await this._changeState({data:{...Ve.stateBeforeChange,state_name:Ve.stateBeforeChange.state===exports.AgentStatus.IDLE?"空闲":"忙碌"}}),t?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async changeState(A){try{if(le.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));Ve.autoStateTimer&&(clearTimeout(Ve.autoStateTimer),Ve.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e;this.roleData.changeState(s,i);const{agent_no:n}=Ve.agentInfo;await vs({agent_no:n,state_name:i,state:s}),(Ve.stateObject.state===exports.AgentStatus.IDLE||Ve.stateObject.state===exports.AgentStatus.BUSY&&"整理"!==i)&&(Ve.stateBeforeChange=Ve.stateObject),s===exports.AgentStatus.IDLE?le.updateActionConfigs(ft):s===exports.AgentStatus.BUSY&&le.updateActionConfigs(Bt),Ve.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async getIdleAgentList(A){const{agent_no:e}=Ve.agentInfo;try{this.roleData.agentInfo();const t=await(A=>xs(`${Rs}/agent/free`,A))({agent_no:e});A.success?.(t)}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async getAgentState(A){try{const e=await xs(`${Ds}/agent/statecfg/list`,{}),t=(e.data||[]).filter(A=>0===A.enable).filter(A=>0!==A.state&&3!==A.state).filter(A=>"通话中"!==A.state_name&&"整理"!==A.state_name&&"未注册"!==A.state_name&&"离线接听"!==A.state_name).map(A=>({state:A.state,state_name:A.state_name})).reverse();A.success?.({...e,data:t})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async setAgentExplicit(A){try{this.roleData.agentInfo(),this.roleData.requestInfo(A),this.roleData.setAgentExplicit(A.data.number);const{agent_id:e}=Ve.agentInfo;await(A=>xs(`${Ds}/agent/update`,A))({agent_id:e,out_display_number:A.data.number}),le.updateSelectOutNumber(A.data.number),A.success?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async checkAgentLogin(A){try{this.roleData.requestInfo(A);const{agent_no:e}=A.data;if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "agent_no" is required'}));const t=await(A=>xs(`${Rs}/agent/islogin`,A))({agent_no:e});A.success?.(t)}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async getCallRecord(A){try{this.roleData.agentInfo();const{success:e}=A,t=new Date,s=new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0),i=new Date(t.getFullYear(),t.getMonth(),t.getDate(),23,59,59),n=[this.formatDate(s),this.formatDate(i)],{agent_no:r}=Ve.agentInfo,o=await(A=>xs(`${Ds}/agent/recordpage`,A))({start_time:n[0],end_time:n[1],page_no:1,page_size:10,agent_no:r}),{code:a,msg:V,data:c}=o;e?.({code:a,msg:V,data:c})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async logout(A){this.roleData.agentInfo();try{const{agent_no:e}=Ve.agentInfo,{data:t,success:s}=A;await(A=>xs(`${Rs}/agent/logout`,A))({...t,agent_no:e}),s?.({code:0,msg:""})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async listenCall(A){try{const{agent_no:e}=Ve.agentInfo,{data:t,success:s}=A;if(this.roleData.agentInfo(),this.roleData.requestInfo(A),!t.monitored_agent_no)throw new Error(JSON.stringify({code:1,msg:'Parameter "monitored_agent_no" is required'}));await(A=>xs(`${Rs}/call/monitor`,A))({...t,monitor_agent_no:e}),Ve.monitoredAgentNo=t.monitored_agent_no,s?.({code:0,msg:""})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async earCall(A){try{const{agentInfo:e,monitoredAgentNo:t}=Ve,{agent_no:s}=e;this.roleData.agentInfo();const{success:i}=A;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await Os({monitored_agent_no:t,monitor_agent_no:s}),i?.({code:0,msg:""})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async stopEarCall(A){try{const{agentInfo:e,earSpeakAgent:t}=Ve;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前没有正在耳语的坐席"}));const{agent_no:s}=e;this.roleData.agentInfo();const{success:i}=A;await Os({monitor_agent_no:s,monitored_agent_no:t}),i?.({code:0,msg:""})}catch(A){throw ae.emit(exports.EventName.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}}let Ks=class extends Et{constructor(){super(...arguments),this.type="info",this.content="",this.duration=3e3}static{this.styles=Ce`
|
|
528
528
|
:host {
|
|
529
529
|
display: block;
|
|
530
530
|
margin-top: 10px;
|
|
@@ -524,7 +524,7 @@ const Zt=A=>(e,t)=>{void 0!==t?t.addInitializer(()=>{customElements.define(A,e)}
|
|
|
524
524
|
* @copyright Chen, Yi-Cyuan 2014-2023
|
|
525
525
|
* @license MIT
|
|
526
526
|
*/
|
|
527
|
-
ws=Qs,function(){var t="input is invalid type",s="object"==typeof window,i=s?window:{};i.JS_MD5_NO_WINDOW&&(s=!1);var r=!s&&"object"==typeof self,o=!i.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;o?i=Bs:r&&(i=self);var n,a=!i.JS_MD5_NO_COMMON_JS&&ws.exports,V=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,c="0123456789abcdef".split(""),h=[128,32768,8388608,-2147483648],l=[0,8,16,24],g=["hex","array","digest","buffer","arrayBuffer","base64"],q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),d=[];if(V){var u=new ArrayBuffer(68);n=new Uint8Array(u),d=new Uint32Array(u)}var p=Array.isArray;!i.JS_MD5_NO_NODE_JS&&p||(p=function(A){return"[object Array]"===Object.prototype.toString.call(A)});var m=ArrayBuffer.isView;!V||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&m||(m=function(A){return"object"==typeof A&&A.buffer&&A.buffer.constructor===ArrayBuffer});var C=function(A){var e=typeof A;if("string"===e)return[A,!0];if("object"!==e||null===A)throw new Error(t);if(V&&A.constructor===ArrayBuffer)return[new Uint8Array(A),!1];if(!p(A)&&!m(A))throw new Error(t);return[A,!1]},E=function(A){return function(e){return new w(!0).update(e)[A]()}},I=function(s){var r,o=A,n=e.Buffer;return r=n.from&&!i.JS_MD5_NO_BUFFER_FROM?n.from:function(A){return new n(A)},function(A){if("string"==typeof A)return o.createHash("md5").update(A,"utf8").digest("hex");if(null==A)throw new Error(t);return A.constructor===ArrayBuffer&&(A=new Uint8Array(A)),p(A)||m(A)||A.constructor===n?o.createHash("md5").update(r(A)).digest("hex"):s(A)}},M=function(A){return function(e,t){return new f(e,!0).update(t)[A]()}};function w(A){if(A)d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d,this.buffer8=n;else if(V){var e=new ArrayBuffer(68);this.buffer8=new Uint8Array(e),this.blocks=new Uint32Array(e)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function f(A,e){var t,s=C(A);if(A=s[0],s[1]){var i,r=[],o=A.length,n=0;for(t=0;t<o;++t)(i=A.charCodeAt(t))<128?r[n++]=i:i<2048?(r[n++]=192|i>>>6,r[n++]=128|63&i):i<55296||i>=57344?(r[n++]=224|i>>>12,r[n++]=128|i>>>6&63,r[n++]=128|63&i):(i=65536+((1023&i)<<10|1023&A.charCodeAt(++t)),r[n++]=240|i>>>18,r[n++]=128|i>>>12&63,r[n++]=128|i>>>6&63,r[n++]=128|63&i);A=r}A.length>64&&(A=new w(!0).update(A).array());var a=[],V=[];for(t=0;t<64;++t){var c=A[t]||0;a[t]=92^c,V[t]=54^c}w.call(this,e),this.update(V),this.oKeyPad=a,this.inner=!0,this.sharedMemory=e}w.prototype.update=function(A){if(this.finalized)throw new Error("finalize already called");var e=C(A);A=e[0];for(var t,s,i=e[1],r=0,o=A.length,n=this.blocks,a=this.buffer8;r<o;){if(this.hashed&&(this.hashed=!1,n[0]=n[16],n[16]=n[1]=n[2]=n[3]=n[4]=n[5]=n[6]=n[7]=n[8]=n[9]=n[10]=n[11]=n[12]=n[13]=n[14]=n[15]=0),i)if(V)for(s=this.start;r<o&&s<64;++r)(t=A.charCodeAt(r))<128?a[s++]=t:t<2048?(a[s++]=192|t>>>6,a[s++]=128|63&t):t<55296||t>=57344?(a[s++]=224|t>>>12,a[s++]=128|t>>>6&63,a[s++]=128|63&t):(t=65536+((1023&t)<<10|1023&A.charCodeAt(++r)),a[s++]=240|t>>>18,a[s++]=128|t>>>12&63,a[s++]=128|t>>>6&63,a[s++]=128|63&t);else for(s=this.start;r<o&&s<64;++r)(t=A.charCodeAt(r))<128?n[s>>>2]|=t<<l[3&s++]:t<2048?(n[s>>>2]|=(192|t>>>6)<<l[3&s++],n[s>>>2]|=(128|63&t)<<l[3&s++]):t<55296||t>=57344?(n[s>>>2]|=(224|t>>>12)<<l[3&s++],n[s>>>2]|=(128|t>>>6&63)<<l[3&s++],n[s>>>2]|=(128|63&t)<<l[3&s++]):(t=65536+((1023&t)<<10|1023&A.charCodeAt(++r)),n[s>>>2]|=(240|t>>>18)<<l[3&s++],n[s>>>2]|=(128|t>>>12&63)<<l[3&s++],n[s>>>2]|=(128|t>>>6&63)<<l[3&s++],n[s>>>2]|=(128|63&t)<<l[3&s++]);else if(V)for(s=this.start;r<o&&s<64;++r)a[s++]=A[r];else for(s=this.start;r<o&&s<64;++r)n[s>>>2]|=A[r]<<l[3&s++];this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},w.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var A=this.blocks,e=this.lastByteIndex;A[e>>>2]|=h[3&e],e>=56&&(this.hashed||this.hash(),A[0]=A[16],A[16]=A[1]=A[2]=A[3]=A[4]=A[5]=A[6]=A[7]=A[8]=A[9]=A[10]=A[11]=A[12]=A[13]=A[14]=A[15]=0),A[14]=this.bytes<<3,A[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},w.prototype.hash=function(){var A,e,t,s,i,r,o=this.blocks;this.first?e=((e=((A=((A=o[0]-680876937)<<7|A>>>25)-271733879|0)^(t=((t=(-271733879^(s=((s=(-1732584194^2004318071&A)+o[1]-117830708)<<12|s>>>20)+A|0)&(-271733879^A))+o[2]-1126478375)<<17|t>>>15)+s|0)&(s^A))+o[3]-1316259209)<<22|e>>>10)+t|0:(A=this.h0,e=this.h1,t=this.h2,e=((e+=((A=((A+=((s=this.h3)^e&(t^s))+o[0]-680876936)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+o[1]-389564586)<<12|s>>>20)+A|0)&(A^e))+o[2]+606105819)<<17|t>>>15)+s|0)&(s^A))+o[3]-1044525330)<<22|e>>>10)+t|0),e=((e+=((A=((A+=(s^e&(t^s))+o[4]-176418897)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+o[5]+1200080426)<<12|s>>>20)+A|0)&(A^e))+o[6]-1473231341)<<17|t>>>15)+s|0)&(s^A))+o[7]-45705983)<<22|e>>>10)+t|0,e=((e+=((A=((A+=(s^e&(t^s))+o[8]+1770035416)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+o[9]-1958414417)<<12|s>>>20)+A|0)&(A^e))+o[10]-42063)<<17|t>>>15)+s|0)&(s^A))+o[11]-1990404162)<<22|e>>>10)+t|0,e=((e+=((A=((A+=(s^e&(t^s))+o[12]+1804603682)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+o[13]-40341101)<<12|s>>>20)+A|0)&(A^e))+o[14]-1502002290)<<17|t>>>15)+s|0)&(s^A))+o[15]+1236535329)<<22|e>>>10)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+o[1]-165796510)<<5|A>>>27)+e|0)^e))+o[6]-1069501632)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+o[11]+643717713)<<14|t>>>18)+s|0)^s))+o[0]-373897302)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+o[5]-701558691)<<5|A>>>27)+e|0)^e))+o[10]+38016083)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+o[15]-660478335)<<14|t>>>18)+s|0)^s))+o[4]-405537848)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+o[9]+568446438)<<5|A>>>27)+e|0)^e))+o[14]-1019803690)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+o[3]-187363961)<<14|t>>>18)+s|0)^s))+o[8]+1163531501)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+o[13]-1444681467)<<5|A>>>27)+e|0)^e))+o[2]-51403784)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+o[7]+1735328473)<<14|t>>>18)+s|0)^s))+o[12]-1926607734)<<20|e>>>12)+t|0,e=((e+=((r=(s=((s+=((i=e^t)^(A=((A+=(i^s)+o[5]-378558)<<4|A>>>28)+e|0))+o[8]-2022574463)<<11|s>>>21)+A|0)^A)^(t=((t+=(r^e)+o[11]+1839030562)<<16|t>>>16)+s|0))+o[14]-35309556)<<23|e>>>9)+t|0,e=((e+=((r=(s=((s+=((i=e^t)^(A=((A+=(i^s)+o[1]-1530992060)<<4|A>>>28)+e|0))+o[4]+1272893353)<<11|s>>>21)+A|0)^A)^(t=((t+=(r^e)+o[7]-155497632)<<16|t>>>16)+s|0))+o[10]-1094730640)<<23|e>>>9)+t|0,e=((e+=((r=(s=((s+=((i=e^t)^(A=((A+=(i^s)+o[13]+681279174)<<4|A>>>28)+e|0))+o[0]-358537222)<<11|s>>>21)+A|0)^A)^(t=((t+=(r^e)+o[3]-722521979)<<16|t>>>16)+s|0))+o[6]+76029189)<<23|e>>>9)+t|0,e=((e+=((r=(s=((s+=((i=e^t)^(A=((A+=(i^s)+o[9]-640364487)<<4|A>>>28)+e|0))+o[12]-421815835)<<11|s>>>21)+A|0)^A)^(t=((t+=(r^e)+o[15]+530742520)<<16|t>>>16)+s|0))+o[2]-995338651)<<23|e>>>9)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+o[0]-198630844)<<6|A>>>26)+e|0)|~t))+o[7]+1126891415)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+o[14]-1416354905)<<15|t>>>17)+s|0)|~A))+o[5]-57434055)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+o[12]+1700485571)<<6|A>>>26)+e|0)|~t))+o[3]-1894986606)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+o[10]-1051523)<<15|t>>>17)+s|0)|~A))+o[1]-2054922799)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+o[8]+1873313359)<<6|A>>>26)+e|0)|~t))+o[15]-30611744)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+o[6]-1560198380)<<15|t>>>17)+s|0)|~A))+o[13]+1309151649)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+o[4]-145523070)<<6|A>>>26)+e|0)|~t))+o[11]-1120210379)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+o[2]+718787259)<<15|t>>>17)+s|0)|~A))+o[9]-343485551)<<21|e>>>11)+t|0,this.first?(this.h0=A+1732584193|0,this.h1=e-271733879|0,this.h2=t-1732584194|0,this.h3=s+271733878|0,this.first=!1):(this.h0=this.h0+A|0,this.h1=this.h1+e|0,this.h2=this.h2+t|0,this.h3=this.h3+s|0)},w.prototype.hex=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,s=this.h3;return c[A>>>4&15]+c[15&A]+c[A>>>12&15]+c[A>>>8&15]+c[A>>>20&15]+c[A>>>16&15]+c[A>>>28&15]+c[A>>>24&15]+c[e>>>4&15]+c[15&e]+c[e>>>12&15]+c[e>>>8&15]+c[e>>>20&15]+c[e>>>16&15]+c[e>>>28&15]+c[e>>>24&15]+c[t>>>4&15]+c[15&t]+c[t>>>12&15]+c[t>>>8&15]+c[t>>>20&15]+c[t>>>16&15]+c[t>>>28&15]+c[t>>>24&15]+c[s>>>4&15]+c[15&s]+c[s>>>12&15]+c[s>>>8&15]+c[s>>>20&15]+c[s>>>16&15]+c[s>>>28&15]+c[s>>>24&15]},w.prototype.toString=w.prototype.hex,w.prototype.digest=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,s=this.h3;return[255&A,A>>>8&255,A>>>16&255,A>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&s,s>>>8&255,s>>>16&255,s>>>24&255]},w.prototype.array=w.prototype.digest,w.prototype.arrayBuffer=function(){this.finalize();var A=new ArrayBuffer(16),e=new Uint32Array(A);return e[0]=this.h0,e[1]=this.h1,e[2]=this.h2,e[3]=this.h3,A},w.prototype.buffer=w.prototype.arrayBuffer,w.prototype.base64=function(){for(var A,e,t,s="",i=this.array(),r=0;r<15;)A=i[r++],e=i[r++],t=i[r++],s+=q[A>>>2]+q[63&(A<<4|e>>>4)]+q[63&(e<<2|t>>>6)]+q[63&t];return A=i[r],s+=q[A>>>2]+q[A<<4&63]+"=="},f.prototype=new w,f.prototype.finalize=function(){if(w.prototype.finalize.call(this),this.inner){this.inner=!1;var A=this.array();w.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(A),w.prototype.finalize.call(this)}};var B=function(){var A=E("hex");o&&(A=I(A)),A.create=function(){return new w},A.update=function(e){return A.create().update(e)};for(var e=0;e<g.length;++e){var t=g[e];A[t]=E(t)}return A}();B.md5=B,B.md5.hmac=function(){var A=M("hex");A.create=function(A){return new f(A)},A.update=function(e,t){return A.create(e).update(t)};for(var e=0;e<g.length;++e){var t=g[e];A[t]=M(t)}return A}(),a?ws.exports=B:i.md5=B}();var Ss=Qs.exports;const Ts=(A,e)=>{const t=Date.now(),s=`${A}:${t}:${Ss.md5(`${e}${t}`)}`,i=(new TextEncoder).encode(s);return btoa(String.fromCharCode(...i))},ys=A=>/^\d+$/.test(A),Ds="/v1/aicc/bmserver",Rs="/v1/aicc/ccs";let Us="",ks="",Gs="",Fs="";function Ys(){const A=Ts(ks,Gs);return fs.create({prefixUrl:`${Us}`,timeout:!1,headers:{Authorization:A},hooks:{afterResponse:[async(A,e,t)=>{if(-1!==t.url.indexOf("heartbeat"))return t;const s=await t.clone().json();if(0!==s.code)throw new Error(JSON.stringify(s)||"请求失败");return t.json=async()=>s,t}]}})}async function Zs(A,e){const t=Ys(),s="api/"+A.replace(/^\/+/,"");return t.post(s,{json:e}).json()}const Os=A=>Zs(`${Rs}/state/change`,A),vs=()=>async function(A,e){const t=Ys(),s=A.replace(/^\/+/,"");return t.post(s,{json:e}).json()}("/heartbeat",{}),xs=A=>Zs(`${Rs}/call/whisper`,A);class Ks{constructor(){this.roleData={agentInfo:()=>{if(!Ve.agentInfo?.agent_no)throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:A=>{if(!A.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:A=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:e}=Ve.agentInfo;if(!e.split(",").map(A=>Number(A)).includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(A,e)=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(2===A&&("通话中"===e||"整理"===e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},setAgentExplicit:A=>{const{out_display_select_switch:e,out_display_data:t}=Ve.agentInfo;if(1!==e)throw new Error(JSON.stringify({code:1,msg:"当前坐席设置未开启允许指定外显"}));if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "number" is required'}));if(!(t||"").split("#").includes(A))throw new Error(JSON.stringify({code:1,msg:"当前外显号码不存在"}))}}}formatDate(A){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")} ${String(A.getHours()).padStart(2,"0")}:${String(A.getMinutes()).padStart(2,"0")}:${String(A.getSeconds()).padStart(2,"0")}`}async _agentLogin(A){try{const t=await(e={agent_no:A},Zs(`${Rs}/agent/login`,e));Ve.agentInfo=t.data}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}var e}async _changeState(A){try{Ve.autoStateTimer&&(clearTimeout(Ve.autoStateTimer),Ve.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e,{agent_no:r}=Ve.agentInfo;await Os({agent_no:r,state_name:i,state:s}),s===Ae.IDLE?he.updateActionConfigs(ft):s===Ae.BUSY&&he.updateActionConfigs(Bt),Ve.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async _getInCallCrmDetail(A){try{const{phone:e}=A.data,t={};ys(e)?t.phone=e:t.trace_id=e;const s=await(A=>Zs(`${Ds}/crm/popups`,A))({...t});A.success?.(s)}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async changeDevice(A){try{if(he.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{device:s}=e;1===s&&he.updateAnswerDevice(s),this.roleData.changeDevice(s);const{agent_no:i}=Ve.agentInfo;await(A=>Zs(`${Rs}/device/change`,A))({agent_no:i,answer_device:s}),he.updateAnswerDevice(s);const r=he.get("actionConfigs");he.updateActionConfigs(r),2===s&&Ve.stateObject.state===Ae.UNREGISTERED&&await this._changeState({data:{...Ve.stateBeforeChange,state_name:Ve.stateBeforeChange.state===Ae.IDLE?"空闲":"忙碌"}}),t?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async changeState(A){try{if(he.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));Ve.autoStateTimer&&(clearTimeout(Ve.autoStateTimer),Ve.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e;this.roleData.changeState(s,i);const{agent_no:r}=Ve.agentInfo;await Os({agent_no:r,state_name:i,state:s}),(Ve.stateObject.state===Ae.IDLE||Ve.stateObject.state===Ae.BUSY&&"整理"!==i)&&(Ve.stateBeforeChange=Ve.stateObject),s===Ae.IDLE?he.updateActionConfigs(ft):s===Ae.BUSY&&he.updateActionConfigs(Bt),Ve.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async getIdleAgentList(A){const{agent_no:e}=Ve.agentInfo;try{this.roleData.agentInfo();const t=await(A=>Zs(`${Rs}/agent/free`,A))({agent_no:e});A.success?.(t)}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async getAgentState(A){try{const e=await Zs(`${Ds}/agent/statecfg/list`,{}),t=(e.data||[]).filter(A=>0===A.enable).filter(A=>0!==A.state&&3!==A.state).filter(A=>"通话中"!==A.state_name&&"整理"!==A.state_name&&"未注册"!==A.state_name&&"离线接听"!==A.state_name).map(A=>({state:A.state,state_name:A.state_name})).reverse();A.success?.({...e,data:t})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async setAgentExplicit(A){try{this.roleData.agentInfo(),this.roleData.requestInfo(A),this.roleData.setAgentExplicit(A.data.number);const{agent_id:e}=Ve.agentInfo;await(A=>Zs(`${Ds}/agent/update`,A))({agent_id:e,out_display_number:A.data.number}),he.updateSelectOutNumber(A.data.number),A.success?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async checkAgentLogin(A){try{this.roleData.requestInfo(A);const{agent_no:e}=A.data;if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "agent_no" is required'}));const t=await(A=>Zs(`${Rs}/agent/islogin`,A))({agent_no:e});A.success?.(t)}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async getCallRecord(A){try{this.roleData.agentInfo();const{success:e}=A,t=new Date,s=new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0),i=new Date(t.getFullYear(),t.getMonth(),t.getDate(),23,59,59),r=[this.formatDate(s),this.formatDate(i)],{agent_no:o}=Ve.agentInfo,n=await(A=>Zs(`${Ds}/agent/recordpage`,A))({start_time:r[0],end_time:r[1],page_no:1,page_size:10,agent_no:o}),{code:a,msg:V,data:c}=n;e?.({code:a,msg:V,data:c})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async logout(A){this.roleData.agentInfo();try{const{agent_no:e}=Ve.agentInfo,{data:t,success:s}=A;await(A=>Zs(`${Rs}/agent/logout`,A))({...t,agent_no:e}),s?.({code:0,msg:""})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async listenCall(A){try{const{agent_no:e}=Ve.agentInfo,{data:t,success:s}=A;if(this.roleData.agentInfo(),this.roleData.requestInfo(A),!t.monitored_agent_no)throw new Error(JSON.stringify({code:1,msg:'Parameter "monitored_agent_no" is required'}));await(A=>Zs(`${Rs}/call/monitor`,A))({...t,monitor_agent_no:e}),Ve.monitoredAgentNo=t.monitored_agent_no,s?.({code:0,msg:""})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async earCall(A){try{const{agentInfo:e,monitoredAgentNo:t}=Ve,{agent_no:s}=e;this.roleData.agentInfo(),this.roleData.requestInfo(A);const{success:i}=A;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await xs({monitored_agent_no:t,monitor_agent_no:s}),i?.({code:0,msg:""})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async stopEarCall(A){try{const{agentInfo:e,earSpeakAgent:t}=Ve;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前没有正在耳语的坐席"}));const{agent_no:s}=e;this.roleData.agentInfo();const{success:i}=A;await xs({monitor_agent_no:s,monitored_agent_no:t}),i?.({code:0,msg:""})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}}let Ns=class extends Et{constructor(){super(...arguments),this.type="info",this.content="",this.duration=3e3}static{this.styles=Ce`
|
|
527
|
+
ws=Qs,function(){var t="input is invalid type",s="object"==typeof window,i=s?window:{};i.JS_MD5_NO_WINDOW&&(s=!1);var r=!s&&"object"==typeof self,o=!i.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;o?i=Bs:r&&(i=self);var n,a=!i.JS_MD5_NO_COMMON_JS&&ws.exports,V=!i.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,c="0123456789abcdef".split(""),h=[128,32768,8388608,-2147483648],l=[0,8,16,24],g=["hex","array","digest","buffer","arrayBuffer","base64"],q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),d=[];if(V){var u=new ArrayBuffer(68);n=new Uint8Array(u),d=new Uint32Array(u)}var p=Array.isArray;!i.JS_MD5_NO_NODE_JS&&p||(p=function(A){return"[object Array]"===Object.prototype.toString.call(A)});var m=ArrayBuffer.isView;!V||!i.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&m||(m=function(A){return"object"==typeof A&&A.buffer&&A.buffer.constructor===ArrayBuffer});var C=function(A){var e=typeof A;if("string"===e)return[A,!0];if("object"!==e||null===A)throw new Error(t);if(V&&A.constructor===ArrayBuffer)return[new Uint8Array(A),!1];if(!p(A)&&!m(A))throw new Error(t);return[A,!1]},E=function(A){return function(e){return new w(!0).update(e)[A]()}},I=function(s){var r,o=A,n=e.Buffer;return r=n.from&&!i.JS_MD5_NO_BUFFER_FROM?n.from:function(A){return new n(A)},function(A){if("string"==typeof A)return o.createHash("md5").update(A,"utf8").digest("hex");if(null==A)throw new Error(t);return A.constructor===ArrayBuffer&&(A=new Uint8Array(A)),p(A)||m(A)||A.constructor===n?o.createHash("md5").update(r(A)).digest("hex"):s(A)}},M=function(A){return function(e,t){return new f(e,!0).update(t)[A]()}};function w(A){if(A)d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d,this.buffer8=n;else if(V){var e=new ArrayBuffer(68);this.buffer8=new Uint8Array(e),this.blocks=new Uint32Array(e)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function f(A,e){var t,s=C(A);if(A=s[0],s[1]){var i,r=[],o=A.length,n=0;for(t=0;t<o;++t)(i=A.charCodeAt(t))<128?r[n++]=i:i<2048?(r[n++]=192|i>>>6,r[n++]=128|63&i):i<55296||i>=57344?(r[n++]=224|i>>>12,r[n++]=128|i>>>6&63,r[n++]=128|63&i):(i=65536+((1023&i)<<10|1023&A.charCodeAt(++t)),r[n++]=240|i>>>18,r[n++]=128|i>>>12&63,r[n++]=128|i>>>6&63,r[n++]=128|63&i);A=r}A.length>64&&(A=new w(!0).update(A).array());var a=[],V=[];for(t=0;t<64;++t){var c=A[t]||0;a[t]=92^c,V[t]=54^c}w.call(this,e),this.update(V),this.oKeyPad=a,this.inner=!0,this.sharedMemory=e}w.prototype.update=function(A){if(this.finalized)throw new Error("finalize already called");var e=C(A);A=e[0];for(var t,s,i=e[1],r=0,o=A.length,n=this.blocks,a=this.buffer8;r<o;){if(this.hashed&&(this.hashed=!1,n[0]=n[16],n[16]=n[1]=n[2]=n[3]=n[4]=n[5]=n[6]=n[7]=n[8]=n[9]=n[10]=n[11]=n[12]=n[13]=n[14]=n[15]=0),i)if(V)for(s=this.start;r<o&&s<64;++r)(t=A.charCodeAt(r))<128?a[s++]=t:t<2048?(a[s++]=192|t>>>6,a[s++]=128|63&t):t<55296||t>=57344?(a[s++]=224|t>>>12,a[s++]=128|t>>>6&63,a[s++]=128|63&t):(t=65536+((1023&t)<<10|1023&A.charCodeAt(++r)),a[s++]=240|t>>>18,a[s++]=128|t>>>12&63,a[s++]=128|t>>>6&63,a[s++]=128|63&t);else for(s=this.start;r<o&&s<64;++r)(t=A.charCodeAt(r))<128?n[s>>>2]|=t<<l[3&s++]:t<2048?(n[s>>>2]|=(192|t>>>6)<<l[3&s++],n[s>>>2]|=(128|63&t)<<l[3&s++]):t<55296||t>=57344?(n[s>>>2]|=(224|t>>>12)<<l[3&s++],n[s>>>2]|=(128|t>>>6&63)<<l[3&s++],n[s>>>2]|=(128|63&t)<<l[3&s++]):(t=65536+((1023&t)<<10|1023&A.charCodeAt(++r)),n[s>>>2]|=(240|t>>>18)<<l[3&s++],n[s>>>2]|=(128|t>>>12&63)<<l[3&s++],n[s>>>2]|=(128|t>>>6&63)<<l[3&s++],n[s>>>2]|=(128|63&t)<<l[3&s++]);else if(V)for(s=this.start;r<o&&s<64;++r)a[s++]=A[r];else for(s=this.start;r<o&&s<64;++r)n[s>>>2]|=A[r]<<l[3&s++];this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},w.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var A=this.blocks,e=this.lastByteIndex;A[e>>>2]|=h[3&e],e>=56&&(this.hashed||this.hash(),A[0]=A[16],A[16]=A[1]=A[2]=A[3]=A[4]=A[5]=A[6]=A[7]=A[8]=A[9]=A[10]=A[11]=A[12]=A[13]=A[14]=A[15]=0),A[14]=this.bytes<<3,A[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},w.prototype.hash=function(){var A,e,t,s,i,r,o=this.blocks;this.first?e=((e=((A=((A=o[0]-680876937)<<7|A>>>25)-271733879|0)^(t=((t=(-271733879^(s=((s=(-1732584194^2004318071&A)+o[1]-117830708)<<12|s>>>20)+A|0)&(-271733879^A))+o[2]-1126478375)<<17|t>>>15)+s|0)&(s^A))+o[3]-1316259209)<<22|e>>>10)+t|0:(A=this.h0,e=this.h1,t=this.h2,e=((e+=((A=((A+=((s=this.h3)^e&(t^s))+o[0]-680876936)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+o[1]-389564586)<<12|s>>>20)+A|0)&(A^e))+o[2]+606105819)<<17|t>>>15)+s|0)&(s^A))+o[3]-1044525330)<<22|e>>>10)+t|0),e=((e+=((A=((A+=(s^e&(t^s))+o[4]-176418897)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+o[5]+1200080426)<<12|s>>>20)+A|0)&(A^e))+o[6]-1473231341)<<17|t>>>15)+s|0)&(s^A))+o[7]-45705983)<<22|e>>>10)+t|0,e=((e+=((A=((A+=(s^e&(t^s))+o[8]+1770035416)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+o[9]-1958414417)<<12|s>>>20)+A|0)&(A^e))+o[10]-42063)<<17|t>>>15)+s|0)&(s^A))+o[11]-1990404162)<<22|e>>>10)+t|0,e=((e+=((A=((A+=(s^e&(t^s))+o[12]+1804603682)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+o[13]-40341101)<<12|s>>>20)+A|0)&(A^e))+o[14]-1502002290)<<17|t>>>15)+s|0)&(s^A))+o[15]+1236535329)<<22|e>>>10)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+o[1]-165796510)<<5|A>>>27)+e|0)^e))+o[6]-1069501632)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+o[11]+643717713)<<14|t>>>18)+s|0)^s))+o[0]-373897302)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+o[5]-701558691)<<5|A>>>27)+e|0)^e))+o[10]+38016083)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+o[15]-660478335)<<14|t>>>18)+s|0)^s))+o[4]-405537848)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+o[9]+568446438)<<5|A>>>27)+e|0)^e))+o[14]-1019803690)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+o[3]-187363961)<<14|t>>>18)+s|0)^s))+o[8]+1163531501)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+o[13]-1444681467)<<5|A>>>27)+e|0)^e))+o[2]-51403784)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+o[7]+1735328473)<<14|t>>>18)+s|0)^s))+o[12]-1926607734)<<20|e>>>12)+t|0,e=((e+=((r=(s=((s+=((i=e^t)^(A=((A+=(i^s)+o[5]-378558)<<4|A>>>28)+e|0))+o[8]-2022574463)<<11|s>>>21)+A|0)^A)^(t=((t+=(r^e)+o[11]+1839030562)<<16|t>>>16)+s|0))+o[14]-35309556)<<23|e>>>9)+t|0,e=((e+=((r=(s=((s+=((i=e^t)^(A=((A+=(i^s)+o[1]-1530992060)<<4|A>>>28)+e|0))+o[4]+1272893353)<<11|s>>>21)+A|0)^A)^(t=((t+=(r^e)+o[7]-155497632)<<16|t>>>16)+s|0))+o[10]-1094730640)<<23|e>>>9)+t|0,e=((e+=((r=(s=((s+=((i=e^t)^(A=((A+=(i^s)+o[13]+681279174)<<4|A>>>28)+e|0))+o[0]-358537222)<<11|s>>>21)+A|0)^A)^(t=((t+=(r^e)+o[3]-722521979)<<16|t>>>16)+s|0))+o[6]+76029189)<<23|e>>>9)+t|0,e=((e+=((r=(s=((s+=((i=e^t)^(A=((A+=(i^s)+o[9]-640364487)<<4|A>>>28)+e|0))+o[12]-421815835)<<11|s>>>21)+A|0)^A)^(t=((t+=(r^e)+o[15]+530742520)<<16|t>>>16)+s|0))+o[2]-995338651)<<23|e>>>9)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+o[0]-198630844)<<6|A>>>26)+e|0)|~t))+o[7]+1126891415)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+o[14]-1416354905)<<15|t>>>17)+s|0)|~A))+o[5]-57434055)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+o[12]+1700485571)<<6|A>>>26)+e|0)|~t))+o[3]-1894986606)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+o[10]-1051523)<<15|t>>>17)+s|0)|~A))+o[1]-2054922799)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+o[8]+1873313359)<<6|A>>>26)+e|0)|~t))+o[15]-30611744)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+o[6]-1560198380)<<15|t>>>17)+s|0)|~A))+o[13]+1309151649)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+o[4]-145523070)<<6|A>>>26)+e|0)|~t))+o[11]-1120210379)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+o[2]+718787259)<<15|t>>>17)+s|0)|~A))+o[9]-343485551)<<21|e>>>11)+t|0,this.first?(this.h0=A+1732584193|0,this.h1=e-271733879|0,this.h2=t-1732584194|0,this.h3=s+271733878|0,this.first=!1):(this.h0=this.h0+A|0,this.h1=this.h1+e|0,this.h2=this.h2+t|0,this.h3=this.h3+s|0)},w.prototype.hex=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,s=this.h3;return c[A>>>4&15]+c[15&A]+c[A>>>12&15]+c[A>>>8&15]+c[A>>>20&15]+c[A>>>16&15]+c[A>>>28&15]+c[A>>>24&15]+c[e>>>4&15]+c[15&e]+c[e>>>12&15]+c[e>>>8&15]+c[e>>>20&15]+c[e>>>16&15]+c[e>>>28&15]+c[e>>>24&15]+c[t>>>4&15]+c[15&t]+c[t>>>12&15]+c[t>>>8&15]+c[t>>>20&15]+c[t>>>16&15]+c[t>>>28&15]+c[t>>>24&15]+c[s>>>4&15]+c[15&s]+c[s>>>12&15]+c[s>>>8&15]+c[s>>>20&15]+c[s>>>16&15]+c[s>>>28&15]+c[s>>>24&15]},w.prototype.toString=w.prototype.hex,w.prototype.digest=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,s=this.h3;return[255&A,A>>>8&255,A>>>16&255,A>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&s,s>>>8&255,s>>>16&255,s>>>24&255]},w.prototype.array=w.prototype.digest,w.prototype.arrayBuffer=function(){this.finalize();var A=new ArrayBuffer(16),e=new Uint32Array(A);return e[0]=this.h0,e[1]=this.h1,e[2]=this.h2,e[3]=this.h3,A},w.prototype.buffer=w.prototype.arrayBuffer,w.prototype.base64=function(){for(var A,e,t,s="",i=this.array(),r=0;r<15;)A=i[r++],e=i[r++],t=i[r++],s+=q[A>>>2]+q[63&(A<<4|e>>>4)]+q[63&(e<<2|t>>>6)]+q[63&t];return A=i[r],s+=q[A>>>2]+q[A<<4&63]+"=="},f.prototype=new w,f.prototype.finalize=function(){if(w.prototype.finalize.call(this),this.inner){this.inner=!1;var A=this.array();w.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(A),w.prototype.finalize.call(this)}};var B=function(){var A=E("hex");o&&(A=I(A)),A.create=function(){return new w},A.update=function(e){return A.create().update(e)};for(var e=0;e<g.length;++e){var t=g[e];A[t]=E(t)}return A}();B.md5=B,B.md5.hmac=function(){var A=M("hex");A.create=function(A){return new f(A)},A.update=function(e,t){return A.create(e).update(t)};for(var e=0;e<g.length;++e){var t=g[e];A[t]=M(t)}return A}(),a?ws.exports=B:i.md5=B}();var Ss=Qs.exports;const Ts=(A,e)=>{const t=Date.now(),s=`${A}:${t}:${Ss.md5(`${e}${t}`)}`,i=(new TextEncoder).encode(s);return btoa(String.fromCharCode(...i))},ys=A=>/^\d+$/.test(A),Ds="/v1/aicc/bmserver",Rs="/v1/aicc/ccs";let Us="",ks="",Gs="",Fs="";function Ys(){const A=Ts(ks,Gs);return fs.create({prefixUrl:`${Us}`,timeout:!1,headers:{Authorization:A},hooks:{afterResponse:[async(A,e,t)=>{if(-1!==t.url.indexOf("heartbeat"))return t;const s=await t.clone().json();if(0!==s.code)throw new Error(JSON.stringify(s)||"请求失败");return t.json=async()=>s,t}]}})}async function Zs(A,e){const t=Ys(),s="api/"+A.replace(/^\/+/,"");return t.post(s,{json:e}).json()}const Os=A=>Zs(`${Rs}/state/change`,A),vs=()=>async function(A,e){const t=Ys(),s=A.replace(/^\/+/,"");return t.post(s,{json:e}).json()}("/heartbeat",{}),xs=A=>Zs(`${Rs}/call/whisper`,A);class Ks{constructor(){this.roleData={agentInfo:()=>{if(!Ve.agentInfo?.agent_no)throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:A=>{if(!A.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:A=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:e}=Ve.agentInfo;if(!e.split(",").map(A=>Number(A)).includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(A,e)=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(2===A&&("通话中"===e||"整理"===e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},setAgentExplicit:A=>{const{out_display_select_switch:e,out_display_data:t}=Ve.agentInfo;if(1!==e)throw new Error(JSON.stringify({code:1,msg:"当前坐席设置未开启允许指定外显"}));if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "number" is required'}));if(!(t||"").split("#").includes(A))throw new Error(JSON.stringify({code:1,msg:"当前外显号码不存在"}))}}}formatDate(A){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")} ${String(A.getHours()).padStart(2,"0")}:${String(A.getMinutes()).padStart(2,"0")}:${String(A.getSeconds()).padStart(2,"0")}`}async _agentLogin(A){try{const t=await(e={agent_no:A},Zs(`${Rs}/agent/login`,e));Ve.agentInfo=t.data}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}var e}async _changeState(A){try{Ve.autoStateTimer&&(clearTimeout(Ve.autoStateTimer),Ve.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e,{agent_no:r}=Ve.agentInfo;await Os({agent_no:r,state_name:i,state:s}),s===Ae.IDLE?he.updateActionConfigs(ft):s===Ae.BUSY&&he.updateActionConfigs(Bt),Ve.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async _getInCallCrmDetail(A){try{const{phone:e}=A.data,t={};ys(e)?t.phone=e:t.trace_id=e;const s=await(A=>Zs(`${Ds}/crm/popups`,A))({...t});A.success?.(s)}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async changeDevice(A){try{if(he.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{device:s}=e;1===s&&he.updateAnswerDevice(s),this.roleData.changeDevice(s);const{agent_no:i}=Ve.agentInfo;await(A=>Zs(`${Rs}/device/change`,A))({agent_no:i,answer_device:s}),he.updateAnswerDevice(s);const r=he.get("actionConfigs");he.updateActionConfigs(r),2===s&&Ve.stateObject.state===Ae.UNREGISTERED&&await this._changeState({data:{...Ve.stateBeforeChange,state_name:Ve.stateBeforeChange.state===Ae.IDLE?"空闲":"忙碌"}}),t?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async changeState(A){try{if(he.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));Ve.autoStateTimer&&(clearTimeout(Ve.autoStateTimer),Ve.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(A);const{data:e,success:t}=A,{state:s,state_name:i}=e;this.roleData.changeState(s,i);const{agent_no:r}=Ve.agentInfo;await Os({agent_no:r,state_name:i,state:s}),(Ve.stateObject.state===Ae.IDLE||Ve.stateObject.state===Ae.BUSY&&"整理"!==i)&&(Ve.stateBeforeChange=Ve.stateObject),s===Ae.IDLE?he.updateActionConfigs(ft):s===Ae.BUSY&&he.updateActionConfigs(Bt),Ve.stateObject={state:s,state_name:i},t?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async getIdleAgentList(A){const{agent_no:e}=Ve.agentInfo;try{this.roleData.agentInfo();const t=await(A=>Zs(`${Rs}/agent/free`,A))({agent_no:e});A.success?.(t)}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async getAgentState(A){try{const e=await Zs(`${Ds}/agent/statecfg/list`,{}),t=(e.data||[]).filter(A=>0===A.enable).filter(A=>0!==A.state&&3!==A.state).filter(A=>"通话中"!==A.state_name&&"整理"!==A.state_name&&"未注册"!==A.state_name&&"离线接听"!==A.state_name).map(A=>({state:A.state,state_name:A.state_name})).reverse();A.success?.({...e,data:t})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async setAgentExplicit(A){try{this.roleData.agentInfo(),this.roleData.requestInfo(A),this.roleData.setAgentExplicit(A.data.number);const{agent_id:e}=Ve.agentInfo;await(A=>Zs(`${Ds}/agent/update`,A))({agent_id:e,out_display_number:A.data.number}),he.updateSelectOutNumber(A.data.number),A.success?.({code:0,msg:"请求成功"})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async checkAgentLogin(A){try{this.roleData.requestInfo(A);const{agent_no:e}=A.data;if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "agent_no" is required'}));const t=await(A=>Zs(`${Rs}/agent/islogin`,A))({agent_no:e});A.success?.(t)}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async getCallRecord(A){try{this.roleData.agentInfo();const{success:e}=A,t=new Date,s=new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0),i=new Date(t.getFullYear(),t.getMonth(),t.getDate(),23,59,59),r=[this.formatDate(s),this.formatDate(i)],{agent_no:o}=Ve.agentInfo,n=await(A=>Zs(`${Ds}/agent/recordpage`,A))({start_time:r[0],end_time:r[1],page_no:1,page_size:10,agent_no:o}),{code:a,msg:V,data:c}=n;e?.({code:a,msg:V,data:c})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async logout(A){this.roleData.agentInfo();try{const{agent_no:e}=Ve.agentInfo,{data:t,success:s}=A;await(A=>Zs(`${Rs}/agent/logout`,A))({...t,agent_no:e}),s?.({code:0,msg:""})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async listenCall(A){try{const{agent_no:e}=Ve.agentInfo,{data:t,success:s}=A;if(this.roleData.agentInfo(),this.roleData.requestInfo(A),!t.monitored_agent_no)throw new Error(JSON.stringify({code:1,msg:'Parameter "monitored_agent_no" is required'}));await(A=>Zs(`${Rs}/call/monitor`,A))({...t,monitor_agent_no:e}),Ve.monitoredAgentNo=t.monitored_agent_no,s?.({code:0,msg:""})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async earCall(A){try{const{agentInfo:e,monitoredAgentNo:t}=Ve,{agent_no:s}=e;this.roleData.agentInfo();const{success:i}=A;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await xs({monitored_agent_no:t,monitor_agent_no:s}),i?.({code:0,msg:""})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}async stopEarCall(A){try{const{agentInfo:e,earSpeakAgent:t}=Ve;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前没有正在耳语的坐席"}));const{agent_no:s}=e;this.roleData.agentInfo();const{success:i}=A;await xs({monitor_agent_no:s,monitored_agent_no:t}),i?.({code:0,msg:""})}catch(A){throw ae.emit(re.FAIL_NOTIFICATION,JSON.parse(A.message).msg),A}}}let Ns=class extends Et{constructor(){super(...arguments),this.type="info",this.content="",this.duration=3e3}static{this.styles=Ce`
|
|
528
528
|
:host {
|
|
529
529
|
display: block;
|
|
530
530
|
margin-top: 10px;
|
|
@@ -524,7 +524,7 @@ const Zt=A=>(e,t)=>{void 0!==t?t.addInitializer(()=>{customElements.define(A,e)}
|
|
|
524
524
|
* @copyright Chen, Yi-Cyuan 2014-2023
|
|
525
525
|
* @license MIT
|
|
526
526
|
*/
|
|
527
|
-
!function(A){!function(){var s="input is invalid type",i="object"==typeof window,n=i?window:{};n.JS_MD5_NO_WINDOW&&(i=!1);var r=!i&&"object"==typeof self,o=!n.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;o?n=Bs:r&&(n=self);var a,V=!n.JS_MD5_NO_COMMON_JS&&A.exports,c=!n.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,l="0123456789abcdef".split(""),h=[128,32768,8388608,-2147483648],g=[0,8,16,24],q=["hex","array","digest","buffer","arrayBuffer","base64"],d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),u=[];if(c){var p=new ArrayBuffer(68);a=new Uint8Array(p),u=new Uint32Array(p)}var m=Array.isArray;!n.JS_MD5_NO_NODE_JS&&m||(m=function(A){return"[object Array]"===Object.prototype.toString.call(A)});var C=ArrayBuffer.isView;!c||!n.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&C||(C=function(A){return"object"==typeof A&&A.buffer&&A.buffer.constructor===ArrayBuffer});var E=function(A){var e=typeof A;if("string"===e)return[A,!0];if("object"!==e||null===A)throw new Error(s);if(c&&A.constructor===ArrayBuffer)return[new Uint8Array(A),!1];if(!m(A)&&!C(A))throw new Error(s);return[A,!1]},I=function(A){return function(e){return new f(!0).update(e)[A]()}},M=function(A){var i,r=e,o=t.Buffer;i=o.from&&!n.JS_MD5_NO_BUFFER_FROM?o.from:function(A){return new o(A)};return function(e){if("string"==typeof e)return r.createHash("md5").update(e,"utf8").digest("hex");if(null==e)throw new Error(s);return e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),m(e)||C(e)||e.constructor===o?r.createHash("md5").update(i(e)).digest("hex"):A(e)}},w=function(A){return function(e,t){return new B(e,!0).update(t)[A]()}};function f(A){if(A)u[0]=u[16]=u[1]=u[2]=u[3]=u[4]=u[5]=u[6]=u[7]=u[8]=u[9]=u[10]=u[11]=u[12]=u[13]=u[14]=u[15]=0,this.blocks=u,this.buffer8=a;else if(c){var e=new ArrayBuffer(68);this.buffer8=new Uint8Array(e),this.blocks=new Uint32Array(e)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function B(A,e){var t,s=E(A);if(A=s[0],s[1]){var i,n=[],r=A.length,o=0;for(t=0;t<r;++t)(i=A.charCodeAt(t))<128?n[o++]=i:i<2048?(n[o++]=192|i>>>6,n[o++]=128|63&i):i<55296||i>=57344?(n[o++]=224|i>>>12,n[o++]=128|i>>>6&63,n[o++]=128|63&i):(i=65536+((1023&i)<<10|1023&A.charCodeAt(++t)),n[o++]=240|i>>>18,n[o++]=128|i>>>12&63,n[o++]=128|i>>>6&63,n[o++]=128|63&i);A=n}A.length>64&&(A=new f(!0).update(A).array());var a=[],V=[];for(t=0;t<64;++t){var c=A[t]||0;a[t]=92^c,V[t]=54^c}f.call(this,e),this.update(V),this.oKeyPad=a,this.inner=!0,this.sharedMemory=e}f.prototype.update=function(A){if(this.finalized)throw new Error("finalize already called");var e=E(A);A=e[0];for(var t,s,i=e[1],n=0,r=A.length,o=this.blocks,a=this.buffer8;n<r;){if(this.hashed&&(this.hashed=!1,o[0]=o[16],o[16]=o[1]=o[2]=o[3]=o[4]=o[5]=o[6]=o[7]=o[8]=o[9]=o[10]=o[11]=o[12]=o[13]=o[14]=o[15]=0),i)if(c)for(s=this.start;n<r&&s<64;++n)(t=A.charCodeAt(n))<128?a[s++]=t:t<2048?(a[s++]=192|t>>>6,a[s++]=128|63&t):t<55296||t>=57344?(a[s++]=224|t>>>12,a[s++]=128|t>>>6&63,a[s++]=128|63&t):(t=65536+((1023&t)<<10|1023&A.charCodeAt(++n)),a[s++]=240|t>>>18,a[s++]=128|t>>>12&63,a[s++]=128|t>>>6&63,a[s++]=128|63&t);else for(s=this.start;n<r&&s<64;++n)(t=A.charCodeAt(n))<128?o[s>>>2]|=t<<g[3&s++]:t<2048?(o[s>>>2]|=(192|t>>>6)<<g[3&s++],o[s>>>2]|=(128|63&t)<<g[3&s++]):t<55296||t>=57344?(o[s>>>2]|=(224|t>>>12)<<g[3&s++],o[s>>>2]|=(128|t>>>6&63)<<g[3&s++],o[s>>>2]|=(128|63&t)<<g[3&s++]):(t=65536+((1023&t)<<10|1023&A.charCodeAt(++n)),o[s>>>2]|=(240|t>>>18)<<g[3&s++],o[s>>>2]|=(128|t>>>12&63)<<g[3&s++],o[s>>>2]|=(128|t>>>6&63)<<g[3&s++],o[s>>>2]|=(128|63&t)<<g[3&s++]);else if(c)for(s=this.start;n<r&&s<64;++n)a[s++]=A[n];else for(s=this.start;n<r&&s<64;++n)o[s>>>2]|=A[n]<<g[3&s++];this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},f.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var A=this.blocks,e=this.lastByteIndex;A[e>>>2]|=h[3&e],e>=56&&(this.hashed||this.hash(),A[0]=A[16],A[16]=A[1]=A[2]=A[3]=A[4]=A[5]=A[6]=A[7]=A[8]=A[9]=A[10]=A[11]=A[12]=A[13]=A[14]=A[15]=0),A[14]=this.bytes<<3,A[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},f.prototype.hash=function(){var A,e,t,s,i,n,r=this.blocks;this.first?e=((e=((A=((A=r[0]-680876937)<<7|A>>>25)-271733879|0)^(t=((t=(-271733879^(s=((s=(-1732584194^2004318071&A)+r[1]-117830708)<<12|s>>>20)+A|0)&(-271733879^A))+r[2]-1126478375)<<17|t>>>15)+s|0)&(s^A))+r[3]-1316259209)<<22|e>>>10)+t|0:(A=this.h0,e=this.h1,t=this.h2,e=((e+=((A=((A+=((s=this.h3)^e&(t^s))+r[0]-680876936)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[1]-389564586)<<12|s>>>20)+A|0)&(A^e))+r[2]+606105819)<<17|t>>>15)+s|0)&(s^A))+r[3]-1044525330)<<22|e>>>10)+t|0),e=((e+=((A=((A+=(s^e&(t^s))+r[4]-176418897)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[5]+1200080426)<<12|s>>>20)+A|0)&(A^e))+r[6]-1473231341)<<17|t>>>15)+s|0)&(s^A))+r[7]-45705983)<<22|e>>>10)+t|0,e=((e+=((A=((A+=(s^e&(t^s))+r[8]+1770035416)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[9]-1958414417)<<12|s>>>20)+A|0)&(A^e))+r[10]-42063)<<17|t>>>15)+s|0)&(s^A))+r[11]-1990404162)<<22|e>>>10)+t|0,e=((e+=((A=((A+=(s^e&(t^s))+r[12]+1804603682)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[13]-40341101)<<12|s>>>20)+A|0)&(A^e))+r[14]-1502002290)<<17|t>>>15)+s|0)&(s^A))+r[15]+1236535329)<<22|e>>>10)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[1]-165796510)<<5|A>>>27)+e|0)^e))+r[6]-1069501632)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[11]+643717713)<<14|t>>>18)+s|0)^s))+r[0]-373897302)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[5]-701558691)<<5|A>>>27)+e|0)^e))+r[10]+38016083)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[15]-660478335)<<14|t>>>18)+s|0)^s))+r[4]-405537848)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[9]+568446438)<<5|A>>>27)+e|0)^e))+r[14]-1019803690)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[3]-187363961)<<14|t>>>18)+s|0)^s))+r[8]+1163531501)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[13]-1444681467)<<5|A>>>27)+e|0)^e))+r[2]-51403784)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[7]+1735328473)<<14|t>>>18)+s|0)^s))+r[12]-1926607734)<<20|e>>>12)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[5]-378558)<<4|A>>>28)+e|0))+r[8]-2022574463)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[11]+1839030562)<<16|t>>>16)+s|0))+r[14]-35309556)<<23|e>>>9)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[1]-1530992060)<<4|A>>>28)+e|0))+r[4]+1272893353)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[7]-155497632)<<16|t>>>16)+s|0))+r[10]-1094730640)<<23|e>>>9)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[13]+681279174)<<4|A>>>28)+e|0))+r[0]-358537222)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[3]-722521979)<<16|t>>>16)+s|0))+r[6]+76029189)<<23|e>>>9)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[9]-640364487)<<4|A>>>28)+e|0))+r[12]-421815835)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[15]+530742520)<<16|t>>>16)+s|0))+r[2]-995338651)<<23|e>>>9)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[0]-198630844)<<6|A>>>26)+e|0)|~t))+r[7]+1126891415)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[14]-1416354905)<<15|t>>>17)+s|0)|~A))+r[5]-57434055)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[12]+1700485571)<<6|A>>>26)+e|0)|~t))+r[3]-1894986606)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[10]-1051523)<<15|t>>>17)+s|0)|~A))+r[1]-2054922799)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[8]+1873313359)<<6|A>>>26)+e|0)|~t))+r[15]-30611744)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[6]-1560198380)<<15|t>>>17)+s|0)|~A))+r[13]+1309151649)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[4]-145523070)<<6|A>>>26)+e|0)|~t))+r[11]-1120210379)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[2]+718787259)<<15|t>>>17)+s|0)|~A))+r[9]-343485551)<<21|e>>>11)+t|0,this.first?(this.h0=A+1732584193|0,this.h1=e-271733879|0,this.h2=t-1732584194|0,this.h3=s+271733878|0,this.first=!1):(this.h0=this.h0+A|0,this.h1=this.h1+e|0,this.h2=this.h2+t|0,this.h3=this.h3+s|0)},f.prototype.hex=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,s=this.h3;return l[A>>>4&15]+l[15&A]+l[A>>>12&15]+l[A>>>8&15]+l[A>>>20&15]+l[A>>>16&15]+l[A>>>28&15]+l[A>>>24&15]+l[e>>>4&15]+l[15&e]+l[e>>>12&15]+l[e>>>8&15]+l[e>>>20&15]+l[e>>>16&15]+l[e>>>28&15]+l[e>>>24&15]+l[t>>>4&15]+l[15&t]+l[t>>>12&15]+l[t>>>8&15]+l[t>>>20&15]+l[t>>>16&15]+l[t>>>28&15]+l[t>>>24&15]+l[s>>>4&15]+l[15&s]+l[s>>>12&15]+l[s>>>8&15]+l[s>>>20&15]+l[s>>>16&15]+l[s>>>28&15]+l[s>>>24&15]},f.prototype.toString=f.prototype.hex,f.prototype.digest=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,s=this.h3;return[255&A,A>>>8&255,A>>>16&255,A>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&s,s>>>8&255,s>>>16&255,s>>>24&255]},f.prototype.array=f.prototype.digest,f.prototype.arrayBuffer=function(){this.finalize();var A=new ArrayBuffer(16),e=new Uint32Array(A);return e[0]=this.h0,e[1]=this.h1,e[2]=this.h2,e[3]=this.h3,A},f.prototype.buffer=f.prototype.arrayBuffer,f.prototype.base64=function(){for(var A,e,t,s="",i=this.array(),n=0;n<15;)A=i[n++],e=i[n++],t=i[n++],s+=d[A>>>2]+d[63&(A<<4|e>>>4)]+d[63&(e<<2|t>>>6)]+d[63&t];return A=i[n],s+=d[A>>>2]+d[A<<4&63]+"=="},B.prototype=new f,B.prototype.finalize=function(){if(f.prototype.finalize.call(this),this.inner){this.inner=!1;var A=this.array();f.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(A),f.prototype.finalize.call(this)}};var Q=function(){var A=I("hex");o&&(A=M(A)),A.create=function(){return new f},A.update=function(e){return A.create().update(e)};for(var e=0;e<q.length;++e){var t=q[e];A[t]=I(t)}return A}();Q.md5=Q,Q.md5.hmac=function(){var A=w("hex");A.create=function(A){return new B(A)},A.update=function(e,t){return A.create(e).update(t)};for(var e=0;e<q.length;++e){var t=q[e];A[t]=w(t)}return A}(),V?A.exports=Q:n.md5=Q}()}(Qs);var Ss=Qs.exports;const Ts=(A,e)=>{const t=Date.now(),s=`${A}:${t}:${Ss.md5(`${e}${t}`)}`,i=(new TextEncoder).encode(s);return btoa(String.fromCharCode(...i))},ys=A=>/^\d+$/.test(A),Ds="/v1/aicc/bmserver",Rs="/v1/aicc/ccs";let Us="",ks="",Gs="",Fs="";function Ys(){const A=Ts(ks,Gs);return fs.create({prefixUrl:`${Us}`,timeout:!1,headers:{Authorization:A},hooks:{afterResponse:[async(A,e,t)=>{if(-1!==t.url.indexOf("heartbeat"))return t;const s=await t.clone().json();if(0!==s.code)throw new Error(JSON.stringify(s)||"请求失败");return t.json=async()=>s,t}]}})}async function vs(A,e){const t=Ys(),s="api/"+A.replace(/^\/+/,"");return t.post(s,{json:e}).json()}const Zs=A=>vs(`${Rs}/state/change`,A),Os=()=>async function(A,e){const t=Ys(),s=A.replace(/^\/+/,"");return t.post(s,{json:e}).json()}("/heartbeat",{}),xs=A=>vs(`${Rs}/call/whisper`,A);class Ns{constructor(){this.roleData={agentInfo:()=>{if(!ce.agentInfo?.agent_no)throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:A=>{if(!A.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:A=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:e}=ce.agentInfo;if(!e.split(",").map(A=>Number(A)).includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(A,e)=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(2===A&&("通话中"===e||"整理"===e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},setAgentExplicit:A=>{const{out_display_select_switch:e,out_display_data:t}=ce.agentInfo;if(1!==e)throw new Error(JSON.stringify({code:1,msg:"当前坐席设置未开启允许指定外显"}));if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "number" is required'}));if(!(t||"").split("#").includes(A))throw new Error(JSON.stringify({code:1,msg:"当前外显号码不存在"}))}}}formatDate(A){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")} ${String(A.getHours()).padStart(2,"0")}:${String(A.getMinutes()).padStart(2,"0")}:${String(A.getSeconds()).padStart(2,"0")}`}async _agentLogin(e){try{const A=await(t={agent_no:e},vs(`${Rs}/agent/login`,t));ce.agentInfo=A.data}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}var t}async _changeState(e){try{ce.autoStateTimer&&(clearTimeout(ce.autoStateTimer),ce.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:t,success:s}=e,{state:i,state_name:n}=t,{agent_no:r}=ce.agentInfo;await Zs({agent_no:r,state_name:n,state:i}),i===A.AgentStatus.IDLE?he.updateActionConfigs(Bt):i===A.AgentStatus.BUSY&&he.updateActionConfigs(Qt),ce.stateObject={state:i,state_name:n},s?.({code:0,msg:"请求成功"})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async _getInCallCrmDetail(e){try{const{phone:A}=e.data,t={};ys(A)?t.phone=A:t.trace_id=A;const s=await(A=>vs(`${Ds}/crm/popups`,A))({...t});e.success?.(s)}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async changeDevice(e){try{if(he.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:t,success:s}=e,{device:i}=t;1===i&&he.updateAnswerDevice(i),this.roleData.changeDevice(i);const{agent_no:n}=ce.agentInfo;await(A=>vs(`${Rs}/device/change`,A))({agent_no:n,answer_device:i}),he.updateAnswerDevice(i);const r=he.get("actionConfigs");he.updateActionConfigs(r),2===i&&ce.stateObject.state===A.AgentStatus.UNREGISTERED&&await this._changeState({data:{...ce.stateBeforeChange,state_name:ce.stateBeforeChange.state===A.AgentStatus.IDLE?"空闲":"忙碌"}}),s?.({code:0,msg:"请求成功"})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async changeState(e){try{if(he.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));ce.autoStateTimer&&(clearTimeout(ce.autoStateTimer),ce.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:t,success:s}=e,{state:i,state_name:n}=t;this.roleData.changeState(i,n);const{agent_no:r}=ce.agentInfo;await Zs({agent_no:r,state_name:n,state:i}),(ce.stateObject.state===A.AgentStatus.IDLE||ce.stateObject.state===A.AgentStatus.BUSY&&"整理"!==n)&&(ce.stateBeforeChange=ce.stateObject),i===A.AgentStatus.IDLE?he.updateActionConfigs(Bt):i===A.AgentStatus.BUSY&&he.updateActionConfigs(Qt),ce.stateObject={state:i,state_name:n},s?.({code:0,msg:"请求成功"})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async getIdleAgentList(e){const{agent_no:t}=ce.agentInfo;try{this.roleData.agentInfo();const A=await(A=>vs(`${Rs}/agent/free`,A))({agent_no:t});e.success?.(A)}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async getAgentState(e){try{const A=await vs(`${Ds}/agent/statecfg/list`,{}),t=(A.data||[]).filter(A=>0===A.enable).filter(A=>0!==A.state&&3!==A.state).filter(A=>"通话中"!==A.state_name&&"整理"!==A.state_name&&"未注册"!==A.state_name&&"离线接听"!==A.state_name).map(A=>({state:A.state,state_name:A.state_name})).reverse();e.success?.({...A,data:t})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async setAgentExplicit(e){try{this.roleData.agentInfo(),this.roleData.requestInfo(e),this.roleData.setAgentExplicit(e.data.number);const{agent_id:A}=ce.agentInfo;await(A=>vs(`${Ds}/agent/update`,A))({agent_id:A,out_display_number:e.data.number}),he.updateSelectOutNumber(e.data.number),e.success?.({code:0,msg:"请求成功"})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async checkAgentLogin(e){try{this.roleData.requestInfo(e);const{agent_no:A}=e.data;if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "agent_no" is required'}));const t=await(A=>vs(`${Rs}/agent/islogin`,A))({agent_no:A});e.success?.(t)}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async getCallRecord(e){try{this.roleData.agentInfo();const{success:A}=e,t=new Date,s=new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0),i=new Date(t.getFullYear(),t.getMonth(),t.getDate(),23,59,59),n=[this.formatDate(s),this.formatDate(i)],{agent_no:r}=ce.agentInfo,o=await(A=>vs(`${Ds}/agent/recordpage`,A))({start_time:n[0],end_time:n[1],page_no:1,page_size:10,agent_no:r}),{code:a,msg:V,data:c}=o;A?.({code:a,msg:V,data:c})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async logout(e){this.roleData.agentInfo();try{const{agent_no:A}=ce.agentInfo,{data:t,success:s}=e;await(A=>vs(`${Rs}/agent/logout`,A))({...t,agent_no:A}),s?.({code:0,msg:""})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async listenCall(e){try{const{agent_no:A}=ce.agentInfo,{data:t,success:s}=e;if(this.roleData.agentInfo(),this.roleData.requestInfo(e),!t.monitored_agent_no)throw new Error(JSON.stringify({code:1,msg:'Parameter "monitored_agent_no" is required'}));await(A=>vs(`${Rs}/call/monitor`,A))({...t,monitor_agent_no:A}),ce.monitoredAgentNo=t.monitored_agent_no,s?.({code:0,msg:""})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async earCall(e){try{const{agentInfo:A,monitoredAgentNo:t}=ce,{agent_no:s}=A;this.roleData.agentInfo(),this.roleData.requestInfo(e);const{success:i}=e;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await xs({monitored_agent_no:t,monitor_agent_no:s}),i?.({code:0,msg:""})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async stopEarCall(e){try{const{agentInfo:A,earSpeakAgent:t}=ce;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前没有正在耳语的坐席"}));const{agent_no:s}=A;this.roleData.agentInfo();const{success:i}=e;await xs({monitor_agent_no:s,monitored_agent_no:t}),i?.({code:0,msg:""})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}}let Ks=class extends It{constructor(){super(...arguments),this.type="info",this.content="",this.duration=3e3}static{this.styles=Ee`
|
|
527
|
+
!function(A){!function(){var s="input is invalid type",i="object"==typeof window,n=i?window:{};n.JS_MD5_NO_WINDOW&&(i=!1);var r=!i&&"object"==typeof self,o=!n.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;o?n=Bs:r&&(n=self);var a,V=!n.JS_MD5_NO_COMMON_JS&&A.exports,c=!n.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,l="0123456789abcdef".split(""),h=[128,32768,8388608,-2147483648],g=[0,8,16,24],q=["hex","array","digest","buffer","arrayBuffer","base64"],d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),u=[];if(c){var p=new ArrayBuffer(68);a=new Uint8Array(p),u=new Uint32Array(p)}var m=Array.isArray;!n.JS_MD5_NO_NODE_JS&&m||(m=function(A){return"[object Array]"===Object.prototype.toString.call(A)});var C=ArrayBuffer.isView;!c||!n.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&C||(C=function(A){return"object"==typeof A&&A.buffer&&A.buffer.constructor===ArrayBuffer});var E=function(A){var e=typeof A;if("string"===e)return[A,!0];if("object"!==e||null===A)throw new Error(s);if(c&&A.constructor===ArrayBuffer)return[new Uint8Array(A),!1];if(!m(A)&&!C(A))throw new Error(s);return[A,!1]},I=function(A){return function(e){return new f(!0).update(e)[A]()}},M=function(A){var i,r=e,o=t.Buffer;i=o.from&&!n.JS_MD5_NO_BUFFER_FROM?o.from:function(A){return new o(A)};return function(e){if("string"==typeof e)return r.createHash("md5").update(e,"utf8").digest("hex");if(null==e)throw new Error(s);return e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),m(e)||C(e)||e.constructor===o?r.createHash("md5").update(i(e)).digest("hex"):A(e)}},w=function(A){return function(e,t){return new B(e,!0).update(t)[A]()}};function f(A){if(A)u[0]=u[16]=u[1]=u[2]=u[3]=u[4]=u[5]=u[6]=u[7]=u[8]=u[9]=u[10]=u[11]=u[12]=u[13]=u[14]=u[15]=0,this.blocks=u,this.buffer8=a;else if(c){var e=new ArrayBuffer(68);this.buffer8=new Uint8Array(e),this.blocks=new Uint32Array(e)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function B(A,e){var t,s=E(A);if(A=s[0],s[1]){var i,n=[],r=A.length,o=0;for(t=0;t<r;++t)(i=A.charCodeAt(t))<128?n[o++]=i:i<2048?(n[o++]=192|i>>>6,n[o++]=128|63&i):i<55296||i>=57344?(n[o++]=224|i>>>12,n[o++]=128|i>>>6&63,n[o++]=128|63&i):(i=65536+((1023&i)<<10|1023&A.charCodeAt(++t)),n[o++]=240|i>>>18,n[o++]=128|i>>>12&63,n[o++]=128|i>>>6&63,n[o++]=128|63&i);A=n}A.length>64&&(A=new f(!0).update(A).array());var a=[],V=[];for(t=0;t<64;++t){var c=A[t]||0;a[t]=92^c,V[t]=54^c}f.call(this,e),this.update(V),this.oKeyPad=a,this.inner=!0,this.sharedMemory=e}f.prototype.update=function(A){if(this.finalized)throw new Error("finalize already called");var e=E(A);A=e[0];for(var t,s,i=e[1],n=0,r=A.length,o=this.blocks,a=this.buffer8;n<r;){if(this.hashed&&(this.hashed=!1,o[0]=o[16],o[16]=o[1]=o[2]=o[3]=o[4]=o[5]=o[6]=o[7]=o[8]=o[9]=o[10]=o[11]=o[12]=o[13]=o[14]=o[15]=0),i)if(c)for(s=this.start;n<r&&s<64;++n)(t=A.charCodeAt(n))<128?a[s++]=t:t<2048?(a[s++]=192|t>>>6,a[s++]=128|63&t):t<55296||t>=57344?(a[s++]=224|t>>>12,a[s++]=128|t>>>6&63,a[s++]=128|63&t):(t=65536+((1023&t)<<10|1023&A.charCodeAt(++n)),a[s++]=240|t>>>18,a[s++]=128|t>>>12&63,a[s++]=128|t>>>6&63,a[s++]=128|63&t);else for(s=this.start;n<r&&s<64;++n)(t=A.charCodeAt(n))<128?o[s>>>2]|=t<<g[3&s++]:t<2048?(o[s>>>2]|=(192|t>>>6)<<g[3&s++],o[s>>>2]|=(128|63&t)<<g[3&s++]):t<55296||t>=57344?(o[s>>>2]|=(224|t>>>12)<<g[3&s++],o[s>>>2]|=(128|t>>>6&63)<<g[3&s++],o[s>>>2]|=(128|63&t)<<g[3&s++]):(t=65536+((1023&t)<<10|1023&A.charCodeAt(++n)),o[s>>>2]|=(240|t>>>18)<<g[3&s++],o[s>>>2]|=(128|t>>>12&63)<<g[3&s++],o[s>>>2]|=(128|t>>>6&63)<<g[3&s++],o[s>>>2]|=(128|63&t)<<g[3&s++]);else if(c)for(s=this.start;n<r&&s<64;++n)a[s++]=A[n];else for(s=this.start;n<r&&s<64;++n)o[s>>>2]|=A[n]<<g[3&s++];this.lastByteIndex=s,this.bytes+=s-this.start,s>=64?(this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},f.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var A=this.blocks,e=this.lastByteIndex;A[e>>>2]|=h[3&e],e>=56&&(this.hashed||this.hash(),A[0]=A[16],A[16]=A[1]=A[2]=A[3]=A[4]=A[5]=A[6]=A[7]=A[8]=A[9]=A[10]=A[11]=A[12]=A[13]=A[14]=A[15]=0),A[14]=this.bytes<<3,A[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},f.prototype.hash=function(){var A,e,t,s,i,n,r=this.blocks;this.first?e=((e=((A=((A=r[0]-680876937)<<7|A>>>25)-271733879|0)^(t=((t=(-271733879^(s=((s=(-1732584194^2004318071&A)+r[1]-117830708)<<12|s>>>20)+A|0)&(-271733879^A))+r[2]-1126478375)<<17|t>>>15)+s|0)&(s^A))+r[3]-1316259209)<<22|e>>>10)+t|0:(A=this.h0,e=this.h1,t=this.h2,e=((e+=((A=((A+=((s=this.h3)^e&(t^s))+r[0]-680876936)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[1]-389564586)<<12|s>>>20)+A|0)&(A^e))+r[2]+606105819)<<17|t>>>15)+s|0)&(s^A))+r[3]-1044525330)<<22|e>>>10)+t|0),e=((e+=((A=((A+=(s^e&(t^s))+r[4]-176418897)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[5]+1200080426)<<12|s>>>20)+A|0)&(A^e))+r[6]-1473231341)<<17|t>>>15)+s|0)&(s^A))+r[7]-45705983)<<22|e>>>10)+t|0,e=((e+=((A=((A+=(s^e&(t^s))+r[8]+1770035416)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[9]-1958414417)<<12|s>>>20)+A|0)&(A^e))+r[10]-42063)<<17|t>>>15)+s|0)&(s^A))+r[11]-1990404162)<<22|e>>>10)+t|0,e=((e+=((A=((A+=(s^e&(t^s))+r[12]+1804603682)<<7|A>>>25)+e|0)^(t=((t+=(e^(s=((s+=(t^A&(e^t))+r[13]-40341101)<<12|s>>>20)+A|0)&(A^e))+r[14]-1502002290)<<17|t>>>15)+s|0)&(s^A))+r[15]+1236535329)<<22|e>>>10)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[1]-165796510)<<5|A>>>27)+e|0)^e))+r[6]-1069501632)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[11]+643717713)<<14|t>>>18)+s|0)^s))+r[0]-373897302)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[5]-701558691)<<5|A>>>27)+e|0)^e))+r[10]+38016083)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[15]-660478335)<<14|t>>>18)+s|0)^s))+r[4]-405537848)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[9]+568446438)<<5|A>>>27)+e|0)^e))+r[14]-1019803690)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[3]-187363961)<<14|t>>>18)+s|0)^s))+r[8]+1163531501)<<20|e>>>12)+t|0,e=((e+=((s=((s+=(e^t&((A=((A+=(t^s&(e^t))+r[13]-1444681467)<<5|A>>>27)+e|0)^e))+r[2]-51403784)<<9|s>>>23)+A|0)^A&((t=((t+=(A^e&(s^A))+r[7]+1735328473)<<14|t>>>18)+s|0)^s))+r[12]-1926607734)<<20|e>>>12)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[5]-378558)<<4|A>>>28)+e|0))+r[8]-2022574463)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[11]+1839030562)<<16|t>>>16)+s|0))+r[14]-35309556)<<23|e>>>9)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[1]-1530992060)<<4|A>>>28)+e|0))+r[4]+1272893353)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[7]-155497632)<<16|t>>>16)+s|0))+r[10]-1094730640)<<23|e>>>9)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[13]+681279174)<<4|A>>>28)+e|0))+r[0]-358537222)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[3]-722521979)<<16|t>>>16)+s|0))+r[6]+76029189)<<23|e>>>9)+t|0,e=((e+=((n=(s=((s+=((i=e^t)^(A=((A+=(i^s)+r[9]-640364487)<<4|A>>>28)+e|0))+r[12]-421815835)<<11|s>>>21)+A|0)^A)^(t=((t+=(n^e)+r[15]+530742520)<<16|t>>>16)+s|0))+r[2]-995338651)<<23|e>>>9)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[0]-198630844)<<6|A>>>26)+e|0)|~t))+r[7]+1126891415)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[14]-1416354905)<<15|t>>>17)+s|0)|~A))+r[5]-57434055)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[12]+1700485571)<<6|A>>>26)+e|0)|~t))+r[3]-1894986606)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[10]-1051523)<<15|t>>>17)+s|0)|~A))+r[1]-2054922799)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[8]+1873313359)<<6|A>>>26)+e|0)|~t))+r[15]-30611744)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[6]-1560198380)<<15|t>>>17)+s|0)|~A))+r[13]+1309151649)<<21|e>>>11)+t|0,e=((e+=((s=((s+=(e^((A=((A+=(t^(e|~s))+r[4]-145523070)<<6|A>>>26)+e|0)|~t))+r[11]-1120210379)<<10|s>>>22)+A|0)^((t=((t+=(A^(s|~e))+r[2]+718787259)<<15|t>>>17)+s|0)|~A))+r[9]-343485551)<<21|e>>>11)+t|0,this.first?(this.h0=A+1732584193|0,this.h1=e-271733879|0,this.h2=t-1732584194|0,this.h3=s+271733878|0,this.first=!1):(this.h0=this.h0+A|0,this.h1=this.h1+e|0,this.h2=this.h2+t|0,this.h3=this.h3+s|0)},f.prototype.hex=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,s=this.h3;return l[A>>>4&15]+l[15&A]+l[A>>>12&15]+l[A>>>8&15]+l[A>>>20&15]+l[A>>>16&15]+l[A>>>28&15]+l[A>>>24&15]+l[e>>>4&15]+l[15&e]+l[e>>>12&15]+l[e>>>8&15]+l[e>>>20&15]+l[e>>>16&15]+l[e>>>28&15]+l[e>>>24&15]+l[t>>>4&15]+l[15&t]+l[t>>>12&15]+l[t>>>8&15]+l[t>>>20&15]+l[t>>>16&15]+l[t>>>28&15]+l[t>>>24&15]+l[s>>>4&15]+l[15&s]+l[s>>>12&15]+l[s>>>8&15]+l[s>>>20&15]+l[s>>>16&15]+l[s>>>28&15]+l[s>>>24&15]},f.prototype.toString=f.prototype.hex,f.prototype.digest=function(){this.finalize();var A=this.h0,e=this.h1,t=this.h2,s=this.h3;return[255&A,A>>>8&255,A>>>16&255,A>>>24&255,255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&s,s>>>8&255,s>>>16&255,s>>>24&255]},f.prototype.array=f.prototype.digest,f.prototype.arrayBuffer=function(){this.finalize();var A=new ArrayBuffer(16),e=new Uint32Array(A);return e[0]=this.h0,e[1]=this.h1,e[2]=this.h2,e[3]=this.h3,A},f.prototype.buffer=f.prototype.arrayBuffer,f.prototype.base64=function(){for(var A,e,t,s="",i=this.array(),n=0;n<15;)A=i[n++],e=i[n++],t=i[n++],s+=d[A>>>2]+d[63&(A<<4|e>>>4)]+d[63&(e<<2|t>>>6)]+d[63&t];return A=i[n],s+=d[A>>>2]+d[A<<4&63]+"=="},B.prototype=new f,B.prototype.finalize=function(){if(f.prototype.finalize.call(this),this.inner){this.inner=!1;var A=this.array();f.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(A),f.prototype.finalize.call(this)}};var Q=function(){var A=I("hex");o&&(A=M(A)),A.create=function(){return new f},A.update=function(e){return A.create().update(e)};for(var e=0;e<q.length;++e){var t=q[e];A[t]=I(t)}return A}();Q.md5=Q,Q.md5.hmac=function(){var A=w("hex");A.create=function(A){return new B(A)},A.update=function(e,t){return A.create(e).update(t)};for(var e=0;e<q.length;++e){var t=q[e];A[t]=w(t)}return A}(),V?A.exports=Q:n.md5=Q}()}(Qs);var Ss=Qs.exports;const Ts=(A,e)=>{const t=Date.now(),s=`${A}:${t}:${Ss.md5(`${e}${t}`)}`,i=(new TextEncoder).encode(s);return btoa(String.fromCharCode(...i))},ys=A=>/^\d+$/.test(A),Ds="/v1/aicc/bmserver",Rs="/v1/aicc/ccs";let Us="",ks="",Gs="",Fs="";function Ys(){const A=Ts(ks,Gs);return fs.create({prefixUrl:`${Us}`,timeout:!1,headers:{Authorization:A},hooks:{afterResponse:[async(A,e,t)=>{if(-1!==t.url.indexOf("heartbeat"))return t;const s=await t.clone().json();if(0!==s.code)throw new Error(JSON.stringify(s)||"请求失败");return t.json=async()=>s,t}]}})}async function vs(A,e){const t=Ys(),s="api/"+A.replace(/^\/+/,"");return t.post(s,{json:e}).json()}const Zs=A=>vs(`${Rs}/state/change`,A),Os=()=>async function(A,e){const t=Ys(),s=A.replace(/^\/+/,"");return t.post(s,{json:e}).json()}("/heartbeat",{}),xs=A=>vs(`${Rs}/call/whisper`,A);class Ns{constructor(){this.roleData={agentInfo:()=>{if(!ce.agentInfo?.agent_no)throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:A=>{if(!A.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:A=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:e}=ce.agentInfo;if(!e.split(",").map(A=>Number(A)).includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(A,e)=>{if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(2===A&&("通话中"===e||"整理"===e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(A))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},setAgentExplicit:A=>{const{out_display_select_switch:e,out_display_data:t}=ce.agentInfo;if(1!==e)throw new Error(JSON.stringify({code:1,msg:"当前坐席设置未开启允许指定外显"}));if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "number" is required'}));if(!(t||"").split("#").includes(A))throw new Error(JSON.stringify({code:1,msg:"当前外显号码不存在"}))}}}formatDate(A){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")} ${String(A.getHours()).padStart(2,"0")}:${String(A.getMinutes()).padStart(2,"0")}:${String(A.getSeconds()).padStart(2,"0")}`}async _agentLogin(e){try{const A=await(t={agent_no:e},vs(`${Rs}/agent/login`,t));ce.agentInfo=A.data}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}var t}async _changeState(e){try{ce.autoStateTimer&&(clearTimeout(ce.autoStateTimer),ce.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:t,success:s}=e,{state:i,state_name:n}=t,{agent_no:r}=ce.agentInfo;await Zs({agent_no:r,state_name:n,state:i}),i===A.AgentStatus.IDLE?he.updateActionConfigs(Bt):i===A.AgentStatus.BUSY&&he.updateActionConfigs(Qt),ce.stateObject={state:i,state_name:n},s?.({code:0,msg:"请求成功"})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async _getInCallCrmDetail(e){try{const{phone:A}=e.data,t={};ys(A)?t.phone=A:t.trace_id=A;const s=await(A=>vs(`${Ds}/crm/popups`,A))({...t});e.success?.(s)}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async changeDevice(e){try{if(he.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:t,success:s}=e,{device:i}=t;1===i&&he.updateAnswerDevice(i),this.roleData.changeDevice(i);const{agent_no:n}=ce.agentInfo;await(A=>vs(`${Rs}/device/change`,A))({agent_no:n,answer_device:i}),he.updateAnswerDevice(i);const r=he.get("actionConfigs");he.updateActionConfigs(r),2===i&&ce.stateObject.state===A.AgentStatus.UNREGISTERED&&await this._changeState({data:{...ce.stateBeforeChange,state_name:ce.stateBeforeChange.state===A.AgentStatus.IDLE?"空闲":"忙碌"}}),s?.({code:0,msg:"请求成功"})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async changeState(e){try{if(he.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));ce.autoStateTimer&&(clearTimeout(ce.autoStateTimer),ce.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:t,success:s}=e,{state:i,state_name:n}=t;this.roleData.changeState(i,n);const{agent_no:r}=ce.agentInfo;await Zs({agent_no:r,state_name:n,state:i}),(ce.stateObject.state===A.AgentStatus.IDLE||ce.stateObject.state===A.AgentStatus.BUSY&&"整理"!==n)&&(ce.stateBeforeChange=ce.stateObject),i===A.AgentStatus.IDLE?he.updateActionConfigs(Bt):i===A.AgentStatus.BUSY&&he.updateActionConfigs(Qt),ce.stateObject={state:i,state_name:n},s?.({code:0,msg:"请求成功"})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async getIdleAgentList(e){const{agent_no:t}=ce.agentInfo;try{this.roleData.agentInfo();const A=await(A=>vs(`${Rs}/agent/free`,A))({agent_no:t});e.success?.(A)}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async getAgentState(e){try{const A=await vs(`${Ds}/agent/statecfg/list`,{}),t=(A.data||[]).filter(A=>0===A.enable).filter(A=>0!==A.state&&3!==A.state).filter(A=>"通话中"!==A.state_name&&"整理"!==A.state_name&&"未注册"!==A.state_name&&"离线接听"!==A.state_name).map(A=>({state:A.state,state_name:A.state_name})).reverse();e.success?.({...A,data:t})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async setAgentExplicit(e){try{this.roleData.agentInfo(),this.roleData.requestInfo(e),this.roleData.setAgentExplicit(e.data.number);const{agent_id:A}=ce.agentInfo;await(A=>vs(`${Ds}/agent/update`,A))({agent_id:A,out_display_number:e.data.number}),he.updateSelectOutNumber(e.data.number),e.success?.({code:0,msg:"请求成功"})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async checkAgentLogin(e){try{this.roleData.requestInfo(e);const{agent_no:A}=e.data;if(!A)throw new Error(JSON.stringify({code:1,msg:'Parameter "agent_no" is required'}));const t=await(A=>vs(`${Rs}/agent/islogin`,A))({agent_no:A});e.success?.(t)}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async getCallRecord(e){try{this.roleData.agentInfo();const{success:A}=e,t=new Date,s=new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0),i=new Date(t.getFullYear(),t.getMonth(),t.getDate(),23,59,59),n=[this.formatDate(s),this.formatDate(i)],{agent_no:r}=ce.agentInfo,o=await(A=>vs(`${Ds}/agent/recordpage`,A))({start_time:n[0],end_time:n[1],page_no:1,page_size:10,agent_no:r}),{code:a,msg:V,data:c}=o;A?.({code:a,msg:V,data:c})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async logout(e){this.roleData.agentInfo();try{const{agent_no:A}=ce.agentInfo,{data:t,success:s}=e;await(A=>vs(`${Rs}/agent/logout`,A))({...t,agent_no:A}),s?.({code:0,msg:""})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async listenCall(e){try{const{agent_no:A}=ce.agentInfo,{data:t,success:s}=e;if(this.roleData.agentInfo(),this.roleData.requestInfo(e),!t.monitored_agent_no)throw new Error(JSON.stringify({code:1,msg:'Parameter "monitored_agent_no" is required'}));await(A=>vs(`${Rs}/call/monitor`,A))({...t,monitor_agent_no:A}),ce.monitoredAgentNo=t.monitored_agent_no,s?.({code:0,msg:""})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async earCall(e){try{const{agentInfo:A,monitoredAgentNo:t}=ce,{agent_no:s}=A;this.roleData.agentInfo();const{success:i}=e;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await xs({monitored_agent_no:t,monitor_agent_no:s}),i?.({code:0,msg:""})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}async stopEarCall(e){try{const{agentInfo:A,earSpeakAgent:t}=ce;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前没有正在耳语的坐席"}));const{agent_no:s}=A;this.roleData.agentInfo();const{success:i}=e;await xs({monitor_agent_no:s,monitored_agent_no:t}),i?.({code:0,msg:""})}catch(e){throw Ve.emit(A.EventName.FAIL_NOTIFICATION,JSON.parse(e.message).msg),e}}}let Ks=class extends It{constructor(){super(...arguments),this.type="info",this.content="",this.duration=3e3}static{this.styles=Ee`
|
|
528
528
|
:host {
|
|
529
529
|
display: block;
|
|
530
530
|
margin-top: 10px;
|