call-control-sdk 5.4.1 → 5.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var xs=Object.defineProperty,Cs=Object.defineProperties;var hs=Object.getOwnPropertyDescriptors;var Wo=Object.getOwnPropertySymbols;var ys=Object.prototype.hasOwnProperty,bs=Object.prototype.propertyIsEnumerable;var st=(t,o,e)=>o in t?xs(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,l=(t,o)=>{for(var e in o||(o={}))ys.call(o,e)&&st(t,e,o[e]);if(Wo)for(var e of Wo(o))bs.call(o,e)&&st(t,e,o[e]);return t},X=(t,o)=>Cs(t,hs(o));var ne=(t,o,e)=>st(t,typeof o!="symbol"?o+"":o,e);var nt=class{constructor(){ne(this,"config",null);ne(this,"ticketId",null);ne(this,"baseUrl","");ne(this,"eventQueue",[]);ne(this,"isOnline",!0);ne(this,"retryQueue",[]);ne(this,"flushTimer",null)}async init(o){this.config=l({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 n={eventType:o,eventData:e,timestamp:Date.now()};if(this.eventQueue.push(n),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift(),this.isOnline)try{await this.sendEvent(n)}catch(r){console.warn("Failed to send event, will retry later:",r)}}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 n=this.eventQueue.findIndex(r=>r.timestamp===o.timestamp);n>-1&&this.eventQueue.splice(n,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 n of o)await this.sendEvent(n);let e=[...this.retryQueue];this.retryQueue=[];for(let n of e)try{await n()}catch(r){console.error("Retry failed:",r)}}async makeRequest(o,e){var c;let n=`${this.baseUrl}${o}`,r=((c=this.config)==null?void 0:c.retryAttempts)||3;for(let p=1;p<=r;p++)try{return await fetch(n,e)}catch(m){if(p===r)throw m;let b=Math.min(1e3*Math.pow(2,p-1),1e4);await new Promise(u=>setTimeout(u,b))}throw new Error("Max retries exceeded")}setupAutoTracking(){var n;if(typeof window=="undefined"||!((n=this.config)!=null&&n.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(r=>console.warn("Failed to track page visit:",r)),o.clicks!==!1&&document.addEventListener("click",r=>{var p;let c=r.target;(c.tagName==="BUTTON"||c.tagName==="A"||c.onclick||c.getAttribute("role")==="button"||c instanceof HTMLButtonElement&&c.type==="button")&&this.logEvent("click",{element:c.tagName,text:(p=c.textContent)==null?void 0:p.trim().substring(0,100),href:c.getAttribute("href"),id:c.id,className:c.className,role:c.getAttribute("role"),position:{x:r.clientX,y:r.clientY},timestamp:new Date().toISOString()}).catch(m=>console.warn("Failed to track click:",m))}),o.forms!==!1&&document.addEventListener("submit",r=>{let c=r.target,p=new FormData(c),m={};p.forEach((b,u)=>{m[u]=b.toString()}),this.logEvent("formSubmission",{formId:c.id,action:c.action,method:c.method,fields:Object.keys(m),fieldCount:Object.keys(m).length,timestamp:new Date().toISOString()}).catch(b=>console.warn("Failed to track form submission:",b))}),o.inputs!==!1){let r;document.addEventListener("input",c=>{let p=c.target;(p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.tagName==="SELECT")&&(clearTimeout(r),r=setTimeout(()=>{var m;this.logEvent("fieldChange",{element:p.tagName,type:p.getAttribute("type"),name:p.getAttribute("name"),id:p.id,valueLength:((m=p.value)==null?void 0:m.length)||0,timestamp:new Date().toISOString()}).catch(b=>console.warn("Failed to track field change:",b))},1e3))})}let e=Date.now();window.addEventListener("beforeunload",()=>{let r=Date.now()-e;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}))}),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",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 c;this.logEvent("unhandledRejection",{reason:(c=r.reason)==null?void 0:c.toString(),timestamp:new Date().toISOString()})})),o.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let r=window.performance.navigation,c=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:c.navigationStart,loadTime:c.loadEventEnd-c.navigationStart,domReady:c.domContentLoadedEventEnd-c.navigationStart,renderTime:c.loadEventEnd-c.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 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)}},at=new nt;typeof window!="undefined"&&(window.EventTracker=at);var it=class{constructor(){ne(this,"state");ne(this,"listeners",[]);ne(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=X(l({},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,n){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=l({showEndCallButton:!0,showTransferButton:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},n),this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return l({},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=l(l({},this.state.callData),o),this.saveToStorage(),this.notifyListeners()}setConferenceLine(o){var n;(!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=(n=this.state.conferenceLine)==null?void 0:n.map(r=>r.line===o.line?o:r);this.state.conferenceLine=e,this.saveToStorage(),this.notifyListeners()}resetConferenceLines(){this.state.conferenceLine=this.getInitialState().conferenceLine,this.saveToStorage(),this.notifyListeners()}clearStorageAndReset(){try{localStorage.removeItem(this.STORAGE_KEY),this.state=this.getInitialState(),this.notifyListeners()}catch(o){console.warn("Failed to clear localStorage:",o)}}debugStorage(){try{let o=localStorage.getItem(this.STORAGE_KEY);console.log("Current localStorage data:",o),o&&console.log("Parsed localStorage data:",JSON.parse(o)),console.log("Current state:",this.state)}catch(o){console.error("Error debugging storage:",o)}}getConferenceLines(){return this.state.conferenceLine||[]}},E=new it;import{useCallback as Ts,useState as Re}from"react";var Je="10.10.102.42",U=`http://${Je}:8095`,vs=`ws://${Je}:8095`,z={v1:"/api/v1"},k={LOGIN:`${U}${z.v1}/cti/login?provider=convox`,READY_AGENT:`${U}${z.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${U}${z.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${U}${z.v1}/cti/calls?provider=convox`,HOLD_CALL:`${U}${z.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${U}${z.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${U}${z.v1}/cti/unmute-call?provider=convox`,END_CALL:`${U}${z.v1}/cti/calls/end?provider=convox`,LOGOUT:`${U}${z.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${U}${z.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${U}${z.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${U}${z.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${U}${z.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${U}${z.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${U}${z.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${U}${z.v1}/cti/users`,PROCESS_LIST:`${U}${z.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${U}${z.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${U}${z.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${U}${z.v1}/users/get_sentiment_analysis`},Ko={WS:`${vs}${z.v1}/cti/ws`};import Ss from"axios";var Es="12345",lt=Ss.create({baseURL:U,headers:{"Content-Type":"application/json",Authorization:Es},timeout:1e4});lt.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))));lt.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 Z=lt;var Ls=()=>{let[t,o]=Re(!1),[e,n]=Re(!1),[r,c]=Re(!1),[p,m]=Re(null),[b,u]=Re(null);return{logout:Ts(async()=>{var C;let g=JSON.parse((C=localStorage.getItem("call-control-sdk-state"))!=null?C:"");o(!0);let i={action:"LOGOUTUSER",userId:g.agentId||""};return Z.post(k.LOGOUT,i).then(x=>(E.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),u(x==null?void 0:x.data),n(!0),x==null?void 0:x.data)).catch(x=>{var v;return c(!0),m(x),(v=x==null?void 0:x.response)==null?void 0:v.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:r,error:p,data:b}},Ds=Ls;import{useCallback as Is,useState as ke}from"react";var _s=()=>{let[t,o]=ke(!1),[e,n]=ke(!1),[r,c]=ke(!1),[p,m]=ke(null),[b,u]=ke(null);return{handleEndCall:Is(async g=>{var x,v,P,N,w,D,O,Q,M,I,f,H,te,oe,L;let i=JSON.parse((x=localStorage.getItem("call-control-sdk-state"))!=null?x:"");o(!0);let C={action:"ENDCALL",userId:i==null?void 0:i.agentId,processid:(N=(P=(v=i==null?void 0:i.process)==null?void 0:v.process_id)==null?void 0:P.toString())!=null?N:"",process_name:(D=(w=i==null?void 0:i.process)==null?void 0:w.process_name)!=null?D:"",callreferenceid:(Q=(O=i==null?void 0:i.callData)==null?void 0:O.convox_id)!=null?Q:"",mobile_number:(I=(M=i==null?void 0:i.callData)==null?void 0:M.phone_number)!=null?I:"",disposition:(f=g==null?void 0:g.disposition)!=null?f:"RES",set_followUp:(H=g==null?void 0:g.followUp)!=null?H:"N",callback_date:(te=g==null?void 0:g.callbackDate)!=null?te:"",callback_hrs:(oe=g==null?void 0:g.callbackHrs)!=null?oe:"",callback_mins:(L=g==null?void 0:g.callbackMins)!=null?L:"",endcall_type:"CLOSE"};return Z.post(k.END_CALL,C).then(y=>(E.endCall(),u(y==null?void 0:y.data),n(!0),y==null?void 0:y.data)).catch(y=>{var R;return c(!0),m(y),(R=y==null?void 0:y.response)==null?void 0:R.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:r,error:p,data:b}};import{useCallback as ws,useState as Ne}from"react";var Rs=()=>{let[t,o]=Ne(!1),[e,n]=Ne(!1),[r,c]=Ne(!1),[p,m]=Ne(null),[b,u]=Ne(null);return{handleStartCall:ws(async g=>{var C,x,v,P,N,w,D,O,Q;let i=JSON.parse((C=localStorage.getItem("call-control-sdk-state"))!=null?C:"");if(o(!0),((x=i==null?void 0:i.callData)==null?void 0:x.status)==="IDLE"){let M={action:"CALL",userId:i==null?void 0:i.agentId,phone_number:g==null?void 0:g.mobileNumber};return Z.post(k.CLICK_TO_CALL,M).then(I=>(u(I==null?void 0:I.data),n(!0),I==null?void 0:I.data)).catch(I=>{var f;return c(!0),m(I),(f=I==null?void 0:I.response)==null?void 0:f.data}).finally(()=>{o(!1)})}else if(((v=i==null?void 0:i.callData)==null?void 0:v.status)==="ONCALL"){let M=(N=(P=i==null?void 0:i.conferenceLine)==null?void 0:P.filter(f=>f.line!==1))==null?void 0:N.find(f=>f.status==="IDLE"&&!(f!=null&&f.isCallStart)),I={action:"EXTERNAL_CONFERENCE",operation:`CALL${M.line}`,line_used:String(M.line),thirdparty_no:g==null?void 0:g.mobileNumber,userid:(D=(w=i.callData)==null?void 0:w.agent_id)!=null?D:"",process:(Q=(O=i.callData)==null?void 0:O.process_name)!=null?Q:""};return Z.post(k.CONFERENCE_CALL,I).then(f=>(u(f==null?void 0:f.data),n(!0),E.setConferenceLine(X(l({},M),{isCallStart:!0,status:"ONCALL",phone:g==null?void 0:g.mobileNumber})),f==null?void 0:f.data)).catch(f=>{var H;return c(!0),m(f),(H=f==null?void 0:f.response)==null?void 0:H.data}).finally(()=>{o(!1)})}else alert("Agent is not ready")},[]),isLoading:t,isSuccess:e,isError:r,error:p,data:b}};import{ArrowDropDown as on,CallEnd as sn,Close as nn,DragIndicator as ns,Group as an,Layers as ln,Mic as rn,MicOff as cn,Pause as dn,Pending as pn,Phone as un,PlayArrow as gn,SupportAgent as fn,TransferWithinAStation as mn,Upcoming as xn,WifiCalling3 as Cn}from"@mui/icons-material";import{Box as ue,Button as Ee,Chip as gt,CircularProgress as Me,Fade as as,IconButton as tt,Menu as ft,MenuItem as is,Paper as ls,TextField as hn,Tooltip as he,Typography as rs,useTheme as yn}from"@mui/material";import{useCallback as bn,useEffect as ot,useRef as vn,useState as re}from"react";import{useCallback as Ve,useRef as rt,useState as Go}from"react";function ct(t,o){let[e,n]=Go(t),[r,c]=Go(!1),p=rt(),m=rt({x:0,y:0}),b=rt({x:0,y:0}),u=Ve(C=>{let x=p.current;if(!x)return;let v=x.getBoundingClientRect(),P=window.innerWidth,N=window.innerHeight,w={x:Math.max(0,Math.min(C.x,P-v.width)),y:Math.max(0,Math.min(C.y,N-v.height))};n(w),o==null||o(w)},[o]),h=Ve((C,x)=>{c(!0),m.current={x:C,y:x},b.current=e;let v=(D,O)=>{let Q=D-m.current.x,M=O-m.current.y;u({x:b.current.x+Q,y:b.current.y+M})},P=D=>{D.preventDefault(),v(D.clientX,D.clientY)},N=D=>{D.preventDefault();let O=D.touches[0];O&&v(O.clientX,O.clientY)},w=()=>{c(!1),document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",w),document.removeEventListener("touchmove",N),document.removeEventListener("touchend",w)};document.addEventListener("mousemove",P),document.addEventListener("mouseup",w),document.addEventListener("touchmove",N,{passive:!1}),document.addEventListener("touchend",w)},[e,u]),g=Ve(C=>{C.preventDefault(),h(C.clientX,C.clientY)},[h]),i=Ve(C=>{C.preventDefault();let x=C.touches[0];x&&h(x.clientX,x.clientY)},[h]);return{position:e,isDragging:r,dragRef:p,handleMouseDown:g,handleTouchStart:i}}import{useState as ks,useEffect as Ns}from"react";function ye(){let[t,o]=ks(E.getState());return Ns(()=>E.subscribe(()=>{o(E.getState())}),[]),t}import{useCallback as Bs,useReducer as Hs}from"react";import{createContext as As,useContext as Ps,useState as dt}from"react";import{Snackbar as Os,Alert as Us}from"@mui/material";import{jsx as Yo,jsxs as Ms}from"react/jsx-runtime";var jo=As(void 0),Ae=()=>{let t=Ps(jo);if(!t)throw new Error("useToast must be used inside ToastProvider");return t},Xo=({children:t})=>{let[o,e]=dt(!1),[n,r]=dt(""),[c,p]=dt("info"),m=(b,u="info")=>{r(b),p(u),e(!0)};return Ms(jo.Provider,{value:{showToast:m},children:[t,Yo(Os,{open:o,color:c,autoHideDuration:3e3,onClose:()=>e(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:Yo(Us,{variant:"filled",severity:c,onClose:()=>e(!1),sx:{width:"100%"},children:n})})]})};var $s={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},zs=(t,o)=>{if(o.type==="isLoading")return X(l({},t),{isLoading:o.payload});if(o.type==="isSuccess")return X(l({},t),{isSuccess:!0,data:o.payload});if(o.type==="isError")return X(l({},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 ae=(t={})=>{let{onSuccess:o=null,onError:e=null}=t,{showToast:n}=Ae(),[r,c]=Hs(zs,$s);return[Bs((m,b,u={})=>{c({type:"isLoading",payload:!0}),Z.post(m,b,u).then(h=>{var g,i;c({type:"isSuccess",payload:h.data}),o==null||o(h.data,b),console.log((g=h.data)==null?void 0:g.message,"res45"),n((i=h.data)==null?void 0:i.message,"success")}).catch(h=>{var i,C,x,v,P,N,w,D,O,Q,M,I;let g={status:(C=(i=h.response)==null?void 0:i.status)!=null?C:500,message:((v=(x=h.response)==null?void 0:x.data)==null?void 0:v.detail)||((N=(P=h.response)==null?void 0:P.data)==null?void 0:N.message)||h.message||"An unknown error occurred",data:(D=(w=h.response)==null?void 0:w.data)!=null?D:null,statusText:(Q=(O=h.response)==null?void 0:O.statusText)!=null?Q:"",code:(M=h==null?void 0:h.code)!=null?M:"",name:(I=h==null?void 0:h.name)!=null?I:""};n(g.message,"error"),c({type:"isError",payload:g}),e==null||e(g,b)}).finally(()=>{c({type:"isLoading",payload:!1})})},[o,e,n]),r]};import{Call as Ze,CallEnd as Jo,CallSplit as Ws,Close as ut,Mic as Ks,MicOff as Gs,Pause as Ys,PhoneDisabled as js,PlayArrow as Xs,SupportAgent as pt}from"@mui/icons-material";import{Box as V,Button as se,Dialog as et,IconButton as Ce,Paper as Oe,TextField as ve,Typography as ee,Autocomplete as Vo,Grid as be,Tooltip as Pe,useTheme as Js,TableContainer as Vs,Table as Qs,TableHead as Zs,TableRow as Qo,TableCell as de,TableBody as en,CircularProgress as Se}from"@mui/material";import{useEffect as Zo,useState as me}from"react";import{useTheme as qs}from"@mui/material";var Fs=({disabled:t,enabled:o,outlined:e})=>{let n=qs();return{disabled:l({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 ${n.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${n.palette.primary.light}`}},t),enabled:l({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${n.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${n.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${n.palette.primary.light}`}},o),outlined:l({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:n.palette.grey[200],boxShadow:`0px 2px 1px ${n.palette.primary.light}`,border:`0px solid ${n.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${n.palette.primary.main}`,border:`0px solid ${n.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${n.palette.primary.light}`}},e)}},Qe=Fs;import{Fragment as Ue,jsx as s,jsxs as A}from"react/jsx-runtime";var tn=({each:t})=>{var I,f,H,te,oe;let o=ye(),{showToast:e}=Ae(),{disabled:n,enabled:r,outlined:c}=Qe({disabled:((I=o.sdkConfig)==null?void 0:I.disabled)||{},enabled:((f=o.sdkConfig)==null?void 0:f.enabled)||{},outlined:((H=o.sdkConfig)==null?void 0:H.outlined)||{}}),p=Js(),[m,b]=me(!1),[u,h]=me(!1),[g,i]=me(!1),[C,x]=me(!1),[v,P]=me(!1),N=(L,y)=>{E.setConferenceLine(l(l({},L),y))},w=(L,y)=>{var $,W,F,K;let R=l(l({},L),y);b(!0);let q={action:"EXTERNAL_CONFERENCE",operation:`CALL${R.line}`,line_used:String(R.line),thirdparty_no:R.phone,userid:(W=($=o.callData)==null?void 0:$.agent_id)!=null?W:"",process:(K=(F=o.callData)==null?void 0:F.process_name)!=null?K:""};Z.post(k.CONFERENCE_CALL,q).then(_=>{var T;e((T=_.data)==null?void 0:T.message,"success"),E.setConferenceLine(l(l({},L),y))}).catch(_=>{var B,G,J,Y;let T=((G=(B=_.response)==null?void 0:B.data)==null?void 0:G.detail)||((Y=(J=_.response)==null?void 0:J.data)==null?void 0:Y.message)||_.message||"An unknown error occurred";e(T,"error")}).finally(()=>{b(!1)})},D=(L,y)=>{var $,W,F,K;let R=l(l({},L),y);h(!0);let q={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(R.line),thirdparty_no:R.phone,userid:(W=($=o.callData)==null?void 0:$.agent_id)!=null?W:"",process:(K=(F=o.callData)==null?void 0:F.process_name)!=null?K:""};Z.post(k.CONFERENCE_CALL,q).then(_=>{var T;e((T=_.data)==null?void 0:T.message,"success"),E.setConferenceLine(l(l({},L),y))}).catch(_=>{var B,G,J,Y;let T=((G=(B=_.response)==null?void 0:B.data)==null?void 0:G.detail)||((Y=(J=_.response)==null?void 0:J.data)==null?void 0:Y.message)||_.message||"An unknown error occurred";e(T,"error")}).finally(()=>{h(!1)})},O=(L,y,R)=>{var W,F,K,_;let q=l(l({},L),y);i(!0);let $={action:"EXTERNAL_CONFERENCE",operation:R,hold_channel_no:R==="HOLDUSER"?`hold${q.line}`:`unhold${q.line}`,userid:(F=(W=o.callData)==null?void 0:W.agent_id)!=null?F:"",process:(_=(K=o.callData)==null?void 0:K.process_name)!=null?_:""};Z.post(k.CONFERENCE_CALL_HOLD_OR_UN_HOLD,$).then(T=>{var B;e((B=T.data)==null?void 0:B.message,"success"),E.setConferenceLine(l(l({},L),y))}).catch(T=>{var G,J,Y,ce;let B=((J=(G=T.response)==null?void 0:G.data)==null?void 0:J.detail)||((ce=(Y=T.response)==null?void 0:Y.data)==null?void 0:ce.message)||T.message||"An unknown error occurred";e(B,"error")}).finally(()=>{i(!1)})},Q=(L,y,R)=>{var W,F,K,_;let q=l(l({},L),y);x(!0);let $={action:"EXTERNAL_CONFERENCE",operation:R,channel_no:R==="MUTEUSER"?`mute${q.line}`:`play${q.line}`,userid:(F=(W=o.callData)==null?void 0:W.agent_id)!=null?F:"",thirdparty_no:q.phone,process:(_=(K=o.callData)==null?void 0:K.process_name)!=null?_:""};Z.post(k.CONFERENCE_CALL_MUTE_OT_UN_MUTE,$).then(T=>{var B;e((B=T.data)==null?void 0:B.message,"success"),E.setConferenceLine(l(l({},L),y))}).catch(T=>{var G,J,Y,ce;let B=((J=(G=T.response)==null?void 0:G.data)==null?void 0:J.detail)||((ce=(Y=T.response)==null?void 0:Y.data)==null?void 0:ce.message)||T.message||"An unknown error occurred";e(B,"error")}).finally(()=>{x(!1)})},M=(L,y)=>{var $,W,F,K;let R=l(l({},L),y);P(!0);let q={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(R.line-1),user_type:`THIRDPARTY${R.line-1}`,thirdparty_no:R.phone,userid:(W=($=o.callData)==null?void 0:$.agent_id)!=null?W:"",process:(K=(F=o.callData)==null?void 0:F.process_name)!=null?K:""};Z.post(k.CONFERENCE_CALL_END,q).then(_=>{var T;e((T=_.data)==null?void 0:T.message,"success"),E.setConferenceLine(l(l({},L),y))}).catch(_=>{var B,G,J,Y;let T=((G=(B=_.response)==null?void 0:B.data)==null?void 0:G.detail)||((Y=(J=_.response)==null?void 0:J.data)==null?void 0:Y.message)||_.message||"An unknown error occurred";e(T,"error")}).finally(()=>{P(!1)})};return A(Qo,{sx:{border:"2px solid #fff"},children:[s(de,{sx:{padding:"6px"},children:A(ee,{children:["Line ",(te=t==null?void 0:t.line)!=null?te:"",". "]})}),s(de,{sx:{padding:"6px"},children:s(ee,{variant:"body2",sx:{px:1,borderRadius:"10px",width:"80px",maxWidth:"100px"},children:(oe=t==null?void 0:t.status)!=null?oe:""})}),s(de,{sx:{padding:"6px"},children:s(se,{sx:{textTransform:"capitalize"},size:"small",children:s(ee,{variant:"body2",children:(t==null?void 0:t.line)===1?"Internal":"External"})})}),s(de,{sx:{padding:"6px"},children:s(ve,{size:"small",placeholder:"Phone Number",value:(t==null?void 0:t.phone)||"",disabled:(t==null?void 0:t.line)===1,onChange:L=>{N(t,{phone:L.target.value})}})}),s(de,{sx:{padding:"6px"},children:A(V,{sx:{display:"flex",alignItems:"center",justifyContent:"space-around"},children:[s(Pe,{title:"Call",children:s(se,{variant:t!=null&&t.isCallStart?"outlined":"contained",color:"success",sx:t!=null&&t.isCallStart?l({},n):X(l({},r),{border:`0px solid ${p.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${p.palette.success.light}`,border:`0px solid ${p.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${p.palette.primary.light}`}}),onClick:()=>{w(t,{isCallStart:!0,status:"ONCALL"})},disabled:(t==null?void 0:t.isCallStart)||m,children:m?s(Se,{size:"20px",color:"success"}):s(Ze,{sx:{color:t!=null&&t.isCallStart?"default":"#e7e7e7ff"}})})}),s(Pe,{title:"Merge Call",children:s(se,{variant:t!=null&&t.isMergeCall?"contained":"outlined",sx:t!=null&&t.isMergeCall&&(t!=null&&t.isCallStart)?l({},n):t!=null&&t.isCallStart?l({},c):l({},n),onClick:()=>{D(t,{isMergeCall:!0,status:"ONCALL"})},disabled:!(t!=null&&t.isCallStart)||u,children:u?s(Se,{size:"20px",sx:{color:t!=null&&t.isMergeCall?"#e7e7e7ff":p.palette.primary.main}}):s(Ws,{})})}),s(Pe,{title:t.isHold?"Hold":"Un Hold",children:s(se,{variant:t!=null&&t.isHold?"contained":"outlined",sx:t!=null&&t.isHold&&(t!=null&&t.isCallStart)?l({},n):t!=null&&t.isCallStart?l({},c):l({},n),onClick:()=>{t.isHold?O(t,{isHold:!1},"UNHOLDUSER"):O(t,{isHold:!0},"HOLDUSER")},disabled:!(t!=null&&t.isCallStart)||g,children:g?s(Se,{size:"20px",sx:{color:p.palette.primary.main}}):t.isHold?s(Xs,{}):s(Ys,{})})}),s(Pe,{title:t.isMute?"Mute":"Un Mute",children:s(se,{variant:t!=null&&t.isMute?"contained":"outlined",sx:t!=null&&t.isMute&&(t!=null&&t.isCallStart)?l({},n):t!=null&&t.isCallStart?l({},c):l({},n),onClick:()=>{t.isMute?Q(t,{isMute:!1},"PLAYUSER"):Q(t,{isMute:!0},"MUTEUSER")},disabled:!(t!=null&&t.isCallStart)||C,children:C?s(Se,{size:"20px",sx:{color:p.palette.primary.main}}):t.isMute?s(Gs,{}):s(Ks,{})})}),s(Pe,{title:"End Call",children:(t==null?void 0:t.line)!==1?s(se,{variant:t!=null&&t.isCallStart?"contained":"outlined",color:"error",sx:t!=null&&t.isCallStart?X(l({},r),{minWidth:"60px !important",border:`0px solid ${p.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${p.palette.error.light}`,border:`0px solid ${p.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${p.palette.primary.light}`}}):X(l({},n),{minWidth:"60px !important"}),onClick:()=>{M(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(t!=null&&t.isCallStart)||v,children:v?s(Se,{size:"20px",color:"error"}):s(Jo,{})}):s(se,{variant:t!=null&&t.isCallStart?"contained":"outlined",sx:X(l({},n),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{M(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(t!=null&&t.isCallStart),children:s(ee,{children:s(Jo,{sx:{visibility:"hidden"}})})})})]})})]},t.line)};function es({open:t,setOpen:o}){var b;let e=ye(),{showToast:n}=Ae(),[r,c]=me(!1),p=()=>{o(!1)},m=()=>{var h,g,i,C;c(!0);let u={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(g=(h=e.callData)==null?void 0:h.agent_id)!=null?g:"",process:(C=(i=e.callData)==null?void 0:i.process_name)!=null?C:""};Z.post(k.CONFERENCE_CALL_END_ALL,u).then(x=>{var v;n((v=x.data)==null?void 0:v.message,"success"),E.resetConferenceLines(),p()}).catch(x=>{var P,N,w,D;let v=((N=(P=x.response)==null?void 0:P.data)==null?void 0:N.detail)||((D=(w=x.response)==null?void 0:w.data)==null?void 0:D.message)||x.message||"An unknown error occurred";n(v,"error")}).finally(()=>{c(!1)})};return Zo(()=>{var h,g,i,C;let u={line:1,status:(g=(h=e.callData)==null?void 0:h.status)!=null?g:"",type:"internal",phone:(C=(i=e.callData)==null?void 0:i.phone_number)!=null?C:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};E.setConferenceLine(u)},[]),s(Ue,{children:s(et,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:A(Oe,{sx:{borderRadius:2},children:[A(V,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px"},children:[A(ee,{variant:"body1",children:[(b=e==null?void 0:e.agentId)!=null?b:""," conference"]}),s(Ce,{onClick:p,children:s(ut,{})})]}),s(V,{sx:{boxShadow:"1px 1px 2px #e7e5e5ff",margin:"0px 15px",borderRadius:"20px"},children:s(Vs,{component:Oe,sx:{outline:"0px solid gray !important",boxShadow:"1px 1px 6px #e7e5e5ff"},children:A(Qs,{sx:{border:"4px solid #ffffff !important"},children:[s(Zs,{children:A(Qo,{sx:{border:"2px solid #f3f3f3ff !important"},children:[s(de,{sx:{padding:"6px"},children:"Line"}),s(de,{sx:{padding:"6px"},children:"Status"}),s(de,{sx:{padding:"6px"},children:"Call Type"}),s(de,{sx:{padding:"6px"},children:"Mobile Number"}),s(de,{sx:{padding:"6px"},children:"Call Actions"})]})}),s(en,{children:e==null?void 0:e.conferenceLine.map(u=>s(tn,{each:u}))})]})})}),s(V,{textAlign:"center",m:2,children:A(se,{variant:"outlined",color:"error",size:"large",onClick:m,disabled:r,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[r?s(Se,{size:"20px",color:"error",sx:{marginRight:"8px"}}):s(Ce,{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:s(js,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function ts({open:t,setOpen:o}){var i,C,x,v,P,N,w,D,O,Q,M,I;let[e]=ae({onSuccess:f=>{console.log("res",f),o(!1)},onError:f=>{console.log("error",f)}}),n=ye(),[r,c]=me("process"),[p,{data:m}]=ae(),[b,{data:u}]=ae(),h=()=>{o(!1)},g=(f,H)=>{var te,oe,L,y,R,q,$,W,F,K,_,T,B,G,J,Y,ce,Be,Te,He,Le,$e,De,ze,qe,Fe,Ie,We,Ke,Ge,Ye,je,Xe;if(console.log(f,"data34"),H==="PROCESS"){let xe={mobile_number:(oe=(te=n.callData)==null?void 0:te.phone_number)!=null?oe:"",userid:(y=(L=n.callData)==null?void 0:L.agent_id)!=null?y:"",type:"PROCESS",transfer_to:(R=f==null?void 0:f.process_name)!=null?R:"",callreferenceid:($=(q=n.callData)==null?void 0:q.convox_id)!=null?$:"",processid:String((F=(W=n.callData)==null?void 0:W.process_id)!=null?F:""),process_name:(_=(K=n.callData)==null?void 0:K.process_name)!=null?_:""};e(k.TRANSFER_CALL,xe)}else if(H==="QUEUE"){let xe={mobile_number:(B=(T=n.callData)==null?void 0:T.phone_number)!=null?B:"",userid:(J=(G=n.callData)==null?void 0:G.agent_id)!=null?J:"",type:"QUEUE",transfer_to:(Y=f==null?void 0:f.queue_name)!=null?Y:"",callreferenceid:(Be=(ce=n.callData)==null?void 0:ce.convox_id)!=null?Be:"",processid:String((He=(Te=n.callData)==null?void 0:Te.process_id)!=null?He:""),process_name:($e=(Le=n.callData)==null?void 0:Le.process_name)!=null?$e:""};e(k.TRANSFER_CALL,xe)}else if(H==="AGENT"){let xe={mobile_number:(ze=(De=n.callData)==null?void 0:De.phone_number)!=null?ze:"",userid:(Fe=(qe=n.callData)==null?void 0:qe.agent_id)!=null?Fe:"",type:"AGENT",transfer_to:(Ie=f==null?void 0:f.user_id)!=null?Ie:"",callreferenceid:(Ke=(We=n.callData)==null?void 0:We.convox_id)!=null?Ke:"",processid:String((Ye=(Ge=n.callData)==null?void 0:Ge.process_id)!=null?Ye:""),process_name:(Xe=(je=n.callData)==null?void 0:je.process_name)!=null?Xe:""};e(k.TRANSFER_CALL,xe)}};return Zo(()=>{p(k.AGENTS_LIST,{status:"IDLE",active:!0}),b(k.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),console.log(m,"idleAgentsList"),s(Ue,{children:s(et,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:A(Oe,{sx:{borderRadius:2},children:[A(V,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[s(ee,{variant:"body1",children:" Call Transfer"}),s(Ce,{onClick:h,children:s(ut,{})})]}),A(V,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[A(V,{sx:{display:"flex",gap:1},children:[s(se,{variant:r==="process"?"contained":"outlined",onClick:()=>c("process"),children:"Process"}),s(se,{variant:r==="queues"?"contained":"outlined",onClick:()=>c("queues"),children:"Queues"}),s(se,{variant:r==="agents"?"contained":"outlined",onClick:()=>c("agents"),children:"Agents"})]}),r==="process"&&s(V,{sx:{display:"flex",gap:1},children:(i=u==null?void 0:u.data)!=null&&i.process&&((x=(C=u==null?void 0:u.data)==null?void 0:C.process)==null?void 0:x.length)>0?(P=(v=u==null?void 0:u.data)==null?void 0:v.process)==null?void 0:P.map((f,H)=>A(V,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[A(ee,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(pt,{sx:{marginRight:"4px"}}),f.process_name]}),s(Ce,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{g(f,"PROCESS")},children:s(Ze,{})})]},H)):s(ee,{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"&&s(V,{sx:{display:"flex",gap:1},children:(N=u==null?void 0:u.data)!=null&&N.queue&&((D=(w=u==null?void 0:u.data)==null?void 0:w.queue)==null?void 0:D.length)>0?(Q=(O=u==null?void 0:u.data)==null?void 0:O.queue)==null?void 0:Q.map((f,H)=>{var te,oe,L,y,R,q;return A(V,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[A(ee,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(pt,{sx:{marginRight:"4px"}}),f.queue_name,(L=(oe=(te=u==null?void 0:u.data)==null?void 0:te.process)==null?void 0:oe.find($=>$.process_id===f.process_id))!=null&&L.process_name?s(ee,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((q=(R=(y=u==null?void 0:u.data)==null?void 0:y.process)==null?void 0:R.find($=>$.process_id===f.process_id))==null?void 0:q.process_name)+")"}):""]}),s(Ce,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{g(f,"QUEUE")},children:s(Ze,{})})]},H)}):s(ee,{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"&&s(V,{sx:{display:"flex",gap:1},children:m!=null&&m.data&&((M=m==null?void 0:m.data)==null?void 0:M.length)>0?(I=m==null?void 0:m.data)==null?void 0:I.map((f,H)=>A(V,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[A(ee,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(pt,{sx:{marginRight:"4px"}}),f.name]}),s(Ce,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{g(f,"AGENT")},children:s(Ze,{})})]},H)):s(ee,{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 os({open:t,setOpen:o,onSubmitDisposition:e}){var h,g;let[n,r]=me({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),c=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],p=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],m=(i,C)=>{r(x=>X(l({},x),{[i]:C}))},b=()=>{r({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},u=()=>{b(),o(!1)};return s(Ue,{children:s(et,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:A(Oe,{sx:{borderRadius:2},children:[s(V,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:A(ee,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),s(V,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:A(be,{container:!0,spacing:2,children:[s(be,{size:6,children:s(Vo,{value:n.disposition,options:c,getOptionLabel:i=>i.label,onChange:(i,C)=>m("disposition",C),size:"small",renderInput:i=>s(ve,X(l({},i),{label:"Disposition",fullWidth:!0}))})}),s(be,{size:6,children:s(Vo,{options:p,getOptionLabel:i=>i.label,value:n.followUp,onChange:(i,C)=>m("followUp",C),size:"small",renderInput:i=>s(ve,X(l({},i),{label:"Follow Up",fullWidth:!0}))})}),((g=(h=n==null?void 0:n.followUp)==null?void 0:h.label)==null?void 0:g.toLowerCase())==="yes"&&A(Ue,{children:[s(be,{size:6,children:s(ve,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:n.callbackDate,onChange:i=>m("callbackDate",i.target.value),fullWidth:!0})}),s(be,{size:6,children:s(ve,{size:"small",label:"Hours (0-23)",type:"text",inputProps:{min:0,max:23},value:n.callbackHrs,onChange:i=>m("callbackHrs",i.target.value),fullWidth:!0})}),s(be,{size:6,children:s(ve,{size:"small",label:"Minutes (0-59)",type:"text",inputProps:{min:0,max:59},value:n.callbackMins,onChange:i=>m("callbackMins",i.target.value),fullWidth:!0})})]})]})}),A(V,{textAlign:"right",m:2,children:[s(se,{variant:"outlined",color:"error",size:"large",onClick:u,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),s(se,{variant:"contained",color:"primary",size:"large",onClick:()=>e(n),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function ss({open:t,setOpen:o}){return s(Ue,{children:s(et,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:A(Oe,{sx:{borderRadius:2},children:[A(V,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[s(ee,{variant:"body1",children:" Call History"}),s(Ce,{onClick:()=>{o(!1)},children:s(ut,{})})]}),s(V,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",margin:"10px",borderRadius:"10px",textAlign:"center",fontSize:"16px",fontWeight:"bold"},p:6,children:"Coming Soon..."})]})})})}import{Fragment as Sn,jsx as d,jsxs as pe}from"react/jsx-runtime";function cs({onDataChange:t}){var xt,Ct,ht,yt,bt,vt,St,Et,Tt,Lt,Dt,It,_t,wt,Rt,kt,Nt,At,Pt,Ot,Ut,Mt,Bt,Ht,$t,zt,qt,Ft,Wt,Kt,Gt,Yt,jt,Xt,Jt,Vt,Qt,Zt,eo,to,oo,so,no,ao,io,lo,ro,co,po,uo,go,fo,mo,xo,Co,ho,yo,bo,vo,So,Eo,To,Lo,Do,Io,_o,wo,Ro,ko,No,Ao,Po;let o=yn(),e=ye(),{disabled:n,enabled:r,outlined:c}=Qe({disabled:((xt=e.sdkConfig)==null?void 0:xt.disabled)||{},enabled:((Ct=e.sdkConfig)==null?void 0:Ct.enabled)||{},outlined:((ht=e.sdkConfig)==null?void 0:ht.outlined)||{}}),p=vn(null),[m,b]=re(null),[u,h]=re(!0),[g,i]=re(null),[C,x]=re(null),[v,P]=re(!1),[N,w]=re(!1),[D,O]=re(!1),[Q,M]=re(!1),[I,f]=re(!1),[H,te]=re(""),[oe,L]=re(0),{position:y,isDragging:R,dragRef:q,handleMouseDown:$,handleTouchStart:W}=ct(e.controlPanelPosition,a=>E.setControlPanelPosition(a)),{position:F,isDragging:K,dragRef:_,handleMouseDown:T,handleTouchStart:B}=ct(e.iframePosition,a=>E.setIframePosition(a)),[G,{data:J}]=ae({onSuccess:a=>{var S;console.log("res",a),a&&a.data&&((S=a==null?void 0:a.data)==null?void 0:S.length)>1?M(!0):(E.setProcess(a==null?void 0:a.data[0]),M(!1))},onError:()=>{M(!1)}}),[Y,{isLoading:ce}]=ae(),[Be,{isLoading:Te}]=ae({onSuccess:()=>{E.setHolding(!e.isHolding)},onError:a=>{console.log("error",a)}}),[He,{isLoading:Le}]=ae({onSuccess:()=>{E.setMuted(!e.isMuted)},onError:a=>{console.log("error",a)}}),[$e,{isLoading:De}]=ae(),[ze,{isLoading:qe}]=ae(),[Fe,{isLoading:Ie}]=ae(),We=bn(a=>{let S=Math.floor(a/60),j=a%60;return`${S.toString().padStart(2,"0")}:${j.toString().padStart(2,"0")}`},[]),Ke=()=>{b(null)},Ge=a=>{h(!0),x(a.currentTarget),E.setStatus("dial")},Ye=()=>{e.status!=="on call"&&E.setStatus("idle"),x(null)},je=a=>{i(a.currentTarget)},Xe=()=>{i(null)},xe=()=>{let a={action:"READYAGENT",userId:e.agentId};$e(k.READY_AGENT,a)},mt=a=>{i(null);let S={action:"AGENTBREAK",break_type:a,userId:e.agentId};ze(k.UPDATE_AGENT_BREAK,S)},us=a=>{if(a.length!==10)alert("Invalid phone number");else if(/^\d+$/.test(a)){let S={action:"CALL",phone_number:a,userId:e.agentId};Y(k.CLICK_TO_CALL,S)}},gs=()=>{let a={action:e.isHolding?"UNHOLD":"HOLD",userId:e.agentId};Be(k.HOLD_CALL,a)},fs=()=>{let a={action:e.isMuted?"UNMUTE":"MUTE",userId:e.agentId};He(k.MUTE_CALL,a)},ms=a=>{var j,ie,le,ge,fe,_e,we,Oo,Uo,Mo,Bo,Ho,$o,zo,qo,Fo;console.log("data",a);let S={action:"ENDCALL",userId:e.agentId,processid:(le=(ie=(j=e.process)==null?void 0:j.process_id)==null?void 0:ie.toString())!=null?le:"",process_name:(fe=(ge=e.process)==null?void 0:ge.process_name)!=null?fe:"",callreferenceid:(we=(_e=e.callData)==null?void 0:_e.convox_id)!=null?we:"",mobile_number:(Uo=(Oo=e.callData)==null?void 0:Oo.phone_number)!=null?Uo:"",disposition:(Bo=(Mo=a==null?void 0:a.disposition)==null?void 0:Mo.value)!=null?Bo:"",set_followUp:($o=(Ho=a==null?void 0:a.followUp)==null?void 0:Ho.value)!=null?$o:"",callback_date:(zo=a==null?void 0:a.callbackDate)!=null?zo:"",callback_hrs:(qo=a==null?void 0:a.callbackHrs)!=null?qo:"",callback_mins:(Fo=a==null?void 0:a.callbackMins)!=null?Fo:"",endcall_type:"CLOSE"};te(""),Fe(k.END_CALL,S),E.endCall(),O(!1)};return ot(()=>{let a;return e.callData.status&&e.callData.status==="ONCALL"?a=setInterval(()=>{let S=Math.floor((Date.now()-e.callStartTime)/1e3);L(S)},1e3):L(0),()=>{a&&clearInterval(a)}},[e.callData.status]),ot(()=>{t&&t(e.callData)},[e.callData,t]),ot(()=>{e.agentId?G(k.PROCESS_LIST,{userId:e.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[e.agentId]),ot(()=>(e.agentId&&(p.current=new WebSocket(`${Ko.WS}?agent_id=${e.agentId}`),p.current.onopen=()=>{console.log("WebSocket connection established")},p.current.onmessage=a=>{try{let S=JSON.parse(a.data);console.log("parsedJSON:",S),E.updateCallData(S),S.status==="ONCALL"&&E.startCall(),S.status==="WRAPUP"&&E.endCall()}catch(S){console.log("Raw message:",a.data)}},p.current.onclose=()=>{console.log("WebSocket connection closed")},p.current.onerror=a=>{console.error("WebSocket error:",a)}),()=>{var a;(a=p.current)==null||a.close()}),[e.agentId]),pe(Sn,{children:[d(as,{in:!0,timeout:300,children:d(ls,{ref:q,elevation:R?4:1,sx:{position:"fixed",left:y.x,top:y.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:pe(ue,{sx:{display:"flex",alignItems:"center"},children:[pe(ue,{sx:{display:"flex",alignItems:"center"},children:[pe(tt,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:$,onTouchStart:W,children:[d(ns,{})," "]}),d(ue,{sx:{marginRight:"10px"},children:d(he,{title:"Dial",children:d(tt,{size:"small",onClick:a=>{var S,j,ie,le,ge,fe,_e,we;((j=(S=e.callData)==null?void 0:S.status)==null?void 0:j.toUpperCase())!=="ONCALL"&&((le=(ie=e.callData)==null?void 0:ie.status)==null?void 0:le.toUpperCase())!=="BREAK"&&((fe=(ge=e.callData)==null?void 0:ge.status)==null?void 0:fe.toUpperCase())!=="RINGING"&&((we=(_e=e.callData)==null?void 0:_e.status)==null?void 0:we.toUpperCase())!=="WRAPUP"&&Ge(a)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:d(Cn,{sx:{color:((bt=(yt=e.callData)==null?void 0:yt.status)==null?void 0:bt.toUpperCase())==="ONCALL"||((St=(vt=e.callData)==null?void 0:vt.status)==null?void 0:St.toUpperCase())==="BREAK"||((Tt=(Et=e.callData)==null?void 0:Et.status)==null?void 0:Tt.toUpperCase())==="RINGING"||((Dt=(Lt=e.callData)==null?void 0:Lt.status)==null?void 0:Dt.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),d(rs,{sx:{color:"success.main",width:"40px",marginRight:"10px"},children:We(oe)}),qe||De?d(ue,{sx:{fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"},children:d(Me,{size:"20px"})}):d(rs,{variant:"body2",sx:{fontWeight:"bold",textAlign:"right"},children:(wt=(_t=(It=e.callData)==null?void 0:It.status)==null?void 0:_t.toUpperCase())!=null?wt:"N/A"}),d(ue,{onClick:je,sx:{display:"flex",alignItems:"center",margin:"6px",cursor:"pointer"},children:d(on,{})})]}),pe(ue,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[d(he,{title:"Agent Ready",children:d(Ee,{variant:((kt=(Rt=e.callData)==null?void 0:Rt.status)==null?void 0:kt.toUpperCase())==="BREAK"||((At=(Nt=e.callData)==null?void 0:Nt.status)==null?void 0:At.toUpperCase())==="MISSED"?"outlined":"contained",onClick:a=>{var S,j,ie,le;(((j=(S=e.callData)==null?void 0:S.status)==null?void 0:j.toUpperCase())==="BREAK"||((le=(ie=e.callData)==null?void 0:ie.status)==null?void 0:le.toUpperCase())==="MISSED")&&(a.stopPropagation(),xe())},classes:{root:((Ot=(Pt=e.callData)==null?void 0:Pt.status)==null?void 0:Ot.toUpperCase())==="BREAK"||((Mt=(Ut=e.callData)==null?void 0:Ut.status)==null?void 0:Mt.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:l({},((Ht=(Bt=e.callData)==null?void 0:Bt.status)==null?void 0:Ht.toUpperCase())==="BREAK"||((zt=($t=e.callData)==null?void 0:$t.status)==null?void 0:zt.toUpperCase())==="MISSED"?c:r),disabled:De,children:d(fn,{})})}),d(he,{title:e.isHolding?"Resume":"Hold",children:d(Ee,{variant:e.isHolding&&((Ft=(qt=e.callData)==null?void 0:qt.status)==null?void 0:Ft.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:a=>{a.stopPropagation(),gs()},sx:e.isHolding&&((Kt=(Wt=e.callData)==null?void 0:Wt.status)==null?void 0:Kt.toUpperCase())==="ONCALL"?l({},r):((Yt=(Gt=e.callData)==null?void 0:Gt.status)==null?void 0:Yt.toUpperCase())==="ONCALL"?l({},c):l({},n),disabled:((Xt=(jt=e.callData)==null?void 0:jt.status)==null?void 0:Xt.toUpperCase())!=="ONCALL"&&!e.isHolding||Te,children:Te?d(Me,{size:"20px",sx:{color:o.palette.primary.main}}):e.isHolding?d(gn,{}):d(dn,{})})}),d(he,{title:e.isMuted?"Unmute":"Mute",children:d(Ee,{variant:e.isMuted&&((Vt=(Jt=e.callData)==null?void 0:Jt.status)==null?void 0:Vt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:a=>{a.stopPropagation(),fs()},sx:e.isMuted&&((Zt=(Qt=e.callData)==null?void 0:Qt.status)==null?void 0:Zt.toUpperCase())==="ONCALL"?l({},r):((to=(eo=e.callData)==null?void 0:eo.status)==null?void 0:to.toUpperCase())==="ONCALL"?l({},c):l({},n),disabled:((so=(oo=e.callData)==null?void 0:oo.status)==null?void 0:so.toUpperCase())!=="ONCALL"&&!e.isMuted||Le,children:Le?d(Me,{size:"20px",sx:{color:o.palette.primary.main}}):e.isMuted?d(cn,{}):d(rn,{})})}),((no=e.sdkConfig)==null?void 0:no.showTransferButton)&&d(he,{title:"Transfer Call",children:d(Ee,{variant:N?"contained":"outlined",onClick:a=>{var S,j;((j=(S=e.callData)==null?void 0:S.status)==null?void 0:j.toUpperCase())==="ONCALL"&&(a.stopPropagation(),w(!0))},sx:N?l({},r):((io=(ao=e.callData)==null?void 0:ao.status)==null?void 0:io.toUpperCase())==="ONCALL"?l({},c):l({},n),disabled:((ro=(lo=e.callData)==null?void 0:lo.status)==null?void 0:ro.toUpperCase())!=="ONCALL",children:d(mn,{})})}),((co=e.sdkConfig)==null?void 0:co.showConferenceButton)&&d(he,{title:"Conference Call",children:d(Ee,{variant:v?"contained":"outlined",onClick:a=>{var S,j;((j=(S=e.callData)==null?void 0:S.status)==null?void 0:j.toUpperCase())==="ONCALL"&&(a.stopPropagation(),P(!0))},sx:v?l({},r):((uo=(po=e.callData)==null?void 0:po.status)==null?void 0:uo.toUpperCase())==="ONCALL"?l({},c):l({},n),disabled:((fo=(go=e.callData)==null?void 0:go.status)==null?void 0:fo.toUpperCase())!=="ONCALL",children:d(an,{})})}),((mo=e.sdkConfig)==null?void 0:mo.showEndCallButton)&&d(he,{title:"End Call",children:d(Ee,{variant:((Co=(xo=e.callData)==null?void 0:xo.status)==null?void 0:Co.toUpperCase())==="ONCALL"||((yo=(ho=e.callData)==null?void 0:ho.status)==null?void 0:yo.toUpperCase())==="RINGING"||((vo=(bo=e.callData)==null?void 0:bo.status)==null?void 0:vo.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:a=>{var S,j,ie,le,ge,fe;(((j=(S=e.callData)==null?void 0:S.status)==null?void 0:j.toUpperCase())==="ONCALL"||((le=(ie=e.callData)==null?void 0:ie.status)==null?void 0:le.toUpperCase())==="RINGING"||((fe=(ge=e.callData)==null?void 0:ge.status)==null?void 0:fe.toUpperCase())==="WRAPUP")&&(a.stopPropagation(),O(!0))},sx:((Eo=(So=e.callData)==null?void 0:So.status)==null?void 0:Eo.toUpperCase())==="ONCALL"||((Lo=(To=e.callData)==null?void 0:To.status)==null?void 0:Lo.toUpperCase())==="RINGING"||((Io=(Do=e.callData)==null?void 0:Do.status)==null?void 0:Io.toUpperCase())==="WRAPUP"?X(l({},r),{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}`}}):X(l({},n),{minWidth:"60px !important"}),disabled:((wo=(_o=e.callData)==null?void 0:_o.status)==null?void 0:wo.toUpperCase())!=="ONCALL"&&((ko=(Ro=e.callData)==null?void 0:Ro.status)==null?void 0:ko.toUpperCase())!=="RINGING"&&((Ao=(No=e.callData)==null?void 0:No.status)==null?void 0:Ao.toUpperCase())!=="WRAPUP"||Ie,children:Ie?d(Me,{size:"20px",color:"error"}):d(sn,{})})})]})]})})}),d(as,{in:!0,timeout:300,children:pe(ls,{ref:_,elevation:K?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:u?"visible":"hidden",userSelect:"none"},children:[pe(ue,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll"},onMouseDown:T,onTouchStart:B,children:[d(ns,{sx:{transform:"rotate(90deg)"}})," ",d(tt,{onClick:()=>h(!1),children:d(nn,{})})]}),d("iframe",{src:`https://${Je}/ConVoxCCS/iframe?agent_id=${e.agentId}&process_id=${(Po=e.process)==null?void 0:Po.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay",style:{border:"none"}})]})}),d(ft,{anchorEl:C,open:!!C,onClose:Ye,onClick:a=>a.stopPropagation(),sx:{zIndex:99999},children:pe(ue,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[d(hn,{size:"small",value:H,placeholder:"Enter Mobile No.",onChange:a=>{te(a.target.value)}}),d(tt,{color:"info",onClick:()=>{us(H)},children:ce?d(Me,{size:"20px",sx:{color:o.palette.success.main}}):d(un,{color:"success"})})]})}),pe(ft,{anchorEl:g,open:!!g,onClose:Xe,onClick:a=>a.stopPropagation(),sx:{zIndex:99999},children:[d(is,{onClick:()=>mt("Lunch"),children:"- Lunch"}),d(is,{onClick:()=>mt("Tea"),children:"- Tea"})]}),d(ft,{anchorEl:m,open:!!m,onClose:Ke,onClick:a=>a.stopPropagation(),sx:{zIndex:99999},children:pe(ue,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[d(gt,{icon:d(ln,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),d(gt,{icon:d(pn,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),d(gt,{icon:d(xn,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!v&&d(es,{open:v,setOpen:P}),!!N&&d(ts,{open:N,setOpen:w}),!!D&&d(os,{open:D,setOpen:O,onSubmitDisposition:ms}),!!I&&d(ss,{open:I,setOpen:f})]})}import{jsx as En}from"react/jsx-runtime";var ds=({children:t})=>En(Xo,{children:t});import{jsx as ps}from"react/jsx-runtime";function Tn({onDataChange:t}){return ps(ds,{children:ps(cs,{onDataChange:t})})}function ni({apiKey:t,tenantId:o,agentId:e,sdkConfig:n}){E.initialize(t,e,n),at.init({apiKey:t,tenantId:o,agentId:e,baseUrl:U}).then(r=>{console.log(r?"SDK initialized successfully":"SDK initialization failed")})}export{Tn as CallControlPanel,ni as initSDK,Rs as useClickToCall,_s as useEndCall,Ds as useLogout};
1
+ var Es=Object.defineProperty,Ts=Object.defineProperties;var Ls=Object.getOwnPropertyDescriptors;var Jo=Object.getOwnPropertySymbols;var Ds=Object.prototype.hasOwnProperty,Is=Object.prototype.propertyIsEnumerable;var nt=(t,o,e)=>o in t?Es(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,l=(t,o)=>{for(var e in o||(o={}))Ds.call(o,e)&&nt(t,e,o[e]);if(Jo)for(var e of Jo(o))Is.call(o,e)&&nt(t,e,o[e]);return t},Q=(t,o)=>Ts(t,Ls(o));var ne=(t,o,e)=>nt(t,typeof o!="symbol"?o+"":o,e);var at=class{constructor(){ne(this,"config",null);ne(this,"ticketId",null);ne(this,"baseUrl","");ne(this,"eventQueue",[]);ne(this,"isOnline",!0);ne(this,"retryQueue",[]);ne(this,"flushTimer",null)}async init(o){this.config=l({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 n={eventType:o,eventData:e,timestamp:Date.now()};if(this.eventQueue.push(n),this.eventQueue.length>(this.config.queueSize||100)&&this.eventQueue.shift(),this.isOnline)try{await this.sendEvent(n)}catch(c){console.warn("Failed to send event, will retry later:",c)}}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 n=this.eventQueue.findIndex(c=>c.timestamp===o.timestamp);n>-1&&this.eventQueue.splice(n,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 n of o)await this.sendEvent(n);let e=[...this.retryQueue];this.retryQueue=[];for(let n of e)try{await n()}catch(c){console.error("Retry failed:",c)}}async makeRequest(o,e){var r;let n=`${this.baseUrl}${o}`,c=((r=this.config)==null?void 0:r.retryAttempts)||3;for(let p=1;p<=c;p++)try{return await fetch(n,e)}catch(f){if(p===c)throw f;let y=Math.min(1e3*Math.pow(2,p-1),1e4);await new Promise(u=>setTimeout(u,y))}throw new Error("Max retries exceeded")}setupAutoTracking(){var n;if(typeof window=="undefined"||!((n=this.config)!=null&&n.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(c=>console.warn("Failed to track page visit:",c)),o.clicks!==!1&&document.addEventListener("click",c=>{var p;let r=c.target;(r.tagName==="BUTTON"||r.tagName==="A"||r.onclick||r.getAttribute("role")==="button"||r instanceof HTMLButtonElement&&r.type==="button")&&this.logEvent("click",{element:r.tagName,text:(p=r.textContent)==null?void 0:p.trim().substring(0,100),href:r.getAttribute("href"),id:r.id,className:r.className,role:r.getAttribute("role"),position:{x:c.clientX,y:c.clientY},timestamp:new Date().toISOString()}).catch(f=>console.warn("Failed to track click:",f))}),o.forms!==!1&&document.addEventListener("submit",c=>{let r=c.target,p=new FormData(r),f={};p.forEach((y,u)=>{f[u]=y.toString()}),this.logEvent("formSubmission",{formId:r.id,action:r.action,method:r.method,fields:Object.keys(f),fieldCount:Object.keys(f).length,timestamp:new Date().toISOString()}).catch(y=>console.warn("Failed to track form submission:",y))}),o.inputs!==!1){let c;document.addEventListener("input",r=>{let p=r.target;(p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.tagName==="SELECT")&&(clearTimeout(c),c=setTimeout(()=>{var f;this.logEvent("fieldChange",{element:p.tagName,type:p.getAttribute("type"),name:p.getAttribute("name"),id:p.id,valueLength:((f=p.value)==null?void 0:f.length)||0,timestamp:new Date().toISOString()}).catch(y=>console.warn("Failed to track field change:",y))},1e3))})}let e=Date.now();window.addEventListener("beforeunload",()=>{let c=Date.now()-e;this.logEvent("pageUnload",{url:window.location.href,sessionDuration:c,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",c=>{this.logEvent("jsError",{message:c.message,filename:c.filename,lineno:c.lineno,colno:c.colno,timestamp:new Date().toISOString()})}),window.addEventListener("unhandledrejection",c=>{var r;this.logEvent("unhandledRejection",{reason:(r=c.reason)==null?void 0:r.toString(),timestamp:new Date().toISOString()})})),o.performance!==!1&&typeof window.performance!="undefined"&&window.performance.navigation&&window.addEventListener("load",()=>{setTimeout(()=>{let c=window.performance.navigation,r=window.performance.timing;this.logEvent("performanceMetrics",{navigationTime:r.navigationStart,loadTime:r.loadEventEnd-r.navigationStart,domReady:r.domContentLoadedEventEnd-r.navigationStart,renderTime:r.loadEventEnd-r.domContentLoadedEventEnd,navigationType:c.type,redirectCount:c.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)}},it=new at;typeof window!="undefined"&&(window.EventTracker=it);var lt=class{constructor(){ne(this,"state");ne(this,"listeners",[]);ne(this,"STORAGE_KEY","call-control-sdk-state");this.state=this.getInitialState(),this.loadFromStorage()}getInitialState(){return{apiKey:null,process:null,agentId:"",isInitialized:!1,sdkConfig:{showEndCallButton:!0,showTransferButton:!0,enableFloatingDrag:!0,enableSoftPhone:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},isHolding:!1,isMuted:!1,status:"idle",callStartTime:null,controlPanelPosition:{x:10,y:10},iframePosition:{x:10,y:80},callData:{agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:[{line:1,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:2,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:3,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:4,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1},{line:5,status:"IDLE",type:"",phone:"",isMute:!1,isHold:!1,isCallStart:!1,isMergeCall:!1}]}}loadFromStorage(){try{let o=localStorage.getItem(this.STORAGE_KEY);if(o){let e=JSON.parse(o);this.state=Q(l({},this.state),{apiKey:e.apiKey||"",agentId:e.agentId||"",process:e.process||null,isInitialized:e.isInitialized||!1,sdkConfig:e.sdkConfig||{showEndCallButton:!0,showTransferButton:!0,enableFloatingDrag:!0,enableSoftPhone:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},isHolding:e.isHolding||!1,isMuted:e.isMuted||!1,status:e.status||"idle",callStartTime:e.callStartTime||null,controlPanelPosition:e.controlPanelPosition||{x:10,y:10},iframePosition:e.iframePosition||{x:10,y:80},callData:e.callData||{mobileNumber:"",callReferenceId:"",agent_id:"",status:"",type:"",event_time:"",phone_number:""},conferenceLine:e.conferenceLine&&Array.isArray(e.conferenceLine)&&e.conferenceLine.length>0?e.conferenceLine:this.state.conferenceLine})}}catch(o){console.warn("Failed to load SDK state from localStorage:",o)}}saveToStorage(){try{let o={apiKey:this.state.apiKey,agentId:this.state.agentId,process:this.state.process,isInitialized:this.state.isInitialized,sdkConfig:this.state.sdkConfig,isHolding:this.state.isHolding,isMuted:this.state.isMuted,status:this.state.status,callStartTime:this.state.callStartTime,controlPanelPosition:this.state.controlPanelPosition,iframePosition:this.state.iframePosition,callData:this.state.callData,conferenceLine:this.state.conferenceLine};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(o))}catch(o){console.warn("Failed to save SDK state to localStorage:",o)}}notifyListeners(){this.listeners.forEach(o=>o())}initialize(o,e,n){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=l({showEndCallButton:!0,showTransferButton:!0,enableFloatingDrag:!0,enableSoftPhone:!0,showConferenceButton:!0,disabled:{},enabled:{},outlined:{}},n),this.state.isInitialized=!0,this.saveToStorage(),this.notifyListeners()}getState(){return l({},this.state)}subscribe(o){return this.listeners.push(o),()=>{let e=this.listeners.indexOf(o);e>-1&&this.listeners.splice(e,1)}}setHolding(o){this.state.isHolding=o,this.saveToStorage(),this.notifyListeners()}setMuted(o){this.state.isMuted=o,this.saveToStorage(),this.notifyListeners()}setStatus(o){this.state.status=o,this.saveToStorage(),this.notifyListeners()}setProcess(o){this.state.process=o,this.saveToStorage(),this.notifyListeners()}setControlPanelPosition(o){this.state.controlPanelPosition=o,this.saveToStorage(),this.notifyListeners()}setIframePosition(o){this.state.iframePosition=o,this.saveToStorage(),this.notifyListeners()}startCall(){this.state.callStartTime=Date.now(),this.state.status="on call",this.saveToStorage(),this.notifyListeners()}endCall(){this.state.callStartTime=null,this.state.status="idle",this.state.isHolding=!1,this.state.isMuted=!1,this.saveToStorage(),this.notifyListeners()}setInitCheck(){this.state.isInitialized=!1,this.saveToStorage(),this.notifyListeners()}updateCallData(o){this.state.callData=l(l({},this.state.callData),o),this.saveToStorage(),this.notifyListeners()}setConferenceLine(o){var n;(!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=(n=this.state.conferenceLine)==null?void 0:n.map(c=>c.line===o.line?o:c);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||[]}},v=new lt;import{useCallback as ks,useState as we}from"react";var Je="10.10.102.42",U=`http://${Je}:8095`,_s=`ws://${Je}:8095`,F={v1:"/api/v1"},D={LOGIN:`${U}${F.v1}/cti/login?provider=convox`,READY_AGENT:`${U}${F.v1}/cti/ready-agent?provider=convox`,UPDATE_AGENT_BREAK:`${U}${F.v1}/cti/update-agent-status?provider=convox`,CLICK_TO_CALL:`${U}${F.v1}/cti/calls?provider=convox`,HOLD_CALL:`${U}${F.v1}/cti/calls/hold?provider=convox`,MUTE_CALL:`${U}${F.v1}/cti/calls/mute?provider=convox`,UNMUTE_CALL:`${U}${F.v1}/cti/unmute-call?provider=convox`,END_CALL:`${U}${F.v1}/cti/calls/end?provider=convox`,LOGOUT:`${U}${F.v1}/cti/logout?provider=convox`,CONFERENCE_CALL:`${U}${F.v1}/cti/calls/conference?provider=convox`,CONFERENCE_CALL_HOLD_OR_UN_HOLD:`${U}${F.v1}/cti/calls/conference/hold?provider=convox`,CONFERENCE_CALL_MUTE_OT_UN_MUTE:`${U}${F.v1}/cti/calls/conference/mute?provider=convox`,CONFERENCE_CALL_END:`${U}${F.v1}/cti/calls/conference/hangup?provider=convox`,CONFERENCE_CALL_END_ALL:`${U}${F.v1}/cti/calls/conference/hangup/all?provider=convox`,TRANSFER_CALL:`${U}${F.v1}/cti/calls/transfer?provider=convox`,AGENTS_LIST:`${U}${F.v1}/cti/users`,PROCESS_LIST:`${U}${F.v1}/cti/processes-list`,TRANSFER_TO_DETAILS:`${U}${F.v1}/cti/transfer-to-details?provider=convox`,CALL_HISTORY:`${U}${F.v1}/dashboard/call-history`,SENTIMENTAL_ANALYSIS:`${U}${F.v1}/users/get_sentiment_analysis`},Vo={WS:`${_s}${F.v1}/cti/ws`};import Rs from"axios";var ws="12345",rt=Rs.create({baseURL:U,headers:{"Content-Type":"application/json",Authorization:ws},timeout:6e4});rt.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))));rt.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 ee=rt;var As=()=>{let[t,o]=we(!1),[e,n]=we(!1),[c,r]=we(!1),[p,f]=we(null),[y,u]=we(null);return{logout:ks(async()=>{var h;let g=JSON.parse((h=localStorage.getItem("call-control-sdk-state"))!=null?h:"");o(!0);let i={action:"LOGOUTUSER",userId:g.agentId||""};return ee.post(D.LOGOUT,i).then(x=>(v.clearStorageAndReset(),localStorage.clear(),sessionStorage.clear(),u(x==null?void 0:x.data),n(!0),x==null?void 0:x.data)).catch(x=>{var S;return r(!0),f(x),(S=x==null?void 0:x.response)==null?void 0:S.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:c,error:p,data:y}},Ns=As;import{useCallback as Ps,useState as ke}from"react";var Os=()=>{let[t,o]=ke(!1),[e,n]=ke(!1),[c,r]=ke(!1),[p,f]=ke(null),[y,u]=ke(null);return{handleEndCall:Ps(async g=>{var x,S,P,N,k,_,O,K,M,R,m,$,te,oe,L;let i=JSON.parse((x=localStorage.getItem("call-control-sdk-state"))!=null?x:"");o(!0);let h={action:"ENDCALL",userId:i==null?void 0:i.agentId,processid:(N=(P=(S=i==null?void 0:i.process)==null?void 0:S.process_id)==null?void 0:P.toString())!=null?N:"",process_name:(_=(k=i==null?void 0:i.process)==null?void 0:k.process_name)!=null?_:"",callreferenceid:(K=(O=i==null?void 0:i.callData)==null?void 0:O.convox_id)!=null?K:"",mobile_number:(R=(M=i==null?void 0:i.callData)==null?void 0:M.phone_number)!=null?R:"",disposition:(m=g==null?void 0:g.disposition)!=null?m:"RES",set_followUp:($=g==null?void 0:g.followUp)!=null?$:"N",callback_date:(te=g==null?void 0:g.callbackDate)!=null?te:"",callback_hrs:(oe=g==null?void 0:g.callbackHrs)!=null?oe:"",callback_mins:(L=g==null?void 0:g.callbackMins)!=null?L:"",endcall_type:"CLOSE"};return ee.post(D.END_CALL,h).then(b=>(v.endCall(),u(b==null?void 0:b.data),n(!0),b==null?void 0:b.data)).catch(b=>{var A;return r(!0),f(b),(A=b==null?void 0:b.response)==null?void 0:A.data}).finally(()=>{o(!1)})},[]),isLoading:t,isSuccess:e,isError:c,error:p,data:y}};import{useCallback as Ms,useState as Ae}from"react";var Us=()=>{let[t,o]=Ae(!1),[e,n]=Ae(!1),[c,r]=Ae(!1),[p,f]=Ae(null),[y,u]=Ae(null);return{handleStartCall:Ms(async g=>{var h,x,S,P,N,k,_,O,K;let i=JSON.parse((h=localStorage.getItem("call-control-sdk-state"))!=null?h:"");if(o(!0),((x=i==null?void 0:i.callData)==null?void 0:x.status)==="IDLE"){let M={action:"CALL",userId:i==null?void 0:i.agentId,phone_number:g==null?void 0:g.mobileNumber};return ee.post(D.CLICK_TO_CALL,M).then(R=>(u(R==null?void 0:R.data),n(!0),R==null?void 0:R.data)).catch(R=>{var m;return r(!0),f(R),(m=R==null?void 0:R.response)==null?void 0:m.data}).finally(()=>{o(!1)})}else if(((S=i==null?void 0:i.callData)==null?void 0:S.status)==="ONCALL"){let M=(N=(P=i==null?void 0:i.conferenceLine)==null?void 0:P.filter(m=>m.line!==1))==null?void 0:N.find(m=>m.status==="IDLE"&&!(m!=null&&m.isCallStart)),R={action:"EXTERNAL_CONFERENCE",operation:`CALL${M.line}`,line_used:String(M.line),thirdparty_no:g==null?void 0:g.mobileNumber,userid:(_=(k=i.callData)==null?void 0:k.agent_id)!=null?_:"",process:(K=(O=i.callData)==null?void 0:O.process_name)!=null?K:""};return ee.post(D.CONFERENCE_CALL,R).then(m=>(u(m==null?void 0:m.data),n(!0),v.setConferenceLine(Q(l({},M),{isCallStart:!0,status:"ONCALL",phone:g==null?void 0:g.mobileNumber})),m==null?void 0:m.data)).catch(m=>{var $;return r(!0),f(m),($=m==null?void 0:m.response)==null?void 0:$.data}).finally(()=>{o(!1)})}else alert("Agent is not ready")},[]),isLoading:t,isSuccess:e,isError:c,error:p,data:y}};import{ArrowDropDown as dn,CallEnd as pn,Close as un,DragIndicator as ps,Group as gn,Layers as fn,Mic as mn,MicOff as xn,Pause as Cn,Pending as hn,Phone as yn,PlayArrow as bn,SupportAgent as vn,TransferWithinAStation as Sn,Upcoming as En,WifiCalling3 as Tn}from"@mui/icons-material";import{Box as ie,Button as Ee,Chip as ut,CircularProgress as Ue,Fade as us,IconButton as ot,Menu as gt,MenuItem as gs,Paper as fs,TextField as Ln,Tooltip as he,Typography as ms,useTheme as Dn}from"@mui/material";import{useCallback as In,useEffect as st,useRef as _n,useState as ce}from"react";import{useCallback as Ve,useRef as ct,useState as Qo}from"react";function dt(t,o){let[e,n]=Qo(t),[c,r]=Qo(!1),p=ct(),f=ct({x:0,y:0}),y=ct({x:0,y:0}),u=Ve(h=>{let x=p.current;if(!x)return;let S=x.getBoundingClientRect(),P=window.innerWidth,N=window.innerHeight,k={x:Math.max(0,Math.min(h.x,P-S.width)),y:Math.max(0,Math.min(h.y,N-S.height))};n(k),o==null||o(k)},[o]),C=Ve((h,x)=>{r(!0),f.current={x:h,y:x},y.current=e;let S=(_,O)=>{let K=_-f.current.x,M=O-f.current.y;u({x:y.current.x+K,y:y.current.y+M})},P=_=>{_.preventDefault(),S(_.clientX,_.clientY)},N=_=>{_.preventDefault();let O=_.touches[0];O&&S(O.clientX,O.clientY)},k=()=>{r(!1),document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",k),document.removeEventListener("touchmove",N),document.removeEventListener("touchend",k)};document.addEventListener("mousemove",P),document.addEventListener("mouseup",k),document.addEventListener("touchmove",N,{passive:!1}),document.addEventListener("touchend",k)},[e,u]),g=Ve(h=>{h.preventDefault(),C(h.clientX,h.clientY)},[C]),i=Ve(h=>{h.preventDefault();let x=h.touches[0];x&&C(x.clientX,x.clientY)},[C]);return{position:e,isDragging:c,dragRef:p,handleMouseDown:g,handleTouchStart:i}}import{useState as Bs,useEffect as Hs}from"react";function ye(){let[t,o]=Bs(v.getState());return Hs(()=>v.subscribe(()=>{o(v.getState())}),[]),t}import{useCallback as Ks,useReducer as Gs}from"react";import{createContext as $s,useContext as zs,useState as pt}from"react";import{Snackbar as Fs,Alert as qs}from"@mui/material";import{jsx as Zo,jsxs as Ws}from"react/jsx-runtime";var es=$s(void 0),Ne=()=>{let t=zs(es);if(!t)throw new Error("useToast must be used inside ToastProvider");return t},ts=({children:t})=>{let[o,e]=pt(!1),[n,c]=pt(""),[r,p]=pt("info"),f=(y,u="info")=>{c(y),p(u),e(!0)};return Ws(es.Provider,{value:{showToast:f},children:[t,Zo(Fs,{open:o,color:r,autoHideDuration:3e3,onClose:()=>e(!1),anchorOrigin:{vertical:"top",horizontal:"right"},children:Zo(qs,{variant:"filled",severity:r,onClose:()=>e(!1),sx:{width:"100%"},children:n})})]})};var Ys={isLoading:!1,isSuccess:!1,isError:!1,error:null,data:null},js=(t,o)=>{if(o.type==="isLoading")return Q(l({},t),{isLoading:o.payload});if(o.type==="isSuccess")return Q(l({},t),{isSuccess:!0,data:o.payload});if(o.type==="isError")return Q(l({},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 ae=(t={})=>{let{onSuccess:o=null,onError:e=null}=t,{showToast:n}=Ne(),[c,r]=Gs(js,Ys);return[Ks((f,y,u={})=>{r({type:"isLoading",payload:!0}),ee.post(f,y,u).then(C=>{var g,i;r({type:"isSuccess",payload:C.data}),o==null||o(C.data,y),console.log((g=C.data)==null?void 0:g.message,"res45"),n((i=C.data)==null?void 0:i.message,"success")}).catch(C=>{var i,h,x,S,P,N,k,_,O,K,M,R;let g={status:(h=(i=C.response)==null?void 0:i.status)!=null?h:500,message:((S=(x=C.response)==null?void 0:x.data)==null?void 0:S.detail)||((N=(P=C.response)==null?void 0:P.data)==null?void 0:N.message)||C.message||"An unknown error occurred",data:(_=(k=C.response)==null?void 0:k.data)!=null?_:null,statusText:(K=(O=C.response)==null?void 0:O.statusText)!=null?K:"",code:(M=C==null?void 0:C.code)!=null?M:"",name:(R=C==null?void 0:C.name)!=null?R:""};n(g.message,"error"),r({type:"isError",payload:g}),e==null||e(g,y)}).finally(()=>{r({type:"isLoading",payload:!1})})},[o,e,n]),c]};import{Call as Ze,CallEnd as os,CallSplit as Vs,Close as tt,Mic as Qs,MicOff as Zs,Pause as en,PhoneDisabled as tn,PlayArrow as on,SupportAgent as et}from"@mui/icons-material";import{Box as H,Button as se,Dialog as Oe,IconButton as xe,Paper as Se,TextField as be,Typography as Z,Autocomplete as ss,Tooltip as Pe,useTheme as sn,TableContainer as nn,Table as an,TableHead as ln,TableRow as ns,TableCell as pe,TableBody as rn,CircularProgress as ve}from"@mui/material";import{useEffect as as,useState as me}from"react";import{useTheme as Xs}from"@mui/material";var Js=({disabled:t,enabled:o,outlined:e})=>{let n=Xs();return{disabled:l({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 ${n.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${n.palette.primary.light}`}},t),enabled:l({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${n.palette.primary.main}`,height:"40px","&:hover":{boxShadow:" 0px 2px 1px rgba(0, 0, 0, 0.507)",border:`1px solid ${n.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${n.palette.primary.light}`}},o),outlined:l({padding:"0px",margin:"0px",minWidth:"40px !important",borderRadius:"16px",backgroundColor:n.palette.grey[200],boxShadow:`0px 2px 1px ${n.palette.primary.light}`,border:`0px solid ${n.palette.primary.main}`,height:"40px","&:hover":{boxShadow:`0px 2px 1px ${n.palette.primary.main}`,border:`0px solid ${n.palette.primary.main}`},"&:active":{bgcolor:"primary.main",boxShadow:`inset 1px -2px 4px ${n.palette.primary.light}`}},e)}},Qe=Js;import{Fragment as Me,jsx as s,jsxs as I}from"react/jsx-runtime";var cn=({each:t})=>{var R,m,$,te,oe;let o=ye(),{showToast:e}=Ne(),{disabled:n,enabled:c,outlined:r}=Qe({disabled:((R=o.sdkConfig)==null?void 0:R.disabled)||{},enabled:((m=o.sdkConfig)==null?void 0:m.enabled)||{},outlined:(($=o.sdkConfig)==null?void 0:$.outlined)||{}}),p=sn(),[f,y]=me(!1),[u,C]=me(!1),[g,i]=me(!1),[h,x]=me(!1),[S,P]=me(!1),N=(L,b)=>{v.setConferenceLine(l(l({},L),b))},k=(L,b)=>{var z,G,W,Y;let A=l(l({},L),b);y(!0);let q={action:"EXTERNAL_CONFERENCE",operation:`CALL${A.line}`,line_used:String(A.line),thirdparty_no:A.phone,userid:(G=(z=o.callData)==null?void 0:z.agent_id)!=null?G:"",process:(Y=(W=o.callData)==null?void 0:W.process_name)!=null?Y:""};ee.post(D.CONFERENCE_CALL,q).then(w=>{var T;e((T=w.data)==null?void 0:T.message,"success"),v.setConferenceLine(l(l({},L),b))}).catch(w=>{var B,j,X,J;let T=((j=(B=w.response)==null?void 0:B.data)==null?void 0:j.detail)||((J=(X=w.response)==null?void 0:X.data)==null?void 0:J.message)||w.message||"An unknown error occurred";e(T,"error")}).finally(()=>{y(!1)})},_=(L,b)=>{var z,G,W,Y;let A=l(l({},L),b);C(!0);let q={action:"EXTERNAL_CONFERENCE",operation:"CONFERENCE",line_used:String(A.line),thirdparty_no:A.phone,userid:(G=(z=o.callData)==null?void 0:z.agent_id)!=null?G:"",process:(Y=(W=o.callData)==null?void 0:W.process_name)!=null?Y:""};ee.post(D.CONFERENCE_CALL,q).then(w=>{var T;e((T=w.data)==null?void 0:T.message,"success"),v.setConferenceLine(l(l({},L),b))}).catch(w=>{var B,j,X,J;let T=((j=(B=w.response)==null?void 0:B.data)==null?void 0:j.detail)||((J=(X=w.response)==null?void 0:X.data)==null?void 0:J.message)||w.message||"An unknown error occurred";e(T,"error")}).finally(()=>{C(!1)})},O=(L,b,A)=>{var G,W,Y,w;let q=l(l({},L),b);i(!0);let z={action:"EXTERNAL_CONFERENCE",operation:A,hold_channel_no:A==="HOLDUSER"?`hold${q.line}`:`unhold${q.line}`,userid:(W=(G=o.callData)==null?void 0:G.agent_id)!=null?W:"",process:(w=(Y=o.callData)==null?void 0:Y.process_name)!=null?w:""};ee.post(D.CONFERENCE_CALL_HOLD_OR_UN_HOLD,z).then(T=>{var B;e((B=T.data)==null?void 0:B.message,"success"),v.setConferenceLine(l(l({},L),b))}).catch(T=>{var j,X,J,de;let B=((X=(j=T.response)==null?void 0:j.data)==null?void 0:X.detail)||((de=(J=T.response)==null?void 0:J.data)==null?void 0:de.message)||T.message||"An unknown error occurred";e(B,"error")}).finally(()=>{i(!1)})},K=(L,b,A)=>{var G,W,Y,w;let q=l(l({},L),b);x(!0);let z={action:"EXTERNAL_CONFERENCE",operation:A,channel_no:A==="MUTEUSER"?`mute${q.line}`:`play${q.line}`,userid:(W=(G=o.callData)==null?void 0:G.agent_id)!=null?W:"",thirdparty_no:q.phone,process:(w=(Y=o.callData)==null?void 0:Y.process_name)!=null?w:""};ee.post(D.CONFERENCE_CALL_MUTE_OT_UN_MUTE,z).then(T=>{var B;e((B=T.data)==null?void 0:B.message,"success"),v.setConferenceLine(l(l({},L),b))}).catch(T=>{var j,X,J,de;let B=((X=(j=T.response)==null?void 0:j.data)==null?void 0:X.detail)||((de=(J=T.response)==null?void 0:J.data)==null?void 0:de.message)||T.message||"An unknown error occurred";e(B,"error")}).finally(()=>{x(!1)})},M=(L,b)=>{var z,G,W,Y;let A=l(l({},L),b);P(!0);let q={action:"EXTERNAL_CONFERENCE",operation:"HANGUP_CHANNEL",line_used:String(A.line-1),user_type:`THIRDPARTY${A.line-1}`,thirdparty_no:A.phone,userid:(G=(z=o.callData)==null?void 0:z.agent_id)!=null?G:"",process:(Y=(W=o.callData)==null?void 0:W.process_name)!=null?Y:""};ee.post(D.CONFERENCE_CALL_END,q).then(w=>{var T;e((T=w.data)==null?void 0:T.message,"success"),v.setConferenceLine(l(l({},L),b))}).catch(w=>{var B,j,X,J;let T=((j=(B=w.response)==null?void 0:B.data)==null?void 0:j.detail)||((J=(X=w.response)==null?void 0:X.data)==null?void 0:J.message)||w.message||"An unknown error occurred";e(T,"error")}).finally(()=>{P(!1)})};return I(ns,{sx:{border:"2px solid #fff"},children:[s(pe,{sx:{padding:"6px"},children:I(Z,{children:["Line ",(te=t==null?void 0:t.line)!=null?te:"",". "]})}),s(pe,{sx:{padding:"6px"},children:s(Z,{variant:"body2",sx:{px:1,borderRadius:"10px",width:"80px",maxWidth:"100px"},children:(oe=t==null?void 0:t.status)!=null?oe:""})}),s(pe,{sx:{padding:"6px"},children:s(se,{sx:{textTransform:"capitalize"},size:"small",children:s(Z,{variant:"body2",children:(t==null?void 0:t.line)===1?"Internal":"External"})})}),s(pe,{sx:{padding:"6px"},children:s(be,{size:"small",placeholder:"Phone Number",value:(t==null?void 0:t.phone)||"",disabled:(t==null?void 0:t.line)===1,onChange:L=>{N(t,{phone:L.target.value})}})}),s(pe,{sx:{padding:"6px"},children:I(H,{sx:{display:"flex",alignItems:"center",justifyContent:"space-around"},children:[s(Pe,{title:"Call",children:s(se,{variant:t!=null&&t.isCallStart?"outlined":"contained",color:"success",sx:t!=null&&t.isCallStart?l({},n):Q(l({},c),{border:`0px solid ${p.palette.success.light}`,"&:hover":{bgcolor:"success.light",boxShadow:`0px 2px 1px ${p.palette.success.light}`,border:`0px solid ${p.palette.success.light}`},"&:active":{bgcolor:"success.light",boxShadow:`inset 1px -2px 4px ${p.palette.primary.light}`}}),onClick:()=>{k(t,{isCallStart:!0,status:"ONCALL"})},disabled:(t==null?void 0:t.isCallStart)||f,children:f?s(ve,{size:"20px",color:"success"}):s(Ze,{sx:{color:t!=null&&t.isCallStart?"default":"#e7e7e7ff"}})})}),s(Pe,{title:"Merge Call",children:s(se,{variant:t!=null&&t.isMergeCall?"contained":"outlined",sx:t!=null&&t.isMergeCall&&(t!=null&&t.isCallStart)?l({},n):t!=null&&t.isCallStart?l({},r):l({},n),onClick:()=>{_(t,{isMergeCall:!0,status:"ONCALL"})},disabled:!(t!=null&&t.isCallStart)||u,children:u?s(ve,{size:"20px",sx:{color:t!=null&&t.isMergeCall?"#e7e7e7ff":p.palette.primary.main}}):s(Vs,{})})}),s(Pe,{title:t.isHold?"Hold":"Un Hold",children:s(se,{variant:t!=null&&t.isHold?"contained":"outlined",sx:t!=null&&t.isHold&&(t!=null&&t.isCallStart)?l({},n):t!=null&&t.isCallStart?l({},r):l({},n),onClick:()=>{t.isHold?O(t,{isHold:!1},"UNHOLDUSER"):O(t,{isHold:!0},"HOLDUSER")},disabled:!(t!=null&&t.isCallStart)||g,children:g?s(ve,{size:"20px",sx:{color:p.palette.primary.main}}):t.isHold?s(on,{}):s(en,{})})}),s(Pe,{title:t.isMute?"Mute":"Un Mute",children:s(se,{variant:t!=null&&t.isMute?"contained":"outlined",sx:t!=null&&t.isMute&&(t!=null&&t.isCallStart)?l({},n):t!=null&&t.isCallStart?l({},r):l({},n),onClick:()=>{t.isMute?K(t,{isMute:!1},"PLAYUSER"):K(t,{isMute:!0},"MUTEUSER")},disabled:!(t!=null&&t.isCallStart)||h,children:h?s(ve,{size:"20px",sx:{color:p.palette.primary.main}}):t.isMute?s(Zs,{}):s(Qs,{})})}),s(Pe,{title:"End Call",children:(t==null?void 0:t.line)!==1?s(se,{variant:t!=null&&t.isCallStart?"contained":"outlined",color:"error",sx:t!=null&&t.isCallStart?Q(l({},c),{minWidth:"60px !important",border:`0px solid ${p.palette.error.light}`,"&:hover":{bgcolor:"error.light",boxShadow:`0px 2px 1px ${p.palette.error.light}`,border:`0px solid ${p.palette.error.light}`},"&:active":{bgcolor:"error.light",boxShadow:`inset 1px -2px 4px ${p.palette.primary.light}`}}):Q(l({},n),{minWidth:"60px !important"}),onClick:()=>{M(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(t!=null&&t.isCallStart)||S,children:S?s(ve,{size:"20px",color:"error"}):s(os,{})}):s(se,{variant:t!=null&&t.isCallStart?"contained":"outlined",sx:Q(l({},n),{visibility:"hidden",minWidth:"60px !important"}),onClick:()=>{M(t,{isCallStart:!1,isMergeCall:!1,isMute:!1,isHold:!1,status:"IDLE",phone:""})},disabled:!(t!=null&&t.isCallStart),children:s(Z,{children:s(os,{sx:{visibility:"hidden"}})})})})]})})]},t.line)};function is({open:t,setOpen:o}){var y;let e=ye(),{showToast:n}=Ne(),[c,r]=me(!1),p=()=>{o(!1)},f=()=>{var C,g,i,h;r(!0);let u={action:"EXTERNAL_CONFERENCE",operation:"ENDCONFERENCE",userid:(g=(C=e.callData)==null?void 0:C.agent_id)!=null?g:"",process:(h=(i=e.callData)==null?void 0:i.process_name)!=null?h:""};ee.post(D.CONFERENCE_CALL_END_ALL,u).then(x=>{var S;n((S=x.data)==null?void 0:S.message,"success"),v.resetConferenceLines(),p()}).catch(x=>{var P,N,k,_;let S=((N=(P=x.response)==null?void 0:P.data)==null?void 0:N.detail)||((_=(k=x.response)==null?void 0:k.data)==null?void 0:_.message)||x.message||"An unknown error occurred";n(S,"error")}).finally(()=>{r(!1)})};return as(()=>{var C,g,i,h;let u={line:1,status:(g=(C=e.callData)==null?void 0:C.status)!=null?g:"",type:"internal",phone:(h=(i=e.callData)==null?void 0:i.phone_number)!=null?h:"",isMute:!1,isHold:!1,isMergeCall:!1,isCallStart:!0};v.setConferenceLine(u)},[]),s(Me,{children:s(Oe,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:I(Se,{sx:{borderRadius:2},children:[I(H,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px"},children:[I(Z,{variant:"body1",children:[(y=e==null?void 0:e.agentId)!=null?y:""," conference"]}),s(xe,{onClick:p,children:s(tt,{})})]}),s(H,{sx:{boxShadow:"1px 1px 2px #e7e5e5ff",margin:"0px 15px",borderRadius:"20px"},children:s(nn,{component:Se,sx:{outline:"0px solid gray !important",boxShadow:"1px 1px 6px #e7e5e5ff"},children:I(an,{sx:{border:"4px solid #ffffff !important"},children:[s(ln,{children:I(ns,{sx:{border:"2px solid #f3f3f3ff !important"},children:[s(pe,{sx:{padding:"6px"},children:"Line"}),s(pe,{sx:{padding:"6px"},children:"Status"}),s(pe,{sx:{padding:"6px"},children:"Call Type"}),s(pe,{sx:{padding:"6px"},children:"Mobile Number"}),s(pe,{sx:{padding:"6px"},children:"Call Actions"})]})}),s(rn,{children:e==null?void 0:e.conferenceLine.map(u=>s(cn,{each:u}))})]})})}),s(H,{textAlign:"center",m:2,children:I(se,{variant:"outlined",color:"error",size:"large",onClick:f,disabled:c,sx:{px:2,borderRadius:"20px",textTransform:"capitalize"},children:[c?s(ve,{size:"20px",color:"error",sx:{marginRight:"8px"}}):s(xe,{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:s(tn,{sx:{color:"white",fontSize:"16px",fontWeight:"600"}})}),"End Conference"]})})]})})})}function ls({open:t,setOpen:o}){var i,h,x,S,P,N,k,_,O,K,M,R;let[e]=ae({onSuccess:()=>{o(!1)},onError:m=>{console.log("error",m)}}),n=ye(),[c,r]=me("process"),[p,{data:f}]=ae(),[y,{data:u}]=ae(),C=()=>{o(!1)},g=(m,$)=>{var te,oe,L,b,A,q,z,G,W,Y,w,T,B,j,X,J,de,Be,Te,He,Le,$e,De,ze,Fe,qe,Ie,We,Ke,Ge,Ye,je,Xe;if(console.log(m,"data34"),$==="PROCESS"){let Ce={mobile_number:(oe=(te=n.callData)==null?void 0:te.phone_number)!=null?oe:"",userid:(b=(L=n.callData)==null?void 0:L.agent_id)!=null?b:"",type:"PROCESS",transfer_to:(A=m==null?void 0:m.process_name)!=null?A:"",callreferenceid:(z=(q=n.callData)==null?void 0:q.convox_id)!=null?z:"",processid:String((W=(G=n.callData)==null?void 0:G.process_id)!=null?W:""),process_name:(w=(Y=n.callData)==null?void 0:Y.process_name)!=null?w:""};e(D.TRANSFER_CALL,Ce)}else if($==="QUEUE"){let Ce={mobile_number:(B=(T=n.callData)==null?void 0:T.phone_number)!=null?B:"",userid:(X=(j=n.callData)==null?void 0:j.agent_id)!=null?X:"",type:"QUEUE",transfer_to:(J=m==null?void 0:m.queue_name)!=null?J:"",callreferenceid:(Be=(de=n.callData)==null?void 0:de.convox_id)!=null?Be:"",processid:String((He=(Te=n.callData)==null?void 0:Te.process_id)!=null?He:""),process_name:($e=(Le=n.callData)==null?void 0:Le.process_name)!=null?$e:""};e(D.TRANSFER_CALL,Ce)}else if($==="AGENT"){let Ce={mobile_number:(ze=(De=n.callData)==null?void 0:De.phone_number)!=null?ze:"",userid:(qe=(Fe=n.callData)==null?void 0:Fe.agent_id)!=null?qe:"",type:"AGENT",transfer_to:(Ie=m==null?void 0:m.user_id)!=null?Ie:"",callreferenceid:(Ke=(We=n.callData)==null?void 0:We.convox_id)!=null?Ke:"",processid:String((Ye=(Ge=n.callData)==null?void 0:Ge.process_id)!=null?Ye:""),process_name:(Xe=(je=n.callData)==null?void 0:je.process_name)!=null?Xe:""};e(D.TRANSFER_CALL,Ce)}};return as(()=>{p(D.AGENTS_LIST,{status:"IDLE",active:!0}),y(D.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},[]),console.log(f,"idleAgentsList"),s(Me,{children:s(Oe,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:I(Se,{sx:{borderRadius:2},children:[I(H,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[s(Z,{variant:"body1",children:" Call Transfer"}),s(xe,{onClick:C,children:s(tt,{})})]}),I(H,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:[I(H,{sx:{display:"flex",gap:1},children:[s(se,{variant:c==="process"?"contained":"outlined",onClick:()=>{r("process"),y(D.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},children:"Process"}),s(se,{variant:c==="queues"?"contained":"outlined",onClick:()=>{r("queues"),y(D.TRANSFER_TO_DETAILS,{status:"ACTIVE",active:!0})},children:"Queues"}),s(se,{variant:c==="agents"?"contained":"outlined",onClick:()=>{r("agents"),p(D.AGENTS_LIST,{status:"IDLE",active:!0})},children:"Agents"})]}),c==="process"&&s(H,{sx:{display:"flex",gap:1},children:(i=u==null?void 0:u.data)!=null&&i.process&&((x=(h=u==null?void 0:u.data)==null?void 0:h.process)==null?void 0:x.length)>0?(P=(S=u==null?void 0:u.data)==null?void 0:S.process)==null?void 0:P.map((m,$)=>I(H,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[I(Z,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(et,{sx:{marginRight:"4px"}}),m.process_name]}),s(xe,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{g(m,"PROCESS")},children:s(Ze,{})})]},$)):s(Z,{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"})}),c==="queues"&&s(H,{sx:{display:"flex",gap:1},children:(N=u==null?void 0:u.data)!=null&&N.queue&&((_=(k=u==null?void 0:u.data)==null?void 0:k.queue)==null?void 0:_.length)>0?(K=(O=u==null?void 0:u.data)==null?void 0:O.queue)==null?void 0:K.map((m,$)=>{var te,oe,L,b,A,q;return I(H,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[I(Z,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(et,{sx:{marginRight:"4px"}}),m.queue_name,(L=(oe=(te=u==null?void 0:u.data)==null?void 0:te.process)==null?void 0:oe.find(z=>z.process_id===m.process_id))!=null&&L.process_name?s(Z,{variant:"body1",sx:{fontSize:"12px",fontWeight:"600",letterSpacing:"0.02em",textTransform:"capitalize",color:"gray"},children:"("+((q=(A=(b=u==null?void 0:u.data)==null?void 0:b.process)==null?void 0:A.find(z=>z.process_id===m.process_id))==null?void 0:q.process_name)+")"}):""]}),s(xe,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{g(m,"QUEUE")},children:s(Ze,{})})]},$)}):s(Z,{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"})}),c==="agents"&&s(H,{sx:{display:"flex",gap:1},children:f!=null&&f.data&&((M=f==null?void 0:f.data)==null?void 0:M.length)>0?(R=f==null?void 0:f.data)==null?void 0:R.map((m,$)=>I(H,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px","&:hover":{bgcolor:"action.selected"}},children:[I(Z,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(et,{sx:{marginRight:"4px"}}),m.name]}),s(xe,{color:"success",sx:{bgcolor:"action.hover","&:hover":{bgcolor:"action.selected"}},onClick:()=>{g(m,"AGENT")},children:s(Ze,{})})]},$)):s(Z,{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 rs({open:t,setOpen:o,onSubmitDisposition:e}){var C,g;let[n,c]=me({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""}),r=[{label:"Not Interested",value:"NI"},{label:"Resolved",value:"RES"}],p=[{label:"Yes",value:"Y"},{label:"No",value:"N"}],f=(i,h)=>{c(x=>Q(l({},x),{[i]:h}))},y=()=>{c({disposition:{label:"Resolved",value:"RES"},followUp:{label:"No",value:"N"},callbackDate:"",callbackHrs:"",callbackMins:""})},u=()=>{y(),o(!1)};return s(Me,{children:s(Oe,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"xs",children:I(Se,{sx:{borderRadius:2},children:[s(H,{sx:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:I(Z,{variant:"body1",m:1,children:[" ","Call Disposition"]})}),I(H,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"10px",margin:"10px",borderRadius:"10px"},children:[I(H,{display:"flex",gap:2,children:[s(ss,{value:n.disposition,options:r,getOptionLabel:i=>i.label,onChange:(i,h)=>f("disposition",h),size:"small",renderInput:i=>s(be,Q(l({},i),{label:"Disposition",fullWidth:!0})),sx:{flex:1}}),s(ss,{options:p,getOptionLabel:i=>i.label,value:n.followUp,onChange:(i,h)=>f("followUp",h),size:"small",renderInput:i=>s(be,Q(l({},i),{label:"Follow Up",fullWidth:!0})),sx:{flex:1}})]}),((g=(C=n==null?void 0:n.followUp)==null?void 0:C.label)==null?void 0:g.toLowerCase())==="yes"&&I(H,{display:"flex",gap:2,mt:2,children:[s(be,{size:"small",label:"Callback Date",type:"date",slotProps:{inputLabel:{shrink:!0}},value:n.callbackDate,onChange:i=>f("callbackDate",i.target.value),fullWidth:!0,sx:{flex:1}}),s(be,{size:"small",label:"Hours (0-23)",type:"number",inputProps:{min:0,max:23},value:n.callbackHrs,onChange:i=>f("callbackHrs",i.target.value),fullWidth:!0,sx:{flex:1}}),s(be,{size:"small",label:"Minutes (0-59)",type:"number",inputProps:{min:0,max:59},value:n.callbackMins,onChange:i=>f("callbackMins",i.target.value),fullWidth:!0,sx:{flex:1}})]})]}),I(H,{textAlign:"right",m:2,children:[s(se,{variant:"outlined",color:"error",size:"large",onClick:u,sx:{px:2,mx:1,borderRadius:"10px",textTransform:"capitalize"},children:"cancel"}),s(se,{variant:"contained",color:"primary",size:"large",onClick:()=>e(n),sx:{px:2,borderRadius:"10px",textTransform:"capitalize"},children:"Submit"})]})]})})})}function cs({open:t,setOpen:o,processList:e=null,handleSelectedProcessor:n}){var r,p;return s(Me,{children:s(Oe,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",maxWidth:"xs",children:I(Se,{sx:{borderRadius:2},children:[I(H,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[s(Z,{variant:"body1",children:" Process List"}),s(xe,{onClick:()=>{o(!1)},children:s(tt,{})})]}),s(H,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px 10px",margin:"10px",borderRadius:"10px"},children:((r=e==null?void 0:e.processes)==null?void 0:r.length)>0?(p=e==null?void 0:e.processes)==null?void 0:p.map((f,y)=>s(H,{sx:{p:1,display:"flex",alignItems:"center",boxShadow:"1px 1px 4px #d3d3d3ff",padding:"6px",margin:"10px 0px",borderRadius:"10px",cursor:"pointer","&:hover":{bgcolor:"action.selected"}},onClick:()=>{n(f)},children:I(Z,{variant:"body1",sx:{mx:1,width:"200px",maxWidth:"250px",display:"flex",alignItems:"center"},children:[s(et,{sx:{marginRight:"4px"}}),f.process_name]})},y)):null})]})})})}function ds({open:t,setOpen:o}){return s(Me,{children:s(Oe,{open:t,"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",fullWidth:!0,maxWidth:"md",children:I(Se,{sx:{borderRadius:2},children:[I(H,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 16px",boxShadow:"0px 1px 2px #f5f5f5ff"},children:[s(Z,{variant:"body1",children:" Call History"}),s(xe,{onClick:()=>{o(!1)},children:s(tt,{})})]}),s(H,{sx:{boxShadow:"1px 1px 4px #d3d3d3ff",margin:"10px",borderRadius:"10px",textAlign:"center",fontSize:"16px",fontWeight:"bold"},p:6,children:"Coming Soon..."})]})})})}import{Fragment as Rn,jsx as d,jsxs as ue}from"react/jsx-runtime";function xs({onDataChange:t}){var mt,xt,Ct,ht,yt,bt,vt,St,Et,Tt,Lt,Dt,It,_t,Rt,wt,kt,At,Nt,Pt,Ot,Mt,Ut,Bt,Ht,$t,zt,Ft,qt,Wt,Kt,Gt,Yt,jt,Xt,Jt,Vt,Qt,Zt,eo,to,oo,so,no,ao,io,lo,ro,co,po,uo,go,fo,mo,xo,Co,ho,yo,bo,vo,So,Eo,To,Lo,Do,Io,_o,Ro,wo,ko,Ao,No,Po,Oo,Mo,Uo,Bo,Ho,$o;let o=Dn(),e=ye(),{disabled:n,enabled:c,outlined:r}=Qe({disabled:((mt=e.sdkConfig)==null?void 0:mt.disabled)||{},enabled:((xt=e.sdkConfig)==null?void 0:xt.enabled)||{},outlined:((Ct=e.sdkConfig)==null?void 0:Ct.outlined)||{}}),p=_n(null),[f,y]=ce(null),[u,C]=ce(!0),[g,i]=ce(null),[h,x]=ce(null),[S,P]=ce(!1),[N,k]=ce(!1),[_,O]=ce(!1),[K,M]=ce(!1),[R,m]=ce(!1),[$,te]=ce(""),[oe,L]=ce(0),{position:b,isDragging:A,dragRef:q,handleMouseDown:z,handleTouchStart:G}=dt(e.controlPanelPosition,a=>v.setControlPanelPosition(a)),{position:W,isDragging:Y,dragRef:w,handleMouseDown:T,handleTouchStart:B}=dt(e.iframePosition,a=>v.setIframePosition(a)),[j,{data:X}]=ae({onSuccess:a=>{var E;console.log("res",a),a&&a.data&&((E=a==null?void 0:a.data)==null?void 0:E.length)>1?M(!0):(v.setProcess(a==null?void 0:a.data[0]),M(!1))},onError:()=>{M(!1)}}),[J,{isLoading:de}]=ae(),[Be,{isLoading:Te}]=ae({onSuccess:()=>{v.setHolding(!e.isHolding)},onError:a=>{console.log("error",a)}}),[He,{isLoading:Le}]=ae({onSuccess:()=>{v.setMuted(!e.isMuted)},onError:a=>{console.log("error",a)}}),[$e,{isLoading:De}]=ae(),[ze,{isLoading:Fe}]=ae(),[qe,{isLoading:Ie}]=ae(),We=In(a=>{let E=Math.floor(a/60),V=a%60;return`${E.toString().padStart(2,"0")}:${V.toString().padStart(2,"0")}`},[]),Ke=()=>{y(null)},Ge=a=>{C(!0),x(a.currentTarget),v.setStatus("dial")},Ye=()=>{e.status!=="on call"&&v.setStatus("idle"),x(null)},je=a=>{i(a.currentTarget)},Xe=()=>{i(null)},Ce=()=>{let a={action:"READYAGENT",userId:e.agentId};$e(D.READY_AGENT,a)},ft=a=>{i(null);let E={action:"AGENTBREAK",break_type:a,userId:e.agentId};ze(D.UPDATE_AGENT_BREAK,E)},ys=a=>{if(a.length!==10)alert("Invalid phone number");else if(/^\d+$/.test(a)){let E={action:"CALL",phone_number:a,userId:e.agentId};J(D.CLICK_TO_CALL,E)}},bs=()=>{let a={action:e.isHolding?"UNHOLD":"HOLD",userId:e.agentId};Be(D.HOLD_CALL,a)},vs=()=>{let a={action:e.isMuted?"UNMUTE":"MUTE",userId:e.agentId};He(D.MUTE_CALL,a)},Ss=a=>{var V,le,re,ge,fe,_e,Re,zo,Fo,qo,Wo,Ko,Go,Yo,jo,Xo;console.log("data",a);let E={action:"ENDCALL",userId:e.agentId,processid:(re=(le=(V=e.process)==null?void 0:V.process_id)==null?void 0:le.toString())!=null?re:"",process_name:(fe=(ge=e.process)==null?void 0:ge.process_name)!=null?fe:"",callreferenceid:(Re=(_e=e.callData)==null?void 0:_e.convox_id)!=null?Re:"",mobile_number:(Fo=(zo=e.callData)==null?void 0:zo.phone_number)!=null?Fo:"",disposition:(Wo=(qo=a==null?void 0:a.disposition)==null?void 0:qo.value)!=null?Wo:"",set_followUp:(Go=(Ko=a==null?void 0:a.followUp)==null?void 0:Ko.value)!=null?Go:"",callback_date:(Yo=a==null?void 0:a.callbackDate)!=null?Yo:"",callback_hrs:(jo=a==null?void 0:a.callbackHrs)!=null?jo:"",callback_mins:(Xo=a==null?void 0:a.callbackMins)!=null?Xo:"",endcall_type:"CLOSE"};te(""),qe(D.END_CALL,E),v.endCall(),O(!1)};return st(()=>{let a;return e.callData.status&&e.callData.status==="ONCALL"?a=setInterval(()=>{let E=Math.floor((Date.now()-e.callStartTime)/1e3);L(E)},1e3):L(0),()=>{a&&clearInterval(a)}},[e.callData.status]),st(()=>{t&&t(e.callData)},[e.callData,t]),st(()=>{e.agentId?j(D.PROCESS_LIST,{userId:e.agentId,action:"GETAGENTPROCESSLIST",refno:"1234221233"}):console.log("No agentId available, skipping API call")},[e.agentId]),st(()=>(e.agentId&&(p.current=new WebSocket(`${Vo.WS}?agent_id=${e.agentId}`),p.current.onopen=()=>{console.log("WebSocket connection established")},p.current.onmessage=a=>{try{let E=JSON.parse(a.data);console.log("parsedJSON:",E),v.updateCallData(E),E.status==="ONCALL"&&(v.startCall(),u||C(!0)),E.status==="WRAPUP"&&v.endCall()}catch(E){console.log("Raw message:",a.data)}},p.current.onclose=()=>{console.log("WebSocket connection closed")},p.current.onerror=a=>{console.error("WebSocket error:",a)}),()=>{var a;(a=p.current)==null||a.close()}),[e.agentId]),!e.isInitialized||!e.process?d(ie,{children:!!K&&d(cs,{processList:X,open:K,setOpen:M,handleSelectedProcessor:a=>{v.setProcess(a)}})}):ue(Rn,{children:[d(ie,{children:d(us,{in:!0,timeout:300,children:d(fs,{ref:(ht=e.sdkConfig)!=null&&ht.enableFloatingDrag?q:null,elevation:A?4:(yt=e.sdkConfig)!=null&&yt.enableFloatingDrag?1:0,sx:{position:(bt=e.sdkConfig)!=null&&bt.enableFloatingDrag?"fixed":"relative",left:(vt=e.sdkConfig)!=null&&vt.enableFloatingDrag?b.x:"auto",top:(St=e.sdkConfig)!=null&&St.enableFloatingDrag?b.y:"auto",display:"inline-block",width:"auto",flexShrink:0,whiteSpace:"nowrap",p:.5,borderRadius:3,bgcolor:"background.paper",zIndex:Number.MAX_SAFE_INTEGER,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),userSelect:"none"},children:ue(ie,{sx:{display:"flex",alignItems:"center"},children:[ue(ie,{sx:{display:"flex",alignItems:"center"},children:[((Et=e.sdkConfig)==null?void 0:Et.enableFloatingDrag)&&ue(ot,{component:"div",size:"small",sx:{cursor:"all-scroll"},onMouseDown:z,onTouchStart:G,children:[d(ps,{})," "]}),d(ie,{sx:{marginRight:"10px"},children:d(he,{title:"Dial",children:d(ot,{size:"small",onClick:a=>{var E,V,le,re,ge,fe,_e,Re;((V=(E=e.callData)==null?void 0:E.status)==null?void 0:V.toUpperCase())!=="ONCALL"&&((re=(le=e.callData)==null?void 0:le.status)==null?void 0:re.toUpperCase())!=="BREAK"&&((fe=(ge=e.callData)==null?void 0:ge.status)==null?void 0:fe.toUpperCase())!=="RINGING"&&((Re=(_e=e.callData)==null?void 0:_e.status)==null?void 0:Re.toUpperCase())!=="WRAPUP"&&Ge(a)},sx:{bgcolor:"action.hover","&:hover":{bgcolor:"warning"}},children:d(Tn,{sx:{color:((Lt=(Tt=e.callData)==null?void 0:Tt.status)==null?void 0:Lt.toUpperCase())==="ONCALL"||((It=(Dt=e.callData)==null?void 0:Dt.status)==null?void 0:It.toUpperCase())==="BREAK"||((Rt=(_t=e.callData)==null?void 0:_t.status)==null?void 0:Rt.toUpperCase())==="RINGING"||((kt=(wt=e.callData)==null?void 0:wt.status)==null?void 0:kt.toUpperCase())==="WRAPUP"?"action.selected":"success.main"}})})})}),d(ms,{sx:{color:"success.main",width:"40px",marginRight:"10px",fontSize:"16px",fontWeight:"600"},children:We(oe)}),Fe||De?d(ie,{sx:{fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"},children:d(Ue,{size:"20px"})}):d(ms,{variant:"body2",sx:{fontWeight:"bold",textAlign:"right"},children:(Pt=(Nt=(At=e.callData)==null?void 0:At.status)==null?void 0:Nt.toUpperCase())!=null?Pt:"N/A"}),d(ie,{onClick:je,sx:{display:"flex",alignItems:"center",margin:"6px",cursor:"pointer"},children:d(dn,{})})]}),ue(ie,{sx:{display:"flex",gap:1,justifyContent:"center",alignItems:"center"},children:[d(he,{title:"Agent Ready",children:d(Ee,{variant:((Mt=(Ot=e.callData)==null?void 0:Ot.status)==null?void 0:Mt.toUpperCase())==="BREAK"||((Bt=(Ut=e.callData)==null?void 0:Ut.status)==null?void 0:Bt.toUpperCase())==="MISSED"?"outlined":"contained",onClick:a=>{var E,V,le,re;(((V=(E=e.callData)==null?void 0:E.status)==null?void 0:V.toUpperCase())==="BREAK"||((re=(le=e.callData)==null?void 0:le.status)==null?void 0:re.toUpperCase())==="MISSED")&&(a.stopPropagation(),Ce())},classes:{root:(($t=(Ht=e.callData)==null?void 0:Ht.status)==null?void 0:$t.toUpperCase())==="BREAK"||((Ft=(zt=e.callData)==null?void 0:zt.status)==null?void 0:Ft.toUpperCase())==="MISSED"?"outlined":"enabled"},sx:l({},((Wt=(qt=e.callData)==null?void 0:qt.status)==null?void 0:Wt.toUpperCase())==="BREAK"||((Gt=(Kt=e.callData)==null?void 0:Kt.status)==null?void 0:Gt.toUpperCase())==="MISSED"?r:c),disabled:De,children:d(vn,{})})}),d(he,{title:e.isHolding?"Resume":"Hold",children:d(Ee,{variant:e.isHolding&&((jt=(Yt=e.callData)==null?void 0:Yt.status)==null?void 0:jt.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:a=>{a.stopPropagation(),bs()},sx:e.isHolding&&((Jt=(Xt=e.callData)==null?void 0:Xt.status)==null?void 0:Jt.toUpperCase())==="ONCALL"?l({},c):((Qt=(Vt=e.callData)==null?void 0:Vt.status)==null?void 0:Qt.toUpperCase())==="ONCALL"?l({},r):l({},n),disabled:((eo=(Zt=e.callData)==null?void 0:Zt.status)==null?void 0:eo.toUpperCase())!=="ONCALL"&&!e.isHolding||Te,children:Te?d(Ue,{size:"20px",sx:{color:o.palette.primary.main}}):e.isHolding?d(bn,{}):d(Cn,{})})}),d(he,{title:e.isMuted?"Unmute":"Mute",children:d(Ee,{variant:e.isMuted&&((oo=(to=e.callData)==null?void 0:to.status)==null?void 0:oo.toUpperCase())==="ONCALL"?"contained":"outlined",onClick:a=>{a.stopPropagation(),vs()},sx:e.isMuted&&((no=(so=e.callData)==null?void 0:so.status)==null?void 0:no.toUpperCase())==="ONCALL"?l({},c):((io=(ao=e.callData)==null?void 0:ao.status)==null?void 0:io.toUpperCase())==="ONCALL"?l({},r):l({},n),disabled:((ro=(lo=e.callData)==null?void 0:lo.status)==null?void 0:ro.toUpperCase())!=="ONCALL"&&!e.isMuted||Le,children:Le?d(Ue,{size:"20px",sx:{color:o.palette.primary.main}}):e.isMuted?d(xn,{}):d(mn,{})})}),((co=e.sdkConfig)==null?void 0:co.showTransferButton)&&d(he,{title:"Transfer Call",children:d(Ee,{variant:N?"contained":"outlined",onClick:a=>{var E,V;((V=(E=e.callData)==null?void 0:E.status)==null?void 0:V.toUpperCase())==="ONCALL"&&(a.stopPropagation(),k(!0))},sx:N?l({},c):((uo=(po=e.callData)==null?void 0:po.status)==null?void 0:uo.toUpperCase())==="ONCALL"?l({},r):l({},n),disabled:((fo=(go=e.callData)==null?void 0:go.status)==null?void 0:fo.toUpperCase())!=="ONCALL",children:d(Sn,{})})}),((mo=e.sdkConfig)==null?void 0:mo.showConferenceButton)&&d(he,{title:"Conference Call",children:d(Ee,{variant:S?"contained":"outlined",onClick:a=>{var E,V;((V=(E=e.callData)==null?void 0:E.status)==null?void 0:V.toUpperCase())==="ONCALL"&&(a.stopPropagation(),P(!0))},sx:S?l({},c):((Co=(xo=e.callData)==null?void 0:xo.status)==null?void 0:Co.toUpperCase())==="ONCALL"?l({},r):l({},n),disabled:((yo=(ho=e.callData)==null?void 0:ho.status)==null?void 0:yo.toUpperCase())!=="ONCALL",children:d(gn,{})})}),((bo=e.sdkConfig)==null?void 0:bo.showEndCallButton)&&d(he,{title:"End Call",children:d(Ee,{variant:((So=(vo=e.callData)==null?void 0:vo.status)==null?void 0:So.toUpperCase())==="ONCALL"||((To=(Eo=e.callData)==null?void 0:Eo.status)==null?void 0:To.toUpperCase())==="RINGING"||((Do=(Lo=e.callData)==null?void 0:Lo.status)==null?void 0:Do.toUpperCase())==="WRAPUP"?"contained":"outlined",onClick:a=>{var E,V,le,re,ge,fe;(((V=(E=e.callData)==null?void 0:E.status)==null?void 0:V.toUpperCase())==="ONCALL"||((re=(le=e.callData)==null?void 0:le.status)==null?void 0:re.toUpperCase())==="RINGING"||((fe=(ge=e.callData)==null?void 0:ge.status)==null?void 0:fe.toUpperCase())==="WRAPUP")&&(a.stopPropagation(),O(!0))},sx:((_o=(Io=e.callData)==null?void 0:Io.status)==null?void 0:_o.toUpperCase())==="ONCALL"||((wo=(Ro=e.callData)==null?void 0:Ro.status)==null?void 0:wo.toUpperCase())==="RINGING"||((Ao=(ko=e.callData)==null?void 0:ko.status)==null?void 0:Ao.toUpperCase())==="WRAPUP"?Q(l({},c),{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}`}}):Q(l({},n),{minWidth:"60px !important"}),disabled:((Po=(No=e.callData)==null?void 0:No.status)==null?void 0:Po.toUpperCase())!=="ONCALL"&&((Mo=(Oo=e.callData)==null?void 0:Oo.status)==null?void 0:Mo.toUpperCase())!=="RINGING"&&((Bo=(Uo=e.callData)==null?void 0:Uo.status)==null?void 0:Bo.toUpperCase())!=="WRAPUP"||Ie,children:Ie?d(Ue,{size:"20px",color:"error"}):d(pn,{})})})]})]})})})}),d(us,{in:!0,timeout:300,children:ue(fs,{ref:w,elevation:Y?4:1,sx:{position:"absolute",left:W.x,top:W.y,borderRadius:2,bgcolor:"background.paper",zIndex:Number.MAX_SAFE_INTEGER,transition:o.transitions.create(["box-shadow","transform"],{duration:o.transitions.duration.short}),visibility:u&&((Ho=e.sdkConfig)!=null&&Ho.enableSoftPhone)?"visible":"hidden",userSelect:"none"},children:[ue(ie,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"all-scroll",padding:"0px 10px"},onMouseDown:T,onTouchStart:B,children:[d(ps,{sx:{transform:"rotate(90deg)",color:"#7b7b7b"}})," ",d(ot,{onClick:()=>C(!1),children:d(un,{})})]}),d(ie,{children:d("iframe",{src:`https://${Je}/ConVoxCCS/iframe?agent_id=${e.agentId}&process_id=${($o=e.process)==null?void 0:$o.process_id}`,height:380,width:420,allow:"camera; microphone; autoplay",style:{border:"none"}})})]})}),d(gt,{anchorEl:h,open:!!h,onClose:Ye,onClick:a=>a.stopPropagation(),sx:{zIndex:99999},children:ue(ie,{sx:{all:"unset",padding:"10px","&hover":{backgroundColor:"white"}},children:[d(Ln,{size:"small",value:$,placeholder:"Enter Mobile No.",onChange:a=>{te(a.target.value)}}),d(ot,{color:"info",onClick:()=>{ys($)},children:de?d(Ue,{size:"20px",sx:{color:o.palette.success.main}}):d(yn,{color:"success"})})]})}),ue(gt,{anchorEl:g,open:!!g,onClose:Xe,onClick:a=>a.stopPropagation(),sx:{zIndex:99999},children:[d(gs,{onClick:()=>ft("Lunch"),children:"- Lunch"}),d(gs,{onClick:()=>ft("Tea"),children:"- Tea"})]}),d(gt,{anchorEl:f,open:!!f,onClose:Ke,onClick:a=>a.stopPropagation(),sx:{zIndex:99999},children:ue(ie,{sx:{display:"flex",justifyContent:"flex-start",flexDirection:"column",padding:"0px 10px","&hover":{backgroundColor:"white"}},children:[d(ut,{icon:d(fn,{color:"secondary"}),variant:"outlined",label:"Waiting - 25",sx:{margin:"4px 2px"}}),d(ut,{icon:d(hn,{color:"info"}),label:"Pending - 99+",variant:"outlined",sx:{margin:"4px 2px"}}),d(ut,{icon:d(En,{color:"success"}),variant:"outlined",label:"Upcoming - 66",sx:{margin:"4px 2px"}})]})}),!!S&&d(is,{open:S,setOpen:P}),!!N&&d(ls,{open:N,setOpen:k}),!!_&&d(rs,{open:_,setOpen:O,onSubmitDisposition:Ss}),!!R&&d(ds,{open:R,setOpen:m})]})}import{jsx as wn}from"react/jsx-runtime";var Cs=({children:t})=>wn(ts,{children:t});import{jsx as hs}from"react/jsx-runtime";function kn({onDataChange:t}){return hs(Cs,{children:hs(xs,{onDataChange:t})})}function di({apiKey:t,tenantId:o,agentId:e,sdkConfig:n}){it.init({apiKey:t,tenantId:o,agentId:e,baseUrl:U}).then(c=>{c?(console.log("SDK initialized successfully"),v.initialize(t,e,n)):(console.log("SDK initialization failed"),v.setInitCheck())})}export{kn as CallControlPanel,di as initSDK,Us as useClickToCall,Os as useEndCall,Ns as useLogout};
2
2
  //# sourceMappingURL=index.mjs.map