@telia-ace/widget-conversation-flamingo 1.1.45-rc.3 → 1.1.45-rc.5

Sign up to get free protection for your applications and to get access to all the features.
package/index.mjs CHANGED
@@ -1,1310 +1,11 @@
1
- let U;
2
- const yt = new Uint8Array(16);
3
- function bt() {
4
- if (!U && (U = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !U))
5
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
6
- return U(yt);
7
- }
8
- const d = [];
9
- for (let r = 0; r < 256; ++r)
10
- d.push((r + 256).toString(16).slice(1));
11
- function mt(r, e = 0) {
12
- return d[r[e + 0]] + d[r[e + 1]] + d[r[e + 2]] + d[r[e + 3]] + "-" + d[r[e + 4]] + d[r[e + 5]] + "-" + d[r[e + 6]] + d[r[e + 7]] + "-" + d[r[e + 8]] + d[r[e + 9]] + "-" + d[r[e + 10]] + d[r[e + 11]] + d[r[e + 12]] + d[r[e + 13]] + d[r[e + 14]] + d[r[e + 15]];
13
- }
14
- const wt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), G = {
15
- randomUUID: wt
16
- };
17
- function St(r, e, t) {
18
- if (G.randomUUID && !e && !r)
19
- return G.randomUUID();
20
- r = r || {};
21
- const n = r.random || (r.rng || bt)();
22
- if (n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, e) {
23
- t = t || 0;
24
- for (let i = 0; i < 16; ++i)
25
- e[t + i] = n[i];
26
- return e;
27
- }
28
- return mt(n);
29
- }
30
- var L = function(r, e) {
31
- return L = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
32
- t.__proto__ = n;
33
- } || function(t, n) {
34
- for (var i in n)
35
- Object.prototype.hasOwnProperty.call(n, i) && (t[i] = n[i]);
36
- }, L(r, e);
37
- };
38
- function x(r, e) {
39
- if (typeof e != "function" && e !== null)
40
- throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
41
- L(r, e);
42
- function t() {
43
- this.constructor = r;
44
- }
45
- r.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
46
- }
47
- function gt(r, e, t, n) {
48
- function i(o) {
49
- return o instanceof t ? o : new t(function(s) {
50
- s(o);
51
- });
52
- }
53
- return new (t || (t = Promise))(function(o, s) {
54
- function u(l) {
55
- try {
56
- c(n.next(l));
57
- } catch (v) {
58
- s(v);
59
- }
60
- }
61
- function a(l) {
62
- try {
63
- c(n.throw(l));
64
- } catch (v) {
65
- s(v);
66
- }
67
- }
68
- function c(l) {
69
- l.done ? o(l.value) : i(l.value).then(u, a);
70
- }
71
- c((n = n.apply(r, e || [])).next());
72
- });
73
- }
74
- function W(r, e) {
75
- var t = { label: 0, sent: function() {
76
- if (o[0] & 1)
77
- throw o[1];
78
- return o[1];
79
- }, trys: [], ops: [] }, n, i, o, s;
80
- return s = { next: u(0), throw: u(1), return: u(2) }, typeof Symbol == "function" && (s[Symbol.iterator] = function() {
81
- return this;
82
- }), s;
83
- function u(c) {
84
- return function(l) {
85
- return a([c, l]);
86
- };
87
- }
88
- function a(c) {
89
- if (n)
90
- throw new TypeError("Generator is already executing.");
91
- for (; s && (s = 0, c[0] && (t = 0)), t; )
92
- try {
93
- if (n = 1, i && (o = c[0] & 2 ? i.return : c[0] ? i.throw || ((o = i.return) && o.call(i), 0) : i.next) && !(o = o.call(i, c[1])).done)
94
- return o;
95
- switch (i = 0, o && (c = [c[0] & 2, o.value]), c[0]) {
96
- case 0:
97
- case 1:
98
- o = c;
99
- break;
100
- case 4:
101
- return t.label++, { value: c[1], done: !1 };
102
- case 5:
103
- t.label++, i = c[1], c = [0];
104
- continue;
105
- case 7:
106
- c = t.ops.pop(), t.trys.pop();
107
- continue;
108
- default:
109
- if (o = t.trys, !(o = o.length > 0 && o[o.length - 1]) && (c[0] === 6 || c[0] === 2)) {
110
- t = 0;
111
- continue;
112
- }
113
- if (c[0] === 3 && (!o || c[1] > o[0] && c[1] < o[3])) {
114
- t.label = c[1];
115
- break;
116
- }
117
- if (c[0] === 6 && t.label < o[1]) {
118
- t.label = o[1], o = c;
119
- break;
120
- }
121
- if (o && t.label < o[2]) {
122
- t.label = o[2], t.ops.push(c);
123
- break;
124
- }
125
- o[2] && t.ops.pop(), t.trys.pop();
126
- continue;
127
- }
128
- c = e.call(r, t);
129
- } catch (l) {
130
- c = [6, l], i = 0;
131
- } finally {
132
- n = o = 0;
133
- }
134
- if (c[0] & 5)
135
- throw c[1];
136
- return { value: c[0] ? c[1] : void 0, done: !0 };
137
- }
138
- }
139
- function g(r) {
140
- var e = typeof Symbol == "function" && Symbol.iterator, t = e && r[e], n = 0;
141
- if (t)
142
- return t.call(r);
143
- if (r && typeof r.length == "number")
144
- return {
145
- next: function() {
146
- return r && n >= r.length && (r = void 0), { value: r && r[n++], done: !r };
147
- }
148
- };
149
- throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
150
- }
151
- function $(r, e) {
152
- var t = typeof Symbol == "function" && r[Symbol.iterator];
153
- if (!t)
154
- return r;
155
- var n = t.call(r), i, o = [], s;
156
- try {
157
- for (; (e === void 0 || e-- > 0) && !(i = n.next()).done; )
158
- o.push(i.value);
159
- } catch (u) {
160
- s = { error: u };
161
- } finally {
162
- try {
163
- i && !i.done && (t = n.return) && t.call(n);
164
- } finally {
165
- if (s)
166
- throw s.error;
167
- }
168
- }
169
- return o;
170
- }
171
- function k(r, e, t) {
172
- if (t || arguments.length === 2)
173
- for (var n = 0, i = e.length, o; n < i; n++)
174
- (o || !(n in e)) && (o || (o = Array.prototype.slice.call(e, 0, n)), o[n] = e[n]);
175
- return r.concat(o || Array.prototype.slice.call(e));
176
- }
177
- function S(r) {
178
- return this instanceof S ? (this.v = r, this) : new S(r);
179
- }
180
- function xt(r, e, t) {
181
- if (!Symbol.asyncIterator)
182
- throw new TypeError("Symbol.asyncIterator is not defined.");
183
- var n = t.apply(r, e || []), i, o = [];
184
- return i = {}, s("next"), s("throw"), s("return"), i[Symbol.asyncIterator] = function() {
185
- return this;
186
- }, i;
187
- function s(f) {
188
- n[f] && (i[f] = function(y) {
189
- return new Promise(function(E, p) {
190
- o.push([f, y, E, p]) > 1 || u(f, y);
191
- });
192
- });
193
- }
194
- function u(f, y) {
195
- try {
196
- a(n[f](y));
197
- } catch (E) {
198
- v(o[0][3], E);
199
- }
200
- }
201
- function a(f) {
202
- f.value instanceof S ? Promise.resolve(f.value.v).then(c, l) : v(o[0][2], f);
203
- }
204
- function c(f) {
205
- u("next", f);
206
- }
207
- function l(f) {
208
- u("throw", f);
209
- }
210
- function v(f, y) {
211
- f(y), o.shift(), o.length && u(o[0][0], o[0][1]);
212
- }
213
- }
214
- function Et(r) {
215
- if (!Symbol.asyncIterator)
216
- throw new TypeError("Symbol.asyncIterator is not defined.");
217
- var e = r[Symbol.asyncIterator], t;
218
- return e ? e.call(r) : (r = typeof g == "function" ? g(r) : r[Symbol.iterator](), t = {}, n("next"), n("throw"), n("return"), t[Symbol.asyncIterator] = function() {
219
- return this;
220
- }, t);
221
- function n(o) {
222
- t[o] = r[o] && function(s) {
223
- return new Promise(function(u, a) {
224
- s = r[o](s), i(u, a, s.done, s.value);
225
- });
226
- };
227
- }
228
- function i(o, s, u, a) {
229
- Promise.resolve(a).then(function(c) {
230
- o({ value: c, done: u });
231
- }, s);
232
- }
233
- }
234
- function h(r) {
235
- return typeof r == "function";
236
- }
237
- function X(r) {
238
- var e = function(n) {
239
- Error.call(n), n.stack = new Error().stack;
240
- }, t = r(e);
241
- return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
242
- }
243
- var R = X(function(r) {
244
- return function(t) {
245
- r(this), this.message = t ? t.length + ` errors occurred during unsubscription:
246
- ` + t.map(function(n, i) {
247
- return i + 1 + ") " + n.toString();
248
- }).join(`
249
- `) : "", this.name = "UnsubscriptionError", this.errors = t;
250
- };
251
- });
252
- function D(r, e) {
253
- if (r) {
254
- var t = r.indexOf(e);
255
- 0 <= t && r.splice(t, 1);
256
- }
257
- }
258
- var j = function() {
259
- function r(e) {
260
- this.initialTeardown = e, this.closed = !1, this._parentage = null, this._finalizers = null;
261
- }
262
- return r.prototype.unsubscribe = function() {
263
- var e, t, n, i, o;
264
- if (!this.closed) {
265
- this.closed = !0;
266
- var s = this._parentage;
267
- if (s)
268
- if (this._parentage = null, Array.isArray(s))
269
- try {
270
- for (var u = g(s), a = u.next(); !a.done; a = u.next()) {
271
- var c = a.value;
272
- c.remove(this);
273
- }
274
- } catch (p) {
275
- e = { error: p };
276
- } finally {
277
- try {
278
- a && !a.done && (t = u.return) && t.call(u);
279
- } finally {
280
- if (e)
281
- throw e.error;
282
- }
283
- }
284
- else
285
- s.remove(this);
286
- var l = this.initialTeardown;
287
- if (h(l))
288
- try {
289
- l();
290
- } catch (p) {
291
- o = p instanceof R ? p.errors : [p];
292
- }
293
- var v = this._finalizers;
294
- if (v) {
295
- this._finalizers = null;
296
- try {
297
- for (var f = g(v), y = f.next(); !y.done; y = f.next()) {
298
- var E = y.value;
299
- try {
300
- z(E);
301
- } catch (p) {
302
- o = o ?? [], p instanceof R ? o = k(k([], $(o)), $(p.errors)) : o.push(p);
303
- }
304
- }
305
- } catch (p) {
306
- n = { error: p };
307
- } finally {
308
- try {
309
- y && !y.done && (i = f.return) && i.call(f);
310
- } finally {
311
- if (n)
312
- throw n.error;
313
- }
314
- }
315
- }
316
- if (o)
317
- throw new R(o);
318
- }
319
- }, r.prototype.add = function(e) {
320
- var t;
321
- if (e && e !== this)
322
- if (this.closed)
323
- z(e);
324
- else {
325
- if (e instanceof r) {
326
- if (e.closed || e._hasParent(this))
327
- return;
328
- e._addParent(this);
329
- }
330
- (this._finalizers = (t = this._finalizers) !== null && t !== void 0 ? t : []).push(e);
331
- }
332
- }, r.prototype._hasParent = function(e) {
333
- var t = this._parentage;
334
- return t === e || Array.isArray(t) && t.includes(e);
335
- }, r.prototype._addParent = function(e) {
336
- var t = this._parentage;
337
- this._parentage = Array.isArray(t) ? (t.push(e), t) : t ? [t, e] : e;
338
- }, r.prototype._removeParent = function(e) {
339
- var t = this._parentage;
340
- t === e ? this._parentage = null : Array.isArray(t) && D(t, e);
341
- }, r.prototype.remove = function(e) {
342
- var t = this._finalizers;
343
- t && D(t, e), e instanceof r && e._removeParent(this);
344
- }, r.EMPTY = function() {
345
- var e = new r();
346
- return e.closed = !0, e;
347
- }(), r;
348
- }(), Z = j.EMPTY;
349
- function N(r) {
350
- return r instanceof j || r && "closed" in r && h(r.remove) && h(r.add) && h(r.unsubscribe);
351
- }
352
- function z(r) {
353
- h(r) ? r() : r.unsubscribe();
354
- }
355
- var tt = {
356
- onUnhandledError: null,
357
- onStoppedNotification: null,
358
- Promise: void 0,
359
- useDeprecatedSynchronousErrorHandling: !1,
360
- useDeprecatedNextContext: !1
361
- }, M = {
362
- setTimeout: function(r, e) {
363
- for (var t = [], n = 2; n < arguments.length; n++)
364
- t[n - 2] = arguments[n];
365
- var i = M.delegate;
366
- return i != null && i.setTimeout ? i.setTimeout.apply(i, k([r, e], $(t))) : setTimeout.apply(void 0, k([r, e], $(t)));
367
- },
368
- clearTimeout: function(r) {
369
- var e = M.delegate;
370
- return ((e == null ? void 0 : e.clearTimeout) || clearTimeout)(r);
371
- },
372
- delegate: void 0
373
- };
374
- function et(r) {
375
- M.setTimeout(function() {
376
- throw r;
377
- });
378
- }
379
- function Y() {
380
- }
381
- function A(r) {
382
- r();
383
- }
384
- var B = function(r) {
385
- x(e, r);
386
- function e(t) {
387
- var n = r.call(this) || this;
388
- return n.isStopped = !1, t ? (n.destination = t, N(t) && t.add(n)) : n.destination = Ot, n;
389
- }
390
- return e.create = function(t, n, i) {
391
- return new V(t, n, i);
392
- }, e.prototype.next = function(t) {
393
- this.isStopped || this._next(t);
394
- }, e.prototype.error = function(t) {
395
- this.isStopped || (this.isStopped = !0, this._error(t));
396
- }, e.prototype.complete = function() {
397
- this.isStopped || (this.isStopped = !0, this._complete());
398
- }, e.prototype.unsubscribe = function() {
399
- this.closed || (this.isStopped = !0, r.prototype.unsubscribe.call(this), this.destination = null);
400
- }, e.prototype._next = function(t) {
401
- this.destination.next(t);
402
- }, e.prototype._error = function(t) {
403
- try {
404
- this.destination.error(t);
405
- } finally {
406
- this.unsubscribe();
407
- }
408
- }, e.prototype._complete = function() {
409
- try {
410
- this.destination.complete();
411
- } finally {
412
- this.unsubscribe();
413
- }
414
- }, e;
415
- }(j), _t = Function.prototype.bind;
416
- function F(r, e) {
417
- return _t.call(r, e);
418
- }
419
- var It = function() {
420
- function r(e) {
421
- this.partialObserver = e;
422
- }
423
- return r.prototype.next = function(e) {
424
- var t = this.partialObserver;
425
- if (t.next)
426
- try {
427
- t.next(e);
428
- } catch (n) {
429
- T(n);
430
- }
431
- }, r.prototype.error = function(e) {
432
- var t = this.partialObserver;
433
- if (t.error)
434
- try {
435
- t.error(e);
436
- } catch (n) {
437
- T(n);
438
- }
439
- else
440
- T(e);
441
- }, r.prototype.complete = function() {
442
- var e = this.partialObserver;
443
- if (e.complete)
444
- try {
445
- e.complete();
446
- } catch (t) {
447
- T(t);
448
- }
449
- }, r;
450
- }(), V = function(r) {
451
- x(e, r);
452
- function e(t, n, i) {
453
- var o = r.call(this) || this, s;
454
- if (h(t) || !t)
455
- s = {
456
- next: t ?? void 0,
457
- error: n ?? void 0,
458
- complete: i ?? void 0
459
- };
460
- else {
461
- var u;
462
- o && tt.useDeprecatedNextContext ? (u = Object.create(t), u.unsubscribe = function() {
463
- return o.unsubscribe();
464
- }, s = {
465
- next: t.next && F(t.next, u),
466
- error: t.error && F(t.error, u),
467
- complete: t.complete && F(t.complete, u)
468
- }) : s = t;
469
- }
470
- return o.destination = new It(s), o;
471
- }
472
- return e;
473
- }(B);
474
- function T(r) {
475
- et(r);
476
- }
477
- function Pt(r) {
478
- throw r;
479
- }
480
- var Ot = {
481
- closed: !0,
482
- next: Y,
483
- error: Pt,
484
- complete: Y
485
- }, q = function() {
486
- return typeof Symbol == "function" && Symbol.observable || "@@observable";
487
- }();
488
- function Ut(r) {
489
- return r;
490
- }
491
- function Tt(r) {
492
- return r.length === 0 ? Ut : r.length === 1 ? r[0] : function(t) {
493
- return r.reduce(function(n, i) {
494
- return i(n);
495
- }, t);
496
- };
497
- }
498
- var b = function() {
499
- function r(e) {
500
- e && (this._subscribe = e);
501
- }
502
- return r.prototype.lift = function(e) {
503
- var t = new r();
504
- return t.source = this, t.operator = e, t;
505
- }, r.prototype.subscribe = function(e, t, n) {
506
- var i = this, o = $t(e) ? e : new V(e, t, n);
507
- return A(function() {
508
- var s = i, u = s.operator, a = s.source;
509
- o.add(u ? u.call(o, a) : a ? i._subscribe(o) : i._trySubscribe(o));
510
- }), o;
511
- }, r.prototype._trySubscribe = function(e) {
512
- try {
513
- return this._subscribe(e);
514
- } catch (t) {
515
- e.error(t);
516
- }
517
- }, r.prototype.forEach = function(e, t) {
518
- var n = this;
519
- return t = K(t), new t(function(i, o) {
520
- var s = new V({
521
- next: function(u) {
522
- try {
523
- e(u);
524
- } catch (a) {
525
- o(a), s.unsubscribe();
526
- }
527
- },
528
- error: o,
529
- complete: i
530
- });
531
- n.subscribe(s);
532
- });
533
- }, r.prototype._subscribe = function(e) {
534
- var t;
535
- return (t = this.source) === null || t === void 0 ? void 0 : t.subscribe(e);
536
- }, r.prototype[q] = function() {
537
- return this;
538
- }, r.prototype.pipe = function() {
539
- for (var e = [], t = 0; t < arguments.length; t++)
540
- e[t] = arguments[t];
541
- return Tt(e)(this);
542
- }, r.prototype.toPromise = function(e) {
543
- var t = this;
544
- return e = K(e), new e(function(n, i) {
545
- var o;
546
- t.subscribe(function(s) {
547
- return o = s;
548
- }, function(s) {
549
- return i(s);
550
- }, function() {
551
- return n(o);
552
- });
553
- });
554
- }, r.create = function(e) {
555
- return new r(e);
556
- }, r;
557
- }();
558
- function K(r) {
559
- var e;
560
- return (e = r ?? tt.Promise) !== null && e !== void 0 ? e : Promise;
561
- }
562
- function At(r) {
563
- return r && h(r.next) && h(r.error) && h(r.complete);
564
- }
565
- function $t(r) {
566
- return r && r instanceof B || At(r) && N(r);
567
- }
568
- function kt(r) {
569
- return h(r == null ? void 0 : r.lift);
570
- }
571
- function I(r) {
572
- return function(e) {
573
- if (kt(e))
574
- return e.lift(function(t) {
575
- try {
576
- return r(t, this);
577
- } catch (n) {
578
- this.error(n);
579
- }
580
- });
581
- throw new TypeError("Unable to lift unknown Observable type");
582
- };
583
- }
584
- function _(r, e, t, n, i) {
585
- return new jt(r, e, t, n, i);
586
- }
587
- var jt = function(r) {
588
- x(e, r);
589
- function e(t, n, i, o, s, u) {
590
- var a = r.call(this, t) || this;
591
- return a.onFinalize = s, a.shouldUnsubscribe = u, a._next = n ? function(c) {
592
- try {
593
- n(c);
594
- } catch (l) {
595
- t.error(l);
596
- }
597
- } : r.prototype._next, a._error = o ? function(c) {
598
- try {
599
- o(c);
600
- } catch (l) {
601
- t.error(l);
602
- } finally {
603
- this.unsubscribe();
604
- }
605
- } : r.prototype._error, a._complete = i ? function() {
606
- try {
607
- i();
608
- } catch (c) {
609
- t.error(c);
610
- } finally {
611
- this.unsubscribe();
612
- }
613
- } : r.prototype._complete, a;
614
- }
615
- return e.prototype.unsubscribe = function() {
616
- var t;
617
- if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
618
- var n = this.closed;
619
- r.prototype.unsubscribe.call(this), !n && ((t = this.onFinalize) === null || t === void 0 || t.call(this));
620
- }
621
- }, e;
622
- }(B), Ct = X(function(r) {
623
- return function() {
624
- r(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
625
- };
626
- }), m = function(r) {
627
- x(e, r);
628
- function e() {
629
- var t = r.call(this) || this;
630
- return t.closed = !1, t.currentObservers = null, t.observers = [], t.isStopped = !1, t.hasError = !1, t.thrownError = null, t;
631
- }
632
- return e.prototype.lift = function(t) {
633
- var n = new J(this, this);
634
- return n.operator = t, n;
635
- }, e.prototype._throwIfClosed = function() {
636
- if (this.closed)
637
- throw new Ct();
638
- }, e.prototype.next = function(t) {
639
- var n = this;
640
- A(function() {
641
- var i, o;
642
- if (n._throwIfClosed(), !n.isStopped) {
643
- n.currentObservers || (n.currentObservers = Array.from(n.observers));
644
- try {
645
- for (var s = g(n.currentObservers), u = s.next(); !u.done; u = s.next()) {
646
- var a = u.value;
647
- a.next(t);
648
- }
649
- } catch (c) {
650
- i = { error: c };
651
- } finally {
652
- try {
653
- u && !u.done && (o = s.return) && o.call(s);
654
- } finally {
655
- if (i)
656
- throw i.error;
657
- }
658
- }
659
- }
660
- });
661
- }, e.prototype.error = function(t) {
662
- var n = this;
663
- A(function() {
664
- if (n._throwIfClosed(), !n.isStopped) {
665
- n.hasError = n.isStopped = !0, n.thrownError = t;
666
- for (var i = n.observers; i.length; )
667
- i.shift().error(t);
668
- }
669
- });
670
- }, e.prototype.complete = function() {
671
- var t = this;
672
- A(function() {
673
- if (t._throwIfClosed(), !t.isStopped) {
674
- t.isStopped = !0;
675
- for (var n = t.observers; n.length; )
676
- n.shift().complete();
677
- }
678
- });
679
- }, e.prototype.unsubscribe = function() {
680
- this.isStopped = this.closed = !0, this.observers = this.currentObservers = null;
681
- }, Object.defineProperty(e.prototype, "observed", {
682
- get: function() {
683
- var t;
684
- return ((t = this.observers) === null || t === void 0 ? void 0 : t.length) > 0;
685
- },
686
- enumerable: !1,
687
- configurable: !0
688
- }), e.prototype._trySubscribe = function(t) {
689
- return this._throwIfClosed(), r.prototype._trySubscribe.call(this, t);
690
- }, e.prototype._subscribe = function(t) {
691
- return this._throwIfClosed(), this._checkFinalizedStatuses(t), this._innerSubscribe(t);
692
- }, e.prototype._innerSubscribe = function(t) {
693
- var n = this, i = this, o = i.hasError, s = i.isStopped, u = i.observers;
694
- return o || s ? Z : (this.currentObservers = null, u.push(t), new j(function() {
695
- n.currentObservers = null, D(u, t);
696
- }));
697
- }, e.prototype._checkFinalizedStatuses = function(t) {
698
- var n = this, i = n.hasError, o = n.thrownError, s = n.isStopped;
699
- i ? t.error(o) : s && t.complete();
700
- }, e.prototype.asObservable = function() {
701
- var t = new b();
702
- return t.source = this, t;
703
- }, e.create = function(t, n) {
704
- return new J(t, n);
705
- }, e;
706
- }(b), J = function(r) {
707
- x(e, r);
708
- function e(t, n) {
709
- var i = r.call(this) || this;
710
- return i.destination = t, i.source = n, i;
711
- }
712
- return e.prototype.next = function(t) {
713
- var n, i;
714
- (i = (n = this.destination) === null || n === void 0 ? void 0 : n.next) === null || i === void 0 || i.call(n, t);
715
- }, e.prototype.error = function(t) {
716
- var n, i;
717
- (i = (n = this.destination) === null || n === void 0 ? void 0 : n.error) === null || i === void 0 || i.call(n, t);
718
- }, e.prototype.complete = function() {
719
- var t, n;
720
- (n = (t = this.destination) === null || t === void 0 ? void 0 : t.complete) === null || n === void 0 || n.call(t);
721
- }, e.prototype._subscribe = function(t) {
722
- var n, i;
723
- return (i = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(t)) !== null && i !== void 0 ? i : Z;
724
- }, e;
725
- }(m), rt = function(r) {
726
- x(e, r);
727
- function e(t) {
728
- var n = r.call(this) || this;
729
- return n._value = t, n;
730
- }
731
- return Object.defineProperty(e.prototype, "value", {
732
- get: function() {
733
- return this.getValue();
734
- },
735
- enumerable: !1,
736
- configurable: !0
737
- }), e.prototype._subscribe = function(t) {
738
- var n = r.prototype._subscribe.call(this, t);
739
- return !n.closed && t.next(this._value), n;
740
- }, e.prototype.getValue = function() {
741
- var t = this, n = t.hasError, i = t.thrownError, o = t._value;
742
- if (n)
743
- throw i;
744
- return this._throwIfClosed(), o;
745
- }, e.prototype.next = function(t) {
746
- r.prototype.next.call(this, this._value = t);
747
- }, e;
748
- }(m), Rt = new b(function(r) {
749
- return r.complete();
750
- });
751
- function Ft(r) {
752
- return r && h(r.schedule);
753
- }
754
- function Lt(r) {
755
- return r[r.length - 1];
756
- }
757
- function Dt(r) {
758
- return Ft(Lt(r)) ? r.pop() : void 0;
759
- }
760
- var nt = function(r) {
761
- return r && typeof r.length == "number" && typeof r != "function";
762
- };
763
- function it(r) {
764
- return h(r == null ? void 0 : r.then);
765
- }
766
- function ot(r) {
767
- return h(r[q]);
768
- }
769
- function st(r) {
770
- return Symbol.asyncIterator && h(r == null ? void 0 : r[Symbol.asyncIterator]);
771
- }
772
- function ut(r) {
773
- return new TypeError("You provided " + (r !== null && typeof r == "object" ? "an invalid object" : "'" + r + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
774
- }
775
- function Mt() {
776
- return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
777
- }
778
- var ct = Mt();
779
- function at(r) {
780
- return h(r == null ? void 0 : r[ct]);
781
- }
782
- function lt(r) {
783
- return xt(this, arguments, function() {
784
- var t, n, i, o;
785
- return W(this, function(s) {
786
- switch (s.label) {
787
- case 0:
788
- t = r.getReader(), s.label = 1;
789
- case 1:
790
- s.trys.push([1, , 9, 10]), s.label = 2;
791
- case 2:
792
- return [4, S(t.read())];
793
- case 3:
794
- return n = s.sent(), i = n.value, o = n.done, o ? [4, S(void 0)] : [3, 5];
795
- case 4:
796
- return [2, s.sent()];
797
- case 5:
798
- return [4, S(i)];
799
- case 6:
800
- return [4, s.sent()];
801
- case 7:
802
- return s.sent(), [3, 2];
803
- case 8:
804
- return [3, 10];
805
- case 9:
806
- return t.releaseLock(), [7];
807
- case 10:
808
- return [2];
809
- }
810
- });
811
- });
812
- }
813
- function ft(r) {
814
- return h(r == null ? void 0 : r.getReader);
815
- }
816
- function P(r) {
817
- if (r instanceof b)
818
- return r;
819
- if (r != null) {
820
- if (ot(r))
821
- return Yt(r);
822
- if (nt(r))
823
- return Vt(r);
824
- if (it(r))
825
- return Bt(r);
826
- if (st(r))
827
- return ht(r);
828
- if (at(r))
829
- return qt(r);
830
- if (ft(r))
831
- return Ht(r);
832
- }
833
- throw ut(r);
834
- }
835
- function Yt(r) {
836
- return new b(function(e) {
837
- var t = r[q]();
838
- if (h(t.subscribe))
839
- return t.subscribe(e);
840
- throw new TypeError("Provided object does not correctly implement Symbol.observable");
841
- });
842
- }
843
- function Vt(r) {
844
- return new b(function(e) {
845
- for (var t = 0; t < r.length && !e.closed; t++)
846
- e.next(r[t]);
847
- e.complete();
848
- });
849
- }
850
- function Bt(r) {
851
- return new b(function(e) {
852
- r.then(function(t) {
853
- e.closed || (e.next(t), e.complete());
854
- }, function(t) {
855
- return e.error(t);
856
- }).then(null, et);
857
- });
858
- }
859
- function qt(r) {
860
- return new b(function(e) {
861
- var t, n;
862
- try {
863
- for (var i = g(r), o = i.next(); !o.done; o = i.next()) {
864
- var s = o.value;
865
- if (e.next(s), e.closed)
866
- return;
867
- }
868
- } catch (u) {
869
- t = { error: u };
870
- } finally {
871
- try {
872
- o && !o.done && (n = i.return) && n.call(i);
873
- } finally {
874
- if (t)
875
- throw t.error;
876
- }
877
- }
878
- e.complete();
879
- });
880
- }
881
- function ht(r) {
882
- return new b(function(e) {
883
- Gt(r, e).catch(function(t) {
884
- return e.error(t);
885
- });
886
- });
887
- }
888
- function Ht(r) {
889
- return ht(lt(r));
890
- }
891
- function Gt(r, e) {
892
- var t, n, i, o;
893
- return gt(this, void 0, void 0, function() {
894
- var s, u;
895
- return W(this, function(a) {
896
- switch (a.label) {
897
- case 0:
898
- a.trys.push([0, 5, 6, 11]), t = Et(r), a.label = 1;
899
- case 1:
900
- return [4, t.next()];
901
- case 2:
902
- if (n = a.sent(), !!n.done)
903
- return [3, 4];
904
- if (s = n.value, e.next(s), e.closed)
905
- return [2];
906
- a.label = 3;
907
- case 3:
908
- return [3, 1];
909
- case 4:
910
- return [3, 11];
911
- case 5:
912
- return u = a.sent(), i = { error: u }, [3, 11];
913
- case 6:
914
- return a.trys.push([6, , 9, 10]), n && !n.done && (o = t.return) ? [4, o.call(t)] : [3, 8];
915
- case 7:
916
- a.sent(), a.label = 8;
917
- case 8:
918
- return [3, 10];
919
- case 9:
920
- if (i)
921
- throw i.error;
922
- return [7];
923
- case 10:
924
- return [7];
925
- case 11:
926
- return e.complete(), [2];
927
- }
928
- });
929
- });
930
- }
931
- function w(r, e, t, n, i) {
932
- n === void 0 && (n = 0), i === void 0 && (i = !1);
933
- var o = e.schedule(function() {
934
- t(), i ? r.add(this.schedule(null, n)) : this.unsubscribe();
935
- }, n);
936
- if (r.add(o), !i)
937
- return o;
938
- }
939
- function dt(r, e) {
940
- return e === void 0 && (e = 0), I(function(t, n) {
941
- t.subscribe(_(n, function(i) {
942
- return w(n, r, function() {
943
- return n.next(i);
944
- }, e);
945
- }, function() {
946
- return w(n, r, function() {
947
- return n.complete();
948
- }, e);
949
- }, function(i) {
950
- return w(n, r, function() {
951
- return n.error(i);
952
- }, e);
953
- }));
954
- });
955
- }
956
- function pt(r, e) {
957
- return e === void 0 && (e = 0), I(function(t, n) {
958
- n.add(r.schedule(function() {
959
- return t.subscribe(n);
960
- }, e));
961
- });
962
- }
963
- function zt(r, e) {
964
- return P(r).pipe(pt(e), dt(e));
965
- }
966
- function Kt(r, e) {
967
- return P(r).pipe(pt(e), dt(e));
968
- }
969
- function Jt(r, e) {
970
- return new b(function(t) {
971
- var n = 0;
972
- return e.schedule(function() {
973
- n === r.length ? t.complete() : (t.next(r[n++]), t.closed || this.schedule());
974
- });
975
- });
976
- }
977
- function Qt(r, e) {
978
- return new b(function(t) {
979
- var n;
980
- return w(t, e, function() {
981
- n = r[ct](), w(t, e, function() {
982
- var i, o, s;
983
- try {
984
- i = n.next(), o = i.value, s = i.done;
985
- } catch (u) {
986
- t.error(u);
987
- return;
988
- }
989
- s ? t.complete() : t.next(o);
990
- }, 0, !0);
991
- }), function() {
992
- return h(n == null ? void 0 : n.return) && n.return();
993
- };
994
- });
995
- }
996
- function vt(r, e) {
997
- if (!r)
998
- throw new Error("Iterable cannot be null");
999
- return new b(function(t) {
1000
- w(t, e, function() {
1001
- var n = r[Symbol.asyncIterator]();
1002
- w(t, e, function() {
1003
- n.next().then(function(i) {
1004
- i.done ? t.complete() : t.next(i.value);
1005
- });
1006
- }, 0, !0);
1007
- });
1008
- });
1009
- }
1010
- function Wt(r, e) {
1011
- return vt(lt(r), e);
1012
- }
1013
- function Xt(r, e) {
1014
- if (r != null) {
1015
- if (ot(r))
1016
- return zt(r, e);
1017
- if (nt(r))
1018
- return Jt(r, e);
1019
- if (it(r))
1020
- return Kt(r, e);
1021
- if (st(r))
1022
- return vt(r, e);
1023
- if (at(r))
1024
- return Qt(r, e);
1025
- if (ft(r))
1026
- return Wt(r, e);
1027
- }
1028
- throw ut(r);
1029
- }
1030
- function Zt(r, e) {
1031
- return e ? Xt(r, e) : P(r);
1032
- }
1033
- function Nt() {
1034
- for (var r = [], e = 0; e < arguments.length; e++)
1035
- r[e] = arguments[e];
1036
- var t = Dt(r);
1037
- return Zt(r, t);
1038
- }
1039
- function Q(r) {
1040
- return r <= 0 ? function() {
1041
- return Rt;
1042
- } : I(function(e, t) {
1043
- var n = 0;
1044
- e.subscribe(_(t, function(i) {
1045
- ++n <= r && (t.next(i), r <= n && t.complete());
1046
- }));
1047
- });
1048
- }
1049
- function te(r, e) {
1050
- return I(function(t, n) {
1051
- var i = null, o = 0, s = !1, u = function() {
1052
- return s && !i && n.complete();
1053
- };
1054
- t.subscribe(_(n, function(a) {
1055
- i == null || i.unsubscribe();
1056
- var c = 0, l = o++;
1057
- P(r(a, l)).subscribe(i = _(n, function(v) {
1058
- return n.next(e ? e(a, v, l, c++) : v);
1059
- }, function() {
1060
- i = null, u();
1061
- }));
1062
- }, function() {
1063
- s = !0, u();
1064
- }));
1065
- });
1066
- }
1067
- function ee(r) {
1068
- return I(function(e, t) {
1069
- P(r).subscribe(_(t, function() {
1070
- return t.complete();
1071
- }, Y)), !t.closed && e.subscribe(t);
1072
- });
1073
- }
1074
- class re {
1075
- constructor(e, t, n) {
1076
- this.id = e, this.component = t, this.platform = n, this.entries$ = new rt([]), this.kill$ = new m(), this.queue = [], t.addEventListener("user-submit", (i) => {
1077
- if (!this.provider) {
1078
- console.warn(
1079
- "No provider activated, unable to print message to conversation."
1080
- );
1081
- return;
1082
- }
1083
- this.provider.onUserSubmit(i.detail);
1084
- });
1085
- }
1086
- write(e) {
1087
- this.addEntryRemoveHandler(e), this.entries$.pipe(Q(1)).subscribe((t) => {
1088
- this.entries$.next([...t, e]);
1089
- });
1090
- }
1091
- entries() {
1092
- return this.entries$.asObservable();
1093
- }
1094
- setProvider(e, t = {}) {
1095
- this.provider = e, this.provider.actions().pipe(ee(this.kill$)).subscribe((n) => {
1096
- this.write(n);
1097
- }), this.provider.connect(t);
1098
- }
1099
- handover(e, t = {}) {
1100
- var i;
1101
- (i = this.provider) == null || i.setTypingState(!1);
1102
- const n = this.platform.registeredProviders.get(e);
1103
- if (n) {
1104
- this.provider && this.queue.unshift(this.provider), this.kill$.next();
1105
- const o = n(this);
1106
- this.setProvider(o, t);
1107
- }
1108
- }
1109
- addEntryRemoveHandler(e) {
1110
- e.remove$.pipe(
1111
- te(() => this.entries$),
1112
- Q(1)
1113
- ).subscribe((t) => {
1114
- this.entries$.next(t.filter((n) => n !== e));
1115
- });
1116
- }
1117
- completeProvider() {
1118
- const [e] = this.queue;
1119
- e && this.setProvider(e);
1120
- }
1121
- isTyping() {
1122
- return this.provider ? this.provider.isTyping() : Nt(!1);
1123
- }
1124
- }
1125
- class H {
1126
- constructor() {
1127
- this.sessions = /* @__PURE__ */ new Map(), this.registeredProviders = /* @__PURE__ */ new Map(), this.activeSessionId = null;
1128
- }
1129
- static async getInstance(e) {
1130
- let t = await e.get("conversation");
1131
- return t || (t = new H(), await e.register("conversation", t), t);
1132
- }
1133
- registerProvider(e, t) {
1134
- this.registeredProviders.set(e, t);
1135
- }
1136
- createSession(e) {
1137
- const t = new re(St(), e, this), n = this.getProviderByConfiguration(e);
1138
- if (n) {
1139
- const i = n(t);
1140
- t.setProvider(i);
1141
- }
1142
- return this.sessions.set(t.id, t), this.activeSessionId = t.id, t;
1143
- }
1144
- getProviderByConfiguration(e) {
1145
- const [t] = e.properties.providers || [];
1146
- if (!t) {
1147
- console.warn(
1148
- "No providers registered. You most likely forgot to add a provider to the conversation component properties."
1149
- );
1150
- return;
1151
- }
1152
- return this.registeredProviders.get(t);
1153
- }
1154
- }
1155
- const se = async (r) => {
1156
- r.registerComponent("conversation", import("./conversation-ed602fb6.mjs")), await H.getInstance(r.container);
1157
- };
1158
- var O = /* @__PURE__ */ ((r) => (r.User = "user", r.Agent = "agent", r.System = "system", r))(O || {});
1159
- class C {
1160
- constructor(e, t, n) {
1161
- this.type = e, this.sender = t, this.messages = n, this.status = "delivered", this.didUpdate = new m(), this.actions$ = new m(), this.remove$ = new m(), this.timestamp = Date.now();
1162
- }
1163
- update(e) {
1164
- this.messages = [
1165
- {
1166
- items: e
1167
- }
1168
- ], this.didUpdate.next(this);
1169
- }
1170
- setStatus(e) {
1171
- this.status = e, this.didUpdate.next(this);
1172
- }
1173
- remove() {
1174
- this.remove$.next();
1175
- }
1176
- }
1177
- class ne {
1178
- constructor(e) {
1179
- this.name = e, this.print$ = new m();
1180
- }
1181
- print(e) {
1182
- const t = new C(
1183
- O.Agent,
1184
- { name: this.name },
1185
- [
1186
- {
1187
- items: [["html", { content: e }]]
1188
- }
1189
- ]
1190
- );
1191
- return this.print$.next(t), t;
1192
- }
1193
- subscribe() {
1194
- return this.print$.asObservable();
1195
- }
1196
- }
1197
- class ie {
1198
- constructor(e) {
1199
- this.name = e, this.print$ = new m();
1200
- }
1201
- print(e) {
1202
- const t = new C(
1203
- O.User,
1204
- { name: this.name },
1205
- [
1206
- {
1207
- items: [["html", { content: e }]]
1208
- }
1209
- ]
1210
- );
1211
- return this.print$.next(t), t;
1212
- }
1213
- subscribe() {
1214
- return this.print$.asObservable();
1215
- }
1216
- }
1217
- class oe {
1218
- constructor() {
1219
- this.print$ = new m(), this.name = "system";
1220
- }
1221
- print(e) {
1222
- const t = new C(
1223
- O.System,
1224
- { name: this.name },
1225
- [
1226
- {
1227
- items: [["html", { content: e }]]
1228
- }
1229
- ]
1230
- );
1231
- return this.print$.next(t), t;
1232
- }
1233
- subscribe() {
1234
- return this.print$.asObservable();
1235
- }
1236
- }
1237
- class ue {
1238
- constructor(e, t) {
1239
- this.name = e, this.session = t, this.print$ = new m(), this.typingState$ = new rt(!1), this.system = this.createSystem();
1240
- }
1241
- connect(e = {}) {
1242
- }
1243
- onUserSubmit(e) {
1244
- this.print(O.User, e.text);
1245
- }
1246
- print(e, t) {
1247
- const n = new C(
1248
- e,
1249
- {
1250
- name: ""
1251
- },
1252
- [
1253
- {
1254
- items: [["html", { content: t }]]
1255
- }
1256
- ]
1257
- );
1258
- return this.printEntry(n);
1259
- }
1260
- printEntry(e) {
1261
- return this.print$.next(e), e;
1262
- }
1263
- createAgent(e) {
1264
- const t = new ne(e);
1265
- return t.subscribe().subscribe((n) => {
1266
- this.playNotification(), this.printEntry(n);
1267
- }), t;
1268
- }
1269
- createUser(e) {
1270
- const t = new ie(e);
1271
- return t.subscribe().subscribe((n) => {
1272
- this.printEntry(n);
1273
- }), t;
1274
- }
1275
- createSystem() {
1276
- const e = new oe();
1277
- return e.subscribe().subscribe((t) => {
1278
- this.printEntry(t);
1279
- }), e;
1280
- }
1281
- setTypingState(e) {
1282
- this.typingState$.next(e);
1283
- }
1284
- setToastMessage(e) {
1285
- this.session.component.setToastMessage(e);
1286
- }
1287
- isTyping() {
1288
- return this.typingState$.asObservable();
1289
- }
1290
- actions() {
1291
- return this.print$.asObservable();
1292
- }
1293
- complete() {
1294
- this.session.completeProvider();
1295
- }
1296
- playNotification() {
1297
- const e = "https://publicpoc.blob.core.windows.net/widget-assets/notification.mp3";
1298
- this.session.component.application.branding().other.disableSound || new Audio(e).play();
1299
- }
1300
- }
1
+ import { A as a, a as e, d as n, C as r, b as t, c as i, e as C, U as v } from "./index-913a371e.mjs";
1301
2
  export {
1302
- ne as Agent,
1303
- se as ConversationComponent,
1304
- C as ConversationEntry,
1305
- O as ConversationMessageType,
1306
- H as ConversationPlatform,
1307
- ue as ConversationProvider,
1308
- re as ConversationSessionState,
1309
- ie as User
3
+ a as Agent,
4
+ e as ConversationComponent,
5
+ n as ConversationEntry,
6
+ r as ConversationMessageType,
7
+ t as ConversationPlatform,
8
+ i as ConversationProvider,
9
+ C as ConversationSessionState,
10
+ v as User
1310
11
  };