ysyt-react-agent-lib 1.1.42 → 1.1.43
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-i3tgl_SQ.js → ConsultModel-KWliYdNQ.js} +1 -1
- package/dist/{ConsultModel-kDJw0dvO.mjs → ConsultModel-rL9vGgyX.mjs} +2 -2
- package/dist/{TransferModel-CyGd40QQ.js → TransferModel-DWgaLD4j.js} +1 -1
- package/dist/{TransferModel-C9aTmib-.mjs → TransferModel-m1Yafzwi.mjs} +2 -2
- package/dist/{index-B78EP7gK.js → index-BExtS83M.js} +1 -1
- package/dist/{index-BnYgsumA.mjs → index-CBAtqjfM.mjs} +1 -1
- package/dist/{index-DUaupCyH.js → index-CRDYYTnZ.js} +3 -3
- package/dist/{index-BKZeqy-s.mjs → index-D4OJU0JW.mjs} +7 -7
- 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 +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-CRDYYTnZ.js"),s=require("react"),i=require("./index-BExtS83M.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 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-D4OJU0JW.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-CBAtqjfM.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-CRDYYTnZ.js"),t=require("react"),l=require("./index-BExtS83M.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;
|
|
@@ -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-D4OJU0JW.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-CBAtqjfM.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,4 +1,4 @@
|
|
|
1
|
-
"use strict";const b=require("react"),a=require("./index-
|
|
1
|
+
"use strict";const b=require("react"),a=require("./index-CRDYYTnZ.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`]:{[`
|
|
@@ -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-D4OJU0JW.mjs";
|
|
4
4
|
const bn = new Ne("antFadeIn", {
|
|
5
5
|
"0%": {
|
|
6
6
|
opacity: 0
|
|
@@ -152,7 +152,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
152
152
|
`+r+`
|
|
153
153
|
`);if(this.state===de.Connected){if(this.onMessage)try{this.onMessage(r)}catch(i){throw this.logger.error(i.toString()),this.logger.error("Exception thrown by onMessage callback"),i}}else this.logger.warn("Received message while not connected, discarding...")}else this.logger.warn("Received empty message, discarding...")}onWebSocketOpen(A,t){t===this._ws&&this._state===de.Connecting&&(this.logger.log(`WebSocket opened ${this.server}`),this.transitionState(de.Connected))}transitionLoopDetectedError(A){let t="A state transition loop has been detected.";return t+=` An attempt to transition from ${this._state} to ${A} before the prior transition completed.`,t+=" Perhaps you are synchronously calling connect() or disconnect() from a callback or state change handler?",this.logger.error(t),new Uo("Loop detected.")}transitionState(A,t){const n=()=>{throw new Error(`Invalid state transition from ${this._state} to ${A}`)};if(this.transitioningState)throw this.transitionLoopDetectedError(A);switch(this.transitioningState=!0,this._state){case de.Connecting:A!==de.Connected&&A!==de.Disconnecting&&A!==de.Disconnected&&n();break;case de.Connected:A!==de.Disconnecting&&A!==de.Disconnected&&n();break;case de.Disconnecting:A!==de.Connecting&&A!==de.Disconnected&&n();break;case de.Disconnected:A!==de.Connecting&&n();break;default:throw new Error("Unknown state.")}const r=this._state;this._state=A;const i=this.connectResolve,o=this.connectReject;r===de.Connecting&&(this.connectPromise=void 0,this.connectResolve=void 0,this.connectReject=void 0);const a=this.disconnectResolve,s=this.disconnectReject;if(r===de.Disconnecting&&(this.disconnectPromise=void 0,this.disconnectResolve=void 0,this.disconnectReject=void 0),this.connectTimeout&&(clearTimeout(this.connectTimeout),this.connectTimeout=void 0),this.logger.log(`Transitioned from ${r} to ${this._state}`),this._stateEventEmitter.emit(this._state),A===de.Connected&&(this.startSendingKeepAlives(),this.onConnect))try{this.onConnect()}catch(l){throw this.logger.error(l.toString()),this.logger.error("Exception thrown by onConnect callback"),l}if(r===de.Connected&&(this.stopSendingKeepAlives(),this.onDisconnect))try{t?this.onDisconnect(t):this.onDisconnect()}catch(l){throw this.logger.error(l.toString()),this.logger.error("Exception thrown by onDisconnect callback"),l}if(r===de.Connecting){if(!i)throw new Error("Connect resolve undefined.");if(!o)throw new Error("Connect reject undefined.");A===de.Connected?i():o(t||new Error("Connect aborted."))}if(r===de.Disconnecting){if(!a)throw new Error("Disconnect resolve undefined.");if(!s)throw new Error("Disconnect reject undefined.");A===de.Disconnected?a():s(t||new Error("Disconnect aborted."))}this.transitioningState=!1}clearKeepAliveTimeout(){this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveDebounceTimeout=void 0}sendKeepAlive(){return this.keepAliveDebounceTimeout?Promise.resolve():(this.keepAliveDebounceTimeout=setTimeout(()=>{this.clearKeepAliveTimeout()},1e3*this.configuration.keepAliveDebounce),this.send(`\r
|
|
154
154
|
\r
|
|
155
|
-
`))}startSendingKeepAlives(){this.configuration.keepAliveInterval&&!this.keepAliveInterval&&(this.keepAliveInterval=setInterval(()=>{this.sendKeepAlive(),this.startSendingKeepAlives()},(A=>{const t=.8*A;return 1e3*(Math.random()*(A-t)+t)})(this.configuration.keepAliveInterval)))}stopSendingKeepAlives(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveInterval=void 0,this.keepAliveDebounceTimeout=void 0}}Dl.defaultOptions={server:"",connectionTimeout:5,keepAliveInterval:0,keepAliveDebounce:10,traceSip:!0};class Pi{constructor(A={}){if(this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this._state=Tt.Stopped,this._stateEventEmitter=new pa,this.delegate=A.delegate,this.options=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Pi.defaultOptions()),{sipjsId:oi(5)}),{uri:new er("sip","anonymous."+oi(6),"anonymous.invalid")}),{viaHost:oi(12)+".invalid"}),Pi.stripUndefinedProperties(A)),this.options.hackIpInContact)if(typeof this.options.hackIpInContact=="boolean"&&this.options.hackIpInContact){const r=Math.floor(Math.random()*254+1);this.options.viaHost="192.0.2."+r}else this.options.hackIpInContact&&(this.options.viaHost=this.options.hackIpInContact);switch(this.loggerFactory=new ow,this.logger=this.loggerFactory.getLogger("sip.UserAgent"),this.loggerFactory.builtinEnabled=this.options.logBuiltinEnabled,this.loggerFactory.connector=this.options.logConnector,this.options.logLevel){case"error":this.loggerFactory.level=bt.error;break;case"warn":this.loggerFactory.level=bt.warn;break;case"log":this.loggerFactory.level=bt.log;break;case"debug":this.loggerFactory.level=bt.debug}if(this.options.logConfiguration&&(this.logger.log("Configuration:"),Object.keys(this.options).forEach(t=>{const n=this.options[t];switch(t){case"uri":case"sessionDescriptionHandlerFactory":this.logger.log("· "+t+": "+n);break;case"authorizationPassword":this.logger.log("· "+t+": NOT SHOWN");break;case"transportConstructor":this.logger.log("· "+t+": "+n.name);break;default:this.logger.log("· "+t+": "+JSON.stringify(n))}})),this.options.transportOptions){const t=this.options.transportOptions,n=t.maxReconnectionAttempts,r=t.reconnectionTimeout;n!==void 0&&this.logger.warn('The transport option "maxReconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),r!==void 0&&this.logger.warn('The transport option "reconnectionTimeout" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),A.reconnectionDelay===void 0&&r!==void 0&&(this.options.reconnectionDelay=r),A.reconnectionAttempts===void 0&&n!==void 0&&(this.options.reconnectionAttempts=n)}if(A.reconnectionDelay!==void 0&&this.logger.warn('The user agent option "reconnectionDelay" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),A.reconnectionAttempts!==void 0&&this.logger.warn('The user agent option "reconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),this._transport=new this.options.transportConstructor(this.getLogger("sip.Transport"),this.options.transportOptions),this.initTransportCallbacks(),this._contact=this.initContact(),this._instanceId=this.options.instanceId?this.options.instanceId:Pi.newUUID(),It.parse(this._instanceId,"uuid")===-1)throw new Error("Invalid instanceId.");this._userAgentCore=this.initCore()}static makeURI(A){return It.URIParse(A)}static defaultOptions(){return{allowLegacyNotifications:!1,authorizationHa1:"",authorizationPassword:"",authorizationUsername:"",delegate:{},contactName:"",contactParams:{transport:"ws"},displayName:"",forceRport:!1,gracefulShutdown:!0,hackAllowUnregisteredOptionTags:!1,hackIpInContact:!1,hackViaTcp:!1,instanceId:"",instanceIdAlwaysAdded:!1,logBuiltinEnabled:!0,logConfiguration:!0,logConnector:()=>{},logLevel:"log",noAnswerTimeout:60,preloadedRouteSet:[],reconnectionAttempts:0,reconnectionDelay:4,sendInitialProvisionalResponse:!0,sessionDescriptionHandlerFactory:ww(),sessionDescriptionHandlerFactoryOptions:{},sipExtension100rel:On.Unsupported,sipExtensionReplaces:On.Unsupported,sipExtensionExtraSupported:[],sipjsId:"",transportConstructor:Dl,transportOptions:{},uri:new er("sip","anonymous","anonymous.invalid"),userAgentString:"SIP.js/0.21.1",viaHost:""}}static newUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.floor(16*Math.random());return(t==="x"?n:n%4+8).toString(16)})}static stripUndefinedProperties(A){return Object.keys(A).reduce((t,n)=>(A[n]!==void 0&&(t[n]=A[n]),t),{})}get configuration(){return this.options}get contact(){return this._contact}get instanceId(){return this._instanceId}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get transport(){return this._transport}get userAgentCore(){return this._userAgentCore}getLogger(A,t){return this.loggerFactory.getLogger(A,t)}getLoggerFactory(){return this.loggerFactory}isConnected(){return this.transport.isConnected()}reconnect(){return this.state===Tt.Stopped?Promise.reject(new Error("User agent stopped.")):Promise.resolve().then(()=>this.transport.connect())}start(){return this.state===Tt.Started?(this.logger.warn("User agent already started"),Promise.resolve()):(this.logger.log(`Starting ${this.configuration.uri}`),this.transitionState(Tt.Started),this.transport.connect())}async stop(){if(this.state===Tt.Stopped)return this.logger.warn("User agent already stopped"),Promise.resolve();if(this.logger.log(`Stopping ${this.configuration.uri}`),!this.options.gracefulShutdown)return this.logger.log("Dispose of transport"),this.transport.dispose().catch(a=>{throw this.logger.error(a.message),a}),this.logger.log("Dispose of core"),this.userAgentCore.dispose(),this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this.transitionState(Tt.Stopped),Promise.resolve();const A=Object.assign({},this._publishers),t=Object.assign({},this._registerers),n=Object.assign({},this._sessions),r=Object.assign({},this._subscriptions),i=this.transport,o=this.userAgentCore;this.logger.log("Dispose of registerers");for(const a in t)t[a]&&await t[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._registerers[a],s});this.logger.log("Dispose of sessions");for(const a in n)n[a]&&await n[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._sessions[a],s});this.logger.log("Dispose of subscriptions");for(const a in r)r[a]&&await r[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._subscriptions[a],s});this.logger.log("Dispose of publishers");for(const a in A)A[a]&&await A[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._publishers[a],s});this.logger.log("Dispose of transport"),await i.dispose().catch(a=>{throw this.logger.error(a.message),a}),this.logger.log("Dispose of core"),o.dispose(),this.transitionState(Tt.Stopped)}_makeInviter(A,t){return new M0(this,A,t)}attemptReconnection(A=1){const t=this.options.reconnectionAttempts,n=this.options.reconnectionDelay;A>t?this.logger.log("Maximum reconnection attempts reached"):(this.logger.log(`Reconnection attempt ${A} of ${t} - trying`),setTimeout(()=>{this.reconnect().then(()=>{this.logger.log(`Reconnection attempt ${A} of ${t} - succeeded`)}).catch(r=>{this.logger.error(r.message),this.logger.log(`Reconnection attempt ${A} of ${t} - failed`),this.attemptReconnection(++A)})},A===1?0:1e3*n))}initContact(){const A=this.options.contactName!==""?this.options.contactName:oi(8),t=this.options.contactParams;return{pubGruu:void 0,tempGruu:void 0,uri:new er("sip",A,this.options.viaHost,void 0,t),toString:(n={})=>{const r=n.anonymous||!1,i=n.outbound||!1,o=n.register||!1;let a="<";return a+=r?this.contact.tempGruu||`sip:anonymous@anonymous.invalid;transport=${t.transport?t.transport:"ws"}`:o?this.contact.uri:this.contact.pubGruu||this.contact.uri,i&&(a+=";ob"),a+=">",this.options.instanceIdAlwaysAdded&&(a+=';+sip.instance="<urn:uuid:'+this._instanceId+'>"'),a}}}initCore(){let A=[];A.push("outbound"),this.options.sipExtension100rel===On.Supported&&A.push("100rel"),this.options.sipExtensionReplaces===On.Supported&&A.push("replaces"),this.options.sipExtensionExtraSupported&&A.push(...this.options.sipExtensionExtraSupported),this.options.hackAllowUnregisteredOptionTags||(A=A.filter(i=>rw[i])),A=Array.from(new Set(A));const t=A.slice();(this.contact.pubGruu||this.contact.tempGruu)&&t.push("gruu");const n={aor:this.options.uri,contact:this.contact,displayName:this.options.displayName,loggerFactory:this.loggerFactory,hackViaTcp:this.options.hackViaTcp,routeSet:this.options.preloadedRouteSet,supportedOptionTags:A,supportedOptionTagsResponse:t,sipjsId:this.options.sipjsId,userAgentHeaderFieldValue:this.options.userAgentString,viaForceRport:this.options.forceRport,viaHost:this.options.viaHost,authenticationFactory:()=>{const i=this.options.authorizationUsername?this.options.authorizationUsername:this.options.uri.user,o=this.options.authorizationPassword?this.options.authorizationPassword:void 0,a=this.options.authorizationHa1?this.options.authorizationHa1:void 0;return new iw(this.getLoggerFactory(),a,i,o)},transportAccessor:()=>this.transport},r={onInvite:i=>{var o;const a=new Wu(this,i);if(i.delegate={onCancel:s=>{a._onCancel(s)},onTransportError:s=>{this.logger.error("A transport error has occurred while handling an incoming INVITE request.")}},i.trying(),this.options.sipExtensionReplaces!==On.Unsupported){const s=i.message.parseHeader("replaces");if(s){const l=s.call_id;if(typeof l!="string")throw new Error("Type of call id is not string");const u=s.replaces_to_tag;if(typeof u!="string")throw new Error("Type of to tag is not string");const V=s.replaces_from_tag;if(typeof V!="string")throw new Error("type of from tag is not string");const d=l+u+V,h=this.userAgentCore.dialogs.get(d);if(!h)return void a.reject({statusCode:481});if(!h.early&&s.early_only===!0)return void a.reject({statusCode:486});const m=this._sessions[l+V]||this._sessions[l+u]||void 0;if(!m)throw new Error("Session does not exist.");a._replacee=m}}if(!((o=this.delegate)===null||o===void 0)&&o.onInvite)return a.autoSendAnInitialProvisionalResponse?void a.progress().then(()=>{var s;if(((s=this.delegate)===null||s===void 0?void 0:s.onInvite)===void 0)throw new Error("onInvite undefined.");this.delegate.onInvite(a)}):void this.delegate.onInvite(a);a.reject({statusCode:486})},onMessage:i=>{if(this.delegate&&this.delegate.onMessage){const o=new y0(i);this.delegate.onMessage(o)}else i.accept()},onNotify:i=>{if(this.delegate&&this.delegate.onNotify){const o=new Ju(i);this.delegate.onNotify(o)}else this.options.allowLegacyNotifications?i.accept():i.reject({statusCode:481})},onRefer:i=>{this.logger.warn("Received an out of dialog REFER request"),this.delegate&&this.delegate.onReferRequest?this.delegate.onReferRequest(i):i.reject({statusCode:405})},onRegister:i=>{this.logger.warn("Received an out of dialog REGISTER request"),this.delegate&&this.delegate.onRegisterRequest?this.delegate.onRegisterRequest(i):i.reject({statusCode:405})},onSubscribe:i=>{this.logger.warn("Received an out of dialog SUBSCRIBE request"),this.delegate&&this.delegate.onSubscribeRequest?this.delegate.onSubscribeRequest(i):i.reject({statusCode:405})}};return new yw(n,r)}initTransportCallbacks(){this.transport.onConnect=()=>this.onTransportConnect(),this.transport.onDisconnect=A=>this.onTransportDisconnect(A),this.transport.onMessage=A=>this.onTransportMessage(A)}onTransportConnect(){this.state!==Tt.Stopped&&this.delegate&&this.delegate.onConnect&&this.delegate.onConnect()}onTransportDisconnect(A){this.state!==Tt.Stopped&&(this.delegate&&this.delegate.onDisconnect&&this.delegate.onDisconnect(A),A&&this.options.reconnectionAttempts>0&&this.attemptReconnection())}onTransportMessage(A){const t=Ts.parseMessage(A,this.getLogger("sip.Parser"));if(!t)return void this.logger.warn("Failed to parse incoming message. Dropping.");if(this.state===Tt.Stopped&&t instanceof Ji)return void this.logger.warn(`Received ${t.method} request while stopped. Dropping.`);const n=()=>{const r=["from","to","call_id","cseq","via"];for(const i of r)if(!t.hasHeader(i))return this.logger.warn(`Missing mandatory header field : ${i}.`),!1;return!0};if(t instanceof Ji){if(!n())return void this.logger.warn("Request missing mandatory header field. Dropping.");if(!t.toTag&&t.callId.substr(0,5)===this.options.sipjsId)return void this.userAgentCore.replyStateless(t,{statusCode:482});const r=fa(t.body),i=t.getHeader("content-length");if(i&&r<Number(i))return void this.userAgentCore.replyStateless(t,{statusCode:400})}if(t instanceof Lr){if(!n())return void this.logger.warn("Response missing mandatory header field. Dropping.");if(t.getHeaders("via").length>1)return void this.logger.warn("More than one Via header field present in the response. Dropping.");if(t.via.host!==this.options.viaHost||t.via.port!==void 0)return void this.logger.warn("Via sent-by in the response does not match UA Via host value. Dropping.");const r=fa(t.body),i=t.getHeader("content-length");if(i&&r<Number(i))return void this.logger.warn("Message body length is lower than the value in Content-Length header field. Dropping.")}if(t instanceof Ji)this.userAgentCore.receiveIncomingRequestFromTransport(t);else{if(!(t instanceof Lr))throw new Error("Invalid message type.");this.userAgentCore.receiveIncomingResponseFromTransport(t)}}transitionState(A,t){const n=()=>{throw new Error(`Invalid state transition from ${this._state} to ${A}`)};switch(this._state){case Tt.Started:A!==Tt.Stopped&&n();break;case Tt.Stopped:A!==Tt.Started&&n();break;default:throw new Error("Unknown state.")}this.logger.log(`Transitioned from ${this._state} to ${A}`),this._state=A,this._stateEventEmitter.emit(this._state)}}class D0{constructor(A){this.listeners=[],this.keyListeners={},this.data={...A},this.proxy=new Proxy(this.data,{set:(t,n,r)=>(t[n]!==r&&(t[n]=r,this.notify(),this.notifyKey(n,r)),!0)})}getState(){return this.proxy}setState(A,t=!1){let n=!1;for(const r in A)if(Object.prototype.hasOwnProperty.call(A,r)){const i=this.data[r],o=A[r];(t||i!==o)&&(this.data[r]=o,n=!0,this.notifyKey(r,o))}(n||t)&&this.notify()}subscribe(A){return this.listeners.push(A),()=>{this.listeners=this.listeners.filter(t=>t!==A)}}subscribeKey(A,t){return this.keyListeners[A]||(this.keyListeners[A]=[]),this.keyListeners[A].push(t),()=>{this.keyListeners[A]=this.keyListeners[A].filter(n=>n!==t)}}notify(){const A=this.getState();for(const t of this.listeners)t(A)}notifyKey(A,t){const n=this.keyListeners[A];n&&n.forEach(r=>r(t))}}var fe,Bt,ae,wn,eA,xA,Xe;(function(e){e[e.IDLE=1]="IDLE",e[e.BUSY=2]="BUSY",e[e.RINGING=3]="RINGING",e[e.OFFLINE=0]="OFFLINE",e[e.UNREGISTERED=4]="UNREGISTERED"})(fe||(fe={})),function(e){e.OUTGOING="outgoing",e.INCOMING="incoming",e.CONSULT="consult",e.MEETING="meeting",e.TRANSFER="transfer",e.PREDICT_OUT_CALL="predict_out_call"}(Bt||(Bt={})),function(e){e[e.OUT_CALL=100]="OUT_CALL",e[e.AGENT_STATE=101]="AGENT_STATE",e[e.OUT_CALL_INCOMING_CALL=102]="OUT_CALL_INCOMING_CALL",e[e.OUT_CALL_RINGING=103]="OUT_CALL_RINGING",e[e.OUT_CALL_ANSWER=104]="OUT_CALL_ANSWER",e[e.CALL_HOLD=105]="CALL_HOLD",e[e.CALL_UNHOLD=106]="CALL_UNHOLD",e[e.OUT_CALL_END=107]="OUT_CALL_END",e[e.CONSULT_REQUEST=108]="CONSULT_REQUEST",e[e.CONSULT_RINGING=109]="CONSULT_RINGING",e[e.CONSULT_ANSWER=110]="CONSULT_ANSWER",e[e.CONSULT_FAIL=111]="CONSULT_FAIL",e[e.MUTE=112]="MUTE",e[e.UNMUTE=113]="UNMUTE",e[e.CONSULT_CALL_IN=114]="CONSULT_CALL_IN",e[e.CONSULT_CALL_IN_SUCCESS=115]="CONSULT_CALL_IN_SUCCESS",e[e.CONSULT_RETURN_CALL=125]="CONSULT_RETURN_CALL",e[e.CONSULT_RETURN_CALL_SUCCESS=126]="CONSULT_RETURN_CALL_SUCCESS",e[e.CONSULT_TRANSFER=116]="CONSULT_TRANSFER",e[e.CONSULT_TRANSFER_FAILED=118]="CONSULT_TRANSFER_FAILED",e[e.CONSULT_TRANSFER_OFF_HOOK=117]="CONSULT_TRANSFER_OFF_HOOK",e[e.INCOMING_CALL=119]="INCOMING_CALL",e[e.INCOMING_CALL_OFF_HOOK=120]="INCOMING_CALL_OFF_HOOK",e[e.INCOMING_CALL_END=121]="INCOMING_CALL_END",e[e.SATISFACTION_EVALUATION=122]="SATISFACTION_EVALUATION",e[e.CONSULT_THREE_WAY=123]="CONSULT_THREE_WAY",e[e.CONSULT_THREE_WAY_RESULT=124]="CONSULT_THREE_WAY_RESULT",e[e.TRANSFER=127]="TRANSFER",e[e.TRANSFER_FAILED=128]="TRANSFER_FAILED",e[e.TRANSFER_INCOMING_CALL=129]="TRANSFER_INCOMING_CALL",e[e.TRANSFER_OFF_HOOK=130]="TRANSFER_OFF_HOOK",e[e.AGENT_HANGUP=131]="AGENT_HANGUP",e[e.KICK_OFFLINE=132]="KICK_OFFLINE",e[e.CONTINUOUS_NOT_ANSWER=133]="CONTINUOUS_NOT_ANSWER",e[e.PREVIEW_OUT_CALL=134]="PREVIEW_OUT_CALL",e[e.SIGN_OUT=135]="SIGN_OUT",e[e.SIGN_IN_SWITCH_DEVICE=136]="SIGN_IN_SWITCH_DEVICE",e[e.LISTEN_CALL_FAILED=137]="LISTEN_CALL_FAILED",e[e.LISTEN_INCOMING_CALL=138]="LISTEN_INCOMING_CALL",e[e.LISTEN_INCOMING_CALL_OFF_HOOK=139]="LISTEN_INCOMING_CALL_OFF_HOOK",e[e.EAR_SPEECH=140]="EAR_SPEECH",e[e.STOP_EAR_SPEECH=141]="STOP_EAR_SPEECH",e[e.CALL_FORCE_INSERT=142]="CALL_FORCE_INSERT"}(ae||(ae={})),function(e){e.WEB_RTC_CONNECTING="connecting",e.WEB_RTC_CONNECTED="connected",e.WEB_RTC_DISCONNECTING="disconnecting",e.WEB_RTC_DISCONNECTED="disconnected",e.WEB_RTC_REGISTERED="registered",e.WEB_RTC_UNREGISTERED="unregistered",e.WEB_RTC_TERMINATED="terminated",e.WEB_RTC_REGISTER_FAILED="register_failed",e.WEB_RTC_ANSWER_FAILED="answer_failed",e.WEB_RTC_SEND_DTMF="send_dtmf"}(wn||(wn={})),function(e){e.CUSTOMER_INFO="customer_info",e.CALL_PROGRESS="call_progress",e.OUT_INCOMING_CALL="out_call_incoming_call",e.PREVIEW_OUT_INCOMING_CALL="preview_out_incoming_call",e.OUT_SUCCESS="out_call_success",e.OUT_FAILED="out_call_failed",e.OUT_RINGING="out_call_ringing",e.OUT_OFF_ANSWER="out_call_answer",e.HOLD_SUCCESS="hold_success",e.HOLD_FAILED="hold_failed",e.UNHOLD_SUCCESS="unhold_success",e.UNHOLD_FAILED="unhold_failed",e.OUT_HANGUP="out_call_hangup",e.CONSULT_RINGING="consult_ringing",e.CONSULT_OFF_HOOK="consult_off_hook",e.CONSULT_FAILED="consult_failed",e.CONSULT_INCOMING="consult_incoming",e.CONSULT_CALL_IN_SUCCESS="consult_call_in_success",e.CONSULT_RETURN_CALL_SUCCESS="consult_return_call_success",e.OTHER_SIDE_CONSULT_HANGUP="other_side_consult_hangup",e.OUR_SIDE_CONSULT_HANGUP="our_side_consult_hangup",e.AGENT_STATE="agent_state",e.MUTE_SUCCESS="mute_success",e.MUTE_FAILED="mute_failed",e.UNMUTE_SUCCESS="unmute_success",e.UNMUTE_FAILED="unmute_failed",e.CONSULT_TRANSFER_SUCCESS="consult_transfer_success",e.CONSULT_TRANSFER_FAILED="consult_transfer_failed",e.CONSULT_TRANSFER_OFF_HOOK="consult_transfer_off_hook",e.INCOMING_CALL="incoming_call",e.PREDICT_INCOMING_CALL="predict_incoming_call",e.INCOMING_CALL_OFF_HOOK="incoming_call_off_hook",e.INCOMING_CALL_END="incoming_call_end",e.SATISFACTION_EVALUATION_SUCCESS="satisfaction_evaluation_success",e.SATISFACTION_EVALUATION_FAILED="satisfaction_evaluation_failed",e.CONSULT_THREE_WAY_SUCCESS="consult_three_way_success",e.CONSULT_THREE_WAY_FAILED="consult_three_way_failed",e.THREE_WAY_OUR_SIDE_HANGUP="three_way_our_side_hangup",e.TRANSFER_FAILED="transfer_failed",e.TRANSFER_PROGRESS="transfer_progress",e.TRANSFER_INCOMING_CALL="transfer_incoming_call",e.TRANSFER_OFF_HOOK="transfer_off_hook",e.TRANSFER_END="transfer_end",e.REJECT="reject",e.LISTEN_CALL_FAILED="listen_call_failed",e.LISTEN_INCOMING_CALL="listen_incoming_call",e.LISTEN_INCOMING_CALL_OFF_HOOK="listen_incoming_call_off_hook",e.LISTEN_HANGUP="listen_hangup",e.EAR_SPEECH_SUCCESS="ear_speech_success",e.EAR_SPEECH_BE_SUCCESS="ear_speech_be_success",e.EAR_SPEECH_FAILED="ear_speech_failed",e.STOP_EAR_SPEECH_SUCCESS="stop_ear_speech_success",e.STOP_EAR_SPEECH_FAILED="stop_ear_speech_failed",e.CALL_FORCE_INSERT_SUCCESS="call_force_insert_success",e.CALL_FORCE_INSERT_SUCCESS_LISTENER="call_force_insert_success_listener",e.CALL_FORCE_INSERT_FAILED="call_force_insert_failed"}(eA||(eA={})),function(e){e.EVENT_ALL="event_all",e.NOTIFICATION_CLICK="notification_click",e.UPDATE_ANSWER_DEVICE="update_answer_device",e.PHONE_BAR_OPERATION="phone_bar_operation",e.AGENT_INIT_STATUS="agent_init_status",e.WEBSITE_DELAY="website_delay",e.SELECT_EXTERNAL_NUMBER="select_external_number",e.FAIL_NOTIFICATION="fail_notification",e.KICK_OFF="kick_off",e.DESTROY="destroy",e.NETWORK_OFFLINE="network_offline",e.NETWORK_ONLINE="network_online",e.SIGN_OUT="sign_out",e.SIGN_IN_SWITCH_DEVICE="sign_in_switch_device"}(xA||(xA={})),function(e){e.RINGING="客户振铃",e.AGENT_RINGING="振铃中",e.CALLING="通话中",e.CONSULTING="正在咨询",e.CONSULT_CALL_IN="咨询来电",e.INCOMING_CALL="客户来电",e.MEETING="会议中",e.TRANSFERRING="转接中",e.TRANSFER_INCOMING_CALL="转接来电",e.HOLDING="保持中",e.MUTING="静音中",e.LISTENING="监听来电",e.LINKING="正在链接"}(Xe||(Xe={}));const Go=function(e){return{all:e=e||new Map,on:function(A,t){var n=e.get(A);n?n.push(t):e.set(A,[t])},off:function(A,t){var n=e.get(A);n&&(t?n.splice(n.indexOf(t)>>>0,1):e.set(A,[]))},emit:function(A,t){var n=e.get(A);n&&n.slice().map(function(r){r(t)}),(n=e.get("*"))&&n.slice().map(function(r){r(A,t)})}}}(),VA={on:(e,A)=>(Go.on(e,A),VA),off(e,A){Go.off(e,A)},emit(e,A){Go.emit(e,A),Go.emit(xA.EVENT_ALL,{event:e,data:A})},clearAllListeners(){Go.all.clear()}},$={agentInfo:{},isRtcReconnecting:!1,sessionId:"",enableBrowserAlert:!1,autoStateTimer:null,autoAnswerTimer:null,logBuiltinEnabled:!1,browserAlertTime:3e3,latency:0,monitoredAgentNo:"",earSpeakAgent:"",stateObject:{state:fe.BUSY,state_name:"忙碌"}},En={isCalling:!1,direction:null,outCallIsAnswer:!1,incomingIsAnswer:!1,transferIsAnswer:!1,isMeeting:!1,isHold:!1,displayText:"",isMuted:!1,consultIsAnswer:!1,actionConfigs:[],answerDevice:1,selectOutNumber:"",customerObject:void 0,isNextState:!0,isSipConnected:!1},N=new class extends D0{updateIsCalling(e){this.setState({isCalling:e})}updateDirection(e){this.setState({direction:e})}updateOutCallIsAnswer(e){this.setState({outCallIsAnswer:e})}updateIsHold(e){var t;if(((t=$.stateObject)==null?void 0:t.state)===fe.UNREGISTERED)return;const A=this.get("actionConfigs");if(e){const n=[...A.filter(r=>r!=="hold")];n.push("unhold"),this.updateActionConfigs(n)}else{const n=[...A.filter(r=>r!=="unhold")];n.push("hold"),this.updateActionConfigs(n)}this.getState().isHold=e}updateDisplayText(e){this.setState({displayText:e}),VA.emit(eA.CALL_PROGRESS,e)}updateActionConfigs(e){const{show_satisfaction:A}=$.agentInfo||{},t=this.get("answerDevice"),n=e.filter(r=>(A!==0||r!=="satisfaction")&&(t!==2||r!=="answer"));this.setState({actionConfigs:n}),VA.emit(xA.PHONE_BAR_OPERATION,n)}updateConsultIsAnswer(e){this.setState({consultIsAnswer:e})}updateIsMuted(e){var t;if(((t=$.stateObject)==null?void 0:t.state)===fe.UNREGISTERED)return;const A=this.get("actionConfigs");if(e){const n=[...A.filter(r=>r!=="mute")];n.push("unmute"),this.updateActionConfigs(n)}else{const n=[...A.filter(r=>r!=="unmute")];n.push("mute"),this.updateActionConfigs(n)}this.setState({isMuted:e})}updateIncomingIsAnswer(e){this.setState({incomingIsAnswer:e})}updateAnswerDevice(e){this.setState({answerDevice:e}),VA.emit(xA.UPDATE_ANSWER_DEVICE,e)}updateIsMeeting(e){this.setState({isMeeting:e})}updateTransferIsAnswer(e){this.setState({transferIsAnswer:e})}updateSelectOutNumber(e){VA.emit(xA.SELECT_EXTERNAL_NUMBER,e),this.setState({selectOutNumber:e})}updateCustomerInfo(e){const A=this.get("displayText");if(e&&A){const{contact_count:t,customer_name:n,phone:r,city:i,province:o,is_vip:a,in_contact_count:s,trace_id:l,contact_count_month:u,in_contact_count_month:V}=e;VA.emit(eA.CUSTOMER_INFO,{customer_name:n||"未知客户",phone:r,city:i||"未知",province:o||"未知",contact_count:t||0,in_contact_count:s||0,is_vip:a,trace_id:l,contact_count_month:u||0,in_contact_count_month:V||0})}else VA.emit(eA.CUSTOMER_INFO,void 0);this.setState({customerObject:e})}updateIsNextState(e){this.setState({isNextState:e}),e?VA.emit(xA.NETWORK_ONLINE):($.stateObject={state:fe.OFFLINE,state_name:"离线"},this.updateActionConfigs([]),VA.emit(eA.AGENT_STATE,$.stateObject),VA.emit(xA.NETWORK_OFFLINE))}updateIsSipConnected(e){this.setState({isSipConnected:e})}reset(){this.updateIsCalling(En.isCalling),this.updateDirection(En.direction),this.updateOutCallIsAnswer(En.outCallIsAnswer),this.updateIsHold(En.isHold),this.updateDisplayText(En.displayText),this.updateActionConfigs(En.actionConfigs),this.updateConsultIsAnswer(En.consultIsAnswer),this.updateIsMuted(En.isMuted),this.updateIncomingIsAnswer(En.incomingIsAnswer),this.updateIsMeeting(En.isMeeting),this.updateTransferIsAnswer(En.transferIsAnswer),this.updateCustomerInfo(void 0)}getCallInfo(){return this.getState()}get(e){return this.getState()[e]}}(En),Gd=new class extends D0{updateRttObject(e){this.setState({rttObject:e}),VA.emit(xA.WEBSITE_DELAY,e)}}({rttObject:{rtt:null,jitter:null,packetsLost:null,packetsReceived:null,packetsSent:null,sendBitrate:null,recvBitrate:null,codec:null}});let Mw=class{constructor(A,t){this.config=A,this.eventCallback=t,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.registerIntervalTimer=null,this.registerInterval=6e4,this.handleNetworkInfoChange=n=>{var r,i;(r=n.rttObject)!=null&&r.rtt&&((((i=n.rttObject)==null?void 0:i.rtt)||0)===0?this.isOffline||(this.isOffline=!0,this.handleOffline()):this.isOffline&&(this.isOffline=!1,this.handleOnline()))},this.handleOffline=()=>{console.warn("[SIPClient] 网络断开,准备销毁 SIP 客户端",new Date().toLocaleString()),VA.emit(xA.FAIL_NOTIFICATION,"网络断开,准备销毁 SIP 客户端"),this.destroy()},this.handleOnline=()=>{console.warn("[SIPClient] 网络恢复,准备重新启动 SIP 客户端",new Date().toLocaleString()),this.reconnect()},this.sleep=n=>new Promise(r=>setTimeout(r,n)),Gd.subscribe(this.handleNetworkInfoChange)}async start(){const A=Pi.makeURI(`sip:${this.config.user}@${this.config.server}`);if(!A)throw new Error("无效的SIP配置");const t={uri:A,authorizationUsername:this.config.user,authorizationPassword:this.config.password,transportOptions:{server:this.config.webSocket,connectionTimeout:30,keepAliveInterval:20},contactName:this.config.user,contactParams:{transport:"wss"},userAgentString:"SwiftSIP/1.1.33",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:500},logBuiltinEnabled:$.logBuiltinEnabled};this.userAgent=new Pi(t),this.setupEventListeners(),await this.userAgent.start(),await this.register()}setupEventListeners(){this.userAgent&&(this.userAgent.transport.stateChange.addListener(A=>{var n;let t;switch(A){case de.Connecting:t=wn.WEB_RTC_CONNECTING;break;case de.Connected:t=wn.WEB_RTC_CONNECTED,this.reconnectAttempts=0,$.isRtcReconnecting=!1,N.updateIsSipConnected(!0),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);break;case de.Disconnecting:t=wn.WEB_RTC_DISCONNECTING,N.updateIsSipConnected(!1);break;case de.Disconnected:{if(N.updateIsSipConnected(!1),this.isManuallyStopped)return void console.warn("[SIP] 手动断开,不触发重连");VA.emit(xA.FAIL_NOTIFICATION,"软电话链接失败"),t=wn.WEB_RTC_DISCONNECTED;const r=N.get("answerDevice");if(!$.isRtcReconnecting&&this.reconnectAttempts<this.maxReconnectAttempts&&r===1){this.reconnectAttempts++;const i=1e3*this.reconnectAttempts;console.warn(`SIP WebSocket 断开,第 ${this.reconnectAttempts} 次尝试重连,${i}ms 后重试...`),this.reconnectTimer=setTimeout(()=>{this.reconnect()},i)}else this.reconnectAttempts>=this.maxReconnectAttempts&&(console.error("SIP 重连失败:已达到最大重试次数"),VA.emit(xA.FAIL_NOTIFICATION,"SIP 重连失败:已达到最大重试次数"));break}default:N.updateIsSipConnected(!1),t="unknown"}(n=this.eventCallback)==null||n.call(this,{type:t})}),this.userAgent.delegate={onInvite:A=>{this.handleIncomingCall(A)}})}async refreshRegister(){if(this.registerer)try{await this.registerer.register(),new Date().toLocaleTimeString()}catch(A){console.error("[SIPClient] REGISTER刷新失败",A)}}async register(){var A,t;if(this.userAgent){this.registerer=new _n(this.userAgent),(A=this.registerer)==null||A.stateChange.addListener(n=>{var i;let r;switch(n){case Ye.Initial:N.updateDisplayText(Xe.LINKING),r="initial";break;case Ye.Registered:N.updateDisplayText(""),r=wn.WEB_RTC_REGISTERED;break;case Ye.Unregistered:r=wn.WEB_RTC_UNREGISTERED;break;case Ye.Terminated:r=wn.WEB_RTC_TERMINATED;break;default:r="unknown"}(i=this.eventCallback)==null||i.call(this,{type:r})});try{await this.registerer.register(),this.registerIntervalTimer||(this.registerIntervalTimer=setInterval(()=>{this.refreshRegister()},this.registerInterval))}catch(n){(t=this.eventCallback)==null||t.call(this,{type:wn.WEB_RTC_REGISTER_FAILED,data:n})}}}attachRemoteAudio(A){const t=A.sessionDescriptionHandler;if(t){const n=t.peerConnection;if(!n)return;const r=new MediaStream;n.getReceivers().forEach(o=>{o.track&&o.track.kind==="audio"&&r.addTrack(o.track)});let i=document.getElementById("sip-remote-audio");i||(i=document.createElement("audio"),i.id="sip-remote-audio",i.autoplay=!0,i.style.display="none",document.body.appendChild(i)),i.srcObject=r,i.play().catch(o=>{console.error("音频播放失败,需要用户交互触发",o)})}}handleSessionState(A,t,n){A.stateChange.addListener(r=>{switch(r){case dA.Established:clearTimeout(this.callTimeoutTimer),this.activeSession=A,this.attachRemoteAudio(A);break;case dA.Terminating:break;case dA.Terminated:this.activeSession=null,clearTimeout(this.callTimeoutTimer);case dA.Establishing:}})}handleIncomingCall(A){this.incomingInvitation=A,this.handleSessionState(A,!1),N.get("direction")===Bt.OUTGOING&&this.answerCall()}async answerCall(){var A;if(!this.incomingInvitation)throw new Error("无来电可接听");$.autoAnswerTimer&&(clearTimeout($.autoAnswerTimer),$.autoAnswerTimer=null);try{await this.incomingInvitation.accept(),this.activeSession=this.incomingInvitation,this.incomingInvitation=null}catch(t){(A=this.eventCallback)==null||A.call(this,{type:wn.WEB_RTC_ANSWER_FAILED,data:{detail:t}})}}async rejectInCall(){var A;if(this.incomingInvitation)try{await this.incomingInvitation.reject(),this.incomingInvitation=null,N.updateDirection(null),N.updateIsCalling(!1),clearTimeout(this.callTimeoutTimer)}catch(t){(A=this.eventCallback)==null||A.call(this,{type:"error",data:{message:"拒接失败",detail:t}})}}sendDTMF(A){var n;if(!this.activeSession)throw new Error("当前没有活跃的通话");const t=this.activeSession.sessionDescriptionHandler;t&&typeof t.sendDtmf=="function"?(t.sendDtmf(A),(n=this.eventCallback)==null||n.call(this,{type:wn.WEB_RTC_SEND_DTMF,data:{tone:A}})):console.warn("DTMF发送不支持或未初始化")}async hangup(){if(this.activeSession,this.activeSession){clearTimeout(this.callTimeoutTimer);const A=this.activeSession;if(!A)return;const t=A.state;try{t===dA.Established?await A.bye():t===dA.Establishing&&(A instanceof M0?await A.cancel():A instanceof Wu&&await A.reject()),clearTimeout(this.callTimeoutTimer)}catch(n){console.error("挂断失败",n)}finally{this.activeSession=null}}}async rejectOutCall(){this.activeSession instanceof Wu&&(await this.activeSession.reject(),this.activeSession=null)}async destroy(){if(this.isManuallyStopped=!0,clearTimeout(this.callTimeoutTimer),clearInterval(this.registerIntervalTimer),this.activeSession&&await this.hangup(),this.registerIntervalTimer&&(clearInterval(this.registerIntervalTimer),this.registerIntervalTimer=null),this.registerer){try{await this.registerer.unregister()}catch(A){console.warn("注销失败",A)}this.registerer=null}this.userAgent&&(await this.userAgent.stop(),this.userAgent=null)}async reconnect(){if(!$.isRtcReconnecting){$.isRtcReconnecting=!0;try{await this.destroy(),await this.start(),this.isOffline=!1}catch(A){console.error("重连失败",A)}finally{$.isRtcReconnecting=!1}}}async getNetworkStats(){var A;if(this.activeSession){const t=(A=this.activeSession.sessionDescriptionHandler)==null?void 0:A.peerConnection;if(!t)return null;const n=await t.getStats(),r={};return n.forEach(i=>{i.type==="candidate-pair"&&i.state==="succeeded"&&i.currentRoundTripTime!=null&&(r.rtt=+(1e3*i.currentRoundTripTime).toFixed(2)),i.type==="inbound-rtp"&&i.kind==="audio"&&(r.jitter=+(1e3*i.jitter).toFixed(2),r.packetsLost=i.packetsLost,r.packetsReceived=i.packetsReceived,i.bytesReceived&&i.timestamp&&(r.recvBitrate=+(i.bytesReceived/1024).toFixed(2))),i.type==="outbound-rtp"&&i.kind==="audio"&&(r.packetsSent=i.packetsSent,i.bytesSent&&i.timestamp&&(r.sendBitrate=+(i.bytesSent/1024).toFixed(2))),i.type==="codec"&&i.mimeType&&(r.codec=i.mimeType)}),{...r,rtt:(r==null?void 0:r.rtt)||40}}return{rtt:$.latency||1}}};/**
|
|
155
|
+
`))}startSendingKeepAlives(){this.configuration.keepAliveInterval&&!this.keepAliveInterval&&(this.keepAliveInterval=setInterval(()=>{this.sendKeepAlive(),this.startSendingKeepAlives()},(A=>{const t=.8*A;return 1e3*(Math.random()*(A-t)+t)})(this.configuration.keepAliveInterval)))}stopSendingKeepAlives(){this.keepAliveInterval&&clearInterval(this.keepAliveInterval),this.keepAliveDebounceTimeout&&clearTimeout(this.keepAliveDebounceTimeout),this.keepAliveInterval=void 0,this.keepAliveDebounceTimeout=void 0}}Dl.defaultOptions={server:"",connectionTimeout:5,keepAliveInterval:0,keepAliveDebounce:10,traceSip:!0};class Pi{constructor(A={}){if(this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this._state=Tt.Stopped,this._stateEventEmitter=new pa,this.delegate=A.delegate,this.options=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Pi.defaultOptions()),{sipjsId:oi(5)}),{uri:new er("sip","anonymous."+oi(6),"anonymous.invalid")}),{viaHost:oi(12)+".invalid"}),Pi.stripUndefinedProperties(A)),this.options.hackIpInContact)if(typeof this.options.hackIpInContact=="boolean"&&this.options.hackIpInContact){const r=Math.floor(Math.random()*254+1);this.options.viaHost="192.0.2."+r}else this.options.hackIpInContact&&(this.options.viaHost=this.options.hackIpInContact);switch(this.loggerFactory=new ow,this.logger=this.loggerFactory.getLogger("sip.UserAgent"),this.loggerFactory.builtinEnabled=this.options.logBuiltinEnabled,this.loggerFactory.connector=this.options.logConnector,this.options.logLevel){case"error":this.loggerFactory.level=bt.error;break;case"warn":this.loggerFactory.level=bt.warn;break;case"log":this.loggerFactory.level=bt.log;break;case"debug":this.loggerFactory.level=bt.debug}if(this.options.logConfiguration&&(this.logger.log("Configuration:"),Object.keys(this.options).forEach(t=>{const n=this.options[t];switch(t){case"uri":case"sessionDescriptionHandlerFactory":this.logger.log("· "+t+": "+n);break;case"authorizationPassword":this.logger.log("· "+t+": NOT SHOWN");break;case"transportConstructor":this.logger.log("· "+t+": "+n.name);break;default:this.logger.log("· "+t+": "+JSON.stringify(n))}})),this.options.transportOptions){const t=this.options.transportOptions,n=t.maxReconnectionAttempts,r=t.reconnectionTimeout;n!==void 0&&this.logger.warn('The transport option "maxReconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),r!==void 0&&this.logger.warn('The transport option "reconnectionTimeout" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),A.reconnectionDelay===void 0&&r!==void 0&&(this.options.reconnectionDelay=r),A.reconnectionAttempts===void 0&&n!==void 0&&(this.options.reconnectionAttempts=n)}if(A.reconnectionDelay!==void 0&&this.logger.warn('The user agent option "reconnectionDelay" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),A.reconnectionAttempts!==void 0&&this.logger.warn('The user agent option "reconnectionAttempts" as has apparently been specified and has been deprecated. It will no longer be available starting with SIP.js release 0.16.0. Please update accordingly.'),this._transport=new this.options.transportConstructor(this.getLogger("sip.Transport"),this.options.transportOptions),this.initTransportCallbacks(),this._contact=this.initContact(),this._instanceId=this.options.instanceId?this.options.instanceId:Pi.newUUID(),It.parse(this._instanceId,"uuid")===-1)throw new Error("Invalid instanceId.");this._userAgentCore=this.initCore()}static makeURI(A){return It.URIParse(A)}static defaultOptions(){return{allowLegacyNotifications:!1,authorizationHa1:"",authorizationPassword:"",authorizationUsername:"",delegate:{},contactName:"",contactParams:{transport:"ws"},displayName:"",forceRport:!1,gracefulShutdown:!0,hackAllowUnregisteredOptionTags:!1,hackIpInContact:!1,hackViaTcp:!1,instanceId:"",instanceIdAlwaysAdded:!1,logBuiltinEnabled:!0,logConfiguration:!0,logConnector:()=>{},logLevel:"log",noAnswerTimeout:60,preloadedRouteSet:[],reconnectionAttempts:0,reconnectionDelay:4,sendInitialProvisionalResponse:!0,sessionDescriptionHandlerFactory:ww(),sessionDescriptionHandlerFactoryOptions:{},sipExtension100rel:On.Unsupported,sipExtensionReplaces:On.Unsupported,sipExtensionExtraSupported:[],sipjsId:"",transportConstructor:Dl,transportOptions:{},uri:new er("sip","anonymous","anonymous.invalid"),userAgentString:"SIP.js/0.21.1",viaHost:""}}static newUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.floor(16*Math.random());return(t==="x"?n:n%4+8).toString(16)})}static stripUndefinedProperties(A){return Object.keys(A).reduce((t,n)=>(A[n]!==void 0&&(t[n]=A[n]),t),{})}get configuration(){return this.options}get contact(){return this._contact}get instanceId(){return this._instanceId}get state(){return this._state}get stateChange(){return this._stateEventEmitter}get transport(){return this._transport}get userAgentCore(){return this._userAgentCore}getLogger(A,t){return this.loggerFactory.getLogger(A,t)}getLoggerFactory(){return this.loggerFactory}isConnected(){return this.transport.isConnected()}reconnect(){return this.state===Tt.Stopped?Promise.reject(new Error("User agent stopped.")):Promise.resolve().then(()=>this.transport.connect())}start(){return this.state===Tt.Started?(this.logger.warn("User agent already started"),Promise.resolve()):(this.logger.log(`Starting ${this.configuration.uri}`),this.transitionState(Tt.Started),this.transport.connect())}async stop(){if(this.state===Tt.Stopped)return this.logger.warn("User agent already stopped"),Promise.resolve();if(this.logger.log(`Stopping ${this.configuration.uri}`),!this.options.gracefulShutdown)return this.logger.log("Dispose of transport"),this.transport.dispose().catch(a=>{throw this.logger.error(a.message),a}),this.logger.log("Dispose of core"),this.userAgentCore.dispose(),this._publishers={},this._registerers={},this._sessions={},this._subscriptions={},this.transitionState(Tt.Stopped),Promise.resolve();const A=Object.assign({},this._publishers),t=Object.assign({},this._registerers),n=Object.assign({},this._sessions),r=Object.assign({},this._subscriptions),i=this.transport,o=this.userAgentCore;this.logger.log("Dispose of registerers");for(const a in t)t[a]&&await t[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._registerers[a],s});this.logger.log("Dispose of sessions");for(const a in n)n[a]&&await n[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._sessions[a],s});this.logger.log("Dispose of subscriptions");for(const a in r)r[a]&&await r[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._subscriptions[a],s});this.logger.log("Dispose of publishers");for(const a in A)A[a]&&await A[a].dispose().catch(s=>{throw this.logger.error(s.message),delete this._publishers[a],s});this.logger.log("Dispose of transport"),await i.dispose().catch(a=>{throw this.logger.error(a.message),a}),this.logger.log("Dispose of core"),o.dispose(),this.transitionState(Tt.Stopped)}_makeInviter(A,t){return new M0(this,A,t)}attemptReconnection(A=1){const t=this.options.reconnectionAttempts,n=this.options.reconnectionDelay;A>t?this.logger.log("Maximum reconnection attempts reached"):(this.logger.log(`Reconnection attempt ${A} of ${t} - trying`),setTimeout(()=>{this.reconnect().then(()=>{this.logger.log(`Reconnection attempt ${A} of ${t} - succeeded`)}).catch(r=>{this.logger.error(r.message),this.logger.log(`Reconnection attempt ${A} of ${t} - failed`),this.attemptReconnection(++A)})},A===1?0:1e3*n))}initContact(){const A=this.options.contactName!==""?this.options.contactName:oi(8),t=this.options.contactParams;return{pubGruu:void 0,tempGruu:void 0,uri:new er("sip",A,this.options.viaHost,void 0,t),toString:(n={})=>{const r=n.anonymous||!1,i=n.outbound||!1,o=n.register||!1;let a="<";return a+=r?this.contact.tempGruu||`sip:anonymous@anonymous.invalid;transport=${t.transport?t.transport:"ws"}`:o?this.contact.uri:this.contact.pubGruu||this.contact.uri,i&&(a+=";ob"),a+=">",this.options.instanceIdAlwaysAdded&&(a+=';+sip.instance="<urn:uuid:'+this._instanceId+'>"'),a}}}initCore(){let A=[];A.push("outbound"),this.options.sipExtension100rel===On.Supported&&A.push("100rel"),this.options.sipExtensionReplaces===On.Supported&&A.push("replaces"),this.options.sipExtensionExtraSupported&&A.push(...this.options.sipExtensionExtraSupported),this.options.hackAllowUnregisteredOptionTags||(A=A.filter(i=>rw[i])),A=Array.from(new Set(A));const t=A.slice();(this.contact.pubGruu||this.contact.tempGruu)&&t.push("gruu");const n={aor:this.options.uri,contact:this.contact,displayName:this.options.displayName,loggerFactory:this.loggerFactory,hackViaTcp:this.options.hackViaTcp,routeSet:this.options.preloadedRouteSet,supportedOptionTags:A,supportedOptionTagsResponse:t,sipjsId:this.options.sipjsId,userAgentHeaderFieldValue:this.options.userAgentString,viaForceRport:this.options.forceRport,viaHost:this.options.viaHost,authenticationFactory:()=>{const i=this.options.authorizationUsername?this.options.authorizationUsername:this.options.uri.user,o=this.options.authorizationPassword?this.options.authorizationPassword:void 0,a=this.options.authorizationHa1?this.options.authorizationHa1:void 0;return new iw(this.getLoggerFactory(),a,i,o)},transportAccessor:()=>this.transport},r={onInvite:i=>{var o;const a=new Wu(this,i);if(i.delegate={onCancel:s=>{a._onCancel(s)},onTransportError:s=>{this.logger.error("A transport error has occurred while handling an incoming INVITE request.")}},i.trying(),this.options.sipExtensionReplaces!==On.Unsupported){const s=i.message.parseHeader("replaces");if(s){const l=s.call_id;if(typeof l!="string")throw new Error("Type of call id is not string");const u=s.replaces_to_tag;if(typeof u!="string")throw new Error("Type of to tag is not string");const V=s.replaces_from_tag;if(typeof V!="string")throw new Error("type of from tag is not string");const d=l+u+V,h=this.userAgentCore.dialogs.get(d);if(!h)return void a.reject({statusCode:481});if(!h.early&&s.early_only===!0)return void a.reject({statusCode:486});const m=this._sessions[l+V]||this._sessions[l+u]||void 0;if(!m)throw new Error("Session does not exist.");a._replacee=m}}if(!((o=this.delegate)===null||o===void 0)&&o.onInvite)return a.autoSendAnInitialProvisionalResponse?void a.progress().then(()=>{var s;if(((s=this.delegate)===null||s===void 0?void 0:s.onInvite)===void 0)throw new Error("onInvite undefined.");this.delegate.onInvite(a)}):void this.delegate.onInvite(a);a.reject({statusCode:486})},onMessage:i=>{if(this.delegate&&this.delegate.onMessage){const o=new y0(i);this.delegate.onMessage(o)}else i.accept()},onNotify:i=>{if(this.delegate&&this.delegate.onNotify){const o=new Ju(i);this.delegate.onNotify(o)}else this.options.allowLegacyNotifications?i.accept():i.reject({statusCode:481})},onRefer:i=>{this.logger.warn("Received an out of dialog REFER request"),this.delegate&&this.delegate.onReferRequest?this.delegate.onReferRequest(i):i.reject({statusCode:405})},onRegister:i=>{this.logger.warn("Received an out of dialog REGISTER request"),this.delegate&&this.delegate.onRegisterRequest?this.delegate.onRegisterRequest(i):i.reject({statusCode:405})},onSubscribe:i=>{this.logger.warn("Received an out of dialog SUBSCRIBE request"),this.delegate&&this.delegate.onSubscribeRequest?this.delegate.onSubscribeRequest(i):i.reject({statusCode:405})}};return new yw(n,r)}initTransportCallbacks(){this.transport.onConnect=()=>this.onTransportConnect(),this.transport.onDisconnect=A=>this.onTransportDisconnect(A),this.transport.onMessage=A=>this.onTransportMessage(A)}onTransportConnect(){this.state!==Tt.Stopped&&this.delegate&&this.delegate.onConnect&&this.delegate.onConnect()}onTransportDisconnect(A){this.state!==Tt.Stopped&&(this.delegate&&this.delegate.onDisconnect&&this.delegate.onDisconnect(A),A&&this.options.reconnectionAttempts>0&&this.attemptReconnection())}onTransportMessage(A){const t=Ts.parseMessage(A,this.getLogger("sip.Parser"));if(!t)return void this.logger.warn("Failed to parse incoming message. Dropping.");if(this.state===Tt.Stopped&&t instanceof Ji)return void this.logger.warn(`Received ${t.method} request while stopped. Dropping.`);const n=()=>{const r=["from","to","call_id","cseq","via"];for(const i of r)if(!t.hasHeader(i))return this.logger.warn(`Missing mandatory header field : ${i}.`),!1;return!0};if(t instanceof Ji){if(!n())return void this.logger.warn("Request missing mandatory header field. Dropping.");if(!t.toTag&&t.callId.substr(0,5)===this.options.sipjsId)return void this.userAgentCore.replyStateless(t,{statusCode:482});const r=fa(t.body),i=t.getHeader("content-length");if(i&&r<Number(i))return void this.userAgentCore.replyStateless(t,{statusCode:400})}if(t instanceof Lr){if(!n())return void this.logger.warn("Response missing mandatory header field. Dropping.");if(t.getHeaders("via").length>1)return void this.logger.warn("More than one Via header field present in the response. Dropping.");if(t.via.host!==this.options.viaHost||t.via.port!==void 0)return void this.logger.warn("Via sent-by in the response does not match UA Via host value. Dropping.");const r=fa(t.body),i=t.getHeader("content-length");if(i&&r<Number(i))return void this.logger.warn("Message body length is lower than the value in Content-Length header field. Dropping.")}if(t instanceof Ji)this.userAgentCore.receiveIncomingRequestFromTransport(t);else{if(!(t instanceof Lr))throw new Error("Invalid message type.");this.userAgentCore.receiveIncomingResponseFromTransport(t)}}transitionState(A,t){const n=()=>{throw new Error(`Invalid state transition from ${this._state} to ${A}`)};switch(this._state){case Tt.Started:A!==Tt.Stopped&&n();break;case Tt.Stopped:A!==Tt.Started&&n();break;default:throw new Error("Unknown state.")}this.logger.log(`Transitioned from ${this._state} to ${A}`),this._state=A,this._stateEventEmitter.emit(this._state)}}class D0{constructor(A){this.listeners=[],this.keyListeners={},this.data={...A},this.proxy=new Proxy(this.data,{set:(t,n,r)=>(t[n]!==r&&(t[n]=r,this.notify(),this.notifyKey(n,r)),!0)})}getState(){return this.proxy}setState(A,t=!1){let n=!1;for(const r in A)if(Object.prototype.hasOwnProperty.call(A,r)){const i=this.data[r],o=A[r];(t||i!==o)&&(this.data[r]=o,n=!0,this.notifyKey(r,o))}(n||t)&&this.notify()}subscribe(A){return this.listeners.push(A),()=>{this.listeners=this.listeners.filter(t=>t!==A)}}subscribeKey(A,t){return this.keyListeners[A]||(this.keyListeners[A]=[]),this.keyListeners[A].push(t),()=>{this.keyListeners[A]=this.keyListeners[A].filter(n=>n!==t)}}notify(){const A=this.getState();for(const t of this.listeners)t(A)}notifyKey(A,t){const n=this.keyListeners[A];n&&n.forEach(r=>r(t))}}var fe,Bt,ae,wn,eA,xA,Xe;(function(e){e[e.IDLE=1]="IDLE",e[e.BUSY=2]="BUSY",e[e.RINGING=3]="RINGING",e[e.OFFLINE=0]="OFFLINE",e[e.UNREGISTERED=4]="UNREGISTERED"})(fe||(fe={})),function(e){e.OUTGOING="outgoing",e.INCOMING="incoming",e.CONSULT="consult",e.MEETING="meeting",e.TRANSFER="transfer",e.PREDICT_OUT_CALL="predict_out_call"}(Bt||(Bt={})),function(e){e[e.OUT_CALL=100]="OUT_CALL",e[e.AGENT_STATE=101]="AGENT_STATE",e[e.OUT_CALL_INCOMING_CALL=102]="OUT_CALL_INCOMING_CALL",e[e.OUT_CALL_RINGING=103]="OUT_CALL_RINGING",e[e.OUT_CALL_ANSWER=104]="OUT_CALL_ANSWER",e[e.CALL_HOLD=105]="CALL_HOLD",e[e.CALL_UNHOLD=106]="CALL_UNHOLD",e[e.OUT_CALL_END=107]="OUT_CALL_END",e[e.CONSULT_REQUEST=108]="CONSULT_REQUEST",e[e.CONSULT_RINGING=109]="CONSULT_RINGING",e[e.CONSULT_ANSWER=110]="CONSULT_ANSWER",e[e.CONSULT_FAIL=111]="CONSULT_FAIL",e[e.MUTE=112]="MUTE",e[e.UNMUTE=113]="UNMUTE",e[e.CONSULT_CALL_IN=114]="CONSULT_CALL_IN",e[e.CONSULT_CALL_IN_SUCCESS=115]="CONSULT_CALL_IN_SUCCESS",e[e.CONSULT_RETURN_CALL=125]="CONSULT_RETURN_CALL",e[e.CONSULT_RETURN_CALL_SUCCESS=126]="CONSULT_RETURN_CALL_SUCCESS",e[e.CONSULT_TRANSFER=116]="CONSULT_TRANSFER",e[e.CONSULT_TRANSFER_FAILED=118]="CONSULT_TRANSFER_FAILED",e[e.CONSULT_TRANSFER_OFF_HOOK=117]="CONSULT_TRANSFER_OFF_HOOK",e[e.INCOMING_CALL=119]="INCOMING_CALL",e[e.INCOMING_CALL_OFF_HOOK=120]="INCOMING_CALL_OFF_HOOK",e[e.INCOMING_CALL_END=121]="INCOMING_CALL_END",e[e.SATISFACTION_EVALUATION=122]="SATISFACTION_EVALUATION",e[e.CONSULT_THREE_WAY=123]="CONSULT_THREE_WAY",e[e.CONSULT_THREE_WAY_RESULT=124]="CONSULT_THREE_WAY_RESULT",e[e.TRANSFER=127]="TRANSFER",e[e.TRANSFER_FAILED=128]="TRANSFER_FAILED",e[e.TRANSFER_INCOMING_CALL=129]="TRANSFER_INCOMING_CALL",e[e.TRANSFER_OFF_HOOK=130]="TRANSFER_OFF_HOOK",e[e.AGENT_HANGUP=131]="AGENT_HANGUP",e[e.KICK_OFFLINE=132]="KICK_OFFLINE",e[e.CONTINUOUS_NOT_ANSWER=133]="CONTINUOUS_NOT_ANSWER",e[e.PREVIEW_OUT_CALL=134]="PREVIEW_OUT_CALL",e[e.SIGN_OUT=135]="SIGN_OUT",e[e.SIGN_IN_SWITCH_DEVICE=136]="SIGN_IN_SWITCH_DEVICE",e[e.LISTEN_CALL_FAILED=137]="LISTEN_CALL_FAILED",e[e.LISTEN_INCOMING_CALL=138]="LISTEN_INCOMING_CALL",e[e.LISTEN_INCOMING_CALL_OFF_HOOK=139]="LISTEN_INCOMING_CALL_OFF_HOOK",e[e.EAR_SPEECH=140]="EAR_SPEECH",e[e.STOP_EAR_SPEECH=141]="STOP_EAR_SPEECH",e[e.CALL_FORCE_INSERT=142]="CALL_FORCE_INSERT"}(ae||(ae={})),function(e){e.WEB_RTC_CONNECTING="connecting",e.WEB_RTC_CONNECTED="connected",e.WEB_RTC_DISCONNECTING="disconnecting",e.WEB_RTC_DISCONNECTED="disconnected",e.WEB_RTC_REGISTERED="registered",e.WEB_RTC_UNREGISTERED="unregistered",e.WEB_RTC_TERMINATED="terminated",e.WEB_RTC_REGISTER_FAILED="register_failed",e.WEB_RTC_ANSWER_FAILED="answer_failed",e.WEB_RTC_SEND_DTMF="send_dtmf"}(wn||(wn={})),function(e){e.CUSTOMER_INFO="customer_info",e.CALL_PROGRESS="call_progress",e.OUT_INCOMING_CALL="out_call_incoming_call",e.PREVIEW_OUT_INCOMING_CALL="preview_out_incoming_call",e.OUT_SUCCESS="out_call_success",e.OUT_FAILED="out_call_failed",e.OUT_RINGING="out_call_ringing",e.OUT_OFF_ANSWER="out_call_answer",e.HOLD_SUCCESS="hold_success",e.HOLD_FAILED="hold_failed",e.UNHOLD_SUCCESS="unhold_success",e.UNHOLD_FAILED="unhold_failed",e.OUT_HANGUP="out_call_hangup",e.CONSULT_RINGING="consult_ringing",e.CONSULT_OFF_HOOK="consult_off_hook",e.CONSULT_FAILED="consult_failed",e.CONSULT_INCOMING="consult_incoming",e.CONSULT_CALL_IN_SUCCESS="consult_call_in_success",e.CONSULT_RETURN_CALL_SUCCESS="consult_return_call_success",e.OTHER_SIDE_CONSULT_HANGUP="other_side_consult_hangup",e.OUR_SIDE_CONSULT_HANGUP="our_side_consult_hangup",e.AGENT_STATE="agent_state",e.MUTE_SUCCESS="mute_success",e.MUTE_FAILED="mute_failed",e.UNMUTE_SUCCESS="unmute_success",e.UNMUTE_FAILED="unmute_failed",e.CONSULT_TRANSFER_SUCCESS="consult_transfer_success",e.CONSULT_TRANSFER_FAILED="consult_transfer_failed",e.CONSULT_TRANSFER_OFF_HOOK="consult_transfer_off_hook",e.INCOMING_CALL="incoming_call",e.PREDICT_INCOMING_CALL="predict_incoming_call",e.INCOMING_CALL_OFF_HOOK="incoming_call_off_hook",e.INCOMING_CALL_END="incoming_call_end",e.SATISFACTION_EVALUATION_SUCCESS="satisfaction_evaluation_success",e.SATISFACTION_EVALUATION_FAILED="satisfaction_evaluation_failed",e.CONSULT_THREE_WAY_SUCCESS="consult_three_way_success",e.CONSULT_THREE_WAY_FAILED="consult_three_way_failed",e.THREE_WAY_OUR_SIDE_HANGUP="three_way_our_side_hangup",e.TRANSFER_FAILED="transfer_failed",e.TRANSFER_PROGRESS="transfer_progress",e.TRANSFER_INCOMING_CALL="transfer_incoming_call",e.TRANSFER_OFF_HOOK="transfer_off_hook",e.TRANSFER_END="transfer_end",e.REJECT="reject",e.LISTEN_CALL_FAILED="listen_call_failed",e.LISTEN_INCOMING_CALL="listen_incoming_call",e.LISTEN_INCOMING_CALL_OFF_HOOK="listen_incoming_call_off_hook",e.LISTEN_HANGUP="listen_hangup",e.EAR_SPEECH_SUCCESS="ear_speech_success",e.EAR_SPEECH_BE_SUCCESS="ear_speech_be_success",e.EAR_SPEECH_FAILED="ear_speech_failed",e.STOP_EAR_SPEECH_SUCCESS="stop_ear_speech_success",e.STOP_EAR_SPEECH_FAILED="stop_ear_speech_failed",e.CALL_FORCE_INSERT_SUCCESS="call_force_insert_success",e.CALL_FORCE_INSERT_SUCCESS_LISTENER="call_force_insert_success_listener",e.CALL_FORCE_INSERT_FAILED="call_force_insert_failed"}(eA||(eA={})),function(e){e.EVENT_ALL="event_all",e.NOTIFICATION_CLICK="notification_click",e.UPDATE_ANSWER_DEVICE="update_answer_device",e.PHONE_BAR_OPERATION="phone_bar_operation",e.AGENT_INIT_STATUS="agent_init_status",e.WEBSITE_DELAY="website_delay",e.SELECT_EXTERNAL_NUMBER="select_external_number",e.FAIL_NOTIFICATION="fail_notification",e.KICK_OFF="kick_off",e.DESTROY="destroy",e.NETWORK_OFFLINE="network_offline",e.NETWORK_ONLINE="network_online",e.SIGN_OUT="sign_out",e.SIGN_IN_SWITCH_DEVICE="sign_in_switch_device"}(xA||(xA={})),function(e){e.RINGING="客户振铃",e.AGENT_RINGING="振铃中",e.CALLING="通话中",e.CONSULTING="正在咨询",e.CONSULT_CALL_IN="咨询来电",e.INCOMING_CALL="客户来电",e.MEETING="会议中",e.TRANSFERRING="转接中",e.TRANSFER_INCOMING_CALL="转接来电",e.HOLDING="保持中",e.MUTING="静音中",e.LISTENING="监听来电",e.LINKING="正在链接"}(Xe||(Xe={}));const Go=function(e){return{all:e=e||new Map,on:function(A,t){var n=e.get(A);n?n.push(t):e.set(A,[t])},off:function(A,t){var n=e.get(A);n&&(t?n.splice(n.indexOf(t)>>>0,1):e.set(A,[]))},emit:function(A,t){var n=e.get(A);n&&n.slice().map(function(r){r(t)}),(n=e.get("*"))&&n.slice().map(function(r){r(A,t)})}}}(),VA={on:(e,A)=>(Go.on(e,A),VA),off(e,A){Go.off(e,A)},emit(e,A){Go.emit(e,A),Go.emit(xA.EVENT_ALL,{event:e,data:A})},clearAllListeners(){Go.all.clear()}},$={agentInfo:{},isRtcReconnecting:!1,sessionId:"",enableBrowserAlert:!1,autoStateTimer:null,autoAnswerTimer:null,logBuiltinEnabled:!1,browserAlertTime:3e3,latency:0,monitoredAgentNo:"",earSpeakAgent:"",stateObject:{state:fe.BUSY,state_name:"忙碌"}},En={isCalling:!1,direction:null,outCallIsAnswer:!1,incomingIsAnswer:!1,transferIsAnswer:!1,isMeeting:!1,isHold:!1,displayText:"",isMuted:!1,consultIsAnswer:!1,actionConfigs:[],answerDevice:1,selectOutNumber:"",customerObject:void 0,isNextState:!0,isSipConnected:!1},N=new class extends D0{updateIsCalling(e){this.setState({isCalling:e})}updateDirection(e){this.setState({direction:e})}updateOutCallIsAnswer(e){this.setState({outCallIsAnswer:e})}updateIsHold(e){var t;if(((t=$.stateObject)==null?void 0:t.state)===fe.UNREGISTERED)return;const A=this.get("actionConfigs");if(e){const n=[...A.filter(r=>r!=="hold")];n.push("unhold"),this.updateActionConfigs(n)}else{const n=[...A.filter(r=>r!=="unhold")];n.push("hold"),this.updateActionConfigs(n)}this.getState().isHold=e}updateDisplayText(e){this.setState({displayText:e}),VA.emit(eA.CALL_PROGRESS,e)}updateActionConfigs(e){const{show_satisfaction:A}=$.agentInfo||{},t=this.get("answerDevice"),n=e.filter(r=>(A!==0||r!=="satisfaction")&&(t!==2||r!=="answer"));this.setState({actionConfigs:n}),VA.emit(xA.PHONE_BAR_OPERATION,n)}updateConsultIsAnswer(e){this.setState({consultIsAnswer:e})}updateIsMuted(e){var t;if(((t=$.stateObject)==null?void 0:t.state)===fe.UNREGISTERED)return;const A=this.get("actionConfigs");if(e){const n=[...A.filter(r=>r!=="mute")];n.push("unmute"),this.updateActionConfigs(n)}else{const n=[...A.filter(r=>r!=="unmute")];n.push("mute"),this.updateActionConfigs(n)}this.setState({isMuted:e})}updateIncomingIsAnswer(e){this.setState({incomingIsAnswer:e})}updateAnswerDevice(e){this.setState({answerDevice:e}),VA.emit(xA.UPDATE_ANSWER_DEVICE,e)}updateIsMeeting(e){this.setState({isMeeting:e})}updateTransferIsAnswer(e){this.setState({transferIsAnswer:e})}updateSelectOutNumber(e){VA.emit(xA.SELECT_EXTERNAL_NUMBER,e),this.setState({selectOutNumber:e})}updateCustomerInfo(e){const A=this.get("displayText");if(e&&A){const{contact_count:t,customer_name:n,phone:r,city:i,province:o,is_vip:a,in_contact_count:s,trace_id:l,contact_count_month:u,in_contact_count_month:V}=e;VA.emit(eA.CUSTOMER_INFO,{customer_name:n||"未知客户",phone:r,city:i||"未知",province:o||"未知",contact_count:t||0,in_contact_count:s||0,is_vip:a,trace_id:l,contact_count_month:u||0,in_contact_count_month:V||0})}else VA.emit(eA.CUSTOMER_INFO,void 0);this.setState({customerObject:e})}updateIsNextState(e){this.setState({isNextState:e}),e?VA.emit(xA.NETWORK_ONLINE):($.stateObject={state:fe.OFFLINE,state_name:"离线"},this.updateActionConfigs([]),VA.emit(eA.AGENT_STATE,$.stateObject),VA.emit(xA.NETWORK_OFFLINE))}updateIsSipConnected(e){this.setState({isSipConnected:e})}reset(){this.updateAnswerDevice(1),this.updateIsCalling(En.isCalling),this.updateDirection(En.direction),this.updateOutCallIsAnswer(En.outCallIsAnswer),this.updateIsHold(En.isHold),this.updateDisplayText(En.displayText),this.updateActionConfigs(En.actionConfigs),this.updateConsultIsAnswer(En.consultIsAnswer),this.updateIsMuted(En.isMuted),this.updateIncomingIsAnswer(En.incomingIsAnswer),this.updateIsMeeting(En.isMeeting),this.updateTransferIsAnswer(En.transferIsAnswer),this.updateCustomerInfo(void 0)}getCallInfo(){return this.getState()}get(e){return this.getState()[e]}}(En),Gd=new class extends D0{updateRttObject(e){this.setState({rttObject:e}),VA.emit(xA.WEBSITE_DELAY,e)}}({rttObject:{rtt:null,jitter:null,packetsLost:null,packetsReceived:null,packetsSent:null,sendBitrate:null,recvBitrate:null,codec:null}});let Mw=class{constructor(A,t){this.config=A,this.eventCallback=t,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.registerIntervalTimer=null,this.registerInterval=6e4,this.handleNetworkInfoChange=n=>{var r,i;(r=n.rttObject)!=null&&r.rtt&&((((i=n.rttObject)==null?void 0:i.rtt)||0)===0?this.isOffline||(this.isOffline=!0,this.handleOffline()):this.isOffline&&(this.isOffline=!1,this.handleOnline()))},this.handleOffline=()=>{console.warn("[SIPClient] 网络断开,准备销毁 SIP 客户端",new Date().toLocaleString()),VA.emit(xA.FAIL_NOTIFICATION,"网络断开,准备销毁 SIP 客户端"),this.destroy()},this.handleOnline=()=>{console.warn("[SIPClient] 网络恢复,准备重新启动 SIP 客户端",new Date().toLocaleString()),this.reconnect()},this.sleep=n=>new Promise(r=>setTimeout(r,n)),Gd.subscribe(this.handleNetworkInfoChange)}async start(){const A=Pi.makeURI(`sip:${this.config.user}@${this.config.server}`);if(!A)throw new Error("无效的SIP配置");const t={uri:A,authorizationUsername:this.config.user,authorizationPassword:this.config.password,transportOptions:{server:this.config.webSocket,connectionTimeout:30,keepAliveInterval:20},contactName:this.config.user,contactParams:{transport:"wss"},userAgentString:"SwiftSIP/1.1.33",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:500},logBuiltinEnabled:$.logBuiltinEnabled};this.userAgent=new Pi(t),this.setupEventListeners(),await this.userAgent.start(),await this.register()}setupEventListeners(){this.userAgent&&(this.userAgent.transport.stateChange.addListener(A=>{var n;let t;switch(A){case de.Connecting:t=wn.WEB_RTC_CONNECTING;break;case de.Connected:t=wn.WEB_RTC_CONNECTED,this.reconnectAttempts=0,$.isRtcReconnecting=!1,N.updateIsSipConnected(!0),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);break;case de.Disconnecting:t=wn.WEB_RTC_DISCONNECTING,N.updateIsSipConnected(!1);break;case de.Disconnected:{if(N.updateIsSipConnected(!1),this.isManuallyStopped)return void console.warn("[SIP] 手动断开,不触发重连");VA.emit(xA.FAIL_NOTIFICATION,"软电话链接失败"),t=wn.WEB_RTC_DISCONNECTED;const r=N.get("answerDevice");if(!$.isRtcReconnecting&&this.reconnectAttempts<this.maxReconnectAttempts&&r===1){this.reconnectAttempts++;const i=1e3*this.reconnectAttempts;console.warn(`SIP WebSocket 断开,第 ${this.reconnectAttempts} 次尝试重连,${i}ms 后重试...`),this.reconnectTimer=setTimeout(()=>{this.reconnect()},i)}else this.reconnectAttempts>=this.maxReconnectAttempts&&(console.error("SIP 重连失败:已达到最大重试次数"),VA.emit(xA.FAIL_NOTIFICATION,"SIP 重连失败:已达到最大重试次数"));break}default:N.updateIsSipConnected(!1),t="unknown"}(n=this.eventCallback)==null||n.call(this,{type:t})}),this.userAgent.delegate={onInvite:A=>{this.handleIncomingCall(A)}})}async refreshRegister(){if(this.registerer)try{await this.registerer.register(),new Date().toLocaleTimeString()}catch(A){console.error("[SIPClient] REGISTER刷新失败",A)}}async register(){var A,t;if(this.userAgent){this.registerer=new _n(this.userAgent),(A=this.registerer)==null||A.stateChange.addListener(n=>{var i;let r;switch(n){case Ye.Initial:N.updateDisplayText(Xe.LINKING),r="initial";break;case Ye.Registered:N.updateDisplayText(""),r=wn.WEB_RTC_REGISTERED;break;case Ye.Unregistered:r=wn.WEB_RTC_UNREGISTERED;break;case Ye.Terminated:r=wn.WEB_RTC_TERMINATED;break;default:r="unknown"}(i=this.eventCallback)==null||i.call(this,{type:r})});try{await this.registerer.register(),this.registerIntervalTimer||(this.registerIntervalTimer=setInterval(()=>{this.refreshRegister()},this.registerInterval))}catch(n){(t=this.eventCallback)==null||t.call(this,{type:wn.WEB_RTC_REGISTER_FAILED,data:n})}}}attachRemoteAudio(A){const t=A.sessionDescriptionHandler;if(t){const n=t.peerConnection;if(!n)return;const r=new MediaStream;n.getReceivers().forEach(o=>{o.track&&o.track.kind==="audio"&&r.addTrack(o.track)});let i=document.getElementById("sip-remote-audio");i||(i=document.createElement("audio"),i.id="sip-remote-audio",i.autoplay=!0,i.style.display="none",document.body.appendChild(i)),i.srcObject=r,i.play().catch(o=>{console.error("音频播放失败,需要用户交互触发",o)})}}handleSessionState(A,t,n){A.stateChange.addListener(r=>{switch(r){case dA.Established:clearTimeout(this.callTimeoutTimer),this.activeSession=A,this.attachRemoteAudio(A);break;case dA.Terminating:break;case dA.Terminated:this.activeSession=null,clearTimeout(this.callTimeoutTimer);case dA.Establishing:}})}handleIncomingCall(A){this.incomingInvitation=A,this.handleSessionState(A,!1),N.get("direction")===Bt.OUTGOING&&this.answerCall()}async answerCall(){var A;if(!this.incomingInvitation)throw new Error("无来电可接听");$.autoAnswerTimer&&(clearTimeout($.autoAnswerTimer),$.autoAnswerTimer=null);try{await this.incomingInvitation.accept(),this.activeSession=this.incomingInvitation,this.incomingInvitation=null}catch(t){(A=this.eventCallback)==null||A.call(this,{type:wn.WEB_RTC_ANSWER_FAILED,data:{detail:t}})}}async rejectInCall(){var A;if(this.incomingInvitation)try{await this.incomingInvitation.reject(),this.incomingInvitation=null,N.updateDirection(null),N.updateIsCalling(!1),clearTimeout(this.callTimeoutTimer)}catch(t){(A=this.eventCallback)==null||A.call(this,{type:"error",data:{message:"拒接失败",detail:t}})}}sendDTMF(A){var n;if(!this.activeSession)throw new Error("当前没有活跃的通话");const t=this.activeSession.sessionDescriptionHandler;t&&typeof t.sendDtmf=="function"?(t.sendDtmf(A),(n=this.eventCallback)==null||n.call(this,{type:wn.WEB_RTC_SEND_DTMF,data:{tone:A}})):console.warn("DTMF发送不支持或未初始化")}async hangup(){if(this.activeSession,this.activeSession){clearTimeout(this.callTimeoutTimer);const A=this.activeSession;if(!A)return;const t=A.state;try{t===dA.Established?await A.bye():t===dA.Establishing&&(A instanceof M0?await A.cancel():A instanceof Wu&&await A.reject()),clearTimeout(this.callTimeoutTimer)}catch(n){console.error("挂断失败",n)}finally{this.activeSession=null}}}async rejectOutCall(){this.activeSession instanceof Wu&&(await this.activeSession.reject(),this.activeSession=null)}async destroy(){if(this.isManuallyStopped=!0,clearTimeout(this.callTimeoutTimer),clearInterval(this.registerIntervalTimer),this.activeSession&&await this.hangup(),this.registerIntervalTimer&&(clearInterval(this.registerIntervalTimer),this.registerIntervalTimer=null),this.registerer){try{await this.registerer.unregister()}catch(A){console.warn("注销失败",A)}this.registerer=null}this.userAgent&&(await this.userAgent.stop(),this.userAgent=null)}async reconnect(){if(!$.isRtcReconnecting){$.isRtcReconnecting=!0;try{await this.destroy(),await this.start(),this.isOffline=!1}catch(A){console.error("重连失败",A)}finally{$.isRtcReconnecting=!1}}}async getNetworkStats(){var A;if(this.activeSession){const t=(A=this.activeSession.sessionDescriptionHandler)==null?void 0:A.peerConnection;if(!t)return null;const n=await t.getStats(),r={};return n.forEach(i=>{i.type==="candidate-pair"&&i.state==="succeeded"&&i.currentRoundTripTime!=null&&(r.rtt=+(1e3*i.currentRoundTripTime).toFixed(2)),i.type==="inbound-rtp"&&i.kind==="audio"&&(r.jitter=+(1e3*i.jitter).toFixed(2),r.packetsLost=i.packetsLost,r.packetsReceived=i.packetsReceived,i.bytesReceived&&i.timestamp&&(r.recvBitrate=+(i.bytesReceived/1024).toFixed(2))),i.type==="outbound-rtp"&&i.kind==="audio"&&(r.packetsSent=i.packetsSent,i.bytesSent&&i.timestamp&&(r.sendBitrate=+(i.bytesSent/1024).toFixed(2))),i.type==="codec"&&i.mimeType&&(r.codec=i.mimeType)}),{...r,rtt:(r==null?void 0:r.rtt)||40}}return{rtt:$.latency||1}}};/**
|
|
156
156
|
* @license
|
|
157
157
|
* Copyright 2019 Google LLC
|
|
158
158
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -1064,7 +1064,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
1064
1064
|
clearInterval(timer);
|
|
1065
1065
|
}
|
|
1066
1066
|
};
|
|
1067
|
-
`],{type:"application/javascript"}),t=URL.createObjectURL(A);this.heartbeatWorker=new Worker(t),this.heartbeatWorker.onmessage=()=>{const n=new Date().getTime();this.sendMessage({type:0,msg_id:n}),this.pendingMessages.set(n,performance.now())},this.heartbeatWorker.postMessage("start")}stopHeartbeat(){this.heartbeatWorker&&(this.heartbeatWorker.postMessage("stop"),this.heartbeatWorker.terminate(),this.heartbeatWorker=null)}sendMessage(A){var t;((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?(this.ws.send(JSON.stringify(A)),A.type!==0&&zh("%cWebSocket 发送消息:","color: green; font-weight: bold;",A)):console.warn("WebSocket 未连接,消息未发送")}close(){var A;this.manualClose=!0,this.stopHeartbeat(),(A=this.ws)==null||A.close()}reconnect(){this.initWebSocket()}static __internalClose(){cr&&(cr.close(),cr=null)}static __internalSend(A){if(!cr)throw new Error("WebSocket 尚未初始化");cr.sendMessage(A)}}class fM{constructor(A){this.sipClient=null,this.sipClient=A}roleMute(){const A=N.get("isCalling"),t=$.sessionId;if(!A)throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));if(!t)throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}))}holdCall(){this.roleMute();const A=N.get("isHold"),{sessionId:t}=$;if(t){if(!N.get("actionConfigs").includes("hold"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿保持"}));if(A)throw new Error(JSON.stringify({code:1,msg:"当前已处于保持状态"}));dt.__internalSend({type:ae.CALL_HOLD,data:{session_id:t}})}}unholdCall(){this.roleMute();const{isHold:A}=N.getState(),{sessionId:t}=$;if(!N.get("actionConfigs").includes("unhold"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿取消保持"}));if(t){if(!A)throw new Error(JSON.stringify({code:1,msg:"当前未处于保持状态"}));dt.__internalSend({type:ae.CALL_UNHOLD,data:{session_id:t}})}}sendDTMF(A){if(N.get("answerDevice")!==1)throw new Error(JSON.stringify({code:1,msg:"当前设备不支持此功能"}));if(!N.get("actionConfigs").includes("dtmf"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿发送按键"}));const{isCalling:t}=N.getState();if(!t)throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));this.sipClient.sendDTMF(A)}cancelCall(){if(!N.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));const A=$.sessionId;VA.emit(eA.REJECT,{session_id:A}),dt.__internalSend({type:ae.AGENT_HANGUP,data:{session_id:A}})}async consultCall(A){this.roleMute();const{isCalling:t,outCallIsAnswer:n,consultIsAnswer:r,incomingIsAnswer:i}=N.getState(),o=$.sessionId;if(!N.get("actionConfigs").includes("consult"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用咨询"}));if(r)throw new Error(JSON.stringify({code:1,msg:"当前正在咨询"}));if(!(t||n||i))throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));if(!o)throw new Error(JSON.stringify({code:1,msg:"sessionId不存在"}));dt.__internalSend({type:ae.CONSULT_REQUEST,data:{session_id:o,consultation_agent_no:A}})}async answerCall(){if(N.get("answerDevice")!==1)throw new Error(JSON.stringify({code:1,msg:"当前设备不支持此功能"}));await this.sipClient.answerCall()}makeCall(A){if(typeof A!="string"||A.trim()==="")throw new Error(JSON.stringify({code:1,msg:"外呼号码非法"}));const t={};if($u(A))t.trace_id=A;else{if(!/^(?:1[3-9]\d{9}|0\d{2,3}-?\d{7,8})$/.test(A.trim()))throw new Error(JSON.stringify({code:1,msg:"外呼号码非法"}));t.customer_phone=A.replace(/[\s\r\n-]+/g,"")}const n=N.get("isCalling"),r=N.get("selectOutNumber")||"";if(n)throw new Error(JSON.stringify({code:1,msg:"正在呼叫中,请勿重复点击"}));N.updateIsCalling(!0),N.updateDirection(Bt.OUTGOING),dt.__internalSend({type:ae.OUT_CALL,data:{...t,caller:r.replace(/[\s\r\n-]+/g,"")}})}previewCall(A,t){const n={};$u(A)?n.trace_id=A:n.customer_phone=A.replace(/[\s\r\n-]+/g,"");const r=N.get("isCalling"),i=N.get("selectOutNumber")||"";if(r)throw new Error(JSON.stringify({code:1,msg:"正在呼叫中,请勿重复点击"}));if(typeof A!="string"||A.trim()==="")throw new Error(JSON.stringify({code:1,msg:"外呼号码非法"}));N.updateIsCalling(!0),N.updateDirection(Bt.OUTGOING),dt.__internalSend({type:ae.PREVIEW_OUT_CALL,data:{...n,caller:i,preview_task_id:t}})}async hangup(){if(!N.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));const A=$.sessionId;dt.__internalSend({type:ae.AGENT_HANGUP,data:{session_id:A}})}mute(){this.roleMute();const A=N.get("actionConfigs"),t=N.get("isMuted"),n=$.sessionId;if(t)throw new Error(JSON.stringify({code:1,msg:"当前未处于静音状态"}));if(!A.includes("mute"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用静音"}));dt.__internalSend({type:ae.MUTE,data:{session_id:n}})}unmute(){this.roleMute();const A=N.get("actionConfigs"),t=N.get("isMuted"),n=$.sessionId;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前未处于未静音状态"}));if(!A.includes("unmute"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用静音"}));dt.__internalSend({type:ae.UNMUTE,data:{session_id:n}})}consultTransfer(){this.roleMute();const A=N.get("consultIsAnswer"),t=$.sessionId;if(!N.get("actionConfigs").includes("consult_transfer"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用咨询转移"}));if(!A)throw new Error(JSON.stringify({code:1,msg:"当前未处于咨询中"}));dt.__internalSend({type:ae.CONSULT_TRANSFER,data:{session_id:t}})}satisfactionEvaluation(){this.roleMute();const A=$.sessionId;if(!N.get("actionConfigs").includes("satisfaction"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用满意度评价"}));dt.__internalSend({type:ae.SATISFACTION_EVALUATION,data:{session_id:A}})}startConference(){if(this.roleMute(),!N.get("actionConfigs").includes("conference"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用三方会议"}));const A=$.sessionId;if(!N.get("consultIsAnswer"))throw new Error(JSON.stringify({code:1,msg:"当前未处于咨询中"}));dt.__internalSend({type:ae.CONSULT_THREE_WAY,data:{session_id:A}})}consultRetrieve(){if(this.roleMute(),!N.get("actionConfigs").includes("consult_retrieve"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿取回通话"}));const A=$.sessionId;if(!N.get("consultIsAnswer"))throw new Error(JSON.stringify({code:1,msg:"当前未处于咨询中"}));dt.__internalSend({type:ae.CONSULT_RETURN_CALL,data:{session_id:A}})}async transferAgent(A){if(this.roleMute(),!N.get("actionConfigs").includes("transfer"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿转接"}));const{transferIsAnswer:t}=N.getState(),n=$.sessionId;if(t)throw new Error(JSON.stringify({code:1,msg:"当前正在转接"}));dt.__internalSend({type:ae.TRANSFER,data:{session_id:n,transfer_type:0,transfer_dest:A}})}async transferOutline(A){if(this.roleMute(),!N.get("actionConfigs").includes("transfer"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿转接"}));if(!A)throw new Error(JSON.stringify({code:1,msg:"号码不能为空"}));if(!/^\d+$/.test(A))throw new Error(JSON.stringify({code:1,msg:"号码格式错误"}));const{transferIsAnswer:t}=N.getState(),n=$.sessionId;if(t)throw new Error(JSON.stringify({code:1,msg:"当前正在转接"}));if(t)throw new Error(JSON.stringify({code:1,msg:"当前正在转接"}));dt.__internalSend({type:ae.TRANSFER,data:{session_id:n,transfer_type:2,transfer_dest:A}})}}var Vn,Wt,Vt,at,ui,hr,Ma,Sa,Vi,zn,Ba,Qa,Pr,J0,P0,ba,W0;const El=class El{constructor(){en(this,Pr);en(this,Wt);en(this,Vt);en(this,at);en(this,ui);en(this,hr);en(this,Ma);en(this,Sa);en(this,Vi);en(this,zn);en(this,Ba);en(this,Qa);en(this,ba);if(ut(this,Wt,null),ut(this,Vt,new ho),ut(this,ui,null),ut(this,hr,!1),ut(this,Vi,!1),ut(this,zn,null),ut(this,Ba,()=>{N.updateIsNextState(!0)}),ut(this,Qa,()=>{N.updateIsNextState(!1)}),this.initWebRtc=async()=>{if(ee(this,Wt))return;const A=$.agentInfo.sip_account_list.find(t=>t.device_type===1);if(!A)throw new Error(JSON.stringify({code:1,msg:"未找到 sip_account_list"}));{const t=A.sip_register_addr;ut(this,Wt,new Mw({server:t.split(":")[0],user:A.sip_account,password:A.sip_password,webSocket:`wss://${t}`,callTimeout:3e4},ee(this,ba))),await ee(this,Wt).start()}},ut(this,ba,A=>{const{type:t,data:n}=A;VA.emit(t,n)}),!Vn._creatingInstance)throw new Error("请使用 YSYTAgentSdk.getInstance() 获取实例");clearInterval(ee(this,ui)),ut(this,ui,setInterval(async()=>{const A=await _a(this,Pr,W0).call(this);Gd.updateRttObject(A)},2e3)),Li.requestMediaPermissions(),ut(this,Ma,N.subscribeKey("answerDevice",async A=>{A===1?$.stateObject.state===fe.UNREGISTERED&&await ee(this,Vt)._changeState({data:{...$.stateBeforeChange,state_name:$.stateBeforeChange.state===fe.IDLE?"空闲":"忙碌"}}):await this.destroyRtc()})),ut(this,Sa,N.subscribeKey("isNextState",async A=>{if(A){await ee(this,Vt)._agentLogin(ds),N.get("answerDevice")===1&&await ee(this,Wt).reconnect();let t="";const n=new URL(Ni).host;t=Ni.includes("https")?`wss://${n}`:`ws://${n}`;const{agent_no:r}=$.agentInfo;dt.getInstance({url:`${t}/ccs-ws/api/v1/ws/call/${r}?Authorization=`,sipClient:ee(this,Wt)}),$.stateObject.state===fe.OFFLINE&&setTimeout(()=>{ee(this,Vt)._changeState({data:{...ee(this,zn),state_name:ee(this,zn).state===fe.BUSY&&ee(this,zn).state_name==="整理"?"忙碌":ee(this,zn).state_name},success:()=>{N.updateDisplayText(""),VA.emit(eA.AGENT_STATE,ee(this,zn))}})},10)}else ut(this,zn,$.stateObject),dt.__internalClose(),N.updateDisplayText("离线")})),this.on(xA.KICK_OFF,()=>{this.destroy()}),window.addEventListener("beforeunload",A=>{A.returnValue="",this.destroy()}),window.addEventListener("online",ee(this,Ba)),window.addEventListener("offline",ee(this,Qa))}static get instance(){return this._instance}static async destroyInstance(){this._instance&&(await this._instance.destroy(),this._instance=null)}static getInstance(A){if(!this._instance){if(!A)throw new Error("首次调用必须传入配置参数");const{url:t,appKey:n,appSecret:r,agentNo:i}=A;Ni=t||"https://aicc-api.yescloudy.com",Kd=n,jd=r,ds=i,Vn._creatingInstance=!0,this._instance=new Vn,delete Vn._creatingInstance}return this._instance}getInit(){return ee(this,Vi)}async init({actionNodeParams:A,enableBrowserAlert:t,logBuiltinEnabled:n,browserAlertTime:r,initialState:i,initDevice:o}){try{let a="";const s=new URL(Ni).host;a=Ni.includes("https")?`wss://${s}`:`ws://${s}`;const l=dt.getInstance({url:`${a}/ccs-ws/api/v1/ws/call/${ds}?Authorization=`,sipClient:null,onOpen:async()=>{const{viewHtmlElement:u,rttHTML:V}=A||{};$.logBuiltinEnabled=n||!1,$.browserAlertTime=r||5e3,await ee(this,Vt)._agentLogin(ds);const{current_answer_device:d,current_state:h,out_display_number:m,out_display_select_switch:C}=$.agentInfo;(i||h)===fe.IDLE?(N.updateActionConfigs(Pt),$.stateObject={state:i||h,state_name:"空闲"},$.stateBeforeChange=$.stateObject):(i||h)===fe.BUSY?(N.updateActionConfigs(Al),$.stateObject={state:h,state_name:"忙碌"},$.stateBeforeChange=$.stateObject):(i||h)===fe.UNREGISTERED&&(N.updateActionConfigs(Al),$.stateObject={state:h,state_name:"未注册"}),C===1?N.updateSelectOutNumber(m):N.updateSelectOutNumber(""),N.updateAnswerDevice(o||d),(o||d)===1&&(await this.initWebRtc(),ho.setInitRtcFn(this.initWebRtc),l.setSipClient(ee(this,Wt))),ut(this,at,new fM(ee(this,Wt))),A&&u&&(ut(this,hr,!0),new hM({container:u,rttHTML:V,statusParams:{state:$.stateObject.state,statusName:$.stateObject.state_name}},this,ee(this,at))),$.enableBrowserAlert=t,t&&Li.requestPermission(),VA.emit(xA.AGENT_INIT_STATUS,!0),ut(this,Vi,!0),clearInterval(Vn._timer),Vn._timer=null,_a(this,Pr,P0).call(this)}})}catch{ee(this,hr)&&un("初始化失败"),VA.emit(xA.AGENT_INIT_STATUS,!1),ut(this,Vi,!1)}}on(A,t){return VA.on(A,t),this}off(A,t){VA.off(A,t)}offAll(){VA.clearAllListeners()}async destroyRtc(){var A;await((A=ee(this,Wt))==null?void 0:A.destroy()),ut(this,Wt,null)}async destroy(){var A,t;Vn._instance&&(await this.destroyRtc(),clearInterval(ee(this,ui)),dt.__internalClose(),VA.emit(xA.DESTROY),this.offAll(),(A=ee(this,Ma))==null||A.call(this),(t=ee(this,Sa))==null||t.call(this),ut(this,hr,!1),Vn._instance=null,N.reset(),N.updateSelectOutNumber(""),clearInterval(Vn._timer),Vn._timer=null)}get call_api(){const A=t=>(...n)=>{if(!ee(this,hr))return t.apply(this,n);console.warn("当前未使用个人开发模式")};return{answerCall:A(()=>ee(this,at).answerCall()),makeCall:t=>ee(this,at).makeCall(t),previewMakeCall:(t,n)=>ee(this,at).previewCall(t,n),cancelCall:A(()=>ee(this,at).cancelCall()),hangup:A(()=>ee(this,at).hangup()),sendDTMF:A(t=>ee(this,at).sendDTMF(t)),holdCall:A(()=>ee(this,at).holdCall()),unholdCall:A(()=>ee(this,at).unholdCall()),consultCall:A(async t=>{try{await ee(this,at).consultCall(t)}catch(n){throw console.warn(n),n}}),consultRetrieve:A(()=>ee(this,at).consultRetrieve()),consultTransfer:A(()=>ee(this,at).consultTransfer()),mute:A(()=>ee(this,at).mute()),unmute:A(()=>ee(this,at).unmute()),satisfactionEvaluation:A(()=>ee(this,at).satisfactionEvaluation()),startConference:A(()=>ee(this,at).startConference()),transferAgent:A(t=>ee(this,at).transferAgent(t)),transferOutline:A(t=>ee(this,at).transferOutline(t)),earSpeakStart:A(t=>ee(this,Vt).earCall(t)),earSpeakStop:A(t=>ee(this,Vt).stopEarCall(t)),forceInsert:A(t=>ee(this,Vt).forceInsert(t)),forceDisconnect:A(t=>ee(this,Vt).forceDisconnect(t))}}get agent_api(){const A=t=>(...n)=>{if(!ee(this,hr))return t.apply(this,n);console.warn("当前未使用个人开发模式")};return{changeDevice:A(t=>ee(this,Vt).changeDevice(t)),changeState:A(t=>ee(this,Vt).changeState(t)),getIdleAgentList:A(t=>ee(this,Vt).getIdleAgentList(t)),getAgentState:A(t=>ee(this,Vt).getAgentState(t)),setAgentExplicit:A(t=>ee(this,Vt).setAgentExplicit(t)),checkAgentLogin:t=>ee(this,Vt).checkAgentLogin(t),getCallRecord:t=>ee(this,Vt).getCallRecord(t),agentLogout:async(t,n)=>{try{await ee(this,Vt).logout(t),await this.destroy(),n==null||n({code:0,msg:""})}catch{}},listenAgentCall:t=>ee(this,Vt).listenCall(t)}}getAgentData(){const{agent_no:A,agent_name:t,answer_devices:n,out_display_data:r,out_display_select_switch:i,current_state:o}=$.agentInfo,{stateObject:a}=$,s={1:"软电话",2:"手机模式",3:"SIP话机"};return{agent_no:A,agent_name:t,init_state:o,default_device:N.get("answerDevice"),out_display_data:r,out_display_select_switch:i,answer_devices:(n||"").split(",").map(l=>({value:Number(l),label:s[Number(l)]})),stateObject:a}}async getRealTimeCustomerInfo(){return N.get("customerObject")}setBrowserAlert(A){if(typeof A!="boolean")throw new Error(JSON.stringify({code:1,msg:"参数类型错误"}));$.logBuiltinEnabled=A||!1}setBrowserAlertTime(A){if(typeof A!="number")throw new Error(JSON.stringify({code:1,msg:"参数类型错误"}));$.browserAlertTime=A||3e3}};Wt=new WeakMap,Vt=new WeakMap,at=new WeakMap,ui=new WeakMap,hr=new WeakMap,Ma=new WeakMap,Sa=new WeakMap,Vi=new WeakMap,zn=new WeakMap,Ba=new WeakMap,Qa=new WeakMap,Pr=new WeakSet,J0=async function(){const A=N.get("isNextState");try{await gM(),A||N.updateIsNextState(!0)}catch{VA.emit(xA.FAIL_NOTIFICATION,"网络断开,请检查网络"),A&&N.updateIsNextState(!1)}},P0=function(){Vn._timer||(Vn._timer=setInterval(()=>_a(this,Pr,J0).call(this),3e3))},ba=new WeakMap,W0=async function(){return ee(this,Wt)?ee(this,Wt).getNetworkStats():{}},El._instance=null,El._timer=null;let Ot=El;Vn=Ot;var nn=function(){return nn=Object.assign||function(A){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(A[i]=t[i])}return A},nn.apply(this,arguments)};function qi(e,A,t){if(t||arguments.length===2)for(var n=0,r=A.length,i;n<r;n++)(i||!(n in A))&&(i||(i=Array.prototype.slice.call(A,0,n)),i[n]=A[n]);return e.concat(i||Array.prototype.slice.call(A))}function mM(e){var A=Object.create(null);return function(t){return A[t]===void 0&&(A[t]=e(t)),A[t]}}var qM=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,CM=mM(function(e){return qM.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91}),At="-ms-",ea="-moz-",Ke="-webkit-",z0="comm",Fl="rule",Hd="decl",vM="@import",X0="@keyframes",EM="@layer",_0=Math.abs,Jd=String.fromCharCode,AV=Object.assign;function IM(e,A){return Qt(e,0)^45?(((A<<2^Qt(e,0))<<2^Qt(e,1))<<2^Qt(e,2))<<2^Qt(e,3):0}function $0(e){return e.trim()}function dr(e,A){return(e=A.exec(e))?e[0]:e}function Be(e,A,t){return e.replace(A,t)}function Os(e,A,t){return e.indexOf(A,t)}function Qt(e,A){return e.charCodeAt(A)|0}function po(e,A,t){return e.slice(A,t)}function $n(e){return e.length}function AC(e){return e.length}function Po(e,A){return A.push(e),e}function yM(e,A){return e.map(A).join("")}function Xh(e,A){return e.filter(function(t){return!dr(t,A)})}var Ol=1,fo=1,eC=0,bn=0,mt=0,wo="";function Ul(e,A,t,n,r,i,o,a){return{value:e,root:A,parent:t,type:n,props:r,children:i,line:Ol,column:fo,length:o,return:"",siblings:a}}function Fr(e,A){return AV(Ul("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},A)}function bi(e){for(;e.root;)e=Fr(e.root,{children:[e]});Po(e,e.siblings)}function wM(){return mt}function MM(){return mt=bn>0?Qt(wo,--bn):0,fo--,mt===10&&(fo=1,Ol--),mt}function kn(){return mt=bn<eC?Qt(wo,bn++):0,fo++,mt===10&&(fo=1,Ol++),mt}function hi(){return Qt(wo,bn)}function Us(){return bn}function Gl(e,A){return po(wo,e,A)}function eV(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function SM(e){return Ol=fo=1,eC=$n(wo=e),bn=0,[]}function BM(e){return wo="",e}function jc(e){return $0(Gl(bn-1,tV(e===91?e+2:e===40?e+1:e)))}function QM(e){for(;(mt=hi())&&mt<33;)kn();return eV(e)>2||eV(mt)>3?"":" "}function bM(e,A){for(;--A&&kn()&&!(mt<48||mt>102||mt>57&&mt<65||mt>70&&mt<97););return Gl(e,Us()+(A<6&&hi()==32&&kn()==32))}function tV(e){for(;kn();)switch(mt){case e:return bn;case 34:case 39:e!==34&&e!==39&&tV(mt);break;case 40:e===41&&tV(e);break;case 92:kn();break}return bn}function RM(e,A){for(;kn()&&e+mt!==57;)if(e+mt===84&&hi()===47)break;return"/*"+Gl(A,bn-1)+"*"+Jd(e===47?e:kn())}function xM(e){for(;!eV(hi());)kn();return Gl(e,bn)}function DM(e){return BM(Gs("",null,null,null,[""],e=SM(e),0,[0],e))}function Gs(e,A,t,n,r,i,o,a,s){for(var l=0,u=0,V=o,d=0,h=0,m=0,C=1,f=1,q=1,y=0,w="",B=r,M=i,g=n,Q=w;f;)switch(m=y,y=kn()){case 40:if(m!=108&&Qt(Q,V-1)==58){Os(Q+=Be(jc(y),"&","&\f"),"&\f",_0(l?a[l-1]:0))!=-1&&(q=-1);break}case 34:case 39:case 91:Q+=jc(y);break;case 9:case 10:case 13:case 32:Q+=QM(m);break;case 92:Q+=bM(Us()-1,7);continue;case 47:switch(hi()){case 42:case 47:Po(TM(RM(kn(),Us()),A,t,s),s);break;default:Q+="/"}break;case 123*C:a[l++]=$n(Q)*q;case 125*C:case 59:case 0:switch(y){case 0:case 125:f=0;case 59+u:q==-1&&(Q=Be(Q,/\f/g,"")),h>0&&$n(Q)-V&&Po(h>32?$h(Q+";",n,t,V-1,s):$h(Be(Q," ","")+";",n,t,V-2,s),s);break;case 59:Q+=";";default:if(Po(g=_h(Q,A,t,l,u,r,a,w,B=[],M=[],V,i),i),y===123)if(u===0)Gs(Q,A,g,g,B,i,V,a,M);else switch(d===99&&Qt(Q,3)===110?100:d){case 100:case 108:case 109:case 115:Gs(e,g,g,n&&Po(_h(e,g,g,0,0,r,a,w,r,B=[],V,M),M),r,M,V,a,n?B:M);break;default:Gs(Q,g,g,g,[""],M,0,a,M)}}l=u=h=0,C=q=1,w=Q="",V=o;break;case 58:V=1+$n(Q),h=m;default:if(C<1){if(y==123)--C;else if(y==125&&C++==0&&MM()==125)continue}switch(Q+=Jd(y),y*C){case 38:q=u>0?1:(Q+="\f",-1);break;case 44:a[l++]=($n(Q)-1)*q,q=1;break;case 64:hi()===45&&(Q+=jc(kn())),d=hi(),u=V=$n(w=Q+=xM(Us())),y++;break;case 45:m===45&&$n(Q)==2&&(C=0)}}return i}function _h(e,A,t,n,r,i,o,a,s,l,u,V){for(var d=r-1,h=r===0?i:[""],m=AC(h),C=0,f=0,q=0;C<n;++C)for(var y=0,w=po(e,d+1,d=_0(f=o[C])),B=e;y<m;++y)(B=$0(f>0?h[y]+" "+w:Be(w,/&\f/g,h[y])))&&(s[q++]=B);return Ul(e,A,t,r===0?Fl:a,s,l,u,V)}function TM(e,A,t,n){return Ul(e,A,t,z0,Jd(wM()),po(e,2,-2),0,n)}function $h(e,A,t,n,r){return Ul(e,A,t,Hd,po(e,0,n),po(e,n+1,-1),n,r)}function tC(e,A,t){switch(IM(e,A)){case 5103:return Ke+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Ke+e+e;case 4789:return ea+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ke+e+ea+e+At+e+e;case 5936:switch(Qt(e,A+11)){case 114:return Ke+e+At+Be(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ke+e+At+Be(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ke+e+At+Be(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return Ke+e+At+e+e;case 6165:return Ke+e+At+"flex-"+e+e;case 5187:return Ke+e+Be(e,/(\w+).+(:[^]+)/,Ke+"box-$1$2"+At+"flex-$1$2")+e;case 5443:return Ke+e+At+"flex-item-"+Be(e,/flex-|-self/g,"")+(dr(e,/flex-|baseline/)?"":At+"grid-row-"+Be(e,/flex-|-self/g,""))+e;case 4675:return Ke+e+At+"flex-line-pack"+Be(e,/align-content|flex-|-self/g,"")+e;case 5548:return Ke+e+At+Be(e,"shrink","negative")+e;case 5292:return Ke+e+At+Be(e,"basis","preferred-size")+e;case 6060:return Ke+"box-"+Be(e,"-grow","")+Ke+e+At+Be(e,"grow","positive")+e;case 4554:return Ke+Be(e,/([^-])(transform)/g,"$1"+Ke+"$2")+e;case 6187:return Be(Be(Be(e,/(zoom-|grab)/,Ke+"$1"),/(image-set)/,Ke+"$1"),e,"")+e;case 5495:case 3959:return Be(e,/(image-set\([^]*)/,Ke+"$1$`$1");case 4968:return Be(Be(e,/(.+:)(flex-)?(.*)/,Ke+"box-pack:$3"+At+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Ke+e+e;case 4200:if(!dr(e,/flex-|baseline/))return At+"grid-column-align"+po(e,A)+e;break;case 2592:case 3360:return At+Be(e,"template-","")+e;case 4384:case 3616:return t&&t.some(function(n,r){return A=r,dr(n.props,/grid-\w+-end/)})?~Os(e+(t=t[A].value),"span",0)?e:At+Be(e,"-start","")+e+At+"grid-row-span:"+(~Os(t,"span",0)?dr(t,/\d+/):+dr(t,/\d+/)-+dr(e,/\d+/))+";":At+Be(e,"-start","")+e;case 4896:case 4128:return t&&t.some(function(n){return dr(n.props,/grid-\w+-start/)})?e:At+Be(Be(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return Be(e,/(.+)-inline(.+)/,Ke+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if($n(e)-1-A>6)switch(Qt(e,A+1)){case 109:if(Qt(e,A+4)!==45)break;case 102:return Be(e,/(.+:)(.+)-([^]+)/,"$1"+Ke+"$2-$3$1"+ea+(Qt(e,A+3)==108?"$3":"$2-$3"))+e;case 115:return~Os(e,"stretch",0)?tC(Be(e,"stretch","fill-available"),A,t)+e:e}break;case 5152:case 5920:return Be(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,r,i,o,a,s,l){return At+r+":"+i+l+(o?At+r+"-span:"+(a?s:+s-+i)+l:"")+e});case 4949:if(Qt(e,A+6)===121)return Be(e,":",":"+Ke)+e;break;case 6444:switch(Qt(e,Qt(e,14)===45?18:11)){case 120:return Be(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Ke+(Qt(e,14)===45?"inline-":"")+"box$3$1"+Ke+"$2$3$1"+At+"$2box$3")+e;case 100:return Be(e,":",":"+At)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Be(e,"scroll-","scroll-snap-")+e}return e}function tl(e,A){for(var t="",n=0;n<e.length;n++)t+=A(e[n],n,e,A)||"";return t}function FM(e,A,t,n){switch(e.type){case EM:if(e.children.length)break;case vM:case Hd:return e.return=e.return||e.value;case z0:return"";case X0:return e.return=e.value+"{"+tl(e.children,n)+"}";case Fl:if(!$n(e.value=e.props.join(",")))return""}return $n(t=tl(e.children,n))?e.return=e.value+"{"+t+"}":""}function OM(e){var A=AC(e);return function(t,n,r,i){for(var o="",a=0;a<A;a++)o+=e[a](t,n,r,i)||"";return o}}function UM(e){return function(A){A.root||(A=A.return)&&e(A)}}function GM(e,A,t,n){if(e.length>-1&&!e.return)switch(e.type){case Hd:e.return=tC(e.value,e.length,t);return;case X0:return tl([Fr(e,{value:Be(e.value,"@","@"+Ke)})],n);case Fl:if(e.length)return yM(t=e.props,function(r){switch(dr(r,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":bi(Fr(e,{props:[Be(r,/:(read-\w+)/,":"+ea+"$1")]})),bi(Fr(e,{props:[r]})),AV(e,{props:Xh(t,n)});break;case"::placeholder":bi(Fr(e,{props:[Be(r,/:(plac\w+)/,":"+Ke+"input-$1")]})),bi(Fr(e,{props:[Be(r,/:(plac\w+)/,":"+ea+"$1")]})),bi(Fr(e,{props:[Be(r,/:(plac\w+)/,At+"input-$1")]})),bi(Fr(e,{props:[r]})),AV(e,{props:Xh(t,n)});break}return""})}}var kM={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Ci=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",nC="active",rC="data-styled-version",kl="6.1.19",Pd=`/*!sc*/
|
|
1067
|
+
`],{type:"application/javascript"}),t=URL.createObjectURL(A);this.heartbeatWorker=new Worker(t),this.heartbeatWorker.onmessage=()=>{const n=new Date().getTime();this.sendMessage({type:0,msg_id:n}),this.pendingMessages.set(n,performance.now())},this.heartbeatWorker.postMessage("start")}stopHeartbeat(){this.heartbeatWorker&&(this.heartbeatWorker.postMessage("stop"),this.heartbeatWorker.terminate(),this.heartbeatWorker=null)}sendMessage(A){var t;((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?(this.ws.send(JSON.stringify(A)),A.type!==0&&zh("%cWebSocket 发送消息:","color: green; font-weight: bold;",A)):console.warn("WebSocket 未连接,消息未发送")}close(){var A;this.manualClose=!0,this.stopHeartbeat(),(A=this.ws)==null||A.close()}reconnect(){this.initWebSocket()}static __internalClose(){cr&&(cr.close(),cr=null)}static __internalSend(A){if(!cr)throw new Error("WebSocket 尚未初始化");cr.sendMessage(A)}}class fM{constructor(A){this.sipClient=null,this.sipClient=A}roleMute(){const A=N.get("isCalling"),t=$.sessionId;if(!A)throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));if(!t)throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}))}holdCall(){this.roleMute();const A=N.get("isHold"),{sessionId:t}=$;if(t){if(!N.get("actionConfigs").includes("hold"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿保持"}));if(A)throw new Error(JSON.stringify({code:1,msg:"当前已处于保持状态"}));dt.__internalSend({type:ae.CALL_HOLD,data:{session_id:t}})}}unholdCall(){this.roleMute();const{isHold:A}=N.getState(),{sessionId:t}=$;if(!N.get("actionConfigs").includes("unhold"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿取消保持"}));if(t){if(!A)throw new Error(JSON.stringify({code:1,msg:"当前未处于保持状态"}));dt.__internalSend({type:ae.CALL_UNHOLD,data:{session_id:t}})}}sendDTMF(A){if(N.get("answerDevice")!==1)throw new Error(JSON.stringify({code:1,msg:"当前设备不支持此功能"}));if(!N.get("actionConfigs").includes("dtmf"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿发送按键"}));const{isCalling:t}=N.getState();if(!t)throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));this.sipClient.sendDTMF(A)}cancelCall(){if(!N.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));const A=$.sessionId;VA.emit(eA.REJECT,{session_id:A}),dt.__internalSend({type:ae.AGENT_HANGUP,data:{session_id:A}})}async consultCall(A){this.roleMute();const{isCalling:t,outCallIsAnswer:n,consultIsAnswer:r,incomingIsAnswer:i}=N.getState(),o=$.sessionId;if(!N.get("actionConfigs").includes("consult"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用咨询"}));if(r)throw new Error(JSON.stringify({code:1,msg:"当前正在咨询"}));if(!(t||n||i))throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));if(!o)throw new Error(JSON.stringify({code:1,msg:"sessionId不存在"}));dt.__internalSend({type:ae.CONSULT_REQUEST,data:{session_id:o,consultation_agent_no:A}})}async answerCall(){if(N.get("answerDevice")!==1)throw new Error(JSON.stringify({code:1,msg:"当前设备不支持此功能"}));await this.sipClient.answerCall()}makeCall(A){if(typeof A!="string"||A.trim()==="")throw new Error(JSON.stringify({code:1,msg:"外呼号码非法"}));const t={};if($u(A))t.trace_id=A;else{if(!/^(?:1[3-9]\d{9}|0\d{2,3}-?\d{7,8})$/.test(A.trim()))throw new Error(JSON.stringify({code:1,msg:"外呼号码非法"}));t.customer_phone=A.replace(/[\s\r\n-]+/g,"")}const n=N.get("isCalling"),r=N.get("selectOutNumber")||"";if(n)throw new Error(JSON.stringify({code:1,msg:"正在呼叫中,请勿重复点击"}));N.updateIsCalling(!0),N.updateDirection(Bt.OUTGOING),dt.__internalSend({type:ae.OUT_CALL,data:{...t,caller:r.replace(/[\s\r\n-]+/g,"")}})}previewCall(A,t){const n={};$u(A)?n.trace_id=A:n.customer_phone=A.replace(/[\s\r\n-]+/g,"");const r=N.get("isCalling"),i=N.get("selectOutNumber")||"";if(r)throw new Error(JSON.stringify({code:1,msg:"正在呼叫中,请勿重复点击"}));if(typeof A!="string"||A.trim()==="")throw new Error(JSON.stringify({code:1,msg:"外呼号码非法"}));N.updateIsCalling(!0),N.updateDirection(Bt.OUTGOING),dt.__internalSend({type:ae.PREVIEW_OUT_CALL,data:{...n,caller:i,preview_task_id:t}})}async hangup(){if(!N.get("isCalling"))throw new Error(JSON.stringify({code:1,msg:"当前没有通话"}));const A=$.sessionId;dt.__internalSend({type:ae.AGENT_HANGUP,data:{session_id:A}})}mute(){this.roleMute();const A=N.get("actionConfigs"),t=N.get("isMuted"),n=$.sessionId;if(t)throw new Error(JSON.stringify({code:1,msg:"当前未处于静音状态"}));if(!A.includes("mute"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用静音"}));dt.__internalSend({type:ae.MUTE,data:{session_id:n}})}unmute(){this.roleMute();const A=N.get("actionConfigs"),t=N.get("isMuted"),n=$.sessionId;if(!t)throw new Error(JSON.stringify({code:1,msg:"当前未处于未静音状态"}));if(!A.includes("unmute"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用静音"}));dt.__internalSend({type:ae.UNMUTE,data:{session_id:n}})}consultTransfer(){this.roleMute();const A=N.get("consultIsAnswer"),t=$.sessionId;if(!N.get("actionConfigs").includes("consult_transfer"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用咨询转移"}));if(!A)throw new Error(JSON.stringify({code:1,msg:"当前未处于咨询中"}));dt.__internalSend({type:ae.CONSULT_TRANSFER,data:{session_id:t}})}satisfactionEvaluation(){this.roleMute();const A=$.sessionId;if(!N.get("actionConfigs").includes("satisfaction"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用满意度评价"}));dt.__internalSend({type:ae.SATISFACTION_EVALUATION,data:{session_id:A}})}startConference(){if(this.roleMute(),!N.get("actionConfigs").includes("conference"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿调用三方会议"}));const A=$.sessionId;if(!N.get("consultIsAnswer"))throw new Error(JSON.stringify({code:1,msg:"当前未处于咨询中"}));dt.__internalSend({type:ae.CONSULT_THREE_WAY,data:{session_id:A}})}consultRetrieve(){if(this.roleMute(),!N.get("actionConfigs").includes("consult_retrieve"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿取回通话"}));const A=$.sessionId;if(!N.get("consultIsAnswer"))throw new Error(JSON.stringify({code:1,msg:"当前未处于咨询中"}));dt.__internalSend({type:ae.CONSULT_RETURN_CALL,data:{session_id:A}})}async transferAgent(A){if(this.roleMute(),!N.get("actionConfigs").includes("transfer"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿转接"}));const{transferIsAnswer:t}=N.getState(),n=$.sessionId;if(t)throw new Error(JSON.stringify({code:1,msg:"当前正在转接"}));dt.__internalSend({type:ae.TRANSFER,data:{session_id:n,transfer_type:0,transfer_dest:A}})}async transferOutline(A){if(this.roleMute(),!N.get("actionConfigs").includes("transfer"))throw new Error(JSON.stringify({code:1,msg:"当前状态请勿转接"}));if(!A)throw new Error(JSON.stringify({code:1,msg:"号码不能为空"}));if(!/^\d+$/.test(A))throw new Error(JSON.stringify({code:1,msg:"号码格式错误"}));const{transferIsAnswer:t}=N.getState(),n=$.sessionId;if(t)throw new Error(JSON.stringify({code:1,msg:"当前正在转接"}));if(t)throw new Error(JSON.stringify({code:1,msg:"当前正在转接"}));dt.__internalSend({type:ae.TRANSFER,data:{session_id:n,transfer_type:2,transfer_dest:A}})}}var Vn,Wt,Vt,at,ui,hr,Ma,Sa,Vi,zn,Ba,Qa,Pr,J0,P0,ba,W0;const El=class El{constructor(){en(this,Pr);en(this,Wt);en(this,Vt);en(this,at);en(this,ui);en(this,hr);en(this,Ma);en(this,Sa);en(this,Vi);en(this,zn);en(this,Ba);en(this,Qa);en(this,ba);if(ut(this,Wt,null),ut(this,Vt,new ho),ut(this,ui,null),ut(this,hr,!1),ut(this,Vi,!1),ut(this,zn,null),ut(this,Ba,()=>{N.updateIsNextState(!0)}),ut(this,Qa,()=>{N.updateIsNextState(!1)}),this.initWebRtc=async()=>{if(ee(this,Wt))return;const A=$.agentInfo.sip_account_list.find(t=>t.device_type===1);if(!A)throw new Error(JSON.stringify({code:1,msg:"未找到 sip_account_list"}));{const t=A.sip_register_addr;ut(this,Wt,new Mw({server:t.split(":")[0],user:A.sip_account,password:A.sip_password,webSocket:`wss://${t}`,callTimeout:3e4},ee(this,ba))),await ee(this,Wt).start()}},ut(this,ba,A=>{const{type:t,data:n}=A;VA.emit(t,n)}),!Vn._creatingInstance)throw new Error("请使用 YSYTAgentSdk.getInstance() 获取实例");clearInterval(ee(this,ui)),ut(this,ui,setInterval(async()=>{const A=await _a(this,Pr,W0).call(this);Gd.updateRttObject(A)},2e3)),Li.requestMediaPermissions(),ut(this,Sa,N.subscribeKey("isNextState",async A=>{if(A){await ee(this,Vt)._agentLogin(ds),N.get("answerDevice")===1&&await ee(this,Wt).reconnect();let t="";const n=new URL(Ni).host;t=Ni.includes("https")?`wss://${n}`:`ws://${n}`;const{agent_no:r}=$.agentInfo;dt.getInstance({url:`${t}/ccs-ws/api/v1/ws/call/${r}?Authorization=`,sipClient:ee(this,Wt)}),$.stateObject.state===fe.OFFLINE&&setTimeout(()=>{ee(this,Vt)._changeState({data:{...ee(this,zn),state_name:ee(this,zn).state===fe.BUSY&&ee(this,zn).state_name==="整理"?"忙碌":ee(this,zn).state_name},success:()=>{N.updateDisplayText(""),VA.emit(eA.AGENT_STATE,ee(this,zn))}})},10)}else ut(this,zn,$.stateObject),dt.__internalClose(),N.updateDisplayText("离线")})),this.on(xA.KICK_OFF,()=>{this.destroy()}),window.addEventListener("beforeunload",A=>{A.returnValue="",this.destroy()}),window.addEventListener("online",ee(this,Ba)),window.addEventListener("offline",ee(this,Qa))}static get instance(){return this._instance}static async destroyInstance(){this._instance&&(await this._instance.destroy(),this._instance=null)}static getInstance(A){if(!this._instance){if(!A)throw new Error("首次调用必须传入配置参数");const{url:t,appKey:n,appSecret:r,agentNo:i}=A;Ni=t||"https://aicc-api.yescloudy.com",Kd=n,jd=r,ds=i,Vn._creatingInstance=!0,this._instance=new Vn,delete Vn._creatingInstance}return this._instance}getInit(){return ee(this,Vi)}async init({actionNodeParams:A,enableBrowserAlert:t,logBuiltinEnabled:n,browserAlertTime:r,initialState:i,initDevice:o}){try{let a="";const s=new URL(Ni).host;a=Ni.includes("https")?`wss://${s}`:`ws://${s}`;const l=dt.getInstance({url:`${a}/ccs-ws/api/v1/ws/call/${ds}?Authorization=`,sipClient:null,onOpen:async()=>{const{viewHtmlElement:u,rttHTML:V}=A||{};$.logBuiltinEnabled=n||!1,$.browserAlertTime=r||5e3,await ee(this,Vt)._agentLogin(ds);const{current_answer_device:d,current_state:h,out_display_number:m,out_display_select_switch:C}=$.agentInfo;(i||h)===fe.IDLE?(N.updateActionConfigs(Pt),$.stateObject={state:i||h,state_name:"空闲"},$.stateBeforeChange=$.stateObject):(i||h)===fe.BUSY?(N.updateActionConfigs(Al),$.stateObject={state:h,state_name:"忙碌"},$.stateBeforeChange=$.stateObject):(i||h)===fe.UNREGISTERED&&(N.updateActionConfigs(Al),$.stateObject={state:h,state_name:"未注册"}),C===1?N.updateSelectOutNumber(m):N.updateSelectOutNumber(""),N.updateAnswerDevice(o||d),(o||d)===1&&(await this.initWebRtc(),ho.setInitRtcFn(this.initWebRtc),l.setSipClient(ee(this,Wt))),ut(this,at,new fM(ee(this,Wt))),A&&u&&(ut(this,hr,!0),new hM({container:u,rttHTML:V,statusParams:{state:$.stateObject.state,statusName:$.stateObject.state_name}},this,ee(this,at))),$.enableBrowserAlert=t,t&&Li.requestPermission(),VA.emit(xA.AGENT_INIT_STATUS,!0),ut(this,Vi,!0),clearInterval(Vn._timer),Vn._timer=null,_a(this,Pr,P0).call(this),ut(this,Ma,N.subscribeKey("answerDevice",async f=>{f===1?$.stateObject.state===fe.UNREGISTERED&&await ee(this,Vt)._changeState({data:{...$.stateBeforeChange,state_name:$.stateBeforeChange.state===fe.IDLE?"空闲":"忙碌"}}):await this.destroyRtc()}))}})}catch{ee(this,hr)&&un("初始化失败"),VA.emit(xA.AGENT_INIT_STATUS,!1),ut(this,Vi,!1)}}on(A,t){return VA.on(A,t),this}off(A,t){VA.off(A,t)}offAll(){VA.clearAllListeners()}async destroyRtc(){var A;await((A=ee(this,Wt))==null?void 0:A.destroy()),ut(this,Wt,null)}async destroy(){var A,t;Vn._instance&&(await this.destroyRtc(),(A=ee(this,Ma))==null||A.call(this),(t=ee(this,Sa))==null||t.call(this),clearInterval(ee(this,ui)),dt.__internalClose(),VA.emit(xA.DESTROY),this.offAll(),ut(this,hr,!1),Vn._instance=null,N.reset(),N.updateSelectOutNumber(""),clearInterval(Vn._timer),Vn._timer=null)}get call_api(){const A=t=>(...n)=>{if(!ee(this,hr))return t.apply(this,n);console.warn("当前未使用个人开发模式")};return{answerCall:A(()=>ee(this,at).answerCall()),makeCall:t=>ee(this,at).makeCall(t),previewMakeCall:(t,n)=>ee(this,at).previewCall(t,n),cancelCall:A(()=>ee(this,at).cancelCall()),hangup:A(()=>ee(this,at).hangup()),sendDTMF:A(t=>ee(this,at).sendDTMF(t)),holdCall:A(()=>ee(this,at).holdCall()),unholdCall:A(()=>ee(this,at).unholdCall()),consultCall:A(async t=>{try{await ee(this,at).consultCall(t)}catch(n){throw console.warn(n),n}}),consultRetrieve:A(()=>ee(this,at).consultRetrieve()),consultTransfer:A(()=>ee(this,at).consultTransfer()),mute:A(()=>ee(this,at).mute()),unmute:A(()=>ee(this,at).unmute()),satisfactionEvaluation:A(()=>ee(this,at).satisfactionEvaluation()),startConference:A(()=>ee(this,at).startConference()),transferAgent:A(t=>ee(this,at).transferAgent(t)),transferOutline:A(t=>ee(this,at).transferOutline(t)),earSpeakStart:A(t=>ee(this,Vt).earCall(t)),earSpeakStop:A(t=>ee(this,Vt).stopEarCall(t)),forceInsert:A(t=>ee(this,Vt).forceInsert(t)),forceDisconnect:A(t=>ee(this,Vt).forceDisconnect(t))}}get agent_api(){const A=t=>(...n)=>{if(!ee(this,hr))return t.apply(this,n);console.warn("当前未使用个人开发模式")};return{changeDevice:A(t=>ee(this,Vt).changeDevice(t)),changeState:A(t=>ee(this,Vt).changeState(t)),getIdleAgentList:A(t=>ee(this,Vt).getIdleAgentList(t)),getAgentState:A(t=>ee(this,Vt).getAgentState(t)),setAgentExplicit:A(t=>ee(this,Vt).setAgentExplicit(t)),checkAgentLogin:t=>ee(this,Vt).checkAgentLogin(t),getCallRecord:t=>ee(this,Vt).getCallRecord(t),agentLogout:async(t,n)=>{try{await ee(this,Vt).logout(t),await this.destroy(),n==null||n({code:0,msg:""})}catch{}},listenAgentCall:t=>ee(this,Vt).listenCall(t)}}getAgentData(){const{agent_no:A,agent_name:t,answer_devices:n,out_display_data:r,out_display_select_switch:i,current_state:o}=$.agentInfo,{stateObject:a}=$,s={1:"软电话",2:"手机模式",3:"SIP话机"};return{agent_no:A,agent_name:t,init_state:o,default_device:N.get("answerDevice"),out_display_data:r,out_display_select_switch:i,answer_devices:(n||"").split(",").map(l=>({value:Number(l),label:s[Number(l)]})),stateObject:a}}async getRealTimeCustomerInfo(){return N.get("customerObject")}setBrowserAlert(A){if(typeof A!="boolean")throw new Error(JSON.stringify({code:1,msg:"参数类型错误"}));$.logBuiltinEnabled=A||!1}setBrowserAlertTime(A){if(typeof A!="number")throw new Error(JSON.stringify({code:1,msg:"参数类型错误"}));$.browserAlertTime=A||3e3}};Wt=new WeakMap,Vt=new WeakMap,at=new WeakMap,ui=new WeakMap,hr=new WeakMap,Ma=new WeakMap,Sa=new WeakMap,Vi=new WeakMap,zn=new WeakMap,Ba=new WeakMap,Qa=new WeakMap,Pr=new WeakSet,J0=async function(){const A=N.get("isNextState");try{await gM(),A||N.updateIsNextState(!0)}catch{VA.emit(xA.FAIL_NOTIFICATION,"网络断开,请检查网络"),A&&N.updateIsNextState(!1)}},P0=function(){Vn._timer||(Vn._timer=setInterval(()=>_a(this,Pr,J0).call(this),3e3))},ba=new WeakMap,W0=async function(){return ee(this,Wt)?ee(this,Wt).getNetworkStats():{}},El._instance=null,El._timer=null;let Ot=El;Vn=Ot;var nn=function(){return nn=Object.assign||function(A){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(A[i]=t[i])}return A},nn.apply(this,arguments)};function qi(e,A,t){if(t||arguments.length===2)for(var n=0,r=A.length,i;n<r;n++)(i||!(n in A))&&(i||(i=Array.prototype.slice.call(A,0,n)),i[n]=A[n]);return e.concat(i||Array.prototype.slice.call(A))}function mM(e){var A=Object.create(null);return function(t){return A[t]===void 0&&(A[t]=e(t)),A[t]}}var qM=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,CM=mM(function(e){return qM.test(e)||e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)<91}),At="-ms-",ea="-moz-",Ke="-webkit-",z0="comm",Fl="rule",Hd="decl",vM="@import",X0="@keyframes",EM="@layer",_0=Math.abs,Jd=String.fromCharCode,AV=Object.assign;function IM(e,A){return Qt(e,0)^45?(((A<<2^Qt(e,0))<<2^Qt(e,1))<<2^Qt(e,2))<<2^Qt(e,3):0}function $0(e){return e.trim()}function dr(e,A){return(e=A.exec(e))?e[0]:e}function Be(e,A,t){return e.replace(A,t)}function Os(e,A,t){return e.indexOf(A,t)}function Qt(e,A){return e.charCodeAt(A)|0}function po(e,A,t){return e.slice(A,t)}function $n(e){return e.length}function AC(e){return e.length}function Po(e,A){return A.push(e),e}function yM(e,A){return e.map(A).join("")}function Xh(e,A){return e.filter(function(t){return!dr(t,A)})}var Ol=1,fo=1,eC=0,bn=0,mt=0,wo="";function Ul(e,A,t,n,r,i,o,a){return{value:e,root:A,parent:t,type:n,props:r,children:i,line:Ol,column:fo,length:o,return:"",siblings:a}}function Fr(e,A){return AV(Ul("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},A)}function bi(e){for(;e.root;)e=Fr(e.root,{children:[e]});Po(e,e.siblings)}function wM(){return mt}function MM(){return mt=bn>0?Qt(wo,--bn):0,fo--,mt===10&&(fo=1,Ol--),mt}function kn(){return mt=bn<eC?Qt(wo,bn++):0,fo++,mt===10&&(fo=1,Ol++),mt}function hi(){return Qt(wo,bn)}function Us(){return bn}function Gl(e,A){return po(wo,e,A)}function eV(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function SM(e){return Ol=fo=1,eC=$n(wo=e),bn=0,[]}function BM(e){return wo="",e}function jc(e){return $0(Gl(bn-1,tV(e===91?e+2:e===40?e+1:e)))}function QM(e){for(;(mt=hi())&&mt<33;)kn();return eV(e)>2||eV(mt)>3?"":" "}function bM(e,A){for(;--A&&kn()&&!(mt<48||mt>102||mt>57&&mt<65||mt>70&&mt<97););return Gl(e,Us()+(A<6&&hi()==32&&kn()==32))}function tV(e){for(;kn();)switch(mt){case e:return bn;case 34:case 39:e!==34&&e!==39&&tV(mt);break;case 40:e===41&&tV(e);break;case 92:kn();break}return bn}function RM(e,A){for(;kn()&&e+mt!==57;)if(e+mt===84&&hi()===47)break;return"/*"+Gl(A,bn-1)+"*"+Jd(e===47?e:kn())}function xM(e){for(;!eV(hi());)kn();return Gl(e,bn)}function DM(e){return BM(Gs("",null,null,null,[""],e=SM(e),0,[0],e))}function Gs(e,A,t,n,r,i,o,a,s){for(var l=0,u=0,V=o,d=0,h=0,m=0,C=1,f=1,q=1,y=0,w="",B=r,M=i,g=n,Q=w;f;)switch(m=y,y=kn()){case 40:if(m!=108&&Qt(Q,V-1)==58){Os(Q+=Be(jc(y),"&","&\f"),"&\f",_0(l?a[l-1]:0))!=-1&&(q=-1);break}case 34:case 39:case 91:Q+=jc(y);break;case 9:case 10:case 13:case 32:Q+=QM(m);break;case 92:Q+=bM(Us()-1,7);continue;case 47:switch(hi()){case 42:case 47:Po(TM(RM(kn(),Us()),A,t,s),s);break;default:Q+="/"}break;case 123*C:a[l++]=$n(Q)*q;case 125*C:case 59:case 0:switch(y){case 0:case 125:f=0;case 59+u:q==-1&&(Q=Be(Q,/\f/g,"")),h>0&&$n(Q)-V&&Po(h>32?$h(Q+";",n,t,V-1,s):$h(Be(Q," ","")+";",n,t,V-2,s),s);break;case 59:Q+=";";default:if(Po(g=_h(Q,A,t,l,u,r,a,w,B=[],M=[],V,i),i),y===123)if(u===0)Gs(Q,A,g,g,B,i,V,a,M);else switch(d===99&&Qt(Q,3)===110?100:d){case 100:case 108:case 109:case 115:Gs(e,g,g,n&&Po(_h(e,g,g,0,0,r,a,w,r,B=[],V,M),M),r,M,V,a,n?B:M);break;default:Gs(Q,g,g,g,[""],M,0,a,M)}}l=u=h=0,C=q=1,w=Q="",V=o;break;case 58:V=1+$n(Q),h=m;default:if(C<1){if(y==123)--C;else if(y==125&&C++==0&&MM()==125)continue}switch(Q+=Jd(y),y*C){case 38:q=u>0?1:(Q+="\f",-1);break;case 44:a[l++]=($n(Q)-1)*q,q=1;break;case 64:hi()===45&&(Q+=jc(kn())),d=hi(),u=V=$n(w=Q+=xM(Us())),y++;break;case 45:m===45&&$n(Q)==2&&(C=0)}}return i}function _h(e,A,t,n,r,i,o,a,s,l,u,V){for(var d=r-1,h=r===0?i:[""],m=AC(h),C=0,f=0,q=0;C<n;++C)for(var y=0,w=po(e,d+1,d=_0(f=o[C])),B=e;y<m;++y)(B=$0(f>0?h[y]+" "+w:Be(w,/&\f/g,h[y])))&&(s[q++]=B);return Ul(e,A,t,r===0?Fl:a,s,l,u,V)}function TM(e,A,t,n){return Ul(e,A,t,z0,Jd(wM()),po(e,2,-2),0,n)}function $h(e,A,t,n,r){return Ul(e,A,t,Hd,po(e,0,n),po(e,n+1,-1),n,r)}function tC(e,A,t){switch(IM(e,A)){case 5103:return Ke+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return Ke+e+e;case 4789:return ea+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return Ke+e+ea+e+At+e+e;case 5936:switch(Qt(e,A+11)){case 114:return Ke+e+At+Be(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return Ke+e+At+Be(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return Ke+e+At+Be(e,/[svh]\w+-[tblr]{2}/,"lr")+e}case 6828:case 4268:case 2903:return Ke+e+At+e+e;case 6165:return Ke+e+At+"flex-"+e+e;case 5187:return Ke+e+Be(e,/(\w+).+(:[^]+)/,Ke+"box-$1$2"+At+"flex-$1$2")+e;case 5443:return Ke+e+At+"flex-item-"+Be(e,/flex-|-self/g,"")+(dr(e,/flex-|baseline/)?"":At+"grid-row-"+Be(e,/flex-|-self/g,""))+e;case 4675:return Ke+e+At+"flex-line-pack"+Be(e,/align-content|flex-|-self/g,"")+e;case 5548:return Ke+e+At+Be(e,"shrink","negative")+e;case 5292:return Ke+e+At+Be(e,"basis","preferred-size")+e;case 6060:return Ke+"box-"+Be(e,"-grow","")+Ke+e+At+Be(e,"grow","positive")+e;case 4554:return Ke+Be(e,/([^-])(transform)/g,"$1"+Ke+"$2")+e;case 6187:return Be(Be(Be(e,/(zoom-|grab)/,Ke+"$1"),/(image-set)/,Ke+"$1"),e,"")+e;case 5495:case 3959:return Be(e,/(image-set\([^]*)/,Ke+"$1$`$1");case 4968:return Be(Be(e,/(.+:)(flex-)?(.*)/,Ke+"box-pack:$3"+At+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Ke+e+e;case 4200:if(!dr(e,/flex-|baseline/))return At+"grid-column-align"+po(e,A)+e;break;case 2592:case 3360:return At+Be(e,"template-","")+e;case 4384:case 3616:return t&&t.some(function(n,r){return A=r,dr(n.props,/grid-\w+-end/)})?~Os(e+(t=t[A].value),"span",0)?e:At+Be(e,"-start","")+e+At+"grid-row-span:"+(~Os(t,"span",0)?dr(t,/\d+/):+dr(t,/\d+/)-+dr(e,/\d+/))+";":At+Be(e,"-start","")+e;case 4896:case 4128:return t&&t.some(function(n){return dr(n.props,/grid-\w+-start/)})?e:At+Be(Be(e,"-end","-span"),"span ","")+e;case 4095:case 3583:case 4068:case 2532:return Be(e,/(.+)-inline(.+)/,Ke+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if($n(e)-1-A>6)switch(Qt(e,A+1)){case 109:if(Qt(e,A+4)!==45)break;case 102:return Be(e,/(.+:)(.+)-([^]+)/,"$1"+Ke+"$2-$3$1"+ea+(Qt(e,A+3)==108?"$3":"$2-$3"))+e;case 115:return~Os(e,"stretch",0)?tC(Be(e,"stretch","fill-available"),A,t)+e:e}break;case 5152:case 5920:return Be(e,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,r,i,o,a,s,l){return At+r+":"+i+l+(o?At+r+"-span:"+(a?s:+s-+i)+l:"")+e});case 4949:if(Qt(e,A+6)===121)return Be(e,":",":"+Ke)+e;break;case 6444:switch(Qt(e,Qt(e,14)===45?18:11)){case 120:return Be(e,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Ke+(Qt(e,14)===45?"inline-":"")+"box$3$1"+Ke+"$2$3$1"+At+"$2box$3")+e;case 100:return Be(e,":",":"+At)+e}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Be(e,"scroll-","scroll-snap-")+e}return e}function tl(e,A){for(var t="",n=0;n<e.length;n++)t+=A(e[n],n,e,A)||"";return t}function FM(e,A,t,n){switch(e.type){case EM:if(e.children.length)break;case vM:case Hd:return e.return=e.return||e.value;case z0:return"";case X0:return e.return=e.value+"{"+tl(e.children,n)+"}";case Fl:if(!$n(e.value=e.props.join(",")))return""}return $n(t=tl(e.children,n))?e.return=e.value+"{"+t+"}":""}function OM(e){var A=AC(e);return function(t,n,r,i){for(var o="",a=0;a<A;a++)o+=e[a](t,n,r,i)||"";return o}}function UM(e){return function(A){A.root||(A=A.return)&&e(A)}}function GM(e,A,t,n){if(e.length>-1&&!e.return)switch(e.type){case Hd:e.return=tC(e.value,e.length,t);return;case X0:return tl([Fr(e,{value:Be(e.value,"@","@"+Ke)})],n);case Fl:if(e.length)return yM(t=e.props,function(r){switch(dr(r,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":bi(Fr(e,{props:[Be(r,/:(read-\w+)/,":"+ea+"$1")]})),bi(Fr(e,{props:[r]})),AV(e,{props:Xh(t,n)});break;case"::placeholder":bi(Fr(e,{props:[Be(r,/:(plac\w+)/,":"+Ke+"input-$1")]})),bi(Fr(e,{props:[Be(r,/:(plac\w+)/,":"+ea+"$1")]})),bi(Fr(e,{props:[Be(r,/:(plac\w+)/,At+"input-$1")]})),bi(Fr(e,{props:[r]})),AV(e,{props:Xh(t,n)});break}return""})}}var kM={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Ci=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",nC="active",rC="data-styled-version",kl="6.1.19",Pd=`/*!sc*/
|
|
1068
1068
|
`,nl=typeof window<"u"&&typeof document<"u",YM=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==""?process.env.REACT_APP_SC_DISABLE_SPEEDY!=="false"&&process.env.REACT_APP_SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.SC_DISABLE_SPEEDY!==void 0&&process.env.SC_DISABLE_SPEEDY!==""?process.env.SC_DISABLE_SPEEDY!=="false"&&process.env.SC_DISABLE_SPEEDY:process.env.NODE_ENV!=="production"),Ap=/invalid hook call/i,gs=new Set,NM=function(e,A){if(process.env.NODE_ENV!=="production"){var t=A?' with the id of "'.concat(A,'"'):"",n="The component ".concat(e).concat(t,` has been created dynamically.
|
|
1069
1069
|
`)+`You may see this warning because you've called styled inside another component.
|
|
1070
1070
|
To resolve this only create new StyledComponents outside of any render method and function component.
|
|
@@ -1556,7 +1556,7 @@ html body {
|
|
|
1556
1556
|
&:hover {
|
|
1557
1557
|
opacity: 0.9;
|
|
1558
1558
|
}
|
|
1559
|
-
`;function PF({title:e,content:A,icon:t,onOk:n,onCancel:r}){const i=document.createElement("div");document.body.appendChild(i);const o=NF.createRoot(i),a=()=>{o.unmount(),i.remove()},s=async()=>{n&&await n(),a()},l=()=>{r==null||r(),a()};o.render(lA.jsx(ZF,{children:lA.jsxs(KF,{children:[lA.jsxs(jF,{children:[t&&lA.jsx(LF,{children:t}),e]}),lA.jsx(HF,{children:A}),lA.jsxs(JF,{children:[lA.jsx(eq,{onClick:l,children:"取消"}),lA.jsx(eq,{primary:!0,onClick:s,children:"确定"})]})]})}))}const WF={1:lA.jsx(Me,{name:"ruandianhua"}),2:lA.jsx(Me,{name:"pnhone"}),3:lA.jsx(Me,{name:"sip-phone"})},zF={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:"强拆"},XF={空闲:1,离线:0,未注册:4},_F=x.lazy(()=>Promise.resolve().then(()=>require("./ConsultModel-
|
|
1559
|
+
`;function PF({title:e,content:A,icon:t,onOk:n,onCancel:r}){const i=document.createElement("div");document.body.appendChild(i);const o=NF.createRoot(i),a=()=>{o.unmount(),i.remove()},s=async()=>{n&&await n(),a()},l=()=>{r==null||r(),a()};o.render(lA.jsx(ZF,{children:lA.jsxs(KF,{children:[lA.jsxs(jF,{children:[t&&lA.jsx(LF,{children:t}),e]}),lA.jsx(HF,{children:A}),lA.jsxs(JF,{children:[lA.jsx(eq,{onClick:l,children:"取消"}),lA.jsx(eq,{primary:!0,onClick:s,children:"确定"})]})]})}))}const WF={1:lA.jsx(Me,{name:"ruandianhua"}),2:lA.jsx(Me,{name:"pnhone"}),3:lA.jsx(Me,{name:"sip-phone"})},zF={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:"强拆"},XF={空闲:1,离线:0,未注册:4},_F=x.lazy(()=>Promise.resolve().then(()=>require("./ConsultModel-KWliYdNQ.js"))),$F=x.lazy(()=>Promise.resolve().then(()=>require("./TransferModel-DWgaLD4j.js"))),gu=lt.div`
|
|
1560
1560
|
width: 25px;
|
|
1561
1561
|
height: 25px;
|
|
1562
1562
|
background: ${({bg:e})=>e};
|
|
@@ -10134,7 +10134,7 @@ const Lo = function(e) {
|
|
|
10134
10134
|
this.setState({ isSipConnected: e });
|
|
10135
10135
|
}
|
|
10136
10136
|
reset() {
|
|
10137
|
-
this.updateIsCalling(Mn.isCalling), this.updateDirection(Mn.direction), this.updateOutCallIsAnswer(Mn.outCallIsAnswer), this.updateIsHold(Mn.isHold), this.updateDisplayText(Mn.displayText), this.updateActionConfigs(Mn.actionConfigs), this.updateConsultIsAnswer(Mn.consultIsAnswer), this.updateIsMuted(Mn.isMuted), this.updateIncomingIsAnswer(Mn.incomingIsAnswer), this.updateIsMeeting(Mn.isMeeting), this.updateTransferIsAnswer(Mn.transferIsAnswer), this.updateCustomerInfo(void 0);
|
|
10137
|
+
this.updateAnswerDevice(1), this.updateIsCalling(Mn.isCalling), this.updateDirection(Mn.direction), this.updateOutCallIsAnswer(Mn.outCallIsAnswer), this.updateIsHold(Mn.isHold), this.updateDisplayText(Mn.displayText), this.updateActionConfigs(Mn.actionConfigs), this.updateConsultIsAnswer(Mn.consultIsAnswer), this.updateIsMuted(Mn.isMuted), this.updateIncomingIsAnswer(Mn.incomingIsAnswer), this.updateIsMeeting(Mn.isMeeting), this.updateTransferIsAnswer(Mn.transferIsAnswer), this.updateCustomerInfo(void 0);
|
|
10138
10138
|
}
|
|
10139
10139
|
getCallInfo() {
|
|
10140
10140
|
return this.getState();
|
|
@@ -13265,9 +13265,7 @@ const Il = class Il {
|
|
|
13265
13265
|
clearInterval(te(this, di)), dt(this, di, setInterval(async () => {
|
|
13266
13266
|
const A = await As(this, _r, $0).call(this);
|
|
13267
13267
|
Yd.updateRttObject(A);
|
|
13268
|
-
}, 2e3)), Wi.requestMediaPermissions(), dt(this,
|
|
13269
|
-
A === 1 ? _.stateObject.state === me.UNREGISTERED && await te(this, gt)._changeState({ data: { ..._.stateBeforeChange, state_name: _.stateBeforeChange.state === me.IDLE ? "空闲" : "忙碌" } }) : await this.destroyRtc();
|
|
13270
|
-
})), dt(this, Ta, Y.subscribeKey("isNextState", async (A) => {
|
|
13268
|
+
}, 2e3)), Wi.requestMediaPermissions(), dt(this, Ta, Y.subscribeKey("isNextState", async (A) => {
|
|
13271
13269
|
if (A) {
|
|
13272
13270
|
await te(this, gt)._agentLogin(hs), Y.get("answerDevice") === 1 && await te(this, _t).reconnect();
|
|
13273
13271
|
let t = "";
|
|
@@ -13312,7 +13310,9 @@ const Il = class Il {
|
|
|
13312
13310
|
const { viewHtmlElement: u, rttHTML: V } = A || {};
|
|
13313
13311
|
_.logBuiltinEnabled = n || !1, _.browserAlertTime = r || 5e3, await te(this, gt)._agentLogin(hs);
|
|
13314
13312
|
const { current_answer_device: d, current_state: h, out_display_number: m, out_display_select_switch: C } = _.agentInfo;
|
|
13315
|
-
(i || h) === me.IDLE ? (Y.updateActionConfigs(Xt), _.stateObject = { state: i || h, state_name: "空闲" }, _.stateBeforeChange = _.stateObject) : (i || h) === me.BUSY ? (Y.updateActionConfigs(Al), _.stateObject = { state: h, state_name: "忙碌" }, _.stateBeforeChange = _.stateObject) : (i || h) === me.UNREGISTERED && (Y.updateActionConfigs(Al), _.stateObject = { state: h, state_name: "未注册" }), C === 1 ? Y.updateSelectOutNumber(m) : Y.updateSelectOutNumber(""), Y.updateAnswerDevice(o || d), (o || d) === 1 && (await this.initWebRtc(), qo.setInitRtcFn(this.initWebRtc), l.setSipClient(te(this, _t))), dt(this, ct, new FM(te(this, _t))), A && u && (dt(this, qr, !0), new xM({ container: u, rttHTML: V, statusParams: { state: _.stateObject.state, statusName: _.stateObject.state_name } }, this, te(this, ct))), _.enableBrowserAlert = t, t && Wi.requestPermission(), VA.emit(xA.AGENT_INIT_STATUS, !0), dt(this, gi, !0), clearInterval(hn._timer), hn._timer = null, As(this, _r, _0).call(this)
|
|
13313
|
+
(i || h) === me.IDLE ? (Y.updateActionConfigs(Xt), _.stateObject = { state: i || h, state_name: "空闲" }, _.stateBeforeChange = _.stateObject) : (i || h) === me.BUSY ? (Y.updateActionConfigs(Al), _.stateObject = { state: h, state_name: "忙碌" }, _.stateBeforeChange = _.stateObject) : (i || h) === me.UNREGISTERED && (Y.updateActionConfigs(Al), _.stateObject = { state: h, state_name: "未注册" }), C === 1 ? Y.updateSelectOutNumber(m) : Y.updateSelectOutNumber(""), Y.updateAnswerDevice(o || d), (o || d) === 1 && (await this.initWebRtc(), qo.setInitRtcFn(this.initWebRtc), l.setSipClient(te(this, _t))), dt(this, ct, new FM(te(this, _t))), A && u && (dt(this, qr, !0), new xM({ container: u, rttHTML: V, statusParams: { state: _.stateObject.state, statusName: _.stateObject.state_name } }, this, te(this, ct))), _.enableBrowserAlert = t, t && Wi.requestPermission(), VA.emit(xA.AGENT_INIT_STATUS, !0), dt(this, gi, !0), clearInterval(hn._timer), hn._timer = null, As(this, _r, _0).call(this), dt(this, xa, Y.subscribeKey("answerDevice", async (f) => {
|
|
13314
|
+
f === 1 ? _.stateObject.state === me.UNREGISTERED && await te(this, gt)._changeState({ data: { ..._.stateBeforeChange, state_name: _.stateBeforeChange.state === me.IDLE ? "空闲" : "忙碌" } }) : await this.destroyRtc();
|
|
13315
|
+
}));
|
|
13316
13316
|
} });
|
|
13317
13317
|
} catch {
|
|
13318
13318
|
te(this, qr) && gn("初始化失败"), VA.emit(xA.AGENT_INIT_STATUS, !1), dt(this, gi, !1);
|
|
@@ -13333,7 +13333,7 @@ const Il = class Il {
|
|
|
13333
13333
|
}
|
|
13334
13334
|
async destroy() {
|
|
13335
13335
|
var A, t;
|
|
13336
|
-
hn._instance && (await this.destroyRtc(),
|
|
13336
|
+
hn._instance && (await this.destroyRtc(), (A = te(this, xa)) == null || A.call(this), (t = te(this, Ta)) == null || t.call(this), clearInterval(te(this, di)), ht.__internalClose(), VA.emit(xA.DESTROY), this.offAll(), dt(this, qr, !1), hn._instance = null, Y.reset(), Y.updateSelectOutNumber(""), clearInterval(hn._timer), hn._timer = null);
|
|
13337
13337
|
}
|
|
13338
13338
|
get call_api() {
|
|
13339
13339
|
const A = (t) => (...n) => {
|
|
@@ -34721,7 +34721,7 @@ const dO = {
|
|
|
34721
34721
|
空闲: 1,
|
|
34722
34722
|
离线: 0,
|
|
34723
34723
|
未注册: 4
|
|
34724
|
-
}, pO = cq(() => import("./ConsultModel-
|
|
34724
|
+
}, pO = cq(() => import("./ConsultModel-rL9vGgyX.mjs")), fO = cq(() => import("./TransferModel-m1Yafzwi.mjs")), Vu = ut.div`
|
|
34725
34725
|
width: 25px;
|
|
34726
34726
|
height: 25px;
|
|
34727
34727
|
background: ${({
|
|
@@ -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-CRDYYTnZ.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-D4OJU0JW.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.1.
|
|
3
|
+
"version": "1.1.43",
|
|
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": "1.1.
|
|
32
|
+
"ysyt-agent-sdk": "1.1.42"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^18.2.0",
|