@onedeskpro/chatbot-core 0.3.0 → 0.4.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 +8 -5
- package/dist/index.cjs +58 -26
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.iife.js +58 -26
- package/dist/index.js +583 -483
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
2
|
var e = Object.defineProperty, t = (t, n) => {
|
|
3
3
|
let r = {};
|
|
4
4
|
for (var i in t) e(r, i, {
|
|
@@ -15,10 +15,21 @@ function a(e) {
|
|
|
15
15
|
let t = e;
|
|
16
16
|
return typeof t.type == "string" && typeof t.url == "string" && typeof t.fileName == "string" && typeof t.size == "number";
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
var o = [
|
|
19
|
+
"ai",
|
|
20
|
+
"waiting",
|
|
21
|
+
"human",
|
|
22
|
+
"closed"
|
|
23
|
+
];
|
|
24
|
+
function s(e) {
|
|
25
|
+
if (typeof e != "object" || !e) return !1;
|
|
26
|
+
let t = e;
|
|
27
|
+
return typeof t.mode == "string" && o.includes(t.mode) && (t.conversationId === void 0 || typeof t.conversationId == "string") && (t.agentName === void 0 || typeof t.agentName == "string");
|
|
28
|
+
}
|
|
29
|
+
function c(e) {
|
|
19
30
|
return e instanceof Error && "apiError" in e && "status" in e && typeof e.status == "number" && i(e.apiError);
|
|
20
31
|
}
|
|
21
|
-
var
|
|
32
|
+
var l = class {
|
|
22
33
|
constructor(e) {
|
|
23
34
|
this.baseUrl = e.baseUrl.replace(/\/$/, ""), this.apiKey = e.apiKey, this.timeoutMs = e.timeoutMs ?? 3e4, this.uploadTimeoutMs = e.uploadTimeoutMs ?? r;
|
|
24
35
|
}
|
|
@@ -91,34 +102,43 @@ var s = class {
|
|
|
91
102
|
async requestHuman(e) {
|
|
92
103
|
return this.request("POST", "/sdk/human-request", { visitorToken: e });
|
|
93
104
|
}
|
|
105
|
+
async cancelHumanRequest(e) {
|
|
106
|
+
return this.postTicketAction("/sdk/human-request/cancel", e);
|
|
107
|
+
}
|
|
108
|
+
async closeConversation(e) {
|
|
109
|
+
return this.postTicketAction("/sdk/conversation/close", e);
|
|
110
|
+
}
|
|
111
|
+
async postTicketAction(e, t) {
|
|
112
|
+
let n = await this.request("POST", e, { visitorToken: t });
|
|
113
|
+
return s(n) || this.fail("The server returned an unexpected ticket status.", 200, "BAD_RESPONSE", e), n;
|
|
114
|
+
}
|
|
94
115
|
async fetchTicketStatus(e) {
|
|
95
116
|
return this.request("GET", "/sdk/ticket-status", void 0, void 0, { "X-Visitor-Token": e });
|
|
96
117
|
}
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
function d(e) {
|
|
118
|
+
}, u = "https://api.onedeskpro.com", d = 10485760, f = 10;
|
|
119
|
+
// src/attachments.ts
|
|
120
|
+
function p(e) {
|
|
101
121
|
if (e.length > 10) return "You can send up to 10 files at a time.";
|
|
102
|
-
let t = e.find((e) => e.size >
|
|
122
|
+
let t = e.find((e) => e.size > d);
|
|
103
123
|
if (t) {
|
|
104
|
-
let e = Math.round(
|
|
124
|
+
let e = Math.round(d / 1048576);
|
|
105
125
|
return `"${t.name || "This file"}" is larger than ${e} MB.`;
|
|
106
126
|
}
|
|
107
127
|
return null;
|
|
108
128
|
}
|
|
109
|
-
function
|
|
129
|
+
function m(e) {
|
|
110
130
|
return /^(https?:\/\/|blob:)/i.test(e);
|
|
111
131
|
}
|
|
112
|
-
function
|
|
132
|
+
function h(e) {
|
|
113
133
|
return typeof URL > "u" || typeof URL.createObjectURL != "function" ? "" : URL.createObjectURL(e);
|
|
114
134
|
}
|
|
115
|
-
function
|
|
135
|
+
function g(e) {
|
|
116
136
|
e.startsWith("blob:") && typeof URL < "u" && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
|
|
117
137
|
}
|
|
118
138
|
function ee(e) {
|
|
119
139
|
return {
|
|
120
140
|
type: e.type || "application/octet-stream",
|
|
121
|
-
url:
|
|
141
|
+
url: h(e),
|
|
122
142
|
fileName: e.name || "attachment",
|
|
123
143
|
size: e.size
|
|
124
144
|
};
|
|
@@ -153,16 +173,15 @@ function re(e, t) {
|
|
|
153
173
|
"Attachment"
|
|
154
174
|
].includes(n) : !0;
|
|
155
175
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
function g(e) {
|
|
176
|
+
// src/audio.ts
|
|
177
|
+
var _ = 16e3;
|
|
178
|
+
function v(e) {
|
|
160
179
|
return (e ?? "").split(";")[0].trim().toLowerCase() || "audio/webm";
|
|
161
180
|
}
|
|
162
181
|
function ie(e) {
|
|
163
182
|
return e.includes("mpeg") || e.includes("mp3") ? "mp3" : e.includes("wav") ? "wav" : e.includes("mp4") || e.includes("m4a") ? "m4a" : e.includes("ogg") ? "ogg" : "webm";
|
|
164
183
|
}
|
|
165
|
-
function
|
|
184
|
+
function y(e) {
|
|
166
185
|
if (!Number.isFinite(e) || e < 0) return "0:00";
|
|
167
186
|
let t = Math.floor(e), n = Math.floor(t / 60), r = t % 60;
|
|
168
187
|
return `${n}:${String(r).padStart(2, "0")}`;
|
|
@@ -193,10 +212,10 @@ async function se(e) {
|
|
|
193
212
|
async function ce(e) {
|
|
194
213
|
let t = oe();
|
|
195
214
|
if (t) try {
|
|
196
|
-
let n = new t(1, Math.max(1, Math.ceil(e.duration *
|
|
215
|
+
let n = new t(1, Math.max(1, Math.ceil(e.duration * _)), _), r = n.createBufferSource();
|
|
197
216
|
return r.buffer = e, r.connect(n.destination), r.start(0), {
|
|
198
217
|
samples: (await n.startRendering()).getChannelData(0),
|
|
199
|
-
sampleRate:
|
|
218
|
+
sampleRate: _
|
|
200
219
|
};
|
|
201
220
|
} catch {}
|
|
202
221
|
return {
|
|
@@ -231,7 +250,7 @@ function ue(e, t = 48) {
|
|
|
231
250
|
return r.map((e) => i > 0 ? Math.max(8, Math.min(100, Math.round(e / i * 100))) : 8);
|
|
232
251
|
}
|
|
233
252
|
async function de(e) {
|
|
234
|
-
let t = Date.now(), n = Math.max(1, Math.round(e.durationSeconds || 1)), r =
|
|
253
|
+
let t = Date.now(), n = Math.max(1, Math.round(e.durationSeconds || 1)), r = v(e.mimeType ?? e.blob.type), i = await se(e.blob);
|
|
235
254
|
if (!i) return {
|
|
236
255
|
file: new File([e.blob], `voice-message-${t}.${ie(r)}`, { type: r }),
|
|
237
256
|
durationSeconds: n
|
|
@@ -243,8 +262,7 @@ async function de(e) {
|
|
|
243
262
|
waveform: ue(a)
|
|
244
263
|
};
|
|
245
264
|
}
|
|
246
|
-
|
|
247
|
-
//#region src/event-emitter.ts
|
|
265
|
+
// src/event-emitter.ts
|
|
248
266
|
var fe = class {
|
|
249
267
|
constructor() {
|
|
250
268
|
this._listeners = {};
|
|
@@ -263,82 +281,81 @@ var fe = class {
|
|
|
263
281
|
removeAllListeners() {
|
|
264
282
|
for (let e of Object.keys(this._listeners)) delete this._listeners[e];
|
|
265
283
|
}
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
var
|
|
269
|
-
Object.keys(
|
|
270
|
-
|
|
284
|
+
}, b = Object.create(null);
|
|
285
|
+
b.open = "0", b.close = "1", b.ping = "2", b.pong = "3", b.message = "4", b.upgrade = "5", b.noop = "6";
|
|
286
|
+
var x = Object.create(null);
|
|
287
|
+
Object.keys(b).forEach((e) => {
|
|
288
|
+
x[b[e]] = e;
|
|
271
289
|
});
|
|
272
|
-
var
|
|
290
|
+
var pe = {
|
|
273
291
|
type: "error",
|
|
274
292
|
data: "parser error"
|
|
275
|
-
},
|
|
293
|
+
}, me = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", he = typeof ArrayBuffer == "function", ge = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e && e.buffer instanceof ArrayBuffer, S = ({ type: e, data: t }, n, r) => me && t instanceof Blob ? n ? r(t) : _e(t, r) : he && (t instanceof ArrayBuffer || ge(t)) ? n ? r(t) : _e(new Blob([t]), r) : r(b[e] + (t || "")), _e = (e, t) => {
|
|
276
294
|
let n = new FileReader();
|
|
277
295
|
return n.onload = function() {
|
|
278
296
|
let e = n.result.split(",")[1];
|
|
279
297
|
t("b" + (e || ""));
|
|
280
298
|
}, n.readAsDataURL(e);
|
|
281
299
|
};
|
|
282
|
-
function
|
|
300
|
+
function ve(e) {
|
|
283
301
|
return e instanceof Uint8Array ? e : e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
284
302
|
}
|
|
285
|
-
var
|
|
286
|
-
function
|
|
287
|
-
if (
|
|
288
|
-
if (
|
|
289
|
-
|
|
290
|
-
|
|
303
|
+
var ye;
|
|
304
|
+
function be(e, t) {
|
|
305
|
+
if (me && e.data instanceof Blob) return e.data.arrayBuffer().then(ve).then(t);
|
|
306
|
+
if (he && (e.data instanceof ArrayBuffer || ge(e.data))) return t(ve(e.data));
|
|
307
|
+
S(e, !1, (e) => {
|
|
308
|
+
ye ||= new TextEncoder(), t(ye.encode(e));
|
|
291
309
|
});
|
|
292
310
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
var xe = (e) => {
|
|
311
|
+
// ../../node_modules/.pnpm/engine.io-parser@5.2.3/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js
|
|
312
|
+
var xe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", C = typeof Uint8Array > "u" ? [] : /* @__PURE__ */ new Uint8Array(256);
|
|
313
|
+
for (let e = 0; e < 64; e++) C[xe.charCodeAt(e)] = e;
|
|
314
|
+
var Se = (e) => {
|
|
298
315
|
let t = e.length * .75, n = e.length, r, i = 0, a, o, s, c;
|
|
299
316
|
e[e.length - 1] === "=" && (t--, e[e.length - 2] === "=" && t--);
|
|
300
317
|
let l = new ArrayBuffer(t), u = new Uint8Array(l);
|
|
301
|
-
for (r = 0; r < n; r += 4) a =
|
|
318
|
+
for (r = 0; r < n; r += 4) a = C[e.charCodeAt(r)], o = C[e.charCodeAt(r + 1)], s = C[e.charCodeAt(r + 2)], c = C[e.charCodeAt(r + 3)], u[i++] = a << 2 | o >> 4, u[i++] = (o & 15) << 4 | s >> 2, u[i++] = (s & 3) << 6 | c & 63;
|
|
302
319
|
return l;
|
|
303
|
-
},
|
|
320
|
+
}, Ce = typeof ArrayBuffer == "function", w = (e, t) => {
|
|
304
321
|
if (typeof e != "string") return {
|
|
305
322
|
type: "message",
|
|
306
|
-
data:
|
|
323
|
+
data: Te(e, t)
|
|
307
324
|
};
|
|
308
325
|
let n = e.charAt(0);
|
|
309
326
|
return n === "b" ? {
|
|
310
327
|
type: "message",
|
|
311
|
-
data:
|
|
312
|
-
} :
|
|
313
|
-
type:
|
|
328
|
+
data: we(e.substring(1), t)
|
|
329
|
+
} : x[n] ? e.length > 1 ? {
|
|
330
|
+
type: x[n],
|
|
314
331
|
data: e.substring(1)
|
|
315
|
-
} : { type:
|
|
316
|
-
},
|
|
332
|
+
} : { type: x[n] } : pe;
|
|
333
|
+
}, we = (e, t) => Ce ? Te(Se(e), t) : {
|
|
317
334
|
base64: !0,
|
|
318
335
|
data: e
|
|
319
|
-
},
|
|
336
|
+
}, Te = (e, t) => {
|
|
320
337
|
switch (t) {
|
|
321
338
|
case "blob": return e instanceof Blob ? e : new Blob([e]);
|
|
322
339
|
default: return e instanceof ArrayBuffer ? e : e.buffer;
|
|
323
340
|
}
|
|
324
|
-
},
|
|
341
|
+
}, Ee = "", De = (e, t) => {
|
|
325
342
|
let n = e.length, r = Array(n), i = 0;
|
|
326
343
|
e.forEach((e, a) => {
|
|
327
|
-
|
|
328
|
-
r[a] = e, ++i === n && t(r.join(
|
|
344
|
+
S(e, !1, (e) => {
|
|
345
|
+
r[a] = e, ++i === n && t(r.join(Ee));
|
|
329
346
|
});
|
|
330
347
|
});
|
|
331
|
-
},
|
|
332
|
-
let n = e.split(
|
|
348
|
+
}, Oe = (e, t) => {
|
|
349
|
+
let n = e.split(Ee), r = [];
|
|
333
350
|
for (let e = 0; e < n.length; e++) {
|
|
334
|
-
let i =
|
|
351
|
+
let i = w(n[e], t);
|
|
335
352
|
if (r.push(i), i.type === "error") break;
|
|
336
353
|
}
|
|
337
354
|
return r;
|
|
338
355
|
};
|
|
339
|
-
function
|
|
356
|
+
function ke() {
|
|
340
357
|
return new TransformStream({ transform(e, t) {
|
|
341
|
-
|
|
358
|
+
be(e, (n) => {
|
|
342
359
|
let r = n.length, i;
|
|
343
360
|
if (r < 126) i = /* @__PURE__ */ new Uint8Array(1), new DataView(i.buffer).setUint8(0, r);
|
|
344
361
|
else if (r < 65536) {
|
|
@@ -354,66 +371,65 @@ function Oe() {
|
|
|
354
371
|
});
|
|
355
372
|
} });
|
|
356
373
|
}
|
|
357
|
-
var
|
|
358
|
-
function
|
|
374
|
+
var Ae;
|
|
375
|
+
function T(e) {
|
|
359
376
|
return e.reduce((e, t) => e + t.length, 0);
|
|
360
377
|
}
|
|
361
|
-
function
|
|
378
|
+
function E(e, t) {
|
|
362
379
|
if (e[0].length === t) return e.shift();
|
|
363
380
|
let n = new Uint8Array(t), r = 0;
|
|
364
381
|
for (let i = 0; i < t; i++) n[i] = e[0][r++], r === e[0].length && (e.shift(), r = 0);
|
|
365
382
|
return e.length && r < e[0].length && (e[0] = e[0].slice(r)), n;
|
|
366
383
|
}
|
|
367
|
-
function
|
|
368
|
-
|
|
384
|
+
function je(e, t) {
|
|
385
|
+
Ae ||= new TextDecoder();
|
|
369
386
|
let n = [], r = 0, i = -1, a = !1;
|
|
370
387
|
return new TransformStream({ transform(o, s) {
|
|
371
388
|
for (n.push(o);;) {
|
|
372
389
|
if (r === 0) {
|
|
373
|
-
if (
|
|
374
|
-
let e =
|
|
390
|
+
if (T(n) < 1) break;
|
|
391
|
+
let e = E(n, 1);
|
|
375
392
|
a = (e[0] & 128) == 128, i = e[0] & 127, r = i < 126 ? 3 : i === 126 ? 1 : 2;
|
|
376
393
|
} else if (r === 1) {
|
|
377
|
-
if (
|
|
378
|
-
let e =
|
|
394
|
+
if (T(n) < 2) break;
|
|
395
|
+
let e = E(n, 2);
|
|
379
396
|
i = new DataView(e.buffer, e.byteOffset, e.length).getUint16(0), r = 3;
|
|
380
397
|
} else if (r === 2) {
|
|
381
|
-
if (
|
|
382
|
-
let e =
|
|
398
|
+
if (T(n) < 8) break;
|
|
399
|
+
let e = E(n, 8), t = new DataView(e.buffer, e.byteOffset, e.length), a = t.getUint32(0);
|
|
383
400
|
if (a > 2 ** 21 - 1) {
|
|
384
|
-
s.enqueue(
|
|
401
|
+
s.enqueue(pe);
|
|
385
402
|
break;
|
|
386
403
|
}
|
|
387
404
|
i = a * 2 ** 32 + t.getUint32(4), r = 3;
|
|
388
405
|
} else {
|
|
389
|
-
if (
|
|
390
|
-
let e =
|
|
391
|
-
s.enqueue(
|
|
406
|
+
if (T(n) < i) break;
|
|
407
|
+
let e = E(n, i);
|
|
408
|
+
s.enqueue(w(a ? e : Ae.decode(e), t)), r = 0;
|
|
392
409
|
}
|
|
393
410
|
if (i === 0 || i > e) {
|
|
394
|
-
s.enqueue(
|
|
411
|
+
s.enqueue(pe);
|
|
395
412
|
break;
|
|
396
413
|
}
|
|
397
414
|
}
|
|
398
415
|
} });
|
|
399
416
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
if (e) return je(e);
|
|
417
|
+
// ../../node_modules/.pnpm/@socket.io+component-emitter@3.1.2/node_modules/@socket.io/component-emitter/lib/esm/index.js
|
|
418
|
+
function D(e) {
|
|
419
|
+
if (e) return Me(e);
|
|
404
420
|
}
|
|
405
|
-
function
|
|
406
|
-
for (var t in
|
|
421
|
+
function Me(e) {
|
|
422
|
+
for (var t in D.prototype) e[t] = D.prototype[t];
|
|
407
423
|
return e;
|
|
408
424
|
}
|
|
409
|
-
|
|
425
|
+
D.prototype.on = D.prototype.addEventListener = function(e, t) {
|
|
410
426
|
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + e] = this._callbacks["$" + e] || []).push(t), this;
|
|
411
|
-
},
|
|
427
|
+
}, D.prototype.once = function(e, t) {
|
|
412
428
|
function n() {
|
|
413
429
|
this.off(e, n), t.apply(this, arguments);
|
|
414
430
|
}
|
|
415
431
|
return n.fn = t, this.on(e, n), this;
|
|
416
|
-
},
|
|
432
|
+
}, D.prototype.off = D.prototype.removeListener = D.prototype.removeAllListeners = D.prototype.removeEventListener = function(e, t) {
|
|
417
433
|
if (this._callbacks = this._callbacks || {}, arguments.length == 0) return this._callbacks = {}, this;
|
|
418
434
|
var n = this._callbacks["$" + e];
|
|
419
435
|
if (!n) return this;
|
|
@@ -423,7 +439,7 @@ E.prototype.on = E.prototype.addEventListener = function(e, t) {
|
|
|
423
439
|
break;
|
|
424
440
|
}
|
|
425
441
|
return n.length === 0 && delete this._callbacks["$" + e], this;
|
|
426
|
-
},
|
|
442
|
+
}, D.prototype.emit = function(e) {
|
|
427
443
|
this._callbacks = this._callbacks || {};
|
|
428
444
|
for (var t = Array(arguments.length - 1), n = this._callbacks["$" + e], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
|
|
429
445
|
if (n) {
|
|
@@ -431,43 +447,40 @@ E.prototype.on = E.prototype.addEventListener = function(e, t) {
|
|
|
431
447
|
for (var r = 0, i = n.length; r < i; ++r) n[r].apply(this, t);
|
|
432
448
|
}
|
|
433
449
|
return this;
|
|
434
|
-
},
|
|
450
|
+
}, D.prototype.emitReserved = D.prototype.emit, D.prototype.listeners = function(e) {
|
|
435
451
|
return this._callbacks = this._callbacks || {}, this._callbacks["$" + e] || [];
|
|
436
|
-
},
|
|
452
|
+
}, D.prototype.hasListeners = function(e) {
|
|
437
453
|
return !!this.listeners(e).length;
|
|
438
454
|
};
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
//#region ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/util.js
|
|
444
|
-
function Ne(e, ...t) {
|
|
455
|
+
// ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/globals.js
|
|
456
|
+
var O = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), k = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Ne = "arraybuffer";
|
|
457
|
+
// ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/util.js
|
|
458
|
+
function Pe(e, ...t) {
|
|
445
459
|
return t.reduce((t, n) => (e.hasOwnProperty(n) && (t[n] = e[n]), t), {});
|
|
446
460
|
}
|
|
447
|
-
var
|
|
448
|
-
function
|
|
449
|
-
t.useNativeTimers ? (e.setTimeoutFn =
|
|
450
|
-
}
|
|
451
|
-
var Ie = 1.33;
|
|
452
|
-
function Le(e) {
|
|
453
|
-
return typeof e == "string" ? Re(e) : Math.ceil((e.byteLength || e.size) * Ie);
|
|
461
|
+
var Fe = k.setTimeout, Ie = k.clearTimeout;
|
|
462
|
+
function A(e, t) {
|
|
463
|
+
t.useNativeTimers ? (e.setTimeoutFn = Fe.bind(k), e.clearTimeoutFn = Ie.bind(k)) : (e.setTimeoutFn = k.setTimeout.bind(k), e.clearTimeoutFn = k.clearTimeout.bind(k));
|
|
454
464
|
}
|
|
465
|
+
var Le = 1.33;
|
|
455
466
|
function Re(e) {
|
|
467
|
+
return typeof e == "string" ? ze(e) : Math.ceil((e.byteLength || e.size) * Le);
|
|
468
|
+
}
|
|
469
|
+
function ze(e) {
|
|
456
470
|
let t = 0, n = 0;
|
|
457
471
|
for (let r = 0, i = e.length; r < i; r++) t = e.charCodeAt(r), t < 128 ? n += 1 : t < 2048 ? n += 2 : t < 55296 || t >= 57344 ? n += 3 : (r++, n += 4);
|
|
458
472
|
return n;
|
|
459
473
|
}
|
|
460
|
-
function
|
|
474
|
+
function Be() {
|
|
461
475
|
return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
|
|
462
476
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
function Be(e) {
|
|
477
|
+
// ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/contrib/parseqs.js
|
|
478
|
+
function Ve(e) {
|
|
466
479
|
let t = "";
|
|
467
480
|
for (let n in e) e.hasOwnProperty(n) && (t.length && (t += "&"), t += encodeURIComponent(n) + "=" + encodeURIComponent(e[n]));
|
|
468
481
|
return t;
|
|
469
482
|
}
|
|
470
|
-
function
|
|
483
|
+
function He(e) {
|
|
471
484
|
let t = {}, n = e.split("&");
|
|
472
485
|
for (let e = 0, r = n.length; e < r; e++) {
|
|
473
486
|
let r = n[e].split("=");
|
|
@@ -475,18 +488,17 @@ function Ve(e) {
|
|
|
475
488
|
}
|
|
476
489
|
return t;
|
|
477
490
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
var He = class extends Error {
|
|
491
|
+
// ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/transport.js
|
|
492
|
+
var Ue = class extends Error {
|
|
481
493
|
constructor(e, t, n) {
|
|
482
494
|
super(e), this.description = t, this.context = n, this.type = "TransportError";
|
|
483
495
|
}
|
|
484
|
-
},
|
|
496
|
+
}, j = class extends D {
|
|
485
497
|
constructor(e) {
|
|
486
|
-
super(), this.writable = !1,
|
|
498
|
+
super(), this.writable = !1, A(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
|
|
487
499
|
}
|
|
488
500
|
onError(e, t, n) {
|
|
489
|
-
return super.emitReserved("error", new
|
|
501
|
+
return super.emitReserved("error", new Ue(e, t, n)), this;
|
|
490
502
|
}
|
|
491
503
|
open() {
|
|
492
504
|
return this.readyState = "opening", this.doOpen(), this;
|
|
@@ -501,7 +513,7 @@ var He = class extends Error {
|
|
|
501
513
|
this.readyState = "open", this.writable = !0, super.emitReserved("open");
|
|
502
514
|
}
|
|
503
515
|
onData(e) {
|
|
504
|
-
let t =
|
|
516
|
+
let t = w(e, this.socket.binaryType);
|
|
505
517
|
this.onPacket(t);
|
|
506
518
|
}
|
|
507
519
|
onPacket(e) {
|
|
@@ -522,10 +534,10 @@ var He = class extends Error {
|
|
|
522
534
|
return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
|
|
523
535
|
}
|
|
524
536
|
_query(e) {
|
|
525
|
-
let t =
|
|
537
|
+
let t = Ve(e);
|
|
526
538
|
return t.length ? "?" + t : "";
|
|
527
539
|
}
|
|
528
|
-
},
|
|
540
|
+
}, We = class extends j {
|
|
529
541
|
constructor() {
|
|
530
542
|
super(...arguments), this._polling = !1;
|
|
531
543
|
}
|
|
@@ -553,7 +565,7 @@ var He = class extends Error {
|
|
|
553
565
|
this._polling = !0, this.doPoll(), this.emitReserved("poll");
|
|
554
566
|
}
|
|
555
567
|
onData(e) {
|
|
556
|
-
|
|
568
|
+
Oe(e, this.socket.binaryType).forEach((e) => {
|
|
557
569
|
if (this.readyState === "opening" && e.type === "open" && this.onOpen(), e.type === "close") return this.onClose({ description: "transport closed by the server" }), !1;
|
|
558
570
|
this.onPacket(e);
|
|
559
571
|
}), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
|
|
@@ -565,7 +577,7 @@ var He = class extends Error {
|
|
|
565
577
|
this.readyState === "open" ? e() : this.once("open", e);
|
|
566
578
|
}
|
|
567
579
|
write(e) {
|
|
568
|
-
this.writable = !1,
|
|
580
|
+
this.writable = !1, De(e, (e) => {
|
|
569
581
|
this.doWrite(e, () => {
|
|
570
582
|
this.writable = !0, this.emitReserved("drain");
|
|
571
583
|
});
|
|
@@ -573,17 +585,16 @@ var He = class extends Error {
|
|
|
573
585
|
}
|
|
574
586
|
uri() {
|
|
575
587
|
let e = this.opts.secure ? "https" : "http", t = this.query || {};
|
|
576
|
-
return !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] =
|
|
588
|
+
return !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] = Be()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
|
|
577
589
|
}
|
|
578
|
-
},
|
|
590
|
+
}, Ge = !1;
|
|
579
591
|
try {
|
|
580
|
-
|
|
592
|
+
Ge = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
|
|
581
593
|
} catch {}
|
|
582
|
-
var
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
var qe = class extends Ue {
|
|
594
|
+
var Ke = Ge;
|
|
595
|
+
// ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/transports/polling-xhr.js
|
|
596
|
+
function qe() {}
|
|
597
|
+
var Je = class extends We {
|
|
587
598
|
constructor(e) {
|
|
588
599
|
if (super(e), typeof location < "u") {
|
|
589
600
|
let t = location.protocol === "https:", n = location.port;
|
|
@@ -605,13 +616,13 @@ var qe = class extends Ue {
|
|
|
605
616
|
this.onError("xhr poll error", e, t);
|
|
606
617
|
}), this.pollXhr = e;
|
|
607
618
|
}
|
|
608
|
-
},
|
|
619
|
+
}, M = class e extends D {
|
|
609
620
|
constructor(e, t, n) {
|
|
610
|
-
super(), this.createRequest = e,
|
|
621
|
+
super(), this.createRequest = e, A(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data === void 0 ? null : n.data, this._create();
|
|
611
622
|
}
|
|
612
623
|
_create() {
|
|
613
624
|
var t;
|
|
614
|
-
let n =
|
|
625
|
+
let n = Pe(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
615
626
|
n.xdomain = !!this._opts.xd;
|
|
616
627
|
let r = this._xhr = this.createRequest(n);
|
|
617
628
|
try {
|
|
@@ -647,7 +658,7 @@ var qe = class extends Ue {
|
|
|
647
658
|
}
|
|
648
659
|
_cleanup(t) {
|
|
649
660
|
if (this._xhr !== void 0 && this._xhr !== null) {
|
|
650
|
-
if (this._xhr.onreadystatechange =
|
|
661
|
+
if (this._xhr.onreadystatechange = qe, t) try {
|
|
651
662
|
this._xhr.abort();
|
|
652
663
|
} catch {}
|
|
653
664
|
typeof document < "u" && delete e.requests[this._index], this._xhr = null;
|
|
@@ -661,46 +672,45 @@ var qe = class extends Ue {
|
|
|
661
672
|
this._cleanup();
|
|
662
673
|
}
|
|
663
674
|
};
|
|
664
|
-
if (
|
|
665
|
-
if (typeof attachEvent == "function") attachEvent("onunload",
|
|
675
|
+
if (M.requestsCount = 0, M.requests = {}, typeof document < "u") {
|
|
676
|
+
if (typeof attachEvent == "function") attachEvent("onunload", Ye);
|
|
666
677
|
else if (typeof addEventListener == "function") {
|
|
667
|
-
let e = "onpagehide" in
|
|
668
|
-
addEventListener(e,
|
|
678
|
+
let e = "onpagehide" in k ? "pagehide" : "unload";
|
|
679
|
+
addEventListener(e, Ye, !1);
|
|
669
680
|
}
|
|
670
681
|
}
|
|
671
|
-
function
|
|
672
|
-
for (let e in
|
|
682
|
+
function Ye() {
|
|
683
|
+
for (let e in M.requests) M.requests.hasOwnProperty(e) && M.requests[e].abort();
|
|
673
684
|
}
|
|
674
|
-
var
|
|
675
|
-
let e =
|
|
685
|
+
var Xe = (function() {
|
|
686
|
+
let e = Qe({ xdomain: !1 });
|
|
676
687
|
return e && e.responseType !== null;
|
|
677
|
-
})(),
|
|
688
|
+
})(), Ze = class extends Je {
|
|
678
689
|
constructor(e) {
|
|
679
690
|
super(e);
|
|
680
691
|
let t = e && e.forceBase64;
|
|
681
|
-
this.supportsBinary =
|
|
692
|
+
this.supportsBinary = Xe && !t;
|
|
682
693
|
}
|
|
683
694
|
request(e = {}) {
|
|
684
|
-
return Object.assign(e, { xd: this.xd }, this.opts), new
|
|
695
|
+
return Object.assign(e, { xd: this.xd }, this.opts), new M(Qe, this.uri(), e);
|
|
685
696
|
}
|
|
686
697
|
};
|
|
687
|
-
function
|
|
698
|
+
function Qe(e) {
|
|
688
699
|
let t = e.xdomain;
|
|
689
700
|
try {
|
|
690
|
-
if (typeof XMLHttpRequest < "u" && (!t ||
|
|
701
|
+
if (typeof XMLHttpRequest < "u" && (!t || Ke)) return new XMLHttpRequest();
|
|
691
702
|
} catch {}
|
|
692
703
|
if (!t) try {
|
|
693
|
-
return new
|
|
704
|
+
return new k.ActiveXObject("Microsoft.XMLHTTP");
|
|
694
705
|
} catch {}
|
|
695
706
|
}
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
var Qe = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", $e = class extends A {
|
|
707
|
+
// ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/transports/websocket.js
|
|
708
|
+
var $e = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", et = class extends j {
|
|
699
709
|
get name() {
|
|
700
710
|
return "websocket";
|
|
701
711
|
}
|
|
702
712
|
doOpen() {
|
|
703
|
-
let e = this.uri(), t = this.opts.protocols, n =
|
|
713
|
+
let e = this.uri(), t = this.opts.protocols, n = $e ? {} : Pe(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
|
704
714
|
this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
|
|
705
715
|
try {
|
|
706
716
|
this.ws = this.createSocket(e, t, n);
|
|
@@ -721,11 +731,11 @@ var Qe = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
721
731
|
this.writable = !1;
|
|
722
732
|
for (let t = 0; t < e.length; t++) {
|
|
723
733
|
let n = e[t], r = t === e.length - 1;
|
|
724
|
-
|
|
734
|
+
S(n, this.supportsBinary, (e) => {
|
|
725
735
|
try {
|
|
726
736
|
this.doWrite(n, e);
|
|
727
737
|
} catch {}
|
|
728
|
-
r &&
|
|
738
|
+
r && O(() => {
|
|
729
739
|
this.writable = !0, this.emitReserved("drain");
|
|
730
740
|
}, this.setTimeoutFn);
|
|
731
741
|
});
|
|
@@ -736,18 +746,18 @@ var Qe = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
736
746
|
}
|
|
737
747
|
uri() {
|
|
738
748
|
let e = this.opts.secure ? "wss" : "ws", t = this.query || {};
|
|
739
|
-
return this.opts.timestampRequests && (t[this.opts.timestampParam] =
|
|
749
|
+
return this.opts.timestampRequests && (t[this.opts.timestampParam] = Be()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
|
|
740
750
|
}
|
|
741
|
-
},
|
|
742
|
-
websocket: class extends
|
|
751
|
+
}, N = k.WebSocket || k.MozWebSocket, tt = {
|
|
752
|
+
websocket: class extends et {
|
|
743
753
|
createSocket(e, t, n) {
|
|
744
|
-
return
|
|
754
|
+
return $e ? new N(e, t, n) : t ? new N(e, t) : new N(e);
|
|
745
755
|
}
|
|
746
756
|
doWrite(e, t) {
|
|
747
757
|
this.ws.send(t);
|
|
748
758
|
}
|
|
749
759
|
},
|
|
750
|
-
webtransport: class extends
|
|
760
|
+
webtransport: class extends j {
|
|
751
761
|
get name() {
|
|
752
762
|
return "webtransport";
|
|
753
763
|
}
|
|
@@ -763,7 +773,7 @@ var Qe = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
763
773
|
this.onError("webtransport error", e);
|
|
764
774
|
}), this._transport.ready.then(() => {
|
|
765
775
|
this._transport.createBidirectionalStream().then((e) => {
|
|
766
|
-
let t =
|
|
776
|
+
let t = je(2 ** 53 - 1, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = ke();
|
|
767
777
|
r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
|
|
768
778
|
let i = () => {
|
|
769
779
|
n.read().then(({ done: e, value: t }) => {
|
|
@@ -781,7 +791,7 @@ var Qe = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
781
791
|
for (let t = 0; t < e.length; t++) {
|
|
782
792
|
let n = e[t], r = t === e.length - 1;
|
|
783
793
|
this._writer.write(n).then(() => {
|
|
784
|
-
r &&
|
|
794
|
+
r && O(() => {
|
|
785
795
|
this.writable = !0, this.emitReserved("drain");
|
|
786
796
|
}, this.setTimeoutFn);
|
|
787
797
|
});
|
|
@@ -792,8 +802,8 @@ var Qe = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
792
802
|
(e = this._transport) == null || e.close();
|
|
793
803
|
}
|
|
794
804
|
},
|
|
795
|
-
polling:
|
|
796
|
-
},
|
|
805
|
+
polling: Ze
|
|
806
|
+
}, nt = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, rt = [
|
|
797
807
|
"source",
|
|
798
808
|
"protocol",
|
|
799
809
|
"authority",
|
|
@@ -809,37 +819,36 @@ var Qe = typeof navigator < "u" && typeof navigator.product == "string" && navig
|
|
|
809
819
|
"query",
|
|
810
820
|
"anchor"
|
|
811
821
|
];
|
|
812
|
-
function
|
|
822
|
+
function P(e) {
|
|
813
823
|
if (e.length > 8e3) throw "URI too long";
|
|
814
824
|
let t = e, n = e.indexOf("["), r = e.indexOf("]");
|
|
815
825
|
n != -1 && r != -1 && (e = e.substring(0, n) + e.substring(n, r).replace(/:/g, ";") + e.substring(r, e.length));
|
|
816
|
-
let i =
|
|
817
|
-
for (; o--;) a[
|
|
818
|
-
return n != -1 && r != -1 && (a.source = t, a.host = a.host.substring(1, a.host.length - 1).replace(/;/g, ":"), a.authority = a.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), a.ipv6uri = !0), a.pathNames =
|
|
826
|
+
let i = nt.exec(e || ""), a = {}, o = 14;
|
|
827
|
+
for (; o--;) a[rt[o]] = i[o] || "";
|
|
828
|
+
return n != -1 && r != -1 && (a.source = t, a.host = a.host.substring(1, a.host.length - 1).replace(/;/g, ":"), a.authority = a.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), a.ipv6uri = !0), a.pathNames = it(a, a.path), a.queryKey = at(a, a.query), a;
|
|
819
829
|
}
|
|
820
|
-
function
|
|
830
|
+
function it(e, t) {
|
|
821
831
|
let n = t.replace(/\/{2,9}/g, "/").split("/");
|
|
822
832
|
return (t.slice(0, 1) == "/" || t.length === 0) && n.splice(0, 1), t.slice(-1) == "/" && n.splice(n.length - 1, 1), n;
|
|
823
833
|
}
|
|
824
|
-
function
|
|
834
|
+
function at(e, t) {
|
|
825
835
|
let n = {};
|
|
826
836
|
return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(e, t, r) {
|
|
827
837
|
t && (n[t] = r);
|
|
828
838
|
}), n;
|
|
829
839
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
F.forEach((e) => e());
|
|
840
|
+
// ../../node_modules/.pnpm/engine.io-client@6.6.6_supports-color@8.1.1/node_modules/engine.io-client/build/esm/socket.js
|
|
841
|
+
var F = typeof addEventListener == "function" && typeof removeEventListener == "function", I = [];
|
|
842
|
+
F && addEventListener("offline", () => {
|
|
843
|
+
I.forEach((e) => e());
|
|
835
844
|
}, !1);
|
|
836
|
-
var
|
|
845
|
+
var L = class e extends D {
|
|
837
846
|
constructor(e, t) {
|
|
838
|
-
if (super(), this.binaryType =
|
|
839
|
-
let n =
|
|
847
|
+
if (super(), this.binaryType = Ne, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = Infinity, e && typeof e == "object" && (t = e, e = null), e) {
|
|
848
|
+
let n = P(e);
|
|
840
849
|
t.hostname = n.host, t.secure = n.protocol === "https" || n.protocol === "wss", t.port = n.port, n.query && (t.query = n.query);
|
|
841
|
-
} else t.host && (t.hostname =
|
|
842
|
-
|
|
850
|
+
} else t.host && (t.hostname = P(t.host).host);
|
|
851
|
+
A(this, t), this.secure = t.secure == null ? typeof location < "u" && location.protocol === "https:" : t.secure, t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((e) => {
|
|
843
852
|
let t = e.prototype.name;
|
|
844
853
|
this.transports.push(t), this._transportsByName[t] = e;
|
|
845
854
|
}), this.opts = Object.assign({
|
|
@@ -854,11 +863,11 @@ var I = class e extends E {
|
|
|
854
863
|
perMessageDeflate: { threshold: 1024 },
|
|
855
864
|
transportOptions: {},
|
|
856
865
|
closeOnBeforeunload: !1
|
|
857
|
-
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query =
|
|
866
|
+
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = He(this.opts.query)), F && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
|
|
858
867
|
this.transport && (this.transport.removeAllListeners(), this.transport.close());
|
|
859
868
|
}, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
|
|
860
869
|
this._onClose("transport close", { description: "network connection lost" });
|
|
861
|
-
},
|
|
870
|
+
}, I.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
|
|
862
871
|
}
|
|
863
872
|
createTransport(e) {
|
|
864
873
|
let t = Object.assign({}, this.opts.query);
|
|
@@ -929,7 +938,7 @@ var I = class e extends E {
|
|
|
929
938
|
let e = 1;
|
|
930
939
|
for (let t = 0; t < this.writeBuffer.length; t++) {
|
|
931
940
|
let n = this.writeBuffer[t].data;
|
|
932
|
-
if (n && (e +=
|
|
941
|
+
if (n && (e += Re(n)), t > 0 && e > this._maxPayload) return this.writeBuffer.slice(0, t);
|
|
933
942
|
e += 2;
|
|
934
943
|
}
|
|
935
944
|
return this.writeBuffer;
|
|
@@ -937,7 +946,7 @@ var I = class e extends E {
|
|
|
937
946
|
_hasPingExpired() {
|
|
938
947
|
if (!this._pingTimeoutTime) return !0;
|
|
939
948
|
let e = Date.now() > this._pingTimeoutTime;
|
|
940
|
-
return e && (this._pingTimeoutTime = 0,
|
|
949
|
+
return e && (this._pingTimeoutTime = 0, O(() => {
|
|
941
950
|
this._onClose("ping timeout");
|
|
942
951
|
}, this.setTimeoutFn)), e;
|
|
943
952
|
}
|
|
@@ -975,16 +984,16 @@ var I = class e extends E {
|
|
|
975
984
|
}
|
|
976
985
|
_onClose(e, t) {
|
|
977
986
|
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
|
|
978
|
-
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(),
|
|
979
|
-
let e =
|
|
980
|
-
e !== -1 &&
|
|
987
|
+
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), F && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
|
|
988
|
+
let e = I.indexOf(this._offlineEventListener);
|
|
989
|
+
e !== -1 && I.splice(e, 1);
|
|
981
990
|
}
|
|
982
991
|
this.readyState = "closed", this.id = null, this.emitReserved("close", e, t), this.writeBuffer = [], this._prevBufferLen = 0;
|
|
983
992
|
}
|
|
984
993
|
}
|
|
985
994
|
};
|
|
986
|
-
|
|
987
|
-
var
|
|
995
|
+
L.protocol = 4;
|
|
996
|
+
var ot = class extends L {
|
|
988
997
|
constructor() {
|
|
989
998
|
super(...arguments), this._upgrades = [];
|
|
990
999
|
}
|
|
@@ -993,7 +1002,7 @@ var at = class extends I {
|
|
|
993
1002
|
}
|
|
994
1003
|
_probe(e) {
|
|
995
1004
|
let t = this.createTransport(e), n = !1;
|
|
996
|
-
|
|
1005
|
+
L.priorWebsocketSuccess = !1;
|
|
997
1006
|
let r = () => {
|
|
998
1007
|
n || (t.send([{
|
|
999
1008
|
type: "ping",
|
|
@@ -1002,7 +1011,7 @@ var at = class extends I {
|
|
|
1002
1011
|
if (!n) {
|
|
1003
1012
|
if (e.type === "pong" && e.data === "probe") {
|
|
1004
1013
|
if (this.upgrading = !0, this.emitReserved("upgrading", t), !t) return;
|
|
1005
|
-
|
|
1014
|
+
L.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
|
|
1006
1015
|
n || this.readyState !== "closed" && (l(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
|
|
1007
1016
|
});
|
|
1008
1017
|
} else {
|
|
@@ -1043,54 +1052,51 @@ var at = class extends I {
|
|
|
1043
1052
|
for (let n = 0; n < e.length; n++) ~this.transports.indexOf(e[n]) && t.push(e[n]);
|
|
1044
1053
|
return t;
|
|
1045
1054
|
}
|
|
1046
|
-
},
|
|
1055
|
+
}, st = class extends ot {
|
|
1047
1056
|
constructor(e, t = {}) {
|
|
1048
1057
|
let n = typeof e == "object", r = n ? { ...e } : { ...t };
|
|
1049
1058
|
(!r.transports || r.transports && typeof r.transports[0] == "string") && (r.transports = (r.transports || [
|
|
1050
1059
|
"polling",
|
|
1051
1060
|
"websocket",
|
|
1052
1061
|
"webtransport"
|
|
1053
|
-
]).map((e) =>
|
|
1062
|
+
]).map((e) => tt[e]).filter((e) => !!e)), super(n ? r : e, r);
|
|
1054
1063
|
}
|
|
1055
1064
|
};
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
function st(e, t = "", n) {
|
|
1065
|
+
st.protocol;
|
|
1066
|
+
// ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/url.js
|
|
1067
|
+
function ct(e, t = "", n) {
|
|
1060
1068
|
let r = e;
|
|
1061
|
-
n ||= typeof location < "u" && location, e ??= n.protocol + "//" + n.host, typeof e == "string" && (e.charAt(0) === "/" && (e = e.charAt(1) === "/" ? n.protocol + e : n.host + e), /^(https?|wss?):\/\//.test(e) || (e = n === void 0 ? "https://" + e : n.protocol + "//" + e), r =
|
|
1069
|
+
n ||= typeof location < "u" && location, e ??= n.protocol + "//" + n.host, typeof e == "string" && (e.charAt(0) === "/" && (e = e.charAt(1) === "/" ? n.protocol + e : n.host + e), /^(https?|wss?):\/\//.test(e) || (e = n === void 0 ? "https://" + e : n.protocol + "//" + e), r = P(e)), r.port || (/^(http|ws)$/.test(r.protocol) ? r.port = "80" : /^(http|ws)s$/.test(r.protocol) && (r.port = "443")), r.path = r.path || "/";
|
|
1062
1070
|
let i = r.host.indexOf(":") === -1 ? r.host : "[" + r.host + "]";
|
|
1063
1071
|
return r.id = r.protocol + "://" + i + ":" + r.port + t, r.href = r.protocol + "://" + i + (n && n.port === r.port ? "" : ":" + r.port), r;
|
|
1064
1072
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
return ct && (e instanceof ArrayBuffer || lt(e)) || dt && e instanceof Blob || ft && e instanceof File;
|
|
1073
|
+
// ../../node_modules/.pnpm/socket.io-parser@4.2.7_supports-color@8.1.1/node_modules/socket.io-parser/build/esm/is-binary.js
|
|
1074
|
+
var lt = typeof ArrayBuffer == "function", ut = (e) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(e) : e.buffer instanceof ArrayBuffer, dt = Object.prototype.toString, ft = typeof Blob == "function" || typeof Blob < "u" && dt.call(Blob) === "[object BlobConstructor]", pt = typeof File == "function" || typeof File < "u" && dt.call(File) === "[object FileConstructor]";
|
|
1075
|
+
function R(e) {
|
|
1076
|
+
return lt && (e instanceof ArrayBuffer || ut(e)) || ft && e instanceof Blob || pt && e instanceof File;
|
|
1070
1077
|
}
|
|
1071
|
-
function
|
|
1078
|
+
function z(e, t) {
|
|
1072
1079
|
if (!e || typeof e != "object") return !1;
|
|
1073
1080
|
if (Array.isArray(e)) {
|
|
1074
|
-
for (let t = 0, n = e.length; t < n; t++) if (
|
|
1081
|
+
for (let t = 0, n = e.length; t < n; t++) if (z(e[t])) return !0;
|
|
1075
1082
|
return !1;
|
|
1076
1083
|
}
|
|
1077
|
-
if (
|
|
1078
|
-
if (e.toJSON && typeof e.toJSON == "function" && arguments.length === 1) return
|
|
1079
|
-
for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) &&
|
|
1084
|
+
if (R(e)) return !0;
|
|
1085
|
+
if (e.toJSON && typeof e.toJSON == "function" && arguments.length === 1) return z(e.toJSON(), !0);
|
|
1086
|
+
for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) && z(e[t])) return !0;
|
|
1080
1087
|
return !1;
|
|
1081
1088
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
function pt(e) {
|
|
1089
|
+
// ../../node_modules/.pnpm/socket.io-parser@4.2.7_supports-color@8.1.1/node_modules/socket.io-parser/build/esm/binary.js
|
|
1090
|
+
function mt(e) {
|
|
1085
1091
|
let t = [], n = e.data, r = e;
|
|
1086
|
-
return r.data =
|
|
1092
|
+
return r.data = B(n, t), r.attachments = t.length, {
|
|
1087
1093
|
packet: r,
|
|
1088
1094
|
buffers: t
|
|
1089
1095
|
};
|
|
1090
1096
|
}
|
|
1091
|
-
function
|
|
1097
|
+
function B(e, t, n) {
|
|
1092
1098
|
if (!e) return e;
|
|
1093
|
-
if (
|
|
1099
|
+
if (R(e)) {
|
|
1094
1100
|
let n = {
|
|
1095
1101
|
_placeholder: !0,
|
|
1096
1102
|
num: t.length
|
|
@@ -1099,56 +1105,55 @@ function z(e, t, n) {
|
|
|
1099
1105
|
}
|
|
1100
1106
|
if (Array.isArray(e)) {
|
|
1101
1107
|
let n = Array(e.length);
|
|
1102
|
-
for (let r = 0; r < e.length; r++) n[r] =
|
|
1108
|
+
for (let r = 0; r < e.length; r++) n[r] = B(e[r], t);
|
|
1103
1109
|
return n;
|
|
1104
1110
|
}
|
|
1105
1111
|
if (typeof e == "object" && !(e instanceof Date)) {
|
|
1106
|
-
if (e.toJSON && typeof e.toJSON == "function" && !n) return
|
|
1112
|
+
if (e.toJSON && typeof e.toJSON == "function" && !n) return B(e.toJSON(), t, !0);
|
|
1107
1113
|
let r = {};
|
|
1108
|
-
for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && (r[n] =
|
|
1114
|
+
for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && (r[n] = B(e[n], t));
|
|
1109
1115
|
return r;
|
|
1110
1116
|
}
|
|
1111
1117
|
return e;
|
|
1112
1118
|
}
|
|
1113
|
-
function
|
|
1114
|
-
return e.data =
|
|
1119
|
+
function ht(e, t) {
|
|
1120
|
+
return e.data = V(e.data, t), delete e.attachments, e;
|
|
1115
1121
|
}
|
|
1116
|
-
function
|
|
1122
|
+
function V(e, t) {
|
|
1117
1123
|
if (!e) return e;
|
|
1118
1124
|
if (e && e._placeholder === !0) {
|
|
1119
1125
|
if (typeof e.num == "number" && e.num >= 0 && e.num < t.length) return t[e.num];
|
|
1120
1126
|
throw Error("illegal attachments");
|
|
1121
1127
|
}
|
|
1122
|
-
if (Array.isArray(e)) for (let n = 0; n < e.length; n++) e[n] =
|
|
1123
|
-
else if (typeof e == "object") for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && (e[n] =
|
|
1128
|
+
if (Array.isArray(e)) for (let n = 0; n < e.length; n++) e[n] = V(e[n], t);
|
|
1129
|
+
else if (typeof e == "object") for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && (e[n] = V(e[n], t));
|
|
1124
1130
|
return e;
|
|
1125
1131
|
}
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
isPacketValid: () => wt,
|
|
1132
|
+
// ../../node_modules/.pnpm/socket.io-parser@4.2.7_supports-color@8.1.1/node_modules/socket.io-parser/build/esm/index.js
|
|
1133
|
+
var gt = /* @__PURE__ */ t({
|
|
1134
|
+
Decoder: () => yt,
|
|
1135
|
+
Encoder: () => vt,
|
|
1136
|
+
PacketType: () => H,
|
|
1137
|
+
isPacketValid: () => Tt,
|
|
1133
1138
|
protocol: () => 5
|
|
1134
|
-
}),
|
|
1139
|
+
}), _t = [
|
|
1135
1140
|
"connect",
|
|
1136
1141
|
"connect_error",
|
|
1137
1142
|
"disconnect",
|
|
1138
1143
|
"disconnecting",
|
|
1139
1144
|
"newListener",
|
|
1140
1145
|
"removeListener"
|
|
1141
|
-
],
|
|
1146
|
+
], H;
|
|
1142
1147
|
(function(e) {
|
|
1143
1148
|
e[e.CONNECT = 0] = "CONNECT", e[e.DISCONNECT = 1] = "DISCONNECT", e[e.EVENT = 2] = "EVENT", e[e.ACK = 3] = "ACK", e[e.CONNECT_ERROR = 4] = "CONNECT_ERROR", e[e.BINARY_EVENT = 5] = "BINARY_EVENT", e[e.BINARY_ACK = 6] = "BINARY_ACK";
|
|
1144
|
-
})(
|
|
1145
|
-
var
|
|
1149
|
+
})(H ||= {});
|
|
1150
|
+
var vt = class {
|
|
1146
1151
|
constructor(e) {
|
|
1147
1152
|
this.replacer = e;
|
|
1148
1153
|
}
|
|
1149
1154
|
encode(e) {
|
|
1150
|
-
return (e.type ===
|
|
1151
|
-
type: e.type ===
|
|
1155
|
+
return (e.type === H.EVENT || e.type === H.ACK) && z(e) ? this.encodeAsBinary({
|
|
1156
|
+
type: e.type === H.EVENT ? H.BINARY_EVENT : H.BINARY_ACK,
|
|
1152
1157
|
nsp: e.nsp,
|
|
1153
1158
|
data: e.data,
|
|
1154
1159
|
id: e.id
|
|
@@ -1156,13 +1161,13 @@ var _t = class {
|
|
|
1156
1161
|
}
|
|
1157
1162
|
encodeAsString(e) {
|
|
1158
1163
|
let t = "" + e.type;
|
|
1159
|
-
return (e.type ===
|
|
1164
|
+
return (e.type === H.BINARY_EVENT || e.type === H.BINARY_ACK) && (t += e.attachments + "-"), e.nsp && e.nsp !== "/" && (t += e.nsp + ","), e.id != null && (t += e.id), e.data != null && (t += JSON.stringify(e.data, this.replacer)), t;
|
|
1160
1165
|
}
|
|
1161
1166
|
encodeAsBinary(e) {
|
|
1162
|
-
let t =
|
|
1167
|
+
let t = mt(e), n = this.encodeAsString(t.packet), r = t.buffers;
|
|
1163
1168
|
return r.unshift(n), r;
|
|
1164
1169
|
}
|
|
1165
|
-
},
|
|
1170
|
+
}, yt = class e extends D {
|
|
1166
1171
|
constructor(e) {
|
|
1167
1172
|
super(), this.opts = Object.assign({
|
|
1168
1173
|
reviver: void 0,
|
|
@@ -1174,23 +1179,23 @@ var _t = class {
|
|
|
1174
1179
|
if (typeof e == "string") {
|
|
1175
1180
|
if (this.reconstructor) throw Error("got plaintext data when reconstructing a packet");
|
|
1176
1181
|
t = this.decodeString(e);
|
|
1177
|
-
let n = t.type ===
|
|
1178
|
-
n || t.type ===
|
|
1179
|
-
} else if (
|
|
1182
|
+
let n = t.type === H.BINARY_EVENT;
|
|
1183
|
+
n || t.type === H.BINARY_ACK ? (t.type = n ? H.EVENT : H.ACK, this.reconstructor = new bt(t)) : super.emitReserved("decoded", t);
|
|
1184
|
+
} else if (R(e) || e.base64) {
|
|
1180
1185
|
if (this.reconstructor) t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
|
|
1181
1186
|
else throw Error("got binary data when not reconstructing a packet");
|
|
1182
1187
|
} else throw Error("Unknown type: " + e);
|
|
1183
1188
|
}
|
|
1184
1189
|
decodeString(t) {
|
|
1185
1190
|
let n = 0, r = { type: Number(t.charAt(0)) };
|
|
1186
|
-
if (
|
|
1187
|
-
if (r.type ===
|
|
1191
|
+
if (H[r.type] === void 0) throw Error("unknown packet type " + r.type);
|
|
1192
|
+
if (r.type === H.BINARY_EVENT || r.type === H.BINARY_ACK) {
|
|
1188
1193
|
let e = n + 1;
|
|
1189
1194
|
for (; t.charAt(++n) !== "-" && n != t.length;);
|
|
1190
1195
|
let i = t.substring(e, n);
|
|
1191
1196
|
if (i != Number(i) || t.charAt(n) !== "-") throw Error("Illegal attachments");
|
|
1192
1197
|
let a = Number(i);
|
|
1193
|
-
if (!
|
|
1198
|
+
if (!St(a) || a < 1) throw Error("Illegal attachments");
|
|
1194
1199
|
if (a > this.opts.maxAttachments) throw Error("too many attachments");
|
|
1195
1200
|
r.attachments = a;
|
|
1196
1201
|
}
|
|
@@ -1228,25 +1233,25 @@ var _t = class {
|
|
|
1228
1233
|
}
|
|
1229
1234
|
static isPayloadValid(e, t) {
|
|
1230
1235
|
switch (e) {
|
|
1231
|
-
case
|
|
1232
|
-
case
|
|
1233
|
-
case
|
|
1234
|
-
case
|
|
1235
|
-
case
|
|
1236
|
-
case
|
|
1237
|
-
case
|
|
1236
|
+
case H.CONNECT: return U(t);
|
|
1237
|
+
case H.DISCONNECT: return t === void 0;
|
|
1238
|
+
case H.CONNECT_ERROR: return typeof t == "string" || U(t);
|
|
1239
|
+
case H.EVENT:
|
|
1240
|
+
case H.BINARY_EVENT: return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && _t.indexOf(t[0]) === -1);
|
|
1241
|
+
case H.ACK:
|
|
1242
|
+
case H.BINARY_ACK: return Array.isArray(t);
|
|
1238
1243
|
}
|
|
1239
1244
|
}
|
|
1240
1245
|
destroy() {
|
|
1241
1246
|
this.reconstructor &&= (this.reconstructor.finishedReconstruction(), null);
|
|
1242
1247
|
}
|
|
1243
|
-
},
|
|
1248
|
+
}, bt = class {
|
|
1244
1249
|
constructor(e) {
|
|
1245
1250
|
this.packet = e, this.buffers = [], this.reconPack = e;
|
|
1246
1251
|
}
|
|
1247
1252
|
takeBinaryData(e) {
|
|
1248
1253
|
if (this.buffers.push(e), this.buffers.length === this.reconPack.attachments) {
|
|
1249
|
-
let e =
|
|
1254
|
+
let e = ht(this.reconPack, this.buffers);
|
|
1250
1255
|
return this.finishedReconstruction(), e;
|
|
1251
1256
|
}
|
|
1252
1257
|
return null;
|
|
@@ -1255,48 +1260,46 @@ var _t = class {
|
|
|
1255
1260
|
this.reconPack = null, this.buffers = [];
|
|
1256
1261
|
}
|
|
1257
1262
|
};
|
|
1258
|
-
function
|
|
1263
|
+
function xt(e) {
|
|
1259
1264
|
return typeof e == "string";
|
|
1260
1265
|
}
|
|
1261
|
-
var
|
|
1266
|
+
var St = Number.isInteger || function(e) {
|
|
1262
1267
|
return typeof e == "number" && isFinite(e) && Math.floor(e) === e;
|
|
1263
1268
|
};
|
|
1264
|
-
function
|
|
1265
|
-
return e === void 0 ||
|
|
1269
|
+
function Ct(e) {
|
|
1270
|
+
return e === void 0 || St(e);
|
|
1266
1271
|
}
|
|
1267
|
-
function
|
|
1272
|
+
function U(e) {
|
|
1268
1273
|
return Object.prototype.toString.call(e) === "[object Object]";
|
|
1269
1274
|
}
|
|
1270
|
-
function
|
|
1275
|
+
function wt(e, t) {
|
|
1271
1276
|
switch (e) {
|
|
1272
|
-
case
|
|
1273
|
-
case
|
|
1274
|
-
case
|
|
1275
|
-
case
|
|
1276
|
-
case
|
|
1277
|
+
case H.CONNECT: return t === void 0 || U(t);
|
|
1278
|
+
case H.DISCONNECT: return t === void 0;
|
|
1279
|
+
case H.EVENT: return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && _t.indexOf(t[0]) === -1);
|
|
1280
|
+
case H.ACK: return Array.isArray(t);
|
|
1281
|
+
case H.CONNECT_ERROR: return typeof t == "string" || U(t);
|
|
1277
1282
|
default: return !1;
|
|
1278
1283
|
}
|
|
1279
1284
|
}
|
|
1280
|
-
function
|
|
1281
|
-
return
|
|
1285
|
+
function Tt(e) {
|
|
1286
|
+
return xt(e.nsp) && Ct(e.id) && wt(e.type, e.data);
|
|
1282
1287
|
}
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
function U(e, t, n) {
|
|
1288
|
+
// ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/on.js
|
|
1289
|
+
function W(e, t, n) {
|
|
1286
1290
|
return e.on(t, n), function() {
|
|
1287
1291
|
e.off(t, n);
|
|
1288
1292
|
};
|
|
1289
1293
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
var Tt = Object.freeze({
|
|
1294
|
+
// ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/socket.js
|
|
1295
|
+
var Et = Object.freeze({
|
|
1293
1296
|
connect: 1,
|
|
1294
1297
|
connect_error: 1,
|
|
1295
1298
|
disconnect: 1,
|
|
1296
1299
|
disconnecting: 1,
|
|
1297
1300
|
newListener: 1,
|
|
1298
1301
|
removeListener: 1
|
|
1299
|
-
}),
|
|
1302
|
+
}), Dt = class extends D {
|
|
1300
1303
|
constructor(e, t, n) {
|
|
1301
1304
|
super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = e, this.nsp = t, n && n.auth && (this.auth = n.auth), this._opts = Object.assign({}, n), this.io._autoConnect && this.open();
|
|
1302
1305
|
}
|
|
@@ -1307,10 +1310,10 @@ var Tt = Object.freeze({
|
|
|
1307
1310
|
if (this.subs) return;
|
|
1308
1311
|
let e = this.io;
|
|
1309
1312
|
this.subs = [
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1313
|
+
W(e, "open", this.onopen.bind(this)),
|
|
1314
|
+
W(e, "packet", this.onpacket.bind(this)),
|
|
1315
|
+
W(e, "error", this.onerror.bind(this)),
|
|
1316
|
+
W(e, "close", this.onclose.bind(this))
|
|
1314
1317
|
];
|
|
1315
1318
|
}
|
|
1316
1319
|
get active() {
|
|
@@ -1326,10 +1329,10 @@ var Tt = Object.freeze({
|
|
|
1326
1329
|
return e.unshift("message"), this.emit.apply(this, e), this;
|
|
1327
1330
|
}
|
|
1328
1331
|
emit(e, ...t) {
|
|
1329
|
-
if (
|
|
1332
|
+
if (Et.hasOwnProperty(e)) throw Error("\"" + e.toString() + "\" is a reserved event name");
|
|
1330
1333
|
if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile) return this._addToQueue(t), this;
|
|
1331
1334
|
let n = {
|
|
1332
|
-
type:
|
|
1335
|
+
type: H.EVENT,
|
|
1333
1336
|
data: t
|
|
1334
1337
|
};
|
|
1335
1338
|
if (n.options = {}, n.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
|
|
@@ -1387,7 +1390,7 @@ var Tt = Object.freeze({
|
|
|
1387
1390
|
}
|
|
1388
1391
|
_sendConnectPacket(e) {
|
|
1389
1392
|
this.packet({
|
|
1390
|
-
type:
|
|
1393
|
+
type: H.CONNECT,
|
|
1391
1394
|
data: this._pid ? Object.assign({
|
|
1392
1395
|
pid: this._pid,
|
|
1393
1396
|
offset: this._lastOffset
|
|
@@ -1410,21 +1413,21 @@ var Tt = Object.freeze({
|
|
|
1410
1413
|
}
|
|
1411
1414
|
onpacket(e) {
|
|
1412
1415
|
if (e.nsp === this.nsp) switch (e.type) {
|
|
1413
|
-
case
|
|
1416
|
+
case H.CONNECT:
|
|
1414
1417
|
e.data && e.data.sid ? this.onconnect(e.data.sid, e.data.pid) : this.emitReserved("connect_error", /* @__PURE__ */ Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
|
|
1415
1418
|
break;
|
|
1416
|
-
case
|
|
1417
|
-
case
|
|
1419
|
+
case H.EVENT:
|
|
1420
|
+
case H.BINARY_EVENT:
|
|
1418
1421
|
this.onevent(e);
|
|
1419
1422
|
break;
|
|
1420
|
-
case
|
|
1421
|
-
case
|
|
1423
|
+
case H.ACK:
|
|
1424
|
+
case H.BINARY_ACK:
|
|
1422
1425
|
this.onack(e);
|
|
1423
1426
|
break;
|
|
1424
|
-
case
|
|
1427
|
+
case H.DISCONNECT:
|
|
1425
1428
|
this.ondisconnect();
|
|
1426
1429
|
break;
|
|
1427
|
-
case
|
|
1430
|
+
case H.CONNECT_ERROR:
|
|
1428
1431
|
this.destroy();
|
|
1429
1432
|
let t = Error(e.data.message);
|
|
1430
1433
|
t.data = e.data.data, this.emitReserved("connect_error", t);
|
|
@@ -1445,7 +1448,7 @@ var Tt = Object.freeze({
|
|
|
1445
1448
|
let t = this, n = !1;
|
|
1446
1449
|
return function(...r) {
|
|
1447
1450
|
n || (n = !0, t.packet({
|
|
1448
|
-
type:
|
|
1451
|
+
type: H.ACK,
|
|
1449
1452
|
id: e,
|
|
1450
1453
|
data: r
|
|
1451
1454
|
}));
|
|
@@ -1470,7 +1473,7 @@ var Tt = Object.freeze({
|
|
|
1470
1473
|
this.subs &&= (this.subs.forEach((e) => e()), void 0), this.io._destroy(this);
|
|
1471
1474
|
}
|
|
1472
1475
|
disconnect() {
|
|
1473
|
-
return this.connected && this.packet({ type:
|
|
1476
|
+
return this.connected && this.packet({ type: H.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
|
|
1474
1477
|
}
|
|
1475
1478
|
close() {
|
|
1476
1479
|
return this.disconnect();
|
|
@@ -1525,37 +1528,35 @@ var Tt = Object.freeze({
|
|
|
1525
1528
|
}
|
|
1526
1529
|
}
|
|
1527
1530
|
};
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
function W(e) {
|
|
1531
|
+
// ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/contrib/backo2.js
|
|
1532
|
+
function G(e) {
|
|
1531
1533
|
e ||= {}, this.ms = e.min || 100, this.max = e.max || 1e4, this.factor = e.factor || 2, this.jitter = e.jitter > 0 && e.jitter <= 1 ? e.jitter : 0, this.attempts = 0;
|
|
1532
1534
|
}
|
|
1533
|
-
|
|
1535
|
+
G.prototype.duration = function() {
|
|
1534
1536
|
var e = this.ms * this.factor ** +this.attempts++;
|
|
1535
1537
|
if (this.jitter) {
|
|
1536
1538
|
var t = Math.random(), n = Math.floor(t * this.jitter * e);
|
|
1537
1539
|
e = Math.floor(t * 10) & 1 ? e + n : e - n;
|
|
1538
1540
|
}
|
|
1539
1541
|
return Math.min(e, this.max) | 0;
|
|
1540
|
-
},
|
|
1542
|
+
}, G.prototype.reset = function() {
|
|
1541
1543
|
this.attempts = 0;
|
|
1542
|
-
},
|
|
1544
|
+
}, G.prototype.setMin = function(e) {
|
|
1543
1545
|
this.ms = e;
|
|
1544
|
-
},
|
|
1546
|
+
}, G.prototype.setMax = function(e) {
|
|
1545
1547
|
this.max = e;
|
|
1546
|
-
},
|
|
1548
|
+
}, G.prototype.setJitter = function(e) {
|
|
1547
1549
|
this.jitter = e;
|
|
1548
1550
|
};
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
var G = class extends E {
|
|
1551
|
+
// ../../node_modules/.pnpm/socket.io-client@4.8.4_supports-color@8.1.1/node_modules/socket.io-client/build/esm/manager.js
|
|
1552
|
+
var K = class extends D {
|
|
1552
1553
|
constructor(e, t) {
|
|
1553
|
-
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t,
|
|
1554
|
+
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t ||= {}, t.path = t.path || "/socket.io", this.opts = t, A(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || Infinity), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor(t.randomizationFactor ?? .5), this.backoff = new G({
|
|
1554
1555
|
min: this.reconnectionDelay(),
|
|
1555
1556
|
max: this.reconnectionDelayMax(),
|
|
1556
1557
|
jitter: this.randomizationFactor()
|
|
1557
1558
|
}), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
|
|
1558
|
-
let n = t.parser ||
|
|
1559
|
+
let n = t.parser || gt;
|
|
1559
1560
|
this.encoder = new n.Encoder(), this.decoder = new n.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
|
|
1560
1561
|
}
|
|
1561
1562
|
reconnection(e) {
|
|
@@ -1584,14 +1585,14 @@ var G = class extends E {
|
|
|
1584
1585
|
}
|
|
1585
1586
|
open(e) {
|
|
1586
1587
|
if (~this._readyState.indexOf("open")) return this;
|
|
1587
|
-
this.engine = new
|
|
1588
|
+
this.engine = new st(this.uri, this.opts);
|
|
1588
1589
|
let t = this.engine, n = this;
|
|
1589
1590
|
this._readyState = "opening", this.skipReconnect = !1;
|
|
1590
|
-
let r =
|
|
1591
|
+
let r = W(t, "open", function() {
|
|
1591
1592
|
n.onopen(), e && e();
|
|
1592
1593
|
}), i = (t) => {
|
|
1593
1594
|
this.cleanup(), this._readyState = "closed", this.emitReserved("error", t), e ? e(t) : this.maybeReconnectOnOpen();
|
|
1594
|
-
}, a =
|
|
1595
|
+
}, a = W(t, "error", i);
|
|
1595
1596
|
if (!1 !== this._timeout) {
|
|
1596
1597
|
let e = this._timeout, n = this.setTimeoutFn(() => {
|
|
1597
1598
|
r(), i(/* @__PURE__ */ Error("timeout")), t.close();
|
|
@@ -1608,7 +1609,7 @@ var G = class extends E {
|
|
|
1608
1609
|
onopen() {
|
|
1609
1610
|
this.cleanup(), this._readyState = "open", this.emitReserved("open");
|
|
1610
1611
|
let e = this.engine;
|
|
1611
|
-
this.subs.push(
|
|
1612
|
+
this.subs.push(W(e, "ping", this.onping.bind(this)), W(e, "data", this.ondata.bind(this)), W(e, "error", this.onerror.bind(this)), W(e, "close", this.onclose.bind(this)), W(this.decoder, "decoded", this.ondecoded.bind(this)));
|
|
1612
1613
|
}
|
|
1613
1614
|
onping() {
|
|
1614
1615
|
this.emitReserved("ping");
|
|
@@ -1621,7 +1622,7 @@ var G = class extends E {
|
|
|
1621
1622
|
}
|
|
1622
1623
|
}
|
|
1623
1624
|
ondecoded(e) {
|
|
1624
|
-
|
|
1625
|
+
O(() => {
|
|
1625
1626
|
this.emitReserved("packet", e);
|
|
1626
1627
|
}, this.setTimeoutFn);
|
|
1627
1628
|
}
|
|
@@ -1630,7 +1631,7 @@ var G = class extends E {
|
|
|
1630
1631
|
}
|
|
1631
1632
|
socket(e, t) {
|
|
1632
1633
|
let n = this.nsps[e];
|
|
1633
|
-
return n ? this._autoConnect && !n.active && n.connect() : (n = new
|
|
1634
|
+
return n ? this._autoConnect && !n.active && n.connect() : (n = new Dt(this, e, t), this.nsps[e] = n), n;
|
|
1634
1635
|
}
|
|
1635
1636
|
_destroy(e) {
|
|
1636
1637
|
let t = Object.keys(this.nsps);
|
|
@@ -1675,21 +1676,20 @@ var G = class extends E {
|
|
|
1675
1676
|
let e = this.backoff.attempts;
|
|
1676
1677
|
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
|
|
1677
1678
|
}
|
|
1678
|
-
},
|
|
1679
|
-
function
|
|
1679
|
+
}, q = {};
|
|
1680
|
+
function J(e, t) {
|
|
1680
1681
|
typeof e == "object" && (t = e, e = void 0), t ||= {};
|
|
1681
|
-
let n =
|
|
1682
|
-
return s ? c = new
|
|
1683
|
-
}
|
|
1684
|
-
Object.assign(
|
|
1685
|
-
Manager:
|
|
1686
|
-
Socket:
|
|
1687
|
-
io:
|
|
1688
|
-
connect:
|
|
1682
|
+
let n = ct(e, t.path || "/socket.io"), r = n.source, i = n.id, a = n.path, o = q[i] && a in q[i].nsps, s = t.forceNew || t["force new connection"] || !1 === t.multiplex || o, c;
|
|
1683
|
+
return s ? c = new K(r, t) : (q[i] || (q[i] = new K(r, t)), c = q[i]), n.query && !t.query && (t.query = n.queryKey), c.socket(n.path, t);
|
|
1684
|
+
}
|
|
1685
|
+
Object.assign(J, {
|
|
1686
|
+
Manager: K,
|
|
1687
|
+
Socket: Dt,
|
|
1688
|
+
io: J,
|
|
1689
|
+
connect: J
|
|
1689
1690
|
});
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
function Dt(e) {
|
|
1691
|
+
// src/sdk-socket.ts
|
|
1692
|
+
function Ot(e) {
|
|
1693
1693
|
let t = e.replace(/\/$/, "");
|
|
1694
1694
|
try {
|
|
1695
1695
|
return `${new URL(t).origin}/sdk`;
|
|
@@ -1697,7 +1697,7 @@ function Dt(e) {
|
|
|
1697
1697
|
return `${t}/sdk`;
|
|
1698
1698
|
}
|
|
1699
1699
|
}
|
|
1700
|
-
var
|
|
1700
|
+
var kt = class {
|
|
1701
1701
|
constructor() {
|
|
1702
1702
|
this.socket = null;
|
|
1703
1703
|
}
|
|
@@ -1706,8 +1706,8 @@ var Ot = class {
|
|
|
1706
1706
|
}
|
|
1707
1707
|
connect(e) {
|
|
1708
1708
|
this.disconnect();
|
|
1709
|
-
let t =
|
|
1710
|
-
this.socket =
|
|
1709
|
+
let t = Ot(e.baseUrl);
|
|
1710
|
+
this.socket = J(t, {
|
|
1711
1711
|
auth: {
|
|
1712
1712
|
apiKey: e.apiKey,
|
|
1713
1713
|
visitorToken: e.visitorToken
|
|
@@ -1730,54 +1730,54 @@ var Ot = class {
|
|
|
1730
1730
|
disconnect() {
|
|
1731
1731
|
this.socket &&= (this.socket.removeAllListeners(), this.socket.disconnect(), null);
|
|
1732
1732
|
}
|
|
1733
|
-
},
|
|
1734
|
-
function
|
|
1733
|
+
}, Y = "onedeskpro_visitor_token";
|
|
1734
|
+
function At(e) {
|
|
1735
1735
|
try {
|
|
1736
1736
|
return typeof window < "u" ? window.localStorage.getItem(e) : null;
|
|
1737
1737
|
} catch {
|
|
1738
1738
|
return null;
|
|
1739
1739
|
}
|
|
1740
1740
|
}
|
|
1741
|
-
function
|
|
1741
|
+
function jt(e, t) {
|
|
1742
1742
|
try {
|
|
1743
1743
|
typeof window < "u" && window.localStorage.setItem(e, t);
|
|
1744
1744
|
} catch {}
|
|
1745
1745
|
}
|
|
1746
|
-
function
|
|
1746
|
+
function Mt(e) {
|
|
1747
1747
|
try {
|
|
1748
1748
|
typeof window < "u" && window.localStorage.removeItem(e);
|
|
1749
1749
|
} catch {}
|
|
1750
1750
|
}
|
|
1751
|
-
var
|
|
1751
|
+
var Nt = class {
|
|
1752
1752
|
constructor() {
|
|
1753
|
-
this.token = null, this.storageKey =
|
|
1753
|
+
this.token = null, this.storageKey = Y;
|
|
1754
1754
|
}
|
|
1755
1755
|
setScope(e) {
|
|
1756
|
-
this.storageKey = e?.trim() ? `${
|
|
1756
|
+
this.storageKey = e?.trim() ? `${Y}:${e.trim()}` : Y, this.token = At(this.storageKey);
|
|
1757
1757
|
}
|
|
1758
1758
|
get() {
|
|
1759
|
-
return this.token ??
|
|
1759
|
+
return this.token ?? At(this.storageKey);
|
|
1760
1760
|
}
|
|
1761
1761
|
set(e) {
|
|
1762
|
-
this.token = e,
|
|
1762
|
+
this.token = e, jt(this.storageKey, e);
|
|
1763
1763
|
}
|
|
1764
1764
|
clear() {
|
|
1765
|
-
this.token = null,
|
|
1765
|
+
this.token = null, Mt(this.storageKey);
|
|
1766
1766
|
}
|
|
1767
|
-
},
|
|
1767
|
+
}, Pt = 300, Ft = 250, It = 100, Lt = [
|
|
1768
1768
|
"audio/webm;codecs=opus",
|
|
1769
1769
|
"audio/webm",
|
|
1770
1770
|
"audio/mp4",
|
|
1771
1771
|
"audio/ogg;codecs=opus"
|
|
1772
1772
|
];
|
|
1773
|
-
function
|
|
1774
|
-
return typeof MediaRecorder > "u" || typeof MediaRecorder.isTypeSupported != "function" ? "audio/webm" :
|
|
1773
|
+
function Rt() {
|
|
1774
|
+
return typeof MediaRecorder > "u" || typeof MediaRecorder.isTypeSupported != "function" ? "audio/webm" : Lt.find((e) => MediaRecorder.isTypeSupported(e)) ?? "audio/webm";
|
|
1775
1775
|
}
|
|
1776
|
-
function
|
|
1776
|
+
function zt(e) {
|
|
1777
1777
|
let t = e instanceof DOMException ? e.name : "";
|
|
1778
1778
|
return t === "NotAllowedError" || t === "PermissionDeniedError" || t === "SecurityError" ? "Microphone access was denied." : t === "NotFoundError" || t === "DevicesNotFoundError" ? "No microphone was found." : "Could not start recording.";
|
|
1779
1779
|
}
|
|
1780
|
-
var
|
|
1780
|
+
var Bt = class e {
|
|
1781
1781
|
constructor(e, t = 300) {
|
|
1782
1782
|
this.onChange = e, this.maxDurationSeconds = t, this.recorder = null, this.stream = null, this.chunks = [], this.mimeType = "audio/webm", this.startedAt = 0, this.tickTimer = null, this.levelTimer = null, this.maxTimer = null, this.audioContext = null, this.analyser = null, this.snapshot = {
|
|
1783
1783
|
state: "idle",
|
|
@@ -1799,20 +1799,20 @@ var Y = class e {
|
|
|
1799
1799
|
try {
|
|
1800
1800
|
t = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
1801
1801
|
} catch (e) {
|
|
1802
|
-
throw Error(
|
|
1802
|
+
throw Error(zt(e));
|
|
1803
1803
|
}
|
|
1804
1804
|
try {
|
|
1805
|
-
this.mimeType =
|
|
1805
|
+
this.mimeType = Rt();
|
|
1806
1806
|
let e = new MediaRecorder(t, { mimeType: this.mimeType });
|
|
1807
1807
|
e.ondataavailable = (e) => {
|
|
1808
1808
|
e.data.size > 0 && this.chunks.push(e.data);
|
|
1809
1809
|
}, this.stream = t, this.recorder = e, this.startedAt = Date.now(), e.start(200);
|
|
1810
1810
|
} catch (e) {
|
|
1811
|
-
throw t.getTracks().forEach((e) => e.stop()), this.stream = null, this.recorder = null, Error(
|
|
1811
|
+
throw t.getTracks().forEach((e) => e.stop()), this.stream = null, this.recorder = null, Error(zt(e));
|
|
1812
1812
|
}
|
|
1813
1813
|
this.startLevelMeter(t), this.tickTimer = setInterval(() => {
|
|
1814
1814
|
this.update({ elapsedSeconds: Math.floor(this.elapsedMs() / 1e3) });
|
|
1815
|
-
},
|
|
1815
|
+
}, Ft), this.maxTimer = setTimeout(() => void this.stop(), this.maxDurationSeconds * 1e3), this.update({
|
|
1816
1816
|
state: "recording",
|
|
1817
1817
|
elapsedSeconds: 0,
|
|
1818
1818
|
level: 0,
|
|
@@ -1827,18 +1827,18 @@ var Y = class e {
|
|
|
1827
1827
|
let n = await new Promise((t) => {
|
|
1828
1828
|
e.onstop = () => {
|
|
1829
1829
|
let e = this.chunks;
|
|
1830
|
-
this.chunks = [], t(new Blob(e, { type:
|
|
1830
|
+
this.chunks = [], t(new Blob(e, { type: v(this.mimeType) }));
|
|
1831
1831
|
};
|
|
1832
1832
|
try {
|
|
1833
1833
|
e.stop();
|
|
1834
1834
|
} catch {
|
|
1835
|
-
t(new Blob(this.chunks, { type:
|
|
1835
|
+
t(new Blob(this.chunks, { type: v(this.mimeType) }));
|
|
1836
1836
|
}
|
|
1837
1837
|
});
|
|
1838
1838
|
this.releaseMedia();
|
|
1839
1839
|
let r = {
|
|
1840
1840
|
blob: n,
|
|
1841
|
-
mimeType:
|
|
1841
|
+
mimeType: v(this.mimeType),
|
|
1842
1842
|
durationSeconds: t
|
|
1843
1843
|
};
|
|
1844
1844
|
return this.update({
|
|
@@ -1887,7 +1887,7 @@ var Y = class e {
|
|
|
1887
1887
|
e += n * n;
|
|
1888
1888
|
}
|
|
1889
1889
|
this.update({ level: Math.min(1, Math.sqrt(e / i.length) * 3.2) });
|
|
1890
|
-
},
|
|
1890
|
+
}, It);
|
|
1891
1891
|
} catch {}
|
|
1892
1892
|
}
|
|
1893
1893
|
clearTimers() {
|
|
@@ -2272,8 +2272,8 @@ var Y = class e {
|
|
|
2272
2272
|
dial: "977",
|
|
2273
2273
|
flag: "🇳🇵"
|
|
2274
2274
|
}
|
|
2275
|
-
],
|
|
2276
|
-
function
|
|
2275
|
+
], Vt = X.find((e) => e.iso === "BD") ?? X[0];
|
|
2276
|
+
function Ht(e, t) {
|
|
2277
2277
|
let n = t.trim();
|
|
2278
2278
|
if (n.startsWith("+")) {
|
|
2279
2279
|
let e = n.replace(/\D/g, "");
|
|
@@ -2282,10 +2282,9 @@ function Bt(e, t) {
|
|
|
2282
2282
|
let r = n.replace(/\D/g, "");
|
|
2283
2283
|
return !r || (r = r.replace(/^0+/, ""), !r) ? "" : `+${e}${r}`;
|
|
2284
2284
|
}
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
function Ht(e, t) {
|
|
2285
|
+
// src/widget/styles.ts
|
|
2286
|
+
var Ut = "(max-width: 640px), (max-height: 500px) and (pointer: coarse)";
|
|
2287
|
+
function Wt(e, t) {
|
|
2289
2288
|
let n = `
|
|
2290
2289
|
--ttcb-bg: #ffffff;
|
|
2291
2290
|
--ttcb-bg-secondary: #f3f4f6;
|
|
@@ -2450,7 +2449,8 @@ function Ht(e, t) {
|
|
|
2450
2449
|
border-top: 1px solid var(--ttcb-border);
|
|
2451
2450
|
flex-shrink: 0;
|
|
2452
2451
|
}
|
|
2453
|
-
.ttcb-mode-banner.visible { display:
|
|
2452
|
+
.ttcb-mode-banner.visible { display: flex; align-items: center; gap: 8px; }
|
|
2453
|
+
.ttcb-mode-banner-text { flex: 1; min-width: 0; }
|
|
2454
2454
|
.ttcb-mode-banner.waiting { color: var(--ttcb-text); }
|
|
2455
2455
|
.ttcb-mode-banner.closed {
|
|
2456
2456
|
color: var(--ttcb-text);
|
|
@@ -2458,6 +2458,37 @@ function Ht(e, t) {
|
|
|
2458
2458
|
}
|
|
2459
2459
|
.ttcb-mode-banner.human { color: var(--ttcb-text); }
|
|
2460
2460
|
|
|
2461
|
+
.ttcb-confirm-bar {
|
|
2462
|
+
display: none;
|
|
2463
|
+
padding: 10px 16px;
|
|
2464
|
+
font-size: 12px;
|
|
2465
|
+
line-height: 1.4;
|
|
2466
|
+
color: var(--ttcb-text);
|
|
2467
|
+
background: var(--ttcb-bg-secondary);
|
|
2468
|
+
border-top: 1px solid var(--ttcb-border);
|
|
2469
|
+
flex-shrink: 0;
|
|
2470
|
+
flex-wrap: wrap; align-items: center; gap: 8px;
|
|
2471
|
+
}
|
|
2472
|
+
.ttcb-confirm-bar.visible { display: flex; }
|
|
2473
|
+
.ttcb-confirm-text { flex: 1 1 160px; min-width: 0; }
|
|
2474
|
+
.ttcb-confirm-actions { display: flex; gap: 8px; flex-shrink: 0; }
|
|
2475
|
+
.ttcb-banner-btn {
|
|
2476
|
+
flex-shrink: 0;
|
|
2477
|
+
font: inherit; font-weight: 600;
|
|
2478
|
+
padding: 4px 10px; border-radius: 6px;
|
|
2479
|
+
border: 1px solid var(--ttcb-border);
|
|
2480
|
+
background: var(--ttcb-bg); color: var(--ttcb-text);
|
|
2481
|
+
cursor: pointer;
|
|
2482
|
+
}
|
|
2483
|
+
.ttcb-banner-btn:hover { background: var(--ttcb-bg-secondary); }
|
|
2484
|
+
.ttcb-banner-btn.primary { background: ${e}; border-color: ${e}; color: #fff; }
|
|
2485
|
+
.ttcb-banner-btn.primary:hover { opacity: 0.9; }
|
|
2486
|
+
.ttcb-banner-btn:focus-visible { outline: 2px solid ${e}; outline-offset: 2px; }
|
|
2487
|
+
.ttcb-banner-btn[aria-disabled="true"], .ttcb-new-session-btn[aria-disabled="true"] {
|
|
2488
|
+
opacity: 0.6; cursor: default;
|
|
2489
|
+
}
|
|
2490
|
+
.ttcb-banner-btn.hidden { display: none; }
|
|
2491
|
+
|
|
2461
2492
|
.ttcb-messages {
|
|
2462
2493
|
flex: 1; overflow-y: auto; padding: 16px;
|
|
2463
2494
|
display: flex; flex-direction: column; gap: 12px;
|
|
@@ -2919,7 +2950,7 @@ function Ht(e, t) {
|
|
|
2919
2950
|
|
|
2920
2951
|
.ttcb-footer.hidden, .ttcb-messages.hidden { display: none; }
|
|
2921
2952
|
|
|
2922
|
-
@media ${
|
|
2953
|
+
@media ${Ut} {
|
|
2923
2954
|
.ttcb-fab.bottom-right { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
|
|
2924
2955
|
.ttcb-fab.bottom-left { left: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
|
|
2925
2956
|
/* The open panel covers the launcher; its own close button takes over. */
|
|
@@ -2985,20 +3016,19 @@ function Ht(e, t) {
|
|
|
2985
3016
|
}
|
|
2986
3017
|
`;
|
|
2987
3018
|
}
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
function Ut(e) {
|
|
3019
|
+
// src/widget/render.ts
|
|
3020
|
+
function Gt(e) {
|
|
2991
3021
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2992
3022
|
}
|
|
2993
|
-
function
|
|
3023
|
+
function Kt(e) {
|
|
2994
3024
|
let t = [], n = e.replace(/```[\w]*\n?([\s\S]*?)```/g, (e, n) => {
|
|
2995
3025
|
let r = t.length;
|
|
2996
|
-
return t.push(`<pre><code>${
|
|
3026
|
+
return t.push(`<pre><code>${Gt(n.trim())}</code></pre>`), `\x04${r}\x05`;
|
|
2997
3027
|
});
|
|
2998
3028
|
n = n.replace(/`([^`\n]+)`/g, (e, n) => {
|
|
2999
3029
|
let r = t.length;
|
|
3000
|
-
return t.push(`<code>${
|
|
3001
|
-
}), n =
|
|
3030
|
+
return t.push(`<code>${Gt(n)}</code>`), `\x02${r}\x03`;
|
|
3031
|
+
}), n = Gt(n);
|
|
3002
3032
|
let r = n.split("\n"), i = [], a = "", o = () => {
|
|
3003
3033
|
a &&= (i.push(`</${a}>`), "");
|
|
3004
3034
|
};
|
|
@@ -3015,71 +3045,71 @@ function Wt(e) {
|
|
|
3015
3045
|
}).join("") : "";
|
|
3016
3046
|
}).filter(Boolean).join(""), n = n.replace(/\x04(\d+)\x05/g, (e, n) => t[+n] ?? "").replace(/\x02(\d+)\x03/g, (e, n) => t[+n] ?? ""), n;
|
|
3017
3047
|
}
|
|
3018
|
-
function
|
|
3048
|
+
function qt() {
|
|
3019
3049
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"/>\n <line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"14\"/>\n <line x1=\"9\" y1=\"11\" x2=\"15\" y2=\"11\"/>\n </svg>";
|
|
3020
3050
|
}
|
|
3021
|
-
function
|
|
3051
|
+
function Jt() {
|
|
3022
3052
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 2H4C2.9 2 2 2.9 2 4v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z\"/>\n </svg>";
|
|
3023
3053
|
}
|
|
3024
|
-
function
|
|
3054
|
+
function Yt() {
|
|
3025
3055
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"/>\n </svg>";
|
|
3026
3056
|
}
|
|
3027
|
-
function
|
|
3057
|
+
function Xt() {
|
|
3028
3058
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\"/>\n </svg>";
|
|
3029
3059
|
}
|
|
3030
3060
|
function Z() {
|
|
3031
3061
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 9V7c0-1.1-.9-2-2-2h-3c0-1.66-1.34-3-3-3S9 3.34 9 5H6c-1.1 0-2 .9-2 2v2c-1.66 0-3 1.34-3 3s1.34 3 3 3v4c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-4c1.66 0 3-1.34 3-3s-1.34-3-3-3zm-2 10H6V7h12v12zm-9-6c-.83 0-1.5-.67-1.5-1.5S8.17 10 9 10s1.5.67 1.5 1.5S9.83 13 9 13zm6 0c-.83 0-1.5-.67-1.5-1.5S14.17 10 15 10s1.5.67 1.5 1.5S15.83 13 15 13z\"/>\n </svg>";
|
|
3032
3062
|
}
|
|
3033
|
-
function
|
|
3063
|
+
function Zt() {
|
|
3034
3064
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\"/>\n </svg>";
|
|
3035
3065
|
}
|
|
3036
|
-
function
|
|
3066
|
+
function Qt() {
|
|
3037
3067
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2\"/>\n <circle cx=\"12\" cy=\"7\" r=\"4\"/>\n </svg>";
|
|
3038
3068
|
}
|
|
3039
|
-
function
|
|
3069
|
+
function $t() {
|
|
3040
3070
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z\"/>\n <polyline points=\"22,6 12,13 2,6\"/>\n </svg>";
|
|
3041
3071
|
}
|
|
3042
|
-
function
|
|
3072
|
+
function en() {
|
|
3043
3073
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <polyline points=\"6 9 12 15 18 9\"/>\n </svg>";
|
|
3044
3074
|
}
|
|
3045
|
-
function
|
|
3075
|
+
function tn() {
|
|
3046
3076
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/>\n <polyline points=\"12 5 19 12 12 19\"/>\n </svg>";
|
|
3047
3077
|
}
|
|
3048
|
-
function
|
|
3078
|
+
function nn() {
|
|
3049
3079
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\"/>\n <polyline points=\"9 12 11 14 15 10\"/>\n </svg>";
|
|
3050
3080
|
}
|
|
3051
|
-
function
|
|
3081
|
+
function rn() {
|
|
3052
3082
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"10\" fill=\"currentColor\"/>\n <path d=\"M9 12l2 2 4-4\" fill=\"none\" stroke=\"#fff\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n </svg>";
|
|
3053
3083
|
}
|
|
3054
|
-
function
|
|
3084
|
+
function an() {
|
|
3055
3085
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path fill=\"#F59E0B\" d=\"M8 2.5l1.1 2.2 2.4.3-1.7 1.7.4 2.4L8 8l-2.2 1.1.4-2.4L4.5 5l2.4-.3L8 2.5z\"/>\n <path fill=\"#F59E0B\" d=\"M16 3.5l.8 1.6 1.8.2-1.3 1.3.3 1.8L16 7.5l-1.6.9.3-1.8-1.3-1.3 1.8-.2L16 3.5z\"/>\n <path fill=\"#FBBF24\" d=\"M12 11.5l1 2 2.2.3-1.6 1.6.4 2.2-2-1.1-2 1.1.4-2.2-1.6-1.6 2.2-.3 1-2z\"/>\n </svg>";
|
|
3056
3086
|
}
|
|
3057
|
-
function
|
|
3087
|
+
function on() {
|
|
3058
3088
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2\"/>\n <circle cx=\"9\" cy=\"7\" r=\"4\"/>\n <path d=\"M23 21v-2a4 4 0 0 0-3-3.87\"/>\n <path d=\"M16 3.13a4 4 0 0 1 0 7.75\"/>\n </svg>";
|
|
3059
3089
|
}
|
|
3060
|
-
function
|
|
3090
|
+
function sn() {
|
|
3061
3091
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/>\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/>\n </svg>";
|
|
3062
3092
|
}
|
|
3063
|
-
function
|
|
3093
|
+
function cn() {
|
|
3064
3094
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48\"/>\n </svg>";
|
|
3065
3095
|
}
|
|
3066
|
-
function
|
|
3096
|
+
function ln() {
|
|
3067
3097
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"/>\n <circle cx=\"8.5\" cy=\"8.5\" r=\"1.5\"/>\n <polyline points=\"21 15 16 10 5 21\"/>\n </svg>";
|
|
3068
3098
|
}
|
|
3069
|
-
function
|
|
3099
|
+
function un() {
|
|
3070
3100
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z\"/>\n <path d=\"M19 10v2a7 7 0 0 1-14 0v-2\"/>\n <line x1=\"12\" y1=\"19\" x2=\"12\" y2=\"23\"/>\n <line x1=\"8\" y1=\"23\" x2=\"16\" y2=\"23\"/>\n </svg>";
|
|
3071
3101
|
}
|
|
3072
|
-
function
|
|
3102
|
+
function dn() {
|
|
3073
3103
|
return "<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"6\" y=\"6\" width=\"12\" height=\"12\" rx=\"2\" fill=\"currentColor\"/>\n </svg>";
|
|
3074
3104
|
}
|
|
3075
|
-
function
|
|
3105
|
+
function fn() {
|
|
3076
3106
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <polyline points=\"3 6 5 6 21 6\"/>\n <path d=\"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6\"/>\n <path d=\"M10 11v6\"/>\n <path d=\"M14 11v6\"/>\n <path d=\"M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2\"/>\n </svg>";
|
|
3077
3107
|
}
|
|
3078
|
-
function
|
|
3108
|
+
function pn() {
|
|
3079
3109
|
return "<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\"/>\n <polyline points=\"14 2 14 8 20 8\"/>\n </svg>";
|
|
3080
3110
|
}
|
|
3081
|
-
function
|
|
3082
|
-
let t =
|
|
3111
|
+
function mn(e) {
|
|
3112
|
+
let t = m(e.url) ? e.url : "", n = e.type.toLowerCase();
|
|
3083
3113
|
if (t && n.startsWith("image/")) {
|
|
3084
3114
|
let n = document.createElement("a");
|
|
3085
3115
|
n.className = "ttcb-attachment ttcb-attachment-image", n.href = t, n.target = "_blank", n.rel = "noopener noreferrer", n.setAttribute("aria-label", `Open ${e.fileName}`);
|
|
@@ -3096,14 +3126,14 @@ function fn(e) {
|
|
|
3096
3126
|
let r = document.createElement("audio");
|
|
3097
3127
|
if (r.className = "ttcb-attachment-audio", r.controls = !0, r.preload = "metadata", r.src = t, r.setAttribute("aria-label", e.fileName), n.appendChild(r), typeof e.durationSeconds == "number" && e.durationSeconds > 0) {
|
|
3098
3128
|
let t = document.createElement("span");
|
|
3099
|
-
t.className = "ttcb-attachment-duration", t.textContent =
|
|
3129
|
+
t.className = "ttcb-attachment-duration", t.textContent = y(e.durationSeconds), n.appendChild(t);
|
|
3100
3130
|
}
|
|
3101
3131
|
return n;
|
|
3102
3132
|
}
|
|
3103
3133
|
let r = document.createElement(t ? "a" : "div");
|
|
3104
3134
|
r.className = "ttcb-attachment ttcb-attachment-file", r instanceof HTMLAnchorElement && (r.href = t, r.target = "_blank", r.rel = "noopener noreferrer");
|
|
3105
3135
|
let i = document.createElement("span");
|
|
3106
|
-
i.className = "ttcb-attachment-icon", i.setAttribute("aria-hidden", "true"), i.innerHTML =
|
|
3136
|
+
i.className = "ttcb-attachment-icon", i.setAttribute("aria-hidden", "true"), i.innerHTML = pn();
|
|
3107
3137
|
let a = document.createElement("span");
|
|
3108
3138
|
a.className = "ttcb-attachment-meta";
|
|
3109
3139
|
let o = document.createElement("span");
|
|
@@ -3115,11 +3145,11 @@ function fn(e) {
|
|
|
3115
3145
|
}
|
|
3116
3146
|
return r.appendChild(i), r.appendChild(a), r;
|
|
3117
3147
|
}
|
|
3118
|
-
function
|
|
3148
|
+
function hn(e) {
|
|
3119
3149
|
let { type: t, content: n } = e, r = e.attachments ?? [], i = document.createElement("div");
|
|
3120
3150
|
i.className = `ttcb-msg ${t}`, e.pending && i.classList.add("ttcb-pending");
|
|
3121
3151
|
let a = document.createElement("div");
|
|
3122
|
-
a.className = "ttcb-msg-avatar", a.innerHTML = t === "human" ?
|
|
3152
|
+
a.className = "ttcb-msg-avatar", a.innerHTML = t === "human" ? Zt() : t === "agent" ? Qt() : Z();
|
|
3123
3153
|
let o = document.createElement("div");
|
|
3124
3154
|
if (o.className = "ttcb-msg-body", t === "agent") {
|
|
3125
3155
|
let e = document.createElement("span");
|
|
@@ -3128,12 +3158,12 @@ function pn(e) {
|
|
|
3128
3158
|
if (r.length > 0) {
|
|
3129
3159
|
let e = document.createElement("div");
|
|
3130
3160
|
e.className = "ttcb-attachments";
|
|
3131
|
-
for (let t of r) e.appendChild(
|
|
3161
|
+
for (let t of r) e.appendChild(mn(t));
|
|
3132
3162
|
o.appendChild(e);
|
|
3133
3163
|
}
|
|
3134
3164
|
if (r.length === 0 || !re(n, r)) {
|
|
3135
3165
|
let e = document.createElement("div");
|
|
3136
|
-
e.className = "ttcb-bubble", t === "human" ? e.textContent = n : e.innerHTML =
|
|
3166
|
+
e.className = "ttcb-bubble", t === "human" ? e.textContent = n : e.innerHTML = Kt(n), o.appendChild(e);
|
|
3137
3167
|
}
|
|
3138
3168
|
if (e.pending) {
|
|
3139
3169
|
let e = document.createElement("span");
|
|
@@ -3141,7 +3171,7 @@ function pn(e) {
|
|
|
3141
3171
|
}
|
|
3142
3172
|
return i.appendChild(a), i.appendChild(o), i;
|
|
3143
3173
|
}
|
|
3144
|
-
function
|
|
3174
|
+
function gn() {
|
|
3145
3175
|
let e = document.createElement("div");
|
|
3146
3176
|
e.className = "ttcb-msg ai", e.id = "ttcb-typing";
|
|
3147
3177
|
let t = document.createElement("div");
|
|
@@ -3149,38 +3179,25 @@ function mn() {
|
|
|
3149
3179
|
let n = document.createElement("div");
|
|
3150
3180
|
return n.className = "ttcb-typing", n.innerHTML = "<span></span><span></span><span></span>", e.appendChild(t), e.appendChild(n), e;
|
|
3151
3181
|
}
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
var hn = [
|
|
3155
|
-
"image/jpeg",
|
|
3156
|
-
"image/png",
|
|
3157
|
-
"image/gif",
|
|
3158
|
-
"video/mp4",
|
|
3159
|
-
"video/webm",
|
|
3160
|
-
"audio/ogg",
|
|
3161
|
-
"audio/mpeg",
|
|
3162
|
-
"audio/wav",
|
|
3163
|
-
"audio/x-m4a",
|
|
3164
|
-
"audio/aac",
|
|
3165
|
-
"audio/opus",
|
|
3166
|
-
"application/pdf",
|
|
3167
|
-
"text/csv"
|
|
3168
|
-
].join(","), gn = "image/jpeg,image/png,image/gif", _n = class {
|
|
3182
|
+
// src/widget/widget.ts
|
|
3183
|
+
var _n = "image/jpeg,image/png,image/gif,video/mp4,video/webm,audio/ogg,audio/mpeg,audio/wav,audio/x-m4a,audio/aac,audio/opus,application/pdf,text/csv", vn = "image/jpeg,image/png,image/gif", yn = class {
|
|
3169
3184
|
constructor(e, t) {
|
|
3170
|
-
this.stopViewportSync = null, this.pendingFiles = [], this.attachMenuOpen = !1, this.recorder = null, this.voicePreviewUrl = "", this.selectedCountry =
|
|
3185
|
+
this.stopViewportSync = null, this.confirmingNew = !1, this.actionPending = !1, this.ticketMode = "ai", this.pendingFiles = [], this.attachMenuOpen = !1, this.recorder = null, this.voicePreviewUrl = "", this.selectedCountry = Vt, this.countryOpen = !1, this.isOpen = !1, this.destroyed = !1, this.position = e.position ?? "bottom-right", this.callbacks = t, this.autoOpen = e.autoOpen === !0, this.mount(e);
|
|
3171
3186
|
}
|
|
3172
3187
|
mount(e) {
|
|
3173
3188
|
this.host = document.createElement("div"), this.host.id = "onedeskpro-chatbot-host", this.host.style.display = "none", this.shadow = this.host.attachShadow({ mode: "closed" });
|
|
3174
3189
|
let t = document.createElement("style");
|
|
3175
|
-
t.textContent =
|
|
3190
|
+
t.textContent = Wt(e.primaryColor ?? "#2563EB", e.theme ?? "auto"), this.shadow.appendChild(t), this.fab = document.createElement("button"), this.fab.className = `ttcb-fab ${this.position}`, this.fab.setAttribute("aria-label", "Open chat"), this.fab.innerHTML = Jt(), this.fab.addEventListener("click", () => this.toggle()), this.shadow.appendChild(this.fab), this.panel = document.createElement("div"), this.panel.className = `ttcb-panel ${this.position} hidden ttcb-mode-compact`, this.panel.tabIndex = -1, this.panel.setAttribute("role", "dialog"), this.panel.setAttribute("aria-modal", "true"), this.panel.setAttribute("aria-label", e.chatbotName ?? "AI Assistant"), this.panel.appendChild(this.buildHeader(e)), this.identifyContainer = document.createElement("div"), this.identifyContainer.className = "ttcb-identify", this.buildIdentifyForm(this.identifyContainer), this.panel.appendChild(this.identifyContainer), this.messagesContainer = document.createElement("div"), this.messagesContainer.className = "ttcb-messages", this.messagesContainer.setAttribute("aria-live", "polite"), this.messagesContainer.setAttribute("aria-label", "Chat messages"), this.panel.appendChild(this.messagesContainer), this.modeBanner = document.createElement("div"), this.modeBanner.className = "ttcb-mode-banner", this.modeBannerText = document.createElement("span"), this.modeBannerText.className = "ttcb-mode-banner-text", this.modeBannerText.setAttribute("role", "status"), this.cancelHumanBtn = this.buildBannerButton("Cancel request", () => {
|
|
3191
|
+
this.actionPending || this.callbacks.onCancelHumanRequest();
|
|
3192
|
+
}), this.cancelHumanBtn.classList.add("hidden"), this.modeBanner.appendChild(this.modeBannerText), this.modeBanner.appendChild(this.cancelHumanBtn), this.panel.appendChild(this.modeBanner), this.panel.appendChild(this.buildConfirmNewBar()), this.footer = document.createElement("div"), this.footer.className = "ttcb-footer", this.pendingTray = document.createElement("div"), this.pendingTray.className = "ttcb-pending-tray", this.pendingTray.setAttribute("role", "list"), this.pendingTray.setAttribute("aria-label", "Files to send"), this.footer.appendChild(this.pendingTray), this.composeError = document.createElement("p"), this.composeError.className = "ttcb-compose-error", this.composeError.setAttribute("role", "alert"), this.footer.appendChild(this.composeError), this.footer.appendChild(this.buildVoiceBar()), this.footer.appendChild(this.buildVoicePreview());
|
|
3176
3193
|
let n = document.createElement("form");
|
|
3177
3194
|
n.className = "ttcb-form", n.addEventListener("submit", (e) => {
|
|
3178
3195
|
e.preventDefault(), this.handleSend();
|
|
3179
|
-
}), this.composeForm = n, n.appendChild(this.buildAttachControls()), this.input = document.createElement("input"), this.input.type = "text", this.input.className = "ttcb-input", this.input.placeholder = e.placeholder ?? "Type your message…", this.input.setAttribute("aria-label", "Message input"), this.input.setAttribute("autocomplete", "off"), this.sendBtn = document.createElement("button"), this.sendBtn.type = "submit", this.sendBtn.className = "ttcb-send-btn", this.sendBtn.innerHTML =
|
|
3196
|
+
}), this.composeForm = n, n.appendChild(this.buildAttachControls()), this.input = document.createElement("input"), this.input.type = "text", this.input.className = "ttcb-input", this.input.placeholder = e.placeholder ?? "Type your message…", this.input.setAttribute("aria-label", "Message input"), this.input.setAttribute("autocomplete", "off"), this.sendBtn = document.createElement("button"), this.sendBtn.type = "submit", this.sendBtn.className = "ttcb-send-btn", this.sendBtn.innerHTML = Xt(), this.sendBtn.setAttribute("aria-label", "Send message"), this.micBtn = document.createElement("button"), this.micBtn.type = "button", this.micBtn.className = "ttcb-mic-btn", this.micBtn.setAttribute("aria-label", "Record voice message"), this.micBtn.title = "Record voice message", this.micBtn.innerHTML = un(), this.micBtn.addEventListener("click", () => void this.startVoice()), n.appendChild(this.input), n.appendChild(this.micBtn), n.appendChild(this.sendBtn), this.footer.appendChild(n), this.panel.appendChild(this.footer), this.shadow.appendChild(this.panel), this.shadow.addEventListener("click", (e) => {
|
|
3180
3197
|
let t = e.target;
|
|
3181
3198
|
this.attachMenuOpen && !(t && (this.attachBtn.contains(t) || this.attachMenu.contains(t))) && this.closeAttachMenu(), this.countryOpen && (t && (this.dialBtn.contains(t) || this.countryPopover.contains(t)) || this.closeCountryPopover());
|
|
3182
3199
|
}), this.panel.addEventListener("keydown", (e) => {
|
|
3183
|
-
e.key === "Escape" && this.attachMenuOpen
|
|
3200
|
+
e.key === "Escape" && this.attachMenuOpen ? (e.stopPropagation(), this.closeAttachMenu(), this.attachBtn.focus()) : e.key === "Escape" && this.confirmingNew && (e.stopPropagation(), this.hideConfirmNew(), this.newSessionBtn.focus());
|
|
3184
3201
|
}), this.attachToDocument(), this.showInitialLoading();
|
|
3185
3202
|
}
|
|
3186
3203
|
reveal() {
|
|
@@ -3198,7 +3215,7 @@ var hn = [
|
|
|
3198
3215
|
let a = document.createElement("div");
|
|
3199
3216
|
a.className = "ttcb-header-title-row", this.headerTitle = document.createElement("span"), this.headerTitle.className = "ttcb-header-title", this.headerTitle.textContent = e.chatbotName ?? "AI Assistant";
|
|
3200
3217
|
let o = document.createElement("span");
|
|
3201
|
-
o.className = "ttcb-verified", o.setAttribute("aria-label", "Verified"), o.innerHTML =
|
|
3218
|
+
o.className = "ttcb-verified", o.setAttribute("aria-label", "Verified"), o.innerHTML = rn(), a.appendChild(this.headerTitle), a.appendChild(o);
|
|
3202
3219
|
let s = document.createElement("div");
|
|
3203
3220
|
s.className = "ttcb-header-meta";
|
|
3204
3221
|
let c = document.createElement("span");
|
|
@@ -3206,24 +3223,55 @@ var hn = [
|
|
|
3206
3223
|
let l = document.createElement("span");
|
|
3207
3224
|
l.className = "ttcb-meta-sep", l.setAttribute("aria-hidden", "true");
|
|
3208
3225
|
let u = document.createElement("span");
|
|
3209
|
-
u.className = "ttcb-meta-replies", u.innerHTML = `${
|
|
3226
|
+
u.className = "ttcb-meta-replies", u.innerHTML = `${an()}<span>Replies instantly</span>`, s.appendChild(c), s.appendChild(l), s.appendChild(u), i.appendChild(a), i.appendChild(s);
|
|
3210
3227
|
let d = document.createElement("div");
|
|
3211
|
-
d.className = "ttcb-header-actions", this.requestHumanBtn = document.createElement("button"), this.requestHumanBtn.type = "button", this.requestHumanBtn.className = "ttcb-request-human-btn hidden", this.requestHumanBtn.id = "ttcb-request-human-btn", this.requestHumanBtn.setAttribute("aria-label", "Request human agent"), this.requestHumanBtn.title = "Request human agent", this.requestHumanBtn.innerHTML =
|
|
3228
|
+
d.className = "ttcb-header-actions", this.requestHumanBtn = document.createElement("button"), this.requestHumanBtn.type = "button", this.requestHumanBtn.className = "ttcb-request-human-btn hidden", this.requestHumanBtn.id = "ttcb-request-human-btn", this.requestHumanBtn.setAttribute("aria-label", "Request human agent"), this.requestHumanBtn.title = "Request human agent", this.requestHumanBtn.innerHTML = on(), this.requestHumanBtn.addEventListener("click", () => this.callbacks.onRequestHuman()), this.newSessionBtn = document.createElement("button"), this.newSessionBtn.type = "button", this.newSessionBtn.className = "ttcb-new-session-btn hidden", this.newSessionBtn.setAttribute("aria-label", "New conversation"), this.newSessionBtn.title = "New conversation", this.newSessionBtn.innerHTML = qt(), this.newSessionBtn.addEventListener("click", () => {
|
|
3229
|
+
this.actionPending || (this.ticketMode === "closed" ? this.callbacks.onNewConversation() : this.showConfirmNew());
|
|
3230
|
+
});
|
|
3212
3231
|
let f = document.createElement("button");
|
|
3213
|
-
return f.className = "ttcb-close-btn", f.setAttribute("aria-label", "Close chat"), f.innerHTML =
|
|
3232
|
+
return f.className = "ttcb-close-btn", f.setAttribute("aria-label", "Close chat"), f.innerHTML = Yt(), f.addEventListener("click", () => this.close()), d.appendChild(this.requestHumanBtn), d.appendChild(this.newSessionBtn), d.appendChild(f), t.appendChild(n), t.appendChild(i), t.appendChild(d), t;
|
|
3233
|
+
}
|
|
3234
|
+
buildBannerButton(e, t) {
|
|
3235
|
+
let n = document.createElement("button");
|
|
3236
|
+
return n.type = "button", n.className = "ttcb-banner-btn", n.textContent = e, n.addEventListener("click", t), n;
|
|
3237
|
+
}
|
|
3238
|
+
buildConfirmNewBar() {
|
|
3239
|
+
this.confirmNewBar = document.createElement("div"), this.confirmNewBar.className = "ttcb-confirm-bar", this.confirmNewBar.setAttribute("role", "group"), this.confirmNewBar.setAttribute("aria-label", "Start a new conversation");
|
|
3240
|
+
let e = document.createElement("span");
|
|
3241
|
+
e.className = "ttcb-confirm-text", e.textContent = "End this conversation and start a new one?", this.confirmNewBtn = this.buildBannerButton("Start new", () => {
|
|
3242
|
+
this.actionPending || (this.hideConfirmNew(), this.input.focus(), this.callbacks.onNewConversation());
|
|
3243
|
+
}), this.confirmNewBtn.classList.add("primary"), this.keepChattingBtn = this.buildBannerButton("Keep chatting", () => {
|
|
3244
|
+
this.hideConfirmNew(), this.newSessionBtn.focus();
|
|
3245
|
+
});
|
|
3246
|
+
let t = document.createElement("div");
|
|
3247
|
+
return t.className = "ttcb-confirm-actions", t.appendChild(this.confirmNewBtn), t.appendChild(this.keepChattingBtn), this.confirmNewBar.appendChild(e), this.confirmNewBar.appendChild(t), this.confirmNewBar;
|
|
3248
|
+
}
|
|
3249
|
+
showConfirmNew() {
|
|
3250
|
+
this.confirmingNew = !0, this.confirmNewBar.classList.add("visible"), queueMicrotask(() => this.keepChattingBtn.focus());
|
|
3251
|
+
}
|
|
3252
|
+
hideConfirmNew() {
|
|
3253
|
+
this.confirmingNew = !1, this.confirmNewBar.classList.remove("visible");
|
|
3254
|
+
}
|
|
3255
|
+
setActionPending(e) {
|
|
3256
|
+
this.actionPending = e;
|
|
3257
|
+
for (let t of [
|
|
3258
|
+
this.newSessionBtn,
|
|
3259
|
+
this.cancelHumanBtn,
|
|
3260
|
+
this.confirmNewBtn
|
|
3261
|
+
]) t.setAttribute("aria-disabled", String(e));
|
|
3214
3262
|
}
|
|
3215
3263
|
buildAttachControls() {
|
|
3216
3264
|
let e = document.createElement("div");
|
|
3217
|
-
e.className = "ttcb-attach", this.attachBtn = document.createElement("button"), this.attachBtn.type = "button", this.attachBtn.className = "ttcb-attach-btn", this.attachBtn.setAttribute("aria-label", "Add attachment"), this.attachBtn.setAttribute("aria-haspopup", "menu"), this.attachBtn.setAttribute("aria-expanded", "false"), this.attachBtn.title = "Add attachment", this.attachBtn.innerHTML =
|
|
3265
|
+
e.className = "ttcb-attach", this.attachBtn = document.createElement("button"), this.attachBtn.type = "button", this.attachBtn.className = "ttcb-attach-btn", this.attachBtn.setAttribute("aria-label", "Add attachment"), this.attachBtn.setAttribute("aria-haspopup", "menu"), this.attachBtn.setAttribute("aria-expanded", "false"), this.attachBtn.title = "Add attachment", this.attachBtn.innerHTML = sn(), this.attachBtn.addEventListener("click", (e) => {
|
|
3218
3266
|
e.preventDefault(), e.stopPropagation(), this.toggleAttachMenu();
|
|
3219
|
-
}), this.attachMenu = document.createElement("div"), this.attachMenu.className = "ttcb-attach-menu", this.attachMenu.setAttribute("role", "menu"), this.attachFileInput = this.createFileInput(
|
|
3267
|
+
}), this.attachMenu = document.createElement("div"), this.attachMenu.className = "ttcb-attach-menu", this.attachMenu.setAttribute("role", "menu"), this.attachFileInput = this.createFileInput(_n, "Choose files"), this.attachPhotoInput = this.createFileInput(vn, "Choose photos");
|
|
3220
3268
|
let t = [{
|
|
3221
3269
|
label: "Attachment",
|
|
3222
|
-
icon:
|
|
3270
|
+
icon: cn(),
|
|
3223
3271
|
input: this.attachFileInput
|
|
3224
3272
|
}, {
|
|
3225
3273
|
label: "Photo",
|
|
3226
|
-
icon:
|
|
3274
|
+
icon: ln(),
|
|
3227
3275
|
input: this.attachPhotoInput
|
|
3228
3276
|
}];
|
|
3229
3277
|
for (let e of t) {
|
|
@@ -3254,12 +3302,12 @@ var hn = [
|
|
|
3254
3302
|
}
|
|
3255
3303
|
addPendingFiles(e) {
|
|
3256
3304
|
if (e.length === 0) return;
|
|
3257
|
-
let t =
|
|
3305
|
+
let t = p([...this.pendingFiles.map((e) => e.file), ...e]);
|
|
3258
3306
|
if (t) this.showComposeError(t);
|
|
3259
3307
|
else {
|
|
3260
3308
|
this.showComposeError("");
|
|
3261
3309
|
for (let t of e) {
|
|
3262
|
-
let e = t.type.startsWith("image/") ?
|
|
3310
|
+
let e = t.type.startsWith("image/") ? h(t) : "";
|
|
3263
3311
|
this.pendingFiles.push({
|
|
3264
3312
|
file: t,
|
|
3265
3313
|
previewUrl: e
|
|
@@ -3270,10 +3318,10 @@ var hn = [
|
|
|
3270
3318
|
}
|
|
3271
3319
|
removePendingFile(e) {
|
|
3272
3320
|
let [t] = this.pendingFiles.splice(e, 1);
|
|
3273
|
-
t &&
|
|
3321
|
+
t && g(t.previewUrl), this.renderPendingTray(), this.input.focus();
|
|
3274
3322
|
}
|
|
3275
3323
|
clearPendingFiles() {
|
|
3276
|
-
for (let e of this.pendingFiles)
|
|
3324
|
+
for (let e of this.pendingFiles) g(e.previewUrl);
|
|
3277
3325
|
this.pendingFiles = [], this.renderPendingTray();
|
|
3278
3326
|
}
|
|
3279
3327
|
renderPendingTray() {
|
|
@@ -3284,12 +3332,12 @@ var hn = [
|
|
|
3284
3332
|
t.className = "ttcb-pending-thumb", t.src = e.previewUrl, t.alt = "", n.appendChild(t);
|
|
3285
3333
|
} else {
|
|
3286
3334
|
let e = document.createElement("span");
|
|
3287
|
-
e.className = "ttcb-pending-icon", e.setAttribute("aria-hidden", "true"), e.innerHTML =
|
|
3335
|
+
e.className = "ttcb-pending-icon", e.setAttribute("aria-hidden", "true"), e.innerHTML = pn(), n.appendChild(e);
|
|
3288
3336
|
}
|
|
3289
3337
|
let r = document.createElement("span");
|
|
3290
3338
|
r.className = "ttcb-pending-name", r.textContent = e.file.name || "attachment", r.title = e.file.name, n.appendChild(r);
|
|
3291
3339
|
let i = document.createElement("button");
|
|
3292
|
-
i.type = "button", i.className = "ttcb-pending-remove", i.setAttribute("aria-label", `Remove ${e.file.name || "attachment"}`), i.innerHTML =
|
|
3340
|
+
i.type = "button", i.className = "ttcb-pending-remove", i.setAttribute("aria-label", `Remove ${e.file.name || "attachment"}`), i.innerHTML = Yt(), i.addEventListener("click", () => this.removePendingFile(t)), n.appendChild(i), this.pendingTray.appendChild(n);
|
|
3293
3341
|
});
|
|
3294
3342
|
}
|
|
3295
3343
|
buildVoiceBar() {
|
|
@@ -3297,10 +3345,10 @@ var hn = [
|
|
|
3297
3345
|
let e = document.createElement("span");
|
|
3298
3346
|
e.className = "ttcb-voice-dot", e.setAttribute("aria-hidden", "true"), this.voiceTime = document.createElement("span"), this.voiceTime.className = "ttcb-voice-time", this.voiceTime.setAttribute("role", "timer"), this.voiceTime.textContent = "0:00";
|
|
3299
3347
|
let t = document.createElement("div");
|
|
3300
|
-
return t.className = "ttcb-voice-meter", t.setAttribute("aria-hidden", "true"), this.voiceLevel = document.createElement("span"), this.voiceLevel.className = "ttcb-voice-level", t.appendChild(this.voiceLevel), this.voiceCancelBtn = this.createVoiceButton("Cancel recording",
|
|
3348
|
+
return t.className = "ttcb-voice-meter", t.setAttribute("aria-hidden", "true"), this.voiceLevel = document.createElement("span"), this.voiceLevel.className = "ttcb-voice-level", t.appendChild(this.voiceLevel), this.voiceCancelBtn = this.createVoiceButton("Cancel recording", fn(), () => this.cancelVoice()), this.voiceStopBtn = this.createVoiceButton("Stop recording", dn(), () => void this.stopVoice()), this.voiceStopBtn.classList.add("primary"), this.voiceBar.appendChild(e), this.voiceBar.appendChild(this.voiceTime), this.voiceBar.appendChild(t), this.voiceBar.appendChild(this.voiceCancelBtn), this.voiceBar.appendChild(this.voiceStopBtn), this.voiceBar;
|
|
3301
3349
|
}
|
|
3302
3350
|
buildVoicePreview() {
|
|
3303
|
-
return this.voicePreview = document.createElement("div"), this.voicePreview.className = "ttcb-voice-preview", this.voicePreview.setAttribute("role", "group"), this.voicePreview.setAttribute("aria-label", "Voice message preview"), this.voiceAudio = document.createElement("audio"), this.voiceAudio.className = "ttcb-voice-audio", this.voiceAudio.controls = !0, this.voiceAudio.preload = "metadata", this.voiceAudio.setAttribute("aria-label", "Recorded voice message"), this.voicePreviewTime = document.createElement("span"), this.voicePreviewTime.className = "ttcb-voice-time", this.voiceDiscardBtn = this.createVoiceButton("Discard voice message",
|
|
3351
|
+
return this.voicePreview = document.createElement("div"), this.voicePreview.className = "ttcb-voice-preview", this.voicePreview.setAttribute("role", "group"), this.voicePreview.setAttribute("aria-label", "Voice message preview"), this.voiceAudio = document.createElement("audio"), this.voiceAudio.className = "ttcb-voice-audio", this.voiceAudio.controls = !0, this.voiceAudio.preload = "metadata", this.voiceAudio.setAttribute("aria-label", "Recorded voice message"), this.voicePreviewTime = document.createElement("span"), this.voicePreviewTime.className = "ttcb-voice-time", this.voiceDiscardBtn = this.createVoiceButton("Discard voice message", fn(), () => this.cancelVoice()), this.voiceSendBtn = this.createVoiceButton("Send voice message", Xt(), () => this.sendVoice()), this.voiceSendBtn.classList.add("primary"), this.voicePreview.appendChild(this.voiceAudio), this.voicePreview.appendChild(this.voicePreviewTime), this.voicePreview.appendChild(this.voiceDiscardBtn), this.voicePreview.appendChild(this.voiceSendBtn), this.voicePreview;
|
|
3304
3352
|
}
|
|
3305
3353
|
createVoiceButton(e, t, n) {
|
|
3306
3354
|
let r = document.createElement("button");
|
|
@@ -3308,9 +3356,9 @@ var hn = [
|
|
|
3308
3356
|
}
|
|
3309
3357
|
async startVoice() {
|
|
3310
3358
|
if (!this.micBtn.disabled) {
|
|
3311
|
-
if (this.closeAttachMenu(), this.showComposeError(""), !
|
|
3359
|
+
if (this.closeAttachMenu(), this.showComposeError(""), !Bt.isSupported()) this.showComposeError("Voice messages are not supported in this browser.");
|
|
3312
3360
|
else {
|
|
3313
|
-
this.recorder?.destroy(), this.recorder = new
|
|
3361
|
+
this.recorder?.destroy(), this.recorder = new Bt((e) => this.renderVoice(e));
|
|
3314
3362
|
try {
|
|
3315
3363
|
await this.recorder.start();
|
|
3316
3364
|
} catch (e) {
|
|
@@ -3342,13 +3390,13 @@ var hn = [
|
|
|
3342
3390
|
renderVoice(e) {
|
|
3343
3391
|
if (this.destroyed) return;
|
|
3344
3392
|
let { state: t } = e;
|
|
3345
|
-
this.composeForm.classList.toggle("hidden", t !== "idle"), this.voiceBar.classList.toggle("visible", t === "recording"), this.voicePreview.classList.toggle("visible", t === "preview"), t === "recording" ? (this.voiceTime.textContent =
|
|
3393
|
+
this.composeForm.classList.toggle("hidden", t !== "idle"), this.voiceBar.classList.toggle("visible", t === "recording"), this.voicePreview.classList.toggle("visible", t === "preview"), t === "recording" ? (this.voiceTime.textContent = y(e.elapsedSeconds), this.voiceLevel.style.width = `${Math.max(4, Math.round(e.level * 100))}%`) : (g(this.voicePreviewUrl), this.voicePreviewUrl = "", this.voiceAudio.removeAttribute("src"), t === "preview" && e.result && (this.voicePreviewUrl = h(new File([e.result.blob], "voice-preview", { type: e.result.blob.type })), this.voicePreviewUrl && (this.voiceAudio.src = this.voicePreviewUrl), this.voicePreviewTime.textContent = y(e.result.durationSeconds), queueMicrotask(() => this.voiceSendBtn.focus())));
|
|
3346
3394
|
}
|
|
3347
3395
|
showComposeError(e) {
|
|
3348
3396
|
this.composeError.textContent = e, this.composeError.classList.toggle("visible", !!e);
|
|
3349
3397
|
}
|
|
3350
3398
|
setPanelMode(e) {
|
|
3351
|
-
this.panel.classList.remove("ttcb-mode-form", "ttcb-mode-chat", "ttcb-mode-compact"), this.panel.classList.add(`ttcb-mode-${e}`), e !== "chat" && (this.requestHumanBtn.classList.add("hidden"), this.newSessionBtn.classList.add("hidden"), this.hideModeBanner());
|
|
3399
|
+
this.panel.classList.remove("ttcb-mode-form", "ttcb-mode-chat", "ttcb-mode-compact"), this.panel.classList.add(`ttcb-mode-${e}`), e !== "chat" && (this.requestHumanBtn.classList.add("hidden"), this.newSessionBtn.classList.add("hidden"), this.hideConfirmNew(), this.hideModeBanner());
|
|
3352
3400
|
}
|
|
3353
3401
|
buildIdentifyForm(e) {
|
|
3354
3402
|
let t = document.createElement("form");
|
|
@@ -3362,7 +3410,7 @@ var hn = [
|
|
|
3362
3410
|
placeholder: "Your name",
|
|
3363
3411
|
type: "text",
|
|
3364
3412
|
autocomplete: "name",
|
|
3365
|
-
icon:
|
|
3413
|
+
icon: Qt()
|
|
3366
3414
|
}), this.createPhoneField(t), this.emailInput = this.createIconField(t, {
|
|
3367
3415
|
id: "email",
|
|
3368
3416
|
label: "Email (optional)",
|
|
@@ -3371,10 +3419,10 @@ var hn = [
|
|
|
3371
3419
|
placeholder: "Email (optional)",
|
|
3372
3420
|
type: "email",
|
|
3373
3421
|
autocomplete: "email",
|
|
3374
|
-
icon:
|
|
3375
|
-
}), this.identifyError = document.createElement("p"), this.identifyError.className = "ttcb-identify-error", t.appendChild(this.identifyError), this.identifySubmit = document.createElement("button"), this.identifySubmit.type = "submit", this.identifySubmit.className = "ttcb-identify-submit", this.identifySubmit.innerHTML = `<span>Start Chatting</span>${
|
|
3422
|
+
icon: $t()
|
|
3423
|
+
}), this.identifyError = document.createElement("p"), this.identifyError.className = "ttcb-identify-error", t.appendChild(this.identifyError), this.identifySubmit = document.createElement("button"), this.identifySubmit.type = "submit", this.identifySubmit.className = "ttcb-identify-submit", this.identifySubmit.innerHTML = `<span>Start Chatting</span>${tn()}`, t.appendChild(this.identifySubmit), e.appendChild(t);
|
|
3376
3424
|
let n = document.createElement("div");
|
|
3377
|
-
n.className = "ttcb-trust", n.innerHTML = `${
|
|
3425
|
+
n.className = "ttcb-trust", n.innerHTML = `${nn()}<span>Encrypted connection • No spam, ever</span>`, e.appendChild(n);
|
|
3378
3426
|
}
|
|
3379
3427
|
createIconField(e, t) {
|
|
3380
3428
|
let n = document.createElement("div");
|
|
@@ -3404,7 +3452,7 @@ var hn = [
|
|
|
3404
3452
|
let a = document.createElement("div");
|
|
3405
3453
|
a.className = "ttcb-phone-row", a.id = "ttcb-phone-row", this.dialBtn = document.createElement("button"), this.dialBtn.type = "button", this.dialBtn.className = "ttcb-dial-btn", this.dialBtn.setAttribute("aria-label", "Select country code"), this.dialBtn.setAttribute("aria-haspopup", "listbox"), this.dialBtn.setAttribute("aria-expanded", "false"), this.dialFlag = document.createElement("span"), this.dialFlag.className = "ttcb-dial-flag", this.dialCode = document.createElement("span"), this.dialCode.className = "ttcb-dial-code", this.syncDialButton(), this.dialBtn.appendChild(this.dialFlag), this.dialBtn.appendChild(this.dialCode);
|
|
3406
3454
|
let o = document.createElement("span");
|
|
3407
|
-
o.setAttribute("aria-hidden", "true"), o.innerHTML =
|
|
3455
|
+
o.setAttribute("aria-hidden", "true"), o.innerHTML = en(), this.dialBtn.appendChild(o), this.dialBtn.addEventListener("click", (e) => {
|
|
3408
3456
|
e.preventDefault(), e.stopPropagation(), this.toggleCountryPopover();
|
|
3409
3457
|
}), this.phoneInput = document.createElement("input"), this.phoneInput.id = "ttcb-tel", this.phoneInput.name = "tel", this.phoneInput.type = "tel", this.phoneInput.className = "ttcb-phone-national", this.phoneInput.placeholder = "1712-345678", this.phoneInput.required = !0, this.phoneInput.autocomplete = "tel-national", this.phoneInput.setAttribute("inputmode", "tel"), a.appendChild(this.dialBtn), a.appendChild(this.phoneInput), this.countryPopover = document.createElement("div"), this.countryPopover.className = "ttcb-country-popover", this.countryPopover.setAttribute("role", "listbox"), this.countrySearch = document.createElement("input"), this.countrySearch.type = "search", this.countrySearch.className = "ttcb-country-search", this.countrySearch.placeholder = "Search country…", this.countrySearch.setAttribute("aria-label", "Search countries"), this.countrySearch.addEventListener("input", () => this.renderCountryList()), this.countryList = document.createElement("div"), this.countryList.className = "ttcb-country-list", this.countryPopover.appendChild(this.countrySearch), this.countryPopover.appendChild(this.countryList), this.renderCountryList(), t.appendChild(n), t.appendChild(a), t.appendChild(this.countryPopover), e.appendChild(t);
|
|
3410
3458
|
}
|
|
@@ -3473,7 +3521,7 @@ var hn = [
|
|
|
3473
3521
|
}
|
|
3474
3522
|
}
|
|
3475
3523
|
handleIdentifySubmit() {
|
|
3476
|
-
let e = this.nameInput.value.trim(), t =
|
|
3524
|
+
let e = this.nameInput.value.trim(), t = Ht(this.selectedCountry.dial, this.phoneInput.value), n = this.emailInput.value.trim();
|
|
3477
3525
|
!e || !t ? this.showIdentifyError("Name and phone are required.") : (this.showIdentifyError(""), this.callbacks.onIdentify({
|
|
3478
3526
|
name: e,
|
|
3479
3527
|
phone: t,
|
|
@@ -3494,13 +3542,13 @@ var hn = [
|
|
|
3494
3542
|
}
|
|
3495
3543
|
buildMessage(e) {
|
|
3496
3544
|
if ("message" in e) {
|
|
3497
|
-
let t =
|
|
3545
|
+
let t = hn({
|
|
3498
3546
|
...e.message,
|
|
3499
3547
|
pending: e.pending
|
|
3500
3548
|
});
|
|
3501
3549
|
return t.dataset.msgId = String(e.id), t;
|
|
3502
3550
|
}
|
|
3503
|
-
return
|
|
3551
|
+
return hn(e);
|
|
3504
3552
|
}
|
|
3505
3553
|
findMessageEl(e) {
|
|
3506
3554
|
for (let t of this.messagesContainer.querySelectorAll(".ttcb-msg")) if (t.dataset.msgId === String(e)) return t;
|
|
@@ -3513,7 +3561,7 @@ var hn = [
|
|
|
3513
3561
|
}
|
|
3514
3562
|
}
|
|
3515
3563
|
setLoading(e) {
|
|
3516
|
-
if (this.sendBtn.disabled = e || this.input.disabled, this.attachBtn.disabled = e || this.input.disabled, this.micBtn.disabled = e || this.input.disabled, e) this.closeAttachMenu(), this.shadow.getElementById("ttcb-typing") || (this.messagesContainer.appendChild(
|
|
3564
|
+
if (this.sendBtn.disabled = e || this.input.disabled, this.attachBtn.disabled = e || this.input.disabled, this.micBtn.disabled = e || this.input.disabled, e) this.closeAttachMenu(), this.shadow.getElementById("ttcb-typing") || (this.messagesContainer.appendChild(gn()), this.scrollToBottom()), this.isFullScreen() || this.input.focus();
|
|
3517
3565
|
else {
|
|
3518
3566
|
let e = this.shadow.getElementById("ttcb-typing");
|
|
3519
3567
|
e && e.remove(), !this.input.disabled && !this.isFullScreen() && this.input.focus();
|
|
@@ -3522,7 +3570,7 @@ var hn = [
|
|
|
3522
3570
|
setIdentifyLoading(e) {
|
|
3523
3571
|
this.identifySubmit.disabled = e, this.nameInput.disabled = e, this.phoneInput.disabled = e, this.emailInput.disabled = e, this.dialBtn.disabled = e, this.shadow.getElementById("ttcb-phone-row")?.classList.toggle("disabled", e);
|
|
3524
3572
|
for (let t of this.identifyContainer.querySelectorAll(".ttcb-input-wrap")) t.classList.toggle("disabled", e);
|
|
3525
|
-
this.identifySubmit.innerHTML = e ? "<span>Starting…</span>" : `<span>Start Chatting</span>${
|
|
3573
|
+
this.identifySubmit.innerHTML = e ? "<span>Starting…</span>" : `<span>Start Chatting</span>${tn()}`, e && this.closeCountryPopover();
|
|
3526
3574
|
}
|
|
3527
3575
|
showIdentifyError(e) {
|
|
3528
3576
|
this.identifyError.textContent = e;
|
|
@@ -3560,26 +3608,30 @@ var hn = [
|
|
|
3560
3608
|
}) : this.showEmptyState(e.chatbotName ?? "AI Assistant"), this.setMode("ai");
|
|
3561
3609
|
}
|
|
3562
3610
|
clearMessages(e) {
|
|
3563
|
-
this.messagesContainer.innerHTML = "", this.clearPendingFiles(), this.showComposeError(""), this.showEmptyState(e);
|
|
3611
|
+
this.messagesContainer.innerHTML = "", this.clearPendingFiles(), this.showComposeError(""), this.hideConfirmNew(), this.showEmptyState(e);
|
|
3564
3612
|
}
|
|
3565
3613
|
setMode(e, t) {
|
|
3566
|
-
let n = this.panel.classList.contains("ttcb-mode-chat"), r = t?.agentName, i = t?.canRequestHuman === !0, a = n && i,
|
|
3567
|
-
this.requestHumanBtn.classList.toggle("hidden", !
|
|
3614
|
+
let n = this.panel.classList.contains("ttcb-mode-chat"), r = t?.agentName, i = t?.canRequestHuman === !0, a = t?.canStartNew ?? e === "closed", o = n && i, s = n && a, c = e === "closed";
|
|
3615
|
+
this.ticketMode = e, this.requestHumanBtn.classList.toggle("hidden", !o), this.newSessionBtn.classList.toggle("hidden", !s), (!s || c) && this.hideConfirmNew(), this.input.disabled = c, c ? (this.sendBtn.disabled = !0, this.attachBtn.disabled = !0, this.micBtn.disabled = !0, this.closeAttachMenu(), this.clearPendingFiles(), this.recorder && this.cancelVoice(), this.showComposeError("")) : this.shadow.getElementById("ttcb-typing") || (this.sendBtn.disabled = !1, this.attachBtn.disabled = !1, this.micBtn.disabled = !1), n ? (e === "waiting" ? this.showModeBanner("Waiting for a human agent…", "waiting") : e === "closed" ? this.showModeBanner("This conversation is closed", "closed") : e === "human" && r?.trim() ? this.showModeBanner(`Connected with ${r.trim()}`, "human") : this.hideModeBanner(), this.rescueFocus()) : (this.hideModeBanner(), this.rescueFocus());
|
|
3568
3616
|
}
|
|
3569
3617
|
showModeBanner(e, t) {
|
|
3570
|
-
this.
|
|
3618
|
+
this.modeBannerText.textContent = e, this.modeBanner.className = `ttcb-mode-banner visible ${t}`, this.cancelHumanBtn.classList.toggle("hidden", t !== "waiting");
|
|
3571
3619
|
}
|
|
3572
3620
|
hideModeBanner() {
|
|
3573
|
-
this.
|
|
3621
|
+
this.modeBannerText.textContent = "", this.modeBanner.className = "ttcb-mode-banner", this.cancelHumanBtn.classList.add("hidden");
|
|
3622
|
+
}
|
|
3623
|
+
rescueFocus() {
|
|
3624
|
+
let e = this.shadow.activeElement;
|
|
3625
|
+
e instanceof HTMLElement && (e.closest(".hidden") || e.closest(".ttcb-mode-banner:not(.visible)")) && (this.input.disabled ? this.panel.focus({ preventScroll: !0 }) : this.input.focus());
|
|
3574
3626
|
}
|
|
3575
3627
|
destroy() {
|
|
3576
|
-
this.destroyed = !0, this.stopViewportSync?.(), this.stopViewportSync = null, this.clearPendingFiles(), this.recorder?.destroy(), this.recorder = null,
|
|
3628
|
+
this.destroyed = !0, this.stopViewportSync?.(), this.stopViewportSync = null, this.clearPendingFiles(), this.recorder?.destroy(), this.recorder = null, g(this.voicePreviewUrl), this.voicePreviewUrl = "", this.host.remove();
|
|
3577
3629
|
}
|
|
3578
3630
|
scrollToBottom() {
|
|
3579
3631
|
this.messagesContainer.scrollTop = this.messagesContainer.scrollHeight;
|
|
3580
3632
|
}
|
|
3581
|
-
},
|
|
3582
|
-
apiBaseUrl:
|
|
3633
|
+
}, bn = {
|
|
3634
|
+
apiBaseUrl: u,
|
|
3583
3635
|
chatbotName: "AI Assistant",
|
|
3584
3636
|
primaryColor: "#2563EB",
|
|
3585
3637
|
theme: "auto",
|
|
@@ -3590,23 +3642,23 @@ var hn = [
|
|
|
3590
3642
|
sessionId: "",
|
|
3591
3643
|
requestTimeoutMs: n
|
|
3592
3644
|
};
|
|
3593
|
-
function
|
|
3645
|
+
function xn(e) {
|
|
3594
3646
|
return Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0));
|
|
3595
3647
|
}
|
|
3596
|
-
var
|
|
3648
|
+
var Sn = [
|
|
3597
3649
|
5e3,
|
|
3598
3650
|
15e3,
|
|
3599
3651
|
3e4,
|
|
3600
3652
|
6e4
|
|
3601
3653
|
];
|
|
3602
|
-
function
|
|
3603
|
-
return
|
|
3604
|
-
}
|
|
3605
|
-
function Sn(e) {
|
|
3606
|
-
return o(e) ? e.apiError.message : e instanceof Error ? e.message : "Failed to load chatbot config.";
|
|
3654
|
+
function Cn(e) {
|
|
3655
|
+
return c(e) ? e.status === 0 || e.status >= 500 || e.apiError.code === "BAD_RESPONSE" : !1;
|
|
3607
3656
|
}
|
|
3608
|
-
var Cn = 0, Q = () => Date.now() * 1e3 + Cn++ % 1e3;
|
|
3609
3657
|
function wn(e) {
|
|
3658
|
+
return c(e) ? e.apiError.message : e instanceof Error ? e.message : "Failed to load chatbot config.";
|
|
3659
|
+
}
|
|
3660
|
+
var Tn = 0, Q = () => Date.now() * 1e3 + Tn++ % 1e3;
|
|
3661
|
+
function En(e) {
|
|
3610
3662
|
if (!e || typeof e != "object") return null;
|
|
3611
3663
|
let t = e;
|
|
3612
3664
|
if (typeof t.textMessage == "string" && t.textMessage.trim()) return t.textMessage.trim();
|
|
@@ -3618,11 +3670,11 @@ function wn(e) {
|
|
|
3618
3670
|
}
|
|
3619
3671
|
return null;
|
|
3620
3672
|
}
|
|
3621
|
-
function
|
|
3673
|
+
function Dn(e) {
|
|
3622
3674
|
let t = (e.attachments ?? []).map((e) => e.url).join("");
|
|
3623
3675
|
return `${e.content}\u0000${t}`;
|
|
3624
3676
|
}
|
|
3625
|
-
function
|
|
3677
|
+
function On(e) {
|
|
3626
3678
|
if (!e || typeof e != "object") return null;
|
|
3627
3679
|
let t = e;
|
|
3628
3680
|
if (typeof t.id == "string" && t.id) return t.id;
|
|
@@ -3632,9 +3684,9 @@ function En(e) {
|
|
|
3632
3684
|
}
|
|
3633
3685
|
return null;
|
|
3634
3686
|
}
|
|
3635
|
-
var
|
|
3687
|
+
var kn = class {
|
|
3636
3688
|
constructor() {
|
|
3637
|
-
this.emitter = new fe(), this.visitorTokens = new
|
|
3689
|
+
this.emitter = new fe(), this.visitorTokens = new Nt(), this.widget = null, this.sdkSocket = null, this.callerSetName = !1, this.hasActiveTicket = !1, this.retryTimer = null, this.lastPushId = null, this.endedConversationId = null, this.initToken = 0, this._state = {
|
|
3638
3690
|
isOpen: !1,
|
|
3639
3691
|
isLoading: !1,
|
|
3640
3692
|
isReady: !1,
|
|
@@ -3662,20 +3714,24 @@ var Dn = class {
|
|
|
3662
3714
|
syncWidgetMode(e, t) {
|
|
3663
3715
|
this.widget?.setMode(e, {
|
|
3664
3716
|
agentName: t,
|
|
3665
|
-
canRequestHuman: e === "ai" && this.hasActiveTicket
|
|
3717
|
+
canRequestHuman: e === "ai" && this.hasActiveTicket,
|
|
3718
|
+
canStartNew: e === "closed" || this.hasActiveTicket
|
|
3666
3719
|
});
|
|
3667
3720
|
}
|
|
3721
|
+
isEndedConversation(e) {
|
|
3722
|
+
return e.mode === "closed" && !!e.conversationId && e.conversationId === this.endedConversationId;
|
|
3723
|
+
}
|
|
3668
3724
|
async init(e) {
|
|
3669
3725
|
if (!e.apiKey) throw Error("[onedeskpro-chatbot] `apiKey` is required to initialise the chatbot.");
|
|
3670
3726
|
let t = ++this.initToken;
|
|
3671
3727
|
this.clearRetry(), this.disconnectSdkSocket(), this.widget?.destroy(), this.widget = null, this.callerSetName = e.chatbotName !== void 0, this.options = {
|
|
3672
|
-
...
|
|
3673
|
-
...
|
|
3674
|
-
}, this.apiClient = new
|
|
3728
|
+
...bn,
|
|
3729
|
+
...xn(e)
|
|
3730
|
+
}, this.apiClient = new l({
|
|
3675
3731
|
baseUrl: this.options.apiBaseUrl,
|
|
3676
3732
|
apiKey: this.options.apiKey,
|
|
3677
3733
|
timeoutMs: this.options.requestTimeoutMs
|
|
3678
|
-
}), this.hasActiveTicket = !1, this.setState({
|
|
3734
|
+
}), this.hasActiveTicket = !1, this.endedConversationId = null, this.setState({
|
|
3679
3735
|
isReady: !1,
|
|
3680
3736
|
blockReason: null,
|
|
3681
3737
|
visitorToken: null,
|
|
@@ -3692,13 +3748,13 @@ var Dn = class {
|
|
|
3692
3748
|
n = await this.apiClient.fetchConfig();
|
|
3693
3749
|
} catch (n) {
|
|
3694
3750
|
if (e !== this.initToken) return;
|
|
3695
|
-
if (
|
|
3751
|
+
if (Cn(n)) {
|
|
3696
3752
|
this.setState({
|
|
3697
3753
|
isReady: !1,
|
|
3698
3754
|
blockReason: "server-unavailable",
|
|
3699
|
-
error:
|
|
3755
|
+
error: wn(n)
|
|
3700
3756
|
});
|
|
3701
|
-
let r =
|
|
3757
|
+
let r = Sn[t];
|
|
3702
3758
|
if (r !== void 0) {
|
|
3703
3759
|
this.retryTimer = setTimeout(() => {
|
|
3704
3760
|
this.retryTimer = null, this.checkReadiness(e, t + 1);
|
|
@@ -3719,7 +3775,7 @@ var Dn = class {
|
|
|
3719
3775
|
}), i ? (this.mountWidget(), this.visitorTokens.setScope(n.agentId), await this.resolveVisitorGate(e), e === this.initToken && (this.widget?.reveal(), this.emitter.emit("ready"))) : this.emitter.emit("ready");
|
|
3720
3776
|
}
|
|
3721
3777
|
mountWidget() {
|
|
3722
|
-
typeof window < "u" && typeof document < "u" && (this.widget = new
|
|
3778
|
+
typeof window < "u" && typeof document < "u" && (this.widget = new yn(this.options, {
|
|
3723
3779
|
onSend: (e) => void this.sendMessage(e),
|
|
3724
3780
|
onSendAttachments: (e, t) => void this.sendAttachments(e, t),
|
|
3725
3781
|
onSendVoice: (e) => void this.sendVoice(e),
|
|
@@ -3730,19 +3786,20 @@ var Dn = class {
|
|
|
3730
3786
|
onClose: () => {
|
|
3731
3787
|
this.setState({ isOpen: !1 }), this.emitter.emit("close");
|
|
3732
3788
|
},
|
|
3733
|
-
|
|
3734
|
-
onRequestHuman: () => void this.requestHuman()
|
|
3789
|
+
onNewConversation: () => void this.startNewConversation(),
|
|
3790
|
+
onRequestHuman: () => void this.requestHuman(),
|
|
3791
|
+
onCancelHumanRequest: () => void this.cancelHumanRequest()
|
|
3735
3792
|
}));
|
|
3736
3793
|
}
|
|
3737
3794
|
clearRetry() {
|
|
3738
3795
|
this.retryTimer !== null && (clearTimeout(this.retryTimer), this.retryTimer = null);
|
|
3739
3796
|
}
|
|
3740
3797
|
handleConfigError(e) {
|
|
3741
|
-
let t = (
|
|
3798
|
+
let t = (c(e) ? e : null)?.apiError.code === "agent_not_assigned" ? "no-agent" : null;
|
|
3742
3799
|
this.setState({
|
|
3743
3800
|
isReady: !1,
|
|
3744
3801
|
blockReason: t,
|
|
3745
|
-
error:
|
|
3802
|
+
error: wn(e)
|
|
3746
3803
|
});
|
|
3747
3804
|
}
|
|
3748
3805
|
async resolveVisitorGate(e) {
|
|
@@ -3774,7 +3831,7 @@ var Dn = class {
|
|
|
3774
3831
|
}), this.widget?.readyToChat(this.options), this.connectSdkSocket(e), await this.restoreTicketStatus(e, n);
|
|
3775
3832
|
}
|
|
3776
3833
|
connectSdkSocket(e) {
|
|
3777
|
-
this.sdkSocket ||= new
|
|
3834
|
+
this.sdkSocket ||= new kt(), this.sdkSocket.connect({
|
|
3778
3835
|
baseUrl: this.options.apiBaseUrl,
|
|
3779
3836
|
apiKey: this.options.apiKey,
|
|
3780
3837
|
visitorToken: e,
|
|
@@ -3795,19 +3852,19 @@ var Dn = class {
|
|
|
3795
3852
|
async restoreTicketStatus(e, t) {
|
|
3796
3853
|
try {
|
|
3797
3854
|
let n = await this.apiClient.fetchTicketStatus(e);
|
|
3798
|
-
if (t !== this.initToken) return;
|
|
3855
|
+
if (t !== this.initToken || this.isEndedConversation(n)) return;
|
|
3799
3856
|
this.applyMode(n.mode, n);
|
|
3800
3857
|
} catch {}
|
|
3801
3858
|
}
|
|
3802
3859
|
handleTicketStatus(e) {
|
|
3803
|
-
e?.mode && this.applyMode(e.mode, e);
|
|
3860
|
+
e?.mode && !this.isEndedConversation(e) && this.applyMode(e.mode, e);
|
|
3804
3861
|
}
|
|
3805
3862
|
handleMessageReceive(e) {
|
|
3806
3863
|
if (this._state.mode === "ai") return;
|
|
3807
|
-
let t =
|
|
3864
|
+
let t = En(e) ?? "", n = ne(e);
|
|
3808
3865
|
if (!t && n.length === 0) return;
|
|
3809
|
-
let r =
|
|
3810
|
-
if (i &&
|
|
3866
|
+
let r = On(e), i = this._state.messages[this._state.messages.length - 1];
|
|
3867
|
+
if (i && Dn(i.message) === Dn({
|
|
3811
3868
|
content: t,
|
|
3812
3869
|
attachments: n
|
|
3813
3870
|
}) && (i.message.type === "ai" || i.message.type === "agent" && (!r || r === this.lastPushId))) return;
|
|
@@ -3864,6 +3921,50 @@ var Dn = class {
|
|
|
3864
3921
|
this.setState({ isLoading: !1 });
|
|
3865
3922
|
}
|
|
3866
3923
|
}
|
|
3924
|
+
async cancelHumanRequest() {
|
|
3925
|
+
if (!this.apiClient || this._state.mode !== "waiting" || this._state.isLoading) return;
|
|
3926
|
+
let e = this.requireVisitorToken("cancelHumanRequest"), t = this.initToken;
|
|
3927
|
+
this.setState({
|
|
3928
|
+
isLoading: !0,
|
|
3929
|
+
error: null
|
|
3930
|
+
}), this.widget?.setActionPending(!0), this.widget?.showComposeError("");
|
|
3931
|
+
try {
|
|
3932
|
+
let n = await this.apiClient.cancelHumanRequest(e);
|
|
3933
|
+
if (t !== this.initToken) return;
|
|
3934
|
+
this.applyMode(n.mode, n), n.mode === "ai" && this.emitter.emit("human-request-cancelled");
|
|
3935
|
+
} catch (e) {
|
|
3936
|
+
if (t !== this.initToken) return;
|
|
3937
|
+
this.rejectAction(e, "Could not cancel the request. Please try again.");
|
|
3938
|
+
} finally {
|
|
3939
|
+
t === this.initToken && (this.setState({ isLoading: !1 }), this.widget?.setActionPending(!1));
|
|
3940
|
+
}
|
|
3941
|
+
}
|
|
3942
|
+
async startNewConversation() {
|
|
3943
|
+
if (!this.apiClient || !this._state.isReady || this._state.needsIdentify || this._state.isLoading) return;
|
|
3944
|
+
let e = this.requireVisitorToken("startNewConversation"), t = this.initToken;
|
|
3945
|
+
this.setState({
|
|
3946
|
+
isLoading: !0,
|
|
3947
|
+
error: null
|
|
3948
|
+
}), this.widget?.setActionPending(!0), this.widget?.showComposeError("");
|
|
3949
|
+
try {
|
|
3950
|
+
let n = await this.apiClient.closeConversation(e);
|
|
3951
|
+
if (t !== this.initToken) return;
|
|
3952
|
+
this.endedConversationId = n.mode === "closed" ? n.conversationId ?? null : null, this.hasActiveTicket = !1, this.setState({
|
|
3953
|
+
messages: [],
|
|
3954
|
+
error: null,
|
|
3955
|
+
mode: "ai"
|
|
3956
|
+
}), this.widget?.clearMessages(this.options.chatbotName), this.syncWidgetMode("ai"), this.emitter.emit("session-reset");
|
|
3957
|
+
} catch (e) {
|
|
3958
|
+
if (t !== this.initToken) return;
|
|
3959
|
+
this.rejectAction(e, "Could not start a new conversation. Please try again.");
|
|
3960
|
+
} finally {
|
|
3961
|
+
t === this.initToken && (this.setState({ isLoading: !1 }), this.widget?.setActionPending(!1));
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
rejectAction(e, t) {
|
|
3965
|
+
let n = e instanceof Error ? e : Error(String(e));
|
|
3966
|
+
this.setState({ error: n.message }), this.widget?.showComposeError(t), this.emitter.emit("error", n);
|
|
3967
|
+
}
|
|
3867
3968
|
requireVisitorToken(e) {
|
|
3868
3969
|
let t = this.visitorTokens.get() ?? this._state.visitorToken;
|
|
3869
3970
|
if (!this.apiClient || !t) throw Error(`[onedeskpro-chatbot] Identify before ${e}().`);
|
|
@@ -3913,7 +4014,7 @@ var Dn = class {
|
|
|
3913
4014
|
return;
|
|
3914
4015
|
}
|
|
3915
4016
|
if (e.length === 0 || this._state.isLoading || this._state.needsIdentify) return;
|
|
3916
|
-
let r =
|
|
4017
|
+
let r = p(e);
|
|
3917
4018
|
r ? this.rejectSend(r) : await this.uploadThenDeliver({
|
|
3918
4019
|
visitorToken: n,
|
|
3919
4020
|
files: e,
|
|
@@ -3944,7 +4045,7 @@ var Dn = class {
|
|
|
3944
4045
|
...n.waveform ? { waveform: n.waveform } : {}
|
|
3945
4046
|
}, i = {
|
|
3946
4047
|
type: n.file.type,
|
|
3947
|
-
url:
|
|
4048
|
+
url: h(n.file),
|
|
3948
4049
|
fileName: n.file.name,
|
|
3949
4050
|
size: n.file.size,
|
|
3950
4051
|
...r
|
|
@@ -3981,7 +4082,7 @@ var Dn = class {
|
|
|
3981
4082
|
}
|
|
3982
4083
|
} catch (e) {
|
|
3983
4084
|
this.removeMessage(a.id);
|
|
3984
|
-
for (let e of r)
|
|
4085
|
+
for (let e of r) g(e.url);
|
|
3985
4086
|
let t = e instanceof Error ? e : Error(String(e));
|
|
3986
4087
|
this.setState({
|
|
3987
4088
|
error: t.message,
|
|
@@ -3998,7 +4099,7 @@ var Dn = class {
|
|
|
3998
4099
|
}
|
|
3999
4100
|
};
|
|
4000
4101
|
this.replaceMessage(a.id, c);
|
|
4001
|
-
for (let e of r)
|
|
4102
|
+
for (let e of r) g(e.url);
|
|
4002
4103
|
o === "ai" && this.widget?.setLoading(!0), await this.deliver({
|
|
4003
4104
|
chatInput: i,
|
|
4004
4105
|
visitorToken: t,
|
|
@@ -4009,7 +4110,7 @@ var Dn = class {
|
|
|
4009
4110
|
async deliver(e, t) {
|
|
4010
4111
|
try {
|
|
4011
4112
|
let n = await this.apiClient.sendMessage(e);
|
|
4012
|
-
this.hasActiveTicket = !0;
|
|
4113
|
+
this.hasActiveTicket = !0, this.endedConversationId = null;
|
|
4013
4114
|
let r = n.mode ?? t, i = [...this._state.messages], a = (n.text ?? "").trim();
|
|
4014
4115
|
if (r !== t && (this.setState({ mode: r }), this.syncWidgetMode(r), this.emitter.emit("ticket-status", { mode: r })), a) {
|
|
4015
4116
|
let e = i[i.length - 1];
|
|
@@ -4070,13 +4171,12 @@ var Dn = class {
|
|
|
4070
4171
|
needsIdentify: !0
|
|
4071
4172
|
});
|
|
4072
4173
|
}
|
|
4073
|
-
}, $ = null,
|
|
4174
|
+
}, $ = null, An = {
|
|
4074
4175
|
async init(e) {
|
|
4075
|
-
return $ = new
|
|
4176
|
+
return $ = new kn(), await $.init(e), $;
|
|
4076
4177
|
},
|
|
4077
4178
|
getInstance() {
|
|
4078
4179
|
return $;
|
|
4079
4180
|
}
|
|
4080
4181
|
};
|
|
4081
|
-
|
|
4082
|
-
export { s as ApiClient, Dn as ChatbotCore, c as DEFAULT_API_BASE_URL, n as DEFAULT_REQUEST_TIMEOUT_MS, fe as EventEmitter, On as OnedeskProChatbot, u as SDK_CHAT_MAX_ATTACHMENTS, l as SDK_UPLOAD_MAX_BYTES, Ot as SdkSocket, Mt as SessionManager, Nt as VOICE_MAX_DURATION_SECONDS, Y as VoiceRecorder, o as isChatbotRequestError, Dt as resolveSdkSocketUrl };
|
|
4182
|
+
export { l as ApiClient, kn as ChatbotCore, u as DEFAULT_API_BASE_URL, n as DEFAULT_REQUEST_TIMEOUT_MS, fe as EventEmitter, An as OnedeskProChatbot, f as SDK_CHAT_MAX_ATTACHMENTS, d as SDK_UPLOAD_MAX_BYTES, kt as SdkSocket, Nt as SessionManager, Pt as VOICE_MAX_DURATION_SECONDS, Bt as VoiceRecorder, c as isChatbotRequestError, Ot as resolveSdkSocketUrl };
|