call-control-sdk 6.5.1-uat.5 → 6.5.1-uat.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -129,9 +129,6 @@ var SDKStateManager = class {
129
129
  enabled: {},
130
130
  outlined: {}
131
131
  },
132
- isHolding: false,
133
- isMuted: false,
134
- status: "idle",
135
132
  callStartTime: null,
136
133
  controlPanelPosition: { x: 10, y: 10 },
137
134
  iframePosition: { x: ((_a2 = window.screen) == null ? void 0 : _a2.availWidth) - 460, y: ((_b = window.screen) == null ? void 0 : _b.height) - 580 },
@@ -227,9 +224,6 @@ var SDKStateManager = class {
227
224
  enabled: {},
228
225
  outlined: {}
229
226
  },
230
- isHolding: parsedState.isHolding || false,
231
- isMuted: parsedState.isMuted || false,
232
- status: parsedState.status || "idle",
233
227
  callStartTime: parsedState.callStartTime || null,
234
228
  controlPanelPosition: parsedState.controlPanelPosition || {
235
229
  x: 10,
@@ -248,12 +242,11 @@ var SDKStateManager = class {
248
242
  event_time: "",
249
243
  phone_number: ""
250
244
  },
251
- // Fix: Properly handle conferenceLine with fallback to initial state
252
245
  conferenceLine: parsedState.conferenceLine && Array.isArray(parsedState.conferenceLine) && parsedState.conferenceLine.length > 0 ? parsedState.conferenceLine : this.state.conferenceLine
253
246
  });
254
247
  }
255
248
  } catch (error) {
256
- console.warn("Failed to load SDK state from localStorage:", error);
249
+ console.warn("Failed to load SDK state:", error);
257
250
  }
258
251
  }
259
252
  saveToStorage() {
@@ -266,9 +259,6 @@ var SDKStateManager = class {
266
259
  openConferenceDialog: this.state.openConferenceDialog,
267
260
  openCallTransferDialog: this.state.openCallTransferDialog,
268
261
  sdkConfig: this.state.sdkConfig,
269
- isHolding: this.state.isHolding,
270
- isMuted: this.state.isMuted,
271
- status: this.state.status,
272
262
  callStartTime: this.state.callStartTime,
273
263
  controlPanelPosition: this.state.controlPanelPosition,
274
264
  iframePosition: this.state.iframePosition,
@@ -277,7 +267,7 @@ var SDKStateManager = class {
277
267
  };
278
268
  localStorage.setItem(this.STORAGE_KEY, JSON.stringify(persistentState));
279
269
  } catch (error) {
280
- console.warn("Failed to save SDK state to localStorage:", error);
270
+ console.warn("Failed to save SDK state:", error);
281
271
  }
282
272
  }
283
273
  notifyListeners() {
@@ -339,21 +329,16 @@ var SDKStateManager = class {
339
329
  }
340
330
  };
341
331
  }
342
- setHolding(isHolding) {
343
- this.state.isHolding = isHolding;
344
- this.saveToStorage();
345
- this.notifyListeners();
346
- }
347
- setMuted(isMuted) {
348
- this.state.isMuted = isMuted;
349
- this.saveToStorage();
350
- this.notifyListeners();
351
- }
352
- setStatus(status) {
353
- this.state.status = status;
354
- this.saveToStorage();
355
- this.notifyListeners();
356
- }
332
+ // public setHolding(isHolding: boolean): void {
333
+ // this.state.isHolding = isHolding;
334
+ // this.saveToStorage();
335
+ // this.notifyListeners();
336
+ // }
337
+ // public setMuted(isMuted: boolean): void {
338
+ // this.state.isMuted = isMuted;
339
+ // this.saveToStorage();
340
+ // this.notifyListeners();
341
+ // }
357
342
  setProcess(process) {
358
343
  this.state.process = process;
359
344
  this.saveToStorage();
@@ -371,15 +356,11 @@ var SDKStateManager = class {
371
356
  }
372
357
  startCall() {
373
358
  this.state.callStartTime = Date.now();
374
- this.state.status = "on call";
375
359
  this.saveToStorage();
376
360
  this.notifyListeners();
377
361
  }
378
362
  endCall() {
379
363
  this.state.callStartTime = null;
380
- this.state.status = "idle";
381
- this.state.isHolding = false;
382
- this.state.isMuted = false;
383
364
  this.saveToStorage();
384
365
  this.notifyListeners();
385
366
  }
@@ -411,7 +392,6 @@ var SDKStateManager = class {
411
392
  setConferenceLine(line) {
412
393
  var _a2;
413
394
  if (!this.state.conferenceLine || !Array.isArray(this.state.conferenceLine)) {
414
- console.warn("Conference line data corrupted, resetting to initial state");
415
395
  this.state.conferenceLine = this.getInitialState().conferenceLine;
416
396
  }
417
397
  const conferenceLineData = (_a2 = this.state.conferenceLine) == null ? void 0 : _a2.map((each) => {
@@ -486,19 +466,7 @@ var SDKStateManager = class {
486
466
  this.state = this.getInitialState();
487
467
  this.notifyListeners();
488
468
  } catch (error) {
489
- console.warn("Failed to clear localStorage:", error);
490
- }
491
- }
492
- debugStorage() {
493
- try {
494
- const stored = localStorage.getItem(this.STORAGE_KEY);
495
- console.log("Current localStorage data:", stored);
496
- if (stored) {
497
- console.log("Parsed localStorage data:", JSON.parse(stored));
498
- }
499
- console.log("Current state:", this.state);
500
- } catch (error) {
501
- console.error("Error debugging storage:", error);
469
+ console.warn("Failed to clear:", error);
502
470
  }
503
471
  }
504
472
  getConferenceLines() {
@@ -513,23 +481,17 @@ var EventTrackerSDK = class {
513
481
  __publicField(this, "config", null);
514
482
  __publicField(this, "ticketId", null);
515
483
  __publicField(this, "baseUrl", "");
516
- __publicField(this, "eventQueue", []);
517
- // private isOnline: boolean = true;
518
- // private retryQueue: Array<() => Promise<void>> = [];
519
484
  __publicField(this, "flushTimer", null);
520
485
  }
521
486
  async init(config) {
522
487
  this.config = __spreadValues({
523
- autoTrack: true,
524
488
  retryAttempts: 3,
525
489
  queueSize: 100,
526
490
  flushInterval: 5e3
527
491
  }, config);
528
492
  this.baseUrl = config.baseUrl || (typeof window !== "undefined" ? window.location.origin : "");
529
- this.setupNetworkDetection();
530
493
  const ticket = await this.createTicket();
531
494
  this.startPeriodicFlush();
532
- console.log("EventTracker SDK initialized successfully");
533
495
  return ticket;
534
496
  }
535
497
  isInitialized() {
@@ -563,104 +525,11 @@ var EventTrackerSDK = class {
563
525
  }
564
526
  const data = await response.json();
565
527
  this.ticketId = data.ticketId;
566
- if (this.config.autoTrack) {
567
- this.setupAutoTracking();
568
- }
569
528
  return data;
570
529
  } catch (error) {
571
- console.error("EventTracker initialization failed:", error);
572
530
  throw error;
573
531
  }
574
532
  }
575
- async logEvent(eventType, eventData) {
576
- if (!this.config || !this.ticketId) {
577
- console.warn("EventTracker not initialized, skipping event:", eventType);
578
- return;
579
- }
580
- const event = {
581
- eventType,
582
- eventData,
583
- timestamp: Date.now()
584
- };
585
- this.eventQueue.push(event);
586
- if (this.eventQueue.length > (this.config.queueSize || 100)) {
587
- this.eventQueue.shift();
588
- }
589
- }
590
- // private async sendEvent(event: {
591
- // eventType: string;
592
- // eventData?: EventData;
593
- // timestamp: number;
594
- // }): Promise<void> {
595
- // if (!this.config || !this.ticketId) return;
596
- // try {
597
- // const response = await this.makeRequest("/api/v1/et/event", {
598
- // method: "POST",
599
- // headers: {
600
- // "Content-Type": "application/json",
601
- // "X-API-Key": this.config.apiKey,
602
- // },
603
- // body: JSON.stringify({
604
- // ticketId: this.ticketId,
605
- // eventType: event.eventType,
606
- // eventData: event.eventData,
607
- // }),
608
- // });
609
- // if (!response.ok) {
610
- // throw new Error(`Failed to log event: ${response.status} ${response.statusText}`);
611
- // }
612
- // const index = this.eventQueue.findIndex((e) => e.timestamp === event.timestamp);
613
- // if (index > -1) {
614
- // this.eventQueue.splice(index, 1);
615
- // }
616
- // } catch (error) {
617
- // console.error("Event logging failed:", error);
618
- // // this.retryQueue.push(() => this.sendEvent(event));
619
- // }
620
- // }
621
- // async closeTicket(): Promise<void> {
622
- // if (!this.config || !this.ticketId) {
623
- // throw new Error("EventTracker not initialized");
624
- // }
625
- // await this.flush();
626
- // try {
627
- // const response = await this.makeRequest("/api/v1/et/close", {
628
- // method: "POST",
629
- // headers: {
630
- // "Content-Type": "application/json",
631
- // "X-API-Key": this.config.apiKey,
632
- // },
633
- // body: JSON.stringify({
634
- // ticketId: this.ticketId,
635
- // }),
636
- // });
637
- // if (!response.ok) {
638
- // throw new Error(`Failed to close ticket: ${response.status} ${response.statusText}`);
639
- // }
640
- // this.ticketId = null;
641
- // this.stopPeriodicFlush();
642
- // console.log("Ticket closed successfully");
643
- // } catch (error) {
644
- // console.error("Ticket close failed:", error);
645
- // throw error;
646
- // }
647
- // }
648
- // async flush(): Promise<void> {
649
- // if (!this.isOnline || this.eventQueue.length === 0) return;
650
- // // const eventsToFlush = [...this.eventQueue];
651
- // // for (const event of eventsToFlush) {
652
- // // await this.sendEvent(event);
653
- // // }
654
- // const retryItems = [...this.retryQueue];
655
- // this.retryQueue = [];
656
- // for (const retryFn of retryItems) {
657
- // try {
658
- // await retryFn();
659
- // } catch (error) {
660
- // console.error("Retry failed:", error);
661
- // }
662
- // }
663
- // }
664
533
  async makeRequest(url, options) {
665
534
  var _a2;
666
535
  const fullUrl = `${this.baseUrl}${url}`;
@@ -679,156 +548,11 @@ var EventTrackerSDK = class {
679
548
  }
680
549
  throw new Error("Max retries exceeded");
681
550
  }
682
- setupAutoTracking() {
683
- var _a2;
684
- if (typeof window === "undefined" || !((_a2 = this.config) == null ? void 0 : _a2.autoTrack)) return;
685
- const autoTrackConfig = this.config.autoTrack === true ? {} : this.config.autoTrack;
686
- if (autoTrackConfig.pageVisits !== false) {
687
- this.logEvent("pageVisit", {
688
- url: window.location.href,
689
- title: document.title,
690
- referrer: document.referrer,
691
- userAgent: navigator.userAgent,
692
- viewport: {
693
- width: window.innerWidth,
694
- height: window.innerHeight
695
- },
696
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
697
- }).catch((error) => console.warn("Failed to track page visit:", error));
698
- }
699
- if (autoTrackConfig.clicks !== false) {
700
- document.addEventListener("click", (event) => {
701
- var _a3;
702
- const target = event.target;
703
- if (target.tagName === "BUTTON" || target.tagName === "A" || target.onclick || target.getAttribute("role") === "button" || target instanceof HTMLButtonElement && target.type === "button") {
704
- this.logEvent("click", {
705
- element: target.tagName,
706
- text: (_a3 = target.textContent) == null ? void 0 : _a3.trim().substring(0, 100),
707
- href: target.getAttribute("href"),
708
- id: target.id,
709
- className: target.className,
710
- role: target.getAttribute("role"),
711
- position: {
712
- x: event.clientX,
713
- y: event.clientY
714
- },
715
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
716
- }).catch((error) => console.warn("Failed to track click:", error));
717
- }
718
- });
719
- }
720
- if (autoTrackConfig.forms !== false) {
721
- document.addEventListener("submit", (event) => {
722
- const target = event.target;
723
- const formData = new FormData(target);
724
- const formFields = {};
725
- formData.forEach((value, key) => {
726
- formFields[key] = value.toString();
727
- });
728
- this.logEvent("formSubmission", {
729
- formId: target.id,
730
- action: target.action,
731
- method: target.method,
732
- fields: Object.keys(formFields),
733
- fieldCount: Object.keys(formFields).length,
734
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
735
- }).catch((error) => console.warn("Failed to track form submission:", error));
736
- });
737
- }
738
- if (autoTrackConfig.inputs !== false) {
739
- let inputTimer;
740
- document.addEventListener("input", (event) => {
741
- const target = event.target;
742
- if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "SELECT") {
743
- clearTimeout(inputTimer);
744
- inputTimer = setTimeout(() => {
745
- var _a3;
746
- this.logEvent("fieldChange", {
747
- element: target.tagName,
748
- type: target.getAttribute("type"),
749
- name: target.getAttribute("name"),
750
- id: target.id,
751
- valueLength: ((_a3 = target.value) == null ? void 0 : _a3.length) || 0,
752
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
753
- }).catch((error) => console.warn("Failed to track field change:", error));
754
- }, 1e3);
755
- }
756
- });
757
- }
758
- const sessionStartTime = Date.now();
759
- window.addEventListener("beforeunload", () => {
760
- const sessionDuration = Date.now() - sessionStartTime;
761
- this.logEvent("pageUnload", {
762
- url: window.location.href,
763
- sessionDuration,
764
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
765
- });
766
- });
767
- if (autoTrackConfig.visibility !== false) {
768
- document.addEventListener("visibilitychange", () => {
769
- this.logEvent("visibilityChange", {
770
- hidden: document.hidden,
771
- visibilityState: document.visibilityState,
772
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
773
- });
774
- });
775
- }
776
- if (autoTrackConfig.errors !== false) {
777
- window.addEventListener("error", (event) => {
778
- this.logEvent("jsError", {
779
- message: event.message,
780
- filename: event.filename,
781
- lineno: event.lineno,
782
- colno: event.colno,
783
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
784
- });
785
- });
786
- window.addEventListener("unhandledrejection", (event) => {
787
- var _a3;
788
- this.logEvent("unhandledRejection", {
789
- reason: (_a3 = event.reason) == null ? void 0 : _a3.toString(),
790
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
791
- });
792
- });
793
- }
794
- if (autoTrackConfig.performance !== false && typeof window.performance !== "undefined" && window.performance.navigation) {
795
- window.addEventListener("load", () => {
796
- setTimeout(() => {
797
- const navigation = window.performance.navigation;
798
- const timing = window.performance.timing;
799
- this.logEvent("performanceMetrics", {
800
- navigationTime: timing.navigationStart,
801
- loadTime: timing.loadEventEnd - timing.navigationStart,
802
- domReady: timing.domContentLoadedEventEnd - timing.navigationStart,
803
- renderTime: timing.loadEventEnd - timing.domContentLoadedEventEnd,
804
- navigationType: navigation.type,
805
- redirectCount: navigation.redirectCount,
806
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
807
- });
808
- }, 1e3);
809
- });
810
- }
811
- }
812
- setupNetworkDetection() {
813
- if (typeof window === "undefined") return;
814
- window.addEventListener("online", () => {
815
- console.log("EventTracker: Back online, flushing queued events");
816
- });
817
- window.addEventListener("offline", () => {
818
- console.log("EventTracker: Offline, queueing events");
819
- });
820
- }
821
551
  startPeriodicFlush() {
822
552
  if (this.flushTimer) {
823
553
  clearInterval(this.flushTimer);
824
554
  }
825
555
  }
826
- // private stopPeriodicFlush(): void {
827
- // if (this.flushTimer) {
828
- // clearInterval(this.flushTimer);
829
- // this.flushTimer = null;
830
- // }
831
- // }
832
556
  };
833
557
  var eventTracker = new EventTrackerSDK();
834
558
  if (typeof window !== "undefined") {
@@ -877,12 +601,6 @@ function createAxiosInstance() {
877
601
  );
878
602
  instance.interceptors.response.use(
879
603
  (response) => {
880
- var _a3;
881
- const endTime = (/* @__PURE__ */ new Date()).getTime();
882
- const startTime = (_a3 = response.config.metadata) == null ? void 0 : _a3.startTime;
883
- if (startTime) {
884
- console.log(`Request to ${response.config.url} took ${endTime - startTime}ms`);
885
- }
886
604
  return response;
887
605
  },
888
606
  async (error) => {
@@ -1127,101 +845,16 @@ var import_icons_material2 = require("@mui/icons-material");
1127
845
  var import_material4 = require("@mui/material");
1128
846
  var import_react11 = require("react");
1129
847
 
1130
- // call-control-sdk/lib/hooks/useDraggable.ts
1131
- var import_react6 = require("react");
1132
- function useDraggable(initialPosition, onPositionChange) {
1133
- const [position, setPosition] = (0, import_react6.useState)(initialPosition);
1134
- const [isDragging, setIsDragging] = (0, import_react6.useState)(false);
1135
- const dragRef = (0, import_react6.useRef)();
1136
- const dragStart = (0, import_react6.useRef)({ x: 0, y: 0 });
1137
- const elementStart = (0, import_react6.useRef)({ x: 0, y: 0 });
1138
- const updatePosition = (0, import_react6.useCallback)(
1139
- (newPosition) => {
1140
- const element = dragRef.current;
1141
- if (!element) return;
1142
- const rect = element.getBoundingClientRect();
1143
- const viewportWidth = window.innerWidth;
1144
- const viewportHeight = window.innerHeight;
1145
- const constrainedPosition = {
1146
- x: Math.max(0, Math.min(newPosition.x, viewportWidth - rect.width)),
1147
- y: Math.max(0, Math.min(newPosition.y, viewportHeight - rect.height))
1148
- };
1149
- setPosition(constrainedPosition);
1150
- onPositionChange == null ? void 0 : onPositionChange(constrainedPosition);
1151
- },
1152
- [onPositionChange]
1153
- );
1154
- const handleStart = (0, import_react6.useCallback)(
1155
- (clientX, clientY) => {
1156
- setIsDragging(true);
1157
- dragStart.current = { x: clientX, y: clientY };
1158
- elementStart.current = position;
1159
- const handleMove = (moveClientX, moveClientY) => {
1160
- const deltaX = moveClientX - dragStart.current.x;
1161
- const deltaY = moveClientY - dragStart.current.y;
1162
- updatePosition({
1163
- x: elementStart.current.x + deltaX,
1164
- y: elementStart.current.y + deltaY
1165
- });
1166
- };
1167
- const handleMouseMove = (e) => {
1168
- e.preventDefault();
1169
- handleMove(e.clientX, e.clientY);
1170
- };
1171
- const handleTouchMove = (e) => {
1172
- e.preventDefault();
1173
- const touch = e.touches[0];
1174
- if (touch) {
1175
- handleMove(touch.clientX, touch.clientY);
1176
- }
1177
- };
1178
- const handleEnd = () => {
1179
- setIsDragging(false);
1180
- document.removeEventListener("mousemove", handleMouseMove);
1181
- document.removeEventListener("mouseup", handleEnd);
1182
- document.removeEventListener("touchmove", handleTouchMove);
1183
- document.removeEventListener("touchend", handleEnd);
1184
- };
1185
- document.addEventListener("mousemove", handleMouseMove);
1186
- document.addEventListener("mouseup", handleEnd);
1187
- document.addEventListener("touchmove", handleTouchMove, {
1188
- passive: false
1189
- });
1190
- document.addEventListener("touchend", handleEnd);
1191
- },
1192
- [position, updatePosition]
1193
- );
1194
- const handleMouseDown = (0, import_react6.useCallback)(
1195
- (e) => {
1196
- e.preventDefault();
1197
- handleStart(e.clientX, e.clientY);
1198
- },
1199
- [handleStart]
1200
- );
1201
- const handleTouchStart = (0, import_react6.useCallback)(
1202
- (e) => {
1203
- e.preventDefault();
1204
- const touch = e.touches[0];
1205
- if (touch) {
1206
- handleStart(touch.clientX, touch.clientY);
1207
- }
1208
- },
1209
- [handleStart]
1210
- );
1211
- return {
1212
- position,
1213
- isDragging,
1214
- dragRef,
1215
- handleMouseDown,
1216
- handleTouchStart
1217
- };
1218
- }
848
+ // call-control-sdk/lib/components/dialog.tsx
849
+ var import_icons_material = require("@mui/icons-material");
850
+ var import_material3 = require("@mui/material");
851
+ var import_react9 = require("react");
1219
852
 
1220
853
  // call-control-sdk/lib/hooks/useSDKState.ts
1221
- var import_react7 = require("react");
854
+ var import_react6 = require("react");
1222
855
  function useSDKState() {
1223
- const [state, setState] = (0, import_react7.useState)(sdkStateManager.getState());
1224
- (0, import_react7.useEffect)(() => {
856
+ const [state, setState] = (0, import_react6.useState)(sdkStateManager.getState());
857
+ (0, import_react6.useEffect)(() => {
1225
858
  const unsubscribe = sdkStateManager.subscribe(() => {
1226
859
  setState(sdkStateManager.getState());
1227
860
  });
@@ -1231,22 +864,22 @@ function useSDKState() {
1231
864
  }
1232
865
 
1233
866
  // call-control-sdk/lib/services/request.ts
1234
- var import_react9 = require("react");
867
+ var import_react8 = require("react");
1235
868
 
1236
869
  // call-control-sdk/lib/services/toastMessage.tsx
1237
- var import_react8 = require("react");
870
+ var import_react7 = require("react");
1238
871
  var import_material = require("@mui/material");
1239
872
  var import_jsx_runtime = require("react/jsx-runtime");
1240
- var ToastContext = (0, import_react8.createContext)(void 0);
873
+ var ToastContext = (0, import_react7.createContext)(void 0);
1241
874
  var useToast = () => {
1242
- const ctx = (0, import_react8.useContext)(ToastContext);
875
+ const ctx = (0, import_react7.useContext)(ToastContext);
1243
876
  if (!ctx) throw new Error("useToast must be used inside ToastProvider");
1244
877
  return ctx;
1245
878
  };
1246
879
  var ToastProvider = ({ children }) => {
1247
- const [open, setOpen] = (0, import_react8.useState)(false);
1248
- const [message, setMessage] = (0, import_react8.useState)("");
1249
- const [severity, setSeverity] = (0, import_react8.useState)("info");
880
+ const [open, setOpen] = (0, import_react7.useState)(false);
881
+ const [message, setMessage] = (0, import_react7.useState)("");
882
+ const [severity, setSeverity] = (0, import_react7.useState)("info");
1250
883
  const showToast = (msg, sev = "info") => {
1251
884
  setMessage(msg);
1252
885
  setSeverity(sev);
@@ -1314,8 +947,8 @@ var reducer = (state, action) => {
1314
947
  var useGetRequest = (props = {}) => {
1315
948
  const { onSuccess = null, onError = null } = props;
1316
949
  const { showToast } = useToast();
1317
- const [state, dispatch] = (0, import_react9.useReducer)(reducer, initialState);
1318
- const getRequest = (0, import_react9.useCallback)(
950
+ const [state, dispatch] = (0, import_react8.useReducer)(reducer, initialState);
951
+ const getRequest = (0, import_react8.useCallback)(
1319
952
  (url, config = {}) => {
1320
953
  dispatch({
1321
954
  type: "isLoading",
@@ -1367,8 +1000,8 @@ var useGetRequest = (props = {}) => {
1367
1000
  var usePostRequest = (props = {}) => {
1368
1001
  const { onSuccess = null, onError = null, disabledSuccessToast = false } = props;
1369
1002
  const { showToast } = useToast();
1370
- const [state, dispatch] = (0, import_react9.useReducer)(reducer, initialState);
1371
- const postRequest = (0, import_react9.useCallback)(
1003
+ const [state, dispatch] = (0, import_react8.useReducer)(reducer, initialState);
1004
+ const postRequest = (0, import_react8.useCallback)(
1372
1005
  (url, payload, config = {}) => {
1373
1006
  dispatch({
1374
1007
  type: "isLoading",
@@ -1412,11 +1045,6 @@ var usePostRequest = (props = {}) => {
1412
1045
  return [postRequest, state];
1413
1046
  };
1414
1047
 
1415
- // call-control-sdk/lib/components/dialog.tsx
1416
- var import_icons_material = require("@mui/icons-material");
1417
- var import_material3 = require("@mui/material");
1418
- var import_react10 = require("react");
1419
-
1420
1048
  // call-control-sdk/lib/components/styles.ts
1421
1049
  var import_material2 = require("@mui/material");
1422
1050
  var useStyles = ({
@@ -1484,19 +1112,19 @@ var styles_default = useStyles;
1484
1112
  // call-control-sdk/lib/components/dialog.tsx
1485
1113
  var import_jsx_runtime2 = require("react/jsx-runtime");
1486
1114
  var ConferenceTableRow = ({ each }) => {
1487
- var _a2, _b, _c, _d, _e;
1115
+ var _a2, _b, _c, _d, _e, _f;
1488
1116
  const state = useSDKState();
1117
+ const theme = (0, import_material3.useTheme)();
1489
1118
  const { showToast } = useToast();
1490
1119
  const { disabled, enabled, outlined } = styles_default({
1491
1120
  disabled: ((_a2 = state.sdkConfig) == null ? void 0 : _a2.disabled) || {},
1492
1121
  enabled: ((_b = state.sdkConfig) == null ? void 0 : _b.enabled) || {},
1493
1122
  outlined: ((_c = state.sdkConfig) == null ? void 0 : _c.outlined) || {}
1494
1123
  });
1495
- const theme = (0, import_material3.useTheme)();
1496
- const [conferenceCallStart, setConferenceCallStart] = (0, import_react10.useState)(false);
1497
- const [conferenceCallMerge, setConferenceCallMerge] = (0, import_react10.useState)(false);
1498
- const [conferenceCallHoldOrUnHold, setConferenceCallHoldOrUnHold] = (0, import_react10.useState)(false);
1499
- const [conferenceCallEnd, setConferenceCallEnd] = (0, import_react10.useState)(false);
1124
+ const [conferenceCallStart, setConferenceCallStart] = (0, import_react9.useState)(false);
1125
+ const [conferenceCallMerge, setConferenceCallMerge] = (0, import_react9.useState)(false);
1126
+ const [conferenceCallHoldOrUnHold, setConferenceCallHoldOrUnHold] = (0, import_react9.useState)(false);
1127
+ const [conferenceCallEnd, setConferenceCallEnd] = (0, import_react9.useState)(false);
1500
1128
  const onConferenceLineUpdate = (line, data) => {
1501
1129
  sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
1502
1130
  };
@@ -1505,7 +1133,7 @@ var ConferenceTableRow = ({ each }) => {
1505
1133
  const line_used = __spreadValues(__spreadValues({}, line), data);
1506
1134
  setConferenceCallStart(true);
1507
1135
  const payload = {
1508
- action: "INTERNAL_CONFERENCE",
1136
+ action: "EXTERNAL_CONFERENCE",
1509
1137
  operation: `CALL${line_used.line}`,
1510
1138
  line_used: String(line_used.line),
1511
1139
  thirdparty_no: line_used.phone,
@@ -1598,26 +1226,12 @@ var ConferenceTableRow = ({ each }) => {
1598
1226
  setConferenceCallEnd(false);
1599
1227
  });
1600
1228
  };
1601
- const [holdOrUnHold] = usePostRequest({
1602
- onSuccess: () => {
1603
- sdkStateManager.setHolding(!state.isHolding);
1604
- },
1605
- onError: (error) => {
1606
- console.log("\u274C Hold operation error:", error);
1607
- }
1608
- });
1609
- const [muteOrUnMute] = usePostRequest({
1610
- onSuccess: () => {
1611
- sdkStateManager.setMuted(!state.isMuted);
1612
- },
1613
- onError: (error) => {
1614
- console.log("\u274C Mute operation error:", error);
1615
- }
1616
- });
1229
+ const [holdOrUnHold] = usePostRequest();
1230
+ const [muteOrUnMute] = usePostRequest();
1617
1231
  const handleHoldToggle = () => {
1618
1232
  var _a3;
1619
1233
  const payload = {
1620
- action: ((_a3 = state.callData) == null ? void 0 : _a3.hold) === 1 ? "UNHOLD" : "HOLD",
1234
+ action: ((_a3 = state.callData) == null ? void 0 : _a3.hold) === 1 ? "UNHOLD" /* UNHOLD */ : "HOLD" /* HOLD */,
1621
1235
  userId: state.agentId
1622
1236
  };
1623
1237
  holdOrUnHold(END_POINT.HOLD_CALL, payload);
@@ -1625,7 +1239,7 @@ var ConferenceTableRow = ({ each }) => {
1625
1239
  const handleMuteToggle = () => {
1626
1240
  var _a3;
1627
1241
  const payload = {
1628
- action: ((_a3 = state.callData) == null ? void 0 : _a3.mute) === 1 ? "UNMUTE" : "MUTE",
1242
+ action: ((_a3 = state.callData) == null ? void 0 : _a3.mute) === 1 ? "UNMUTE" /* UNMUTE */ : "MUTE" /* MUTE */,
1629
1243
  userId: state.agentId
1630
1244
  };
1631
1245
  muteOrUnMute(END_POINT.MUTE_CALL, payload);
@@ -1687,7 +1301,7 @@ var ConferenceTableRow = ({ each }) => {
1687
1301
  placeholder: "Phone Number",
1688
1302
  fullWidth: true,
1689
1303
  value: (each == null ? void 0 : each.phone) || "",
1690
- disabled: (each == null ? void 0 : each.line) === 1 || (each == null ? void 0 : each.status) === "ONCALL" || (each == null ? void 0 : each.status) === "DISCONNECTED" || (each == null ? void 0 : each.status) === "CONFERENCE" || (each == null ? void 0 : each.status) === "HOLD" || (each == null ? void 0 : each.status) === "MUTE" || (each == null ? void 0 : each.status) === "DIALING" || (each == null ? void 0 : each.status) === "RINGING",
1304
+ disabled: (each == null ? void 0 : each.line) === 1 || ["ONCALL" /* ONCALL */, "DISCONNECTED" /* DISCONNECTED */, "CONFERENCE" /* CONFERENCE */, "HOLD" /* HOLD */, "MUTE" /* MUTE */, "DIALING" /* DIALING */, "RINGING" /* RINGING */].includes((_f = each == null ? void 0 : each.status) != null ? _f : ""),
1691
1305
  onChange: (e) => {
1692
1306
  onConferenceLineUpdate(each, { phone: e.target.value });
1693
1307
  }
@@ -1700,7 +1314,6 @@ var ConferenceTableRow = ({ each }) => {
1700
1314
  {
1701
1315
  sx: {
1702
1316
  padding: "6px",
1703
- // width: "200px",
1704
1317
  flex: 1
1705
1318
  },
1706
1319
  children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
@@ -1714,20 +1327,20 @@ var ConferenceTableRow = ({ each }) => {
1714
1327
  gap: "10px"
1715
1328
  },
1716
1329
  children: [
1717
- (each == null ? void 0 : each.line) === 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: (each == null ? void 0 : each.status) !== "HOLD" ? "Hold" : "Resume", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1330
+ (each == null ? void 0 : each.line) === 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: (each == null ? void 0 : each.status) !== "HOLD" /* HOLD */ ? "Hold" : "Resume", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1718
1331
  import_material3.Button,
1719
1332
  {
1720
- variant: (each == null ? void 0 : each.status) === "HOLD" ? "contained" : "outlined",
1721
- sx: (each == null ? void 0 : each.status) === "CONFERENCE" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
1333
+ variant: (each == null ? void 0 : each.status) === "HOLD" /* HOLD */ ? "contained" : "outlined",
1334
+ sx: (each == null ? void 0 : each.status) === "CONFERENCE" /* CONFERENCE */ ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
1722
1335
  onClick: () => {
1723
- if (each.status === "HOLD") {
1336
+ if (each.status === "HOLD" /* HOLD */) {
1724
1337
  onHoldOrUnHoldConferenceCall(each, { isHold: false }, "UNHOLDUSER");
1725
1338
  } else {
1726
1339
  onHoldOrUnHoldConferenceCall(each, { isHold: true }, "HOLDUSER");
1727
1340
  }
1728
1341
  },
1729
- disabled: (each == null ? void 0 : each.status) !== "CONFERENCE" && (each == null ? void 0 : each.status) !== "HOLD" || conferenceCallHoldOrUnHold,
1730
- children: each.status === "HOLD" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1342
+ disabled: (each == null ? void 0 : each.status) !== "CONFERENCE" /* CONFERENCE */ && (each == null ? void 0 : each.status) !== "HOLD" /* HOLD */ || conferenceCallHoldOrUnHold,
1343
+ children: each.status === "HOLD" /* HOLD */ ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1731
1344
  import_material3.Box,
1732
1345
  {
1733
1346
  sx: {
@@ -1744,7 +1357,7 @@ var ConferenceTableRow = ({ each }) => {
1744
1357
  variant: "body2",
1745
1358
  sx: {
1746
1359
  fontSize: "12px",
1747
- color: each.status === "HOLD" ? "#fff" : "initial"
1360
+ color: each.status === "HOLD" /* HOLD */ ? "#fff" : "initial"
1748
1361
  },
1749
1362
  children: "Unhold"
1750
1363
  }
@@ -1776,7 +1389,7 @@ var ConferenceTableRow = ({ each }) => {
1776
1389
  {
1777
1390
  variant: "body2",
1778
1391
  sx: {
1779
- color: each.status === "HOLD" ? "#fff" : "#000",
1392
+ color: each.status === "HOLD" /* HOLD */ ? "#fff" : "#000",
1780
1393
  fontSize: "12px"
1781
1394
  },
1782
1395
  children: "Hold"
@@ -1799,9 +1412,9 @@ var ConferenceTableRow = ({ each }) => {
1799
1412
  (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: "Call", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1800
1413
  import_material3.Button,
1801
1414
  {
1802
- variant: (each == null ? void 0 : each.status) !== "IDLE" ? "outlined" : "contained",
1415
+ variant: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ ? "outlined" : "contained",
1803
1416
  color: "success",
1804
- sx: (each == null ? void 0 : each.status) !== "IDLE" ? __spreadValues({}, disabled) : __spreadProps(__spreadValues({}, enabled), {
1417
+ sx: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ ? __spreadValues({}, disabled) : __spreadProps(__spreadValues({}, enabled), {
1805
1418
  border: `0px solid ${theme.palette.success.light}`,
1806
1419
  "&:hover": {
1807
1420
  bgcolor: "success.light",
@@ -1816,7 +1429,7 @@ var ConferenceTableRow = ({ each }) => {
1816
1429
  onClick: () => {
1817
1430
  onConferenceCallStart(each, {});
1818
1431
  },
1819
- disabled: (each == null ? void 0 : each.status) !== "IDLE",
1432
+ disabled: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */,
1820
1433
  children: conferenceCallStart ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1821
1434
  import_material3.CircularProgress,
1822
1435
  {
@@ -1827,7 +1440,7 @@ var ConferenceTableRow = ({ each }) => {
1827
1440
  import_icons_material.Call,
1828
1441
  {
1829
1442
  sx: {
1830
- color: (each == null ? void 0 : each.status) !== "IDLE" ? "default" : "#f3f2f2"
1443
+ color: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ ? "default" : "#f3f2f2"
1831
1444
  }
1832
1445
  }
1833
1446
  )
@@ -1836,34 +1449,30 @@ var ConferenceTableRow = ({ each }) => {
1836
1449
  (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: "Merge Call", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1837
1450
  import_material3.Button,
1838
1451
  {
1839
- variant: (each == null ? void 0 : each.status) === "ONCALL" ? "contained" : "outlined",
1840
- sx: (each == null ? void 0 : each.status) === "ONCALL" ? __spreadValues({}, enabled) : __spreadValues({}, disabled),
1452
+ variant: (each == null ? void 0 : each.status) === "ONCALL" /* ONCALL */ ? "contained" : "outlined",
1453
+ sx: (each == null ? void 0 : each.status) === "ONCALL" /* ONCALL */ ? __spreadValues({}, enabled) : __spreadValues({}, disabled),
1841
1454
  onClick: () => {
1842
1455
  onMergeConferenceCall(each, {
1843
1456
  isMergeCall: true
1844
1457
  });
1845
1458
  },
1846
- disabled: (each == null ? void 0 : each.status) !== "ONCALL",
1459
+ disabled: (each == null ? void 0 : each.status) !== "ONCALL" /* ONCALL */,
1847
1460
  children: conferenceCallMerge ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.CircularProgress, { size: "20px" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.CallSplit, {})
1848
1461
  }
1849
1462
  ) }),
1850
- (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: (each == null ? void 0 : each.status) !== "HOLD" ? "Hold" : "Resume", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1463
+ (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: (each == null ? void 0 : each.status) !== "HOLD" /* HOLD */ ? "Hold" : "Resume", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1851
1464
  import_material3.Button,
1852
1465
  {
1853
- variant: (each == null ? void 0 : each.status) === "HOLD" ? "contained" : "outlined",
1854
- sx: (each == null ? void 0 : each.status) === "CONFERENCE" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
1466
+ variant: (each == null ? void 0 : each.status) === "HOLD" /* HOLD */ ? "contained" : "outlined",
1467
+ sx: (each == null ? void 0 : each.status) === "CONFERENCE" /* CONFERENCE */ ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
1855
1468
  onClick: () => {
1856
- if (each.status === "HOLD") {
1469
+ if (each.status === "HOLD" /* HOLD */) {
1857
1470
  onHoldOrUnHoldConferenceCall(each, { isHold: false }, "UNHOLDUSER");
1858
1471
  } else {
1859
1472
  onHoldOrUnHoldConferenceCall(each, { isHold: true }, "HOLDUSER");
1860
1473
  }
1861
1474
  },
1862
- disabled: (each == null ? void 0 : each.status) !== "CONFERENCE" && (each == null ? void 0 : each.status) !== "HOLD" || // each?.status === "IDLE" ||
1863
- // each?.status === "ONCALL" ||
1864
- // each?.status === "DIALING" ||
1865
- // each?.status === "RINGING" ||
1866
- conferenceCallHoldOrUnHold,
1475
+ disabled: (each == null ? void 0 : each.status) !== "CONFERENCE" /* CONFERENCE */ && (each == null ? void 0 : each.status) !== "HOLD" /* HOLD */ || conferenceCallHoldOrUnHold,
1867
1476
  children: conferenceCallHoldOrUnHold ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1868
1477
  import_material3.CircularProgress,
1869
1478
  {
@@ -1872,15 +1481,15 @@ var ConferenceTableRow = ({ each }) => {
1872
1481
  color: theme.palette.primary.main
1873
1482
  }
1874
1483
  }
1875
- ) : each.status === "HOLD" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.PlayArrow, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Pause, {})
1484
+ ) : each.status === "HOLD" /* HOLD */ ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.PlayArrow, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Pause, {})
1876
1485
  }
1877
1486
  ) }),
1878
1487
  (each == null ? void 0 : each.line) !== 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.Tooltip, { title: "End Call", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1879
1488
  import_material3.Button,
1880
1489
  {
1881
- variant: (each == null ? void 0 : each.status) !== "IDLE" && (each == null ? void 0 : each.status) !== "DISCONNECTED" ? "contained" : "outlined",
1490
+ variant: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ && (each == null ? void 0 : each.status) !== "DISCONNECTED" /* DISCONNECTED */ ? "contained" : "outlined",
1882
1491
  color: "error",
1883
- sx: (each == null ? void 0 : each.status) !== "IDLE" && (each == null ? void 0 : each.status) !== "DISCONNECTED" ? __spreadProps(__spreadValues({}, enabled), {
1492
+ sx: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ && (each == null ? void 0 : each.status) !== "DISCONNECTED" /* DISCONNECTED */ ? __spreadProps(__spreadValues({}, enabled), {
1884
1493
  border: `0px solid ${theme.palette.error.light}`,
1885
1494
  "&:hover": {
1886
1495
  bgcolor: "error.light",
@@ -1900,7 +1509,7 @@ var ConferenceTableRow = ({ each }) => {
1900
1509
  isHold: false
1901
1510
  });
1902
1511
  },
1903
- disabled: (each == null ? void 0 : each.status) === "IDLE" || (each == null ? void 0 : each.status) === "DISCONNECTED" || conferenceCallEnd,
1512
+ disabled: (each == null ? void 0 : each.status) === "IDLE" /* IDLE */ || (each == null ? void 0 : each.status) === "DISCONNECTED" /* DISCONNECTED */ || conferenceCallEnd,
1904
1513
  children: conferenceCallEnd ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1905
1514
  import_material3.CircularProgress,
1906
1515
  {
@@ -1924,7 +1533,7 @@ function ConferenceDialog() {
1924
1533
  var _a2;
1925
1534
  const state = useSDKState();
1926
1535
  const { showToast } = useToast();
1927
- const [conferenceCallEndAll, setConferenceCallEndAll] = (0, import_react10.useState)(false);
1536
+ const [conferenceCallEndAll, setConferenceCallEndAll] = (0, import_react9.useState)(false);
1928
1537
  const handleClose = () => {
1929
1538
  sdkStateManager.setOpenConferenceDialog(false);
1930
1539
  };
@@ -2127,7 +1736,7 @@ function CallTransferDialog({ open }) {
2127
1736
  sdkStateManager.setOpenCallTransferDialog(false);
2128
1737
  }
2129
1738
  });
2130
- const [currentselecteTab, setCurrentselecteTab] = (0, import_react10.useState)("process");
1739
+ const [currentselecteTab, setCurrentselecteTab] = (0, import_react9.useState)("process");
2131
1740
  const [getIdelAgentsList, { data: idleAgentsList, isLoading: isIdleAgentsListLoading }] = usePostRequest({
2132
1741
  disabledSuccessToast: true
2133
1742
  });
@@ -2177,7 +1786,7 @@ function CallTransferDialog({ open }) {
2177
1786
  transferCall(END_POINT.TRANSFER_CALL, payload);
2178
1787
  }
2179
1788
  };
2180
- (0, import_react10.useEffect)(() => {
1789
+ (0, import_react9.useEffect)(() => {
2181
1790
  getIdelAgentsList(END_POINT.AGENTS_LIST, {
2182
1791
  status: "IDLE",
2183
1792
  active: true
@@ -2510,7 +2119,7 @@ function CallTransferDialog({ open }) {
2510
2119
  function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2511
2120
  var _a2, _b, _c, _d, _e;
2512
2121
  const [getDispositions, data] = useGetRequest();
2513
- const [formData, setFormData] = (0, import_react10.useState)({
2122
+ const [formData, setFormData] = (0, import_react9.useState)({
2514
2123
  disposition: { label: "Resolved", value: "RES" },
2515
2124
  followUp: { label: "No", value: "N" },
2516
2125
  callbackDate: "",
@@ -2539,11 +2148,10 @@ function EndCallDispositionDialog({ open, setOpen, onSubmitDisposition }) {
2539
2148
  handleReset();
2540
2149
  setOpen(false);
2541
2150
  };
2542
- (0, import_react10.useEffect)(() => {
2151
+ (0, import_react9.useEffect)(() => {
2543
2152
  getDispositions(END_POINT.DISPOSITIONS);
2544
2153
  }, []);
2545
- console.log("dispositionsData", formData);
2546
- const dispositionsOptions = (0, import_react10.useMemo)(() => {
2154
+ const dispositionsOptions = (0, import_react9.useMemo)(() => {
2547
2155
  var _a3, _b2;
2548
2156
  return ((_b2 = (_a3 = data == null ? void 0 : data.data) == null ? void 0 : _a3.data) == null ? void 0 : _b2.map((item) => ({
2549
2157
  label: item.name,
@@ -2896,6 +2504,147 @@ function CallHistoryDialog({ open, setOpen }) {
2896
2504
  ) });
2897
2505
  }
2898
2506
 
2507
+ // call-control-sdk/lib/hooks/useDraggable.ts
2508
+ var import_react10 = require("react");
2509
+ function useDraggable(initialPosition, onPositionChange) {
2510
+ const [position, setPosition] = (0, import_react10.useState)(initialPosition);
2511
+ const [isDragging, setIsDragging] = (0, import_react10.useState)(false);
2512
+ const dragRef = (0, import_react10.useRef)();
2513
+ const dragStart = (0, import_react10.useRef)({ x: 0, y: 0 });
2514
+ const elementStart = (0, import_react10.useRef)({ x: 0, y: 0 });
2515
+ const updatePosition = (0, import_react10.useCallback)(
2516
+ (newPosition) => {
2517
+ const element = dragRef.current;
2518
+ if (!element) return;
2519
+ const rect = element.getBoundingClientRect();
2520
+ const viewportWidth = window.innerWidth;
2521
+ const viewportHeight = window.innerHeight;
2522
+ const constrainedPosition = {
2523
+ x: Math.max(0, Math.min(newPosition.x, viewportWidth - rect.width)),
2524
+ y: Math.max(0, Math.min(newPosition.y, viewportHeight - rect.height))
2525
+ };
2526
+ setPosition(constrainedPosition);
2527
+ onPositionChange == null ? void 0 : onPositionChange(constrainedPosition);
2528
+ },
2529
+ [onPositionChange]
2530
+ );
2531
+ const handleStart = (0, import_react10.useCallback)(
2532
+ (clientX, clientY) => {
2533
+ setIsDragging(true);
2534
+ dragStart.current = { x: clientX, y: clientY };
2535
+ elementStart.current = position;
2536
+ const handleMove = (moveClientX, moveClientY) => {
2537
+ const deltaX = moveClientX - dragStart.current.x;
2538
+ const deltaY = moveClientY - dragStart.current.y;
2539
+ updatePosition({
2540
+ x: elementStart.current.x + deltaX,
2541
+ y: elementStart.current.y + deltaY
2542
+ });
2543
+ };
2544
+ const handleMouseMove = (e) => {
2545
+ e.preventDefault();
2546
+ handleMove(e.clientX, e.clientY);
2547
+ };
2548
+ const handleTouchMove = (e) => {
2549
+ e.preventDefault();
2550
+ const touch = e.touches[0];
2551
+ if (touch) {
2552
+ handleMove(touch.clientX, touch.clientY);
2553
+ }
2554
+ };
2555
+ const handleEnd = () => {
2556
+ setIsDragging(false);
2557
+ document.removeEventListener("mousemove", handleMouseMove);
2558
+ document.removeEventListener("mouseup", handleEnd);
2559
+ document.removeEventListener("touchmove", handleTouchMove);
2560
+ document.removeEventListener("touchend", handleEnd);
2561
+ };
2562
+ document.addEventListener("mousemove", handleMouseMove);
2563
+ document.addEventListener("mouseup", handleEnd);
2564
+ document.addEventListener("touchmove", handleTouchMove, {
2565
+ passive: false
2566
+ });
2567
+ document.addEventListener("touchend", handleEnd);
2568
+ },
2569
+ [position, updatePosition]
2570
+ );
2571
+ const handleMouseDown = (0, import_react10.useCallback)(
2572
+ (e) => {
2573
+ e.preventDefault();
2574
+ handleStart(e.clientX, e.clientY);
2575
+ },
2576
+ [handleStart]
2577
+ );
2578
+ const handleTouchStart = (0, import_react10.useCallback)(
2579
+ (e) => {
2580
+ e.preventDefault();
2581
+ const touch = e.touches[0];
2582
+ if (touch) {
2583
+ handleStart(touch.clientX, touch.clientY);
2584
+ }
2585
+ },
2586
+ [handleStart]
2587
+ );
2588
+ return {
2589
+ position,
2590
+ isDragging,
2591
+ dragRef,
2592
+ handleMouseDown,
2593
+ handleTouchStart
2594
+ };
2595
+ }
2596
+
2597
+ // call-control-sdk/lib/services/micController.ts
2598
+ function createMicController(constraints = { audio: true }) {
2599
+ let stream = null;
2600
+ let muted = false;
2601
+ async function start() {
2602
+ if (stream) return;
2603
+ stream = await navigator.mediaDevices.getUserMedia(constraints);
2604
+ stream.getAudioTracks().forEach((track) => track.enabled = true);
2605
+ muted = false;
2606
+ }
2607
+ function setEnabled(enabled) {
2608
+ if (!stream) return;
2609
+ stream.getAudioTracks().forEach((track) => track.enabled = enabled);
2610
+ muted = !enabled;
2611
+ }
2612
+ function mute() {
2613
+ setEnabled(false);
2614
+ }
2615
+ function unmute() {
2616
+ setEnabled(true);
2617
+ }
2618
+ function toggleMute() {
2619
+ if (muted) {
2620
+ unmute();
2621
+ } else {
2622
+ mute();
2623
+ }
2624
+ }
2625
+ function stop() {
2626
+ if (!stream) return;
2627
+ stream.getTracks().forEach((t) => t.stop());
2628
+ stream = null;
2629
+ muted = false;
2630
+ }
2631
+ function isMuted() {
2632
+ return muted;
2633
+ }
2634
+ function getStream() {
2635
+ return stream;
2636
+ }
2637
+ return {
2638
+ start,
2639
+ stop,
2640
+ mute,
2641
+ unmute,
2642
+ toggleMute,
2643
+ isMuted,
2644
+ getStream
2645
+ };
2646
+ }
2647
+
2899
2648
  // call-control-sdk/lib/utils/audioLoader.ts
2900
2649
  var import_incoming = __toESM(require("./incoming-4WP3FJI4.mp3"));
2901
2650
  var audioBlobUrl = null;
@@ -2919,7 +2668,7 @@ async function loadAudioAsBlob() {
2919
2668
  audioBlobUrl = URL.createObjectURL(blob);
2920
2669
  return audioBlobUrl;
2921
2670
  } catch (error) {
2922
- console.warn("Could not create blob URL, using direct URL:", error);
2671
+ console.error("Could not create blob URL, using direct URL:", error);
2923
2672
  return import_incoming.default;
2924
2673
  }
2925
2674
  }
@@ -2958,15 +2707,11 @@ async function createAudioElement() {
2958
2707
  };
2959
2708
  let loaded = await tryLoadAudio(audioUrl);
2960
2709
  if (!loaded && audioUrl !== import_incoming.default) {
2961
- console.log("Primary URL failed, trying original import URL:", import_incoming.default);
2962
2710
  loaded = await tryLoadAudio(import_incoming.default);
2963
2711
  if (loaded) {
2964
2712
  audioUrl = import_incoming.default;
2965
2713
  }
2966
2714
  }
2967
- if (!loaded) {
2968
- console.error("Failed to load audio with all methods. URL:", audioUrl);
2969
- }
2970
2715
  return audio;
2971
2716
  }
2972
2717
  function cleanupAudioResources() {
@@ -2977,57 +2722,6 @@ function cleanupAudioResources() {
2977
2722
  audioBuffer = null;
2978
2723
  }
2979
2724
 
2980
- // call-control-sdk/lib/services/micController.ts
2981
- function createMicController(constraints = { audio: true }) {
2982
- let stream = null;
2983
- let muted = false;
2984
- async function start() {
2985
- if (stream) return;
2986
- stream = await navigator.mediaDevices.getUserMedia(constraints);
2987
- stream.getAudioTracks().forEach((track) => track.enabled = true);
2988
- muted = false;
2989
- }
2990
- function setEnabled(enabled) {
2991
- if (!stream) return;
2992
- stream.getAudioTracks().forEach((track) => track.enabled = enabled);
2993
- muted = !enabled;
2994
- }
2995
- function mute() {
2996
- setEnabled(false);
2997
- }
2998
- function unmute() {
2999
- setEnabled(true);
3000
- }
3001
- function toggleMute() {
3002
- if (muted) {
3003
- unmute();
3004
- } else {
3005
- mute();
3006
- }
3007
- }
3008
- function stop() {
3009
- if (!stream) return;
3010
- stream.getTracks().forEach((t) => t.stop());
3011
- stream = null;
3012
- muted = false;
3013
- }
3014
- function isMuted() {
3015
- return muted;
3016
- }
3017
- function getStream() {
3018
- return stream;
3019
- }
3020
- return {
3021
- start,
3022
- stop,
3023
- mute,
3024
- unmute,
3025
- toggleMute,
3026
- isMuted,
3027
- getStream
3028
- };
3029
- }
3030
-
3031
2725
  // call-control-sdk/lib/components/callControls.tsx
3032
2726
  var import_jsx_runtime3 = require("react/jsx-runtime");
3033
2727
  var getCombineConfrenceData = (localState, apiData) => {
@@ -3059,7 +2753,7 @@ var formatDuration = (seconds) => {
3059
2753
  return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
3060
2754
  };
3061
2755
  function CallControls({ onDataChange }) {
3062
- 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, _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;
2756
+ 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;
3063
2757
  const theme = (0, import_material4.useTheme)();
3064
2758
  const state = useSDKState();
3065
2759
  const { showToast } = useToast();
@@ -3078,16 +2772,17 @@ function CallControls({ onDataChange }) {
3078
2772
  const baseReconnectDelay = 2e3;
3079
2773
  const maxReconnectDelay = 3e4;
3080
2774
  const [anchorEl, setAnchorEl] = (0, import_react11.useState)(null);
3081
- const [showIframe, setShowIframe] = (0, import_react11.useState)(true);
3082
2775
  const [statusAnchorEl, setStatusAnchorEl] = (0, import_react11.useState)(null);
3083
2776
  const [dialerAnchorEl, setDialerAnchorEl] = (0, import_react11.useState)(null);
3084
2777
  const [ambulanceAnchorEl, setAmbulanceAnchorEl] = (0, import_react11.useState)(null);
2778
+ const [showIframe, setShowIframe] = (0, import_react11.useState)(true);
3085
2779
  const [openCallDisposition, setOpenCallDisposition] = (0, import_react11.useState)(false);
3086
2780
  const [openProcessorDialog, setOpenProcessorDialog] = (0, import_react11.useState)(false);
3087
2781
  const [openCallHistoryDialog, setOpenCallHistoryDialog] = (0, import_react11.useState)(false);
3088
2782
  const [processList, setProcessList] = (0, import_react11.useState)(null);
3089
2783
  const [phoneNumber, setPhoneNumber] = (0, import_react11.useState)("");
3090
2784
  const [callDuration, setCallDuration] = (0, import_react11.useState)(0);
2785
+ const [callWrapuptime, setCallWrapuptime] = (0, import_react11.useState)(null);
3091
2786
  const { position, isDragging, dragRef, handleMouseDown, handleTouchStart } = useDraggable(
3092
2787
  state.controlPanelPosition,
3093
2788
  (newPosition) => sdkStateManager.setControlPanelPosition(newPosition)
@@ -3109,26 +2804,22 @@ function CallControls({ onDataChange }) {
3109
2804
  }
3110
2805
  });
3111
2806
  const [holdOrUnHold, { isLoading: holdOrUnHoldLoading }] = usePostRequest({
3112
- onSuccess: () => {
3113
- sdkStateManager.setHolding(!state.isHolding);
3114
- },
3115
- onError: (error) => {
3116
- console.log("\u274C Hold operation error:", error);
3117
- }
2807
+ // onSuccess: () => {
2808
+ // sdkStateManager.setHolding(!state.isHolding);
2809
+ // },
3118
2810
  });
3119
2811
  const [muteOrUnMute, { isLoading: muteOrUnMuteLoading }] = usePostRequest({
3120
- onSuccess: () => {
3121
- sdkStateManager.setMuted(!state.isMuted);
3122
- },
3123
- onError: (error) => {
3124
- console.log("\u274C Mute operation error:", error);
3125
- }
2812
+ // onSuccess: () => {
2813
+ // sdkStateManager.setMuted(!state.isMuted);
2814
+ // },
3126
2815
  });
3127
2816
  const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest();
3128
2817
  const [updateAgentStatus, { isLoading }] = usePostRequest();
3129
2818
  const [sendNotification] = usePostRequest();
3130
2819
  const [endCall, { isLoading: endCallLoading }] = usePostRequest({
3131
2820
  onSuccess: () => {
2821
+ sdkStateManager.endCall();
2822
+ setOpenCallDisposition(false);
3132
2823
  sdkStateManager.resetConferenceLines();
3133
2824
  }
3134
2825
  });
@@ -3138,15 +2829,11 @@ function CallControls({ onDataChange }) {
3138
2829
  const handleOpenDialer = (event) => {
3139
2830
  setShowIframe(true);
3140
2831
  setDialerAnchorEl(event.currentTarget);
3141
- sdkStateManager.setStatus("dial");
3142
2832
  };
3143
2833
  const handleOpenAbulanceServices = (event) => {
3144
2834
  setAmbulanceAnchorEl(event.currentTarget);
3145
2835
  };
3146
2836
  const handleCloseDialer = () => {
3147
- if (state.status !== "on call") {
3148
- sdkStateManager.setStatus("idle");
3149
- }
3150
2837
  setDialerAnchorEl(null);
3151
2838
  };
3152
2839
  const handleCloseAmbulance = () => {
@@ -3191,7 +2878,7 @@ function CallControls({ onDataChange }) {
3191
2878
  const handleHoldToggle = () => {
3192
2879
  var _a3;
3193
2880
  const payload = {
3194
- action: ((_a3 = state.callData) == null ? void 0 : _a3.hold) === 1 ? "UNHOLD" : "HOLD",
2881
+ action: ((_a3 = state.callData) == null ? void 0 : _a3.hold) === 1 ? "UNHOLD" /* UNHOLD */ : "HOLD" /* HOLD */,
3195
2882
  userId: state.agentId
3196
2883
  };
3197
2884
  holdOrUnHold(END_POINT.HOLD_CALL, payload);
@@ -3199,7 +2886,7 @@ function CallControls({ onDataChange }) {
3199
2886
  const handleMuteToggle = () => {
3200
2887
  var _a3;
3201
2888
  const payload = {
3202
- action: ((_a3 = state.callData) == null ? void 0 : _a3.mute) === 1 ? "UNMUTE" : "MUTE",
2889
+ action: ((_a3 = state.callData) == null ? void 0 : _a3.mute) === 1 ? "UNMUTE" /* UNMUTE */ : "MUTE" /* MUTE */,
3203
2890
  userId: state.agentId
3204
2891
  };
3205
2892
  muteOrUnMute(END_POINT.MUTE_CALL, payload);
@@ -3226,8 +2913,6 @@ function CallControls({ onDataChange }) {
3226
2913
  isBreak: (_q2 = data == null ? void 0 : data.selected_break) != null ? _q2 : false
3227
2914
  }
3228
2915
  });
3229
- sdkStateManager.endCall();
3230
- setOpenCallDisposition(false);
3231
2916
  };
3232
2917
  (0, import_react11.useEffect)(() => {
3233
2918
  const handleBeforeUnload = (e) => {
@@ -3248,14 +2933,14 @@ function CallControls({ onDataChange }) {
3248
2933
  var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
3249
2934
  const fullState = JSON.parse((_a3 = localStorage.getItem("call-control-sdk-state")) != null ? _a3 : "");
3250
2935
  const key = (_b2 = event.key) == null ? void 0 : _b2.toLowerCase();
3251
- if (!event.altKey || ((_c2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _c2.status) !== "ONCALL") {
2936
+ if (!event.altKey || ((_c2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _c2.status) !== "ONCALL" /* ONCALL */) {
3252
2937
  return;
3253
2938
  }
3254
2939
  if (key === "m" && String((_d2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _d2.mute) === "0") {
3255
2940
  event.preventDefault();
3256
2941
  (_e2 = micRef.current) == null ? void 0 : _e2.mute();
3257
2942
  const payload = {
3258
- action: "MUTE",
2943
+ action: "MUTE" /* MUTE */,
3259
2944
  userId: fullState.agentId
3260
2945
  };
3261
2946
  muteOrUnMute(END_POINT.MUTE_CALL, payload);
@@ -3263,7 +2948,7 @@ function CallControls({ onDataChange }) {
3263
2948
  if (key === "u" && String((_f2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _f2.mute) === "1") {
3264
2949
  event.preventDefault();
3265
2950
  const payload = {
3266
- action: "UNMUTE",
2951
+ action: "UNMUTE" /* UNMUTE */,
3267
2952
  userId: fullState.agentId
3268
2953
  };
3269
2954
  muteOrUnMute(END_POINT.MUTE_CALL, payload);
@@ -3272,7 +2957,7 @@ function CallControls({ onDataChange }) {
3272
2957
  if (key === "h" && String((_h2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _h2.hold) === "0") {
3273
2958
  event.preventDefault();
3274
2959
  const payload = {
3275
- action: "HOLD",
2960
+ action: "HOLD" /* HOLD */,
3276
2961
  userId: fullState.agentId
3277
2962
  };
3278
2963
  holdOrUnHold(END_POINT.HOLD_CALL, payload);
@@ -3280,7 +2965,7 @@ function CallControls({ onDataChange }) {
3280
2965
  if (key === "r" && String((_i2 = fullState == null ? void 0 : fullState.callData) == null ? void 0 : _i2.hold) === "1") {
3281
2966
  event.preventDefault();
3282
2967
  const payload = {
3283
- action: "UNHOLD",
2968
+ action: "UNHOLD" /* UNHOLD */,
3284
2969
  userId: fullState.agentId
3285
2970
  };
3286
2971
  holdOrUnHold(END_POINT.HOLD_CALL, payload);
@@ -3293,7 +2978,8 @@ function CallControls({ onDataChange }) {
3293
2978
  }, []);
3294
2979
  (0, import_react11.useEffect)(() => {
3295
2980
  let interval;
3296
- if (state.callData.status && state.callData.status === "ONCALL") {
2981
+ let wrapUpinterval;
2982
+ if (state.callData.status && state.callData.status === "ONCALL" /* ONCALL */) {
3297
2983
  interval = setInterval(() => {
3298
2984
  const elapsed = Math.floor((Date.now() - state.callStartTime) / 1e3);
3299
2985
  setCallDuration(elapsed);
@@ -3301,8 +2987,28 @@ function CallControls({ onDataChange }) {
3301
2987
  } else {
3302
2988
  setCallDuration(0);
3303
2989
  }
2990
+ if (state.callData.status && state.callData.status === "WRAPUP" /* WRAPUP */ && callWrapuptime !== null) {
2991
+ wrapUpinterval = setInterval(() => {
2992
+ setCallWrapuptime((prevTime) => {
2993
+ if (prevTime === null || prevTime <= 1) {
2994
+ clearInterval(wrapUpinterval);
2995
+ handleEndCall({
2996
+ disposition: { label: "Resolved", value: "RES" },
2997
+ followUp: { label: "No", value: "N" },
2998
+ callbackDate: "",
2999
+ callbackHrs: "",
3000
+ callbackMins: "",
3001
+ selected_break: false
3002
+ });
3003
+ return null;
3004
+ }
3005
+ return prevTime - 1;
3006
+ });
3007
+ }, 1e3);
3008
+ }
3304
3009
  return () => {
3305
3010
  if (interval) clearInterval(interval);
3011
+ if (wrapUpinterval) clearInterval(wrapUpinterval);
3306
3012
  };
3307
3013
  }, [state.callData.status]);
3308
3014
  (0, import_react11.useEffect)(() => {
@@ -3353,13 +3059,10 @@ function CallControls({ onDataChange }) {
3353
3059
  }).catch((err) => {
3354
3060
  showToast(err.response.data.message, "error");
3355
3061
  });
3356
- } else {
3357
- console.log("No agentId available, skipping API call");
3358
3062
  }
3359
3063
  }, [state.agentId]);
3360
3064
  const connectWebSocket = () => {
3361
3065
  if (!state.agentId) {
3362
- console.log("No agentId available, cannot connect WebSocket");
3363
3066
  return;
3364
3067
  }
3365
3068
  if (reconnectTimeoutRef.current) {
@@ -3378,7 +3081,6 @@ function CallControls({ onDataChange }) {
3378
3081
  if (webSocketRef.current && webSocketRef.current.readyState === WebSocket.OPEN) {
3379
3082
  try {
3380
3083
  webSocketRef.current.send(JSON.stringify({ type: "ping" }));
3381
- console.log("\u{1F4E1} WebSocket ping sent");
3382
3084
  } catch (error) {
3383
3085
  console.error("Failed to send ping:", error);
3384
3086
  }
@@ -3386,71 +3088,88 @@ function CallControls({ onDataChange }) {
3386
3088
  }, 3e4);
3387
3089
  };
3388
3090
  webSocketRef.current.onmessage = (event) => {
3091
+ var _a3, _b2, _c2;
3389
3092
  try {
3390
3093
  const data = JSON.parse(event.data);
3391
3094
  if (data.type === "pong") {
3392
- console.log("\u{1F4E1} WebSocket pong received");
3393
3095
  return;
3394
3096
  }
3395
- const rls = localStorage.getItem("call-control-sdk-state");
3396
- const confrence = getCombineConfrenceData(JSON.parse(rls || "{}"), data);
3397
- sdkStateManager.updateCallData(data);
3097
+ const sdkState = JSON.parse((_a3 = localStorage.getItem(STORAGE_KEY)) != null ? _a3 : "{}");
3098
+ const confrence = getCombineConfrenceData(sdkState, data);
3099
+ const callData = {
3100
+ "agent_id": data == null ? void 0 : data.agent_id,
3101
+ "status": data == null ? void 0 : data.status,
3102
+ "type": data == null ? void 0 : data.type,
3103
+ "event_time": data == null ? void 0 : data.event_time,
3104
+ "phone_number": data == null ? void 0 : data.phone_number,
3105
+ "convox_id": data == null ? void 0 : data.convox_id,
3106
+ "process_id": data == null ? void 0 : data.process_id,
3107
+ "process_name": data == null ? void 0 : data.process_name,
3108
+ "hold": data == null ? void 0 : data.hold,
3109
+ "mute": data == null ? void 0 : data.mute,
3110
+ "mode": data == null ? void 0 : data.mode,
3111
+ "queue_name": data == null ? void 0 : data.queue_name
3112
+ };
3113
+ sdkStateManager.updateCallData(callData);
3398
3114
  sdkStateManager.updateConferenceData([...confrence]);
3399
- if ((data.status === "RINGING" || data.status === "DIALING") && (data == null ? void 0 : data.mode) !== "manual") {
3115
+ if (["RINGING" /* RINGING */, "DIALING" /* DIALING */].includes(data.status)) {
3400
3116
  setShowIframe(true);
3401
- sdkStateManager.updateConferenceData([
3402
- {
3403
- line: 1,
3404
- status: "IDLE",
3405
- type: "",
3406
- phone: "",
3407
- isMute: false,
3408
- isHold: false,
3409
- isCallStart: false,
3410
- isMergeCall: false
3411
- },
3412
- {
3413
- line: 2,
3414
- status: "IDLE",
3415
- type: "",
3416
- phone: "",
3417
- isMute: false,
3418
- isHold: false,
3419
- isCallStart: false,
3420
- isMergeCall: false
3421
- },
3422
- {
3423
- line: 3,
3424
- status: "IDLE",
3425
- type: "",
3426
- phone: "",
3427
- isMute: false,
3428
- isHold: false,
3429
- isCallStart: false,
3430
- isMergeCall: false
3431
- },
3432
- {
3433
- line: 4,
3434
- status: "IDLE",
3435
- type: "",
3436
- phone: "",
3437
- isMute: false,
3438
- isHold: false,
3439
- isCallStart: false,
3440
- isMergeCall: false
3441
- },
3442
- {
3443
- line: 5,
3444
- status: "IDLE",
3445
- type: "",
3446
- phone: "",
3447
- isMute: false,
3448
- isHold: false,
3449
- isCallStart: false,
3450
- isMergeCall: false
3451
- }
3452
- ]);
3453
- if (audioRef.current) {
3117
+ setCallWrapuptime((_c2 = (_b2 = sdkState == null ? void 0 : sdkState.sdkConfig) == null ? void 0 : _b2.auto_wrapup_time) != null ? _c2 : null);
3118
+ sdkStateManager.updateConferenceData(
3119
+ [
3120
+ {
3121
+ line: 1,
3122
+ status: "IDLE",
3123
+ type: "",
3124
+ phone: "",
3125
+ isMute: false,
3126
+ isHold: false,
3127
+ isCallStart: false,
3128
+ isMergeCall: false
3129
+ },
3130
+ {
3131
+ line: 2,
3132
+ status: "IDLE",
3133
+ type: "",
3134
+ phone: "",
3135
+ isMute: false,
3136
+ isHold: false,
3137
+ isCallStart: false,
3138
+ isMergeCall: false
3139
+ },
3140
+ {
3141
+ line: 3,
3142
+ status: "IDLE",
3143
+ type: "",
3144
+ phone: "",
3145
+ isMute: false,
3146
+ isHold: false,
3147
+ isCallStart: false,
3148
+ isMergeCall: false
3149
+ },
3150
+ {
3151
+ line: 4,
3152
+ status: "IDLE",
3153
+ type: "",
3154
+ phone: "",
3155
+ isMute: false,
3156
+ isHold: false,
3157
+ isCallStart: false,
3158
+ isMergeCall: false
3159
+ },
3160
+ {
3161
+ line: 5,
3162
+ status: "IDLE",
3163
+ type: "",
3164
+ phone: "",
3165
+ isMute: false,
3166
+ isHold: false,
3167
+ isCallStart: false,
3168
+ isMergeCall: false
3169
+ }
3170
+ ]
3171
+ );
3172
+ if ((data == null ? void 0 : data.mode) !== "manual" && audioRef.current) {
3454
3173
  audioRef.current.play().catch((error) => {
3455
3174
  console.error("Failed to play ringtone:", error);
3456
3175
  });
@@ -3461,21 +3180,20 @@ function CallControls({ onDataChange }) {
3461
3180
  audioRef.current.currentTime = 0;
3462
3181
  }
3463
3182
  }
3464
- if (data.status === "ONCALL") {
3183
+ if (data.status === "ONCALL" /* ONCALL */) {
3465
3184
  sdkStateManager.startCall();
3466
3185
  if (!showIframe) {
3467
3186
  setShowIframe(true);
3468
3187
  }
3469
3188
  }
3470
- if (data.status === "WRAPUP") {
3189
+ if (data.status === "WRAPUP" /* WRAPUP */) {
3471
3190
  sdkStateManager.endCall();
3472
3191
  }
3473
3192
  } catch (e) {
3474
- console.log("\u{1F4E8} Raw message:", event.data);
3193
+ console.error("\u{1F4E8} Raw message:", event.data);
3475
3194
  }
3476
3195
  };
3477
3196
  webSocketRef.current.onclose = (event) => {
3478
- console.log("\u{1F50C} WebSocket connection closed", event.code, event.reason);
3479
3197
  if (pingIntervalRef.current) {
3480
3198
  clearInterval(pingIntervalRef.current);
3481
3199
  pingIntervalRef.current = null;
@@ -3486,14 +3204,13 @@ function CallControls({ onDataChange }) {
3486
3204
  baseReconnectDelay * Math.pow(2, reconnectAttemptsRef.current - 1),
3487
3205
  maxReconnectDelay
3488
3206
  );
3489
- console.log(
3207
+ console.warn(
3490
3208
  `\u{1F504} Attempting to reconnect WebSocket (attempt ${reconnectAttemptsRef.current}/${maxReconnectAttempts}) in ${delay}ms`
3491
3209
  );
3492
3210
  reconnectTimeoutRef.current = setTimeout(() => {
3493
3211
  connectWebSocket();
3494
3212
  }, delay);
3495
3213
  } else if (reconnectAttemptsRef.current >= maxReconnectAttempts) {
3496
- console.error("\u274C Maximum reconnection attempts reached. Please refresh the page.");
3497
3214
  showToast("WebSocket connection failed. Please refresh the page.", "error");
3498
3215
  }
3499
3216
  };
@@ -3501,7 +3218,6 @@ function CallControls({ onDataChange }) {
3501
3218
  console.error("\u274C WebSocket error:", error);
3502
3219
  };
3503
3220
  } catch (error) {
3504
- console.error("\u274C Failed to create WebSocket:", error);
3505
3221
  if (reconnectAttemptsRef.current < maxReconnectAttempts) {
3506
3222
  reconnectAttemptsRef.current += 1;
3507
3223
  const delay = Math.min(
@@ -3617,32 +3333,29 @@ function CallControls({ onDataChange }) {
3617
3333
  }
3618
3334
  ),
3619
3335
  ((_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__ */ (0, import_jsx_runtime3.jsx)(import_material4.Chip, { label: (_n = state == null ? void 0 : state.callData) == null ? void 0 : _n.queue_name }),
3620
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: !((_o = state.sdkConfig) == null ? void 0 : _o.disabledDialButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Dial", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3336
+ !((_o = state.sdkConfig) == null ? void 0 : _o.disabledDialButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Dial", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3621
3337
  import_material4.IconButton,
3622
3338
  {
3623
3339
  size: "small",
3624
3340
  onClick: (e) => {
3625
- var _a3, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
3626
- if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) !== "ONCALL" && ((_d2 = (_c2 = state.callData) == null ? void 0 : _c2.status) == null ? void 0 : _d2.toUpperCase()) !== "BREAK" && ((_f2 = (_e2 = state.callData) == null ? void 0 : _e2.status) == null ? void 0 : _f2.toUpperCase()) !== "RINGING" && ((_h2 = (_g2 = state.callData) == null ? void 0 : _g2.status) == null ? void 0 : _h2.toUpperCase()) !== "WRAPUP") {
3341
+ var _a3, _b2;
3342
+ if (!["BREAK" /* BREAK */, "ONCALL" /* ONCALL */, "RINGING" /* RINGING */, "WRAPUP" /* WRAPUP */].includes(
3343
+ (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()
3344
+ )) {
3627
3345
  handleOpenDialer(e);
3628
3346
  }
3629
3347
  },
3630
- sx: {
3631
- bgcolor: "action.hover",
3632
- "&:hover": {
3633
- bgcolor: "warning"
3634
- }
3635
- },
3348
+ disabled: ["BREAK" /* BREAK */, "ONCALL" /* ONCALL */, "RINGING" /* RINGING */, "WRAPUP" /* WRAPUP */].includes(state.callData.status.toUpperCase()),
3636
3349
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3637
3350
  import_icons_material2.WifiCalling3,
3638
3351
  {
3639
3352
  sx: {
3640
- color: ((_q = (_p = state.callData) == null ? void 0 : _p.status) == null ? void 0 : _q.toUpperCase()) === "ONCALL" || ((_s = (_r = state.callData) == null ? void 0 : _r.status) == null ? void 0 : _s.toUpperCase()) === "BREAK" || ((_u = (_t = state.callData) == null ? void 0 : _t.status) == null ? void 0 : _u.toUpperCase()) === "RINGING" || ((_w = (_v = state.callData) == null ? void 0 : _v.status) == null ? void 0 : _w.toUpperCase()) === "WRAPUP" ? "action.selected" : "success.main"
3353
+ color: ["BREAK" /* BREAK */, "ONCALL" /* ONCALL */, "RINGING" /* RINGING */, "WRAPUP" /* WRAPUP */].includes(state.callData.status.toUpperCase()) ? "action.selected" : "success.main"
3641
3354
  }
3642
3355
  }
3643
3356
  )
3644
3357
  }
3645
- ) }) }),
3358
+ ) }),
3646
3359
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { onClick: () => setShowIframe(true), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3647
3360
  import_material4.Typography,
3648
3361
  {
@@ -3654,7 +3367,7 @@ function CallControls({ onDataChange }) {
3654
3367
  fontWeight: "600",
3655
3368
  cursor: "pointer"
3656
3369
  },
3657
- children: formatDuration(callDuration)
3370
+ children: state.callData.status === "WRAPUP" /* WRAPUP */ && callWrapuptime !== null ? formatDuration(callWrapuptime) : formatDuration(callDuration)
3658
3371
  }
3659
3372
  ) }),
3660
3373
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -3684,7 +3397,7 @@ function CallControls({ onDataChange }) {
3684
3397
  width: "60px",
3685
3398
  textAlign: "center"
3686
3399
  },
3687
- children: (_z = (_y = (_x = state.callData) == null ? void 0 : _x.status) == null ? void 0 : _y.toUpperCase()) != null ? _z : "N/A"
3400
+ children: (_r = (_q = (_p = state.callData) == null ? void 0 : _p.status) == null ? void 0 : _q.toUpperCase()) != null ? _r : "N/A"
3688
3401
  }
3689
3402
  ),
3690
3403
  onClick: handleOpenAgentStatus,
@@ -3708,32 +3421,32 @@ function CallControls({ onDataChange }) {
3708
3421
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Agent Ready", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3709
3422
  import_material4.Button,
3710
3423
  {
3711
- variant: ((_B = (_A = state.callData) == null ? void 0 : _A.status) == null ? void 0 : _B.toUpperCase()) === "BREAK" || ((_D = (_C = state.callData) == null ? void 0 : _C.status) == null ? void 0 : _D.toUpperCase()) === "MISSED" ? "outlined" : "contained",
3424
+ variant: ["BREAK" /* BREAK */, "MISSED" /* MISSED */].includes((_t = (_s = state.callData) == null ? void 0 : _s.status) == null ? void 0 : _t.toUpperCase()) ? "outlined" : "contained",
3712
3425
  onClick: (e) => {
3713
- var _a3, _b2, _c2, _d2;
3714
- if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "BREAK" || ((_d2 = (_c2 = state.callData) == null ? void 0 : _c2.status) == null ? void 0 : _d2.toUpperCase()) === "MISSED") {
3426
+ var _a3, _b2;
3427
+ if (["BREAK" /* BREAK */, "MISSED" /* MISSED */].includes((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase())) {
3715
3428
  e.stopPropagation();
3716
3429
  handleAgentReady();
3717
3430
  }
3718
3431
  },
3719
3432
  classes: {
3720
- root: ((_F = (_E = state.callData) == null ? void 0 : _E.status) == null ? void 0 : _F.toUpperCase()) === "BREAK" || ((_H = (_G = state.callData) == null ? void 0 : _G.status) == null ? void 0 : _H.toUpperCase()) === "MISSED" ? "outlined" : "enabled"
3433
+ root: ["BREAK" /* BREAK */, "MISSED" /* MISSED */].includes((_v = (_u = state.callData) == null ? void 0 : _u.status) == null ? void 0 : _v.toUpperCase()) ? "outlined" : "enabled"
3721
3434
  },
3722
- sx: __spreadValues({}, ((_J = (_I = state.callData) == null ? void 0 : _I.status) == null ? void 0 : _J.toUpperCase()) === "BREAK" || ((_L = (_K = state.callData) == null ? void 0 : _K.status) == null ? void 0 : _L.toUpperCase()) === "MISSED" ? outlined : enabled),
3435
+ sx: __spreadValues({}, ["BREAK" /* BREAK */, "MISSED" /* MISSED */].includes((_x = (_w = state.callData) == null ? void 0 : _w.status) == null ? void 0 : _x.toUpperCase()) ? outlined : enabled),
3723
3436
  disabled: agentReadyLoading,
3724
3437
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.SupportAgent, {})
3725
3438
  }
3726
3439
  ) }),
3727
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: ((_M = state.callData) == null ? void 0 : _M.hold) === 1 ? "Resume" : "Hold", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3440
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: ((_y = state.callData) == null ? void 0 : _y.hold) === 1 ? "Resume" : "Hold", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3728
3441
  import_material4.Button,
3729
3442
  {
3730
- variant: ((_N = state.callData) == null ? void 0 : _N.hold) === 1 && ((_P = (_O = state.callData) == null ? void 0 : _O.status) == null ? void 0 : _P.toUpperCase()) === "ONCALL" ? "contained" : "outlined",
3443
+ 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",
3731
3444
  onClick: (e) => {
3732
3445
  e.stopPropagation();
3733
3446
  handleHoldToggle();
3734
3447
  },
3735
- sx: ((_Q = state.callData) == null ? void 0 : _Q.hold) === 1 && ((_S = (_R = state.callData) == null ? void 0 : _R.status) == null ? void 0 : _S.toUpperCase()) === "ONCALL" ? __spreadValues({}, enabled) : ((_U = (_T = state.callData) == null ? void 0 : _T.status) == null ? void 0 : _U.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3736
- disabled: ((_W = (_V = state.callData) == null ? void 0 : _V.status) == null ? void 0 : _W.toUpperCase()) !== "ONCALL" && ((_X = state.callData) == null ? void 0 : _X.hold) !== 1 || holdOrUnHoldLoading,
3448
+ 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),
3449
+ 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,
3737
3450
  children: holdOrUnHoldLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3738
3451
  import_material4.CircularProgress,
3739
3452
  {
@@ -3742,19 +3455,19 @@ function CallControls({ onDataChange }) {
3742
3455
  color: theme.palette.primary.main
3743
3456
  }
3744
3457
  }
3745
- ) : ((_Y = state.callData) == null ? void 0 : _Y.hold) === 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.PlayArrow, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Pause, {})
3458
+ ) : ((_K = state.callData) == null ? void 0 : _K.hold) === 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.PlayArrow, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Pause, {})
3746
3459
  }
3747
3460
  ) }),
3748
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: ((_Z = state.callData) == null ? void 0 : _Z.mute) === 1 ? "Unmute" : "Mute", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3461
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: ((_L = state.callData) == null ? void 0 : _L.mute) === 1 ? "Unmute" : "Mute", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3749
3462
  import_material4.Button,
3750
3463
  {
3751
- variant: ((__ = state.callData) == null ? void 0 : __.mute) === 1 && ((_aa = (_$ = state.callData) == null ? void 0 : _$.status) == null ? void 0 : _aa.toUpperCase()) === "ONCALL" ? "contained" : "outlined",
3464
+ 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",
3752
3465
  onClick: (e) => {
3753
3466
  e.stopPropagation();
3754
3467
  handleMuteToggle();
3755
3468
  },
3756
- sx: ((_ba = state.callData) == null ? void 0 : _ba.hold) === 1 ? __spreadValues({}, disabled) : ((_ca = state.callData) == null ? void 0 : _ca.mute) === 1 && ((_ea = (_da = state.callData) == null ? void 0 : _da.status) == null ? void 0 : _ea.toUpperCase()) === "ONCALL" ? __spreadValues({}, enabled) : ((_ga = (_fa = state.callData) == null ? void 0 : _fa.status) == null ? void 0 : _ga.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3757
- disabled: ((_ia = (_ha = state.callData) == null ? void 0 : _ha.status) == null ? void 0 : _ia.toUpperCase()) !== "ONCALL" && ((_ja = state.callData) == null ? void 0 : _ja.mute) !== 1 || muteOrUnMuteLoading || ((_ka = state.callData) == null ? void 0 : _ka.hold) === 1,
3469
+ 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),
3470
+ 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,
3758
3471
  children: muteOrUnMuteLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3759
3472
  import_material4.CircularProgress,
3760
3473
  {
@@ -3763,69 +3476,93 @@ function CallControls({ onDataChange }) {
3763
3476
  color: theme.palette.primary.main
3764
3477
  }
3765
3478
  }
3766
- ) : ((_la = state.callData) == null ? void 0 : _la.mute) === 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.MicOff, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Mic, {})
3479
+ ) : ((_Z = state.callData) == null ? void 0 : _Z.mute) === 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.MicOff, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Mic, {})
3767
3480
  }
3768
3481
  ) }),
3769
- !((_ma = state.sdkConfig) == null ? void 0 : _ma.disableCallTransferButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Transfer Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3482
+ !((__ = state.sdkConfig) == null ? void 0 : __.disableCallTransferButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Transfer Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3770
3483
  import_material4.Button,
3771
3484
  {
3772
3485
  variant: state.openCallTransferDialog ? "contained" : "outlined",
3773
3486
  onClick: (e) => {
3774
3487
  var _a3, _b2;
3775
- if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL") {
3488
+ if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL" /* ONCALL */) {
3776
3489
  e.stopPropagation();
3777
3490
  sdkStateManager.setOpenCallTransferDialog(true);
3778
3491
  }
3779
3492
  },
3780
- sx: state.openCallTransferDialog ? __spreadValues({}, enabled) : ((_oa = (_na = state.callData) == null ? void 0 : _na.status) == null ? void 0 : _oa.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3781
- disabled: ((_qa = (_pa = state.callData) == null ? void 0 : _pa.status) == null ? void 0 : _qa.toUpperCase()) !== "ONCALL",
3493
+ sx: state.openCallTransferDialog ? __spreadValues({}, enabled) : ((_aa = (_$ = state.callData) == null ? void 0 : _$.status) == null ? void 0 : _aa.toUpperCase()) === "ONCALL" /* ONCALL */ ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3494
+ disabled: ((_ca = (_ba = state.callData) == null ? void 0 : _ba.status) == null ? void 0 : _ca.toUpperCase()) !== "ONCALL" /* ONCALL */,
3782
3495
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.TransferWithinAStation, {})
3783
3496
  }
3784
3497
  ) }),
3785
- !((_ra = state.sdkConfig) == null ? void 0 : _ra.disableConferenceButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Conference Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3498
+ !((_da = state.sdkConfig) == null ? void 0 : _da.disableConferenceButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Conference Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3786
3499
  import_material4.Button,
3787
3500
  {
3788
3501
  variant: state.openConferenceDialog ? "contained" : "outlined",
3789
3502
  onClick: (e) => {
3790
3503
  var _a3, _b2;
3791
- if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL") {
3504
+ if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL" /* ONCALL */) {
3792
3505
  e.stopPropagation();
3793
3506
  sdkStateManager.setOpenConferenceDialog(true);
3794
3507
  }
3795
3508
  },
3796
- sx: state.openConferenceDialog ? __spreadValues({}, enabled) : ((_ta = (_sa = state.callData) == null ? void 0 : _sa.status) == null ? void 0 : _ta.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3797
- disabled: ((_va = (_ua = state.callData) == null ? void 0 : _ua.status) == null ? void 0 : _va.toUpperCase()) !== "ONCALL",
3509
+ 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),
3510
+ disabled: ((_ha = (_ga = state.callData) == null ? void 0 : _ga.status) == null ? void 0 : _ha.toUpperCase()) !== "ONCALL" /* ONCALL */,
3798
3511
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.Group, {})
3799
3512
  }
3800
3513
  ) }),
3801
- ((_wa = state.sdkConfig) == null ? void 0 : _wa.enableSmsServices) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Send SMS", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3514
+ ((_ia = state.sdkConfig) == null ? void 0 : _ia.enableSmsServices) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Send SMS", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3802
3515
  import_material4.Button,
3803
3516
  {
3804
3517
  variant: Boolean(ambulanceAnchorEl) ? "contained" : "outlined",
3805
3518
  onClick: (e) => {
3806
- var _a3, _b2, _c2, _d2;
3807
- if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL" || ((_d2 = (_c2 = state.callData) == null ? void 0 : _c2.status) == null ? void 0 : _d2.toUpperCase()) === "WRAPUP") {
3519
+ var _a3, _b2;
3520
+ if ([
3521
+ "ONCALL" /* ONCALL */,
3522
+ "WRAPUP" /* WRAPUP */
3523
+ ].includes((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase())) {
3808
3524
  e.stopPropagation();
3809
3525
  handleOpenAbulanceServices(e);
3810
3526
  }
3811
3527
  },
3812
- sx: Boolean(ambulanceAnchorEl) ? __spreadValues({}, enabled) : ((_ya = (_xa = state.callData) == null ? void 0 : _xa.status) == null ? void 0 : _ya.toUpperCase()) === "ONCALL" || ((_Aa = (_za = state.callData) == null ? void 0 : _za.status) == null ? void 0 : _Aa.toUpperCase()) === "WRAPUP" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3813
- disabled: ((_Ca = (_Ba = state.callData) == null ? void 0 : _Ba.status) == null ? void 0 : _Ca.toUpperCase()) !== "ONCALL" && ((_Ea = (_Da = state.callData) == null ? void 0 : _Da.status) == null ? void 0 : _Ea.toUpperCase()) !== "WRAPUP",
3528
+ sx: Boolean(ambulanceAnchorEl) ? __spreadValues({}, enabled) : [
3529
+ "ONCALL" /* ONCALL */,
3530
+ "WRAPUP" /* WRAPUP */
3531
+ ].includes((_ka = (_ja = state.callData) == null ? void 0 : _ja.status) == null ? void 0 : _ka.toUpperCase()) ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
3532
+ disabled: ![
3533
+ "ONCALL" /* ONCALL */,
3534
+ "WRAPUP" /* WRAPUP */
3535
+ ].includes((_ma = (_la = state.callData) == null ? void 0 : _la.status) == null ? void 0 : _ma.toUpperCase()),
3814
3536
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.SmsSharp, {})
3815
3537
  }
3816
3538
  ) }),
3817
- !((_Fa = state.sdkConfig) == null ? void 0 : _Fa.disableEndCallButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "End Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3539
+ !((_na = state.sdkConfig) == null ? void 0 : _na.disableEndCallButton) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "End Call", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3818
3540
  import_material4.Button,
3819
3541
  {
3820
- variant: ((_Ha = (_Ga = state.callData) == null ? void 0 : _Ga.status) == null ? void 0 : _Ha.toUpperCase()) === "ONCALL" || ((_Ja = (_Ia = state.callData) == null ? void 0 : _Ia.status) == null ? void 0 : _Ja.toUpperCase()) === "RINGING" || ((_La = (_Ka = state.callData) == null ? void 0 : _Ka.status) == null ? void 0 : _La.toUpperCase()) === "WRAPUP" ? "contained" : "outlined",
3542
+ variant: [
3543
+ "ONCALL" /* ONCALL */,
3544
+ "RINGING" /* RINGING */,
3545
+ "DIALING" /* DIALING */,
3546
+ "WRAPUP" /* WRAPUP */
3547
+ ].includes((_pa = (_oa = state.callData) == null ? void 0 : _oa.status) == null ? void 0 : _pa.toUpperCase()) ? "contained" : "outlined",
3821
3548
  onClick: (e) => {
3822
- var _a3, _b2, _c2, _d2, _e2, _f2;
3823
- if (((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL" || ((_d2 = (_c2 = state.callData) == null ? void 0 : _c2.status) == null ? void 0 : _d2.toUpperCase()) === "RINGING" || ((_f2 = (_e2 = state.callData) == null ? void 0 : _e2.status) == null ? void 0 : _f2.toUpperCase()) === "WRAPUP") {
3549
+ var _a3, _b2;
3550
+ if ([
3551
+ "ONCALL" /* ONCALL */,
3552
+ "RINGING" /* RINGING */,
3553
+ "DIALING" /* DIALING */,
3554
+ "WRAPUP" /* WRAPUP */
3555
+ ].includes((_b2 = (_a3 = state.callData) == null ? void 0 : _a3.status) == null ? void 0 : _b2.toUpperCase())) {
3824
3556
  e.stopPropagation();
3825
3557
  setOpenCallDisposition(true);
3826
3558
  }
3827
3559
  },
3828
- sx: ((_Na = (_Ma = state.callData) == null ? void 0 : _Ma.status) == null ? void 0 : _Na.toUpperCase()) === "ONCALL" || ((_Pa = (_Oa = state.callData) == null ? void 0 : _Oa.status) == null ? void 0 : _Pa.toUpperCase()) === "RINGING" || ((_Ra = (_Qa = state.callData) == null ? void 0 : _Qa.status) == null ? void 0 : _Ra.toUpperCase()) === "WRAPUP" ? __spreadProps(__spreadValues({}, enabled), {
3560
+ sx: [
3561
+ "ONCALL" /* ONCALL */,
3562
+ "RINGING" /* RINGING */,
3563
+ "DIALING" /* DIALING */,
3564
+ "WRAPUP" /* WRAPUP */
3565
+ ].includes((_ra = (_qa = state.callData) == null ? void 0 : _qa.status) == null ? void 0 : _ra.toUpperCase()) ? __spreadProps(__spreadValues({}, enabled), {
3829
3566
  borderRight: "1px",
3830
3567
  backgroundColor: "error.main",
3831
3568
  minWidth: "60px !important",
@@ -3844,7 +3581,12 @@ function CallControls({ onDataChange }) {
3844
3581
  }) : __spreadProps(__spreadValues({}, disabled), {
3845
3582
  minWidth: "60px !important"
3846
3583
  }),
3847
- disabled: ((_Ta = (_Sa = state.callData) == null ? void 0 : _Sa.status) == null ? void 0 : _Ta.toUpperCase()) !== "ONCALL" && ((_Va = (_Ua = state.callData) == null ? void 0 : _Ua.status) == null ? void 0 : _Va.toUpperCase()) !== "RINGING" && ((_Xa = (_Wa = state.callData) == null ? void 0 : _Wa.status) == null ? void 0 : _Xa.toUpperCase()) !== "WRAPUP" || endCallLoading,
3584
+ disabled: ![
3585
+ "ONCALL" /* ONCALL */,
3586
+ "RINGING" /* RINGING */,
3587
+ "DIALING" /* DIALING */,
3588
+ "WRAPUP" /* WRAPUP */
3589
+ ].includes((_ta = (_sa = state.callData) == null ? void 0 : _sa.status) == null ? void 0 : _ta.toUpperCase()) || endCallLoading,
3848
3590
  children: endCallLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3849
3591
  import_material4.CircularProgress,
3850
3592
  {
@@ -3884,7 +3626,7 @@ function CallControls({ onDataChange }) {
3884
3626
  transition: theme.transitions.create(["box-shadow", "transform"], {
3885
3627
  duration: theme.transitions.duration.short
3886
3628
  }),
3887
- visibility: showIframe && !((_Ya = state.sdkConfig) == null ? void 0 : _Ya.disableSoftPhone) ? "visible" : "hidden",
3629
+ visibility: showIframe && !((_ua = state.sdkConfig) == null ? void 0 : _ua.disableSoftPhone) ? "visible" : "hidden",
3888
3630
  userSelect: "none"
3889
3631
  },
3890
3632
  children: [
@@ -3918,7 +3660,7 @@ function CallControls({ onDataChange }) {
3918
3660
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Box, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3919
3661
  "iframe",
3920
3662
  {
3921
- src: `https://${IP}/ConVoxCCS/iframe?agent_id=${state.agentId}&process_id=${(_Za = state.process) == null ? void 0 : _Za.process_id}`,
3663
+ src: `https://${IP}/ConVoxCCS/iframe?agent_id=${state.agentId}&process_id=${(_va = state.process) == null ? void 0 : _va.process_id}`,
3922
3664
  height: 380,
3923
3665
  width: 420,
3924
3666
  allow: "camera; microphone; autoplay",
@@ -4203,24 +3945,27 @@ async function initSDK({
4203
3945
  agentId: agentId.trim(),
4204
3946
  baseUrl: BASE_URL
4205
3947
  });
3948
+ const res = {
3949
+ accessToken: initResult == null ? void 0 : initResult.accessToken,
3950
+ expiration: initResult == null ? void 0 : initResult.expiration,
3951
+ ticketId: initResult == null ? void 0 : initResult.ticketId
3952
+ };
4206
3953
  if (initResult) {
4207
- console.log("SDK initialized successfully");
3954
+ console.info("SDK initialized successfully");
4208
3955
  sdkStateManager.initialize(
4209
3956
  apiKey.trim(),
4210
3957
  tenantId.trim(),
4211
3958
  agentId.trim(),
4212
3959
  __spreadValues(__spreadValues({}, initResult == null ? void 0 : initResult.call_controls), sdkConfig),
4213
- initResult
3960
+ res
4214
3961
  );
4215
3962
  } else {
4216
- console.error("SDK initialization failed: Event tracker initialization returned false");
4217
3963
  sdkStateManager.setInitCheck();
4218
3964
  throw new Error(
4219
3965
  "SDK initialization failed: Unable to establish connection with the CTI system"
4220
3966
  );
4221
3967
  }
4222
3968
  } catch (error) {
4223
- console.error("SDK initialization error:", error);
4224
3969
  sdkStateManager.setInitCheck();
4225
3970
  if (error instanceof Error) {
4226
3971
  throw error;