@carbon/ai-chat 0.1.1-alpha5 → 0.1.1-react17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/App.js +933 -55468
  2. package/dist/Carousel.js +1 -5705
  3. package/dist/Chat.js +1 -8339
  4. package/dist/GenesysMessengerServiceDesk.js +1 -579
  5. package/dist/HumanAgentServiceImpl.js +1 -1122
  6. package/dist/NiceDFOServiceDesk.js +2 -2097
  7. package/dist/PDFViewerContainer.js +2 -27439
  8. package/dist/SFServiceDesk.js +1 -1012
  9. package/dist/ServiceDeskImpl.js +1 -72
  10. package/dist/ZendeskServiceDesk.js +1 -649
  11. package/dist/_commonjsHelpers.js +1 -33
  12. package/dist/_node-resolve_empty.js +1 -25
  13. package/dist/agentActions.js +1 -187
  14. package/dist/aiChatEntry.js +1 -28
  15. package/dist/aiChatEntry2.js +4 -7022
  16. package/dist/anonymousUserIDStorage.js +2 -250
  17. package/dist/ar-dz.js +1 -55
  18. package/dist/ar-kw.js +1 -55
  19. package/dist/ar-ly.js +1 -55
  20. package/dist/ar-ma.js +1 -55
  21. package/dist/ar-sa.js +1 -55
  22. package/dist/ar-tn.js +1 -55
  23. package/dist/ar.js +1 -55
  24. package/dist/ar2.js +1 -470
  25. package/dist/cs.js +1 -55
  26. package/dist/cs2.js +1 -470
  27. package/dist/de-at.js +1 -55
  28. package/dist/de-ch.js +1 -55
  29. package/dist/de.js +1 -55
  30. package/dist/de2.js +1 -470
  31. package/dist/domUtils.js +2 -820
  32. package/dist/en-au.js +1 -55
  33. package/dist/en-ca.js +1 -55
  34. package/dist/en-gb.js +1 -55
  35. package/dist/en-ie.js +1 -55
  36. package/dist/en-il.js +1 -55
  37. package/dist/en-nz.js +1 -55
  38. package/dist/es-do.js +1 -55
  39. package/dist/es-us.js +1 -55
  40. package/dist/es.js +1 -55
  41. package/dist/es2.js +1 -470
  42. package/dist/export.js +1 -25
  43. package/dist/export.legacy.js +1 -25
  44. package/dist/fontUtils.js +1 -1036
  45. package/dist/fr-ca.js +1 -55
  46. package/dist/fr-ch.js +1 -55
  47. package/dist/fr.js +1 -55
  48. package/dist/fr2.js +1 -470
  49. package/dist/humanAgentUtils.js +1 -1393
  50. package/dist/it-ch.js +1 -55
  51. package/dist/it.js +1 -55
  52. package/dist/it2.js +1 -470
  53. package/dist/ja.js +1 -55
  54. package/dist/ja2.js +1 -470
  55. package/dist/jstz.min.js +1 -41
  56. package/dist/ko.js +1 -55
  57. package/dist/ko2.js +1 -470
  58. package/dist/messageUtils.js +1 -1338
  59. package/dist/mockServiceDesk.js +1 -851
  60. package/dist/moduleFederationPluginUtils.js +2 -5852
  61. package/dist/nl.js +1 -55
  62. package/dist/nl2.js +1 -470
  63. package/dist/pt-br.js +1 -55
  64. package/dist/pt-br2.js +1 -470
  65. package/dist/pt.js +1 -55
  66. package/dist/render.js +1 -88
  67. package/dist/web-components/cds-aichat-container/index.js +3 -3
  68. package/dist/web-components/cds-aichat-container/index.js.map +1 -1
  69. package/dist/web-components/cds-aichat-custom-element/index.js +2 -2
  70. package/dist/web-components/cds-aichat-custom-element/index.js.map +1 -1
  71. package/dist/zh-cn.js +1 -55
  72. package/dist/zh-tw.js +1 -55
  73. package/dist/zh-tw2.js +1 -470
  74. package/dist/zh.js +1 -470
  75. package/package.json +1 -1
@@ -1,2097 +1,2 @@
1
- /*
2
-
3
-
4
- (C) Copyright IBM Corp. 2017, 2024. All Rights Reserved.
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7
- in compliance with the License. You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software distributed under the License
12
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13
- or implied. See the License for the specific language governing permissions and limitations under
14
- the License.
15
-
16
- @carbon/ai-chat 0.1.1-alpha5
17
-
18
- Built: Oct 24 2024 10:59 am -04:00
19
-
20
-
21
-
22
- */
23
- import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers.js';
24
- import { t as isConnectToAgent, L as InternalMessageResponseType, a0 as ButtonItemKind, a2 as ButtonItemType, ak as ErrorType } from './messageUtils.js';
25
- import { h as debugLog, u as uuid, U as UUIDType, a7 as resolveOrTimeout, c as consoleError, a4 as assertType, p as MessageResponseTypes } from './aiChatEntry2.js';
26
- import { r as resolvablePromise, aL as getSummaryMessages } from './humanAgentUtils.js';
27
- import { A as ANONYMOUS_USER_ID_PREFIX } from './anonymousUserIDStorage.js';
28
- import { S as ServiceDeskImpl } from './ServiceDeskImpl.js';
29
- import '@lit/react';
30
- import 'react';
31
- import 'lit';
32
- import 'lit/decorators.js';
33
- import 'react-dom';
34
-
35
- var niceCxoneChatWebSdk = {exports: {}};
36
-
37
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
38
- // require the crypto API and do not support built-in fallback to lower quality random number
39
- // generators (like Math.random()).
40
- var getRandomValues;
41
- var rnds8 = new Uint8Array(16);
42
- function rng() {
43
- // lazy load so that environments that need to polyfill have a chance to do so
44
- if (!getRandomValues) {
45
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
46
- // find the complete implementation of crypto (msCrypto) on IE11.
47
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
48
-
49
- if (!getRandomValues) {
50
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
51
- }
52
- }
53
-
54
- return getRandomValues(rnds8);
55
- }
56
-
57
- var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
58
-
59
- function validate(uuid) {
60
- return typeof uuid === 'string' && REGEX.test(uuid);
61
- }
62
-
63
- /**
64
- * Convert array of 16 byte values to UUID string format of the form:
65
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
66
- */
67
-
68
- var byteToHex = [];
69
-
70
- for (var i = 0; i < 256; ++i) {
71
- byteToHex.push((i + 0x100).toString(16).substr(1));
72
- }
73
-
74
- function stringify(arr) {
75
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
76
- // Note: Be careful editing this code! It's been tuned for performance
77
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
78
- var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
79
- // of the following:
80
- // - One or more input array values don't map to a hex octet (leading to
81
- // "undefined" in the uuid)
82
- // - Invalid input values for the RFC `version` or `variant` fields
83
-
84
- if (!validate(uuid)) {
85
- throw TypeError('Stringified UUID is invalid');
86
- }
87
-
88
- return uuid;
89
- }
90
-
91
- //
92
- // Inspired by https://github.com/LiosK/UUID.js
93
- // and http://docs.python.org/library/uuid.html
94
-
95
- var _nodeId;
96
-
97
- var _clockseq; // Previous uuid creation time
98
-
99
-
100
- var _lastMSecs = 0;
101
- var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
102
-
103
- function v1(options, buf, offset) {
104
- var i = buf && offset || 0;
105
- var b = buf || new Array(16);
106
- options = options || {};
107
- var node = options.node || _nodeId;
108
- var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
109
- // specified. We do this lazily to minimize issues related to insufficient
110
- // system entropy. See #189
111
-
112
- if (node == null || clockseq == null) {
113
- var seedBytes = options.random || (options.rng || rng)();
114
-
115
- if (node == null) {
116
- // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
117
- node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
118
- }
119
-
120
- if (clockseq == null) {
121
- // Per 4.2.2, randomize (14 bit) clockseq
122
- clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
123
- }
124
- } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
125
- // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
126
- // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
127
- // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
128
-
129
-
130
- var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
131
- // cycle to simulate higher resolution clock
132
-
133
- var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
134
-
135
- var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
136
-
137
- if (dt < 0 && options.clockseq === undefined) {
138
- clockseq = clockseq + 1 & 0x3fff;
139
- } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
140
- // time interval
141
-
142
-
143
- if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
144
- nsecs = 0;
145
- } // Per 4.2.1.2 Throw error if too many uuids are requested
146
-
147
-
148
- if (nsecs >= 10000) {
149
- throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
150
- }
151
-
152
- _lastMSecs = msecs;
153
- _lastNSecs = nsecs;
154
- _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
155
-
156
- msecs += 12219292800000; // `time_low`
157
-
158
- var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
159
- b[i++] = tl >>> 24 & 0xff;
160
- b[i++] = tl >>> 16 & 0xff;
161
- b[i++] = tl >>> 8 & 0xff;
162
- b[i++] = tl & 0xff; // `time_mid`
163
-
164
- var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
165
- b[i++] = tmh >>> 8 & 0xff;
166
- b[i++] = tmh & 0xff; // `time_high_and_version`
167
-
168
- b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
169
-
170
- b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
171
-
172
- b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
173
-
174
- b[i++] = clockseq & 0xff; // `node`
175
-
176
- for (var n = 0; n < 6; ++n) {
177
- b[i + n] = node[n];
178
- }
179
-
180
- return buf || stringify(b);
181
- }
182
-
183
- function parse(uuid) {
184
- if (!validate(uuid)) {
185
- throw TypeError('Invalid UUID');
186
- }
187
-
188
- var v;
189
- var arr = new Uint8Array(16); // Parse ########-....-....-....-............
190
-
191
- arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
192
- arr[1] = v >>> 16 & 0xff;
193
- arr[2] = v >>> 8 & 0xff;
194
- arr[3] = v & 0xff; // Parse ........-####-....-....-............
195
-
196
- arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
197
- arr[5] = v & 0xff; // Parse ........-....-####-....-............
198
-
199
- arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
200
- arr[7] = v & 0xff; // Parse ........-....-....-####-............
201
-
202
- arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
203
- arr[9] = v & 0xff; // Parse ........-....-....-....-############
204
- // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
205
-
206
- arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
207
- arr[11] = v / 0x100000000 & 0xff;
208
- arr[12] = v >>> 24 & 0xff;
209
- arr[13] = v >>> 16 & 0xff;
210
- arr[14] = v >>> 8 & 0xff;
211
- arr[15] = v & 0xff;
212
- return arr;
213
- }
214
-
215
- function stringToBytes(str) {
216
- str = unescape(encodeURIComponent(str)); // UTF8 escape
217
-
218
- var bytes = [];
219
-
220
- for (var i = 0; i < str.length; ++i) {
221
- bytes.push(str.charCodeAt(i));
222
- }
223
-
224
- return bytes;
225
- }
226
-
227
- var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
228
- var URL$1 = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
229
- function v35 (name, version, hashfunc) {
230
- function generateUUID(value, namespace, buf, offset) {
231
- if (typeof value === 'string') {
232
- value = stringToBytes(value);
233
- }
234
-
235
- if (typeof namespace === 'string') {
236
- namespace = parse(namespace);
237
- }
238
-
239
- if (namespace.length !== 16) {
240
- throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
241
- } // Compute hash of namespace and value, Per 4.3
242
- // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
243
- // hashfunc([...namespace, ... value])`
244
-
245
-
246
- var bytes = new Uint8Array(16 + value.length);
247
- bytes.set(namespace);
248
- bytes.set(value, namespace.length);
249
- bytes = hashfunc(bytes);
250
- bytes[6] = bytes[6] & 0x0f | version;
251
- bytes[8] = bytes[8] & 0x3f | 0x80;
252
-
253
- if (buf) {
254
- offset = offset || 0;
255
-
256
- for (var i = 0; i < 16; ++i) {
257
- buf[offset + i] = bytes[i];
258
- }
259
-
260
- return buf;
261
- }
262
-
263
- return stringify(bytes);
264
- } // Function#name is not settable on some platforms (#270)
265
-
266
-
267
- try {
268
- generateUUID.name = name; // eslint-disable-next-line no-empty
269
- } catch (err) {} // For CommonJS default export support
270
-
271
-
272
- generateUUID.DNS = DNS;
273
- generateUUID.URL = URL$1;
274
- return generateUUID;
275
- }
276
-
277
- /*
278
- * Browser-compatible JavaScript MD5
279
- *
280
- * Modification of JavaScript MD5
281
- * https://github.com/blueimp/JavaScript-MD5
282
- *
283
- * Copyright 2011, Sebastian Tschan
284
- * https://blueimp.net
285
- *
286
- * Licensed under the MIT license:
287
- * https://opensource.org/licenses/MIT
288
- *
289
- * Based on
290
- * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
291
- * Digest Algorithm, as defined in RFC 1321.
292
- * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
293
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
294
- * Distributed under the BSD License
295
- * See http://pajhome.org.uk/crypt/md5 for more info.
296
- */
297
- function md5(bytes) {
298
- if (typeof bytes === 'string') {
299
- var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
300
-
301
- bytes = new Uint8Array(msg.length);
302
-
303
- for (var i = 0; i < msg.length; ++i) {
304
- bytes[i] = msg.charCodeAt(i);
305
- }
306
- }
307
-
308
- return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
309
- }
310
- /*
311
- * Convert an array of little-endian words to an array of bytes
312
- */
313
-
314
-
315
- function md5ToHexEncodedArray(input) {
316
- var output = [];
317
- var length32 = input.length * 32;
318
- var hexTab = '0123456789abcdef';
319
-
320
- for (var i = 0; i < length32; i += 8) {
321
- var x = input[i >> 5] >>> i % 32 & 0xff;
322
- var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
323
- output.push(hex);
324
- }
325
-
326
- return output;
327
- }
328
- /**
329
- * Calculate output length with padding and bit length
330
- */
331
-
332
-
333
- function getOutputLength(inputLength8) {
334
- return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
335
- }
336
- /*
337
- * Calculate the MD5 of an array of little-endian words, and a bit length.
338
- */
339
-
340
-
341
- function wordsToMd5(x, len) {
342
- /* append padding */
343
- x[len >> 5] |= 0x80 << len % 32;
344
- x[getOutputLength(len) - 1] = len;
345
- var a = 1732584193;
346
- var b = -271733879;
347
- var c = -1732584194;
348
- var d = 271733878;
349
-
350
- for (var i = 0; i < x.length; i += 16) {
351
- var olda = a;
352
- var oldb = b;
353
- var oldc = c;
354
- var oldd = d;
355
- a = md5ff(a, b, c, d, x[i], 7, -680876936);
356
- d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
357
- c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
358
- b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
359
- a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
360
- d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
361
- c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
362
- b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
363
- a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
364
- d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
365
- c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
366
- b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
367
- a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
368
- d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
369
- c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
370
- b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
371
- a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
372
- d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
373
- c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
374
- b = md5gg(b, c, d, a, x[i], 20, -373897302);
375
- a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
376
- d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
377
- c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
378
- b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
379
- a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
380
- d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
381
- c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
382
- b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
383
- a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
384
- d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
385
- c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
386
- b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
387
- a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
388
- d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
389
- c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
390
- b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
391
- a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
392
- d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
393
- c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
394
- b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
395
- a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
396
- d = md5hh(d, a, b, c, x[i], 11, -358537222);
397
- c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
398
- b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
399
- a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
400
- d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
401
- c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
402
- b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
403
- a = md5ii(a, b, c, d, x[i], 6, -198630844);
404
- d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
405
- c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
406
- b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
407
- a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
408
- d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
409
- c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
410
- b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
411
- a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
412
- d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
413
- c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
414
- b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
415
- a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
416
- d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
417
- c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
418
- b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
419
- a = safeAdd(a, olda);
420
- b = safeAdd(b, oldb);
421
- c = safeAdd(c, oldc);
422
- d = safeAdd(d, oldd);
423
- }
424
-
425
- return [a, b, c, d];
426
- }
427
- /*
428
- * Convert an array bytes to an array of little-endian words
429
- * Characters >255 have their high-byte silently ignored.
430
- */
431
-
432
-
433
- function bytesToWords(input) {
434
- if (input.length === 0) {
435
- return [];
436
- }
437
-
438
- var length8 = input.length * 8;
439
- var output = new Uint32Array(getOutputLength(length8));
440
-
441
- for (var i = 0; i < length8; i += 8) {
442
- output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
443
- }
444
-
445
- return output;
446
- }
447
- /*
448
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally
449
- * to work around bugs in some JS interpreters.
450
- */
451
-
452
-
453
- function safeAdd(x, y) {
454
- var lsw = (x & 0xffff) + (y & 0xffff);
455
- var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
456
- return msw << 16 | lsw & 0xffff;
457
- }
458
- /*
459
- * Bitwise rotate a 32-bit number to the left.
460
- */
461
-
462
-
463
- function bitRotateLeft(num, cnt) {
464
- return num << cnt | num >>> 32 - cnt;
465
- }
466
- /*
467
- * These functions implement the four basic operations the algorithm uses.
468
- */
469
-
470
-
471
- function md5cmn(q, a, b, x, s, t) {
472
- return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
473
- }
474
-
475
- function md5ff(a, b, c, d, x, s, t) {
476
- return md5cmn(b & c | ~b & d, a, b, x, s, t);
477
- }
478
-
479
- function md5gg(a, b, c, d, x, s, t) {
480
- return md5cmn(b & d | c & ~d, a, b, x, s, t);
481
- }
482
-
483
- function md5hh(a, b, c, d, x, s, t) {
484
- return md5cmn(b ^ c ^ d, a, b, x, s, t);
485
- }
486
-
487
- function md5ii(a, b, c, d, x, s, t) {
488
- return md5cmn(c ^ (b | ~d), a, b, x, s, t);
489
- }
490
-
491
- var v3 = v35('v3', 0x30, md5);
492
-
493
- function v4(options, buf, offset) {
494
- options = options || {};
495
- var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
496
-
497
- rnds[6] = rnds[6] & 0x0f | 0x40;
498
- rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
499
-
500
- if (buf) {
501
- offset = offset || 0;
502
-
503
- for (var i = 0; i < 16; ++i) {
504
- buf[offset + i] = rnds[i];
505
- }
506
-
507
- return buf;
508
- }
509
-
510
- return stringify(rnds);
511
- }
512
-
513
- // Adapted from Chris Veness' SHA1 code at
514
- // http://www.movable-type.co.uk/scripts/sha1.html
515
- function f(s, x, y, z) {
516
- switch (s) {
517
- case 0:
518
- return x & y ^ ~x & z;
519
-
520
- case 1:
521
- return x ^ y ^ z;
522
-
523
- case 2:
524
- return x & y ^ x & z ^ y & z;
525
-
526
- case 3:
527
- return x ^ y ^ z;
528
- }
529
- }
530
-
531
- function ROTL(x, n) {
532
- return x << n | x >>> 32 - n;
533
- }
534
-
535
- function sha1(bytes) {
536
- var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
537
- var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
538
-
539
- if (typeof bytes === 'string') {
540
- var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
541
-
542
- bytes = [];
543
-
544
- for (var i = 0; i < msg.length; ++i) {
545
- bytes.push(msg.charCodeAt(i));
546
- }
547
- } else if (!Array.isArray(bytes)) {
548
- // Convert Array-like to Array
549
- bytes = Array.prototype.slice.call(bytes);
550
- }
551
-
552
- bytes.push(0x80);
553
- var l = bytes.length / 4 + 2;
554
- var N = Math.ceil(l / 16);
555
- var M = new Array(N);
556
-
557
- for (var _i = 0; _i < N; ++_i) {
558
- var arr = new Uint32Array(16);
559
-
560
- for (var j = 0; j < 16; ++j) {
561
- arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
562
- }
563
-
564
- M[_i] = arr;
565
- }
566
-
567
- M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
568
- M[N - 1][14] = Math.floor(M[N - 1][14]);
569
- M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
570
-
571
- for (var _i2 = 0; _i2 < N; ++_i2) {
572
- var W = new Uint32Array(80);
573
-
574
- for (var t = 0; t < 16; ++t) {
575
- W[t] = M[_i2][t];
576
- }
577
-
578
- for (var _t = 16; _t < 80; ++_t) {
579
- W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
580
- }
581
-
582
- var a = H[0];
583
- var b = H[1];
584
- var c = H[2];
585
- var d = H[3];
586
- var e = H[4];
587
-
588
- for (var _t2 = 0; _t2 < 80; ++_t2) {
589
- var s = Math.floor(_t2 / 20);
590
- var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
591
- e = d;
592
- d = c;
593
- c = ROTL(b, 30) >>> 0;
594
- b = a;
595
- a = T;
596
- }
597
-
598
- H[0] = H[0] + a >>> 0;
599
- H[1] = H[1] + b >>> 0;
600
- H[2] = H[2] + c >>> 0;
601
- H[3] = H[3] + d >>> 0;
602
- H[4] = H[4] + e >>> 0;
603
- }
604
-
605
- return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
606
- }
607
-
608
- var v5 = v35('v5', 0x50, sha1);
609
-
610
- var nil = '00000000-0000-0000-0000-000000000000';
611
-
612
- function version(uuid) {
613
- if (!validate(uuid)) {
614
- throw TypeError('Invalid UUID');
615
- }
616
-
617
- return parseInt(uuid.substr(14, 1), 16);
618
- }
619
-
620
- var esmBrowser = /*#__PURE__*/Object.freeze({
621
- __proto__: null,
622
- NIL: nil,
623
- parse: parse,
624
- stringify: stringify,
625
- v1: v1,
626
- v3: v3,
627
- v4: v4,
628
- v5: v5,
629
- validate: validate,
630
- version: version
631
- });
632
-
633
- var uaParser = {exports: {}};
634
-
635
- var hasRequiredUaParser;
636
-
637
- function requireUaParser () {
638
- if (hasRequiredUaParser) return uaParser.exports;
639
- hasRequiredUaParser = 1;
640
- (function (module, exports) {
641
- /////////////////////////////////////////////////////////////////////////////////
642
- /* UAParser.js v1.0.37
643
- Copyright © 2012-2021 Faisal Salman <f@faisalman.com>
644
- MIT License *//*
645
- Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data.
646
- Supports browser & node.js environment.
647
- Demo : https://faisalman.github.io/ua-parser-js
648
- Source : https://github.com/faisalman/ua-parser-js */
649
- /////////////////////////////////////////////////////////////////////////////////
650
-
651
- (function (window, undefined$1) {
652
-
653
- //////////////
654
- // Constants
655
- /////////////
656
-
657
-
658
- var LIBVERSION = '1.0.37',
659
- EMPTY = '',
660
- UNKNOWN = '?',
661
- FUNC_TYPE = 'function',
662
- UNDEF_TYPE = 'undefined',
663
- OBJ_TYPE = 'object',
664
- STR_TYPE = 'string',
665
- MAJOR = 'major',
666
- MODEL = 'model',
667
- NAME = 'name',
668
- TYPE = 'type',
669
- VENDOR = 'vendor',
670
- VERSION = 'version',
671
- ARCHITECTURE= 'architecture',
672
- CONSOLE = 'console',
673
- MOBILE = 'mobile',
674
- TABLET = 'tablet',
675
- SMARTTV = 'smarttv',
676
- WEARABLE = 'wearable',
677
- EMBEDDED = 'embedded',
678
- UA_MAX_LENGTH = 500;
679
-
680
- var AMAZON = 'Amazon',
681
- APPLE = 'Apple',
682
- ASUS = 'ASUS',
683
- BLACKBERRY = 'BlackBerry',
684
- BROWSER = 'Browser',
685
- CHROME = 'Chrome',
686
- EDGE = 'Edge',
687
- FIREFOX = 'Firefox',
688
- GOOGLE = 'Google',
689
- HUAWEI = 'Huawei',
690
- LG = 'LG',
691
- MICROSOFT = 'Microsoft',
692
- MOTOROLA = 'Motorola',
693
- OPERA = 'Opera',
694
- SAMSUNG = 'Samsung',
695
- SHARP = 'Sharp',
696
- SONY = 'Sony',
697
- XIAOMI = 'Xiaomi',
698
- ZEBRA = 'Zebra',
699
- FACEBOOK = 'Facebook',
700
- CHROMIUM_OS = 'Chromium OS',
701
- MAC_OS = 'Mac OS';
702
-
703
- ///////////
704
- // Helper
705
- //////////
706
-
707
- var extend = function (regexes, extensions) {
708
- var mergedRegexes = {};
709
- for (var i in regexes) {
710
- if (extensions[i] && extensions[i].length % 2 === 0) {
711
- mergedRegexes[i] = extensions[i].concat(regexes[i]);
712
- } else {
713
- mergedRegexes[i] = regexes[i];
714
- }
715
- }
716
- return mergedRegexes;
717
- },
718
- enumerize = function (arr) {
719
- var enums = {};
720
- for (var i=0; i<arr.length; i++) {
721
- enums[arr[i].toUpperCase()] = arr[i];
722
- }
723
- return enums;
724
- },
725
- has = function (str1, str2) {
726
- return typeof str1 === STR_TYPE ? lowerize(str2).indexOf(lowerize(str1)) !== -1 : false;
727
- },
728
- lowerize = function (str) {
729
- return str.toLowerCase();
730
- },
731
- majorize = function (version) {
732
- return typeof(version) === STR_TYPE ? version.replace(/[^\d\.]/g, EMPTY).split('.')[0] : undefined$1;
733
- },
734
- trim = function (str, len) {
735
- if (typeof(str) === STR_TYPE) {
736
- str = str.replace(/^\s\s*/, EMPTY);
737
- return typeof(len) === UNDEF_TYPE ? str : str.substring(0, UA_MAX_LENGTH);
738
- }
739
- };
740
-
741
- ///////////////
742
- // Map helper
743
- //////////////
744
-
745
- var rgxMapper = function (ua, arrays) {
746
-
747
- var i = 0, j, k, p, q, matches, match;
748
-
749
- // loop through all regexes maps
750
- while (i < arrays.length && !matches) {
751
-
752
- var regex = arrays[i], // even sequence (0,2,4,..)
753
- props = arrays[i + 1]; // odd sequence (1,3,5,..)
754
- j = k = 0;
755
-
756
- // try matching uastring with regexes
757
- while (j < regex.length && !matches) {
758
-
759
- if (!regex[j]) { break; }
760
- matches = regex[j++].exec(ua);
761
-
762
- if (!!matches) {
763
- for (p = 0; p < props.length; p++) {
764
- match = matches[++k];
765
- q = props[p];
766
- // check if given property is actually array
767
- if (typeof q === OBJ_TYPE && q.length > 0) {
768
- if (q.length === 2) {
769
- if (typeof q[1] == FUNC_TYPE) {
770
- // assign modified match
771
- this[q[0]] = q[1].call(this, match);
772
- } else {
773
- // assign given value, ignore regex match
774
- this[q[0]] = q[1];
775
- }
776
- } else if (q.length === 3) {
777
- // check whether function or regex
778
- if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) {
779
- // call function (usually string mapper)
780
- this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined$1;
781
- } else {
782
- // sanitize match using given regex
783
- this[q[0]] = match ? match.replace(q[1], q[2]) : undefined$1;
784
- }
785
- } else if (q.length === 4) {
786
- this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined$1;
787
- }
788
- } else {
789
- this[q] = match ? match : undefined$1;
790
- }
791
- }
792
- }
793
- }
794
- i += 2;
795
- }
796
- },
797
-
798
- strMapper = function (str, map) {
799
-
800
- for (var i in map) {
801
- // check if current value is array
802
- if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
803
- for (var j = 0; j < map[i].length; j++) {
804
- if (has(map[i][j], str)) {
805
- return (i === UNKNOWN) ? undefined$1 : i;
806
- }
807
- }
808
- } else if (has(map[i], str)) {
809
- return (i === UNKNOWN) ? undefined$1 : i;
810
- }
811
- }
812
- return str;
813
- };
814
-
815
- ///////////////
816
- // String map
817
- //////////////
818
-
819
- // Safari < 3.0
820
- var oldSafariMap = {
821
- '1.0' : '/8',
822
- '1.2' : '/1',
823
- '1.3' : '/3',
824
- '2.0' : '/412',
825
- '2.0.2' : '/416',
826
- '2.0.3' : '/417',
827
- '2.0.4' : '/419',
828
- '?' : '/'
829
- },
830
- windowsVersionMap = {
831
- 'ME' : '4.90',
832
- 'NT 3.11' : 'NT3.51',
833
- 'NT 4.0' : 'NT4.0',
834
- '2000' : 'NT 5.0',
835
- 'XP' : ['NT 5.1', 'NT 5.2'],
836
- 'Vista' : 'NT 6.0',
837
- '7' : 'NT 6.1',
838
- '8' : 'NT 6.2',
839
- '8.1' : 'NT 6.3',
840
- '10' : ['NT 6.4', 'NT 10.0'],
841
- 'RT' : 'ARM'
842
- };
843
-
844
- //////////////
845
- // Regex map
846
- /////////////
847
-
848
- var regexes = {
849
-
850
- browser : [[
851
-
852
- /\b(?:crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS
853
- ], [VERSION, [NAME, 'Chrome']], [
854
- /edg(?:e|ios|a)?\/([\w\.]+)/i // Microsoft Edge
855
- ], [VERSION, [NAME, 'Edge']], [
856
-
857
- // Presto based
858
- /(opera mini)\/([-\w\.]+)/i, // Opera Mini
859
- /(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i, // Opera Mobi/Tablet
860
- /(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i // Opera
861
- ], [NAME, VERSION], [
862
- /opios[\/ ]+([\w\.]+)/i // Opera mini on iphone >= 8.0
863
- ], [VERSION, [NAME, OPERA+' Mini']], [
864
- /\bopr\/([\w\.]+)/i // Opera Webkit
865
- ], [VERSION, [NAME, OPERA]], [
866
-
867
- // Mixed
868
- /\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i // Baidu
869
- ], [VERSION, [NAME, 'Baidu']], [
870
- /(kindle)\/([\w\.]+)/i, // Kindle
871
- /(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i, // Lunascape/Maxthon/Netfront/Jasmine/Blazer
872
- // Trident based
873
- /(avant|iemobile|slim)\s?(?:browser)?[\/ ]?([\w\.]*)/i, // Avant/IEMobile/SlimBrowser
874
- /(?:ms|\()(ie) ([\w\.]+)/i, // Internet Explorer
875
-
876
- // Webkit/KHTML based // Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
877
- /(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,
878
- // Rekonq/Puffin/Brave/Whale/QQBrowserLite/QQ, aka ShouQ
879
- /(heytap|ovi)browser\/([\d\.]+)/i, // Heytap/Ovi
880
- /(weibo)__([\d\.]+)/i // Weibo
881
- ], [NAME, VERSION], [
882
- /(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i // UCBrowser
883
- ], [VERSION, [NAME, 'UC'+BROWSER]], [
884
- /microm.+\bqbcore\/([\w\.]+)/i, // WeChat Desktop for Windows Built-in Browser
885
- /\bqbcore\/([\w\.]+).+microm/i,
886
- /micromessenger\/([\w\.]+)/i // WeChat
887
- ], [VERSION, [NAME, 'WeChat']], [
888
- /konqueror\/([\w\.]+)/i // Konqueror
889
- ], [VERSION, [NAME, 'Konqueror']], [
890
- /trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i // IE11
891
- ], [VERSION, [NAME, 'IE']], [
892
- /ya(?:search)?browser\/([\w\.]+)/i // Yandex
893
- ], [VERSION, [NAME, 'Yandex']], [
894
- /slbrowser\/([\w\.]+)/i // Smart Lenovo Browser
895
- ], [VERSION, [NAME, 'Smart Lenovo '+BROWSER]], [
896
- /(avast|avg)\/([\w\.]+)/i // Avast/AVG Secure Browser
897
- ], [[NAME, /(.+)/, '$1 Secure '+BROWSER], VERSION], [
898
- /\bfocus\/([\w\.]+)/i // Firefox Focus
899
- ], [VERSION, [NAME, FIREFOX+' Focus']], [
900
- /\bopt\/([\w\.]+)/i // Opera Touch
901
- ], [VERSION, [NAME, OPERA+' Touch']], [
902
- /coc_coc\w+\/([\w\.]+)/i // Coc Coc Browser
903
- ], [VERSION, [NAME, 'Coc Coc']], [
904
- /dolfin\/([\w\.]+)/i // Dolphin
905
- ], [VERSION, [NAME, 'Dolphin']], [
906
- /coast\/([\w\.]+)/i // Opera Coast
907
- ], [VERSION, [NAME, OPERA+' Coast']], [
908
- /miuibrowser\/([\w\.]+)/i // MIUI Browser
909
- ], [VERSION, [NAME, 'MIUI '+BROWSER]], [
910
- /fxios\/([-\w\.]+)/i // Firefox for iOS
911
- ], [VERSION, [NAME, FIREFOX]], [
912
- /\bqihu|(qi?ho?o?|360)browser/i // 360
913
- ], [[NAME, '360 ' + BROWSER]], [
914
- /(oculus|sailfish|huawei|vivo)browser\/([\w\.]+)/i
915
- ], [[NAME, /(.+)/, '$1 ' + BROWSER], VERSION], [ // Oculus/Sailfish/HuaweiBrowser/VivoBrowser
916
- /samsungbrowser\/([\w\.]+)/i // Samsung Internet
917
- ], [VERSION, [NAME, SAMSUNG + ' Internet']], [
918
- /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
919
- ], [[NAME, /_/g, ' '], VERSION], [
920
- /metasr[\/ ]?([\d\.]+)/i // Sogou Explorer
921
- ], [VERSION, [NAME, 'Sogou Explorer']], [
922
- /(sogou)mo\w+\/([\d\.]+)/i // Sogou Mobile
923
- ], [[NAME, 'Sogou Mobile'], VERSION], [
924
- /(electron)\/([\w\.]+) safari/i, // Electron-based App
925
- /(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i, // Tesla
926
- /m?(qqbrowser|2345Explorer)[\/ ]?([\w\.]+)/i // QQBrowser/2345 Browser
927
- ], [NAME, VERSION], [
928
- /(lbbrowser)/i, // LieBao Browser
929
- /\[(linkedin)app\]/i // LinkedIn App for iOS & Android
930
- ], [NAME], [
931
-
932
- // WebView
933
- /((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i // Facebook App for iOS & Android
934
- ], [[NAME, FACEBOOK], VERSION], [
935
- /(Klarna)\/([\w\.]+)/i, // Klarna Shopping Browser for iOS & Android
936
- /(kakao(?:talk|story))[\/ ]([\w\.]+)/i, // Kakao App
937
- /(naver)\(.*?(\d+\.[\w\.]+).*\)/i, // Naver InApp
938
- /safari (line)\/([\w\.]+)/i, // Line App for iOS
939
- /\b(line)\/([\w\.]+)\/iab/i, // Line App for Android
940
- /(alipay)client\/([\w\.]+)/i, // Alipay
941
- /(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i // Chromium/Instagram/Snapchat
942
- ], [NAME, VERSION], [
943
- /\bgsa\/([\w\.]+) .*safari\//i // Google Search Appliance on iOS
944
- ], [VERSION, [NAME, 'GSA']], [
945
- /musical_ly(?:.+app_?version\/|_)([\w\.]+)/i // TikTok
946
- ], [VERSION, [NAME, 'TikTok']], [
947
-
948
- /headlesschrome(?:\/([\w\.]+)| )/i // Chrome Headless
949
- ], [VERSION, [NAME, CHROME+' Headless']], [
950
-
951
- / wv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
952
- ], [[NAME, CHROME+' WebView'], VERSION], [
953
-
954
- /droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i // Android Browser
955
- ], [VERSION, [NAME, 'Android '+BROWSER]], [
956
-
957
- /(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i // Chrome/OmniWeb/Arora/Tizen/Nokia
958
- ], [NAME, VERSION], [
959
-
960
- /version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i // Mobile Safari
961
- ], [VERSION, [NAME, 'Mobile Safari']], [
962
- /version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i // Safari & Safari Mobile
963
- ], [VERSION, NAME], [
964
- /webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i // Safari < 3.0
965
- ], [NAME, [VERSION, strMapper, oldSafariMap]], [
966
-
967
- /(webkit|khtml)\/([\w\.]+)/i
968
- ], [NAME, VERSION], [
969
-
970
- // Gecko based
971
- /(navigator|netscape\d?)\/([-\w\.]+)/i // Netscape
972
- ], [[NAME, 'Netscape'], VERSION], [
973
- /mobile vr; rv:([\w\.]+)\).+firefox/i // Firefox Reality
974
- ], [VERSION, [NAME, FIREFOX+' Reality']], [
975
- /ekiohf.+(flow)\/([\w\.]+)/i, // Flow
976
- /(swiftfox)/i, // Swiftfox
977
- /(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,
978
- // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror/Klar
979
- /(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,
980
- // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
981
- /(firefox)\/([\w\.]+)/i, // Other Firefox-based
982
- /(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i, // Mozilla
983
-
984
- // Other
985
- /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,
986
- // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir/Obigo/Mosaic/Go/ICE/UP.Browser
987
- /(links) \(([\w\.]+)/i, // Links
988
- /panasonic;(viera)/i // Panasonic Viera
989
- ], [NAME, VERSION], [
990
-
991
- /(cobalt)\/([\w\.]+)/i // Cobalt
992
- ], [NAME, [VERSION, /master.|lts./, ""]]
993
- ],
994
-
995
- cpu : [[
996
-
997
- /(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i // AMD64 (x64)
998
- ], [[ARCHITECTURE, 'amd64']], [
999
-
1000
- /(ia32(?=;))/i // IA32 (quicktime)
1001
- ], [[ARCHITECTURE, lowerize]], [
1002
-
1003
- /((?:i[346]|x)86)[;\)]/i // IA32 (x86)
1004
- ], [[ARCHITECTURE, 'ia32']], [
1005
-
1006
- /\b(aarch64|arm(v?8e?l?|_?64))\b/i // ARM64
1007
- ], [[ARCHITECTURE, 'arm64']], [
1008
-
1009
- /\b(arm(?:v[67])?ht?n?[fl]p?)\b/i // ARMHF
1010
- ], [[ARCHITECTURE, 'armhf']], [
1011
-
1012
- // PocketPC mistakenly identified as PowerPC
1013
- /windows (ce|mobile); ppc;/i
1014
- ], [[ARCHITECTURE, 'arm']], [
1015
-
1016
- /((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i // PowerPC
1017
- ], [[ARCHITECTURE, /ower/, EMPTY, lowerize]], [
1018
-
1019
- /(sun4\w)[;\)]/i // SPARC
1020
- ], [[ARCHITECTURE, 'sparc']], [
1021
-
1022
- /((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i
1023
- // IA64, 68K, ARM/64, AVR/32, IRIX/64, MIPS/64, SPARC/64, PA-RISC
1024
- ], [[ARCHITECTURE, lowerize]]
1025
- ],
1026
-
1027
- device : [[
1028
-
1029
- //////////////////////////
1030
- // MOBILES & TABLETS
1031
- /////////////////////////
1032
-
1033
- // Samsung
1034
- /\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i
1035
- ], [MODEL, [VENDOR, SAMSUNG], [TYPE, TABLET]], [
1036
- /\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,
1037
- /samsung[- ]([-\w]+)/i,
1038
- /sec-(sgh\w+)/i
1039
- ], [MODEL, [VENDOR, SAMSUNG], [TYPE, MOBILE]], [
1040
-
1041
- // Apple
1042
- /(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i // iPod/iPhone
1043
- ], [MODEL, [VENDOR, APPLE], [TYPE, MOBILE]], [
1044
- /\((ipad);[-\w\),; ]+apple/i, // iPad
1045
- /applecoremedia\/[\w\.]+ \((ipad)/i,
1046
- /\b(ipad)\d\d?,\d\d?[;\]].+ios/i
1047
- ], [MODEL, [VENDOR, APPLE], [TYPE, TABLET]], [
1048
- /(macintosh);/i
1049
- ], [MODEL, [VENDOR, APPLE]], [
1050
-
1051
- // Sharp
1052
- /\b(sh-?[altvz]?\d\d[a-ekm]?)/i
1053
- ], [MODEL, [VENDOR, SHARP], [TYPE, MOBILE]], [
1054
-
1055
- // Huawei
1056
- /\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i
1057
- ], [MODEL, [VENDOR, HUAWEI], [TYPE, TABLET]], [
1058
- /(?:huawei|honor)([-\w ]+)[;\)]/i,
1059
- /\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i
1060
- ], [MODEL, [VENDOR, HUAWEI], [TYPE, MOBILE]], [
1061
-
1062
- // Xiaomi
1063
- /\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i, // Xiaomi POCO
1064
- /\b; (\w+) build\/hm\1/i, // Xiaomi Hongmi 'numeric' models
1065
- /\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i, // Xiaomi Hongmi
1066
- /\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i, // Xiaomi Redmi
1067
- /oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i, // Xiaomi Redmi 'numeric' models
1068
- /\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i // Xiaomi Mi
1069
- ], [[MODEL, /_/g, ' '], [VENDOR, XIAOMI], [TYPE, MOBILE]], [
1070
- /oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i, // Redmi Pad
1071
- /\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i // Mi Pad tablets
1072
- ],[[MODEL, /_/g, ' '], [VENDOR, XIAOMI], [TYPE, TABLET]], [
1073
-
1074
- // OPPO
1075
- /; (\w+) bui.+ oppo/i,
1076
- /\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i
1077
- ], [MODEL, [VENDOR, 'OPPO'], [TYPE, MOBILE]], [
1078
-
1079
- // Vivo
1080
- /vivo (\w+)(?: bui|\))/i,
1081
- /\b(v[12]\d{3}\w?[at])(?: bui|;)/i
1082
- ], [MODEL, [VENDOR, 'Vivo'], [TYPE, MOBILE]], [
1083
-
1084
- // Realme
1085
- /\b(rmx[1-3]\d{3})(?: bui|;|\))/i
1086
- ], [MODEL, [VENDOR, 'Realme'], [TYPE, MOBILE]], [
1087
-
1088
- // Motorola
1089
- /\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,
1090
- /\bmot(?:orola)?[- ](\w*)/i,
1091
- /((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i
1092
- ], [MODEL, [VENDOR, MOTOROLA], [TYPE, MOBILE]], [
1093
- /\b(mz60\d|xoom[2 ]{0,2}) build\//i
1094
- ], [MODEL, [VENDOR, MOTOROLA], [TYPE, TABLET]], [
1095
-
1096
- // LG
1097
- /((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i
1098
- ], [MODEL, [VENDOR, LG], [TYPE, TABLET]], [
1099
- /(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,
1100
- /\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,
1101
- /\blg-?([\d\w]+) bui/i
1102
- ], [MODEL, [VENDOR, LG], [TYPE, MOBILE]], [
1103
-
1104
- // Lenovo
1105
- /(ideatab[-\w ]+)/i,
1106
- /lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i
1107
- ], [MODEL, [VENDOR, 'Lenovo'], [TYPE, TABLET]], [
1108
-
1109
- // Nokia
1110
- /(?:maemo|nokia).*(n900|lumia \d+)/i,
1111
- /nokia[-_ ]?([-\w\.]*)/i
1112
- ], [[MODEL, /_/g, ' '], [VENDOR, 'Nokia'], [TYPE, MOBILE]], [
1113
-
1114
- // Google
1115
- /(pixel c)\b/i // Google Pixel C
1116
- ], [MODEL, [VENDOR, GOOGLE], [TYPE, TABLET]], [
1117
- /droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i // Google Pixel
1118
- ], [MODEL, [VENDOR, GOOGLE], [TYPE, MOBILE]], [
1119
-
1120
- // Sony
1121
- /droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i
1122
- ], [MODEL, [VENDOR, SONY], [TYPE, MOBILE]], [
1123
- /sony tablet [ps]/i,
1124
- /\b(?:sony)?sgp\w+(?: bui|\))/i
1125
- ], [[MODEL, 'Xperia Tablet'], [VENDOR, SONY], [TYPE, TABLET]], [
1126
-
1127
- // OnePlus
1128
- / (kb2005|in20[12]5|be20[12][59])\b/i,
1129
- /(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i
1130
- ], [MODEL, [VENDOR, 'OnePlus'], [TYPE, MOBILE]], [
1131
-
1132
- // Amazon
1133
- /(alexa)webm/i,
1134
- /(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i, // Kindle Fire without Silk / Echo Show
1135
- /(kf[a-z]+)( bui|\)).+silk\//i // Kindle Fire HD
1136
- ], [MODEL, [VENDOR, AMAZON], [TYPE, TABLET]], [
1137
- /((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i // Fire Phone
1138
- ], [[MODEL, /(.+)/g, 'Fire Phone $1'], [VENDOR, AMAZON], [TYPE, MOBILE]], [
1139
-
1140
- // BlackBerry
1141
- /(playbook);[-\w\),; ]+(rim)/i // BlackBerry PlayBook
1142
- ], [MODEL, VENDOR, [TYPE, TABLET]], [
1143
- /\b((?:bb[a-f]|st[hv])100-\d)/i,
1144
- /\(bb10; (\w+)/i // BlackBerry 10
1145
- ], [MODEL, [VENDOR, BLACKBERRY], [TYPE, MOBILE]], [
1146
-
1147
- // Asus
1148
- /(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i
1149
- ], [MODEL, [VENDOR, ASUS], [TYPE, TABLET]], [
1150
- / (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i
1151
- ], [MODEL, [VENDOR, ASUS], [TYPE, MOBILE]], [
1152
-
1153
- // HTC
1154
- /(nexus 9)/i // HTC Nexus 9
1155
- ], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [
1156
- /(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i, // HTC
1157
-
1158
- // ZTE
1159
- /(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,
1160
- /(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
1161
- ], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
1162
-
1163
- // Acer
1164
- /droid.+; ([ab][1-7]-?[0178a]\d\d?)/i
1165
- ], [MODEL, [VENDOR, 'Acer'], [TYPE, TABLET]], [
1166
-
1167
- // Meizu
1168
- /droid.+; (m[1-5] note) bui/i,
1169
- /\bmz-([-\w]{2,})/i
1170
- ], [MODEL, [VENDOR, 'Meizu'], [TYPE, MOBILE]], [
1171
-
1172
- // Ulefone
1173
- /; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i
1174
- ], [MODEL, [VENDOR, 'Ulefone'], [TYPE, MOBILE]], [
1175
-
1176
- // MIXED
1177
- /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i,
1178
- // BlackBerry/BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron
1179
- /(hp) ([\w ]+\w)/i, // HP iPAQ
1180
- /(asus)-?(\w+)/i, // Asus
1181
- /(microsoft); (lumia[\w ]+)/i, // Microsoft Lumia
1182
- /(lenovo)[-_ ]?([-\w]+)/i, // Lenovo
1183
- /(jolla)/i, // Jolla
1184
- /(oppo) ?([\w ]+) bui/i // OPPO
1185
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
1186
-
1187
- /(kobo)\s(ereader|touch)/i, // Kobo
1188
- /(archos) (gamepad2?)/i, // Archos
1189
- /(hp).+(touchpad(?!.+tablet)|tablet)/i, // HP TouchPad
1190
- /(kindle)\/([\w\.]+)/i, // Kindle
1191
- /(nook)[\w ]+build\/(\w+)/i, // Nook
1192
- /(dell) (strea[kpr\d ]*[\dko])/i, // Dell Streak
1193
- /(le[- ]+pan)[- ]+(\w{1,9}) bui/i, // Le Pan Tablets
1194
- /(trinity)[- ]*(t\d{3}) bui/i, // Trinity Tablets
1195
- /(gigaset)[- ]+(q\w{1,9}) bui/i, // Gigaset Tablets
1196
- /(vodafone) ([\w ]+)(?:\)| bui)/i // Vodafone
1197
- ], [VENDOR, MODEL, [TYPE, TABLET]], [
1198
-
1199
- /(surface duo)/i // Surface Duo
1200
- ], [MODEL, [VENDOR, MICROSOFT], [TYPE, TABLET]], [
1201
- /droid [\d\.]+; (fp\du?)(?: b|\))/i // Fairphone
1202
- ], [MODEL, [VENDOR, 'Fairphone'], [TYPE, MOBILE]], [
1203
- /(u304aa)/i // AT&T
1204
- ], [MODEL, [VENDOR, 'AT&T'], [TYPE, MOBILE]], [
1205
- /\bsie-(\w*)/i // Siemens
1206
- ], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [
1207
- /\b(rct\w+) b/i // RCA Tablets
1208
- ], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [
1209
- /\b(venue[\d ]{2,7}) b/i // Dell Venue Tablets
1210
- ], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [
1211
- /\b(q(?:mv|ta)\w+) b/i // Verizon Tablet
1212
- ], [MODEL, [VENDOR, 'Verizon'], [TYPE, TABLET]], [
1213
- /\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i // Barnes & Noble Tablet
1214
- ], [MODEL, [VENDOR, 'Barnes & Noble'], [TYPE, TABLET]], [
1215
- /\b(tm\d{3}\w+) b/i
1216
- ], [MODEL, [VENDOR, 'NuVision'], [TYPE, TABLET]], [
1217
- /\b(k88) b/i // ZTE K Series Tablet
1218
- ], [MODEL, [VENDOR, 'ZTE'], [TYPE, TABLET]], [
1219
- /\b(nx\d{3}j) b/i // ZTE Nubia
1220
- ], [MODEL, [VENDOR, 'ZTE'], [TYPE, MOBILE]], [
1221
- /\b(gen\d{3}) b.+49h/i // Swiss GEN Mobile
1222
- ], [MODEL, [VENDOR, 'Swiss'], [TYPE, MOBILE]], [
1223
- /\b(zur\d{3}) b/i // Swiss ZUR Tablet
1224
- ], [MODEL, [VENDOR, 'Swiss'], [TYPE, TABLET]], [
1225
- /\b((zeki)?tb.*\b) b/i // Zeki Tablets
1226
- ], [MODEL, [VENDOR, 'Zeki'], [TYPE, TABLET]], [
1227
- /\b([yr]\d{2}) b/i,
1228
- /\b(dragon[- ]+touch |dt)(\w{5}) b/i // Dragon Touch Tablet
1229
- ], [[VENDOR, 'Dragon Touch'], MODEL, [TYPE, TABLET]], [
1230
- /\b(ns-?\w{0,9}) b/i // Insignia Tablets
1231
- ], [MODEL, [VENDOR, 'Insignia'], [TYPE, TABLET]], [
1232
- /\b((nxa|next)-?\w{0,9}) b/i // NextBook Tablets
1233
- ], [MODEL, [VENDOR, 'NextBook'], [TYPE, TABLET]], [
1234
- /\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i // Voice Xtreme Phones
1235
- ], [[VENDOR, 'Voice'], MODEL, [TYPE, MOBILE]], [
1236
- /\b(lvtel\-)?(v1[12]) b/i // LvTel Phones
1237
- ], [[VENDOR, 'LvTel'], MODEL, [TYPE, MOBILE]], [
1238
- /\b(ph-1) /i // Essential PH-1
1239
- ], [MODEL, [VENDOR, 'Essential'], [TYPE, MOBILE]], [
1240
- /\b(v(100md|700na|7011|917g).*\b) b/i // Envizen Tablets
1241
- ], [MODEL, [VENDOR, 'Envizen'], [TYPE, TABLET]], [
1242
- /\b(trio[-\w\. ]+) b/i // MachSpeed Tablets
1243
- ], [MODEL, [VENDOR, 'MachSpeed'], [TYPE, TABLET]], [
1244
- /\btu_(1491) b/i // Rotor Tablets
1245
- ], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]], [
1246
- /(shield[\w ]+) b/i // Nvidia Shield Tablets
1247
- ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, TABLET]], [
1248
- /(sprint) (\w+)/i // Sprint Phones
1249
- ], [VENDOR, MODEL, [TYPE, MOBILE]], [
1250
- /(kin\.[onetw]{3})/i // Microsoft Kin
1251
- ], [[MODEL, /\./g, ' '], [VENDOR, MICROSOFT], [TYPE, MOBILE]], [
1252
- /droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i // Zebra
1253
- ], [MODEL, [VENDOR, ZEBRA], [TYPE, TABLET]], [
1254
- /droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i
1255
- ], [MODEL, [VENDOR, ZEBRA], [TYPE, MOBILE]], [
1256
-
1257
- ///////////////////
1258
- // SMARTTVS
1259
- ///////////////////
1260
-
1261
- /smart-tv.+(samsung)/i // Samsung
1262
- ], [VENDOR, [TYPE, SMARTTV]], [
1263
- /hbbtv.+maple;(\d+)/i
1264
- ], [[MODEL, /^/, 'SmartTV'], [VENDOR, SAMSUNG], [TYPE, SMARTTV]], [
1265
- /(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i // LG SmartTV
1266
- ], [[VENDOR, LG], [TYPE, SMARTTV]], [
1267
- /(apple) ?tv/i // Apple TV
1268
- ], [VENDOR, [MODEL, APPLE+' TV'], [TYPE, SMARTTV]], [
1269
- /crkey/i // Google Chromecast
1270
- ], [[MODEL, CHROME+'cast'], [VENDOR, GOOGLE], [TYPE, SMARTTV]], [
1271
- /droid.+aft(\w+)( bui|\))/i // Fire TV
1272
- ], [MODEL, [VENDOR, AMAZON], [TYPE, SMARTTV]], [
1273
- /\(dtv[\);].+(aquos)/i,
1274
- /(aquos-tv[\w ]+)\)/i // Sharp
1275
- ], [MODEL, [VENDOR, SHARP], [TYPE, SMARTTV]],[
1276
- /(bravia[\w ]+)( bui|\))/i // Sony
1277
- ], [MODEL, [VENDOR, SONY], [TYPE, SMARTTV]], [
1278
- /(mitv-\w{5}) bui/i // Xiaomi
1279
- ], [MODEL, [VENDOR, XIAOMI], [TYPE, SMARTTV]], [
1280
- /Hbbtv.*(technisat) (.*);/i // TechniSAT
1281
- ], [VENDOR, MODEL, [TYPE, SMARTTV]], [
1282
- /\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i, // Roku
1283
- /hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i // HbbTV devices
1284
- ], [[VENDOR, trim], [MODEL, trim], [TYPE, SMARTTV]], [
1285
- /\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i // SmartTV from Unidentified Vendors
1286
- ], [[TYPE, SMARTTV]], [
1287
-
1288
- ///////////////////
1289
- // CONSOLES
1290
- ///////////////////
1291
-
1292
- /(ouya)/i, // Ouya
1293
- /(nintendo) ([wids3utch]+)/i // Nintendo
1294
- ], [VENDOR, MODEL, [TYPE, CONSOLE]], [
1295
- /droid.+; (shield) bui/i // Nvidia
1296
- ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [
1297
- /(playstation [345portablevi]+)/i // Playstation
1298
- ], [MODEL, [VENDOR, SONY], [TYPE, CONSOLE]], [
1299
- /\b(xbox(?: one)?(?!; xbox))[\); ]/i // Microsoft Xbox
1300
- ], [MODEL, [VENDOR, MICROSOFT], [TYPE, CONSOLE]], [
1301
-
1302
- ///////////////////
1303
- // WEARABLES
1304
- ///////////////////
1305
-
1306
- /((pebble))app/i // Pebble
1307
- ], [VENDOR, MODEL, [TYPE, WEARABLE]], [
1308
- /(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i // Apple Watch
1309
- ], [MODEL, [VENDOR, APPLE], [TYPE, WEARABLE]], [
1310
- /droid.+; (glass) \d/i // Google Glass
1311
- ], [MODEL, [VENDOR, GOOGLE], [TYPE, WEARABLE]], [
1312
- /droid.+; (wt63?0{2,3})\)/i
1313
- ], [MODEL, [VENDOR, ZEBRA], [TYPE, WEARABLE]], [
1314
- /(quest( 2| pro)?)/i // Oculus Quest
1315
- ], [MODEL, [VENDOR, FACEBOOK], [TYPE, WEARABLE]], [
1316
-
1317
- ///////////////////
1318
- // EMBEDDED
1319
- ///////////////////
1320
-
1321
- /(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i // Tesla
1322
- ], [VENDOR, [TYPE, EMBEDDED]], [
1323
- /(aeobc)\b/i // Echo Dot
1324
- ], [MODEL, [VENDOR, AMAZON], [TYPE, EMBEDDED]], [
1325
-
1326
- ////////////////////
1327
- // MIXED (GENERIC)
1328
- ///////////////////
1329
-
1330
- /droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i // Android Phones from Unidentified Vendors
1331
- ], [MODEL, [TYPE, MOBILE]], [
1332
- /droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i // Android Tablets from Unidentified Vendors
1333
- ], [MODEL, [TYPE, TABLET]], [
1334
- /\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i // Unidentifiable Tablet
1335
- ], [[TYPE, TABLET]], [
1336
- /(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i // Unidentifiable Mobile
1337
- ], [[TYPE, MOBILE]], [
1338
- /(android[-\w\. ]{0,9});.+buil/i // Generic Android Device
1339
- ], [MODEL, [VENDOR, 'Generic']]
1340
- ],
1341
-
1342
- engine : [[
1343
-
1344
- /windows.+ edge\/([\w\.]+)/i // EdgeHTML
1345
- ], [VERSION, [NAME, EDGE+'HTML']], [
1346
-
1347
- /webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i // Blink
1348
- ], [VERSION, [NAME, 'Blink']], [
1349
-
1350
- /(presto)\/([\w\.]+)/i, // Presto
1351
- /(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i, // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m/Goanna
1352
- /ekioh(flow)\/([\w\.]+)/i, // Flow
1353
- /(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i, // KHTML/Tasman/Links
1354
- /(icab)[\/ ]([23]\.[\d\.]+)/i, // iCab
1355
- /\b(libweb)/i
1356
- ], [NAME, VERSION], [
1357
-
1358
- /rv\:([\w\.]{1,9})\b.+(gecko)/i // Gecko
1359
- ], [VERSION, NAME]
1360
- ],
1361
-
1362
- os : [[
1363
-
1364
- // Windows
1365
- /microsoft (windows) (vista|xp)/i // Windows (iTunes)
1366
- ], [NAME, VERSION], [
1367
- /(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i // Windows Phone
1368
- ], [NAME, [VERSION, strMapper, windowsVersionMap]], [
1369
- /windows nt 6\.2; (arm)/i, // Windows RT
1370
- /windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,
1371
- /(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i
1372
- ], [[VERSION, strMapper, windowsVersionMap], [NAME, 'Windows']], [
1373
-
1374
- // iOS/macOS
1375
- /ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i, // iOS
1376
- /(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,
1377
- /cfnetwork\/.+darwin/i
1378
- ], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
1379
- /(mac os x) ?([\w\. ]*)/i,
1380
- /(macintosh|mac_powerpc\b)(?!.+haiku)/i // Mac OS
1381
- ], [[NAME, MAC_OS], [VERSION, /_/g, '.']], [
1382
-
1383
- // Mobile OSes
1384
- /droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i // Android-x86/HarmonyOS
1385
- ], [VERSION, NAME], [ // Android/WebOS/QNX/Bada/RIM/Maemo/MeeGo/Sailfish OS
1386
- /(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,
1387
- /(blackberry)\w*\/([\w\.]*)/i, // Blackberry
1388
- /(tizen|kaios)[\/ ]([\w\.]+)/i, // Tizen/KaiOS
1389
- /\((series40);/i // Series 40
1390
- ], [NAME, VERSION], [
1391
- /\(bb(10);/i // BlackBerry 10
1392
- ], [VERSION, [NAME, BLACKBERRY]], [
1393
- /(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i // Symbian
1394
- ], [VERSION, [NAME, 'Symbian']], [
1395
- /mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i // Firefox OS
1396
- ], [VERSION, [NAME, FIREFOX+' OS']], [
1397
- /web0s;.+rt(tv)/i,
1398
- /\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i // WebOS
1399
- ], [VERSION, [NAME, 'webOS']], [
1400
- /watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i // watchOS
1401
- ], [VERSION, [NAME, 'watchOS']], [
1402
-
1403
- // Google Chromecast
1404
- /crkey\/([\d\.]+)/i // Google Chromecast
1405
- ], [VERSION, [NAME, CHROME+'cast']], [
1406
- /(cros) [\w]+(?:\)| ([\w\.]+)\b)/i // Chromium OS
1407
- ], [[NAME, CHROMIUM_OS], VERSION],[
1408
-
1409
- // Smart TVs
1410
- /panasonic;(viera)/i, // Panasonic Viera
1411
- /(netrange)mmh/i, // Netrange
1412
- /(nettv)\/(\d+\.[\w\.]+)/i, // NetTV
1413
-
1414
- // Console
1415
- /(nintendo|playstation) ([wids345portablevuch]+)/i, // Nintendo/Playstation
1416
- /(xbox); +xbox ([^\);]+)/i, // Microsoft Xbox (360, One, X, S, Series X, Series S)
1417
-
1418
- // Other
1419
- /\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i, // Joli/Palm
1420
- /(mint)[\/\(\) ]?(\w*)/i, // Mint
1421
- /(mageia|vectorlinux)[; ]/i, // Mageia/VectorLinux
1422
- /([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,
1423
- // Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware/Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus/Raspbian/Plan9/Minix/RISCOS/Contiki/Deepin/Manjaro/elementary/Sabayon/Linspire
1424
- /(hurd|linux) ?([\w\.]*)/i, // Hurd/Linux
1425
- /(gnu) ?([\w\.]*)/i, // GNU
1426
- /\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i, // FreeBSD/NetBSD/OpenBSD/PC-BSD/GhostBSD/DragonFly
1427
- /(haiku) (\w+)/i // Haiku
1428
- ], [NAME, VERSION], [
1429
- /(sunos) ?([\w\.\d]*)/i // Solaris
1430
- ], [[NAME, 'Solaris'], VERSION], [
1431
- /((?:open)?solaris)[-\/ ]?([\w\.]*)/i, // Solaris
1432
- /(aix) ((\d)(?=\.|\)| )[\w\.])*/i, // AIX
1433
- /\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i, // BeOS/OS2/AmigaOS/MorphOS/OpenVMS/Fuchsia/HP-UX/SerenityOS
1434
- /(unix) ?([\w\.]*)/i // UNIX
1435
- ], [NAME, VERSION]
1436
- ]
1437
- };
1438
-
1439
- /////////////////
1440
- // Constructor
1441
- ////////////////
1442
-
1443
- var UAParser = function (ua, extensions) {
1444
-
1445
- if (typeof ua === OBJ_TYPE) {
1446
- extensions = ua;
1447
- ua = undefined$1;
1448
- }
1449
-
1450
- if (!(this instanceof UAParser)) {
1451
- return new UAParser(ua, extensions).getResult();
1452
- }
1453
-
1454
- var _navigator = (typeof window !== UNDEF_TYPE && window.navigator) ? window.navigator : undefined$1;
1455
- var _ua = ua || ((_navigator && _navigator.userAgent) ? _navigator.userAgent : EMPTY);
1456
- var _uach = (_navigator && _navigator.userAgentData) ? _navigator.userAgentData : undefined$1;
1457
- var _rgxmap = extensions ? extend(regexes, extensions) : regexes;
1458
- var _isSelfNav = _navigator && _navigator.userAgent == _ua;
1459
-
1460
- this.getBrowser = function () {
1461
- var _browser = {};
1462
- _browser[NAME] = undefined$1;
1463
- _browser[VERSION] = undefined$1;
1464
- rgxMapper.call(_browser, _ua, _rgxmap.browser);
1465
- _browser[MAJOR] = majorize(_browser[VERSION]);
1466
- // Brave-specific detection
1467
- if (_isSelfNav && _navigator && _navigator.brave && typeof _navigator.brave.isBrave == FUNC_TYPE) {
1468
- _browser[NAME] = 'Brave';
1469
- }
1470
- return _browser;
1471
- };
1472
- this.getCPU = function () {
1473
- var _cpu = {};
1474
- _cpu[ARCHITECTURE] = undefined$1;
1475
- rgxMapper.call(_cpu, _ua, _rgxmap.cpu);
1476
- return _cpu;
1477
- };
1478
- this.getDevice = function () {
1479
- var _device = {};
1480
- _device[VENDOR] = undefined$1;
1481
- _device[MODEL] = undefined$1;
1482
- _device[TYPE] = undefined$1;
1483
- rgxMapper.call(_device, _ua, _rgxmap.device);
1484
- if (_isSelfNav && !_device[TYPE] && _uach && _uach.mobile) {
1485
- _device[TYPE] = MOBILE;
1486
- }
1487
- // iPadOS-specific detection: identified as Mac, but has some iOS-only properties
1488
- if (_isSelfNav && _device[MODEL] == 'Macintosh' && _navigator && typeof _navigator.standalone !== UNDEF_TYPE && _navigator.maxTouchPoints && _navigator.maxTouchPoints > 2) {
1489
- _device[MODEL] = 'iPad';
1490
- _device[TYPE] = TABLET;
1491
- }
1492
- return _device;
1493
- };
1494
- this.getEngine = function () {
1495
- var _engine = {};
1496
- _engine[NAME] = undefined$1;
1497
- _engine[VERSION] = undefined$1;
1498
- rgxMapper.call(_engine, _ua, _rgxmap.engine);
1499
- return _engine;
1500
- };
1501
- this.getOS = function () {
1502
- var _os = {};
1503
- _os[NAME] = undefined$1;
1504
- _os[VERSION] = undefined$1;
1505
- rgxMapper.call(_os, _ua, _rgxmap.os);
1506
- if (_isSelfNav && !_os[NAME] && _uach && _uach.platform != 'Unknown') {
1507
- _os[NAME] = _uach.platform
1508
- .replace(/chrome os/i, CHROMIUM_OS)
1509
- .replace(/macos/i, MAC_OS); // backward compatibility
1510
- }
1511
- return _os;
1512
- };
1513
- this.getResult = function () {
1514
- return {
1515
- ua : this.getUA(),
1516
- browser : this.getBrowser(),
1517
- engine : this.getEngine(),
1518
- os : this.getOS(),
1519
- device : this.getDevice(),
1520
- cpu : this.getCPU()
1521
- };
1522
- };
1523
- this.getUA = function () {
1524
- return _ua;
1525
- };
1526
- this.setUA = function (ua) {
1527
- _ua = (typeof ua === STR_TYPE && ua.length > UA_MAX_LENGTH) ? trim(ua, UA_MAX_LENGTH) : ua;
1528
- return this;
1529
- };
1530
- this.setUA(_ua);
1531
- return this;
1532
- };
1533
-
1534
- UAParser.VERSION = LIBVERSION;
1535
- UAParser.BROWSER = enumerize([NAME, VERSION, MAJOR]);
1536
- UAParser.CPU = enumerize([ARCHITECTURE]);
1537
- UAParser.DEVICE = enumerize([MODEL, VENDOR, TYPE, CONSOLE, MOBILE, SMARTTV, TABLET, WEARABLE, EMBEDDED]);
1538
- UAParser.ENGINE = UAParser.OS = enumerize([NAME, VERSION]);
1539
-
1540
- ///////////
1541
- // Export
1542
- //////////
1543
-
1544
- // check js environment
1545
- {
1546
- // nodejs env
1547
- if (module.exports) {
1548
- exports = module.exports = UAParser;
1549
- }
1550
- exports.UAParser = UAParser;
1551
- }
1552
-
1553
- // jQuery/Zepto specific (optional)
1554
- // Note:
1555
- // In AMD env the global scope should be kept clean, but jQuery is an exception.
1556
- // jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
1557
- // and we should catch that.
1558
- var $ = typeof window !== UNDEF_TYPE && (window.jQuery || window.Zepto);
1559
- if ($ && !$.ua) {
1560
- var parser = new UAParser();
1561
- $.ua = parser.getResult();
1562
- $.ua.get = function () {
1563
- return parser.getUA();
1564
- };
1565
- $.ua.set = function (ua) {
1566
- parser.setUA(ua);
1567
- var result = parser.getResult();
1568
- for (var prop in result) {
1569
- $.ua[prop] = result[prop];
1570
- }
1571
- };
1572
- }
1573
-
1574
- })(typeof window === 'object' ? window : commonjsGlobal);
1575
- } (uaParser, uaParser.exports));
1576
- return uaParser.exports;
1577
- }
1578
-
1579
- /*! For license information please see index.js.LICENSE.txt */
1580
- niceCxoneChatWebSdk.exports;
1581
-
1582
- (function (module, exports) {
1583
- !function(e,t){module.exports=t(esmBrowser,requireUaParser());}(self,((e,t)=>(()=>{var n={910:(e,t,n)=>{t.Nf=void 0;n(151),n(749);t.Nf=function(e){var t=Date.parse(e);return isNaN(t)&&(t=function(e){var t,n=/^(\d{4}-\d\d-\d\d([tT][\d:.]*)?)([zZ]|([+-])(\d\d):?(\d\d))?$/.exec(e)||[];if(n[1]){if((t=n[1].split(/\D/).map((function(e){return parseInt(e,10)||0})))[1]-=1,!(t=new Date(Date.UTC.apply(Date,t))).getDate())return NaN;if(n[5]){var o=60*parseInt(n[5],10);n[6]&&(o+=parseInt(n[6],10)),"+"===n[4]&&(o*=-1),o&&t.setUTCMinutes(t.getUTCMinutes()+o);}return t.getTime()}return NaN}(e)),new Date(t)};},749:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getTimeInMinutes=t.getTimeInMilliseconds=t.getTimeInSeconds=t.padDateTimeUnit=void 0,t.padDateTimeUnit=function(e){var t=Math.abs(Math.floor("string"==typeof e?Number(e):e));return (t<10?"0":"")+t},t.getTimeInSeconds=function(e){var t=e.hours,n=void 0===t?0:t,o=e.minutes,r=void 0===o?0:o,s=e.seconds;return 60*n*60+60*r+(void 0===s?0:s)},t.getTimeInMilliseconds=function(e){var n=e.hours,o=void 0===n?0:n,r=e.minutes,s=void 0===r?0:r,i=e.seconds,a=void 0===i?0:i,c=e.milliseconds,u=void 0===c?0:c;return 1e3*(0, t.getTimeInSeconds)({hours:o,minutes:s,seconds:a})+u},t.getTimeInMinutes=function(e){var n=e.hours,o=void 0===n?0:n,r=e.minutes,s=void 0===r?0:r,i=e.seconds,a=void 0===i?0:i;return (0, t.getTimeInSeconds)({hours:o,minutes:s,seconds:a})/60};},151:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getTimezoneISOOffset=void 0;var o=n(749);t.getTimezoneISOOffset=function(e){void 0===e&&(e=new Date);var t=e.getTimezoneOffset();return "".concat(t>0?"-":"+").concat((0, o.padDateTimeUnit)(t/60),":").concat((0, o.padDateTimeUnit)(t%60))};},893:(e,t)=>{t.P=void 0,t.P=function(e){return Object.keys(e).filter((function(t){return null!==e[t]})).map((function(t){return [t,e[t]].map(encodeURIComponent).join("=")})).join("&")};},282:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.LogLevels=void 0,(n=t.LogLevels||(t.LogLevels={})).ERROR="error",n.INFO="info",n.WARN="warn";},996:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EventTargetPolyfill=void 0;var n=function(){function e(){this.listeners={};}return e.prototype.addEventListener=function(e,t){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push(t);},e.prototype.removeEventListener=function(e,t){if(e in this.listeners)for(var n=this.listeners[e],o=0,r=n.length;o<r;o++)if(n[o]===t)return void n.splice(o,1)},e.prototype.dispatchEvent=function(e){if(!(e.type in this.listeners))return !0;for(var t=this.listeners[e.type].slice(),n=0,o=t.length;n<o;n++)t[n].call(this,e);return !e.defaultPrevented},e}();t.EventTargetPolyfill=n;},455:(e,t,n)=>{t.xT=void 0;n(546),n(996),n(846);var o=n(982);Object.defineProperty(t,"xT",{enumerable:!0,get:function(){return o.WebSocketClientEvent}});},415:function(e,t,n){var o=this&&this.__assign||function(){return o=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},o.apply(this,arguments)},r=this&&this.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.getPushUpdateWebSocket=t.setupSocketConnection=void 0;var s=n(846),i=n(982),a=null,c={forceSecureProtocol:!1,heartbeatAfterAuthorize:!1,maxRetries:20,maxReconnectionDelay:1e3};t.setupSocketConnection=function(e,t){if(void 0===t&&(t={}),"object"!=typeof t)throw new TypeError("Options parameter must be an object not a "+typeof t);var n=o(o({},c),t),u=n.forceSecureProtocol,l=n.heartbeatAfterAuthorize,d=r(n,["forceSecureProtocol","heartbeatAfterAuthorize"]),E=function(e,t){return t?"wss://"+e:("https:"===window.location.protocol?"wss:":"ws:")+"//"+e}(e,u);return a=new s.WebSocketClient(E,void 0,d),l?a.addEventListener(i.WebSocketClientEvent.MESSAGE,(function(e){"authorized"===JSON.parse(e.detail.data)&&(null==a||a.startHeartBeat());})):a.startHeartBeat(),a},t.getPushUpdateWebSocket=function(){return a};},546:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.HeartBeatState=void 0,(n=t.HeartBeatState||(t.HeartBeatState={})).DIED="died",n.DYING="dying",n.LIVING="living";},846:function(e,t,n){var o,r=this&&this.__extends||(o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);},o(e,t)},function(e,t){function n(){this.constructor=e;}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n);}),s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocketClient=t.HEART_BEAT_CHECK_TIMEOUT=t.HEART_BEAT_INTERVAL=void 0;var i=n(282),a=s(n(864)),c=n(996),u=n(546),l=n(982);t.HEART_BEAT_INTERVAL=15e3,t.HEART_BEAT_CHECK_TIMEOUT=3*t.HEART_BEAT_INTERVAL;var d=function(e){function n(n,o,r){var s=e.call(this)||this;return s.heartBeatTimeout=null,s.heartBeatCheckTimeout=null,s.enableDebugMode=function(){s.debugMode||s.log(i.LogLevels.INFO,"websocket-push-updates--loggerEnabled"),s.debugMode=!0;},s.disableDebugMode=function(){s.debugMode=!1;},s.log=function(e,t,n){s.debugMode&&s.logger&&s.logger[e](t,n);},s.sendHeartBeat=function(){s.log(i.LogLevels.INFO,"websocket-push-updates--sendHeartBeat"),s.send(JSON.stringify({action:"heartbeat"}));},s.handleHeartBeatResponse=function(){s.heartBeatState===u.HeartBeatState.DYING&&(s.heartBeatState=u.HeartBeatState.LIVING,s.dispatchHeartBeatState()),s.setHeartBeatCheckTimeout();},s.setHeartBeatCheckTimeout=function(){null!==s.heartBeatCheckTimeout&&clearTimeout(s.heartBeatCheckTimeout),s.heartBeatCheckTimeout=setTimeout((function(){s.heartBeatState=u.HeartBeatState.DYING,s.dispatchHeartBeatState();}),t.HEART_BEAT_CHECK_TIMEOUT);},s.dispatchHeartBeatState=function(){s.log(i.LogLevels.INFO,"websocket-push-updates--dispatchHeartBeatState",[{hearbeatState:s.heartBeatState}]),null!==s.heartBeatState&&s.dispatchEvent(new CustomEvent(s.heartBeatState));},s.isHeartBeatActive=function(){return null!==s.heartBeatState},s.heartBeatState=null,s.debugMode=!1,s.socket=new a.default(n,o,r),s.socket.onopen=function(){s.dispatchEvent(new CustomEvent(l.WebSocketClientEvent.OPEN));},(null==r?void 0:r.logger)&&(s.logger=r.logger),s.socket.onclose=function(e){s.socket.retryCount===(null==r?void 0:r.maxRetries)?s.heartBeatState=u.HeartBeatState.DIED:s.heartBeatState=u.HeartBeatState.DYING,s.dispatchHeartBeatState(),s.dispatchEvent(new CustomEvent(l.WebSocketClientEvent.CLOSE,{detail:e}));},s.socket.onmessage=function(e){s.handleHeartBeatResponse(),"pong"!==JSON.parse(e.data)&&(s.log(i.LogLevels.INFO,"websocket-push-updates--onmessage",[e]),s.dispatchEvent(new CustomEvent(l.WebSocketClientEvent.MESSAGE,{detail:e})));},s.socket.onerror=function(e){s.log(i.LogLevels.ERROR,"websocket-push-updates--onError",[e]),s.dispatchEvent(new CustomEvent(l.WebSocketClientEvent.ERROR,{detail:e}));},s}return r(n,e),n.prototype.send=function(e){this.socket.send(e);},n.prototype.startHeartBeat=function(){var e=this;this.log(i.LogLevels.INFO,"websocket-push-updates--startHeartBeat",[{interval:t.HEART_BEAT_INTERVAL}]);var n=function(){e.log(i.LogLevels.INFO,"websocket-push-updates--heartBeatCallback"),e.sendHeartBeat(),e.heartBeatTimeout=setTimeout(n,t.HEART_BEAT_INTERVAL);};this.setHeartBeatCheckTimeout(),n(),this.heartBeatState=u.HeartBeatState.LIVING;},n.prototype.stopHeartBeat=function(){this.log(i.LogLevels.INFO,"websocket-push-updates--stopHeartBeat"),null!==this.heartBeatTimeout&&clearTimeout(this.heartBeatTimeout),null!==this.heartBeatCheckTimeout&&clearTimeout(this.heartBeatCheckTimeout),this.heartBeatState=null;},n}(c.EventTargetPolyfill);t.WebSocketClient=d;},982:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocketClientEvent=void 0,(n=t.WebSocketClientEvent||(t.WebSocketClientEvent={})).CLOSE="close",n.ERROR="error",n.MESSAGE="message",n.OPEN="open";},864:(e,t,n)=>{n.r(t),n.d(t,{default:()=>E});var o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t;}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);},o(e,t)};function r(e,t){function n(){this.constructor=e;}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n);}function s(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,s=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(o=s.next()).done;)i.push(o.value);}catch(e){r={error:e};}finally{try{o&&!o.done&&(n=s.return)&&n.call(s);}finally{if(r)throw r.error}}return i}function i(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(s(arguments[t]));return e}var a=function(e,t){this.target=t,this.type=e;},c=function(e){function t(t,n){var o=e.call(this,"error",n)||this;return o.message=t.message,o.error=t,o}return r(t,e),t}(a),u=function(e){function t(t,n,o){void 0===t&&(t=1e3),void 0===n&&(n="");var r=e.call(this,"close",o)||this;return r.wasClean=!0,r.code=t,r.reason=n,r}return r(t,e),t}(a),l=function(){if("undefined"!=typeof WebSocket)return WebSocket},d={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+4e3*Math.random(),minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1};const E=function(){function e(e,t,n){var o=this;void 0===n&&(n={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(e){o._debug("open event");var t=o._options.minUptime,n=void 0===t?d.minUptime:t;clearTimeout(o._connectTimeout),o._uptimeTimeout=setTimeout((function(){return o._acceptOpen()}),n),o._ws.binaryType=o._binaryType,o._messageQueue.forEach((function(e){var t;return null===(t=o._ws)||void 0===t?void 0:t.send(e)})),o._messageQueue=[],o.onopen&&o.onopen(e),o._listeners.open.forEach((function(t){return o._callEventListener(e,t)}));},this._handleMessage=function(e){o._debug("message event"),o.onmessage&&o.onmessage(e),o._listeners.message.forEach((function(t){return o._callEventListener(e,t)}));},this._handleError=function(e){o._debug("error event",e.message),o._disconnect(void 0,"TIMEOUT"===e.message?"timeout":void 0),o.onerror&&o.onerror(e),o._debug("exec error listeners"),o._listeners.error.forEach((function(t){return o._callEventListener(e,t)})),o._connect();},this._handleClose=function(e){o._debug("close event"),o._clearTimeouts(),o._shouldReconnect&&o._connect(),o.onclose&&o.onclose(e),o._listeners.close.forEach((function(t){return o._callEventListener(e,t)}));},this._url=e,this._protocols=t,this._options=n,this._options.startClosed&&(this._shouldReconnect=!1),this._connect();}return Object.defineProperty(e,"CONNECTING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OPEN",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSED",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CONNECTING",{get:function(){return e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"OPEN",{get:function(){return e.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSING",{get:function(){return e.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSED",{get:function(){return e.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryType",{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e);},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){return this._messageQueue.reduce((function(e,t){return "string"==typeof t?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e}),0)+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this._ws?this._ws.extensions:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this._ws?this._ws.protocol:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._ws?this._ws.url:""},enumerable:!0,configurable:!0}),e.prototype.close=function(e,t){void 0===e&&(e=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),this._ws?this._ws.readyState!==this.CLOSED?this._ws.close(e,t):this._debug("close: already closed"):this._debug("close enqueued: no ws instance");},e.prototype.reconnect=function(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,this._ws&&this._ws.readyState!==this.CLOSED?(this._disconnect(e,t),this._connect()):this._connect();},e.prototype.send=function(e){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",e),this._ws.send(e);else {var t=this._options.maxEnqueuedMessages,n=void 0===t?d.maxEnqueuedMessages:t;this._messageQueue.length<n&&(this._debug("enqueue",e),this._messageQueue.push(e));}},e.prototype.addEventListener=function(e,t){this._listeners[e]&&this._listeners[e].push(t);},e.prototype.dispatchEvent=function(e){var t,n,o=this._listeners[e.type];if(o)try{for(var r=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}(o),s=r.next();!s.done;s=r.next()){var i=s.value;this._callEventListener(e,i);}}catch(e){t={error:e};}finally{try{s&&!s.done&&(n=r.return)&&n.call(r);}finally{if(t)throw t.error}}return !0},e.prototype.removeEventListener=function(e,t){this._listeners[e]&&(this._listeners[e]=this._listeners[e].filter((function(e){return e!==t})));},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._options.debug&&console.log.apply(console,i(["RWS>"],e));},e.prototype._getNextDelay=function(){var e=this._options,t=e.reconnectionDelayGrowFactor,n=void 0===t?d.reconnectionDelayGrowFactor:t,o=e.minReconnectionDelay,r=void 0===o?d.minReconnectionDelay:o,s=e.maxReconnectionDelay,i=void 0===s?d.maxReconnectionDelay:s,a=0;return this._retryCount>0&&(a=r*Math.pow(n,this._retryCount-1))>i&&(a=i),this._debug("next delay",a),a},e.prototype._wait=function(){var e=this;return new Promise((function(t){setTimeout(t,e._getNextDelay());}))},e.prototype._getNextUrl=function(e){if("string"==typeof e)return Promise.resolve(e);if("function"==typeof e){var t=e();if("string"==typeof t)return Promise.resolve(t);if(t.then)return t}throw Error("Invalid URL")},e.prototype._connect=function(){var e=this;if(!this._connectLock&&this._shouldReconnect){this._connectLock=!0;var t=this._options,n=t.maxRetries,o=void 0===n?d.maxRetries:n,r=t.connectionTimeout,s=void 0===r?d.connectionTimeout:r,i=t.WebSocket,a=void 0===i?l():i;if(this._retryCount>=o)this._debug("max retries reached",this._retryCount,">=",o);else {if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),void 0===(u=a)||!u||2!==u.CLOSING)throw Error("No valid WebSocket class provided");var u;this._wait().then((function(){return e._getNextUrl(e._url)})).then((function(t){e._closeCalled?e._connectLock=!1:(e._debug("connect",{url:t,protocols:e._protocols}),e._ws=e._protocols?new a(t,e._protocols):new a(t),e._ws.binaryType=e._binaryType,e._connectLock=!1,e._addListeners(),e._connectTimeout=setTimeout((function(){return e._handleTimeout()}),s));})).catch((function(t){e._connectLock=!1,e._handleError(new c(Error(t.message),e));}));}}},e.prototype._handleTimeout=function(){this._debug("timeout event"),this._handleError(new c(Error("TIMEOUT"),this));},e.prototype._disconnect=function(e,t){if(void 0===e&&(e=1e3),this._clearTimeouts(),this._ws){this._removeListeners();try{this._ws.close(e,t),this._handleClose(new u(e,t,this));}catch(e){}}},e.prototype._acceptOpen=function(){this._debug("accept open"),this._retryCount=0;},e.prototype._callEventListener=function(e,t){"handleEvent"in t?t.handleEvent(e):t(e);},e.prototype._removeListeners=function(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError));},e.prototype._addListeners=function(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError));},e.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout);},e}();},441:(e,t)=>{var n;(n=t.p||(t.p={})).CHAT_WINDOW_EVENT="chatWindowEvent",n.REGISTER="register";},154:(e,t)=>{var n,o;(o=t.YU||(t.YU={})).SENDER_TYPING_STARTED="SenderTypingStarted",o.SENDER_TYPING_ENDED="SenderTypingEnded",o.LOAD_MORE_MESSAGES="LoadMoreMessages",o.RECOVER_LIVECHAT="RecoverLivechat",o.RECOVER_THREAD="RecoverThread",o.SEND_MESSAGE="SendMessage",o.SEND_OUTBOUND="SendOutbound",o.SEND_OFFLINE_MESSAGE="SendOfflineMessage",o.SEND_PAGE_VIEWS="SendPageViews",o.SEND_CONSUMER_CUSTOM_FIELDS="SetConsumerCustomFields",o.SET_CONSUMER_CONTACT_CUSTOM_FIELD="SetConsumerContactCustomFields",o.MESSAGE_SEEN="MessageSeenByConsumer",o.SEND_TRANSCRIPT="SendTranscript",o.FETCH_THREAD_LIST="FetchThreadList",o.END_CONTACT="EndContact",o.EXECUTE_TRIGGER="ExecuteTrigger",o.AUTHORIZE_CONSUMER="AuthorizeConsumer",o.AUTHORIZE_CUSTOMER="AuthorizeCustomer",o.RECONNECT_CONSUMER="ReconnectConsumer",o.UPDATE_THREAD="UpdateThread",o.ARCHIVE_THREAD="ArchiveThread",o.LOAD_THREAD_METADATA="LoadThreadMetadata",o.REFRESH_TOKEN="RefreshToken",o.STORE_VISITOR="StoreVisitor",o.STORE_VISITOR_EVENTS="StoreVisitorEvents",o.CREATE_GROUP_CHAT_INVITE="CreateInvitationToGroupChat",o.SEND_EMAIL_INVITE_TO_GROUP_CHAT="SendEmailInvitationToGroupChat",o.JOIN_GROUP_CHAT="JoinGroupChat",o.LEAVE_GROUP_CHAT="LeaveGroupChat",o.GENERATE_AUTHORIZATION_TOKEN="GenerateAuthorizationToken",o.ADD_VISITOR_TAGS="AddVisitorTags",o.REMOVE_VISITOR_TAGS="RemoveVisitorTags",o.SEND_MESSAGE_PREVIEW="SendMessagePreview",(n=t.Ne||(t.Ne={})).LIVECHAT_RECOVERED="LivechatRecovered",n.MORE_MESSAGES_LOADED="MoreMessagesLoaded",n.OFFLINE_MESSAGE_SENT="OfflineMessageSent",n.THREAD_LIST_FETCHED="ThreadListFetched",n.THREAD_RECOVERED="ThreadRecovered",n.TRANSCRIPT_SENT="TranscriptSent",n.CONSUMER_AUTHORIZED="ConsumerAuthorized",n.THREAD_METADATA_LOADED="ThreadMetadataLoaded",n.SET_POSITION_IN_QUEUE="SetPositionInQueue",n.GROUP_CHAT_INVITE_CREATED="InvitationToGroupChatCreated",n.GROUP_CHAT_INVITE_SENT="EmailInvitationToGroupChatSent",n.GROUP_CHAT_JOINED="GroupChatJoined",n.TOKEN_REFRESHED="TokenRefreshed",n.AUTHORIZATION_TOKEN_GENERATED="AuthorizationTokenGenerated",n.THREAD_ARCHIVED="ThreadArchived";},58:(e,t)=>{var n;(n=t.Yi||(t.Yi={})).DESKTOP="desktop",n.MOBILE="mobile",n.OTHER="other",n.TABLET="tablet",(t.vQ||(t.vQ={})).BROWSER="browser";},880:(e,t,n)=>{var o=n(256);t.P=o.CaseStatus;},354:(e,t)=>{t.GO="X-Caller-Service-ID";},510:(e,t)=>{var n;(n=t.T||(t.T={})).INBOUND="inbound",n.OUTBOUND="outbound";},115:(e,t)=>{var n;(n=t.C||(t.C={})).TEXT="TEXT",n.FILE="FILE",n.FORM="FORM",n.PLUGIN="PLUGIN",n.POSTBACK="POSTBACK",n.QUICK_REPLIES="QUICK_REPLIES",n.RICH_LINK="RICH_LINK",n.LIST_PICKER="LIST_PICKER",n.ADAPTIVE_CARD="ADAPTIVE_CARD",n.TIME_PICKER="TIME_PICKER";},256:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),(n=t.CaseStatus||(t.CaseStatus={})).NEW="new",n.OPEN="open",n.PENDING="pending",n.ESCALATED="escalated",n.RESOLVED="resolved",n.CLOSED="closed",n.TRASHED="trashed";},403:(e,t)=>{var n;(n=t.m||(t.m={})).AUTHORIZE_CONSUMER="AuthorizeConsumer",n.CASE_CREATED="CaseCreated",n.CASE_INBOX_ASSIGNEE_CHANGED="CaseInboxAssigneeChanged",n.CASE_STATUS_CHANGED="CaseStatusChanged",n.CASE_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED="CaseToRoutingQueueAssignmentChanged",n.CONTACT_CREATED="CaseCreated",n.ASSIGNED_AGENT_CHANGED="CaseInboxAssigneeChanged",n.CONTACT_STATUS_CHANGED="CaseStatusChanged",n.CONTACT_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED="CaseToRoutingQueueAssignmentChanged",n.CONTACT_PREFERRED_USER_CHANGED="ContactPreferredUserChanged",n.CONTACT_PROFICIENCY_CHANGED="ContactProficiencyChanged",n.CONTACT_PRIORITY_CHANGED="ContactPriorityChanged",n.CONTACT_SYNC="ContactSync",n.CHANNEL_CREATED="ChannelCreated",n.CHANNEL_DELETED="ChannelDeleted",n.CHANNEL_UPDATED="ChannelUpdated",n.MESSAGE_ADDED_INTO_CASE="MessageAddedIntoCase",n.MESSAGE_CREATED="MessageCreated",n.MESSAGE_DELIVERED_TO_END_USER="MessageDeliveredToEndUser",n.MESSAGE_DELIVERED_TO_USER="MessageDeliveredToUser",n.MESSAGE_NOTE_CREATED="MessageNoteCreated",n.MESSAGE_NOTE_UPDATED="MessageNoteUpdated",n.MESSAGE_NOTE_DELETED="MessageNoteDeleted",n.MESSAGE_READ_CHANGED="MessageReadChanged",n.MESSAGE_SEEN_BY_END_USER="MessageSeenByEndUser",n.MESSAGE_SEEN_BY_USER="MessageSeenByUser",n.MESSAGE_SENT="MessageSent",n.MESSAGE_UPDATED="MessageUpdated",n.PAGE_VIEW_CREATED="PageViewCreated",n.ROUTING_QUEUE_CREATED="RoutingQueueCreated",n.ROUTING_QUEUE_DELETED="RoutingQueueDeleted",n.ROUTING_QUEUE_UPDATED="RoutingQueueUpdated",n.SUBQUEUE_ASSIGNED_TO_ROUTING_QUEUE="SubqueueAssignedToRoutingQueue",n.SUBQUEUE_UNASSIGNED_TO_ROUTING_QUEUE="SubqueueUnassignedFromRoutingQueue",n.USER_ASSIGNED_TO_ROUTING_QUEUE="UserAssignedToRoutingQueue",n.USER_STATUS_CHANGED="UserStatusChanged",n.USER_UNASSIGNED_FROM_ROUTING_QUEUE="UserUnassignedFromRoutingQueue",n.AGENT_CONTACT_STARTED="AgentContactStarted",n.AGENT_CONTACT_ENDED="AgentContactEnded",n.SENDER_TYPING_STARTED="SenderTypingStarted",n.SENDER_TYPING_ENDED="SenderTypingEnded",n.FIRE_PROACTIVE="FireProactiveAction",n.CONTACT_INBOX_PRE_ASSIGNEE_CHANGED="ConsumerContactInboxPreAssigneeChanged",n.CONTACT_RECIPIENTS_CHANGED="ContactRecipientsChanged",n.MESSAGE_PREVIEW_CREATED="MessagePreviewCreated",n.EVENT_IN_S3="EventInS3";},585:e=>{e.exports=t;},459:t=>{t.exports=e;}},o={};function r(e){var t=o[e];if(void 0!==t)return t.exports;var s=o[e]={exports:{}};return n[e].call(s.exports,s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]});},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});};var s={};return (()=>{r.r(s),r.d(s,{AbortError:()=>Xt,AbortablePromise:()=>Zt,AuthorizationError:()=>d,ChatEvent:()=>Ze,ChatSdk:()=>qt,ContactStatus:()=>Tt.P,Customer:()=>ke,EnvironmentName:()=>Je,LivechatThread:()=>Wt,MessageType:()=>dt.C,SendMessageFailedError:()=>lt,Thread:()=>Vt,ThreadRecoverFailedError:()=>Bt,UploadAttachmentError:()=>St,WebSocketClientError:()=>_t,WebSocketClientEvent:()=>t.xT,createCreateInvitationToGroupChatPayloadData:()=>En,createJoinGroupChatPayloadData:()=>vn,createLeaveGroupChatPayloadData:()=>fn,createReconnectPayloadData:()=>We,createSendEmailInvitationToGroupChatPayloadData:()=>Cn,default:()=>On,generateId:()=>E.v4,getAuthor:()=>rn,isAgentTypingEndedEvent:()=>nn,isAgentTypingStartedEvent:()=>tn,isAssignedAgentChangedEvent:()=>en,isAuthSuccessEvent:()=>$e,isContactCreatedEvent:()=>It,isContactRecipientsChangedEvent:()=>Rt,isContactStatusChangedEvent:()=>Nt,isContactToRoutingQueueAssignmentChangedEvent:()=>wt,isCustomerReconnectSuccessPayloadData:()=>An,isLoadMetadataSuccessPayload:()=>jt,isMessage:()=>sn,isMessageCreatedEvent:()=>an,isMessageReadChangedEvent:()=>un,isMessageSentEvent:()=>cn,isMoreMessagesLoadedEvent:()=>Pt,isRecoverSuccessEvent:()=>kt,isSetPositionInQueueEvent:()=>ln,isThreadArchivedSuccessPayload:()=>Lt,isThreadListFetchedPostbackData:()=>Qt,isTokenRefreshedSuccessResponse:()=>Ke,sendChatEvent:()=>Ye,sendCreateInvitationToGroupChatEvent:()=>hn,sendEmailInvitationToGroupChatEvent:()=>gn,sendJoinGroupChatEvent:()=>Tn,sendLeaveGroupChatEvent:()=>pn,splitName:()=>Pe});var e,t=r(455),n=r(441),o=r(154);!function(e){e.ACCESS_TOKEN="ACCESS_TOKEN",e.ACCESS_TOKEN_EXPIRES_IN="ACCESS_TOKEN_EXPIRES_IN",e.APP_NAME="APP_NAME",e.APP_VERSION="APP_VERSION",e.AUTHORIZATION_CODE="AUTHORIZATION_CODE",e.BRAND_ID="BRAND_ID",e.CHANNEL_ID="CHANNEL_ID",e.CUSTOMER_ID="CUSTOMER_ID",e.CUSTOMER_IMAGE="CUSTOMER_IMAGE",e.CUSTOMER_NAME="CUSTOMER_NAME",e.ENDPOINT_CHAT="ENDPOINT_CHAT",e.ENDPOINT_GATEWAY="ENDPOINT_GATEWAY",e.THREAD_DATA="THREAD_DATA";}(e||(e={}));const i=new class{constructor(){this._vars={};}set(e,t){this._vars[e]=t;}get(e,t){var n;return null!==(n=this._vars[e])&&void 0!==n?n:t}list(){return Object.keys(this._vars)}clear(){this._vars={};}},a=function(e){return null===e};function c(t){i.set(e.ACCESS_TOKEN,t.token),i.set(e.ACCESS_TOKEN_EXPIRES_IN,String(t.expiresIn));}function u(){const t=i.get(e.ACCESS_TOKEN,null),n=i.get(e.ACCESS_TOKEN_EXPIRES_IN,null);return a(t)||a(n)?null:{token:t,expiresIn:Number(n)}}class l extends Error{constructor(e,t){super(),this.name="ChatSDKError",this.message=`[ChatSDKError]: ${this._getErrorMessage(e)}`,this.data=t;}_getErrorMessage(e){return e instanceof Error?e.message:"string"==typeof e?e:JSON.stringify(e)}}class d extends l{constructor(e,t){super(e,t),void 0!==t&&(this.message=`${e} because of (${t.errorMessage})`);}}var E=r(459);function h(e){return {visitor:{id:e}}}var _=Object.prototype;const v=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||_)},T=(f=Object.keys,p=Object,function(e){return f(p(e))});var f,p,m=Object.prototype.hasOwnProperty;const C="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal;var g="object"==typeof self&&self&&self.Object===Object&&self;const A=C||g||Function("return this")(),O=A.Symbol;var y=Object.prototype,S=y.hasOwnProperty,b=y.toString,N=O?O.toStringTag:void 0;var I=Object.prototype.toString;var w=O?O.toStringTag:void 0;const R=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":w&&w in Object(e)?function(e){var t=S.call(e,N),n=e[N];try{e[N]=void 0;var o=!0;}catch(e){}var r=b.call(e);return o&&(t?e[N]=n:delete e[N]),r}(e):function(e){return I.call(e)}(e)},D=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},P=function(e){if(!D(e))return !1;var t=R(e);return "[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},U=A["__core-js_shared__"];var M,G=(M=/[^.]+$/.exec(U&&U.keys&&U.keys.IE_PROTO||""))?"Symbol(src)_1."+M:"";var j=Function.prototype.toString;const k=function(e){if(null!=e){try{return j.call(e)}catch(e){}try{return e+""}catch(e){}}return ""};var L=/^\[object .+?Constructor\]$/,H=Function.prototype,x=Object.prototype,F=H.toString,B=x.hasOwnProperty,V=RegExp("^"+F.call(B).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const Y=function(e){return !(!D(e)||function(e){return !!G&&G in e}(e))&&(P(e)?V:L).test(k(e))},W=function(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Y(n)?n:void 0},Q=W(A,"DataView"),z=W(A,"Map"),$=W(A,"Promise"),K=W(A,"Set"),J=W(A,"WeakMap");var X="[object Map]",Z="[object Promise]",q="[object Set]",ee="[object WeakMap]",te="[object DataView]",ne=k(Q),oe=k(z),re=k($),se=k(K),ie=k(J),ae=R;(Q&&ae(new Q(new ArrayBuffer(1)))!=te||z&&ae(new z)!=X||$&&ae($.resolve())!=Z||K&&ae(new K)!=q||J&&ae(new J)!=ee)&&(ae=function(e){var t=R(e),n="[object Object]"==t?e.constructor:void 0,o=n?k(n):"";if(o)switch(o){case ne:return te;case oe:return X;case re:return Z;case se:return q;case ie:return ee}return t});const ce=ae,ue=function(e){return null!=e&&"object"==typeof e},le=function(e){return ue(e)&&"[object Arguments]"==R(e)};var de=Object.prototype,Ee=de.hasOwnProperty,he=de.propertyIsEnumerable;const _e=le(function(){return arguments}())?le:function(e){return ue(e)&&Ee.call(e,"callee")&&!he.call(e,"callee")},ve=Array.isArray,Te=function(e){return "number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};var fe=exports&&!exports.nodeType&&exports,pe=fe&&"object"=='object'&&module&&!module.nodeType&&module,me=pe&&pe.exports===fe?A.Buffer:void 0;const Ce=(me?me.isBuffer:void 0)||function(){return !1};var ge={};ge["[object Float32Array]"]=ge["[object Float64Array]"]=ge["[object Int8Array]"]=ge["[object Int16Array]"]=ge["[object Int32Array]"]=ge["[object Uint8Array]"]=ge["[object Uint8ClampedArray]"]=ge["[object Uint16Array]"]=ge["[object Uint32Array]"]=!0,ge["[object Arguments]"]=ge["[object Array]"]=ge["[object ArrayBuffer]"]=ge["[object Boolean]"]=ge["[object DataView]"]=ge["[object Date]"]=ge["[object Error]"]=ge["[object Function]"]=ge["[object Map]"]=ge["[object Number]"]=ge["[object Object]"]=ge["[object RegExp]"]=ge["[object Set]"]=ge["[object String]"]=ge["[object WeakMap]"]=!1;var Ae=exports&&!exports.nodeType&&exports,Oe=Ae&&"object"=='object'&&module&&!module.nodeType&&module,ye=Oe&&Oe.exports===Ae&&C.process,Se=function(){try{return Oe&&Oe.require&&Oe.require("util").types||ye&&ye.binding&&ye.binding("util")}catch(e){}}(),be=Se&&Se.isTypedArray;const Ne=be?function(e){return function(t){return e(t)}}(be):function(e){return ue(e)&&Te(e.length)&&!!ge[R(e)]};var Ie=Object.prototype.hasOwnProperty;const we=function(e){if(null==e)return !0;if(function(e){return null!=e&&Te(e.length)&&!P(e)}(e)&&(ve(e)||"string"==typeof e||"function"==typeof e.splice||Ce(e)||Ne(e)||_e(e)))return !e.length;var t=ce(e);if("[object Map]"==t||"[object Set]"==t)return !e.size;if(v(e))return !function(e){if(!v(e))return T(e);var t=[];for(var n in Object(e))m.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e).length;for(var n in e)if(Ie.call(e,n))return !1;return !0},Re=new Map,De=async(e,t)=>{if(a(t))throw new l("WebSocketClient is not initialized");return we(e.eventId)&&(e.eventId=(0, E.v4)()),new Promise((n=>{Re.set(e.eventId,n),null==t||t.send(e);}))};function Pe(e){const[t,...n]=e.split(" ");return [t,n.join(" ")]}function Ue(e,t={}){for(const n of Object.keys(t))e.set(n,t[n]);}function Me(e,t=[]){for(const{ident:n,value:o}of t)e.set(n,o);}function Ge(e){return Object.fromEntries(e)}function je(e){return Array.from(e).map((([e,t])=>({ident:e,value:t})))}class ke{constructor(e,t,n,o){this._customFields=new Map,this._exists=!1,this._websocketClient=o,ke.setId(e),ke.setName(t),n&&ke.setImage(n);}static setId(t){i.set(e.CUSTOMER_ID,t);}static getId(){return i.get(e.CUSTOMER_ID,null)}static getName(){return i.get(e.CUSTOMER_NAME)}static setName(t){i.set(e.CUSTOMER_NAME,t);}static getIdOrCreateNewOne(){let e=this.getId();return e||(e=(0, E.v4)(),this.setId(e)),e}static getImage(){return i.get(e.CUSTOMER_IMAGE)}static setImage(t){i.set(e.CUSTOMER_IMAGE,t);}getId(){return ke.getIdOrCreateNewOne()}getName(){return ke.getName()}setName(e){ke.setName(e);}setImage(e){ke.setImage(e);}setExists(e){this._exists=e;}setCustomField(e,t){return this.setCustomFields({[e]:t})}setCustomFields(e){if(Ue(this._customFields,e),this._exists)return this.sendCustomFields()}getCustomFields(){return Ge(this._customFields)}setCustomFieldsFromArray(e){Me(this._customFields,e);}getCustomFieldsArray(){return je(this._customFields)}async sendCustomFields(){var e;return Ye((e=je(this._customFields),{eventType:o.YU.SEND_CONSUMER_CUSTOM_FIELDS,data:{customFields:e}}),this._websocketClient)}}function Le(e,t){const n=ke.getName(),o=ke.getImage();let r={};if("string"==typeof n&&n.length>0){const[e,t]=Pe(n);r={firstName:e,lastName:t};}return o&&(r.image=o),Object.assign({idOnExternalPlatform:ke.getIdOrCreateNewOne()},r)}const He=function(e){return null==e};function xe(){const t=parseInt(i.get(e.BRAND_ID)),n=i.get(e.CHANNEL_ID);if(He(t)||isNaN(t)||He(n))throw new l(`Cannot get BrandId and ChannelId from SDKVariableStorage \n brandId (${t}) |\n channelId (${n})`);return {brandId:t,channelId:n}}const Fe=function(e){return void 0===e};function Be(e){const{eventType:t,data:n,consumerIdentity:o=Le(),destination:r={},visitor:s={}}=e,{brandId:i,channelId:a}=xe();if(Fe(t))throw new l(`Cannot create an event payload because of missing eventType (${t})`);return {eventType:t,brand:{id:Number(i)},channel:{id:a},consumerIdentity:o,data:n,destination:r,visitor:s}}function Ve(e,t=(0, E.v4)(),o=n.p.CHAT_WINDOW_EVENT){return {action:o,eventId:t,payload:e}}async function Ye(e,t){const n=Ve(Be(e));return De(n,t)}function We(e,t){return Object.assign(Object.assign(Object.assign({},h(t)),Le()),{eventType:o.YU.RECONNECT_CONSUMER,data:{accessToken:{token:e.token}}})}let Qe=null;function ze(e,t){null!==Qe&&clearTimeout(Qe),Qe=setTimeout(t,1e3*function(e){const t=Math.round(.9*e);return t<20?20:t}(e.expiresIn));}const $e=e=>{var t;const n=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.status;return (null==e?void 0:e.type)===o.Ne.CONSUMER_AUTHORIZED&&"success"===n};function Ke(e){var t,n;return (null==e?void 0:e.type)===o.Ne.TOKEN_REFRESHED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.accessToken)||void 0===n?void 0:n.token)}var Je;!function(e){e.AU1="AU1",e.CA1="CA1",e.EU1="EU1",e.JP1="JP1",e.NA1="NA1",e.UK1="UK1",e.custom="custom";}(Je||(Je={}));var Xe=r(403);const Ze=Object.assign(Object.assign(Object.assign({},Xe.m),o.Ne),{AGENT_TYPING_STARTED:"AgentTypingStarted",AGENT_TYPING_ENDED:"AgentTypingEnded",ASSIGNED_AGENT_CHANGED:"AssignedAgentChanged",CONTACT_CREATED:"ContactCreated",CONTACT_STATUS_CHANGED:"ContactStatusChanged",CONTACT_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED:"ContactToRoutingQueueAssignmentChanged"});class qe extends CustomEvent{}class et{constructor(){this.middlewares=[];}register(e){this.middlewares.push(e);}process(e){if(He(e))return null;let t=e;for(const e of this.middlewares){if(null===t)return null;t=e(t);}return t}}const tt=EventTarget;function nt(e){return !He(null==e?void 0:e.user)}var ot=r(910),rt=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);}return n};const st={id:"",data:null,type:void 0,createdAt:new Date};function it(e){var t;if(!(e=>"eventId"in e)(e))return st;if((e=>"error"in e)(e))return {createdAt:(0, ot.Nf)(null!==(t=e.createdAt)&&void 0!==t?t:(new Date).toString()),data:null,error:e.error,id:e.eventId};const n=(e=>"eventType"in e)(e)?e.eventType:void 0;if((e=>"data"in e)(e))return {createdAt:(0, ot.Nf)(e.createdAt),context:e.context,data:e.data,id:e.eventId,type:n};if((e=>{const t=null==e?void 0:e.postback;return !1===we(t)})(e)){const{postback:{data:t,eventType:n},eventId:o}=e,r=rt(e,["postback","eventId"]);return {type:n,data:Object.assign(Object.assign({},r),t),createdAt:(0, ot.Nf)(e.createdAt),id:o}}const{eventId:o}=e,r=rt(e,["eventId"]);return Object.assign(Object.assign({data:void 0},r),{id:o,type:n,createdAt:(0, ot.Nf)(e.createdAt)})}const at={[Ze.SENDER_TYPING_STARTED]:function(e){return nt(e.data)?Object.assign(Object.assign({},e),{type:Ze.AGENT_TYPING_STARTED}):e},[Ze.SENDER_TYPING_ENDED]:function(e){return nt(e.data)?Object.assign(Object.assign({},e),{type:Ze.AGENT_TYPING_ENDED}):e},[Ze.CASE_INBOX_ASSIGNEE_CHANGED]:function(e){return Object.assign(Object.assign({},e),{type:Ze.ASSIGNED_AGENT_CHANGED})},[Ze.CASE_CREATED]:function(e){return Object.assign(Object.assign({},e),{type:Ze.CONTACT_CREATED})},[Ze.CASE_STATUS_CHANGED]:function(e){return Object.assign(Object.assign({},e),{type:Ze.CONTACT_STATUS_CHANGED})},[Ze.CASE_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED]:function(e){return Object.assign(Object.assign({},e),{type:Ze.CONTACT_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED})},[Ze.LIVECHAT_RECOVERED]:function(e){const t=e.data.contactHistory.map(it);return Object.assign(Object.assign({},e),{data:Object.assign(Object.assign({},e.data),{contactHistory:t})})},[Ze.THREAD_RECOVERED]:function(e){const t=e.data.contactHistory.map(it);return Object.assign(Object.assign({},e),{data:Object.assign(Object.assign({},e.data),{contactHistory:t})})}};function ct(e){return e.type&&void 0!==at[e.type]?at[e.type](e):e}function ut(e){const t=!1===Fe(null==e?void 0:e.id);return !1==(!1===Fe(e.error))&&t}class lt extends l{}var dt=r(115);var Et=r(893),ht=r(415);class _t extends Error{constructor(e,t=""){super(`[WebSocketClientError]: ${e}${t?` (${t})`:""}`),this.name="WebSocketClientError";}}class vt{constructor(e,t,n,o,r){this.brandId=e,this.channelId=t,this.customerId=n,this.options=o,this.onError=r,this._connection=null,this.connect();}connect(){var n,o,r,s,a,c,u,l,d,E,h,_;const v=(null===(n=this.options)||void 0===n?void 0:n.port)?`:${null===(o=this.options)||void 0===o?void 0:o.port}`:"",T=(null===(r=this.options)||void 0===r?void 0:r.host)?`${null===(s=this.options)||void 0===s?void 0:s.host}${v}`:"",f=null!==(c=null===(a=this.options)||void 0===a?void 0:a.prefix)&&void 0!==c?c:"",p=null===(l=null===(u=this.options)||void 0===u?void 0:u.forceSecureProtocol)||void 0===l||l,m=function(t,n,o,r,s){const a={brandId:o,channelId:r,consumerId:s,v:i.get(e.APP_VERSION)};return `${t}/${n}?${(0, Et.P)(a)}`}(T,f,this.brandId,this.channelId,this.customerId);this._connection=(0, ht.setupSocketConnection)(m,{startClosed:!0,forceSecureProtocol:p});const C=this._errorHandler.bind(this);null===(d=this._connection)||void 0===d||d.addEventListener(t.xT.CLOSE,C),null===(E=this._connection)||void 0===E||E.addEventListener(t.xT.ERROR,C),null===(_=null===(h=this._connection)||void 0===h?void 0:h.socket)||void 0===_||_.reconnect();}disconnect(){var e;null===(e=this._connection)||void 0===e||e.socket.close();}reconnect(){var e;null===(e=this._connection)||void 0===e||e.socket.reconnect();}send(e){var t;const n=JSON.stringify(e);null===(t=this._connection)||void 0===t||t.send(n);}on(e,t){var n;null===(n=this._connection)||void 0===n||n.addEventListener(e,t);}off(e,t){var n;null===(n=this._connection)||void 0===n||n.removeEventListener(e,t);}_errorHandler(e){const t=e.detail;let n;if(t instanceof ErrorEvent&&(n=new _t("Connection error",t.message)),t instanceof CloseEvent&&(n=new _t("Connection closed",t.reason)),void 0===n&&(n=new _t("Unknown error",t.type)),"function"!=typeof this.onError)throw n;this.onError(n);}}var Tt=r(880),ft=r(585),pt=r.n(ft),mt=r(58);const Ct=()=>navigator.language,gt=()=>Intl.DateTimeFormat().resolvedOptions().timeZone;function At(e){switch(e){case"mobile":return mt.Yi.MOBILE;case"tablet":return mt.Yi.TABLET;default:return mt.Yi.DESKTOP}}const Ot=(e={})=>{var t,n,o,r;const s=new(pt())(navigator.userAgent),{country:i="",location:a=gt(),language:c=Ct(),ip:u=null}=e;return {browser:null!==(t=s.getBrowser().name)&&void 0!==t?t:null,browserVersion:null!==(n=s.getBrowser().version)&&void 0!==n?n:null,country:i,ip:u,language:c,location:a,os:null!==(o=s.getOS().name)&&void 0!==o?o:null,osVersion:null!==(r=s.getOS().version)&&void 0!==r?r:null,deviceType:At(s.getDevice().type),applicationType:mt.vQ.BROWSER}};var yt=r(354);class St extends l{}const bt=async(t,n,o)=>{const r=await(async e=>{const t=await function(e){return new Promise(((t,n)=>{const o=new FileReader;o.onloadend=()=>{t(o);},o.onerror=e=>{var t,o;return n(null===(o=null===(t=e.target)||void 0===t?void 0:t.error)||void 0===o?void 0:o.message)},o.readAsDataURL(e);}))}(e);if(null!==t.error)throw new l(`Cannot create payload for attachment upload because of error (${t.error.message})`);if("string"!=typeof t.result)throw new l(`Cannot create payload for attachment upload because of missing:\n reader result (${t.result})`);return {url:t.result,name:e.name,mimeType:e.type}})(t),s=await async function(t,n,o){const r=i.get(e.ENDPOINT_CHAT),{url:s,name:a,mimeType:c}=o,u={content:s.split(";base64,")[1],fileName:a,mimeType:c},d=await fetch(`${r}/chat/1.0/brand/${t}/channel/${n}/attachment`,{method:"POST",body:JSON.stringify(u),headers:{"Content-Type":"application/json",[yt.GO]:i.get(e.APP_NAME)}});if(!d.ok)throw new l(`Failed to upload Attachments. Status (${d.status})`);return d.json()}(n,o,r);if(!1===Fe(null==(a=s)?void 0:a.fileUrl))return {url:s.fileUrl,friendlyName:r.name};var a;if(function(e){return !1===Fe(null==e?void 0:e.allowedFileSize)}(s))throw new St("Upload attachment failed",s);throw new l(`Unknown file upload response (${s})`)};function Nt(e){var t,n;return e.type===Ze.CONTACT_STATUS_CHANGED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.case)||void 0===n?void 0:n.id)}function It(e){var t,n;return e.type===Ze.CONTACT_CREATED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.case)||void 0===n?void 0:n.id)}function wt(e){var t,n;return e.type===Ze.CONTACT_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.case)||void 0===n?void 0:n.id)}function Rt(e){return e.type===Xe.m.CONTACT_RECIPIENTS_CHANGED}const Dt=(e,t,n,o=Ot())=>({messageContent:e,browserFingerprint:o,idOnExternalPlatform:t,thread:{idOnExternalPlatform:n},consumer:{customFields:[]},consumerContact:{customFields:[]},attachments:[]});function Pt(e){var t;return e.type===o.Ne.MORE_MESSAGES_LOADED&&void 0!==(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.messages)}const Ut=e=>({eventType:o.YU.LOAD_MORE_MESSAGES,data:e});class Mt extends l{}class Gt extends l{}const jt=e=>e.type===o.Ne.THREAD_METADATA_LOADED&&void 0!==e.data.lastMessage,kt=e=>{const t=e.data,n=!1===Fe(t),r=!1===Fe(null==t?void 0:t.messages),s=e.type===o.Ne.THREAD_RECOVERED||e.type===o.Ne.LIVECHAT_RECOVERED,i=Fe(e.error);return n&&r&&i&&s};function Lt(e){return e.type===o.Ne.THREAD_ARCHIVED}class Ht extends l{}function xt(e){const t={eventType:o.YU.RECOVER_THREAD,data:{}};return void 0===e?t:Object.assign(Object.assign({},t),{data:{thread:{idOnExternalPlatform:e}}})}class Ft extends l{}class Bt extends l{}class Vt{constructor(e,t,n,o,r={},s=!1){this._exists=!1,this._typingTimeoutID=void 0,this._isAuthorizationEnabled=!1,this._customFields=new Map,this._typingPreviewText="",this.idOnExternalPlatform=e,this._websocketClient=t,this._messageEmitter=n,this._customer=o,this._isAuthorizationEnabled=s,Ue(this._customFields,r),this._registerEventHandlers();}async recover(){const e=await Ye(xt(this.idOnExternalPlatform),this._websocketClient);if(kt(e)){const t=e.data,{contact:n,consumerContact:o}=t,r=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);}return n}(t,["contact","consumerContact"]);return Object.assign(Object.assign({},r),{contact:null!=n?n:o})}throw new Bt("Thread recover fail",e)}async sendMessage(e){return (async(e,t)=>{const n=(r=e,{eventType:o.YU.SEND_MESSAGE,data:r});var r;const s=await Ye(n,t);if(ut(s))return s;throw new lt("Send message failed",s)})(this._mergeCustomFieldsAndAccessTokenWithMessageData(e,!1),this._websocketClient)}async sendTextMessage(e,t={}){const{messageId:n=(0, E.v4)(),browserFingerprint:o=Ot()}=t,r=function(e){return {payload:{text:e},type:dt.C.TEXT}}(e),s=Dt(r,n,this.idOnExternalPlatform,o);return this.sendMessage(s)}async sendPostbackMessage(e,t,n={}){const{messageId:o=(0, E.v4)(),browserFingerprint:r=Ot()}=n,s=function(e,t){return {payload:{text:t,postback:e},postback:e,type:dt.C.TEXT}}(e,t),i=Dt(s,o,this.idOnExternalPlatform,r);return this.sendMessage(i)}async sendOutboundMessage(e){return (async(e,t)=>{const n=(r=e,{eventType:o.YU.SEND_OUTBOUND,data:r});var r;const s=await Ye(n,t);if(ut(s))return s;throw new lt("Send Outbound message failed",s)})(this._mergeCustomFieldsAndAccessTokenWithMessageData(e,!0),this._websocketClient)}async loadMoreMessages(){var t;const{scrollToken:n,oldestMessageDatetime:o}=null!==(t=JSON.parse(i.get(e.THREAD_DATA,"{}")))&&void 0!==t?t:{};if(we(n))return null;const r={scrollToken:n,oldestMessageDatetime:o,thread:{idOnExternalPlatform:this.idOnExternalPlatform}},s=await Ye(Ut(r),this._websocketClient);if(Pt(s))return s;throw new Ht("Load more messages failed",s)}async lastMessageSeen(){var e;return Ye((e=this.idOnExternalPlatform,{eventType:o.YU.MESSAGE_SEEN,data:{thread:{idOnExternalPlatform:e}}}),this._websocketClient)}async sendAttachments(e,t={}){if(Fe(e)||0===e.length)throw new l("FileList must be provided to sendAttachment method");const n=await(async(e,t,n={})=>{const{brandId:o,channelId:r}=xe();try{const s=await Promise.all(Array.from(e).map((async e=>bt(e,o,r)))),{messageId:i=(0,E.v4)(),browserFingerprint:a=Ot()}=n;return {messageContent:{type:dt.C.TEXT,payload:{text:""}},attachments:s,browserFingerprint:a,thread:{idOnExternalPlatform:t},idOnExternalPlatform:i,consumer:{customFields:[]},consumerContact:{customFields:[]}}}catch(e){if(e instanceof St)throw e;if(e instanceof Error)throw new l(`Send attachment failed because of (${e.message})`);throw new l("Unknown error during file upload")}})(e,this.idOnExternalPlatform,t);return this.sendMessage(n)}keystroke(e=1e3,t){var n;this._typingTimeoutID||Ye((n=this.idOnExternalPlatform,{eventType:o.YU.SENDER_TYPING_STARTED,data:{thread:{idOnExternalPlatform:n}}}),this._websocketClient),clearTimeout(this._typingTimeoutID),this._typingTimeoutID=setTimeout((()=>{this._stopTypingCallback(t);}),e);}stopTyping(){this._stopTypingCallback();}_stopTypingCallback(e){var t;clearTimeout(this._typingTimeoutID),this._typingTimeoutID=void 0,Ye((t=this.idOnExternalPlatform,{eventType:o.YU.SENDER_TYPING_ENDED,data:{thread:{idOnExternalPlatform:t}}}),this._websocketClient),"function"==typeof e&&e();}keystrokeForPreview(e,t=1250){this._typingPreviewText=e,this._typingForPreviewTimeoutID||(this._typingForPreviewTimeoutID=setTimeout((()=>{this.stopTypingForPreview();}),t));}stopTypingForPreview(e=!0){clearTimeout(this._typingForPreviewTimeoutID),this._typingForPreviewTimeoutID=void 0;const t=this._typingPreviewText;this._typingPreviewText="",!1!==e&&this.sendMessagePreview(t);}async getMetadata(){const e=await Ye((t=this.idOnExternalPlatform,{eventType:o.YU.LOAD_THREAD_METADATA,data:{thread:{idOnExternalPlatform:t}}}),this._websocketClient);var t;if(jt(e))return e;throw new Gt("Get metadata failed",e)}onThreadEvent(e,t){const n=((e,t)=>n=>{(e=>{var t,n,o,r,s,i,a;const c=e;return null!==(i=null!==(r=null!==(n=null===(t=null==c?void 0:c.thread)||void 0===t?void 0:t.idOnExternalPlatform)&&void 0!==n?n:null===(o=null==c?void 0:c.case)||void 0===o?void 0:o.threadIdOnExternalPlatform)&&void 0!==r?r:null===(s=null==c?void 0:c.message)||void 0===s?void 0:s.threadIdOnExternalPlatform)&&void 0!==i?i:null===(a=null==c?void 0:c.messagePreview)||void 0===a?void 0:a.threadIdOnExternalPlatform})(n.detail.data)===e&&t(n);})(this.idOnExternalPlatform,t);return this._messageEmitter.addEventListener(e,n),()=>{this._messageEmitter.removeEventListener(e,n);}}async sendCustomFields(){var e,t;return Ye((e=je(this._customFields),t=this.idOnExternalPlatform,{eventType:o.YU.SET_CONSUMER_CONTACT_CUSTOM_FIELD,data:{customFields:e,thread:{idOnExternalPlatform:t}}}),this._websocketClient)}async setCustomFields(e){Ue(this._customFields,e),!1!==this._exists&&await this.sendCustomFields();}setCustomField(e,t){return this.setCustomFields({[e]:t})}async archive(){const e=await Ye((t=this.idOnExternalPlatform,{eventType:o.YU.ARCHIVE_THREAD,data:{thread:{idOnExternalPlatform:t}}}),this._websocketClient);var t;if(Lt(e))return !0;throw new Mt("Archive Thread failed",e)}async setName(e){const t=(n=this.idOnExternalPlatform,r=e,{eventType:o.YU.UPDATE_THREAD,data:{thread:{idOnExternalPlatform:n,threadName:r}}});var n,r;const s=await Ye(t,this._websocketClient);if(function(e){return Fe(e.error)}(s))return !0;throw new Ft("Set Thread name failed",s)}async sendMessagePreview(e){const t=((e,t)=>({eventType:o.YU.SEND_MESSAGE_PREVIEW,data:{thread:{idOnExternalPlatform:e},messageContent:{payload:{text:t},type:dt.C.TEXT}}}))(this.idOnExternalPlatform,e);await Ye(t,this._websocketClient);}async sendTranscript(e,t){const n=((e,t)=>({eventType:o.YU.SEND_TRANSCRIPT,data:{consumerContact:{id:e},consumerRecipients:[{idOnExternalPlatform:t}]}}))(e,t);return Ye(n,this._websocketClient)}_setThreadAndCustomerExists(){var e;this._exists=!0,null===(e=this._customer)||void 0===e||e.setExists(!0);}_clearCustomFieldsOnContactStatusChangedToClosed(e){const t=e.detail;Nt(t)&&t.data.case.status===Tt.P.CLOSED&&this._customFields.clear();}_mergeCustomFieldsAndAccessTokenWithMessageData(e,t){var n,o,r,s,i,a;let c;const l=null!==(n=this._isAuthorizationEnabled&&u())&&void 0!==n&&n;!1!==l&&(c={token:l.token}),Me(this._customFields,e.consumerContact.customFields);const d={customFields:je(this._customFields)};let E;return t||(null===(o=this._customer)||void 0===o||o.setCustomFieldsFromArray(null!==(s=null===(r=e.consumer)||void 0===r?void 0:r.customFields)&&void 0!==s?s:[]),E={customFields:null!==(a=null===(i=this._customer)||void 0===i?void 0:i.getCustomFieldsArray())&&void 0!==a?a:[]}),Object.assign(Object.assign({},e),{accessToken:c,consumer:E,consumerContact:d})}_registerEventHandlers(){this.onThreadEvent(Ze.CASE_CREATED,(()=>this._setThreadAndCustomerExists())),this.onThreadEvent(Ze.CONTACT_CREATED,(()=>this._setThreadAndCustomerExists())),this.onThreadEvent(Ze.THREAD_RECOVERED,(()=>this._setThreadAndCustomerExists())),this.onThreadEvent(Ze.CONTACT_STATUS_CHANGED,(e=>this._clearCustomFieldsOnContactStatusChangedToClosed(e)));}}function Yt(e){const t={eventType:o.YU.RECOVER_LIVECHAT,data:{}};return void 0===e?t:Object.assign(Object.assign({},t),{data:{thread:{idOnExternalPlatform:e}}})}class Wt extends Vt{constructor(e,t,n,o,r={},s=!1){super(e,t,n,o,r,s),this._isInitialized=!1,this._canSendMessage=!0,this._registerLivechatEventHandlers();}async recover(){const e=await Ye(Yt(this.idOnExternalPlatform),this._websocketClient);if(kt(e)){const t=e.data,{contact:n,consumerContact:o}=t,r=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);}return n}(t,["contact","consumerContact"]);return Object.assign(Object.assign({},r),{contact:null!=n?n:o})}throw new Bt("Thread recover fail",e)}async sendMessage(e){if(!1===this._canSendMessage)throw new l("Cannot send more messages to Contact");return super.sendMessage(e)}async startChat(e="Begin conversation"){if(this._isInitialized)throw new l("Chat is already initialized");try{const t=await this.sendTextMessage(e);return this._isInitialized=!0,t}catch(e){if(e instanceof Error)throw new l(`Sending initial message failed because of (${e.message})`);return}}async endChat(){const t=i.get(e.THREAD_DATA,"{}"),n=JSON.parse(t),r=null==n?void 0:n.contactId;if(Fe(r))throw new l("Cannot end Chat because of missing ContactId in the storage");await Ye(function(e,t){return {eventType:o.YU.END_CONTACT,data:{thread:{idOnExternalPlatform:e},contact:{id:t}}}}(this.idOnExternalPlatform,r),this._websocketClient);}async loadMoreMessages(){var t;const{scrollToken:n,oldestMessageDatetime:o,contactId:r}=null!==(t=JSON.parse(i.get(e.THREAD_DATA,"{}")))&&void 0!==t?t:{};if(we(n)||we(r))return null;const s={scrollToken:n,oldestMessageDatetime:o,thread:{idOnExternalPlatform:this.idOnExternalPlatform},contact:{id:r}},a=await Ye(Ut(s),this._websocketClient);if(Pt(a))return a;throw new Ht("Load more messages failed",a)}_registerLivechatEventHandlers(){this.onThreadEvent(Ze.LIVECHAT_RECOVERED,(e=>{kt(e.detail)&&this._setThreadAndCustomerExists();}));}}const Qt=e=>!a(e)&&"threads"in e;function zt(t){const n=i.get(e.THREAD_DATA,"{}"),o=JSON.parse(n)||{};i.set(e.THREAD_DATA,JSON.stringify(Object.assign(Object.assign({},o),{contactId:t})));}function $t(e){var t,n,o;return It(e)&&zt(e.data.case.id),kt(e)&&zt(null!==(n=null===(t=e.data.consumerContact)||void 0===t?void 0:t.caseId)&&void 0!==n?n:null===(o=e.data.contact)||void 0===o?void 0:o.id),e}function Kt(t){var n;const o=null===(a=t.messages,n=(c=null==a?0:a.length)?a[c-1]:void 0)||void 0===n?void 0:n.createdAt,r=i.get(e.THREAD_DATA,"{}"),s=JSON.parse(r)||{};var a,c;i.set(e.THREAD_DATA,JSON.stringify(Object.assign(Object.assign({},s),{scrollToken:t.scrollToken,oldestMessageDatetime:Fe(o)?"":o})));}function Jt(e){if(kt(e)){const{messages:t,messagesScrollToken:n}=e.data;Kt({messages:t,scrollToken:n});}if(Pt(e)){const{scrollToken:t,messages:n}=e.data;Kt({scrollToken:t,messages:n});}return e}class Xt extends Error{constructor(e="Aborted"){super(e),this.name="AbortError";}}class Zt extends Promise{constructor(e){const t=new AbortController,n=t.signal;super(((t,o)=>{n.addEventListener("abort",(()=>{o(new Xt(this.abortReason));})),null==e||e(t,o,n);})),this.abort=e=>{this._abortReason=null!=e?e:"Aborted",t.abort();};}get abortReason(){return this._abortReason}}Zt.from=e=>e instanceof Zt?e:new Zt(((t,n)=>{e.then(t).catch(n);}));class qt{constructor(t){var n,r;if(this.isLivechat=!1,this.channelId="",this.websocketClient=null,this.customer=null,this._incomingChatEventMiddleware=new et,this.isAuthorizationEnabled=!1,this._threadCache=new Map,this._contactCustomFieldsQueue=new Map,this._sendRefreshTokenEvent=async()=>{const e=u();if(a(e))return;const t=await Ye((n=e.token,{eventType:o.YU.REFRESH_TOKEN,data:{accessToken:{token:n}}}),this.websocketClient);var n;if(Ke(t))return c(t.data.accessToken),void ze(t.data.accessToken,this._sendRefreshTokenEvent);throw new d("An error occurred while refreshing the access token",t.error)},void 0===t)throw new l("No options was provided for initialization of ChatSdk");i.set(e.AUTHORIZATION_CODE,t.authorizationCode),i.set(e.BRAND_ID,`${t.brandId}`),i.set(e.CHANNEL_ID,t.channelId),i.set(e.APP_NAME,null!==(n=t.appName)&&void 0!==n?n:"chat-web-sdk"),i.set(e.APP_VERSION,`${null!==(r=t.appVersion)&&void 0!==r?r:0}`);const{brandId:s,channelId:E}=xe();this.onError=t.onError,this.onRawEvent=t.onRawEvent,this._incomingChatEventMiddleware.register(ct),this._incomingChatEventMiddleware.register(Jt),this._incomingChatEventMiddleware.register($t),this._messageEmitter=new tt;try{if(isNaN(s))throw new Error("Missing BrandID");if(void 0===E)throw new Error("Missing ChannelId");if(void 0===t.customerId)throw new Error("Missing CustomerId");this._initEnvironment(t),this._initWS(s,E,t.customerId),this.customer=new ke(t.customerId,t.customerName,t.customerImage,this.websocketClient),this.channelId=E;}catch(e){this.onErrorHandler(e);}}onErrorHandler(e){if("function"!=typeof this.onError)throw new l(e);this.onError(new l(e));}async authorize(t,r){var s,a,_,v,T,f,p;const m=u();if(null!==m)try{const e=await async function(e,t,n,o){const r=We(n,o),s=await Ye(r,e);if(void 0!==s.error)throw new d("Authorization reconnect failed",s.error);return ze(n,t),{reconnected:!0}}(this.websocketClient,this._sendRefreshTokenEvent,m,r);return e}catch(e){}const C=function(e,t=(0, E.v4)()){return Object.assign({eventType:o.YU.AUTHORIZE_CUSTOMER,data:{authorization:{authorizationCode:e}}},h(t))}(null!=t?t:i.get(e.AUTHORIZATION_CODE,null),r),g=Ve(Be(C),(0, E.v4)(),n.p.REGISTER),A=await De(g,this.websocketClient);if(!$e(A))throw null===(s=this.websocketClient)||void 0===s||s.disconnect(),new d("Authorization failed",A.error);const{consumerIdentity:O,customer:y,channel:S,contact:b}=A.data,N=null==O?void 0:O.idOnExternalPlatform;if(He(I=N)||""===I)throw null===(a=this.websocketClient)||void 0===a||a.disconnect(),new l("Invalid customer identity");var I;ke.setId(N),void 0===O.firstName&&void 0===O.lastName||ke.setName(`${O.firstName} ${O.lastName}`);const w=O.image;return void 0!==w&&ke.setImage(w),(null==y?void 0:y.customFields)&&(null===(_=this.customer)||void 0===_||_.setCustomFieldsFromArray(y.customFields)),(null==b?void 0:b.customFields)&&Me(this._contactCustomFieldsQueue,b.customFields),this.isLivechat=null!==(T=null===(v=null==S?void 0:S.settings)||void 0===v?void 0:v.isLivechat)&&void 0!==T&&T,this.isAuthorizationEnabled=null!==(f=null==S?void 0:S.settings.isAuthorizationEnabled)&&void 0!==f&&f,void 0!==(null===(p=A.data.accessToken)||void 0===p?void 0:p.token)&&(c(A.data.accessToken),ze(A.data.accessToken,this._sendRefreshTokenEvent)),A.data}async generateAuthorizationToken(e,t){const n=await Ye(function(e,t){return {eventType:o.YU.GENERATE_AUTHORIZATION_TOKEN,data:{thread:{idOnExternalPlatform:e},url:t}}}(e,t),this.websocketClient);if(!("authorizationToken"in n.data))throw new l("Invalid response from generate authorization token (generateAuthorizationToken)");const{authorizationToken:r}=n.data;return r}onChatEvent(e,t){return this._messageEmitter.addEventListener(e,t),()=>{this._messageEmitter.removeEventListener(e,t);}}getCustomer(){return this.customer}getThread(e){if(a(this.websocketClient))throw new l("Cannot get thread because websocket is disconnected");if(He(e))throw new l("Cannot get thread because id is undefined");const t=this._threadCache.get(e);if(!Fe(t))return t;if(this.isLivechat){const t=new Wt(e,this.websocketClient,this._messageEmitter,this.customer,this._getContactCustomFieldsFromQueue(),this.isAuthorizationEnabled);return this._threadCache.set(e,t),t}const n=new Vt(e,this.websocketClient,this._messageEmitter,this.customer,this._getContactCustomFieldsFromQueue(),this.isAuthorizationEnabled);return this._threadCache.set(e,n),n}async getThreadList(){if(a(this.websocketClient))throw new l("Cannot get thread list because websocket is disconnected");const e={eventType:o.YU.FETCH_THREAD_LIST,data:{}},t=await Ye(e,this.websocketClient);if(!Qt(t.data))throw new l("Invalid response from fetch thread list (getThreadList)");return t.data.threads}getWebsocketClient(){return this.websocketClient}async sendOfflineMessage(e){return (async(e,t)=>{const n=(e=>{const[t,...n]=e.name.split(" ").reverse(),r=n.reverse().join(" "),s={idOnExternalPlatform:e.email,firstName:r,lastName:t},i={messageContent:{type:dt.C.TEXT,payload:{text:e.message}}};return {eventType:o.YU.SEND_OFFLINE_MESSAGE,consumerIdentity:s,data:i}})(e),r=await Ye(n,t);if(ut(r))return r;throw new lt("Send offline message failed",r)})(e,this.websocketClient)}recoverThreadData(e){return new Zt((async(t,n)=>{const o=xt(e),r=await Ye(o,this.websocketClient);kt(r)?t(r):n(new l("Invalid response from recover livechat thread"));}))}recoverLivechatThreadData(e){return new Zt((async(t,n)=>{const o=Yt(e),r=await Ye(o,this.websocketClient);kt(r)?t(r):n(new l("Invalid response from recover livechat thread"));}))}_getContactCustomFieldsFromQueue(){if(this._contactCustomFieldsQueue.size>0){const e=Ge(this._contactCustomFieldsQueue);return this._contactCustomFieldsQueue.clear(),e}return {}}_initEnvironment(t){var n,o;if(t.environment===Je.custom){if(we(t.customEnvironment))throw new l('customEnvironment must be provided when environment is set to "custom"');return i.set(e.ENDPOINT_GATEWAY,null===(n=t.customEnvironment)||void 0===n?void 0:n.gateway),void i.set(e.ENDPOINT_CHAT,null===(o=t.customEnvironment)||void 0===o?void 0:o.chat)}const{gateway:r,chat:s}=function(e){const t="{ENV}",n="https://channels-de-{ENV}.niceincontact.com",o="wss://chat-gateway-de-{ENV}.niceincontact.com";switch(e){case Je.AU1:return {chat:n.replace(t,"au1"),name:"Australia",gateway:o.replace(t,"au1")};case Je.CA1:return {chat:n.replace(t,"ca1"),name:"Canada",gateway:o.replace(t,"ca1")};case Je.EU1:return {chat:n.replace(t,"eu1"),name:"Europe",gateway:o.replace(t,"eu1")};case Je.JP1:return {chat:n.replace(t,"jp1"),name:"Japan",gateway:o.replace(t,"jp1")};case Je.NA1:return {chat:n.replace(t,"na1"),name:"North America",gateway:o.replace(t,"na1")};case Je.UK1:return {chat:n.replace(t,"uk1"),name:"United Kingdom",gateway:o.replace(t,"uk1")};case Je.custom:return {chat:"",name:"Custom",gateway:""};default:throw new l(`Unknown environment: ${e}`)}}(t.environment);i.set(e.ENDPOINT_GATEWAY,r),i.set(e.ENDPOINT_CHAT,s);}_initWS(n,o,r){const s=i.get(e.ENDPOINT_GATEWAY);!function(e){if(null==e)throw Error(`Expected non-nullish value, got ${e}`)}(s);const a=new URL(s),c=a.protocol,u={host:a.hostname,port:a.port,prefix:a.pathname.substring(1),forceSecureProtocol:"wss:"===c};this.websocketClient=new vt(n,o,r,u,this.onError),this.websocketClient.on(t.xT.MESSAGE,(async e=>{try{"function"==typeof this.onRawEvent&&this.onRawEvent(e);const t=await(async e=>{if(He(e))return null;if(e.type!==Xe.m.EVENT_IN_S3)return e;const t=e.data.s3Object.url,n=await fetch(t);if(n.ok)return it(await n.json());throw new l("Failed to fetch S3 event data")})((e=>{const t=null==e?void 0:e.detail;if(!t)return;let n;try{n=JSON.parse(t.data);}catch(e){return}return it(n)})(e)),n=this._incomingChatEventMiddleware.process(t);if(!He(n)){const{type:e}=n;(e=>{const{id:t}=e;if(Re.has(t)){const n=Re.get(t);"function"==typeof n&&n(e),Re.delete(t);}})(n),this._messageEmitter.dispatchEvent(new qe(null!=e?e:"",{detail:n}));}}catch(e){this.onErrorHandler(e);}}));}}function en(e){var t,n;return e.type===Ze.ASSIGNED_AGENT_CHANGED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.case)||void 0===n?void 0:n.id)}function tn(e){var t,n;return e.type===Ze.AGENT_TYPING_STARTED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.thread)||void 0===n?void 0:n.idOnExternalPlatform)}function nn(e){var t,n;return e.type===Ze.AGENT_TYPING_ENDED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.thread)||void 0===n?void 0:n.idOnExternalPlatform)}var on=r(510);const rn=e=>{var t,n,o,r,s,i;return e.direction===on.T.INBOUND?null!==(n=null===(t=e.authorEndUserIdentity)||void 0===t?void 0:t.fullName)&&void 0!==n?n:"":`${null!==(r=null===(o=e.authorUser)||void 0===o?void 0:o.firstName)&&void 0!==r?r:""} ${null!==(i=null===(s=e.authorUser)||void 0===s?void 0:s.surname)&&void 0!==i?i:""}`.trim()};function sn(e){const t=!1===Fe(e.id),n=!1===Fe(e.direction),o=!1===Fe(e.messageContent);return t&&n&&o}function an(e){return e.type===Xe.m.MESSAGE_CREATED}function cn(e){return e.type===Xe.m.MESSAGE_SENT}function un(e){return e.type===Xe.m.MESSAGE_READ_CHANGED}const ln=e=>{const t=e;return Number.isInteger(null==t?void 0:t.data.positionInQueue)&&!1===we(null==t?void 0:t.id)&&(null==t?void 0:t.type)===o.Ne.SET_POSITION_IN_QUEUE};class dn extends l{}function En(e){return {eventType:o.YU.CREATE_GROUP_CHAT_INVITE,data:{contact:{id:e}}}}async function hn(e,t){const n=await Ye(e,t);if(function(e){return e.type===Ze.GROUP_CHAT_INVITE_CREATED}(n))return n;throw new dn("Create invitation failed",n)}class _n extends l{}function vn(e){return {eventType:o.YU.JOIN_GROUP_CHAT,data:{invitation:{code:e}}}}async function Tn(e,t){const n=await Ye(e,t);if(function(e){return e.type===Ze.GROUP_CHAT_JOINED}(n))return n;throw new _n("Join Group chat failed",n)}function fn(e){return {eventType:o.YU.LEAVE_GROUP_CHAT,data:{contact:{id:e}}}}async function pn(e,t){return Ye(e,t)}class mn extends l{}function Cn(e,t,n){return {eventType:o.YU.SEND_EMAIL_INVITE_TO_GROUP_CHAT,data:{contact:{id:e},invitation:{code:t},recipients:[{idOnExternalPlatform:n}]}}}async function gn(e,t){const n=await Ye(e,t);if(function(e){return e.type===Ze.GROUP_CHAT_INVITE_SENT}(n))return n;throw new mn("Send Email Invitation failed",n)}function An(e){return "object"==typeof e&&null!==e&&"reconnected"in e&&!0===e.reconnected}const On=qt;})(),s})()));
1584
- } (niceCxoneChatWebSdk, niceCxoneChatWebSdk.exports));
1585
-
1586
- var niceCxoneChatWebSdkExports = niceCxoneChatWebSdk.exports;
1587
- var ChatSdk = /*@__PURE__*/getDefaultExportFromCjs(niceCxoneChatWebSdkExports);
1588
-
1589
- /**
1590
- *
1591
- * IBM Confidential
1592
- *
1593
- * (C) Copyright IBM Corp. 2023
1594
- *
1595
- * The source code for this program is not published or otherwise
1596
- * divested of its trade secrets, irrespective of what has been
1597
- * deposited with the U. S. Copyright Office
1598
- *
1599
- * US Government Users Restricted Rights - Use, duplication or
1600
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
1601
- *
1602
- */
1603
- function isUploadFailResponse(data) {
1604
- return Boolean(data.allowedFileSize && data.allowedFileTypes);
1605
- }
1606
-
1607
- /**
1608
- *
1609
- * IBM Confidential
1610
- *
1611
- * (C) Copyright IBM Corp. 2023
1612
- *
1613
- * The source code for this program is not published or otherwise
1614
- * divested of its trade secrets, irrespective of what has been
1615
- * deposited with the U. S. Copyright Office
1616
- *
1617
- * US Government Users Restricted Rights - Use, duplication or
1618
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
1619
- *
1620
- */
1621
- /**
1622
- * This service desk integration is an integration to the Nice CXone contact center using their Digital First
1623
- * Omnichannel (DFO) functionality.
1624
- *
1625
- * @see https://help.nice-incontact.com/content/acd/digital/chatsdk/chatwebsdk.htm for their SDK documentation.
1626
- * @see https://github.com/nice-devone/nice-cxone-chat-web-sdk for the SDK repo (distribution code only, no source).
1627
- * @see https://github.com/nice-devone/nice-cxone-chat-web-sample for a working sample implementation.
1628
- * @see https://help.nice-incontact.com/content/acd/digital/chat/setuplivechat.htm for information on how to set up
1629
- * a live chat channel.
1630
- */
1631
- const PREFIX = '[NiceDFOServiceDesk]';
1632
- // The amount of time to wait for steps in the initialization process to complete before timing out.
1633
- const INIT_TIMEOUT_MS = 10 * 1000;
1634
- class NiceDFOServiceDesk extends ServiceDeskImpl {
1635
- constructor() {
1636
- super(...arguments);
1637
- /**
1638
- * Indicates if any agents are available.
1639
- */
1640
- this.isChannelOnline = false;
1641
- // Old code to support debugging.
1642
- // addEvents() {
1643
- // this.addChatEvent(ChatEvent.AGENT_TYPING_STARTED);
1644
- // this.addChatEvent(ChatEvent.AGENT_TYPING_ENDED);
1645
- // this.addChatEvent(ChatEvent.ASSIGNED_AGENT_CHANGED);
1646
- // this.addChatEvent(ChatEvent.CONTACT_CREATED);
1647
- // this.addChatEvent(ChatEvent.CONTACT_STATUS_CHANGED);
1648
- // this.addChatEvent(ChatEvent.CONTACT_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED);
1649
- // this.addChatEvent(ChatEvent.LIVECHAT_RECOVERED);
1650
- // this.addChatEvent(ChatEvent.MORE_MESSAGES_LOADED);
1651
- // this.addChatEvent(ChatEvent.OFFLINE_MESSAGE_SENT);
1652
- // this.addChatEvent(ChatEvent.THREAD_LIST_FETCHED);
1653
- // this.addChatEvent(ChatEvent.THREAD_RECOVERED);
1654
- // this.addChatEvent(ChatEvent.TRANSCRIPT_SENT);
1655
- // this.addChatEvent(ChatEvent.CONSUMER_AUTHORIZED);
1656
- // this.addChatEvent(ChatEvent.THREAD_METADATA_LOADED);
1657
- // this.addChatEvent(ChatEvent.SET_POSITION_IN_QUEUE);
1658
- // this.addChatEvent(ChatEvent.GROUP_CHAT_INVITE_CREATED);
1659
- // this.addChatEvent(ChatEvent.GROUP_CHAT_INVITE_SENT);
1660
- // this.addChatEvent(ChatEvent.GROUP_CHAT_JOINED);
1661
- // this.addChatEvent(ChatEvent.TOKEN_REFRESHED);
1662
- // this.addChatEvent(ChatEvent.AUTHORIZATION_TOKEN_GENERATED);
1663
- // this.addChatEvent(ChatEvent.THREAD_ARCHIVED);
1664
- // this.addChatEvent(ChatEvent.AUTHORIZE_CONSUMER);
1665
- // this.addChatEvent(ChatEvent.CASE_CREATED);
1666
- // this.addChatEvent(ChatEvent.CASE_INBOX_ASSIGNEE_CHANGED);
1667
- // this.addChatEvent(ChatEvent.CASE_STATUS_CHANGED);
1668
- // this.addChatEvent(ChatEvent.CASE_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED);
1669
- // this.addChatEvent(ChatEvent.CONTACT_PREFERRED_USER_CHANGED);
1670
- // this.addChatEvent(ChatEvent.CONTACT_SYNC);
1671
- // this.addChatEvent(ChatEvent.CHANNEL_CREATED);
1672
- // this.addChatEvent(ChatEvent.CHANNEL_DELETED);
1673
- // this.addChatEvent(ChatEvent.CHANNEL_UPDATED);
1674
- // this.addChatEvent(ChatEvent.MESSAGE_ADDED_INTO_CASE);
1675
- // this.addChatEvent(ChatEvent.MESSAGE_CREATED);
1676
- // this.addChatEvent(ChatEvent.MESSAGE_DELIVERED_TO_END_USER);
1677
- // this.addChatEvent(ChatEvent.MESSAGE_DELIVERED_TO_USER);
1678
- // this.addChatEvent(ChatEvent.MESSAGE_NOTE_CREATED);
1679
- // this.addChatEvent(ChatEvent.MESSAGE_NOTE_UPDATED);
1680
- // this.addChatEvent(ChatEvent.MESSAGE_NOTE_DELETED);
1681
- // this.addChatEvent(ChatEvent.MESSAGE_READ_CHANGED);
1682
- // this.addChatEvent(ChatEvent.MESSAGE_SEEN_BY_END_USER);
1683
- // this.addChatEvent(ChatEvent.MESSAGE_SEEN_BY_USER);
1684
- // this.addChatEvent(ChatEvent.MESSAGE_UPDATED);
1685
- // this.addChatEvent(ChatEvent.PAGE_VIEW_CREATED);
1686
- // this.addChatEvent(ChatEvent.ROUTING_QUEUE_CREATED);
1687
- // this.addChatEvent(ChatEvent.ROUTING_QUEUE_DELETED);
1688
- // this.addChatEvent(ChatEvent.ROUTING_QUEUE_UPDATED);
1689
- // this.addChatEvent(ChatEvent.SUBQUEUE_ASSIGNED_TO_ROUTING_QUEUE);
1690
- // this.addChatEvent(ChatEvent.SUBQUEUE_UNASSIGNED_TO_ROUTING_QUEUE);
1691
- // this.addChatEvent(ChatEvent.USER_ASSIGNED_TO_ROUTING_QUEUE);
1692
- // this.addChatEvent(ChatEvent.USER_STATUS_CHANGED);
1693
- // this.addChatEvent(ChatEvent.USER_UNASSIGNED_FROM_ROUTING_QUEUE);
1694
- // this.addChatEvent(ChatEvent.AGENT_CONTACT_STARTED);
1695
- // this.addChatEvent(ChatEvent.AGENT_CONTACT_ENDED);
1696
- // this.addChatEvent(ChatEvent.SENDER_TYPING_STARTED);
1697
- // this.addChatEvent(ChatEvent.SENDER_TYPING_ENDED);
1698
- // this.addChatEvent(ChatEvent.FIRE_PROACTIVE);
1699
- // this.addChatEvent(ChatEvent.CONTACT_INBOX_PRE_ASSIGNEE_CHANGED);
1700
- // this.addChatEvent(ChatEvent.CONTACT_RECIPIENTS_CHANGED);
1701
- // this.addChatEvent(ChatEvent.MESSAGE_PREVIEW_CREATED);
1702
- // }
1703
- //
1704
- // addChatEvent(eventType: any) {
1705
- // this.sdk.onChatEvent(eventType, (event: any) => {
1706
- // debugLog(`${PREFIX} (All) ${eventType}`, event);
1707
- // });
1708
- // }
1709
- }
1710
- /**
1711
- * Ensures that the SDK is loaded and the user is authorized to access Nice. This will also determine if agents are
1712
- * available.
1713
- */
1714
- async ensureSDK() {
1715
- if (this.sdk) {
1716
- return;
1717
- }
1718
- if (!this.persistedState()) {
1719
- this.updatePersistedState({ customerID: null, lastAgentMessageID: null, contactID: null, threadID: null }, false);
1720
- }
1721
- else {
1722
- debugLog(`${PREFIX} Retrieved previous state`, this.persistedState());
1723
- }
1724
- const configData = this.config;
1725
- debugLog(`${PREFIX} Creating integration using config`, configData);
1726
- let { customerID } = this.persistedState();
1727
- if (!customerID) {
1728
- if (configData.useWebChatUserID === true) {
1729
- customerID = this.state.userID;
1730
- }
1731
- else if (configData.useWebChatUserID === false || this.state.userID.startsWith(ANONYMOUS_USER_ID_PREFIX)) {
1732
- customerID = uuid(UUIDType.MISCELLANEOUS);
1733
- }
1734
- else {
1735
- customerID = this.state.userID;
1736
- }
1737
- this.updatePersistedState({ customerID });
1738
- }
1739
- debugLog(`${PREFIX} Using customer ID "${customerID}"`);
1740
- const options = {
1741
- brandId: configData.brandID,
1742
- channelId: configData.channelID,
1743
- environment: configData.environment,
1744
- customerId: customerID,
1745
- };
1746
- // this.fixEnvironment(options);
1747
- // Fire an event to get an auth code for the case where authentication is enabled for the channel. These
1748
- // properties are optional if authentication is not enabled. The two properties will be filled in by any event
1749
- // handlers that are configured.
1750
- const getAuthCodeEvent = {
1751
- type: "agent:niceDFO:getAuthCode" /* BusEventType.NICE_DFO_GET_AUTH_CODE */,
1752
- authCode: null,
1753
- visitorID: null,
1754
- };
1755
- await this.eventBus.fire(getAuthCodeEvent, this.instance);
1756
- this.sdk = new ChatSdk(options);
1757
- // this.addEvents();
1758
- debugLog(`${PREFIX} Authorizing...`);
1759
- const authResponse = (await this.sdk.authorize(getAuthCodeEvent.authCode, getAuthCodeEvent.visitorID));
1760
- debugLog(`${PREFIX} Authorize complete`, authResponse);
1761
- this.isChannelOnline = authResponse.channel?.availability?.status === 'online';
1762
- this.sdk.onChatEvent(niceCxoneChatWebSdkExports.ChatEvent.SET_POSITION_IN_QUEUE, event => this.handlePositionInQueue(event));
1763
- this.sdk.onChatEvent(niceCxoneChatWebSdkExports.ChatEvent.ASSIGNED_AGENT_CHANGED, event => this.handleAgentChanged(event));
1764
- this.sdk.onChatEvent(niceCxoneChatWebSdkExports.ChatEvent.CONTACT_STATUS_CHANGED, event => this.handleContactStatusChanged(event));
1765
- this.sdk.onChatEvent(niceCxoneChatWebSdkExports.ChatEvent.CONTACT_CREATED, event => this.handleContactCreated(event));
1766
- this.callback.updateCapabilities({ allowFileUploads: true, allowMultipleFileUploads: true });
1767
- }
1768
- /**
1769
- * Attempts to recover an existing thread from a previous instance.
1770
- */
1771
- async recoverThread() {
1772
- const { threadID } = this.persistedState();
1773
- if (threadID) {
1774
- try {
1775
- debugLog(`${PREFIX} Using existing thread ${threadID}`, this.thread);
1776
- // If we had a previous thread, then use that and try to recover it.
1777
- this.thread = this.sdk.getThread(threadID);
1778
- const recovered = await resolveOrTimeout(this.thread.recover(), INIT_TIMEOUT_MS, 'recover timed out');
1779
- debugLog(`${PREFIX} Recovered thread ${threadID}`, recovered);
1780
- await this.handleRecover(recovered);
1781
- this.addThreadListeners();
1782
- return true;
1783
- }
1784
- catch (error) {
1785
- consoleError(`${PREFIX} Error getting existing thread`, error);
1786
- this.updatePersistedState({ threadID: null, contactID: null });
1787
- }
1788
- }
1789
- return false;
1790
- }
1791
- /**
1792
- * Adds the listener to the current thread.
1793
- */
1794
- addThreadListeners() {
1795
- this.thread.onThreadEvent(niceCxoneChatWebSdkExports.ChatEvent.MESSAGE_CREATED, event => this.handleMessageCreated(event));
1796
- this.thread.onThreadEvent(niceCxoneChatWebSdkExports.ChatEvent.AGENT_TYPING_STARTED, event => this.handleAgentTyping(event, true));
1797
- this.thread.onThreadEvent(niceCxoneChatWebSdkExports.ChatEvent.AGENT_TYPING_ENDED, event => this.handleAgentTyping(event, false));
1798
- }
1799
- /**
1800
- * Instructs the service desk to start a new chat. This should be called immediately after the service desk
1801
- * instance has been created. It will make the appropriate calls to the service desk and begin communicating back
1802
- * to the calling code using the callback produce to the instance. This may only be called once per instance.
1803
- */
1804
- async startChat(connectMessage, startChatOptions) {
1805
- await this.ensureSDK();
1806
- const connectItem = connectMessage.output.generic.find(isConnectToAgent);
1807
- const { preStartChatPayload } = startChatOptions;
1808
- // Create a new thread.
1809
- const threadID = uuid(UUIDType.MISCELLANEOUS);
1810
- debugLog(`${PREFIX} Creating new thread ${threadID}`);
1811
- this.thread = this.sdk.getThread(threadID);
1812
- this.addThreadListeners();
1813
- if (preStartChatPayload?.customerName) {
1814
- this.sdk.getCustomer().setName(preStartChatPayload.customerName);
1815
- }
1816
- this.newContactPromise = resolvablePromise();
1817
- // Set any custom fields from the pre-chat handler.
1818
- if (preStartChatPayload?.consumerContact?.customFields?.length) {
1819
- const customFields = {};
1820
- preStartChatPayload?.consumerContact.customFields.forEach(field => {
1821
- customFields[field.ident] = field.value;
1822
- });
1823
- this.thread.setCustomFields(customFields);
1824
- }
1825
- const messagesToAgent = getSummaryMessages(connectItem, 'Begin conversation');
1826
- await this.thread.startChat(messagesToAgent.join('\n'));
1827
- // Sending the messages above should result in a new contact being created.
1828
- const contactID = await resolveOrTimeout(this.newContactPromise, INIT_TIMEOUT_MS, 'A new chat timed out waiting for a contact to be created.');
1829
- this.updatePersistedState({ threadID, contactID });
1830
- this.newContactPromise = null;
1831
- debugLog(`${PREFIX} Started chat with contact ${contactID}`);
1832
- }
1833
- /**
1834
- * Handles a ChatEvent.MESSAGE_CREATED event from Nice.
1835
- */
1836
- async handleMessageCreated(event) {
1837
- debugLog(`${PREFIX} ${event.type}`, event);
1838
- const eventData = event.detail.data;
1839
- const { message, agentContact } = eventData;
1840
- await this.handleMessage(message, true, agentContact?.user);
1841
- }
1842
- /**
1843
- * Handles the results of a recovered thread. This will look for any undelivered messages from an agent and will
1844
- * display them to the user.
1845
- */
1846
- async handleRecover(recovered) {
1847
- const { lastAgentMessageID } = this.persistedState();
1848
- const { messages } = recovered;
1849
- debugLog(`${PREFIX} Last agent message: ${lastAgentMessageID}`);
1850
- const lastIndex = messages.findIndex((message) => message.id === lastAgentMessageID);
1851
- if (lastIndex > 0) {
1852
- // Go backwards from the last index and handle each message.
1853
- for (let index = lastIndex - 1; index >= 0; index--) {
1854
- const message = messages[index];
1855
- // eslint-disable-next-line no-await-in-loop
1856
- this.handleMessage(message, false, recovered.ownerAssignee);
1857
- }
1858
- }
1859
- }
1860
- /**
1861
- * Handles a message. This may either be a live message delivered from an agent or it may be a recovered message
1862
- * that was sent while web chat was unloaded and not previously delivered
1863
- */
1864
- async handleMessage(message, allowAgentJoined, agentInfo) {
1865
- if (message.direction === 'outbound') {
1866
- const threadID = message.threadIdOnExternalPlatform;
1867
- const currentThreadID = this.persistedState().threadID;
1868
- if (!threadID || threadID !== currentThreadID) {
1869
- debugLog(`${PREFIX} Got message for thread ${threadID} but the current thread is ${currentThreadID}.`);
1870
- return;
1871
- }
1872
- const { isConnected } = this.serviceManager.store.getState().persistedToBrowserStorage.chatState.agentState;
1873
- if (allowAgentJoined && !isConnected) {
1874
- // If we've received a message but an agent has not yet joined, then treat this as an agent joining. This
1875
- // occurs when we've recovered a previous conversation where the agent is already assigned to the contact.
1876
- await this.doAgentJoined(agentInfo);
1877
- }
1878
- const messageItems = [];
1879
- if (message.messageContent?.text) {
1880
- messageItems.push(assertType({
1881
- response_type: MessageResponseTypes.TEXT,
1882
- text: message.messageContent.text,
1883
- }));
1884
- }
1885
- if (message.attachments?.length) {
1886
- message.attachments.forEach((attachment) => {
1887
- messageItems.push(assertType({
1888
- response_type: InternalMessageResponseType.BUTTON,
1889
- kind: ButtonItemKind.LINK,
1890
- button_type: ButtonItemType.URL,
1891
- url: attachment.url,
1892
- label: attachment.friendlyName || attachment.fileName || attachment.filename,
1893
- }));
1894
- });
1895
- }
1896
- if (messageItems.length) {
1897
- const messageToUser = { id: null, output: { generic: messageItems } };
1898
- // Nice seems to send the "typing off" after a delay after the agent has sent the message which is stupid.
1899
- await this.callback.agentTyping(false);
1900
- await this.callback.sendMessageToUser(messageToUser, agentInfo?.id);
1901
- this.updatePersistedState({ lastAgentMessageID: message.id });
1902
- }
1903
- }
1904
- }
1905
- /**
1906
- * Handles a ChatEvent.AGENT_TYPING_STARTED or ChatEvent.AGENT_TYPING_ENDED event from Nice.
1907
- */
1908
- async handleAgentTyping(event, isTyping) {
1909
- debugLog(`${PREFIX} ${event.type}`, event);
1910
- await this.callback.agentTyping(isTyping);
1911
- }
1912
- /**
1913
- * Handles a ChatEvent.CONTACT_STATUS_CHANGED event from Nice.
1914
- */
1915
- async handleContactStatusChanged(event) {
1916
- debugLog(`${PREFIX} ${event.type}`, event);
1917
- const eventData = event.detail.data;
1918
- const contactID = eventData.case.id;
1919
- const currentContactID = this.persistedState().contactID;
1920
- if (!contactID || contactID !== currentContactID) {
1921
- debugLog(`${PREFIX} Got contact ${contactID} status change but the current contact is ${currentContactID}.`);
1922
- return;
1923
- }
1924
- if (eventData.case?.status === 'closed') {
1925
- debugLog(`${PREFIX} Agent closed contact ${contactID}`, event);
1926
- await this.callback.agentEndedChat();
1927
- }
1928
- }
1929
- /**
1930
- * Handles a ChatEvent.CONTACT_CREATED event from Nice.
1931
- */
1932
- async handleContactCreated(event) {
1933
- debugLog(`${PREFIX} ${event.type}`, event);
1934
- if (this.newContactPromise) {
1935
- this.newContactPromise.doResolve(event.detail.data?.case?.id);
1936
- }
1937
- else {
1938
- debugLog(`${PREFIX} Got a new contact but wasn't expecting one.`, event);
1939
- }
1940
- }
1941
- /**
1942
- * Handles a ChatEvent.ASSIGNED_AGENT_CHANGED event from Nice.
1943
- */
1944
- async handleAgentChanged(event) {
1945
- debugLog(`${PREFIX} ${event.type}`, event);
1946
- const eventData = event.detail.data;
1947
- const contactID = eventData.case.id;
1948
- const currentContactID = this.persistedState().contactID;
1949
- if (!contactID || contactID !== currentContactID) {
1950
- debugLog(`${PREFIX} Got contact ${contactID} status change but the current contact is ${currentContactID}.`);
1951
- return;
1952
- }
1953
- const { inboxAssignee, previousInboxAssignee } = eventData;
1954
- if (!inboxAssignee) {
1955
- await this.callback.agentLeftChat();
1956
- }
1957
- else {
1958
- if (previousInboxAssignee) {
1959
- await this.callback.beginTransferToAnotherAgent();
1960
- }
1961
- await this.doAgentJoined(inboxAssignee);
1962
- }
1963
- }
1964
- /**
1965
- * Handles a ChatEvent.SET_POSITION_IN_QUEUE event from Nice.
1966
- */
1967
- async handlePositionInQueue(event) {
1968
- debugLog(`${PREFIX} ${event.type}`, event);
1969
- const eventDetail = event.detail;
1970
- await this.callback.updateAgentAvailability({ position_in_queue: eventDetail.data.positionInQueue || 1 });
1971
- }
1972
- /**
1973
- * Generates an agentJoined call using the given agent information.
1974
- */
1975
- async doAgentJoined(agentInfo) {
1976
- const nickname = agentInfo?.nickname || `${agentInfo?.firstName || ''} ${agentInfo?.surname || ''}`.trim() || null;
1977
- const newAgent = {
1978
- id: agentInfo?.id,
1979
- nickname,
1980
- profile_picture_url: agentInfo?.imageUrl,
1981
- };
1982
- await this.callback.agentJoined(newAgent);
1983
- }
1984
- /**
1985
- * Tells the service desk to terminate the chat.
1986
- */
1987
- async endChat(info) {
1988
- debugLog(`${PREFIX} Ended chat`);
1989
- this.updatePersistedState({ threadID: null, contactID: null });
1990
- if (!info.endedByAgent) {
1991
- // Note: This Promise doesn't seem to ever resolve which is a bug in the Nice SDK so we're not going to await it.
1992
- // We only call this if triggered from an agent because this will cause the contact to be closed and there's a
1993
- // bug in the Nice SDK that can close the wrong contact if the user happens to have more than one open.
1994
- this.thread?.endChat();
1995
- }
1996
- this.thread = null;
1997
- }
1998
- /**
1999
- * Sends a message to the agent in the service desk.
2000
- */
2001
- async sendMessageToAgent(message, messageID, additionalData) {
2002
- // Send any message that's text.
2003
- if (message.input.text) {
2004
- const messageText = message.input.text;
2005
- try {
2006
- await this.thread.sendTextMessage(messageText);
2007
- }
2008
- catch (error) {
2009
- this.callback.setErrorStatus({ type: ErrorType.USER_MESSAGE, messageID });
2010
- consoleError(`${PREFIX} Error sending message to agent`, error);
2011
- }
2012
- }
2013
- // Send any file uploads that were included.
2014
- if (additionalData.filesToUpload.length) {
2015
- // Note, we're not waiting for the uploads to finish to complete the send request.
2016
- this.doFileUploads(additionalData.filesToUpload);
2017
- }
2018
- }
2019
- /**
2020
- * Uploads the requested files.
2021
- */
2022
- async doFileUploads(uploads) {
2023
- const transfer = new DataTransfer();
2024
- uploads.forEach(upload => transfer.items.add(upload.file));
2025
- let errorMessage;
2026
- try {
2027
- const result = await this.thread.sendAttachments(transfer.files);
2028
- debugLog(`${PREFIX} Got sendAttachments result`, result);
2029
- if (isUploadFailResponse(result)) {
2030
- // The SDK types say this is supposed to be returned from sendAttachments but in testing, it seems that it is
2031
- // thrown instead so this is here just in case.
2032
- errorMessage = this.formatUploadErrorMessage(result);
2033
- }
2034
- }
2035
- catch (error) {
2036
- consoleError(`${PREFIX} Error sending files to agent`, error);
2037
- errorMessage = this.formatUploadErrorMessage(error);
2038
- }
2039
- // The uploads either all succeed or they all fail. Only display the error message on the first file.
2040
- uploads.forEach((upload, index) => {
2041
- this.callback.setFileUploadStatus(upload.id, Boolean(errorMessage), index === 0 ? errorMessage : null);
2042
- });
2043
- }
2044
- /**
2045
- * Returns an error message suitable for reporting on a failed file upload or a generic error message if the
2046
- * necessary information is not contained in the given object.
2047
- */
2048
- formatUploadErrorMessage(error) {
2049
- if (isUploadFailResponse(error)) {
2050
- const allowedTypes = error.allowedFileTypes.map(({ mimeType }) => mimeType).join(', ');
2051
- const intl = this.instance.getIntl();
2052
- return intl.formatMessage({ id: 'serviceDesk_niceDFO_fileUploadError' }, { allowedTypes, fileSize: error.allowedFileSize });
2053
- }
2054
- return this.getIntlText('fileSharing_uploadFailed');
2055
- }
2056
- /**
2057
- * Informs the service desk that the user has read all the messages that have been sent by the service desk.
2058
- *
2059
- * @returns Returns a Promise that resolves when the service desk has successfully handled the call.
2060
- */
2061
- async userReadMessages() {
2062
- // Not supported in this integration.
2063
- }
2064
- /**
2065
- * Tells the service desk if a user has started or stopped typing.
2066
- */
2067
- async userTyping(isTyping) {
2068
- if (isTyping) {
2069
- // We need some time value here or the typing indicator immediately disappears for the agent.
2070
- this.thread?.keystroke(5000);
2071
- }
2072
- else {
2073
- this.thread?.stopTyping();
2074
- }
2075
- }
2076
- /**
2077
- * Checks if any agents are online and ready to communicate with the user.
2078
- */
2079
- async areAnyAgentsOnline(connectMessage) {
2080
- await this.ensureSDK();
2081
- return this.isChannelOnline;
2082
- }
2083
- /**
2084
- * This will be called when the service desk is first initialized and it is determined that the user was previously
2085
- * connected to an agent. This function should perform whatever steps are necessary to reconnect the user. Web chat
2086
- * will assume the user is permitted to send messages and is connected to the same agent when this function resolves.
2087
- *
2088
- * @returns true to indicate that the reconnect was successful.
2089
- */
2090
- async reconnect() {
2091
- await this.ensureSDK();
2092
- // We only allow a reconnect if we were able to recover the previous thread and we didn't create a new thread.
2093
- return this.recoverThread();
2094
- }
2095
- }
2096
-
2097
- export { NiceDFOServiceDesk };
1
+ import{c as e,g as t}from"./_commonjsHelpers.js";import{t as n,L as i,a0 as r,a2 as o,ak as s}from"./messageUtils.js";import{h as a,u as c,U as u,a7 as d,c as l,a4 as h,p as E}from"./aiChatEntry2.js";import{r as p,aL as v}from"./humanAgentUtils.js";import{A as f}from"./anonymousUserIDStorage.js";import{S as m}from"./ServiceDeskImpl.js";import"@lit/react";import"react";import"lit";import"lit/decorators.js";import"react-dom";var _,g={exports:{}},b=new Uint8Array(16);function T(){if(!_&&!(_="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return _(b)}var w=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function C(e){return"string"==typeof e&&w.test(e)}for(var y,A,S=[],O=0;O<256;++O)S.push((O+256).toString(16).substr(1));function N(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(S[e[t+0]]+S[e[t+1]]+S[e[t+2]]+S[e[t+3]]+"-"+S[e[t+4]]+S[e[t+5]]+"-"+S[e[t+6]]+S[e[t+7]]+"-"+S[e[t+8]]+S[e[t+9]]+"-"+S[e[t+10]]+S[e[t+11]]+S[e[t+12]]+S[e[t+13]]+S[e[t+14]]+S[e[t+15]]).toLowerCase();if(!C(n))throw TypeError("Stringified UUID is invalid");return n}var I=0,D=0;function R(e){if(!C(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}function k(e,t,n){function i(e,i,r,o){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof i&&(i=R(i)),16!==i.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+e.length);if(s.set(i),s.set(e,i.length),(s=n(s))[6]=15&s[6]|t,s[8]=63&s[8]|128,r){o=o||0;for(var a=0;a<16;++a)r[o+a]=s[a];return r}return N(s)}try{i.name=e}catch(e){}return i.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",i.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",i}function P(e){return 14+(e+64>>>9<<4)+1}function U(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function M(e,t,n,i,r,o){return U((s=U(U(t,e),U(i,o)))<<(a=r)|s>>>32-a,n);var s,a}function x(e,t,n,i,r,o,s){return M(t&n|~t&i,e,t,r,o,s)}function G(e,t,n,i,r,o,s){return M(t&i|n&~i,e,t,r,o,s)}function j(e,t,n,i,r,o,s){return M(t^n^i,e,t,r,o,s)}function L(e,t,n,i,r,o,s){return M(n^(t|~i),e,t,r,o,s)}var H=k("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,i="0123456789abcdef",r=0;r<n;r+=8){var o=e[r>>5]>>>r%32&255,s=parseInt(i.charAt(o>>>4&15)+i.charAt(15&o),16);t.push(s)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[P(t)-1]=t;for(var n=1732584193,i=-271733879,r=-1732584194,o=271733878,s=0;s<e.length;s+=16){var a=n,c=i,u=r,d=o;n=x(n,i,r,o,e[s],7,-680876936),o=x(o,n,i,r,e[s+1],12,-389564586),r=x(r,o,n,i,e[s+2],17,606105819),i=x(i,r,o,n,e[s+3],22,-1044525330),n=x(n,i,r,o,e[s+4],7,-176418897),o=x(o,n,i,r,e[s+5],12,1200080426),r=x(r,o,n,i,e[s+6],17,-1473231341),i=x(i,r,o,n,e[s+7],22,-45705983),n=x(n,i,r,o,e[s+8],7,1770035416),o=x(o,n,i,r,e[s+9],12,-1958414417),r=x(r,o,n,i,e[s+10],17,-42063),i=x(i,r,o,n,e[s+11],22,-1990404162),n=x(n,i,r,o,e[s+12],7,1804603682),o=x(o,n,i,r,e[s+13],12,-40341101),r=x(r,o,n,i,e[s+14],17,-1502002290),n=G(n,i=x(i,r,o,n,e[s+15],22,1236535329),r,o,e[s+1],5,-165796510),o=G(o,n,i,r,e[s+6],9,-1069501632),r=G(r,o,n,i,e[s+11],14,643717713),i=G(i,r,o,n,e[s],20,-373897302),n=G(n,i,r,o,e[s+5],5,-701558691),o=G(o,n,i,r,e[s+10],9,38016083),r=G(r,o,n,i,e[s+15],14,-660478335),i=G(i,r,o,n,e[s+4],20,-405537848),n=G(n,i,r,o,e[s+9],5,568446438),o=G(o,n,i,r,e[s+14],9,-1019803690),r=G(r,o,n,i,e[s+3],14,-187363961),i=G(i,r,o,n,e[s+8],20,1163531501),n=G(n,i,r,o,e[s+13],5,-1444681467),o=G(o,n,i,r,e[s+2],9,-51403784),r=G(r,o,n,i,e[s+7],14,1735328473),n=j(n,i=G(i,r,o,n,e[s+12],20,-1926607734),r,o,e[s+5],4,-378558),o=j(o,n,i,r,e[s+8],11,-2022574463),r=j(r,o,n,i,e[s+11],16,1839030562),i=j(i,r,o,n,e[s+14],23,-35309556),n=j(n,i,r,o,e[s+1],4,-1530992060),o=j(o,n,i,r,e[s+4],11,1272893353),r=j(r,o,n,i,e[s+7],16,-155497632),i=j(i,r,o,n,e[s+10],23,-1094730640),n=j(n,i,r,o,e[s+13],4,681279174),o=j(o,n,i,r,e[s],11,-358537222),r=j(r,o,n,i,e[s+3],16,-722521979),i=j(i,r,o,n,e[s+6],23,76029189),n=j(n,i,r,o,e[s+9],4,-640364487),o=j(o,n,i,r,e[s+12],11,-421815835),r=j(r,o,n,i,e[s+15],16,530742520),n=L(n,i=j(i,r,o,n,e[s+2],23,-995338651),r,o,e[s],6,-198630844),o=L(o,n,i,r,e[s+7],10,1126891415),r=L(r,o,n,i,e[s+14],15,-1416354905),i=L(i,r,o,n,e[s+5],21,-57434055),n=L(n,i,r,o,e[s+12],6,1700485571),o=L(o,n,i,r,e[s+3],10,-1894986606),r=L(r,o,n,i,e[s+10],15,-1051523),i=L(i,r,o,n,e[s+1],21,-2054922799),n=L(n,i,r,o,e[s+8],6,1873313359),o=L(o,n,i,r,e[s+15],10,-30611744),r=L(r,o,n,i,e[s+6],15,-1560198380),i=L(i,r,o,n,e[s+13],21,1309151649),n=L(n,i,r,o,e[s+4],6,-145523070),o=L(o,n,i,r,e[s+11],10,-1120210379),r=L(r,o,n,i,e[s+2],15,718787259),i=L(i,r,o,n,e[s+9],21,-343485551),n=U(n,a),i=U(i,c),r=U(r,u),o=U(o,d)}return[n,i,r,o]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(P(t)),i=0;i<t;i+=8)n[i>>5]|=(255&e[i/8])<<i%32;return n}(e),8*e.length))}));function F(e,t,n,i){switch(e){case 0:return t&n^~t&i;case 1:case 3:return t^n^i;case 2:return t&n^t&i^n&i}}function B(e,t){return e<<t|e>>>32-t}var V=k("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var i=unescape(encodeURIComponent(e));e=[];for(var r=0;r<i.length;++r)e.push(i.charCodeAt(r))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var o=e.length/4+2,s=Math.ceil(o/16),a=new Array(s),c=0;c<s;++c){for(var u=new Uint32Array(16),d=0;d<16;++d)u[d]=e[64*c+4*d]<<24|e[64*c+4*d+1]<<16|e[64*c+4*d+2]<<8|e[64*c+4*d+3];a[c]=u}a[s-1][14]=8*(e.length-1)/Math.pow(2,32),a[s-1][14]=Math.floor(a[s-1][14]),a[s-1][15]=8*(e.length-1)&4294967295;for(var l=0;l<s;++l){for(var h=new Uint32Array(80),E=0;E<16;++E)h[E]=a[l][E];for(var p=16;p<80;++p)h[p]=B(h[p-3]^h[p-8]^h[p-14]^h[p-16],1);for(var v=n[0],f=n[1],m=n[2],_=n[3],g=n[4],b=0;b<80;++b){var T=Math.floor(b/20),w=B(v,5)+F(T,f,m,_)+g+t[T]+h[b]>>>0;g=_,_=m,m=B(f,30)>>>0,f=v,v=w}n[0]=n[0]+v>>>0,n[1]=n[1]+f>>>0,n[2]=n[2]+m>>>0,n[3]=n[3]+_>>>0,n[4]=n[4]+g>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}));var $,z,Y,W,Q=Object.freeze({__proto__:null,NIL:"00000000-0000-0000-0000-000000000000",parse:R,stringify:N,v1:function(e,t,n){var i=t&&n||0,r=t||new Array(16),o=(e=e||{}).node||y,s=void 0!==e.clockseq?e.clockseq:A;if(null==o||null==s){var a=e.random||(e.rng||T)();null==o&&(o=y=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==s&&(s=A=16383&(a[6]<<8|a[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),u=void 0!==e.nsecs?e.nsecs:D+1,d=c-I+(u-D)/1e4;if(d<0&&void 0===e.clockseq&&(s=s+1&16383),(d<0||c>I)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");I=c,D=u,A=s;var l=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;r[i++]=l>>>24&255,r[i++]=l>>>16&255,r[i++]=l>>>8&255,r[i++]=255&l;var h=c/4294967296*1e4&268435455;r[i++]=h>>>8&255,r[i++]=255&h,r[i++]=h>>>24&15|16,r[i++]=h>>>16&255,r[i++]=s>>>8|128,r[i++]=255&s;for(var E=0;E<6;++E)r[i+E]=o[E];return t||N(r)},v3:H,v4:function(e,t,n){var i=(e=e||{}).random||(e.rng||T)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var r=0;r<16;++r)t[n+r]=i[r];return t}return N(i)},v5:V,validate:C,version:function(e){if(!C(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)}}),K={exports:{}};function q(){return $||($=1,t=K,n=K.exports,function(e,i){var r="function",o="undefined",s="object",a="string",c="major",u="model",d="name",l="type",h="vendor",E="version",p="architecture",v="console",f="mobile",m="tablet",_="smarttv",g="wearable",b="embedded",T="Amazon",w="Apple",C="ASUS",y="BlackBerry",A="Browser",S="Chrome",O="Firefox",N="Google",I="Huawei",D="LG",R="Microsoft",k="Motorola",P="Opera",U="Samsung",M="Sharp",x="Sony",G="Xiaomi",j="Zebra",L="Facebook",H="Chromium OS",F="Mac OS",B=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},V=function(e,t){return typeof e===a&&-1!==$(t).indexOf($(e))},$=function(e){return e.toLowerCase()},z=function(e,t){if(typeof e===a)return e=e.replace(/^\s\s*/,""),typeof t===o?e:e.substring(0,500)},Y=function(e,t){for(var n,o,a,c,u,d,l=0;l<t.length&&!u;){var h=t[l],E=t[l+1];for(n=o=0;n<h.length&&!u&&h[n];)if(u=h[n++].exec(e))for(a=0;a<E.length;a++)d=u[++o],typeof(c=E[a])===s&&c.length>0?2===c.length?typeof c[1]==r?this[c[0]]=c[1].call(this,d):this[c[0]]=c[1]:3===c.length?typeof c[1]!==r||c[1].exec&&c[1].test?this[c[0]]=d?d.replace(c[1],c[2]):i:this[c[0]]=d?c[1].call(this,d,c[2]):i:4===c.length&&(this[c[0]]=d?c[3].call(this,d.replace(c[1],c[2])):i):this[c]=d||i;l+=2}},W=function(e,t){for(var n in t)if(typeof t[n]===s&&t[n].length>0){for(var r=0;r<t[n].length;r++)if(V(t[n][r],e))return"?"===n?i:n}else if(V(t[n],e))return"?"===n?i:n;return e},Q={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},K={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[E,[d,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[E,[d,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[d,E],[/opios[\/ ]+([\w\.]+)/i],[E,[d,P+" Mini"]],[/\bopr\/([\w\.]+)/i],[E,[d,P]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[E,[d,"Baidu"]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant|iemobile|slim)\s?(?:browser)?[\/ ]?([\w\.]*)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[d,E],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[E,[d,"UC"+A]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[E,[d,"WeChat"]],[/konqueror\/([\w\.]+)/i],[E,[d,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[E,[d,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[E,[d,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[E,[d,"Smart Lenovo "+A]],[/(avast|avg)\/([\w\.]+)/i],[[d,/(.+)/,"$1 Secure "+A],E],[/\bfocus\/([\w\.]+)/i],[E,[d,O+" Focus"]],[/\bopt\/([\w\.]+)/i],[E,[d,P+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[E,[d,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[E,[d,"Dolphin"]],[/coast\/([\w\.]+)/i],[E,[d,P+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[E,[d,"MIUI "+A]],[/fxios\/([-\w\.]+)/i],[E,[d,O]],[/\bqihu|(qi?ho?o?|360)browser/i],[[d,"360 "+A]],[/(oculus|sailfish|huawei|vivo)browser\/([\w\.]+)/i],[[d,/(.+)/,"$1 "+A],E],[/samsungbrowser\/([\w\.]+)/i],[E,[d,U+" Internet"]],[/(comodo_dragon)\/([\w\.]+)/i],[[d,/_/g," "],E],[/metasr[\/ ]?([\d\.]+)/i],[E,[d,"Sogou Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[d,"Sogou Mobile"],E],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345Explorer)[\/ ]?([\w\.]+)/i],[d,E],[/(lbbrowser)/i,/\[(linkedin)app\]/i],[d],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[d,L],E],[/(Klarna)\/([\w\.]+)/i,/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(alipay)client\/([\w\.]+)/i,/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i],[d,E],[/\bgsa\/([\w\.]+) .*safari\//i],[E,[d,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[E,[d,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[E,[d,S+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[d,S+" WebView"],E],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[E,[d,"Android "+A]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[d,E],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[E,[d,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[E,d],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[d,[E,W,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[d,E],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[d,"Netscape"],E],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[E,[d,O+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[d,E],[/(cobalt)\/([\w\.]+)/i],[d,[E,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[p,"amd64"]],[/(ia32(?=;))/i],[[p,$]],[/((?:i[346]|x)86)[;\)]/i],[[p,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[p,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[p,"armhf"]],[/windows (ce|mobile); ppc;/i],[[p,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[p,/ower/,"",$]],[/(sun4\w)[;\)]/i],[[p,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[p,$]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[u,[h,U],[l,m]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[u,[h,U],[l,f]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[u,[h,w],[l,f]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[u,[h,w],[l,m]],[/(macintosh);/i],[u,[h,w]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[u,[h,M],[l,f]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[u,[h,I],[l,m]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[u,[h,I],[l,f]],[/\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[u,/_/g," "],[h,G],[l,f]],[/oid[^\)]+; (2\d{4}(283|rpbf)[cgl])( bui|\))/i,/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[u,/_/g," "],[h,G],[l,m]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[u,[h,"OPPO"],[l,f]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[u,[h,"Vivo"],[l,f]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[u,[h,"Realme"],[l,f]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[u,[h,k],[l,f]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[u,[h,k],[l,m]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[u,[h,D],[l,m]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[u,[h,D],[l,f]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[u,[h,"Lenovo"],[l,m]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[u,/_/g," "],[h,"Nokia"],[l,f]],[/(pixel c)\b/i],[u,[h,N],[l,m]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[u,[h,N],[l,f]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[u,[h,x],[l,f]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[u,"Xperia Tablet"],[h,x],[l,m]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[u,[h,"OnePlus"],[l,f]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[u,[h,T],[l,m]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[u,/(.+)/g,"Fire Phone $1"],[h,T],[l,f]],[/(playbook);[-\w\),; ]+(rim)/i],[u,h,[l,m]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[u,[h,y],[l,f]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[u,[h,C],[l,m]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[u,[h,C],[l,f]],[/(nexus 9)/i],[u,[h,"HTC"],[l,m]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[h,[u,/_/g," "],[l,f]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[u,[h,"Acer"],[l,m]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[u,[h,"Meizu"],[l,f]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[u,[h,"Ulefone"],[l,f]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron|infinix|tecno)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[h,u,[l,f]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[h,u,[l,m]],[/(surface duo)/i],[u,[h,R],[l,m]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[u,[h,"Fairphone"],[l,f]],[/(u304aa)/i],[u,[h,"AT&T"],[l,f]],[/\bsie-(\w*)/i],[u,[h,"Siemens"],[l,f]],[/\b(rct\w+) b/i],[u,[h,"RCA"],[l,m]],[/\b(venue[\d ]{2,7}) b/i],[u,[h,"Dell"],[l,m]],[/\b(q(?:mv|ta)\w+) b/i],[u,[h,"Verizon"],[l,m]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[u,[h,"Barnes & Noble"],[l,m]],[/\b(tm\d{3}\w+) b/i],[u,[h,"NuVision"],[l,m]],[/\b(k88) b/i],[u,[h,"ZTE"],[l,m]],[/\b(nx\d{3}j) b/i],[u,[h,"ZTE"],[l,f]],[/\b(gen\d{3}) b.+49h/i],[u,[h,"Swiss"],[l,f]],[/\b(zur\d{3}) b/i],[u,[h,"Swiss"],[l,m]],[/\b((zeki)?tb.*\b) b/i],[u,[h,"Zeki"],[l,m]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[h,"Dragon Touch"],u,[l,m]],[/\b(ns-?\w{0,9}) b/i],[u,[h,"Insignia"],[l,m]],[/\b((nxa|next)-?\w{0,9}) b/i],[u,[h,"NextBook"],[l,m]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[h,"Voice"],u,[l,f]],[/\b(lvtel\-)?(v1[12]) b/i],[[h,"LvTel"],u,[l,f]],[/\b(ph-1) /i],[u,[h,"Essential"],[l,f]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[u,[h,"Envizen"],[l,m]],[/\b(trio[-\w\. ]+) b/i],[u,[h,"MachSpeed"],[l,m]],[/\btu_(1491) b/i],[u,[h,"Rotor"],[l,m]],[/(shield[\w ]+) b/i],[u,[h,"Nvidia"],[l,m]],[/(sprint) (\w+)/i],[h,u,[l,f]],[/(kin\.[onetw]{3})/i],[[u,/\./g," "],[h,R],[l,f]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[u,[h,j],[l,m]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[u,[h,j],[l,f]],[/smart-tv.+(samsung)/i],[h,[l,_]],[/hbbtv.+maple;(\d+)/i],[[u,/^/,"SmartTV"],[h,U],[l,_]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[h,D],[l,_]],[/(apple) ?tv/i],[h,[u,w+" TV"],[l,_]],[/crkey/i],[[u,S+"cast"],[h,N],[l,_]],[/droid.+aft(\w+)( bui|\))/i],[u,[h,T],[l,_]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[u,[h,M],[l,_]],[/(bravia[\w ]+)( bui|\))/i],[u,[h,x],[l,_]],[/(mitv-\w{5}) bui/i],[u,[h,G],[l,_]],[/Hbbtv.*(technisat) (.*);/i],[h,u,[l,_]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[h,z],[u,z],[l,_]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[l,_]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[h,u,[l,v]],[/droid.+; (shield) bui/i],[u,[h,"Nvidia"],[l,v]],[/(playstation [345portablevi]+)/i],[u,[h,x],[l,v]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[u,[h,R],[l,v]],[/((pebble))app/i],[h,u,[l,g]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[u,[h,w],[l,g]],[/droid.+; (glass) \d/i],[u,[h,N],[l,g]],[/droid.+; (wt63?0{2,3})\)/i],[u,[h,j],[l,g]],[/(quest( 2| pro)?)/i],[u,[h,L],[l,g]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[h,[l,b]],[/(aeobc)\b/i],[u,[h,T],[l,b]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew).+? mobile safari/i],[u,[l,f]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[u,[l,m]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[l,m]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[l,f]],[/(android[-\w\. ]{0,9});.+buil/i],[u,[h,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[E,[d,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[E,[d,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[d,E],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[E,d]],os:[[/microsoft (windows) (vista|xp)/i],[d,E],[/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i],[d,[E,W,Q]],[/windows nt 6\.2; (arm)/i,/windows[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i,/(?:win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[E,W,Q],[d,"Windows"]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/(?:ios;fbsv\/|iphone.+ios[\/ ])([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[E,/_/g,"."],[d,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[d,F],[E,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[E,d],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[d,E],[/\(bb(10);/i],[E,[d,y]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[E,[d,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[E,[d,O+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[E,[d,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[E,[d,"watchOS"]],[/crkey\/([\d\.]+)/i],[E,[d,S+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[d,H],E],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[d,E],[/(sunos) ?([\w\.\d]*)/i],[[d,"Solaris"],E],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[d,E]]},q=function(t,n){if(typeof t===s&&(n=t,t=i),!(this instanceof q))return new q(t,n).getResult();var v=typeof e!==o&&e.navigator?e.navigator:i,_=t||(v&&v.userAgent?v.userAgent:""),g=v&&v.userAgentData?v.userAgentData:i,b=n?function(e,t){var n={};for(var i in e)t[i]&&t[i].length%2==0?n[i]=t[i].concat(e[i]):n[i]=e[i];return n}(K,n):K,T=v&&v.userAgent==_;return this.getBrowser=function(){var e={};return e[d]=i,e[E]=i,Y.call(e,_,b.browser),e[c]=function(e){return typeof e===a?e.replace(/[^\d\.]/g,"").split(".")[0]:i}(e[E]),T&&v&&v.brave&&typeof v.brave.isBrave==r&&(e[d]="Brave"),e},this.getCPU=function(){var e={};return e[p]=i,Y.call(e,_,b.cpu),e},this.getDevice=function(){var e={};return e[h]=i,e[u]=i,e[l]=i,Y.call(e,_,b.device),T&&!e[l]&&g&&g.mobile&&(e[l]=f),T&&"Macintosh"==e[u]&&v&&typeof v.standalone!==o&&v.maxTouchPoints&&v.maxTouchPoints>2&&(e[u]="iPad",e[l]=m),e},this.getEngine=function(){var e={};return e[d]=i,e[E]=i,Y.call(e,_,b.engine),e},this.getOS=function(){var e={};return e[d]=i,e[E]=i,Y.call(e,_,b.os),T&&!e[d]&&g&&"Unknown"!=g.platform&&(e[d]=g.platform.replace(/chrome os/i,H).replace(/macos/i,F)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return _},this.setUA=function(e){return _=typeof e===a&&e.length>500?z(e,500):e,this},this.setUA(_),this};q.VERSION="1.0.37",q.BROWSER=B([d,E,c]),q.CPU=B([p]),q.DEVICE=B([u,h,l,v,f,_,m,g,b]),q.ENGINE=q.OS=B([d,E]),t.exports&&(n=t.exports=q),n.UAParser=q;var J=typeof e!==o&&(e.jQuery||e.Zepto);if(J&&!J.ua){var X=new q;J.ua=X.getResult(),J.ua.get=function(){return X.getUA()},J.ua.set=function(e){X.setUA(e);var t=X.getResult();for(var n in t)J.ua[n]=t[n]}}}("object"==typeof window?window:e)),K.exports;var t,n}
2
+ /*! For license information please see index.js.LICENSE.txt */z=g,Y=g.exports,self,W=(t,n)=>(()=>{var i={910:(e,t,n)=>{t.Nf=void 0,n(151),n(749),t.Nf=function(e){var t=Date.parse(e);return isNaN(t)&&(t=function(e){var t,n=/^(\d{4}-\d\d-\d\d([tT][\d:.]*)?)([zZ]|([+-])(\d\d):?(\d\d))?$/.exec(e)||[];if(n[1]){if((t=n[1].split(/\D/).map((function(e){return parseInt(e,10)||0})))[1]-=1,!(t=new Date(Date.UTC.apply(Date,t))).getDate())return NaN;if(n[5]){var i=60*parseInt(n[5],10);n[6]&&(i+=parseInt(n[6],10)),"+"===n[4]&&(i*=-1),i&&t.setUTCMinutes(t.getUTCMinutes()+i)}return t.getTime()}return NaN}(e)),new Date(t)}},749:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getTimeInMinutes=t.getTimeInMilliseconds=t.getTimeInSeconds=t.padDateTimeUnit=void 0,t.padDateTimeUnit=function(e){var t=Math.abs(Math.floor("string"==typeof e?Number(e):e));return(t<10?"0":"")+t},t.getTimeInSeconds=function(e){var t=e.hours,n=void 0===t?0:t,i=e.minutes,r=void 0===i?0:i,o=e.seconds;return 60*n*60+60*r+(void 0===o?0:o)},t.getTimeInMilliseconds=function(e){var n=e.hours,i=void 0===n?0:n,r=e.minutes,o=void 0===r?0:r,s=e.seconds,a=void 0===s?0:s,c=e.milliseconds,u=void 0===c?0:c;return 1e3*(0,t.getTimeInSeconds)({hours:i,minutes:o,seconds:a})+u},t.getTimeInMinutes=function(e){var n=e.hours,i=void 0===n?0:n,r=e.minutes,o=void 0===r?0:r,s=e.seconds,a=void 0===s?0:s;return(0,t.getTimeInSeconds)({hours:i,minutes:o,seconds:a})/60}},151:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getTimezoneISOOffset=void 0;var i=n(749);t.getTimezoneISOOffset=function(e){void 0===e&&(e=new Date);var t=e.getTimezoneOffset();return"".concat(t>0?"-":"+").concat((0,i.padDateTimeUnit)(t/60),":").concat((0,i.padDateTimeUnit)(t%60))}},893:(e,t)=>{t.P=void 0,t.P=function(e){return Object.keys(e).filter((function(t){return null!==e[t]})).map((function(t){return[t,e[t]].map(encodeURIComponent).join("=")})).join("&")}},282:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.LogLevels=void 0,(n=t.LogLevels||(t.LogLevels={})).ERROR="error",n.INFO="info",n.WARN="warn"},996:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EventTargetPolyfill=void 0;var n=function(){function e(){this.listeners={}}return e.prototype.addEventListener=function(e,t){e in this.listeners||(this.listeners[e]=[]),this.listeners[e].push(t)},e.prototype.removeEventListener=function(e,t){if(e in this.listeners)for(var n=this.listeners[e],i=0,r=n.length;i<r;i++)if(n[i]===t)return void n.splice(i,1)},e.prototype.dispatchEvent=function(e){if(!(e.type in this.listeners))return!0;for(var t=this.listeners[e.type].slice(),n=0,i=t.length;n<i;n++)t[n].call(this,e);return!e.defaultPrevented},e}();t.EventTargetPolyfill=n},455:(e,t,n)=>{t.xT=void 0,n(546),n(996),n(846);var i=n(982);Object.defineProperty(t,"xT",{enumerable:!0,get:function(){return i.WebSocketClientEvent}})},415:function(e,t,n){var i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},i.apply(this,arguments)},r=this&&this.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.getPushUpdateWebSocket=t.setupSocketConnection=void 0;var o=n(846),s=n(982),a=null,c={forceSecureProtocol:!1,heartbeatAfterAuthorize:!1,maxRetries:20,maxReconnectionDelay:1e3};t.setupSocketConnection=function(e,t){if(void 0===t&&(t={}),"object"!=typeof t)throw new TypeError("Options parameter must be an object not a "+typeof t);var n=i(i({},c),t),u=n.forceSecureProtocol,d=n.heartbeatAfterAuthorize,l=r(n,["forceSecureProtocol","heartbeatAfterAuthorize"]),h=function(e,t){return t?"wss://"+e:("https:"===window.location.protocol?"wss:":"ws:")+"//"+e}(e,u);return a=new o.WebSocketClient(h,void 0,l),d?a.addEventListener(s.WebSocketClientEvent.MESSAGE,(function(e){"authorized"===JSON.parse(e.detail.data)&&(null==a||a.startHeartBeat())})):a.startHeartBeat(),a},t.getPushUpdateWebSocket=function(){return a}},546:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.HeartBeatState=void 0,(n=t.HeartBeatState||(t.HeartBeatState={})).DIED="died",n.DYING="dying",n.LIVING="living"},846:function(e,t,n){var i,r=this&&this.__extends||(i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)},function(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocketClient=t.HEART_BEAT_CHECK_TIMEOUT=t.HEART_BEAT_INTERVAL=void 0;var s=n(282),a=o(n(864)),c=n(996),u=n(546),d=n(982);t.HEART_BEAT_INTERVAL=15e3,t.HEART_BEAT_CHECK_TIMEOUT=3*t.HEART_BEAT_INTERVAL;var l=function(e){function n(n,i,r){var o=e.call(this)||this;return o.heartBeatTimeout=null,o.heartBeatCheckTimeout=null,o.enableDebugMode=function(){o.debugMode||o.log(s.LogLevels.INFO,"websocket-push-updates--loggerEnabled"),o.debugMode=!0},o.disableDebugMode=function(){o.debugMode=!1},o.log=function(e,t,n){o.debugMode&&o.logger&&o.logger[e](t,n)},o.sendHeartBeat=function(){o.log(s.LogLevels.INFO,"websocket-push-updates--sendHeartBeat"),o.send(JSON.stringify({action:"heartbeat"}))},o.handleHeartBeatResponse=function(){o.heartBeatState===u.HeartBeatState.DYING&&(o.heartBeatState=u.HeartBeatState.LIVING,o.dispatchHeartBeatState()),o.setHeartBeatCheckTimeout()},o.setHeartBeatCheckTimeout=function(){null!==o.heartBeatCheckTimeout&&clearTimeout(o.heartBeatCheckTimeout),o.heartBeatCheckTimeout=setTimeout((function(){o.heartBeatState=u.HeartBeatState.DYING,o.dispatchHeartBeatState()}),t.HEART_BEAT_CHECK_TIMEOUT)},o.dispatchHeartBeatState=function(){o.log(s.LogLevels.INFO,"websocket-push-updates--dispatchHeartBeatState",[{hearbeatState:o.heartBeatState}]),null!==o.heartBeatState&&o.dispatchEvent(new CustomEvent(o.heartBeatState))},o.isHeartBeatActive=function(){return null!==o.heartBeatState},o.heartBeatState=null,o.debugMode=!1,o.socket=new a.default(n,i,r),o.socket.onopen=function(){o.dispatchEvent(new CustomEvent(d.WebSocketClientEvent.OPEN))},(null==r?void 0:r.logger)&&(o.logger=r.logger),o.socket.onclose=function(e){o.socket.retryCount===(null==r?void 0:r.maxRetries)?o.heartBeatState=u.HeartBeatState.DIED:o.heartBeatState=u.HeartBeatState.DYING,o.dispatchHeartBeatState(),o.dispatchEvent(new CustomEvent(d.WebSocketClientEvent.CLOSE,{detail:e}))},o.socket.onmessage=function(e){o.handleHeartBeatResponse(),"pong"!==JSON.parse(e.data)&&(o.log(s.LogLevels.INFO,"websocket-push-updates--onmessage",[e]),o.dispatchEvent(new CustomEvent(d.WebSocketClientEvent.MESSAGE,{detail:e})))},o.socket.onerror=function(e){o.log(s.LogLevels.ERROR,"websocket-push-updates--onError",[e]),o.dispatchEvent(new CustomEvent(d.WebSocketClientEvent.ERROR,{detail:e}))},o}return r(n,e),n.prototype.send=function(e){this.socket.send(e)},n.prototype.startHeartBeat=function(){var e=this;this.log(s.LogLevels.INFO,"websocket-push-updates--startHeartBeat",[{interval:t.HEART_BEAT_INTERVAL}]);var n=function(){e.log(s.LogLevels.INFO,"websocket-push-updates--heartBeatCallback"),e.sendHeartBeat(),e.heartBeatTimeout=setTimeout(n,t.HEART_BEAT_INTERVAL)};this.setHeartBeatCheckTimeout(),n(),this.heartBeatState=u.HeartBeatState.LIVING},n.prototype.stopHeartBeat=function(){this.log(s.LogLevels.INFO,"websocket-push-updates--stopHeartBeat"),null!==this.heartBeatTimeout&&clearTimeout(this.heartBeatTimeout),null!==this.heartBeatCheckTimeout&&clearTimeout(this.heartBeatCheckTimeout),this.heartBeatState=null},n}(c.EventTargetPolyfill);t.WebSocketClient=l},982:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.WebSocketClientEvent=void 0,(n=t.WebSocketClientEvent||(t.WebSocketClientEvent={})).CLOSE="close",n.ERROR="error",n.MESSAGE="message",n.OPEN="open"},864:(e,t,n)=>{n.r(t),n.d(t,{default:()=>d});var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},i(e,t)};function r(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function o(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}var s=function(e,t){this.target=t,this.type=e},a=function(e){function t(t,n){var i=e.call(this,"error",n)||this;return i.message=t.message,i.error=t,i}return r(t,e),t}(s),c=function(e){function t(t,n,i){void 0===t&&(t=1e3),void 0===n&&(n="");var r=e.call(this,"close",i)||this;return r.wasClean=!0,r.code=t,r.reason=n,r}return r(t,e),t}(s),u={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+4e3*Math.random(),minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1};const d=function(){function e(e,t,n){var i=this;void 0===n&&(n={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(e){i._debug("open event");var t=i._options.minUptime,n=void 0===t?u.minUptime:t;clearTimeout(i._connectTimeout),i._uptimeTimeout=setTimeout((function(){return i._acceptOpen()}),n),i._ws.binaryType=i._binaryType,i._messageQueue.forEach((function(e){var t;return null===(t=i._ws)||void 0===t?void 0:t.send(e)})),i._messageQueue=[],i.onopen&&i.onopen(e),i._listeners.open.forEach((function(t){return i._callEventListener(e,t)}))},this._handleMessage=function(e){i._debug("message event"),i.onmessage&&i.onmessage(e),i._listeners.message.forEach((function(t){return i._callEventListener(e,t)}))},this._handleError=function(e){i._debug("error event",e.message),i._disconnect(void 0,"TIMEOUT"===e.message?"timeout":void 0),i.onerror&&i.onerror(e),i._debug("exec error listeners"),i._listeners.error.forEach((function(t){return i._callEventListener(e,t)})),i._connect()},this._handleClose=function(e){i._debug("close event"),i._clearTimeouts(),i._shouldReconnect&&i._connect(),i.onclose&&i.onclose(e),i._listeners.close.forEach((function(t){return i._callEventListener(e,t)}))},this._url=e,this._protocols=t,this._options=n,this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}return Object.defineProperty(e,"CONNECTING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OPEN",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSED",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CONNECTING",{get:function(){return e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"OPEN",{get:function(){return e.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSING",{get:function(){return e.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSED",{get:function(){return e.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryType",{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){return this._messageQueue.reduce((function(e,t){return"string"==typeof t?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e}),0)+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this._ws?this._ws.extensions:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this._ws?this._ws.protocol:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._ws?this._ws.url:""},enumerable:!0,configurable:!0}),e.prototype.close=function(e,t){void 0===e&&(e=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),this._ws?this._ws.readyState!==this.CLOSED?this._ws.close(e,t):this._debug("close: already closed"):this._debug("close enqueued: no ws instance")},e.prototype.reconnect=function(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,this._ws&&this._ws.readyState!==this.CLOSED?(this._disconnect(e,t),this._connect()):this._connect()},e.prototype.send=function(e){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",e),this._ws.send(e);else{var t=this._options.maxEnqueuedMessages,n=void 0===t?u.maxEnqueuedMessages:t;this._messageQueue.length<n&&(this._debug("enqueue",e),this._messageQueue.push(e))}},e.prototype.addEventListener=function(e,t){this._listeners[e]&&this._listeners[e].push(t)},e.prototype.dispatchEvent=function(e){var t,n,i=this._listeners[e.type];if(i)try{for(var r=function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}(i),o=r.next();!o.done;o=r.next()){var s=o.value;this._callEventListener(e,s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}return!0},e.prototype.removeEventListener=function(e,t){this._listeners[e]&&(this._listeners[e]=this._listeners[e].filter((function(e){return e!==t})))},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._options.debug&&console.log.apply(console,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(o(arguments[t]));return e}(["RWS>"],e))},e.prototype._getNextDelay=function(){var e=this._options,t=e.reconnectionDelayGrowFactor,n=void 0===t?u.reconnectionDelayGrowFactor:t,i=e.minReconnectionDelay,r=void 0===i?u.minReconnectionDelay:i,o=e.maxReconnectionDelay,s=void 0===o?u.maxReconnectionDelay:o,a=0;return this._retryCount>0&&(a=r*Math.pow(n,this._retryCount-1))>s&&(a=s),this._debug("next delay",a),a},e.prototype._wait=function(){var e=this;return new Promise((function(t){setTimeout(t,e._getNextDelay())}))},e.prototype._getNextUrl=function(e){if("string"==typeof e)return Promise.resolve(e);if("function"==typeof e){var t=e();if("string"==typeof t)return Promise.resolve(t);if(t.then)return t}throw Error("Invalid URL")},e.prototype._connect=function(){var e=this;if(!this._connectLock&&this._shouldReconnect){this._connectLock=!0;var t=this._options,n=t.maxRetries,i=void 0===n?u.maxRetries:n,r=t.connectionTimeout,o=void 0===r?u.connectionTimeout:r,s=t.WebSocket,c=void 0===s?function(){if("undefined"!=typeof WebSocket)return WebSocket}():s;if(this._retryCount>=i)this._debug("max retries reached",this._retryCount,">=",i);else{if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),void 0===(d=c)||!d||2!==d.CLOSING)throw Error("No valid WebSocket class provided");var d;this._wait().then((function(){return e._getNextUrl(e._url)})).then((function(t){e._closeCalled?e._connectLock=!1:(e._debug("connect",{url:t,protocols:e._protocols}),e._ws=e._protocols?new c(t,e._protocols):new c(t),e._ws.binaryType=e._binaryType,e._connectLock=!1,e._addListeners(),e._connectTimeout=setTimeout((function(){return e._handleTimeout()}),o))})).catch((function(t){e._connectLock=!1,e._handleError(new a(Error(t.message),e))}))}}},e.prototype._handleTimeout=function(){this._debug("timeout event"),this._handleError(new a(Error("TIMEOUT"),this))},e.prototype._disconnect=function(e,t){if(void 0===e&&(e=1e3),this._clearTimeouts(),this._ws){this._removeListeners();try{this._ws.close(e,t),this._handleClose(new c(e,t,this))}catch(e){}}},e.prototype._acceptOpen=function(){this._debug("accept open"),this._retryCount=0},e.prototype._callEventListener=function(e,t){"handleEvent"in t?t.handleEvent(e):t(e)},e.prototype._removeListeners=function(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))},e.prototype._addListeners=function(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))},e.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)},e}()},441:(e,t)=>{var n;(n=t.p||(t.p={})).CHAT_WINDOW_EVENT="chatWindowEvent",n.REGISTER="register"},154:(e,t)=>{var n,i;(i=t.YU||(t.YU={})).SENDER_TYPING_STARTED="SenderTypingStarted",i.SENDER_TYPING_ENDED="SenderTypingEnded",i.LOAD_MORE_MESSAGES="LoadMoreMessages",i.RECOVER_LIVECHAT="RecoverLivechat",i.RECOVER_THREAD="RecoverThread",i.SEND_MESSAGE="SendMessage",i.SEND_OUTBOUND="SendOutbound",i.SEND_OFFLINE_MESSAGE="SendOfflineMessage",i.SEND_PAGE_VIEWS="SendPageViews",i.SEND_CONSUMER_CUSTOM_FIELDS="SetConsumerCustomFields",i.SET_CONSUMER_CONTACT_CUSTOM_FIELD="SetConsumerContactCustomFields",i.MESSAGE_SEEN="MessageSeenByConsumer",i.SEND_TRANSCRIPT="SendTranscript",i.FETCH_THREAD_LIST="FetchThreadList",i.END_CONTACT="EndContact",i.EXECUTE_TRIGGER="ExecuteTrigger",i.AUTHORIZE_CONSUMER="AuthorizeConsumer",i.AUTHORIZE_CUSTOMER="AuthorizeCustomer",i.RECONNECT_CONSUMER="ReconnectConsumer",i.UPDATE_THREAD="UpdateThread",i.ARCHIVE_THREAD="ArchiveThread",i.LOAD_THREAD_METADATA="LoadThreadMetadata",i.REFRESH_TOKEN="RefreshToken",i.STORE_VISITOR="StoreVisitor",i.STORE_VISITOR_EVENTS="StoreVisitorEvents",i.CREATE_GROUP_CHAT_INVITE="CreateInvitationToGroupChat",i.SEND_EMAIL_INVITE_TO_GROUP_CHAT="SendEmailInvitationToGroupChat",i.JOIN_GROUP_CHAT="JoinGroupChat",i.LEAVE_GROUP_CHAT="LeaveGroupChat",i.GENERATE_AUTHORIZATION_TOKEN="GenerateAuthorizationToken",i.ADD_VISITOR_TAGS="AddVisitorTags",i.REMOVE_VISITOR_TAGS="RemoveVisitorTags",i.SEND_MESSAGE_PREVIEW="SendMessagePreview",(n=t.Ne||(t.Ne={})).LIVECHAT_RECOVERED="LivechatRecovered",n.MORE_MESSAGES_LOADED="MoreMessagesLoaded",n.OFFLINE_MESSAGE_SENT="OfflineMessageSent",n.THREAD_LIST_FETCHED="ThreadListFetched",n.THREAD_RECOVERED="ThreadRecovered",n.TRANSCRIPT_SENT="TranscriptSent",n.CONSUMER_AUTHORIZED="ConsumerAuthorized",n.THREAD_METADATA_LOADED="ThreadMetadataLoaded",n.SET_POSITION_IN_QUEUE="SetPositionInQueue",n.GROUP_CHAT_INVITE_CREATED="InvitationToGroupChatCreated",n.GROUP_CHAT_INVITE_SENT="EmailInvitationToGroupChatSent",n.GROUP_CHAT_JOINED="GroupChatJoined",n.TOKEN_REFRESHED="TokenRefreshed",n.AUTHORIZATION_TOKEN_GENERATED="AuthorizationTokenGenerated",n.THREAD_ARCHIVED="ThreadArchived"},58:(e,t)=>{var n;(n=t.Yi||(t.Yi={})).DESKTOP="desktop",n.MOBILE="mobile",n.OTHER="other",n.TABLET="tablet",(t.vQ||(t.vQ={})).BROWSER="browser"},880:(e,t,n)=>{var i=n(256);t.P=i.CaseStatus},354:(e,t)=>{t.GO="X-Caller-Service-ID"},510:(e,t)=>{var n;(n=t.T||(t.T={})).INBOUND="inbound",n.OUTBOUND="outbound"},115:(e,t)=>{var n;(n=t.C||(t.C={})).TEXT="TEXT",n.FILE="FILE",n.FORM="FORM",n.PLUGIN="PLUGIN",n.POSTBACK="POSTBACK",n.QUICK_REPLIES="QUICK_REPLIES",n.RICH_LINK="RICH_LINK",n.LIST_PICKER="LIST_PICKER",n.ADAPTIVE_CARD="ADAPTIVE_CARD",n.TIME_PICKER="TIME_PICKER"},256:(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),(n=t.CaseStatus||(t.CaseStatus={})).NEW="new",n.OPEN="open",n.PENDING="pending",n.ESCALATED="escalated",n.RESOLVED="resolved",n.CLOSED="closed",n.TRASHED="trashed"},403:(e,t)=>{var n;(n=t.m||(t.m={})).AUTHORIZE_CONSUMER="AuthorizeConsumer",n.CASE_CREATED="CaseCreated",n.CASE_INBOX_ASSIGNEE_CHANGED="CaseInboxAssigneeChanged",n.CASE_STATUS_CHANGED="CaseStatusChanged",n.CASE_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED="CaseToRoutingQueueAssignmentChanged",n.CONTACT_CREATED="CaseCreated",n.ASSIGNED_AGENT_CHANGED="CaseInboxAssigneeChanged",n.CONTACT_STATUS_CHANGED="CaseStatusChanged",n.CONTACT_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED="CaseToRoutingQueueAssignmentChanged",n.CONTACT_PREFERRED_USER_CHANGED="ContactPreferredUserChanged",n.CONTACT_PROFICIENCY_CHANGED="ContactProficiencyChanged",n.CONTACT_PRIORITY_CHANGED="ContactPriorityChanged",n.CONTACT_SYNC="ContactSync",n.CHANNEL_CREATED="ChannelCreated",n.CHANNEL_DELETED="ChannelDeleted",n.CHANNEL_UPDATED="ChannelUpdated",n.MESSAGE_ADDED_INTO_CASE="MessageAddedIntoCase",n.MESSAGE_CREATED="MessageCreated",n.MESSAGE_DELIVERED_TO_END_USER="MessageDeliveredToEndUser",n.MESSAGE_DELIVERED_TO_USER="MessageDeliveredToUser",n.MESSAGE_NOTE_CREATED="MessageNoteCreated",n.MESSAGE_NOTE_UPDATED="MessageNoteUpdated",n.MESSAGE_NOTE_DELETED="MessageNoteDeleted",n.MESSAGE_READ_CHANGED="MessageReadChanged",n.MESSAGE_SEEN_BY_END_USER="MessageSeenByEndUser",n.MESSAGE_SEEN_BY_USER="MessageSeenByUser",n.MESSAGE_SENT="MessageSent",n.MESSAGE_UPDATED="MessageUpdated",n.PAGE_VIEW_CREATED="PageViewCreated",n.ROUTING_QUEUE_CREATED="RoutingQueueCreated",n.ROUTING_QUEUE_DELETED="RoutingQueueDeleted",n.ROUTING_QUEUE_UPDATED="RoutingQueueUpdated",n.SUBQUEUE_ASSIGNED_TO_ROUTING_QUEUE="SubqueueAssignedToRoutingQueue",n.SUBQUEUE_UNASSIGNED_TO_ROUTING_QUEUE="SubqueueUnassignedFromRoutingQueue",n.USER_ASSIGNED_TO_ROUTING_QUEUE="UserAssignedToRoutingQueue",n.USER_STATUS_CHANGED="UserStatusChanged",n.USER_UNASSIGNED_FROM_ROUTING_QUEUE="UserUnassignedFromRoutingQueue",n.AGENT_CONTACT_STARTED="AgentContactStarted",n.AGENT_CONTACT_ENDED="AgentContactEnded",n.SENDER_TYPING_STARTED="SenderTypingStarted",n.SENDER_TYPING_ENDED="SenderTypingEnded",n.FIRE_PROACTIVE="FireProactiveAction",n.CONTACT_INBOX_PRE_ASSIGNEE_CHANGED="ConsumerContactInboxPreAssigneeChanged",n.CONTACT_RECIPIENTS_CHANGED="ContactRecipientsChanged",n.MESSAGE_PREVIEW_CREATED="MessagePreviewCreated",n.EVENT_IN_S3="EventInS3"},585:e=>{e.exports=n},459:e=>{e.exports=t}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var n=r[e]={exports:{}};return i[e].call(n.exports,n,n.exports,o),n.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{o.r(s),o.d(s,{AbortError:()=>Zt,AbortablePromise:()=>en,AuthorizationError:()=>h,ChatEvent:()=>et,ChatSdk:()=>tn,ContactStatus:()=>_t.P,Customer:()=>Le,EnvironmentName:()=>Xe,LivechatThread:()=>Wt,MessageType:()=>Et.C,SendMessageFailedError:()=>ht,Thread:()=>zt,ThreadRecoverFailedError:()=>$t,UploadAttachmentError:()=>Ot,WebSocketClientError:()=>ft,WebSocketClientEvent:()=>n.xT,createCreateInvitationToGroupChatPayloadData:()=>pn,createJoinGroupChatPayloadData:()=>mn,createLeaveGroupChatPayloadData:()=>gn,createReconnectPayloadData:()=>We,createSendEmailInvitationToGroupChatPayloadData:()=>wn,default:()=>An,generateId:()=>E.v4,getAuthor:()=>an,isAgentTypingEndedEvent:()=>on,isAgentTypingStartedEvent:()=>rn,isAssignedAgentChangedEvent:()=>nn,isAuthSuccessEvent:()=>qe,isContactCreatedEvent:()=>Dt,isContactRecipientsChangedEvent:()=>kt,isContactStatusChangedEvent:()=>It,isContactToRoutingQueueAssignmentChangedEvent:()=>Rt,isCustomerReconnectSuccessPayloadData:()=>yn,isLoadMetadataSuccessPayload:()=>jt,isMessage:()=>cn,isMessageCreatedEvent:()=>un,isMessageReadChangedEvent:()=>ln,isMessageSentEvent:()=>dn,isMoreMessagesLoadedEvent:()=>Ut,isRecoverSuccessEvent:()=>Lt,isSetPositionInQueueEvent:()=>hn,isThreadArchivedSuccessPayload:()=>Ht,isThreadListFetchedPostbackData:()=>Qt,isTokenRefreshedSuccessResponse:()=>Je,sendChatEvent:()=>Ye,sendCreateInvitationToGroupChatEvent:()=>vn,sendEmailInvitationToGroupChatEvent:()=>Cn,sendJoinGroupChatEvent:()=>_n,sendLeaveGroupChatEvent:()=>bn,splitName:()=>Ue});var t,n=o(455),i=o(441),r=o(154);!function(e){e.ACCESS_TOKEN="ACCESS_TOKEN",e.ACCESS_TOKEN_EXPIRES_IN="ACCESS_TOKEN_EXPIRES_IN",e.APP_NAME="APP_NAME",e.APP_VERSION="APP_VERSION",e.AUTHORIZATION_CODE="AUTHORIZATION_CODE",e.BRAND_ID="BRAND_ID",e.CHANNEL_ID="CHANNEL_ID",e.CUSTOMER_ID="CUSTOMER_ID",e.CUSTOMER_IMAGE="CUSTOMER_IMAGE",e.CUSTOMER_NAME="CUSTOMER_NAME",e.ENDPOINT_CHAT="ENDPOINT_CHAT",e.ENDPOINT_GATEWAY="ENDPOINT_GATEWAY",e.THREAD_DATA="THREAD_DATA"}(t||(t={}));const a=new class{constructor(){this._vars={}}set(e,t){this._vars[e]=t}get(e,t){var n;return null!==(n=this._vars[e])&&void 0!==n?n:t}list(){return Object.keys(this._vars)}clear(){this._vars={}}},c=function(e){return null===e};function u(e){a.set(t.ACCESS_TOKEN,e.token),a.set(t.ACCESS_TOKEN_EXPIRES_IN,String(e.expiresIn))}function d(){const e=a.get(t.ACCESS_TOKEN,null),n=a.get(t.ACCESS_TOKEN_EXPIRES_IN,null);return c(e)||c(n)?null:{token:e,expiresIn:Number(n)}}class l extends Error{constructor(e,t){super(),this.name="ChatSDKError",this.message=`[ChatSDKError]: ${this._getErrorMessage(e)}`,this.data=t}_getErrorMessage(e){return e instanceof Error?e.message:"string"==typeof e?e:JSON.stringify(e)}}class h extends l{constructor(e,t){super(e,t),void 0!==t&&(this.message=`${e} because of (${t.errorMessage})`)}}var E=o(459);function p(e){return{visitor:{id:e}}}var v=Object.prototype;const f=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||v)},m=(_=Object.keys,g=Object,function(e){return _(g(e))});var _,g,b=Object.prototype.hasOwnProperty;const T="object"==typeof e&&e&&e.Object===Object&&e;var w="object"==typeof self&&self&&self.Object===Object&&self;const C=T||w||Function("return this")(),y=C.Symbol;var A=Object.prototype,S=A.hasOwnProperty,O=A.toString,N=y?y.toStringTag:void 0,I=Object.prototype.toString,D=y?y.toStringTag:void 0;const R=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":D&&D in Object(e)?function(e){var t=S.call(e,N),n=e[N];try{e[N]=void 0;var i=!0}catch(e){}var r=O.call(e);return i&&(t?e[N]=n:delete e[N]),r}(e):function(e){return I.call(e)}(e)},k=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},P=function(e){if(!k(e))return!1;var t=R(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},U=C["__core-js_shared__"];var M,x=(M=/[^.]+$/.exec(U&&U.keys&&U.keys.IE_PROTO||""))?"Symbol(src)_1."+M:"",G=Function.prototype.toString;const j=function(e){if(null!=e){try{return G.call(e)}catch(e){}try{return e+""}catch(e){}}return""};var L=/^\[object .+?Constructor\]$/,H=Function.prototype,F=Object.prototype,B=H.toString,V=F.hasOwnProperty,$=RegExp("^"+B.call(V).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const W=function(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){return!(!k(e)||function(e){return!!x&&x in e}(e))&&(P(e)?$:L).test(j(e))}(n)?n:void 0},Q=W(C,"DataView"),K=W(C,"Map"),q=W(C,"Promise"),J=W(C,"Set"),X=W(C,"WeakMap");var Z="[object Map]",ee="[object Promise]",te="[object Set]",ne="[object WeakMap]",ie="[object DataView]",re=j(Q),oe=j(K),se=j(q),ae=j(J),ce=j(X),ue=R;(Q&&ue(new Q(new ArrayBuffer(1)))!=ie||K&&ue(new K)!=Z||q&&ue(q.resolve())!=ee||J&&ue(new J)!=te||X&&ue(new X)!=ne)&&(ue=function(e){var t=R(e),n="[object Object]"==t?e.constructor:void 0,i=n?j(n):"";if(i)switch(i){case re:return ie;case oe:return Z;case se:return ee;case ae:return te;case ce:return ne}return t});const de=ue,le=function(e){return null!=e&&"object"==typeof e},he=function(e){return le(e)&&"[object Arguments]"==R(e)};var Ee=Object.prototype,pe=Ee.hasOwnProperty,ve=Ee.propertyIsEnumerable;const fe=he(function(){return arguments}())?he:function(e){return le(e)&&pe.call(e,"callee")&&!ve.call(e,"callee")},me=Array.isArray,_e=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};var ge=Y&&!Y.nodeType&&Y,be=ge&&z&&!z.nodeType&&z,Te=be&&be.exports===ge?C.Buffer:void 0;const we=(Te?Te.isBuffer:void 0)||function(){return!1};var Ce={};Ce["[object Float32Array]"]=Ce["[object Float64Array]"]=Ce["[object Int8Array]"]=Ce["[object Int16Array]"]=Ce["[object Int32Array]"]=Ce["[object Uint8Array]"]=Ce["[object Uint8ClampedArray]"]=Ce["[object Uint16Array]"]=Ce["[object Uint32Array]"]=!0,Ce["[object Arguments]"]=Ce["[object Array]"]=Ce["[object ArrayBuffer]"]=Ce["[object Boolean]"]=Ce["[object DataView]"]=Ce["[object Date]"]=Ce["[object Error]"]=Ce["[object Function]"]=Ce["[object Map]"]=Ce["[object Number]"]=Ce["[object Object]"]=Ce["[object RegExp]"]=Ce["[object Set]"]=Ce["[object String]"]=Ce["[object WeakMap]"]=!1;var ye=Y&&!Y.nodeType&&Y,Ae=ye&&z&&!z.nodeType&&z,Se=Ae&&Ae.exports===ye&&T.process,Oe=function(){try{return Ae&&Ae.require&&Ae.require("util").types||Se&&Se.binding&&Se.binding("util")}catch(e){}}(),Ne=Oe&&Oe.isTypedArray;const Ie=Ne?function(e){return function(t){return e(t)}}(Ne):function(e){return le(e)&&_e(e.length)&&!!Ce[R(e)]};var De=Object.prototype.hasOwnProperty;const Re=function(e){if(null==e)return!0;if(function(e){return null!=e&&_e(e.length)&&!P(e)}(e)&&(me(e)||"string"==typeof e||"function"==typeof e.splice||we(e)||Ie(e)||fe(e)))return!e.length;var t=de(e);if("[object Map]"==t||"[object Set]"==t)return!e.size;if(f(e))return!function(e){if(!f(e))return m(e);var t=[];for(var n in Object(e))b.call(e,n)&&"constructor"!=n&&t.push(n);return t}(e).length;for(var n in e)if(De.call(e,n))return!1;return!0},ke=new Map,Pe=async(e,t)=>{if(c(t))throw new l("WebSocketClient is not initialized");return Re(e.eventId)&&(e.eventId=(0,E.v4)()),new Promise((n=>{ke.set(e.eventId,n),null==t||t.send(e)}))};function Ue(e){const[t,...n]=e.split(" ");return[t,n.join(" ")]}function Me(e,t={}){for(const n of Object.keys(t))e.set(n,t[n])}function xe(e,t=[]){for(const{ident:n,value:i}of t)e.set(n,i)}function Ge(e){return Object.fromEntries(e)}function je(e){return Array.from(e).map((([e,t])=>({ident:e,value:t})))}class Le{constructor(e,t,n,i){this._customFields=new Map,this._exists=!1,this._websocketClient=i,Le.setId(e),Le.setName(t),n&&Le.setImage(n)}static setId(e){a.set(t.CUSTOMER_ID,e)}static getId(){return a.get(t.CUSTOMER_ID,null)}static getName(){return a.get(t.CUSTOMER_NAME)}static setName(e){a.set(t.CUSTOMER_NAME,e)}static getIdOrCreateNewOne(){let e=this.getId();return e||(e=(0,E.v4)(),this.setId(e)),e}static getImage(){return a.get(t.CUSTOMER_IMAGE)}static setImage(e){a.set(t.CUSTOMER_IMAGE,e)}getId(){return Le.getIdOrCreateNewOne()}getName(){return Le.getName()}setName(e){Le.setName(e)}setImage(e){Le.setImage(e)}setExists(e){this._exists=e}setCustomField(e,t){return this.setCustomFields({[e]:t})}setCustomFields(e){if(Me(this._customFields,e),this._exists)return this.sendCustomFields()}getCustomFields(){return Ge(this._customFields)}setCustomFieldsFromArray(e){xe(this._customFields,e)}getCustomFieldsArray(){return je(this._customFields)}async sendCustomFields(){var e;return Ye((e=je(this._customFields),{eventType:r.YU.SEND_CONSUMER_CUSTOM_FIELDS,data:{customFields:e}}),this._websocketClient)}}function He(e,t){const n=Le.getName(),i=Le.getImage();let r={};if("string"==typeof n&&n.length>0){const[e,t]=Ue(n);r={firstName:e,lastName:t}}return i&&(r.image=i),Object.assign({idOnExternalPlatform:Le.getIdOrCreateNewOne()},r)}const Fe=function(e){return null==e};function Be(){const e=parseInt(a.get(t.BRAND_ID)),n=a.get(t.CHANNEL_ID);if(Fe(e)||isNaN(e)||Fe(n))throw new l(`Cannot get BrandId and ChannelId from SDKVariableStorage \n brandId (${e}) |\n channelId (${n})`);return{brandId:e,channelId:n}}const Ve=function(e){return void 0===e};function $e(e){const{eventType:t,data:n,consumerIdentity:i=He(),destination:r={},visitor:o={}}=e,{brandId:s,channelId:a}=Be();if(Ve(t))throw new l(`Cannot create an event payload because of missing eventType (${t})`);return{eventType:t,brand:{id:Number(s)},channel:{id:a},consumerIdentity:i,data:n,destination:r,visitor:o}}function ze(e,t=(0,E.v4)(),n=i.p.CHAT_WINDOW_EVENT){return{action:n,eventId:t,payload:e}}async function Ye(e,t){const n=ze($e(e));return Pe(n,t)}function We(e,t){return Object.assign(Object.assign(Object.assign({},p(t)),He()),{eventType:r.YU.RECONNECT_CONSUMER,data:{accessToken:{token:e.token}}})}let Qe=null;function Ke(e,t){null!==Qe&&clearTimeout(Qe),Qe=setTimeout(t,1e3*function(e){const t=Math.round(.9*e);return t<20?20:t}(e.expiresIn))}const qe=e=>{var t;const n=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.status;return(null==e?void 0:e.type)===r.Ne.CONSUMER_AUTHORIZED&&"success"===n};function Je(e){var t,n;return(null==e?void 0:e.type)===r.Ne.TOKEN_REFRESHED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.accessToken)||void 0===n?void 0:n.token)}var Xe;!function(e){e.AU1="AU1",e.CA1="CA1",e.EU1="EU1",e.JP1="JP1",e.NA1="NA1",e.UK1="UK1",e.custom="custom"}(Xe||(Xe={}));var Ze=o(403);const et=Object.assign(Object.assign(Object.assign({},Ze.m),r.Ne),{AGENT_TYPING_STARTED:"AgentTypingStarted",AGENT_TYPING_ENDED:"AgentTypingEnded",ASSIGNED_AGENT_CHANGED:"AssignedAgentChanged",CONTACT_CREATED:"ContactCreated",CONTACT_STATUS_CHANGED:"ContactStatusChanged",CONTACT_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED:"ContactToRoutingQueueAssignmentChanged"});class tt extends CustomEvent{}class nt{constructor(){this.middlewares=[]}register(e){this.middlewares.push(e)}process(e){if(Fe(e))return null;let t=e;for(const e of this.middlewares){if(null===t)return null;t=e(t)}return t}}const it=EventTarget;function rt(e){return!Fe(null==e?void 0:e.user)}var ot=o(910),st=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n};const at={id:"",data:null,type:void 0,createdAt:new Date};function ct(e){var t;if(!(e=>"eventId"in e)(e))return at;if((e=>"error"in e)(e))return{createdAt:(0,ot.Nf)(null!==(t=e.createdAt)&&void 0!==t?t:(new Date).toString()),data:null,error:e.error,id:e.eventId};const n=(e=>"eventType"in e)(e)?e.eventType:void 0;if((e=>"data"in e)(e))return{createdAt:(0,ot.Nf)(e.createdAt),context:e.context,data:e.data,id:e.eventId,type:n};if((e=>{const t=null==e?void 0:e.postback;return!1===Re(t)})(e)){const{postback:{data:t,eventType:n},eventId:i}=e,r=st(e,["postback","eventId"]);return{type:n,data:Object.assign(Object.assign({},r),t),createdAt:(0,ot.Nf)(e.createdAt),id:i}}const{eventId:i}=e,r=st(e,["eventId"]);return Object.assign(Object.assign({data:void 0},r),{id:i,type:n,createdAt:(0,ot.Nf)(e.createdAt)})}const ut={[et.SENDER_TYPING_STARTED]:function(e){return rt(e.data)?Object.assign(Object.assign({},e),{type:et.AGENT_TYPING_STARTED}):e},[et.SENDER_TYPING_ENDED]:function(e){return rt(e.data)?Object.assign(Object.assign({},e),{type:et.AGENT_TYPING_ENDED}):e},[et.CASE_INBOX_ASSIGNEE_CHANGED]:function(e){return Object.assign(Object.assign({},e),{type:et.ASSIGNED_AGENT_CHANGED})},[et.CASE_CREATED]:function(e){return Object.assign(Object.assign({},e),{type:et.CONTACT_CREATED})},[et.CASE_STATUS_CHANGED]:function(e){return Object.assign(Object.assign({},e),{type:et.CONTACT_STATUS_CHANGED})},[et.CASE_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED]:function(e){return Object.assign(Object.assign({},e),{type:et.CONTACT_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED})},[et.LIVECHAT_RECOVERED]:function(e){const t=e.data.contactHistory.map(ct);return Object.assign(Object.assign({},e),{data:Object.assign(Object.assign({},e.data),{contactHistory:t})})},[et.THREAD_RECOVERED]:function(e){const t=e.data.contactHistory.map(ct);return Object.assign(Object.assign({},e),{data:Object.assign(Object.assign({},e.data),{contactHistory:t})})}};function dt(e){return e.type&&void 0!==ut[e.type]?ut[e.type](e):e}function lt(e){const t=!1===Ve(null==e?void 0:e.id);return 0==(!1===Ve(e.error))&&t}class ht extends l{}var Et=o(115),pt=o(893),vt=o(415);class ft extends Error{constructor(e,t=""){super(`[WebSocketClientError]: ${e}${t?` (${t})`:""}`),this.name="WebSocketClientError"}}class mt{constructor(e,t,n,i,r){this.brandId=e,this.channelId=t,this.customerId=n,this.options=i,this.onError=r,this._connection=null,this.connect()}connect(){var e,i,r,o,s,c,u,d,l,h,E,p;const v=(null===(e=this.options)||void 0===e?void 0:e.port)?`:${null===(i=this.options)||void 0===i?void 0:i.port}`:"",f=(null===(r=this.options)||void 0===r?void 0:r.host)?`${null===(o=this.options)||void 0===o?void 0:o.host}${v}`:"",m=null!==(c=null===(s=this.options)||void 0===s?void 0:s.prefix)&&void 0!==c?c:"",_=null===(d=null===(u=this.options)||void 0===u?void 0:u.forceSecureProtocol)||void 0===d||d,g=function(e,n,i,r,o){const s={brandId:i,channelId:r,consumerId:o,v:a.get(t.APP_VERSION)};return`${e}/${n}?${(0,pt.P)(s)}`}(f,m,this.brandId,this.channelId,this.customerId);this._connection=(0,vt.setupSocketConnection)(g,{startClosed:!0,forceSecureProtocol:_});const b=this._errorHandler.bind(this);null===(l=this._connection)||void 0===l||l.addEventListener(n.xT.CLOSE,b),null===(h=this._connection)||void 0===h||h.addEventListener(n.xT.ERROR,b),null===(p=null===(E=this._connection)||void 0===E?void 0:E.socket)||void 0===p||p.reconnect()}disconnect(){var e;null===(e=this._connection)||void 0===e||e.socket.close()}reconnect(){var e;null===(e=this._connection)||void 0===e||e.socket.reconnect()}send(e){var t;const n=JSON.stringify(e);null===(t=this._connection)||void 0===t||t.send(n)}on(e,t){var n;null===(n=this._connection)||void 0===n||n.addEventListener(e,t)}off(e,t){var n;null===(n=this._connection)||void 0===n||n.removeEventListener(e,t)}_errorHandler(e){const t=e.detail;let n;if(t instanceof ErrorEvent&&(n=new ft("Connection error",t.message)),t instanceof CloseEvent&&(n=new ft("Connection closed",t.reason)),void 0===n&&(n=new ft("Unknown error",t.type)),"function"!=typeof this.onError)throw n;this.onError(n)}}var _t=o(880),gt=o(585),bt=o.n(gt),Tt=o(58);const wt=()=>navigator.language,Ct=()=>Intl.DateTimeFormat().resolvedOptions().timeZone;function yt(e){switch(e){case"mobile":return Tt.Yi.MOBILE;case"tablet":return Tt.Yi.TABLET;default:return Tt.Yi.DESKTOP}}const At=(e={})=>{var t,n,i,r;const o=new(bt())(navigator.userAgent),{country:s="",location:a=Ct(),language:c=wt(),ip:u=null}=e;return{browser:null!==(t=o.getBrowser().name)&&void 0!==t?t:null,browserVersion:null!==(n=o.getBrowser().version)&&void 0!==n?n:null,country:s,ip:u,language:c,location:a,os:null!==(i=o.getOS().name)&&void 0!==i?i:null,osVersion:null!==(r=o.getOS().version)&&void 0!==r?r:null,deviceType:yt(o.getDevice().type),applicationType:Tt.vQ.BROWSER}};var St=o(354);class Ot extends l{}const Nt=async(e,n,i)=>{const r=await(async e=>{const t=await function(e){return new Promise(((t,n)=>{const i=new FileReader;i.onloadend=()=>{t(i)},i.onerror=e=>{var t,i;return n(null===(i=null===(t=e.target)||void 0===t?void 0:t.error)||void 0===i?void 0:i.message)},i.readAsDataURL(e)}))}(e);if(null!==t.error)throw new l(`Cannot create payload for attachment upload because of error (${t.error.message})`);if("string"!=typeof t.result)throw new l(`Cannot create payload for attachment upload because of missing:\n reader result (${t.result})`);return{url:t.result,name:e.name,mimeType:e.type}})(e),o=await async function(e,n,i){const r=a.get(t.ENDPOINT_CHAT),{url:o,name:s,mimeType:c}=i,u={content:o.split(";base64,")[1],fileName:s,mimeType:c},d=await fetch(`${r}/chat/1.0/brand/${e}/channel/${n}/attachment`,{method:"POST",body:JSON.stringify(u),headers:{"Content-Type":"application/json",[St.GO]:a.get(t.APP_NAME)}});if(!d.ok)throw new l(`Failed to upload Attachments. Status (${d.status})`);return d.json()}(n,i,r);if(!1===Ve(null==(s=o)?void 0:s.fileUrl))return{url:o.fileUrl,friendlyName:r.name};var s;if(function(e){return!1===Ve(null==e?void 0:e.allowedFileSize)}(o))throw new Ot("Upload attachment failed",o);throw new l(`Unknown file upload response (${o})`)};function It(e){var t,n;return e.type===et.CONTACT_STATUS_CHANGED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.case)||void 0===n?void 0:n.id)}function Dt(e){var t,n;return e.type===et.CONTACT_CREATED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.case)||void 0===n?void 0:n.id)}function Rt(e){var t,n;return e.type===et.CONTACT_TO_ROUTING_QUEUE_ASSIGNMENT_CHANGED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.case)||void 0===n?void 0:n.id)}function kt(e){return e.type===Ze.m.CONTACT_RECIPIENTS_CHANGED}const Pt=(e,t,n,i=At())=>({messageContent:e,browserFingerprint:i,idOnExternalPlatform:t,thread:{idOnExternalPlatform:n},consumer:{customFields:[]},consumerContact:{customFields:[]},attachments:[]});function Ut(e){var t;return e.type===r.Ne.MORE_MESSAGES_LOADED&&void 0!==(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.messages)}const Mt=e=>({eventType:r.YU.LOAD_MORE_MESSAGES,data:e});class xt extends l{}class Gt extends l{}const jt=e=>e.type===r.Ne.THREAD_METADATA_LOADED&&void 0!==e.data.lastMessage,Lt=e=>{const t=e.data,n=!1===Ve(t),i=!1===Ve(null==t?void 0:t.messages),o=e.type===r.Ne.THREAD_RECOVERED||e.type===r.Ne.LIVECHAT_RECOVERED,s=Ve(e.error);return n&&i&&s&&o};function Ht(e){return e.type===r.Ne.THREAD_ARCHIVED}class Ft extends l{}function Bt(e){const t={eventType:r.YU.RECOVER_THREAD,data:{}};return void 0===e?t:Object.assign(Object.assign({},t),{data:{thread:{idOnExternalPlatform:e}}})}class Vt extends l{}class $t extends l{}class zt{constructor(e,t,n,i,r={},o=!1){this._exists=!1,this._typingTimeoutID=void 0,this._isAuthorizationEnabled=!1,this._customFields=new Map,this._typingPreviewText="",this.idOnExternalPlatform=e,this._websocketClient=t,this._messageEmitter=n,this._customer=i,this._isAuthorizationEnabled=o,Me(this._customFields,r),this._registerEventHandlers()}async recover(){const e=await Ye(Bt(this.idOnExternalPlatform),this._websocketClient);if(Lt(e)){const t=e.data,{contact:n,consumerContact:i}=t,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["contact","consumerContact"]);return Object.assign(Object.assign({},r),{contact:null!=n?n:i})}throw new $t("Thread recover fail",e)}async sendMessage(e){return(async(e,t)=>{const n=(i=e,{eventType:r.YU.SEND_MESSAGE,data:i});var i;const o=await Ye(n,t);if(lt(o))return o;throw new ht("Send message failed",o)})(this._mergeCustomFieldsAndAccessTokenWithMessageData(e,!1),this._websocketClient)}async sendTextMessage(e,t={}){const{messageId:n=(0,E.v4)(),browserFingerprint:i=At()}=t,r=function(e){return{payload:{text:e},type:Et.C.TEXT}}(e),o=Pt(r,n,this.idOnExternalPlatform,i);return this.sendMessage(o)}async sendPostbackMessage(e,t,n={}){const{messageId:i=(0,E.v4)(),browserFingerprint:r=At()}=n,o=function(e,t){return{payload:{text:t,postback:e},postback:e,type:Et.C.TEXT}}(e,t),s=Pt(o,i,this.idOnExternalPlatform,r);return this.sendMessage(s)}async sendOutboundMessage(e){return(async(e,t)=>{const n=(i=e,{eventType:r.YU.SEND_OUTBOUND,data:i});var i;const o=await Ye(n,t);if(lt(o))return o;throw new ht("Send Outbound message failed",o)})(this._mergeCustomFieldsAndAccessTokenWithMessageData(e,!0),this._websocketClient)}async loadMoreMessages(){var e;const{scrollToken:n,oldestMessageDatetime:i}=null!==(e=JSON.parse(a.get(t.THREAD_DATA,"{}")))&&void 0!==e?e:{};if(Re(n))return null;const r={scrollToken:n,oldestMessageDatetime:i,thread:{idOnExternalPlatform:this.idOnExternalPlatform}},o=await Ye(Mt(r),this._websocketClient);if(Ut(o))return o;throw new Ft("Load more messages failed",o)}async lastMessageSeen(){var e;return Ye((e=this.idOnExternalPlatform,{eventType:r.YU.MESSAGE_SEEN,data:{thread:{idOnExternalPlatform:e}}}),this._websocketClient)}async sendAttachments(e,t={}){if(Ve(e)||0===e.length)throw new l("FileList must be provided to sendAttachment method");const n=await(async(e,t,n={})=>{const{brandId:i,channelId:r}=Be();try{const o=await Promise.all(Array.from(e).map((async e=>Nt(e,i,r)))),{messageId:s=(0,E.v4)(),browserFingerprint:a=At()}=n;return{messageContent:{type:Et.C.TEXT,payload:{text:""}},attachments:o,browserFingerprint:a,thread:{idOnExternalPlatform:t},idOnExternalPlatform:s,consumer:{customFields:[]},consumerContact:{customFields:[]}}}catch(e){if(e instanceof Ot)throw e;if(e instanceof Error)throw new l(`Send attachment failed because of (${e.message})`);throw new l("Unknown error during file upload")}})(e,this.idOnExternalPlatform,t);return this.sendMessage(n)}keystroke(e=1e3,t){var n;this._typingTimeoutID||Ye((n=this.idOnExternalPlatform,{eventType:r.YU.SENDER_TYPING_STARTED,data:{thread:{idOnExternalPlatform:n}}}),this._websocketClient),clearTimeout(this._typingTimeoutID),this._typingTimeoutID=setTimeout((()=>{this._stopTypingCallback(t)}),e)}stopTyping(){this._stopTypingCallback()}_stopTypingCallback(e){var t;clearTimeout(this._typingTimeoutID),this._typingTimeoutID=void 0,Ye((t=this.idOnExternalPlatform,{eventType:r.YU.SENDER_TYPING_ENDED,data:{thread:{idOnExternalPlatform:t}}}),this._websocketClient),"function"==typeof e&&e()}keystrokeForPreview(e,t=1250){this._typingPreviewText=e,this._typingForPreviewTimeoutID||(this._typingForPreviewTimeoutID=setTimeout((()=>{this.stopTypingForPreview()}),t))}stopTypingForPreview(e=!0){clearTimeout(this._typingForPreviewTimeoutID),this._typingForPreviewTimeoutID=void 0;const t=this._typingPreviewText;this._typingPreviewText="",!1!==e&&this.sendMessagePreview(t)}async getMetadata(){const e=await Ye((t=this.idOnExternalPlatform,{eventType:r.YU.LOAD_THREAD_METADATA,data:{thread:{idOnExternalPlatform:t}}}),this._websocketClient);var t;if(jt(e))return e;throw new Gt("Get metadata failed",e)}onThreadEvent(e,t){const n=((e,t)=>n=>{(e=>{var t,n,i,r,o,s,a;const c=e;return null!==(s=null!==(r=null!==(n=null===(t=null==c?void 0:c.thread)||void 0===t?void 0:t.idOnExternalPlatform)&&void 0!==n?n:null===(i=null==c?void 0:c.case)||void 0===i?void 0:i.threadIdOnExternalPlatform)&&void 0!==r?r:null===(o=null==c?void 0:c.message)||void 0===o?void 0:o.threadIdOnExternalPlatform)&&void 0!==s?s:null===(a=null==c?void 0:c.messagePreview)||void 0===a?void 0:a.threadIdOnExternalPlatform})(n.detail.data)===e&&t(n)})(this.idOnExternalPlatform,t);return this._messageEmitter.addEventListener(e,n),()=>{this._messageEmitter.removeEventListener(e,n)}}async sendCustomFields(){var e,t;return Ye((e=je(this._customFields),t=this.idOnExternalPlatform,{eventType:r.YU.SET_CONSUMER_CONTACT_CUSTOM_FIELD,data:{customFields:e,thread:{idOnExternalPlatform:t}}}),this._websocketClient)}async setCustomFields(e){Me(this._customFields,e),!1!==this._exists&&await this.sendCustomFields()}setCustomField(e,t){return this.setCustomFields({[e]:t})}async archive(){const e=await Ye((t=this.idOnExternalPlatform,{eventType:r.YU.ARCHIVE_THREAD,data:{thread:{idOnExternalPlatform:t}}}),this._websocketClient);var t;if(Ht(e))return!0;throw new xt("Archive Thread failed",e)}async setName(e){const t=(n=this.idOnExternalPlatform,i=e,{eventType:r.YU.UPDATE_THREAD,data:{thread:{idOnExternalPlatform:n,threadName:i}}});var n,i;const o=await Ye(t,this._websocketClient);if(function(e){return Ve(e.error)}(o))return!0;throw new Vt("Set Thread name failed",o)}async sendMessagePreview(e){const t=((e,t)=>({eventType:r.YU.SEND_MESSAGE_PREVIEW,data:{thread:{idOnExternalPlatform:e},messageContent:{payload:{text:t},type:Et.C.TEXT}}}))(this.idOnExternalPlatform,e);await Ye(t,this._websocketClient)}async sendTranscript(e,t){const n=((e,t)=>({eventType:r.YU.SEND_TRANSCRIPT,data:{consumerContact:{id:e},consumerRecipients:[{idOnExternalPlatform:t}]}}))(e,t);return Ye(n,this._websocketClient)}_setThreadAndCustomerExists(){var e;this._exists=!0,null===(e=this._customer)||void 0===e||e.setExists(!0)}_clearCustomFieldsOnContactStatusChangedToClosed(e){const t=e.detail;It(t)&&t.data.case.status===_t.P.CLOSED&&this._customFields.clear()}_mergeCustomFieldsAndAccessTokenWithMessageData(e,t){var n,i,r,o,s,a;let c;const u=null!==(n=this._isAuthorizationEnabled&&d())&&void 0!==n&&n;!1!==u&&(c={token:u.token}),xe(this._customFields,e.consumerContact.customFields);const l={customFields:je(this._customFields)};let h;return t||(null===(i=this._customer)||void 0===i||i.setCustomFieldsFromArray(null!==(o=null===(r=e.consumer)||void 0===r?void 0:r.customFields)&&void 0!==o?o:[]),h={customFields:null!==(a=null===(s=this._customer)||void 0===s?void 0:s.getCustomFieldsArray())&&void 0!==a?a:[]}),Object.assign(Object.assign({},e),{accessToken:c,consumer:h,consumerContact:l})}_registerEventHandlers(){this.onThreadEvent(et.CASE_CREATED,(()=>this._setThreadAndCustomerExists())),this.onThreadEvent(et.CONTACT_CREATED,(()=>this._setThreadAndCustomerExists())),this.onThreadEvent(et.THREAD_RECOVERED,(()=>this._setThreadAndCustomerExists())),this.onThreadEvent(et.CONTACT_STATUS_CHANGED,(e=>this._clearCustomFieldsOnContactStatusChangedToClosed(e)))}}function Yt(e){const t={eventType:r.YU.RECOVER_LIVECHAT,data:{}};return void 0===e?t:Object.assign(Object.assign({},t),{data:{thread:{idOnExternalPlatform:e}}})}class Wt extends zt{constructor(e,t,n,i,r={},o=!1){super(e,t,n,i,r,o),this._isInitialized=!1,this._canSendMessage=!0,this._registerLivechatEventHandlers()}async recover(){const e=await Ye(Yt(this.idOnExternalPlatform),this._websocketClient);if(Lt(e)){const t=e.data,{contact:n,consumerContact:i}=t,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["contact","consumerContact"]);return Object.assign(Object.assign({},r),{contact:null!=n?n:i})}throw new $t("Thread recover fail",e)}async sendMessage(e){if(!1===this._canSendMessage)throw new l("Cannot send more messages to Contact");return super.sendMessage(e)}async startChat(e="Begin conversation"){if(this._isInitialized)throw new l("Chat is already initialized");try{const t=await this.sendTextMessage(e);return this._isInitialized=!0,t}catch(e){if(e instanceof Error)throw new l(`Sending initial message failed because of (${e.message})`);return}}async endChat(){const e=a.get(t.THREAD_DATA,"{}"),n=JSON.parse(e),i=null==n?void 0:n.contactId;if(Ve(i))throw new l("Cannot end Chat because of missing ContactId in the storage");await Ye(function(e,t){return{eventType:r.YU.END_CONTACT,data:{thread:{idOnExternalPlatform:e},contact:{id:t}}}}(this.idOnExternalPlatform,i),this._websocketClient)}async loadMoreMessages(){var e;const{scrollToken:n,oldestMessageDatetime:i,contactId:r}=null!==(e=JSON.parse(a.get(t.THREAD_DATA,"{}")))&&void 0!==e?e:{};if(Re(n)||Re(r))return null;const o={scrollToken:n,oldestMessageDatetime:i,thread:{idOnExternalPlatform:this.idOnExternalPlatform},contact:{id:r}},s=await Ye(Mt(o),this._websocketClient);if(Ut(s))return s;throw new Ft("Load more messages failed",s)}_registerLivechatEventHandlers(){this.onThreadEvent(et.LIVECHAT_RECOVERED,(e=>{Lt(e.detail)&&this._setThreadAndCustomerExists()}))}}const Qt=e=>!c(e)&&"threads"in e;function Kt(e){const n=a.get(t.THREAD_DATA,"{}"),i=JSON.parse(n)||{};a.set(t.THREAD_DATA,JSON.stringify(Object.assign(Object.assign({},i),{contactId:e})))}function qt(e){var t,n,i;return Dt(e)&&Kt(e.data.case.id),Lt(e)&&Kt(null!==(n=null===(t=e.data.consumerContact)||void 0===t?void 0:t.caseId)&&void 0!==n?n:null===(i=e.data.contact)||void 0===i?void 0:i.id),e}function Jt(e){var n;const i=null===(n=(c=null==(s=e.messages)?0:s.length)?s[c-1]:void 0)||void 0===n?void 0:n.createdAt,r=a.get(t.THREAD_DATA,"{}"),o=JSON.parse(r)||{};var s,c;a.set(t.THREAD_DATA,JSON.stringify(Object.assign(Object.assign({},o),{scrollToken:e.scrollToken,oldestMessageDatetime:Ve(i)?"":i})))}function Xt(e){if(Lt(e)){const{messages:t,messagesScrollToken:n}=e.data;Jt({messages:t,scrollToken:n})}if(Ut(e)){const{scrollToken:t,messages:n}=e.data;Jt({scrollToken:t,messages:n})}return e}class Zt extends Error{constructor(e="Aborted"){super(e),this.name="AbortError"}}class en extends Promise{constructor(e){const t=new AbortController,n=t.signal;super(((t,i)=>{n.addEventListener("abort",(()=>{i(new Zt(this.abortReason))})),null==e||e(t,i,n)})),this.abort=e=>{this._abortReason=null!=e?e:"Aborted",t.abort()}}get abortReason(){return this._abortReason}}en.from=e=>e instanceof en?e:new en(((t,n)=>{e.then(t).catch(n)}));class tn{constructor(e){var n,i;if(this.isLivechat=!1,this.channelId="",this.websocketClient=null,this.customer=null,this._incomingChatEventMiddleware=new nt,this.isAuthorizationEnabled=!1,this._threadCache=new Map,this._contactCustomFieldsQueue=new Map,this._sendRefreshTokenEvent=async()=>{const e=d();if(c(e))return;const t=await Ye((n=e.token,{eventType:r.YU.REFRESH_TOKEN,data:{accessToken:{token:n}}}),this.websocketClient);var n;if(Je(t))return u(t.data.accessToken),void Ke(t.data.accessToken,this._sendRefreshTokenEvent);throw new h("An error occurred while refreshing the access token",t.error)},void 0===e)throw new l("No options was provided for initialization of ChatSdk");a.set(t.AUTHORIZATION_CODE,e.authorizationCode),a.set(t.BRAND_ID,`${e.brandId}`),a.set(t.CHANNEL_ID,e.channelId),a.set(t.APP_NAME,null!==(n=e.appName)&&void 0!==n?n:"chat-web-sdk"),a.set(t.APP_VERSION,`${null!==(i=e.appVersion)&&void 0!==i?i:0}`);const{brandId:o,channelId:s}=Be();this.onError=e.onError,this.onRawEvent=e.onRawEvent,this._incomingChatEventMiddleware.register(dt),this._incomingChatEventMiddleware.register(Xt),this._incomingChatEventMiddleware.register(qt),this._messageEmitter=new it;try{if(isNaN(o))throw new Error("Missing BrandID");if(void 0===s)throw new Error("Missing ChannelId");if(void 0===e.customerId)throw new Error("Missing CustomerId");this._initEnvironment(e),this._initWS(o,s,e.customerId),this.customer=new Le(e.customerId,e.customerName,e.customerImage,this.websocketClient),this.channelId=s}catch(e){this.onErrorHandler(e)}}onErrorHandler(e){if("function"!=typeof this.onError)throw new l(e);this.onError(new l(e))}async authorize(e,n){var o,s,c,v,f,m,_;const g=d();if(null!==g)try{const e=await async function(e,t,n,i){const r=We(n,i),o=await Ye(r,e);if(void 0!==o.error)throw new h("Authorization reconnect failed",o.error);return Ke(n,t),{reconnected:!0}}(this.websocketClient,this._sendRefreshTokenEvent,g,n);return e}catch(e){}const b=function(e,t=(0,E.v4)()){return Object.assign({eventType:r.YU.AUTHORIZE_CUSTOMER,data:{authorization:{authorizationCode:e}}},p(t))}(null!=e?e:a.get(t.AUTHORIZATION_CODE,null),n),T=ze($e(b),(0,E.v4)(),i.p.REGISTER),w=await Pe(T,this.websocketClient);if(!qe(w))throw null===(o=this.websocketClient)||void 0===o||o.disconnect(),new h("Authorization failed",w.error);const{consumerIdentity:C,customer:y,channel:A,contact:S}=w.data,O=null==C?void 0:C.idOnExternalPlatform;if(Fe(N=O)||""===N)throw null===(s=this.websocketClient)||void 0===s||s.disconnect(),new l("Invalid customer identity");var N;Le.setId(O),void 0===C.firstName&&void 0===C.lastName||Le.setName(`${C.firstName} ${C.lastName}`);const I=C.image;return void 0!==I&&Le.setImage(I),(null==y?void 0:y.customFields)&&(null===(c=this.customer)||void 0===c||c.setCustomFieldsFromArray(y.customFields)),(null==S?void 0:S.customFields)&&xe(this._contactCustomFieldsQueue,S.customFields),this.isLivechat=null!==(f=null===(v=null==A?void 0:A.settings)||void 0===v?void 0:v.isLivechat)&&void 0!==f&&f,this.isAuthorizationEnabled=null!==(m=null==A?void 0:A.settings.isAuthorizationEnabled)&&void 0!==m&&m,void 0!==(null===(_=w.data.accessToken)||void 0===_?void 0:_.token)&&(u(w.data.accessToken),Ke(w.data.accessToken,this._sendRefreshTokenEvent)),w.data}async generateAuthorizationToken(e,t){const n=await Ye(function(e,t){return{eventType:r.YU.GENERATE_AUTHORIZATION_TOKEN,data:{thread:{idOnExternalPlatform:e},url:t}}}(e,t),this.websocketClient);if(!("authorizationToken"in n.data))throw new l("Invalid response from generate authorization token (generateAuthorizationToken)");const{authorizationToken:i}=n.data;return i}onChatEvent(e,t){return this._messageEmitter.addEventListener(e,t),()=>{this._messageEmitter.removeEventListener(e,t)}}getCustomer(){return this.customer}getThread(e){if(c(this.websocketClient))throw new l("Cannot get thread because websocket is disconnected");if(Fe(e))throw new l("Cannot get thread because id is undefined");const t=this._threadCache.get(e);if(!Ve(t))return t;if(this.isLivechat){const t=new Wt(e,this.websocketClient,this._messageEmitter,this.customer,this._getContactCustomFieldsFromQueue(),this.isAuthorizationEnabled);return this._threadCache.set(e,t),t}const n=new zt(e,this.websocketClient,this._messageEmitter,this.customer,this._getContactCustomFieldsFromQueue(),this.isAuthorizationEnabled);return this._threadCache.set(e,n),n}async getThreadList(){if(c(this.websocketClient))throw new l("Cannot get thread list because websocket is disconnected");const e={eventType:r.YU.FETCH_THREAD_LIST,data:{}},t=await Ye(e,this.websocketClient);if(!Qt(t.data))throw new l("Invalid response from fetch thread list (getThreadList)");return t.data.threads}getWebsocketClient(){return this.websocketClient}async sendOfflineMessage(e){return(async(e,t)=>{const n=(e=>{const[t,...n]=e.name.split(" ").reverse(),i=n.reverse().join(" "),o={idOnExternalPlatform:e.email,firstName:i,lastName:t},s={messageContent:{type:Et.C.TEXT,payload:{text:e.message}}};return{eventType:r.YU.SEND_OFFLINE_MESSAGE,consumerIdentity:o,data:s}})(e),i=await Ye(n,t);if(lt(i))return i;throw new ht("Send offline message failed",i)})(e,this.websocketClient)}recoverThreadData(e){return new en((async(t,n)=>{const i=Bt(e),r=await Ye(i,this.websocketClient);Lt(r)?t(r):n(new l("Invalid response from recover livechat thread"))}))}recoverLivechatThreadData(e){return new en((async(t,n)=>{const i=Yt(e),r=await Ye(i,this.websocketClient);Lt(r)?t(r):n(new l("Invalid response from recover livechat thread"))}))}_getContactCustomFieldsFromQueue(){if(this._contactCustomFieldsQueue.size>0){const e=Ge(this._contactCustomFieldsQueue);return this._contactCustomFieldsQueue.clear(),e}return{}}_initEnvironment(e){var n,i;if(e.environment===Xe.custom){if(Re(e.customEnvironment))throw new l('customEnvironment must be provided when environment is set to "custom"');return a.set(t.ENDPOINT_GATEWAY,null===(n=e.customEnvironment)||void 0===n?void 0:n.gateway),void a.set(t.ENDPOINT_CHAT,null===(i=e.customEnvironment)||void 0===i?void 0:i.chat)}const{gateway:r,chat:o}=function(e){const t="{ENV}",n="https://channels-de-{ENV}.niceincontact.com",i="wss://chat-gateway-de-{ENV}.niceincontact.com";switch(e){case Xe.AU1:return{chat:n.replace(t,"au1"),name:"Australia",gateway:i.replace(t,"au1")};case Xe.CA1:return{chat:n.replace(t,"ca1"),name:"Canada",gateway:i.replace(t,"ca1")};case Xe.EU1:return{chat:n.replace(t,"eu1"),name:"Europe",gateway:i.replace(t,"eu1")};case Xe.JP1:return{chat:n.replace(t,"jp1"),name:"Japan",gateway:i.replace(t,"jp1")};case Xe.NA1:return{chat:n.replace(t,"na1"),name:"North America",gateway:i.replace(t,"na1")};case Xe.UK1:return{chat:n.replace(t,"uk1"),name:"United Kingdom",gateway:i.replace(t,"uk1")};case Xe.custom:return{chat:"",name:"Custom",gateway:""};default:throw new l(`Unknown environment: ${e}`)}}(e.environment);a.set(t.ENDPOINT_GATEWAY,r),a.set(t.ENDPOINT_CHAT,o)}_initWS(e,i,r){const o=a.get(t.ENDPOINT_GATEWAY);!function(e){if(null==e)throw Error(`Expected non-nullish value, got ${e}`)}(o);const s=new URL(o),c=s.protocol,u={host:s.hostname,port:s.port,prefix:s.pathname.substring(1),forceSecureProtocol:"wss:"===c};this.websocketClient=new mt(e,i,r,u,this.onError),this.websocketClient.on(n.xT.MESSAGE,(async e=>{try{"function"==typeof this.onRawEvent&&this.onRawEvent(e);const t=await(async e=>{if(Fe(e))return null;if(e.type!==Ze.m.EVENT_IN_S3)return e;const t=e.data.s3Object.url,n=await fetch(t);if(n.ok)return ct(await n.json());throw new l("Failed to fetch S3 event data")})((e=>{const t=null==e?void 0:e.detail;if(!t)return;let n;try{n=JSON.parse(t.data)}catch(e){return}return ct(n)})(e)),n=this._incomingChatEventMiddleware.process(t);if(!Fe(n)){const{type:e}=n;(e=>{const{id:t}=e;if(ke.has(t)){const n=ke.get(t);"function"==typeof n&&n(e),ke.delete(t)}})(n),this._messageEmitter.dispatchEvent(new tt(null!=e?e:"",{detail:n}))}}catch(e){this.onErrorHandler(e)}}))}}function nn(e){var t,n;return e.type===et.ASSIGNED_AGENT_CHANGED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.case)||void 0===n?void 0:n.id)}function rn(e){var t,n;return e.type===et.AGENT_TYPING_STARTED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.thread)||void 0===n?void 0:n.idOnExternalPlatform)}function on(e){var t,n;return e.type===et.AGENT_TYPING_ENDED&&void 0!==(null===(n=null===(t=e.data)||void 0===t?void 0:t.thread)||void 0===n?void 0:n.idOnExternalPlatform)}var sn=o(510);const an=e=>{var t,n,i,r,o,s;return e.direction===sn.T.INBOUND?null!==(n=null===(t=e.authorEndUserIdentity)||void 0===t?void 0:t.fullName)&&void 0!==n?n:"":`${null!==(r=null===(i=e.authorUser)||void 0===i?void 0:i.firstName)&&void 0!==r?r:""} ${null!==(s=null===(o=e.authorUser)||void 0===o?void 0:o.surname)&&void 0!==s?s:""}`.trim()};function cn(e){const t=!1===Ve(e.id),n=!1===Ve(e.direction),i=!1===Ve(e.messageContent);return t&&n&&i}function un(e){return e.type===Ze.m.MESSAGE_CREATED}function dn(e){return e.type===Ze.m.MESSAGE_SENT}function ln(e){return e.type===Ze.m.MESSAGE_READ_CHANGED}const hn=e=>{const t=e;return Number.isInteger(null==t?void 0:t.data.positionInQueue)&&!1===Re(null==t?void 0:t.id)&&(null==t?void 0:t.type)===r.Ne.SET_POSITION_IN_QUEUE};class En extends l{}function pn(e){return{eventType:r.YU.CREATE_GROUP_CHAT_INVITE,data:{contact:{id:e}}}}async function vn(e,t){const n=await Ye(e,t);if(function(e){return e.type===et.GROUP_CHAT_INVITE_CREATED}(n))return n;throw new En("Create invitation failed",n)}class fn extends l{}function mn(e){return{eventType:r.YU.JOIN_GROUP_CHAT,data:{invitation:{code:e}}}}async function _n(e,t){const n=await Ye(e,t);if(function(e){return e.type===et.GROUP_CHAT_JOINED}(n))return n;throw new fn("Join Group chat failed",n)}function gn(e){return{eventType:r.YU.LEAVE_GROUP_CHAT,data:{contact:{id:e}}}}async function bn(e,t){return Ye(e,t)}class Tn extends l{}function wn(e,t,n){return{eventType:r.YU.SEND_EMAIL_INVITE_TO_GROUP_CHAT,data:{contact:{id:e},invitation:{code:t},recipients:[{idOnExternalPlatform:n}]}}}async function Cn(e,t){const n=await Ye(e,t);if(function(e){return e.type===et.GROUP_CHAT_INVITE_SENT}(n))return n;throw new Tn("Send Email Invitation failed",n)}function yn(e){return"object"==typeof e&&null!==e&&"reconnected"in e&&!0===e.reconnected}const An=tn})(),s})(),z.exports=W(Q,q());var J=g.exports,X=t(J);function Z(e){return Boolean(e.allowedFileSize&&e.allowedFileTypes)}const ee="[NiceDFOServiceDesk]";class te extends m{constructor(){super(...arguments),this.isChannelOnline=!1}async ensureSDK(){if(this.sdk)return;this.persistedState()?a(`${ee} Retrieved previous state`,this.persistedState()):this.updatePersistedState({customerID:null,lastAgentMessageID:null,contactID:null,threadID:null},!1);const e=this.config;a(`${ee} Creating integration using config`,e);let{customerID:t}=this.persistedState();t||(t=!0===e.useWebChatUserID?this.state.userID:!1===e.useWebChatUserID||this.state.userID.startsWith(f)?c(u.MISCELLANEOUS):this.state.userID,this.updatePersistedState({customerID:t})),a(`${ee} Using customer ID "${t}"`);const n={brandId:e.brandID,channelId:e.channelID,environment:e.environment,customerId:t},i={type:"agent:niceDFO:getAuthCode",authCode:null,visitorID:null};await this.eventBus.fire(i,this.instance),this.sdk=new X(n),a(`${ee} Authorizing...`);const r=await this.sdk.authorize(i.authCode,i.visitorID);a(`${ee} Authorize complete`,r),this.isChannelOnline="online"===r.channel?.availability?.status,this.sdk.onChatEvent(J.ChatEvent.SET_POSITION_IN_QUEUE,(e=>this.handlePositionInQueue(e))),this.sdk.onChatEvent(J.ChatEvent.ASSIGNED_AGENT_CHANGED,(e=>this.handleAgentChanged(e))),this.sdk.onChatEvent(J.ChatEvent.CONTACT_STATUS_CHANGED,(e=>this.handleContactStatusChanged(e))),this.sdk.onChatEvent(J.ChatEvent.CONTACT_CREATED,(e=>this.handleContactCreated(e))),this.callback.updateCapabilities({allowFileUploads:!0,allowMultipleFileUploads:!0})}async recoverThread(){const{threadID:e}=this.persistedState();if(e)try{a(`${ee} Using existing thread ${e}`,this.thread),this.thread=this.sdk.getThread(e);const t=await d(this.thread.recover(),1e4,"recover timed out");return a(`${ee} Recovered thread ${e}`,t),await this.handleRecover(t),this.addThreadListeners(),!0}catch(e){l(`${ee} Error getting existing thread`,e),this.updatePersistedState({threadID:null,contactID:null})}return!1}addThreadListeners(){this.thread.onThreadEvent(J.ChatEvent.MESSAGE_CREATED,(e=>this.handleMessageCreated(e))),this.thread.onThreadEvent(J.ChatEvent.AGENT_TYPING_STARTED,(e=>this.handleAgentTyping(e,!0))),this.thread.onThreadEvent(J.ChatEvent.AGENT_TYPING_ENDED,(e=>this.handleAgentTyping(e,!1)))}async startChat(e,t){await this.ensureSDK();const i=e.output.generic.find(n),{preStartChatPayload:r}=t,o=c(u.MISCELLANEOUS);if(a(`${ee} Creating new thread ${o}`),this.thread=this.sdk.getThread(o),this.addThreadListeners(),r?.customerName&&this.sdk.getCustomer().setName(r.customerName),this.newContactPromise=p(),r?.consumerContact?.customFields?.length){const e={};r?.consumerContact.customFields.forEach((t=>{e[t.ident]=t.value})),this.thread.setCustomFields(e)}const s=v(i,"Begin conversation");await this.thread.startChat(s.join("\n"));const l=await d(this.newContactPromise,1e4,"A new chat timed out waiting for a contact to be created.");this.updatePersistedState({threadID:o,contactID:l}),this.newContactPromise=null,a(`${ee} Started chat with contact ${l}`)}async handleMessageCreated(e){a(`${ee} ${e.type}`,e);const t=e.detail.data,{message:n,agentContact:i}=t;await this.handleMessage(n,!0,i?.user)}async handleRecover(e){const{lastAgentMessageID:t}=this.persistedState(),{messages:n}=e;a(`${ee} Last agent message: ${t}`);const i=n.findIndex((e=>e.id===t));if(i>0)for(let t=i-1;t>=0;t--){const i=n[t];this.handleMessage(i,!1,e.ownerAssignee)}}async handleMessage(e,t,n){if("outbound"===e.direction){const s=e.threadIdOnExternalPlatform,c=this.persistedState().threadID;if(!s||s!==c)return void a(`${ee} Got message for thread ${s} but the current thread is ${c}.`);const{isConnected:u}=this.serviceManager.store.getState().persistedToBrowserStorage.chatState.agentState;t&&!u&&await this.doAgentJoined(n);const d=[];if(e.messageContent?.text&&d.push(h({response_type:E.TEXT,text:e.messageContent.text})),e.attachments?.length&&e.attachments.forEach((e=>{d.push(h({response_type:i.BUTTON,kind:r.LINK,button_type:o.URL,url:e.url,label:e.friendlyName||e.fileName||e.filename}))})),d.length){const t={id:null,output:{generic:d}};await this.callback.agentTyping(!1),await this.callback.sendMessageToUser(t,n?.id),this.updatePersistedState({lastAgentMessageID:e.id})}}}async handleAgentTyping(e,t){a(`${ee} ${e.type}`,e),await this.callback.agentTyping(t)}async handleContactStatusChanged(e){a(`${ee} ${e.type}`,e);const t=e.detail.data,n=t.case.id,i=this.persistedState().contactID;n&&n===i?"closed"===t.case?.status&&(a(`${ee} Agent closed contact ${n}`,e),await this.callback.agentEndedChat()):a(`${ee} Got contact ${n} status change but the current contact is ${i}.`)}async handleContactCreated(e){a(`${ee} ${e.type}`,e),this.newContactPromise?this.newContactPromise.doResolve(e.detail.data?.case?.id):a(`${ee} Got a new contact but wasn't expecting one.`,e)}async handleAgentChanged(e){a(`${ee} ${e.type}`,e);const t=e.detail.data,n=t.case.id,i=this.persistedState().contactID;if(!n||n!==i)return void a(`${ee} Got contact ${n} status change but the current contact is ${i}.`);const{inboxAssignee:r,previousInboxAssignee:o}=t;r?(o&&await this.callback.beginTransferToAnotherAgent(),await this.doAgentJoined(r)):await this.callback.agentLeftChat()}async handlePositionInQueue(e){a(`${ee} ${e.type}`,e);const t=e.detail;await this.callback.updateAgentAvailability({position_in_queue:t.data.positionInQueue||1})}async doAgentJoined(e){const t=e?.nickname||`${e?.firstName||""} ${e?.surname||""}`.trim()||null,n={id:e?.id,nickname:t,profile_picture_url:e?.imageUrl};await this.callback.agentJoined(n)}async endChat(e){a(`${ee} Ended chat`),this.updatePersistedState({threadID:null,contactID:null}),e.endedByAgent||this.thread?.endChat(),this.thread=null}async sendMessageToAgent(e,t,n){if(e.input.text){const n=e.input.text;try{await this.thread.sendTextMessage(n)}catch(e){this.callback.setErrorStatus({type:s.USER_MESSAGE,messageID:t}),l(`${ee} Error sending message to agent`,e)}}n.filesToUpload.length&&this.doFileUploads(n.filesToUpload)}async doFileUploads(e){const t=new DataTransfer;let n;e.forEach((e=>t.items.add(e.file)));try{const e=await this.thread.sendAttachments(t.files);a(`${ee} Got sendAttachments result`,e),Z(e)&&(n=this.formatUploadErrorMessage(e))}catch(e){l(`${ee} Error sending files to agent`,e),n=this.formatUploadErrorMessage(e)}e.forEach(((e,t)=>{this.callback.setFileUploadStatus(e.id,Boolean(n),0===t?n:null)}))}formatUploadErrorMessage(e){if(Z(e)){const t=e.allowedFileTypes.map((({mimeType:e})=>e)).join(", ");return this.instance.getIntl().formatMessage({id:"serviceDesk_niceDFO_fileUploadError"},{allowedTypes:t,fileSize:e.allowedFileSize})}return this.getIntlText("fileSharing_uploadFailed")}async userReadMessages(){}async userTyping(e){e?this.thread?.keystroke(5e3):this.thread?.stopTyping()}async areAnyAgentsOnline(e){return await this.ensureSDK(),this.isChannelOnline}async reconnect(){return await this.ensureSDK(),this.recoverThread()}}export{te as NiceDFOServiceDesk};