call-control-sdk 5.4.1 → 5.4.3
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/README.md +18 -19
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,8 +13,6 @@ A lightweight SDK that provides a **draggable call control panel** and utility h
|
|
|
13
13
|
- 🔧 **TypeScript Support** – Full type safety and IntelliSense
|
|
14
14
|
- 🎪 **Singleton State** – Consistent shared state across components
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
16
|
### 📦 Installation [](https://bundlephobia.com/package/call-control-sdk)
|
|
19
17
|
|
|
20
18
|
```bash
|
|
@@ -107,7 +105,8 @@ export default function LogoutButton() {
|
|
|
107
105
|
import { useClickToCall } from "call-control-sdk";
|
|
108
106
|
|
|
109
107
|
export default function CallButton() {
|
|
110
|
-
const { handleStartCall, isLoading, isSuccess, isError, error } =
|
|
108
|
+
const { handleStartCall, isLoading, isSuccess, isError, error } =
|
|
109
|
+
useClickToCall();
|
|
111
110
|
|
|
112
111
|
const onStartCall = () => {
|
|
113
112
|
handleStartCall({ mobileNumber: "1111111111" });
|
|
@@ -116,7 +115,7 @@ export default function CallButton() {
|
|
|
116
115
|
return (
|
|
117
116
|
<div>
|
|
118
117
|
<button onClick={onStartCall} disabled={isLoading}>
|
|
119
|
-
{
|
|
118
|
+
{"Call"}
|
|
120
119
|
</button>
|
|
121
120
|
{isSuccess && <p>✅ Call ended successfully</p>}
|
|
122
121
|
{isError && <p>❌ Error: {error?.message}</p>}
|
|
@@ -124,6 +123,7 @@ export default function CallButton() {
|
|
|
124
123
|
);
|
|
125
124
|
}
|
|
126
125
|
```
|
|
126
|
+
|
|
127
127
|
#### 5. End Call
|
|
128
128
|
|
|
129
129
|
```tsx
|
|
@@ -203,14 +203,14 @@ Hook for call to mobile number.
|
|
|
203
203
|
|
|
204
204
|
**Returns**:
|
|
205
205
|
|
|
206
|
-
| Key
|
|
207
|
-
|
|
|
206
|
+
| Key | Type | Description |
|
|
207
|
+
| ----------------- | -------- | ----------------------------------------------------------------- |
|
|
208
208
|
| `handleStartCall` | function | `(payload: StartCallPayload) => void` – triggers end-call request |
|
|
209
|
-
| `isLoading`
|
|
210
|
-
| `isSuccess`
|
|
211
|
-
| `isError`
|
|
212
|
-
| `error`
|
|
213
|
-
| `data`
|
|
209
|
+
| `isLoading` | boolean | True while request is pending |
|
|
210
|
+
| `isSuccess` | boolean | True if request succeeded |
|
|
211
|
+
| `isError` | boolean | True if request failed |
|
|
212
|
+
| `error` | any | Error object if failed |
|
|
213
|
+
| `data` | any | API response on success |
|
|
214
214
|
|
|
215
215
|
#### `useEndCall()`
|
|
216
216
|
|
|
@@ -247,17 +247,16 @@ interface EndCallPayload {
|
|
|
247
247
|
|
|
248
248
|
### 🎛 Control Features
|
|
249
249
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
250
|
+
**Status Management**: Idle / Break
|
|
251
|
+
**Call Controls**: Hold / Resume, Mute / Unmute, End Call, Agent Status
|
|
252
|
+
**Persistent State**: Hold, mute, agent status, panel position, call timer
|
|
253
253
|
|
|
254
254
|
### 🌍 Browser Support
|
|
255
255
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
256
|
+
✅ Chrome 60+
|
|
257
|
+
✅ Firefox 60+
|
|
258
|
+
✅ Safari 12+
|
|
259
|
+
✅ Edge 79+
|
|
261
260
|
|
|
262
261
|
---
|
|
263
262
|
|
package/dist/index.d.mts
CHANGED
|
@@ -55,6 +55,8 @@ type CallStatus = "idle" | "ready" | "break" | "on call" | "wrap up" | "dial" |
|
|
|
55
55
|
interface SDKConfig {
|
|
56
56
|
showEndCallButton?: boolean;
|
|
57
57
|
showTransferButton?: boolean;
|
|
58
|
+
enableFloatingDrag?: boolean;
|
|
59
|
+
enableSoftPhone?: boolean;
|
|
58
60
|
showConferenceButton?: boolean;
|
|
59
61
|
disabled?: SxProps;
|
|
60
62
|
enabled?: SxProps;
|
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,8 @@ type CallStatus = "idle" | "ready" | "break" | "on call" | "wrap up" | "dial" |
|
|
|
55
55
|
interface SDKConfig {
|
|
56
56
|
showEndCallButton?: boolean;
|
|
57
57
|
showTransferButton?: boolean;
|
|
58
|
+
enableFloatingDrag?: boolean;
|
|
59
|
+
enableSoftPhone?: boolean;
|
|
58
60
|
showConferenceButton?: boolean;
|
|
59
61
|
disabled?: SxProps;
|
|
60
62
|
enabled?: SxProps;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var Vo=Object.create;var De=Object.defineProperty,Qo=Object.defineProperties,Zo=Object.getOwnPropertyDescriptor,es=Object.getOwnPropertyDescriptors,ts=Object.getOwnPropertyNames,_o=Object.getOwnPropertySymbols,os=Object.getPrototypeOf,wo=Object.prototype.hasOwnProperty,ss=Object.prototype.propertyIsEnumerable;var Ge=(t,o,e)=>o in t?De(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,c=(t,o)=>{for(var e in o||(o={}))wo.call(o,e)&&Ge(t,e,o[e]);if(_o)for(var e of _o(o))ss.call(o,e)&&Ge(t,e,o[e]);return t},Z=(t,o)=>Qo(t,es(o));var ns=(t,o)=>{for(var e in o)De(t,e,{get:o[e],enumerable:!0})},Ro=(t,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of ts(o))!wo.call(t,l)&&l!==e&&De(t,l,{get:()=>o[l],enumerable:!(a=Zo(o,l))||a.enumerable});return t};var as=(t,o,e)=>(e=t!=null?Vo(os(t)):{},Ro(o||!t||!t.__esModule?De(e,"default",{value:t,enumerable:!0}):e,t)),is=t=>Ro(De({},"__esModule",{value:!0}),t);var ae=(t,o,e)=>Ge(t,typeof o!="symbol"?o+"":o,e);var ms={};ns(ms,{CallControlPanel:()=>Go,initSDK:()=>fs,useClickToCall:()=>Oo,useEndCall:()=>Po,useLogout:()=>Ao});module.exports=is(ms);var Ye=class{constructor(){ae(this,"config",null);ae(this,"ticketId",null);ae(this,"baseUrl","");ae(this,"eventQueue",[]);ae(this,"isOnline",!0);ae(this,"retryQueue",[]);ae(this,"flushTimer",null)}async init(o){this.config=c({autoTrack:!0,retryAttempts:3,queueSize:100,flushInterval:5e3},o),this.baseUrl=o.baseUrl||(typeof window!="undefined"?window.location.origin:""),this.setupNetworkDetection();let e=await this.createTicket();return this.startPeriodicFlush(),console.log("EventTracker SDK initialized successfully"),e}isInitialized(){return this.config!==null&&this.ticketId!==null}getConfig(){return this.config}getTicketId(){return this.ticketId}async createTicket(){if(!this.config)throw new Error("EventTracker not initialized");try{let o=await this.makeRequest("/api/v1/et/init",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({agentId:this.config.agentId,sessionId:this.config.sessionId})});if(!o.ok)throw new Error(`Failed to initialize: ${o.status} ${o.statusText}`);let e=await o.json();return this.ticketId=e.ticketId,this.config.autoTrack&&this.setupAutoTracking(),this.ticketId}catch(o){throw console.error("EventTracker initialization failed:",o),o}}async logEvent(o,e){if(!this.config||!this.ticketId){console.warn("EventTracker not initialized, skipping event:",o);return}let a={eventType:o,eventData:e,timestamp:Date.now()};if(this.eventQueue.push(a),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift(),this.isOnline)try{await this.sendEvent(a)}catch(l){console.warn("Failed to send event, will retry later:",l)}}async sendEvent(o){if(!(!this.config||!this.ticketId))try{let e=await this.makeRequest("/api/v1/et/event",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({ticketId:this.ticketId,eventType:o.eventType,eventData:o.eventData})});if(!e.ok)throw new Error(`Failed to log event: ${e.status} ${e.statusText}`);let a=this.eventQueue.findIndex(l=>l.timestamp===o.timestamp);a>-1&&this.eventQueue.splice(a,1)}catch(e){console.error("Event logging failed:",e),this.retryQueue.push(()=>this.sendEvent(o))}}async closeTicket(){if(!this.config||!this.ticketId)throw new Error("EventTracker not initialized");await this.flush();try{let o=await this.makeRequest("/api/v1/et/close",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({ticketId:this.ticketId})});if(!o.ok)throw new Error(`Failed to close ticket: ${o.status} ${o.statusText}`);this.ticketId=null,this.stopPeriodicFlush(),console.log("Ticket closed successfully")}catch(o){throw console.error("Ticket close failed:",o),o}}async flush(){if(!this.isOnline||this.eventQueue.length===0)return;let o=[...this.eventQueue];for(let a of o)await this.sendEvent(a);let e=[...this.retryQueue];this.retryQueue=[];for(let a of e)try{await a()}catch(l){console.error("Retry failed:",l)}}async makeRequest(o,e){var p;let a=`${this.baseUrl}${o}`,l=((p=this.config)==null?void 0:p.retryAttempts)||3;for(let g=1;g<=l;g++)try{return await fetch(a,e)}catch(C){if(g===l)throw C;let S=Math.min(1e3*Math.pow(2,g-1),1e4);await new Promise(f=>setTimeout(f,S))}throw new Error("Max retries exceeded")}setupAutoTracking(){var a;if(typeof window=="undefined"||!((a=this.config)!=null&&a.autoTrack))return;let o=this.config.autoTrack===!0?{}:this.config.autoTrack;if(o.pageVisits!==!1&&this.logEvent("pageVisit",{url:window.location.href,title:document.title,referrer:document.referrer,userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},timestamp:new Date().toISOString()}).catch(l=>console.warn("Failed to track page visit:",l)),o.clicks!==!1&&document.addEventListener("click",l=>{var g;let p=l.target;(p.tagName==="BUTTON"||p.tagName==="A"||p.onclick||p.getAttribute("role")==="button"||p instanceof HTMLButtonElement&&p.type==="button")&&this.logEvent("click",{element:p.tagName,text:(g=p.textContent)==null?void 0:g.trim().substring(0,100),href:p.getAttribute("href"),id:p.id,className:p.className,role:p.getAttribute("role"),position:{x:l.clientX,y:l.clientY},timestamp:new Date().toISOString()}).catch(C=>console.warn("Failed to track click:",C))}),o.forms!==!1&&document.addEventListener("submit",l=>{let p=l.target,g=new FormData(p),C={};g.forEach((S,f)=>{C[f]=S.toString()}),this.logEvent("formSubmission",{formId:p.id,action:p.action,method:p.method,fields:Object.keys(C),fieldCount:Object.keys(C).length,timestamp:new Date().toISOString()}).catch(S=>console.warn("Failed to track form submission:",S))}),o.inputs!==!1){let l;document.addEventListener("input",p=>{let g=p.target;(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.tagName==="SELECT")&&(clearTimeout(l),l=setTimeout(()=>{var C;this.logEvent("fieldChange",{element:g.tagName,type:g.getAttribute("type"),name:g.getAttribute("name"),id:g.id,valueLength:((C=g.value)==null?void 0:C.length)||0,timestamp:new Date().toISOString()}).catch(S=>console.warn("Failed to track field change:",S))},1e3))})}let e=Date.now();window.addEventListener("beforeunload",()=>{let l=Date.now()-e;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:l,timestamp:new Date().toISOString()}),this.ticketId&&navigator.sendBeacon(`${this.baseUrl}/api/v1/et/close`,JSON.stringify({ticketId:this.ticketId}))}),o.visibility!==!1&&document.addEventListener("visibilitychange",()=>{this.logEvent("visibilityChange",{hidden:document.hidden,visibilityState:document.visibilityState,timestamp:new Date().toISOString()})}),o.errors!==!1&&(window.addEventListener("error",l=>{this.logEvent("jsError",{message:l.message,filename:l.filename,lineno:l.lineno,colno:l.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",l=>{var p;this.logEvent("unhandledRejection",{reason:(p=l.reason)==null?void 0:p.toString(),timestamp:new Date().toISOString()})})),o.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let l=window.performance.navigation,p=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:p.navigationStart,loadTime:p.loadEventEnd-p.navigationStart,domReady:p.domContentLoadedEventEnd-p.navigationStart,renderTime:p.loadEventEnd-p.domContentLoadedEventEnd,navigationType:l.type,redirectCount:l.redirectCount,timestamp:new Date().toISOString()})},1e3)})}setupNetworkDetection(){typeof window!="undefined"&&(this.isOnline=navigator.onLine,window.addEventListener("online",()=>{this.isOnline=!0,console.log("EventTracker: Back online, flushing queued events"),this.flush()}),window.addEventListener("offline",()=>{this.isOnline=!1,console.log("EventTracker: Offline, queueing events")}))}startPeriodicFlush(){var e;this.flushTimer&&clearInterval(this.flushTimer);let o=((e=this.config)==null?void 0:e.flushInterval)||5e3;this.flushTimer=setInterval(()=>{this.flush()},o)}stopPeriodicFlush(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}},je=new Ye;typeof window!="undefined"&&(window.EventTracker=je);var Xe=class{constructor(){ae(this,"state");ae(this,"listeners",[]);ae(this,"STORAGE_KEY","call-control-sdk-state");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{apiKey:null,process:null,agentId:"",isInitialized:!1,sdkConfig:{showEndCallButton:!0,showTransferButton:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},isHolding:!1,isMuted:!1,status:"idle",callStartTime:null,controlPanelPosition:{x:10,y:10},iframePosition:{x:10,y:80},callData:{agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:[{line:1,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:2,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:3,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:4,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:5,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1}]}}loadFromStorage(){try{let o=localStorage.getItem(this.STORAGE_KEY);if(o){let e=JSON.parse(o);this.state=Z(c({},this.state),{apiKey:e.apiKey||"",agentId:e.agentId||"",process:e.process||null,isInitialized:e.isInitialized||!1,sdkConfig:e.sdkConfig||{showEndCallButton:!0,showTransferButton:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},isHolding:e.isHolding||!1,isMuted:e.isMuted||!1,status:e.status||"idle",callStartTime:e.callStartTime||null,controlPanelPosition:e.controlPanelPosition||{x:10,y:10},iframePosition:e.iframePosition||{x:10,y:80},callData:e.callData||{mobileNumber:"",callReferenceId:"",agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:e.conferenceLine&&Array.isArray(e.conferenceLine)&&e.conferenceLine.length>0?e.conferenceLine:this.state.conferenceLine})}}catch(o){console.warn("Failed to load SDK state from localStorage:",o)}}saveToStorage(){try{let o={apiKey:this.state.apiKey,agentId:this.state.agentId,process:this.state.process,isInitialized:this.state.isInitialized,sdkConfig:this.state.sdkConfig,isHolding:this.state.isHolding,isMuted:this.state.isMuted,status:this.state.status,callStartTime:this.state.callStartTime,controlPanelPosition:this.state.controlPanelPosition,iframePosition:this.state.iframePosition,callData:this.state.callData,conferenceLine:this.state.conferenceLine};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(o))}catch(o){console.warn("Failed to save SDK state to localStorage:",o)}}notifyListeners(){this.listeners.forEach(o=>o())}initialize(o,e,a){if(!o||typeof o!="string"||o.trim().length===0)throw new Error("API key not available");this.state.apiKey=o,this.state.agentId=e,this.state.sdkConfig=c({showEndCallButton:!0,showTransferButton:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},a),this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return c({},this.state)}subscribe(o){return this.listeners.push(o),()=>{let e=this.listeners.indexOf(o);e>-1&&this.listeners.splice(e,1)}}setHolding(o){this.state.isHolding=o,this.saveToStorage(),this.notifyListeners()}setMuted(o){this.state.isMuted=o,this.saveToStorage(),this.notifyListeners()}setStatus(o){this.state.status=o,this.saveToStorage(),this.notifyListeners()}setProcess(o){this.state.process=o,this.saveToStorage(),this.notifyListeners()}setControlPanelPosition(o){this.state.controlPanelPosition=o,this.saveToStorage(),this.notifyListeners()}setIframePosition(o){this.state.iframePosition=o,this.saveToStorage(),this.notifyListeners()}startCall(){this.state.callStartTime=Date.now(),this.state.status="on call",this.saveToStorage(),this.notifyListeners()}endCall(){this.state.callStartTime=null,this.state.status="idle",this.state.isHolding=!1,this.state.isMuted=!1,this.saveToStorage(),this.notifyListeners()}updateCallData(o){this.state.callData=c(c({},this.state.callData),o),this.saveToStorage(),this.notifyListeners()}setConferenceLine(o){var a;(!this.state.conferenceLine||!Array.isArray(this.state.conferenceLine))&&(console.warn("Conference line data corrupted, resetting to initial state"),this.state.conferenceLine=this.getInitialState().conferenceLine);let e=(a=this.state.conferenceLine)==null?void 0:a.map(l=>l.line===o.line?o:l);this.state.conferenceLine=e,this.saveToStorage(),this.notifyListeners()}resetConferenceLines(){this.state.conferenceLine=this.getInitialState().conferenceLine,this.saveToStorage(),this.notifyListeners()}clearStorageAndReset(){try{localStorage.removeItem(this.STORAGE_KEY),this.state=this.getInitialState(),this.notifyListeners()}catch(o){console.warn("Failed to clear localStorage:",o)}}debugStorage(){try{let o=localStorage.getItem(this.STORAGE_KEY);console.log("Current localStorage data:",o),o&&console.log("Parsed localStorage data:",JSON.parse(o)),console.log("Current state:",this.state)}catch(o){console.error("Error debugging storage:",o)}}getConferenceLines(){return this.state.conferenceLine||[]}},L=new Xe;var fe=require("react");var ze="10.10.102.42",H=`http://${ze}:8095`,ls=`ws://${ze}:8095`,W={v1:"/api/v1"},O={LOGIN:`${H}${W.v1}/cti/login?provider=convox`,READY_AGENT:`${H}${W.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${H}${W.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${H}${W.v1}/cti/calls?provider=convox`,HOLD_CALL:`${H}${W.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${H}${W.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${H}${W.v1}/cti/unmute-call?provider=convox`,END_CALL:`${H}${W.v1}/cti/calls/end?provider=convox`,LOGOUT:`${H}${W.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${H}${W.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${H}${W.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${H}${W.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${H}${W.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${H}${W.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${H}${W.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${H}${W.v1}/cti/users`,PROCESS_LIST:`${H}${W.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${H}${W.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${H}${W.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${H}${W.v1}/users/get_sentiment_analysis`},ko={WS:`${ls}${W.v1}/cti/ws`};var No=as(require("axios"));var rs="12345",Je=No.default.create({baseURL:H,headers:{"Content-Type":"application/json",Authorization:rs},timeout:1e4});Je.interceptors.request.use(t=>{let o="12345";return o&&t.headers&&(t.headers.Authorization=`Bearer ${o}`),t},t=>Promise.reject(t instanceof Error?t:new Error(String(t))));Je.interceptors.response.use(t=>t,async t=>{var e;let o=t.config;return((e=t.response)==null?void 0:e.status)===401&&!o._retry&&(o._retry=!0),Promise.reject(t instanceof Error?t:new Error(String(t)))});var oe=Je;var cs=()=>{let[t,o]=(0,fe.useState)(!1),[e,a]=(0,fe.useState)(!1),[l,p]=(0,fe.useState)(!1),[g,C]=(0,fe.useState)(null),[S,f]=(0,fe.useState)(null);return{logout:(0,fe.useCallback)(async()=>{var y;let m=JSON.parse((y=localStorage.getItem("call-control-sdk-state"))!=null?y:"");o(!0);let r={action:"LOGOUTUSER",userId:m.agentId||""};return oe.post(O.LOGOUT,r).then(h=>(L.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),f(h==null?void 0:h.data),a(!0),h==null?void 0:h.data)).catch(h=>{var E;return p(!0),C(h),(E=h==null?void 0:h.response)==null?void 0:E.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:l,error:g,data:S}},Ao=cs;var me=require("react");var Po=()=>{let[t,o]=(0,me.useState)(!1),[e,a]=(0,me.useState)(!1),[l,p]=(0,me.useState)(!1),[g,C]=(0,me.useState)(null),[S,f]=(0,me.useState)(null);return{handleEndCall:(0,me.useCallback)(async m=>{var h,E,M,U,A,w,B,te,$,R,x,q,se,ne,_;let r=JSON.parse((h=localStorage.getItem("call-control-sdk-state"))!=null?h:"");o(!0);let y={action:"ENDCALL",userId:r==null?void 0:r.agentId,processid:(U=(M=(E=r==null?void 0:r.process)==null?void 0:E.process_id)==null?void 0:M.toString())!=null?U:"",process_name:(w=(A=r==null?void 0:r.process)==null?void 0:A.process_name)!=null?w:"",callreferenceid:(te=(B=r==null?void 0:r.callData)==null?void 0:B.convox_id)!=null?te:"",mobile_number:(R=($=r==null?void 0:r.callData)==null?void 0:$.phone_number)!=null?R:"",disposition:(x=m==null?void 0:m.disposition)!=null?x:"RES",set_followUp:(q=m==null?void 0:m.followUp)!=null?q:"N",callback_date:(se=m==null?void 0:m.callbackDate)!=null?se:"",callback_hrs:(ne=m==null?void 0:m.callbackHrs)!=null?ne:"",callback_mins:(_=m==null?void 0:m.callbackMins)!=null?_:"",endcall_type:"CLOSE"};return oe.post(O.END_CALL,y).then(v=>(L.endCall(),f(v==null?void 0:v.data),a(!0),v==null?void 0:v.data)).catch(v=>{var P;return p(!0),C(v),(P=v==null?void 0:v.response)==null?void 0:P.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:l,error:g,data:S}};var xe=require("react");var Oo=()=>{let[t,o]=(0,xe.useState)(!1),[e,a]=(0,xe.useState)(!1),[l,p]=(0,xe.useState)(!1),[g,C]=(0,xe.useState)(null),[S,f]=(0,xe.useState)(null);return{handleStartCall:(0,xe.useCallback)(async m=>{var y,h,E,M,U,A,w,B,te;let r=JSON.parse((y=localStorage.getItem("call-control-sdk-state"))!=null?y:"");if(o(!0),((h=r==null?void 0:r.callData)==null?void 0:h.status)==="IDLE"){let $={action:"CALL",userId:r==null?void 0:r.agentId,phone_number:m==null?void 0:m.mobileNumber};return oe.post(O.CLICK_TO_CALL,$).then(R=>(f(R==null?void 0:R.data),a(!0),R==null?void 0:R.data)).catch(R=>{var x;return p(!0),C(R),(x=R==null?void 0:R.response)==null?void 0:x.data}).finally(()=>{o(!1)})}else if(((E=r==null?void 0:r.callData)==null?void 0:E.status)==="ONCALL"){let $=(U=(M=r==null?void 0:r.conferenceLine)==null?void 0:M.filter(x=>x.line!==1))==null?void 0:U.find(x=>x.status==="IDLE"&&!(x!=null&&x.isCallStart)),R={action:"EXTERNAL_CONFERENCE",operation:`CALL${$.line}`,line_used:String($.line),thirdparty_no:m==null?void 0:m.mobileNumber,userid:(w=(A=r.callData)==null?void 0:A.agent_id)!=null?w:"",process:(te=(B=r.callData)==null?void 0:B.process_name)!=null?te:""};return oe.post(O.CONFERENCE_CALL,R).then(x=>(f(x==null?void 0:x.data),a(!0),L.setConferenceLine(Z(c({},$),{isCallStart:!0,status:"ONCALL",phone:m==null?void 0:m.mobileNumber})),x==null?void 0:x.data)).catch(x=>{var q;return p(!0),C(x),(q=x==null?void 0:x.response)==null?void 0:q.data}).finally(()=>{o(!1)})}else alert("Agent is not ready")},[]),isLoading:t,isSuccess:e,isError:l,error:g,data:S}};var D=require("@mui/icons-material"),u=require("@mui/material"),K=require("react");var ie=require("react");function Ve(t,o){let[e,a]=(0,ie.useState)(t),[l,p]=(0,ie.useState)(!1),g=(0,ie.useRef)(),C=(0,ie.useRef)({x:0,y:0}),S=(0,ie.useRef)({x:0,y:0}),f=(0,ie.useCallback)(y=>{let h=g.current;if(!h)return;let E=h.getBoundingClientRect(),M=window.innerWidth,U=window.innerHeight,A={x:Math.max(0,Math.min(y.x,M-E.width)),y:Math.max(0,Math.min(y.y,U-E.height))};a(A),o==null||o(A)},[o]),b=(0,ie.useCallback)((y,h)=>{p(!0),C.current={x:y,y:h},S.current=e;let E=(w,B)=>{let te=w-C.current.x,$=B-C.current.y;f({x:S.current.x+te,y:S.current.y+$})},M=w=>{w.preventDefault(),E(w.clientX,w.clientY)},U=w=>{w.preventDefault();let B=w.touches[0];B&&E(B.clientX,B.clientY)},A=()=>{p(!1),document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",A),document.removeEventListener("touchmove",U),document.removeEventListener("touchend",A)};document.addEventListener("mousemove",M),document.addEventListener("mouseup",A),document.addEventListener("touchmove",U,{passive:!1}),document.addEventListener("touchend",A)},[e,f]),m=(0,ie.useCallback)(y=>{y.preventDefault(),b(y.clientX,y.clientY)},[b]),r=(0,ie.useCallback)(y=>{y.preventDefault();let h=y.touches[0];h&&b(h.clientX,h.clientY)},[b]);return{position:e,isDragging:l,dragRef:g,handleMouseDown:m,handleTouchStart:r}}var qe=require("react");function ye(){let[t,o]=(0,qe.useState)(L.getState());return(0,qe.useEffect)(()=>L.subscribe(()=>{o(L.getState())}),[]),t}var We=require("react");var Ce=require("react"),Fe=require("@mui/material"),Ie=require("react/jsx-runtime"),Uo=(0,Ce.createContext)(void 0),_e=()=>{let t=(0,Ce.useContext)(Uo);if(!t)throw new Error("useToast must be used inside ToastProvider");return t},Mo=({children:t})=>{let[o,e]=(0,Ce.useState)(!1),[a,l]=(0,Ce.useState)(""),[p,g]=(0,Ce.useState)("info"),C=(S,f="info")=>{l(S),g(f),e(!0)};return(0,Ie.jsxs)(Uo.Provider,{value:{showToast:C},children:[t,(0,Ie.jsx)(Fe.Snackbar,{open:o,color:p,autoHideDuration:3e3,onClose:()=>e(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,Ie.jsx)(Fe.Alert,{variant:"filled",severity:p,onClose:()=>e(!1),sx:{width:"100%"},children:a})})]})};var ds={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},ps=(t,o)=>{if(o.type==="isLoading")return Z(c({},t),{isLoading:o.payload});if(o.type==="isSuccess")return Z(c({},t),{isSuccess:!0,data:o.payload});if(o.type==="isError")return Z(c({},t),{isError:!0,error:o.payload});if(o.type==="reset")return{isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null};throw Error("Unknown action.")};var le=(t={})=>{let{onSuccess:o=null,onError:e=null}=t,{showToast:a}=_e(),[l,p]=(0,We.useReducer)(ps,ds);return[(0,We.useCallback)((C,S,f={})=>{p({type:"isLoading",payload:!0}),oe.post(C,S,f).then(b=>{var m,r;p({type:"isSuccess",payload:b.data}),o==null||o(b.data,S),console.log((m=b.data)==null?void 0:m.message,"res45"),a((r=b.data)==null?void 0:r.message,"success")}).catch(b=>{var r,y,h,E,M,U,A,w,B,te,$,R;let m={status:(y=(r=b.response)==null?void 0:r.status)!=null?y:500,message:((E=(h=b.response)==null?void 0:h.data)==null?void 0:E.detail)||((U=(M=b.response)==null?void 0:M.data)==null?void 0:U.message)||b.message||"An unknown error occurred",data:(w=(A=b.response)==null?void 0:A.data)!=null?w:null,statusText:(te=(B=b.response)==null?void 0:B.statusText)!=null?te:"",code:($=b==null?void 0:b.code)!=null?$:"",name:(R=b==null?void 0:b.name)!=null?R:""};a(m.message,"error"),p({type:"isError",payload:m}),e==null||e(m,S)}).finally(()=>{p({type:"isLoading",payload:!1})})},[o,e,a]),l]};var N=require("@mui/icons-material"),n=require("@mui/material"),re=require("react");var Bo=require("@mui/material");var us=({disabled:t,enabled:o,outlined:e})=>{let a=(0,Bo.useTheme)();return{disabled:c({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",border:"1px solid rgb(206, 204, 204)",height:"40px","&:hover":{boxShadow:" 0px 2px 2px rgba(0, 0, 0, 0.79)",border:`1px solid ${a.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${a.palette.primary.light}`}},t),enabled:c({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${a.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${a.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${a.palette.primary.light}`}},o),outlined:c({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:a.palette.grey[200],boxShadow:`0px 2px 1px ${a.palette.primary.light}`,border:`0px solid ${a.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${a.palette.primary.main}`,border:`0px solid ${a.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${a.palette.primary.light}`}},e)}},Ke=us;var s=require("react/jsx-runtime"),gs=({each:t})=>{var R,x,q,se,ne;let o=ye(),{showToast:e}=_e(),{disabled:a,enabled:l,outlined:p}=Ke({disabled:((R=o.sdkConfig)==null?void 0:R.disabled)||{},enabled:((x=o.sdkConfig)==null?void 0:x.enabled)||{},outlined:((q=o.sdkConfig)==null?void 0:q.outlined)||{}}),g=(0,n.useTheme)(),[C,S]=(0,re.useState)(!1),[f,b]=(0,re.useState)(!1),[m,r]=(0,re.useState)(!1),[y,h]=(0,re.useState)(!1),[E,M]=(0,re.useState)(!1),U=(_,v)=>{L.setConferenceLine(c(c({},_),v))},A=(_,v)=>{var F,j,Y,X;let P=c(c({},_),v);S(!0);let G={action:"EXTERNAL_CONFERENCE",operation:`CALL${P.line}`,line_used:String(P.line),thirdparty_no:P.phone,userid:(j=(F=o.callData)==null?void 0:F.agent_id)!=null?j:"",process:(X=(Y=o.callData)==null?void 0:Y.process_name)!=null?X:""};oe.post(O.CONFERENCE_CALL,G).then(k=>{var I;e((I=k.data)==null?void 0:I.message,"success"),L.setConferenceLine(c(c({},_),v))}).catch(k=>{var z,J,ee,V;let I=((J=(z=k.response)==null?void 0:z.data)==null?void 0:J.detail)||((V=(ee=k.response)==null?void 0:ee.data)==null?void 0:V.message)||k.message||"An unknown error occurred";e(I,"error")}).finally(()=>{S(!1)})},w=(_,v)=>{var F,j,Y,X;let P=c(c({},_),v);b(!0);let G={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(P.line),thirdparty_no:P.phone,userid:(j=(F=o.callData)==null?void 0:F.agent_id)!=null?j:"",process:(X=(Y=o.callData)==null?void 0:Y.process_name)!=null?X:""};oe.post(O.CONFERENCE_CALL,G).then(k=>{var I;e((I=k.data)==null?void 0:I.message,"success"),L.setConferenceLine(c(c({},_),v))}).catch(k=>{var z,J,ee,V;let I=((J=(z=k.response)==null?void 0:z.data)==null?void 0:J.detail)||((V=(ee=k.response)==null?void 0:ee.data)==null?void 0:V.message)||k.message||"An unknown error occurred";e(I,"error")}).finally(()=>{b(!1)})},B=(_,v,P)=>{var j,Y,X,k;let G=c(c({},_),v);r(!0);let F={action:"EXTERNAL_CONFERENCE",operation:P,hold_channel_no:P==="HOLDUSER"?`hold${G.line}`:`unhold${G.line}`,userid:(Y=(j=o.callData)==null?void 0:j.agent_id)!=null?Y:"",process:(k=(X=o.callData)==null?void 0:X.process_name)!=null?k:""};oe.post(O.CONFERENCE_CALL_HOLD_OR_UN_HOLD,F).then(I=>{var z;e((z=I.data)==null?void 0:z.message,"success"),L.setConferenceLine(c(c({},_),v))}).catch(I=>{var J,ee,V,pe;let z=((ee=(J=I.response)==null?void 0:J.data)==null?void 0:ee.detail)||((pe=(V=I.response)==null?void 0:V.data)==null?void 0:pe.message)||I.message||"An unknown error occurred";e(z,"error")}).finally(()=>{r(!1)})},te=(_,v,P)=>{var j,Y,X,k;let G=c(c({},_),v);h(!0);let F={action:"EXTERNAL_CONFERENCE",operation:P,channel_no:P==="MUTEUSER"?`mute${G.line}`:`play${G.line}`,userid:(Y=(j=o.callData)==null?void 0:j.agent_id)!=null?Y:"",thirdparty_no:G.phone,process:(k=(X=o.callData)==null?void 0:X.process_name)!=null?k:""};oe.post(O.CONFERENCE_CALL_MUTE_OT_UN_MUTE,F).then(I=>{var z;e((z=I.data)==null?void 0:z.message,"success"),L.setConferenceLine(c(c({},_),v))}).catch(I=>{var J,ee,V,pe;let z=((ee=(J=I.response)==null?void 0:J.data)==null?void 0:ee.detail)||((pe=(V=I.response)==null?void 0:V.data)==null?void 0:pe.message)||I.message||"An unknown error occurred";e(z,"error")}).finally(()=>{h(!1)})},$=(_,v)=>{var F,j,Y,X;let P=c(c({},_),v);M(!0);let G={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(P.line-1),user_type:`THIRDPARTY${P.line-1}`,thirdparty_no:P.phone,userid:(j=(F=o.callData)==null?void 0:F.agent_id)!=null?j:"",process:(X=(Y=o.callData)==null?void 0:Y.process_name)!=null?X:""};oe.post(O.CONFERENCE_CALL_END,G).then(k=>{var I;e((I=k.data)==null?void 0:I.message,"success"),L.setConferenceLine(c(c({},_),v))}).catch(k=>{var z,J,ee,V;let I=((J=(z=k.response)==null?void 0:z.data)==null?void 0:J.detail)||((V=(ee=k.response)==null?void 0:ee.data)==null?void 0:V.message)||k.message||"An unknown error occurred";e(I,"error")}).finally(()=>{M(!1)})};return(0,s.jsxs)(n.TableRow,{sx:{border:"2px solid #fff"},children:[(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsxs)(n.Typography,{children:["Line ",(se=t==null?void 0:t.line)!=null?se:"",". "]})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsx)(n.Typography,{variant:"body2",sx:{px:1,borderRadius:"10px",width:"80px",maxWidth:"100px"},children:(ne=t==null?void 0:t.status)!=null?ne:""})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsx)(n.Button,{sx:{textTransform:"capitalize"},size:"small",children:(0,s.jsx)(n.Typography,{variant:"body2",children:(t==null?void 0:t.line)===1?"Internal":"External"})})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsx)(n.TextField,{size:"small",placeholder:"Phone Number",value:(t==null?void 0:t.phone)||"",disabled:(t==null?void 0:t.line)===1,onChange:_=>{U(t,{phone:_.target.value})}})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsxs)(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-around"},children:[(0,s.jsx)(n.Tooltip,{title:"Call",children:(0,s.jsx)(n.Button,{variant:t!=null&&t.isCallStart?"outlined":"contained",color:"success",sx:t!=null&&t.isCallStart?c({},a):Z(c({},l),{border:`0px solid ${g.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${g.palette.success.light}`,border:`0px solid ${g.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${g.palette.primary.light}`}}),onClick:()=>{A(t,{isCallStart:!0,status:"ONCALL"})},disabled:(t==null?void 0:t.isCallStart)||C,children:C?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"success"}):(0,s.jsx)(N.Call,{sx:{color:t!=null&&t.isCallStart?"default":"#e7e7e7ff"}})})}),(0,s.jsx)(n.Tooltip,{title:"Merge Call",children:(0,s.jsx)(n.Button,{variant:t!=null&&t.isMergeCall?"contained":"outlined",sx:t!=null&&t.isMergeCall&&(t!=null&&t.isCallStart)?c({},a):t!=null&&t.isCallStart?c({},p):c({},a),onClick:()=>{w(t,{isMergeCall:!0,status:"ONCALL"})},disabled:!(t!=null&&t.isCallStart)||f,children:f?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:t!=null&&t.isMergeCall?"#e7e7e7ff":g.palette.primary.main}}):(0,s.jsx)(N.CallSplit,{})})}),(0,s.jsx)(n.Tooltip,{title:t.isHold?"Hold":"Un Hold",children:(0,s.jsx)(n.Button,{variant:t!=null&&t.isHold?"contained":"outlined",sx:t!=null&&t.isHold&&(t!=null&&t.isCallStart)?c({},a):t!=null&&t.isCallStart?c({},p):c({},a),onClick:()=>{t.isHold?B(t,{isHold:!1},"UNHOLDUSER"):B(t,{isHold:!0},"HOLDUSER")},disabled:!(t!=null&&t.isCallStart)||m,children:m?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:g.palette.primary.main}}):t.isHold?(0,s.jsx)(N.PlayArrow,{}):(0,s.jsx)(N.Pause,{})})}),(0,s.jsx)(n.Tooltip,{title:t.isMute?"Mute":"Un Mute",children:(0,s.jsx)(n.Button,{variant:t!=null&&t.isMute?"contained":"outlined",sx:t!=null&&t.isMute&&(t!=null&&t.isCallStart)?c({},a):t!=null&&t.isCallStart?c({},p):c({},a),onClick:()=>{t.isMute?te(t,{isMute:!1},"PLAYUSER"):te(t,{isMute:!0},"MUTEUSER")},disabled:!(t!=null&&t.isCallStart)||y,children:y?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:g.palette.primary.main}}):t.isMute?(0,s.jsx)(N.MicOff,{}):(0,s.jsx)(N.Mic,{})})}),(0,s.jsx)(n.Tooltip,{title:"End Call",children:(t==null?void 0:t.line)!==1?(0,s.jsx)(n.Button,{variant:t!=null&&t.isCallStart?"contained":"outlined",color:"error",sx:t!=null&&t.isCallStart?Z(c({},l),{minWidth:"60px !important",border:`0px solid ${g.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${g.palette.error.light}`,border:`0px solid ${g.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${g.palette.primary.light}`}}):Z(c({},a),{minWidth:"60px !important"}),onClick:()=>{$(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(t!=null&&t.isCallStart)||E,children:E?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"error"}):(0,s.jsx)(N.CallEnd,{})}):(0,s.jsx)(n.Button,{variant:t!=null&&t.isCallStart?"contained":"outlined",sx:Z(c({},a),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{$(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(t!=null&&t.isCallStart),children:(0,s.jsx)(n.Typography,{children:(0,s.jsx)(N.CallEnd,{sx:{visibility:"hidden"}})})})})]})})]},t.line)};function Ho({open:t,setOpen:o}){var S;let e=ye(),{showToast:a}=_e(),[l,p]=(0,re.useState)(!1),g=()=>{o(!1)},C=()=>{var b,m,r,y;p(!0);let f={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(m=(b=e.callData)==null?void 0:b.agent_id)!=null?m:"",process:(y=(r=e.callData)==null?void 0:r.process_name)!=null?y:""};oe.post(O.CONFERENCE_CALL_END_ALL,f).then(h=>{var E;a((E=h.data)==null?void 0:E.message,"success"),L.resetConferenceLines(),g()}).catch(h=>{var M,U,A,w;let E=((U=(M=h.response)==null?void 0:M.data)==null?void 0:U.detail)||((w=(A=h.response)==null?void 0:A.data)==null?void 0:w.message)||h.message||"An unknown error occurred";a(E,"error")}).finally(()=>{p(!1)})};return(0,re.useEffect)(()=>{var b,m,r,y;let f={line:1,status:(m=(b=e.callData)==null?void 0:b.status)!=null?m:"",type:"internal",phone:(y=(r=e.callData)==null?void 0:r.phone_number)!=null?y:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};L.setConferenceLine(f)},[]),(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px"},children:[(0,s.jsxs)(n.Typography,{variant:"body1",children:[(S=e==null?void 0:e.agentId)!=null?S:""," conference"]}),(0,s.jsx)(n.IconButton,{onClick:g,children:(0,s.jsx)(N.Close,{})})]}),(0,s.jsx)(n.Box,{sx:{boxShadow:"1px 1px 2px #e7e5e5ff",margin:"0px 15px",borderRadius:"20px"},children:(0,s.jsx)(n.TableContainer,{component:n.Paper,sx:{outline:"0px solid gray !important",boxShadow:"1px 1px 6px #e7e5e5ff"},children:(0,s.jsxs)(n.Table,{sx:{border:"4px solid #ffffff !important"},children:[(0,s.jsx)(n.TableHead,{children:(0,s.jsxs)(n.TableRow,{sx:{border:"2px solid #f3f3f3ff !important"},children:[(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Line"}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Status"}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Call Type"}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Mobile Number"}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Call Actions"})]})}),(0,s.jsx)(n.TableBody,{children:e==null?void 0:e.conferenceLine.map(f=>(0,s.jsx)(gs,{each:f}))})]})})}),(0,s.jsx)(n.Box,{textAlign:"center",m:2,children:(0,s.jsxs)(n.Button,{variant:"outlined",color:"error",size:"large",onClick:C,disabled:l,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[l?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"error",sx:{marginRight:"8px"}}):(0,s.jsx)(n.IconButton,{sx:{bgcolor:"error.main","&:hover":{bgcolor:"error.dark"},marginRight:"8px",width:"28px",height:"28px",fontSize:"12px",fontWeight:"600",lineHeight:"16px",letterSpacing:"0.02em",textTransform:"capitalize",color:"white",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%"},children:(0,s.jsx)(N.PhoneDisabled,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function $o({open:t,setOpen:o}){var r,y,h,E,M,U,A,w,B,te,$,R;let[e]=le({onSuccess:x=>{console.log("res",x),o(!1)},onError:x=>{console.log("error",x)}}),a=ye(),[l,p]=(0,re.useState)("process"),[g,{data:C}]=le(),[S,{data:f}]=le(),b=()=>{o(!1)},m=(x,q)=>{var se,ne,_,v,P,G,F,j,Y,X,k,I,z,J,ee,V,pe,we,be,Re,ve,ke,Se,Ne,Ae,Pe,Ee,Oe,Ue,Me,Be,He,$e;if(console.log(x,"data34"),q==="PROCESS"){let he={mobile_number:(ne=(se=a.callData)==null?void 0:se.phone_number)!=null?ne:"",userid:(v=(_=a.callData)==null?void 0:_.agent_id)!=null?v:"",type:"PROCESS",transfer_to:(P=x==null?void 0:x.process_name)!=null?P:"",callreferenceid:(F=(G=a.callData)==null?void 0:G.convox_id)!=null?F:"",processid:String((Y=(j=a.callData)==null?void 0:j.process_id)!=null?Y:""),process_name:(k=(X=a.callData)==null?void 0:X.process_name)!=null?k:""};e(O.TRANSFER_CALL,he)}else if(q==="QUEUE"){let he={mobile_number:(z=(I=a.callData)==null?void 0:I.phone_number)!=null?z:"",userid:(ee=(J=a.callData)==null?void 0:J.agent_id)!=null?ee:"",type:"QUEUE",transfer_to:(V=x==null?void 0:x.queue_name)!=null?V:"",callreferenceid:(we=(pe=a.callData)==null?void 0:pe.convox_id)!=null?we:"",processid:String((Re=(be=a.callData)==null?void 0:be.process_id)!=null?Re:""),process_name:(ke=(ve=a.callData)==null?void 0:ve.process_name)!=null?ke:""};e(O.TRANSFER_CALL,he)}else if(q==="AGENT"){let he={mobile_number:(Ne=(Se=a.callData)==null?void 0:Se.phone_number)!=null?Ne:"",userid:(Pe=(Ae=a.callData)==null?void 0:Ae.agent_id)!=null?Pe:"",type:"AGENT",transfer_to:(Ee=x==null?void 0:x.user_id)!=null?Ee:"",callreferenceid:(Ue=(Oe=a.callData)==null?void 0:Oe.convox_id)!=null?Ue:"",processid:String((Be=(Me=a.callData)==null?void 0:Me.process_id)!=null?Be:""),process_name:($e=(He=a.callData)==null?void 0:He.process_name)!=null?$e:""};e(O.TRANSFER_CALL,he)}};return(0,re.useEffect)(()=>{g(O.AGENTS_LIST,{status:"IDLE",active:!0}),S(O.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),console.log(C,"idleAgentsList"),(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,s.jsx)(n.Typography,{variant:"body1",children:" Call Transfer"}),(0,s.jsx)(n.IconButton,{onClick:b,children:(0,s.jsx)(N.Close,{})})]}),(0,s.jsxs)(n.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",gap:1},children:[(0,s.jsx)(n.Button,{variant:l==="process"?"contained":"outlined",onClick:()=>p("process"),children:"Process"}),(0,s.jsx)(n.Button,{variant:l==="queues"?"contained":"outlined",onClick:()=>p("queues"),children:"Queues"}),(0,s.jsx)(n.Button,{variant:l==="agents"?"contained":"outlined",onClick:()=>p("agents"),children:"Agents"})]}),l==="process"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(r=f==null?void 0:f.data)!=null&&r.process&&((h=(y=f==null?void 0:f.data)==null?void 0:y.process)==null?void 0:h.length)>0?(M=(E=f==null?void 0:f.data)==null?void 0:E.process)==null?void 0:M.map((x,q)=>(0,s.jsxs)(n.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,s.jsxs)(n.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,s.jsx)(N.SupportAgent,{sx:{marginRight:"4px"}}),x.process_name]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{m(x,"PROCESS")},children:(0,s.jsx)(N.Call,{})})]},q)):(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Process Found"})}),l==="queues"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(U=f==null?void 0:f.data)!=null&&U.queue&&((w=(A=f==null?void 0:f.data)==null?void 0:A.queue)==null?void 0:w.length)>0?(te=(B=f==null?void 0:f.data)==null?void 0:B.queue)==null?void 0:te.map((x,q)=>{var se,ne,_,v,P,G;return(0,s.jsxs)(n.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,s.jsxs)(n.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,s.jsx)(N.SupportAgent,{sx:{marginRight:"4px"}}),x.queue_name,(_=(ne=(se=f==null?void 0:f.data)==null?void 0:se.process)==null?void 0:ne.find(F=>F.process_id===x.process_id))!=null&&_.process_name?(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((G=(P=(v=f==null?void 0:f.data)==null?void 0:v.process)==null?void 0:P.find(F=>F.process_id===x.process_id))==null?void 0:G.process_name)+")"}):""]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{m(x,"QUEUE")},children:(0,s.jsx)(N.Call,{})})]},q)}):(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Queues Found"})}),l==="agents"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:C!=null&&C.data&&(($=C==null?void 0:C.data)==null?void 0:$.length)>0?(R=C==null?void 0:C.data)==null?void 0:R.map((x,q)=>(0,s.jsxs)(n.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,s.jsxs)(n.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,s.jsx)(N.SupportAgent,{sx:{marginRight:"4px"}}),x.name]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{m(x,"AGENT")},children:(0,s.jsx)(N.Call,{})})]},q)):(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Agents Found"})})]})]})})})}function zo({open:t,setOpen:o,onSubmitDisposition:e}){var b,m;let[a,l]=(0,re.useState)({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),p=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],g=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],C=(r,y)=>{l(h=>Z(c({},h),{[r]:y}))},S=()=>{l({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},f=()=>{S(),o(!1)};return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsx)(n.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:(0,s.jsxs)(n.Typography,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),(0,s.jsx)(n.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:(0,s.jsxs)(n.Grid,{container:!0,spacing:2,children:[(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.Autocomplete,{value:a.disposition,options:p,getOptionLabel:r=>r.label,onChange:(r,y)=>C("disposition",y),size:"small",renderInput:r=>(0,s.jsx)(n.TextField,Z(c({},r),{label:"Disposition",fullWidth:!0}))})}),(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.Autocomplete,{options:g,getOptionLabel:r=>r.label,value:a.followUp,onChange:(r,y)=>C("followUp",y),size:"small",renderInput:r=>(0,s.jsx)(n.TextField,Z(c({},r),{label:"Follow Up",fullWidth:!0}))})}),((m=(b=a==null?void 0:a.followUp)==null?void 0:b.label)==null?void 0:m.toLowerCase())==="yes"&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.TextField,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:a.callbackDate,onChange:r=>C("callbackDate",r.target.value),fullWidth:!0})}),(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.TextField,{size:"small",label:"Hours (0-23)",type:"text",inputProps:{min:0,max:23},value:a.callbackHrs,onChange:r=>C("callbackHrs",r.target.value),fullWidth:!0})}),(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.TextField,{size:"small",label:"Minutes (0-59)",type:"text",inputProps:{min:0,max:59},value:a.callbackMins,onChange:r=>C("callbackMins",r.target.value),fullWidth:!0})})]})]})}),(0,s.jsxs)(n.Box,{textAlign:"right",m:2,children:[(0,s.jsx)(n.Button,{variant:"outlined",color:"error",size:"large",onClick:f,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),(0,s.jsx)(n.Button,{variant:"contained",color:"primary",size:"large",onClick:()=>e(a),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function qo({open:t,setOpen:o}){return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,s.jsx)(n.Typography,{variant:"body1",children:" Call History"}),(0,s.jsx)(n.IconButton,{onClick:()=>{o(!1)},children:(0,s.jsx)(N.Close,{})})]}),(0,s.jsx)(n.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",margin:"10px",borderRadius:"10px",textAlign:"center",fontSize:"16px",fontWeight:"bold"},p:6,children:"Coming Soon..."})]})})})}var d=require("react/jsx-runtime");function Fo({onDataChange:t}){var et,tt,ot,st,nt,at,it,lt,rt,ct,dt,pt,ut,gt,ft,mt,xt,Ct,ht,yt,bt,vt,St,Et,Tt,Lt,Dt,It,_t,wt,Rt,kt,Nt,At,Pt,Ot,Ut,Mt,Bt,Ht,$t,zt,qt,Ft,Wt,Kt,Gt,Yt,jt,Xt,Jt,Vt,Qt,Zt,eo,to,oo,so,no,ao,io,lo,ro,co,po,uo,go,fo,mo,xo,Co,ho;let o=(0,u.useTheme)(),e=ye(),{disabled:a,enabled:l,outlined:p}=Ke({disabled:((et=e.sdkConfig)==null?void 0:et.disabled)||{},enabled:((tt=e.sdkConfig)==null?void 0:tt.enabled)||{},outlined:((ot=e.sdkConfig)==null?void 0:ot.outlined)||{}}),g=(0,K.useRef)(null),[C,S]=(0,K.useState)(null),[f,b]=(0,K.useState)(!0),[m,r]=(0,K.useState)(null),[y,h]=(0,K.useState)(null),[E,M]=(0,K.useState)(!1),[U,A]=(0,K.useState)(!1),[w,B]=(0,K.useState)(!1),[te,$]=(0,K.useState)(!1),[R,x]=(0,K.useState)(!1),[q,se]=(0,K.useState)(""),[ne,_]=(0,K.useState)(0),{position:v,isDragging:P,dragRef:G,handleMouseDown:F,handleTouchStart:j}=Ve(e.controlPanelPosition,i=>L.setControlPanelPosition(i)),{position:Y,isDragging:X,dragRef:k,handleMouseDown:I,handleTouchStart:z}=Ve(e.iframePosition,i=>L.setIframePosition(i)),[J,{data:ee}]=le({onSuccess:i=>{var T;console.log("res",i),i&&i.data&&((T=i==null?void 0:i.data)==null?void 0:T.length)>1?$(!0):(L.setProcess(i==null?void 0:i.data[0]),$(!1))},onError:()=>{$(!1)}}),[V,{isLoading:pe}]=le(),[we,{isLoading:be}]=le({onSuccess:()=>{L.setHolding(!e.isHolding)},onError:i=>{console.log("error",i)}}),[Re,{isLoading:ve}]=le({onSuccess:()=>{L.setMuted(!e.isMuted)},onError:i=>{console.log("error",i)}}),[ke,{isLoading:Se}]=le(),[Ne,{isLoading:Ae}]=le(),[Pe,{isLoading:Ee}]=le(),Oe=(0,K.useCallback)(i=>{let T=Math.floor(i/60),Q=i%60;return`${T.toString().padStart(2,"0")}:${Q.toString().padStart(2,"0")}`},[]),Ue=()=>{S(null)},Me=i=>{b(!0),h(i.currentTarget),L.setStatus("dial")},Be=()=>{e.status!=="on call"&&L.setStatus("idle"),h(null)},He=i=>{r(i.currentTarget)},$e=()=>{r(null)},he=()=>{let i={action:"READYAGENT",userId:e.agentId};ke(O.READY_AGENT,i)},Ze=i=>{r(null);let T={action:"AGENTBREAK",break_type:i,userId:e.agentId};Ne(O.UPDATE_AGENT_BREAK,T)},Yo=i=>{if(i.length!==10)alert("Invalid phone number");else if(/^\d+$/.test(i)){let T={action:"CALL",phone_number:i,userId:e.agentId};V(O.CLICK_TO_CALL,T)}},jo=()=>{let i={action:e.isHolding?"UNHOLD":"HOLD",userId:e.agentId};we(O.HOLD_CALL,i)},Xo=()=>{let i={action:e.isMuted?"UNMUTE":"MUTE",userId:e.agentId};Re(O.MUTE_CALL,i)},Jo=i=>{var Q,ce,de,ue,ge,Te,Le,yo,bo,vo,So,Eo,To,Lo,Do,Io;console.log("data",i);let T={action:"ENDCALL",userId:e.agentId,processid:(de=(ce=(Q=e.process)==null?void 0:Q.process_id)==null?void 0:ce.toString())!=null?de:"",process_name:(ge=(ue=e.process)==null?void 0:ue.process_name)!=null?ge:"",callreferenceid:(Le=(Te=e.callData)==null?void 0:Te.convox_id)!=null?Le:"",mobile_number:(bo=(yo=e.callData)==null?void 0:yo.phone_number)!=null?bo:"",disposition:(So=(vo=i==null?void 0:i.disposition)==null?void 0:vo.value)!=null?So:"",set_followUp:(To=(Eo=i==null?void 0:i.followUp)==null?void 0:Eo.value)!=null?To:"",callback_date:(Lo=i==null?void 0:i.callbackDate)!=null?Lo:"",callback_hrs:(Do=i==null?void 0:i.callbackHrs)!=null?Do:"",callback_mins:(Io=i==null?void 0:i.callbackMins)!=null?Io:"",endcall_type:"CLOSE"};se(""),Pe(O.END_CALL,T),L.endCall(),B(!1)};return(0,K.useEffect)(()=>{let i;return e.callData.status&&e.callData.status==="ONCALL"?i=setInterval(()=>{let T=Math.floor((Date.now()-e.callStartTime)/1e3);_(T)},1e3):_(0),()=>{i&&clearInterval(i)}},[e.callData.status]),(0,K.useEffect)(()=>{t&&t(e.callData)},[e.callData,t]),(0,K.useEffect)(()=>{e.agentId?J(O.PROCESS_LIST,{userId:e.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[e.agentId]),(0,K.useEffect)(()=>(e.agentId&&(g.current=new WebSocket(`${ko.WS}?agent_id=${e.agentId}`),g.current.onopen=()=>{console.log("WebSocket connection established")},g.current.onmessage=i=>{try{let T=JSON.parse(i.data);console.log("parsedJSON:",T),L.updateCallData(T),T.status==="ONCALL"&&L.startCall(),T.status==="WRAPUP"&&L.endCall()}catch(T){console.log("Raw message:",i.data)}},g.current.onclose=()=>{console.log("WebSocket connection closed")},g.current.onerror=i=>{console.error("WebSocket error:",i)}),()=>{var i;(i=g.current)==null||i.close()}),[e.agentId]),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(u.Fade,{in:!0,timeout:300,children:(0,d.jsx)(u.Paper,{ref:G,elevation:P?4:1,sx:{position:"fixed",left:v.x,top:v.y,p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:99999,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),userSelect:"none"},children:(0,d.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,d.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,d.jsxs)(u.IconButton,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:F,onTouchStart:j,children:[(0,d.jsx)(D.DragIndicator,{})," "]}),(0,d.jsx)(u.Box,{sx:{marginRight:"10px"},children:(0,d.jsx)(u.Tooltip,{title:"Dial",children:(0,d.jsx)(u.IconButton,{size:"small",onClick:i=>{var T,Q,ce,de,ue,ge,Te,Le;((Q=(T=e.callData)==null?void 0:T.status)==null?void 0:Q.toUpperCase())!=="ONCALL"&&((de=(ce=e.callData)==null?void 0:ce.status)==null?void 0:de.toUpperCase())!=="BREAK"&&((ge=(ue=e.callData)==null?void 0:ue.status)==null?void 0:ge.toUpperCase())!=="RINGING"&&((Le=(Te=e.callData)==null?void 0:Te.status)==null?void 0:Le.toUpperCase())!=="WRAPUP"&&Me(i)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:(0,d.jsx)(D.WifiCalling3,{sx:{color:((nt=(st=e.callData)==null?void 0:st.status)==null?void 0:nt.toUpperCase())==="ONCALL"||((it=(at=e.callData)==null?void 0:at.status)==null?void 0:it.toUpperCase())==="BREAK"||((rt=(lt=e.callData)==null?void 0:lt.status)==null?void 0:rt.toUpperCase())==="RINGING"||((dt=(ct=e.callData)==null?void 0:ct.status)==null?void 0:dt.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),(0,d.jsx)(u.Typography,{sx:{color:"success.main",width:"40px",marginRight:"10px"},children:Oe(ne)}),Ae||Se?(0,d.jsx)(u.Box,{sx:{fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,d.jsx)(u.CircularProgress,{size:"20px"})}):(0,d.jsx)(u.Typography,{variant:"body2",sx:{fontWeight:"bold",textAlign:"right"},children:(gt=(ut=(pt=e.callData)==null?void 0:pt.status)==null?void 0:ut.toUpperCase())!=null?gt:"N/A"}),(0,d.jsx)(u.Box,{onClick:He,sx:{display:"flex",alignItems:"center",margin:"6px",cursor:"pointer"},children:(0,d.jsx)(D.ArrowDropDown,{})})]}),(0,d.jsxs)(u.Box,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[(0,d.jsx)(u.Tooltip,{title:"Agent Ready",children:(0,d.jsx)(u.Button,{variant:((mt=(ft=e.callData)==null?void 0:ft.status)==null?void 0:mt.toUpperCase())==="BREAK"||((Ct=(xt=e.callData)==null?void 0:xt.status)==null?void 0:Ct.toUpperCase())==="MISSED"?"outlined":"contained",onClick:i=>{var T,Q,ce,de;(((Q=(T=e.callData)==null?void 0:T.status)==null?void 0:Q.toUpperCase())==="BREAK"||((de=(ce=e.callData)==null?void 0:ce.status)==null?void 0:de.toUpperCase())==="MISSED")&&(i.stopPropagation(),he())},classes:{root:((yt=(ht=e.callData)==null?void 0:ht.status)==null?void 0:yt.toUpperCase())==="BREAK"||((vt=(bt=e.callData)==null?void 0:bt.status)==null?void 0:vt.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:c({},((Et=(St=e.callData)==null?void 0:St.status)==null?void 0:Et.toUpperCase())==="BREAK"||((Lt=(Tt=e.callData)==null?void 0:Tt.status)==null?void 0:Lt.toUpperCase())==="MISSED"?p:l),disabled:Se,children:(0,d.jsx)(D.SupportAgent,{})})}),(0,d.jsx)(u.Tooltip,{title:e.isHolding?"Resume":"Hold",children:(0,d.jsx)(u.Button,{variant:e.isHolding&&((It=(Dt=e.callData)==null?void 0:Dt.status)==null?void 0:It.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),jo()},sx:e.isHolding&&((wt=(_t=e.callData)==null?void 0:_t.status)==null?void 0:wt.toUpperCase())==="ONCALL"?c({},l):((kt=(Rt=e.callData)==null?void 0:Rt.status)==null?void 0:kt.toUpperCase())==="ONCALL"?c({},p):c({},a),disabled:((At=(Nt=e.callData)==null?void 0:Nt.status)==null?void 0:At.toUpperCase())!=="ONCALL"&&!e.isHolding||be,children:be?(0,d.jsx)(u.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isHolding?(0,d.jsx)(D.PlayArrow,{}):(0,d.jsx)(D.Pause,{})})}),(0,d.jsx)(u.Tooltip,{title:e.isMuted?"Unmute":"Mute",children:(0,d.jsx)(u.Button,{variant:e.isMuted&&((Ot=(Pt=e.callData)==null?void 0:Pt.status)==null?void 0:Ot.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),Xo()},sx:e.isMuted&&((Mt=(Ut=e.callData)==null?void 0:Ut.status)==null?void 0:Mt.toUpperCase())==="ONCALL"?c({},l):((Ht=(Bt=e.callData)==null?void 0:Bt.status)==null?void 0:Ht.toUpperCase())==="ONCALL"?c({},p):c({},a),disabled:((zt=($t=e.callData)==null?void 0:$t.status)==null?void 0:zt.toUpperCase())!=="ONCALL"&&!e.isMuted||ve,children:ve?(0,d.jsx)(u.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isMuted?(0,d.jsx)(D.MicOff,{}):(0,d.jsx)(D.Mic,{})})}),((qt=e.sdkConfig)==null?void 0:qt.showTransferButton)&&(0,d.jsx)(u.Tooltip,{title:"Transfer Call",children:(0,d.jsx)(u.Button,{variant:U?"contained":"outlined",onClick:i=>{var T,Q;((Q=(T=e.callData)==null?void 0:T.status)==null?void 0:Q.toUpperCase())==="ONCALL"&&(i.stopPropagation(),A(!0))},sx:U?c({},l):((Wt=(Ft=e.callData)==null?void 0:Ft.status)==null?void 0:Wt.toUpperCase())==="ONCALL"?c({},p):c({},a),disabled:((Gt=(Kt=e.callData)==null?void 0:Kt.status)==null?void 0:Gt.toUpperCase())!=="ONCALL",children:(0,d.jsx)(D.TransferWithinAStation,{})})}),((Yt=e.sdkConfig)==null?void 0:Yt.showConferenceButton)&&(0,d.jsx)(u.Tooltip,{title:"Conference Call",children:(0,d.jsx)(u.Button,{variant:E?"contained":"outlined",onClick:i=>{var T,Q;((Q=(T=e.callData)==null?void 0:T.status)==null?void 0:Q.toUpperCase())==="ONCALL"&&(i.stopPropagation(),M(!0))},sx:E?c({},l):((Xt=(jt=e.callData)==null?void 0:jt.status)==null?void 0:Xt.toUpperCase())==="ONCALL"?c({},p):c({},a),disabled:((Vt=(Jt=e.callData)==null?void 0:Jt.status)==null?void 0:Vt.toUpperCase())!=="ONCALL",children:(0,d.jsx)(D.Group,{})})}),((Qt=e.sdkConfig)==null?void 0:Qt.showEndCallButton)&&(0,d.jsx)(u.Tooltip,{title:"End Call",children:(0,d.jsx)(u.Button,{variant:((eo=(Zt=e.callData)==null?void 0:Zt.status)==null?void 0:eo.toUpperCase())==="ONCALL"||((oo=(to=e.callData)==null?void 0:to.status)==null?void 0:oo.toUpperCase())==="RINGING"||((no=(so=e.callData)==null?void 0:so.status)==null?void 0:no.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:i=>{var T,Q,ce,de,ue,ge;(((Q=(T=e.callData)==null?void 0:T.status)==null?void 0:Q.toUpperCase())==="ONCALL"||((de=(ce=e.callData)==null?void 0:ce.status)==null?void 0:de.toUpperCase())==="RINGING"||((ge=(ue=e.callData)==null?void 0:ue.status)==null?void 0:ge.toUpperCase())==="WRAPUP")&&(i.stopPropagation(),B(!0))},sx:((io=(ao=e.callData)==null?void 0:ao.status)==null?void 0:io.toUpperCase())==="ONCALL"||((ro=(lo=e.callData)==null?void 0:lo.status)==null?void 0:ro.toUpperCase())==="RINGING"||((po=(co=e.callData)==null?void 0:co.status)==null?void 0:po.toUpperCase())==="WRAPUP"?Z(c({},l),{borderRight:"1px",backgroundColor:"error.main",minWidth:"60px !important",boxShadow:" 0px 2px 1px #5f3f3f",border:`1px solid ${o.palette.error.light}`,height:"40px","&:hover":{bgcolor:"error.light",boxShadow:" 0px 2px 1px #5f3f3f",border:`0px solid ${o.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${o.palette.primary.light}`}}):Z(c({},a),{minWidth:"60px !important"}),disabled:((go=(uo=e.callData)==null?void 0:uo.status)==null?void 0:go.toUpperCase())!=="ONCALL"&&((mo=(fo=e.callData)==null?void 0:fo.status)==null?void 0:mo.toUpperCase())!=="RINGING"&&((Co=(xo=e.callData)==null?void 0:xo.status)==null?void 0:Co.toUpperCase())!=="WRAPUP"||Ee,children:Ee?(0,d.jsx)(u.CircularProgress,{size:"20px",color:"error"}):(0,d.jsx)(D.CallEnd,{})})})]})]})})}),(0,d.jsx)(u.Fade,{in:!0,timeout:300,children:(0,d.jsxs)(u.Paper,{ref:k,elevation:X?4:1,sx:{position:"fixed",left:Y.x,top:Y.y,p:1,height:"auto",borderRadius:2,bgcolor:"background.paper",zIndex:99999,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),visibility:f?"visible":"hidden",userSelect:"none"},children:[(0,d.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll"},onMouseDown:I,onTouchStart:z,children:[(0,d.jsx)(D.DragIndicator,{sx:{transform:"rotate(90deg)"}})," ",(0,d.jsx)(u.IconButton,{onClick:()=>b(!1),children:(0,d.jsx)(D.Close,{})})]}),(0,d.jsx)("iframe",{src:`https://${ze}/ConVoxCCS/iframe?agent_id=${e.agentId}&process_id=${(ho=e.process)==null?void 0:ho.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay",style:{border:"none"}})]})}),(0,d.jsx)(u.Menu,{anchorEl:y,open:!!y,onClose:Be,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,d.jsxs)(u.Box,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[(0,d.jsx)(u.TextField,{size:"small",value:q,placeholder:"Enter Mobile No.",onChange:i=>{se(i.target.value)}}),(0,d.jsx)(u.IconButton,{color:"info",onClick:()=>{Yo(q)},children:pe?(0,d.jsx)(u.CircularProgress,{size:"20px",sx:{color:o.palette.success.main}}):(0,d.jsx)(D.Phone,{color:"success"})})]})}),(0,d.jsxs)(u.Menu,{anchorEl:m,open:!!m,onClose:$e,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:[(0,d.jsx)(u.MenuItem,{onClick:()=>Ze("Lunch"),children:"- Lunch"}),(0,d.jsx)(u.MenuItem,{onClick:()=>Ze("Tea"),children:"- Tea"})]}),(0,d.jsx)(u.Menu,{anchorEl:C,open:!!C,onClose:Ue,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,d.jsxs)(u.Box,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[(0,d.jsx)(u.Chip,{icon:(0,d.jsx)(D.Layers,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),(0,d.jsx)(u.Chip,{icon:(0,d.jsx)(D.Pending,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),(0,d.jsx)(u.Chip,{icon:(0,d.jsx)(D.Upcoming,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!E&&(0,d.jsx)(Ho,{open:E,setOpen:M}),!!U&&(0,d.jsx)($o,{open:U,setOpen:A}),!!w&&(0,d.jsx)(zo,{open:w,setOpen:B,onSubmitDisposition:Jo}),!!R&&(0,d.jsx)(qo,{open:R,setOpen:x})]})}var Ko=require("react/jsx-runtime"),Wo=({children:t})=>(0,Ko.jsx)(Mo,{children:t});var Qe=require("react/jsx-runtime");function Go({onDataChange:t}){return(0,Qe.jsx)(Wo,{children:(0,Qe.jsx)(Fo,{onDataChange:t})})}function fs({apiKey:t,tenantId:o,agentId:e,sdkConfig:a}){L.initialize(t,e,a),je.init({apiKey:t,tenantId:o,agentId:e,baseUrl:H}).then(l=>{console.log(l?"SDK initialized successfully":"SDK initialization failed")})}0&&(module.exports={CallControlPanel,initSDK,useClickToCall,useEndCall,useLogout});
|
|
1
|
+
"use strict";var as=Object.create;var De=Object.defineProperty,is=Object.defineProperties,ls=Object.getOwnPropertyDescriptor,rs=Object.getOwnPropertyDescriptors,cs=Object.getOwnPropertyNames,Oo=Object.getOwnPropertySymbols,ds=Object.getPrototypeOf,Mo=Object.prototype.hasOwnProperty,ps=Object.prototype.propertyIsEnumerable;var Ge=(t,o,e)=>o in t?De(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,d=(t,o)=>{for(var e in o||(o={}))Mo.call(o,e)&&Ge(t,e,o[e]);if(Oo)for(var e of Oo(o))ps.call(o,e)&&Ge(t,e,o[e]);return t},te=(t,o)=>is(t,rs(o));var us=(t,o)=>{for(var e in o)De(t,e,{get:o[e],enumerable:!0})},Uo=(t,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of cs(o))!Mo.call(t,l)&&l!==e&&De(t,l,{get:()=>o[l],enumerable:!(a=ls(o,l))||a.enumerable});return t};var gs=(t,o,e)=>(e=t!=null?as(ds(t)):{},Uo(o||!t||!t.__esModule?De(e,"default",{value:t,enumerable:!0}):e,t)),fs=t=>Uo(De({},"__esModule",{value:!0}),t);var ae=(t,o,e)=>Ge(t,typeof o!="symbol"?o+"":o,e);var Es={};us(Es,{CallControlPanel:()=>es,initSDK:()=>Ss,useClickToCall:()=>Fo,useEndCall:()=>zo,useLogout:()=>$o});module.exports=fs(Es);var Ye=class{constructor(){ae(this,"config",null);ae(this,"ticketId",null);ae(this,"baseUrl","");ae(this,"eventQueue",[]);ae(this,"isOnline",!0);ae(this,"retryQueue",[]);ae(this,"flushTimer",null)}async init(o){this.config=d({autoTrack:!0,retryAttempts:3,queueSize:100,flushInterval:5e3},o),this.baseUrl=o.baseUrl||(typeof window!="undefined"?window.location.origin:""),this.setupNetworkDetection();let e=await this.createTicket();return this.startPeriodicFlush(),console.log("EventTracker SDK initialized successfully"),e}isInitialized(){return this.config!==null&&this.ticketId!==null}getConfig(){return this.config}getTicketId(){return this.ticketId}async createTicket(){if(!this.config)throw new Error("EventTracker not initialized");try{let o=await this.makeRequest("/api/v1/et/init",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({agentId:this.config.agentId,sessionId:this.config.sessionId})});if(!o.ok)throw new Error(`Failed to initialize: ${o.status} ${o.statusText}`);let e=await o.json();return this.ticketId=e.ticketId,this.config.autoTrack&&this.setupAutoTracking(),this.ticketId}catch(o){throw console.error("EventTracker initialization failed:",o),o}}async logEvent(o,e){if(!this.config||!this.ticketId){console.warn("EventTracker not initialized, skipping event:",o);return}let a={eventType:o,eventData:e,timestamp:Date.now()};if(this.eventQueue.push(a),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift(),this.isOnline)try{await this.sendEvent(a)}catch(l){console.warn("Failed to send event, will retry later:",l)}}async sendEvent(o){if(!(!this.config||!this.ticketId))try{let e=await this.makeRequest("/api/v1/et/event",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({ticketId:this.ticketId,eventType:o.eventType,eventData:o.eventData})});if(!e.ok)throw new Error(`Failed to log event: ${e.status} ${e.statusText}`);let a=this.eventQueue.findIndex(l=>l.timestamp===o.timestamp);a>-1&&this.eventQueue.splice(a,1)}catch(e){console.error("Event logging failed:",e),this.retryQueue.push(()=>this.sendEvent(o))}}async closeTicket(){if(!this.config||!this.ticketId)throw new Error("EventTracker not initialized");await this.flush();try{let o=await this.makeRequest("/api/v1/et/close",{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.config.apiKey},body:JSON.stringify({ticketId:this.ticketId})});if(!o.ok)throw new Error(`Failed to close ticket: ${o.status} ${o.statusText}`);this.ticketId=null,this.stopPeriodicFlush(),console.log("Ticket closed successfully")}catch(o){throw console.error("Ticket close failed:",o),o}}async flush(){if(!this.isOnline||this.eventQueue.length===0)return;let o=[...this.eventQueue];for(let a of o)await this.sendEvent(a);let e=[...this.retryQueue];this.retryQueue=[];for(let a of e)try{await a()}catch(l){console.error("Retry failed:",l)}}async makeRequest(o,e){var p;let a=`${this.baseUrl}${o}`,l=((p=this.config)==null?void 0:p.retryAttempts)||3;for(let g=1;g<=l;g++)try{return await fetch(a,e)}catch(x){if(g===l)throw x;let v=Math.min(1e3*Math.pow(2,g-1),1e4);await new Promise(f=>setTimeout(f,v))}throw new Error("Max retries exceeded")}setupAutoTracking(){var a;if(typeof window=="undefined"||!((a=this.config)!=null&&a.autoTrack))return;let o=this.config.autoTrack===!0?{}:this.config.autoTrack;if(o.pageVisits!==!1&&this.logEvent("pageVisit",{url:window.location.href,title:document.title,referrer:document.referrer,userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},timestamp:new Date().toISOString()}).catch(l=>console.warn("Failed to track page visit:",l)),o.clicks!==!1&&document.addEventListener("click",l=>{var g;let p=l.target;(p.tagName==="BUTTON"||p.tagName==="A"||p.onclick||p.getAttribute("role")==="button"||p instanceof HTMLButtonElement&&p.type==="button")&&this.logEvent("click",{element:p.tagName,text:(g=p.textContent)==null?void 0:g.trim().substring(0,100),href:p.getAttribute("href"),id:p.id,className:p.className,role:p.getAttribute("role"),position:{x:l.clientX,y:l.clientY},timestamp:new Date().toISOString()}).catch(x=>console.warn("Failed to track click:",x))}),o.forms!==!1&&document.addEventListener("submit",l=>{let p=l.target,g=new FormData(p),x={};g.forEach((v,f)=>{x[f]=v.toString()}),this.logEvent("formSubmission",{formId:p.id,action:p.action,method:p.method,fields:Object.keys(x),fieldCount:Object.keys(x).length,timestamp:new Date().toISOString()}).catch(v=>console.warn("Failed to track form submission:",v))}),o.inputs!==!1){let l;document.addEventListener("input",p=>{let g=p.target;(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.tagName==="SELECT")&&(clearTimeout(l),l=setTimeout(()=>{var x;this.logEvent("fieldChange",{element:g.tagName,type:g.getAttribute("type"),name:g.getAttribute("name"),id:g.id,valueLength:((x=g.value)==null?void 0:x.length)||0,timestamp:new Date().toISOString()}).catch(v=>console.warn("Failed to track field change:",v))},1e3))})}let e=Date.now();window.addEventListener("beforeunload",()=>{let l=Date.now()-e;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:l,timestamp:new Date().toISOString()}),this.ticketId&&navigator.sendBeacon(`${this.baseUrl}/api/v1/et/close`,JSON.stringify({ticketId:this.ticketId}))}),o.visibility!==!1&&document.addEventListener("visibilitychange",()=>{this.logEvent("visibilityChange",{hidden:document.hidden,visibilityState:document.visibilityState,timestamp:new Date().toISOString()})}),o.errors!==!1&&(window.addEventListener("error",l=>{this.logEvent("jsError",{message:l.message,filename:l.filename,lineno:l.lineno,colno:l.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",l=>{var p;this.logEvent("unhandledRejection",{reason:(p=l.reason)==null?void 0:p.toString(),timestamp:new Date().toISOString()})})),o.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let l=window.performance.navigation,p=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:p.navigationStart,loadTime:p.loadEventEnd-p.navigationStart,domReady:p.domContentLoadedEventEnd-p.navigationStart,renderTime:p.loadEventEnd-p.domContentLoadedEventEnd,navigationType:l.type,redirectCount:l.redirectCount,timestamp:new Date().toISOString()})},1e3)})}setupNetworkDetection(){typeof window!="undefined"&&(this.isOnline=navigator.onLine,window.addEventListener("online",()=>{this.isOnline=!0,console.log("EventTracker: Back online, flushing queued events"),this.flush()}),window.addEventListener("offline",()=>{this.isOnline=!1,console.log("EventTracker: Offline, queueing events")}))}startPeriodicFlush(){var e;this.flushTimer&&clearInterval(this.flushTimer);let o=((e=this.config)==null?void 0:e.flushInterval)||5e3;this.flushTimer=setInterval(()=>{this.flush()},o)}stopPeriodicFlush(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}},je=new Ye;typeof window!="undefined"&&(window.EventTracker=je);var Xe=class{constructor(){ae(this,"state");ae(this,"listeners",[]);ae(this,"STORAGE_KEY","call-control-sdk-state");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{apiKey:null,process:null,agentId:"",isInitialized:!1,sdkConfig:{showEndCallButton:!0,showTransferButton:!0,enableFloatingDrag:!0,enableSoftPhone:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},isHolding:!1,isMuted:!1,status:"idle",callStartTime:null,controlPanelPosition:{x:10,y:10},iframePosition:{x:10,y:80},callData:{agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:[{line:1,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:2,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:3,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:4,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:5,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1}]}}loadFromStorage(){try{let o=localStorage.getItem(this.STORAGE_KEY);if(o){let e=JSON.parse(o);this.state=te(d({},this.state),{apiKey:e.apiKey||"",agentId:e.agentId||"",process:e.process||null,isInitialized:e.isInitialized||!1,sdkConfig:e.sdkConfig||{showEndCallButton:!0,showTransferButton:!0,enableFloatingDrag:!0,enableSoftPhone:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},isHolding:e.isHolding||!1,isMuted:e.isMuted||!1,status:e.status||"idle",callStartTime:e.callStartTime||null,controlPanelPosition:e.controlPanelPosition||{x:10,y:10},iframePosition:e.iframePosition||{x:10,y:80},callData:e.callData||{mobileNumber:"",callReferenceId:"",agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:e.conferenceLine&&Array.isArray(e.conferenceLine)&&e.conferenceLine.length>0?e.conferenceLine:this.state.conferenceLine})}}catch(o){console.warn("Failed to load SDK state from localStorage:",o)}}saveToStorage(){try{let o={apiKey:this.state.apiKey,agentId:this.state.agentId,process:this.state.process,isInitialized:this.state.isInitialized,sdkConfig:this.state.sdkConfig,isHolding:this.state.isHolding,isMuted:this.state.isMuted,status:this.state.status,callStartTime:this.state.callStartTime,controlPanelPosition:this.state.controlPanelPosition,iframePosition:this.state.iframePosition,callData:this.state.callData,conferenceLine:this.state.conferenceLine};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(o))}catch(o){console.warn("Failed to save SDK state to localStorage:",o)}}notifyListeners(){this.listeners.forEach(o=>o())}initialize(o,e,a){if(!o||typeof o!="string"||o.trim().length===0)throw new Error("API key not available");this.state.apiKey=o,this.state.agentId=e,this.state.sdkConfig=d({showEndCallButton:!0,showTransferButton:!0,enableFloatingDrag:!0,enableSoftPhone:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},a),this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return d({},this.state)}subscribe(o){return this.listeners.push(o),()=>{let e=this.listeners.indexOf(o);e>-1&&this.listeners.splice(e,1)}}setHolding(o){this.state.isHolding=o,this.saveToStorage(),this.notifyListeners()}setMuted(o){this.state.isMuted=o,this.saveToStorage(),this.notifyListeners()}setStatus(o){this.state.status=o,this.saveToStorage(),this.notifyListeners()}setProcess(o){this.state.process=o,this.saveToStorage(),this.notifyListeners()}setControlPanelPosition(o){this.state.controlPanelPosition=o,this.saveToStorage(),this.notifyListeners()}setIframePosition(o){this.state.iframePosition=o,this.saveToStorage(),this.notifyListeners()}startCall(){this.state.callStartTime=Date.now(),this.state.status="on call",this.saveToStorage(),this.notifyListeners()}endCall(){this.state.callStartTime=null,this.state.status="idle",this.state.isHolding=!1,this.state.isMuted=!1,this.saveToStorage(),this.notifyListeners()}setInitCheck(){this.state.isInitialized=!1,this.saveToStorage(),this.notifyListeners()}updateCallData(o){this.state.callData=d(d({},this.state.callData),o),this.saveToStorage(),this.notifyListeners()}setConferenceLine(o){var a;(!this.state.conferenceLine||!Array.isArray(this.state.conferenceLine))&&(console.warn("Conference line data corrupted, resetting to initial state"),this.state.conferenceLine=this.getInitialState().conferenceLine);let e=(a=this.state.conferenceLine)==null?void 0:a.map(l=>l.line===o.line?o:l);this.state.conferenceLine=e,this.saveToStorage(),this.notifyListeners()}resetConferenceLines(){this.state.conferenceLine=this.getInitialState().conferenceLine,this.saveToStorage(),this.notifyListeners()}clearStorageAndReset(){try{localStorage.removeItem(this.STORAGE_KEY),this.state=this.getInitialState(),this.notifyListeners()}catch(o){console.warn("Failed to clear localStorage:",o)}}debugStorage(){try{let o=localStorage.getItem(this.STORAGE_KEY);console.log("Current localStorage data:",o),o&&console.log("Parsed localStorage data:",JSON.parse(o)),console.log("Current state:",this.state)}catch(o){console.error("Error debugging storage:",o)}}getConferenceLines(){return this.state.conferenceLine||[]}},E=new Xe;var fe=require("react");var ze="10.10.102.42",$=`http://${ze}:8095`,ms=`ws://${ze}:8095`,W={v1:"/api/v1"},R={LOGIN:`${$}${W.v1}/cti/login?provider=convox`,READY_AGENT:`${$}${W.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${$}${W.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${$}${W.v1}/cti/calls?provider=convox`,HOLD_CALL:`${$}${W.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${$}${W.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${$}${W.v1}/cti/unmute-call?provider=convox`,END_CALL:`${$}${W.v1}/cti/calls/end?provider=convox`,LOGOUT:`${$}${W.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${$}${W.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${$}${W.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${$}${W.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${$}${W.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${$}${W.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${$}${W.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${$}${W.v1}/cti/users`,PROCESS_LIST:`${$}${W.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${$}${W.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${$}${W.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${$}${W.v1}/users/get_sentiment_analysis`},Bo={WS:`${ms}${W.v1}/cti/ws`};var Ho=gs(require("axios"));var xs="12345",Je=Ho.default.create({baseURL:$,headers:{"Content-Type":"application/json",Authorization:xs},timeout:6e4});Je.interceptors.request.use(t=>{let o="12345";return o&&t.headers&&(t.headers.Authorization=`Bearer ${o}`),t},t=>Promise.reject(t instanceof Error?t:new Error(String(t))));Je.interceptors.response.use(t=>t,async t=>{var e;let o=t.config;return((e=t.response)==null?void 0:e.status)===401&&!o._retry&&(o._retry=!0),Promise.reject(t instanceof Error?t:new Error(String(t)))});var oe=Je;var Cs=()=>{let[t,o]=(0,fe.useState)(!1),[e,a]=(0,fe.useState)(!1),[l,p]=(0,fe.useState)(!1),[g,x]=(0,fe.useState)(null),[v,f]=(0,fe.useState)(null);return{logout:(0,fe.useCallback)(async()=>{var b;let m=JSON.parse((b=localStorage.getItem("call-control-sdk-state"))!=null?b:"");o(!0);let c={action:"LOGOUTUSER",userId:m.agentId||""};return oe.post(R.LOGOUT,c).then(h=>(E.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),f(h==null?void 0:h.data),a(!0),h==null?void 0:h.data)).catch(h=>{var T;return p(!0),x(h),(T=h==null?void 0:h.response)==null?void 0:T.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:l,error:g,data:v}},$o=Cs;var me=require("react");var zo=()=>{let[t,o]=(0,me.useState)(!1),[e,a]=(0,me.useState)(!1),[l,p]=(0,me.useState)(!1),[g,x]=(0,me.useState)(null),[v,f]=(0,me.useState)(null);return{handleEndCall:(0,me.useCallback)(async m=>{var h,T,U,M,P,k,B,j,H,A,C,F,se,ne,_;let c=JSON.parse((h=localStorage.getItem("call-control-sdk-state"))!=null?h:"");o(!0);let b={action:"ENDCALL",userId:c==null?void 0:c.agentId,processid:(M=(U=(T=c==null?void 0:c.process)==null?void 0:T.process_id)==null?void 0:U.toString())!=null?M:"",process_name:(k=(P=c==null?void 0:c.process)==null?void 0:P.process_name)!=null?k:"",callreferenceid:(j=(B=c==null?void 0:c.callData)==null?void 0:B.convox_id)!=null?j:"",mobile_number:(A=(H=c==null?void 0:c.callData)==null?void 0:H.phone_number)!=null?A:"",disposition:(C=m==null?void 0:m.disposition)!=null?C:"RES",set_followUp:(F=m==null?void 0:m.followUp)!=null?F:"N",callback_date:(se=m==null?void 0:m.callbackDate)!=null?se:"",callback_hrs:(ne=m==null?void 0:m.callbackHrs)!=null?ne:"",callback_mins:(_=m==null?void 0:m.callbackMins)!=null?_:"",endcall_type:"CLOSE"};return oe.post(R.END_CALL,b).then(S=>(E.endCall(),f(S==null?void 0:S.data),a(!0),S==null?void 0:S.data)).catch(S=>{var O;return p(!0),x(S),(O=S==null?void 0:S.response)==null?void 0:O.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:l,error:g,data:v}};var xe=require("react");var Fo=()=>{let[t,o]=(0,xe.useState)(!1),[e,a]=(0,xe.useState)(!1),[l,p]=(0,xe.useState)(!1),[g,x]=(0,xe.useState)(null),[v,f]=(0,xe.useState)(null);return{handleStartCall:(0,xe.useCallback)(async m=>{var b,h,T,U,M,P,k,B,j;let c=JSON.parse((b=localStorage.getItem("call-control-sdk-state"))!=null?b:"");if(o(!0),((h=c==null?void 0:c.callData)==null?void 0:h.status)==="IDLE"){let H={action:"CALL",userId:c==null?void 0:c.agentId,phone_number:m==null?void 0:m.mobileNumber};return oe.post(R.CLICK_TO_CALL,H).then(A=>(f(A==null?void 0:A.data),a(!0),A==null?void 0:A.data)).catch(A=>{var C;return p(!0),x(A),(C=A==null?void 0:A.response)==null?void 0:C.data}).finally(()=>{o(!1)})}else if(((T=c==null?void 0:c.callData)==null?void 0:T.status)==="ONCALL"){let H=(M=(U=c==null?void 0:c.conferenceLine)==null?void 0:U.filter(C=>C.line!==1))==null?void 0:M.find(C=>C.status==="IDLE"&&!(C!=null&&C.isCallStart)),A={action:"EXTERNAL_CONFERENCE",operation:`CALL${H.line}`,line_used:String(H.line),thirdparty_no:m==null?void 0:m.mobileNumber,userid:(k=(P=c.callData)==null?void 0:P.agent_id)!=null?k:"",process:(j=(B=c.callData)==null?void 0:B.process_name)!=null?j:""};return oe.post(R.CONFERENCE_CALL,A).then(C=>(f(C==null?void 0:C.data),a(!0),E.setConferenceLine(te(d({},H),{isCallStart:!0,status:"ONCALL",phone:m==null?void 0:m.mobileNumber})),C==null?void 0:C.data)).catch(C=>{var F;return p(!0),x(C),(F=C==null?void 0:C.response)==null?void 0:F.data}).finally(()=>{o(!1)})}else alert("Agent is not ready")},[]),isLoading:t,isSuccess:e,isError:l,error:g,data:v}};var D=require("@mui/icons-material"),u=require("@mui/material"),K=require("react");var ie=require("react");function Ve(t,o){let[e,a]=(0,ie.useState)(t),[l,p]=(0,ie.useState)(!1),g=(0,ie.useRef)(),x=(0,ie.useRef)({x:0,y:0}),v=(0,ie.useRef)({x:0,y:0}),f=(0,ie.useCallback)(b=>{let h=g.current;if(!h)return;let T=h.getBoundingClientRect(),U=window.innerWidth,M=window.innerHeight,P={x:Math.max(0,Math.min(b.x,U-T.width)),y:Math.max(0,Math.min(b.y,M-T.height))};a(P),o==null||o(P)},[o]),y=(0,ie.useCallback)((b,h)=>{p(!0),x.current={x:b,y:h},v.current=e;let T=(k,B)=>{let j=k-x.current.x,H=B-x.current.y;f({x:v.current.x+j,y:v.current.y+H})},U=k=>{k.preventDefault(),T(k.clientX,k.clientY)},M=k=>{k.preventDefault();let B=k.touches[0];B&&T(B.clientX,B.clientY)},P=()=>{p(!1),document.removeEventListener("mousemove",U),document.removeEventListener("mouseup",P),document.removeEventListener("touchmove",M),document.removeEventListener("touchend",P)};document.addEventListener("mousemove",U),document.addEventListener("mouseup",P),document.addEventListener("touchmove",M,{passive:!1}),document.addEventListener("touchend",P)},[e,f]),m=(0,ie.useCallback)(b=>{b.preventDefault(),y(b.clientX,b.clientY)},[y]),c=(0,ie.useCallback)(b=>{b.preventDefault();let h=b.touches[0];h&&y(h.clientX,h.clientY)},[y]);return{position:e,isDragging:l,dragRef:g,handleMouseDown:m,handleTouchStart:c}}var Fe=require("react");function ye(){let[t,o]=(0,Fe.useState)(E.getState());return(0,Fe.useEffect)(()=>E.subscribe(()=>{o(E.getState())}),[]),t}var We=require("react");var Ce=require("react"),qe=require("@mui/material"),Ie=require("react/jsx-runtime"),qo=(0,Ce.createContext)(void 0),_e=()=>{let t=(0,Ce.useContext)(qo);if(!t)throw new Error("useToast must be used inside ToastProvider");return t},Wo=({children:t})=>{let[o,e]=(0,Ce.useState)(!1),[a,l]=(0,Ce.useState)(""),[p,g]=(0,Ce.useState)("info"),x=(v,f="info")=>{l(v),g(f),e(!0)};return(0,Ie.jsxs)(qo.Provider,{value:{showToast:x},children:[t,(0,Ie.jsx)(qe.Snackbar,{open:o,color:p,autoHideDuration:3e3,onClose:()=>e(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,Ie.jsx)(qe.Alert,{variant:"filled",severity:p,onClose:()=>e(!1),sx:{width:"100%"},children:a})})]})};var hs={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},ys=(t,o)=>{if(o.type==="isLoading")return te(d({},t),{isLoading:o.payload});if(o.type==="isSuccess")return te(d({},t),{isSuccess:!0,data:o.payload});if(o.type==="isError")return te(d({},t),{isError:!0,error:o.payload});if(o.type==="reset")return{isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null};throw Error("Unknown action.")};var le=(t={})=>{let{onSuccess:o=null,onError:e=null}=t,{showToast:a}=_e(),[l,p]=(0,We.useReducer)(ys,hs);return[(0,We.useCallback)((x,v,f={})=>{p({type:"isLoading",payload:!0}),oe.post(x,v,f).then(y=>{var m,c;p({type:"isSuccess",payload:y.data}),o==null||o(y.data,v),console.log((m=y.data)==null?void 0:m.message,"res45"),a((c=y.data)==null?void 0:c.message,"success")}).catch(y=>{var c,b,h,T,U,M,P,k,B,j,H,A;let m={status:(b=(c=y.response)==null?void 0:c.status)!=null?b:500,message:((T=(h=y.response)==null?void 0:h.data)==null?void 0:T.detail)||((M=(U=y.response)==null?void 0:U.data)==null?void 0:M.message)||y.message||"An unknown error occurred",data:(k=(P=y.response)==null?void 0:P.data)!=null?k:null,statusText:(j=(B=y.response)==null?void 0:B.statusText)!=null?j:"",code:(H=y==null?void 0:y.code)!=null?H:"",name:(A=y==null?void 0:y.name)!=null?A:""};a(m.message,"error"),p({type:"isError",payload:m}),e==null||e(m,v)}).finally(()=>{p({type:"isLoading",payload:!1})})},[o,e,a]),l]};var w=require("@mui/icons-material"),n=require("@mui/material"),re=require("react");var Ko=require("@mui/material");var bs=({disabled:t,enabled:o,outlined:e})=>{let a=(0,Ko.useTheme)();return{disabled:d({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",border:"1px solid rgb(206, 204, 204)",height:"40px","&:hover":{boxShadow:" 0px 2px 2px rgba(0, 0, 0, 0.79)",border:`1px solid ${a.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${a.palette.primary.light}`}},t),enabled:d({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${a.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${a.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${a.palette.primary.light}`}},o),outlined:d({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:a.palette.grey[200],boxShadow:`0px 2px 1px ${a.palette.primary.light}`,border:`0px solid ${a.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${a.palette.primary.main}`,border:`0px solid ${a.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${a.palette.primary.light}`}},e)}},Ke=bs;var s=require("react/jsx-runtime"),vs=({each:t})=>{var A,C,F,se,ne;let o=ye(),{showToast:e}=_e(),{disabled:a,enabled:l,outlined:p}=Ke({disabled:((A=o.sdkConfig)==null?void 0:A.disabled)||{},enabled:((C=o.sdkConfig)==null?void 0:C.enabled)||{},outlined:((F=o.sdkConfig)==null?void 0:F.outlined)||{}}),g=(0,n.useTheme)(),[x,v]=(0,re.useState)(!1),[f,y]=(0,re.useState)(!1),[m,c]=(0,re.useState)(!1),[b,h]=(0,re.useState)(!1),[T,U]=(0,re.useState)(!1),M=(_,S)=>{E.setConferenceLine(d(d({},_),S))},P=(_,S)=>{var q,X,Y,J;let O=d(d({},_),S);v(!0);let G={action:"EXTERNAL_CONFERENCE",operation:`CALL${O.line}`,line_used:String(O.line),thirdparty_no:O.phone,userid:(X=(q=o.callData)==null?void 0:q.agent_id)!=null?X:"",process:(J=(Y=o.callData)==null?void 0:Y.process_name)!=null?J:""};oe.post(R.CONFERENCE_CALL,G).then(N=>{var I;e((I=N.data)==null?void 0:I.message,"success"),E.setConferenceLine(d(d({},_),S))}).catch(N=>{var z,V,Q,Z;let I=((V=(z=N.response)==null?void 0:z.data)==null?void 0:V.detail)||((Z=(Q=N.response)==null?void 0:Q.data)==null?void 0:Z.message)||N.message||"An unknown error occurred";e(I,"error")}).finally(()=>{v(!1)})},k=(_,S)=>{var q,X,Y,J;let O=d(d({},_),S);y(!0);let G={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(O.line),thirdparty_no:O.phone,userid:(X=(q=o.callData)==null?void 0:q.agent_id)!=null?X:"",process:(J=(Y=o.callData)==null?void 0:Y.process_name)!=null?J:""};oe.post(R.CONFERENCE_CALL,G).then(N=>{var I;e((I=N.data)==null?void 0:I.message,"success"),E.setConferenceLine(d(d({},_),S))}).catch(N=>{var z,V,Q,Z;let I=((V=(z=N.response)==null?void 0:z.data)==null?void 0:V.detail)||((Z=(Q=N.response)==null?void 0:Q.data)==null?void 0:Z.message)||N.message||"An unknown error occurred";e(I,"error")}).finally(()=>{y(!1)})},B=(_,S,O)=>{var X,Y,J,N;let G=d(d({},_),S);c(!0);let q={action:"EXTERNAL_CONFERENCE",operation:O,hold_channel_no:O==="HOLDUSER"?`hold${G.line}`:`unhold${G.line}`,userid:(Y=(X=o.callData)==null?void 0:X.agent_id)!=null?Y:"",process:(N=(J=o.callData)==null?void 0:J.process_name)!=null?N:""};oe.post(R.CONFERENCE_CALL_HOLD_OR_UN_HOLD,q).then(I=>{var z;e((z=I.data)==null?void 0:z.message,"success"),E.setConferenceLine(d(d({},_),S))}).catch(I=>{var V,Q,Z,pe;let z=((Q=(V=I.response)==null?void 0:V.data)==null?void 0:Q.detail)||((pe=(Z=I.response)==null?void 0:Z.data)==null?void 0:pe.message)||I.message||"An unknown error occurred";e(z,"error")}).finally(()=>{c(!1)})},j=(_,S,O)=>{var X,Y,J,N;let G=d(d({},_),S);h(!0);let q={action:"EXTERNAL_CONFERENCE",operation:O,channel_no:O==="MUTEUSER"?`mute${G.line}`:`play${G.line}`,userid:(Y=(X=o.callData)==null?void 0:X.agent_id)!=null?Y:"",thirdparty_no:G.phone,process:(N=(J=o.callData)==null?void 0:J.process_name)!=null?N:""};oe.post(R.CONFERENCE_CALL_MUTE_OT_UN_MUTE,q).then(I=>{var z;e((z=I.data)==null?void 0:z.message,"success"),E.setConferenceLine(d(d({},_),S))}).catch(I=>{var V,Q,Z,pe;let z=((Q=(V=I.response)==null?void 0:V.data)==null?void 0:Q.detail)||((pe=(Z=I.response)==null?void 0:Z.data)==null?void 0:pe.message)||I.message||"An unknown error occurred";e(z,"error")}).finally(()=>{h(!1)})},H=(_,S)=>{var q,X,Y,J;let O=d(d({},_),S);U(!0);let G={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(O.line-1),user_type:`THIRDPARTY${O.line-1}`,thirdparty_no:O.phone,userid:(X=(q=o.callData)==null?void 0:q.agent_id)!=null?X:"",process:(J=(Y=o.callData)==null?void 0:Y.process_name)!=null?J:""};oe.post(R.CONFERENCE_CALL_END,G).then(N=>{var I;e((I=N.data)==null?void 0:I.message,"success"),E.setConferenceLine(d(d({},_),S))}).catch(N=>{var z,V,Q,Z;let I=((V=(z=N.response)==null?void 0:z.data)==null?void 0:V.detail)||((Z=(Q=N.response)==null?void 0:Q.data)==null?void 0:Z.message)||N.message||"An unknown error occurred";e(I,"error")}).finally(()=>{U(!1)})};return(0,s.jsxs)(n.TableRow,{sx:{border:"2px solid #fff"},children:[(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsxs)(n.Typography,{children:["Line ",(se=t==null?void 0:t.line)!=null?se:"",". "]})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsx)(n.Typography,{variant:"body2",sx:{px:1,borderRadius:"10px",width:"80px",maxWidth:"100px"},children:(ne=t==null?void 0:t.status)!=null?ne:""})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsx)(n.Button,{sx:{textTransform:"capitalize"},size:"small",children:(0,s.jsx)(n.Typography,{variant:"body2",children:(t==null?void 0:t.line)===1?"Internal":"External"})})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsx)(n.TextField,{size:"small",placeholder:"Phone Number",value:(t==null?void 0:t.phone)||"",disabled:(t==null?void 0:t.line)===1,onChange:_=>{M(t,{phone:_.target.value})}})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsxs)(n.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-around"},children:[(0,s.jsx)(n.Tooltip,{title:"Call",children:(0,s.jsx)(n.Button,{variant:t!=null&&t.isCallStart?"outlined":"contained",color:"success",sx:t!=null&&t.isCallStart?d({},a):te(d({},l),{border:`0px solid ${g.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${g.palette.success.light}`,border:`0px solid ${g.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${g.palette.primary.light}`}}),onClick:()=>{P(t,{isCallStart:!0,status:"ONCALL"})},disabled:(t==null?void 0:t.isCallStart)||x,children:x?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"success"}):(0,s.jsx)(w.Call,{sx:{color:t!=null&&t.isCallStart?"default":"#e7e7e7ff"}})})}),(0,s.jsx)(n.Tooltip,{title:"Merge Call",children:(0,s.jsx)(n.Button,{variant:t!=null&&t.isMergeCall?"contained":"outlined",sx:t!=null&&t.isMergeCall&&(t!=null&&t.isCallStart)?d({},a):t!=null&&t.isCallStart?d({},p):d({},a),onClick:()=>{k(t,{isMergeCall:!0,status:"ONCALL"})},disabled:!(t!=null&&t.isCallStart)||f,children:f?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:t!=null&&t.isMergeCall?"#e7e7e7ff":g.palette.primary.main}}):(0,s.jsx)(w.CallSplit,{})})}),(0,s.jsx)(n.Tooltip,{title:t.isHold?"Hold":"Un Hold",children:(0,s.jsx)(n.Button,{variant:t!=null&&t.isHold?"contained":"outlined",sx:t!=null&&t.isHold&&(t!=null&&t.isCallStart)?d({},a):t!=null&&t.isCallStart?d({},p):d({},a),onClick:()=>{t.isHold?B(t,{isHold:!1},"UNHOLDUSER"):B(t,{isHold:!0},"HOLDUSER")},disabled:!(t!=null&&t.isCallStart)||m,children:m?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:g.palette.primary.main}}):t.isHold?(0,s.jsx)(w.PlayArrow,{}):(0,s.jsx)(w.Pause,{})})}),(0,s.jsx)(n.Tooltip,{title:t.isMute?"Mute":"Un Mute",children:(0,s.jsx)(n.Button,{variant:t!=null&&t.isMute?"contained":"outlined",sx:t!=null&&t.isMute&&(t!=null&&t.isCallStart)?d({},a):t!=null&&t.isCallStart?d({},p):d({},a),onClick:()=>{t.isMute?j(t,{isMute:!1},"PLAYUSER"):j(t,{isMute:!0},"MUTEUSER")},disabled:!(t!=null&&t.isCallStart)||b,children:b?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:g.palette.primary.main}}):t.isMute?(0,s.jsx)(w.MicOff,{}):(0,s.jsx)(w.Mic,{})})}),(0,s.jsx)(n.Tooltip,{title:"End Call",children:(t==null?void 0:t.line)!==1?(0,s.jsx)(n.Button,{variant:t!=null&&t.isCallStart?"contained":"outlined",color:"error",sx:t!=null&&t.isCallStart?te(d({},l),{minWidth:"60px !important",border:`0px solid ${g.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${g.palette.error.light}`,border:`0px solid ${g.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${g.palette.primary.light}`}}):te(d({},a),{minWidth:"60px !important"}),onClick:()=>{H(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(t!=null&&t.isCallStart)||T,children:T?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"error"}):(0,s.jsx)(w.CallEnd,{})}):(0,s.jsx)(n.Button,{variant:t!=null&&t.isCallStart?"contained":"outlined",sx:te(d({},a),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{H(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(t!=null&&t.isCallStart),children:(0,s.jsx)(n.Typography,{children:(0,s.jsx)(w.CallEnd,{sx:{visibility:"hidden"}})})})})]})})]},t.line)};function Go({open:t,setOpen:o}){var v;let e=ye(),{showToast:a}=_e(),[l,p]=(0,re.useState)(!1),g=()=>{o(!1)},x=()=>{var y,m,c,b;p(!0);let f={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(m=(y=e.callData)==null?void 0:y.agent_id)!=null?m:"",process:(b=(c=e.callData)==null?void 0:c.process_name)!=null?b:""};oe.post(R.CONFERENCE_CALL_END_ALL,f).then(h=>{var T;a((T=h.data)==null?void 0:T.message,"success"),E.resetConferenceLines(),g()}).catch(h=>{var U,M,P,k;let T=((M=(U=h.response)==null?void 0:U.data)==null?void 0:M.detail)||((k=(P=h.response)==null?void 0:P.data)==null?void 0:k.message)||h.message||"An unknown error occurred";a(T,"error")}).finally(()=>{p(!1)})};return(0,re.useEffect)(()=>{var y,m,c,b;let f={line:1,status:(m=(y=e.callData)==null?void 0:y.status)!=null?m:"",type:"internal",phone:(b=(c=e.callData)==null?void 0:c.phone_number)!=null?b:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};E.setConferenceLine(f)},[]),(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px"},children:[(0,s.jsxs)(n.Typography,{variant:"body1",children:[(v=e==null?void 0:e.agentId)!=null?v:""," conference"]}),(0,s.jsx)(n.IconButton,{onClick:g,children:(0,s.jsx)(w.Close,{})})]}),(0,s.jsx)(n.Box,{sx:{boxShadow:"1px 1px 2px #e7e5e5ff",margin:"0px 15px",borderRadius:"20px"},children:(0,s.jsx)(n.TableContainer,{component:n.Paper,sx:{outline:"0px solid gray !important",boxShadow:"1px 1px 6px #e7e5e5ff"},children:(0,s.jsxs)(n.Table,{sx:{border:"4px solid #ffffff !important"},children:[(0,s.jsx)(n.TableHead,{children:(0,s.jsxs)(n.TableRow,{sx:{border:"2px solid #f3f3f3ff !important"},children:[(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Line"}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Status"}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Call Type"}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Mobile Number"}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:"Call Actions"})]})}),(0,s.jsx)(n.TableBody,{children:e==null?void 0:e.conferenceLine.map(f=>(0,s.jsx)(vs,{each:f}))})]})})}),(0,s.jsx)(n.Box,{textAlign:"center",m:2,children:(0,s.jsxs)(n.Button,{variant:"outlined",color:"error",size:"large",onClick:x,disabled:l,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[l?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"error",sx:{marginRight:"8px"}}):(0,s.jsx)(n.IconButton,{sx:{bgcolor:"error.main","&:hover":{bgcolor:"error.dark"},marginRight:"8px",width:"28px",height:"28px",fontSize:"12px",fontWeight:"600",lineHeight:"16px",letterSpacing:"0.02em",textTransform:"capitalize",color:"white",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%"},children:(0,s.jsx)(w.PhoneDisabled,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function Yo({open:t,setOpen:o}){var c,b,h,T,U,M,P,k,B,j,H,A;let[e]=le({onSuccess:()=>{o(!1)},onError:C=>{console.log("error",C)}}),a=ye(),[l,p]=(0,re.useState)("process"),[g,{data:x}]=le(),[v,{data:f}]=le(),y=()=>{o(!1)},m=(C,F)=>{var se,ne,_,S,O,G,q,X,Y,J,N,I,z,V,Q,Z,pe,Re,be,we,ve,ke,Se,Ae,Ne,Pe,Ee,Oe,Me,Ue,Be,He,$e;if(console.log(C,"data34"),F==="PROCESS"){let he={mobile_number:(ne=(se=a.callData)==null?void 0:se.phone_number)!=null?ne:"",userid:(S=(_=a.callData)==null?void 0:_.agent_id)!=null?S:"",type:"PROCESS",transfer_to:(O=C==null?void 0:C.process_name)!=null?O:"",callreferenceid:(q=(G=a.callData)==null?void 0:G.convox_id)!=null?q:"",processid:String((Y=(X=a.callData)==null?void 0:X.process_id)!=null?Y:""),process_name:(N=(J=a.callData)==null?void 0:J.process_name)!=null?N:""};e(R.TRANSFER_CALL,he)}else if(F==="QUEUE"){let he={mobile_number:(z=(I=a.callData)==null?void 0:I.phone_number)!=null?z:"",userid:(Q=(V=a.callData)==null?void 0:V.agent_id)!=null?Q:"",type:"QUEUE",transfer_to:(Z=C==null?void 0:C.queue_name)!=null?Z:"",callreferenceid:(Re=(pe=a.callData)==null?void 0:pe.convox_id)!=null?Re:"",processid:String((we=(be=a.callData)==null?void 0:be.process_id)!=null?we:""),process_name:(ke=(ve=a.callData)==null?void 0:ve.process_name)!=null?ke:""};e(R.TRANSFER_CALL,he)}else if(F==="AGENT"){let he={mobile_number:(Ae=(Se=a.callData)==null?void 0:Se.phone_number)!=null?Ae:"",userid:(Pe=(Ne=a.callData)==null?void 0:Ne.agent_id)!=null?Pe:"",type:"AGENT",transfer_to:(Ee=C==null?void 0:C.user_id)!=null?Ee:"",callreferenceid:(Me=(Oe=a.callData)==null?void 0:Oe.convox_id)!=null?Me:"",processid:String((Be=(Ue=a.callData)==null?void 0:Ue.process_id)!=null?Be:""),process_name:($e=(He=a.callData)==null?void 0:He.process_name)!=null?$e:""};e(R.TRANSFER_CALL,he)}};return(0,re.useEffect)(()=>{g(R.AGENTS_LIST,{status:"IDLE",active:!0}),v(R.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),console.log(x,"idleAgentsList"),(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,s.jsx)(n.Typography,{variant:"body1",children:" Call Transfer"}),(0,s.jsx)(n.IconButton,{onClick:y,children:(0,s.jsx)(w.Close,{})})]}),(0,s.jsxs)(n.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",gap:1},children:[(0,s.jsx)(n.Button,{variant:l==="process"?"contained":"outlined",onClick:()=>{p("process"),v(R.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},children:"Process"}),(0,s.jsx)(n.Button,{variant:l==="queues"?"contained":"outlined",onClick:()=>{p("queues"),v(R.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},children:"Queues"}),(0,s.jsx)(n.Button,{variant:l==="agents"?"contained":"outlined",onClick:()=>{p("agents"),g(R.AGENTS_LIST,{status:"IDLE",active:!0})},children:"Agents"})]}),l==="process"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(c=f==null?void 0:f.data)!=null&&c.process&&((h=(b=f==null?void 0:f.data)==null?void 0:b.process)==null?void 0:h.length)>0?(U=(T=f==null?void 0:f.data)==null?void 0:T.process)==null?void 0:U.map((C,F)=>(0,s.jsxs)(n.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,s.jsxs)(n.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,s.jsx)(w.SupportAgent,{sx:{marginRight:"4px"}}),C.process_name]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{m(C,"PROCESS")},children:(0,s.jsx)(w.Call,{})})]},F)):(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Process Found"})}),l==="queues"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(M=f==null?void 0:f.data)!=null&&M.queue&&((k=(P=f==null?void 0:f.data)==null?void 0:P.queue)==null?void 0:k.length)>0?(j=(B=f==null?void 0:f.data)==null?void 0:B.queue)==null?void 0:j.map((C,F)=>{var se,ne,_,S,O,G;return(0,s.jsxs)(n.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,s.jsxs)(n.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,s.jsx)(w.SupportAgent,{sx:{marginRight:"4px"}}),C.queue_name,(_=(ne=(se=f==null?void 0:f.data)==null?void 0:se.process)==null?void 0:ne.find(q=>q.process_id===C.process_id))!=null&&_.process_name?(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((G=(O=(S=f==null?void 0:f.data)==null?void 0:S.process)==null?void 0:O.find(q=>q.process_id===C.process_id))==null?void 0:G.process_name)+")"}):""]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{m(C,"QUEUE")},children:(0,s.jsx)(w.Call,{})})]},F)}):(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Queues Found"})}),l==="agents"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:x!=null&&x.data&&((H=x==null?void 0:x.data)==null?void 0:H.length)>0?(A=x==null?void 0:x.data)==null?void 0:A.map((C,F)=>(0,s.jsxs)(n.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[(0,s.jsxs)(n.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,s.jsx)(w.SupportAgent,{sx:{marginRight:"4px"}}),C.name]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{m(C,"AGENT")},children:(0,s.jsx)(w.Call,{})})]},F)):(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",textAlign:"center",width:"100%",margin:"10px 0px",color:"gray"},children:"No Agents Found"})})]})]})})})}function jo({open:t,setOpen:o,onSubmitDisposition:e}){var y,m;let[a,l]=(0,re.useState)({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),p=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],g=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],x=(c,b)=>{l(h=>te(d({},h),{[c]:b}))},v=()=>{l({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},f=()=>{v(),o(!1)};return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsx)(n.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:(0,s.jsxs)(n.Typography,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),(0,s.jsxs)(n.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:[(0,s.jsxs)(n.Box,{display:"flex",gap:2,children:[(0,s.jsx)(n.Autocomplete,{value:a.disposition,options:p,getOptionLabel:c=>c.label,onChange:(c,b)=>x("disposition",b),size:"small",renderInput:c=>(0,s.jsx)(n.TextField,te(d({},c),{label:"Disposition",fullWidth:!0})),sx:{flex:1}}),(0,s.jsx)(n.Autocomplete,{options:g,getOptionLabel:c=>c.label,value:a.followUp,onChange:(c,b)=>x("followUp",b),size:"small",renderInput:c=>(0,s.jsx)(n.TextField,te(d({},c),{label:"Follow Up",fullWidth:!0})),sx:{flex:1}})]}),((m=(y=a==null?void 0:a.followUp)==null?void 0:y.label)==null?void 0:m.toLowerCase())==="yes"&&(0,s.jsxs)(n.Box,{display:"flex",gap:2,mt:2,children:[(0,s.jsx)(n.TextField,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:a.callbackDate,onChange:c=>x("callbackDate",c.target.value),fullWidth:!0,sx:{flex:1}}),(0,s.jsx)(n.TextField,{size:"small",label:"Hours (0-23)",type:"number",inputProps:{min:0,max:23},value:a.callbackHrs,onChange:c=>x("callbackHrs",c.target.value),fullWidth:!0,sx:{flex:1}}),(0,s.jsx)(n.TextField,{size:"small",label:"Minutes (0-59)",type:"number",inputProps:{min:0,max:59},value:a.callbackMins,onChange:c=>x("callbackMins",c.target.value),fullWidth:!0,sx:{flex:1}})]})]}),(0,s.jsxs)(n.Box,{textAlign:"right",m:2,children:[(0,s.jsx)(n.Button,{variant:"outlined",color:"error",size:"large",onClick:f,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),(0,s.jsx)(n.Button,{variant:"contained",color:"primary",size:"large",onClick:()=>e(a),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function Xo({open:t,setOpen:o,processList:e=null,handleSelectedProcessor:a}){var p,g;return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",maxWidth:"xs",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,s.jsx)(n.Typography,{variant:"body1",children:" Process List"}),(0,s.jsx)(n.IconButton,{onClick:()=>{o(!1)},children:(0,s.jsx)(w.Close,{})})]}),(0,s.jsx)(n.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:((p=e==null?void 0:e.processes)==null?void 0:p.length)>0?(g=e==null?void 0:e.processes)==null?void 0:g.map((x,v)=>(0,s.jsx)(n.Box,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px",cursor:"pointer","&:hover":{bgcolor:"action.selected"}},onClick:()=>{a(x)},children:(0,s.jsxs)(n.Typography,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[(0,s.jsx)(w.SupportAgent,{sx:{marginRight:"4px"}}),x.process_name]})},v)):null})]})})})}function Jo({open:t,setOpen:o}){return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:(0,s.jsxs)(n.Paper,{sx:{borderRadius:2},children:[(0,s.jsxs)(n.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[(0,s.jsx)(n.Typography,{variant:"body1",children:" Call History"}),(0,s.jsx)(n.IconButton,{onClick:()=>{o(!1)},children:(0,s.jsx)(w.Close,{})})]}),(0,s.jsx)(n.Box,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",margin:"10px",borderRadius:"10px",textAlign:"center",fontSize:"16px",fontWeight:"bold"},p:6,children:"Coming Soon..."})]})})})}var r=require("react/jsx-runtime");function Vo({onDataChange:t}){var et,tt,ot,st,nt,at,it,lt,rt,ct,dt,pt,ut,gt,ft,mt,xt,Ct,ht,yt,bt,vt,St,Et,Tt,Lt,Dt,It,_t,Rt,wt,kt,At,Nt,Pt,Ot,Mt,Ut,Bt,Ht,$t,zt,Ft,qt,Wt,Kt,Gt,Yt,jt,Xt,Jt,Vt,Qt,Zt,eo,to,oo,so,no,ao,io,lo,ro,co,po,uo,go,fo,mo,xo,Co,ho,yo,bo,vo,So,Eo,To,Lo;let o=(0,u.useTheme)(),e=ye(),{disabled:a,enabled:l,outlined:p}=Ke({disabled:((et=e.sdkConfig)==null?void 0:et.disabled)||{},enabled:((tt=e.sdkConfig)==null?void 0:tt.enabled)||{},outlined:((ot=e.sdkConfig)==null?void 0:ot.outlined)||{}}),g=(0,K.useRef)(null),[x,v]=(0,K.useState)(null),[f,y]=(0,K.useState)(!0),[m,c]=(0,K.useState)(null),[b,h]=(0,K.useState)(null),[T,U]=(0,K.useState)(!1),[M,P]=(0,K.useState)(!1),[k,B]=(0,K.useState)(!1),[j,H]=(0,K.useState)(!1),[A,C]=(0,K.useState)(!1),[F,se]=(0,K.useState)(""),[ne,_]=(0,K.useState)(0),{position:S,isDragging:O,dragRef:G,handleMouseDown:q,handleTouchStart:X}=Ve(e.controlPanelPosition,i=>E.setControlPanelPosition(i)),{position:Y,isDragging:J,dragRef:N,handleMouseDown:I,handleTouchStart:z}=Ve(e.iframePosition,i=>E.setIframePosition(i)),[V,{data:Q}]=le({onSuccess:i=>{var L;console.log("res",i),i&&i.data&&((L=i==null?void 0:i.data)==null?void 0:L.length)>1?H(!0):(E.setProcess(i==null?void 0:i.data[0]),H(!1))},onError:()=>{H(!1)}}),[Z,{isLoading:pe}]=le(),[Re,{isLoading:be}]=le({onSuccess:()=>{E.setHolding(!e.isHolding)},onError:i=>{console.log("error",i)}}),[we,{isLoading:ve}]=le({onSuccess:()=>{E.setMuted(!e.isMuted)},onError:i=>{console.log("error",i)}}),[ke,{isLoading:Se}]=le(),[Ae,{isLoading:Ne}]=le(),[Pe,{isLoading:Ee}]=le(),Oe=(0,K.useCallback)(i=>{let L=Math.floor(i/60),ee=i%60;return`${L.toString().padStart(2,"0")}:${ee.toString().padStart(2,"0")}`},[]),Me=()=>{v(null)},Ue=i=>{y(!0),h(i.currentTarget),E.setStatus("dial")},Be=()=>{e.status!=="on call"&&E.setStatus("idle"),h(null)},He=i=>{c(i.currentTarget)},$e=()=>{c(null)},he=()=>{let i={action:"READYAGENT",userId:e.agentId};ke(R.READY_AGENT,i)},Ze=i=>{c(null);let L={action:"AGENTBREAK",break_type:i,userId:e.agentId};Ae(R.UPDATE_AGENT_BREAK,L)},ts=i=>{if(i.length!==10)alert("Invalid phone number");else if(/^\d+$/.test(i)){let L={action:"CALL",phone_number:i,userId:e.agentId};Z(R.CLICK_TO_CALL,L)}},os=()=>{let i={action:e.isHolding?"UNHOLD":"HOLD",userId:e.agentId};Re(R.HOLD_CALL,i)},ss=()=>{let i={action:e.isMuted?"UNMUTE":"MUTE",userId:e.agentId};we(R.MUTE_CALL,i)},ns=i=>{var ee,ce,de,ue,ge,Te,Le,Do,Io,_o,Ro,wo,ko,Ao,No,Po;console.log("data",i);let L={action:"ENDCALL",userId:e.agentId,processid:(de=(ce=(ee=e.process)==null?void 0:ee.process_id)==null?void 0:ce.toString())!=null?de:"",process_name:(ge=(ue=e.process)==null?void 0:ue.process_name)!=null?ge:"",callreferenceid:(Le=(Te=e.callData)==null?void 0:Te.convox_id)!=null?Le:"",mobile_number:(Io=(Do=e.callData)==null?void 0:Do.phone_number)!=null?Io:"",disposition:(Ro=(_o=i==null?void 0:i.disposition)==null?void 0:_o.value)!=null?Ro:"",set_followUp:(ko=(wo=i==null?void 0:i.followUp)==null?void 0:wo.value)!=null?ko:"",callback_date:(Ao=i==null?void 0:i.callbackDate)!=null?Ao:"",callback_hrs:(No=i==null?void 0:i.callbackHrs)!=null?No:"",callback_mins:(Po=i==null?void 0:i.callbackMins)!=null?Po:"",endcall_type:"CLOSE"};se(""),Pe(R.END_CALL,L),E.endCall(),B(!1)};return(0,K.useEffect)(()=>{let i;return e.callData.status&&e.callData.status==="ONCALL"?i=setInterval(()=>{let L=Math.floor((Date.now()-e.callStartTime)/1e3);_(L)},1e3):_(0),()=>{i&&clearInterval(i)}},[e.callData.status]),(0,K.useEffect)(()=>{t&&t(e.callData)},[e.callData,t]),(0,K.useEffect)(()=>{e.agentId?V(R.PROCESS_LIST,{userId:e.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[e.agentId]),(0,K.useEffect)(()=>(e.agentId&&(g.current=new WebSocket(`${Bo.WS}?agent_id=${e.agentId}`),g.current.onopen=()=>{console.log("WebSocket connection established")},g.current.onmessage=i=>{try{let L=JSON.parse(i.data);console.log("parsedJSON:",L),E.updateCallData(L),L.status==="ONCALL"&&(E.startCall(),f||y(!0)),L.status==="WRAPUP"&&E.endCall()}catch(L){console.log("Raw message:",i.data)}},g.current.onclose=()=>{console.log("WebSocket connection closed")},g.current.onerror=i=>{console.error("WebSocket error:",i)}),()=>{var i;(i=g.current)==null||i.close()}),[e.agentId]),!e.isInitialized||!e.process?(0,r.jsx)(u.Box,{children:!!j&&(0,r.jsx)(Xo,{processList:Q,open:j,setOpen:H,handleSelectedProcessor:i=>{E.setProcess(i)}})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.Box,{children:(0,r.jsx)(u.Fade,{in:!0,timeout:300,children:(0,r.jsx)(u.Paper,{ref:(st=e.sdkConfig)!=null&&st.enableFloatingDrag?G:null,elevation:O?4:(nt=e.sdkConfig)!=null&&nt.enableFloatingDrag?1:0,sx:{position:(at=e.sdkConfig)!=null&&at.enableFloatingDrag?"fixed":"relative",left:(it=e.sdkConfig)!=null&&it.enableFloatingDrag?S.x:"auto",top:(lt=e.sdkConfig)!=null&<.enableFloatingDrag?S.y:"auto",display:"inline-block",width:"auto",flexShrink:0,whiteSpace:"nowrap",p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:Number.MAX_SAFE_INTEGER,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),userSelect:"none"},children:(0,r.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center"},children:[((rt=e.sdkConfig)==null?void 0:rt.enableFloatingDrag)&&(0,r.jsxs)(u.IconButton,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:q,onTouchStart:X,children:[(0,r.jsx)(D.DragIndicator,{})," "]}),(0,r.jsx)(u.Box,{sx:{marginRight:"10px"},children:(0,r.jsx)(u.Tooltip,{title:"Dial",children:(0,r.jsx)(u.IconButton,{size:"small",onClick:i=>{var L,ee,ce,de,ue,ge,Te,Le;((ee=(L=e.callData)==null?void 0:L.status)==null?void 0:ee.toUpperCase())!=="ONCALL"&&((de=(ce=e.callData)==null?void 0:ce.status)==null?void 0:de.toUpperCase())!=="BREAK"&&((ge=(ue=e.callData)==null?void 0:ue.status)==null?void 0:ge.toUpperCase())!=="RINGING"&&((Le=(Te=e.callData)==null?void 0:Te.status)==null?void 0:Le.toUpperCase())!=="WRAPUP"&&Ue(i)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:(0,r.jsx)(D.WifiCalling3,{sx:{color:((dt=(ct=e.callData)==null?void 0:ct.status)==null?void 0:dt.toUpperCase())==="ONCALL"||((ut=(pt=e.callData)==null?void 0:pt.status)==null?void 0:ut.toUpperCase())==="BREAK"||((ft=(gt=e.callData)==null?void 0:gt.status)==null?void 0:ft.toUpperCase())==="RINGING"||((xt=(mt=e.callData)==null?void 0:mt.status)==null?void 0:xt.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),(0,r.jsx)(u.Typography,{sx:{color:"success.main",width:"40px",marginRight:"10px",fontSize:"16px",fontWeight:"600"},children:Oe(ne)}),Ne||Se?(0,r.jsx)(u.Box,{sx:{fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,r.jsx)(u.CircularProgress,{size:"20px"})}):(0,r.jsx)(u.Typography,{variant:"body2",sx:{fontWeight:"bold",textAlign:"right"},children:(yt=(ht=(Ct=e.callData)==null?void 0:Ct.status)==null?void 0:ht.toUpperCase())!=null?yt:"N/A"}),(0,r.jsx)(u.Box,{onClick:He,sx:{display:"flex",alignItems:"center",margin:"6px",cursor:"pointer"},children:(0,r.jsx)(D.ArrowDropDown,{})})]}),(0,r.jsxs)(u.Box,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[(0,r.jsx)(u.Tooltip,{title:"Agent Ready",children:(0,r.jsx)(u.Button,{variant:((vt=(bt=e.callData)==null?void 0:bt.status)==null?void 0:vt.toUpperCase())==="BREAK"||((Et=(St=e.callData)==null?void 0:St.status)==null?void 0:Et.toUpperCase())==="MISSED"?"outlined":"contained",onClick:i=>{var L,ee,ce,de;(((ee=(L=e.callData)==null?void 0:L.status)==null?void 0:ee.toUpperCase())==="BREAK"||((de=(ce=e.callData)==null?void 0:ce.status)==null?void 0:de.toUpperCase())==="MISSED")&&(i.stopPropagation(),he())},classes:{root:((Lt=(Tt=e.callData)==null?void 0:Tt.status)==null?void 0:Lt.toUpperCase())==="BREAK"||((It=(Dt=e.callData)==null?void 0:Dt.status)==null?void 0:It.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:d({},((Rt=(_t=e.callData)==null?void 0:_t.status)==null?void 0:Rt.toUpperCase())==="BREAK"||((kt=(wt=e.callData)==null?void 0:wt.status)==null?void 0:kt.toUpperCase())==="MISSED"?p:l),disabled:Se,children:(0,r.jsx)(D.SupportAgent,{})})}),(0,r.jsx)(u.Tooltip,{title:e.isHolding?"Resume":"Hold",children:(0,r.jsx)(u.Button,{variant:e.isHolding&&((Nt=(At=e.callData)==null?void 0:At.status)==null?void 0:Nt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),os()},sx:e.isHolding&&((Ot=(Pt=e.callData)==null?void 0:Pt.status)==null?void 0:Ot.toUpperCase())==="ONCALL"?d({},l):((Ut=(Mt=e.callData)==null?void 0:Mt.status)==null?void 0:Ut.toUpperCase())==="ONCALL"?d({},p):d({},a),disabled:((Ht=(Bt=e.callData)==null?void 0:Bt.status)==null?void 0:Ht.toUpperCase())!=="ONCALL"&&!e.isHolding||be,children:be?(0,r.jsx)(u.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isHolding?(0,r.jsx)(D.PlayArrow,{}):(0,r.jsx)(D.Pause,{})})}),(0,r.jsx)(u.Tooltip,{title:e.isMuted?"Unmute":"Mute",children:(0,r.jsx)(u.Button,{variant:e.isMuted&&((zt=($t=e.callData)==null?void 0:$t.status)==null?void 0:zt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),ss()},sx:e.isMuted&&((qt=(Ft=e.callData)==null?void 0:Ft.status)==null?void 0:qt.toUpperCase())==="ONCALL"?d({},l):((Kt=(Wt=e.callData)==null?void 0:Wt.status)==null?void 0:Kt.toUpperCase())==="ONCALL"?d({},p):d({},a),disabled:((Yt=(Gt=e.callData)==null?void 0:Gt.status)==null?void 0:Yt.toUpperCase())!=="ONCALL"&&!e.isMuted||ve,children:ve?(0,r.jsx)(u.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isMuted?(0,r.jsx)(D.MicOff,{}):(0,r.jsx)(D.Mic,{})})}),((jt=e.sdkConfig)==null?void 0:jt.showTransferButton)&&(0,r.jsx)(u.Tooltip,{title:"Transfer Call",children:(0,r.jsx)(u.Button,{variant:M?"contained":"outlined",onClick:i=>{var L,ee;((ee=(L=e.callData)==null?void 0:L.status)==null?void 0:ee.toUpperCase())==="ONCALL"&&(i.stopPropagation(),P(!0))},sx:M?d({},l):((Jt=(Xt=e.callData)==null?void 0:Xt.status)==null?void 0:Jt.toUpperCase())==="ONCALL"?d({},p):d({},a),disabled:((Qt=(Vt=e.callData)==null?void 0:Vt.status)==null?void 0:Qt.toUpperCase())!=="ONCALL",children:(0,r.jsx)(D.TransferWithinAStation,{})})}),((Zt=e.sdkConfig)==null?void 0:Zt.showConferenceButton)&&(0,r.jsx)(u.Tooltip,{title:"Conference Call",children:(0,r.jsx)(u.Button,{variant:T?"contained":"outlined",onClick:i=>{var L,ee;((ee=(L=e.callData)==null?void 0:L.status)==null?void 0:ee.toUpperCase())==="ONCALL"&&(i.stopPropagation(),U(!0))},sx:T?d({},l):((to=(eo=e.callData)==null?void 0:eo.status)==null?void 0:to.toUpperCase())==="ONCALL"?d({},p):d({},a),disabled:((so=(oo=e.callData)==null?void 0:oo.status)==null?void 0:so.toUpperCase())!=="ONCALL",children:(0,r.jsx)(D.Group,{})})}),((no=e.sdkConfig)==null?void 0:no.showEndCallButton)&&(0,r.jsx)(u.Tooltip,{title:"End Call",children:(0,r.jsx)(u.Button,{variant:((io=(ao=e.callData)==null?void 0:ao.status)==null?void 0:io.toUpperCase())==="ONCALL"||((ro=(lo=e.callData)==null?void 0:lo.status)==null?void 0:ro.toUpperCase())==="RINGING"||((po=(co=e.callData)==null?void 0:co.status)==null?void 0:po.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:i=>{var L,ee,ce,de,ue,ge;(((ee=(L=e.callData)==null?void 0:L.status)==null?void 0:ee.toUpperCase())==="ONCALL"||((de=(ce=e.callData)==null?void 0:ce.status)==null?void 0:de.toUpperCase())==="RINGING"||((ge=(ue=e.callData)==null?void 0:ue.status)==null?void 0:ge.toUpperCase())==="WRAPUP")&&(i.stopPropagation(),B(!0))},sx:((go=(uo=e.callData)==null?void 0:uo.status)==null?void 0:go.toUpperCase())==="ONCALL"||((mo=(fo=e.callData)==null?void 0:fo.status)==null?void 0:mo.toUpperCase())==="RINGING"||((Co=(xo=e.callData)==null?void 0:xo.status)==null?void 0:Co.toUpperCase())==="WRAPUP"?te(d({},l),{borderRight:"1px",backgroundColor:"error.main",minWidth:"60px !important",boxShadow:" 0px 2px 1px #5f3f3f",border:`1px solid ${o.palette.error.light}`,height:"40px","&:hover":{bgcolor:"error.light",boxShadow:" 0px 2px 1px #5f3f3f",border:`0px solid ${o.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${o.palette.primary.light}`}}):te(d({},a),{minWidth:"60px !important"}),disabled:((yo=(ho=e.callData)==null?void 0:ho.status)==null?void 0:yo.toUpperCase())!=="ONCALL"&&((vo=(bo=e.callData)==null?void 0:bo.status)==null?void 0:vo.toUpperCase())!=="RINGING"&&((Eo=(So=e.callData)==null?void 0:So.status)==null?void 0:Eo.toUpperCase())!=="WRAPUP"||Ee,children:Ee?(0,r.jsx)(u.CircularProgress,{size:"20px",color:"error"}):(0,r.jsx)(D.CallEnd,{})})})]})]})})})}),(0,r.jsx)(u.Fade,{in:!0,timeout:300,children:(0,r.jsxs)(u.Paper,{ref:N,elevation:J?4:1,sx:{position:"absolute",left:Y.x,top:Y.y,borderRadius:2,bgcolor:"background.paper",zIndex:Number.MAX_SAFE_INTEGER,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),visibility:f&&((To=e.sdkConfig)!=null&&To.enableSoftPhone)?"visible":"hidden",userSelect:"none"},children:[(0,r.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll",padding:"0px 10px"},onMouseDown:I,onTouchStart:z,children:[(0,r.jsx)(D.DragIndicator,{sx:{transform:"rotate(90deg)",color:"#7b7b7b"}})," ",(0,r.jsx)(u.IconButton,{onClick:()=>y(!1),children:(0,r.jsx)(D.Close,{})})]}),(0,r.jsx)(u.Box,{children:(0,r.jsx)("iframe",{src:`https://${ze}/ConVoxCCS/iframe?agent_id=${e.agentId}&process_id=${(Lo=e.process)==null?void 0:Lo.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay",style:{border:"none"}})})]})}),(0,r.jsx)(u.Menu,{anchorEl:b,open:!!b,onClose:Be,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,r.jsxs)(u.Box,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[(0,r.jsx)(u.TextField,{size:"small",value:F,placeholder:"Enter Mobile No.",onChange:i=>{se(i.target.value)}}),(0,r.jsx)(u.IconButton,{color:"info",onClick:()=>{ts(F)},children:pe?(0,r.jsx)(u.CircularProgress,{size:"20px",sx:{color:o.palette.success.main}}):(0,r.jsx)(D.Phone,{color:"success"})})]})}),(0,r.jsxs)(u.Menu,{anchorEl:m,open:!!m,onClose:$e,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:[(0,r.jsx)(u.MenuItem,{onClick:()=>Ze("Lunch"),children:"- Lunch"}),(0,r.jsx)(u.MenuItem,{onClick:()=>Ze("Tea"),children:"- Tea"})]}),(0,r.jsx)(u.Menu,{anchorEl:x,open:!!x,onClose:Me,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,r.jsxs)(u.Box,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[(0,r.jsx)(u.Chip,{icon:(0,r.jsx)(D.Layers,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),(0,r.jsx)(u.Chip,{icon:(0,r.jsx)(D.Pending,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),(0,r.jsx)(u.Chip,{icon:(0,r.jsx)(D.Upcoming,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!T&&(0,r.jsx)(Go,{open:T,setOpen:U}),!!M&&(0,r.jsx)(Yo,{open:M,setOpen:P}),!!k&&(0,r.jsx)(jo,{open:k,setOpen:B,onSubmitDisposition:ns}),!!A&&(0,r.jsx)(Jo,{open:A,setOpen:C})]})}var Zo=require("react/jsx-runtime"),Qo=({children:t})=>(0,Zo.jsx)(Wo,{children:t});var Qe=require("react/jsx-runtime");function es({onDataChange:t}){return(0,Qe.jsx)(Qo,{children:(0,Qe.jsx)(Vo,{onDataChange:t})})}function Ss({apiKey:t,tenantId:o,agentId:e,sdkConfig:a}){je.init({apiKey:t,tenantId:o,agentId:e,baseUrl:$}).then(l=>{l?(console.log("SDK initialized successfully"),E.initialize(t,e,a)):(console.log("SDK initialization failed"),E.setInitCheck())})}0&&(module.exports={CallControlPanel,initSDK,useClickToCall,useEndCall,useLogout});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|