call-control-sdk 2.0.0 → 2.2.0
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/README.md +25 -43
- package/dist/index.d.mts +10 -12
- package/dist/index.d.ts +10 -12
- package/dist/index.js +696 -108
- package/dist/index.mjs +705 -110
- package/package.json +29 -14
package/dist/index.js
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
6
10
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7
23
|
var __export = (target, all) => {
|
|
8
24
|
for (var name in all)
|
|
9
25
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -23,12 +39,416 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
23
39
|
var index_exports = {};
|
|
24
40
|
__export(index_exports, {
|
|
25
41
|
CallControlPanel: () => CallControlPanel,
|
|
26
|
-
|
|
27
|
-
updateCallData: () => updateCallData
|
|
42
|
+
initSDK: () => initSDK
|
|
28
43
|
});
|
|
29
44
|
module.exports = __toCommonJS(index_exports);
|
|
30
45
|
|
|
31
|
-
// src/lib/
|
|
46
|
+
// src/lib/hooks/eventsTracker.ts
|
|
47
|
+
var EventTrackerSDK = class {
|
|
48
|
+
constructor() {
|
|
49
|
+
__publicField(this, "config", null);
|
|
50
|
+
__publicField(this, "ticketId", null);
|
|
51
|
+
__publicField(this, "baseUrl", "");
|
|
52
|
+
__publicField(this, "eventQueue", []);
|
|
53
|
+
__publicField(this, "isOnline", true);
|
|
54
|
+
__publicField(this, "retryQueue", []);
|
|
55
|
+
__publicField(this, "flushTimer", null);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Initialize the EventTracker SDK
|
|
59
|
+
* @param config Configuration object
|
|
60
|
+
*/
|
|
61
|
+
async init(config) {
|
|
62
|
+
this.config = __spreadValues({
|
|
63
|
+
autoTrack: true,
|
|
64
|
+
retryAttempts: 3,
|
|
65
|
+
queueSize: 100,
|
|
66
|
+
flushInterval: 5e3
|
|
67
|
+
}, config);
|
|
68
|
+
this.baseUrl = config.baseUrl || (typeof window !== "undefined" ? window.location.origin : "");
|
|
69
|
+
this.setupNetworkDetection();
|
|
70
|
+
const ticket = await this.createTicket();
|
|
71
|
+
this.startPeriodicFlush();
|
|
72
|
+
console.log("EventTracker SDK initialized successfully");
|
|
73
|
+
return ticket;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Check if the SDK is initialized
|
|
77
|
+
*/
|
|
78
|
+
isInitialized() {
|
|
79
|
+
return this.config !== null && this.ticketId !== null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get the current configuration
|
|
83
|
+
*/
|
|
84
|
+
getConfig() {
|
|
85
|
+
return this.config;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get the current ticket ID
|
|
89
|
+
*/
|
|
90
|
+
getTicketId() {
|
|
91
|
+
return this.ticketId;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Create a new ticket
|
|
95
|
+
*/
|
|
96
|
+
async createTicket() {
|
|
97
|
+
if (!this.config) {
|
|
98
|
+
throw new Error("EventTracker not initialized");
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
const response = await this.makeRequest("/api/v1/et/init", {
|
|
102
|
+
method: "POST",
|
|
103
|
+
headers: {
|
|
104
|
+
"Content-Type": "application/json",
|
|
105
|
+
"X-API-Key": this.config.apiKey
|
|
106
|
+
},
|
|
107
|
+
body: JSON.stringify({
|
|
108
|
+
agentId: this.config.agentId,
|
|
109
|
+
sessionId: this.config.sessionId
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
if (!response.ok) {
|
|
113
|
+
throw new Error(
|
|
114
|
+
`Failed to initialize: ${response.status} ${response.statusText}`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
const data = await response.json();
|
|
118
|
+
this.ticketId = data.ticketId;
|
|
119
|
+
if (this.config.autoTrack) {
|
|
120
|
+
this.setupAutoTracking();
|
|
121
|
+
}
|
|
122
|
+
return this.ticketId;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error("EventTracker initialization failed:", error);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Log an event
|
|
130
|
+
* @param eventType The type of event
|
|
131
|
+
* @param eventData Optional event data
|
|
132
|
+
*/
|
|
133
|
+
async logEvent(eventType, eventData) {
|
|
134
|
+
if (!this.config || !this.ticketId) {
|
|
135
|
+
console.warn("EventTracker not initialized, skipping event:", eventType);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const event = {
|
|
139
|
+
eventType,
|
|
140
|
+
eventData,
|
|
141
|
+
timestamp: Date.now()
|
|
142
|
+
};
|
|
143
|
+
this.eventQueue.push(event);
|
|
144
|
+
if (this.eventQueue.length > (this.config.queueSize || 100)) {
|
|
145
|
+
this.eventQueue.shift();
|
|
146
|
+
}
|
|
147
|
+
if (this.isOnline) {
|
|
148
|
+
try {
|
|
149
|
+
await this.sendEvent(event);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.warn("Failed to send event, will retry later:", error);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Send an event to the server
|
|
157
|
+
*/
|
|
158
|
+
async sendEvent(event) {
|
|
159
|
+
if (!this.config || !this.ticketId) return;
|
|
160
|
+
try {
|
|
161
|
+
const response = await this.makeRequest("/api/v1/et/event", {
|
|
162
|
+
method: "POST",
|
|
163
|
+
headers: {
|
|
164
|
+
"Content-Type": "application/json",
|
|
165
|
+
"X-API-Key": this.config.apiKey
|
|
166
|
+
},
|
|
167
|
+
body: JSON.stringify({
|
|
168
|
+
ticketId: this.ticketId,
|
|
169
|
+
eventType: event.eventType,
|
|
170
|
+
eventData: event.eventData
|
|
171
|
+
})
|
|
172
|
+
});
|
|
173
|
+
if (!response.ok) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`Failed to log event: ${response.status} ${response.statusText}`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
const index = this.eventQueue.findIndex(
|
|
179
|
+
(e) => e.timestamp === event.timestamp
|
|
180
|
+
);
|
|
181
|
+
if (index > -1) {
|
|
182
|
+
this.eventQueue.splice(index, 1);
|
|
183
|
+
}
|
|
184
|
+
} catch (error) {
|
|
185
|
+
console.error("Event logging failed:", error);
|
|
186
|
+
this.retryQueue.push(() => this.sendEvent(event));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Close the current ticket
|
|
191
|
+
*/
|
|
192
|
+
async closeTicket() {
|
|
193
|
+
if (!this.config || !this.ticketId) {
|
|
194
|
+
throw new Error("EventTracker not initialized");
|
|
195
|
+
}
|
|
196
|
+
await this.flush();
|
|
197
|
+
try {
|
|
198
|
+
const response = await this.makeRequest("/api/v1/et/close", {
|
|
199
|
+
method: "POST",
|
|
200
|
+
headers: {
|
|
201
|
+
"Content-Type": "application/json",
|
|
202
|
+
"X-API-Key": this.config.apiKey
|
|
203
|
+
},
|
|
204
|
+
body: JSON.stringify({
|
|
205
|
+
ticketId: this.ticketId
|
|
206
|
+
})
|
|
207
|
+
});
|
|
208
|
+
if (!response.ok) {
|
|
209
|
+
throw new Error(
|
|
210
|
+
`Failed to close ticket: ${response.status} ${response.statusText}`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
this.ticketId = null;
|
|
214
|
+
this.stopPeriodicFlush();
|
|
215
|
+
console.log("Ticket closed successfully");
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.error("Ticket close failed:", error);
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Flush all pending events
|
|
223
|
+
*/
|
|
224
|
+
async flush() {
|
|
225
|
+
if (!this.isOnline || this.eventQueue.length === 0) return;
|
|
226
|
+
const eventsToFlush = [...this.eventQueue];
|
|
227
|
+
for (const event of eventsToFlush) {
|
|
228
|
+
await this.sendEvent(event);
|
|
229
|
+
}
|
|
230
|
+
const retryItems = [...this.retryQueue];
|
|
231
|
+
this.retryQueue = [];
|
|
232
|
+
for (const retryFn of retryItems) {
|
|
233
|
+
try {
|
|
234
|
+
await retryFn();
|
|
235
|
+
} catch (error) {
|
|
236
|
+
console.error("Retry failed:", error);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Make an HTTP request with retry logic
|
|
242
|
+
*/
|
|
243
|
+
async makeRequest(url, options) {
|
|
244
|
+
var _a;
|
|
245
|
+
const fullUrl = `${this.baseUrl}${url}`;
|
|
246
|
+
const maxRetries = ((_a = this.config) == null ? void 0 : _a.retryAttempts) || 3;
|
|
247
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
248
|
+
try {
|
|
249
|
+
const response = await fetch(fullUrl, options);
|
|
250
|
+
return response;
|
|
251
|
+
} catch (error) {
|
|
252
|
+
if (attempt === maxRetries) {
|
|
253
|
+
throw error;
|
|
254
|
+
}
|
|
255
|
+
const delay = Math.min(1e3 * Math.pow(2, attempt - 1), 1e4);
|
|
256
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
throw new Error("Max retries exceeded");
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Set up automatic event tracking
|
|
263
|
+
*/
|
|
264
|
+
setupAutoTracking() {
|
|
265
|
+
var _a;
|
|
266
|
+
if (typeof window === "undefined" || !((_a = this.config) == null ? void 0 : _a.autoTrack)) return;
|
|
267
|
+
const autoTrackConfig = this.config.autoTrack === true ? {} : this.config.autoTrack;
|
|
268
|
+
if (autoTrackConfig.pageVisits !== false) {
|
|
269
|
+
this.logEvent("pageVisit", {
|
|
270
|
+
url: window.location.href,
|
|
271
|
+
title: document.title,
|
|
272
|
+
referrer: document.referrer,
|
|
273
|
+
userAgent: navigator.userAgent,
|
|
274
|
+
viewport: {
|
|
275
|
+
width: window.innerWidth,
|
|
276
|
+
height: window.innerHeight
|
|
277
|
+
},
|
|
278
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
279
|
+
}).catch((error) => console.warn("Failed to track page visit:", error));
|
|
280
|
+
}
|
|
281
|
+
if (autoTrackConfig.clicks !== false) {
|
|
282
|
+
document.addEventListener("click", (event) => {
|
|
283
|
+
var _a2;
|
|
284
|
+
const target = event.target;
|
|
285
|
+
if (target.tagName === "BUTTON" || target.tagName === "A" || target.onclick || target.getAttribute("role") === "button" || target instanceof HTMLButtonElement && target.type === "button") {
|
|
286
|
+
this.logEvent("click", {
|
|
287
|
+
element: target.tagName,
|
|
288
|
+
text: (_a2 = target.textContent) == null ? void 0 : _a2.trim().substring(0, 100),
|
|
289
|
+
// Limit text length
|
|
290
|
+
href: target.getAttribute("href"),
|
|
291
|
+
id: target.id,
|
|
292
|
+
className: target.className,
|
|
293
|
+
role: target.getAttribute("role"),
|
|
294
|
+
position: {
|
|
295
|
+
x: event.clientX,
|
|
296
|
+
y: event.clientY
|
|
297
|
+
},
|
|
298
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
299
|
+
}).catch((error) => console.warn("Failed to track click:", error));
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
if (autoTrackConfig.forms !== false) {
|
|
304
|
+
document.addEventListener("submit", (event) => {
|
|
305
|
+
const target = event.target;
|
|
306
|
+
const formData = new FormData(target);
|
|
307
|
+
const formFields = {};
|
|
308
|
+
formData.forEach((value, key) => {
|
|
309
|
+
formFields[key] = value.toString();
|
|
310
|
+
});
|
|
311
|
+
this.logEvent("formSubmission", {
|
|
312
|
+
formId: target.id,
|
|
313
|
+
action: target.action,
|
|
314
|
+
method: target.method,
|
|
315
|
+
fields: Object.keys(formFields),
|
|
316
|
+
fieldCount: Object.keys(formFields).length,
|
|
317
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
318
|
+
}).catch(
|
|
319
|
+
(error) => console.warn("Failed to track form submission:", error)
|
|
320
|
+
);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
if (autoTrackConfig.inputs !== false) {
|
|
324
|
+
let inputTimer;
|
|
325
|
+
document.addEventListener("input", (event) => {
|
|
326
|
+
const target = event.target;
|
|
327
|
+
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "SELECT") {
|
|
328
|
+
clearTimeout(inputTimer);
|
|
329
|
+
inputTimer = setTimeout(() => {
|
|
330
|
+
var _a2;
|
|
331
|
+
this.logEvent("fieldChange", {
|
|
332
|
+
element: target.tagName,
|
|
333
|
+
type: target.getAttribute("type"),
|
|
334
|
+
name: target.getAttribute("name"),
|
|
335
|
+
id: target.id,
|
|
336
|
+
valueLength: ((_a2 = target.value) == null ? void 0 : _a2.length) || 0,
|
|
337
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
338
|
+
}).catch(
|
|
339
|
+
(error) => console.warn("Failed to track field change:", error)
|
|
340
|
+
);
|
|
341
|
+
}, 1e3);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
const sessionStartTime = Date.now();
|
|
346
|
+
window.addEventListener("beforeunload", () => {
|
|
347
|
+
const sessionDuration = Date.now() - sessionStartTime;
|
|
348
|
+
this.logEvent("pageUnload", {
|
|
349
|
+
url: window.location.href,
|
|
350
|
+
sessionDuration,
|
|
351
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
352
|
+
});
|
|
353
|
+
if (this.ticketId) {
|
|
354
|
+
navigator.sendBeacon(
|
|
355
|
+
`${this.baseUrl}/api/v1/et/close`,
|
|
356
|
+
JSON.stringify({
|
|
357
|
+
ticketId: this.ticketId
|
|
358
|
+
})
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
if (autoTrackConfig.visibility !== false) {
|
|
363
|
+
document.addEventListener("visibilitychange", () => {
|
|
364
|
+
this.logEvent("visibilityChange", {
|
|
365
|
+
hidden: document.hidden,
|
|
366
|
+
visibilityState: document.visibilityState,
|
|
367
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
if (autoTrackConfig.errors !== false) {
|
|
372
|
+
window.addEventListener("error", (event) => {
|
|
373
|
+
this.logEvent("jsError", {
|
|
374
|
+
message: event.message,
|
|
375
|
+
filename: event.filename,
|
|
376
|
+
lineno: event.lineno,
|
|
377
|
+
colno: event.colno,
|
|
378
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
window.addEventListener("unhandledrejection", (event) => {
|
|
382
|
+
var _a2;
|
|
383
|
+
this.logEvent("unhandledRejection", {
|
|
384
|
+
reason: (_a2 = event.reason) == null ? void 0 : _a2.toString(),
|
|
385
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
if (autoTrackConfig.performance !== false && typeof window.performance !== "undefined" && window.performance.navigation) {
|
|
390
|
+
window.addEventListener("load", () => {
|
|
391
|
+
setTimeout(() => {
|
|
392
|
+
const navigation = window.performance.navigation;
|
|
393
|
+
const timing = window.performance.timing;
|
|
394
|
+
this.logEvent("performanceMetrics", {
|
|
395
|
+
navigationTime: timing.navigationStart,
|
|
396
|
+
loadTime: timing.loadEventEnd - timing.navigationStart,
|
|
397
|
+
domReady: timing.domContentLoadedEventEnd - timing.navigationStart,
|
|
398
|
+
renderTime: timing.loadEventEnd - timing.domContentLoadedEventEnd,
|
|
399
|
+
navigationType: navigation.type,
|
|
400
|
+
redirectCount: navigation.redirectCount,
|
|
401
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
402
|
+
});
|
|
403
|
+
}, 1e3);
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Set up network detection
|
|
409
|
+
*/
|
|
410
|
+
setupNetworkDetection() {
|
|
411
|
+
if (typeof window === "undefined") return;
|
|
412
|
+
this.isOnline = navigator.onLine;
|
|
413
|
+
window.addEventListener("online", () => {
|
|
414
|
+
this.isOnline = true;
|
|
415
|
+
console.log("EventTracker: Back online, flushing queued events");
|
|
416
|
+
this.flush();
|
|
417
|
+
});
|
|
418
|
+
window.addEventListener("offline", () => {
|
|
419
|
+
this.isOnline = false;
|
|
420
|
+
console.log("EventTracker: Offline, queueing events");
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Start periodic flush timer
|
|
425
|
+
*/
|
|
426
|
+
startPeriodicFlush() {
|
|
427
|
+
var _a;
|
|
428
|
+
if (this.flushTimer) {
|
|
429
|
+
clearInterval(this.flushTimer);
|
|
430
|
+
}
|
|
431
|
+
const interval = ((_a = this.config) == null ? void 0 : _a.flushInterval) || 5e3;
|
|
432
|
+
this.flushTimer = setInterval(() => {
|
|
433
|
+
this.flush();
|
|
434
|
+
}, interval);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Stop periodic flush timer
|
|
438
|
+
*/
|
|
439
|
+
stopPeriodicFlush() {
|
|
440
|
+
if (this.flushTimer) {
|
|
441
|
+
clearInterval(this.flushTimer);
|
|
442
|
+
this.flushTimer = null;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
var eventTracker = new EventTrackerSDK();
|
|
447
|
+
if (typeof window !== "undefined") {
|
|
448
|
+
window.EventTracker = eventTracker;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// src/lib/hooks/sdk-state.ts
|
|
32
452
|
var SDKStateManager = class {
|
|
33
453
|
constructor() {
|
|
34
454
|
__publicField(this, "state");
|
|
@@ -45,7 +465,8 @@ var SDKStateManager = class {
|
|
|
45
465
|
isMuted: false,
|
|
46
466
|
status: "idle",
|
|
47
467
|
callStartTime: null,
|
|
48
|
-
|
|
468
|
+
controlPanelPosition: { x: 0, y: 0 },
|
|
469
|
+
iframePosition: { x: 0, y: 0 },
|
|
49
470
|
callData: {
|
|
50
471
|
mobileNumber: "",
|
|
51
472
|
callReferenceId: "",
|
|
@@ -58,14 +479,14 @@ var SDKStateManager = class {
|
|
|
58
479
|
const stored = localStorage.getItem(this.STORAGE_KEY);
|
|
59
480
|
if (stored) {
|
|
60
481
|
const parsedState = JSON.parse(stored);
|
|
61
|
-
this.state = {
|
|
62
|
-
...this.state,
|
|
482
|
+
this.state = __spreadProps(__spreadValues({}, this.state), {
|
|
63
483
|
isHolding: parsedState.isHolding || false,
|
|
64
484
|
isMuted: parsedState.isMuted || false,
|
|
65
485
|
status: parsedState.status || "idle",
|
|
66
|
-
|
|
486
|
+
controlPanelPosition: parsedState.controlPanelPosition || { x: 50, y: 50 },
|
|
487
|
+
iframePosition: parsedState.iframePosition || { x: 50, y: 50 },
|
|
67
488
|
callStartTime: parsedState.callStartTime || null
|
|
68
|
-
};
|
|
489
|
+
});
|
|
69
490
|
}
|
|
70
491
|
} catch (error) {
|
|
71
492
|
console.warn("Failed to load SDK state from localStorage:", error);
|
|
@@ -77,7 +498,8 @@ var SDKStateManager = class {
|
|
|
77
498
|
isHolding: this.state.isHolding,
|
|
78
499
|
isMuted: this.state.isMuted,
|
|
79
500
|
status: this.state.status,
|
|
80
|
-
|
|
501
|
+
controlPanelPosition: this.state.controlPanelPosition,
|
|
502
|
+
iframePosition: this.state.iframePosition,
|
|
81
503
|
callStartTime: this.state.callStartTime
|
|
82
504
|
};
|
|
83
505
|
localStorage.setItem(this.STORAGE_KEY, JSON.stringify(persistentState));
|
|
@@ -97,7 +519,7 @@ var SDKStateManager = class {
|
|
|
97
519
|
this.notifyListeners();
|
|
98
520
|
}
|
|
99
521
|
getState() {
|
|
100
|
-
return {
|
|
522
|
+
return __spreadValues({}, this.state);
|
|
101
523
|
}
|
|
102
524
|
subscribe(listener) {
|
|
103
525
|
this.listeners.push(listener);
|
|
@@ -123,8 +545,13 @@ var SDKStateManager = class {
|
|
|
123
545
|
this.saveToStorage();
|
|
124
546
|
this.notifyListeners();
|
|
125
547
|
}
|
|
126
|
-
|
|
127
|
-
this.state.
|
|
548
|
+
setControlPanelPosition(position) {
|
|
549
|
+
this.state.controlPanelPosition = position;
|
|
550
|
+
this.saveToStorage();
|
|
551
|
+
this.notifyListeners();
|
|
552
|
+
}
|
|
553
|
+
setIframePosition(position) {
|
|
554
|
+
this.state.iframePosition = position;
|
|
128
555
|
this.saveToStorage();
|
|
129
556
|
this.notifyListeners();
|
|
130
557
|
}
|
|
@@ -143,7 +570,7 @@ var SDKStateManager = class {
|
|
|
143
570
|
this.notifyListeners();
|
|
144
571
|
}
|
|
145
572
|
updateCallData(data) {
|
|
146
|
-
this.state.callData = {
|
|
573
|
+
this.state.callData = __spreadValues(__spreadValues({}, this.state.callData), data);
|
|
147
574
|
this.notifyListeners();
|
|
148
575
|
}
|
|
149
576
|
};
|
|
@@ -187,7 +614,7 @@ function useDraggable(initialPosition, onPositionChange) {
|
|
|
187
614
|
y: Math.max(0, Math.min(newPosition.y, viewportHeight - rect.height))
|
|
188
615
|
};
|
|
189
616
|
setPosition(constrainedPosition);
|
|
190
|
-
onPositionChange
|
|
617
|
+
onPositionChange == null ? void 0 : onPositionChange(constrainedPosition);
|
|
191
618
|
},
|
|
192
619
|
[onPositionChange]
|
|
193
620
|
);
|
|
@@ -199,11 +626,10 @@ function useDraggable(initialPosition, onPositionChange) {
|
|
|
199
626
|
const handleMove = (moveClientX, moveClientY) => {
|
|
200
627
|
const deltaX = moveClientX - dragStart.current.x;
|
|
201
628
|
const deltaY = moveClientY - dragStart.current.y;
|
|
202
|
-
|
|
629
|
+
updatePosition({
|
|
203
630
|
x: elementStart.current.x + deltaX,
|
|
204
631
|
y: elementStart.current.y + deltaY
|
|
205
|
-
};
|
|
206
|
-
updatePosition(newPosition);
|
|
632
|
+
});
|
|
207
633
|
};
|
|
208
634
|
const handleMouseMove = (e) => {
|
|
209
635
|
e.preventDefault();
|
|
@@ -264,11 +690,19 @@ function CallControlPanel({ onDataChange }) {
|
|
|
264
690
|
const theme = (0, import_material.useTheme)();
|
|
265
691
|
const state = useSDKState();
|
|
266
692
|
const [anchorEl, setAnchorEl] = (0, import_react3.useState)(null);
|
|
693
|
+
const [phoneNumber, setPhoneNumber] = (0, import_react3.useState)("");
|
|
694
|
+
const [dialerAnchorEl, setDialerAnchorEl] = (0, import_react3.useState)(
|
|
695
|
+
null
|
|
696
|
+
);
|
|
267
697
|
const [moreOptionsAnchorEl, setMoreOptionsAnchorEl] = (0, import_react3.useState)(null);
|
|
268
698
|
const [callDuration, setCallDuration] = (0, import_react3.useState)(0);
|
|
269
699
|
const { position, isDragging, dragRef, handleMouseDown, handleTouchStart } = useDraggable(
|
|
270
|
-
state.
|
|
271
|
-
(newPosition) => sdkStateManager.
|
|
700
|
+
state.controlPanelPosition,
|
|
701
|
+
(newPosition) => sdkStateManager.setControlPanelPosition(newPosition)
|
|
702
|
+
);
|
|
703
|
+
const { position: xposition, isDragging: xisDragging, dragRef: xdragRef, handleMouseDown: xhandleMouseDown, handleTouchStart: xhandleTouchStart } = useDraggable(
|
|
704
|
+
state.iframePosition,
|
|
705
|
+
(newPosition) => sdkStateManager.setIframePosition(newPosition)
|
|
272
706
|
);
|
|
273
707
|
(0, import_react3.useEffect)(() => {
|
|
274
708
|
let interval;
|
|
@@ -301,9 +735,9 @@ function CallControlPanel({ onDataChange }) {
|
|
|
301
735
|
case "break":
|
|
302
736
|
return "warning";
|
|
303
737
|
case "idle":
|
|
304
|
-
return "
|
|
738
|
+
return "info";
|
|
305
739
|
default:
|
|
306
|
-
return "
|
|
740
|
+
return "info";
|
|
307
741
|
}
|
|
308
742
|
}, []);
|
|
309
743
|
const handleHoldToggle = () => {
|
|
@@ -314,13 +748,17 @@ function CallControlPanel({ onDataChange }) {
|
|
|
314
748
|
};
|
|
315
749
|
const handleStatusChange = (newStatus) => {
|
|
316
750
|
sdkStateManager.setStatus(newStatus);
|
|
317
|
-
|
|
751
|
+
setMoreOptionsAnchorEl(null);
|
|
318
752
|
};
|
|
319
753
|
const handleEndCall = () => {
|
|
320
754
|
sdkStateManager.endCall();
|
|
321
755
|
};
|
|
322
|
-
const handleStartCall = () => {
|
|
323
|
-
|
|
756
|
+
const handleStartCall = (number) => {
|
|
757
|
+
if (number.length !== 10) {
|
|
758
|
+
alert("Invalid phone number");
|
|
759
|
+
} else {
|
|
760
|
+
sdkStateManager.startCall();
|
|
761
|
+
}
|
|
324
762
|
};
|
|
325
763
|
const handleMoreClick = (event) => {
|
|
326
764
|
setAnchorEl(event.currentTarget);
|
|
@@ -334,6 +772,15 @@ function CallControlPanel({ onDataChange }) {
|
|
|
334
772
|
const handleMoreOptionsClose = () => {
|
|
335
773
|
setMoreOptionsAnchorEl(null);
|
|
336
774
|
};
|
|
775
|
+
const handleOpenDialer = (event) => {
|
|
776
|
+
setDialerAnchorEl(event.currentTarget);
|
|
777
|
+
};
|
|
778
|
+
const handleCloseDialer = () => {
|
|
779
|
+
setDialerAnchorEl(null);
|
|
780
|
+
};
|
|
781
|
+
if (!state.isInitialized) {
|
|
782
|
+
return null;
|
|
783
|
+
}
|
|
337
784
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
338
785
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Fade, { in: true, timeout: 300, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
339
786
|
import_material.Paper,
|
|
@@ -351,7 +798,6 @@ function CallControlPanel({ onDataChange }) {
|
|
|
351
798
|
transition: theme.transitions.create(["box-shadow", "transform"], {
|
|
352
799
|
duration: theme.transitions.duration.short
|
|
353
800
|
}),
|
|
354
|
-
transform: isDragging ? "scale(1.01)" : "scale(1)",
|
|
355
801
|
minWidth: 320,
|
|
356
802
|
userSelect: "none"
|
|
357
803
|
},
|
|
@@ -386,24 +832,33 @@ function CallControlPanel({ onDataChange }) {
|
|
|
386
832
|
alignItems: "center"
|
|
387
833
|
},
|
|
388
834
|
children: [
|
|
835
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.DragIndicator, {}),
|
|
836
|
+
" ",
|
|
389
837
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
390
|
-
|
|
838
|
+
import_material.Box,
|
|
391
839
|
{
|
|
392
840
|
sx: {
|
|
393
841
|
marginRight: "10px"
|
|
394
|
-
}
|
|
842
|
+
},
|
|
843
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Tooltip, { title: "Dial", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
844
|
+
import_material.IconButton,
|
|
845
|
+
{
|
|
846
|
+
onClick: (e) => {
|
|
847
|
+
handleOpenDialer(e);
|
|
848
|
+
},
|
|
849
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.WifiCalling3, { color: "success" })
|
|
850
|
+
}
|
|
851
|
+
) })
|
|
395
852
|
}
|
|
396
853
|
),
|
|
397
|
-
" ",
|
|
398
854
|
formatDuration(callDuration)
|
|
399
855
|
]
|
|
400
856
|
}
|
|
401
857
|
),
|
|
402
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Tooltip, { title: "Status", children: /* @__PURE__ */ (0, import_jsx_runtime.
|
|
858
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Tooltip, { title: "Status", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
403
859
|
import_material.Button,
|
|
404
860
|
{
|
|
405
861
|
sx: {
|
|
406
|
-
backgroundColor: getStatusColor(state.status),
|
|
407
862
|
fontWeight: "bold",
|
|
408
863
|
borderRadius: "16px",
|
|
409
864
|
display: "flex",
|
|
@@ -411,25 +866,20 @@ function CallControlPanel({ onDataChange }) {
|
|
|
411
866
|
justifyContent: "space-between",
|
|
412
867
|
marginRight: "8px"
|
|
413
868
|
},
|
|
414
|
-
|
|
415
|
-
e.stopPropagation();
|
|
416
|
-
handleMoreClick(e);
|
|
417
|
-
},
|
|
869
|
+
color: getStatusColor(state.status),
|
|
418
870
|
variant: "outlined",
|
|
419
|
-
children:
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.KeyboardArrowDown, {})
|
|
432
|
-
]
|
|
871
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
872
|
+
import_material.Typography,
|
|
873
|
+
{
|
|
874
|
+
width: 50,
|
|
875
|
+
variant: "body2",
|
|
876
|
+
sx: {
|
|
877
|
+
color: getStatusColor(state.status),
|
|
878
|
+
fontWeight: "bold"
|
|
879
|
+
},
|
|
880
|
+
children: state.status.toUpperCase()
|
|
881
|
+
}
|
|
882
|
+
)
|
|
433
883
|
}
|
|
434
884
|
) })
|
|
435
885
|
]
|
|
@@ -489,6 +939,23 @@ function CallControlPanel({ onDataChange }) {
|
|
|
489
939
|
children: state.isMuted ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.MicOff, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Mic, {})
|
|
490
940
|
}
|
|
491
941
|
) }),
|
|
942
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Tooltip, { title: "Queue", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
943
|
+
import_material.IconButton,
|
|
944
|
+
{
|
|
945
|
+
onClick: (e) => {
|
|
946
|
+
e.stopPropagation();
|
|
947
|
+
handleMoreClick(e);
|
|
948
|
+
},
|
|
949
|
+
color: "default",
|
|
950
|
+
sx: {
|
|
951
|
+
bgcolor: "action.hover",
|
|
952
|
+
"&:hover": {
|
|
953
|
+
bgcolor: "warning"
|
|
954
|
+
}
|
|
955
|
+
},
|
|
956
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Layers, {})
|
|
957
|
+
}
|
|
958
|
+
) }),
|
|
492
959
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Tooltip, { title: "More Options", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
493
960
|
import_material.IconButton,
|
|
494
961
|
{
|
|
@@ -508,14 +975,16 @@ function CallControlPanel({ onDataChange }) {
|
|
|
508
975
|
{
|
|
509
976
|
onClick: (e) => {
|
|
510
977
|
e.stopPropagation();
|
|
511
|
-
(state.callStartTime
|
|
978
|
+
if (state.callStartTime) {
|
|
979
|
+
handleEndCall();
|
|
980
|
+
}
|
|
512
981
|
},
|
|
513
982
|
color: "error",
|
|
514
983
|
sx: {
|
|
515
|
-
bgcolor: state.callStartTime ? "error.main" : "
|
|
984
|
+
bgcolor: state.callStartTime ? "error.main" : "gray",
|
|
516
985
|
color: "white",
|
|
517
986
|
"&:hover": {
|
|
518
|
-
bgcolor: state.callStartTime ? "error.light" : "
|
|
987
|
+
bgcolor: state.callStartTime ? "error.light" : "gray"
|
|
519
988
|
}
|
|
520
989
|
},
|
|
521
990
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.CallEnd, {})
|
|
@@ -529,64 +998,172 @@ function CallControlPanel({ onDataChange }) {
|
|
|
529
998
|
)
|
|
530
999
|
}
|
|
531
1000
|
) }),
|
|
532
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
1001
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Fade, { in: true, timeout: 300, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1002
|
+
import_material.Paper,
|
|
1003
|
+
{
|
|
1004
|
+
ref: xdragRef,
|
|
1005
|
+
elevation: xisDragging ? 2 : 1,
|
|
1006
|
+
sx: {
|
|
1007
|
+
position: "fixed",
|
|
1008
|
+
left: xposition.x,
|
|
1009
|
+
top: xposition.y,
|
|
1010
|
+
p: 1,
|
|
1011
|
+
height: "auto",
|
|
1012
|
+
// borderRadius: 3,
|
|
1013
|
+
bgcolor: "background.paper",
|
|
1014
|
+
cursor: xisDragging ? "grabbing" : "grab",
|
|
1015
|
+
transition: theme.transitions.create(["box-shadow", "transform"], {
|
|
1016
|
+
duration: theme.transitions.duration.short
|
|
1017
|
+
}),
|
|
1018
|
+
// minWidth: 320,
|
|
1019
|
+
userSelect: "none"
|
|
1020
|
+
},
|
|
1021
|
+
onMouseDown: xhandleMouseDown,
|
|
1022
|
+
onTouchStart: xhandleTouchStart,
|
|
1023
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Box, { sx: {
|
|
1024
|
+
display: "flex",
|
|
1025
|
+
alignItems: "center",
|
|
1026
|
+
justifyContent: "center",
|
|
1027
|
+
flexDirection: "column"
|
|
1028
|
+
}, children: [
|
|
1029
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1030
|
+
import_material.Box,
|
|
1031
|
+
{
|
|
1032
|
+
sx: {
|
|
1033
|
+
width: "100%",
|
|
1034
|
+
height: "auto",
|
|
1035
|
+
display: "flex",
|
|
1036
|
+
alignItems: "center",
|
|
1037
|
+
justifyContent: "space-between"
|
|
1038
|
+
},
|
|
1039
|
+
children: [
|
|
1040
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.DragIndicator, { sx: {
|
|
1041
|
+
transform: "rotate(90deg)"
|
|
1042
|
+
} }),
|
|
1043
|
+
" ",
|
|
1044
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.IconButton, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Close, {}) })
|
|
1045
|
+
]
|
|
1046
|
+
}
|
|
1047
|
+
),
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1049
|
+
"iframe",
|
|
1050
|
+
{
|
|
1051
|
+
src: "https://h68.deepijatel.in/ConVoxCCS",
|
|
1052
|
+
height: 300
|
|
1053
|
+
}
|
|
1054
|
+
)
|
|
1055
|
+
] })
|
|
1056
|
+
}
|
|
1057
|
+
) }),
|
|
1058
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1059
|
+
import_material.Menu,
|
|
1060
|
+
{
|
|
1061
|
+
anchorEl: dialerAnchorEl,
|
|
1062
|
+
open: Boolean(dialerAnchorEl),
|
|
1063
|
+
onClose: handleCloseDialer,
|
|
1064
|
+
onClick: (e) => e.stopPropagation(),
|
|
1065
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1066
|
+
import_material.Box,
|
|
1067
|
+
{
|
|
1068
|
+
sx: {
|
|
1069
|
+
all: "unset",
|
|
1070
|
+
padding: "10px",
|
|
1071
|
+
"&hover": {
|
|
1072
|
+
backgroundColor: "white"
|
|
1073
|
+
}
|
|
1074
|
+
},
|
|
1075
|
+
children: [
|
|
1076
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1077
|
+
import_material.TextField,
|
|
1078
|
+
{
|
|
1079
|
+
size: "small",
|
|
1080
|
+
value: phoneNumber,
|
|
1081
|
+
placeholder: "Enter Mobile No.",
|
|
1082
|
+
onChange: (e) => {
|
|
1083
|
+
setPhoneNumber(e.target.value);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
),
|
|
1087
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1088
|
+
import_material.IconButton,
|
|
1089
|
+
{
|
|
1090
|
+
color: "info",
|
|
1091
|
+
onClick: () => {
|
|
1092
|
+
handleStartCall(phoneNumber);
|
|
1093
|
+
},
|
|
1094
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Phone, { color: "success" })
|
|
1095
|
+
}
|
|
1096
|
+
)
|
|
1097
|
+
]
|
|
1098
|
+
}
|
|
1099
|
+
)
|
|
1100
|
+
}
|
|
1101
|
+
),
|
|
1102
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
533
1103
|
import_material.Menu,
|
|
534
1104
|
{
|
|
535
1105
|
anchorEl,
|
|
536
1106
|
open: Boolean(anchorEl),
|
|
537
1107
|
onClose: handleMoreClose,
|
|
538
1108
|
onClick: (e) => e.stopPropagation(),
|
|
539
|
-
children:
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
{
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
1109
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1110
|
+
import_material.Box,
|
|
1111
|
+
{
|
|
1112
|
+
sx: {
|
|
1113
|
+
all: "unset",
|
|
1114
|
+
padding: "0px 10px",
|
|
1115
|
+
"&hover": {
|
|
1116
|
+
backgroundColor: "white"
|
|
1117
|
+
}
|
|
1118
|
+
},
|
|
1119
|
+
children: [
|
|
1120
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Badge, { badgeContent: 100, color: "secondary", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1121
|
+
import_material.Chip,
|
|
1122
|
+
{
|
|
1123
|
+
avatar: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Avatar, { children: "Q" }),
|
|
1124
|
+
variant: "outlined",
|
|
1125
|
+
label: "Waiting"
|
|
1126
|
+
}
|
|
1127
|
+
) }),
|
|
1128
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1129
|
+
import_material.Badge,
|
|
549
1130
|
{
|
|
1131
|
+
badgeContent: 100,
|
|
1132
|
+
color: "warning",
|
|
550
1133
|
sx: {
|
|
551
|
-
|
|
552
|
-
alignItems: "center",
|
|
553
|
-
gap: 1
|
|
1134
|
+
margin: "10px"
|
|
554
1135
|
},
|
|
555
|
-
children:
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
1136
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1137
|
+
import_material.Chip,
|
|
1138
|
+
{
|
|
1139
|
+
avatar: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Avatar, { children: "C" }),
|
|
1140
|
+
label: "Pending",
|
|
1141
|
+
variant: "outlined"
|
|
1142
|
+
}
|
|
1143
|
+
)
|
|
1144
|
+
}
|
|
1145
|
+
),
|
|
1146
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1147
|
+
import_material.Badge,
|
|
1148
|
+
{
|
|
1149
|
+
badgeContent: 100,
|
|
1150
|
+
color: "info",
|
|
1151
|
+
sx: {
|
|
1152
|
+
margin: "10px"
|
|
1153
|
+
},
|
|
1154
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1155
|
+
import_material.Chip,
|
|
1156
|
+
{
|
|
1157
|
+
avatar: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Avatar, { children: "C" }),
|
|
1158
|
+
variant: "outlined",
|
|
1159
|
+
label: "Upcoming"
|
|
1160
|
+
}
|
|
1161
|
+
)
|
|
559
1162
|
}
|
|
560
1163
|
)
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
import_material.MenuItem,
|
|
565
|
-
{
|
|
566
|
-
onClick: () => handleStatusChange("break"),
|
|
567
|
-
sx: {
|
|
568
|
-
backgroundColor: state.status === "break" ? "#0038f01c" : "initial"
|
|
569
|
-
},
|
|
570
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
571
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.FreeBreakfast, { color: "error" }),
|
|
572
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { children: "Break" })
|
|
573
|
-
] })
|
|
574
|
-
}
|
|
575
|
-
),
|
|
576
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
577
|
-
import_material.MenuItem,
|
|
578
|
-
{
|
|
579
|
-
onClick: () => handleStatusChange("idle"),
|
|
580
|
-
sx: {
|
|
581
|
-
backgroundColor: state.status === "idle" ? "#0038f01c" : "initial"
|
|
582
|
-
},
|
|
583
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
584
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.AirlineSeatIndividualSuite, { color: "warning" }),
|
|
585
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { children: "Idle" })
|
|
586
|
-
] })
|
|
587
|
-
}
|
|
588
|
-
)
|
|
589
|
-
]
|
|
1164
|
+
]
|
|
1165
|
+
}
|
|
1166
|
+
)
|
|
590
1167
|
}
|
|
591
1168
|
),
|
|
592
1169
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
@@ -605,9 +1182,13 @@ function CallControlPanel({ onDataChange }) {
|
|
|
605
1182
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Groups, { color: "secondary" }),
|
|
606
1183
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { children: "Conference Call" })
|
|
607
1184
|
] }) }),
|
|
608
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.MenuItem, { onClick: () =>
|
|
609
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.
|
|
610
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { children: "
|
|
1185
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.MenuItem, { onClick: () => handleStatusChange("break"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
1186
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.FreeBreakfast, { color: "secondary" }),
|
|
1187
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { children: "Break" })
|
|
1188
|
+
] }) }),
|
|
1189
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.MenuItem, { onClick: () => handleStatusChange("idle"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Box, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
|
|
1190
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.AirlineSeatIndividualSuite, { color: "secondary" }),
|
|
1191
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { children: "Idle" })
|
|
611
1192
|
] }) })
|
|
612
1193
|
]
|
|
613
1194
|
}
|
|
@@ -616,15 +1197,22 @@ function CallControlPanel({ onDataChange }) {
|
|
|
616
1197
|
}
|
|
617
1198
|
|
|
618
1199
|
// src/index.ts
|
|
619
|
-
function
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
1200
|
+
function initSDK({
|
|
1201
|
+
apiKey,
|
|
1202
|
+
tenantId,
|
|
1203
|
+
agentId,
|
|
1204
|
+
baseUrl
|
|
1205
|
+
}) {
|
|
1206
|
+
sdkStateManager.initialize(apiKey);
|
|
1207
|
+
eventTracker.init({
|
|
1208
|
+
apiKey,
|
|
1209
|
+
tenantId,
|
|
1210
|
+
agentId,
|
|
1211
|
+
baseUrl
|
|
1212
|
+
});
|
|
624
1213
|
}
|
|
625
1214
|
// Annotate the CommonJS export names for ESM import in node:
|
|
626
1215
|
0 && (module.exports = {
|
|
627
1216
|
CallControlPanel,
|
|
628
|
-
|
|
629
|
-
updateCallData
|
|
1217
|
+
initSDK
|
|
630
1218
|
});
|