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