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