ysyt-react-agent-lib 1.2.29 → 1.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ConsultModel-CuZkIKkR.mjs → ConsultModel-Drj_G5X0.mjs} +2 -2
- package/dist/{ConsultModel-jmIlt-NX.js → ConsultModel-SOPfzVzm.js} +1 -1
- package/dist/{TransferModel-DImaY37Y.mjs → TransferModel-DnkmhYXF.mjs} +2 -2
- package/dist/{TransferModel-Dwpt0k23.js → TransferModel-DvJoGCCU.js} +1 -1
- package/dist/{index-Bog4mamg.mjs → index-B1H13oYF.mjs} +2 -2
- package/dist/{index-CacMonKa.mjs → index-B9tTbkR-.mjs} +1 -1
- package/dist/{index-DBzza2zf.js → index-Bv7k4mKs.js} +1 -1
- package/dist/{index-yA-8foML.js → index-Dh83b1rK.js} +2 -2
- package/dist/ysyt-react-agent-lib.cjs.js +1 -1
- package/dist/ysyt-react-agent-lib.es.js +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { j as e, M as l, E as r, S as i, Y as d } from "./index-
|
|
1
|
+
import { j as e, M as l, E as r, S as i, Y as d } from "./index-B1H13oYF.mjs";
|
|
2
2
|
import { memo as m, useState as g, useEffect as x } from "react";
|
|
3
|
-
import { M as p, T as j } from "./index-
|
|
3
|
+
import { M as p, T as j } from "./index-B9tTbkR-.mjs";
|
|
4
4
|
const E = m(({ open: t, onCallBack: a, queryFetch: o }) => {
|
|
5
5
|
const [n, c] = g([]);
|
|
6
6
|
return x(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-Dh83b1rK.js"),s=require("react"),i=require("./index-Bv7k4mKs.js"),c=s.memo(({open:n,onCallBack:r,queryFetch:x})=>{const[o,a]=s.useState([]);return s.useEffect(()=>{(async()=>{try{await x({success:t=>{a(t.data||[])}})}catch(t){console.log(t)}})()},[n]),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(i.Modal,{open:n,title:"咨询",footer:!1,onCancel:()=>r(),children:e.jsxRuntimeExports.jsx(e.ModelBody,{children:o.length===0?e.jsxRuntimeExports.jsx(e.Empty,{image:e.Empty.PRESENTED_IMAGE_SIMPLE,description:"暂无咨询坐席"}):e.jsxRuntimeExports.jsx(e.Space,{wrap:!0,children:o.map(t=>e.jsxRuntimeExports.jsx(i.Tag,{color:"processing",onClick:()=>r(t.agent_no),children:e.jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsxRuntimeExports.jsx(e.YsytIconSvg,{name:"zixun"}),e.jsxRuntimeExports.jsxs("span",{style:{marginLeft:10},children:["咨询坐席: ",t.agent_name]})]})},t.agent_no))})})})})});exports.default=c;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { j as e, M as h, R as j, a as f, E as d, S as y, Y as c, I as v } from "./index-
|
|
1
|
+
import { j as e, M as h, R as j, a as f, E as d, S as y, Y as c, I as v } from "./index-B1H13oYF.mjs";
|
|
2
2
|
import { memo as E, useState as n, useEffect as T } from "react";
|
|
3
|
-
import { M as I, T as M } from "./index-
|
|
3
|
+
import { M as I, T as M } from "./index-B9tTbkR-.mjs";
|
|
4
4
|
const _ = E(({ open: l, onCallBack: a, queryFetch: p }) => {
|
|
5
5
|
const [o, g] = n([]), [t, x] = n(0), [r, m] = n(""), [u, i] = n(!1);
|
|
6
6
|
return T(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-Dh83b1rK.js"),t=require("react"),l=require("./index-Bv7k4mKs.js"),m=t.memo(({open:o,onCallBack:n,queryFetch:u})=>{const[x,p]=t.useState([]),[r,c]=t.useState(0),[i,d]=t.useState(""),[j,a]=t.useState(!1);return t.useEffect(()=>{(async()=>{a(!0);try{await u({success:s=>{p(s.data||[])}})}catch(s){console.log(s)}a(!1)})()},[o]),e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(l.Modal,{open:o,title:"转接",footer:!1,onCancel:()=>n(),children:e.jsxRuntimeExports.jsxs(e.ModelBody,{children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsx(e.Radio.Group,{options:[{label:"转接坐席",value:0},{label:"转接外线",value:1}],value:r,onChange:s=>c(s.target.value)})}),e.jsxRuntimeExports.jsx(e.Spin,{spinning:j,children:e.jsxRuntimeExports.jsxs("div",{style:{borderTop:"1px solid #eee",marginTop:10,paddingTop:10},children:[r===0&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:x.length===0?e.jsxRuntimeExports.jsx(e.Empty,{image:e.Empty.PRESENTED_IMAGE_SIMPLE,description:"暂无转接坐席"}):e.jsxRuntimeExports.jsx(e.Space,{wrap:!0,children:x.map(s=>e.jsxRuntimeExports.jsx(l.Tag,{color:"processing",onClick:()=>n(s.agent_no,0),children:e.jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsxRuntimeExports.jsx(e.YsytIconSvg,{name:"zixun"}),e.jsxRuntimeExports.jsxs("span",{style:{marginRight:10},children:["转接坐席: ",s.agent_name]})]})},s.agent_no))})}),r===1&&e.jsxRuntimeExports.jsxs("div",{style:{width:"100%",display:"flex",alignItems:"center",gap:"0 5px"},children:[e.jsxRuntimeExports.jsx(e.Input,{style:{flex:1},value:i,onChange:s=>d(s.target.value),placeholder:"请输入外线号码, 回车转接",onPressEnter:()=>{n(i,1)}}),e.jsxRuntimeExports.jsx(e.YsytIconSvg,{name:"boda",color:"#1D92E9",size:25,onClick:()=>{n(i,1)}})]})]})})]})})})});exports.default=m;
|
|
@@ -11103,7 +11103,7 @@ class un {
|
|
|
11103
11103
|
else if (o === ot.CONSULT_TRANSFER) q.isAgentHangup = !1, s === 0 ? ge.emit(ie.CONSULT_TRANSFER_SUCCESS) : (ge.emit(ie.CONSULT_TRANSFER_FAILED, A), ge.emit(Ge.FAIL_NOTIFICATION, A));
|
|
11104
11104
|
else if (o === ot.CONSULT_TRANSFER_FAILED) ge.emit(ie.CONSULT_TRANSFER_FAILED, a.status);
|
|
11105
11105
|
else if (o === ot.CONSULT_TRANSFER_OFF_HOOK) H.updateDirection(Tn.INCOMING), H.updateDisplayText(zt.CALLING), ge.emit(ie.CONSULT_TRANSFER_OFF_HOOK), H.updateActionConfigs(Ki), H.updateIncomingIsAnswer(!0), H.updateConsultIsAnswer(!1);
|
|
11106
|
-
else if (o === ot.INCOMING_CALL) q.isAgentHangup = !1, clearTimeout(q.autoStateTimer), q.sessionId = a.session_id, H.updateIsCalling(!0), H.updateDirection(Tn.INCOMING), H.updateDisplayText(zt.INCOMING_CALL), this.inCallAutoAnswer(), a.direction
|
|
11106
|
+
else if (o === ot.INCOMING_CALL) q.isAgentHangup = !1, clearTimeout(q.autoStateTimer), q.sessionId = a.session_id, H.updateIsCalling(!0), H.updateDirection(Tn.INCOMING), H.updateDisplayText(zt.INCOMING_CALL), this.inCallAutoAnswer(), a.direction !== 1 && a.direction !== 4 && a.direction !== 7 || (this.getCustomerInfo(a.trace_id || a.customer_phone, "incoming_call"), ge.emit(ie.INCOMING_CALL, { customer_phone: a.customer_phone, trace_id: a.trace_id, session_id: a.session_id })), a.direction === 8 && (this.getCustomerInfo(a.trace_id || a.customer_phone, "incoming_call_in"), ge.emit(ie.INCOMING_CALL_IN, { customer_phone: a.customer_phone, trace_id: a.trace_id, session_id: a.session_id })), a.direction === 3 && (this.getCustomerInfo(a.trace_id || a.customer_phone, "predict_incoming_call"), ge.emit(ie.PREDICT_INCOMING_CALL, { customer_phone: a.customer_phone, trace_id: a.trace_id, session_id: a.session_id })), a.direction === 6 && (this.getCustomerInfo(a.trace_id || a.customer_phone, "dual_call_incoming_call"), ge.emit(ie.DUAL_CALL_INCOMING_CALL, { customer_phone: a.customer_phone, trace_id: a.trace_id, session_id: a.session_id })), H.updateActionConfigs(Ts), q.enableBrowserAlert && Fo.show("📞 客户来电", `客户 [${a.customer_phone}] 正在呼入...`, () => {
|
|
11107
11107
|
ge.emit(Ge.NOTIFICATION_CLICK, { customer_phone: a.customer_phone });
|
|
11108
11108
|
}, q.browserAlertTime);
|
|
11109
11109
|
else if (o === ot.INCOMING_CALL_OFF_HOOK) H.updateIncomingIsAnswer(!0), a.direction === 8 ? (H.updateActionConfigs(Vc), ge.emit(ie.INCOMING_CALL_IN_OFF_HOOK, { session_id: q.sessionId })) : (H.updateActionConfigs(Ki), ge.emit(ie.INCOMING_CALL_OFF_HOOK, { session_id: q.sessionId })), H.updateDisplayText(zt.CALLING);
|
|
@@ -32887,7 +32887,7 @@ const HN = {
|
|
|
32887
32887
|
空闲: 1,
|
|
32888
32888
|
离线: 0,
|
|
32889
32889
|
未注册: 4
|
|
32890
|
-
}, ZN = nv(() => import("./ConsultModel-
|
|
32890
|
+
}, ZN = nv(() => import("./ConsultModel-Drj_G5X0.mjs")), KN = nv(() => import("./TransferModel-DnkmhYXF.mjs")), ml = An.div`
|
|
32891
32891
|
width: 25px;
|
|
32892
32892
|
height: 25px;
|
|
32893
32893
|
background: ${({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as r from "react";
|
|
2
2
|
import $, { useContext as re, useRef as Z, useMemo as Lt, useEffect as De } from "react";
|
|
3
|
-
import { i as Dt, K as Ne, g as se, F as kt, m as fe, u as N, r as nt, b as Pe, p as je, C as q, c as O, d as Ie, e as At, o as ge, f as Ce, h as _t, k as Vt, l as Wt, W as qt, n as Gt, B as Te, q as ot, s as Xt, _ as R, t as ke, v as Y, w as Me, x as at, y as Ae, z as Ut, A as _e, D as Ve, P as Kt, G as Qt, H as K, J as Zt, L as Yt, N as Re, O as Jt, Q as lt, T as en, U as tn, V as rt, X as nn, Z as on, $ as an, a0 as ue, a1 as ln, a2 as st, a3 as rn, a4 as sn, a5 as cn, a6 as dn, a7 as un, a8 as mn, a9 as fn, aa as gn, ab as Cn, ac as it, ad as pn, ae as vn } from "./index-
|
|
3
|
+
import { i as Dt, K as Ne, g as se, F as kt, m as fe, u as N, r as nt, b as Pe, p as je, C as q, c as O, d as Ie, e as At, o as ge, f as Ce, h as _t, k as Vt, l as Wt, W as qt, n as Gt, B as Te, q as ot, s as Xt, _ as R, t as ke, v as Y, w as Me, x as at, y as Ae, z as Ut, A as _e, D as Ve, P as Kt, G as Qt, H as K, J as Zt, L as Yt, N as Re, O as Jt, Q as lt, T as en, U as tn, V as rt, X as nn, Z as on, $ as an, a0 as ue, a1 as ln, a2 as st, a3 as rn, a4 as sn, a5 as cn, a6 as dn, a7 as un, a8 as mn, a9 as fn, aa as gn, ab as Cn, ac as it, ad as pn, ae as vn } from "./index-B1H13oYF.mjs";
|
|
4
4
|
const bn = new Ne("antFadeIn", {
|
|
5
5
|
"0%": {
|
|
6
6
|
opacity: 0
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const b=require("react"),a=require("./index-
|
|
1
|
+
"use strict";const b=require("react"),a=require("./index-Dh83b1rK.js");function st(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const s=st(b),it=new a.Keyframe("antFadeIn",{"0%":{opacity:0},"100%":{opacity:1}}),ct=new a.Keyframe("antFadeOut",{"0%":{opacity:1},"100%":{opacity:0}}),dt=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const{antCls:o}=e,n=`${o}-fade`,r=t?"&":"";return[a.initMotion(n,it,ct,e.motionDurationMid,t),{[`
|
|
2
2
|
${r}${n}-enter,
|
|
3
3
|
${r}${n}-appear
|
|
4
4
|
`]:{opacity:0,animationTimingFunction:"linear"},[`${r}${n}-leave`]:{animationTimingFunction:"linear"}}]},ut=e=>{const{paddingXXS:t,lineWidth:o,tagPaddingHorizontal:n,componentCls:r,calc:l}=e,i=l(n).sub(o).equal(),u=l(t).sub(o).equal();return{[r]:Object.assign(Object.assign({},a.resetComponent(e)),{display:"inline-block",height:"auto",marginInlineEnd:e.marginXS,paddingInline:i,fontSize:e.tagFontSize,lineHeight:e.tagLineHeight,whiteSpace:"nowrap",background:e.defaultBg,border:`${a.unit(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:e.borderRadiusSM,opacity:1,transition:`all ${e.motionDurationMid}`,textAlign:"start",position:"relative",[`&${r}-rtl`]:{direction:"rtl"},"&, a, a:hover":{color:e.defaultColor},[`${r}-close-icon`]:{marginInlineStart:u,fontSize:e.tagIconSize,color:e.colorTextDescription,cursor:"pointer",transition:`all ${e.motionDurationMid}`,"&:hover":{color:e.colorTextHeading}},[`&${r}-has-color`]:{borderColor:"transparent",[`&, a, a:hover, ${e.iconCls}-close, ${e.iconCls}-close:hover`]:{color:e.colorTextLightSolid}},"&-checkable":{backgroundColor:"transparent",borderColor:"transparent",cursor:"pointer",[`&:not(${r}-checkable-checked):hover`]:{color:e.colorPrimary,backgroundColor:e.colorFillSecondary},"&:active, &-checked":{color:e.colorTextLightSolid},"&-checked":{backgroundColor:e.colorPrimary,"&:hover":{backgroundColor:e.colorPrimaryHover}},"&:active":{backgroundColor:e.colorPrimaryActive}},"&-hidden":{display:"none"},[`> ${e.iconCls} + span, > span + ${e.iconCls}`]:{marginInlineStart:i}}),[`${r}-borderless`]:{borderColor:"transparent",background:e.tagBorderlessBg}}},Ce=e=>{const{lineWidth:t,fontSizeIcon:o,calc:n}=e,r=e.fontSizeSM;return a.merge(e,{tagFontSize:r,tagLineHeight:a.unit(n(e.lineHeightSM).mul(r).equal()),tagIconSize:n(o).sub(n(t).mul(2)).equal(),tagPaddingHorizontal:8,tagBorderlessBg:e.defaultBg})},pe=e=>({defaultBg:new a.FastColor(e.colorFillQuaternary).onBackground(e.colorBgContainer).toHexString(),defaultColor:e.colorText}),Re=a.genStyleHooks("Tag",e=>{const t=Ce(e);return ut(t)},pe);function oe(e){if(e)return{closable:e.closable,closeIcon:e.closeIcon}}function $e(e){const{closable:t,closeIcon:o}=e||{};return b.useMemo(()=>{if(!t&&(t===!1||o===!1||o===null))return!1;if(t===void 0&&o===void 0)return null;let n={closeIcon:typeof o!="boolean"&&o!==null?o:void 0};return t&&typeof t=="object"&&(n=Object.assign(Object.assign({},n),t)),n},[t,o])}function xe(){const e={};for(var t=arguments.length,o=new Array(t),n=0;n<t;n++)o[n]=arguments[n];return o.forEach(r=>{r&&Object.keys(r).forEach(l=>{r[l]!==void 0&&(e[l]=r[l])})}),e}const mt={};function Be(e,t){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mt;const n=$e(e),r=$e(t),l=typeof n!="boolean"?!!(n!=null&&n.disabled):!1,i=b.useMemo(()=>Object.assign({closeIcon:b.createElement(a.RefIcon,null)},o),[o]),u=b.useMemo(()=>n===!1?!1:n?xe(i,r,n):r===!1?!1:r?xe(i,r):i.closable?i:!1,[n,r,i]);return b.useMemo(()=>{if(u===!1)return[!1,null,l];const{closeIconRender:c}=i,{closeIcon:g}=u;let d=g;if(d!=null){c&&(d=c(g));const m=a.pickAttrs(u,!0);Object.keys(m).length&&(d=b.isValidElement(d)?b.cloneElement(d,m):b.createElement("span",Object.assign({},m),d))}return[!0,d,l]},[u,i])}var ft=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]]);return o};const gt=s.forwardRef((e,t)=>{const{prefixCls:o,style:n,className:r,checked:l,onChange:i,onClick:u}=e,c=ft(e,["prefixCls","style","className","checked","onChange","onClick"]),{getPrefixCls:g,tag:d}=s.useContext(a.ConfigContext),m=y=>{i==null||i(!l),u==null||u(y)},f=g("tag",o),[v,x,C]=Re(f),p=a.classNames(f,`${f}-checkable`,{[`${f}-checkable-checked`]:l},d==null?void 0:d.className,r,x,C);return v(s.createElement("span",Object.assign({},c,{ref:t,style:Object.assign(Object.assign({},n),d==null?void 0:d.style),className:p,onClick:m})))}),Ct=e=>a.genPresetColor(e,(t,o)=>{let{textColor:n,lightBorderColor:r,lightColor:l,darkColor:i}=o;return{[`${e.componentCls}${e.componentCls}-${t}`]:{color:n,background:l,borderColor:r,"&-inverse":{color:e.colorTextLightSolid,background:i,borderColor:i},[`&${e.componentCls}-borderless`]:{borderColor:"transparent"}}}}),pt=a.genSubStyleComponent(["Tag","preset"],e=>{const t=Ce(e);return Ct(t)},pe);function bt(e){return typeof e!="string"?e:e.charAt(0).toUpperCase()+e.slice(1)}const ne=(e,t,o)=>{const n=bt(o);return{[`${e.componentCls}${e.componentCls}-${t}`]:{color:e[`color${o}`],background:e[`color${n}Bg`],borderColor:e[`color${n}Border`],[`&${e.componentCls}-borderless`]:{borderColor:"transparent"}}}},vt=a.genSubStyleComponent(["Tag","status"],e=>{const t=Ce(e);return[ne(t,"success","Success"),ne(t,"processing","Info"),ne(t,"error","Error"),ne(t,"warning","Warning")]},pe);var ht=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]]);return o};const yt=s.forwardRef((e,t)=>{const{prefixCls:o,className:n,rootClassName:r,style:l,children:i,icon:u,color:c,onClose:g,bordered:d=!0,visible:m}=e,f=ht(e,["prefixCls","className","rootClassName","style","children","icon","color","onClose","bordered","visible"]),{getPrefixCls:v,direction:x,tag:C}=s.useContext(a.ConfigContext),[p,y]=s.useState(!0),h=a.omit(f,["closeIcon","closable"]);process.env.NODE_ENV!=="production"&&a.devUseWarning("Tag").deprecated(!("visible"in e),"visible","visible && <Tag />"),s.useEffect(()=>{m!==void 0&&y(m)},[m]);const S=a.isPresetColor(c),N=a.isPresetStatusColor(c),E=S||N,O=Object.assign(Object.assign({backgroundColor:c&&!E?c:void 0},C==null?void 0:C.style),l),$=v("tag",o),[P,j,H]=Re($),B=a.classNames($,C==null?void 0:C.className,{[`${$}-${c}`]:E,[`${$}-has-color`]:c&&!E,[`${$}-hidden`]:!p,[`${$}-rtl`]:x==="rtl",[`${$}-borderless`]:!d},n,r,j,H),_=I=>{I.stopPropagation(),g==null||g(I),!I.defaultPrevented&&y(!1)},[,V]=Be(oe(e),oe(C),{closable:!1,closeIconRender:I=>{const X=s.createElement("span",{className:`${$}-close-icon`,onClick:_},I);return a.replaceElement(I,X,M=>({onClick:q=>{var R;(R=M==null?void 0:M.onClick)===null||R===void 0||R.call(M,q),_(q)},className:a.classNames(M==null?void 0:M.className,`${$}-close-icon`)}))}}),A=typeof f.onClick=="function"||i&&i.type==="a",z=u||null,W=z?s.createElement(s.Fragment,null,z,i&&s.createElement("span",null,i)):i,L=s.createElement("span",Object.assign({},h,{ref:t,className:B,style:O}),W,V,S&&s.createElement(pt,{key:"preset",prefixCls:$}),N&&s.createElement(vt,{key:"status",prefixCls:$}));return P(A?s.createElement(a.Wave,{component:"Tag"},L):L)}),be=yt;process.env.NODE_ENV!=="production"&&(be.displayName="Tag");be.CheckableTag=gt;function ie(e){return!!(e!=null&&e.then)}const _e=e=>{const{type:t,children:o,prefixCls:n,buttonProps:r,close:l,autoFocus:i,emitEvent:u,isSilent:c,quitOnNullishReturnValue:g,actionFn:d}=e,m=s.useRef(!1),f=s.useRef(null),[v,x]=a.useSafeState(!1),C=function(){l==null||l.apply(void 0,arguments)};s.useEffect(()=>{let h=null;return i&&(h=setTimeout(()=>{var S;(S=f.current)===null||S===void 0||S.focus({preventScroll:!0})})),()=>{h&&clearTimeout(h)}},[]);const p=h=>{ie(h)&&(x(!0),h.then(function(){x(!1,!0),C.apply(void 0,arguments),m.current=!1},S=>{if(x(!1,!0),m.current=!1,!(c!=null&&c()))return Promise.reject(S)}))},y=h=>{if(m.current)return;if(m.current=!0,!d){C();return}let S;if(u){if(S=d(h),g&&!ie(S)){m.current=!1,C(h);return}}else if(d.length)S=d(l),m.current=!1;else if(S=d(),!ie(S)){C();return}p(S)};return s.createElement(a.Button,Object.assign({},a.convertLegacyProps(t),{onClick:y,loading:v,prefixCls:n},r,{ref:f}),o)},ee=b.createContext({}),{Provider:He}=ee,Se=()=>{const{autoFocusButton:e,cancelButtonProps:t,cancelTextLocale:o,isSilent:n,mergedOkCancel:r,rootPrefixCls:l,close:i,onCancel:u,onConfirm:c}=b.useContext(ee);return r?b.createElement(_e,{isSilent:n,actionFn:u,close:function(){i==null||i.apply(void 0,arguments),c==null||c(!1)},autoFocus:e==="cancel",buttonProps:t,prefixCls:`${l}-btn`},o):null},Oe=()=>{const{autoFocusButton:e,close:t,isSilent:o,okButtonProps:n,rootPrefixCls:r,okTextLocale:l,okType:i,onConfirm:u,onOk:c}=b.useContext(ee);return b.createElement(_e,{isSilent:o,type:i||"primary",actionFn:c,close:function(){t==null||t.apply(void 0,arguments),u==null||u(!0)},autoFocus:e==="ok",buttonProps:n,prefixCls:`${r}-btn`},l)};var ze=s.createContext({});function Ne(e,t,o){var n=t;return!n&&o&&(n="".concat(e,"-").concat(o)),n}function Ee(e,t){var o=e["page".concat(t?"Y":"X","Offset")],n="scroll".concat(t?"Top":"Left");if(typeof o!="number"){var r=e.document;o=r.documentElement[n],typeof o!="number"&&(o=r.body[n])}return o}function $t(e){var t=e.getBoundingClientRect(),o={left:t.left,top:t.top},n=e.ownerDocument,r=n.defaultView||n.parentWindow;return o.left+=Ee(r),o.top+=Ee(r,!0),o}const xt=s.memo(function(e){var t=e.children;return t},function(e,t){var o=t.shouldUpdate;return!o});var St={width:0,height:0,overflow:"hidden",outline:"none"},Ot={outline:"none"},ve=b.forwardRef(function(e,t){var o=e.prefixCls,n=e.className,r=e.style,l=e.title,i=e.ariaId,u=e.footer,c=e.closable,g=e.closeIcon,d=e.onClose,m=e.children,f=e.bodyStyle,v=e.bodyProps,x=e.modalRender,C=e.onMouseDown,p=e.onMouseUp,y=e.holderRef,h=e.visible,S=e.forceRender,N=e.width,E=e.height,O=e.classNames,$=e.styles,P=b.useContext(ze),j=P.panel,H=a.useComposeRef(y,j),B=b.useRef(),_=b.useRef();b.useImperativeHandle(t,function(){return{focus:function(){var R;(R=B.current)===null||R===void 0||R.focus({preventScroll:!0})},changeActive:function(R){var Y=document,G=Y.activeElement;R&&G===_.current?B.current.focus({preventScroll:!0}):!R&&G===B.current&&_.current.focus({preventScroll:!0})}}});var V={};N!==void 0&&(V.width=N),E!==void 0&&(V.height=E);var A=u?b.createElement("div",{className:a.classNames("".concat(o,"-footer"),O==null?void 0:O.footer),style:a._objectSpread2({},$==null?void 0:$.footer)},u):null,z=l?b.createElement("div",{className:a.classNames("".concat(o,"-header"),O==null?void 0:O.header),style:a._objectSpread2({},$==null?void 0:$.header)},b.createElement("div",{className:"".concat(o,"-title"),id:i},l)):null,W=b.useMemo(function(){return a._typeof(c)==="object"&&c!==null?c:c?{closeIcon:g??b.createElement("span",{className:"".concat(o,"-close-x")})}:{}},[c,g,o]),L=a.pickAttrs(W,!0),I=a._typeof(c)==="object"&&c.disabled,X=c?b.createElement("button",a._extends({type:"button",onClick:d,"aria-label":"Close"},L,{className:"".concat(o,"-close"),disabled:I}),W.closeIcon):null,M=b.createElement("div",{className:a.classNames("".concat(o,"-content"),O==null?void 0:O.content),style:$==null?void 0:$.content},X,z,b.createElement("div",a._extends({className:a.classNames("".concat(o,"-body"),O==null?void 0:O.body),style:a._objectSpread2(a._objectSpread2({},f),$==null?void 0:$.body)},v),m),A);return b.createElement("div",{key:"dialog-element",role:"dialog","aria-labelledby":l?i:null,"aria-modal":"true",ref:H,style:a._objectSpread2(a._objectSpread2({},r),V),className:a.classNames(o,n),onMouseDown:C,onMouseUp:p},b.createElement("div",{ref:B,tabIndex:0,style:Ot},b.createElement(xt,{shouldUpdate:h||S},x?x(M):M)),b.createElement("div",{tabIndex:0,ref:_,style:St}))});process.env.NODE_ENV!=="production"&&(ve.displayName="Panel");var Ae=s.forwardRef(function(e,t){var o=e.prefixCls,n=e.title,r=e.style,l=e.className,i=e.visible,u=e.forceRender,c=e.destroyOnClose,g=e.motionName,d=e.ariaId,m=e.onVisibleChanged,f=e.mousePosition,v=b.useRef(),x=s.useState(),C=a._slicedToArray(x,2),p=C[0],y=C[1],h={};p&&(h.transformOrigin=p);function S(){var N=$t(v.current);y(f&&(f.x||f.y)?"".concat(f.x-N.left,"px ").concat(f.y-N.top,"px"):"")}return s.createElement(a.CSSMotion,{visible:i,onVisibleChanged:m,onAppearPrepare:S,onEnterPrepare:S,forceRender:u,motionName:g,removeOnLeave:c,ref:v},function(N,E){var O=N.className,$=N.style;return s.createElement(ve,a._extends({},e,{ref:t,title:n,ariaId:d,prefixCls:o,holderRef:E,style:a._objectSpread2(a._objectSpread2(a._objectSpread2({},$),r),h),className:a.classNames(l,O)}))})});Ae.displayName="Content";var Nt=function(t){var o=t.prefixCls,n=t.style,r=t.visible,l=t.maskProps,i=t.motionName,u=t.className;return s.createElement(a.CSSMotion,{key:"mask",visible:r,motionName:i,leavedClassName:"".concat(o,"-mask-hidden")},function(c,g){var d=c.className,m=c.style;return s.createElement("div",a._extends({ref:g,style:a._objectSpread2(a._objectSpread2({},m),n),className:a.classNames("".concat(o,"-mask"),d,u)},l))})},Et=function(t){var o=t.prefixCls,n=o===void 0?"rc-dialog":o,r=t.zIndex,l=t.visible,i=l===void 0?!1:l,u=t.keyboard,c=u===void 0?!0:u,g=t.focusTriggerAfterClose,d=g===void 0?!0:g,m=t.wrapStyle,f=t.wrapClassName,v=t.wrapProps,x=t.onClose,C=t.afterOpenChange,p=t.afterClose,y=t.transitionName,h=t.animation,S=t.closable,N=S===void 0?!0:S,E=t.mask,O=E===void 0?!0:E,$=t.maskTransitionName,P=t.maskAnimation,j=t.maskClosable,H=j===void 0?!0:j,B=t.maskStyle,_=t.maskProps,V=t.rootClassName,A=t.classNames,z=t.styles;process.env.NODE_ENV!=="production"&&(["wrapStyle","bodyStyle","maskStyle"].forEach(function(w){a.warning(!(w in t),"".concat(w," is deprecated, please use styles instead."))}),"wrapClassName"in t&&a.warning(!1,"wrapClassName is deprecated, please use classNames instead."));var W=b.useRef(),L=b.useRef(),I=b.useRef(),X=s.useState(i),M=a._slicedToArray(X,2),q=M[0],R=M[1],Y=a.useId();function G(){a.contains(L.current,document.activeElement)||(W.current=document.activeElement)}function le(){if(!a.contains(L.current,document.activeElement)){var w;(w=I.current)===null||w===void 0||w.focus()}}function k(w){if(w)le();else{if(R(!1),O&&W.current&&d){try{W.current.focus({preventScroll:!0})}catch{}W.current=null}q&&(p==null||p())}C==null||C(w)}function T(w){x==null||x(w)}var D=b.useRef(!1),J=b.useRef(),ot=function(){clearTimeout(J.current),D.current=!0},at=function(){J.current=setTimeout(function(){D.current=!1})},ye=null;H&&(ye=function(se){D.current?D.current=!1:L.current===se.target&&T(se)});function rt(w){if(c&&w.keyCode===a.KeyCode.ESC){w.stopPropagation(),T(w);return}i&&w.keyCode===a.KeyCode.TAB&&I.current.changeActive(!w.shiftKey)}b.useEffect(function(){i&&(R(!0),G())},[i]),b.useEffect(function(){return function(){clearTimeout(J.current)}},[]);var lt=a._objectSpread2(a._objectSpread2(a._objectSpread2({zIndex:r},m),z==null?void 0:z.wrapper),{},{display:q?null:"none"});return s.createElement("div",a._extends({className:a.classNames("".concat(n,"-root"),V)},a.pickAttrs(t,{data:!0})),s.createElement(Nt,{prefixCls:n,visible:O&&i,motionName:Ne(n,$,P),style:a._objectSpread2(a._objectSpread2({zIndex:r},B),z==null?void 0:z.mask),maskProps:_,className:A==null?void 0:A.mask}),s.createElement("div",a._extends({tabIndex:-1,onKeyDown:rt,className:a.classNames("".concat(n,"-wrap"),f,A==null?void 0:A.wrapper),ref:L,onClick:ye,style:lt},v),s.createElement(Ae,a._extends({},t,{onMouseDown:ot,onMouseUp:at,ref:I,closable:N,ariaId:Y,prefixCls:n,visible:i&&q,onClose:T,onVisibleChanged:k,motionName:Ne(n,y,h)}))))},Le=function(t){var o=t.visible,n=t.getContainer,r=t.forceRender,l=t.destroyOnClose,i=l===void 0?!1:l,u=t.afterClose,c=t.panelRef,g=s.useState(o),d=a._slicedToArray(g,2),m=d[0],f=d[1],v=s.useMemo(function(){return{panel:c}},[c]);return s.useEffect(function(){o&&f(!0)},[o]),!r&&i&&!m?null:s.createElement(ze.Provider,{value:v},s.createElement(a.Portal,{open:o||r||m,autoDestroy:!1,getContainer:n,autoLock:o||m},s.createElement(Et,a._extends({},t,{destroyOnClose:i,afterClose:function(){u==null||u(),f(!1)}}))))};Le.displayName="Dialog";const wt=()=>a.canUseDom()&&window.document.documentElement,ae=e=>{const{prefixCls:t,className:o,style:n,size:r,shape:l}=e,i=a.classNames({[`${t}-lg`]:r==="large",[`${t}-sm`]:r==="small"}),u=a.classNames({[`${t}-circle`]:l==="circle",[`${t}-square`]:l==="square",[`${t}-round`]:l==="round"}),c=s.useMemo(()=>typeof r=="number"?{width:r,height:r,lineHeight:`${r}px`}:{},[r]);return s.createElement("span",{className:a.classNames(t,i,u,o),style:Object.assign(Object.assign({},c),n)})},jt=new a.Keyframe("ant-skeleton-loading",{"0%":{backgroundPosition:"100% 50%"},"100%":{backgroundPosition:"0 50%"}}),re=e=>({height:e,lineHeight:a.unit(e)}),Q=e=>Object.assign({width:e},re(e)),Pt=e=>({background:e.skeletonLoadingBackground,backgroundSize:"400% 100%",animationName:jt,animationDuration:e.skeletonLoadingMotionDuration,animationTimingFunction:"ease",animationIterationCount:"infinite"}),ce=(e,t)=>Object.assign({width:t(e).mul(5).equal(),minWidth:t(e).mul(5).equal()},re(e)),It=e=>{const{skeletonAvatarCls:t,gradientFromColor:o,controlHeight:n,controlHeightLG:r,controlHeightSM:l}=e;return{[t]:Object.assign({display:"inline-block",verticalAlign:"top",background:o},Q(n)),[`${t}${t}-circle`]:{borderRadius:"50%"},[`${t}${t}-lg`]:Object.assign({},Q(r)),[`${t}${t}-sm`]:Object.assign({},Q(l))}},Tt=e=>{const{controlHeight:t,borderRadiusSM:o,skeletonInputCls:n,controlHeightLG:r,controlHeightSM:l,gradientFromColor:i,calc:u}=e;return{[n]:Object.assign({display:"inline-block",verticalAlign:"top",background:i,borderRadius:o},ce(t,u)),[`${n}-lg`]:Object.assign({},ce(r,u)),[`${n}-sm`]:Object.assign({},ce(l,u))}},we=e=>Object.assign({width:e},re(e)),Mt=e=>{const{skeletonImageCls:t,imageSizeBase:o,gradientFromColor:n,borderRadiusSM:r,calc:l}=e;return{[t]:Object.assign(Object.assign({display:"inline-flex",alignItems:"center",justifyContent:"center",verticalAlign:"middle",background:n,borderRadius:r},we(l(o).mul(2).equal())),{[`${t}-path`]:{fill:"#bfbfbf"},[`${t}-svg`]:Object.assign(Object.assign({},we(o)),{maxWidth:l(o).mul(4).equal(),maxHeight:l(o).mul(4).equal()}),[`${t}-svg${t}-svg-circle`]:{borderRadius:"50%"}}),[`${t}${t}-circle`]:{borderRadius:"50%"}}},de=(e,t,o)=>{const{skeletonButtonCls:n}=e;return{[`${o}${n}-circle`]:{width:t,minWidth:t,borderRadius:"50%"},[`${o}${n}-round`]:{borderRadius:t}}},ue=(e,t)=>Object.assign({width:t(e).mul(2).equal(),minWidth:t(e).mul(2).equal()},re(e)),Rt=e=>{const{borderRadiusSM:t,skeletonButtonCls:o,controlHeight:n,controlHeightLG:r,controlHeightSM:l,gradientFromColor:i,calc:u}=e;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({[o]:Object.assign({display:"inline-block",verticalAlign:"top",background:i,borderRadius:t,width:u(n).mul(2).equal(),minWidth:u(n).mul(2).equal()},ue(n,u))},de(e,n,o)),{[`${o}-lg`]:Object.assign({},ue(r,u))}),de(e,r,`${o}-lg`)),{[`${o}-sm`]:Object.assign({},ue(l,u))}),de(e,l,`${o}-sm`))},Bt=e=>{const{componentCls:t,skeletonAvatarCls:o,skeletonTitleCls:n,skeletonParagraphCls:r,skeletonButtonCls:l,skeletonInputCls:i,skeletonImageCls:u,controlHeight:c,controlHeightLG:g,controlHeightSM:d,gradientFromColor:m,padding:f,marginSM:v,borderRadius:x,titleHeight:C,blockRadius:p,paragraphLiHeight:y,controlHeightXS:h,paragraphMarginTop:S}=e;return{[t]:{display:"table",width:"100%",[`${t}-header`]:{display:"table-cell",paddingInlineEnd:f,verticalAlign:"top",[o]:Object.assign({display:"inline-block",verticalAlign:"top",background:m},Q(c)),[`${o}-circle`]:{borderRadius:"50%"},[`${o}-lg`]:Object.assign({},Q(g)),[`${o}-sm`]:Object.assign({},Q(d))},[`${t}-content`]:{display:"table-cell",width:"100%",verticalAlign:"top",[n]:{width:"100%",height:C,background:m,borderRadius:p,[`+ ${r}`]:{marginBlockStart:d}},[r]:{padding:0,"> li":{width:"100%",height:y,listStyle:"none",background:m,borderRadius:p,"+ li":{marginBlockStart:h}}},[`${r}> li:last-child:not(:first-child):not(:nth-child(2))`]:{width:"61%"}},[`&-round ${t}-content`]:{[`${n}, ${r} > li`]:{borderRadius:x}}},[`${t}-with-avatar ${t}-content`]:{[n]:{marginBlockStart:v,[`+ ${r}`]:{marginBlockStart:S}}},[`${t}${t}-element`]:Object.assign(Object.assign(Object.assign(Object.assign({display:"inline-block",width:"auto"},Rt(e)),It(e)),Tt(e)),Mt(e)),[`${t}${t}-block`]:{width:"100%",[l]:{width:"100%"},[i]:{width:"100%"}},[`${t}${t}-active`]:{[`
|
|
@@ -160,7 +160,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
160
160
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
161
161
|
* @copyright Chen, Yi-Cyuan 2014-2023
|
|
162
162
|
* @license MIT
|
|
163
|
-
*/Vc=k0,function(){var t="input is invalid type",e=typeof window=="object",n=e?window:{};n.JS_MD5_NO_WINDOW&&(e=!1);var r=!e&&typeof self=="object",i=!n.JS_MD5_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;i?n=Tw:r&&(n=self);var o,a=!n.JS_MD5_NO_COMMON_JS&&Vc.exports,s=!n.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",A="0123456789abcdef".split(""),c=[128,32768,8388608,-2147483648],u=[0,8,16,24],d=["hex","array","digest","buffer","arrayBuffer","base64"],f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),p=[];if(s){var v=new ArrayBuffer(68);o=new Uint8Array(v),p=new Uint32Array(v)}var C=Array.isArray;!n.JS_MD5_NO_NODE_JS&&C||(C=function(E){return Object.prototype.toString.call(E)==="[object Array]"});var m=ArrayBuffer.isView;!s||!n.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&m||(m=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});var y=function(E){var b=typeof E;if(b==="string")return[E,!0];if(b!=="object"||E===null)throw new Error(t);if(s&&E.constructor===ArrayBuffer)return[new Uint8Array(E),!1];if(!C(E)&&!m(E))throw new Error(t);return[E,!1]},w=function(E){return function(b){return new x(!0).update(b)[E]()}},I=function(E){var b,h=Og,S=Og.Buffer;return b=S.from&&!n.JS_MD5_NO_BUFFER_FROM?S.from:function(T){return new S(T)},function(T){if(typeof T=="string")return h.createHash("md5").update(T,"utf8").digest("hex");if(T==null)throw new Error(t);return T.constructor===ArrayBuffer&&(T=new Uint8Array(T)),C(T)||m(T)||T.constructor===S?h.createHash("md5").update(b(T)).digest("hex"):E(T)}},O=function(E){return function(b,h){return new g(b,!0).update(h)[E]()}};function x(E){if(E)p[0]=p[16]=p[1]=p[2]=p[3]=p[4]=p[5]=p[6]=p[7]=p[8]=p[9]=p[10]=p[11]=p[12]=p[13]=p[14]=p[15]=0,this.blocks=p,this.buffer8=o;else if(s){var b=new ArrayBuffer(68);this.buffer8=new Uint8Array(b),this.blocks=new Uint32Array(b)}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 g(E,b){var h,S=y(E);if(E=S[0],S[1]){var T,R=[],D=E.length,B=0;for(h=0;h<D;++h)(T=E.charCodeAt(h))<128?R[B++]=T:T<2048?(R[B++]=192|T>>>6,R[B++]=128|63&T):T<55296||T>=57344?(R[B++]=224|T>>>12,R[B++]=128|T>>>6&63,R[B++]=128|63&T):(T=65536+((1023&T)<<10|1023&E.charCodeAt(++h)),R[B++]=240|T>>>18,R[B++]=128|T>>>12&63,R[B++]=128|T>>>6&63,R[B++]=128|63&T);E=R}E.length>64&&(E=new x(!0).update(E).array());var k=[],P=[];for(h=0;h<64;++h){var H=E[h]||0;k[h]=92^H,P[h]=54^H}x.call(this,b),this.update(P),this.oKeyPad=k,this.inner=!0,this.sharedMemory=b}x.prototype.update=function(E){if(this.finalized)throw new Error("finalize already called");var b=y(E);E=b[0];for(var h,S,T=b[1],R=0,D=E.length,B=this.blocks,k=this.buffer8;R<D;){if(this.hashed&&(this.hashed=!1,B[0]=B[16],B[16]=B[1]=B[2]=B[3]=B[4]=B[5]=B[6]=B[7]=B[8]=B[9]=B[10]=B[11]=B[12]=B[13]=B[14]=B[15]=0),T)if(s)for(S=this.start;R<D&&S<64;++R)(h=E.charCodeAt(R))<128?k[S++]=h:h<2048?(k[S++]=192|h>>>6,k[S++]=128|63&h):h<55296||h>=57344?(k[S++]=224|h>>>12,k[S++]=128|h>>>6&63,k[S++]=128|63&h):(h=65536+((1023&h)<<10|1023&E.charCodeAt(++R)),k[S++]=240|h>>>18,k[S++]=128|h>>>12&63,k[S++]=128|h>>>6&63,k[S++]=128|63&h);else for(S=this.start;R<D&&S<64;++R)(h=E.charCodeAt(R))<128?B[S>>>2]|=h<<u[3&S++]:h<2048?(B[S>>>2]|=(192|h>>>6)<<u[3&S++],B[S>>>2]|=(128|63&h)<<u[3&S++]):h<55296||h>=57344?(B[S>>>2]|=(224|h>>>12)<<u[3&S++],B[S>>>2]|=(128|h>>>6&63)<<u[3&S++],B[S>>>2]|=(128|63&h)<<u[3&S++]):(h=65536+((1023&h)<<10|1023&E.charCodeAt(++R)),B[S>>>2]|=(240|h>>>18)<<u[3&S++],B[S>>>2]|=(128|h>>>12&63)<<u[3&S++],B[S>>>2]|=(128|h>>>6&63)<<u[3&S++],B[S>>>2]|=(128|63&h)<<u[3&S++]);else if(s)for(S=this.start;R<D&&S<64;++R)k[S++]=E[R];else for(S=this.start;R<D&&S<64;++R)B[S>>>2]|=E[R]<<u[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},x.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var E=this.blocks,b=this.lastByteIndex;E[b>>>2]|=c[3&b],b>=56&&(this.hashed||this.hash(),E[0]=E[16],E[16]=E[1]=E[2]=E[3]=E[4]=E[5]=E[6]=E[7]=E[8]=E[9]=E[10]=E[11]=E[12]=E[13]=E[14]=E[15]=0),E[14]=this.bytes<<3,E[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},x.prototype.hash=function(){var E,b,h,S,T,R,D=this.blocks;this.first?b=((b=((E=((E=D[0]-680876937)<<7|E>>>25)-271733879|0)^(h=((h=(-271733879^(S=((S=(-1732584194^2004318071&E)+D[1]-117830708)<<12|S>>>20)+E|0)&(-271733879^E))+D[2]-1126478375)<<17|h>>>15)+S|0)&(S^E))+D[3]-1316259209)<<22|b>>>10)+h|0:(E=this.h0,b=this.h1,h=this.h2,b=((b+=((E=((E+=((S=this.h3)^b&(h^S))+D[0]-680876936)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[1]-389564586)<<12|S>>>20)+E|0)&(E^b))+D[2]+606105819)<<17|h>>>15)+S|0)&(S^E))+D[3]-1044525330)<<22|b>>>10)+h|0),b=((b+=((E=((E+=(S^b&(h^S))+D[4]-176418897)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[5]+1200080426)<<12|S>>>20)+E|0)&(E^b))+D[6]-1473231341)<<17|h>>>15)+S|0)&(S^E))+D[7]-45705983)<<22|b>>>10)+h|0,b=((b+=((E=((E+=(S^b&(h^S))+D[8]+1770035416)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[9]-1958414417)<<12|S>>>20)+E|0)&(E^b))+D[10]-42063)<<17|h>>>15)+S|0)&(S^E))+D[11]-1990404162)<<22|b>>>10)+h|0,b=((b+=((E=((E+=(S^b&(h^S))+D[12]+1804603682)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[13]-40341101)<<12|S>>>20)+E|0)&(E^b))+D[14]-1502002290)<<17|h>>>15)+S|0)&(S^E))+D[15]+1236535329)<<22|b>>>10)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[1]-165796510)<<5|E>>>27)+b|0)^b))+D[6]-1069501632)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[11]+643717713)<<14|h>>>18)+S|0)^S))+D[0]-373897302)<<20|b>>>12)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[5]-701558691)<<5|E>>>27)+b|0)^b))+D[10]+38016083)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[15]-660478335)<<14|h>>>18)+S|0)^S))+D[4]-405537848)<<20|b>>>12)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[9]+568446438)<<5|E>>>27)+b|0)^b))+D[14]-1019803690)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[3]-187363961)<<14|h>>>18)+S|0)^S))+D[8]+1163531501)<<20|b>>>12)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[13]-1444681467)<<5|E>>>27)+b|0)^b))+D[2]-51403784)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[7]+1735328473)<<14|h>>>18)+S|0)^S))+D[12]-1926607734)<<20|b>>>12)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[5]-378558)<<4|E>>>28)+b|0))+D[8]-2022574463)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[11]+1839030562)<<16|h>>>16)+S|0))+D[14]-35309556)<<23|b>>>9)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[1]-1530992060)<<4|E>>>28)+b|0))+D[4]+1272893353)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[7]-155497632)<<16|h>>>16)+S|0))+D[10]-1094730640)<<23|b>>>9)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[13]+681279174)<<4|E>>>28)+b|0))+D[0]-358537222)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[3]-722521979)<<16|h>>>16)+S|0))+D[6]+76029189)<<23|b>>>9)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[9]-640364487)<<4|E>>>28)+b|0))+D[12]-421815835)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[15]+530742520)<<16|h>>>16)+S|0))+D[2]-995338651)<<23|b>>>9)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[0]-198630844)<<6|E>>>26)+b|0)|~h))+D[7]+1126891415)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[14]-1416354905)<<15|h>>>17)+S|0)|~E))+D[5]-57434055)<<21|b>>>11)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[12]+1700485571)<<6|E>>>26)+b|0)|~h))+D[3]-1894986606)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[10]-1051523)<<15|h>>>17)+S|0)|~E))+D[1]-2054922799)<<21|b>>>11)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[8]+1873313359)<<6|E>>>26)+b|0)|~h))+D[15]-30611744)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[6]-1560198380)<<15|h>>>17)+S|0)|~E))+D[13]+1309151649)<<21|b>>>11)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[4]-145523070)<<6|E>>>26)+b|0)|~h))+D[11]-1120210379)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[2]+718787259)<<15|h>>>17)+S|0)|~E))+D[9]-343485551)<<21|b>>>11)+h|0,this.first?(this.h0=E+1732584193|0,this.h1=b-271733879|0,this.h2=h-1732584194|0,this.h3=S+271733878|0,this.first=!1):(this.h0=this.h0+E|0,this.h1=this.h1+b|0,this.h2=this.h2+h|0,this.h3=this.h3+S|0)},x.prototype.hex=function(){this.finalize();var E=this.h0,b=this.h1,h=this.h2,S=this.h3;return A[E>>>4&15]+A[15&E]+A[E>>>12&15]+A[E>>>8&15]+A[E>>>20&15]+A[E>>>16&15]+A[E>>>28&15]+A[E>>>24&15]+A[b>>>4&15]+A[15&b]+A[b>>>12&15]+A[b>>>8&15]+A[b>>>20&15]+A[b>>>16&15]+A[b>>>28&15]+A[b>>>24&15]+A[h>>>4&15]+A[15&h]+A[h>>>12&15]+A[h>>>8&15]+A[h>>>20&15]+A[h>>>16&15]+A[h>>>28&15]+A[h>>>24&15]+A[S>>>4&15]+A[15&S]+A[S>>>12&15]+A[S>>>8&15]+A[S>>>20&15]+A[S>>>16&15]+A[S>>>28&15]+A[S>>>24&15]},x.prototype.toString=x.prototype.hex,x.prototype.digest=function(){this.finalize();var E=this.h0,b=this.h1,h=this.h2,S=this.h3;return[255&E,E>>>8&255,E>>>16&255,E>>>24&255,255&b,b>>>8&255,b>>>16&255,b>>>24&255,255&h,h>>>8&255,h>>>16&255,h>>>24&255,255&S,S>>>8&255,S>>>16&255,S>>>24&255]},x.prototype.array=x.prototype.digest,x.prototype.arrayBuffer=function(){this.finalize();var E=new ArrayBuffer(16),b=new Uint32Array(E);return b[0]=this.h0,b[1]=this.h1,b[2]=this.h2,b[3]=this.h3,E},x.prototype.buffer=x.prototype.arrayBuffer,x.prototype.base64=function(){for(var E,b,h,S="",T=this.array(),R=0;R<15;)E=T[R++],b=T[R++],h=T[R++],S+=f[E>>>2]+f[63&(E<<4|b>>>4)]+f[63&(b<<2|h>>>6)]+f[63&h];return E=T[R],S+=f[E>>>2]+f[E<<4&63]+"=="},g.prototype=new x,g.prototype.finalize=function(){if(x.prototype.finalize.call(this),this.inner){this.inner=!1;var E=this.array();x.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(E),x.prototype.finalize.call(this)}};var M=function(){var E=w("hex");i&&(E=I(E)),E.create=function(){return new x},E.update=function(S){return E.create().update(S)};for(var b=0;b<d.length;++b){var h=d[b];E[h]=w(h)}return E}();M.md5=M,M.md5.hmac=function(){var E=O("hex");E.create=function(S){return new g(S)},E.update=function(S,T){return E.create(S).update(T)};for(var b=0;b<d.length;++b){var h=d[b];E[h]=O(h)}return E}(),a?Vc.exports=M:n.md5=M}();var Nw=k0.exports;const P0=(t,e)=>{const n=Date.now(),r=`${t}:${n}:${Nw.md5(`${e}${n}`)}`,i=new TextEncoder().encode(r);return btoa(String.fromCharCode(...i))},iu=t=>{if(/^\d+$/.test(t)||!t||typeof t!="string"||t.length%4!=0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))return!1;try{const e=atob(t);return btoa(e)===t}catch{return!1}},Yi="/v1/aicc/bmserver",Or="/v1/aicc/ccs";let Si="",Kd="",Vd="",zc="";function Q0(t){const e=P0(Kd,Vd);return Mw.create({prefixUrl:`${Si}`,timeout:!1,headers:{Authorization:e,...t},hooks:{afterResponse:[async(n,r,i)=>{if(i.url.indexOf("heartbeat")!==-1)return i;const o=await i.clone().json();if(o.code!==0)throw new Error(JSON.stringify(o)||"请求失败");return i.json=async()=>o,i}]}})}async function yn(t,e,n){const r=Q0(n),i="api/"+t.replace(/^\/+/,"");return r.post(i,{json:e}).json()}const Ug=(t,e)=>yn(`${Or}/state/change?h=${e}`,t,{h:e}),Dw=()=>async function(t,e){const n=Q0(),r=t.replace(/^\/+/,"");return n.post(r,{json:e}).json()}("/heartbeat",{});class nn{static log(e,n={}){const{level:r="info",module:i="",timestamp:o=!0}=n;if(Z.logBuiltinEnabled){const A=i?`[${i}]`:"",c=o?`[${new Date().toLocaleString()}]`:"";switch(r){case"debug":break;case"warn":console.warn(`${c}${A} ${e}`);break;case"error":console.error(`${c}${A} ${e}`)}}const a=Z.agentInfo.agent_no;if(a){const A=JSON.stringify({level:r,module:i,content:e,timestamp:new Date().toISOString()});(s={agent_no:a,content:A},yn("/v1/aicc/ccs/softphone/log",s)).catch(()=>{})}var s}static debug(e,n){this.log(e,{level:"debug",module:n})}static info(e,n){this.log(e,{level:"info",module:n})}static warn(e,n){this.log(e,{level:"warn",module:n})}static error(e,n){this.log(e,{level:"error",module:n})}static errorObj(e,n){const r=JSON.stringify({message:e.message,stack:e.stack,name:e.name});this.log(r,{level:"error",module:n})}}class Bw{constructor(e,n){this.config=e,this.eventCallback=n,this.userAgent=null,this.registerer=null,this.activeSession=null,this.callTimeoutTimer=null,this.incomingInvitation=null,this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectTimer=null,this.isOffline=!1,this.isManuallyStopped=!1,this.registerInterval=6e4,this.handleNetworkInfoChange=r=>{var i,o;if((i=r.rttObject)!=null&&i.rtt){const a=(o=r.rttObject)==null?void 0:o.rtt,s=a!=null&&a>0;s||this.isOffline?s&&this.isOffline&&(this.isOffline=!1,this.handleOnline()):(this.isOffline=!0,this.handleOffline())}},this.handleOffline=()=>{nn.warn("网络断开,准备销毁 SIP 客户端","sip-client.ts 75 handleOffline"),fe.emit(He.FAIL_NOTIFICATION,"网络断开,准备销毁 SIP 客户端"),this.destroy()},this.handleOnline=()=>{nn.warn("网络恢复,准备重新启动 SIP 客户端","sip-client.ts 82 handleOnline"),this.reconnect()},this.sleep=r=>new Promise(i=>setTimeout(i,r)),T0.subscribe(this.handleNetworkInfoChange)}async start(){const e=Fg.makeURI(`sip:${this.config.user}@${this.config.server}`);if(!e)throw new Error("无效的SIP配置");const n={uri:e,authorizationUsername:this.config.user,authorizationPassword:this.config.password,sendInitialProvisionalResponse:!1,transportOptions:{server:this.config.webSocket,connectionTimeout:10,keepAliveInterval:20,keepAliveDebounce:10},contactName:this.config.user,contactParams:{transport:"wss"},userAgentString:"SwiftSIP/2.0.21",sessionDescriptionHandlerFactoryOptions:{alwaysAcquireMediaFirst:!0,peerConnectionConfiguration:{iceServers:[{urls:"stun:stun.l.google.com:19302"}],iceCandidatePoolSize:0,iceTransportPolicy:"all",rtcpMuxPolicy:"require",bundlePolicy:"balanced",certificates:void 0,peerIdentity:void 0},iceGatheringTimeout:1e3},logBuiltinEnabled:Z.logBuiltinEnabled};this.userAgent=new Fg(n),this.setupEventListeners(),await this.userAgent.start(),await this.register()}setupEventListeners(){this.userAgent&&(this.userAgent.transport.stateChange.addListener(e=>{var r;let n;switch(e){case dt.Connecting:n=Ar.WEB_RTC_CONNECTING;break;case dt.Connected:n=Ar.WEB_RTC_CONNECTED,this.reconnectAttempts=0,Z.isRtcReconnecting=!1,G.updateIsSipConnected(!0),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);break;case dt.Disconnecting:n=Ar.WEB_RTC_DISCONNECTING,G.updateIsSipConnected(!1);break;case dt.Disconnected:{if(G.updateIsSipConnected(!1),this.isManuallyStopped)return nn.warn("手动断开,不触发重连","sip-client.ts 204"),void console.warn("[SIP] 手动断开,不触发重连");fe.emit(He.FAIL_NOTIFICATION,"软电话链接失败"),n=Ar.WEB_RTC_DISCONNECTED;const i=G.get("answerDevice");if(!Z.isRtcReconnecting&&this.reconnectAttempts<this.maxReconnectAttempts&&i===1){this.reconnectAttempts++;const o=1e3*this.reconnectAttempts;nn.warn(`SIP WebSocket 断开,第 ${this.reconnectAttempts} 次尝试重连,${o}ms 后重试...`,"sip-client.ts 219"),this.reconnectTimer=setTimeout(()=>{this.reconnect()},o)}else this.reconnectAttempts>=this.maxReconnectAttempts&&(nn.warn(`SIP 重连失败:已达到最大重试次数; reconnectAttempts: ${this.reconnectAttempts}; maxReconnectAttempts: ${this.maxReconnectAttempts}`,"sip-client.ts 228"),console.error("SIP 重连失败:已达到最大重试次数"),fe.emit(He.FAIL_NOTIFICATION,"SIP 重连失败:已达到最大重试次数"));break}default:G.updateIsSipConnected(!1),n="unknown"}(r=this.eventCallback)==null||r.call(this,{type:n})}),this.userAgent.delegate={onInvite:e=>{this.handleIncomingCall(e)}})}async refreshRegister(){if(this.registerer)try{await this.registerer.register(),new Date().toLocaleTimeString()}catch(e){console.error("[SIPClient] REGISTER刷新失败",e)}}async register(){var e,n;if(this.userAgent){this.registerer=new tu(this.userAgent,{expires:120,refreshFrequency:80}),(e=this.registerer)==null||e.stateChange.addListener(r=>{var o;let i;switch(r){case jt.Initial:G.updateDisplayText(Kt.LINKING),i="initial";break;case jt.Registered:G.updateDisplayText(""),i=Ar.WEB_RTC_REGISTERED;break;case jt.Unregistered:i=Ar.WEB_RTC_UNREGISTERED;break;case jt.Terminated:nn.warn(`注册流程已终止,无法再注册(如 UA 停止,或网络不可达);regStatus: ${Ar.WEB_RTC_TERMINATED}`,"sip-client.ts 299"),i=Ar.WEB_RTC_TERMINATED;break;default:i="unknown"}(o=this.eventCallback)==null||o.call(this,{type:i})});try{await this.registerer.register()}catch(r){(n=this.eventCallback)==null||n.call(this,{type:Ar.WEB_RTC_REGISTER_FAILED,data:r})}}}attachRemoteAudio(e){const n=e.sessionDescriptionHandler;if(n){const r=n.peerConnection;if(!r)return;const i=new MediaStream;r.getReceivers().forEach(a=>{a.track&&a.track.kind==="audio"&&i.addTrack(a.track)});let o=document.getElementById("sip-remote-audio");o||(o=document.createElement("audio"),o.id="sip-remote-audio",o.autoplay=!0,o.style.display="none",document.body.appendChild(o)),o.srcObject=i,o.play().catch(a=>{console.error("音频播放失败,需要用户交互触发",a)})}}handleSessionState(e,n,r){e.stateChange.addListener(i=>{switch(i){case he.Established:clearTimeout(this.callTimeoutTimer),this.activeSession=e,this.attachRemoteAudio(e);break;case he.Terminating:break;case he.Terminated:this.activeSession=null,clearTimeout(this.callTimeoutTimer);case he.Establishing:}})}handleIncomingCall(e){this.incomingInvitation=e,this.handleSessionState(e,!1),e.progress({statusCode:180,reasonPhrase:"Ringing"}).catch(n=>console.error("发送 180 失败",n)),G.get("direction")===xn.OUTGOING&&this.answerCall()}async answerCall(){var e;if(!this.incomingInvitation)throw new Error("无来电可接听");Z.autoAnswerTimer&&(clearTimeout(Z.autoAnswerTimer),Z.autoAnswerTimer=null);try{await this.incomingInvitation.accept(),this.activeSession=this.incomingInvitation,this.incomingInvitation=null}catch(n){(e=this.eventCallback)==null||e.call(this,{type:Ar.WEB_RTC_ANSWER_FAILED,data:{detail:n}})}}async rejectInCall(){var e;if(this.incomingInvitation)try{await this.incomingInvitation.reject(),this.incomingInvitation=null,G.updateDirection(null),G.updateIsCalling(!1),clearTimeout(this.callTimeoutTimer)}catch(n){(e=this.eventCallback)==null||e.call(this,{type:"error",data:{message:"拒接失败",detail:n}})}}sendDTMF(e){var r;if(!this.activeSession)throw new Error("当前没有活跃的通话");const n=this.activeSession.sessionDescriptionHandler;n&&typeof n.sendDtmf=="function"?(n.sendDtmf(e),(r=this.eventCallback)==null||r.call(this,{type:Ar.WEB_RTC_SEND_DTMF,data:{tone:e}})):(console.warn("DTMF发送不支持或未初始化"),nn.warn("DTMF发送不支持或未初始化","sip-client.ts 490 sendDTMF"))}async hangup(){if(this.activeSession,this.activeSession){clearTimeout(this.callTimeoutTimer);const e=this.activeSession;if(!e)return;const n=e.state;try{n===he.Established?await e.bye():n===he.Establishing&&(e instanceof v0?await e.cancel():e instanceof eu&&await e.reject()),clearTimeout(this.callTimeoutTimer)}catch(r){nn.error("挂断失败","sip-client.ts 522 hangup"),console.error("挂断失败",r)}finally{this.activeSession=null}}}async rejectOutCall(){this.activeSession instanceof eu&&(await this.activeSession.reject(),this.activeSession=null)}async destroy(){if(this.isManuallyStopped=!0,clearTimeout(this.callTimeoutTimer),this.activeSession&&await this.hangup(),this.registerer){try{await this.registerer.unregister()}catch(e){console.warn("注销失败",e)}this.registerer=null}this.userAgent&&(await this.userAgent.stop(),this.userAgent=null)}async reconnect(){if(!Z.isRtcReconnecting){Z.isRtcReconnecting=!0;try{this.isManuallyStopped=!1,await this.destroy(),await this.start(),this.isOffline=!1,this.reconnectAttempts=0}catch(e){console.error("重连失败",e),Z.isRtcReconnecting=!1}finally{Z.isRtcReconnecting=!1}}}async getNetworkStats(){var e;if(this.activeSession){const n=(e=this.activeSession.sessionDescriptionHandler)==null?void 0:e.peerConnection;if(!n)return null;const r=await n.getStats(),i={};return r.forEach(o=>{o.type==="candidate-pair"&&o.state==="succeeded"&&o.currentRoundTripTime!=null&&(i.rtt=+(1e3*o.currentRoundTripTime).toFixed(2)),o.type==="inbound-rtp"&&o.kind==="audio"&&(i.jitter=+(1e3*o.jitter).toFixed(2),i.packetsLost=o.packetsLost,i.packetsReceived=o.packetsReceived,o.bytesReceived&&o.timestamp&&(i.recvBitrate=+(o.bytesReceived/1024).toFixed(2))),o.type==="outbound-rtp"&&o.kind==="audio"&&(i.packetsSent=o.packetsSent,o.bytesSent&&o.timestamp&&(i.sendBitrate=+(o.bytesSent/1024).toFixed(2))),o.type==="codec"&&o.mimeType&&(i.codec=o.mimeType)}),{...i,rtt:(i==null?void 0:i.rtt)||40}}return{rtt:Z.latency||1}}}class To{static requestPermission(){"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()}static async requestMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(n=>n.kind==="audioinput"&&n.label!=="")?null:await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){return console.warn("获取音频权限失败:",e),null}}static show(e,n,r,i){if("Notification"in window&&Notification.permission==="granted"){const o=new Notification(e,{body:n,tag:`xy-global-notification${new Date().getTime()}`,renotify:!0});o.onclick=()=>{window.focus(),o.close(),r==null||r()},setTimeout(()=>o.close(),1e3*(i||3))}}static async checkMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(e=>e.kind==="audioinput"&&e.label!=="")}catch(e){return console.warn("无法检查设备权限:",e),!1}}}const Fw=[],Vn=["call_number"],gA=["call_number"],kw=["hangup"],Ci=["hold","hangup","mute","transfer","consult","satisfaction","dtmf"],Yc=["hold","hangup","mute","transfer","consult"],Hg=["consult_transfer","conference","consult_retrieve"],Pw=["hangup"],Qw=["hangup"],Os=["answer","reject"],Gi=["hangup","consult","transfer","hold","mute","satisfaction","dtmf"],Gg=["hangup","whisper","force_insert","force_disconnect"],jw=["hangup"],Lw=["hangup","cancel_whisper","force_insert"],Uw=["hangup"],Hw=["hangup"];class ja{constructor(){this.roleData={agentInfo:()=>{var e;if(!((e=Z.agentInfo)!=null&&e.agent_no))throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:e=>{if(!e.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:e=>{if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:n}=Z.agentInfo;if(!n.split(",").map(r=>Number(r)).includes(e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(e,n)=>{if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!n)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(e===2&&(n==="通话中"||n==="整理"))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},setAgentExplicit:e=>{const{out_display_select_switch:n,out_display_data:r}=Z.agentInfo;if(n!==1)throw new Error(JSON.stringify({code:1,msg:"当前坐席设置未开启允许指定外显"}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "number" is required'}));if(!(r||"").split("#").includes(e))throw new Error(JSON.stringify({code:1,msg:"当前外显号码不存在"}))}},this.changeDevice=async e=>{try{if(G.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:n,success:r}=e,{device:i}=n;i===1&&await ja.initRtcFn(),this.roleData.changeDevice(i);const{agent_no:o}=Z.agentInfo;await(s=>yn(`${Or}/device/change`,s))({agent_no:o,answer_device:i}),G.updateAnswerDevice(i);const a=G.get("actionConfigs");G.updateActionConfigs(a),i===2&&Z.stateObject.state===Rt.UNREGISTERED&&await this._changeState({data:{...Z.stateBeforeChange,state_name:Z.stateBeforeChange.state===Rt.IDLE?"空闲":"忙碌"}},"q"),r==null||r({code:0,msg:"请求成功"})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}}formatDate(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`}static setInitRtcFn(e){this.initRtcFn=e}async _agentLogin(e){try{const r=await(n={agent_no:e},yn(`${Or}/agent/login`,n));Z.agentInfo=r.data}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}var n}async _changeState(e,n){try{Z.autoStateTimer&&(clearTimeout(Z.autoStateTimer),Z.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:r,success:i}=e,{state:o,state_name:a}=r,{agent_no:s}=Z.agentInfo;await Ug({agent_no:s,state_name:a,state:o},n),o===Rt.IDLE?G.updateActionConfigs(Vn):o===Rt.BUSY&&G.updateActionConfigs(gA),Z.stateObject={state:o,state_name:a},i==null||i({code:0,msg:"请求成功"})}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async _getInCallCrmDetail(e){var n;try{const{phone:r}=e.data,i={};iu(r)?i.trace_id=r:i.phone=r.replace(/[\s\r\n-]+/g,"");const o=await(a=>yn(`${Yi}/crm/popups`,a))({...i});(n=e.success)==null||n.call(e,o)}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async changeState(e,n){try{if(G.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));Z.autoStateTimer&&(clearTimeout(Z.autoStateTimer),Z.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:r,success:i}=e,{state:o,state_name:a}=r;this.roleData.changeState(o,a);const{agent_no:s}=Z.agentInfo;await Ug({agent_no:s,state_name:a,state:o},n),(Z.stateObject.state===Rt.IDLE||Z.stateObject.state===Rt.BUSY&&a!=="整理")&&(Z.stateBeforeChange=Z.stateObject),o===Rt.IDLE?G.updateActionConfigs(Vn):o===Rt.BUSY&&G.updateActionConfigs(gA),Z.stateObject={state:o,state_name:a},i==null||i({code:0,msg:"请求成功"})}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async getIdleAgentList(e){var r;const{agent_no:n}=Z.agentInfo;try{this.roleData.agentInfo();const i=await(o=>yn(`${Or}/agent/free`,o))({agent_no:n});(r=e.success)==null||r.call(e,i)}catch(i){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(i.message).msg),i}}async getAgentState(e){var n;try{const r=await yn(`${Yi}/agent/statecfg/list`,{}),i=(r.data||[]).filter(o=>o.enable===0).filter(o=>o.state!==0&&o.state!==3).filter(o=>o.state_name!=="通话中"&&o.state_name!=="整理"&&o.state_name!=="未注册"&&o.state_name!=="离线接听").map(o=>({state:o.state,state_name:o.state_name})).reverse();(n=e.success)==null||n.call(e,{...r,data:i})}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async setAgentExplicit(e){var n;try{this.roleData.agentInfo(),this.roleData.requestInfo(e),this.roleData.setAgentExplicit(e.data.number);const{agent_id:r}=Z.agentInfo;await(i=>yn(`${Yi}/agent/update`,i))({agent_id:r,out_display_number:e.data.number}),G.updateSelectOutNumber(e.data.number),(n=e.success)==null||n.call(e,{code:0,msg:"请求成功"})}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async checkAgentLogin(e){var n;try{this.roleData.requestInfo(e);const{agent_no:r}=e.data;if(!r)throw new Error(JSON.stringify({code:1,msg:'Parameter "agent_no" is required'}));const i=await(o=>yn(`${Or}/agent/islogin`,o))({agent_no:r});(n=e.success)==null||n.call(e,i)}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async getCallRecord(e){try{this.roleData.agentInfo();const{success:n}=e,r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),0,0,0),o=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59),a=[this.formatDate(i),this.formatDate(o)],{agent_no:s}=Z.agentInfo,A=await(f=>yn(`${Yi}/agent/recordpage`,f))({start_time:a[0],end_time:a[1],page_no:1,page_size:10,agent_no:s}),{code:c,msg:u,data:d}=A;n==null||n({code:c,msg:u,data:d})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async logout(e){this.roleData.agentInfo();try{const{agent_no:n}=Z.agentInfo,{data:r,success:i}=e;await(o=>yn(`${Or}/agent/logout`,o))({...r,agent_no:n}),i==null||i({code:0,msg:""})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async listenCall(e){try{const{agent_no:n}=Z.agentInfo,{data:r,success:i}=e;if(this.roleData.agentInfo(),this.roleData.requestInfo(e),!r.monitored_agent_no)throw new Error(JSON.stringify({code:1,msg:'Parameter "monitored_agent_no" is required'}));await(o=>yn(`${Or}/call/monitor`,o))({...r,monitor_agent_no:n}),Z.monitoredAgentNo=r.monitored_agent_no,i==null||i({code:0,msg:""})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async earCall(e){try{const{agentInfo:n,monitoredAgentNo:r}=Z,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(a=>yn(`${Or}/call/whisper`,a))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async stopEarCall(e){try{const{agentInfo:n,earSpeakAgent:r}=Z;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前没有正在耳语的坐席"}));const{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;await(a=>yn(`${Or}/call/stopwhisper`,a))({monitor_agent_no:i,monitored_agent_no:r}),o==null||o({code:0,msg:""})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async forceInsert(e){try{const{agentInfo:n,monitoredAgentNo:r}=Z,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(a=>yn(`${Or}/call/bargein`,a))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async forceDisconnect(e){try{const{agentInfo:n,monitoredAgentNo:r}=Z,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(a=>yn(`${Or}/call/intercept`,a))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}}const Gw=console.log,qg=(...t)=>{Z.logBuiltinEnabled&&Gw(...t)};let ni=null;class An{constructor(e,n){this.url=e,this.onOpenCallback=n,this.ws=null,this.heartbeatWorker=null,this.reconnectDelay=3e3,this.manualClose=!1,this.apiClient=new ja,this.sipClient=null,this.pendingMessages=new Map,this.initWebSocket()}static getInstance({url:e,sipClient:n,onOpen:r}){if(!ni){if(!e)throw new Error("WebSocket 尚未初始化");ni=new An(e,r),ni.sipClient=n}return ni}setSipClient(e){this.sipClient=e}stateIdleChange(e){const{state:n}=Z.stateObject;n!==Rt.IDLE&&this.apiClient._changeState({data:{...Z.stateBeforeChange,state_name:Z.stateBeforeChange.state===Rt.IDLE?"空闲":"忙碌"}},e)}inCallAutoAnswer(){const{soft_device_auto_answer:e,auto_answer_time:n}=Z.agentInfo,r=e===1,i=G.get("direction");if(r&&i===xn.INCOMING){const o=Number(n)||0;o>0&&(Z.autoAnswerTimer=setTimeout(()=>{var a;(a=this.sipClient)==null||a.answerCall(),Z.autoAnswerTimer=null},o>0?1e3*o-500:0))}}async getCustomerInfo(e,n){try{await this.apiClient._getInCallCrmDetail({data:{phone:e},success:r=>{const i=r.data?{...r.data,type:n,session_id:Z.sessionId}:{phone:r.data.phone,is_vip:0,customer_name:"未知客户",city:"未知",province:"未知",contact_count:0,in_contact_count:0,trace_id:r.data.trace_id,contact_count_month:0,in_contact_count_month:0,session_id:Z.sessionId,type:n};G.updateCustomerInfo(i)}})}catch{}}putAgentState(e,n){if(!e)return;if(n===5)return void this.stateIdleChange("device_type5");Z.sessionId="";const{post_call_process_time:r}=Z.agentInfo,i=r||0;if(Z.autoStateTimer&&(clearTimeout(Z.autoStateTimer),Z.autoStateTimer=null),G.updateCustomerInfo(void 0),i>0){const{state:o}=Z.stateObject;if(o===Rt.IDLE)return;this.apiClient._changeState({data:{state:Rt.BUSY,state_name:"整理"}},"ez"),Z.autoStateTimer=setTimeout(()=>{Z.autoStateTimer=null,this.stateIdleChange(`delay${i}`)},1e3*i)}else this.stateIdleChange("delay0")}stateBusyChange(){Z.sessionId="",clearTimeout(Z.autoStateTimer),G.updateCustomerInfo(void 0),this.apiClient._changeState({data:{state:Rt.BUSY,state_name:"忙碌"}},"dm")}initWebSocket(){var n;if(((n=this.ws)==null?void 0:n.readyState)===1||!G.get("isNextState")||this.manualClose)return;const e=P0(Kd,Vd);this.ws=new WebSocket(this.url+e),this.ws.onopen=()=>{const r=new Date().getTime();this.sendMessage({type:0,msg_id:r}),this.pendingMessages.set(r,performance.now()),this.startHeartbeat(),this.manualClose=!1,this.onOpenCallback&&this.onOpenCallback()},this.ws.onmessage=async r=>{var u;const i=JSON.parse(r.data),{type:o,data:a,code:s,msg:A,msg_id:c}=i;if(o===0&&c){const d=this.pendingMessages.get(c),f=performance.now()-d;Z.latency=parseFloat(f.toFixed(2)),this.pendingMessages.delete(c)}if(o!==0&&qg("%cWebSocket 收到消息:","color: blue; font-weight: bold;",i),o!==it.OUT_CALL&&o!==it.PREVIEW_OUT_CALL||(Z.isAgentHangup=!1,s!==0?(G.reset(),fe.emit(ie.OUT_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A),G.updateActionConfigs(Vn),setTimeout(()=>{G.updateCustomerInfo(void 0)},500),this.stateIdleChange("h")):s===0&&(fe.emit(ie.OUT_SUCCESS),Z.sessionId=a.session_id,G.updateIsCalling(!0),clearTimeout(Z.autoStateTimer))),o===it.AGENT_STATE){const{state:d,state_name:f}=a;Z.stateObject={state:d,state_name:f},(u=Z.stateBeforeChange)!=null&&u.state||Z.stateObject.state!==Rt.IDLE&&(Z.stateObject.state!==Rt.BUSY||f==="整理")||(Z.stateBeforeChange=Z.stateObject),f==="振铃中"&&G.updateDisplayText(Kt.AGENT_RINGING);const p=G.get("isCalling");d!==Rt.UNREGISTERED||p||G.updateActionConfigs(Fw),d===Rt.IDLE&&Z.stateObject.state===Rt.UNREGISTERED&&G.updateActionConfigs(Vn),fe.emit(ie.AGENT_STATE,{state:d,state_name:f})}else if(o===it.OUT_CALL_INCOMING_CALL)Z.isAgentHangup=!1,a.preview_task_id?(this.getCustomerInfo(a.trace_id||a.customer_phone,"preview_out_incoming_call"),fe.emit(ie.PREVIEW_OUT_INCOMING_CALL,{customer_phone:a.customer_phone,session_id:a.session_id,preview_task_id:a.preview_task_id,trace_id:a.trace_id})):a.direction===0?(this.getCustomerInfo(a.trace_id||a.customer_phone,"out_call_incoming_call"),fe.emit(ie.OUT_INCOMING_CALL,{customer_phone:a.customer_phone,session_id:a.session_id,trace_id:a.trace_id})):a.direction===8&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"internal_out_incoming_call"),fe.emit(ie.INTERNAL_OUT_INCOMING_CALL,{customer_phone:a.customer_phone,session_id:a.session_id,trace_id:a.trace_id})),Z.sessionId=a.session_id,G.updateActionConfigs(kw,a.direction!==8);else if(o===it.OUT_CALL_END){if(Z.sessionId!==a.session_id)return;if(G.updateDisplayText(""),a.device_type===1&&a.agent_no===Z.agentInfo.agent_no)G.reset(),fe.emit(ie.OUT_HANGUP,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),G.updateActionConfigs(Vn),this.putAgentState(!0);else if(a.device_type===2&&a.agent_no===Z.agentInfo.agent_no)G.reset(),fe.emit(ie.OUR_SIDE_CONSULT_HANGUP,{session_id:a.session_id}),G.updateActionConfigs(Vn),this.putAgentState(!0);else if(a.device_type===2&&a.agent_no!==Z.agentInfo.agent_no)G.get("isCalling")&&(G.updateDisplayText(Kt.CALLING),fe.emit(ie.OTHER_SIDE_CONSULT_HANGUP,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),G.updateActionConfigs(Ci));else if(a.device_type===3&&a.agent_no===Z.agentInfo.agent_no)G.reset(),fe.emit(ie.THREE_WAY_OUR_SIDE_HANGUP,{session_id:a.session_id}),G.updateActionConfigs(Vn),this.putAgentState(!0);else if(a.device_type===4&&a.agent_no===Z.agentInfo.agent_no)G.reset(),fe.emit(ie.TRANSFER_END,{session_id:a.session_id}),G.updateActionConfigs(Vn),this.putAgentState(!0);else if(a.device_type===4&&a.agent_no!==Z.agentInfo.agent_no){fe.emit(ie.TRANSFER_FAILED,"未知原因"),fe.emit(He.FAIL_NOTIFICATION,"转接失败");const d=G.get("direction");d===xn.OUTGOING?G.updateActionConfigs(Ci):d===xn.INCOMING&&G.updateActionConfigs(Gi)}else a.device_type===5&&a.agent_no===Z.agentInfo.agent_no&&(Z.monitoredAgentNo="",Z.earSpeakAgent="",G.reset(),fe.emit(ie.LISTEN_HANGUP,{session_id:a.session_id}),G.updateActionConfigs(Vn),this.putAgentState(!0,5))}else if(o===it.OUT_CALL_RINGING)a.type===1&&(Z.isAgentHangup=!1,fe.emit(ie.OUT_RINGING,{session_id:Z.sessionId,type:a.type}),G.updateDisplayText(Kt.RINGING));else if(o===it.OUT_CALL_ANSWER)Z.isAgentHangup=!1,clearTimeout(Z.autoStateTimer),G.updateIsCalling(!0),G.updateOutCallIsAnswer(!0),G.updateDisplayText(Kt.CALLING),a.direction===8?(fe.emit(ie.INTERNAL_OUT_OFF_ANSWER,{session_id:Z.sessionId}),G.updateActionConfigs(Yc)):(fe.emit(ie.OUT_OFF_ANSWER,{session_id:Z.sessionId}),G.updateActionConfigs(Ci));else if(o===it.CONSULT_RINGING)Z.isAgentHangup=!1,fe.emit(ie.CONSULT_RINGING,{session_id:a.session_id}),G.updateDisplayText(Kt.AGENT_RINGING),G.updateActionConfigs([]),clearTimeout(Z.autoStateTimer);else if(o===it.CONSULT_ANSWER)Z.isAgentHangup=!1,fe.emit(ie.CONSULT_OFF_HOOK,{session_id:a.session_id}),G.updateConsultIsAnswer(!0),G.updateDisplayText(Kt.CONSULTING),G.updateActionConfigs(Hg);else if(o===it.CONSULT_FAIL)fe.emit(ie.CONSULT_FAILED,{custom_reason:a.custom_reason}),G.updateDisplayText(Kt.CALLING),G.updateActionConfigs(Ci);else if(o===it.CONSULT_CALL_IN)Z.isAgentHangup=!1,fe.emit(ie.CONSULT_INCOMING,{agent_no:a.agent_no,agent_mane:a.agent_name,session_id:a.session_id}),Z.sessionId=a.session_id,G.updateIsCalling(!0),G.updateDirection(xn.CONSULT),G.updateDisplayText(Kt.CONSULT_CALL_IN),G.updateActionConfigs(Os),Z.enableBrowserAlert&&To.show("📞 咨询来电",`坐席 [${a.agent_name}] 正在咨询...`,()=>{fe.emit(He.NOTIFICATION_CLICK,{agent_mane:a.agent_name,agent_no:a.agent_no})},Z.browserAlertTime);else if(o===it.CONSULT_CALL_IN_SUCCESS)fe.emit(ie.CONSULT_CALL_IN_SUCCESS,{session_id:a.session_id}),G.updateConsultIsAnswer(!0),G.updateDisplayText(Kt.CALLING),G.updateActionConfigs(Pw);else if(o===it.CONSULT_RETURN_CALL_SUCCESS)a.status==="success"?(G.updateConsultIsAnswer(!1),fe.emit(ie.CONSULT_RETURN_CALL_SUCCESS),G.updateDisplayText(Kt.CALLING),fe.emit(ie.OTHER_SIDE_CONSULT_HANGUP),G.updateActionConfigs(Ci)):fe.emit(He.FAIL_NOTIFICATION,"媒体失败");else if(o===it.MUTE)s===0?(G.updateIsMuted(!0),fe.emit(ie.MUTE_SUCCESS),G.updateDisplayText(Kt.MUTING)):(fe.emit(ie.MUTE_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A));else if(o===it.UNMUTE)s===0?(G.updateIsMuted(!1),fe.emit(ie.UNMUTE_SUCCESS),G.updateDisplayText(Kt.CALLING)):(fe.emit(ie.UNMUTE_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A));else if(o===it.CALL_HOLD)s===0?(G.updateIsHold(!0),G.updateDisplayText(Kt.HOLDING),fe.emit(ie.HOLD_SUCCESS)):(fe.emit(ie.HOLD_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A));else if(o===it.CALL_UNHOLD)s===0?(G.updateDisplayText(Kt.CALLING),G.updateIsHold(!1),fe.emit(ie.UNHOLD_SUCCESS)):(fe.emit(ie.UNHOLD_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A));else if(o===it.CONSULT_TRANSFER)Z.isAgentHangup=!1,s===0?fe.emit(ie.CONSULT_TRANSFER_SUCCESS):(fe.emit(ie.CONSULT_TRANSFER_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A));else if(o===it.CONSULT_TRANSFER_FAILED)fe.emit(ie.CONSULT_TRANSFER_FAILED,a.status);else if(o===it.CONSULT_TRANSFER_OFF_HOOK)G.updateDirection(xn.INCOMING),G.updateDisplayText(Kt.CALLING),fe.emit(ie.CONSULT_TRANSFER_OFF_HOOK),G.updateActionConfigs(Gi),G.updateIncomingIsAnswer(!0),G.updateConsultIsAnswer(!1);else if(o===it.INCOMING_CALL)Z.isAgentHangup=!1,clearTimeout(Z.autoStateTimer),Z.sessionId=a.session_id,G.updateIsCalling(!0),G.updateDirection(xn.INCOMING),G.updateDisplayText(Kt.INCOMING_CALL),this.inCallAutoAnswer(),a.direction===1&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"incoming_call"),fe.emit(ie.INCOMING_CALL,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),a.direction===8&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"incoming_call_in"),fe.emit(ie.INCOMING_CALL_IN,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),a.direction===3&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"predict_incoming_call"),fe.emit(ie.PREDICT_INCOMING_CALL,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),a.direction===6&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"dual_call_incoming_call"),fe.emit(ie.DUAL_CALL_INCOMING_CALL,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),G.updateActionConfigs(Os),Z.enableBrowserAlert&&To.show("📞 客户来电",`客户 [${a.customer_phone}] 正在呼入...`,()=>{fe.emit(He.NOTIFICATION_CLICK,{customer_phone:a.customer_phone})},Z.browserAlertTime);else if(o===it.INCOMING_CALL_OFF_HOOK)G.updateIncomingIsAnswer(!0),a.direction===8?(G.updateActionConfigs(Yc),fe.emit(ie.INCOMING_CALL_IN_OFF_HOOK,{session_id:Z.sessionId})):(G.updateActionConfigs(Gi),fe.emit(ie.INCOMING_CALL_OFF_HOOK,{session_id:Z.sessionId})),G.updateDisplayText(Kt.CALLING);else if(o===it.INCOMING_CALL_END){if(Z.sessionId!==a.session_id)return;if(G.updateDisplayText(""),a.device_type!==1&&a.device_type!==7||a.agent_no!==Z.agentInfo.agent_no)if(a.device_type===2&&a.agent_no===Z.agentInfo.agent_no)G.reset(),fe.emit(ie.OUR_SIDE_CONSULT_HANGUP,{session_id:a.session_id}),this.putAgentState(!0),G.updateActionConfigs(Vn);else if(a.device_type===2&&a.agent_no!==Z.agentInfo.agent_no)G.updateDisplayText(Kt.CALLING),fe.emit(ie.OTHER_SIDE_CONSULT_HANGUP,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),G.updateActionConfigs(Ci);else if(a.device_type===3&&a.agent_no===Z.agentInfo.agent_no)this.putAgentState(!0),G.reset(),fe.emit(ie.THREE_WAY_OUR_SIDE_HANGUP,{session_id:a.session_id}),G.updateActionConfigs(Vn);else if(a.device_type===4&&a.agent_no===Z.agentInfo.agent_no)this.putAgentState(!0),G.reset(),fe.emit(ie.TRANSFER_END,{session_id:a.session_id}),G.updateActionConfigs(Vn);else if(a.device_type===4&&a.agent_no!==Z.agentInfo.agent_no){fe.emit(ie.TRANSFER_FAILED,"未知原因"),fe.emit(He.FAIL_NOTIFICATION,"转接失败");const d=G.get("direction");d===xn.OUTGOING?G.updateActionConfigs(Ci):d===xn.INCOMING&&G.updateActionConfigs(Gi)}else a.device_type===5&&a.agent_no===Z.agentInfo.agent_no&&(this.putAgentState(!0,5),Z.monitoredAgentNo="",Z.earSpeakAgent="",G.reset(),fe.emit(ie.LISTEN_HANGUP,{session_id:a.session_id}),G.updateActionConfigs(Vn));else this.putAgentState(!0),G.reset(),fe.emit(ie.INCOMING_CALL_END,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),G.updateActionConfigs(Vn)}else if(o===it.SATISFACTION_EVALUATION)s===0?fe.emit(ie.SATISFACTION_EVALUATION_SUCCESS):(fe.emit(ie.SATISFACTION_EVALUATION_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A));else if(o===it.CONSULT_THREE_WAY)s!==0?(fe.emit(ie.CONSULT_THREE_WAY_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A)):s===0&&G.updateIsMeeting(!0);else if(o===it.CONSULT_THREE_WAY_RESULT)a.status==="success"?(G.updateDirection(xn.MEETING),G.updateDisplayText(Kt.MEETING),G.updateActionConfigs(Qw),fe.emit(ie.CONSULT_THREE_WAY_SUCCESS)):(fe.emit(ie.CONSULT_THREE_WAY_FAILED,{conf_name:a.conf_name}),G.updateIsMeeting(!1));else if(o===it.TRANSFER_INCOMING_CALL)Z.isAgentHangup=!1,clearTimeout(Z.autoStateTimer),a.agent_no===Z.agentInfo.agent_no?(G.updateDisplayText(Kt.TRANSFERRING),fe.emit(ie.TRANSFER_PROGRESS),G.updateActionConfigs([]),G.updateTransferIsAnswer(!0)):(Z.sessionId=a.session_id,fe.emit(ie.TRANSFER_INCOMING_CALL,{agent_no:a.agent_no,agent_name:a.agent_name,session_id:a.session_id}),G.updateIsCalling(!0),G.updateDirection(xn.TRANSFER),G.updateDisplayText(Kt.TRANSFER_INCOMING_CALL),G.updateActionConfigs(Os),Z.enableBrowserAlert&&To.show("📞 转接来电",`坐席 [${a.agent_no}] 正在转接...`,()=>{fe.emit(He.NOTIFICATION_CLICK,{agent_no:a.agent_no})},Z.browserAlertTime));else if(o===it.TRANSFER_OFF_HOOK)fe.emit(ie.TRANSFER_OFF_HOOK,{session_id:Z.sessionId}),G.updateTransferIsAnswer(!1),G.updateDisplayText(Kt.CALLING),G.updateActionConfigs(Gi,a.direction!==8);else if(o===it.TRANSFER_FAILED){if(a.status==="failed"){fe.emit(ie.TRANSFER_FAILED,"未知原因"),fe.emit(He.FAIL_NOTIFICATION,"转接失败");const d=G.get("direction");d===xn.OUTGOING?G.updateActionConfigs(Ci):d===xn.INCOMING&&G.updateActionConfigs(Gi)}}else o===it.KICK_OFFLINE?fe.emit(He.KICK_OFF):o===it.CONTINUOUS_NOT_ANSWER?(fe.emit(He.FAIL_NOTIFICATION,`已连续 ${a.miss_count} 次未接, 设置忙碌`),this.stateBusyChange()):o===it.SIGN_OUT?fe.emit(He.SIGN_OUT):o===it.SIGN_IN_SWITCH_DEVICE?fe.emit(He.SIGN_IN_SWITCH_DEVICE,a):o===it.LISTEN_INCOMING_CALL?(clearTimeout(Z.autoStateTimer),Z.sessionId=a.session_id,G.updateIsCalling(!0),G.updateDirection(xn.INCOMING),this.inCallAutoAnswer(),G.updateDisplayText(Kt.LISTENING),G.updateActionConfigs(Os),fe.emit(ie.LISTEN_INCOMING_CALL,{session_id:a.session_id}),Z.enableBrowserAlert&&To.show("📞 监听来电","正在来电...",()=>{fe.emit(He.NOTIFICATION_CLICK,{customer_phone:a.customer_phone})},Z.browserAlertTime)):o===it.LISTEN_INCOMING_CALL_OFF_HOOK?(Z.monitoredAgentNo=a.monitored_agent_no,Z.earSpeakAgent="",G.updateIncomingIsAnswer(!0),fe.emit(ie.LISTEN_INCOMING_CALL_OFF_HOOK,{session_id:Z.sessionId,monitored_agent_no:a.monitored_agent_no}),G.updateActionConfigs(Gg),G.updateDisplayText(Kt.CALLING)):o===it.LISTEN_CALL_FAILED?a.status==="failed"&&(fe.emit(ie.LISTEN_CALL_FAILED),Z.monitoredAgentNo=""):o===it.EAR_SPEECH?a.status==="success"?(a.monitored_agent_no===Z.agentInfo.agent_no&&(G.updateActionConfigs(jw),fe.emit(ie.EAR_SPEECH_BE_SUCCESS)),a.monitor_agent_no===Z.agentInfo.agent_no&&(G.updateActionConfigs(Lw),fe.emit(ie.EAR_SPEECH_SUCCESS,{monitored_agent_no:a.monitored_agent_no,monitor_agent_no:a.monitor_agent_no}),Z.earSpeakAgent=a.monitored_agent_no)):fe.emit(ie.EAR_SPEECH_FAILED):o===it.STOP_EAR_SPEECH?a.status==="success"?(a.monitored_agent_no===Z.agentInfo.agent_no&&G.updateActionConfigs(Gi),a.monitor_agent_no===Z.agentInfo.agent_no&&G.updateActionConfigs(Gg),Z.earSpeakAgent="",fe.emit(ie.STOP_EAR_SPEECH_SUCCESS)):fe.emit(ie.STOP_EAR_SPEECH_FAILED):o===it.CALL_FORCE_INSERT?a.status==="success"?(a.monitored_agent_no===Z.agentInfo.agent_no&&(G.updateActionConfigs(Hw),fe.emit(ie.CALL_FORCE_INSERT_SUCCESS,{monitored_agent_no:a.monitored_agent_no,monitor_agent_no:a.monitor_agent_no})),a.monitor_agent_no===Z.agentInfo.agent_no&&(G.updateActionConfigs(Uw),fe.emit(ie.CALL_FORCE_INSERT_SUCCESS_LISTENER,{monitored_agent_no:a.monitored_agent_no,monitor_agent_no:a.monitor_agent_no}))):fe.emit(ie.CALL_FORCE_INSERT_FAILED):o===it.INTERNAL_CALL_START_CONSULT?a.agent_no===Z.agentInfo.agent_no?(G.updateConsultIsAnswer(!0),G.updateActionConfigs(Hg),G.updateDisplayText(Kt.CONSULTING)):(G.updateDisplayText(Kt.OTHER_SIDE_CONSULTING),G.updateActionConfigs([])):o===it.INTERNAL_CALL_END_CONSULT?(G.updateActionConfigs(Yc),G.updateDisplayText(""),G.updateConsultIsAnswer(!1)):o===it.CALL_SIP_INCOMING_CALL&&fe.emit(ie.CALL_SIP_INCOMING_CALL)},this.ws.onclose=r=>{fe.emit(He.FAIL_NOTIFICATION,"链接已断开,请检查网络"),this.stopHeartbeat();const i=G.get("isNextState");!this.manualClose&&i&&setTimeout(()=>this.initWebSocket(),this.reconnectDelay)},this.ws.onerror=r=>{var i;fe.emit(He.FAIL_NOTIFICATION,"连接失败,请检查网络"),(i=this.ws)==null||i.close()}}startHeartbeat(){const e=new Blob([`
|
|
163
|
+
*/Vc=k0,function(){var t="input is invalid type",e=typeof window=="object",n=e?window:{};n.JS_MD5_NO_WINDOW&&(e=!1);var r=!e&&typeof self=="object",i=!n.JS_MD5_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;i?n=Tw:r&&(n=self);var o,a=!n.JS_MD5_NO_COMMON_JS&&Vc.exports,s=!n.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",A="0123456789abcdef".split(""),c=[128,32768,8388608,-2147483648],u=[0,8,16,24],d=["hex","array","digest","buffer","arrayBuffer","base64"],f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),p=[];if(s){var v=new ArrayBuffer(68);o=new Uint8Array(v),p=new Uint32Array(v)}var C=Array.isArray;!n.JS_MD5_NO_NODE_JS&&C||(C=function(E){return Object.prototype.toString.call(E)==="[object Array]"});var m=ArrayBuffer.isView;!s||!n.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&m||(m=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});var y=function(E){var b=typeof E;if(b==="string")return[E,!0];if(b!=="object"||E===null)throw new Error(t);if(s&&E.constructor===ArrayBuffer)return[new Uint8Array(E),!1];if(!C(E)&&!m(E))throw new Error(t);return[E,!1]},w=function(E){return function(b){return new x(!0).update(b)[E]()}},I=function(E){var b,h=Og,S=Og.Buffer;return b=S.from&&!n.JS_MD5_NO_BUFFER_FROM?S.from:function(T){return new S(T)},function(T){if(typeof T=="string")return h.createHash("md5").update(T,"utf8").digest("hex");if(T==null)throw new Error(t);return T.constructor===ArrayBuffer&&(T=new Uint8Array(T)),C(T)||m(T)||T.constructor===S?h.createHash("md5").update(b(T)).digest("hex"):E(T)}},O=function(E){return function(b,h){return new g(b,!0).update(h)[E]()}};function x(E){if(E)p[0]=p[16]=p[1]=p[2]=p[3]=p[4]=p[5]=p[6]=p[7]=p[8]=p[9]=p[10]=p[11]=p[12]=p[13]=p[14]=p[15]=0,this.blocks=p,this.buffer8=o;else if(s){var b=new ArrayBuffer(68);this.buffer8=new Uint8Array(b),this.blocks=new Uint32Array(b)}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 g(E,b){var h,S=y(E);if(E=S[0],S[1]){var T,R=[],D=E.length,B=0;for(h=0;h<D;++h)(T=E.charCodeAt(h))<128?R[B++]=T:T<2048?(R[B++]=192|T>>>6,R[B++]=128|63&T):T<55296||T>=57344?(R[B++]=224|T>>>12,R[B++]=128|T>>>6&63,R[B++]=128|63&T):(T=65536+((1023&T)<<10|1023&E.charCodeAt(++h)),R[B++]=240|T>>>18,R[B++]=128|T>>>12&63,R[B++]=128|T>>>6&63,R[B++]=128|63&T);E=R}E.length>64&&(E=new x(!0).update(E).array());var k=[],P=[];for(h=0;h<64;++h){var H=E[h]||0;k[h]=92^H,P[h]=54^H}x.call(this,b),this.update(P),this.oKeyPad=k,this.inner=!0,this.sharedMemory=b}x.prototype.update=function(E){if(this.finalized)throw new Error("finalize already called");var b=y(E);E=b[0];for(var h,S,T=b[1],R=0,D=E.length,B=this.blocks,k=this.buffer8;R<D;){if(this.hashed&&(this.hashed=!1,B[0]=B[16],B[16]=B[1]=B[2]=B[3]=B[4]=B[5]=B[6]=B[7]=B[8]=B[9]=B[10]=B[11]=B[12]=B[13]=B[14]=B[15]=0),T)if(s)for(S=this.start;R<D&&S<64;++R)(h=E.charCodeAt(R))<128?k[S++]=h:h<2048?(k[S++]=192|h>>>6,k[S++]=128|63&h):h<55296||h>=57344?(k[S++]=224|h>>>12,k[S++]=128|h>>>6&63,k[S++]=128|63&h):(h=65536+((1023&h)<<10|1023&E.charCodeAt(++R)),k[S++]=240|h>>>18,k[S++]=128|h>>>12&63,k[S++]=128|h>>>6&63,k[S++]=128|63&h);else for(S=this.start;R<D&&S<64;++R)(h=E.charCodeAt(R))<128?B[S>>>2]|=h<<u[3&S++]:h<2048?(B[S>>>2]|=(192|h>>>6)<<u[3&S++],B[S>>>2]|=(128|63&h)<<u[3&S++]):h<55296||h>=57344?(B[S>>>2]|=(224|h>>>12)<<u[3&S++],B[S>>>2]|=(128|h>>>6&63)<<u[3&S++],B[S>>>2]|=(128|63&h)<<u[3&S++]):(h=65536+((1023&h)<<10|1023&E.charCodeAt(++R)),B[S>>>2]|=(240|h>>>18)<<u[3&S++],B[S>>>2]|=(128|h>>>12&63)<<u[3&S++],B[S>>>2]|=(128|h>>>6&63)<<u[3&S++],B[S>>>2]|=(128|63&h)<<u[3&S++]);else if(s)for(S=this.start;R<D&&S<64;++R)k[S++]=E[R];else for(S=this.start;R<D&&S<64;++R)B[S>>>2]|=E[R]<<u[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},x.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var E=this.blocks,b=this.lastByteIndex;E[b>>>2]|=c[3&b],b>=56&&(this.hashed||this.hash(),E[0]=E[16],E[16]=E[1]=E[2]=E[3]=E[4]=E[5]=E[6]=E[7]=E[8]=E[9]=E[10]=E[11]=E[12]=E[13]=E[14]=E[15]=0),E[14]=this.bytes<<3,E[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},x.prototype.hash=function(){var E,b,h,S,T,R,D=this.blocks;this.first?b=((b=((E=((E=D[0]-680876937)<<7|E>>>25)-271733879|0)^(h=((h=(-271733879^(S=((S=(-1732584194^2004318071&E)+D[1]-117830708)<<12|S>>>20)+E|0)&(-271733879^E))+D[2]-1126478375)<<17|h>>>15)+S|0)&(S^E))+D[3]-1316259209)<<22|b>>>10)+h|0:(E=this.h0,b=this.h1,h=this.h2,b=((b+=((E=((E+=((S=this.h3)^b&(h^S))+D[0]-680876936)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[1]-389564586)<<12|S>>>20)+E|0)&(E^b))+D[2]+606105819)<<17|h>>>15)+S|0)&(S^E))+D[3]-1044525330)<<22|b>>>10)+h|0),b=((b+=((E=((E+=(S^b&(h^S))+D[4]-176418897)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[5]+1200080426)<<12|S>>>20)+E|0)&(E^b))+D[6]-1473231341)<<17|h>>>15)+S|0)&(S^E))+D[7]-45705983)<<22|b>>>10)+h|0,b=((b+=((E=((E+=(S^b&(h^S))+D[8]+1770035416)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[9]-1958414417)<<12|S>>>20)+E|0)&(E^b))+D[10]-42063)<<17|h>>>15)+S|0)&(S^E))+D[11]-1990404162)<<22|b>>>10)+h|0,b=((b+=((E=((E+=(S^b&(h^S))+D[12]+1804603682)<<7|E>>>25)+b|0)^(h=((h+=(b^(S=((S+=(h^E&(b^h))+D[13]-40341101)<<12|S>>>20)+E|0)&(E^b))+D[14]-1502002290)<<17|h>>>15)+S|0)&(S^E))+D[15]+1236535329)<<22|b>>>10)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[1]-165796510)<<5|E>>>27)+b|0)^b))+D[6]-1069501632)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[11]+643717713)<<14|h>>>18)+S|0)^S))+D[0]-373897302)<<20|b>>>12)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[5]-701558691)<<5|E>>>27)+b|0)^b))+D[10]+38016083)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[15]-660478335)<<14|h>>>18)+S|0)^S))+D[4]-405537848)<<20|b>>>12)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[9]+568446438)<<5|E>>>27)+b|0)^b))+D[14]-1019803690)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[3]-187363961)<<14|h>>>18)+S|0)^S))+D[8]+1163531501)<<20|b>>>12)+h|0,b=((b+=((S=((S+=(b^h&((E=((E+=(h^S&(b^h))+D[13]-1444681467)<<5|E>>>27)+b|0)^b))+D[2]-51403784)<<9|S>>>23)+E|0)^E&((h=((h+=(E^b&(S^E))+D[7]+1735328473)<<14|h>>>18)+S|0)^S))+D[12]-1926607734)<<20|b>>>12)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[5]-378558)<<4|E>>>28)+b|0))+D[8]-2022574463)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[11]+1839030562)<<16|h>>>16)+S|0))+D[14]-35309556)<<23|b>>>9)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[1]-1530992060)<<4|E>>>28)+b|0))+D[4]+1272893353)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[7]-155497632)<<16|h>>>16)+S|0))+D[10]-1094730640)<<23|b>>>9)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[13]+681279174)<<4|E>>>28)+b|0))+D[0]-358537222)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[3]-722521979)<<16|h>>>16)+S|0))+D[6]+76029189)<<23|b>>>9)+h|0,b=((b+=((R=(S=((S+=((T=b^h)^(E=((E+=(T^S)+D[9]-640364487)<<4|E>>>28)+b|0))+D[12]-421815835)<<11|S>>>21)+E|0)^E)^(h=((h+=(R^b)+D[15]+530742520)<<16|h>>>16)+S|0))+D[2]-995338651)<<23|b>>>9)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[0]-198630844)<<6|E>>>26)+b|0)|~h))+D[7]+1126891415)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[14]-1416354905)<<15|h>>>17)+S|0)|~E))+D[5]-57434055)<<21|b>>>11)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[12]+1700485571)<<6|E>>>26)+b|0)|~h))+D[3]-1894986606)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[10]-1051523)<<15|h>>>17)+S|0)|~E))+D[1]-2054922799)<<21|b>>>11)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[8]+1873313359)<<6|E>>>26)+b|0)|~h))+D[15]-30611744)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[6]-1560198380)<<15|h>>>17)+S|0)|~E))+D[13]+1309151649)<<21|b>>>11)+h|0,b=((b+=((S=((S+=(b^((E=((E+=(h^(b|~S))+D[4]-145523070)<<6|E>>>26)+b|0)|~h))+D[11]-1120210379)<<10|S>>>22)+E|0)^((h=((h+=(E^(S|~b))+D[2]+718787259)<<15|h>>>17)+S|0)|~E))+D[9]-343485551)<<21|b>>>11)+h|0,this.first?(this.h0=E+1732584193|0,this.h1=b-271733879|0,this.h2=h-1732584194|0,this.h3=S+271733878|0,this.first=!1):(this.h0=this.h0+E|0,this.h1=this.h1+b|0,this.h2=this.h2+h|0,this.h3=this.h3+S|0)},x.prototype.hex=function(){this.finalize();var E=this.h0,b=this.h1,h=this.h2,S=this.h3;return A[E>>>4&15]+A[15&E]+A[E>>>12&15]+A[E>>>8&15]+A[E>>>20&15]+A[E>>>16&15]+A[E>>>28&15]+A[E>>>24&15]+A[b>>>4&15]+A[15&b]+A[b>>>12&15]+A[b>>>8&15]+A[b>>>20&15]+A[b>>>16&15]+A[b>>>28&15]+A[b>>>24&15]+A[h>>>4&15]+A[15&h]+A[h>>>12&15]+A[h>>>8&15]+A[h>>>20&15]+A[h>>>16&15]+A[h>>>28&15]+A[h>>>24&15]+A[S>>>4&15]+A[15&S]+A[S>>>12&15]+A[S>>>8&15]+A[S>>>20&15]+A[S>>>16&15]+A[S>>>28&15]+A[S>>>24&15]},x.prototype.toString=x.prototype.hex,x.prototype.digest=function(){this.finalize();var E=this.h0,b=this.h1,h=this.h2,S=this.h3;return[255&E,E>>>8&255,E>>>16&255,E>>>24&255,255&b,b>>>8&255,b>>>16&255,b>>>24&255,255&h,h>>>8&255,h>>>16&255,h>>>24&255,255&S,S>>>8&255,S>>>16&255,S>>>24&255]},x.prototype.array=x.prototype.digest,x.prototype.arrayBuffer=function(){this.finalize();var E=new ArrayBuffer(16),b=new Uint32Array(E);return b[0]=this.h0,b[1]=this.h1,b[2]=this.h2,b[3]=this.h3,E},x.prototype.buffer=x.prototype.arrayBuffer,x.prototype.base64=function(){for(var E,b,h,S="",T=this.array(),R=0;R<15;)E=T[R++],b=T[R++],h=T[R++],S+=f[E>>>2]+f[63&(E<<4|b>>>4)]+f[63&(b<<2|h>>>6)]+f[63&h];return E=T[R],S+=f[E>>>2]+f[E<<4&63]+"=="},g.prototype=new x,g.prototype.finalize=function(){if(x.prototype.finalize.call(this),this.inner){this.inner=!1;var E=this.array();x.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(E),x.prototype.finalize.call(this)}};var M=function(){var E=w("hex");i&&(E=I(E)),E.create=function(){return new x},E.update=function(S){return E.create().update(S)};for(var b=0;b<d.length;++b){var h=d[b];E[h]=w(h)}return E}();M.md5=M,M.md5.hmac=function(){var E=O("hex");E.create=function(S){return new g(S)},E.update=function(S,T){return E.create(S).update(T)};for(var b=0;b<d.length;++b){var h=d[b];E[h]=O(h)}return E}(),a?Vc.exports=M:n.md5=M}();var Nw=k0.exports;const P0=(t,e)=>{const n=Date.now(),r=`${t}:${n}:${Nw.md5(`${e}${n}`)}`,i=new TextEncoder().encode(r);return btoa(String.fromCharCode(...i))},iu=t=>{if(/^\d+$/.test(t)||!t||typeof t!="string"||t.length%4!=0||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t))return!1;try{const e=atob(t);return btoa(e)===t}catch{return!1}},Yi="/v1/aicc/bmserver",Or="/v1/aicc/ccs";let Si="",Kd="",Vd="",zc="";function Q0(t){const e=P0(Kd,Vd);return Mw.create({prefixUrl:`${Si}`,timeout:!1,headers:{Authorization:e,...t},hooks:{afterResponse:[async(n,r,i)=>{if(i.url.indexOf("heartbeat")!==-1)return i;const o=await i.clone().json();if(o.code!==0)throw new Error(JSON.stringify(o)||"请求失败");return i.json=async()=>o,i}]}})}async function yn(t,e,n){const r=Q0(n),i="api/"+t.replace(/^\/+/,"");return r.post(i,{json:e}).json()}const Ug=(t,e)=>yn(`${Or}/state/change?h=${e}`,t,{h:e}),Dw=()=>async function(t,e){const n=Q0(),r=t.replace(/^\/+/,"");return n.post(r,{json:e}).json()}("/heartbeat",{});class nn{static log(e,n={}){const{level:r="info",module:i="",timestamp:o=!0}=n;if(Z.logBuiltinEnabled){const A=i?`[${i}]`:"",c=o?`[${new Date().toLocaleString()}]`:"";switch(r){case"debug":break;case"warn":console.warn(`${c}${A} ${e}`);break;case"error":console.error(`${c}${A} ${e}`)}}const a=Z.agentInfo.agent_no;if(a){const A=JSON.stringify({level:r,module:i,content:e,timestamp:new Date().toISOString()});(s={agent_no:a,content:A},yn("/v1/aicc/ccs/softphone/log",s)).catch(()=>{})}var s}static debug(e,n){this.log(e,{level:"debug",module:n})}static info(e,n){this.log(e,{level:"info",module:n})}static warn(e,n){this.log(e,{level:"warn",module:n})}static error(e,n){this.log(e,{level:"error",module:n})}static errorObj(e,n){const r=JSON.stringify({message:e.message,stack:e.stack,name:e.name});this.log(r,{level:"error",module:n})}}class Bw{constructor(e,n){this.config=e,this.eventCallback=n,this.userAgent=null,this.registerer=null,this.activeSession=null,this.callTimeoutTimer=null,this.incomingInvitation=null,this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectTimer=null,this.isOffline=!1,this.isManuallyStopped=!1,this.registerInterval=6e4,this.handleNetworkInfoChange=r=>{var i,o;if((i=r.rttObject)!=null&&i.rtt){const a=(o=r.rttObject)==null?void 0:o.rtt,s=a!=null&&a>0;s||this.isOffline?s&&this.isOffline&&(this.isOffline=!1,this.handleOnline()):(this.isOffline=!0,this.handleOffline())}},this.handleOffline=()=>{nn.warn("网络断开,准备销毁 SIP 客户端","sip-client.ts 75 handleOffline"),fe.emit(He.FAIL_NOTIFICATION,"网络断开,准备销毁 SIP 客户端"),this.destroy()},this.handleOnline=()=>{nn.warn("网络恢复,准备重新启动 SIP 客户端","sip-client.ts 82 handleOnline"),this.reconnect()},this.sleep=r=>new Promise(i=>setTimeout(i,r)),T0.subscribe(this.handleNetworkInfoChange)}async start(){const e=Fg.makeURI(`sip:${this.config.user}@${this.config.server}`);if(!e)throw new Error("无效的SIP配置");const n={uri:e,authorizationUsername:this.config.user,authorizationPassword:this.config.password,sendInitialProvisionalResponse:!1,transportOptions:{server:this.config.webSocket,connectionTimeout:10,keepAliveInterval:20,keepAliveDebounce:10},contactName:this.config.user,contactParams:{transport:"wss"},userAgentString:"SwiftSIP/2.0.21",sessionDescriptionHandlerFactoryOptions:{alwaysAcquireMediaFirst:!0,peerConnectionConfiguration:{iceServers:[{urls:"stun:stun.l.google.com:19302"}],iceCandidatePoolSize:0,iceTransportPolicy:"all",rtcpMuxPolicy:"require",bundlePolicy:"balanced",certificates:void 0,peerIdentity:void 0},iceGatheringTimeout:1e3},logBuiltinEnabled:Z.logBuiltinEnabled};this.userAgent=new Fg(n),this.setupEventListeners(),await this.userAgent.start(),await this.register()}setupEventListeners(){this.userAgent&&(this.userAgent.transport.stateChange.addListener(e=>{var r;let n;switch(e){case dt.Connecting:n=Ar.WEB_RTC_CONNECTING;break;case dt.Connected:n=Ar.WEB_RTC_CONNECTED,this.reconnectAttempts=0,Z.isRtcReconnecting=!1,G.updateIsSipConnected(!0),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);break;case dt.Disconnecting:n=Ar.WEB_RTC_DISCONNECTING,G.updateIsSipConnected(!1);break;case dt.Disconnected:{if(G.updateIsSipConnected(!1),this.isManuallyStopped)return nn.warn("手动断开,不触发重连","sip-client.ts 204"),void console.warn("[SIP] 手动断开,不触发重连");fe.emit(He.FAIL_NOTIFICATION,"软电话链接失败"),n=Ar.WEB_RTC_DISCONNECTED;const i=G.get("answerDevice");if(!Z.isRtcReconnecting&&this.reconnectAttempts<this.maxReconnectAttempts&&i===1){this.reconnectAttempts++;const o=1e3*this.reconnectAttempts;nn.warn(`SIP WebSocket 断开,第 ${this.reconnectAttempts} 次尝试重连,${o}ms 后重试...`,"sip-client.ts 219"),this.reconnectTimer=setTimeout(()=>{this.reconnect()},o)}else this.reconnectAttempts>=this.maxReconnectAttempts&&(nn.warn(`SIP 重连失败:已达到最大重试次数; reconnectAttempts: ${this.reconnectAttempts}; maxReconnectAttempts: ${this.maxReconnectAttempts}`,"sip-client.ts 228"),console.error("SIP 重连失败:已达到最大重试次数"),fe.emit(He.FAIL_NOTIFICATION,"SIP 重连失败:已达到最大重试次数"));break}default:G.updateIsSipConnected(!1),n="unknown"}(r=this.eventCallback)==null||r.call(this,{type:n})}),this.userAgent.delegate={onInvite:e=>{this.handleIncomingCall(e)}})}async refreshRegister(){if(this.registerer)try{await this.registerer.register(),new Date().toLocaleTimeString()}catch(e){console.error("[SIPClient] REGISTER刷新失败",e)}}async register(){var e,n;if(this.userAgent){this.registerer=new tu(this.userAgent,{expires:120,refreshFrequency:80}),(e=this.registerer)==null||e.stateChange.addListener(r=>{var o;let i;switch(r){case jt.Initial:G.updateDisplayText(Kt.LINKING),i="initial";break;case jt.Registered:G.updateDisplayText(""),i=Ar.WEB_RTC_REGISTERED;break;case jt.Unregistered:i=Ar.WEB_RTC_UNREGISTERED;break;case jt.Terminated:nn.warn(`注册流程已终止,无法再注册(如 UA 停止,或网络不可达);regStatus: ${Ar.WEB_RTC_TERMINATED}`,"sip-client.ts 299"),i=Ar.WEB_RTC_TERMINATED;break;default:i="unknown"}(o=this.eventCallback)==null||o.call(this,{type:i})});try{await this.registerer.register()}catch(r){(n=this.eventCallback)==null||n.call(this,{type:Ar.WEB_RTC_REGISTER_FAILED,data:r})}}}attachRemoteAudio(e){const n=e.sessionDescriptionHandler;if(n){const r=n.peerConnection;if(!r)return;const i=new MediaStream;r.getReceivers().forEach(a=>{a.track&&a.track.kind==="audio"&&i.addTrack(a.track)});let o=document.getElementById("sip-remote-audio");o||(o=document.createElement("audio"),o.id="sip-remote-audio",o.autoplay=!0,o.style.display="none",document.body.appendChild(o)),o.srcObject=i,o.play().catch(a=>{console.error("音频播放失败,需要用户交互触发",a)})}}handleSessionState(e,n,r){e.stateChange.addListener(i=>{switch(i){case he.Established:clearTimeout(this.callTimeoutTimer),this.activeSession=e,this.attachRemoteAudio(e);break;case he.Terminating:break;case he.Terminated:this.activeSession=null,clearTimeout(this.callTimeoutTimer);case he.Establishing:}})}handleIncomingCall(e){this.incomingInvitation=e,this.handleSessionState(e,!1),e.progress({statusCode:180,reasonPhrase:"Ringing"}).catch(n=>console.error("发送 180 失败",n)),G.get("direction")===xn.OUTGOING&&this.answerCall()}async answerCall(){var e;if(!this.incomingInvitation)throw new Error("无来电可接听");Z.autoAnswerTimer&&(clearTimeout(Z.autoAnswerTimer),Z.autoAnswerTimer=null);try{await this.incomingInvitation.accept(),this.activeSession=this.incomingInvitation,this.incomingInvitation=null}catch(n){(e=this.eventCallback)==null||e.call(this,{type:Ar.WEB_RTC_ANSWER_FAILED,data:{detail:n}})}}async rejectInCall(){var e;if(this.incomingInvitation)try{await this.incomingInvitation.reject(),this.incomingInvitation=null,G.updateDirection(null),G.updateIsCalling(!1),clearTimeout(this.callTimeoutTimer)}catch(n){(e=this.eventCallback)==null||e.call(this,{type:"error",data:{message:"拒接失败",detail:n}})}}sendDTMF(e){var r;if(!this.activeSession)throw new Error("当前没有活跃的通话");const n=this.activeSession.sessionDescriptionHandler;n&&typeof n.sendDtmf=="function"?(n.sendDtmf(e),(r=this.eventCallback)==null||r.call(this,{type:Ar.WEB_RTC_SEND_DTMF,data:{tone:e}})):(console.warn("DTMF发送不支持或未初始化"),nn.warn("DTMF发送不支持或未初始化","sip-client.ts 490 sendDTMF"))}async hangup(){if(this.activeSession,this.activeSession){clearTimeout(this.callTimeoutTimer);const e=this.activeSession;if(!e)return;const n=e.state;try{n===he.Established?await e.bye():n===he.Establishing&&(e instanceof v0?await e.cancel():e instanceof eu&&await e.reject()),clearTimeout(this.callTimeoutTimer)}catch(r){nn.error("挂断失败","sip-client.ts 522 hangup"),console.error("挂断失败",r)}finally{this.activeSession=null}}}async rejectOutCall(){this.activeSession instanceof eu&&(await this.activeSession.reject(),this.activeSession=null)}async destroy(){if(this.isManuallyStopped=!0,clearTimeout(this.callTimeoutTimer),this.activeSession&&await this.hangup(),this.registerer){try{await this.registerer.unregister()}catch(e){console.warn("注销失败",e)}this.registerer=null}this.userAgent&&(await this.userAgent.stop(),this.userAgent=null)}async reconnect(){if(!Z.isRtcReconnecting){Z.isRtcReconnecting=!0;try{this.isManuallyStopped=!1,await this.destroy(),await this.start(),this.isOffline=!1,this.reconnectAttempts=0}catch(e){console.error("重连失败",e),Z.isRtcReconnecting=!1}finally{Z.isRtcReconnecting=!1}}}async getNetworkStats(){var e;if(this.activeSession){const n=(e=this.activeSession.sessionDescriptionHandler)==null?void 0:e.peerConnection;if(!n)return null;const r=await n.getStats(),i={};return r.forEach(o=>{o.type==="candidate-pair"&&o.state==="succeeded"&&o.currentRoundTripTime!=null&&(i.rtt=+(1e3*o.currentRoundTripTime).toFixed(2)),o.type==="inbound-rtp"&&o.kind==="audio"&&(i.jitter=+(1e3*o.jitter).toFixed(2),i.packetsLost=o.packetsLost,i.packetsReceived=o.packetsReceived,o.bytesReceived&&o.timestamp&&(i.recvBitrate=+(o.bytesReceived/1024).toFixed(2))),o.type==="outbound-rtp"&&o.kind==="audio"&&(i.packetsSent=o.packetsSent,o.bytesSent&&o.timestamp&&(i.sendBitrate=+(o.bytesSent/1024).toFixed(2))),o.type==="codec"&&o.mimeType&&(i.codec=o.mimeType)}),{...i,rtt:(i==null?void 0:i.rtt)||40}}return{rtt:Z.latency||1}}}class To{static requestPermission(){"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()}static async requestMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(n=>n.kind==="audioinput"&&n.label!=="")?null:await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){return console.warn("获取音频权限失败:",e),null}}static show(e,n,r,i){if("Notification"in window&&Notification.permission==="granted"){const o=new Notification(e,{body:n,tag:`xy-global-notification${new Date().getTime()}`,renotify:!0});o.onclick=()=>{window.focus(),o.close(),r==null||r()},setTimeout(()=>o.close(),1e3*(i||3))}}static async checkMediaPermissions(){try{return(await navigator.mediaDevices.enumerateDevices()).some(e=>e.kind==="audioinput"&&e.label!=="")}catch(e){return console.warn("无法检查设备权限:",e),!1}}}const Fw=[],Vn=["call_number"],gA=["call_number"],kw=["hangup"],Ci=["hold","hangup","mute","transfer","consult","satisfaction","dtmf"],Yc=["hold","hangup","mute","transfer","consult"],Hg=["consult_transfer","conference","consult_retrieve"],Pw=["hangup"],Qw=["hangup"],Os=["answer","reject"],Gi=["hangup","consult","transfer","hold","mute","satisfaction","dtmf"],Gg=["hangup","whisper","force_insert","force_disconnect"],jw=["hangup"],Lw=["hangup","cancel_whisper","force_insert"],Uw=["hangup"],Hw=["hangup"];class ja{constructor(){this.roleData={agentInfo:()=>{var e;if(!((e=Z.agentInfo)!=null&&e.agent_no))throw new Error(JSON.stringify({code:1,msg:"请先登录"}))},requestInfo:e=>{if(!e.data)throw new Error(JSON.stringify({code:1,msg:'Parameter "data" is required'}))},changeDevice:e=>{if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "device" is required'}));const{answer_devices:n}=Z.agentInfo;if(!n.split(",").map(r=>Number(r)).includes(e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},changeState:(e,n)=>{if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "state" is required'}));if(!n)throw new Error(JSON.stringify({code:1,msg:'Parameter "state_name" is required'}));if(e===2&&(n==="通话中"||n==="整理"))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}));if(![1,2].includes(e))throw new Error(JSON.stringify({code:1,msg:"当前状态不支持"}))},setAgentExplicit:e=>{const{out_display_select_switch:n,out_display_data:r}=Z.agentInfo;if(n!==1)throw new Error(JSON.stringify({code:1,msg:"当前坐席设置未开启允许指定外显"}));if(!e)throw new Error(JSON.stringify({code:1,msg:'Parameter "number" is required'}));if(!(r||"").split("#").includes(e))throw new Error(JSON.stringify({code:1,msg:"当前外显号码不存在"}))}},this.changeDevice=async e=>{try{if(G.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:n,success:r}=e,{device:i}=n;i===1&&await ja.initRtcFn(),this.roleData.changeDevice(i);const{agent_no:o}=Z.agentInfo;await(s=>yn(`${Or}/device/change`,s))({agent_no:o,answer_device:i}),G.updateAnswerDevice(i);const a=G.get("actionConfigs");G.updateActionConfigs(a),i===2&&Z.stateObject.state===Rt.UNREGISTERED&&await this._changeState({data:{...Z.stateBeforeChange,state_name:Z.stateBeforeChange.state===Rt.IDLE?"空闲":"忙碌"}},"q"),r==null||r({code:0,msg:"请求成功"})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}}formatDate(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`}static setInitRtcFn(e){this.initRtcFn=e}async _agentLogin(e){try{const r=await(n={agent_no:e},yn(`${Or}/agent/login`,n));Z.agentInfo=r.data}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}var n}async _changeState(e,n){try{Z.autoStateTimer&&(clearTimeout(Z.autoStateTimer),Z.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:r,success:i}=e,{state:o,state_name:a}=r,{agent_no:s}=Z.agentInfo;await Ug({agent_no:s,state_name:a,state:o},n),o===Rt.IDLE?G.updateActionConfigs(Vn):o===Rt.BUSY&&G.updateActionConfigs(gA),Z.stateObject={state:o,state_name:a},i==null||i({code:0,msg:"请求成功"})}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async _getInCallCrmDetail(e){var n;try{const{phone:r}=e.data,i={};iu(r)?i.trace_id=r:i.phone=r.replace(/[\s\r\n-]+/g,"");const o=await(a=>yn(`${Yi}/crm/popups`,a))({...i});(n=e.success)==null||n.call(e,o)}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async changeState(e,n){try{if(G.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前正在通话中,请勿切换设备"}));Z.autoStateTimer&&(clearTimeout(Z.autoStateTimer),Z.autoStateTimer=null),this.roleData.agentInfo(),this.roleData.requestInfo(e);const{data:r,success:i}=e,{state:o,state_name:a}=r;this.roleData.changeState(o,a);const{agent_no:s}=Z.agentInfo;await Ug({agent_no:s,state_name:a,state:o},n),(Z.stateObject.state===Rt.IDLE||Z.stateObject.state===Rt.BUSY&&a!=="整理")&&(Z.stateBeforeChange=Z.stateObject),o===Rt.IDLE?G.updateActionConfigs(Vn):o===Rt.BUSY&&G.updateActionConfigs(gA),Z.stateObject={state:o,state_name:a},i==null||i({code:0,msg:"请求成功"})}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async getIdleAgentList(e){var r;const{agent_no:n}=Z.agentInfo;try{this.roleData.agentInfo();const i=await(o=>yn(`${Or}/agent/free`,o))({agent_no:n});(r=e.success)==null||r.call(e,i)}catch(i){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(i.message).msg),i}}async getAgentState(e){var n;try{const r=await yn(`${Yi}/agent/statecfg/list`,{}),i=(r.data||[]).filter(o=>o.enable===0).filter(o=>o.state!==0&&o.state!==3).filter(o=>o.state_name!=="通话中"&&o.state_name!=="整理"&&o.state_name!=="未注册"&&o.state_name!=="离线接听").map(o=>({state:o.state,state_name:o.state_name})).reverse();(n=e.success)==null||n.call(e,{...r,data:i})}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async setAgentExplicit(e){var n;try{this.roleData.agentInfo(),this.roleData.requestInfo(e),this.roleData.setAgentExplicit(e.data.number);const{agent_id:r}=Z.agentInfo;await(i=>yn(`${Yi}/agent/update`,i))({agent_id:r,out_display_number:e.data.number}),G.updateSelectOutNumber(e.data.number),(n=e.success)==null||n.call(e,{code:0,msg:"请求成功"})}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async checkAgentLogin(e){var n;try{this.roleData.requestInfo(e);const{agent_no:r}=e.data;if(!r)throw new Error(JSON.stringify({code:1,msg:'Parameter "agent_no" is required'}));const i=await(o=>yn(`${Or}/agent/islogin`,o))({agent_no:r});(n=e.success)==null||n.call(e,i)}catch(r){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(r.message).msg),r}}async getCallRecord(e){try{this.roleData.agentInfo();const{success:n}=e,r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate(),0,0,0),o=new Date(r.getFullYear(),r.getMonth(),r.getDate(),23,59,59),a=[this.formatDate(i),this.formatDate(o)],{agent_no:s}=Z.agentInfo,A=await(f=>yn(`${Yi}/agent/recordpage`,f))({start_time:a[0],end_time:a[1],page_no:1,page_size:10,agent_no:s}),{code:c,msg:u,data:d}=A;n==null||n({code:c,msg:u,data:d})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async logout(e){this.roleData.agentInfo();try{const{agent_no:n}=Z.agentInfo,{data:r,success:i}=e;await(o=>yn(`${Or}/agent/logout`,o))({...r,agent_no:n}),i==null||i({code:0,msg:""})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async listenCall(e){try{const{agent_no:n}=Z.agentInfo,{data:r,success:i}=e;if(this.roleData.agentInfo(),this.roleData.requestInfo(e),!r.monitored_agent_no)throw new Error(JSON.stringify({code:1,msg:'Parameter "monitored_agent_no" is required'}));await(o=>yn(`${Or}/call/monitor`,o))({...r,monitor_agent_no:n}),Z.monitoredAgentNo=r.monitored_agent_no,i==null||i({code:0,msg:""})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async earCall(e){try{const{agentInfo:n,monitoredAgentNo:r}=Z,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(a=>yn(`${Or}/call/whisper`,a))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async stopEarCall(e){try{const{agentInfo:n,earSpeakAgent:r}=Z;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前没有正在耳语的坐席"}));const{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;await(a=>yn(`${Or}/call/stopwhisper`,a))({monitor_agent_no:i,monitored_agent_no:r}),o==null||o({code:0,msg:""})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async forceInsert(e){try{const{agentInfo:n,monitoredAgentNo:r}=Z,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(a=>yn(`${Or}/call/bargein`,a))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}async forceDisconnect(e){try{const{agentInfo:n,monitoredAgentNo:r}=Z,{agent_no:i}=n;this.roleData.agentInfo();const{success:o}=e;if(!r)throw new Error(JSON.stringify({code:1,msg:"当前未有监听坐席"}));await(a=>yn(`${Or}/call/intercept`,a))({monitored_agent_no:r,monitor_agent_no:i}),o==null||o({code:0,msg:""})}catch(n){throw fe.emit(He.FAIL_NOTIFICATION,JSON.parse(n.message).msg),n}}}const Gw=console.log,qg=(...t)=>{Z.logBuiltinEnabled&&Gw(...t)};let ni=null;class An{constructor(e,n){this.url=e,this.onOpenCallback=n,this.ws=null,this.heartbeatWorker=null,this.reconnectDelay=3e3,this.manualClose=!1,this.apiClient=new ja,this.sipClient=null,this.pendingMessages=new Map,this.initWebSocket()}static getInstance({url:e,sipClient:n,onOpen:r}){if(!ni){if(!e)throw new Error("WebSocket 尚未初始化");ni=new An(e,r),ni.sipClient=n}return ni}setSipClient(e){this.sipClient=e}stateIdleChange(e){const{state:n}=Z.stateObject;n!==Rt.IDLE&&this.apiClient._changeState({data:{...Z.stateBeforeChange,state_name:Z.stateBeforeChange.state===Rt.IDLE?"空闲":"忙碌"}},e)}inCallAutoAnswer(){const{soft_device_auto_answer:e,auto_answer_time:n}=Z.agentInfo,r=e===1,i=G.get("direction");if(r&&i===xn.INCOMING){const o=Number(n)||0;o>0&&(Z.autoAnswerTimer=setTimeout(()=>{var a;(a=this.sipClient)==null||a.answerCall(),Z.autoAnswerTimer=null},o>0?1e3*o-500:0))}}async getCustomerInfo(e,n){try{await this.apiClient._getInCallCrmDetail({data:{phone:e},success:r=>{const i=r.data?{...r.data,type:n,session_id:Z.sessionId}:{phone:r.data.phone,is_vip:0,customer_name:"未知客户",city:"未知",province:"未知",contact_count:0,in_contact_count:0,trace_id:r.data.trace_id,contact_count_month:0,in_contact_count_month:0,session_id:Z.sessionId,type:n};G.updateCustomerInfo(i)}})}catch{}}putAgentState(e,n){if(!e)return;if(n===5)return void this.stateIdleChange("device_type5");Z.sessionId="";const{post_call_process_time:r}=Z.agentInfo,i=r||0;if(Z.autoStateTimer&&(clearTimeout(Z.autoStateTimer),Z.autoStateTimer=null),G.updateCustomerInfo(void 0),i>0){const{state:o}=Z.stateObject;if(o===Rt.IDLE)return;this.apiClient._changeState({data:{state:Rt.BUSY,state_name:"整理"}},"ez"),Z.autoStateTimer=setTimeout(()=>{Z.autoStateTimer=null,this.stateIdleChange(`delay${i}`)},1e3*i)}else this.stateIdleChange("delay0")}stateBusyChange(){Z.sessionId="",clearTimeout(Z.autoStateTimer),G.updateCustomerInfo(void 0),this.apiClient._changeState({data:{state:Rt.BUSY,state_name:"忙碌"}},"dm")}initWebSocket(){var n;if(((n=this.ws)==null?void 0:n.readyState)===1||!G.get("isNextState")||this.manualClose)return;const e=P0(Kd,Vd);this.ws=new WebSocket(this.url+e),this.ws.onopen=()=>{const r=new Date().getTime();this.sendMessage({type:0,msg_id:r}),this.pendingMessages.set(r,performance.now()),this.startHeartbeat(),this.manualClose=!1,this.onOpenCallback&&this.onOpenCallback()},this.ws.onmessage=async r=>{var u;const i=JSON.parse(r.data),{type:o,data:a,code:s,msg:A,msg_id:c}=i;if(o===0&&c){const d=this.pendingMessages.get(c),f=performance.now()-d;Z.latency=parseFloat(f.toFixed(2)),this.pendingMessages.delete(c)}if(o!==0&&qg("%cWebSocket 收到消息:","color: blue; font-weight: bold;",i),o!==it.OUT_CALL&&o!==it.PREVIEW_OUT_CALL||(Z.isAgentHangup=!1,s!==0?(G.reset(),fe.emit(ie.OUT_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A),G.updateActionConfigs(Vn),setTimeout(()=>{G.updateCustomerInfo(void 0)},500),this.stateIdleChange("h")):s===0&&(fe.emit(ie.OUT_SUCCESS),Z.sessionId=a.session_id,G.updateIsCalling(!0),clearTimeout(Z.autoStateTimer))),o===it.AGENT_STATE){const{state:d,state_name:f}=a;Z.stateObject={state:d,state_name:f},(u=Z.stateBeforeChange)!=null&&u.state||Z.stateObject.state!==Rt.IDLE&&(Z.stateObject.state!==Rt.BUSY||f==="整理")||(Z.stateBeforeChange=Z.stateObject),f==="振铃中"&&G.updateDisplayText(Kt.AGENT_RINGING);const p=G.get("isCalling");d!==Rt.UNREGISTERED||p||G.updateActionConfigs(Fw),d===Rt.IDLE&&Z.stateObject.state===Rt.UNREGISTERED&&G.updateActionConfigs(Vn),fe.emit(ie.AGENT_STATE,{state:d,state_name:f})}else if(o===it.OUT_CALL_INCOMING_CALL)Z.isAgentHangup=!1,a.preview_task_id?(this.getCustomerInfo(a.trace_id||a.customer_phone,"preview_out_incoming_call"),fe.emit(ie.PREVIEW_OUT_INCOMING_CALL,{customer_phone:a.customer_phone,session_id:a.session_id,preview_task_id:a.preview_task_id,trace_id:a.trace_id})):a.direction===0?(this.getCustomerInfo(a.trace_id||a.customer_phone,"out_call_incoming_call"),fe.emit(ie.OUT_INCOMING_CALL,{customer_phone:a.customer_phone,session_id:a.session_id,trace_id:a.trace_id})):a.direction===8&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"internal_out_incoming_call"),fe.emit(ie.INTERNAL_OUT_INCOMING_CALL,{customer_phone:a.customer_phone,session_id:a.session_id,trace_id:a.trace_id})),Z.sessionId=a.session_id,G.updateActionConfigs(kw,a.direction!==8);else if(o===it.OUT_CALL_END){if(Z.sessionId!==a.session_id)return;if(G.updateDisplayText(""),a.device_type===1&&a.agent_no===Z.agentInfo.agent_no)G.reset(),fe.emit(ie.OUT_HANGUP,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),G.updateActionConfigs(Vn),this.putAgentState(!0);else if(a.device_type===2&&a.agent_no===Z.agentInfo.agent_no)G.reset(),fe.emit(ie.OUR_SIDE_CONSULT_HANGUP,{session_id:a.session_id}),G.updateActionConfigs(Vn),this.putAgentState(!0);else if(a.device_type===2&&a.agent_no!==Z.agentInfo.agent_no)G.get("isCalling")&&(G.updateDisplayText(Kt.CALLING),fe.emit(ie.OTHER_SIDE_CONSULT_HANGUP,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),G.updateActionConfigs(Ci));else if(a.device_type===3&&a.agent_no===Z.agentInfo.agent_no)G.reset(),fe.emit(ie.THREE_WAY_OUR_SIDE_HANGUP,{session_id:a.session_id}),G.updateActionConfigs(Vn),this.putAgentState(!0);else if(a.device_type===4&&a.agent_no===Z.agentInfo.agent_no)G.reset(),fe.emit(ie.TRANSFER_END,{session_id:a.session_id}),G.updateActionConfigs(Vn),this.putAgentState(!0);else if(a.device_type===4&&a.agent_no!==Z.agentInfo.agent_no){fe.emit(ie.TRANSFER_FAILED,"未知原因"),fe.emit(He.FAIL_NOTIFICATION,"转接失败");const d=G.get("direction");d===xn.OUTGOING?G.updateActionConfigs(Ci):d===xn.INCOMING&&G.updateActionConfigs(Gi)}else a.device_type===5&&a.agent_no===Z.agentInfo.agent_no&&(Z.monitoredAgentNo="",Z.earSpeakAgent="",G.reset(),fe.emit(ie.LISTEN_HANGUP,{session_id:a.session_id}),G.updateActionConfigs(Vn),this.putAgentState(!0,5))}else if(o===it.OUT_CALL_RINGING)a.type===1&&(Z.isAgentHangup=!1,fe.emit(ie.OUT_RINGING,{session_id:Z.sessionId,type:a.type}),G.updateDisplayText(Kt.RINGING));else if(o===it.OUT_CALL_ANSWER)Z.isAgentHangup=!1,clearTimeout(Z.autoStateTimer),G.updateIsCalling(!0),G.updateOutCallIsAnswer(!0),G.updateDisplayText(Kt.CALLING),a.direction===8?(fe.emit(ie.INTERNAL_OUT_OFF_ANSWER,{session_id:Z.sessionId}),G.updateActionConfigs(Yc)):(fe.emit(ie.OUT_OFF_ANSWER,{session_id:Z.sessionId}),G.updateActionConfigs(Ci));else if(o===it.CONSULT_RINGING)Z.isAgentHangup=!1,fe.emit(ie.CONSULT_RINGING,{session_id:a.session_id}),G.updateDisplayText(Kt.AGENT_RINGING),G.updateActionConfigs([]),clearTimeout(Z.autoStateTimer);else if(o===it.CONSULT_ANSWER)Z.isAgentHangup=!1,fe.emit(ie.CONSULT_OFF_HOOK,{session_id:a.session_id}),G.updateConsultIsAnswer(!0),G.updateDisplayText(Kt.CONSULTING),G.updateActionConfigs(Hg);else if(o===it.CONSULT_FAIL)fe.emit(ie.CONSULT_FAILED,{custom_reason:a.custom_reason}),G.updateDisplayText(Kt.CALLING),G.updateActionConfigs(Ci);else if(o===it.CONSULT_CALL_IN)Z.isAgentHangup=!1,fe.emit(ie.CONSULT_INCOMING,{agent_no:a.agent_no,agent_mane:a.agent_name,session_id:a.session_id}),Z.sessionId=a.session_id,G.updateIsCalling(!0),G.updateDirection(xn.CONSULT),G.updateDisplayText(Kt.CONSULT_CALL_IN),G.updateActionConfigs(Os),Z.enableBrowserAlert&&To.show("📞 咨询来电",`坐席 [${a.agent_name}] 正在咨询...`,()=>{fe.emit(He.NOTIFICATION_CLICK,{agent_mane:a.agent_name,agent_no:a.agent_no})},Z.browserAlertTime);else if(o===it.CONSULT_CALL_IN_SUCCESS)fe.emit(ie.CONSULT_CALL_IN_SUCCESS,{session_id:a.session_id}),G.updateConsultIsAnswer(!0),G.updateDisplayText(Kt.CALLING),G.updateActionConfigs(Pw);else if(o===it.CONSULT_RETURN_CALL_SUCCESS)a.status==="success"?(G.updateConsultIsAnswer(!1),fe.emit(ie.CONSULT_RETURN_CALL_SUCCESS),G.updateDisplayText(Kt.CALLING),fe.emit(ie.OTHER_SIDE_CONSULT_HANGUP),G.updateActionConfigs(Ci)):fe.emit(He.FAIL_NOTIFICATION,"媒体失败");else if(o===it.MUTE)s===0?(G.updateIsMuted(!0),fe.emit(ie.MUTE_SUCCESS),G.updateDisplayText(Kt.MUTING)):(fe.emit(ie.MUTE_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A));else if(o===it.UNMUTE)s===0?(G.updateIsMuted(!1),fe.emit(ie.UNMUTE_SUCCESS),G.updateDisplayText(Kt.CALLING)):(fe.emit(ie.UNMUTE_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A));else if(o===it.CALL_HOLD)s===0?(G.updateIsHold(!0),G.updateDisplayText(Kt.HOLDING),fe.emit(ie.HOLD_SUCCESS)):(fe.emit(ie.HOLD_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A));else if(o===it.CALL_UNHOLD)s===0?(G.updateDisplayText(Kt.CALLING),G.updateIsHold(!1),fe.emit(ie.UNHOLD_SUCCESS)):(fe.emit(ie.UNHOLD_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A));else if(o===it.CONSULT_TRANSFER)Z.isAgentHangup=!1,s===0?fe.emit(ie.CONSULT_TRANSFER_SUCCESS):(fe.emit(ie.CONSULT_TRANSFER_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A));else if(o===it.CONSULT_TRANSFER_FAILED)fe.emit(ie.CONSULT_TRANSFER_FAILED,a.status);else if(o===it.CONSULT_TRANSFER_OFF_HOOK)G.updateDirection(xn.INCOMING),G.updateDisplayText(Kt.CALLING),fe.emit(ie.CONSULT_TRANSFER_OFF_HOOK),G.updateActionConfigs(Gi),G.updateIncomingIsAnswer(!0),G.updateConsultIsAnswer(!1);else if(o===it.INCOMING_CALL)Z.isAgentHangup=!1,clearTimeout(Z.autoStateTimer),Z.sessionId=a.session_id,G.updateIsCalling(!0),G.updateDirection(xn.INCOMING),G.updateDisplayText(Kt.INCOMING_CALL),this.inCallAutoAnswer(),a.direction!==1&&a.direction!==4&&a.direction!==7||(this.getCustomerInfo(a.trace_id||a.customer_phone,"incoming_call"),fe.emit(ie.INCOMING_CALL,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),a.direction===8&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"incoming_call_in"),fe.emit(ie.INCOMING_CALL_IN,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),a.direction===3&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"predict_incoming_call"),fe.emit(ie.PREDICT_INCOMING_CALL,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),a.direction===6&&(this.getCustomerInfo(a.trace_id||a.customer_phone,"dual_call_incoming_call"),fe.emit(ie.DUAL_CALL_INCOMING_CALL,{customer_phone:a.customer_phone,trace_id:a.trace_id,session_id:a.session_id})),G.updateActionConfigs(Os),Z.enableBrowserAlert&&To.show("📞 客户来电",`客户 [${a.customer_phone}] 正在呼入...`,()=>{fe.emit(He.NOTIFICATION_CLICK,{customer_phone:a.customer_phone})},Z.browserAlertTime);else if(o===it.INCOMING_CALL_OFF_HOOK)G.updateIncomingIsAnswer(!0),a.direction===8?(G.updateActionConfigs(Yc),fe.emit(ie.INCOMING_CALL_IN_OFF_HOOK,{session_id:Z.sessionId})):(G.updateActionConfigs(Gi),fe.emit(ie.INCOMING_CALL_OFF_HOOK,{session_id:Z.sessionId})),G.updateDisplayText(Kt.CALLING);else if(o===it.INCOMING_CALL_END){if(Z.sessionId!==a.session_id)return;if(G.updateDisplayText(""),a.device_type!==1&&a.device_type!==7||a.agent_no!==Z.agentInfo.agent_no)if(a.device_type===2&&a.agent_no===Z.agentInfo.agent_no)G.reset(),fe.emit(ie.OUR_SIDE_CONSULT_HANGUP,{session_id:a.session_id}),this.putAgentState(!0),G.updateActionConfigs(Vn);else if(a.device_type===2&&a.agent_no!==Z.agentInfo.agent_no)G.updateDisplayText(Kt.CALLING),fe.emit(ie.OTHER_SIDE_CONSULT_HANGUP,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),G.updateActionConfigs(Ci);else if(a.device_type===3&&a.agent_no===Z.agentInfo.agent_no)this.putAgentState(!0),G.reset(),fe.emit(ie.THREE_WAY_OUR_SIDE_HANGUP,{session_id:a.session_id}),G.updateActionConfigs(Vn);else if(a.device_type===4&&a.agent_no===Z.agentInfo.agent_no)this.putAgentState(!0),G.reset(),fe.emit(ie.TRANSFER_END,{session_id:a.session_id}),G.updateActionConfigs(Vn);else if(a.device_type===4&&a.agent_no!==Z.agentInfo.agent_no){fe.emit(ie.TRANSFER_FAILED,"未知原因"),fe.emit(He.FAIL_NOTIFICATION,"转接失败");const d=G.get("direction");d===xn.OUTGOING?G.updateActionConfigs(Ci):d===xn.INCOMING&&G.updateActionConfigs(Gi)}else a.device_type===5&&a.agent_no===Z.agentInfo.agent_no&&(this.putAgentState(!0,5),Z.monitoredAgentNo="",Z.earSpeakAgent="",G.reset(),fe.emit(ie.LISTEN_HANGUP,{session_id:a.session_id}),G.updateActionConfigs(Vn));else this.putAgentState(!0),G.reset(),fe.emit(ie.INCOMING_CALL_END,{session_id:a.session_id,isAgentHangup:Z.isAgentHangup}),G.updateActionConfigs(Vn)}else if(o===it.SATISFACTION_EVALUATION)s===0?fe.emit(ie.SATISFACTION_EVALUATION_SUCCESS):(fe.emit(ie.SATISFACTION_EVALUATION_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A));else if(o===it.CONSULT_THREE_WAY)s!==0?(fe.emit(ie.CONSULT_THREE_WAY_FAILED,A),fe.emit(He.FAIL_NOTIFICATION,A)):s===0&&G.updateIsMeeting(!0);else if(o===it.CONSULT_THREE_WAY_RESULT)a.status==="success"?(G.updateDirection(xn.MEETING),G.updateDisplayText(Kt.MEETING),G.updateActionConfigs(Qw),fe.emit(ie.CONSULT_THREE_WAY_SUCCESS)):(fe.emit(ie.CONSULT_THREE_WAY_FAILED,{conf_name:a.conf_name}),G.updateIsMeeting(!1));else if(o===it.TRANSFER_INCOMING_CALL)Z.isAgentHangup=!1,clearTimeout(Z.autoStateTimer),a.agent_no===Z.agentInfo.agent_no?(G.updateDisplayText(Kt.TRANSFERRING),fe.emit(ie.TRANSFER_PROGRESS),G.updateActionConfigs([]),G.updateTransferIsAnswer(!0)):(Z.sessionId=a.session_id,fe.emit(ie.TRANSFER_INCOMING_CALL,{agent_no:a.agent_no,agent_name:a.agent_name,session_id:a.session_id}),G.updateIsCalling(!0),G.updateDirection(xn.TRANSFER),G.updateDisplayText(Kt.TRANSFER_INCOMING_CALL),G.updateActionConfigs(Os),Z.enableBrowserAlert&&To.show("📞 转接来电",`坐席 [${a.agent_no}] 正在转接...`,()=>{fe.emit(He.NOTIFICATION_CLICK,{agent_no:a.agent_no})},Z.browserAlertTime));else if(o===it.TRANSFER_OFF_HOOK)fe.emit(ie.TRANSFER_OFF_HOOK,{session_id:Z.sessionId}),G.updateTransferIsAnswer(!1),G.updateDisplayText(Kt.CALLING),G.updateActionConfigs(Gi,a.direction!==8);else if(o===it.TRANSFER_FAILED){if(a.status==="failed"){fe.emit(ie.TRANSFER_FAILED,"未知原因"),fe.emit(He.FAIL_NOTIFICATION,"转接失败");const d=G.get("direction");d===xn.OUTGOING?G.updateActionConfigs(Ci):d===xn.INCOMING&&G.updateActionConfigs(Gi)}}else o===it.KICK_OFFLINE?fe.emit(He.KICK_OFF):o===it.CONTINUOUS_NOT_ANSWER?(fe.emit(He.FAIL_NOTIFICATION,`已连续 ${a.miss_count} 次未接, 设置忙碌`),this.stateBusyChange()):o===it.SIGN_OUT?fe.emit(He.SIGN_OUT):o===it.SIGN_IN_SWITCH_DEVICE?fe.emit(He.SIGN_IN_SWITCH_DEVICE,a):o===it.LISTEN_INCOMING_CALL?(clearTimeout(Z.autoStateTimer),Z.sessionId=a.session_id,G.updateIsCalling(!0),G.updateDirection(xn.INCOMING),this.inCallAutoAnswer(),G.updateDisplayText(Kt.LISTENING),G.updateActionConfigs(Os),fe.emit(ie.LISTEN_INCOMING_CALL,{session_id:a.session_id}),Z.enableBrowserAlert&&To.show("📞 监听来电","正在来电...",()=>{fe.emit(He.NOTIFICATION_CLICK,{customer_phone:a.customer_phone})},Z.browserAlertTime)):o===it.LISTEN_INCOMING_CALL_OFF_HOOK?(Z.monitoredAgentNo=a.monitored_agent_no,Z.earSpeakAgent="",G.updateIncomingIsAnswer(!0),fe.emit(ie.LISTEN_INCOMING_CALL_OFF_HOOK,{session_id:Z.sessionId,monitored_agent_no:a.monitored_agent_no}),G.updateActionConfigs(Gg),G.updateDisplayText(Kt.CALLING)):o===it.LISTEN_CALL_FAILED?a.status==="failed"&&(fe.emit(ie.LISTEN_CALL_FAILED),Z.monitoredAgentNo=""):o===it.EAR_SPEECH?a.status==="success"?(a.monitored_agent_no===Z.agentInfo.agent_no&&(G.updateActionConfigs(jw),fe.emit(ie.EAR_SPEECH_BE_SUCCESS)),a.monitor_agent_no===Z.agentInfo.agent_no&&(G.updateActionConfigs(Lw),fe.emit(ie.EAR_SPEECH_SUCCESS,{monitored_agent_no:a.monitored_agent_no,monitor_agent_no:a.monitor_agent_no}),Z.earSpeakAgent=a.monitored_agent_no)):fe.emit(ie.EAR_SPEECH_FAILED):o===it.STOP_EAR_SPEECH?a.status==="success"?(a.monitored_agent_no===Z.agentInfo.agent_no&&G.updateActionConfigs(Gi),a.monitor_agent_no===Z.agentInfo.agent_no&&G.updateActionConfigs(Gg),Z.earSpeakAgent="",fe.emit(ie.STOP_EAR_SPEECH_SUCCESS)):fe.emit(ie.STOP_EAR_SPEECH_FAILED):o===it.CALL_FORCE_INSERT?a.status==="success"?(a.monitored_agent_no===Z.agentInfo.agent_no&&(G.updateActionConfigs(Hw),fe.emit(ie.CALL_FORCE_INSERT_SUCCESS,{monitored_agent_no:a.monitored_agent_no,monitor_agent_no:a.monitor_agent_no})),a.monitor_agent_no===Z.agentInfo.agent_no&&(G.updateActionConfigs(Uw),fe.emit(ie.CALL_FORCE_INSERT_SUCCESS_LISTENER,{monitored_agent_no:a.monitored_agent_no,monitor_agent_no:a.monitor_agent_no}))):fe.emit(ie.CALL_FORCE_INSERT_FAILED):o===it.INTERNAL_CALL_START_CONSULT?a.agent_no===Z.agentInfo.agent_no?(G.updateConsultIsAnswer(!0),G.updateActionConfigs(Hg),G.updateDisplayText(Kt.CONSULTING)):(G.updateDisplayText(Kt.OTHER_SIDE_CONSULTING),G.updateActionConfigs([])):o===it.INTERNAL_CALL_END_CONSULT?(G.updateActionConfigs(Yc),G.updateDisplayText(""),G.updateConsultIsAnswer(!1)):o===it.CALL_SIP_INCOMING_CALL&&fe.emit(ie.CALL_SIP_INCOMING_CALL)},this.ws.onclose=r=>{fe.emit(He.FAIL_NOTIFICATION,"链接已断开,请检查网络"),this.stopHeartbeat();const i=G.get("isNextState");!this.manualClose&&i&&setTimeout(()=>this.initWebSocket(),this.reconnectDelay)},this.ws.onerror=r=>{var i;fe.emit(He.FAIL_NOTIFICATION,"连接失败,请检查网络"),(i=this.ws)==null||i.close()}}startHeartbeat(){const e=new Blob([`
|
|
164
164
|
let timer;
|
|
165
165
|
self.onmessage = function (e) {
|
|
166
166
|
if (e.data === 'start') {
|
|
@@ -683,7 +683,7 @@ html body {
|
|
|
683
683
|
&:hover {
|
|
684
684
|
opacity: 0.9;
|
|
685
685
|
}
|
|
686
|
-
`;function bN({title:t,content:e,icon:n,onOk:r,onCancel:i}){const o=document.createElement("div");document.body.appendChild(o);const a=hN.createRoot(o),s=()=>{a.unmount(),o.remove()},A=async()=>{r&&await r(),s()},c=()=>{i==null||i(),s()};a.render(ae.jsx(pN,{children:ae.jsxs(mN,{children:[ae.jsxs(vN,{children:[n&&ae.jsx(CN,{children:n}),t]}),ae.jsx(yN,{children:e}),ae.jsxs(EN,{children:[ae.jsx(Ym,{onClick:c,children:"取消"}),ae.jsx(Ym,{primary:!0,onClick:A,children:"确定"})]})]})}))}const SN={1:ae.jsx(vt,{name:"ruandianhua"}),2:ae.jsx(vt,{name:"pnhone"}),3:ae.jsx(vt,{name:"sip-phone"})},wN={call_number:"",answer:"接听",reject:"拒接",hangup:"挂机",dtmf:"DTMF",unhold:"取消保持",hold:"保持",mute:"静音",unmute:"取消静音",satisfaction:"满意度",consult:"咨询",consult_transfer:"咨询转接",consult_retrieve:"取回通话",conference:"三方会议",whisper:"耳语",cancel_whisper:"取消耳语",force_insert:"强插",force_disconnect:"强拆",transfer:"转接"},IN={空闲:1,离线:0,未注册:4},xN=N.lazy(()=>Promise.resolve().then(()=>require("./ConsultModel-
|
|
686
|
+
`;function bN({title:t,content:e,icon:n,onOk:r,onCancel:i}){const o=document.createElement("div");document.body.appendChild(o);const a=hN.createRoot(o),s=()=>{a.unmount(),o.remove()},A=async()=>{r&&await r(),s()},c=()=>{i==null||i(),s()};a.render(ae.jsx(pN,{children:ae.jsxs(mN,{children:[ae.jsxs(vN,{children:[n&&ae.jsx(CN,{children:n}),t]}),ae.jsx(yN,{children:e}),ae.jsxs(EN,{children:[ae.jsx(Ym,{onClick:c,children:"取消"}),ae.jsx(Ym,{primary:!0,onClick:A,children:"确定"})]})]})}))}const SN={1:ae.jsx(vt,{name:"ruandianhua"}),2:ae.jsx(vt,{name:"pnhone"}),3:ae.jsx(vt,{name:"sip-phone"})},wN={call_number:"",answer:"接听",reject:"拒接",hangup:"挂机",dtmf:"DTMF",unhold:"取消保持",hold:"保持",mute:"静音",unmute:"取消静音",satisfaction:"满意度",consult:"咨询",consult_transfer:"咨询转接",consult_retrieve:"取回通话",conference:"三方会议",whisper:"耳语",cancel_whisper:"取消耳语",force_insert:"强插",force_disconnect:"强拆",transfer:"转接"},IN={空闲:1,离线:0,未注册:4},xN=N.lazy(()=>Promise.resolve().then(()=>require("./ConsultModel-SOPfzVzm.js"))),RN=N.lazy(()=>Promise.resolve().then(()=>require("./TransferModel-DvJoGCCU.js"))),Cl=on.div`
|
|
687
687
|
width: 25px;
|
|
688
688
|
height: 25px;
|
|
689
689
|
background: ${({bg:t})=>t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-Dh83b1rK.js");exports.YsytAgentLogout=e.agentLogout;exports.YsytCallForceInsert=e.callForceInsert;exports.YsytCallForceSplit=e.callForceSplit;exports.YsytGetCustomerInfo=e.getCustomerInfo;exports.YsytListenCall=e.listenCall;exports.YsytMakeCall=e.makeCall;exports.YsytPreviewMakeCall=e.previewMakeCall;exports.YsytSetAgentDevice=e.setAgentDevice;exports.YsytSetAgentInitState=e.setAgentInitState;exports.YsytStartEarSpeak=e.startEarSpeak;exports.YsytStopEarSpeak=e.stopEarSpeak;exports.default=e.YsytBarPhone;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ak as s, ap as e, aq as l, ah as y, am as Y, ag as o, al as r, aj as n, ai as S, an as i, ao as p, af as C } from "./index-
|
|
1
|
+
import { ak as s, ap as e, aq as l, ah as y, am as Y, ag as o, al as r, aj as n, ai as S, an as i, ao as p, af as C } from "./index-B1H13oYF.mjs";
|
|
2
2
|
export {
|
|
3
3
|
s as YsytAgentLogout,
|
|
4
4
|
e as YsytCallForceInsert,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ysyt-react-agent-lib",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.30",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/ysyt-react-agent-lib.cjs.js",
|
|
6
6
|
"module": "dist/ysyt-react-agent-lib.es.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"antd": "5.24.0",
|
|
31
31
|
"styled-components": "^6.1.13",
|
|
32
|
-
"ysyt-agent-sdk": "2.0.
|
|
32
|
+
"ysyt-agent-sdk": "2.0.41"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^18.2.0",
|