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