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