call-control-sdk 5.4.0 → 5.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +21 -12
- package/dist/index.d.ts +21 -12
- 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 +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SxProps } from '@mui/material';
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -35,6 +34,25 @@ declare const useEndCall: () => {
|
|
|
35
34
|
data: null;
|
|
36
35
|
};
|
|
37
36
|
|
|
37
|
+
interface StartCallPayload {
|
|
38
|
+
mobileNumber: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Custom hook for handling end call functionality
|
|
42
|
+
* @param options - Optional callbacks for success, error, and completion
|
|
43
|
+
* @returns Object containing logout function and loading state
|
|
44
|
+
* @example
|
|
45
|
+
* handleStartCall({ mobileNumber: "1111111111" });
|
|
46
|
+
*/
|
|
47
|
+
declare const useClickToCall: () => {
|
|
48
|
+
handleStartCall: (data: StartCallPayload) => Promise<any>;
|
|
49
|
+
isLoading: boolean;
|
|
50
|
+
isSuccess: boolean;
|
|
51
|
+
isError: boolean;
|
|
52
|
+
error: null;
|
|
53
|
+
data: null;
|
|
54
|
+
};
|
|
55
|
+
|
|
38
56
|
interface CallData {
|
|
39
57
|
mobileNumber?: string;
|
|
40
58
|
callReferenceId?: string;
|
|
@@ -52,14 +70,6 @@ interface CallControlPanelProps {
|
|
|
52
70
|
onDataChange?: (data: any) => void;
|
|
53
71
|
}
|
|
54
72
|
type CallStatus = "idle" | "ready" | "break" | "on call" | "wrap up" | "dial" | "hold" | "mute";
|
|
55
|
-
interface SDKConfig {
|
|
56
|
-
showEndCallButton?: boolean;
|
|
57
|
-
showTransferButton?: boolean;
|
|
58
|
-
showConferenceButton?: boolean;
|
|
59
|
-
disabled?: SxProps;
|
|
60
|
-
enabled?: SxProps;
|
|
61
|
-
outlined?: SxProps;
|
|
62
|
-
}
|
|
63
73
|
|
|
64
74
|
declare function CallControlPanel({ onDataChange }: CallControlPanelProps): react_jsx_runtime.JSX.Element;
|
|
65
75
|
|
|
@@ -72,8 +82,7 @@ type intiSDKParams = {
|
|
|
72
82
|
apiKey: string;
|
|
73
83
|
tenantId: string;
|
|
74
84
|
agentId: string;
|
|
75
|
-
sdkConfig?: SDKConfig;
|
|
76
85
|
};
|
|
77
|
-
declare function initSDK({ apiKey, tenantId, agentId
|
|
86
|
+
declare function initSDK({ apiKey, tenantId, agentId }: intiSDKParams): void;
|
|
78
87
|
|
|
79
|
-
export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useEndCall, useLogout };
|
|
88
|
+
export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useClickToCall, useEndCall, useLogout };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SxProps } from '@mui/material';
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -35,6 +34,25 @@ declare const useEndCall: () => {
|
|
|
35
34
|
data: null;
|
|
36
35
|
};
|
|
37
36
|
|
|
37
|
+
interface StartCallPayload {
|
|
38
|
+
mobileNumber: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Custom hook for handling end call functionality
|
|
42
|
+
* @param options - Optional callbacks for success, error, and completion
|
|
43
|
+
* @returns Object containing logout function and loading state
|
|
44
|
+
* @example
|
|
45
|
+
* handleStartCall({ mobileNumber: "1111111111" });
|
|
46
|
+
*/
|
|
47
|
+
declare const useClickToCall: () => {
|
|
48
|
+
handleStartCall: (data: StartCallPayload) => Promise<any>;
|
|
49
|
+
isLoading: boolean;
|
|
50
|
+
isSuccess: boolean;
|
|
51
|
+
isError: boolean;
|
|
52
|
+
error: null;
|
|
53
|
+
data: null;
|
|
54
|
+
};
|
|
55
|
+
|
|
38
56
|
interface CallData {
|
|
39
57
|
mobileNumber?: string;
|
|
40
58
|
callReferenceId?: string;
|
|
@@ -52,14 +70,6 @@ interface CallControlPanelProps {
|
|
|
52
70
|
onDataChange?: (data: any) => void;
|
|
53
71
|
}
|
|
54
72
|
type CallStatus = "idle" | "ready" | "break" | "on call" | "wrap up" | "dial" | "hold" | "mute";
|
|
55
|
-
interface SDKConfig {
|
|
56
|
-
showEndCallButton?: boolean;
|
|
57
|
-
showTransferButton?: boolean;
|
|
58
|
-
showConferenceButton?: boolean;
|
|
59
|
-
disabled?: SxProps;
|
|
60
|
-
enabled?: SxProps;
|
|
61
|
-
outlined?: SxProps;
|
|
62
|
-
}
|
|
63
73
|
|
|
64
74
|
declare function CallControlPanel({ onDataChange }: CallControlPanelProps): react_jsx_runtime.JSX.Element;
|
|
65
75
|
|
|
@@ -72,8 +82,7 @@ type intiSDKParams = {
|
|
|
72
82
|
apiKey: string;
|
|
73
83
|
tenantId: string;
|
|
74
84
|
agentId: string;
|
|
75
|
-
sdkConfig?: SDKConfig;
|
|
76
85
|
};
|
|
77
|
-
declare function initSDK({ apiKey, tenantId, agentId
|
|
86
|
+
declare function initSDK({ apiKey, tenantId, agentId }: intiSDKParams): void;
|
|
78
87
|
|
|
79
|
-
export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useEndCall, useLogout };
|
|
88
|
+
export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, initSDK, useClickToCall, useEndCall, useLogout };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var Xo=Object.create;var Le=Object.defineProperty,Jo=Object.defineProperties,Vo=Object.getOwnPropertyDescriptor,Qo=Object.getOwnPropertyDescriptors,Zo=Object.getOwnPropertyNames,wo=Object.getOwnPropertySymbols,es=Object.getPrototypeOf,Io=Object.prototype.hasOwnProperty,ts=Object.prototype.propertyIsEnumerable;var Ke=(t,o,e)=>o in t?Le(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,c=(t,o)=>{for(var e in o||(o={}))Io.call(o,e)&&Ke(t,e,o[e]);if(wo)for(var e of wo(o))ts.call(o,e)&&Ke(t,e,o[e]);return t},Z=(t,o)=>Jo(t,Qo(o));var os=(t,o)=>{for(var e in o)Le(t,e,{get:o[e],enumerable:!0})},Ro=(t,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of Zo(o))!Io.call(t,l)&&l!==e&&Le(t,l,{get:()=>o[l],enumerable:!(a=Vo(o,l))||a.enumerable});return t};var ss=(t,o,e)=>(e=t!=null?Xo(es(t)):{},Ro(o||!t||!t.__esModule?Le(e,"default",{value:t,enumerable:!0}):e,t)),ns=t=>Ro(Le({},"__esModule",{value:!0}),t);var ae=(t,o,e)=>Ke(t,typeof o!="symbol"?o+"":o,e);var gs={};os(gs,{CallControlPanel:()=>Fo,initSDK:()=>us,useEndCall:()=>No,useLogout:()=>Ao});module.exports=ns(gs);var Ge=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 d;let a=`${this.baseUrl}${o}`,l=((d=this.config)==null?void 0:d.retryAttempts)||3;for(let g=1;g<=l;g++)try{return await fetch(a,e)}catch(m){if(g===l)throw m;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 d=l.target;(d.tagName==="BUTTON"||d.tagName==="A"||d.onclick||d.getAttribute("role")==="button"||d instanceof HTMLButtonElement&&d.type==="button")&&this.logEvent("click",{element:d.tagName,text:(g=d.textContent)==null?void 0:g.trim().substring(0,100),href:d.getAttribute("href"),id:d.id,className:d.className,role:d.getAttribute("role"),position:{x:l.clientX,y:l.clientY},timestamp:new Date().toISOString()}).catch(m=>console.warn("Failed to track click:",m))}),o.forms!==!1&&document.addEventListener("submit",l=>{let d=l.target,g=new FormData(d),m={};g.forEach((v,f)=>{m[f]=v.toString()}),this.logEvent("formSubmission",{formId:d.id,action:d.action,method:d.method,fields:Object.keys(m),fieldCount:Object.keys(m).length,timestamp:new Date().toISOString()}).catch(v=>console.warn("Failed to track form submission:",v))}),o.inputs!==!1){let l;document.addEventListener("input",d=>{let g=d.target;(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.tagName==="SELECT")&&(clearTimeout(l),l=setTimeout(()=>{var m;this.logEvent("fieldChange",{element:g.tagName,type:g.getAttribute("type"),name:g.getAttribute("name"),id:g.id,valueLength:((m=g.value)==null?void 0:m.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 d;this.logEvent("unhandledRejection",{reason:(d=l.reason)==null?void 0:d.toString(),timestamp:new Date().toISOString()})})),o.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let l=window.performance.navigation,d=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:d.navigationStart,loadTime:d.loadEventEnd-d.navigationStart,domReady:d.domContentLoadedEventEnd-d.navigationStart,renderTime:d.loadEventEnd-d.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)}},Ye=new Ge;typeof window!="undefined"&&(window.EventTracker=Ye);var je=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||[]}},D=new je;var fe=require("react");var $e="10.10.102.42",P=`http://${$e}:8095`,as=`ws://${$e}:8095`,z={v1:"/api/v1"},O={LOGIN:`${P}${z.v1}/cti/login?provider=convox`,READY_AGENT:`${P}${z.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${P}${z.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${P}${z.v1}/cti/calls?provider=convox`,HOLD_CALL:`${P}${z.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${P}${z.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${P}${z.v1}/cti/unmute-call?provider=convox`,END_CALL:`${P}${z.v1}/cti/calls/end?provider=convox`,LOGOUT:`${P}${z.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${P}${z.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${P}${z.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${P}${z.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${P}${z.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${P}${z.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${P}${z.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${P}${z.v1}/cti/users`,PROCESS_LIST:`${P}${z.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${P}${z.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${P}${z.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${P}${z.v1}/users/get_sentiment_analysis`},_o={WS:`${as}${z.v1}/cti/ws`};var ko=ss(require("axios"));var is="12345",Xe=ko.default.create({baseURL:P,headers:{"Content-Type":"application/json",Authorization:is},timeout:1e4});Xe.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))));Xe.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 ne=Xe;var ls=()=>{let[t,o]=(0,fe.useState)(!1),[e,a]=(0,fe.useState)(!1),[l,d]=(0,fe.useState)(!1),[g,m]=(0,fe.useState)(null),[v,f]=(0,fe.useState)(null);return{logout:(0,fe.useCallback)(async()=>{var y;let x=JSON.parse((y=localStorage.getItem("call-control-sdk-state"))!=null?y:"");o(!0);let u={action:"LOGOUTUSER",userId:x.agentId||""};return ne.post(O.LOGOUT,u).then(C=>(D.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),f(C==null?void 0:C.data),a(!0),C==null?void 0:C.data)).catch(C=>{var w;return d(!0),m(C),(w=C==null?void 0:C.response)==null?void 0:w.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:l,error:g,data:v}},Ao=ls;var me=require("react");var No=()=>{let[t,o]=(0,me.useState)(!1),[e,a]=(0,me.useState)(!1),[l,d]=(0,me.useState)(!1),[g,m]=(0,me.useState)(null),[v,f]=(0,me.useState)(null);return{handleEndCall:(0,me.useCallback)(async x=>{var C,w,B,U,N,A,H,ee,Q,te,S,J,oe,se,I;let u=JSON.parse((C=localStorage.getItem("call-control-sdk-state"))!=null?C:"");o(!0);let y={action:"ENDCALL",userId:u==null?void 0:u.agentId,processid:(U=(B=(w=u==null?void 0:u.process)==null?void 0:w.process_id)==null?void 0:B.toString())!=null?U:"",process_name:(A=(N=u==null?void 0:u.process)==null?void 0:N.process_name)!=null?A:"",callreferenceid:(ee=(H=u==null?void 0:u.callData)==null?void 0:H.convox_id)!=null?ee:"",mobile_number:(te=(Q=u==null?void 0:u.callData)==null?void 0:Q.phone_number)!=null?te:"",disposition:(S=x==null?void 0:x.disposition)!=null?S:"RES",set_followUp:(J=x==null?void 0:x.followUp)!=null?J:"N",callback_date:(oe=x==null?void 0:x.callbackDate)!=null?oe:"",callback_hrs:(se=x==null?void 0:x.callbackHrs)!=null?se:"",callback_mins:(I=x==null?void 0:x.callbackMins)!=null?I:"",endcall_type:"CLOSE"};return ne.post(O.END_CALL,y).then(b=>(D.endCall(),f(b==null?void 0:b.data),a(!0),b==null?void 0:b.data)).catch(b=>{var k;return d(!0),m(b),(k=b==null?void 0:b.response)==null?void 0:k.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:l,error:g,data:v}};var E=require("@mui/icons-material"),p=require("@mui/material"),q=require("react");var ie=require("react");function Je(t,o){let[e,a]=(0,ie.useState)(t),[l,d]=(0,ie.useState)(!1),g=(0,ie.useRef)(),m=(0,ie.useRef)({x:0,y:0}),v=(0,ie.useRef)({x:0,y:0}),f=(0,ie.useCallback)(y=>{let C=g.current;if(!C)return;let w=C.getBoundingClientRect(),B=window.innerWidth,U=window.innerHeight,N={x:Math.max(0,Math.min(y.x,B-w.width)),y:Math.max(0,Math.min(y.y,U-w.height))};a(N),o==null||o(N)},[o]),h=(0,ie.useCallback)((y,C)=>{d(!0),m.current={x:y,y:C},v.current=e;let w=(A,H)=>{let ee=A-m.current.x,Q=H-m.current.y;f({x:v.current.x+ee,y:v.current.y+Q})},B=A=>{A.preventDefault(),w(A.clientX,A.clientY)},U=A=>{A.preventDefault();let H=A.touches[0];H&&w(H.clientX,H.clientY)},N=()=>{d(!1),document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",N),document.removeEventListener("touchmove",U),document.removeEventListener("touchend",N)};document.addEventListener("mousemove",B),document.addEventListener("mouseup",N),document.addEventListener("touchmove",U,{passive:!1}),document.addEventListener("touchend",N)},[e,f]),x=(0,ie.useCallback)(y=>{y.preventDefault(),h(y.clientX,y.clientY)},[h]),u=(0,ie.useCallback)(y=>{y.preventDefault();let C=y.touches[0];C&&h(C.clientX,C.clientY)},[h]);return{position:e,isDragging:l,dragRef:g,handleMouseDown:x,handleTouchStart:u}}var ze=require("react");function he(){let[t,o]=(0,ze.useState)(D.getState());return(0,ze.useEffect)(()=>D.subscribe(()=>{o(D.getState())}),[]),t}var We=require("react");var xe=require("react"),qe=require("@mui/material"),De=require("react/jsx-runtime"),Po=(0,xe.createContext)(void 0),we=()=>{let t=(0,xe.useContext)(Po);if(!t)throw new Error("useToast must be used inside ToastProvider");return t},Oo=({children:t})=>{let[o,e]=(0,xe.useState)(!1),[a,l]=(0,xe.useState)(""),[d,g]=(0,xe.useState)("info"),m=(v,f="info")=>{l(v),g(f),e(!0)};return(0,De.jsxs)(Po.Provider,{value:{showToast:m},children:[t,(0,De.jsx)(qe.Snackbar,{open:o,color:d,autoHideDuration:3e3,onClose:()=>e(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,De.jsx)(qe.Alert,{variant:"filled",severity:d,onClose:()=>e(!1),sx:{width:"100%"},children:a})})]})};var rs={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},cs=(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}=we(),[l,d]=(0,We.useReducer)(cs,rs);return[(0,We.useCallback)((m,v,f={})=>{d({type:"isLoading",payload:!0}),ne.post(m,v,f).then(h=>{var x,u;d({type:"isSuccess",payload:h.data}),o==null||o(h.data,v),console.log((x=h.data)==null?void 0:x.message,"res45"),a((u=h.data)==null?void 0:u.message,"success")}).catch(h=>{var u,y,C,w,B,U,N,A,H,ee,Q,te;let x={status:(y=(u=h.response)==null?void 0:u.status)!=null?y:500,message:((w=(C=h.response)==null?void 0:C.data)==null?void 0:w.detail)||((U=(B=h.response)==null?void 0:B.data)==null?void 0:U.message)||h.message||"An unknown error occurred",data:(A=(N=h.response)==null?void 0:N.data)!=null?A:null,statusText:(ee=(H=h.response)==null?void 0:H.statusText)!=null?ee:"",code:(Q=h==null?void 0:h.code)!=null?Q:"",name:(te=h==null?void 0:h.name)!=null?te:""};a(x.message,"error"),d({type:"isError",payload:x}),e==null||e(x,v)}).finally(()=>{d({type:"isLoading",payload:!1})})},[o,e,a]),l]};var _=require("@mui/icons-material"),n=require("@mui/material"),re=require("react");var Uo=require("@mui/material");var ds=({disabled:t,enabled:o,outlined:e})=>{let a=(0,Uo.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)}},Fe=ds;var s=require("react/jsx-runtime"),ps=({each:t})=>{var te,S,J,oe,se;let o=he(),{showToast:e}=we(),{disabled:a,enabled:l,outlined:d}=Fe({disabled:((te=o.sdkConfig)==null?void 0:te.disabled)||{},enabled:((S=o.sdkConfig)==null?void 0:S.enabled)||{},outlined:((J=o.sdkConfig)==null?void 0:J.outlined)||{}}),g=(0,n.useTheme)(),[m,v]=(0,re.useState)(!1),[f,h]=(0,re.useState)(!1),[x,u]=(0,re.useState)(!1),[y,C]=(0,re.useState)(!1),[w,B]=(0,re.useState)(!1),U=(I,b)=>{D.setConferenceLine(c(c({},I),b))},N=(I,b)=>{var $,K,F,G;let k=c(c({},I),b);v(!0);let W={action:"EXTERNAL_CONFERENCE",operation:`CALL${k.line}`,line_used:String(k.line),thirdparty_no:k.phone,userid:(K=($=o.callData)==null?void 0:$.agent_id)!=null?K:"",process:(G=(F=o.callData)==null?void 0:F.process_name)!=null?G:""};ne.post(O.CONFERENCE_CALL,W).then(R=>{var L;e((L=R.data)==null?void 0:L.message,"success"),D.setConferenceLine(c(c({},I),b))}).catch(R=>{var M,Y,V,j;let L=((Y=(M=R.response)==null?void 0:M.data)==null?void 0:Y.detail)||((j=(V=R.response)==null?void 0:V.data)==null?void 0:j.message)||R.message||"An unknown error occurred";e(L,"error")}).finally(()=>{v(!1)})},A=(I,b)=>{var $,K,F,G;let k=c(c({},I),b);h(!0);let W={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(k.line),thirdparty_no:k.phone,userid:(K=($=o.callData)==null?void 0:$.agent_id)!=null?K:"",process:(G=(F=o.callData)==null?void 0:F.process_name)!=null?G:""};ne.post(O.CONFERENCE_CALL,W).then(R=>{var L;e((L=R.data)==null?void 0:L.message,"success"),D.setConferenceLine(c(c({},I),b))}).catch(R=>{var M,Y,V,j;let L=((Y=(M=R.response)==null?void 0:M.data)==null?void 0:Y.detail)||((j=(V=R.response)==null?void 0:V.data)==null?void 0:j.message)||R.message||"An unknown error occurred";e(L,"error")}).finally(()=>{h(!1)})},H=(I,b,k)=>{var K,F,G,R;let W=c(c({},I),b);u(!0);let $={action:"EXTERNAL_CONFERENCE",operation:k,hold_channel_no:k==="HOLDUSER"?`hold${W.line}`:`unhold${W.line}`,userid:(F=(K=o.callData)==null?void 0:K.agent_id)!=null?F:"",process:(R=(G=o.callData)==null?void 0:G.process_name)!=null?R:""};ne.post(O.CONFERENCE_CALL_HOLD_OR_UN_HOLD,$).then(L=>{var M;e((M=L.data)==null?void 0:M.message,"success"),D.setConferenceLine(c(c({},I),b))}).catch(L=>{var Y,V,j,pe;let M=((V=(Y=L.response)==null?void 0:Y.data)==null?void 0:V.detail)||((pe=(j=L.response)==null?void 0:j.data)==null?void 0:pe.message)||L.message||"An unknown error occurred";e(M,"error")}).finally(()=>{u(!1)})},ee=(I,b,k)=>{var K,F,G,R;let W=c(c({},I),b);C(!0);let $={action:"EXTERNAL_CONFERENCE",operation:k,channel_no:k==="MUTEUSER"?`mute${W.line}`:`play${W.line}`,userid:(F=(K=o.callData)==null?void 0:K.agent_id)!=null?F:"",thirdparty_no:W.phone,process:(R=(G=o.callData)==null?void 0:G.process_name)!=null?R:""};ne.post(O.CONFERENCE_CALL_MUTE_OT_UN_MUTE,$).then(L=>{var M;e((M=L.data)==null?void 0:M.message,"success"),D.setConferenceLine(c(c({},I),b))}).catch(L=>{var Y,V,j,pe;let M=((V=(Y=L.response)==null?void 0:Y.data)==null?void 0:V.detail)||((pe=(j=L.response)==null?void 0:j.data)==null?void 0:pe.message)||L.message||"An unknown error occurred";e(M,"error")}).finally(()=>{C(!1)})},Q=(I,b)=>{var $,K,F,G;let k=c(c({},I),b);B(!0);let W={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(k.line-1),user_type:`THIRDPARTY${k.line-1}`,thirdparty_no:k.phone,userid:(K=($=o.callData)==null?void 0:$.agent_id)!=null?K:"",process:(G=(F=o.callData)==null?void 0:F.process_name)!=null?G:""};ne.post(O.CONFERENCE_CALL_END,W).then(R=>{var L;e((L=R.data)==null?void 0:L.message,"success"),D.setConferenceLine(c(c({},I),b))}).catch(R=>{var M,Y,V,j;let L=((Y=(M=R.response)==null?void 0:M.data)==null?void 0:Y.detail)||((j=(V=R.response)==null?void 0:V.data)==null?void 0:j.message)||R.message||"An unknown error occurred";e(L,"error")}).finally(()=>{B(!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 ",(oe=t==null?void 0:t.line)!=null?oe:"",". "]})}),(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:(se=t==null?void 0:t.status)!=null?se:""})}),(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:I=>{U(t,{phone:I.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:()=>{N(t,{isCallStart:!0,status:"ONCALL"})},disabled:(t==null?void 0:t.isCallStart)||m,children:m?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"success"}):(0,s.jsx)(_.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({},d):c({},a),onClick:()=>{A(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)(_.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({},d):c({},a),onClick:()=>{t.isHold?H(t,{isHold:!1},"UNHOLDUSER"):H(t,{isHold:!0},"HOLDUSER")},disabled:!(t!=null&&t.isCallStart)||x,children:x?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:g.palette.primary.main}}):t.isHold?(0,s.jsx)(_.PlayArrow,{}):(0,s.jsx)(_.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({},d):c({},a),onClick:()=>{t.isMute?ee(t,{isMute:!1},"PLAYUSER"):ee(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)(_.MicOff,{}):(0,s.jsx)(_.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:()=>{Q(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(t!=null&&t.isCallStart)||w,children:w?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"error"}):(0,s.jsx)(_.CallEnd,{})}):(0,s.jsx)(n.Button,{variant:t!=null&&t.isCallStart?"contained":"outlined",sx:Z(c({},a),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{Q(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)(_.CallEnd,{sx:{visibility:"hidden"}})})})})]})})]},t.line)};function Mo({open:t,setOpen:o}){var v;let e=he(),{showToast:a}=we(),[l,d]=(0,re.useState)(!1),g=()=>{o(!1)},m=()=>{var h,x,u,y;d(!0);let f={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(x=(h=e.callData)==null?void 0:h.agent_id)!=null?x:"",process:(y=(u=e.callData)==null?void 0:u.process_name)!=null?y:""};ne.post(O.CONFERENCE_CALL_END_ALL,f).then(C=>{var w;a((w=C.data)==null?void 0:w.message,"success"),D.resetConferenceLines(),g()}).catch(C=>{var B,U,N,A;let w=((U=(B=C.response)==null?void 0:B.data)==null?void 0:U.detail)||((A=(N=C.response)==null?void 0:N.data)==null?void 0:A.message)||C.message||"An unknown error occurred";a(w,"error")}).finally(()=>{d(!1)})};return(0,re.useEffect)(()=>{var h,x,u,y;let f={line:1,status:(x=(h=e.callData)==null?void 0:h.status)!=null?x:"",type:"internal",phone:(y=(u=e.callData)==null?void 0:u.phone_number)!=null?y:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};D.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)(_.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)(ps,{each:f}))})]})})}),(0,s.jsx)(n.Box,{textAlign:"center",m:2,children:(0,s.jsxs)(n.Button,{variant:"outlined",color:"error",size:"large",onClick:m,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)(_.PhoneDisabled,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function Bo({open:t,setOpen:o}){var u,y,C,w,B,U,N,A,H,ee,Q,te;let[e]=le({onSuccess:S=>{console.log("res",S),o(!1)},onError:S=>{console.log("error",S)}}),a=he(),[l,d]=(0,re.useState)("process"),[g,{data:m}]=le(),[v,{data:f}]=le(),h=()=>{o(!1)},x=(S,J)=>{var oe,se,I,b,k,W,$,K,F,G,R,L,M,Y,V,j,pe,Ie,ye,Re,be,_e,ve,ke,Ae,Ne,Se,Pe,Oe,Ue,Me,Be,He;if(console.log(S,"data34"),J==="PROCESS"){let Ce={mobile_number:(se=(oe=a.callData)==null?void 0:oe.phone_number)!=null?se:"",userid:(b=(I=a.callData)==null?void 0:I.agent_id)!=null?b:"",type:"PROCESS",transfer_to:(k=S==null?void 0:S.process_name)!=null?k:"",callreferenceid:($=(W=a.callData)==null?void 0:W.convox_id)!=null?$:"",processid:String((F=(K=a.callData)==null?void 0:K.process_id)!=null?F:""),process_name:(R=(G=a.callData)==null?void 0:G.process_name)!=null?R:""};e(O.TRANSFER_CALL,Ce)}else if(J==="QUEUE"){let Ce={mobile_number:(M=(L=a.callData)==null?void 0:L.phone_number)!=null?M:"",userid:(V=(Y=a.callData)==null?void 0:Y.agent_id)!=null?V:"",type:"QUEUE",transfer_to:(j=S==null?void 0:S.queue_name)!=null?j:"",callreferenceid:(Ie=(pe=a.callData)==null?void 0:pe.convox_id)!=null?Ie:"",processid:String((Re=(ye=a.callData)==null?void 0:ye.process_id)!=null?Re:""),process_name:(_e=(be=a.callData)==null?void 0:be.process_name)!=null?_e:""};e(O.TRANSFER_CALL,Ce)}else if(J==="AGENT"){let Ce={mobile_number:(ke=(ve=a.callData)==null?void 0:ve.phone_number)!=null?ke:"",userid:(Ne=(Ae=a.callData)==null?void 0:Ae.agent_id)!=null?Ne:"",type:"AGENT",transfer_to:(Se=S==null?void 0:S.user_id)!=null?Se:"",callreferenceid:(Oe=(Pe=a.callData)==null?void 0:Pe.convox_id)!=null?Oe:"",processid:String((Me=(Ue=a.callData)==null?void 0:Ue.process_id)!=null?Me:""),process_name:(He=(Be=a.callData)==null?void 0:Be.process_name)!=null?He:""};e(O.TRANSFER_CALL,Ce)}};return(0,re.useEffect)(()=>{g(O.AGENTS_LIST,{status:"IDLE",active:!0}),v(O.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),console.log(m,"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:h,children:(0,s.jsx)(_.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:()=>d("process"),children:"Process"}),(0,s.jsx)(n.Button,{variant:l==="queues"?"contained":"outlined",onClick:()=>d("queues"),children:"Queues"}),(0,s.jsx)(n.Button,{variant:l==="agents"?"contained":"outlined",onClick:()=>d("agents"),children:"Agents"})]}),l==="process"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(u=f==null?void 0:f.data)!=null&&u.process&&((C=(y=f==null?void 0:f.data)==null?void 0:y.process)==null?void 0:C.length)>0?(B=(w=f==null?void 0:f.data)==null?void 0:w.process)==null?void 0:B.map((S,J)=>(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)(_.SupportAgent,{sx:{marginRight:"4px"}}),S.process_name]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{x(S,"PROCESS")},children:(0,s.jsx)(_.Call,{})})]},J)):(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&&((A=(N=f==null?void 0:f.data)==null?void 0:N.queue)==null?void 0:A.length)>0?(ee=(H=f==null?void 0:f.data)==null?void 0:H.queue)==null?void 0:ee.map((S,J)=>{var oe,se,I,b,k,W;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)(_.SupportAgent,{sx:{marginRight:"4px"}}),S.queue_name,(I=(se=(oe=f==null?void 0:f.data)==null?void 0:oe.process)==null?void 0:se.find($=>$.process_id===S.process_id))!=null&&I.process_name?(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((W=(k=(b=f==null?void 0:f.data)==null?void 0:b.process)==null?void 0:k.find($=>$.process_id===S.process_id))==null?void 0:W.process_name)+")"}):""]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{x(S,"QUEUE")},children:(0,s.jsx)(_.Call,{})})]},J)}):(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:m!=null&&m.data&&((Q=m==null?void 0:m.data)==null?void 0:Q.length)>0?(te=m==null?void 0:m.data)==null?void 0:te.map((S,J)=>(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)(_.SupportAgent,{sx:{marginRight:"4px"}}),S.name]}),(0,s.jsx)(n.IconButton,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{x(S,"AGENT")},children:(0,s.jsx)(_.Call,{})})]},J)):(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 Ho({open:t,setOpen:o,onSubmitDisposition:e}){var h,x;let[a,l]=(0,re.useState)({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),d=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],g=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],m=(u,y)=>{l(C=>Z(c({},C),{[u]:y}))},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.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:d,getOptionLabel:u=>u.label,onChange:(u,y)=>m("disposition",y),size:"small",renderInput:u=>(0,s.jsx)(n.TextField,Z(c({},u),{label:"Disposition",fullWidth:!0}))})}),(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.Autocomplete,{options:g,getOptionLabel:u=>u.label,value:a.followUp,onChange:(u,y)=>m("followUp",y),size:"small",renderInput:u=>(0,s.jsx)(n.TextField,Z(c({},u),{label:"Follow Up",fullWidth:!0}))})}),((x=(h=a==null?void 0:a.followUp)==null?void 0:h.label)==null?void 0:x.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:u=>m("callbackDate",u.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:u=>m("callbackHrs",u.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:u=>m("callbackMins",u.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 $o({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)(_.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 zo({onDataChange:t}){var Ze,et,tt,ot,st,nt,at,it,lt,rt,ct,dt,pt,ut,gt,ft,mt,xt,Ct,ht,yt,bt,vt,St,Tt,Et,Lt,Dt,wt,It,Rt,_t,kt,At,Nt,Pt,Ot,Ut,Mt,Bt,Ht,$t,zt,qt,Wt,Ft,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;let o=(0,p.useTheme)(),e=he(),{disabled:a,enabled:l,outlined:d}=Fe({disabled:((Ze=e.sdkConfig)==null?void 0:Ze.disabled)||{},enabled:((et=e.sdkConfig)==null?void 0:et.enabled)||{},outlined:((tt=e.sdkConfig)==null?void 0:tt.outlined)||{}}),g=(0,q.useRef)(null),[m,v]=(0,q.useState)(null),[f,h]=(0,q.useState)(!0),[x,u]=(0,q.useState)(null),[y,C]=(0,q.useState)(null),[w,B]=(0,q.useState)(!1),[U,N]=(0,q.useState)(!1),[A,H]=(0,q.useState)(!1),[ee,Q]=(0,q.useState)(!1),[te,S]=(0,q.useState)(!1),[J,oe]=(0,q.useState)(""),[se,I]=(0,q.useState)(0),{position:b,isDragging:k,dragRef:W,handleMouseDown:$,handleTouchStart:K}=Je(e.controlPanelPosition,i=>D.setControlPanelPosition(i)),{position:F,isDragging:G,dragRef:R,handleMouseDown:L,handleTouchStart:M}=Je(e.iframePosition,i=>D.setIframePosition(i)),[Y,{data:V}]=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?Q(!0):(D.setProcess(i==null?void 0:i.data[0]),Q(!1))},onError:()=>{Q(!1)}}),[j,{isLoading:pe}]=le(),[Ie,{isLoading:ye}]=le({onSuccess:()=>{D.setHolding(!e.isHolding)},onError:i=>{console.log("error",i)}}),[Re,{isLoading:be}]=le({onSuccess:()=>{D.setMuted(!e.isMuted)},onError:i=>{console.log("error",i)}}),[_e,{isLoading:ve}]=le(),[ke,{isLoading:Ae}]=le(),[Ne,{isLoading:Se}]=le(),Pe=(0,q.useCallback)(i=>{let T=Math.floor(i/60),X=i%60;return`${T.toString().padStart(2,"0")}:${X.toString().padStart(2,"0")}`},[]),Oe=()=>{v(null)},Ue=i=>{h(!0),C(i.currentTarget),D.setStatus("dial")},Me=()=>{e.status!=="on call"&&D.setStatus("idle"),C(null)},Be=i=>{u(i.currentTarget)},He=()=>{u(null)},Ce=()=>{let i={action:"READYAGENT",userId:e.agentId};_e(O.READY_AGENT,i)},Qe=i=>{u(null);let T={action:"AGENTBREAK",break_type:i,userId:e.agentId};ke(O.UPDATE_AGENT_BREAK,T)},Ko=i=>{if(i.length!==10)alert("Invalid phone number");else if(/^\d+$/.test(i)){let T={action:"CALL",phone_number:i,userId:e.agentId};j(O.CLICK_TO_CALL,T)}},Go=()=>{let i={action:e.isHolding?"UNHOLD":"HOLD",userId:e.agentId};Ie(O.HOLD_CALL,i)},Yo=()=>{let i={action:e.isMuted?"UNMUTE":"MUTE",userId:e.agentId};Re(O.MUTE_CALL,i)},jo=i=>{var X,ce,de,ue,ge,Te,Ee,ho,yo,bo,vo,So,To,Eo,Lo,Do;console.log("data",i);let T={action:"ENDCALL",userId:e.agentId,processid:(de=(ce=(X=e.process)==null?void 0:X.process_id)==null?void 0:ce.toString())!=null?de:"",process_name:(ge=(ue=e.process)==null?void 0:ue.process_name)!=null?ge:"",callreferenceid:(Ee=(Te=e.callData)==null?void 0:Te.convox_id)!=null?Ee:"",mobile_number:(yo=(ho=e.callData)==null?void 0:ho.phone_number)!=null?yo:"",disposition:(vo=(bo=i==null?void 0:i.disposition)==null?void 0:bo.value)!=null?vo:"",set_followUp:(To=(So=i==null?void 0:i.followUp)==null?void 0:So.value)!=null?To:"",callback_date:(Eo=i==null?void 0:i.callbackDate)!=null?Eo:"",callback_hrs:(Lo=i==null?void 0:i.callbackHrs)!=null?Lo:"",callback_mins:(Do=i==null?void 0:i.callbackMins)!=null?Do:"",endcall_type:"CLOSE"};oe(""),Ne(O.END_CALL,T),D.endCall(),H(!1)};return(0,q.useEffect)(()=>{let i;return e.callData.status&&e.callData.status==="ONCALL"?i=setInterval(()=>{let T=Math.floor((Date.now()-e.callStartTime)/1e3);I(T)},1e3):I(0),()=>{i&&clearInterval(i)}},[e.callData.status]),(0,q.useEffect)(()=>{t&&t(e.callData)},[e.callData,t]),(0,q.useEffect)(()=>{e.agentId?Y(O.PROCESS_LIST,{userId:e.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[e.agentId]),(0,q.useEffect)(()=>(e.agentId&&(g.current=new WebSocket(`${_o.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),D.updateCallData(T),T.status==="ONCALL"&&D.startCall(),T.status==="WRAPUP"&&D.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,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p.Fade,{in:!0,timeout:300,children:(0,r.jsx)(p.Paper,{ref:W,elevation:k?4:1,sx:{position:"fixed",left:b.x,top:b.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,r.jsxs)(p.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsxs)(p.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,r.jsxs)(p.IconButton,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:$,onTouchStart:K,children:[(0,r.jsx)(E.DragIndicator,{})," "]}),(0,r.jsx)(p.Box,{sx:{marginRight:"10px"},children:(0,r.jsx)(p.Tooltip,{title:"Dial",children:(0,r.jsx)(p.IconButton,{size:"small",onClick:i=>{var T,X,ce,de,ue,ge,Te,Ee;((X=(T=e.callData)==null?void 0:T.status)==null?void 0:X.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"&&((Ee=(Te=e.callData)==null?void 0:Te.status)==null?void 0:Ee.toUpperCase())!=="WRAPUP"&&Ue(i)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:(0,r.jsx)(E.WifiCalling3,{sx:{color:((st=(ot=e.callData)==null?void 0:ot.status)==null?void 0:st.toUpperCase())==="ONCALL"||((at=(nt=e.callData)==null?void 0:nt.status)==null?void 0:at.toUpperCase())==="BREAK"||((lt=(it=e.callData)==null?void 0:it.status)==null?void 0:lt.toUpperCase())==="RINGING"||((ct=(rt=e.callData)==null?void 0:rt.status)==null?void 0:ct.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),(0,r.jsx)(p.Typography,{sx:{color:"success.main",width:"40px",marginRight:"10px"},children:Pe(se)}),Ae||ve?(0,r.jsx)(p.Box,{sx:{fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,r.jsx)(p.CircularProgress,{size:"20px"})}):(0,r.jsx)(p.Typography,{variant:"body2",sx:{fontWeight:"bold",textAlign:"right"},children:(ut=(pt=(dt=e.callData)==null?void 0:dt.status)==null?void 0:pt.toUpperCase())!=null?ut:"N/A"}),(0,r.jsx)(p.Box,{onClick:Be,sx:{display:"flex",alignItems:"center",margin:"6px",cursor:"pointer"},children:(0,r.jsx)(E.ArrowDropDown,{})})]}),(0,r.jsxs)(p.Box,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[(0,r.jsx)(p.Tooltip,{title:"Agent Ready",children:(0,r.jsx)(p.Button,{variant:((ft=(gt=e.callData)==null?void 0:gt.status)==null?void 0:ft.toUpperCase())==="BREAK"||((xt=(mt=e.callData)==null?void 0:mt.status)==null?void 0:xt.toUpperCase())==="MISSED"?"outlined":"contained",onClick:i=>{var T,X,ce,de;(((X=(T=e.callData)==null?void 0:T.status)==null?void 0:X.toUpperCase())==="BREAK"||((de=(ce=e.callData)==null?void 0:ce.status)==null?void 0:de.toUpperCase())==="MISSED")&&(i.stopPropagation(),Ce())},classes:{root:((ht=(Ct=e.callData)==null?void 0:Ct.status)==null?void 0:ht.toUpperCase())==="BREAK"||((bt=(yt=e.callData)==null?void 0:yt.status)==null?void 0:bt.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:c({},((St=(vt=e.callData)==null?void 0:vt.status)==null?void 0:St.toUpperCase())==="BREAK"||((Et=(Tt=e.callData)==null?void 0:Tt.status)==null?void 0:Et.toUpperCase())==="MISSED"?d:l),disabled:ve,children:(0,r.jsx)(E.SupportAgent,{})})}),(0,r.jsx)(p.Tooltip,{title:e.isHolding?"Resume":"Hold",children:(0,r.jsx)(p.Button,{variant:e.isHolding&&((Dt=(Lt=e.callData)==null?void 0:Lt.status)==null?void 0:Dt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),Go()},sx:e.isHolding&&((It=(wt=e.callData)==null?void 0:wt.status)==null?void 0:It.toUpperCase())==="ONCALL"?c({},l):((_t=(Rt=e.callData)==null?void 0:Rt.status)==null?void 0:_t.toUpperCase())==="ONCALL"?c({},d):c({},a),disabled:((At=(kt=e.callData)==null?void 0:kt.status)==null?void 0:At.toUpperCase())!=="ONCALL"&&!e.isHolding||ye,children:ye?(0,r.jsx)(p.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isHolding?(0,r.jsx)(E.PlayArrow,{}):(0,r.jsx)(E.Pause,{})})}),(0,r.jsx)(p.Tooltip,{title:e.isMuted?"Unmute":"Mute",children:(0,r.jsx)(p.Button,{variant:e.isMuted&&((Pt=(Nt=e.callData)==null?void 0:Nt.status)==null?void 0:Pt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),Yo()},sx:e.isMuted&&((Ut=(Ot=e.callData)==null?void 0:Ot.status)==null?void 0:Ut.toUpperCase())==="ONCALL"?c({},l):((Bt=(Mt=e.callData)==null?void 0:Mt.status)==null?void 0:Bt.toUpperCase())==="ONCALL"?c({},d):c({},a),disabled:(($t=(Ht=e.callData)==null?void 0:Ht.status)==null?void 0:$t.toUpperCase())!=="ONCALL"&&!e.isMuted||be,children:be?(0,r.jsx)(p.CircularProgress,{size:"20px",sx:{color:o.palette.primary.main}}):e.isMuted?(0,r.jsx)(E.MicOff,{}):(0,r.jsx)(E.Mic,{})})}),((zt=e.sdkConfig)==null?void 0:zt.showTransferButton)&&(0,r.jsx)(p.Tooltip,{title:"Transfer Call",children:(0,r.jsx)(p.Button,{variant:U?"contained":"outlined",onClick:i=>{var T,X;((X=(T=e.callData)==null?void 0:T.status)==null?void 0:X.toUpperCase())==="ONCALL"&&(i.stopPropagation(),N(!0))},sx:U?c({},l):((Wt=(qt=e.callData)==null?void 0:qt.status)==null?void 0:Wt.toUpperCase())==="ONCALL"?c({},d):c({},a),disabled:((Kt=(Ft=e.callData)==null?void 0:Ft.status)==null?void 0:Kt.toUpperCase())!=="ONCALL",children:(0,r.jsx)(E.TransferWithinAStation,{})})}),((Gt=e.sdkConfig)==null?void 0:Gt.showConferenceButton)&&(0,r.jsx)(p.Tooltip,{title:"Conference Call",children:(0,r.jsx)(p.Button,{variant:w?"contained":"outlined",onClick:i=>{var T,X;((X=(T=e.callData)==null?void 0:T.status)==null?void 0:X.toUpperCase())==="ONCALL"&&(i.stopPropagation(),B(!0))},sx:w?c({},l):((jt=(Yt=e.callData)==null?void 0:Yt.status)==null?void 0:jt.toUpperCase())==="ONCALL"?c({},d):c({},a),disabled:((Jt=(Xt=e.callData)==null?void 0:Xt.status)==null?void 0:Jt.toUpperCase())!=="ONCALL",children:(0,r.jsx)(E.Group,{})})}),((Vt=e.sdkConfig)==null?void 0:Vt.showEndCallButton)&&(0,r.jsx)(p.Tooltip,{title:"End Call",children:(0,r.jsx)(p.Button,{variant:((Zt=(Qt=e.callData)==null?void 0:Qt.status)==null?void 0:Zt.toUpperCase())==="ONCALL"||((to=(eo=e.callData)==null?void 0:eo.status)==null?void 0:to.toUpperCase())==="RINGING"||((so=(oo=e.callData)==null?void 0:oo.status)==null?void 0:so.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:i=>{var T,X,ce,de,ue,ge;(((X=(T=e.callData)==null?void 0:T.status)==null?void 0:X.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(),H(!0))},sx:((ao=(no=e.callData)==null?void 0:no.status)==null?void 0:ao.toUpperCase())==="ONCALL"||((lo=(io=e.callData)==null?void 0:io.status)==null?void 0:lo.toUpperCase())==="RINGING"||((co=(ro=e.callData)==null?void 0:ro.status)==null?void 0:co.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:((uo=(po=e.callData)==null?void 0:po.status)==null?void 0:uo.toUpperCase())!=="ONCALL"&&((fo=(go=e.callData)==null?void 0:go.status)==null?void 0:fo.toUpperCase())!=="RINGING"&&((xo=(mo=e.callData)==null?void 0:mo.status)==null?void 0:xo.toUpperCase())!=="WRAPUP"||Se,children:Se?(0,r.jsx)(p.CircularProgress,{size:"20px",color:"error"}):(0,r.jsx)(E.CallEnd,{})})})]})]})})}),(0,r.jsx)(p.Fade,{in:!0,timeout:300,children:(0,r.jsxs)(p.Paper,{ref:R,elevation:G?4:1,sx:{position:"fixed",left:F.x,top:F.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,r.jsxs)(p.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll"},onMouseDown:L,onTouchStart:M,children:[(0,r.jsx)(E.DragIndicator,{sx:{transform:"rotate(90deg)"}})," ",(0,r.jsx)(p.IconButton,{onClick:()=>h(!1),children:(0,r.jsx)(E.Close,{})})]}),(0,r.jsx)("iframe",{src:`https://${$e}/ConVoxCCS/iframe?agent_id=${e.agentId}&process_id=${(Co=e.process)==null?void 0:Co.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay",style:{border:"none"}})]})}),(0,r.jsx)(p.Menu,{anchorEl:y,open:!!y,onClose:Me,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,r.jsxs)(p.Box,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[(0,r.jsx)(p.TextField,{size:"small",value:J,placeholder:"Enter Mobile No.",onChange:i=>{oe(i.target.value)}}),(0,r.jsx)(p.IconButton,{color:"info",onClick:()=>{Ko(J)},children:pe?(0,r.jsx)(p.CircularProgress,{size:"20px",sx:{color:o.palette.success.main}}):(0,r.jsx)(E.Phone,{color:"success"})})]})}),(0,r.jsxs)(p.Menu,{anchorEl:x,open:!!x,onClose:He,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:[(0,r.jsx)(p.MenuItem,{onClick:()=>Qe("Lunch"),children:"- Lunch"}),(0,r.jsx)(p.MenuItem,{onClick:()=>Qe("Tea"),children:"- Tea"})]}),(0,r.jsx)(p.Menu,{anchorEl:m,open:!!m,onClose:Oe,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,r.jsxs)(p.Box,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[(0,r.jsx)(p.Chip,{icon:(0,r.jsx)(E.Layers,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),(0,r.jsx)(p.Chip,{icon:(0,r.jsx)(E.Pending,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),(0,r.jsx)(p.Chip,{icon:(0,r.jsx)(E.Upcoming,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!w&&(0,r.jsx)(Mo,{open:w,setOpen:B}),!!U&&(0,r.jsx)(Bo,{open:U,setOpen:N}),!!A&&(0,r.jsx)(Ho,{open:A,setOpen:H,onSubmitDisposition:jo}),!!te&&(0,r.jsx)($o,{open:te,setOpen:S})]})}var Wo=require("react/jsx-runtime"),qo=({children:t})=>(0,Wo.jsx)(Oo,{children:t});var Ve=require("react/jsx-runtime");function Fo({onDataChange:t}){return(0,Ve.jsx)(qo,{children:(0,Ve.jsx)(zo,{onDataChange:t})})}function us({apiKey:t,tenantId:o,agentId:e,sdkConfig:a}){D.initialize(t,e,a),Ye.init({apiKey:t,tenantId:o,agentId:e,baseUrl:P}).then(l=>{console.log(l?"SDK initialized successfully":"SDK initialization failed")})}0&&(module.exports={CallControlPanel,initSDK,useEndCall,useLogout});
|
|
1
|
+
"use strict";var Wo=Object.create;var Ee=Object.defineProperty,Go=Object.defineProperties,Ko=Object.getOwnPropertyDescriptor,jo=Object.getOwnPropertyDescriptors,Yo=Object.getOwnPropertyNames,vo=Object.getOwnPropertySymbols,Xo=Object.getPrototypeOf,So=Object.prototype.hasOwnProperty,Jo=Object.prototype.propertyIsEnumerable;var Ge=(e,t,a)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,d=(e,t)=>{for(var a in t||(t={}))So.call(t,a)&&Ge(e,a,t[a]);if(vo)for(var a of vo(t))Jo.call(t,a)&&Ge(e,a,t[a]);return e},Z=(e,t)=>Go(e,jo(t));var Vo=(e,t)=>{for(var a in t)Ee(e,a,{get:t[a],enumerable:!0})},Eo=(e,t,a,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Yo(t))!So.call(e,r)&&r!==a&&Ee(e,r,{get:()=>t[r],enumerable:!(l=Ko(t,r))||l.enumerable});return e};var Qo=(e,t,a)=>(a=e!=null?Wo(Xo(e)):{},Eo(t||!e||!e.__esModule?Ee(a,"default",{value:e,enumerable:!0}):a,e)),Zo=e=>Eo(Ee({},"__esModule",{value:!0}),e);var oe=(e,t,a)=>Ge(e,typeof t!="symbol"?t+"":t,a);var rs={};Vo(rs,{CallControlPanel:()=>Ho,initSDK:()=>ls,useClickToCall:()=>Ro,useEndCall:()=>Io,useLogout:()=>Do});module.exports=Zo(rs);var Ke=class{constructor(){oe(this,"config",null);oe(this,"ticketId",null);oe(this,"baseUrl","");oe(this,"eventQueue",[]);oe(this,"isOnline",!0);oe(this,"retryQueue",[]);oe(this,"flushTimer",null)}async init(t){this.config=d({autoTrack:!0,retryAttempts:3,queueSize:100,flushInterval:5e3},t),this.baseUrl=t.baseUrl||(typeof window!="undefined"?window.location.origin:""),this.setupNetworkDetection();let a=await this.createTicket();return this.startPeriodicFlush(),console.log("EventTracker SDK initialized successfully"),a}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 t=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(!t.ok)throw new Error(`Failed to initialize: ${t.status} ${t.statusText}`);let a=await t.json();return this.ticketId=a.ticketId,this.config.autoTrack&&this.setupAutoTracking(),this.ticketId}catch(t){throw console.error("EventTracker initialization failed:",t),t}}async logEvent(t,a){if(!this.config||!this.ticketId){console.warn("EventTracker not initialized, skipping event:",t);return}let l={eventType:t,eventData:a,timestamp:Date.now()};if(this.eventQueue.push(l),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift(),this.isOnline)try{await this.sendEvent(l)}catch(r){console.warn("Failed to send event, will retry later:",r)}}async sendEvent(t){if(!(!this.config||!this.ticketId))try{let a=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:t.eventType,eventData:t.eventData})});if(!a.ok)throw new Error(`Failed to log event: ${a.status} ${a.statusText}`);let l=this.eventQueue.findIndex(r=>r.timestamp===t.timestamp);l>-1&&this.eventQueue.splice(l,1)}catch(a){console.error("Event logging failed:",a),this.retryQueue.push(()=>this.sendEvent(t))}}async closeTicket(){if(!this.config||!this.ticketId)throw new Error("EventTracker not initialized");await this.flush();try{let t=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(!t.ok)throw new Error(`Failed to close ticket: ${t.status} ${t.statusText}`);this.ticketId=null,this.stopPeriodicFlush(),console.log("Ticket closed successfully")}catch(t){throw console.error("Ticket close failed:",t),t}}async flush(){if(!this.isOnline||this.eventQueue.length===0)return;let t=[...this.eventQueue];for(let l of t)await this.sendEvent(l);let a=[...this.retryQueue];this.retryQueue=[];for(let l of a)try{await l()}catch(r){console.error("Retry failed:",r)}}async makeRequest(t,a){var o;let l=`${this.baseUrl}${t}`,r=((o=this.config)==null?void 0:o.retryAttempts)||3;for(let g=1;g<=r;g++)try{return await fetch(l,a)}catch(y){if(g===r)throw y;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 l;if(typeof window=="undefined"||!((l=this.config)!=null&&l.autoTrack))return;let t=this.config.autoTrack===!0?{}:this.config.autoTrack;if(t.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(r=>console.warn("Failed to track page visit:",r)),t.clicks!==!1&&document.addEventListener("click",r=>{var g;let o=r.target;(o.tagName==="BUTTON"||o.tagName==="A"||o.onclick||o.getAttribute("role")==="button"||o instanceof HTMLButtonElement&&o.type==="button")&&this.logEvent("click",{element:o.tagName,text:(g=o.textContent)==null?void 0:g.trim().substring(0,100),href:o.getAttribute("href"),id:o.id,className:o.className,role:o.getAttribute("role"),position:{x:r.clientX,y:r.clientY},timestamp:new Date().toISOString()}).catch(y=>console.warn("Failed to track click:",y))}),t.forms!==!1&&document.addEventListener("submit",r=>{let o=r.target,g=new FormData(o),y={};g.forEach((S,f)=>{y[f]=S.toString()}),this.logEvent("formSubmission",{formId:o.id,action:o.action,method:o.method,fields:Object.keys(y),fieldCount:Object.keys(y).length,timestamp:new Date().toISOString()}).catch(S=>console.warn("Failed to track form submission:",S))}),t.inputs!==!1){let r;document.addEventListener("input",o=>{let g=o.target;(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.tagName==="SELECT")&&(clearTimeout(r),r=setTimeout(()=>{var y;this.logEvent("fieldChange",{element:g.tagName,type:g.getAttribute("type"),name:g.getAttribute("name"),id:g.id,valueLength:((y=g.value)==null?void 0:y.length)||0,timestamp:new Date().toISOString()}).catch(S=>console.warn("Failed to track field change:",S))},1e3))})}let a=Date.now();window.addEventListener("beforeunload",()=>{let r=Date.now()-a;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:r,timestamp:new Date().toISOString()}),this.ticketId&&navigator.sendBeacon(`${this.baseUrl}/api/v1/et/close`,JSON.stringify({ticketId:this.ticketId}))}),t.visibility!==!1&&document.addEventListener("visibilitychange",()=>{this.logEvent("visibilityChange",{hidden:document.hidden,visibilityState:document.visibilityState,timestamp:new Date().toISOString()})}),t.errors!==!1&&(window.addEventListener("error",r=>{this.logEvent("jsError",{message:r.message,filename:r.filename,lineno:r.lineno,colno:r.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",r=>{var o;this.logEvent("unhandledRejection",{reason:(o=r.reason)==null?void 0:o.toString(),timestamp:new Date().toISOString()})})),t.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let r=window.performance.navigation,o=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:o.navigationStart,loadTime:o.loadEventEnd-o.navigationStart,domReady:o.domContentLoadedEventEnd-o.navigationStart,renderTime:o.loadEventEnd-o.domContentLoadedEventEnd,navigationType:r.type,redirectCount:r.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 a;this.flushTimer&&clearInterval(this.flushTimer);let t=((a=this.config)==null?void 0:a.flushInterval)||5e3;this.flushTimer=setInterval(()=>{this.flush()},t)}stopPeriodicFlush(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}},je=new Ke;typeof window!="undefined"&&(window.EventTracker=je);var Ye=class{constructor(){oe(this,"state");oe(this,"listeners",[]);oe(this,"STORAGE_KEY","call-control-sdk-state");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{apiKey:null,process:null,agentId:"",isInitialized:!1,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 t=localStorage.getItem(this.STORAGE_KEY);if(t){let a=JSON.parse(t);this.state=Z(d({},this.state),{apiKey:a.apiKey||"",agentId:a.agentId||"",process:a.process||null,isInitialized:a.isInitialized||!1,isHolding:a.isHolding||!1,isMuted:a.isMuted||!1,status:a.status||"idle",callStartTime:a.callStartTime||null,controlPanelPosition:a.controlPanelPosition||{x:10,y:10},iframePosition:a.iframePosition||{x:10,y:80},callData:a.callData||{mobileNumber:"",callReferenceId:"",agentLoginId:""},conferenceLine:a.conferenceLine&&Array.isArray(a.conferenceLine)&&a.conferenceLine.length>0?a.conferenceLine:this.state.conferenceLine})}}catch(t){console.warn("Failed to load SDK state from localStorage:",t)}}saveToStorage(){try{let t={apiKey:this.state.apiKey,agentId:this.state.agentId,process:this.state.process,isInitialized:this.state.isInitialized,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(t))}catch(t){console.warn("Failed to save SDK state to localStorage:",t)}}notifyListeners(){this.listeners.forEach(t=>t())}initialize(t,a){if(!t||typeof t!="string"||t.trim().length===0)throw new Error("API key not available");this.state.apiKey=t,this.state.agentId=a,this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return d({},this.state)}subscribe(t){return this.listeners.push(t),()=>{let a=this.listeners.indexOf(t);a>-1&&this.listeners.splice(a,1)}}setHolding(t){this.state.isHolding=t,this.saveToStorage(),this.notifyListeners()}setMuted(t){this.state.isMuted=t,this.saveToStorage(),this.notifyListeners()}setStatus(t){this.state.status=t,this.saveToStorage(),this.notifyListeners()}setProcess(t){this.state.process=t,this.saveToStorage(),this.notifyListeners()}setControlPanelPosition(t){this.state.controlPanelPosition=t,this.saveToStorage(),this.notifyListeners()}setIframePosition(t){this.state.iframePosition=t,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(t){this.state.callData=d(d({},this.state.callData),t),this.saveToStorage(),this.notifyListeners()}setConferenceLine(t){var l;(!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 a=(l=this.state.conferenceLine)==null?void 0:l.map(r=>r.line===t.line?t:r);this.state.conferenceLine=a,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(t){console.warn("Failed to clear localStorage:",t)}}debugStorage(){try{let t=localStorage.getItem(this.STORAGE_KEY);console.log("Current localStorage data:",t),t&&console.log("Parsed localStorage data:",JSON.parse(t)),console.log("Current state:",this.state)}catch(t){console.error("Error debugging storage:",t)}}getConferenceLines(){return this.state.conferenceLine||[]}},D=new Ye;var de=require("react");var q="http://172.29.16.1:8095",es="ws://172.29.16.1:8095",j={v1:"/api/v1"},M={LOGIN:`${q}${j.v1}/cti/login?provider=convox`,READY_AGENT:`${q}${j.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${q}${j.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${q}${j.v1}/cti/calls?provider=convox`,HOLD_CALL:`${q}${j.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${q}${j.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${q}${j.v1}/cti/unmute-call?provider=convox`,END_CALL:`${q}${j.v1}/cti/calls/end?provider=convox`,LOGOUT:`${q}${j.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${q}${j.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${q}${j.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${q}${j.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${q}${j.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${q}${j.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${q}${j.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${q}${j.v1}/cti/users`,PROCESS_LIST:`${q}${j.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${q}${j.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${q}${j.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${q}${j.v1}/users/get_sentiment_analysis`},To={WS:`${es}${j.v1}/cti/ws`};var Lo=Qo(require("axios"));var ts="12345",Xe=Lo.default.create({baseURL:q,headers:{"Content-Type":"application/json",Authorization:ts},timeout:1e4});Xe.interceptors.request.use(e=>{let t="12345";return t&&e.headers&&(e.headers.Authorization=`Bearer ${t}`),e},e=>Promise.reject(e instanceof Error?e:new Error(String(e))));Xe.interceptors.response.use(e=>e,async e=>{var a;let t=e.config;return((a=e.response)==null?void 0:a.status)===401&&!t._retry&&(t._retry=!0),Promise.reject(e instanceof Error?e:new Error(String(e)))});var te=Xe;var os=()=>{let[e,t]=(0,de.useState)(!1),[a,l]=(0,de.useState)(!1),[r,o]=(0,de.useState)(!1),[g,y]=(0,de.useState)(null),[S,f]=(0,de.useState)(null);return{logout:(0,de.useCallback)(async()=>{var h;let m=JSON.parse((h=localStorage.getItem("call-control-sdk-state"))!=null?h:"");t(!0);let c={action:"LOGOUTUSER",userId:m.agentId||""};return te.post(M.LOGOUT,c).then(C=>(D.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),f(C==null?void 0:C.data),l(!0),C==null?void 0:C.data)).catch(C=>{var E;return o(!0),y(C),(E=C==null?void 0:C.response)==null?void 0:E.data}).finally(()=>{t(!1)})},[]),isLoading:e,isSuccess:a,isError:r,error:g,data:S}},Do=os;var ue=require("react");var Io=()=>{let[e,t]=(0,ue.useState)(!1),[a,l]=(0,ue.useState)(!1),[r,o]=(0,ue.useState)(!1),[g,y]=(0,ue.useState)(null),[S,f]=(0,ue.useState)(null);return{handleEndCall:(0,ue.useCallback)(async m=>{var C,E,B,U,P,_,$,ee,F,w,x,v,k,O,z;let c=JSON.parse((C=localStorage.getItem("call-control-sdk-state"))!=null?C:"");t(!0);let h={action:"ENDCALL",userId:c==null?void 0:c.agentId,processid:(U=(B=(E=c==null?void 0:c.process)==null?void 0:E.process_id)==null?void 0:B.toString())!=null?U:"",process_name:(_=(P=c==null?void 0:c.process)==null?void 0:P.process_name)!=null?_:"",callreferenceid:(ee=($=c==null?void 0:c.callData)==null?void 0:$.convox_id)!=null?ee:"",mobile_number:(w=(F=c==null?void 0:c.callData)==null?void 0:F.phone_number)!=null?w:"",disposition:(x=m==null?void 0:m.disposition)!=null?x:"RES",set_followUp:(v=m==null?void 0:m.followUp)!=null?v:"N",callback_date:(k=m==null?void 0:m.callbackDate)!=null?k:"",callback_hrs:(O=m==null?void 0:m.callbackHrs)!=null?O:"",callback_mins:(z=m==null?void 0:m.callbackMins)!=null?z:"",endcall_type:"CLOSE"};return te.post(M.END_CALL,h).then(T=>(D.endCall(),f(T==null?void 0:T.data),l(!0),T==null?void 0:T.data)).catch(T=>{var H;return o(!0),y(T),(H=T==null?void 0:T.response)==null?void 0:H.data}).finally(()=>{t(!1)})},[]),isLoading:e,isSuccess:a,isError:r,error:g,data:S}};var ge=require("react");var Ro=()=>{let[e,t]=(0,ge.useState)(!1),[a,l]=(0,ge.useState)(!1),[r,o]=(0,ge.useState)(!1),[g,y]=(0,ge.useState)(null),[S,f]=(0,ge.useState)(null);return{handleStartCall:(0,ge.useCallback)(async m=>{var h,C,E,B,U,P,_,$,ee;let c=JSON.parse((h=localStorage.getItem("call-control-sdk-state"))!=null?h:"");if(t(!0),((C=c==null?void 0:c.callData)==null?void 0:C.status)==="IDLE"){let F={action:"CALL",userId:c==null?void 0:c.agentId,phone_number:m==null?void 0:m.mobileNumber};return te.post(M.CLICK_TO_CALL,F).then(w=>(f(w==null?void 0:w.data),l(!0),w==null?void 0:w.data)).catch(w=>{var x;return o(!0),y(w),(x=w==null?void 0:w.response)==null?void 0:x.data}).finally(()=>{t(!1)})}else if(((E=c==null?void 0:c.callData)==null?void 0:E.status)==="ONCALL"){let F=(U=(B=c==null?void 0:c.conferenceLine)==null?void 0:B.filter(x=>x.line!==1))==null?void 0:U.find(x=>x.status==="IDLE"&&!(x!=null&&x.isCallStart)),w={action:"EXTERNAL_CONFERENCE",operation:`CALL${F.line}`,line_used:String(F.line),thirdparty_no:m==null?void 0:m.mobileNumber,userid:(_=(P=c.callData)==null?void 0:P.agent_id)!=null?_:"",process:(ee=($=c.callData)==null?void 0:$.process_name)!=null?ee:""};return te.post(M.CONFERENCE_CALL,w).then(x=>(f(x==null?void 0:x.data),l(!0),D.setConferenceLine(Z(d({},F),{isCallStart:!0,status:"ONCALL",phone:m==null?void 0:m.mobileNumber})),x==null?void 0:x.data)).catch(x=>{var v;return o(!0),y(x),(v=x==null?void 0:x.response)==null?void 0:v.data}).finally(()=>{t(!1)})}else alert("Agent is not ready")},[]),isLoading:e,isSuccess:a,isError:r,error:g,data:S}};var I=require("@mui/icons-material"),u=require("@mui/material"),Y=require("react");var se=require("react");function Je(e,t){let[a,l]=(0,se.useState)(e),[r,o]=(0,se.useState)(!1),g=(0,se.useRef)(),y=(0,se.useRef)({x:0,y:0}),S=(0,se.useRef)({x:0,y:0}),f=(0,se.useCallback)(h=>{let C=g.current;if(!C)return;let E=C.getBoundingClientRect(),B=window.innerWidth,U=window.innerHeight,P={x:Math.max(0,Math.min(h.x,B-E.width)),y:Math.max(0,Math.min(h.y,U-E.height))};l(P),t==null||t(P)},[t]),b=(0,se.useCallback)((h,C)=>{o(!0),y.current={x:h,y:C},S.current=a;let E=(_,$)=>{let ee=_-y.current.x,F=$-y.current.y;f({x:S.current.x+ee,y:S.current.y+F})},B=_=>{_.preventDefault(),E(_.clientX,_.clientY)},U=_=>{_.preventDefault();let $=_.touches[0];$&&E($.clientX,$.clientY)},P=()=>{o(!1),document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",P),document.removeEventListener("touchmove",U),document.removeEventListener("touchend",P)};document.addEventListener("mousemove",B),document.addEventListener("mouseup",P),document.addEventListener("touchmove",U,{passive:!1}),document.addEventListener("touchend",P)},[a,f]),m=(0,se.useCallback)(h=>{h.preventDefault(),b(h.clientX,h.clientY)},[b]),c=(0,se.useCallback)(h=>{h.preventDefault();let C=h.touches[0];C&&b(C.clientX,C.clientY)},[b]);return{position:a,isDragging:r,dragRef:g,handleMouseDown:m,handleTouchStart:c}}var $e=require("react");function xe(){let[e,t]=(0,$e.useState)(D.getState());return(0,$e.useEffect)(()=>D.subscribe(()=>{t(D.getState())}),[]),e}var qe=require("react");var fe=require("react"),ze=require("@mui/material"),Te=require("react/jsx-runtime"),_o=(0,fe.createContext)(void 0),Le=()=>{let e=(0,fe.useContext)(_o);if(!e)throw new Error("useToast must be used inside ToastProvider");return e},wo=({children:e})=>{let[t,a]=(0,fe.useState)(!1),[l,r]=(0,fe.useState)(""),[o,g]=(0,fe.useState)("info"),y=(S,f="info")=>{r(S),g(f),a(!0)};return(0,Te.jsxs)(_o.Provider,{value:{showToast:y},children:[e,(0,Te.jsx)(ze.Snackbar,{open:t,color:o,autoHideDuration:3e3,onClose:()=>a(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:(0,Te.jsx)(ze.Alert,{variant:"filled",severity:o,onClose:()=>a(!1),sx:{width:"100%"},children:l})})]})};var ss={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},as=(e,t)=>{if(t.type==="isLoading")return Z(d({},e),{isLoading:t.payload});if(t.type==="isSuccess")return Z(d({},e),{isSuccess:!0,data:t.payload});if(t.type==="isError")return Z(d({},e),{isError:!0,error:t.payload});if(t.type==="reset")return{isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null};throw Error("Unknown action.")};var ae=(e={})=>{let{onSuccess:t=null,onError:a=null}=e,{showToast:l}=Le(),[r,o]=(0,qe.useReducer)(as,ss);return[(0,qe.useCallback)((y,S,f={})=>{o({type:"isLoading",payload:!0}),te.post(y,S,f).then(b=>{var m,c;o({type:"isSuccess",payload:b.data}),t==null||t(b.data,S),console.log((m=b.data)==null?void 0:m.message,"res45"),l((c=b.data)==null?void 0:c.message,"success")}).catch(b=>{var c,h,C,E,B,U,P,_,$,ee,F,w;let m={status:(h=(c=b.response)==null?void 0:c.status)!=null?h:500,message:((E=(C=b.response)==null?void 0:C.data)==null?void 0:E.detail)||((U=(B=b.response)==null?void 0:B.data)==null?void 0:U.message)||b.message||"An unknown error occurred",data:(_=(P=b.response)==null?void 0:P.data)!=null?_:null,statusText:(ee=($=b.response)==null?void 0:$.statusText)!=null?ee:"",code:(F=b==null?void 0:b.code)!=null?F:"",name:(w=b==null?void 0:b.name)!=null?w:""};l(m.message,"error"),o({type:"isError",payload:m}),a==null||a(m,S)}).finally(()=>{o({type:"isLoading",payload:!1})})},[t,a,l]),r]};var A=require("@mui/icons-material"),n=require("@mui/material"),ne=require("react");var ko=require("@mui/material"),ns=()=>{let e=(0,ko.useTheme)();return{disabled:{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 ${e.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${e.palette.primary.light}`}},enabled:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${e.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${e.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${e.palette.primary.light}`}},outlined:{padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:e.palette.grey[200],boxShadow:`0px 2px 1px ${e.palette.primary.light}`,border:`0px solid ${e.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${e.palette.primary.main}`,border:`0px solid ${e.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${e.palette.primary.light}`}}}},Fe=ns;var s=require("react/jsx-runtime"),is=({each:e})=>{var w,x;let t=xe(),{showToast:a}=Le(),{disabled:l,enabled:r,outlined:o}=Fe(),g=(0,n.useTheme)(),[y,S]=(0,ne.useState)(!1),[f,b]=(0,ne.useState)(!1),[m,c]=(0,ne.useState)(!1),[h,C]=(0,ne.useState)(!1),[E,B]=(0,ne.useState)(!1),U=(v,k)=>{D.setConferenceLine(d(d({},v),k))},P=(v,k)=>{var T,H,K,W;let O=d(d({},v),k);S(!0);let z={action:"EXTERNAL_CONFERENCE",operation:`CALL${O.line}`,line_used:String(O.line),thirdparty_no:O.phone,userid:(H=(T=t.callData)==null?void 0:T.agent_id)!=null?H:"",process:(W=(K=t.callData)==null?void 0:K.process_name)!=null?W:""};te.post(M.CONFERENCE_CALL,z).then(N=>{var R;a((R=N.data)==null?void 0:R.message,"success"),D.setConferenceLine(d(d({},v),k))}).catch(N=>{var G,X,J,V;let R=((X=(G=N.response)==null?void 0:G.data)==null?void 0:X.detail)||((V=(J=N.response)==null?void 0:J.data)==null?void 0:V.message)||N.message||"An unknown error occurred";a(R,"error")}).finally(()=>{S(!1)})},_=(v,k)=>{var T,H,K,W;let O=d(d({},v),k);b(!0);let z={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(O.line),thirdparty_no:O.phone,userid:(H=(T=t.callData)==null?void 0:T.agent_id)!=null?H:"",process:(W=(K=t.callData)==null?void 0:K.process_name)!=null?W:""};te.post(M.CONFERENCE_CALL,z).then(N=>{var R;a((R=N.data)==null?void 0:R.message,"success"),D.setConferenceLine(d(d({},v),k))}).catch(N=>{var G,X,J,V;let R=((X=(G=N.response)==null?void 0:G.data)==null?void 0:X.detail)||((V=(J=N.response)==null?void 0:J.data)==null?void 0:V.message)||N.message||"An unknown error occurred";a(R,"error")}).finally(()=>{b(!1)})},$=(v,k,O)=>{var H,K,W,N;let z=d(d({},v),k);c(!0);let T={action:"EXTERNAL_CONFERENCE",operation:O,hold_channel_no:O==="HOLDUSER"?`hold${z.line}`:`unhold${z.line}`,userid:(K=(H=t.callData)==null?void 0:H.agent_id)!=null?K:"",process:(N=(W=t.callData)==null?void 0:W.process_name)!=null?N:""};te.post(M.CONFERENCE_CALL_HOLD_OR_UN_HOLD,T).then(R=>{var G;a((G=R.data)==null?void 0:G.message,"success"),D.setConferenceLine(d(d({},v),k))}).catch(R=>{var X,J,V,re;let G=((J=(X=R.response)==null?void 0:X.data)==null?void 0:J.detail)||((re=(V=R.response)==null?void 0:V.data)==null?void 0:re.message)||R.message||"An unknown error occurred";a(G,"error")}).finally(()=>{c(!1)})},ee=(v,k,O)=>{var H,K,W,N;let z=d(d({},v),k);C(!0);let T={action:"EXTERNAL_CONFERENCE",operation:O,channel_no:O==="MUTEUSER"?`mute${z.line}`:`play${z.line}`,userid:(K=(H=t.callData)==null?void 0:H.agent_id)!=null?K:"",thirdparty_no:z.phone,process:(N=(W=t.callData)==null?void 0:W.process_name)!=null?N:""};te.post(M.CONFERENCE_CALL_MUTE_OT_UN_MUTE,T).then(R=>{var G;a((G=R.data)==null?void 0:G.message,"success"),D.setConferenceLine(d(d({},v),k))}).catch(R=>{var X,J,V,re;let G=((J=(X=R.response)==null?void 0:X.data)==null?void 0:J.detail)||((re=(V=R.response)==null?void 0:V.data)==null?void 0:re.message)||R.message||"An unknown error occurred";a(G,"error")}).finally(()=>{C(!1)})},F=(v,k)=>{var T,H,K,W;let O=d(d({},v),k);B(!0);let z={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(O.line-1),user_type:`THIRDPARTY${O.line-1}`,thirdparty_no:O.phone,userid:(H=(T=t.callData)==null?void 0:T.agent_id)!=null?H:"",process:(W=(K=t.callData)==null?void 0:K.process_name)!=null?W:""};te.post(M.CONFERENCE_CALL_END,z).then(N=>{var R;a((R=N.data)==null?void 0:R.message,"success"),D.setConferenceLine(d(d({},v),k))}).catch(N=>{var G,X,J,V;let R=((X=(G=N.response)==null?void 0:G.data)==null?void 0:X.detail)||((V=(J=N.response)==null?void 0:J.data)==null?void 0:V.message)||N.message||"An unknown error occurred";a(R,"error")}).finally(()=>{B(!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 ",(w=e==null?void 0:e.line)!=null?w:"",". "]})}),(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:(x=e==null?void 0:e.status)!=null?x:""})}),(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:(e==null?void 0:e.line)===1?"Internal":"External"})})}),(0,s.jsx)(n.TableCell,{sx:{padding:"6px"},children:(0,s.jsx)(n.TextField,{size:"small",placeholder:"Phone Number",value:(e==null?void 0:e.phone)||"",disabled:(e==null?void 0:e.line)===1,onChange:v=>{U(e,{phone:v.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:e!=null&&e.isCallStart?"outlined":"contained",color:"success",sx:e!=null&&e.isCallStart?d({},l):Z(d({},r),{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(e,{isCallStart:!0,status:"ONCALL"})},disabled:(e==null?void 0:e.isCallStart)||y,children:y?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"success"}):(0,s.jsx)(A.Call,{sx:{color:e!=null&&e.isCallStart?"default":"#e7e7e7ff"}})})}),(0,s.jsx)(n.Tooltip,{title:"Merge Call",children:(0,s.jsx)(n.Button,{variant:e!=null&&e.isMergeCall?"contained":"outlined",sx:e!=null&&e.isMergeCall&&(e!=null&&e.isCallStart)?d({},l):e!=null&&e.isCallStart?d({},o):d({},l),onClick:()=>{_(e,{isMergeCall:!0,status:"ONCALL"})},disabled:!(e!=null&&e.isCallStart)||f,children:f?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:e!=null&&e.isMergeCall?"#e7e7e7ff":g.palette.primary.main}}):(0,s.jsx)(A.CallSplit,{})})}),(0,s.jsx)(n.Tooltip,{title:e.isHold?"Hold":"Un Hold",children:(0,s.jsx)(n.Button,{variant:e!=null&&e.isHold?"contained":"outlined",sx:e!=null&&e.isHold&&(e!=null&&e.isCallStart)?d({},l):e!=null&&e.isCallStart?d({},o):d({},l),onClick:()=>{e.isHold?$(e,{isHold:!1},"UNHOLDUSER"):$(e,{isHold:!0},"HOLDUSER")},disabled:!(e!=null&&e.isCallStart)||m,children:m?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:g.palette.primary.main}}):e.isHold?(0,s.jsx)(A.PlayArrow,{}):(0,s.jsx)(A.Pause,{})})}),(0,s.jsx)(n.Tooltip,{title:e.isMute?"Mute":"Un Mute",children:(0,s.jsx)(n.Button,{variant:e!=null&&e.isMute?"contained":"outlined",sx:e!=null&&e.isMute&&(e!=null&&e.isCallStart)?d({},l):e!=null&&e.isCallStart?d({},o):d({},l),onClick:()=>{e.isMute?ee(e,{isMute:!1},"PLAYUSER"):ee(e,{isMute:!0},"MUTEUSER")},disabled:!(e!=null&&e.isCallStart)||h,children:h?(0,s.jsx)(n.CircularProgress,{size:"20px",sx:{color:g.palette.primary.main}}):e.isMute?(0,s.jsx)(A.MicOff,{}):(0,s.jsx)(A.Mic,{})})}),(0,s.jsx)(n.Tooltip,{title:"End Call",children:(e==null?void 0:e.line)!==1?(0,s.jsx)(n.Button,{variant:e!=null&&e.isCallStart?"contained":"outlined",color:"error",sx:e!=null&&e.isCallStart?Z(d({},r),{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(d({},l),{minWidth:"60px !important"}),onClick:()=>{F(e,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(e!=null&&e.isCallStart)||E,children:E?(0,s.jsx)(n.CircularProgress,{size:"20px",color:"error"}):(0,s.jsx)(A.CallEnd,{})}):(0,s.jsx)(n.Button,{variant:e!=null&&e.isCallStart?"contained":"outlined",sx:Z(d({},l),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{F(e,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(e!=null&&e.isCallStart),children:(0,s.jsx)(n.Typography,{children:(0,s.jsx)(A.CallEnd,{sx:{visibility:"hidden"}})})})})]})})]},e.line)};function No({open:e,setOpen:t}){var S;let a=xe(),{showToast:l}=Le(),[r,o]=(0,ne.useState)(!1),g=()=>{t(!1)},y=()=>{var b,m,c,h;o(!0);let f={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(m=(b=a.callData)==null?void 0:b.agent_id)!=null?m:"",process:(h=(c=a.callData)==null?void 0:c.process_name)!=null?h:""};te.post(M.CONFERENCE_CALL_END_ALL,f).then(C=>{var E;l((E=C.data)==null?void 0:E.message,"success"),D.resetConferenceLines(),g()}).catch(C=>{var B,U,P,_;let E=((U=(B=C.response)==null?void 0:B.data)==null?void 0:U.detail)||((_=(P=C.response)==null?void 0:P.data)==null?void 0:_.message)||C.message||"An unknown error occurred";l(E,"error")}).finally(()=>{o(!1)})};return(0,ne.useEffect)(()=>{var b,m,c,h;let f={line:1,status:(m=(b=a.callData)==null?void 0:b.status)!=null?m:"",type:"internal",phone:(h=(c=a.callData)==null?void 0:c.phone_number)!=null?h:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};D.setConferenceLine(f)},[]),(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:e,"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=a==null?void 0:a.agentId)!=null?S:""," conference"]}),(0,s.jsx)(n.IconButton,{onClick:g,children:(0,s.jsx)(A.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:a==null?void 0:a.conferenceLine.map(f=>(0,s.jsx)(is,{each:f}))})]})})}),(0,s.jsx)(n.Box,{textAlign:"center",m:2,children:(0,s.jsxs)(n.Button,{variant:"outlined",color:"error",size:"large",onClick:y,disabled:r,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[r?(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)(A.PhoneDisabled,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function Ao({open:e,setOpen:t}){var c,h,C,E,B,U,P,_,$,ee,F,w;let[a]=ae({onSuccess:x=>{console.log("res",x),t(!1)},onError:x=>{console.log("error",x)}}),l=xe(),[r,o]=(0,ne.useState)("process"),[g,{data:y}]=ae(),[S,{data:f}]=ae(),b=()=>{t(!1)},m=(x,v)=>{var k,O,z,T,H,K,W,N,R,G,X,J,V,re,We,De,Ie,Re,ye,_e,Ce,we,he,ke,Ne,Ae,be,Pe,Oe,Me,Ue,Be,He;if(console.log(x,"data34"),v==="PROCESS"){let me={mobile_number:(O=(k=l.callData)==null?void 0:k.phone_number)!=null?O:"",userid:(T=(z=l.callData)==null?void 0:z.agent_id)!=null?T:"",type:"PROCESS",transfer_to:(H=x==null?void 0:x.process_name)!=null?H:"",callreferenceid:(W=(K=l.callData)==null?void 0:K.convox_id)!=null?W:"",processid:String((R=(N=l.callData)==null?void 0:N.process_id)!=null?R:""),process_name:(X=(G=l.callData)==null?void 0:G.process_name)!=null?X:""};a(M.TRANSFER_CALL,me)}else if(v==="QUEUE"){let me={mobile_number:(V=(J=l.callData)==null?void 0:J.phone_number)!=null?V:"",userid:(We=(re=l.callData)==null?void 0:re.agent_id)!=null?We:"",type:"QUEUE",transfer_to:(De=x==null?void 0:x.queue_name)!=null?De:"",callreferenceid:(Re=(Ie=l.callData)==null?void 0:Ie.convox_id)!=null?Re:"",processid:String((_e=(ye=l.callData)==null?void 0:ye.process_id)!=null?_e:""),process_name:(we=(Ce=l.callData)==null?void 0:Ce.process_name)!=null?we:""};a(M.TRANSFER_CALL,me)}else if(v==="AGENT"){let me={mobile_number:(ke=(he=l.callData)==null?void 0:he.phone_number)!=null?ke:"",userid:(Ae=(Ne=l.callData)==null?void 0:Ne.agent_id)!=null?Ae:"",type:"AGENT",transfer_to:(be=x==null?void 0:x.user_id)!=null?be:"",callreferenceid:(Oe=(Pe=l.callData)==null?void 0:Pe.convox_id)!=null?Oe:"",processid:String((Ue=(Me=l.callData)==null?void 0:Me.process_id)!=null?Ue:""),process_name:(He=(Be=l.callData)==null?void 0:Be.process_name)!=null?He:""};a(M.TRANSFER_CALL,me)}};return(0,ne.useEffect)(()=>{g(M.AGENTS_LIST,{status:"IDLE",active:!0}),S(M.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),console.log(y,"idleAgentsList"),(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:e,"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)(A.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:r==="process"?"contained":"outlined",onClick:()=>o("process"),children:"Process"}),(0,s.jsx)(n.Button,{variant:r==="queues"?"contained":"outlined",onClick:()=>o("queues"),children:"Queues"}),(0,s.jsx)(n.Button,{variant:r==="agents"?"contained":"outlined",onClick:()=>o("agents"),children:"Agents"})]}),r==="process"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(c=f==null?void 0:f.data)!=null&&c.process&&((C=(h=f==null?void 0:f.data)==null?void 0:h.process)==null?void 0:C.length)>0?(B=(E=f==null?void 0:f.data)==null?void 0:E.process)==null?void 0:B.map((x,v)=>(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)(A.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)(A.Call,{})})]},v)):(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"})}),r==="queues"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:(U=f==null?void 0:f.data)!=null&&U.queue&&((_=(P=f==null?void 0:f.data)==null?void 0:P.queue)==null?void 0:_.length)>0?(ee=($=f==null?void 0:f.data)==null?void 0:$.queue)==null?void 0:ee.map((x,v)=>{var k,O,z,T,H,K;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)(A.SupportAgent,{sx:{marginRight:"4px"}}),x.queue_name,(z=(O=(k=f==null?void 0:f.data)==null?void 0:k.process)==null?void 0:O.find(W=>W.process_id===x.process_id))!=null&&z.process_name?(0,s.jsx)(n.Typography,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((K=(H=(T=f==null?void 0:f.data)==null?void 0:T.process)==null?void 0:H.find(W=>W.process_id===x.process_id))==null?void 0:K.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)(A.Call,{})})]},v)}):(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"})}),r==="agents"&&(0,s.jsx)(n.Box,{sx:{display:"flex",gap:1},children:y!=null&&y.data&&((F=y==null?void 0:y.data)==null?void 0:F.length)>0?(w=y==null?void 0:y.data)==null?void 0:w.map((x,v)=>(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)(A.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)(A.Call,{})})]},v)):(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 Po({open:e,setOpen:t,onSubmitDisposition:a}){var b,m;let[l,r]=(0,ne.useState)({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),o=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],g=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],y=(c,h)=>{r(C=>Z(d({},C),{[c]:h}))},S=()=>{r({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},f=()=>{S(),t(!1)};return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:e,"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:l.disposition,options:o,getOptionLabel:c=>c.label,onChange:(c,h)=>y("disposition",h),size:"small",renderInput:c=>(0,s.jsx)(n.TextField,Z(d({},c),{label:"Disposition",fullWidth:!0}))})}),(0,s.jsx)(n.Grid,{size:6,children:(0,s.jsx)(n.Autocomplete,{options:g,getOptionLabel:c=>c.label,value:l.followUp,onChange:(c,h)=>y("followUp",h),size:"small",renderInput:c=>(0,s.jsx)(n.TextField,Z(d({},c),{label:"Follow Up",fullWidth:!0}))})}),((m=(b=l==null?void 0:l.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:l.callbackDate,onChange:c=>y("callbackDate",c.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:l.callbackHrs,onChange:c=>y("callbackHrs",c.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:l.callbackMins,onChange:c=>y("callbackMins",c.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:()=>a(l),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function Oo({open:e,setOpen:t}){return(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(n.Dialog,{open:e,"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:()=>{t(!1)},children:(0,s.jsx)(A.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 p=require("react/jsx-runtime");function Mo({onDataChange:e}){var Ze,et,tt,ot,st,at,nt,it,lt,rt,ct,pt,dt,ut,gt,ft,mt,xt,yt,Ct,ht,bt,vt,St,Et,Tt,Lt,Dt,It,Rt,_t,wt,kt,Nt,At,Pt,Ot,Mt,Ut,Bt,Ht,$t,zt,qt,Ft,Wt,Gt,Kt,jt,Yt,Xt,Jt,Vt,Qt,Zt,eo,to,oo,so,ao,no,io,lo,ro,co,po;let t=(0,u.useTheme)(),{disabled:a,enabled:l,outlined:r}=Fe(),o=xe(),g=(0,Y.useRef)(null),[y,S]=(0,Y.useState)(null),[f,b]=(0,Y.useState)(!0),[m,c]=(0,Y.useState)(null),[h,C]=(0,Y.useState)(null),[E,B]=(0,Y.useState)(!1),[U,P]=(0,Y.useState)(!1),[_,$]=(0,Y.useState)(!1),[ee,F]=(0,Y.useState)(!1),[w,x]=(0,Y.useState)(!1),[v,k]=(0,Y.useState)(""),[O,z]=(0,Y.useState)(0),{position:T,isDragging:H,dragRef:K,handleMouseDown:W,handleTouchStart:N}=Je(o.controlPanelPosition,i=>D.setControlPanelPosition(i)),{position:R,isDragging:G,dragRef:X,handleMouseDown:J,handleTouchStart:V}=Je(o.iframePosition,i=>D.setIframePosition(i)),[re,{data:We}]=ae({onSuccess:i=>{var L;console.log("res",i),i&&i.data&&((L=i==null?void 0:i.data)==null?void 0:L.length)>1?F(!0):(D.setProcess(i==null?void 0:i.data[0]),F(!1))},onError:()=>{F(!1)}}),[De,{isLoading:Ie}]=ae(),[Re,{isLoading:ye}]=ae({onSuccess:()=>{D.setHolding(!o.isHolding)},onError:i=>{console.log("error",i)}}),[_e,{isLoading:Ce}]=ae({onSuccess:()=>{D.setMuted(!o.isMuted)},onError:i=>{console.log("error",i)}}),[we,{isLoading:he}]=ae(),[ke,{isLoading:Ne}]=ae(),[Ae,{isLoading:be}]=ae(),Pe=(0,Y.useCallback)(i=>{let L=Math.floor(i/60),Q=i%60;return`${L.toString().padStart(2,"0")}:${Q.toString().padStart(2,"0")}`},[]),Oe=()=>{S(null)},Me=i=>{b(!0),C(i.currentTarget),D.setStatus("dial")},Ue=()=>{o.status!=="on call"&&D.setStatus("idle"),C(null)},Be=i=>{c(i.currentTarget)},He=()=>{c(null)},me=()=>{let i={action:"READYAGENT",userId:o.agentId};we(M.READY_AGENT,i)},Qe=i=>{c(null);let L={action:"AGENTBREAK",break_type:i,userId:o.agentId};ke(M.UPDATE_AGENT_BREAK,L)},$o=i=>{if(i.length!==10)alert("Invalid phone number");else if(/^\d+$/.test(i)){let L={action:"CALL",phone_number:i,userId:o.agentId};De(M.CLICK_TO_CALL,L)}},zo=()=>{let i={action:o.isHolding?"UNHOLD":"HOLD",userId:o.agentId};Re(M.HOLD_CALL,i)},qo=()=>{let i={action:o.isMuted?"UNMUTE":"MUTE",userId:o.agentId};_e(M.MUTE_CALL,i)},Fo=i=>{var Q,ie,le,ce,pe,ve,Se,uo,go,fo,mo,xo,yo,Co,ho,bo;console.log("data",i);let L={action:"ENDCALL",userId:o.agentId,processid:(le=(ie=(Q=o.process)==null?void 0:Q.process_id)==null?void 0:ie.toString())!=null?le:"",process_name:(pe=(ce=o.process)==null?void 0:ce.process_name)!=null?pe:"",callreferenceid:(Se=(ve=o.callData)==null?void 0:ve.convox_id)!=null?Se:"",mobile_number:(go=(uo=o.callData)==null?void 0:uo.phone_number)!=null?go:"",disposition:(mo=(fo=i==null?void 0:i.disposition)==null?void 0:fo.value)!=null?mo:"",set_followUp:(yo=(xo=i==null?void 0:i.followUp)==null?void 0:xo.value)!=null?yo:"",callback_date:(Co=i==null?void 0:i.callbackDate)!=null?Co:"",callback_hrs:(ho=i==null?void 0:i.callbackHrs)!=null?ho:"",callback_mins:(bo=i==null?void 0:i.callbackMins)!=null?bo:"",endcall_type:"CLOSE"};k(""),Ae(M.END_CALL,L),D.endCall(),$(!1)};return(0,Y.useEffect)(()=>{let i;return o.callData.status&&o.callData.status==="ONCALL"?i=setInterval(()=>{let L=Math.floor((Date.now()-o.callStartTime)/1e3);z(L)},1e3):z(0),()=>{i&&clearInterval(i)}},[o.callData.status]),(0,Y.useEffect)(()=>{e&&e(o.callData)},[o.callData,e]),(0,Y.useEffect)(()=>{o.agentId?re(M.PROCESS_LIST,{userId:o.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[o.agentId]),(0,Y.useEffect)(()=>(o.agentId&&(g.current=new WebSocket(`${To.WS}?agent_id=${o.agentId}`),g.current.onopen=()=>{console.log("WebSocket connection established")},g.current.onmessage=i=>{try{let L=JSON.parse(i.data);console.log("parsedJSON:",L),D.updateCallData(L),L.status==="ONCALL"&&D.startCall(),L.status==="WRAPUP"&&D.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()}),[o.agentId]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(u.Fade,{in:!0,timeout:300,children:(0,p.jsx)(u.Paper,{ref:K,elevation:H?4:1,sx:{position:"fixed",left:T.x,top:T.y,p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:99999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),userSelect:"none"},children:(0,p.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,p.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center"},children:[(0,p.jsxs)(u.IconButton,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:W,onTouchStart:N,children:[(0,p.jsx)(I.DragIndicator,{})," "]}),(0,p.jsx)(u.Box,{sx:{marginRight:"10px"},children:(0,p.jsx)(u.Tooltip,{title:"Dial",children:(0,p.jsx)(u.IconButton,{size:"small",onClick:i=>{var L,Q,ie,le,ce,pe,ve,Se;((Q=(L=o.callData)==null?void 0:L.status)==null?void 0:Q.toUpperCase())!=="ONCALL"&&((le=(ie=o.callData)==null?void 0:ie.status)==null?void 0:le.toUpperCase())!=="BREAK"&&((pe=(ce=o.callData)==null?void 0:ce.status)==null?void 0:pe.toUpperCase())!=="RINGING"&&((Se=(ve=o.callData)==null?void 0:ve.status)==null?void 0:Se.toUpperCase())!=="WRAPUP"&&Me(i)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:(0,p.jsx)(I.WifiCalling3,{sx:{color:((et=(Ze=o.callData)==null?void 0:Ze.status)==null?void 0:et.toUpperCase())==="ONCALL"||((ot=(tt=o.callData)==null?void 0:tt.status)==null?void 0:ot.toUpperCase())==="BREAK"||((at=(st=o.callData)==null?void 0:st.status)==null?void 0:at.toUpperCase())==="RINGING"||((it=(nt=o.callData)==null?void 0:nt.status)==null?void 0:it.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),(0,p.jsx)(u.Typography,{sx:{color:"success.main",width:"40px",marginRight:"10px"},children:Pe(O)}),Ne||he?(0,p.jsx)(u.Box,{sx:{fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,p.jsx)(u.CircularProgress,{size:"20px"})}):(0,p.jsx)(u.Typography,{variant:"body2",sx:{fontWeight:"bold",textAlign:"right"},children:(ct=(rt=(lt=o.callData)==null?void 0:lt.status)==null?void 0:rt.toUpperCase())!=null?ct:"N/A"}),(0,p.jsx)(u.Box,{onClick:Be,sx:{display:"flex",alignItems:"center",margin:"6px",cursor:"pointer"},children:(0,p.jsx)(I.ArrowDropDown,{})})]}),(0,p.jsxs)(u.Box,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[(0,p.jsx)(u.Tooltip,{title:"Agent Ready",children:(0,p.jsx)(u.Button,{variant:((dt=(pt=o.callData)==null?void 0:pt.status)==null?void 0:dt.toUpperCase())==="BREAK"||((gt=(ut=o.callData)==null?void 0:ut.status)==null?void 0:gt.toUpperCase())==="MISSED"?"outlined":"contained",onClick:i=>{var L,Q,ie,le;(((Q=(L=o.callData)==null?void 0:L.status)==null?void 0:Q.toUpperCase())==="BREAK"||((le=(ie=o.callData)==null?void 0:ie.status)==null?void 0:le.toUpperCase())==="MISSED")&&(i.stopPropagation(),me())},classes:{root:((mt=(ft=o.callData)==null?void 0:ft.status)==null?void 0:mt.toUpperCase())==="BREAK"||((yt=(xt=o.callData)==null?void 0:xt.status)==null?void 0:yt.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:d({},((ht=(Ct=o.callData)==null?void 0:Ct.status)==null?void 0:ht.toUpperCase())==="BREAK"||((vt=(bt=o.callData)==null?void 0:bt.status)==null?void 0:vt.toUpperCase())==="MISSED"?r:l),disabled:he,children:(0,p.jsx)(I.SupportAgent,{})})}),(0,p.jsx)(u.Tooltip,{title:o.isHolding?"Resume":"Hold",children:(0,p.jsx)(u.Button,{variant:o.isHolding&&((Et=(St=o.callData)==null?void 0:St.status)==null?void 0:Et.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),zo()},sx:o.isHolding&&((Lt=(Tt=o.callData)==null?void 0:Tt.status)==null?void 0:Lt.toUpperCase())==="ONCALL"?d({},l):((It=(Dt=o.callData)==null?void 0:Dt.status)==null?void 0:It.toUpperCase())==="ONCALL"?d({},r):d({},a),disabled:((_t=(Rt=o.callData)==null?void 0:Rt.status)==null?void 0:_t.toUpperCase())!=="ONCALL"&&!o.isHolding||ye,children:ye?(0,p.jsx)(u.CircularProgress,{size:"20px",sx:{color:t.palette.primary.main}}):o.isHolding?(0,p.jsx)(I.PlayArrow,{}):(0,p.jsx)(I.Pause,{})})}),(0,p.jsx)(u.Tooltip,{title:o.isMuted?"Unmute":"Mute",children:(0,p.jsx)(u.Button,{variant:o.isMuted&&((kt=(wt=o.callData)==null?void 0:wt.status)==null?void 0:kt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:i=>{i.stopPropagation(),qo()},sx:o.isMuted&&((At=(Nt=o.callData)==null?void 0:Nt.status)==null?void 0:At.toUpperCase())==="ONCALL"?d({},l):((Ot=(Pt=o.callData)==null?void 0:Pt.status)==null?void 0:Ot.toUpperCase())==="ONCALL"?d({},r):d({},a),disabled:((Ut=(Mt=o.callData)==null?void 0:Mt.status)==null?void 0:Ut.toUpperCase())!=="ONCALL"&&!o.isMuted||Ce,children:Ce?(0,p.jsx)(u.CircularProgress,{size:"20px",sx:{color:t.palette.primary.main}}):o.isMuted?(0,p.jsx)(I.MicOff,{}):(0,p.jsx)(I.Mic,{})})}),(0,p.jsx)(u.Tooltip,{title:"Transfer Call",children:(0,p.jsx)(u.Button,{variant:U?"contained":"outlined",onClick:i=>{var L,Q;((Q=(L=o.callData)==null?void 0:L.status)==null?void 0:Q.toUpperCase())==="ONCALL"&&(i.stopPropagation(),P(!0))},sx:U?d({},l):((Ht=(Bt=o.callData)==null?void 0:Bt.status)==null?void 0:Ht.toUpperCase())==="ONCALL"?d({},r):d({},a),disabled:((zt=($t=o.callData)==null?void 0:$t.status)==null?void 0:zt.toUpperCase())!=="ONCALL",children:(0,p.jsx)(I.TransferWithinAStation,{})})}),(0,p.jsx)(u.Tooltip,{title:"Conference Call",children:(0,p.jsx)(u.Button,{variant:E?"contained":"outlined",onClick:i=>{var L,Q;((Q=(L=o.callData)==null?void 0:L.status)==null?void 0:Q.toUpperCase())==="ONCALL"&&(i.stopPropagation(),B(!0))},sx:E?d({},l):((Ft=(qt=o.callData)==null?void 0:qt.status)==null?void 0:Ft.toUpperCase())==="ONCALL"?d({},r):d({},a),disabled:((Gt=(Wt=o.callData)==null?void 0:Wt.status)==null?void 0:Gt.toUpperCase())!=="ONCALL",children:(0,p.jsx)(I.Group,{})})}),(0,p.jsx)(u.Tooltip,{title:"End Call",children:(0,p.jsx)(u.Button,{variant:((jt=(Kt=o.callData)==null?void 0:Kt.status)==null?void 0:jt.toUpperCase())==="ONCALL"||((Xt=(Yt=o.callData)==null?void 0:Yt.status)==null?void 0:Xt.toUpperCase())==="RINGING"||((Vt=(Jt=o.callData)==null?void 0:Jt.status)==null?void 0:Vt.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:i=>{var L,Q,ie,le,ce,pe;(((Q=(L=o.callData)==null?void 0:L.status)==null?void 0:Q.toUpperCase())==="ONCALL"||((le=(ie=o.callData)==null?void 0:ie.status)==null?void 0:le.toUpperCase())==="RINGING"||((pe=(ce=o.callData)==null?void 0:ce.status)==null?void 0:pe.toUpperCase())==="WRAPUP")&&(i.stopPropagation(),$(!0))},sx:((Zt=(Qt=o.callData)==null?void 0:Qt.status)==null?void 0:Zt.toUpperCase())==="ONCALL"||((to=(eo=o.callData)==null?void 0:eo.status)==null?void 0:to.toUpperCase())==="RINGING"||((so=(oo=o.callData)==null?void 0:oo.status)==null?void 0:so.toUpperCase())==="WRAPUP"?Z(d({},l),{borderRight:"1px",backgroundColor:"error.main",minWidth:"60px !important",boxShadow:" 0px 2px 1px #5f3f3f",border:`1px solid ${t.palette.error.light}`,height:"40px","&:hover":{bgcolor:"error.light",boxShadow:" 0px 2px 1px #5f3f3f",border:`0px solid ${t.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${t.palette.primary.light}`}}):Z(d({},a),{minWidth:"60px !important"}),disabled:((no=(ao=o.callData)==null?void 0:ao.status)==null?void 0:no.toUpperCase())!=="ONCALL"&&((lo=(io=o.callData)==null?void 0:io.status)==null?void 0:lo.toUpperCase())!=="RINGING"&&((co=(ro=o.callData)==null?void 0:ro.status)==null?void 0:co.toUpperCase())!=="WRAPUP"||be,children:be?(0,p.jsx)(u.CircularProgress,{size:"20px",color:"error"}):(0,p.jsx)(I.CallEnd,{})})})]})]})})}),(0,p.jsx)(u.Fade,{in:!0,timeout:300,children:(0,p.jsxs)(u.Paper,{ref:X,elevation:G?4:1,sx:{position:"fixed",left:R.x,top:R.y,p:1,height:"auto",borderRadius:2,bgcolor:"background.paper",zIndex:99999,transition:t.transitions.create(["box-shadow","transform"],{duration:t.transitions.duration.short}),visibility:f?"visible":"hidden",userSelect:"none"},children:[(0,p.jsxs)(u.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll"},onMouseDown:J,onTouchStart:V,children:[(0,p.jsx)(I.DragIndicator,{sx:{transform:"rotate(90deg)"}})," ",(0,p.jsx)(u.IconButton,{onClick:()=>b(!1),children:(0,p.jsx)(I.Close,{})})]}),(0,p.jsx)("iframe",{src:`https://h68.deepijatel.in/ConVoxCCS/iframe?agent_id=${o.agentId}&process_id=${(po=o.process)==null?void 0:po.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay"})]})}),(0,p.jsx)(u.Menu,{anchorEl:h,open:!!h,onClose:Ue,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,p.jsxs)(u.Box,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[(0,p.jsx)(u.TextField,{size:"small",value:v,placeholder:"Enter Mobile No.",onChange:i=>{k(i.target.value)}}),(0,p.jsx)(u.IconButton,{color:"info",onClick:()=>{$o(v)},children:Ie?(0,p.jsx)(u.CircularProgress,{size:"20px",sx:{color:t.palette.success.main}}):(0,p.jsx)(I.Phone,{color:"success"})})]})}),(0,p.jsxs)(u.Menu,{anchorEl:m,open:!!m,onClose:He,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:[(0,p.jsx)(u.MenuItem,{onClick:()=>Qe("Lunch"),children:"- Lunch"}),(0,p.jsx)(u.MenuItem,{onClick:()=>Qe("Tea"),children:"- Tea"})]}),(0,p.jsx)(u.Menu,{anchorEl:y,open:!!y,onClose:Oe,onClick:i=>i.stopPropagation(),sx:{zIndex:99999},children:(0,p.jsxs)(u.Box,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[(0,p.jsx)(u.Chip,{icon:(0,p.jsx)(I.Layers,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),(0,p.jsx)(u.Chip,{icon:(0,p.jsx)(I.Pending,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),(0,p.jsx)(u.Chip,{icon:(0,p.jsx)(I.Upcoming,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!E&&(0,p.jsx)(No,{open:E,setOpen:B}),!!U&&(0,p.jsx)(Ao,{open:U,setOpen:P}),!!_&&(0,p.jsx)(Po,{open:_,setOpen:$,onSubmitDisposition:Fo}),!!w&&(0,p.jsx)(Oo,{open:w,setOpen:x})]})}var Bo=require("react/jsx-runtime"),Uo=({children:e})=>(0,Bo.jsx)(wo,{children:e});var Ve=require("react/jsx-runtime");function Ho({onDataChange:e}){return(0,Ve.jsx)(Uo,{children:(0,Ve.jsx)(Mo,{onDataChange:e})})}function ls({apiKey:e,tenantId:t,agentId:a}){D.initialize(e,a),je.init({apiKey:e,tenantId:t,agentId:a,baseUrl:q})}0&&(module.exports={CallControlPanel,initSDK,useClickToCall,useEndCall,useLogout});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|