@telia-ace/widget-conversation-flamingo 1.1.12-rc.0 → 1.1.12-rc.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/conversation-1bf28a6e.js +572 -0
  2. package/conversation-7da6b954.mjs +2619 -0
  3. package/conversation-component.d.ts +2 -0
  4. package/conversation-platform.d.ts +10 -49
  5. package/conversation-session.d.ts +11 -0
  6. package/conversation.d.ts +23 -0
  7. package/entry.d.ts +9 -0
  8. package/group.d.ts +7 -0
  9. package/{index-1ea0fde8.mjs → index-217978bc.mjs} +320 -319
  10. package/index-43151bb4.js +1 -0
  11. package/index-494250de.js +3 -0
  12. package/index-4ba82b09.mjs +777 -0
  13. package/index.d.ts +6 -10
  14. package/index.js +1 -1
  15. package/index.mjs +7 -9
  16. package/{components/conversation/ui/message-types → message-types}/message-type-html.d.ts +3 -2
  17. package/models/agent.d.ts +8 -0
  18. package/models/conversation-entry.d.ts +11 -0
  19. package/models/conversation-provider.d.ts +19 -0
  20. package/models/conversation-session-state.d.ts +13 -0
  21. package/models/user.d.ts +8 -0
  22. package/package.json +5 -6
  23. package/types.d.ts +9 -123
  24. package/agent.d.ts +0 -20
  25. package/components/conversation/conversation.d.ts +0 -19
  26. package/components/conversation/plugin.d.ts +0 -45
  27. package/components/conversation/ui/message-list.d.ts +0 -9
  28. package/components/conversation/ui/message-types/message-type-link-list.d.ts +0 -8
  29. package/components/conversation/ui/message-types/message-type-separator.d.ts +0 -7
  30. package/components/conversation/ui/message.d.ts +0 -8
  31. package/components/conversation/utils.d.ts +0 -1
  32. package/conversation-17a64990.mjs +0 -1865
  33. package/conversation-b2f9f789.js +0 -446
  34. package/conversation-controller.d.ts +0 -118
  35. package/conversation-history.d.ts +0 -26
  36. package/conversation-provider.d.ts +0 -32
  37. package/index-c51d4b6a.js +0 -1
  38. package/index-ecfa0fe7.js +0 -156
  39. package/index-ffd77508.mjs +0 -3923
  40. package/send-18482cae.mjs +0 -4
  41. package/send-eb8b9428.js +0 -1
  42. package/store.d.ts +0 -31
  43. package/user.d.ts +0 -9
  44. package/utils/custom-message.d.ts +0 -2
  45. package/utils/index.d.ts +0 -1
  46. package/utils/open-chat-widget.d.ts +0 -4
  47. package/utils/swap-provider.d.ts +0 -8
@@ -0,0 +1,777 @@
1
+ const gt = async (e) => {
2
+ e.registerComponent("conversation", import("./conversation-7da6b954.mjs").then((t) => t.c));
3
+ const r = await Promise.resolve().then(() => yt).then(
4
+ (t) => t.ConversationPlatform
5
+ );
6
+ e.container.register("conversation", new r());
7
+ };
8
+ let m;
9
+ const q = new Uint8Array(16);
10
+ function G() {
11
+ if (!m && (m = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !m))
12
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
13
+ return m(q);
14
+ }
15
+ const a = [];
16
+ for (let e = 0; e < 256; ++e)
17
+ a.push((e + 256).toString(16).slice(1));
18
+ function J(e, r = 0) {
19
+ return a[e[r + 0]] + a[e[r + 1]] + a[e[r + 2]] + a[e[r + 3]] + "-" + a[e[r + 4]] + a[e[r + 5]] + "-" + a[e[r + 6]] + a[e[r + 7]] + "-" + a[e[r + 8]] + a[e[r + 9]] + "-" + a[e[r + 10]] + a[e[r + 11]] + a[e[r + 12]] + a[e[r + 13]] + a[e[r + 14]] + a[e[r + 15]];
20
+ }
21
+ const Q = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), R = {
22
+ randomUUID: Q
23
+ };
24
+ function W(e, r, t) {
25
+ if (R.randomUUID && !r && !e)
26
+ return R.randomUUID();
27
+ e = e || {};
28
+ const n = e.random || (e.rng || G)();
29
+ if (n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, r) {
30
+ t = t || 0;
31
+ for (let i = 0; i < 16; ++i)
32
+ r[t + i] = n[i];
33
+ return r;
34
+ }
35
+ return J(n);
36
+ }
37
+ var O = function(e, r) {
38
+ return O = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
39
+ t.__proto__ = n;
40
+ } || function(t, n) {
41
+ for (var i in n)
42
+ Object.prototype.hasOwnProperty.call(n, i) && (t[i] = n[i]);
43
+ }, O(e, r);
44
+ };
45
+ function d(e, r) {
46
+ if (typeof r != "function" && r !== null)
47
+ throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
48
+ O(e, r);
49
+ function t() {
50
+ this.constructor = e;
51
+ }
52
+ e.prototype = r === null ? Object.create(r) : (t.prototype = r.prototype, new t());
53
+ }
54
+ function j(e) {
55
+ var r = typeof Symbol == "function" && Symbol.iterator, t = r && e[r], n = 0;
56
+ if (t)
57
+ return t.call(e);
58
+ if (e && typeof e.length == "number")
59
+ return {
60
+ next: function() {
61
+ return e && n >= e.length && (e = void 0), { value: e && e[n++], done: !e };
62
+ }
63
+ };
64
+ throw new TypeError(r ? "Object is not iterable." : "Symbol.iterator is not defined.");
65
+ }
66
+ function w(e, r) {
67
+ var t = typeof Symbol == "function" && e[Symbol.iterator];
68
+ if (!t)
69
+ return e;
70
+ var n = t.call(e), i, o = [], s;
71
+ try {
72
+ for (; (r === void 0 || r-- > 0) && !(i = n.next()).done; )
73
+ o.push(i.value);
74
+ } catch (u) {
75
+ s = { error: u };
76
+ } finally {
77
+ try {
78
+ i && !i.done && (t = n.return) && t.call(n);
79
+ } finally {
80
+ if (s)
81
+ throw s.error;
82
+ }
83
+ }
84
+ return o;
85
+ }
86
+ function _(e, r, t) {
87
+ if (t || arguments.length === 2)
88
+ for (var n = 0, i = r.length, o; n < i; n++)
89
+ (o || !(n in r)) && (o || (o = Array.prototype.slice.call(r, 0, n)), o[n] = r[n]);
90
+ return e.concat(o || Array.prototype.slice.call(r));
91
+ }
92
+ function p(e) {
93
+ return typeof e == "function";
94
+ }
95
+ function Y(e) {
96
+ var r = function(n) {
97
+ Error.call(n), n.stack = new Error().stack;
98
+ }, t = e(r);
99
+ return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
100
+ }
101
+ var x = Y(function(e) {
102
+ return function(t) {
103
+ e(this), this.message = t ? t.length + ` errors occurred during unsubscription:
104
+ ` + t.map(function(n, i) {
105
+ return i + 1 + ") " + n.toString();
106
+ }).join(`
107
+ `) : "", this.name = "UnsubscriptionError", this.errors = t;
108
+ };
109
+ });
110
+ function A(e, r) {
111
+ if (e) {
112
+ var t = e.indexOf(r);
113
+ 0 <= t && e.splice(t, 1);
114
+ }
115
+ }
116
+ var E = function() {
117
+ function e(r) {
118
+ this.initialTeardown = r, this.closed = !1, this._parentage = null, this._finalizers = null;
119
+ }
120
+ return e.prototype.unsubscribe = function() {
121
+ var r, t, n, i, o;
122
+ if (!this.closed) {
123
+ this.closed = !0;
124
+ var s = this._parentage;
125
+ if (s)
126
+ if (this._parentage = null, Array.isArray(s))
127
+ try {
128
+ for (var u = j(s), c = u.next(); !c.done; c = u.next()) {
129
+ var h = c.value;
130
+ h.remove(this);
131
+ }
132
+ } catch (l) {
133
+ r = { error: l };
134
+ } finally {
135
+ try {
136
+ c && !c.done && (t = u.return) && t.call(u);
137
+ } finally {
138
+ if (r)
139
+ throw r.error;
140
+ }
141
+ }
142
+ else
143
+ s.remove(this);
144
+ var f = this.initialTeardown;
145
+ if (p(f))
146
+ try {
147
+ f();
148
+ } catch (l) {
149
+ o = l instanceof x ? l.errors : [l];
150
+ }
151
+ var F = this._finalizers;
152
+ if (F) {
153
+ this._finalizers = null;
154
+ try {
155
+ for (var y = j(F), b = y.next(); !b.done; b = y.next()) {
156
+ var K = b.value;
157
+ try {
158
+ B(K);
159
+ } catch (l) {
160
+ o = o ?? [], l instanceof x ? o = _(_([], w(o)), w(l.errors)) : o.push(l);
161
+ }
162
+ }
163
+ } catch (l) {
164
+ n = { error: l };
165
+ } finally {
166
+ try {
167
+ b && !b.done && (i = y.return) && i.call(y);
168
+ } finally {
169
+ if (n)
170
+ throw n.error;
171
+ }
172
+ }
173
+ }
174
+ if (o)
175
+ throw new x(o);
176
+ }
177
+ }, e.prototype.add = function(r) {
178
+ var t;
179
+ if (r && r !== this)
180
+ if (this.closed)
181
+ B(r);
182
+ else {
183
+ if (r instanceof e) {
184
+ if (r.closed || r._hasParent(this))
185
+ return;
186
+ r._addParent(this);
187
+ }
188
+ (this._finalizers = (t = this._finalizers) !== null && t !== void 0 ? t : []).push(r);
189
+ }
190
+ }, e.prototype._hasParent = function(r) {
191
+ var t = this._parentage;
192
+ return t === r || Array.isArray(t) && t.includes(r);
193
+ }, e.prototype._addParent = function(r) {
194
+ var t = this._parentage;
195
+ this._parentage = Array.isArray(t) ? (t.push(r), t) : t ? [t, r] : r;
196
+ }, e.prototype._removeParent = function(r) {
197
+ var t = this._parentage;
198
+ t === r ? this._parentage = null : Array.isArray(t) && A(t, r);
199
+ }, e.prototype.remove = function(r) {
200
+ var t = this._finalizers;
201
+ t && A(t, r), r instanceof e && r._removeParent(this);
202
+ }, e.EMPTY = function() {
203
+ var r = new e();
204
+ return r.closed = !0, r;
205
+ }(), e;
206
+ }(), H = E.EMPTY;
207
+ function z(e) {
208
+ return e instanceof E || e && "closed" in e && p(e.remove) && p(e.add) && p(e.unsubscribe);
209
+ }
210
+ function B(e) {
211
+ p(e) ? e() : e.unsubscribe();
212
+ }
213
+ var L = {
214
+ onUnhandledError: null,
215
+ onStoppedNotification: null,
216
+ Promise: void 0,
217
+ useDeprecatedSynchronousErrorHandling: !1,
218
+ useDeprecatedNextContext: !1
219
+ }, C = {
220
+ setTimeout: function(e, r) {
221
+ for (var t = [], n = 2; n < arguments.length; n++)
222
+ t[n - 2] = arguments[n];
223
+ var i = C.delegate;
224
+ return i != null && i.setTimeout ? i.setTimeout.apply(i, _([e, r], w(t))) : setTimeout.apply(void 0, _([e, r], w(t)));
225
+ },
226
+ clearTimeout: function(e) {
227
+ var r = C.delegate;
228
+ return ((r == null ? void 0 : r.clearTimeout) || clearTimeout)(e);
229
+ },
230
+ delegate: void 0
231
+ };
232
+ function X(e) {
233
+ C.setTimeout(function() {
234
+ throw e;
235
+ });
236
+ }
237
+ function V() {
238
+ }
239
+ function g(e) {
240
+ e();
241
+ }
242
+ var $ = function(e) {
243
+ d(r, e);
244
+ function r(t) {
245
+ var n = e.call(this) || this;
246
+ return n.isStopped = !1, t ? (n.destination = t, z(t) && t.add(n)) : n.destination = rt, n;
247
+ }
248
+ return r.create = function(t, n, i) {
249
+ return new T(t, n, i);
250
+ }, r.prototype.next = function(t) {
251
+ this.isStopped || this._next(t);
252
+ }, r.prototype.error = function(t) {
253
+ this.isStopped || (this.isStopped = !0, this._error(t));
254
+ }, r.prototype.complete = function() {
255
+ this.isStopped || (this.isStopped = !0, this._complete());
256
+ }, r.prototype.unsubscribe = function() {
257
+ this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this), this.destination = null);
258
+ }, r.prototype._next = function(t) {
259
+ this.destination.next(t);
260
+ }, r.prototype._error = function(t) {
261
+ try {
262
+ this.destination.error(t);
263
+ } finally {
264
+ this.unsubscribe();
265
+ }
266
+ }, r.prototype._complete = function() {
267
+ try {
268
+ this.destination.complete();
269
+ } finally {
270
+ this.unsubscribe();
271
+ }
272
+ }, r;
273
+ }(E), Z = Function.prototype.bind;
274
+ function U(e, r) {
275
+ return Z.call(e, r);
276
+ }
277
+ var N = function() {
278
+ function e(r) {
279
+ this.partialObserver = r;
280
+ }
281
+ return e.prototype.next = function(r) {
282
+ var t = this.partialObserver;
283
+ if (t.next)
284
+ try {
285
+ t.next(r);
286
+ } catch (n) {
287
+ S(n);
288
+ }
289
+ }, e.prototype.error = function(r) {
290
+ var t = this.partialObserver;
291
+ if (t.error)
292
+ try {
293
+ t.error(r);
294
+ } catch (n) {
295
+ S(n);
296
+ }
297
+ else
298
+ S(r);
299
+ }, e.prototype.complete = function() {
300
+ var r = this.partialObserver;
301
+ if (r.complete)
302
+ try {
303
+ r.complete();
304
+ } catch (t) {
305
+ S(t);
306
+ }
307
+ }, e;
308
+ }(), T = function(e) {
309
+ d(r, e);
310
+ function r(t, n, i) {
311
+ var o = e.call(this) || this, s;
312
+ if (p(t) || !t)
313
+ s = {
314
+ next: t ?? void 0,
315
+ error: n ?? void 0,
316
+ complete: i ?? void 0
317
+ };
318
+ else {
319
+ var u;
320
+ o && L.useDeprecatedNextContext ? (u = Object.create(t), u.unsubscribe = function() {
321
+ return o.unsubscribe();
322
+ }, s = {
323
+ next: t.next && U(t.next, u),
324
+ error: t.error && U(t.error, u),
325
+ complete: t.complete && U(t.complete, u)
326
+ }) : s = t;
327
+ }
328
+ return o.destination = new N(s), o;
329
+ }
330
+ return r;
331
+ }($);
332
+ function S(e) {
333
+ X(e);
334
+ }
335
+ function tt(e) {
336
+ throw e;
337
+ }
338
+ var rt = {
339
+ closed: !0,
340
+ next: V,
341
+ error: tt,
342
+ complete: V
343
+ }, et = function() {
344
+ return typeof Symbol == "function" && Symbol.observable || "@@observable";
345
+ }();
346
+ function nt(e) {
347
+ return e;
348
+ }
349
+ function it(e) {
350
+ return e.length === 0 ? nt : e.length === 1 ? e[0] : function(t) {
351
+ return e.reduce(function(n, i) {
352
+ return i(n);
353
+ }, t);
354
+ };
355
+ }
356
+ var I = function() {
357
+ function e(r) {
358
+ r && (this._subscribe = r);
359
+ }
360
+ return e.prototype.lift = function(r) {
361
+ var t = new e();
362
+ return t.source = this, t.operator = r, t;
363
+ }, e.prototype.subscribe = function(r, t, n) {
364
+ var i = this, o = st(r) ? r : new T(r, t, n);
365
+ return g(function() {
366
+ var s = i, u = s.operator, c = s.source;
367
+ o.add(u ? u.call(o, c) : c ? i._subscribe(o) : i._trySubscribe(o));
368
+ }), o;
369
+ }, e.prototype._trySubscribe = function(r) {
370
+ try {
371
+ return this._subscribe(r);
372
+ } catch (t) {
373
+ r.error(t);
374
+ }
375
+ }, e.prototype.forEach = function(r, t) {
376
+ var n = this;
377
+ return t = k(t), new t(function(i, o) {
378
+ var s = new T({
379
+ next: function(u) {
380
+ try {
381
+ r(u);
382
+ } catch (c) {
383
+ o(c), s.unsubscribe();
384
+ }
385
+ },
386
+ error: o,
387
+ complete: i
388
+ });
389
+ n.subscribe(s);
390
+ });
391
+ }, e.prototype._subscribe = function(r) {
392
+ var t;
393
+ return (t = this.source) === null || t === void 0 ? void 0 : t.subscribe(r);
394
+ }, e.prototype[et] = function() {
395
+ return this;
396
+ }, e.prototype.pipe = function() {
397
+ for (var r = [], t = 0; t < arguments.length; t++)
398
+ r[t] = arguments[t];
399
+ return it(r)(this);
400
+ }, e.prototype.toPromise = function(r) {
401
+ var t = this;
402
+ return r = k(r), new r(function(n, i) {
403
+ var o;
404
+ t.subscribe(function(s) {
405
+ return o = s;
406
+ }, function(s) {
407
+ return i(s);
408
+ }, function() {
409
+ return n(o);
410
+ });
411
+ });
412
+ }, e.create = function(r) {
413
+ return new e(r);
414
+ }, e;
415
+ }();
416
+ function k(e) {
417
+ var r;
418
+ return (r = e ?? L.Promise) !== null && r !== void 0 ? r : Promise;
419
+ }
420
+ function ot(e) {
421
+ return e && p(e.next) && p(e.error) && p(e.complete);
422
+ }
423
+ function st(e) {
424
+ return e && e instanceof $ || ot(e) && z(e);
425
+ }
426
+ function ut(e) {
427
+ return p(e == null ? void 0 : e.lift);
428
+ }
429
+ function ct(e) {
430
+ return function(r) {
431
+ if (ut(r))
432
+ return r.lift(function(t) {
433
+ try {
434
+ return e(t, this);
435
+ } catch (n) {
436
+ this.error(n);
437
+ }
438
+ });
439
+ throw new TypeError("Unable to lift unknown Observable type");
440
+ };
441
+ }
442
+ function at(e, r, t, n, i) {
443
+ return new lt(e, r, t, n, i);
444
+ }
445
+ var lt = function(e) {
446
+ d(r, e);
447
+ function r(t, n, i, o, s, u) {
448
+ var c = e.call(this, t) || this;
449
+ return c.onFinalize = s, c.shouldUnsubscribe = u, c._next = n ? function(h) {
450
+ try {
451
+ n(h);
452
+ } catch (f) {
453
+ t.error(f);
454
+ }
455
+ } : e.prototype._next, c._error = o ? function(h) {
456
+ try {
457
+ o(h);
458
+ } catch (f) {
459
+ t.error(f);
460
+ } finally {
461
+ this.unsubscribe();
462
+ }
463
+ } : e.prototype._error, c._complete = i ? function() {
464
+ try {
465
+ i();
466
+ } catch (h) {
467
+ t.error(h);
468
+ } finally {
469
+ this.unsubscribe();
470
+ }
471
+ } : e.prototype._complete, c;
472
+ }
473
+ return r.prototype.unsubscribe = function() {
474
+ var t;
475
+ if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
476
+ var n = this.closed;
477
+ e.prototype.unsubscribe.call(this), !n && ((t = this.onFinalize) === null || t === void 0 || t.call(this));
478
+ }
479
+ }, r;
480
+ }($), pt = Y(function(e) {
481
+ return function() {
482
+ e(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
483
+ };
484
+ }), v = function(e) {
485
+ d(r, e);
486
+ function r() {
487
+ var t = e.call(this) || this;
488
+ return t.closed = !1, t.currentObservers = null, t.observers = [], t.isStopped = !1, t.hasError = !1, t.thrownError = null, t;
489
+ }
490
+ return r.prototype.lift = function(t) {
491
+ var n = new M(this, this);
492
+ return n.operator = t, n;
493
+ }, r.prototype._throwIfClosed = function() {
494
+ if (this.closed)
495
+ throw new pt();
496
+ }, r.prototype.next = function(t) {
497
+ var n = this;
498
+ g(function() {
499
+ var i, o;
500
+ if (n._throwIfClosed(), !n.isStopped) {
501
+ n.currentObservers || (n.currentObservers = Array.from(n.observers));
502
+ try {
503
+ for (var s = j(n.currentObservers), u = s.next(); !u.done; u = s.next()) {
504
+ var c = u.value;
505
+ c.next(t);
506
+ }
507
+ } catch (h) {
508
+ i = { error: h };
509
+ } finally {
510
+ try {
511
+ u && !u.done && (o = s.return) && o.call(s);
512
+ } finally {
513
+ if (i)
514
+ throw i.error;
515
+ }
516
+ }
517
+ }
518
+ });
519
+ }, r.prototype.error = function(t) {
520
+ var n = this;
521
+ g(function() {
522
+ if (n._throwIfClosed(), !n.isStopped) {
523
+ n.hasError = n.isStopped = !0, n.thrownError = t;
524
+ for (var i = n.observers; i.length; )
525
+ i.shift().error(t);
526
+ }
527
+ });
528
+ }, r.prototype.complete = function() {
529
+ var t = this;
530
+ g(function() {
531
+ if (t._throwIfClosed(), !t.isStopped) {
532
+ t.isStopped = !0;
533
+ for (var n = t.observers; n.length; )
534
+ n.shift().complete();
535
+ }
536
+ });
537
+ }, r.prototype.unsubscribe = function() {
538
+ this.isStopped = this.closed = !0, this.observers = this.currentObservers = null;
539
+ }, Object.defineProperty(r.prototype, "observed", {
540
+ get: function() {
541
+ var t;
542
+ return ((t = this.observers) === null || t === void 0 ? void 0 : t.length) > 0;
543
+ },
544
+ enumerable: !1,
545
+ configurable: !0
546
+ }), r.prototype._trySubscribe = function(t) {
547
+ return this._throwIfClosed(), e.prototype._trySubscribe.call(this, t);
548
+ }, r.prototype._subscribe = function(t) {
549
+ return this._throwIfClosed(), this._checkFinalizedStatuses(t), this._innerSubscribe(t);
550
+ }, r.prototype._innerSubscribe = function(t) {
551
+ var n = this, i = this, o = i.hasError, s = i.isStopped, u = i.observers;
552
+ return o || s ? H : (this.currentObservers = null, u.push(t), new E(function() {
553
+ n.currentObservers = null, A(u, t);
554
+ }));
555
+ }, r.prototype._checkFinalizedStatuses = function(t) {
556
+ var n = this, i = n.hasError, o = n.thrownError, s = n.isStopped;
557
+ i ? t.error(o) : s && t.complete();
558
+ }, r.prototype.asObservable = function() {
559
+ var t = new I();
560
+ return t.source = this, t;
561
+ }, r.create = function(t, n) {
562
+ return new M(t, n);
563
+ }, r;
564
+ }(I), M = function(e) {
565
+ d(r, e);
566
+ function r(t, n) {
567
+ var i = e.call(this) || this;
568
+ return i.destination = t, i.source = n, i;
569
+ }
570
+ return r.prototype.next = function(t) {
571
+ var n, i;
572
+ (i = (n = this.destination) === null || n === void 0 ? void 0 : n.next) === null || i === void 0 || i.call(n, t);
573
+ }, r.prototype.error = function(t) {
574
+ var n, i;
575
+ (i = (n = this.destination) === null || n === void 0 ? void 0 : n.error) === null || i === void 0 || i.call(n, t);
576
+ }, r.prototype.complete = function() {
577
+ var t, n;
578
+ (n = (t = this.destination) === null || t === void 0 ? void 0 : t.complete) === null || n === void 0 || n.call(t);
579
+ }, r.prototype._subscribe = function(t) {
580
+ var n, i;
581
+ return (i = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(t)) !== null && i !== void 0 ? i : H;
582
+ }, r;
583
+ }(v), ht = function(e) {
584
+ d(r, e);
585
+ function r(t) {
586
+ var n = e.call(this) || this;
587
+ return n._value = t, n;
588
+ }
589
+ return Object.defineProperty(r.prototype, "value", {
590
+ get: function() {
591
+ return this.getValue();
592
+ },
593
+ enumerable: !1,
594
+ configurable: !0
595
+ }), r.prototype._subscribe = function(t) {
596
+ var n = e.prototype._subscribe.call(this, t);
597
+ return !n.closed && t.next(this._value), n;
598
+ }, r.prototype.getValue = function() {
599
+ var t = this, n = t.hasError, i = t.thrownError, o = t._value;
600
+ if (n)
601
+ throw i;
602
+ return this._throwIfClosed(), o;
603
+ }, r.prototype.next = function(t) {
604
+ e.prototype.next.call(this, this._value = t);
605
+ }, r;
606
+ }(v), ft = new I(function(e) {
607
+ return e.complete();
608
+ });
609
+ function dt(e) {
610
+ return e <= 0 ? function() {
611
+ return ft;
612
+ } : ct(function(r, t) {
613
+ var n = 0;
614
+ r.subscribe(at(t, function(i) {
615
+ ++n <= e && (t.next(i), e <= n && t.complete());
616
+ }));
617
+ });
618
+ }
619
+ class vt {
620
+ constructor(r, t) {
621
+ this.id = r, this.entries$ = new ht([]), t.addEventListener("user-submit", (n) => {
622
+ if (!this.provider) {
623
+ console.warn(
624
+ "No provider activated, unable to print message to conversation."
625
+ );
626
+ return;
627
+ }
628
+ this.provider.onUserSubmit(n.detail);
629
+ });
630
+ }
631
+ write(r) {
632
+ this.entries$.pipe(dt(1)).subscribe((t) => {
633
+ this.entries$.next([...t, r]);
634
+ });
635
+ }
636
+ entries() {
637
+ return this.entries$.asObservable();
638
+ }
639
+ setProvider(r) {
640
+ this.provider = r, this.provider.actions().subscribe((t) => {
641
+ this.write(t);
642
+ });
643
+ }
644
+ }
645
+ class bt {
646
+ constructor() {
647
+ this.sessions = /* @__PURE__ */ new Map(), this.registeredProviders = /* @__PURE__ */ new Map(), this.activeSessionId = null;
648
+ }
649
+ registerProvider(r, t) {
650
+ this.registeredProviders.set(r, t);
651
+ }
652
+ createSession(r) {
653
+ const t = new vt(W(), r), n = this.getProviderByConfiguration(r);
654
+ if (n) {
655
+ const i = n();
656
+ t.setProvider(i);
657
+ }
658
+ return this.sessions.set(t.id, t), this.activeSessionId = t.id, t;
659
+ }
660
+ getProviderByConfiguration(r) {
661
+ const [t] = r.properties.providers || [];
662
+ if (!t) {
663
+ console.warn(
664
+ "No providers registered. You most likely forgot to add a provider to the conversation component properties."
665
+ );
666
+ return;
667
+ }
668
+ return this.registeredProviders.get(t);
669
+ }
670
+ }
671
+ const yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
672
+ __proto__: null,
673
+ ConversationPlatform: bt
674
+ }, Symbol.toStringTag, { value: "Module" }));
675
+ var P = /* @__PURE__ */ ((e) => (e.User = "user", e.Agent = "agent", e.System = "system", e))(P || {});
676
+ class D {
677
+ constructor(r, t, n) {
678
+ this.type = r, this.sender = t, this.messages = n, this.didUpdate = new v(), this.timestamp = Date.now();
679
+ }
680
+ update(r) {
681
+ this.messages = [
682
+ {
683
+ items: r
684
+ }
685
+ ], this.didUpdate.next(this);
686
+ }
687
+ }
688
+ class mt {
689
+ constructor(r) {
690
+ this.name = r, this.print$ = new v();
691
+ }
692
+ print(r) {
693
+ const t = new D(
694
+ P.Agent,
695
+ { name: this.name },
696
+ [
697
+ {
698
+ items: [["html", { content: r }]]
699
+ }
700
+ ]
701
+ );
702
+ return this.print$.next(t), t;
703
+ }
704
+ subscribe() {
705
+ return this.print$.asObservable();
706
+ }
707
+ }
708
+ class St {
709
+ constructor(r) {
710
+ this.name = r, this.print$ = new v();
711
+ }
712
+ print(r) {
713
+ const t = new D(
714
+ P.User,
715
+ { name: this.name },
716
+ [
717
+ {
718
+ items: [["html", { content: r }]]
719
+ }
720
+ ]
721
+ );
722
+ return this.print$.next(t), t;
723
+ }
724
+ subscribe() {
725
+ return this.print$.asObservable();
726
+ }
727
+ }
728
+ class wt {
729
+ constructor(r) {
730
+ this.name = r, this.print$ = new v();
731
+ }
732
+ onUserSubmit(r) {
733
+ this.print(P.User, r.text);
734
+ }
735
+ print(r, t) {
736
+ const n = new D(
737
+ r,
738
+ {
739
+ name: "Botsson"
740
+ // TODO:
741
+ },
742
+ [
743
+ {
744
+ items: [["html", { content: t }]]
745
+ }
746
+ ]
747
+ );
748
+ return this.printEntry(n);
749
+ }
750
+ printEntry(r) {
751
+ return this.print$.next(r), r;
752
+ }
753
+ createAgent(r) {
754
+ const t = new mt(r);
755
+ return t.subscribe().subscribe((n) => {
756
+ this.printEntry(n);
757
+ }), t;
758
+ }
759
+ createUser(r) {
760
+ const t = new St(r);
761
+ return t.subscribe().subscribe((n) => {
762
+ this.printEntry(n);
763
+ }), t;
764
+ }
765
+ actions() {
766
+ return this.print$.asObservable();
767
+ }
768
+ }
769
+ export {
770
+ mt as A,
771
+ P as C,
772
+ St as U,
773
+ gt as a,
774
+ bt as b,
775
+ wt as c,
776
+ D as d
777
+ };