ahs-cti 0.0.1

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.
Files changed (60) hide show
  1. package/LICENSE +53 -0
  2. package/LICENSE-ACHALA +80 -0
  3. package/README.md +639 -0
  4. package/dist/agentDetailReport-7TDO6MYQ.mjs +11 -0
  5. package/dist/agentDetailReport-7TDO6MYQ.mjs.map +1 -0
  6. package/dist/agentPerformanceReport-R3WY7Q7D.mjs +531 -0
  7. package/dist/agentPerformanceReport-R3WY7Q7D.mjs.map +1 -0
  8. package/dist/auditReport-CJ23LXIZ.mjs +15 -0
  9. package/dist/auditReport-CJ23LXIZ.mjs.map +1 -0
  10. package/dist/callHistory-743J7EKD.mjs +783 -0
  11. package/dist/callHistory-743J7EKD.mjs.map +1 -0
  12. package/dist/campaigns-N2RLUJHH.mjs +3005 -0
  13. package/dist/campaigns-N2RLUJHH.mjs.map +1 -0
  14. package/dist/caroQualityAuditDashboard-NRWY6SEC.mjs +66 -0
  15. package/dist/caroQualityAuditDashboard-NRWY6SEC.mjs.map +1 -0
  16. package/dist/caroVoiceAI-Z5BDDDSY.mjs +21 -0
  17. package/dist/caroVoiceAI-Z5BDDDSY.mjs.map +1 -0
  18. package/dist/cdrReport-577UYGZA.mjs +798 -0
  19. package/dist/cdrReport-577UYGZA.mjs.map +1 -0
  20. package/dist/chunk-6ICPXSN6.mjs +61 -0
  21. package/dist/chunk-6ICPXSN6.mjs.map +1 -0
  22. package/dist/chunk-BU6FMNBY.mjs +82 -0
  23. package/dist/chunk-BU6FMNBY.mjs.map +1 -0
  24. package/dist/chunk-DBSNJ3QH.mjs +1060 -0
  25. package/dist/chunk-DBSNJ3QH.mjs.map +1 -0
  26. package/dist/chunk-EJIWPC3H.mjs +747 -0
  27. package/dist/chunk-EJIWPC3H.mjs.map +1 -0
  28. package/dist/chunk-GTDWTI5S.mjs +17217 -0
  29. package/dist/chunk-GTDWTI5S.mjs.map +1 -0
  30. package/dist/chunk-L4LLUMYA.mjs +57 -0
  31. package/dist/chunk-L4LLUMYA.mjs.map +1 -0
  32. package/dist/chunk-NQL4VODC.mjs +180 -0
  33. package/dist/chunk-NQL4VODC.mjs.map +1 -0
  34. package/dist/chunk-NUYGQI7D.mjs +678 -0
  35. package/dist/chunk-NUYGQI7D.mjs.map +1 -0
  36. package/dist/chunk-RZZQ42MG.mjs +115 -0
  37. package/dist/chunk-RZZQ42MG.mjs.map +1 -0
  38. package/dist/chunk-UB5HSUGK.mjs +65 -0
  39. package/dist/chunk-UB5HSUGK.mjs.map +1 -0
  40. package/dist/chunk-VGVOMFYH.mjs +5781 -0
  41. package/dist/chunk-VGVOMFYH.mjs.map +1 -0
  42. package/dist/chunk-VZCHJLAW.mjs +61 -0
  43. package/dist/chunk-VZCHJLAW.mjs.map +1 -0
  44. package/dist/incoming-4WP3FJI4.mp3 +0 -0
  45. package/dist/incoming.mp3 +0 -0
  46. package/dist/index.d.mts +2476 -0
  47. package/dist/index.d.ts +2477 -0
  48. package/dist/index.js +41208 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/index.mjs +4641 -0
  51. package/dist/index.mjs.map +1 -0
  52. package/dist/liveStatus-IQIEZZE5.mjs +1077 -0
  53. package/dist/liveStatus-IQIEZZE5.mjs.map +1 -0
  54. package/dist/loginReport-H6XJU2MY.mjs +826 -0
  55. package/dist/loginReport-H6XJU2MY.mjs.map +1 -0
  56. package/dist/managementDashboard-NZMAJPPB.mjs +527 -0
  57. package/dist/managementDashboard-NZMAJPPB.mjs.map +1 -0
  58. package/dist/qualityAuditDashboard-ZJEEAMBS.mjs +66 -0
  59. package/dist/qualityAuditDashboard-ZJEEAMBS.mjs.map +1 -0
  60. package/package.json +114 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,4641 @@
1
+ import {
2
+ useCallMonitoring
3
+ } from "./chunk-BU6FMNBY.mjs";
4
+ import {
5
+ useGetCallerData
6
+ } from "./chunk-L4LLUMYA.mjs";
7
+ import {
8
+ setAuditReportUrlResolver
9
+ } from "./chunk-NUYGQI7D.mjs";
10
+ import {
11
+ SDKAccessDenied,
12
+ SDKPermissionGuard,
13
+ useSDKPermissions
14
+ } from "./chunk-NQL4VODC.mjs";
15
+ import {
16
+ SDKProvider,
17
+ useToast
18
+ } from "./chunk-6ICPXSN6.mjs";
19
+ import {
20
+ END_POINT,
21
+ SDK_MENU_CODES,
22
+ SDK_PERMISSIONS,
23
+ SDK_WILDCARD,
24
+ STORAGE_KEY,
25
+ axios_default,
26
+ sdkStateManager
27
+ } from "./chunk-DBSNJ3QH.mjs";
28
+ import {
29
+ __publicField,
30
+ __spreadProps,
31
+ __spreadValues
32
+ } from "./chunk-UB5HSUGK.mjs";
33
+
34
+ // call-control-sdk/lib/hooks/eventsTracker.ts
35
+ var EventTrackerSDK = class {
36
+ constructor() {
37
+ __publicField(this, "config", null);
38
+ __publicField(this, "ticketId", null);
39
+ __publicField(this, "baseUrl", "");
40
+ __publicField(this, "flushTimer", null);
41
+ }
42
+ async init(config) {
43
+ this.config = __spreadValues({
44
+ retryAttempts: 3,
45
+ queueSize: 100,
46
+ flushInterval: 5e3
47
+ }, config);
48
+ this.baseUrl = config.baseUrl || (typeof window !== "undefined" ? window.location.origin : "");
49
+ const ticket = await this.createTicket();
50
+ this.startPeriodicFlush();
51
+ return ticket;
52
+ }
53
+ isInitialized() {
54
+ return this.config !== null && this.ticketId !== null;
55
+ }
56
+ getConfig() {
57
+ return this.config;
58
+ }
59
+ getTicketId() {
60
+ return this.ticketId;
61
+ }
62
+ async createTicket() {
63
+ var _a;
64
+ if (!this.config) {
65
+ throw new Error("EventTracker not initialized");
66
+ }
67
+ try {
68
+ const response = await this.makeRequest("/api/v1/auth/login", {
69
+ // login with base url - same as main application
70
+ method: "POST",
71
+ headers: {
72
+ "Content-Type": "application/json"
73
+ },
74
+ body: JSON.stringify({
75
+ userId: String((_a = this.config.agentId) != null ? _a : ""),
76
+ // sessionId: this.config.sessionId,
77
+ password: this.config.password
78
+ })
79
+ });
80
+ const data = await response.json();
81
+ this.ticketId = data.ticketId;
82
+ return data;
83
+ } catch (error) {
84
+ throw error;
85
+ }
86
+ }
87
+ async makeRequest(url, options) {
88
+ var _a;
89
+ const fullUrl = `${this.baseUrl}${url}`;
90
+ const maxRetries = ((_a = this.config) == null ? void 0 : _a.retryAttempts) || 3;
91
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
92
+ try {
93
+ const response = await fetch(fullUrl, options);
94
+ return response;
95
+ } catch (error) {
96
+ if (attempt === maxRetries) {
97
+ throw error;
98
+ }
99
+ const delay = Math.min(1e3 * Math.pow(2, attempt - 1), 1e4);
100
+ await new Promise((resolve) => setTimeout(resolve, delay));
101
+ }
102
+ }
103
+ throw new Error("Max retries exceeded");
104
+ }
105
+ startPeriodicFlush() {
106
+ if (this.flushTimer) {
107
+ clearInterval(this.flushTimer);
108
+ }
109
+ }
110
+ };
111
+ var eventTracker = new EventTrackerSDK();
112
+ if (typeof window !== "undefined") {
113
+ window.EventTracker = eventTracker;
114
+ }
115
+
116
+ // call-control-sdk/lib/hooks/useLogout.ts
117
+ import { useCallback, useState } from "react";
118
+ import { removeSession } from "@react-solutions/vault";
119
+ var useLogout = () => {
120
+ const [loading, setLoading] = useState(false);
121
+ const [success, setSuccess] = useState(false);
122
+ const [isError, setIsError] = useState(false);
123
+ const [error, setError] = useState(null);
124
+ const [data, setData] = useState(null);
125
+ const { showToast } = useToast();
126
+ const handleLogout = useCallback(async () => {
127
+ var _a, _b;
128
+ setLoading(true);
129
+ try {
130
+ await axios_default.post(END_POINT.AUTH_LOGOUT);
131
+ } catch (err) {
132
+ const message = ((_b = (_a = err == null ? void 0 : err.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || "Logout failed. Please try again.";
133
+ showToast(message, "error");
134
+ } finally {
135
+ sdkStateManager.clearStorageAndReset();
136
+ removeSession(STORAGE_KEY);
137
+ setSuccess(true);
138
+ setLoading(false);
139
+ }
140
+ }, []);
141
+ return {
142
+ logout: handleLogout,
143
+ isLoading: loading,
144
+ isSuccess: success,
145
+ isError,
146
+ error,
147
+ data
148
+ };
149
+ };
150
+
151
+ // call-control-sdk/lib/hooks/useEndCall.ts
152
+ import { useCallback as useCallback2, useState as useState2 } from "react";
153
+ import { getSession } from "@react-solutions/vault";
154
+ var useEndCall = () => {
155
+ const [loading, setLoading] = useState2(false);
156
+ const [success, setSuccess] = useState2(false);
157
+ const [isError, setIsError] = useState2(false);
158
+ const [error, setError] = useState2(null);
159
+ const [data, setData] = useState2(null);
160
+ const handleEndCall = useCallback2(
161
+ async (data2 = {}) => {
162
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
163
+ const state = getSession(STORAGE_KEY);
164
+ setLoading(true);
165
+ const payload = {
166
+ call_id: (_c = (_b = data2 == null ? void 0 : data2.call_id) != null ? _b : (_a = state == null ? void 0 : state.callData) == null ? void 0 : _a.call_id) != null ? _c : "",
167
+ agent_id: (_e = (_d = data2 == null ? void 0 : data2.agent_id) != null ? _d : state == null ? void 0 : state.agentId) != null ? _e : "",
168
+ set_followUp: (_f = data2 == null ? void 0 : data2.set_followUp) != null ? _f : "N",
169
+ callback_date: (_g = data2 == null ? void 0 : data2.callback_date) != null ? _g : "",
170
+ callback_hrs: (_h = data2 == null ? void 0 : data2.callback_hrs) != null ? _h : 0,
171
+ callback_mins: (_i = data2 == null ? void 0 : data2.callback_mins) != null ? _i : 0,
172
+ mobile_number: (_l = (_k = data2 == null ? void 0 : data2.mobile_number) != null ? _k : (_j = state == null ? void 0 : state.callData) == null ? void 0 : _j.phone_number) != null ? _l : "",
173
+ list_comments: (_m = data2 == null ? void 0 : data2.list_comments) != null ? _m : "",
174
+ call_reference_id: (_p = (_o = data2 == null ? void 0 : data2.call_reference_id) != null ? _o : (_n = state == null ? void 0 : state.callData) == null ? void 0 : _n.call_id) != null ? _p : "",
175
+ is_mark_as_break: (_q = data2 == null ? void 0 : data2.is_mark_as_break) != null ? _q : false,
176
+ disposition: (_r = data2 == null ? void 0 : data2.disposition) != null ? _r : "RES",
177
+ line_number: (_s = data2 == null ? void 0 : data2.line_number) != null ? _s : 0,
178
+ reason: (_t = data2 == null ? void 0 : data2.reason) != null ? _t : "normal"
179
+ };
180
+ return axios_default.post(END_POINT.END_CALL, payload).then((res) => {
181
+ sdkStateManager.resetConferenceLines();
182
+ sdkStateManager.endCall();
183
+ setData(res == null ? void 0 : res.data);
184
+ setSuccess(true);
185
+ return res == null ? void 0 : res.data;
186
+ }).catch((err) => {
187
+ var _a2;
188
+ setIsError(true);
189
+ setError(err);
190
+ return (_a2 = err == null ? void 0 : err.response) == null ? void 0 : _a2.data;
191
+ }).finally(() => {
192
+ setLoading(false);
193
+ });
194
+ },
195
+ []
196
+ );
197
+ return {
198
+ handleEndCall,
199
+ isLoading: loading,
200
+ isSuccess: success,
201
+ isError,
202
+ error,
203
+ data
204
+ };
205
+ };
206
+
207
+ // call-control-sdk/lib/hooks/useClickToCall.ts
208
+ import { useCallback as useCallback3, useState as useState3 } from "react";
209
+ import { getSession as getSession2 } from "@react-solutions/vault";
210
+ var useClickToCall = () => {
211
+ const [loading, setLoading] = useState3(false);
212
+ const [success, setSuccess] = useState3(false);
213
+ const [isError, setIsError] = useState3(false);
214
+ const [error, setError] = useState3(null);
215
+ const [data, setData] = useState3(null);
216
+ const handleStartCall = useCallback3(async (data2) => {
217
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
218
+ const state = getSession2(STORAGE_KEY);
219
+ const status = (_a = state == null ? void 0 : state.callData) == null ? void 0 : _a.status;
220
+ setLoading(true);
221
+ if (status === "IDLE" || status === "ONCALL" || status === "WRAPUP") {
222
+ const liveState = sdkStateManager.getState();
223
+ const isWrapupCall = status === "WRAPUP";
224
+ let parentCallUuid = "";
225
+ if (data2 == null ? void 0 : data2.parentCallUuid) {
226
+ parentCallUuid = data2.parentCallUuid;
227
+ } else if ((_b = liveState.sdkConfig) == null ? void 0 : _b.disableAlternateDialing) {
228
+ if (isWrapupCall) {
229
+ if (liveState.rootCallUuid) {
230
+ parentCallUuid = liveState.rootCallUuid;
231
+ } else if ((_c = state == null ? void 0 : state.callData) == null ? void 0 : _c.call_id) {
232
+ parentCallUuid = state.callData.call_id;
233
+ sdkStateManager.setRootCallUuid(parentCallUuid);
234
+ }
235
+ } else if (liveState.rootCallUuid) {
236
+ sdkStateManager.setRootCallUuid(null);
237
+ }
238
+ } else if (liveState.rootCallUuid) {
239
+ sdkStateManager.setRootCallUuid(null);
240
+ }
241
+ const payload = {
242
+ phone_number: data2 == null ? void 0 : data2.mobileNumber,
243
+ user: (_e = (_d = data2 == null ? void 0 : data2.user) != null ? _d : state == null ? void 0 : state.agentId) != null ? _e : "",
244
+ auto_answer: (_f = data2 == null ? void 0 : data2.auto_answer) != null ? _f : false,
245
+ call_id: (_i = (_h = (_g = state == null ? void 0 : state.callData) == null ? void 0 : _g.call_id) != null ? _h : data2 == null ? void 0 : data2.call_id) != null ? _i : "",
246
+ reference_id: (_j = data2 == null ? void 0 : data2.reference_id) != null ? _j : "",
247
+ call_source: (_k = data2 == null ? void 0 : data2.call_source) != null ? _k : "",
248
+ caseId: (_l = data2 == null ? void 0 : data2.caseId) != null ? _l : "",
249
+ isWrapup: (_m = data2 == null ? void 0 : data2.isWrapup) != null ? _m : false,
250
+ parentCallUuid: (_p = (_o = (_n = data2 == null ? void 0 : data2.parentCallUuid) != null ? _n : data2.parentCallUuid) != null ? _o : parentCallUuid) != null ? _p : ""
251
+ };
252
+ return axios_default.post(END_POINT.CLICK_TO_CALL, payload).then((res) => {
253
+ sdkStateManager.resetConferenceLines();
254
+ setData(res == null ? void 0 : res.data);
255
+ setSuccess(true);
256
+ return res == null ? void 0 : res.data;
257
+ }).catch((err) => {
258
+ var _a2;
259
+ setIsError(true);
260
+ setError(err);
261
+ return (_a2 = err == null ? void 0 : err.response) == null ? void 0 : _a2.data;
262
+ }).finally(() => {
263
+ setLoading(false);
264
+ });
265
+ } else {
266
+ setLoading(false);
267
+ alert("Agent is not ready");
268
+ }
269
+ }, []);
270
+ return {
271
+ handleStartCall,
272
+ isLoading: loading,
273
+ isSuccess: success,
274
+ isError,
275
+ error,
276
+ data
277
+ };
278
+ };
279
+
280
+ // call-control-sdk/lib/hooks/useGetAuthorizationToken.ts
281
+ import { useState as useState4, useEffect } from "react";
282
+ var useGetAuthorizationToken = () => {
283
+ const [token, setToken] = useState4(sdkStateManager.getSdkAuthToken());
284
+ useEffect(() => {
285
+ const unsubscribe = sdkStateManager.subscribe(() => {
286
+ setToken(sdkStateManager.getSdkAuthToken());
287
+ });
288
+ return unsubscribe;
289
+ }, []);
290
+ return token;
291
+ };
292
+
293
+ // call-control-sdk/lib/hooks/useSDKState.ts
294
+ import { useState as useState5, useEffect as useEffect2 } from "react";
295
+ function useSDKState() {
296
+ const [state, setState] = useState5(sdkStateManager.getState());
297
+ useEffect2(() => {
298
+ const unsubscribe = sdkStateManager.subscribe(() => {
299
+ setState(sdkStateManager.getState());
300
+ });
301
+ return unsubscribe;
302
+ }, []);
303
+ return state;
304
+ }
305
+
306
+ // call-control-sdk/lib/components/callControlPanel.tsx
307
+ import { memo, useCallback as useCallback6 } from "react";
308
+
309
+ // call-control-sdk/lib/components/callControls.tsx
310
+ import CallEnd2 from "@mui/icons-material/CallEnd";
311
+ import Close2 from "@mui/icons-material/Close";
312
+ import DragIndicator from "@mui/icons-material/DragIndicator";
313
+ import Group from "@mui/icons-material/Group";
314
+ import KeyboardArrowDown from "@mui/icons-material/KeyboardArrowDown";
315
+ import Layers from "@mui/icons-material/Layers";
316
+ import Mic from "@mui/icons-material/Mic";
317
+ import MicOff from "@mui/icons-material/MicOff";
318
+ import Pause2 from "@mui/icons-material/Pause";
319
+ import Pending from "@mui/icons-material/Pending";
320
+ import Phone from "@mui/icons-material/Phone";
321
+ import PlayArrow2 from "@mui/icons-material/PlayArrow";
322
+ import SupportAgent2 from "@mui/icons-material/SupportAgent";
323
+ import TransferWithinAStation2 from "@mui/icons-material/TransferWithinAStation";
324
+ import Upcoming2 from "@mui/icons-material/Upcoming";
325
+ import WifiCalling3 from "@mui/icons-material/WifiCalling3";
326
+ import SendRounded from "@mui/icons-material/SendRounded";
327
+ import SmsSharp from "@mui/icons-material/SmsSharp";
328
+ import MoreVert from "@mui/icons-material/MoreVert";
329
+ import {
330
+ Box as Box2,
331
+ Button as Button2,
332
+ Chip,
333
+ CircularProgress as CircularProgress2,
334
+ Fade,
335
+ IconButton as IconButton2,
336
+ Menu as Menu2,
337
+ MenuItem as MenuItem2,
338
+ Paper as Paper2,
339
+ TextField as TextField2,
340
+ Tooltip as Tooltip2,
341
+ Typography as Typography2,
342
+ useTheme as useTheme3
343
+ } from "@mui/material";
344
+ import { useEffect as useEffect4, useRef as useRef2, useState as useState8 } from "react";
345
+
346
+ // call-control-sdk/lib/components/dialog.tsx
347
+ import Airlines from "@mui/icons-material/Airlines";
348
+ import Call from "@mui/icons-material/Call";
349
+ import CallEnd from "@mui/icons-material/CallEnd";
350
+ import CallSplit from "@mui/icons-material/CallSplit";
351
+ import Close from "@mui/icons-material/Close";
352
+ import MemoryOutlined from "@mui/icons-material/MemoryOutlined";
353
+ import Pause from "@mui/icons-material/Pause";
354
+ import PhoneDisabled from "@mui/icons-material/PhoneDisabled";
355
+ import PlayArrow from "@mui/icons-material/PlayArrow";
356
+ import RecordVoiceOver from "@mui/icons-material/RecordVoiceOver";
357
+ import Roofing from "@mui/icons-material/Roofing";
358
+ import SupportAgent from "@mui/icons-material/SupportAgent";
359
+ import TransferWithinAStation from "@mui/icons-material/TransferWithinAStation";
360
+ import Upcoming from "@mui/icons-material/Upcoming";
361
+ import {
362
+ Box,
363
+ Button,
364
+ Dialog,
365
+ IconButton,
366
+ Menu,
367
+ MenuItem,
368
+ Paper,
369
+ TextField,
370
+ Typography,
371
+ Autocomplete,
372
+ Tooltip,
373
+ useTheme as useTheme2,
374
+ TableContainer,
375
+ Table,
376
+ TableHead,
377
+ TableRow,
378
+ TableCell,
379
+ TableBody,
380
+ CircularProgress,
381
+ Checkbox
382
+ } from "@mui/material";
383
+ import { useEffect as useEffect3, useMemo, useState as useState6 } from "react";
384
+
385
+ // call-control-sdk/lib/services/request.ts
386
+ import { useCallback as useCallback4, useReducer } from "react";
387
+ var initialState = {
388
+ isLoading: false,
389
+ isSuccess: false,
390
+ isError: false,
391
+ error: null,
392
+ data: null
393
+ };
394
+ var reducer = (state, action) => {
395
+ if (action.type === "isLoading") {
396
+ return __spreadProps(__spreadValues({}, state), {
397
+ isLoading: action.payload
398
+ });
399
+ } else if (action.type === "isSuccess") {
400
+ return __spreadProps(__spreadValues({}, state), {
401
+ isSuccess: true,
402
+ data: action.payload
403
+ });
404
+ } else if (action.type === "isError") {
405
+ return __spreadProps(__spreadValues({}, state), {
406
+ isError: true,
407
+ error: action.payload
408
+ });
409
+ } else if (action.type === "reset") {
410
+ return {
411
+ isLoading: false,
412
+ isSuccess: false,
413
+ isError: false,
414
+ error: null,
415
+ data: null
416
+ };
417
+ }
418
+ throw Error("Unknown action.");
419
+ };
420
+ var useGetRequest = (props = {}) => {
421
+ const { onSuccess = null, onError = null } = props;
422
+ const { showToast } = useToast();
423
+ const [state, dispatch] = useReducer(reducer, initialState);
424
+ const getRequest = useCallback4(
425
+ (url, config = {}) => {
426
+ dispatch({
427
+ type: "isLoading",
428
+ payload: true
429
+ });
430
+ axios_default.get(url, config).then((res) => {
431
+ var _a, _b;
432
+ if ((_a = res.data) == null ? void 0 : _a.success) {
433
+ dispatch({
434
+ type: "isSuccess",
435
+ payload: res.data
436
+ });
437
+ onSuccess == null ? void 0 : onSuccess(res.data, config);
438
+ } else {
439
+ dispatch({
440
+ type: "isError",
441
+ payload: res.data
442
+ });
443
+ showToast((_b = res.data) == null ? void 0 : _b.message, "error");
444
+ onError == null ? void 0 : onError(res.data, config);
445
+ }
446
+ }).catch((err) => {
447
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
448
+ const error = {
449
+ status: (_b = (_a = err.response) == null ? void 0 : _a.status) != null ? _b : 500,
450
+ message: ((_d = (_c = err.response) == null ? void 0 : _c.data) == null ? void 0 : _d.detail) || ((_f = (_e = err.response) == null ? void 0 : _e.data) == null ? void 0 : _f.message) || err.message || "An unknown error occurred",
451
+ data: (_h = (_g = err.response) == null ? void 0 : _g.data) != null ? _h : null,
452
+ statusText: (_j = (_i = err.response) == null ? void 0 : _i.statusText) != null ? _j : "",
453
+ code: (_k = err == null ? void 0 : err.code) != null ? _k : "",
454
+ name: (_l = err == null ? void 0 : err.name) != null ? _l : ""
455
+ };
456
+ showToast(error.message, "error");
457
+ dispatch({
458
+ type: "isError",
459
+ payload: error
460
+ });
461
+ onError == null ? void 0 : onError(error, config);
462
+ }).finally(() => {
463
+ dispatch({
464
+ type: "isLoading",
465
+ payload: false
466
+ });
467
+ });
468
+ },
469
+ [onSuccess, onError, showToast]
470
+ );
471
+ return [getRequest, state];
472
+ };
473
+ var usePostRequest = (props = {}) => {
474
+ const { onSuccess = null, onError = null, disabledSuccessToast = false } = props;
475
+ const { showToast } = useToast();
476
+ const [state, dispatch] = useReducer(reducer, initialState);
477
+ const postRequest = useCallback4(
478
+ async (url, payload, config = {}) => {
479
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
480
+ dispatch({
481
+ type: "isLoading",
482
+ payload: true
483
+ });
484
+ try {
485
+ try {
486
+ const res = await axios_default.post(url, payload, config);
487
+ dispatch({
488
+ type: "isSuccess",
489
+ payload: res.data
490
+ });
491
+ onSuccess == null ? void 0 : onSuccess(res.data, payload);
492
+ if (!disabledSuccessToast) {
493
+ showToast((_a = res.data) == null ? void 0 : _a.message, "success");
494
+ }
495
+ } catch (err) {
496
+ const error = {
497
+ status: (_c = (_b = err.response) == null ? void 0 : _b.status) != null ? _c : 500,
498
+ message: ((_e = (_d = err.response) == null ? void 0 : _d.data) == null ? void 0 : _e.detail) || ((_g = (_f = err.response) == null ? void 0 : _f.data) == null ? void 0 : _g.message) || err.message || "An unknown error occurred",
499
+ data: (_i = (_h = err.response) == null ? void 0 : _h.data) != null ? _i : null,
500
+ statusText: (_k = (_j = err.response) == null ? void 0 : _j.statusText) != null ? _k : "",
501
+ code: (_l = err == null ? void 0 : err.code) != null ? _l : "",
502
+ name: (_m = err == null ? void 0 : err.name) != null ? _m : ""
503
+ };
504
+ showToast(error.message, "error");
505
+ dispatch({
506
+ type: "isError",
507
+ payload: error
508
+ });
509
+ onError == null ? void 0 : onError(error, payload);
510
+ }
511
+ } finally {
512
+ dispatch({
513
+ type: "isLoading",
514
+ payload: false
515
+ });
516
+ }
517
+ },
518
+ [onSuccess, onError, showToast]
519
+ );
520
+ return [postRequest, state];
521
+ };
522
+
523
+ // call-control-sdk/lib/components/styles.ts
524
+ import { useTheme } from "@mui/material";
525
+ var useStyles = ({
526
+ disabled,
527
+ enabled,
528
+ outlined
529
+ }) => {
530
+ const theme = useTheme();
531
+ return {
532
+ disabled: __spreadValues({
533
+ padding: "0px",
534
+ margin: "0px",
535
+ minWidth: "40px !important",
536
+ borderRadius: "16px",
537
+ border: `1px solid rgb(206, 204, 204)`,
538
+ height: "40px",
539
+ "&:hover": {
540
+ boxShadow: " 0px 2px 2px rgba(0, 0, 0, 0.79)",
541
+ border: `1px solid ${theme.palette.primary.main}`
542
+ },
543
+ "&:active": {
544
+ bgcolor: "primary.main",
545
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
546
+ }
547
+ }, disabled),
548
+ enabled: __spreadValues({
549
+ padding: "0px",
550
+ margin: "0px",
551
+ minWidth: "40px !important",
552
+ borderRadius: "16px",
553
+ boxShadow: " 0px 2px 1px rgba(0, 0, 0, 0.507)",
554
+ border: `1px solid ${theme.palette.primary.main}`,
555
+ height: "40px",
556
+ "&:hover": {
557
+ boxShadow: " 0px 2px 1px rgba(0, 0, 0, 0.507)",
558
+ border: `1px solid ${theme.palette.primary.main}`
559
+ },
560
+ "&:active": {
561
+ bgcolor: "primary.main",
562
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
563
+ }
564
+ }, enabled),
565
+ outlined: __spreadValues({
566
+ padding: "0px",
567
+ margin: "0px",
568
+ minWidth: "40px !important",
569
+ borderRadius: "16px",
570
+ backgroundColor: theme.palette.grey[200],
571
+ boxShadow: `0px 2px 1px ${theme.palette.primary.light}`,
572
+ border: `0px solid ${theme.palette.primary.main}`,
573
+ height: "40px",
574
+ "&:hover": {
575
+ boxShadow: `0px 2px 1px ${theme.palette.primary.main}`,
576
+ border: `0px solid ${theme.palette.primary.main}`
577
+ },
578
+ "&:active": {
579
+ bgcolor: "primary.main",
580
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
581
+ }
582
+ }, outlined)
583
+ };
584
+ };
585
+ var styles_default = useStyles;
586
+
587
+ // call-control-sdk/lib/components/dialog.tsx
588
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
589
+ var ConferenceTableRow = ({ each, isLineDialing }) => {
590
+ var _a, _b, _c, _d, _e, _f, _g, _h;
591
+ const state = useSDKState();
592
+ const theme = useTheme2();
593
+ const { showToast } = useToast();
594
+ const { disabled, enabled, outlined } = styles_default({
595
+ disabled: ((_a = state.sdkConfig) == null ? void 0 : _a.disabled) || {},
596
+ enabled: ((_b = state.sdkConfig) == null ? void 0 : _b.enabled) || {},
597
+ outlined: ((_c = state.sdkConfig) == null ? void 0 : _c.outlined) || {}
598
+ });
599
+ const [conferenceCallStart, setConferenceCallStart] = useState6(false);
600
+ const [conferenceCallMerge, setConferenceCallMerge] = useState6(false);
601
+ const [conferenceCallHoldOrUnHold, setConferenceCallHoldOrUnHold] = useState6(false);
602
+ const [conferenceCallEnd, setConferenceCallEnd] = useState6(false);
603
+ const isSameAsActiveCall = (each == null ? void 0 : each.phone) === ((_d = state.callData) == null ? void 0 : _d.phone_number) && !!(each == null ? void 0 : each.phone);
604
+ const isDuplicateInConference = !!(each == null ? void 0 : each.phone) && (each == null ? void 0 : each.line) !== 1 && ((_e = state.conferenceLine) == null ? void 0 : _e.some(
605
+ (line) => line.line < each.line && line.phone === (each == null ? void 0 : each.phone) && !!line.phone
606
+ ));
607
+ const hasPhoneConflict = isDuplicateInConference;
608
+ const phoneConflictHelperText = isDuplicateInConference ? "Number already used in another conference line" : "";
609
+ const onConferenceLineUpdate = (line, data) => {
610
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
611
+ };
612
+ const onConferenceCallStart = (line, data) => {
613
+ var _a2, _b2, _c2, _d2, _e2;
614
+ const line_used = __spreadValues(__spreadValues({}, line), data);
615
+ if (line_used.phone === ((_a2 = state.callData) == null ? void 0 : _a2.phone_number)) {
616
+ showToast("Cannot conference with the active call number", "error");
617
+ return;
618
+ }
619
+ const isDuplicateNumber = (_b2 = state.conferenceLine) == null ? void 0 : _b2.some(
620
+ (l) => l.line !== line_used.line && l.phone === line_used.phone && !!l.phone
621
+ );
622
+ if (isDuplicateNumber) {
623
+ showToast("Number already used in another conference line", "error");
624
+ return;
625
+ }
626
+ if (!line_used.phone || line_used.phone.length < 10) {
627
+ showToast("Invalid phone number", "error");
628
+ return;
629
+ }
630
+ setConferenceCallStart(true);
631
+ const payload = {
632
+ action: "EXTERNAL_CONFERENCE",
633
+ operation: `CALL${line_used.line}`,
634
+ // line_used: Number(line_used.line),
635
+ // thirdparty_no: line_used.phone,
636
+ target: line_used.phone,
637
+ line_number: Number(line_used.line),
638
+ userid: (_c2 = state.agentId) != null ? _c2 : "",
639
+ process: (_e2 = (_d2 = state.callData) == null ? void 0 : _d2.process_name) != null ? _e2 : ""
640
+ };
641
+ axios_default.post(END_POINT.CONFERENCE_CALL, payload).then((res) => {
642
+ var _a3;
643
+ showToast((_a3 = res.data) == null ? void 0 : _a3.message, "success");
644
+ }).catch((err) => {
645
+ var _a3, _b3, _c3, _d3;
646
+ const message = ((_b3 = (_a3 = err.response) == null ? void 0 : _a3.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
647
+ showToast(message, "error");
648
+ }).finally(() => {
649
+ setConferenceCallStart(false);
650
+ });
651
+ };
652
+ const onMergeConferenceCall = (line, data) => {
653
+ var _a2, _b2, _c2, _d2, _e2;
654
+ const line_used = __spreadValues(__spreadValues({}, line), data);
655
+ setConferenceCallMerge(true);
656
+ const payload = {
657
+ action: "EXTERNAL_CONFERENCE",
658
+ operation: `CONFERENCE`,
659
+ line_used: String(line_used.line),
660
+ thirdparty_no: line_used.phone,
661
+ userid: (_a2 = state.agentId) != null ? _a2 : "",
662
+ process: (_c2 = (_b2 = state.callData) == null ? void 0 : _b2.process_name) != null ? _c2 : "",
663
+ call_id: (_e2 = (_d2 = state.callData) == null ? void 0 : _d2.call_id) != null ? _e2 : ""
664
+ };
665
+ axios_default.post(END_POINT.CONFERENCE_MERGE_CALL, payload).then((res) => {
666
+ var _a3, _b3, _c3;
667
+ if (((_a3 = state.callData) == null ? void 0 : _a3.hold) === 1) {
668
+ handleHoldToggle();
669
+ }
670
+ if (((_b3 = state.callData) == null ? void 0 : _b3.mute) === 1) {
671
+ handleMuteToggle();
672
+ }
673
+ showToast((_c3 = res.data) == null ? void 0 : _c3.message, "success");
674
+ }).catch((err) => {
675
+ var _a3, _b3, _c3, _d3;
676
+ const message = ((_b3 = (_a3 = err.response) == null ? void 0 : _a3.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
677
+ showToast(message, "error");
678
+ }).finally(() => {
679
+ setConferenceCallMerge(false);
680
+ });
681
+ };
682
+ const onHoldOrUnHoldConferenceCall = (line, data, type) => {
683
+ var _a2, _b2, _c2, _d2, _e2;
684
+ const line_used = __spreadValues(__spreadValues({}, line), data);
685
+ setConferenceCallHoldOrUnHold(true);
686
+ const payload = {
687
+ action: type === "HOLDUSER" ? "HOLD" : "UNHOLD",
688
+ operation: type,
689
+ hold_channel_no: type === "HOLDUSER" ? `hold${line_used.line}` : `unhold${line_used.line}`,
690
+ userid: (_a2 = state.agentId) != null ? _a2 : "",
691
+ process: (_c2 = (_b2 = state.callData) == null ? void 0 : _b2.process_name) != null ? _c2 : "",
692
+ call_uuid: (_e2 = (_d2 = state.callData) == null ? void 0 : _d2.call_id) != null ? _e2 : "",
693
+ line_number: Number(line_used.line)
694
+ };
695
+ axios_default.post(END_POINT.CONFERENCE_CALL_HOLD_OR_UN_HOLD, payload).then((res) => {
696
+ var _a3;
697
+ showToast((_a3 = res.data) == null ? void 0 : _a3.message, "success");
698
+ }).catch((err) => {
699
+ var _a3, _b3, _c3, _d3;
700
+ const message = ((_b3 = (_a3 = err.response) == null ? void 0 : _a3.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
701
+ showToast(message, "error");
702
+ }).finally(() => {
703
+ setConferenceCallHoldOrUnHold(false);
704
+ });
705
+ };
706
+ const onEndConferenceCall = (line, data) => {
707
+ var _a2, _b2, _c2, _d2;
708
+ const line_used = __spreadValues(__spreadValues({}, line), data);
709
+ if (line_used.line === 1) {
710
+ showToast("Cannot end the primary call from conference controls", "error");
711
+ return;
712
+ }
713
+ setConferenceCallEnd(true);
714
+ const payload = {
715
+ call_id: (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.call_id) != null ? _b2 : "",
716
+ agent_id: (_c2 = state.agentId) != null ? _c2 : "",
717
+ mobile_number: (_d2 = line_used.phone) != null ? _d2 : "",
718
+ line_number: Number(line_used.line),
719
+ reason: "normal"
720
+ };
721
+ axios_default.post(END_POINT.CONFERENCE_CALL_END, payload).then(() => {
722
+ showToast("Call disconnected successfully", "success");
723
+ }).catch((err) => {
724
+ var _a3, _b3, _c3, _d3;
725
+ const message = ((_b3 = (_a3 = err.response) == null ? void 0 : _a3.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
726
+ showToast(message, "error");
727
+ }).finally(() => {
728
+ setConferenceCallEnd(false);
729
+ });
730
+ };
731
+ const [holdOrUnHold] = usePostRequest();
732
+ const [muteOrUnMute] = usePostRequest();
733
+ const handleHoldToggle = () => {
734
+ var _a2, _b2, _c2, _d2;
735
+ const payload = {
736
+ action: ((_a2 = state.callData) == null ? void 0 : _a2.hold) === 1 ? "UNHOLD" /* UNHOLD */ : "HOLD" /* HOLD */,
737
+ user_id: String((_b2 = state.agentId) != null ? _b2 : ""),
738
+ call_uuid: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.call_id) != null ? _d2 : "",
739
+ line_number: 0
740
+ };
741
+ holdOrUnHold(END_POINT.HOLD_CALL, payload);
742
+ };
743
+ const handleMuteToggle = () => {
744
+ var _a2, _b2, _c2, _d2;
745
+ const payload = {
746
+ action: ((_a2 = state.callData) == null ? void 0 : _a2.mute) === 1 ? "UNMUTE" /* UNMUTE */ : "MUTE" /* MUTE */,
747
+ direction: "both",
748
+ user_id: String((_b2 = state.agentId) != null ? _b2 : ""),
749
+ call_uuid: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.call_id) != null ? _d2 : "",
750
+ line_number: 0
751
+ };
752
+ muteOrUnMute(END_POINT.MUTE_CALL, payload);
753
+ };
754
+ return /* @__PURE__ */ jsxs(
755
+ TableRow,
756
+ {
757
+ sx: {
758
+ border: "2px solid #fff"
759
+ },
760
+ children: [
761
+ /* @__PURE__ */ jsx(
762
+ TableCell,
763
+ {
764
+ sx: {
765
+ padding: "6px",
766
+ flex: 1,
767
+ width: "100px"
768
+ },
769
+ children: /* @__PURE__ */ jsxs(Typography, { children: [
770
+ "Line ",
771
+ (_f = each == null ? void 0 : each.line) != null ? _f : "",
772
+ ". "
773
+ ] })
774
+ }
775
+ ),
776
+ /* @__PURE__ */ jsx(
777
+ TableCell,
778
+ {
779
+ sx: {
780
+ padding: "6px",
781
+ width: "150px"
782
+ },
783
+ children: /* @__PURE__ */ jsx(
784
+ Typography,
785
+ {
786
+ variant: "body2",
787
+ sx: {
788
+ px: 1,
789
+ borderRadius: "10px",
790
+ width: "150px"
791
+ },
792
+ children: (_g = each == null ? void 0 : each.status) != null ? _g : ""
793
+ }
794
+ )
795
+ }
796
+ ),
797
+ /* @__PURE__ */ jsx(
798
+ TableCell,
799
+ {
800
+ sx: {
801
+ padding: "6px",
802
+ flex: 1
803
+ },
804
+ children: /* @__PURE__ */ jsx(
805
+ TextField,
806
+ {
807
+ size: "small",
808
+ type: "tel",
809
+ placeholder: "Phone Number",
810
+ fullWidth: true,
811
+ value: (each == null ? void 0 : each.phone) || "",
812
+ error: hasPhoneConflict,
813
+ helperText: phoneConflictHelperText,
814
+ slotProps: {
815
+ htmlInput: {
816
+ inputMode: "numeric",
817
+ maxLength: 11
818
+ }
819
+ },
820
+ disabled: (each == null ? void 0 : each.line) === 1 || [
821
+ "ONCALL" /* ONCALL */,
822
+ "DISCONNECTED" /* DISCONNECTED */,
823
+ "CONFERENCE" /* CONFERENCE */,
824
+ "HOLD" /* HOLD */,
825
+ "MUTE" /* MUTE */,
826
+ "DIALING" /* DIALING */,
827
+ "RINGING" /* RINGING */
828
+ ].includes((_h = each == null ? void 0 : each.status) != null ? _h : "") || isLineDialing,
829
+ onKeyDown: (e) => {
830
+ const allowedKeys = [
831
+ "Backspace",
832
+ "Delete",
833
+ "Tab",
834
+ "ArrowLeft",
835
+ "ArrowRight",
836
+ "ArrowUp",
837
+ "ArrowDown",
838
+ "Home",
839
+ "End"
840
+ ];
841
+ if (!/^\d$/.test(e.key) && !allowedKeys.includes(e.key) && !(e.ctrlKey || e.metaKey)) {
842
+ e.preventDefault();
843
+ }
844
+ },
845
+ onPaste: (e) => {
846
+ const pasted = e.clipboardData.getData("text");
847
+ if (!/^\d*$/.test(pasted)) {
848
+ e.preventDefault();
849
+ }
850
+ },
851
+ onChange: (e) => {
852
+ const v = e.target.value;
853
+ if (/^\d*$/.test(v)) {
854
+ onConferenceLineUpdate(each, { phone: v });
855
+ }
856
+ }
857
+ }
858
+ )
859
+ }
860
+ ),
861
+ /* @__PURE__ */ jsx(
862
+ TableCell,
863
+ {
864
+ sx: {
865
+ padding: "6px",
866
+ flex: 1
867
+ },
868
+ children: /* @__PURE__ */ jsxs(
869
+ Box,
870
+ {
871
+ sx: {
872
+ width: "100%",
873
+ display: "flex",
874
+ alignItems: "center",
875
+ justifyContent: "flex-start",
876
+ gap: "10px"
877
+ },
878
+ children: [
879
+ (each == null ? void 0 : each.line) === 1 && /* @__PURE__ */ jsx(Tooltip, { title: (each == null ? void 0 : each.status) !== "HOLD" /* HOLD */ ? "Hold" : "Resume", children: /* @__PURE__ */ jsx(
880
+ Button,
881
+ {
882
+ variant: (each == null ? void 0 : each.status) === "HOLD" /* HOLD */ ? "contained" : "outlined",
883
+ sx: (each == null ? void 0 : each.status) === "CONFERENCE" /* CONFERENCE */ ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
884
+ onClick: () => {
885
+ if (each.status === "HOLD" /* HOLD */) {
886
+ onHoldOrUnHoldConferenceCall(each, { isHold: false }, "UNHOLDUSER");
887
+ } else {
888
+ onHoldOrUnHoldConferenceCall(each, { isHold: true }, "HOLDUSER");
889
+ }
890
+ },
891
+ disabled: (each == null ? void 0 : each.status) !== "CONFERENCE" /* CONFERENCE */ && (each == null ? void 0 : each.status) !== "HOLD" /* HOLD */ || conferenceCallHoldOrUnHold,
892
+ children: each.status === "HOLD" /* HOLD */ ? /* @__PURE__ */ jsxs(
893
+ Box,
894
+ {
895
+ sx: {
896
+ display: "flex",
897
+ alignItems: "center",
898
+ justifyContent: "center",
899
+ gap: "5px",
900
+ width: "98px"
901
+ },
902
+ children: [
903
+ /* @__PURE__ */ jsx(
904
+ Typography,
905
+ {
906
+ variant: "body2",
907
+ sx: {
908
+ fontSize: "12px",
909
+ color: each.status === "HOLD" /* HOLD */ ? "#fff" : "initial"
910
+ },
911
+ children: "Unhold"
912
+ }
913
+ ),
914
+ conferenceCallHoldOrUnHold ? /* @__PURE__ */ jsx(CircularProgress, { size: "16px", sx: { color: theme.palette.primary.main } }) : /* @__PURE__ */ jsx(PlayArrow, {})
915
+ ]
916
+ }
917
+ ) : /* @__PURE__ */ jsxs(
918
+ Box,
919
+ {
920
+ sx: {
921
+ display: "flex",
922
+ alignItems: "center",
923
+ justifyContent: "center",
924
+ gap: "5px",
925
+ width: "98px"
926
+ },
927
+ children: [
928
+ /* @__PURE__ */ jsx(
929
+ Typography,
930
+ {
931
+ variant: "body2",
932
+ sx: { color: each.status === "HOLD" /* HOLD */ ? "#fff" : "#000", fontSize: "12px" },
933
+ children: "Hold"
934
+ }
935
+ ),
936
+ conferenceCallHoldOrUnHold ? /* @__PURE__ */ jsx(CircularProgress, { size: "16px", sx: { color: theme.palette.primary.main } }) : /* @__PURE__ */ jsx(Pause, {})
937
+ ]
938
+ }
939
+ )
940
+ }
941
+ ) }),
942
+ (each == null ? void 0 : each.line) !== 1 && (() => {
943
+ var _a2, _b2;
944
+ const hasMinDigits = ((_b2 = (_a2 = each == null ? void 0 : each.phone) == null ? void 0 : _a2.length) != null ? _b2 : 0) >= 3;
945
+ const callDisabled = (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ || isLineDialing || hasPhoneConflict || !hasMinDigits;
946
+ const tooltipTitle = hasPhoneConflict ? phoneConflictHelperText || "Cannot dial this number" : !(each == null ? void 0 : each.phone) ? "Enter mobile number" : !hasMinDigits ? "Enter at least 3 digits" : "Call";
947
+ return /* @__PURE__ */ jsx(Tooltip, { title: tooltipTitle, children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
948
+ Button,
949
+ {
950
+ variant: callDisabled ? "outlined" : "contained",
951
+ color: "success",
952
+ sx: callDisabled ? __spreadValues({}, disabled) : __spreadProps(__spreadValues({}, enabled), {
953
+ border: `0px solid ${theme.palette.success.light}`,
954
+ "&:hover": {
955
+ bgcolor: "success.light",
956
+ boxShadow: `0px 2px 1px ${theme.palette.success.light}`,
957
+ border: `0px solid ${theme.palette.success.light}`
958
+ },
959
+ "&:active": {
960
+ bgcolor: "success.light",
961
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
962
+ }
963
+ }),
964
+ onClick: () => {
965
+ onConferenceCallStart(each, {});
966
+ },
967
+ disabled: callDisabled,
968
+ children: conferenceCallStart ? /* @__PURE__ */ jsx(CircularProgress, { size: "20px", color: "success" }) : /* @__PURE__ */ jsx(
969
+ Call,
970
+ {
971
+ sx: {
972
+ color: callDisabled ? "default" : "#f3f2f2"
973
+ }
974
+ }
975
+ )
976
+ }
977
+ ) }) });
978
+ })(),
979
+ (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ jsx(Tooltip, { title: "Merge Call", children: /* @__PURE__ */ jsx(
980
+ Button,
981
+ {
982
+ variant: (each == null ? void 0 : each.status) === "ONCALL" /* ONCALL */ ? "contained" : "outlined",
983
+ sx: (each == null ? void 0 : each.status) === "ONCALL" /* ONCALL */ ? __spreadValues({}, enabled) : __spreadValues({}, disabled),
984
+ onClick: () => {
985
+ onMergeConferenceCall(each, { isMergeCall: true });
986
+ },
987
+ disabled: (each == null ? void 0 : each.status) !== "ONCALL" /* ONCALL */,
988
+ children: conferenceCallMerge ? /* @__PURE__ */ jsx(CircularProgress, { size: "20px" }) : /* @__PURE__ */ jsx(CallSplit, {})
989
+ }
990
+ ) }),
991
+ (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ jsx(Tooltip, { title: (each == null ? void 0 : each.status) !== "HOLD" /* HOLD */ ? "Hold" : "Resume", children: /* @__PURE__ */ jsx(
992
+ Button,
993
+ {
994
+ variant: (each == null ? void 0 : each.status) === "HOLD" /* HOLD */ ? "contained" : "outlined",
995
+ sx: (each == null ? void 0 : each.status) === "CONFERENCE" /* CONFERENCE */ ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
996
+ onClick: () => {
997
+ if (each.status === "HOLD" /* HOLD */) {
998
+ onHoldOrUnHoldConferenceCall(each, { isHold: false }, "UNHOLDUSER");
999
+ } else {
1000
+ onHoldOrUnHoldConferenceCall(each, { isHold: true }, "HOLDUSER");
1001
+ }
1002
+ },
1003
+ disabled: (each == null ? void 0 : each.status) !== "CONFERENCE" /* CONFERENCE */ && (each == null ? void 0 : each.status) !== "HOLD" /* HOLD */ || conferenceCallHoldOrUnHold,
1004
+ children: conferenceCallHoldOrUnHold ? /* @__PURE__ */ jsx(CircularProgress, { size: "20px", sx: { color: theme.palette.primary.main } }) : each.status === "HOLD" /* HOLD */ ? /* @__PURE__ */ jsx(PlayArrow, {}) : /* @__PURE__ */ jsx(Pause, {})
1005
+ }
1006
+ ) }),
1007
+ (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ jsx(Tooltip, { title: "End Call", children: /* @__PURE__ */ jsx(
1008
+ Button,
1009
+ {
1010
+ variant: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ && (each == null ? void 0 : each.status) !== "DISCONNECTED" /* DISCONNECTED */ ? "contained" : "outlined",
1011
+ color: "error",
1012
+ sx: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ && (each == null ? void 0 : each.status) !== "DISCONNECTED" /* DISCONNECTED */ ? __spreadProps(__spreadValues({}, enabled), {
1013
+ border: `0px solid ${theme.palette.error.light}`,
1014
+ "&:hover": {
1015
+ bgcolor: "error.light",
1016
+ boxShadow: `0px 2px 1px ${theme.palette.error.light}`,
1017
+ border: `0px solid ${theme.palette.error.light}`
1018
+ },
1019
+ "&:active": {
1020
+ bgcolor: "error.light",
1021
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1022
+ }
1023
+ }) : __spreadValues({}, disabled),
1024
+ onClick: () => {
1025
+ onEndConferenceCall(each, {
1026
+ isCallStart: false,
1027
+ isMergeCall: false,
1028
+ isMute: false,
1029
+ isHold: false
1030
+ });
1031
+ },
1032
+ disabled: (each == null ? void 0 : each.status) === "IDLE" /* IDLE */ || (each == null ? void 0 : each.status) === "DISCONNECTED" /* DISCONNECTED */ || conferenceCallEnd,
1033
+ children: conferenceCallEnd ? /* @__PURE__ */ jsx(CircularProgress, { size: "20px", color: "error" }) : /* @__PURE__ */ jsx(CallEnd, {})
1034
+ }
1035
+ ) })
1036
+ ]
1037
+ }
1038
+ )
1039
+ }
1040
+ )
1041
+ ]
1042
+ },
1043
+ each.line
1044
+ );
1045
+ };
1046
+ function ConferenceDialog() {
1047
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1048
+ const state = useSDKState();
1049
+ const { showToast } = useToast();
1050
+ const [conferenceCallEndAll, setConferenceCallEndAll] = useState6(false);
1051
+ const handleClose = () => {
1052
+ sdkStateManager.setOpenConferenceDialog(false);
1053
+ };
1054
+ const onEndAllConferenceCalls = () => {
1055
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n;
1056
+ setConferenceCallEndAll(true);
1057
+ const payload = {
1058
+ action: "EXTERNAL_CONFERENCE",
1059
+ operation: "ENDCONFERENCE",
1060
+ userid: (_a2 = state.agentId) != null ? _a2 : "",
1061
+ process: (_c2 = (_b2 = state.callData) == null ? void 0 : _b2.process_name) != null ? _c2 : "",
1062
+ processid: (_f2 = (_e2 = (_d2 = state.process) == null ? void 0 : _d2.process_id) == null ? void 0 : _e2.toString()) != null ? _f2 : "",
1063
+ process_name: (_h2 = (_g2 = state.process) == null ? void 0 : _g2.process_name) != null ? _h2 : "",
1064
+ callreferenceid: (_j2 = (_i2 = state.callData) == null ? void 0 : _i2.call_id) != null ? _j2 : "",
1065
+ call_id: (_l2 = (_k2 = state.callData) == null ? void 0 : _k2.call_id) != null ? _l2 : "",
1066
+ mobile_number: (_n = (_m2 = state.callData) == null ? void 0 : _m2.phone_number) != null ? _n : ""
1067
+ };
1068
+ axios_default.post(END_POINT.CONFERENCE_CALL_END_ALL, payload).then(() => {
1069
+ showToast("Call disconnected successfully", "success");
1070
+ sdkStateManager.resetConferenceLines();
1071
+ handleClose();
1072
+ }).catch((err) => {
1073
+ var _a3, _b3, _c3, _d3;
1074
+ const message = ((_b3 = (_a3 = err.response) == null ? void 0 : _a3.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
1075
+ showToast(message, "error");
1076
+ }).finally(() => {
1077
+ setConferenceCallEndAll(false);
1078
+ });
1079
+ };
1080
+ const handleTransferConferenceCall = () => {
1081
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n;
1082
+ const payload = {
1083
+ action: "TRANSFERAPI",
1084
+ userid: (_a2 = state.agentId) != null ? _a2 : "",
1085
+ process: (_c2 = (_b2 = state.callData) == null ? void 0 : _b2.process_name) != null ? _c2 : "",
1086
+ processid: (_f2 = (_e2 = (_d2 = state.process) == null ? void 0 : _d2.process_id) == null ? void 0 : _e2.toString()) != null ? _f2 : "",
1087
+ process_name: (_h2 = (_g2 = state.process) == null ? void 0 : _g2.process_name) != null ? _h2 : "",
1088
+ callreferenceid: (_j2 = (_i2 = state.callData) == null ? void 0 : _i2.call_id) != null ? _j2 : "",
1089
+ call_id: (_l2 = (_k2 = state.callData) == null ? void 0 : _k2.call_id) != null ? _l2 : "",
1090
+ mobile_number: (_n = (_m2 = state.callData) == null ? void 0 : _m2.phone_number) != null ? _n : ""
1091
+ };
1092
+ axios_default.post(END_POINT.CONFERENCE_CALL_TRANSFER, payload).then((res) => {
1093
+ var _a3;
1094
+ showToast((_a3 = res.data) == null ? void 0 : _a3.message, "success");
1095
+ sdkStateManager.resetConferenceLines();
1096
+ handleClose();
1097
+ }).catch((err) => {
1098
+ var _a3, _b3, _c3, _d3;
1099
+ const message = ((_b3 = (_a3 = err.response) == null ? void 0 : _a3.data) == null ? void 0 : _b3.detail) || ((_d3 = (_c3 = err.response) == null ? void 0 : _c3.data) == null ? void 0 : _d3.message) || err.message || "An unknown error occurred";
1100
+ showToast(message, "error");
1101
+ });
1102
+ };
1103
+ const isLineDialing = (_a = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _a.some((item) => (item == null ? void 0 : item.status) === "DIALING" /* DIALING */);
1104
+ const conferenceLineCount = (_d = (_c = (_b = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _b.filter((item) => (item == null ? void 0 : item.status) === "CONFERENCE" /* CONFERENCE */)) == null ? void 0 : _c.length) != null ? _d : 0;
1105
+ const isHold = (_e = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _e.some((item) => (item == null ? void 0 : item.status) === "HOLD" /* HOLD */);
1106
+ const isOnCall = (_f = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _f.some((item) => (item == null ? void 0 : item.status) === "ONCALL" /* ONCALL */);
1107
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
1108
+ Dialog,
1109
+ {
1110
+ open: state.openConferenceDialog,
1111
+ "aria-labelledby": "alert-dialog-title",
1112
+ "aria-describedby": "alert-dialog-description",
1113
+ maxWidth: "md",
1114
+ slotProps: { paper: { sx: { minWidth: 800 } } },
1115
+ children: /* @__PURE__ */ jsxs(Paper, { sx: { borderRadius: 2 }, children: [
1116
+ /* @__PURE__ */ jsxs(
1117
+ Box,
1118
+ {
1119
+ sx: {
1120
+ display: "flex",
1121
+ justifyContent: "space-between",
1122
+ alignItems: "center",
1123
+ padding: "0px 16px",
1124
+ paddingBottom: "6px",
1125
+ boxShadow: "1px 1px 2px #e7e5e5ff",
1126
+ margin: "10px 0px"
1127
+ },
1128
+ children: [
1129
+ /* @__PURE__ */ jsxs(
1130
+ Typography,
1131
+ {
1132
+ variant: "body1",
1133
+ color: "primary.main",
1134
+ sx: { textTransform: "uppercase", fontWeight: "bold", fontSize: "14px" },
1135
+ children: [
1136
+ (_g = state == null ? void 0 : state.agentId) != null ? _g : "",
1137
+ " conference"
1138
+ ]
1139
+ }
1140
+ ),
1141
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
1142
+ IconButton,
1143
+ {
1144
+ onClick: handleClose,
1145
+ color: "primary",
1146
+ children: /* @__PURE__ */ jsx(Close, { sx: { color: "primary.main" } })
1147
+ }
1148
+ ) })
1149
+ ]
1150
+ }
1151
+ ),
1152
+ /* @__PURE__ */ jsx(
1153
+ Box,
1154
+ {
1155
+ sx: {
1156
+ boxShadow: "1px 1px 2px #e7e5e5ff",
1157
+ margin: "0px 15px",
1158
+ borderRadius: "20px"
1159
+ },
1160
+ children: /* @__PURE__ */ jsx(
1161
+ TableContainer,
1162
+ {
1163
+ component: Paper,
1164
+ sx: {
1165
+ outline: "0px solid gray !important",
1166
+ boxShadow: "1px 1px 6px #e7e5e5ff"
1167
+ },
1168
+ children: /* @__PURE__ */ jsxs(Table, { sx: { border: "4px solid #ffffff !important" }, children: [
1169
+ /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { sx: { border: "2px solid #f3f3f3ff !important" }, children: [
1170
+ /* @__PURE__ */ jsx(TableCell, { sx: { padding: "6px" }, children: "Line" }),
1171
+ /* @__PURE__ */ jsx(TableCell, { sx: { padding: "6px" }, children: "Status" }),
1172
+ /* @__PURE__ */ jsx(TableCell, { sx: { padding: "6px" }, children: "Mobile Number" }),
1173
+ /* @__PURE__ */ jsx(TableCell, { sx: { padding: "6px" }, children: "Call Actions" })
1174
+ ] }) }),
1175
+ /* @__PURE__ */ jsx(TableBody, { children: state == null ? void 0 : state.conferenceLine.map((each) => /* @__PURE__ */ jsx(ConferenceTableRow, { each, isLineDialing }, each.line)) })
1176
+ ] })
1177
+ }
1178
+ )
1179
+ }
1180
+ ),
1181
+ /* @__PURE__ */ jsx(Box, { sx: { textAlign: "center", m: 2 }, children: /* @__PURE__ */ jsx(Tooltip, { title: ((_h = state.sdkConfig) == null ? void 0 : _h.disableEndConference) ? "End Conference feature is disabled" : "", children: /* @__PURE__ */ jsx(Box, { component: "span", children: /* @__PURE__ */ jsxs(
1182
+ Button,
1183
+ {
1184
+ variant: "outlined",
1185
+ color: "error",
1186
+ size: "large",
1187
+ onClick: onEndAllConferenceCalls,
1188
+ disabled: conferenceCallEndAll || conferenceLineCount <= 0 || ((_i = state.sdkConfig) == null ? void 0 : _i.disableEndConference),
1189
+ sx: { px: 2, borderRadius: "20px", textTransform: "capitalize" },
1190
+ children: [
1191
+ conferenceCallEndAll ? /* @__PURE__ */ jsx(
1192
+ CircularProgress,
1193
+ {
1194
+ size: "20px",
1195
+ color: "error",
1196
+ sx: { marginRight: "8px" }
1197
+ }
1198
+ ) : /* @__PURE__ */ jsx(
1199
+ IconButton,
1200
+ {
1201
+ disabled: !!((_j = state.sdkConfig) == null ? void 0 : _j.disableEndConference),
1202
+ sx: {
1203
+ bgcolor: ((_k = state.sdkConfig) == null ? void 0 : _k.disableEndConference) ? "action.disabledBackground" : "error.main",
1204
+ "&:hover": { bgcolor: ((_l = state.sdkConfig) == null ? void 0 : _l.disableEndConference) ? "action.disabledBackground" : "error.dark" },
1205
+ marginRight: "8px",
1206
+ width: "28px",
1207
+ height: "28px",
1208
+ fontSize: "12px",
1209
+ fontWeight: "600",
1210
+ lineHeight: "16px",
1211
+ letterSpacing: "0.02em",
1212
+ textTransform: "capitalize",
1213
+ color: "white",
1214
+ display: "flex",
1215
+ alignItems: "center",
1216
+ justifyContent: "center",
1217
+ borderRadius: "50%"
1218
+ },
1219
+ children: /* @__PURE__ */ jsx(PhoneDisabled, { sx: { color: ((_m = state.sdkConfig) == null ? void 0 : _m.disableEndConference) ? "action.disabled" : "white", fontSize: "16px", fontWeight: "600" } })
1220
+ }
1221
+ ),
1222
+ "End Conference"
1223
+ ]
1224
+ }
1225
+ ) }) }) })
1226
+ ] })
1227
+ }
1228
+ ) });
1229
+ }
1230
+ function CallTransferDialog({ open }) {
1231
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
1232
+ const state = useSDKState();
1233
+ const [mobileNumber, setMobileNumber] = useState6("");
1234
+ const [transferCall, { isLoading: isTransferLoading }] = usePostRequest({
1235
+ onSuccess: () => {
1236
+ sdkStateManager.setOpenCallTransferDialog(false);
1237
+ }
1238
+ });
1239
+ const [initiateConsultCall] = usePostRequest({});
1240
+ const [completeConsultTransfer, { isLoading: isCompleteConsultLoading }] = usePostRequest({
1241
+ onSuccess: () => {
1242
+ sdkStateManager.setConsultInfo(null);
1243
+ sdkStateManager.setOpenCallTransferDialog(false);
1244
+ }
1245
+ });
1246
+ const [cancelConsultTransfer, { isLoading: isCancelConsultLoading }] = usePostRequest({
1247
+ onSuccess: () => {
1248
+ sdkStateManager.setConsultInfo(null);
1249
+ }
1250
+ });
1251
+ const [currentselecteTab, setCurrentselecteTab] = useState6("queues");
1252
+ const [transferMenuAnchor, setTransferMenuAnchor] = useState6(null);
1253
+ const [pendingTransferData, setPendingTransferData] = useState6(null);
1254
+ const blindEnabled = !((_a = state.sdkConfig) == null ? void 0 : _a.disableBlindTransfer);
1255
+ const attendedEnabled = !((_b = state.sdkConfig) == null ? void 0 : _b.disableAttendedTransfer);
1256
+ const enabledTransferModeCount = (blindEnabled ? 1 : 0) + (attendedEnabled ? 1 : 0);
1257
+ const singleTransferMode = enabledTransferModeCount === 1 ? blindEnabled ? "DEFAULT" : "CONSULT" : null;
1258
+ const [getIdelAgentsList, { data: idleAgentsList, isLoading: isIdleAgentsListLoading }] = usePostRequest({ disabledSuccessToast: true });
1259
+ const [
1260
+ getHospitalsServicesList,
1261
+ { data: hospitalsServicesList, isLoading: isHospitalsServicesListLoading }
1262
+ ] = useGetRequest({ disabledSuccessToast: true });
1263
+ const [
1264
+ getProcessAndQueuesList,
1265
+ { data: processAndQueuesList, isLoading: isProcessAndQueuesListLoading }
1266
+ ] = usePostRequest({ disabledSuccessToast: true });
1267
+ const handleClose = () => {
1268
+ sdkStateManager.setOpenCallTransferDialog(false);
1269
+ };
1270
+ const handleTransferCall = (data, type, mode = "DEFAULT") => {
1271
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v2, _w2, _x2, _y2, _z, _A, _B, _C, _D, _E;
1272
+ const lead_data = sdkStateManager.getTransferLeadData();
1273
+ if (type === "PROCESS") {
1274
+ const payload = __spreadValues({
1275
+ mobile_number: (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.phone_number) != null ? _b2 : "",
1276
+ userid: state.agentId,
1277
+ type: "PROCESS",
1278
+ transfer_to: (_c2 = data == null ? void 0 : data.process_name) != null ? _c2 : "",
1279
+ callreferenceid: (_e2 = (_d2 = state.callData) == null ? void 0 : _d2.call_id) != null ? _e2 : "",
1280
+ processid: String((_g2 = (_f2 = state.callData) == null ? void 0 : _f2.process_id) != null ? _g2 : ""),
1281
+ process_name: (_i2 = (_h2 = state.callData) == null ? void 0 : _h2.process_name) != null ? _i2 : ""
1282
+ }, lead_data !== void 0 && { lead_data });
1283
+ transferCall(END_POINT.TRANSFER_CALL, payload);
1284
+ } else if (type === "QUEUE") {
1285
+ const payload = __spreadValues({
1286
+ mobile_number: (_k2 = (_j2 = state.callData) == null ? void 0 : _j2.phone_number) != null ? _k2 : "",
1287
+ userid: state.agentId,
1288
+ type: "QUEUE",
1289
+ transfer_to: (_l2 = data == null ? void 0 : data.queue_name) != null ? _l2 : "",
1290
+ callreferenceid: (_n2 = (_m2 = state.callData) == null ? void 0 : _m2.call_id) != null ? _n2 : "",
1291
+ processid: String((_p2 = (_o2 = state.callData) == null ? void 0 : _o2.process_id) != null ? _p2 : ""),
1292
+ process_name: (_r2 = (_q2 = state.callData) == null ? void 0 : _q2.process_name) != null ? _r2 : ""
1293
+ }, lead_data !== void 0 && { lead_data });
1294
+ transferCall(END_POINT.TRANSFER_CALL, payload);
1295
+ } else if (type === "AGENT") {
1296
+ const payload = __spreadValues({
1297
+ mobile_number: (_t2 = (_s2 = state.callData) == null ? void 0 : _s2.phone_number) != null ? _t2 : "",
1298
+ userid: state.agentId,
1299
+ type: "AGENT",
1300
+ transfer_type: mode === "CONSULT" ? "ATTENDED" : "BLIND",
1301
+ transfer_to: (_v2 = (_u2 = data == null ? void 0 : data.user_id) == null ? void 0 : _u2.toString()) != null ? _v2 : "",
1302
+ callreferenceid: (_x2 = (_w2 = state.callData) == null ? void 0 : _w2.call_id) != null ? _x2 : "",
1303
+ processid: String((_z = (_y2 = state.callData) == null ? void 0 : _y2.process_id) != null ? _z : ""),
1304
+ process_name: (_B = (_A = state.callData) == null ? void 0 : _A.process_name) != null ? _B : ""
1305
+ }, lead_data !== void 0 && { lead_data });
1306
+ if (mode === "CONSULT") {
1307
+ initiateConsultCall(END_POINT.TRANSFER_CALL, payload);
1308
+ } else {
1309
+ transferCall(END_POINT.TRANSFER_CALL, payload);
1310
+ }
1311
+ } else if (type === "OTHER") {
1312
+ const payload = __spreadValues({
1313
+ // action: mode === "CONSULT" ? "ATTENDED" : "BLIND_TRANSFER",
1314
+ transfer_type: mode === "CONSULT" ? "ATTENDED" : "BLIND",
1315
+ type: "OTHER",
1316
+ transfer_to: (_C = data == null ? void 0 : data.mobile_number) != null ? _C : "",
1317
+ userid: state.agentId,
1318
+ callreferenceid: (_E = (_D = state.callData) == null ? void 0 : _D.call_id) != null ? _E : ""
1319
+ }, lead_data !== void 0 && { lead_data });
1320
+ if (mode === "CONSULT") {
1321
+ initiateConsultCall(END_POINT.TRANSFER_CALL, payload);
1322
+ } else {
1323
+ transferCall(END_POINT.TRANSFER_CALL, payload);
1324
+ }
1325
+ }
1326
+ };
1327
+ const handleTransferClick = (e, data, type) => {
1328
+ if (singleTransferMode) {
1329
+ handleTransferCall(data, type, singleTransferMode);
1330
+ } else {
1331
+ setPendingTransferData({ data, type });
1332
+ setTransferMenuAnchor(e.currentTarget);
1333
+ }
1334
+ };
1335
+ useEffect3(() => {
1336
+ getIdelAgentsList(END_POINT.AGENTS_LIST, { status: "IDLE", active: true });
1337
+ getProcessAndQueuesList(END_POINT.TRANSFER_TO_DETAILS, { status: "ACTIVE", active: true });
1338
+ getHospitalsServicesList(END_POINT.HOSPITALS_SERVICES);
1339
+ }, []);
1340
+ useEffect3(() => {
1341
+ if (!open || currentselecteTab !== "agents") return;
1342
+ const intervalId = setInterval(() => {
1343
+ getIdelAgentsList(END_POINT.AGENTS_LIST, { status: "IDLE", active: true });
1344
+ }, 2e3);
1345
+ return () => clearInterval(intervalId);
1346
+ }, [open, currentselecteTab]);
1347
+ const idleAgentsLoaderActive = isIdleAgentsListLoading && !(idleAgentsList == null ? void 0 : idleAgentsList.data);
1348
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1349
+ /* @__PURE__ */ jsx(
1350
+ Dialog,
1351
+ {
1352
+ open,
1353
+ "aria-labelledby": "alert-dialog-title",
1354
+ "aria-describedby": "alert-dialog-description",
1355
+ maxWidth: "md",
1356
+ slotProps: { paper: { sx: { minWidth: 600 } } },
1357
+ children: /* @__PURE__ */ jsxs(Paper, { sx: { borderRadius: 2 }, children: [
1358
+ /* @__PURE__ */ jsxs(
1359
+ Box,
1360
+ {
1361
+ sx: {
1362
+ display: "flex",
1363
+ alignItems: "center",
1364
+ padding: "4px 16px",
1365
+ boxShadow: "0px 1px 2px #f5f5f5ff",
1366
+ position: "relative"
1367
+ },
1368
+ children: [
1369
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { flex: 1 }, children: " Call Transfer" }),
1370
+ /* @__PURE__ */ jsxs(Box, { sx: { position: "absolute", left: "50%", transform: "translateX(-50%)" }, children: [
1371
+ state.consultInfo && ((_c = state.consultInfo.status) == null ? void 0 : _c.toUpperCase()) === "RINGING" /* RINGING */ && /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
1372
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { whiteSpace: "nowrap" }, children: "Trying to consult" }),
1373
+ /* @__PURE__ */ jsx(Box, { component: "span", sx: { display: "inline-flex", gap: "3px", alignItems: "flex-end", height: "14px" }, children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx(Box, { component: "span", sx: {
1374
+ "@keyframes jumpDot": {
1375
+ "0%, 60%, 100%": { transform: "translateY(0)" },
1376
+ "30%": { transform: "translateY(-5px)" }
1377
+ },
1378
+ animation: "jumpDot 1s ease-in-out infinite",
1379
+ animationDelay: `${i * 0.15}s`,
1380
+ fontSize: "14px",
1381
+ fontWeight: 700,
1382
+ lineHeight: 1,
1383
+ display: "inline-block"
1384
+ }, children: "." }, i)) })
1385
+ ] }),
1386
+ state.consultInfo && ((_d = state.consultInfo.status) == null ? void 0 : _d.toUpperCase()) === "ONCALL" /* ONCALL */ && /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
1387
+ /* @__PURE__ */ jsx(
1388
+ Button,
1389
+ {
1390
+ variant: "outlined",
1391
+ size: "small",
1392
+ startIcon: isCompleteConsultLoading ? /* @__PURE__ */ jsx(CircularProgress, { size: 14 }) : /* @__PURE__ */ jsx(TransferWithinAStation, { sx: { fontSize: 16 } }),
1393
+ disabled: isCompleteConsultLoading || isCancelConsultLoading,
1394
+ onClick: () => {
1395
+ if (state.consultInfo) {
1396
+ completeConsultTransfer(END_POINT.TRANSFER_COMPLETE, {}, {
1397
+ params: { call_uuid: state.consultInfo.call_uuid }
1398
+ });
1399
+ }
1400
+ },
1401
+ children: "Transfer"
1402
+ }
1403
+ ),
1404
+ /* @__PURE__ */ jsx(
1405
+ Button,
1406
+ {
1407
+ variant: "outlined",
1408
+ size: "small",
1409
+ color: "error",
1410
+ startIcon: isCancelConsultLoading ? /* @__PURE__ */ jsx(CircularProgress, { size: 14 }) : /* @__PURE__ */ jsx(PhoneDisabled, { sx: { fontSize: 16 } }),
1411
+ disabled: isCancelConsultLoading || isCompleteConsultLoading,
1412
+ onClick: () => {
1413
+ if (state.consultInfo) {
1414
+ cancelConsultTransfer(END_POINT.TRANSFER_CANCEL, {
1415
+ status: state.consultInfo.status,
1416
+ participant_identifier: state.consultInfo.participant_identifier,
1417
+ channel_id: state.consultInfo.channel_id,
1418
+ call_uuid: state.consultInfo.call_uuid,
1419
+ bridge_id: state.consultInfo.bridge_id
1420
+ });
1421
+ }
1422
+ },
1423
+ children: "Cancel"
1424
+ }
1425
+ )
1426
+ ] })
1427
+ ] }),
1428
+ /* @__PURE__ */ jsx(Box, { sx: { flex: 1, display: "flex", justifyContent: "flex-end" }, children: /* @__PURE__ */ jsx(IconButton, { onClick: handleClose, children: /* @__PURE__ */ jsx(Close, {}) }) })
1429
+ ]
1430
+ }
1431
+ ),
1432
+ /* @__PURE__ */ jsxs(Box, { sx: { margin: "10px", borderRadius: "10px" }, children: [
1433
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", gap: 1, margin: "10px" }, children: [
1434
+ /* @__PURE__ */ jsx(
1435
+ Button,
1436
+ {
1437
+ variant: currentselecteTab === "queues" ? "contained" : "outlined",
1438
+ onClick: () => setCurrentselecteTab("queues"),
1439
+ children: "Queues"
1440
+ }
1441
+ ),
1442
+ /* @__PURE__ */ jsx(
1443
+ Button,
1444
+ {
1445
+ variant: currentselecteTab === "agents" ? "contained" : "outlined",
1446
+ onClick: () => {
1447
+ setCurrentselecteTab("agents");
1448
+ getIdelAgentsList(END_POINT.AGENTS_LIST, { status: "IDLE", active: true });
1449
+ },
1450
+ children: "Agents"
1451
+ }
1452
+ ),
1453
+ /* @__PURE__ */ jsx(
1454
+ Button,
1455
+ {
1456
+ variant: currentselecteTab === "others" ? "contained" : "outlined",
1457
+ onClick: () => setCurrentselecteTab("others"),
1458
+ children: "Others"
1459
+ }
1460
+ )
1461
+ ] }),
1462
+ (isProcessAndQueuesListLoading || idleAgentsLoaderActive || isHospitalsServicesListLoading || isTransferLoading) && /* @__PURE__ */ jsx(
1463
+ Box,
1464
+ {
1465
+ sx: {
1466
+ display: "flex",
1467
+ justifyContent: "center",
1468
+ alignItems: "center",
1469
+ height: "80px"
1470
+ },
1471
+ children: /* @__PURE__ */ jsx(CircularProgress, {})
1472
+ }
1473
+ ),
1474
+ !isProcessAndQueuesListLoading && !idleAgentsLoaderActive && !isHospitalsServicesListLoading && !isTransferLoading && currentselecteTab === "process" && /* @__PURE__ */ jsx(
1475
+ Box,
1476
+ {
1477
+ sx: {
1478
+ display: "grid",
1479
+ gridTemplateColumns: ((_e = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _e.process) && ((_g = (_f = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _f.process) == null ? void 0 : _g.length) > 0 ? "repeat(2, 1fr)" : "repeat(1, 1fr)",
1480
+ gap: 1,
1481
+ padding: "10px",
1482
+ flexWrap: "wrap",
1483
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1484
+ borderRadius: "10px"
1485
+ },
1486
+ children: ((_h = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _h.process) && ((_j = (_i = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _i.process) == null ? void 0 : _j.length) > 0 ? (_l = (_k = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _k.process) == null ? void 0 : _l.map((process, index) => /* @__PURE__ */ jsxs(
1487
+ Box,
1488
+ {
1489
+ sx: {
1490
+ p: 1,
1491
+ display: "flex",
1492
+ alignItems: "center",
1493
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1494
+ padding: "6px",
1495
+ borderRadius: "10px",
1496
+ "&:hover": { bgcolor: "action.selected" }
1497
+ },
1498
+ children: [
1499
+ /* @__PURE__ */ jsxs(
1500
+ Typography,
1501
+ {
1502
+ variant: "body1",
1503
+ sx: {
1504
+ mx: 1,
1505
+ width: "200px",
1506
+ maxWidth: "250px",
1507
+ display: "flex",
1508
+ alignItems: "center"
1509
+ },
1510
+ children: [
1511
+ /* @__PURE__ */ jsx(MemoryOutlined, { sx: { marginRight: "4px" } }),
1512
+ process.process_name
1513
+ ]
1514
+ }
1515
+ ),
1516
+ /* @__PURE__ */ jsx(Tooltip, { title: state.consultInfo ? "Please complete or cancel the ongoing consult transfer before proceeding." : "", children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
1517
+ IconButton,
1518
+ {
1519
+ color: "success",
1520
+ sx: {
1521
+ bgcolor: "action.hover",
1522
+ "&:hover": { bgcolor: "action.selected" }
1523
+ },
1524
+ disabled: !!state.consultInfo,
1525
+ onClick: () => handleTransferCall(process, "PROCESS"),
1526
+ children: /* @__PURE__ */ jsx(Call, {})
1527
+ }
1528
+ ) }) })
1529
+ ]
1530
+ },
1531
+ index
1532
+ )) : /* @__PURE__ */ jsxs(
1533
+ Box,
1534
+ {
1535
+ sx: {
1536
+ display: "flex",
1537
+ alignItems: "center",
1538
+ justifyContent: "center",
1539
+ flexDirection: "column",
1540
+ p: 2
1541
+ },
1542
+ children: [
1543
+ /* @__PURE__ */ jsx(Upcoming, { color: "primary" }),
1544
+ /* @__PURE__ */ jsx(
1545
+ Typography,
1546
+ {
1547
+ variant: "body1",
1548
+ sx: {
1549
+ fontSize: "16px",
1550
+ letterSpacing: "0.02em",
1551
+ textTransform: "capitalize",
1552
+ display: "flex",
1553
+ alignItems: "center",
1554
+ justifyContent: "center",
1555
+ width: "100%",
1556
+ margin: "10px 0px",
1557
+ color: "primary.main",
1558
+ height: "20px"
1559
+ },
1560
+ children: "No Process Found"
1561
+ }
1562
+ )
1563
+ ]
1564
+ }
1565
+ )
1566
+ }
1567
+ ),
1568
+ !isProcessAndQueuesListLoading && !idleAgentsLoaderActive && !isHospitalsServicesListLoading && !isTransferLoading && currentselecteTab === "queues" && /* @__PURE__ */ jsx(
1569
+ Box,
1570
+ {
1571
+ sx: {
1572
+ display: "grid",
1573
+ gridTemplateColumns: ((_m = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _m.queue) && ((_o = (_n = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _n.queue) == null ? void 0 : _o.length) > 0 ? "repeat(2, 1fr)" : "repeat(1, 1fr)",
1574
+ gap: 1,
1575
+ padding: "10px",
1576
+ flexWrap: "wrap",
1577
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1578
+ borderRadius: "10px"
1579
+ },
1580
+ children: ((_p = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _p.queue) && ((_r = (_q = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _q.queue) == null ? void 0 : _r.length) > 0 ? (_t = (_s = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _s.queue) == null ? void 0 : _t.map((queue, index) => {
1581
+ var _a2, _b2, _c2, _d2, _e2, _f2;
1582
+ return /* @__PURE__ */ jsxs(
1583
+ Box,
1584
+ {
1585
+ sx: {
1586
+ p: 1,
1587
+ display: "flex",
1588
+ alignItems: "center",
1589
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1590
+ padding: "6px",
1591
+ borderRadius: "10px",
1592
+ "&:hover": { bgcolor: "action.selected" }
1593
+ },
1594
+ children: [
1595
+ /* @__PURE__ */ jsxs(
1596
+ Typography,
1597
+ {
1598
+ variant: "body1",
1599
+ sx: {
1600
+ mx: 1,
1601
+ width: "200px",
1602
+ maxWidth: "250px",
1603
+ display: "flex",
1604
+ alignItems: "center"
1605
+ },
1606
+ children: [
1607
+ /* @__PURE__ */ jsx(Airlines, { sx: { marginRight: "4px" } }),
1608
+ queue.queue_name,
1609
+ ((_c2 = (_b2 = (_a2 = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _a2.process) == null ? void 0 : _b2.find(
1610
+ (process) => process.process_id === queue.process_id
1611
+ )) == null ? void 0 : _c2.process_name) ? /* @__PURE__ */ jsx(
1612
+ Typography,
1613
+ {
1614
+ variant: "body1",
1615
+ sx: {
1616
+ fontSize: "12px",
1617
+ fontWeight: "600",
1618
+ letterSpacing: "0.02em",
1619
+ textTransform: "capitalize",
1620
+ color: "gray"
1621
+ },
1622
+ children: "(" + ((_f2 = (_e2 = (_d2 = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _d2.process) == null ? void 0 : _e2.find(
1623
+ (process) => process.process_id === queue.process_id
1624
+ )) == null ? void 0 : _f2.process_name) + ")"
1625
+ }
1626
+ ) : ""
1627
+ ]
1628
+ }
1629
+ ),
1630
+ /* @__PURE__ */ jsx(Tooltip, { title: state.consultInfo ? "Please complete or cancel the ongoing consult transfer before proceeding." : "", children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
1631
+ IconButton,
1632
+ {
1633
+ color: "success",
1634
+ sx: {
1635
+ bgcolor: "action.hover",
1636
+ "&:hover": { bgcolor: "action.selected" }
1637
+ },
1638
+ disabled: !!state.consultInfo,
1639
+ onClick: () => handleTransferCall(queue, "QUEUE"),
1640
+ children: /* @__PURE__ */ jsx(Call, {})
1641
+ }
1642
+ ) }) })
1643
+ ]
1644
+ },
1645
+ index
1646
+ );
1647
+ }) : /* @__PURE__ */ jsxs(
1648
+ Box,
1649
+ {
1650
+ sx: {
1651
+ display: "flex",
1652
+ alignItems: "center",
1653
+ justifyContent: "center",
1654
+ flexDirection: "column",
1655
+ p: 2
1656
+ },
1657
+ children: [
1658
+ /* @__PURE__ */ jsx(Upcoming, { color: "primary" }),
1659
+ /* @__PURE__ */ jsx(
1660
+ Typography,
1661
+ {
1662
+ variant: "body1",
1663
+ sx: {
1664
+ fontSize: "16px",
1665
+ letterSpacing: "0.02em",
1666
+ textTransform: "capitalize",
1667
+ display: "flex",
1668
+ alignItems: "center",
1669
+ justifyContent: "center",
1670
+ width: "100%",
1671
+ margin: "10px 0px",
1672
+ color: "primary.main",
1673
+ height: "20px"
1674
+ },
1675
+ children: "No Queues Found"
1676
+ }
1677
+ )
1678
+ ]
1679
+ }
1680
+ )
1681
+ }
1682
+ ),
1683
+ !isProcessAndQueuesListLoading && !idleAgentsLoaderActive && !isHospitalsServicesListLoading && !isTransferLoading && currentselecteTab === "agents" && /* @__PURE__ */ jsx(
1684
+ Box,
1685
+ {
1686
+ sx: {
1687
+ display: "grid",
1688
+ gridTemplateColumns: (idleAgentsList == null ? void 0 : idleAgentsList.data) && ((_u = idleAgentsList == null ? void 0 : idleAgentsList.data) == null ? void 0 : _u.length) > 0 ? "repeat(2, 1fr)" : "repeat(1, 1fr)",
1689
+ gap: 1,
1690
+ padding: "10px",
1691
+ flexWrap: "wrap",
1692
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1693
+ borderRadius: "10px"
1694
+ },
1695
+ children: (idleAgentsList == null ? void 0 : idleAgentsList.data) && ((_v = idleAgentsList == null ? void 0 : idleAgentsList.data) == null ? void 0 : _v.length) > 0 ? (_w = idleAgentsList == null ? void 0 : idleAgentsList.data) == null ? void 0 : _w.map((agent, index) => /* @__PURE__ */ jsxs(
1696
+ Box,
1697
+ {
1698
+ sx: {
1699
+ p: 1,
1700
+ display: "flex",
1701
+ alignItems: "center",
1702
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1703
+ padding: "6px",
1704
+ borderRadius: "10px",
1705
+ "&:hover": { bgcolor: "action.selected" }
1706
+ },
1707
+ children: [
1708
+ /* @__PURE__ */ jsxs(
1709
+ Typography,
1710
+ {
1711
+ variant: "body1",
1712
+ sx: {
1713
+ mx: 1,
1714
+ width: "200px",
1715
+ maxWidth: "250px",
1716
+ display: "flex",
1717
+ alignItems: "center"
1718
+ },
1719
+ children: [
1720
+ /* @__PURE__ */ jsx(SupportAgent, { sx: { marginRight: "4px" } }),
1721
+ agent.name
1722
+ ]
1723
+ }
1724
+ ),
1725
+ /* @__PURE__ */ jsx(Tooltip, { title: state.consultInfo ? "Please complete or cancel the ongoing consult transfer before proceeding." : "", children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
1726
+ IconButton,
1727
+ {
1728
+ color: "success",
1729
+ sx: {
1730
+ bgcolor: "action.hover",
1731
+ "&:hover": { bgcolor: "action.selected" }
1732
+ },
1733
+ disabled: !!state.consultInfo,
1734
+ onClick: (e) => handleTransferClick(e, agent, "AGENT"),
1735
+ children: /* @__PURE__ */ jsx(Call, {})
1736
+ }
1737
+ ) }) })
1738
+ ]
1739
+ },
1740
+ index
1741
+ )) : /* @__PURE__ */ jsxs(
1742
+ Box,
1743
+ {
1744
+ sx: {
1745
+ display: "flex",
1746
+ alignItems: "center",
1747
+ justifyContent: "center",
1748
+ flexDirection: "column",
1749
+ p: 2
1750
+ },
1751
+ children: [
1752
+ /* @__PURE__ */ jsx(Upcoming, { color: "primary" }),
1753
+ /* @__PURE__ */ jsx(
1754
+ Typography,
1755
+ {
1756
+ variant: "body1",
1757
+ sx: {
1758
+ fontSize: "16px",
1759
+ letterSpacing: "0.02em",
1760
+ textTransform: "capitalize",
1761
+ display: "flex",
1762
+ alignItems: "center",
1763
+ justifyContent: "center",
1764
+ width: "100%",
1765
+ margin: "10px 0px",
1766
+ color: "primary.main",
1767
+ height: "20px"
1768
+ },
1769
+ children: "No Agents Found"
1770
+ }
1771
+ )
1772
+ ]
1773
+ }
1774
+ )
1775
+ }
1776
+ ),
1777
+ !isProcessAndQueuesListLoading && !idleAgentsLoaderActive && !isHospitalsServicesListLoading && !isTransferLoading && currentselecteTab === "others" && /* @__PURE__ */ jsxs(
1778
+ Box,
1779
+ {
1780
+ sx: {
1781
+ display: "grid",
1782
+ gridTemplateColumns: "repeat(2, 1fr)",
1783
+ gap: 1,
1784
+ padding: "10px",
1785
+ flexWrap: "wrap",
1786
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1787
+ borderRadius: "10px"
1788
+ },
1789
+ children: [
1790
+ (hospitalsServicesList == null ? void 0 : hospitalsServicesList.data) && ((_x = hospitalsServicesList == null ? void 0 : hospitalsServicesList.data) == null ? void 0 : _x.length) > 0 && ((_y = hospitalsServicesList == null ? void 0 : hospitalsServicesList.data) == null ? void 0 : _y.map((service, index) => {
1791
+ var _a2, _b2, _c2;
1792
+ return /* @__PURE__ */ jsxs(
1793
+ Box,
1794
+ {
1795
+ sx: {
1796
+ p: 1,
1797
+ display: "flex",
1798
+ alignItems: "center",
1799
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1800
+ padding: "6px",
1801
+ borderRadius: "10px",
1802
+ "&:hover": { bgcolor: "action.selected" }
1803
+ },
1804
+ children: [
1805
+ /* @__PURE__ */ jsxs(
1806
+ Typography,
1807
+ {
1808
+ variant: "body1",
1809
+ sx: {
1810
+ mx: 1,
1811
+ width: "200px",
1812
+ maxWidth: "250px",
1813
+ display: "flex",
1814
+ alignItems: "center"
1815
+ },
1816
+ children: [
1817
+ /* @__PURE__ */ jsx(Roofing, { sx: { marginRight: "4px" } }),
1818
+ /* @__PURE__ */ jsx(Tooltip, { title: `${(_a2 = service == null ? void 0 : service.description) != null ? _a2 : ""}`, children: /* @__PURE__ */ jsxs(Box, { sx: { color: "text.secondary" }, children: [
1819
+ service.name,
1820
+ /* @__PURE__ */ jsx(
1821
+ Box,
1822
+ {
1823
+ sx: {
1824
+ fontSize: "9px",
1825
+ fontWeight: "600",
1826
+ letterSpacing: "0.02em",
1827
+ textTransform: "capitalize",
1828
+ color: "gray",
1829
+ textOverflow: "ellipsis",
1830
+ whiteSpace: "nowrap",
1831
+ overflow: "hidden",
1832
+ maxWidth: "160px"
1833
+ },
1834
+ children: (_b2 = service == null ? void 0 : service.description) != null ? _b2 : ""
1835
+ }
1836
+ )
1837
+ ] }) })
1838
+ ]
1839
+ }
1840
+ ),
1841
+ /* @__PURE__ */ jsx(Tooltip, { title: state.consultInfo ? "Please complete or cancel the ongoing consult transfer before proceeding." : (_c2 = service == null ? void 0 : service.phone_number) != null ? _c2 : "", children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
1842
+ IconButton,
1843
+ {
1844
+ color: "success",
1845
+ disabled: !!state.consultInfo,
1846
+ sx: {
1847
+ bgcolor: "action.hover",
1848
+ "&:hover": { bgcolor: "action.selected" }
1849
+ },
1850
+ onClick: (e) => {
1851
+ var _a3;
1852
+ return handleTransferClick(e, { mobile_number: (_a3 = service == null ? void 0 : service.phone_number) != null ? _a3 : "" }, "OTHER");
1853
+ },
1854
+ children: /* @__PURE__ */ jsx(Call, {})
1855
+ }
1856
+ ) }) })
1857
+ ]
1858
+ },
1859
+ index
1860
+ );
1861
+ })),
1862
+ /* @__PURE__ */ jsx(
1863
+ Box,
1864
+ {
1865
+ sx: {
1866
+ p: 1,
1867
+ display: "flex",
1868
+ alignItems: "center",
1869
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1870
+ padding: "6px",
1871
+ borderRadius: "10px"
1872
+ },
1873
+ children: (() => {
1874
+ var _a2, _b2;
1875
+ const isSameAsActiveCall = !!mobileNumber && mobileNumber === ((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.phone_number) != null ? _b2 : "");
1876
+ const hasMinDigits = mobileNumber.length >= 3;
1877
+ const transferDisabled = !!state.consultInfo || !hasMinDigits || isSameAsActiveCall;
1878
+ const tooltipTitle = state.consultInfo ? "Please complete or cancel the ongoing consult transfer before proceeding." : isSameAsActiveCall ? "Cannot transfer to the same number" : !mobileNumber ? "Enter mobile number" : !hasMinDigits ? "Enter at least 3 digits" : `Call To - ${mobileNumber}`;
1879
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1880
+ /* @__PURE__ */ jsx(
1881
+ Typography,
1882
+ {
1883
+ variant: "body1",
1884
+ sx: {
1885
+ mx: 1,
1886
+ width: "200px",
1887
+ maxWidth: "250px",
1888
+ display: "flex",
1889
+ alignItems: "center"
1890
+ },
1891
+ children: /* @__PURE__ */ jsx(
1892
+ TextField,
1893
+ {
1894
+ size: "small",
1895
+ name: "others",
1896
+ label: "Mobile number",
1897
+ variant: "outlined",
1898
+ type: "tel",
1899
+ value: mobileNumber,
1900
+ error: isSameAsActiveCall,
1901
+ helperText: isSameAsActiveCall ? "Cannot transfer to the same number" : "",
1902
+ onKeyDown: (e) => {
1903
+ const allowedKeys = [
1904
+ "Backspace",
1905
+ "Delete",
1906
+ "Tab",
1907
+ "ArrowLeft",
1908
+ "ArrowRight",
1909
+ "ArrowUp",
1910
+ "ArrowDown",
1911
+ "Home",
1912
+ "End"
1913
+ ];
1914
+ if (!/^\d$/.test(e.key) && !allowedKeys.includes(e.key) && !(e.ctrlKey || e.metaKey)) {
1915
+ e.preventDefault();
1916
+ }
1917
+ },
1918
+ onPaste: (e) => {
1919
+ const pasted = e.clipboardData.getData("text");
1920
+ if (!/^\d*$/.test(pasted)) {
1921
+ e.preventDefault();
1922
+ }
1923
+ },
1924
+ onChange: (e) => {
1925
+ const v = e.target.value;
1926
+ if (/^\d*$/.test(v)) {
1927
+ setMobileNumber(v);
1928
+ }
1929
+ },
1930
+ slotProps: {
1931
+ htmlInput: {
1932
+ inputMode: "numeric",
1933
+ maxLength: 11
1934
+ },
1935
+ formHelperText: {
1936
+ sx: {
1937
+ whiteSpace: "normal",
1938
+ wordBreak: "break-word",
1939
+ lineHeight: 1.2,
1940
+ mx: 0
1941
+ }
1942
+ }
1943
+ },
1944
+ placeholder: "Enter mobile number",
1945
+ autoComplete: "off"
1946
+ }
1947
+ )
1948
+ }
1949
+ ),
1950
+ /* @__PURE__ */ jsx(Tooltip, { title: tooltipTitle, children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
1951
+ IconButton,
1952
+ {
1953
+ color: "success",
1954
+ disabled: transferDisabled,
1955
+ sx: {
1956
+ bgcolor: "action.hover",
1957
+ "&:hover": { bgcolor: "action.selected" }
1958
+ },
1959
+ onClick: (e) => handleTransferClick(e, { mobile_number: mobileNumber != null ? mobileNumber : "" }, "OTHER"),
1960
+ children: /* @__PURE__ */ jsx(Call, {})
1961
+ }
1962
+ ) }) })
1963
+ ] });
1964
+ })()
1965
+ }
1966
+ )
1967
+ ]
1968
+ }
1969
+ )
1970
+ ] })
1971
+ ] })
1972
+ }
1973
+ ),
1974
+ /* @__PURE__ */ jsxs(
1975
+ Menu,
1976
+ {
1977
+ anchorEl: transferMenuAnchor,
1978
+ open: Boolean(transferMenuAnchor),
1979
+ onClose: () => setTransferMenuAnchor(null),
1980
+ anchorOrigin: { vertical: "top", horizontal: "left" },
1981
+ transformOrigin: { vertical: "bottom", horizontal: "left" },
1982
+ children: [
1983
+ blindEnabled && /* @__PURE__ */ jsxs(
1984
+ MenuItem,
1985
+ {
1986
+ onClick: () => {
1987
+ if (pendingTransferData) handleTransferCall(pendingTransferData.data, pendingTransferData.type, "DEFAULT");
1988
+ setTransferMenuAnchor(null);
1989
+ },
1990
+ sx: { gap: 1 },
1991
+ children: [
1992
+ /* @__PURE__ */ jsx(TransferWithinAStation, { fontSize: "small", color: "primary" }),
1993
+ "Transfer"
1994
+ ]
1995
+ }
1996
+ ),
1997
+ attendedEnabled && /* @__PURE__ */ jsxs(
1998
+ MenuItem,
1999
+ {
2000
+ onClick: () => {
2001
+ if (pendingTransferData) handleTransferCall(pendingTransferData.data, pendingTransferData.type, "CONSULT");
2002
+ setTransferMenuAnchor(null);
2003
+ },
2004
+ sx: { gap: 1 },
2005
+ children: [
2006
+ /* @__PURE__ */ jsx(RecordVoiceOver, { fontSize: "small", color: "primary" }),
2007
+ "Consult then Transfer"
2008
+ ]
2009
+ }
2010
+ )
2011
+ ]
2012
+ }
2013
+ )
2014
+ ] });
2015
+ }
2016
+ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2017
+ var _a, _b, _c, _d, _e;
2018
+ const [getDispositions, data] = useGetRequest();
2019
+ const [formData, setFormData] = useState6({
2020
+ disposition: { label: "", value: "", id: 0 },
2021
+ followUp: { label: "No", value: "N" },
2022
+ callbackDate: "",
2023
+ callbackHrs: "",
2024
+ callbackMins: "",
2025
+ selected_break: false,
2026
+ notes: ""
2027
+ });
2028
+ const followUpOptions = [
2029
+ { label: "Yes", value: "Y" },
2030
+ { label: "No", value: "N" }
2031
+ ];
2032
+ const handleChange = (field, value) => {
2033
+ setFormData((prev) => __spreadProps(__spreadValues({}, prev), { [field]: value }));
2034
+ };
2035
+ const handleReset = () => {
2036
+ setFormData({
2037
+ disposition: { label: "", value: "", id: 0 },
2038
+ followUp: { label: "No", value: "N" },
2039
+ callbackDate: "",
2040
+ callbackHrs: "",
2041
+ callbackMins: "",
2042
+ selected_break: false,
2043
+ notes: ""
2044
+ });
2045
+ };
2046
+ const handleClose = () => {
2047
+ handleReset();
2048
+ setOpen(false);
2049
+ };
2050
+ useEffect3(() => {
2051
+ getDispositions(END_POINT.DISPOSITIONS);
2052
+ }, []);
2053
+ const dispositionsOptions = useMemo(() => {
2054
+ var _a2, _b2, _c2, _d2;
2055
+ return ((_d2 = (_c2 = (_b2 = (_a2 = data == null ? void 0 : data.data) == null ? void 0 : _a2.data) == null ? void 0 : _b2.filter((item) => item.name !== "Resolved")) == null ? void 0 : _c2.map((item) => ({
2056
+ label: item.name,
2057
+ value: item.code,
2058
+ id: item.disposition_id
2059
+ }))) == null ? void 0 : _d2.sort((a, b) => a.label.localeCompare(b.label))) || [];
2060
+ }, [(_a = data == null ? void 0 : data.data) == null ? void 0 : _a.data]);
2061
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
2062
+ Dialog,
2063
+ {
2064
+ open,
2065
+ "aria-labelledby": "alert-dialog-title",
2066
+ "aria-describedby": "alert-dialog-description",
2067
+ maxWidth: "sm",
2068
+ fullWidth: true,
2069
+ slotProps: { paper: { sx: { minWidth: 600 } } },
2070
+ sx: {
2071
+ minWidth: "650px"
2072
+ },
2073
+ children: /* @__PURE__ */ jsxs(Paper, { sx: { borderRadius: 2 }, children: [
2074
+ /* @__PURE__ */ jsx(
2075
+ Box,
2076
+ {
2077
+ sx: {
2078
+ display: "flex",
2079
+ justifyContent: "center",
2080
+ alignItems: "center",
2081
+ padding: "4px 16px",
2082
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2083
+ },
2084
+ children: /* @__PURE__ */ jsxs(
2085
+ Typography,
2086
+ {
2087
+ variant: "body1",
2088
+ sx: { m: 1 },
2089
+ children: [
2090
+ " ",
2091
+ "Call Disposition"
2092
+ ]
2093
+ }
2094
+ )
2095
+ }
2096
+ ),
2097
+ /* @__PURE__ */ jsxs(
2098
+ Box,
2099
+ {
2100
+ sx: {
2101
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2102
+ padding: "10px",
2103
+ margin: "10px",
2104
+ borderRadius: "10px"
2105
+ },
2106
+ children: [
2107
+ /* @__PURE__ */ jsxs(
2108
+ Box,
2109
+ {
2110
+ sx: { display: "flex", gap: 2 },
2111
+ children: [
2112
+ /* @__PURE__ */ jsx(
2113
+ Autocomplete,
2114
+ {
2115
+ value: formData.disposition,
2116
+ options: dispositionsOptions,
2117
+ getOptionLabel: (opt) => opt.label,
2118
+ onChange: (_, val) => handleChange("disposition", val),
2119
+ size: "small",
2120
+ renderInput: (params) => /* @__PURE__ */ jsx(
2121
+ TextField,
2122
+ __spreadProps(__spreadValues({}, params), {
2123
+ label: "Disposition",
2124
+ fullWidth: true
2125
+ })
2126
+ ),
2127
+ sx: { flex: 1 }
2128
+ }
2129
+ ),
2130
+ /* @__PURE__ */ jsx(
2131
+ Autocomplete,
2132
+ {
2133
+ options: followUpOptions,
2134
+ getOptionLabel: (opt) => opt.label,
2135
+ value: formData.followUp,
2136
+ onChange: (_, val) => handleChange("followUp", val),
2137
+ size: "small",
2138
+ renderInput: (params) => /* @__PURE__ */ jsx(
2139
+ TextField,
2140
+ __spreadProps(__spreadValues({}, params), {
2141
+ label: "Follow Up",
2142
+ fullWidth: true
2143
+ })
2144
+ ),
2145
+ sx: { flex: 1 }
2146
+ }
2147
+ )
2148
+ ]
2149
+ }
2150
+ ),
2151
+ /* @__PURE__ */ jsxs(
2152
+ Box,
2153
+ {
2154
+ sx: { display: "flex", gap: 2, mt: 2 },
2155
+ children: [
2156
+ /* @__PURE__ */ jsxs(
2157
+ Box,
2158
+ {
2159
+ sx: {
2160
+ flex: "1",
2161
+ border: "1px solid #bdbdbd",
2162
+ borderRadius: "5px"
2163
+ },
2164
+ children: [
2165
+ /* @__PURE__ */ jsx(
2166
+ Checkbox,
2167
+ {
2168
+ name: "selected_break",
2169
+ sx: {
2170
+ padding: "6px"
2171
+ },
2172
+ checked: formData.selected_break,
2173
+ onChange: (event) => {
2174
+ handleChange("selected_break", event.target.checked);
2175
+ },
2176
+ slotProps: {
2177
+ input: { "aria-label": "controlled" }
2178
+ }
2179
+ }
2180
+ ),
2181
+ " ",
2182
+ "Mark as break"
2183
+ ]
2184
+ }
2185
+ ),
2186
+ ((_c = (_b = formData == null ? void 0 : formData.followUp) == null ? void 0 : _b.label) == null ? void 0 : _c.toLowerCase()) === "yes" ? /* @__PURE__ */ jsx(
2187
+ TextField,
2188
+ {
2189
+ size: "small",
2190
+ label: "Callback Date",
2191
+ type: "date",
2192
+ slotProps: {
2193
+ inputLabel: { shrink: true },
2194
+ htmlInput: {
2195
+ min: (/* @__PURE__ */ new Date()).toISOString().split("T")[0]
2196
+ }
2197
+ },
2198
+ value: formData.callbackDate,
2199
+ onChange: (e) => {
2200
+ handleChange("callbackDate", e.target.value);
2201
+ const isToday = e.target.value === (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
2202
+ if (isToday) {
2203
+ const now = /* @__PURE__ */ new Date();
2204
+ const currentHr = now.getHours();
2205
+ if (formData.callbackHrs && Number(formData.callbackHrs) < currentHr) {
2206
+ handleChange("callbackHrs", "");
2207
+ handleChange("callbackMins", "");
2208
+ } else if (formData.callbackHrs && Number(formData.callbackHrs) === currentHr && formData.callbackMins && Number(formData.callbackMins) < now.getMinutes()) {
2209
+ handleChange("callbackMins", "");
2210
+ }
2211
+ }
2212
+ },
2213
+ fullWidth: true,
2214
+ sx: { flex: 1 }
2215
+ }
2216
+ ) : /* @__PURE__ */ jsx(Box, { sx: { flex: 1 } })
2217
+ ]
2218
+ }
2219
+ ),
2220
+ ((_e = (_d = formData == null ? void 0 : formData.followUp) == null ? void 0 : _d.label) == null ? void 0 : _e.toLowerCase()) === "yes" && /* @__PURE__ */ jsxs(
2221
+ Box,
2222
+ {
2223
+ sx: { display: "flex", gap: 2, mt: 2 },
2224
+ children: [
2225
+ /* @__PURE__ */ jsx(
2226
+ Autocomplete,
2227
+ {
2228
+ size: "small",
2229
+ options: Array.from({ length: 24 }, (_, i) => String(i).padStart(2, "0")),
2230
+ getOptionDisabled: (option) => {
2231
+ const isToday = formData.callbackDate === (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
2232
+ return isToday && Number(option) < (/* @__PURE__ */ new Date()).getHours();
2233
+ },
2234
+ value: formData.callbackHrs || null,
2235
+ onChange: (_, value) => handleChange("callbackHrs", value || ""),
2236
+ renderInput: (params) => /* @__PURE__ */ jsx(TextField, __spreadProps(__spreadValues({}, params), { label: "Hours (0-23)" })),
2237
+ fullWidth: true,
2238
+ sx: { flex: 1 }
2239
+ }
2240
+ ),
2241
+ /* @__PURE__ */ jsx(
2242
+ Autocomplete,
2243
+ {
2244
+ size: "small",
2245
+ options: Array.from({ length: 60 }, (_, i) => String(i).padStart(2, "0")),
2246
+ getOptionDisabled: (option) => {
2247
+ const isToday = formData.callbackDate === (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
2248
+ const now = /* @__PURE__ */ new Date();
2249
+ const isCurrentHr = isToday && formData.callbackHrs === String(now.getHours()).padStart(2, "0");
2250
+ return isCurrentHr && Number(option) < now.getMinutes();
2251
+ },
2252
+ value: formData.callbackMins || null,
2253
+ onChange: (_, value) => handleChange("callbackMins", value || ""),
2254
+ renderInput: (params) => /* @__PURE__ */ jsx(TextField, __spreadProps(__spreadValues({}, params), { label: "Minutes (0-59)" })),
2255
+ fullWidth: true,
2256
+ sx: { flex: 1 }
2257
+ }
2258
+ )
2259
+ ]
2260
+ }
2261
+ ),
2262
+ /* @__PURE__ */ jsx(Box, { sx: { mt: 2 }, children: /* @__PURE__ */ jsx(
2263
+ TextField,
2264
+ {
2265
+ size: "small",
2266
+ label: "Notes",
2267
+ multiline: true,
2268
+ minRows: 2,
2269
+ maxRows: 4,
2270
+ value: formData.notes,
2271
+ onChange: (e) => handleChange("notes", e.target.value),
2272
+ fullWidth: true
2273
+ }
2274
+ ) })
2275
+ ]
2276
+ }
2277
+ ),
2278
+ /* @__PURE__ */ jsxs(
2279
+ Box,
2280
+ {
2281
+ sx: { textAlign: "right", m: 2 },
2282
+ children: [
2283
+ /* @__PURE__ */ jsx(
2284
+ Button,
2285
+ {
2286
+ variant: "outlined",
2287
+ color: "error",
2288
+ size: "large",
2289
+ onClick: handleClose,
2290
+ sx: {
2291
+ px: 2,
2292
+ mx: 1,
2293
+ borderRadius: "10px",
2294
+ textTransform: "capitalize"
2295
+ },
2296
+ children: "cancel"
2297
+ }
2298
+ ),
2299
+ /* @__PURE__ */ jsx(
2300
+ Button,
2301
+ {
2302
+ variant: "contained",
2303
+ color: "primary",
2304
+ size: "large",
2305
+ onClick: () => onSubmitDisposition(formData),
2306
+ sx: { px: 2, borderRadius: "10px", textTransform: "capitalize" },
2307
+ children: "Submit"
2308
+ }
2309
+ )
2310
+ ]
2311
+ }
2312
+ )
2313
+ ] })
2314
+ }
2315
+ ) });
2316
+ }
2317
+ function ProcessorListDialog({
2318
+ open,
2319
+ setOpen,
2320
+ processList = null,
2321
+ handleSelectedProcessor
2322
+ }) {
2323
+ const handleClose = () => {
2324
+ setOpen(false);
2325
+ };
2326
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
2327
+ Dialog,
2328
+ {
2329
+ open,
2330
+ "aria-labelledby": "alert-dialog-title",
2331
+ "aria-describedby": "alert-dialog-description",
2332
+ maxWidth: false,
2333
+ slotProps: { paper: { sx: { minWidth: 500 } } },
2334
+ children: /* @__PURE__ */ jsxs(Paper, { sx: { borderRadius: 2 }, children: [
2335
+ /* @__PURE__ */ jsxs(
2336
+ Box,
2337
+ {
2338
+ sx: {
2339
+ display: "flex",
2340
+ justifyContent: "space-between",
2341
+ alignItems: "center",
2342
+ padding: "4px 16px",
2343
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2344
+ },
2345
+ children: [
2346
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", children: " Process List" }),
2347
+ /* @__PURE__ */ jsx(IconButton, { onClick: handleClose, children: /* @__PURE__ */ jsx(Close, {}) })
2348
+ ]
2349
+ }
2350
+ ),
2351
+ /* @__PURE__ */ jsx(
2352
+ Box,
2353
+ {
2354
+ sx: {
2355
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2356
+ padding: "6px 10px",
2357
+ margin: "10px",
2358
+ borderRadius: "10px"
2359
+ },
2360
+ children: processList.length > 0 ? processList == null ? void 0 : processList.map((process, index) => /* @__PURE__ */ jsx(
2361
+ Box,
2362
+ {
2363
+ sx: {
2364
+ p: 1,
2365
+ display: "flex",
2366
+ alignItems: "center",
2367
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2368
+ padding: "6px",
2369
+ margin: "10px 0px",
2370
+ borderRadius: "10px",
2371
+ cursor: "pointer",
2372
+ "&:hover": { bgcolor: "action.selected" }
2373
+ },
2374
+ onClick: () => {
2375
+ handleSelectedProcessor(process);
2376
+ },
2377
+ children: /* @__PURE__ */ jsxs(
2378
+ Typography,
2379
+ {
2380
+ variant: "body1",
2381
+ sx: {
2382
+ mx: 1,
2383
+ width: "200px",
2384
+ maxWidth: "250px",
2385
+ display: "flex",
2386
+ alignItems: "center"
2387
+ },
2388
+ children: [
2389
+ /* @__PURE__ */ jsx(SupportAgent, { sx: { marginRight: "4px" } }),
2390
+ process.process_name
2391
+ ]
2392
+ }
2393
+ )
2394
+ },
2395
+ index
2396
+ )) : null
2397
+ }
2398
+ )
2399
+ ] })
2400
+ }
2401
+ ) });
2402
+ }
2403
+ function CallHistoryDialog({ open, setOpen }) {
2404
+ const handleClose = () => {
2405
+ setOpen(false);
2406
+ };
2407
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
2408
+ Dialog,
2409
+ {
2410
+ open,
2411
+ "aria-labelledby": "alert-dialog-title",
2412
+ "aria-describedby": "alert-dialog-description",
2413
+ maxWidth: "md",
2414
+ slotProps: { paper: { sx: { minWidth: 500 } } },
2415
+ children: /* @__PURE__ */ jsxs(Paper, { sx: { borderRadius: 2 }, children: [
2416
+ /* @__PURE__ */ jsxs(
2417
+ Box,
2418
+ {
2419
+ sx: {
2420
+ display: "flex",
2421
+ justifyContent: "space-between",
2422
+ alignItems: "center",
2423
+ padding: "4px 16px",
2424
+ boxShadow: "0px 1px 2px #f5f5f5ff"
2425
+ },
2426
+ children: [
2427
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", children: " Call History" }),
2428
+ /* @__PURE__ */ jsx(IconButton, { onClick: handleClose, children: /* @__PURE__ */ jsx(Close, {}) })
2429
+ ]
2430
+ }
2431
+ ),
2432
+ /* @__PURE__ */ jsx(
2433
+ Box,
2434
+ {
2435
+ sx: {
2436
+ boxShadow: "1px 1px 4px #d3d3d3ff",
2437
+ margin: "10px",
2438
+ borderRadius: "10px",
2439
+ textAlign: "center",
2440
+ fontSize: "16px",
2441
+ fontWeight: "bold",
2442
+ p: 6
2443
+ },
2444
+ children: "Coming Soon..."
2445
+ }
2446
+ )
2447
+ ] })
2448
+ }
2449
+ ) });
2450
+ }
2451
+
2452
+ // call-control-sdk/lib/hooks/useDraggable.ts
2453
+ import { useCallback as useCallback5, useRef, useState as useState7 } from "react";
2454
+ function useDraggable(initialPosition, onPositionChange) {
2455
+ const [position, setPosition] = useState7(initialPosition);
2456
+ const [isDragging, setIsDragging] = useState7(false);
2457
+ const dragRef = useRef();
2458
+ const dragStart = useRef({ x: 0, y: 0 });
2459
+ const elementStart = useRef({ x: 0, y: 0 });
2460
+ const updatePosition = useCallback5(
2461
+ (newPosition) => {
2462
+ const element = dragRef.current;
2463
+ if (!element) return;
2464
+ const rect = element.getBoundingClientRect();
2465
+ const viewportWidth = window.innerWidth;
2466
+ const viewportHeight = window.innerHeight;
2467
+ const constrainedPosition = {
2468
+ x: Math.max(0, Math.min(newPosition.x, viewportWidth - rect.width)),
2469
+ y: Math.max(0, Math.min(newPosition.y, viewportHeight - rect.height))
2470
+ };
2471
+ setPosition(constrainedPosition);
2472
+ onPositionChange == null ? void 0 : onPositionChange(constrainedPosition);
2473
+ },
2474
+ [onPositionChange]
2475
+ );
2476
+ const handleStart = useCallback5(
2477
+ (clientX, clientY) => {
2478
+ setIsDragging(true);
2479
+ dragStart.current = { x: clientX, y: clientY };
2480
+ elementStart.current = position;
2481
+ const handleMove = (moveClientX, moveClientY) => {
2482
+ const deltaX = moveClientX - dragStart.current.x;
2483
+ const deltaY = moveClientY - dragStart.current.y;
2484
+ updatePosition({
2485
+ x: elementStart.current.x + deltaX,
2486
+ y: elementStart.current.y + deltaY
2487
+ });
2488
+ };
2489
+ const handleMouseMove = (e) => {
2490
+ e.preventDefault();
2491
+ handleMove(e.clientX, e.clientY);
2492
+ };
2493
+ const handleTouchMove = (e) => {
2494
+ e.preventDefault();
2495
+ const touch = e.touches[0];
2496
+ if (touch) {
2497
+ handleMove(touch.clientX, touch.clientY);
2498
+ }
2499
+ };
2500
+ const handleEnd = () => {
2501
+ setIsDragging(false);
2502
+ document.removeEventListener("mousemove", handleMouseMove);
2503
+ document.removeEventListener("mouseup", handleEnd);
2504
+ document.removeEventListener("touchmove", handleTouchMove);
2505
+ document.removeEventListener("touchend", handleEnd);
2506
+ };
2507
+ document.addEventListener("mousemove", handleMouseMove);
2508
+ document.addEventListener("mouseup", handleEnd);
2509
+ document.addEventListener("touchmove", handleTouchMove, {
2510
+ passive: false
2511
+ });
2512
+ document.addEventListener("touchend", handleEnd);
2513
+ },
2514
+ [position, updatePosition]
2515
+ );
2516
+ const handleMouseDown = useCallback5(
2517
+ (e) => {
2518
+ e.preventDefault();
2519
+ handleStart(e.clientX, e.clientY);
2520
+ },
2521
+ [handleStart]
2522
+ );
2523
+ const handleTouchStart = useCallback5(
2524
+ (e) => {
2525
+ e.preventDefault();
2526
+ const touch = e.touches[0];
2527
+ if (touch) {
2528
+ handleStart(touch.clientX, touch.clientY);
2529
+ }
2530
+ },
2531
+ [handleStart]
2532
+ );
2533
+ return {
2534
+ position,
2535
+ isDragging,
2536
+ dragRef,
2537
+ handleMouseDown,
2538
+ handleTouchStart
2539
+ };
2540
+ }
2541
+
2542
+ // call-control-sdk/lib/services/micController.ts
2543
+ function createMicController(constraints = { audio: true }) {
2544
+ let stream = null;
2545
+ let muted = false;
2546
+ async function start() {
2547
+ if (stream) return;
2548
+ stream = await navigator.mediaDevices.getUserMedia(constraints);
2549
+ stream.getAudioTracks().forEach((track) => track.enabled = true);
2550
+ muted = false;
2551
+ }
2552
+ function setEnabled(enabled) {
2553
+ if (!stream) return;
2554
+ stream.getAudioTracks().forEach((track) => track.enabled = enabled);
2555
+ muted = !enabled;
2556
+ }
2557
+ function mute() {
2558
+ setEnabled(false);
2559
+ }
2560
+ function unmute() {
2561
+ setEnabled(true);
2562
+ }
2563
+ function toggleMute() {
2564
+ if (muted) {
2565
+ unmute();
2566
+ } else {
2567
+ mute();
2568
+ }
2569
+ }
2570
+ function stop() {
2571
+ if (!stream) return;
2572
+ stream.getTracks().forEach((t) => t.stop());
2573
+ stream = null;
2574
+ muted = false;
2575
+ }
2576
+ function isMuted() {
2577
+ return muted;
2578
+ }
2579
+ function getStream() {
2580
+ return stream;
2581
+ }
2582
+ return {
2583
+ start,
2584
+ stop,
2585
+ mute,
2586
+ unmute,
2587
+ toggleMute,
2588
+ isMuted,
2589
+ getStream
2590
+ };
2591
+ }
2592
+
2593
+ // call-control-sdk/lib/utils/audioLoader.ts
2594
+ import incomingRingtoneUrl from "./incoming-4WP3FJI4.mp3";
2595
+ var audioBlobUrl = null;
2596
+ var audioBuffer = null;
2597
+ async function loadAudioAsBlob() {
2598
+ if (audioBlobUrl) {
2599
+ return audioBlobUrl;
2600
+ }
2601
+ if (incomingRingtoneUrl.startsWith("data:") || incomingRingtoneUrl.startsWith("http://") || incomingRingtoneUrl.startsWith("https://") || incomingRingtoneUrl.startsWith("blob:")) {
2602
+ return incomingRingtoneUrl;
2603
+ }
2604
+ try {
2605
+ const response = await fetch(incomingRingtoneUrl);
2606
+ if (!response.ok) {
2607
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
2608
+ }
2609
+ const blob = await response.blob();
2610
+ if (blob.size === 0) {
2611
+ throw new Error("Empty blob");
2612
+ }
2613
+ audioBlobUrl = URL.createObjectURL(blob);
2614
+ return audioBlobUrl;
2615
+ } catch (error) {
2616
+ console.error("Could not create blob URL, using direct URL:", error);
2617
+ return incomingRingtoneUrl;
2618
+ }
2619
+ }
2620
+ async function createAudioElement() {
2621
+ const audio = new Audio();
2622
+ audio.loop = true;
2623
+ audio.volume = 0.7;
2624
+ audio.preload = "auto";
2625
+ let audioUrl = "";
2626
+ try {
2627
+ audioUrl = await loadAudioAsBlob();
2628
+ } catch (error) {
2629
+ console.warn("Failed to load audio as blob, trying direct URL:", error);
2630
+ audioUrl = incomingRingtoneUrl;
2631
+ }
2632
+ const tryLoadAudio = async (url) => {
2633
+ return new Promise((resolve) => {
2634
+ const checkCanPlay = () => {
2635
+ const canPlay = audio.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA;
2636
+ if (canPlay) {
2637
+ resolve(true);
2638
+ return;
2639
+ }
2640
+ if (audio.error) {
2641
+ resolve(false);
2642
+ return;
2643
+ }
2644
+ setTimeout(checkCanPlay, 100);
2645
+ };
2646
+ audio.addEventListener("canplay", () => resolve(true), { once: true });
2647
+ audio.addEventListener("error", () => resolve(false), { once: true });
2648
+ audio.src = url;
2649
+ audio.load();
2650
+ setTimeout(() => resolve(false), 2e3);
2651
+ });
2652
+ };
2653
+ let loaded = await tryLoadAudio(audioUrl);
2654
+ if (!loaded && audioUrl !== incomingRingtoneUrl) {
2655
+ loaded = await tryLoadAudio(incomingRingtoneUrl);
2656
+ if (loaded) {
2657
+ audioUrl = incomingRingtoneUrl;
2658
+ }
2659
+ }
2660
+ return audio;
2661
+ }
2662
+ function cleanupAudioResources() {
2663
+ if (audioBlobUrl) {
2664
+ URL.revokeObjectURL(audioBlobUrl);
2665
+ audioBlobUrl = null;
2666
+ }
2667
+ audioBuffer = null;
2668
+ }
2669
+
2670
+ // call-control-sdk/lib/components/callControls.tsx
2671
+ import { getSession as getSession3 } from "@react-solutions/vault";
2672
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
2673
+ var getCombineConfrenceData = (localState, apiData) => {
2674
+ const localConfrenceData = localState == null ? void 0 : localState.conferenceLine;
2675
+ const apiConferenceData = apiData == null ? void 0 : apiData.conferencestatus;
2676
+ const updatedConferenceData = localConfrenceData.map((item) => {
2677
+ var _a, _b, _c, _d, _e;
2678
+ if ((item == null ? void 0 : item.line) === 1) {
2679
+ const statusKey = `line_${item.line}_status`;
2680
+ return __spreadProps(__spreadValues({}, item), {
2681
+ line: 1,
2682
+ status: (_b = apiConferenceData == null ? void 0 : apiConferenceData[statusKey]) != null ? _b : (_a = localState == null ? void 0 : localState.callData) == null ? void 0 : _a.status,
2683
+ phone: (_d = (_c = localState == null ? void 0 : localState.callData) == null ? void 0 : _c.phone_number) != null ? _d : ""
2684
+ });
2685
+ } else {
2686
+ const statusKey = `line_${item.line}_status`;
2687
+ const phoneKey = `line_${item.line}_phonenumber`;
2688
+ const newStatus = apiConferenceData ? (_e = apiConferenceData[statusKey]) != null ? _e : "IDLE" : item.status;
2689
+ let newPhone = apiConferenceData == null ? void 0 : apiConferenceData[phoneKey];
2690
+ if (newPhone === null || newPhone === "0" || newPhone === void 0) {
2691
+ newPhone = newStatus === "IDLE" ? "" : item.phone;
2692
+ }
2693
+ return __spreadProps(__spreadValues({}, item), {
2694
+ status: newStatus,
2695
+ phone: newPhone
2696
+ });
2697
+ }
2698
+ });
2699
+ return updatedConferenceData;
2700
+ };
2701
+ var formatDuration = (seconds) => {
2702
+ const mins = Math.floor(seconds / 60);
2703
+ const secs = seconds % 60;
2704
+ return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
2705
+ };
2706
+ function CallControls({ onDataChange }) {
2707
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub, _vb, _wb, _xb, _yb, _zb;
2708
+ const theme = useTheme3();
2709
+ const state = useSDKState();
2710
+ const { showToast } = useToast();
2711
+ const { disabled, enabled, outlined } = styles_default({
2712
+ disabled: ((_a = state.sdkConfig) == null ? void 0 : _a.disabled) || {},
2713
+ enabled: ((_b = state.sdkConfig) == null ? void 0 : _b.enabled) || {},
2714
+ outlined: ((_c = state.sdkConfig) == null ? void 0 : _c.outlined) || {}
2715
+ });
2716
+ const micRef = useRef2(null);
2717
+ const webSocketRef = useRef2(null);
2718
+ const audioRef = useRef2(null);
2719
+ const reconnectTimeoutRef = useRef2(null);
2720
+ const pingIntervalRef = useRef2(null);
2721
+ const reconnectAttemptsRef = useRef2(0);
2722
+ const hasFlashedRef = useRef2(false);
2723
+ const lastEventTimeRef = useRef2(null);
2724
+ const conferenceAutoOpenedRef = useRef2(false);
2725
+ const holdStartTimeRef = useRef2(null);
2726
+ const muteStartTimeRef = useRef2(null);
2727
+ const maxReconnectAttempts = 60;
2728
+ const baseReconnectDelay = 2e3;
2729
+ const maxReconnectDelay = 3e4;
2730
+ const [anchorEl, setAnchorEl] = useState8(null);
2731
+ const [statusAnchorEl, setStatusAnchorEl] = useState8(null);
2732
+ const [dialerAnchorEl, setDialerAnchorEl] = useState8(null);
2733
+ const [ambulanceAnchorEl, setAmbulanceAnchorEl] = useState8(null);
2734
+ const [moreOptionsAnchorEl, setMoreOptionsAnchorEl] = useState8(null);
2735
+ const [showIframe, setShowIframe] = useState8(true);
2736
+ const [openCallDisposition, setOpenCallDisposition] = useState8(false);
2737
+ const [openProcessorDialog, setOpenProcessorDialog] = useState8(false);
2738
+ const [openCallHistoryDialog, setOpenCallHistoryDialog] = useState8(false);
2739
+ const [processList, setProcessList] = useState8(null);
2740
+ const [breaksList, setBreaksList] = useState8(null);
2741
+ const [phoneNumber, setPhoneNumber] = useState8("");
2742
+ const [callDuration, setCallDuration] = useState8(0);
2743
+ const [callWrapuptime, setCallWrapuptime] = useState8(null);
2744
+ const [holdDuration, setHoldDuration] = useState8(0);
2745
+ const [muteDuration, setMuteDuration] = useState8(0);
2746
+ const { position, isDragging, dragRef, handleMouseDown, handleTouchStart } = useDraggable(
2747
+ state.controlPanelPosition,
2748
+ (newPosition) => sdkStateManager.setControlPanelPosition(newPosition)
2749
+ );
2750
+ const {
2751
+ position: iframePosition,
2752
+ isDragging: iframeIsDragging,
2753
+ dragRef: iframeDragRef,
2754
+ handleMouseDown: iframeHandleMouseDown,
2755
+ handleTouchStart: iframeHandleTouchStart
2756
+ } = useDraggable(
2757
+ state.iframePosition,
2758
+ (newPosition) => sdkStateManager.setIframePosition(newPosition)
2759
+ );
2760
+ const [clickToCall2, { isLoading: clickToCallLoading }] = usePostRequest({
2761
+ onSuccess: () => {
2762
+ setPhoneNumber("");
2763
+ setDialerAnchorEl(null);
2764
+ }
2765
+ });
2766
+ const [holdOrUnHold, { isLoading: holdOrUnHoldLoading }] = usePostRequest();
2767
+ const [muteOrUnMute, { isLoading: muteOrUnMuteLoading }] = usePostRequest();
2768
+ const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest({
2769
+ onSuccess: () => {
2770
+ sdkStateManager.setAgentStatus("");
2771
+ }
2772
+ });
2773
+ const [updateAgentStatus, { isLoading }] = usePostRequest();
2774
+ const [sendNotification] = usePostRequest();
2775
+ const [endCall2, { isLoading: endCallLoading }] = usePostRequest({
2776
+ disabledSuccessToast: true,
2777
+ onSuccess: (res) => {
2778
+ sdkStateManager.endCall();
2779
+ setOpenCallDisposition(false);
2780
+ sdkStateManager.resetConferenceLines();
2781
+ showToast((res == null ? void 0 : res.message) || "Call ended successfully", "success");
2782
+ }
2783
+ });
2784
+ const handleCloseQueueCounts = () => {
2785
+ setAnchorEl(null);
2786
+ };
2787
+ const handleOpenDialer = (event) => {
2788
+ setShowIframe(true);
2789
+ setDialerAnchorEl(event.currentTarget);
2790
+ };
2791
+ const handleOpenAbulanceServices = (event) => {
2792
+ setAmbulanceAnchorEl(event.currentTarget);
2793
+ };
2794
+ const handleOpenMoreOptions = (event) => {
2795
+ setMoreOptionsAnchorEl(event.currentTarget);
2796
+ };
2797
+ const handleCloseDialer = () => {
2798
+ setDialerAnchorEl(null);
2799
+ };
2800
+ const handleCloseAmbulance = () => {
2801
+ setAmbulanceAnchorEl(null);
2802
+ };
2803
+ const handleCloseMoreOptions = () => {
2804
+ setMoreOptionsAnchorEl(null);
2805
+ };
2806
+ const handleOpenAgentStatus = (event) => {
2807
+ setStatusAnchorEl(event.currentTarget);
2808
+ };
2809
+ const handleCloseAgentStatus = () => {
2810
+ setStatusAnchorEl(null);
2811
+ };
2812
+ const handleAgentReady = () => {
2813
+ var _a2;
2814
+ const payload = {
2815
+ action: "READYAGENT",
2816
+ userId: String((_a2 = state.agentId) != null ? _a2 : "")
2817
+ };
2818
+ readyAgentStatus(END_POINT.READY_AGENT, payload);
2819
+ };
2820
+ const handleUpdateAgentStatus = (status) => {
2821
+ var _a2, _b2, _c2;
2822
+ setStatusAnchorEl(null);
2823
+ const currentStatus = (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase();
2824
+ if (["ONCALL" /* ONCALL */, "RINGING" /* RINGING */, "DIALING" /* DIALING */, "WRAPUP" /* WRAPUP */].includes(currentStatus)) {
2825
+ showToast("Cannot put agent on break while on a call", "error");
2826
+ return;
2827
+ }
2828
+ const payload = {
2829
+ action: "AGENTBREAK",
2830
+ break_type: status,
2831
+ userId: String((_c2 = state.agentId) != null ? _c2 : "")
2832
+ };
2833
+ updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload).then(() => {
2834
+ sdkStateManager.setAgentStatus(status);
2835
+ });
2836
+ };
2837
+ const handleStartCall = (number) => {
2838
+ var _a2, _b2, _c2, _d2;
2839
+ if (number.length !== 10) {
2840
+ showToast("Invalid phone number", "error");
2841
+ } else if (!/^\d+$/.test(number)) {
2842
+ showToast("Invalid phone number", "error");
2843
+ } else {
2844
+ const currentStatus = ((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) != null ? _b2 : "").toUpperCase();
2845
+ const isWrapupCall = currentStatus === "WRAPUP" /* WRAPUP */;
2846
+ let parentCallUuid = "";
2847
+ if (!((_c2 = state.sdkConfig) == null ? void 0 : _c2.disableAlternateDialing)) {
2848
+ if (isWrapupCall) {
2849
+ if (state.rootCallUuid) {
2850
+ parentCallUuid = state.rootCallUuid;
2851
+ } else if ((_d2 = state.callData) == null ? void 0 : _d2.call_id) {
2852
+ parentCallUuid = state.callData.call_id;
2853
+ sdkStateManager.setRootCallUuid(parentCallUuid);
2854
+ }
2855
+ } else if (state.rootCallUuid) {
2856
+ sdkStateManager.setRootCallUuid(null);
2857
+ }
2858
+ } else if (state.rootCallUuid) {
2859
+ sdkStateManager.setRootCallUuid(null);
2860
+ }
2861
+ const payload = {
2862
+ phone_number: number,
2863
+ user: state.agentId,
2864
+ auto_answer: false,
2865
+ call_id: "",
2866
+ reference_id: "",
2867
+ call_source: "",
2868
+ caseId: "",
2869
+ isWrapup: isWrapupCall,
2870
+ parentCallUuid
2871
+ };
2872
+ clickToCall2(END_POINT.CLICK_TO_CALL, payload);
2873
+ }
2874
+ };
2875
+ const handleHoldToggle = () => {
2876
+ var _a2, _b2, _c2, _d2;
2877
+ const payload = {
2878
+ action: ((_a2 = state.callData) == null ? void 0 : _a2.hold) === 1 ? "UNHOLD" /* UNHOLD */ : "HOLD" /* HOLD */,
2879
+ user_id: String((_b2 = state.agentId) != null ? _b2 : ""),
2880
+ call_uuid: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.call_id) != null ? _d2 : "",
2881
+ line_number: 0
2882
+ };
2883
+ holdOrUnHold(END_POINT.HOLD_CALL, payload);
2884
+ };
2885
+ const handleMuteToggle = () => {
2886
+ var _a2, _b2, _c2, _d2;
2887
+ const payload = {
2888
+ action: ((_a2 = state.callData) == null ? void 0 : _a2.mute) === 1 ? "UNMUTE" /* UNMUTE */ : "MUTE" /* MUTE */,
2889
+ direction: "both",
2890
+ user_id: String((_b2 = state.agentId) != null ? _b2 : ""),
2891
+ call_uuid: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.call_id) != null ? _d2 : "",
2892
+ line_number: 0
2893
+ };
2894
+ muteOrUnMute(END_POINT.MUTE_CALL, payload);
2895
+ };
2896
+ const handleEndCall = (data) => {
2897
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
2898
+ const payload = {
2899
+ call_id: (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.call_id) != null ? _b2 : "",
2900
+ agent_id: (_c2 = state.agentId) != null ? _c2 : "",
2901
+ set_followUp: (_e2 = (_d2 = data == null ? void 0 : data.followUp) == null ? void 0 : _d2.value) != null ? _e2 : "",
2902
+ callback_date: (_f2 = data == null ? void 0 : data.callbackDate) != null ? _f2 : "",
2903
+ callback_hrs: Number(data == null ? void 0 : data.callbackHrs) || 0,
2904
+ callback_mins: Number(data == null ? void 0 : data.callbackMins) || 0,
2905
+ mobile_number: (_h2 = (_g2 = state.callData) == null ? void 0 : _g2.phone_number) != null ? _h2 : "",
2906
+ list_comments: (_i2 = data == null ? void 0 : data.notes) != null ? _i2 : "",
2907
+ call_reference_id: (_k2 = (_j2 = state.callData) == null ? void 0 : _j2.call_id) != null ? _k2 : "",
2908
+ is_mark_as_break: (_l2 = data == null ? void 0 : data.selected_break) != null ? _l2 : false,
2909
+ disposition: (_n2 = (_m2 = data == null ? void 0 : data.disposition) == null ? void 0 : _m2.value) != null ? _n2 : "",
2910
+ line_number: 0,
2911
+ reason: "normal"
2912
+ };
2913
+ setPhoneNumber("");
2914
+ endCall2(END_POINT.END_CALL, payload);
2915
+ };
2916
+ useEffect4(() => {
2917
+ const handleBeforeUnload = (e) => {
2918
+ e.preventDefault();
2919
+ };
2920
+ window.addEventListener("beforeunload", handleBeforeUnload);
2921
+ return () => {
2922
+ window.removeEventListener("beforeunload", handleBeforeUnload);
2923
+ };
2924
+ }, []);
2925
+ useEffect4(() => {
2926
+ const mic = createMicController();
2927
+ micRef.current = mic;
2928
+ mic.start().catch((err) => {
2929
+ console.error("Failed to start mic:", err);
2930
+ });
2931
+ const handleKeyDown = (event) => {
2932
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2;
2933
+ const fullState = getSession3(STORAGE_KEY);
2934
+ const key = (_a2 = event.key) == null ? void 0 : _a2.toLowerCase();
2935
+ if (!event.altKey || ((_b2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _b2.status) !== "ONCALL" /* ONCALL */) {
2936
+ return;
2937
+ }
2938
+ if (key === "m" && String((_c2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _c2.mute) === "0") {
2939
+ event.preventDefault();
2940
+ (_d2 = micRef.current) == null ? void 0 : _d2.mute();
2941
+ const payload = {
2942
+ action: "MUTE" /* MUTE */,
2943
+ direction: "both",
2944
+ user_id: String((_e2 = fullState.agentId) != null ? _e2 : ""),
2945
+ call_uuid: (_g2 = (_f2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _f2.call_id) != null ? _g2 : "",
2946
+ line_number: 0
2947
+ };
2948
+ muteOrUnMute(END_POINT.MUTE_CALL, payload);
2949
+ }
2950
+ if (key === "u" && String((_h2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _h2.mute) === "1") {
2951
+ event.preventDefault();
2952
+ const payload = {
2953
+ action: "UNMUTE" /* UNMUTE */,
2954
+ direction: "both",
2955
+ user_id: String((_i2 = fullState.agentId) != null ? _i2 : ""),
2956
+ call_uuid: (_k2 = (_j2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _j2.call_id) != null ? _k2 : "",
2957
+ line_number: 0
2958
+ };
2959
+ muteOrUnMute(END_POINT.MUTE_CALL, payload);
2960
+ (_l2 = micRef.current) == null ? void 0 : _l2.unmute();
2961
+ }
2962
+ if (key === "h" && String((_m2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _m2.hold) === "0") {
2963
+ event.preventDefault();
2964
+ const payload = {
2965
+ action: "HOLD" /* HOLD */,
2966
+ user_id: String((_n2 = fullState.agentId) != null ? _n2 : ""),
2967
+ call_uuid: (_p2 = (_o2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _o2.call_id) != null ? _p2 : "",
2968
+ line_number: 0
2969
+ };
2970
+ holdOrUnHold(END_POINT.HOLD_CALL, payload);
2971
+ }
2972
+ if (key === "r" && String((_q2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _q2.hold) === "1") {
2973
+ event.preventDefault();
2974
+ const payload = {
2975
+ action: "UNHOLD" /* UNHOLD */,
2976
+ user_id: String((_r2 = fullState.agentId) != null ? _r2 : ""),
2977
+ call_uuid: (_t2 = (_s2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _s2.call_id) != null ? _t2 : "",
2978
+ line_number: 0
2979
+ };
2980
+ holdOrUnHold(END_POINT.HOLD_CALL, payload);
2981
+ }
2982
+ };
2983
+ window.addEventListener("keydown", handleKeyDown);
2984
+ return () => {
2985
+ window.removeEventListener("keydown", handleKeyDown);
2986
+ };
2987
+ }, []);
2988
+ useEffect4(() => {
2989
+ let interval;
2990
+ let wrapUpinterval;
2991
+ if (state.callData.status && state.callData.status === "ONCALL" /* ONCALL */) {
2992
+ interval = setInterval(() => {
2993
+ const elapsed = state.callStartTime ? Math.floor((Date.now() - Number(state.callStartTime)) / 1e3) : 0;
2994
+ setCallDuration(elapsed);
2995
+ }, 1e3);
2996
+ } else {
2997
+ setCallDuration(0);
2998
+ }
2999
+ if (state.callData.status && state.callData.status === "WRAPUP" /* WRAPUP */ && callWrapuptime !== null) {
3000
+ wrapUpinterval = setInterval(() => {
3001
+ setCallWrapuptime((prevTime) => {
3002
+ if (prevTime === null || prevTime <= 1) {
3003
+ clearInterval(wrapUpinterval);
3004
+ handleEndCall({
3005
+ disposition: { label: "Auto Wrapup", value: "AUTO_WRAPUP" },
3006
+ followUp: { label: "No", value: "N" },
3007
+ callbackDate: "",
3008
+ callbackHrs: "",
3009
+ callbackMins: "",
3010
+ selected_break: false
3011
+ });
3012
+ return null;
3013
+ }
3014
+ return prevTime - 1;
3015
+ });
3016
+ }, 1e3);
3017
+ }
3018
+ return () => {
3019
+ if (interval) clearInterval(interval);
3020
+ if (wrapUpinterval) clearInterval(wrapUpinterval);
3021
+ };
3022
+ }, [state.callData.status]);
3023
+ useEffect4(() => {
3024
+ var _a2, _b2, _c2;
3025
+ let holdInterval;
3026
+ const isOnCall = ((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL" /* ONCALL */;
3027
+ const isOnHold2 = ((_c2 = state.callData) == null ? void 0 : _c2.hold) === 1;
3028
+ if (isOnHold2 && isOnCall) {
3029
+ if (!holdStartTimeRef.current) {
3030
+ holdStartTimeRef.current = Date.now();
3031
+ }
3032
+ holdInterval = setInterval(() => {
3033
+ setHoldDuration(
3034
+ Math.floor((Date.now() - holdStartTimeRef.current) / 1e3)
3035
+ );
3036
+ }, 1e3);
3037
+ } else {
3038
+ holdStartTimeRef.current = null;
3039
+ setHoldDuration(0);
3040
+ }
3041
+ return () => {
3042
+ if (holdInterval) clearInterval(holdInterval);
3043
+ };
3044
+ }, [(_d = state.callData) == null ? void 0 : _d.hold, (_e = state.callData) == null ? void 0 : _e.status]);
3045
+ useEffect4(() => {
3046
+ var _a2, _b2, _c2, _d2;
3047
+ let muteInterval;
3048
+ const isOnCall = ((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL" /* ONCALL */;
3049
+ const isMuted2 = ((_c2 = state.callData) == null ? void 0 : _c2.mute) === 1;
3050
+ const isHeld = ((_d2 = state.callData) == null ? void 0 : _d2.hold) === 1;
3051
+ if (isMuted2 && isOnCall && !isHeld) {
3052
+ if (!muteStartTimeRef.current) {
3053
+ muteStartTimeRef.current = Date.now();
3054
+ }
3055
+ muteInterval = setInterval(() => {
3056
+ setMuteDuration(
3057
+ Math.floor((Date.now() - muteStartTimeRef.current) / 1e3)
3058
+ );
3059
+ }, 1e3);
3060
+ } else {
3061
+ muteStartTimeRef.current = null;
3062
+ setMuteDuration(0);
3063
+ }
3064
+ return () => {
3065
+ if (muteInterval) clearInterval(muteInterval);
3066
+ };
3067
+ }, [(_f = state.callData) == null ? void 0 : _f.mute, (_g = state.callData) == null ? void 0 : _g.status]);
3068
+ useEffect4(() => {
3069
+ createAudioElement().then((audio) => {
3070
+ audioRef.current = audio;
3071
+ }).catch((error) => {
3072
+ console.error("Failed to load audio element:", error);
3073
+ });
3074
+ return () => {
3075
+ if (audioRef.current) {
3076
+ audioRef.current.pause();
3077
+ audioRef.current.currentTime = 0;
3078
+ audioRef.current.src = "";
3079
+ audioRef.current = null;
3080
+ }
3081
+ cleanupAudioResources();
3082
+ };
3083
+ }, []);
3084
+ useEffect4(() => {
3085
+ var _a2, _b2;
3086
+ if (onDataChange && state.callData) {
3087
+ const { process_id, process_name, status, phone_number, agent_id, call_id, call_details } = state.callData;
3088
+ const lead_data = sdkStateManager.getTransferLeadData();
3089
+ const callData = __spreadProps(__spreadValues({
3090
+ phone_number,
3091
+ status,
3092
+ callReferenceId: call_id,
3093
+ agent_id,
3094
+ process_id,
3095
+ process_name,
3096
+ call_details,
3097
+ auto_wrapup_time: (_b2 = (_a2 = state.backendCallControls) == null ? void 0 : _a2.auto_wrapup_time) != null ? _b2 : null
3098
+ }, lead_data !== void 0 && { lead_data }), {
3099
+ socket_info: state.callData
3100
+ });
3101
+ onDataChange(callData);
3102
+ }
3103
+ }, [state.callData, onDataChange]);
3104
+ useEffect4(() => {
3105
+ if (state.agentId) {
3106
+ axios_default.get(END_POINT.BREAKS_LIST).then((res) => {
3107
+ var _a2, _b2, _c2, _d2;
3108
+ if (res && ((_a2 = res.data) == null ? void 0 : _a2.data) && ((_c2 = (_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.data) == null ? void 0 : _c2.length)) {
3109
+ setBreaksList(res.data.data);
3110
+ const liveStatus = (_d2 = sdkStateManager.getState().callData) == null ? void 0 : _d2.status;
3111
+ if (!liveStatus) {
3112
+ handleUpdateAgentStatus(res.data.data[0].type);
3113
+ }
3114
+ }
3115
+ }).catch((err) => {
3116
+ showToast(err.response.data.message, "error");
3117
+ });
3118
+ }
3119
+ }, [state.agentId]);
3120
+ const connectWebSocket = () => {
3121
+ var _a2, _b2;
3122
+ if (!state.agentId) {
3123
+ return;
3124
+ }
3125
+ if (reconnectTimeoutRef.current) {
3126
+ clearTimeout(reconnectTimeoutRef.current);
3127
+ reconnectTimeoutRef.current = null;
3128
+ }
3129
+ try {
3130
+ webSocketRef.current = new WebSocket(`${(_a2 = state.urlConfig) == null ? void 0 : _a2.webSocketURL}/api/v1/ws/agent/events?token=${(_b2 = state.authorization) == null ? void 0 : _b2.accessToken}`);
3131
+ webSocketRef.current.onopen = () => {
3132
+ console.log("\u{1F310} WebSocket connection established");
3133
+ reconnectAttemptsRef.current = 0;
3134
+ if (pingIntervalRef.current) {
3135
+ clearInterval(pingIntervalRef.current);
3136
+ }
3137
+ pingIntervalRef.current = setInterval(() => {
3138
+ if (webSocketRef.current && webSocketRef.current.readyState === WebSocket.OPEN) {
3139
+ try {
3140
+ webSocketRef.current.send(JSON.stringify({ type: "ping" }));
3141
+ } catch (error) {
3142
+ console.error("Failed to send ping:", error);
3143
+ }
3144
+ }
3145
+ }, 3e4);
3146
+ };
3147
+ webSocketRef.current.onmessage = (event) => {
3148
+ var _a3, _b3, _c2, _d2, _e2, _f2, _g2;
3149
+ try {
3150
+ const data = JSON.parse(event.data);
3151
+ if (data.type === "pong") {
3152
+ return;
3153
+ }
3154
+ const sdkState = getSession3(STORAGE_KEY);
3155
+ const confrence = getCombineConfrenceData(sdkState, data);
3156
+ const callData = __spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, data), {
3157
+ agent_id: data == null ? void 0 : data.agent_id,
3158
+ status: data == null ? void 0 : data.status,
3159
+ type: data == null ? void 0 : data.type,
3160
+ event_time: data == null ? void 0 : data.event_time,
3161
+ phone_number: data == null ? void 0 : data.phone_number,
3162
+ call_id: data == null ? void 0 : data.call_id,
3163
+ process_id: data == null ? void 0 : data.process_id,
3164
+ process_name: data == null ? void 0 : data.process_name,
3165
+ hold: data == null ? void 0 : data.hold,
3166
+ mute: data == null ? void 0 : data.mute,
3167
+ mode: data == null ? void 0 : data.mode,
3168
+ queue_name: data == null ? void 0 : data.queue_name,
3169
+ auto_wrapup_time: (_a3 = data == null ? void 0 : data.auto_wrapup_time) != null ? _a3 : null
3170
+ }), (data == null ? void 0 : data.call_details) !== void 0 && { call_details: data.call_details }), (data == null ? void 0 : data.break_details) !== void 0 && { break_details: data.break_details }), (data == null ? void 0 : data.call_sage) !== void 0 && { call_sage: data.call_sage });
3171
+ sdkStateManager.updateCallData(callData);
3172
+ sdkStateManager.updateConferenceData([...confrence]);
3173
+ sdkStateManager.setConsultInfo((_b3 = data.consult_info) != null ? _b3 : null);
3174
+ const conferenceStatus = data == null ? void 0 : data.conferencestatus;
3175
+ if (conferenceStatus) {
3176
+ const hasAnsweredSecondaryLine = Object.keys(conferenceStatus).some((key) => {
3177
+ var _a4;
3178
+ const match = key.match(/^line_(\d+)_status$/);
3179
+ if (!match) return false;
3180
+ const lineNum = Number(match[1]);
3181
+ if (lineNum <= 1) return false;
3182
+ const status = String((_a4 = conferenceStatus[key]) != null ? _a4 : "").toUpperCase();
3183
+ return status === "ONCALL" /* ONCALL */;
3184
+ });
3185
+ if (hasAnsweredSecondaryLine) {
3186
+ if (!conferenceAutoOpenedRef.current) {
3187
+ sdkStateManager.setOpenConferenceDialog(true);
3188
+ conferenceAutoOpenedRef.current = true;
3189
+ }
3190
+ } else {
3191
+ conferenceAutoOpenedRef.current = false;
3192
+ }
3193
+ } else {
3194
+ conferenceAutoOpenedRef.current = false;
3195
+ }
3196
+ if (data == null ? void 0 : data.call_consult_controls) {
3197
+ sdkStateManager.updateSDKConfigFromPermissions(data.call_consult_controls);
3198
+ } else {
3199
+ sdkStateManager.resetConsultControls();
3200
+ }
3201
+ if (["RINGING" /* RINGING */, "DIALING" /* DIALING */].includes(data.status)) {
3202
+ setShowIframe(true);
3203
+ setCallWrapuptime((_d2 = (_c2 = sdkState == null ? void 0 : sdkState.sdkConfig) == null ? void 0 : _c2.auto_wrapup_time) != null ? _d2 : null);
3204
+ sdkStateManager.updateConferenceData([
3205
+ {
3206
+ line: 1,
3207
+ status: "IDLE",
3208
+ type: "",
3209
+ phone: "",
3210
+ isMute: false,
3211
+ isHold: false,
3212
+ isCallStart: false,
3213
+ isMergeCall: false
3214
+ },
3215
+ {
3216
+ line: 2,
3217
+ status: "IDLE",
3218
+ type: "",
3219
+ phone: "",
3220
+ isMute: false,
3221
+ isHold: false,
3222
+ isCallStart: false,
3223
+ isMergeCall: false
3224
+ },
3225
+ {
3226
+ line: 3,
3227
+ status: "IDLE",
3228
+ type: "",
3229
+ phone: "",
3230
+ isMute: false,
3231
+ isHold: false,
3232
+ isCallStart: false,
3233
+ isMergeCall: false
3234
+ },
3235
+ {
3236
+ line: 4,
3237
+ status: "IDLE",
3238
+ type: "",
3239
+ phone: "",
3240
+ isMute: false,
3241
+ isHold: false,
3242
+ isCallStart: false,
3243
+ isMergeCall: false
3244
+ },
3245
+ {
3246
+ line: 5,
3247
+ status: "IDLE",
3248
+ type: "",
3249
+ phone: "",
3250
+ isMute: false,
3251
+ isHold: false,
3252
+ isCallStart: false,
3253
+ isMergeCall: false
3254
+ }
3255
+ ]);
3256
+ if ((data == null ? void 0 : data.mode) !== "manual" && audioRef.current && ((_e2 = state == null ? void 0 : state.sdkConfig) == null ? void 0 : _e2.enableRingtone)) {
3257
+ audioRef.current.play().catch((error) => {
3258
+ console.error("Failed to play ringtone:", error);
3259
+ });
3260
+ }
3261
+ } else {
3262
+ if (audioRef.current) {
3263
+ audioRef.current.pause();
3264
+ audioRef.current.currentTime = 0;
3265
+ }
3266
+ }
3267
+ if (data.status === "IDLE" /* IDLE */) {
3268
+ sdkStateManager.setOpenCallTransferDialog(false);
3269
+ sdkStateManager.setOpenConferenceDialog(false);
3270
+ sdkStateManager.clearTransferLeadData();
3271
+ } else if (data.status === "ONCALL" /* ONCALL */) {
3272
+ if (data.status === "ONCALL" /* ONCALL */) {
3273
+ sdkStateManager.startCall();
3274
+ }
3275
+ if (!showIframe) {
3276
+ setShowIframe(true);
3277
+ }
3278
+ if ((data == null ? void 0 : data.mute) !== 1 && (data == null ? void 0 : data.hold) !== 1) {
3279
+ } else {
3280
+ }
3281
+ } else if (((data == null ? void 0 : data.mute) === 1 || (data == null ? void 0 : data.hold) === 1) && data.status === "ONCALL" /* ONCALL */) {
3282
+ } else if (data.status === "BREAK" /* BREAK */) {
3283
+ const breakTime = (_f2 = sdkState == null ? void 0 : sdkState.sdkConfig) == null ? void 0 : _f2.break_time;
3284
+ const eventTime = (_g2 = data == null ? void 0 : data.event_time) != null ? _g2 : null;
3285
+ if (eventTime !== lastEventTimeRef.current) {
3286
+ hasFlashedRef.current = false;
3287
+ lastEventTimeRef.current = eventTime;
3288
+ }
3289
+ let isOverLimit = false;
3290
+ if (breakTime && eventTime) {
3291
+ const differenceInMinutes = ((/* @__PURE__ */ new Date()).getTime() - new Date(eventTime).getTime()) / 6e4;
3292
+ if (Number(differenceInMinutes.toFixed(0)) >= Number(breakTime)) {
3293
+ isOverLimit = true;
3294
+ }
3295
+ }
3296
+ if (isOverLimit) {
3297
+ if (!hasFlashedRef.current) {
3298
+ hasFlashedRef.current = true;
3299
+ }
3300
+ } else {
3301
+ }
3302
+ } else if (data.status === "WRAPUP" /* WRAPUP */) {
3303
+ sdkStateManager.endCall();
3304
+ sdkStateManager.setOpenCallTransferDialog(false);
3305
+ sdkStateManager.setOpenConferenceDialog(false);
3306
+ }
3307
+ } catch (e) {
3308
+ console.error("\u{1F4E8} Raw message:", event.data);
3309
+ }
3310
+ };
3311
+ webSocketRef.current.onclose = (event) => {
3312
+ if (pingIntervalRef.current) {
3313
+ clearInterval(pingIntervalRef.current);
3314
+ pingIntervalRef.current = null;
3315
+ }
3316
+ if (event.code !== 1e3 && reconnectAttemptsRef.current < maxReconnectAttempts) {
3317
+ reconnectAttemptsRef.current += 1;
3318
+ const delay = Math.min(
3319
+ baseReconnectDelay * Math.pow(2, reconnectAttemptsRef.current - 1),
3320
+ maxReconnectDelay
3321
+ );
3322
+ console.warn(
3323
+ `\u{1F504} Attempting to reconnect WebSocket (attempt ${reconnectAttemptsRef.current}/${maxReconnectAttempts}) in ${delay}ms`
3324
+ );
3325
+ reconnectTimeoutRef.current = setTimeout(() => {
3326
+ connectWebSocket();
3327
+ }, delay);
3328
+ } else if (reconnectAttemptsRef.current >= maxReconnectAttempts) {
3329
+ showToast("WebSocket connection failed. Please refresh the page.", "error");
3330
+ }
3331
+ };
3332
+ webSocketRef.current.onerror = (error) => {
3333
+ console.error("\u274C WebSocket error:", error);
3334
+ };
3335
+ } catch (error) {
3336
+ if (reconnectAttemptsRef.current < maxReconnectAttempts) {
3337
+ reconnectAttemptsRef.current += 1;
3338
+ const delay = Math.min(
3339
+ baseReconnectDelay * Math.pow(2, reconnectAttemptsRef.current - 1),
3340
+ maxReconnectDelay
3341
+ );
3342
+ reconnectTimeoutRef.current = setTimeout(() => {
3343
+ connectWebSocket();
3344
+ }, delay);
3345
+ }
3346
+ }
3347
+ };
3348
+ useEffect4(() => {
3349
+ if (state.agentId) {
3350
+ connectWebSocket();
3351
+ }
3352
+ return () => {
3353
+ if (reconnectTimeoutRef.current) {
3354
+ clearTimeout(reconnectTimeoutRef.current);
3355
+ reconnectTimeoutRef.current = null;
3356
+ }
3357
+ if (pingIntervalRef.current) {
3358
+ clearInterval(pingIntervalRef.current);
3359
+ pingIntervalRef.current = null;
3360
+ }
3361
+ if (webSocketRef.current) {
3362
+ webSocketRef.current.close(1e3, "Component unmounting");
3363
+ webSocketRef.current = null;
3364
+ }
3365
+ reconnectAttemptsRef.current = 0;
3366
+ };
3367
+ }, [state.agentId]);
3368
+ const handleSendSMS = (data) => {
3369
+ var _a2;
3370
+ sendNotification(END_POINT.SEND_NOTIFICATIONS, {
3371
+ phone_number: (_a2 = data == null ? void 0 : data.phone_number) != null ? _a2 : "",
3372
+ type: "ambulance"
3373
+ });
3374
+ };
3375
+ if (!state.isInitialized) {
3376
+ return /* @__PURE__ */ jsx2(Box2, { children: Boolean(openProcessorDialog) && /* @__PURE__ */ jsx2(
3377
+ ProcessorListDialog,
3378
+ {
3379
+ processList,
3380
+ open: openProcessorDialog,
3381
+ setOpen: setOpenProcessorDialog,
3382
+ handleSelectedProcessor: (data) => {
3383
+ sdkStateManager.setProcess(data);
3384
+ }
3385
+ }
3386
+ ) });
3387
+ }
3388
+ const isOnHold = ((_h = state.callData) == null ? void 0 : _h.hold) === 1 && ((_j = (_i = state.callData) == null ? void 0 : _i.status) == null ? void 0 : _j.toUpperCase()) === "ONCALL" /* ONCALL */;
3389
+ const isMuted = ((_k = state.callData) == null ? void 0 : _k.mute) === 1 && ((_m = (_l = state.callData) == null ? void 0 : _l.status) == null ? void 0 : _m.toUpperCase()) === "ONCALL" /* ONCALL */;
3390
+ const isVertical = ((_n = state.sdkConfig) == null ? void 0 : _n.sdkPosition) === "vertical";
3391
+ return /* @__PURE__ */ jsxs2(Fragment2, { children: [
3392
+ /* @__PURE__ */ jsx2(Box2, { children: /* @__PURE__ */ jsx2(Fade, { in: true, timeout: 300, children: /* @__PURE__ */ jsx2(
3393
+ Paper2,
3394
+ {
3395
+ ref: ((_o = state.sdkConfig) == null ? void 0 : _o.isDraggable) ? dragRef : null,
3396
+ elevation: isDragging ? 4 : ((_p = state.sdkConfig) == null ? void 0 : _p.isDraggable) ? 1 : 0,
3397
+ sx: {
3398
+ position: ((_q = state.sdkConfig) == null ? void 0 : _q.isDraggable) ? "fixed" : "relative",
3399
+ left: ((_r = state.sdkConfig) == null ? void 0 : _r.isDraggable) ? position.x : "auto",
3400
+ top: ((_s = state.sdkConfig) == null ? void 0 : _s.isDraggable) ? position.y : "auto",
3401
+ display: "inline-block",
3402
+ width: isVertical ? "180px" : "auto",
3403
+ flexShrink: 0,
3404
+ whiteSpace: "nowrap",
3405
+ p: 0.5,
3406
+ borderRadius: 3,
3407
+ bgcolor: "background.paper",
3408
+ zIndex: ((_t = state.sdkConfig) == null ? void 0 : _t.isDraggable) ? Number.MAX_SAFE_INTEGER : 0,
3409
+ transition: theme.transitions.create(["box-shadow", "transform"], {
3410
+ duration: theme.transitions.duration.short
3411
+ }),
3412
+ userSelect: "none"
3413
+ },
3414
+ children: /* @__PURE__ */ jsxs2(
3415
+ Box2,
3416
+ {
3417
+ sx: {
3418
+ display: "flex",
3419
+ flexDirection: isVertical ? "column" : "row",
3420
+ alignItems: isVertical ? "stretch" : "center"
3421
+ },
3422
+ children: [
3423
+ /* @__PURE__ */ jsxs2(
3424
+ Box2,
3425
+ {
3426
+ sx: {
3427
+ display: "flex",
3428
+ flexDirection: isVertical ? "column" : "row",
3429
+ alignItems: isVertical ? "stretch" : "center",
3430
+ gap: 1,
3431
+ margin: isVertical ? "10px 8px 4px 8px" : "0px 10px"
3432
+ },
3433
+ children: [
3434
+ ((_u = state.sdkConfig) == null ? void 0 : _u.isDraggable) && /* @__PURE__ */ jsx2(
3435
+ IconButton2,
3436
+ {
3437
+ component: "div",
3438
+ size: "small",
3439
+ sx: {
3440
+ cursor: "all-scroll"
3441
+ },
3442
+ onMouseDown: handleMouseDown,
3443
+ onTouchStart: handleTouchStart,
3444
+ children: /* @__PURE__ */ jsx2(DragIndicator, {})
3445
+ }
3446
+ ),
3447
+ ((_v = state.sdkConfig) == null ? void 0 : _v.enableQueueName) && ((_w = state == null ? void 0 : state.callData) == null ? void 0 : _w.queue_name) && ((_x = state == null ? void 0 : state.callData) == null ? void 0 : _x.mode) !== "manual" && /* @__PURE__ */ jsx2(Chip, { label: (_y = state == null ? void 0 : state.callData) == null ? void 0 : _y.queue_name }),
3448
+ /* @__PURE__ */ jsx2(Tooltip2, { title: ((_z = state.sdkConfig) == null ? void 0 : _z.disabledDialButton) ? "Outbound call feature is disabled" : "Dial", children: /* @__PURE__ */ jsx2(Box2, { component: "span", sx: isVertical ? { display: "block" } : {}, children: isVertical ? /* @__PURE__ */ jsx2(
3449
+ Button2,
3450
+ {
3451
+ variant: "outlined",
3452
+ startIcon: /* @__PURE__ */ jsx2(WifiCalling3, {}),
3453
+ onClick: (e) => {
3454
+ var _a2, _b2, _c2, _d2, _e2, _f2;
3455
+ if (![
3456
+ "BREAK" /* BREAK */,
3457
+ "ONCALL" /* ONCALL */,
3458
+ "RINGING" /* RINGING */
3459
+ ].includes((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()) && !((_c2 = state.sdkConfig) == null ? void 0 : _c2.disabledDialButton) && !(((_e2 = (_d2 = state.callData) == null ? void 0 : _d2.status) == null ? void 0 : _e2.toUpperCase()) === "WRAPUP" /* WRAPUP */ && ((_f2 = state.sdkConfig) == null ? void 0 : _f2.disableAlternateDialing))) {
3460
+ handleOpenDialer(e);
3461
+ }
3462
+ },
3463
+ disabled: [
3464
+ "BREAK" /* BREAK */,
3465
+ "ONCALL" /* ONCALL */,
3466
+ "RINGING" /* RINGING */
3467
+ ].includes((_A = state.callData.status) == null ? void 0 : _A.toUpperCase()) || ((_B = state.sdkConfig) == null ? void 0 : _B.disabledDialButton) || ((_C = state.callData.status) == null ? void 0 : _C.toUpperCase()) === "WRAPUP" /* WRAPUP */ && !!((_D = state.sdkConfig) == null ? void 0 : _D.disableAlternateDialing),
3468
+ sx: {
3469
+ justifyContent: "flex-start",
3470
+ width: "100%",
3471
+ px: 2,
3472
+ color: [
3473
+ "BREAK" /* BREAK */,
3474
+ "ONCALL" /* ONCALL */,
3475
+ "RINGING" /* RINGING */
3476
+ ].includes((_E = state.callData.status) == null ? void 0 : _E.toUpperCase()) || ((_F = state.sdkConfig) == null ? void 0 : _F.disabledDialButton) || ((_G = state.callData.status) == null ? void 0 : _G.toUpperCase()) === "WRAPUP" /* WRAPUP */ && !!((_H = state.sdkConfig) == null ? void 0 : _H.disableAlternateDialing) ? "action.selected" : "success.main",
3477
+ borderColor: [
3478
+ "BREAK" /* BREAK */,
3479
+ "ONCALL" /* ONCALL */,
3480
+ "RINGING" /* RINGING */
3481
+ ].includes((_I = state.callData.status) == null ? void 0 : _I.toUpperCase()) || ((_J = state.sdkConfig) == null ? void 0 : _J.disabledDialButton) || ((_K = state.callData.status) == null ? void 0 : _K.toUpperCase()) === "WRAPUP" /* WRAPUP */ && !!((_L = state.sdkConfig) == null ? void 0 : _L.disableAlternateDialing) ? "action.selected" : "success.main"
3482
+ },
3483
+ children: "Dial"
3484
+ }
3485
+ ) : /* @__PURE__ */ jsx2(
3486
+ IconButton2,
3487
+ {
3488
+ size: "small",
3489
+ onClick: (e) => {
3490
+ var _a2, _b2, _c2, _d2, _e2, _f2;
3491
+ if (![
3492
+ "BREAK" /* BREAK */,
3493
+ "ONCALL" /* ONCALL */,
3494
+ "RINGING" /* RINGING */
3495
+ ].includes((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()) && !((_c2 = state.sdkConfig) == null ? void 0 : _c2.disabledDialButton) && !(((_e2 = (_d2 = state.callData) == null ? void 0 : _d2.status) == null ? void 0 : _e2.toUpperCase()) === "WRAPUP" /* WRAPUP */ && ((_f2 = state.sdkConfig) == null ? void 0 : _f2.disableAlternateDialing))) {
3496
+ handleOpenDialer(e);
3497
+ }
3498
+ },
3499
+ disabled: [
3500
+ "BREAK" /* BREAK */,
3501
+ "ONCALL" /* ONCALL */,
3502
+ "RINGING" /* RINGING */
3503
+ ].includes((_M = state.callData.status) == null ? void 0 : _M.toUpperCase()) || ((_N = state.sdkConfig) == null ? void 0 : _N.disabledDialButton) || ((_O = state.callData.status) == null ? void 0 : _O.toUpperCase()) === "WRAPUP" /* WRAPUP */ && !!((_P = state.sdkConfig) == null ? void 0 : _P.disableAlternateDialing),
3504
+ children: /* @__PURE__ */ jsx2(
3505
+ WifiCalling3,
3506
+ {
3507
+ sx: {
3508
+ color: [
3509
+ "BREAK" /* BREAK */,
3510
+ "ONCALL" /* ONCALL */,
3511
+ "RINGING" /* RINGING */
3512
+ ].includes((_Q = state.callData.status) == null ? void 0 : _Q.toUpperCase()) || ((_R = state.sdkConfig) == null ? void 0 : _R.disabledDialButton) || ((_S = state.callData.status) == null ? void 0 : _S.toUpperCase()) === "WRAPUP" /* WRAPUP */ && !!((_T = state.sdkConfig) == null ? void 0 : _T.disableAlternateDialing) ? "action.selected" : "success.main"
3513
+ }
3514
+ }
3515
+ )
3516
+ }
3517
+ ) }) }),
3518
+ /* @__PURE__ */ jsxs2(
3519
+ Box2,
3520
+ {
3521
+ onClick: () => setShowIframe(true),
3522
+ sx: {
3523
+ display: "flex",
3524
+ flexDirection: "column",
3525
+ alignItems: "center",
3526
+ cursor: "pointer",
3527
+ minWidth: "52px",
3528
+ marginRight: "10px"
3529
+ },
3530
+ children: [
3531
+ ((_V = (_U = state.callData) == null ? void 0 : _U.status) == null ? void 0 : _V.toUpperCase()) === "BREAK" /* BREAK */ && ((_X = (_W = state.callData) == null ? void 0 : _W.break_details) == null ? void 0 : _X.value) ? /* @__PURE__ */ jsx2(Tooltip2, { title: state.callData.break_details.value, children: /* @__PURE__ */ jsx2(
3532
+ Box2,
3533
+ {
3534
+ sx: {
3535
+ border: "1.5px solid",
3536
+ borderColor: "success.main",
3537
+ borderRadius: "50px",
3538
+ px: "8px",
3539
+ py: "3px",
3540
+ maxWidth: "80px",
3541
+ minWidth: "80px",
3542
+ overflow: "hidden",
3543
+ textAlign: "center"
3544
+ },
3545
+ children: /* @__PURE__ */ jsx2(
3546
+ Typography2,
3547
+ {
3548
+ sx: {
3549
+ color: "success.main",
3550
+ fontSize: "10px",
3551
+ fontWeight: "700",
3552
+ lineHeight: 1.2,
3553
+ overflow: "hidden",
3554
+ textOverflow: "ellipsis",
3555
+ whiteSpace: "nowrap",
3556
+ textTransform: "uppercase"
3557
+ },
3558
+ children: state.callData.break_details.value
3559
+ }
3560
+ )
3561
+ }
3562
+ ) }) : /* @__PURE__ */ jsx2(
3563
+ Typography2,
3564
+ {
3565
+ sx: {
3566
+ color: isOnHold ? "warning.main" : isMuted ? "error.main" : "success.main",
3567
+ fontSize: "18px",
3568
+ fontWeight: "600",
3569
+ lineHeight: 1.2
3570
+ },
3571
+ children: state.callData.status === "WRAPUP" /* WRAPUP */ && callWrapuptime !== null ? formatDuration(callWrapuptime) : formatDuration(callDuration)
3572
+ }
3573
+ ),
3574
+ isOnHold && /* @__PURE__ */ jsxs2(
3575
+ Box2,
3576
+ {
3577
+ sx: {
3578
+ display: "flex",
3579
+ alignItems: "center",
3580
+ gap: "3px",
3581
+ backgroundColor: "warning.main",
3582
+ color: "#fff",
3583
+ borderRadius: "6px",
3584
+ px: "5px",
3585
+ py: "1px",
3586
+ mt: "2px"
3587
+ },
3588
+ children: [
3589
+ /* @__PURE__ */ jsx2(Pause2, { sx: { fontSize: "11px" } }),
3590
+ /* @__PURE__ */ jsx2(
3591
+ Typography2,
3592
+ {
3593
+ sx: {
3594
+ fontSize: "11px",
3595
+ fontWeight: 700,
3596
+ lineHeight: 1
3597
+ },
3598
+ children: formatDuration(holdDuration)
3599
+ }
3600
+ )
3601
+ ]
3602
+ }
3603
+ ),
3604
+ isMuted && !isOnHold && /* @__PURE__ */ jsxs2(
3605
+ Box2,
3606
+ {
3607
+ sx: {
3608
+ display: "flex",
3609
+ alignItems: "center",
3610
+ gap: "3px",
3611
+ backgroundColor: "error.main",
3612
+ color: "#fff",
3613
+ borderRadius: "6px",
3614
+ px: "5px",
3615
+ py: "1px",
3616
+ mt: "2px"
3617
+ },
3618
+ children: [
3619
+ /* @__PURE__ */ jsx2(MicOff, { sx: { fontSize: "11px" } }),
3620
+ /* @__PURE__ */ jsx2(
3621
+ Typography2,
3622
+ {
3623
+ sx: {
3624
+ fontSize: "11px",
3625
+ fontWeight: 700,
3626
+ lineHeight: 1
3627
+ },
3628
+ children: formatDuration(muteDuration)
3629
+ }
3630
+ )
3631
+ ]
3632
+ }
3633
+ )
3634
+ ]
3635
+ }
3636
+ ),
3637
+ /* @__PURE__ */ jsx2(
3638
+ Chip,
3639
+ {
3640
+ sx: { padding: "18px 0px" },
3641
+ label: isLoading || agentReadyLoading ? /* @__PURE__ */ jsx2(
3642
+ Box2,
3643
+ {
3644
+ sx: {
3645
+ fontWeight: "bold",
3646
+ width: "60px",
3647
+ display: "flex",
3648
+ alignItems: "center",
3649
+ justifyContent: "center"
3650
+ },
3651
+ children: /* @__PURE__ */ jsx2(CircularProgress2, { size: "20px" })
3652
+ }
3653
+ ) : /* @__PURE__ */ jsx2(
3654
+ Typography2,
3655
+ {
3656
+ variant: "body2",
3657
+ sx: {
3658
+ fontWeight: "bold",
3659
+ width: "60px",
3660
+ textAlign: "center"
3661
+ },
3662
+ children: (__ = (_Z = (_Y = state.callData) == null ? void 0 : _Y.status) == null ? void 0 : _Z.toUpperCase()) != null ? __ : "N/A"
3663
+ }
3664
+ ),
3665
+ onClick: handleOpenAgentStatus,
3666
+ deleteIcon: /* @__PURE__ */ jsx2(KeyboardArrowDown, { color: "primary" }),
3667
+ onDelete: handleOpenAgentStatus
3668
+ }
3669
+ )
3670
+ ]
3671
+ }
3672
+ ),
3673
+ /* @__PURE__ */ jsxs2(
3674
+ Box2,
3675
+ {
3676
+ sx: {
3677
+ display: "flex",
3678
+ flexDirection: isVertical ? "column" : "row",
3679
+ gap: 1,
3680
+ justifyContent: "center",
3681
+ alignItems: isVertical ? "stretch" : "center",
3682
+ margin: isVertical ? "0px 8px 8px 8px" : "0px"
3683
+ },
3684
+ children: [
3685
+ /* @__PURE__ */ jsx2(Tooltip2, { title: "Agent Ready", children: /* @__PURE__ */ jsx2(
3686
+ Button2,
3687
+ {
3688
+ variant: ["BREAK" /* BREAK */, "MISSED" /* MISSED */].includes(
3689
+ (_aa = (_$ = state.callData) == null ? void 0 : _$.status) == null ? void 0 : _aa.toUpperCase()
3690
+ ) ? "outlined" : "contained",
3691
+ startIcon: isVertical ? /* @__PURE__ */ jsx2(SupportAgent2, {}) : void 0,
3692
+ onClick: (e) => {
3693
+ var _a2, _b2;
3694
+ if (["BREAK" /* BREAK */, "MISSED" /* MISSED */].includes(
3695
+ (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()
3696
+ )) {
3697
+ e.stopPropagation();
3698
+ handleAgentReady();
3699
+ }
3700
+ },
3701
+ classes: {
3702
+ root: ["BREAK" /* BREAK */, "MISSED" /* MISSED */].includes(
3703
+ (_ca = (_ba = state.callData) == null ? void 0 : _ba.status) == null ? void 0 : _ca.toUpperCase()
3704
+ ) ? "outlined" : "enabled"
3705
+ },
3706
+ sx: __spreadValues(__spreadValues({}, ["BREAK" /* BREAK */, "MISSED" /* MISSED */].includes(
3707
+ (_ea = (_da = state.callData) == null ? void 0 : _da.status) == null ? void 0 : _ea.toUpperCase()
3708
+ ) ? outlined : enabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }),
3709
+ disabled: agentReadyLoading,
3710
+ children: isVertical ? "Agent Ready" : /* @__PURE__ */ jsx2(SupportAgent2, {})
3711
+ }
3712
+ ) }),
3713
+ /* @__PURE__ */ jsx2(Tooltip2, { title: ((_fa = state.sdkConfig) == null ? void 0 : _fa.disableHoldButton) ? "Hold feature is disabled" : ((_ga = state.callData) == null ? void 0 : _ga.hold) === 1 ? "Resume" : "Hold", children: /* @__PURE__ */ jsx2(Box2, { component: "span", sx: isVertical ? { display: "block" } : {}, children: /* @__PURE__ */ jsx2(
3714
+ Button2,
3715
+ {
3716
+ variant: ((_ha = state.callData) == null ? void 0 : _ha.hold) === 1 && ((_ja = (_ia = state.callData) == null ? void 0 : _ia.status) == null ? void 0 : _ja.toUpperCase()) === "ONCALL" /* ONCALL */ ? "contained" : "outlined",
3717
+ startIcon: isVertical ? holdOrUnHoldLoading ? void 0 : ((_ka = state.callData) == null ? void 0 : _ka.hold) === 1 ? /* @__PURE__ */ jsx2(PlayArrow2, {}) : /* @__PURE__ */ jsx2(Pause2, {}) : void 0,
3718
+ onClick: (e) => {
3719
+ var _a2;
3720
+ e.stopPropagation();
3721
+ if (!((_a2 = state.sdkConfig) == null ? void 0 : _a2.disableHoldButton)) {
3722
+ handleHoldToggle();
3723
+ }
3724
+ },
3725
+ sx: ((_la = state.callData) == null ? void 0 : _la.hold) === 1 && ((_na = (_ma = state.callData) == null ? void 0 : _ma.status) == null ? void 0 : _na.toUpperCase()) === "ONCALL" /* ONCALL */ ? __spreadValues(__spreadValues({}, enabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : ((_pa = (_oa = state.callData) == null ? void 0 : _oa.status) == null ? void 0 : _pa.toUpperCase()) === "ONCALL" /* ONCALL */ && !((_qa = state.sdkConfig) == null ? void 0 : _qa.disableHoldButton) ? __spreadValues(__spreadValues({}, outlined), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : __spreadValues(__spreadValues({}, disabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }),
3726
+ disabled: ((_sa = (_ra = state.callData) == null ? void 0 : _ra.status) == null ? void 0 : _sa.toUpperCase()) !== "ONCALL" /* ONCALL */ && ((_ta = state.callData) == null ? void 0 : _ta.hold) !== 1 || holdOrUnHoldLoading || ((_ua = state.sdkConfig) == null ? void 0 : _ua.disableHoldButton),
3727
+ children: holdOrUnHoldLoading ? /* @__PURE__ */ jsx2(
3728
+ CircularProgress2,
3729
+ {
3730
+ size: "20px",
3731
+ sx: { color: theme.palette.primary.main }
3732
+ }
3733
+ ) : isVertical ? ((_va = state.callData) == null ? void 0 : _va.hold) === 1 ? "Resume" : "Hold" : ((_wa = state.callData) == null ? void 0 : _wa.hold) === 1 ? /* @__PURE__ */ jsx2(PlayArrow2, {}) : /* @__PURE__ */ jsx2(Pause2, {})
3734
+ }
3735
+ ) }) }),
3736
+ /* @__PURE__ */ jsx2(Tooltip2, { title: ((_xa = state.sdkConfig) == null ? void 0 : _xa.disableMuteButton) ? "Mute feature is disabled" : ((_ya = state.callData) == null ? void 0 : _ya.mute) === 1 ? "Unmute" : "Mute", children: /* @__PURE__ */ jsx2(Box2, { component: "span", sx: isVertical ? { display: "block" } : {}, children: /* @__PURE__ */ jsx2(
3737
+ Button2,
3738
+ {
3739
+ variant: ((_za = state.callData) == null ? void 0 : _za.mute) === 1 && ((_Ba = (_Aa = state.callData) == null ? void 0 : _Aa.status) == null ? void 0 : _Ba.toUpperCase()) === "ONCALL" /* ONCALL */ ? "contained" : "outlined",
3740
+ startIcon: isVertical ? muteOrUnMuteLoading ? void 0 : ((_Ca = state.callData) == null ? void 0 : _Ca.mute) === 1 ? /* @__PURE__ */ jsx2(MicOff, {}) : /* @__PURE__ */ jsx2(Mic, {}) : void 0,
3741
+ onClick: (e) => {
3742
+ var _a2;
3743
+ e.stopPropagation();
3744
+ if (!((_a2 = state.sdkConfig) == null ? void 0 : _a2.disableMuteButton)) {
3745
+ handleMuteToggle();
3746
+ }
3747
+ },
3748
+ sx: ((_Da = state.sdkConfig) == null ? void 0 : _Da.disableMuteButton) || ((_Ea = state.callData) == null ? void 0 : _Ea.hold) === 1 ? __spreadValues(__spreadValues({}, disabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : ((_Fa = state.callData) == null ? void 0 : _Fa.mute) === 1 && ((_Ha = (_Ga = state.callData) == null ? void 0 : _Ga.status) == null ? void 0 : _Ha.toUpperCase()) === "ONCALL" /* ONCALL */ ? __spreadValues(__spreadValues({}, enabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : ((_Ja = (_Ia = state.callData) == null ? void 0 : _Ia.status) == null ? void 0 : _Ja.toUpperCase()) === "ONCALL" /* ONCALL */ ? __spreadValues(__spreadValues({}, outlined), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : __spreadValues(__spreadValues({}, disabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }),
3749
+ disabled: ((_La = (_Ka = state.callData) == null ? void 0 : _Ka.status) == null ? void 0 : _La.toUpperCase()) !== "ONCALL" /* ONCALL */ && ((_Ma = state.callData) == null ? void 0 : _Ma.mute) !== 1 || muteOrUnMuteLoading || ((_Na = state.callData) == null ? void 0 : _Na.hold) === 1 || ((_Oa = state.sdkConfig) == null ? void 0 : _Oa.disableMuteButton),
3750
+ children: muteOrUnMuteLoading ? /* @__PURE__ */ jsx2(
3751
+ CircularProgress2,
3752
+ {
3753
+ size: "20px",
3754
+ sx: { color: theme.palette.primary.main }
3755
+ }
3756
+ ) : isVertical ? ((_Pa = state.callData) == null ? void 0 : _Pa.mute) === 1 ? "Unmute" : "Mute" : ((_Qa = state.callData) == null ? void 0 : _Qa.mute) === 1 ? /* @__PURE__ */ jsx2(MicOff, {}) : /* @__PURE__ */ jsx2(Mic, {})
3757
+ }
3758
+ ) }) }),
3759
+ /* @__PURE__ */ jsx2(Tooltip2, { title: ((_Ra = state.sdkConfig) == null ? void 0 : _Ra.disableCallTransferButton) ? "Transfer Call feature is disabled" : "Transfer Call", children: /* @__PURE__ */ jsx2(Box2, { component: "span", sx: isVertical ? { display: "block" } : {}, children: /* @__PURE__ */ jsx2(
3760
+ Button2,
3761
+ {
3762
+ variant: state.openCallTransferDialog ? "contained" : "outlined",
3763
+ startIcon: isVertical ? /* @__PURE__ */ jsx2(TransferWithinAStation2, {}) : void 0,
3764
+ onClick: (e) => {
3765
+ var _a2, _b2, _c2;
3766
+ if (((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL" /* ONCALL */ && !((_c2 = state.sdkConfig) == null ? void 0 : _c2.disableCallTransferButton)) {
3767
+ e.stopPropagation();
3768
+ sdkStateManager.setOpenCallTransferDialog(true);
3769
+ }
3770
+ },
3771
+ sx: state.openCallTransferDialog ? __spreadValues(__spreadValues({}, enabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : ((_Ta = (_Sa = state.callData) == null ? void 0 : _Sa.status) == null ? void 0 : _Ta.toUpperCase()) === "ONCALL" /* ONCALL */ && !((_Ua = state.sdkConfig) == null ? void 0 : _Ua.disableCallTransferButton) ? __spreadValues(__spreadValues({}, outlined), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : __spreadValues(__spreadValues({}, disabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }),
3772
+ disabled: ((_Wa = (_Va = state.callData) == null ? void 0 : _Va.status) == null ? void 0 : _Wa.toUpperCase()) !== "ONCALL" /* ONCALL */ || ((_Xa = state.sdkConfig) == null ? void 0 : _Xa.disableCallTransferButton),
3773
+ children: isVertical ? "Transfer" : /* @__PURE__ */ jsx2(TransferWithinAStation2, {})
3774
+ }
3775
+ ) }) }),
3776
+ /* @__PURE__ */ jsx2(Tooltip2, { title: ((_Ya = state.sdkConfig) == null ? void 0 : _Ya.disableConferenceButton) ? "Conference Call feature is disabled" : "Conference Call", children: /* @__PURE__ */ jsx2(Box2, { component: "span", sx: isVertical ? { display: "block" } : {}, children: /* @__PURE__ */ jsx2(
3777
+ Button2,
3778
+ {
3779
+ variant: state.openConferenceDialog ? "contained" : "outlined",
3780
+ startIcon: isVertical ? /* @__PURE__ */ jsx2(Group, {}) : void 0,
3781
+ onClick: (e) => {
3782
+ var _a2, _b2, _c2;
3783
+ if (((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL" /* ONCALL */ && !((_c2 = state.sdkConfig) == null ? void 0 : _c2.disableConferenceButton)) {
3784
+ e.stopPropagation();
3785
+ sdkStateManager.setOpenConferenceDialog(true);
3786
+ }
3787
+ },
3788
+ sx: state.openConferenceDialog ? __spreadValues(__spreadValues({}, enabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : ((__a = (_Za = state.callData) == null ? void 0 : _Za.status) == null ? void 0 : __a.toUpperCase()) === "ONCALL" /* ONCALL */ && !((_$a = state.sdkConfig) == null ? void 0 : _$a.disableConferenceButton) ? __spreadValues(__spreadValues({}, outlined), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : __spreadValues(__spreadValues({}, disabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }),
3789
+ disabled: ((_bb = (_ab = state.callData) == null ? void 0 : _ab.status) == null ? void 0 : _bb.toUpperCase()) !== "ONCALL" /* ONCALL */ || ((_cb = state.sdkConfig) == null ? void 0 : _cb.disableConferenceButton),
3790
+ children: isVertical ? "Conference" : /* @__PURE__ */ jsx2(Group, {})
3791
+ }
3792
+ ) }) }),
3793
+ ((_db = state.sdkConfig) == null ? void 0 : _db.enableSmsServices) && /* @__PURE__ */ jsx2(Tooltip2, { title: "Send SMS", children: /* @__PURE__ */ jsx2(
3794
+ Button2,
3795
+ {
3796
+ variant: Boolean(ambulanceAnchorEl) ? "contained" : "outlined",
3797
+ startIcon: isVertical ? /* @__PURE__ */ jsx2(SmsSharp, {}) : void 0,
3798
+ onClick: (e) => {
3799
+ var _a2, _b2;
3800
+ if (["ONCALL" /* ONCALL */, "WRAPUP" /* WRAPUP */].includes(
3801
+ (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()
3802
+ )) {
3803
+ e.stopPropagation();
3804
+ handleOpenAbulanceServices(e);
3805
+ }
3806
+ },
3807
+ sx: Boolean(ambulanceAnchorEl) ? __spreadValues(__spreadValues({}, enabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : ["ONCALL" /* ONCALL */, "WRAPUP" /* WRAPUP */].includes(
3808
+ (_fb = (_eb = state.callData) == null ? void 0 : _eb.status) == null ? void 0 : _fb.toUpperCase()
3809
+ ) ? __spreadValues(__spreadValues({}, outlined), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : __spreadValues(__spreadValues({}, disabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }),
3810
+ disabled: !["ONCALL" /* ONCALL */, "WRAPUP" /* WRAPUP */].includes(
3811
+ (_hb = (_gb = state.callData) == null ? void 0 : _gb.status) == null ? void 0 : _hb.toUpperCase()
3812
+ ),
3813
+ children: isVertical ? "Send SMS" : /* @__PURE__ */ jsx2(SmsSharp, {})
3814
+ }
3815
+ ) }),
3816
+ /* @__PURE__ */ jsx2(Tooltip2, { title: ((_ib = state.sdkConfig) == null ? void 0 : _ib.disableEndCallButton) ? "End Call feature is disabled" : "End Call", children: /* @__PURE__ */ jsx2(Box2, { component: "span", sx: isVertical ? { display: "block" } : {}, children: /* @__PURE__ */ jsx2(
3817
+ Button2,
3818
+ {
3819
+ variant: [
3820
+ "ONCALL" /* ONCALL */,
3821
+ "RINGING" /* RINGING */,
3822
+ "DIALING" /* DIALING */,
3823
+ "WRAPUP" /* WRAPUP */
3824
+ ].includes((_kb = (_jb = state.callData) == null ? void 0 : _jb.status) == null ? void 0 : _kb.toUpperCase()) && !((_lb = state.sdkConfig) == null ? void 0 : _lb.disableEndCallButton) ? "contained" : "outlined",
3825
+ startIcon: isVertical && !endCallLoading ? /* @__PURE__ */ jsx2(CallEnd2, {}) : void 0,
3826
+ onClick: (e) => {
3827
+ var _a2, _b2, _c2;
3828
+ if ([
3829
+ "ONCALL" /* ONCALL */,
3830
+ "RINGING" /* RINGING */,
3831
+ "DIALING" /* DIALING */,
3832
+ "WRAPUP" /* WRAPUP */
3833
+ ].includes((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()) && !((_c2 = state.sdkConfig) == null ? void 0 : _c2.disableEndCallButton)) {
3834
+ e.stopPropagation();
3835
+ setOpenCallDisposition(true);
3836
+ }
3837
+ },
3838
+ sx: [
3839
+ "ONCALL" /* ONCALL */,
3840
+ "RINGING" /* RINGING */,
3841
+ "DIALING" /* DIALING */,
3842
+ "WRAPUP" /* WRAPUP */
3843
+ ].includes((_nb = (_mb = state.callData) == null ? void 0 : _mb.status) == null ? void 0 : _nb.toUpperCase()) && !((_ob = state.sdkConfig) == null ? void 0 : _ob.disableEndCallButton) ? __spreadValues(__spreadProps(__spreadValues({}, enabled), {
3844
+ borderRight: "1px",
3845
+ backgroundColor: "error.main",
3846
+ minWidth: "60px !important",
3847
+ boxShadow: " 0px 2px 1px #5f3f3f",
3848
+ border: `1px solid ${theme.palette.error.light}`,
3849
+ height: "40px",
3850
+ "&:hover": {
3851
+ bgcolor: "error.light",
3852
+ boxShadow: " 0px 2px 1px #5f3f3f",
3853
+ border: `0px solid ${theme.palette.error.light}`
3854
+ },
3855
+ "&:active": {
3856
+ bgcolor: "error.light",
3857
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
3858
+ }
3859
+ }), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : __spreadValues(__spreadProps(__spreadValues({}, disabled), {
3860
+ minWidth: "60px !important"
3861
+ }), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }),
3862
+ disabled: ![
3863
+ "ONCALL" /* ONCALL */,
3864
+ "RINGING" /* RINGING */,
3865
+ "DIALING" /* DIALING */,
3866
+ "WRAPUP" /* WRAPUP */
3867
+ ].includes((_qb = (_pb = state.callData) == null ? void 0 : _pb.status) == null ? void 0 : _qb.toUpperCase()) || endCallLoading || ((_rb = state.sdkConfig) == null ? void 0 : _rb.disableEndCallButton),
3868
+ children: endCallLoading ? /* @__PURE__ */ jsx2(CircularProgress2, { size: "20px", color: "error" }) : isVertical ? "End Call" : /* @__PURE__ */ jsx2(CallEnd2, {})
3869
+ }
3870
+ ) }) }),
3871
+ !((_sb = state.sdkConfig) == null ? void 0 : _sb.disabledMoreOptionsButton) && processList && (processList == null ? void 0 : processList.length) > 1 && /* @__PURE__ */ jsx2(Tooltip2, { title: "Switch Process", children: /* @__PURE__ */ jsx2(
3872
+ Button2,
3873
+ {
3874
+ variant: Boolean(moreOptionsAnchorEl) ? "contained" : "outlined",
3875
+ startIcon: isVertical ? /* @__PURE__ */ jsx2(MoreVert, {}) : void 0,
3876
+ onClick: (e) => {
3877
+ var _a2, _b2;
3878
+ if (["BREAK" /* BREAK */, "IDLE" /* IDLE */].includes(
3879
+ (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()
3880
+ )) {
3881
+ e.stopPropagation();
3882
+ handleOpenMoreOptions(e);
3883
+ }
3884
+ },
3885
+ sx: Boolean(moreOptionsAnchorEl) ? __spreadValues(__spreadValues({}, enabled), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }) : __spreadValues(__spreadValues({}, outlined), isVertical && { justifyContent: "flex-start", width: "100%", px: 2 }),
3886
+ disabled: !["BREAK" /* BREAK */, "IDLE" /* IDLE */].includes(
3887
+ (_ub = (_tb = state.callData) == null ? void 0 : _tb.status) == null ? void 0 : _ub.toUpperCase()
3888
+ ),
3889
+ children: isVertical ? "Switch Process" : /* @__PURE__ */ jsx2(MoreVert, {})
3890
+ }
3891
+ ) })
3892
+ ]
3893
+ }
3894
+ )
3895
+ ]
3896
+ }
3897
+ )
3898
+ }
3899
+ ) }) }),
3900
+ /* @__PURE__ */ jsx2(
3901
+ Fade,
3902
+ {
3903
+ in: true,
3904
+ timeout: 300,
3905
+ children: /* @__PURE__ */ jsxs2(
3906
+ Paper2,
3907
+ {
3908
+ ref: iframeDragRef,
3909
+ elevation: iframeIsDragging ? 4 : 1,
3910
+ sx: {
3911
+ position: "absolute",
3912
+ left: iframePosition.x,
3913
+ top: iframePosition.y,
3914
+ borderRadius: 2,
3915
+ bgcolor: "background.paper",
3916
+ zIndex: Number.MAX_SAFE_INTEGER,
3917
+ transition: theme.transitions.create(["box-shadow", "transform"], {
3918
+ duration: theme.transitions.duration.short
3919
+ }),
3920
+ visibility: showIframe && !((_vb = state.sdkConfig) == null ? void 0 : _vb.disableSoftPhone) ? "visible" : "hidden",
3921
+ userSelect: "none"
3922
+ },
3923
+ children: [
3924
+ /* @__PURE__ */ jsxs2(
3925
+ Box2,
3926
+ {
3927
+ sx: {
3928
+ display: "flex",
3929
+ alignItems: "center",
3930
+ justifyContent: "space-between",
3931
+ cursor: "all-scroll",
3932
+ padding: "0px 10px"
3933
+ },
3934
+ onMouseDown: iframeHandleMouseDown,
3935
+ onTouchStart: iframeHandleTouchStart,
3936
+ children: [
3937
+ /* @__PURE__ */ jsx2(
3938
+ DragIndicator,
3939
+ {
3940
+ sx: {
3941
+ transform: "rotate(90deg)",
3942
+ color: "#7b7b7b"
3943
+ }
3944
+ }
3945
+ ),
3946
+ " ",
3947
+ /* @__PURE__ */ jsx2(Typography2, { variant: "subtitle1", fontWeight: 600, sx: { textAlign: "center" }, children: "ahs-cti" }),
3948
+ /* @__PURE__ */ jsx2(IconButton2, { onClick: () => setShowIframe(false), children: /* @__PURE__ */ jsx2(Close2, {}) })
3949
+ ]
3950
+ }
3951
+ ),
3952
+ /* @__PURE__ */ jsx2(Box2, { children: /* @__PURE__ */ jsx2(
3953
+ "iframe",
3954
+ {
3955
+ src: `${(_wb = state.urlConfig) == null ? void 0 : _wb.iframeURL}/static/phone/index.html?user_id=${(_xb = state.urlConfig) == null ? void 0 : _xb.id}&api_url=${(_yb = state.urlConfig) == null ? void 0 : _yb.iframeAPIURL}&token=${(_zb = state.authorization) == null ? void 0 : _zb.accessToken}`,
3956
+ height: 380,
3957
+ width: 420,
3958
+ allow: "camera; microphone; autoplay",
3959
+ style: {
3960
+ border: "none"
3961
+ }
3962
+ }
3963
+ ) })
3964
+ ]
3965
+ }
3966
+ )
3967
+ }
3968
+ ),
3969
+ /* @__PURE__ */ jsx2(
3970
+ Menu2,
3971
+ {
3972
+ anchorEl: dialerAnchorEl,
3973
+ open: Boolean(dialerAnchorEl),
3974
+ onClose: handleCloseDialer,
3975
+ onClick: (e) => e.stopPropagation(),
3976
+ sx: {
3977
+ zIndex: 99999
3978
+ },
3979
+ children: /* @__PURE__ */ jsxs2(
3980
+ Box2,
3981
+ {
3982
+ sx: {
3983
+ all: "unset",
3984
+ padding: "10px",
3985
+ "&hover": {
3986
+ backgroundColor: "white"
3987
+ }
3988
+ },
3989
+ children: [
3990
+ /* @__PURE__ */ jsx2(
3991
+ TextField2,
3992
+ {
3993
+ size: "small",
3994
+ type: "tel",
3995
+ value: phoneNumber,
3996
+ placeholder: "Enter Mobile No.",
3997
+ slotProps: {
3998
+ htmlInput: {
3999
+ inputMode: "numeric",
4000
+ maxLength: 11
4001
+ }
4002
+ },
4003
+ onChange: (e) => {
4004
+ const value = e.target.value;
4005
+ if (/^\d*$/.test(value)) {
4006
+ setPhoneNumber(value);
4007
+ }
4008
+ },
4009
+ onPaste: (e) => {
4010
+ const pasted = e.clipboardData.getData("text");
4011
+ if (!/^\d*$/.test(pasted)) {
4012
+ e.preventDefault();
4013
+ }
4014
+ },
4015
+ onKeyDown: (e) => {
4016
+ if (e.key === "Enter") {
4017
+ handleStartCall(phoneNumber);
4018
+ return;
4019
+ }
4020
+ const allowedKeys = [
4021
+ "Backspace",
4022
+ "Delete",
4023
+ "Tab",
4024
+ "ArrowLeft",
4025
+ "ArrowRight",
4026
+ "ArrowUp",
4027
+ "ArrowDown",
4028
+ "Home",
4029
+ "End"
4030
+ ];
4031
+ if (!/^\d$/.test(e.key) && !allowedKeys.includes(e.key) && !(e.ctrlKey || e.metaKey)) {
4032
+ e.preventDefault();
4033
+ }
4034
+ }
4035
+ }
4036
+ ),
4037
+ /* @__PURE__ */ jsx2(
4038
+ IconButton2,
4039
+ {
4040
+ color: "info",
4041
+ onClick: () => {
4042
+ handleStartCall(phoneNumber);
4043
+ },
4044
+ children: clickToCallLoading ? /* @__PURE__ */ jsx2(
4045
+ CircularProgress2,
4046
+ {
4047
+ size: "20px",
4048
+ sx: {
4049
+ color: theme.palette.success.main
4050
+ }
4051
+ }
4052
+ ) : /* @__PURE__ */ jsx2(Phone, { color: "success" })
4053
+ }
4054
+ )
4055
+ ]
4056
+ }
4057
+ )
4058
+ }
4059
+ ),
4060
+ /* @__PURE__ */ jsx2(
4061
+ Menu2,
4062
+ {
4063
+ anchorEl: ambulanceAnchorEl,
4064
+ open: Boolean(ambulanceAnchorEl),
4065
+ onClose: handleCloseAmbulance,
4066
+ onClick: (e) => e.stopPropagation(),
4067
+ sx: {
4068
+ zIndex: 99999
4069
+ },
4070
+ children: /* @__PURE__ */ jsx2(
4071
+ Box2,
4072
+ {
4073
+ sx: {
4074
+ all: "unset",
4075
+ padding: " 0px 20px",
4076
+ "&hover": {
4077
+ backgroundColor: "white"
4078
+ },
4079
+ display: "flex",
4080
+ alignItems: "center"
4081
+ },
4082
+ children: /* @__PURE__ */ jsx2(Tooltip2, { title: "Ambulance Service", children: /* @__PURE__ */ jsxs2(
4083
+ Button2,
4084
+ {
4085
+ color: "primary",
4086
+ variant: "outlined",
4087
+ onClick: () => {
4088
+ handleSendSMS(state.callData);
4089
+ },
4090
+ children: [
4091
+ "Ambulance",
4092
+ /* @__PURE__ */ jsxs2(
4093
+ Box2,
4094
+ {
4095
+ sx: {
4096
+ display: "flex",
4097
+ alignItems: "center",
4098
+ backgroundColor: "green",
4099
+ color: "#fff",
4100
+ marginLeft: "14px",
4101
+ padding: "2px 6px",
4102
+ borderRadius: "10px"
4103
+ },
4104
+ children: [
4105
+ "Send",
4106
+ /* @__PURE__ */ jsx2(
4107
+ SendRounded,
4108
+ {
4109
+ sx: {
4110
+ marginLeft: "8px",
4111
+ width: "18px",
4112
+ transform: "rotate(-16deg)"
4113
+ }
4114
+ }
4115
+ )
4116
+ ]
4117
+ }
4118
+ )
4119
+ ]
4120
+ }
4121
+ ) })
4122
+ }
4123
+ )
4124
+ }
4125
+ ),
4126
+ /* @__PURE__ */ jsx2(
4127
+ Menu2,
4128
+ {
4129
+ anchorEl: moreOptionsAnchorEl,
4130
+ open: Boolean(moreOptionsAnchorEl),
4131
+ onClose: handleCloseMoreOptions,
4132
+ onClick: (e) => e.stopPropagation(),
4133
+ sx: {
4134
+ zIndex: 99999
4135
+ },
4136
+ children: /* @__PURE__ */ jsx2(
4137
+ Box2,
4138
+ {
4139
+ sx: {
4140
+ all: "unset",
4141
+ padding: " 0px 20px",
4142
+ "&hover": {
4143
+ backgroundColor: "white"
4144
+ },
4145
+ display: "flex",
4146
+ alignItems: "center",
4147
+ flexDirection: "column",
4148
+ gap: 1
4149
+ },
4150
+ children: processList == null ? void 0 : processList.map((item) => {
4151
+ var _a2, _b2, _c2;
4152
+ return /* @__PURE__ */ jsx2(
4153
+ Box2,
4154
+ {
4155
+ sx: {
4156
+ width: "100%"
4157
+ },
4158
+ children: /* @__PURE__ */ jsx2(Tooltip2, { title: (_a2 = item == null ? void 0 : item.process_name) != null ? _a2 : "", children: /* @__PURE__ */ jsx2(
4159
+ Button2,
4160
+ {
4161
+ color: "primary",
4162
+ variant: ((_b2 = state == null ? void 0 : state.process) == null ? void 0 : _b2.process_id) === (item == null ? void 0 : item.process_id) ? "contained" : "outlined",
4163
+ onClick: () => {
4164
+ sdkStateManager.setProcess(item);
4165
+ },
4166
+ sx: {
4167
+ width: "100%"
4168
+ },
4169
+ children: (_c2 = item == null ? void 0 : item.process_name) != null ? _c2 : ""
4170
+ }
4171
+ ) })
4172
+ },
4173
+ item == null ? void 0 : item.process_id
4174
+ );
4175
+ })
4176
+ }
4177
+ )
4178
+ }
4179
+ ),
4180
+ /* @__PURE__ */ jsx2(
4181
+ Menu2,
4182
+ {
4183
+ anchorEl: statusAnchorEl,
4184
+ open: Boolean(statusAnchorEl),
4185
+ onClose: handleCloseAgentStatus,
4186
+ onClick: (e) => e.stopPropagation(),
4187
+ sx: {
4188
+ zIndex: 99999
4189
+ },
4190
+ children: !breaksList || (breaksList == null ? void 0 : breaksList.length) === 0 ? /* @__PURE__ */ jsx2(MenuItem2, { onClick: () => handleUpdateAgentStatus("Lunch"), children: "- Break" }) : breaksList == null ? void 0 : breaksList.map((item) => {
4191
+ var _a2, _b2, _c2;
4192
+ return /* @__PURE__ */ jsxs2(
4193
+ MenuItem2,
4194
+ {
4195
+ sx: {
4196
+ // hilight background of selected
4197
+ backgroundColor: ((_a2 = state == null ? void 0 : state.callData) == null ? void 0 : _a2.status) === "BREAK" && (state == null ? void 0 : state.agentStatus) === (item == null ? void 0 : item.type) ? "primary.main" : "transparent",
4198
+ color: ((_b2 = state == null ? void 0 : state.callData) == null ? void 0 : _b2.status) === "BREAK" && (state == null ? void 0 : state.agentStatus) === (item == null ? void 0 : item.type) ? "white" : "primary.main",
4199
+ ":hover": {
4200
+ backgroundColor: ((_c2 = state == null ? void 0 : state.callData) == null ? void 0 : _c2.status) === "BREAK" && (state == null ? void 0 : state.agentStatus) === (item == null ? void 0 : item.type) ? "primary.dark" : "selected.hover"
4201
+ // color:
4202
+ // state?.callData?.status === "BREAK" && state?.agentStatus === item?.type ?
4203
+ // "primary.main"
4204
+ // : "primary.main",
4205
+ }
4206
+ },
4207
+ onClick: () => handleUpdateAgentStatus(item == null ? void 0 : item.type),
4208
+ children: [
4209
+ "- ",
4210
+ item == null ? void 0 : item.type
4211
+ ]
4212
+ },
4213
+ item == null ? void 0 : item.type
4214
+ );
4215
+ })
4216
+ }
4217
+ ),
4218
+ /* @__PURE__ */ jsx2(
4219
+ Menu2,
4220
+ {
4221
+ anchorEl,
4222
+ open: Boolean(anchorEl),
4223
+ onClose: handleCloseQueueCounts,
4224
+ onClick: (e) => e.stopPropagation(),
4225
+ sx: {
4226
+ zIndex: 99999
4227
+ },
4228
+ children: /* @__PURE__ */ jsxs2(
4229
+ Box2,
4230
+ {
4231
+ sx: {
4232
+ display: "flex",
4233
+ justifyContent: "flex-start",
4234
+ flexDirection: "column",
4235
+ padding: "0px 10px",
4236
+ "&hover": {
4237
+ backgroundColor: "white"
4238
+ }
4239
+ },
4240
+ children: [
4241
+ /* @__PURE__ */ jsx2(
4242
+ Chip,
4243
+ {
4244
+ icon: /* @__PURE__ */ jsx2(Layers, { color: "secondary" }),
4245
+ variant: "outlined",
4246
+ label: "Waiting - 25",
4247
+ sx: {
4248
+ margin: "4px 2px"
4249
+ }
4250
+ }
4251
+ ),
4252
+ /* @__PURE__ */ jsx2(
4253
+ Chip,
4254
+ {
4255
+ icon: /* @__PURE__ */ jsx2(Pending, { color: "info" }),
4256
+ label: "Pending - 99+",
4257
+ variant: "outlined",
4258
+ sx: {
4259
+ margin: "4px 2px"
4260
+ }
4261
+ }
4262
+ ),
4263
+ /* @__PURE__ */ jsx2(
4264
+ Chip,
4265
+ {
4266
+ icon: /* @__PURE__ */ jsx2(Upcoming2, { color: "success" }),
4267
+ variant: "outlined",
4268
+ label: "Upcoming - 66",
4269
+ sx: {
4270
+ margin: "4px 2px"
4271
+ }
4272
+ }
4273
+ )
4274
+ ]
4275
+ }
4276
+ )
4277
+ }
4278
+ ),
4279
+ Boolean(state.openConferenceDialog) && /* @__PURE__ */ jsx2(ConferenceDialog, {}),
4280
+ Boolean(state.openCallTransferDialog) && /* @__PURE__ */ jsx2(CallTransferDialog, { open: state.openCallTransferDialog }),
4281
+ Boolean(openCallDisposition) && /* @__PURE__ */ jsx2(
4282
+ EndCallDispositionDialog,
4283
+ {
4284
+ open: openCallDisposition,
4285
+ setOpen: setOpenCallDisposition,
4286
+ onSubmitDisposition: handleEndCall
4287
+ }
4288
+ ),
4289
+ Boolean(openCallHistoryDialog) && /* @__PURE__ */ jsx2(
4290
+ CallHistoryDialog,
4291
+ {
4292
+ open: openCallHistoryDialog,
4293
+ setOpen: setOpenCallHistoryDialog
4294
+ }
4295
+ )
4296
+ ] });
4297
+ }
4298
+
4299
+ // call-control-sdk/lib/components/callControlPanel.tsx
4300
+ import { jsx as jsx3 } from "react/jsx-runtime";
4301
+ var CallControlPanel = memo(({ onDataChange }) => {
4302
+ var _a;
4303
+ const { sdk } = useSDKState();
4304
+ const handleDataChange = useCallback6(
4305
+ (data) => {
4306
+ try {
4307
+ if (onDataChange && typeof onDataChange === "function") {
4308
+ onDataChange(data);
4309
+ }
4310
+ } catch (error) {
4311
+ console.error("Error in CallControlPanel data change handler:", error);
4312
+ }
4313
+ },
4314
+ [onDataChange]
4315
+ );
4316
+ const sdkObject = sdk == null ? void 0 : sdk.calls;
4317
+ const hasDialerAccess = (sdkObject == null ? void 0 : sdkObject.enabled) && ((_a = sdkObject == null ? void 0 : sdkObject.items) == null ? void 0 : _a.some(
4318
+ (item) => item.code === SDK_PERMISSIONS.CALL_OUTBOUND || item.code === SDK_PERMISSIONS.CALL_INBOUND
4319
+ ));
4320
+ if (!hasDialerAccess) return null;
4321
+ return /* @__PURE__ */ jsx3(SDKProvider, { children: /* @__PURE__ */ jsx3(CallControls, { onDataChange: handleDataChange }) });
4322
+ });
4323
+ CallControlPanel.displayName = "CallControlPanel";
4324
+
4325
+ // call-control-sdk/lib/pages/sdkPages.tsx
4326
+ import React3 from "react";
4327
+ import { jsx as jsx4 } from "react/jsx-runtime";
4328
+ function withGuard(menuCodes, loader) {
4329
+ return React3.lazy(async () => {
4330
+ const mod = await loader();
4331
+ const Page = mod.default;
4332
+ const Guarded = (props) => /* @__PURE__ */ jsx4(SDKPermissionGuard, { menuFeature: menuCodes, children: /* @__PURE__ */ jsx4(Page, __spreadValues({}, props)) });
4333
+ return { default: Guarded };
4334
+ });
4335
+ }
4336
+ var SDKPages = {
4337
+ CallHistory: withGuard(SDK_MENU_CODES.CALL_HISTORY, () => import("./callHistory-743J7EKD.mjs")),
4338
+ Campaigns: withGuard(SDK_MENU_CODES.CAMPAIGNS, () => import("./campaigns-N2RLUJHH.mjs")),
4339
+ LoginReport: withGuard(SDK_MENU_CODES.LOGIN_REPORT, () => import("./loginReport-H6XJU2MY.mjs")),
4340
+ CdrReports: withGuard(SDK_MENU_CODES.CDR_REPORT, () => import("./cdrReport-577UYGZA.mjs")),
4341
+ AuditReportPage: withGuard(SDK_MENU_CODES.CDR_REPORT, () => import("./auditReport-CJ23LXIZ.mjs")),
4342
+ AgentPerformanceReport: withGuard(SDK_MENU_CODES.AGENT_PERFORMANCE_REPORT, () => import("./agentPerformanceReport-R3WY7Q7D.mjs")),
4343
+ AgentDetailReport: withGuard(SDK_MENU_CODES.AGENT_DETAIL_REPORT, () => import("./agentDetailReport-7TDO6MYQ.mjs")),
4344
+ LiveStatus: withGuard(SDK_MENU_CODES.LIVE_STATUS, () => import("./liveStatus-IQIEZZE5.mjs")),
4345
+ ManagementDashboard: withGuard(SDK_MENU_CODES.MANAGEMENT_DASHBOARD, () => import("./managementDashboard-NZMAJPPB.mjs")),
4346
+ CaroVoiceAI: withGuard(SDK_MENU_CODES.CARO_VOICE_AI, () => import("./caroVoiceAI-Z5BDDDSY.mjs")),
4347
+ QualityAuditDashboard: withGuard(SDK_MENU_CODES.MANAGEMENT_DASHBOARD, () => import("./qualityAuditDashboard-ZJEEAMBS.mjs")),
4348
+ CaroQualityAuditDashboard: withGuard(SDK_MENU_CODES.MANAGEMENT_DASHBOARD, () => import("./caroQualityAuditDashboard-NRWY6SEC.mjs"))
4349
+ };
4350
+
4351
+ // call-control-sdk/lib/hooks/useClickToConference.ts
4352
+ import { useCallback as useCallback7, useEffect as useEffect5, useRef as useRef3, useState as useState9 } from "react";
4353
+ import { getSession as getSession4 } from "@react-solutions/vault";
4354
+ var useClickToConference = () => {
4355
+ const [loading, setLoading] = useState9(false);
4356
+ const [success, setSuccess] = useState9(false);
4357
+ const [isError, setIsError] = useState9(false);
4358
+ const [error, setError] = useState9(null);
4359
+ const [data, setData] = useState9(null);
4360
+ const pendingLineRef = useRef3(null);
4361
+ const prevConferenceRef = useRef3([]);
4362
+ useEffect5(() => {
4363
+ if (pendingLineRef.current === null) return;
4364
+ const unsubscribe = sdkStateManager.subscribe(() => {
4365
+ var _a;
4366
+ const state = sdkStateManager.getState();
4367
+ const targetLine = pendingLineRef.current;
4368
+ if (targetLine === null) return;
4369
+ const line = (_a = state.conferenceLine) == null ? void 0 : _a.find(
4370
+ (l) => l.line === targetLine
4371
+ );
4372
+ if (line && line.status !== "IDLE") {
4373
+ pendingLineRef.current = null;
4374
+ prevConferenceRef.current = [];
4375
+ sdkStateManager.setOpenConferenceDialog(true);
4376
+ }
4377
+ });
4378
+ return unsubscribe;
4379
+ }, [loading]);
4380
+ const handleStartConferenceCall = useCallback7(
4381
+ async (payload) => {
4382
+ var _a, _b, _c, _d, _e, _f;
4383
+ const state = getSession4(STORAGE_KEY);
4384
+ if (((_a = state == null ? void 0 : state.callData) == null ? void 0 : _a.status) !== "ONCALL") {
4385
+ const msg = "Conference call requires an active call (ONCALL status)";
4386
+ setIsError(true);
4387
+ setError(new Error(msg));
4388
+ throw new Error(msg);
4389
+ }
4390
+ const availableLine = payload.lineNumber != null ? (_b = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _b.find(
4391
+ (l) => l.line === payload.lineNumber
4392
+ ) : (_d = (_c = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _c.filter((l) => l.line !== 1)) == null ? void 0 : _d.find((l) => l.status === "IDLE" && !(l == null ? void 0 : l.isCallStart));
4393
+ if (!availableLine) {
4394
+ const msg = "No available conference line found";
4395
+ setIsError(true);
4396
+ setError(new Error(msg));
4397
+ throw new Error(msg);
4398
+ }
4399
+ const requestPayload = {
4400
+ action: "EXTERNAL_CONFERENCE",
4401
+ operation: `CALL${availableLine.line}`,
4402
+ target: payload.mobileNumber,
4403
+ line_number: Number(availableLine.line),
4404
+ userid: state.agentId,
4405
+ process: (_f = (_e = state.callData) == null ? void 0 : _e.process_name) != null ? _f : ""
4406
+ };
4407
+ setLoading(true);
4408
+ setIsError(false);
4409
+ setError(null);
4410
+ setSuccess(false);
4411
+ pendingLineRef.current = availableLine.line;
4412
+ return axios_default.post(END_POINT.CONFERENCE_CALL, requestPayload).then((res) => {
4413
+ setData(res == null ? void 0 : res.data);
4414
+ setSuccess(true);
4415
+ return res == null ? void 0 : res.data;
4416
+ }).catch((err) => {
4417
+ var _a2;
4418
+ pendingLineRef.current = null;
4419
+ setIsError(true);
4420
+ setError(err);
4421
+ return (_a2 = err == null ? void 0 : err.response) == null ? void 0 : _a2.data;
4422
+ }).finally(() => {
4423
+ setLoading(false);
4424
+ });
4425
+ },
4426
+ []
4427
+ );
4428
+ return {
4429
+ handleStartConferenceCall,
4430
+ isLoading: loading,
4431
+ isSuccess: success,
4432
+ isError,
4433
+ error,
4434
+ data
4435
+ };
4436
+ };
4437
+
4438
+ // call-control-sdk/lib/angular-services/index.ts
4439
+ import { removeSession as removeSession2 } from "@react-solutions/vault";
4440
+ function clickToCall(payload) {
4441
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
4442
+ const state = sdkStateManager.getState();
4443
+ const body = {
4444
+ phone_number: payload.mobileNumber,
4445
+ user: (_b = (_a = payload.user) != null ? _a : state == null ? void 0 : state.agentId) != null ? _b : "",
4446
+ auto_answer: (_c = payload.auto_answer) != null ? _c : false,
4447
+ call_id: (_f = (_e = payload.call_id) != null ? _e : (_d = state == null ? void 0 : state.callData) == null ? void 0 : _d.call_id) != null ? _f : "",
4448
+ reference_id: (_g = payload.reference_id) != null ? _g : "",
4449
+ call_source: (_h = payload.call_source) != null ? _h : "",
4450
+ caseId: (_i = payload.caseId) != null ? _i : "",
4451
+ isWrapup: (_j = payload.isWrapup) != null ? _j : false,
4452
+ parentCallUuid: (_k = payload.parentCallUuid) != null ? _k : ""
4453
+ };
4454
+ return axios_default.post(END_POINT.CLICK_TO_CALL, body).then((res) => {
4455
+ try {
4456
+ sdkStateManager.resetConferenceLines();
4457
+ } catch (_) {
4458
+ }
4459
+ return res.data;
4460
+ }).catch((err) => {
4461
+ var _a2;
4462
+ return (_a2 = err == null ? void 0 : err.response) == null ? void 0 : _a2.data;
4463
+ });
4464
+ }
4465
+ function clickToConference(payload) {
4466
+ var _a, _b, _c, _d, _e;
4467
+ const state = sdkStateManager.getState();
4468
+ const availableLine = payload.lineNumber != null ? (_a = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _a.find((l) => l.line === payload.lineNumber) : (_c = (_b = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _b.filter((l) => l.line !== 1)) == null ? void 0 : _c.find((l) => l.status === "IDLE" && !(l == null ? void 0 : l.isCallStart));
4469
+ if (!availableLine) {
4470
+ return Promise.reject(new Error("No available conference line found"));
4471
+ }
4472
+ const body = {
4473
+ action: "EXTERNAL_CONFERENCE",
4474
+ operation: `CALL${availableLine.line}`,
4475
+ target: payload.mobileNumber,
4476
+ line_number: Number(availableLine.line),
4477
+ userid: state.agentId,
4478
+ process: (_e = (_d = state.callData) == null ? void 0 : _d.process_name) != null ? _e : ""
4479
+ };
4480
+ return axios_default.post(END_POINT.CONFERENCE_CALL, body).then((res) => {
4481
+ try {
4482
+ sdkStateManager.setOpenConferenceDialog(true);
4483
+ } catch (_) {
4484
+ }
4485
+ return res.data;
4486
+ }).catch((err) => {
4487
+ var _a2;
4488
+ return (_a2 = err == null ? void 0 : err.response) == null ? void 0 : _a2.data;
4489
+ });
4490
+ }
4491
+ async function endCall(options = {}) {
4492
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
4493
+ const state = sdkStateManager.getState();
4494
+ const body = {
4495
+ call_id: (_c = (_b = options.call_id) != null ? _b : (_a = state == null ? void 0 : state.callData) == null ? void 0 : _a.call_id) != null ? _c : "",
4496
+ agent_id: (_e = (_d = options.agent_id) != null ? _d : state == null ? void 0 : state.agentId) != null ? _e : "",
4497
+ set_followUp: (_f = options.set_followUp) != null ? _f : "N",
4498
+ callback_date: (_g = options.callback_date) != null ? _g : "",
4499
+ callback_hrs: (_h = options.callback_hrs) != null ? _h : 0,
4500
+ callback_mins: (_i = options.callback_mins) != null ? _i : 0,
4501
+ mobile_number: (_l = (_k = options.mobile_number) != null ? _k : (_j = state == null ? void 0 : state.callData) == null ? void 0 : _j.phone_number) != null ? _l : "",
4502
+ list_comments: (_m = options.list_comments) != null ? _m : "",
4503
+ call_reference_id: (_p = (_o = options.call_reference_id) != null ? _o : (_n = state == null ? void 0 : state.callData) == null ? void 0 : _n.call_id) != null ? _p : "",
4504
+ is_mark_as_break: (_q = options.is_mark_as_break) != null ? _q : false,
4505
+ disposition: (_r = options.disposition) != null ? _r : "RES",
4506
+ line_number: (_s = options.line_number) != null ? _s : 0,
4507
+ reason: (_t = options.reason) != null ? _t : "normal"
4508
+ };
4509
+ const res = await axios_default.post(END_POINT.END_CALL, body);
4510
+ sdkStateManager.resetConferenceLines();
4511
+ sdkStateManager.endCall();
4512
+ return res.data;
4513
+ }
4514
+ async function logout() {
4515
+ var _a, _b;
4516
+ let logoutError;
4517
+ try {
4518
+ await axios_default.post(END_POINT.AUTH_LOGOUT);
4519
+ } catch (err) {
4520
+ logoutError = new Error(((_b = (_a = err == null ? void 0 : err.response) == null ? void 0 : _a.data) == null ? void 0 : _b.message) || "Logout failed. Please try again.");
4521
+ } finally {
4522
+ sdkStateManager.clearStorageAndReset();
4523
+ removeSession2(STORAGE_KEY);
4524
+ }
4525
+ if (logoutError) throw logoutError;
4526
+ }
4527
+ async function startMonitoring(payload) {
4528
+ const res = await axios_default.post(END_POINT.SUPERVISOR_CALL_LISTEN, payload);
4529
+ return res.data;
4530
+ }
4531
+ async function stopMonitoring(payload) {
4532
+ const res = await axios_default.post(END_POINT.SUPERVISOR_CALL_LEAVE, payload);
4533
+ return res.data;
4534
+ }
4535
+ async function changeMonitorMode(payload) {
4536
+ const res = await axios_default.post(END_POINT.SUPERVISOR_CALL_CHANGE_MODE, payload);
4537
+ return res.data;
4538
+ }
4539
+ function setTransferLeadData(data) {
4540
+ sdkStateManager.setTransferLeadData(data);
4541
+ }
4542
+
4543
+ // call-control-sdk/index.ts
4544
+ async function initSDK({
4545
+ apiKey,
4546
+ tenantId,
4547
+ agentId,
4548
+ sdkConfig,
4549
+ urlConfig
4550
+ }) {
4551
+ if (!apiKey || typeof apiKey !== "string" || apiKey.trim().length === 0) {
4552
+ throw new Error("SDK initialization failed: API key is required");
4553
+ }
4554
+ if (!tenantId || typeof tenantId !== "string" || tenantId.trim().length === 0) {
4555
+ throw new Error("SDK initialization failed: Tenant ID is required");
4556
+ }
4557
+ if (!agentId || typeof agentId !== "string" || agentId.trim().length === 0) {
4558
+ throw new Error("SDK initialization failed: Agent ID is required");
4559
+ }
4560
+ try {
4561
+ const initResult = await eventTracker.init({
4562
+ apiKey: apiKey.trim(),
4563
+ tenantId: tenantId.trim(),
4564
+ agentId: agentId.trim(),
4565
+ password: urlConfig == null ? void 0 : urlConfig.password,
4566
+ accessToken: urlConfig == null ? void 0 : urlConfig.accessToken,
4567
+ baseUrl: urlConfig == null ? void 0 : urlConfig.coreBaseURL
4568
+ });
4569
+ if (!initResult) {
4570
+ sdkStateManager.setInitCheck();
4571
+ throw new Error("SDK initialization failed");
4572
+ }
4573
+ if (initResult.userInfo) {
4574
+ sdkStateManager.setSDKPermissions(initResult.userInfo);
4575
+ }
4576
+ const permissionControlsConfig = sdkStateManager.getControlsConfig();
4577
+ const callcontrolConfig = __spreadValues(__spreadValues(__spreadValues({}, initResult.callControls || {}), permissionControlsConfig), sdkConfig || {});
4578
+ const res = {
4579
+ accessToken: initResult.accessToken,
4580
+ expiration: initResult.expiration,
4581
+ ticketId: initResult.ticketId,
4582
+ callControls: callcontrolConfig,
4583
+ userInfo: initResult.userInfo
4584
+ };
4585
+ console.info("SDK initialized successfully");
4586
+ sdkStateManager.initialize(
4587
+ apiKey.trim(),
4588
+ tenantId.trim(),
4589
+ agentId.trim(),
4590
+ urlConfig,
4591
+ res,
4592
+ callcontrolConfig,
4593
+ initResult.callControls
4594
+ );
4595
+ return res;
4596
+ } catch (error) {
4597
+ sdkStateManager.setInitCheck();
4598
+ if (error instanceof Error) {
4599
+ throw error;
4600
+ }
4601
+ throw new Error(`SDK initialization failed: ${String(error)}`);
4602
+ }
4603
+ }
4604
+ function getSDKVersion() {
4605
+ return "6.x.x";
4606
+ }
4607
+ function isSDKInitialized() {
4608
+ return sdkStateManager.getState().isInitialized;
4609
+ }
4610
+ export {
4611
+ CallControlPanel,
4612
+ SDKAccessDenied,
4613
+ SDKPages,
4614
+ SDKPermissionGuard,
4615
+ SDK_MENU_CODES,
4616
+ SDK_PERMISSIONS,
4617
+ SDK_WILDCARD,
4618
+ changeMonitorMode,
4619
+ clickToCall,
4620
+ clickToConference,
4621
+ endCall,
4622
+ getSDKVersion,
4623
+ initSDK,
4624
+ isSDKInitialized,
4625
+ logout,
4626
+ sdkStateManager,
4627
+ setAuditReportUrlResolver,
4628
+ setTransferLeadData,
4629
+ startMonitoring,
4630
+ stopMonitoring,
4631
+ useCallMonitoring,
4632
+ useClickToCall,
4633
+ useClickToConference,
4634
+ useEndCall,
4635
+ useGetAuthorizationToken,
4636
+ useGetCallerData,
4637
+ useLogout,
4638
+ useSDKPermissions,
4639
+ useSDKState
4640
+ };
4641
+ //# sourceMappingURL=index.mjs.map