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

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1199 @@
1
+ let _;
2
+ const ot = new Uint8Array(16);
3
+ function st() {
4
+ if (!_ && (_ = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !_))
5
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
6
+ return _(ot);
7
+ }
8
+ const h = [];
9
+ for (let r = 0; r < 256; ++r)
10
+ h.push((r + 256).toString(16).slice(1));
11
+ function ut(r, e = 0) {
12
+ return h[r[e + 0]] + h[r[e + 1]] + h[r[e + 2]] + h[r[e + 3]] + "-" + h[r[e + 4]] + h[r[e + 5]] + "-" + h[r[e + 6]] + h[r[e + 7]] + "-" + h[r[e + 8]] + h[r[e + 9]] + "-" + h[r[e + 10]] + h[r[e + 11]] + h[r[e + 12]] + h[r[e + 13]] + h[r[e + 14]] + h[r[e + 15]];
13
+ }
14
+ const ct = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), q = {
15
+ randomUUID: ct
16
+ };
17
+ function at(r, e, t) {
18
+ if (q.randomUUID && !e && !r)
19
+ return q.randomUUID();
20
+ r = r || {};
21
+ const n = r.random || (r.rng || st)();
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 ut(n);
29
+ }
30
+ var C = function(r, e) {
31
+ return C = 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
+ }, C(r, e);
37
+ };
38
+ function g(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
+ C(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 lt(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 S(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 P(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 U(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 w(r) {
178
+ return this instanceof w ? (this.v = r, this) : new w(r);
179
+ }
180
+ function ft(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(x, d) {
190
+ o.push([f, y, x, d]) > 1 || u(f, y);
191
+ });
192
+ });
193
+ }
194
+ function u(f, y) {
195
+ try {
196
+ a(n[f](y));
197
+ } catch (x) {
198
+ v(o[0][3], x);
199
+ }
200
+ }
201
+ function a(f) {
202
+ f.value instanceof w ? 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 ht(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 S == "function" ? S(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 p(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 k = 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 R(r, e) {
253
+ if (r) {
254
+ var t = r.indexOf(e);
255
+ 0 <= t && r.splice(t, 1);
256
+ }
257
+ }
258
+ var $ = 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 = S(s), a = u.next(); !a.done; a = u.next()) {
271
+ var c = a.value;
272
+ c.remove(this);
273
+ }
274
+ } catch (d) {
275
+ e = { error: d };
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 (p(l))
288
+ try {
289
+ l();
290
+ } catch (d) {
291
+ o = d instanceof k ? d.errors : [d];
292
+ }
293
+ var v = this._finalizers;
294
+ if (v) {
295
+ this._finalizers = null;
296
+ try {
297
+ for (var f = S(v), y = f.next(); !y.done; y = f.next()) {
298
+ var x = y.value;
299
+ try {
300
+ z(x);
301
+ } catch (d) {
302
+ o = o ?? [], d instanceof k ? o = U(U([], P(o)), P(d.errors)) : o.push(d);
303
+ }
304
+ }
305
+ } catch (d) {
306
+ n = { error: d };
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 k(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) && R(t, e);
341
+ }, r.prototype.remove = function(e) {
342
+ var t = this._finalizers;
343
+ t && R(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 = $.EMPTY;
349
+ function N(r) {
350
+ return r instanceof $ || r && "closed" in r && p(r.remove) && p(r.add) && p(r.unsubscribe);
351
+ }
352
+ function z(r) {
353
+ p(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
+ }, F = {
362
+ setTimeout: function(r, e) {
363
+ for (var t = [], n = 2; n < arguments.length; n++)
364
+ t[n - 2] = arguments[n];
365
+ var i = F.delegate;
366
+ return i != null && i.setTimeout ? i.setTimeout.apply(i, U([r, e], P(t))) : setTimeout.apply(void 0, U([r, e], P(t)));
367
+ },
368
+ clearTimeout: function(r) {
369
+ var e = F.delegate;
370
+ return ((e == null ? void 0 : e.clearTimeout) || clearTimeout)(r);
371
+ },
372
+ delegate: void 0
373
+ };
374
+ function et(r) {
375
+ F.setTimeout(function() {
376
+ throw r;
377
+ });
378
+ }
379
+ function D() {
380
+ }
381
+ function O(r) {
382
+ r();
383
+ }
384
+ var V = function(r) {
385
+ g(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 = yt, n;
389
+ }
390
+ return e.create = function(t, n, i) {
391
+ return new L(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
+ }($), pt = Function.prototype.bind;
416
+ function j(r, e) {
417
+ return pt.call(r, e);
418
+ }
419
+ var dt = 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
+ I(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
+ I(n);
438
+ }
439
+ else
440
+ I(e);
441
+ }, r.prototype.complete = function() {
442
+ var e = this.partialObserver;
443
+ if (e.complete)
444
+ try {
445
+ e.complete();
446
+ } catch (t) {
447
+ I(t);
448
+ }
449
+ }, r;
450
+ }(), L = function(r) {
451
+ g(e, r);
452
+ function e(t, n, i) {
453
+ var o = r.call(this) || this, s;
454
+ if (p(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 && j(t.next, u),
466
+ error: t.error && j(t.error, u),
467
+ complete: t.complete && j(t.complete, u)
468
+ }) : s = t;
469
+ }
470
+ return o.destination = new dt(s), o;
471
+ }
472
+ return e;
473
+ }(V);
474
+ function I(r) {
475
+ et(r);
476
+ }
477
+ function vt(r) {
478
+ throw r;
479
+ }
480
+ var yt = {
481
+ closed: !0,
482
+ next: D,
483
+ error: vt,
484
+ complete: D
485
+ }, B = function() {
486
+ return typeof Symbol == "function" && Symbol.observable || "@@observable";
487
+ }();
488
+ function bt(r) {
489
+ return r;
490
+ }
491
+ function mt(r) {
492
+ return r.length === 0 ? bt : r.length === 1 ? r[0] : function(t) {
493
+ return r.reduce(function(n, i) {
494
+ return i(n);
495
+ }, t);
496
+ };
497
+ }
498
+ var m = 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 = St(e) ? e : new L(e, t, n);
507
+ return O(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 L({
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[B] = 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 mt(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 wt(r) {
563
+ return r && p(r.next) && p(r.error) && p(r.complete);
564
+ }
565
+ function St(r) {
566
+ return r && r instanceof V || wt(r) && N(r);
567
+ }
568
+ function gt(r) {
569
+ return p(r == null ? void 0 : r.lift);
570
+ }
571
+ function H(r) {
572
+ return function(e) {
573
+ if (gt(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 T(r, e, t, n, i) {
585
+ return new xt(r, e, t, n, i);
586
+ }
587
+ var xt = function(r) {
588
+ g(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
+ }(V), Et = X(function(r) {
623
+ return function() {
624
+ r(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
625
+ };
626
+ }), b = function(r) {
627
+ g(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 Et();
638
+ }, e.prototype.next = function(t) {
639
+ var n = this;
640
+ O(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 = S(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
+ O(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
+ O(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 $(function() {
695
+ n.currentObservers = null, R(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 m();
702
+ return t.source = this, t;
703
+ }, e.create = function(t, n) {
704
+ return new J(t, n);
705
+ }, e;
706
+ }(m), J = function(r) {
707
+ g(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
+ }(b), M = function(r) {
726
+ g(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
+ }(b), rt = new m(function(r) {
749
+ return r.complete();
750
+ }), _t = function(r) {
751
+ return r && typeof r.length == "number" && typeof r != "function";
752
+ };
753
+ function It(r) {
754
+ return p(r == null ? void 0 : r.then);
755
+ }
756
+ function Ot(r) {
757
+ return p(r[B]);
758
+ }
759
+ function Pt(r) {
760
+ return Symbol.asyncIterator && p(r == null ? void 0 : r[Symbol.asyncIterator]);
761
+ }
762
+ function Ut(r) {
763
+ 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.");
764
+ }
765
+ function Tt() {
766
+ return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
767
+ }
768
+ var $t = Tt();
769
+ function At(r) {
770
+ return p(r == null ? void 0 : r[$t]);
771
+ }
772
+ function kt(r) {
773
+ return ft(this, arguments, function() {
774
+ var t, n, i, o;
775
+ return W(this, function(s) {
776
+ switch (s.label) {
777
+ case 0:
778
+ t = r.getReader(), s.label = 1;
779
+ case 1:
780
+ s.trys.push([1, , 9, 10]), s.label = 2;
781
+ case 2:
782
+ return [4, w(t.read())];
783
+ case 3:
784
+ return n = s.sent(), i = n.value, o = n.done, o ? [4, w(void 0)] : [3, 5];
785
+ case 4:
786
+ return [2, s.sent()];
787
+ case 5:
788
+ return [4, w(i)];
789
+ case 6:
790
+ return [4, s.sent()];
791
+ case 7:
792
+ return s.sent(), [3, 2];
793
+ case 8:
794
+ return [3, 10];
795
+ case 9:
796
+ return t.releaseLock(), [7];
797
+ case 10:
798
+ return [2];
799
+ }
800
+ });
801
+ });
802
+ }
803
+ function jt(r) {
804
+ return p(r == null ? void 0 : r.getReader);
805
+ }
806
+ function nt(r) {
807
+ if (r instanceof m)
808
+ return r;
809
+ if (r != null) {
810
+ if (Ot(r))
811
+ return Ct(r);
812
+ if (_t(r))
813
+ return Rt(r);
814
+ if (It(r))
815
+ return Ft(r);
816
+ if (Pt(r))
817
+ return it(r);
818
+ if (At(r))
819
+ return Dt(r);
820
+ if (jt(r))
821
+ return Lt(r);
822
+ }
823
+ throw Ut(r);
824
+ }
825
+ function Ct(r) {
826
+ return new m(function(e) {
827
+ var t = r[B]();
828
+ if (p(t.subscribe))
829
+ return t.subscribe(e);
830
+ throw new TypeError("Provided object does not correctly implement Symbol.observable");
831
+ });
832
+ }
833
+ function Rt(r) {
834
+ return new m(function(e) {
835
+ for (var t = 0; t < r.length && !e.closed; t++)
836
+ e.next(r[t]);
837
+ e.complete();
838
+ });
839
+ }
840
+ function Ft(r) {
841
+ return new m(function(e) {
842
+ r.then(function(t) {
843
+ e.closed || (e.next(t), e.complete());
844
+ }, function(t) {
845
+ return e.error(t);
846
+ }).then(null, et);
847
+ });
848
+ }
849
+ function Dt(r) {
850
+ return new m(function(e) {
851
+ var t, n;
852
+ try {
853
+ for (var i = S(r), o = i.next(); !o.done; o = i.next()) {
854
+ var s = o.value;
855
+ if (e.next(s), e.closed)
856
+ return;
857
+ }
858
+ } catch (u) {
859
+ t = { error: u };
860
+ } finally {
861
+ try {
862
+ o && !o.done && (n = i.return) && n.call(i);
863
+ } finally {
864
+ if (t)
865
+ throw t.error;
866
+ }
867
+ }
868
+ e.complete();
869
+ });
870
+ }
871
+ function it(r) {
872
+ return new m(function(e) {
873
+ Mt(r, e).catch(function(t) {
874
+ return e.error(t);
875
+ });
876
+ });
877
+ }
878
+ function Lt(r) {
879
+ return it(kt(r));
880
+ }
881
+ function Mt(r, e) {
882
+ var t, n, i, o;
883
+ return lt(this, void 0, void 0, function() {
884
+ var s, u;
885
+ return W(this, function(a) {
886
+ switch (a.label) {
887
+ case 0:
888
+ a.trys.push([0, 5, 6, 11]), t = ht(r), a.label = 1;
889
+ case 1:
890
+ return [4, t.next()];
891
+ case 2:
892
+ if (n = a.sent(), !!n.done)
893
+ return [3, 4];
894
+ if (s = n.value, e.next(s), e.closed)
895
+ return [2];
896
+ a.label = 3;
897
+ case 3:
898
+ return [3, 1];
899
+ case 4:
900
+ return [3, 11];
901
+ case 5:
902
+ return u = a.sent(), i = { error: u }, [3, 11];
903
+ case 6:
904
+ return a.trys.push([6, , 9, 10]), n && !n.done && (o = t.return) ? [4, o.call(t)] : [3, 8];
905
+ case 7:
906
+ a.sent(), a.label = 8;
907
+ case 8:
908
+ return [3, 10];
909
+ case 9:
910
+ if (i)
911
+ throw i.error;
912
+ return [7];
913
+ case 10:
914
+ return [7];
915
+ case 11:
916
+ return e.complete(), [2];
917
+ }
918
+ });
919
+ });
920
+ }
921
+ function Y(r) {
922
+ return r <= 0 ? function() {
923
+ return rt;
924
+ } : H(function(e, t) {
925
+ var n = 0;
926
+ e.subscribe(T(t, function(i) {
927
+ ++n <= r && (t.next(i), r <= n && t.complete());
928
+ }));
929
+ });
930
+ }
931
+ function Yt(r, e) {
932
+ return H(function(t, n) {
933
+ var i = null, o = 0, s = !1, u = function() {
934
+ return s && !i && n.complete();
935
+ };
936
+ t.subscribe(T(n, function(a) {
937
+ i == null || i.unsubscribe();
938
+ var c = 0, l = o++;
939
+ nt(r(a, l)).subscribe(i = T(n, function(v) {
940
+ return n.next(e ? e(a, v, l, c++) : v);
941
+ }, function() {
942
+ i = null, u();
943
+ }));
944
+ }, function() {
945
+ s = !0, u();
946
+ }));
947
+ });
948
+ }
949
+ function Q(r) {
950
+ return H(function(e, t) {
951
+ nt(r).subscribe(T(t, function() {
952
+ return t.complete();
953
+ }, D)), !t.closed && e.subscribe(t);
954
+ });
955
+ }
956
+ class Vt {
957
+ constructor(e, t, n) {
958
+ this.id = e, this.component = t, this.platform = n, this.entries$ = new M([]), this.kill$ = new b(), this.isTyping$ = new M(!1), t.addEventListener("user-submit", (i) => {
959
+ if (!this.provider) {
960
+ console.warn(
961
+ "No provider activated, unable to print message to conversation."
962
+ );
963
+ return;
964
+ }
965
+ this.provider.onUserSubmit(i.detail);
966
+ });
967
+ }
968
+ write(e) {
969
+ this.addEntryRemoveHandler(e), this.entries$.pipe(Y(1)).subscribe((t) => {
970
+ this.entries$.next([...t, e]);
971
+ });
972
+ }
973
+ entries() {
974
+ return this.entries$.asObservable();
975
+ }
976
+ setProvider(e, t = {}) {
977
+ this.provider = e, this.provider.actions().pipe(Q(this.kill$)).subscribe((n) => {
978
+ this.write(n);
979
+ }), this.provider.isTyping().pipe(Q(this.kill$)).subscribe((n) => {
980
+ this.isTyping$.next(n);
981
+ }), this.provider.connect(t);
982
+ }
983
+ handover(e, t = {}) {
984
+ var i;
985
+ (i = this.provider) == null || i.setTypingState(!1);
986
+ const n = this.platform.registeredProviders.get(e);
987
+ if (n) {
988
+ this.kill$.next();
989
+ const o = n(this);
990
+ return this.setProvider(o, t), o.onComplete();
991
+ }
992
+ return rt;
993
+ }
994
+ addEntryRemoveHandler(e) {
995
+ e.remove$.pipe(
996
+ Yt(() => this.entries$),
997
+ Y(1)
998
+ ).subscribe((t) => {
999
+ this.entries$.next(t.filter((n) => n !== e));
1000
+ });
1001
+ }
1002
+ isTyping() {
1003
+ return this.isTyping$.asObservable();
1004
+ }
1005
+ }
1006
+ class G {
1007
+ constructor() {
1008
+ this.sessions = /* @__PURE__ */ new Map(), this.registeredProviders = /* @__PURE__ */ new Map(), this.activeSessionId = null;
1009
+ }
1010
+ static async getInstance(e) {
1011
+ let t = await e.get("conversation");
1012
+ return t || (t = new G(), await e.register("conversation", t), t);
1013
+ }
1014
+ registerProvider(e, t) {
1015
+ this.registeredProviders.set(e, t);
1016
+ }
1017
+ createSession(e) {
1018
+ const t = new Vt(at(), e, this), n = this.getProviderByConfiguration(e);
1019
+ if (n) {
1020
+ const i = n(t);
1021
+ t.setProvider(i);
1022
+ }
1023
+ return this.sessions.set(t.id, t), this.activeSessionId = t.id, t;
1024
+ }
1025
+ getProviderByConfiguration(e) {
1026
+ const [t] = e.properties.providers || [];
1027
+ if (!t) {
1028
+ console.warn(
1029
+ "No providers registered. You most likely forgot to add a provider to the conversation component properties."
1030
+ );
1031
+ return;
1032
+ }
1033
+ return this.registeredProviders.get(t);
1034
+ }
1035
+ }
1036
+ const qt = async (r) => {
1037
+ r.registerComponent("conversation", import("./conversation-f7ad8459.mjs")), await G.getInstance(r.container);
1038
+ };
1039
+ var E = /* @__PURE__ */ ((r) => (r.User = "user", r.Agent = "agent", r.System = "system", r))(E || {});
1040
+ class A {
1041
+ constructor(e, t, n) {
1042
+ this.type = e, this.sender = t, this.messages = n, this.status = "delivered", this.didUpdate = new b(), this.actions$ = new b(), this.remove$ = new b(), this.timestamp = Date.now();
1043
+ }
1044
+ update(e) {
1045
+ this.messages = [
1046
+ {
1047
+ items: e
1048
+ }
1049
+ ], this.didUpdate.next(this);
1050
+ }
1051
+ setStatus(e) {
1052
+ this.status = e, this.didUpdate.next(this);
1053
+ }
1054
+ remove() {
1055
+ this.remove$.next();
1056
+ }
1057
+ }
1058
+ class Bt {
1059
+ constructor(e) {
1060
+ this.name = e, this.print$ = new b();
1061
+ }
1062
+ print(e) {
1063
+ const t = new A(
1064
+ E.Agent,
1065
+ { name: this.name },
1066
+ [
1067
+ {
1068
+ items: [["html", { content: e }]]
1069
+ }
1070
+ ]
1071
+ );
1072
+ return this.print$.next(t), t;
1073
+ }
1074
+ subscribe() {
1075
+ return this.print$.asObservable();
1076
+ }
1077
+ }
1078
+ class Ht {
1079
+ constructor(e) {
1080
+ this.name = e, this.print$ = new b();
1081
+ }
1082
+ print(e) {
1083
+ const t = new A(
1084
+ E.User,
1085
+ { name: this.name },
1086
+ [
1087
+ {
1088
+ items: [["html", { content: e }]]
1089
+ }
1090
+ ]
1091
+ );
1092
+ return this.print$.next(t), t;
1093
+ }
1094
+ subscribe() {
1095
+ return this.print$.asObservable();
1096
+ }
1097
+ }
1098
+ class Gt {
1099
+ constructor() {
1100
+ this.print$ = new b(), this.name = "system";
1101
+ }
1102
+ print(e) {
1103
+ const t = new A(
1104
+ E.System,
1105
+ { name: this.name },
1106
+ [
1107
+ {
1108
+ items: [["html", { content: e }]]
1109
+ }
1110
+ ]
1111
+ );
1112
+ return this.print$.next(t), t;
1113
+ }
1114
+ subscribe() {
1115
+ return this.print$.asObservable();
1116
+ }
1117
+ }
1118
+ class zt {
1119
+ constructor(e, t) {
1120
+ this.name = e, this.session = t, this.print$ = new b(), this.typingState$ = new M(!1), this.complete$ = new b(), this.system = this.createSystem(), this.onComplete = () => this.complete$.asObservable();
1121
+ }
1122
+ connect(e = {}) {
1123
+ this.complete$.pipe(Y(1)).subscribe(() => {
1124
+ this.disconnected();
1125
+ });
1126
+ }
1127
+ // this is always executed when a provider is complete
1128
+ // overide this method to handle specific cases
1129
+ disconnected() {
1130
+ }
1131
+ onUserSubmit(e) {
1132
+ this.print(E.User, e.text);
1133
+ }
1134
+ print(e, t) {
1135
+ const n = new A(
1136
+ e,
1137
+ {
1138
+ name: ""
1139
+ },
1140
+ [
1141
+ {
1142
+ items: [["html", { content: t }]]
1143
+ }
1144
+ ]
1145
+ );
1146
+ return this.printEntry(n);
1147
+ }
1148
+ printEntry(e) {
1149
+ return this.print$.next(e), e;
1150
+ }
1151
+ createAgent(e) {
1152
+ const t = new Bt(e);
1153
+ return t.subscribe().subscribe((n) => {
1154
+ this.playNotification(), this.printEntry(n);
1155
+ }), t;
1156
+ }
1157
+ createUser(e) {
1158
+ const t = new Ht(e);
1159
+ return t.subscribe().subscribe((n) => {
1160
+ this.printEntry(n);
1161
+ }), t;
1162
+ }
1163
+ createSystem() {
1164
+ const e = new Gt();
1165
+ return e.subscribe().subscribe((t) => {
1166
+ this.printEntry(t);
1167
+ }), e;
1168
+ }
1169
+ setTypingState(e) {
1170
+ this.typingState$.next(e);
1171
+ }
1172
+ setToastMessage(e) {
1173
+ this.session.component.setToastMessage(e);
1174
+ }
1175
+ isTyping() {
1176
+ return this.typingState$.asObservable();
1177
+ }
1178
+ actions() {
1179
+ return this.print$.asObservable();
1180
+ }
1181
+ playNotification() {
1182
+ const e = "https://publicpoc.blob.core.windows.net/widget-assets/notification.mp3";
1183
+ this.session.component.application.branding().other.disableSound || new Audio(e).play();
1184
+ }
1185
+ complete() {
1186
+ this.complete$.next();
1187
+ }
1188
+ }
1189
+ export {
1190
+ Bt as A,
1191
+ E as C,
1192
+ rt as E,
1193
+ Ht as U,
1194
+ qt as a,
1195
+ G as b,
1196
+ zt as c,
1197
+ A as d,
1198
+ Vt as e
1199
+ };