call-control-sdk 6.3.4-dev.1 → 6.3.5

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