@telia-ace/widget-conversation 1.0.37-next.2 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
var
|
|
1
|
+
var F = Object.defineProperty, G = Object.defineProperties;
|
|
2
2
|
var J = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var x = Object.getOwnPropertySymbols;
|
|
4
4
|
var $ = Object.prototype.hasOwnProperty, _ = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var T = (
|
|
5
|
+
var T = (i, e, t) => e in i ? F(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, m = (i, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
$.call(e, t) && T(
|
|
7
|
+
$.call(e, t) && T(i, t, e[t]);
|
|
8
8
|
if (x)
|
|
9
9
|
for (var t of x(e))
|
|
10
|
-
_.call(e, t) && T(
|
|
11
|
-
return
|
|
12
|
-
}, b = (
|
|
13
|
-
var B = (
|
|
10
|
+
_.call(e, t) && T(i, t, e[t]);
|
|
11
|
+
return i;
|
|
12
|
+
}, b = (i, e) => G(i, J(e));
|
|
13
|
+
var B = (i, e) => {
|
|
14
14
|
var t = {};
|
|
15
|
-
for (var s in
|
|
16
|
-
$.call(
|
|
17
|
-
if (
|
|
18
|
-
for (var s of x(
|
|
19
|
-
e.indexOf(s) < 0 && _.call(
|
|
15
|
+
for (var s in i)
|
|
16
|
+
$.call(i, s) && e.indexOf(s) < 0 && (t[s] = i[s]);
|
|
17
|
+
if (i != null && x)
|
|
18
|
+
for (var s of x(i))
|
|
19
|
+
e.indexOf(s) < 0 && _.call(i, s) && (t[s] = i[s]);
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
|
-
var d = (
|
|
23
|
-
var v = (
|
|
22
|
+
var d = (i, e, t) => (T(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
23
|
+
var v = (i, e, t) => new Promise((s, r) => {
|
|
24
24
|
var n = (c) => {
|
|
25
25
|
try {
|
|
26
26
|
o(t.next(c));
|
|
27
27
|
} catch (h) {
|
|
28
|
-
|
|
28
|
+
r(h);
|
|
29
29
|
}
|
|
30
30
|
}, a = (c) => {
|
|
31
31
|
try {
|
|
32
32
|
o(t.throw(c));
|
|
33
33
|
} catch (h) {
|
|
34
|
-
|
|
34
|
+
r(h);
|
|
35
35
|
}
|
|
36
36
|
}, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(n, a);
|
|
37
|
-
o((t = t.apply(
|
|
37
|
+
o((t = t.apply(i, e)).next());
|
|
38
38
|
});
|
|
39
|
-
import { ComponentPlatform as
|
|
39
|
+
import { ComponentPlatform as Q } from "@telia-ace/widget-core";
|
|
40
40
|
import { createStorageWriter as D, StorageCategory as N, readStorage as w, StorageMedium as A, StorageScope as V } from "@telia-ace/widget-services";
|
|
41
41
|
import { uuid as U, lock as Y } from "@telia-ace/widget-utilities";
|
|
42
42
|
import { FormBuilder as X } from "@telia-ace/widget-forms";
|
|
@@ -48,18 +48,18 @@ class ee {
|
|
|
48
48
|
d(this, "cache", /* @__PURE__ */ new Map());
|
|
49
49
|
d(this, "subscriptions", []);
|
|
50
50
|
this.controller = e;
|
|
51
|
-
const { events: t } = e.container.get("$widget"), s = t.subscribe("data-client:fetched", (
|
|
51
|
+
const { events: t } = e.container.get("$widget"), s = t.subscribe("data-client:fetched", (r, n) => {
|
|
52
52
|
n.type === "contact-method" && this.cache.set(n.response.id, n.response);
|
|
53
53
|
});
|
|
54
54
|
this.subscriptions.push(s);
|
|
55
55
|
}
|
|
56
56
|
getConversationLogs() {
|
|
57
57
|
return this.controller.messages.reduce((t, s) => {
|
|
58
|
-
const
|
|
58
|
+
const r = I(s), { key: n, content: a, type: o, sender: c, timestamp: h } = r.content, u = this.parseEntry(a, o, c, h);
|
|
59
59
|
return u && t.push(u), t;
|
|
60
60
|
}, []);
|
|
61
61
|
}
|
|
62
|
-
parseEntry(e, t, s,
|
|
62
|
+
parseEntry(e, t, s, r) {
|
|
63
63
|
const n = (h) => {
|
|
64
64
|
let u = [], l = [], f;
|
|
65
65
|
if (Array.isArray(h)) {
|
|
@@ -89,7 +89,7 @@ class ee {
|
|
|
89
89
|
`) : void 0,
|
|
90
90
|
source: this.createMessageSource(t),
|
|
91
91
|
alias: this.createAlias(t, s),
|
|
92
|
-
timestamp:
|
|
92
|
+
timestamp: r
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
createMessageSource(e) {
|
|
@@ -108,21 +108,24 @@ class ee {
|
|
|
108
108
|
getDetails(e, t = !0) {
|
|
109
109
|
if (!e)
|
|
110
110
|
return "";
|
|
111
|
-
const { header: s, title:
|
|
111
|
+
const { header: s, title: r, label: n, description: a, text: o, html: c, body: h, contactMethodId: u } = e;
|
|
112
112
|
let l = "";
|
|
113
113
|
if (u) {
|
|
114
114
|
const f = this.handleContactMethod(u.toString());
|
|
115
115
|
f && (l = this.appendText(l, f, t));
|
|
116
116
|
}
|
|
117
|
-
return s && (l = this.appendText(l, s, t)),
|
|
117
|
+
return s && (l = this.appendText(l, s, t)), r && (l = this.appendText(l, r, t)), a && (l = this.appendText(l, a, t)), o && (l = this.appendText(l, o, t)), n && (l = this.appendText(l, n, t)), c && (l = this.appendText(l, c, t)), h && typeof h == "string" && (l = this.appendText(l, h, t)), l;
|
|
118
118
|
}
|
|
119
119
|
createMessageContent(e) {
|
|
120
120
|
let t = "";
|
|
121
121
|
return t = this.getDetails(e), t;
|
|
122
122
|
}
|
|
123
123
|
createMessageOptions(e) {
|
|
124
|
-
let t = [];
|
|
125
|
-
return e
|
|
124
|
+
let t = [], s = [];
|
|
125
|
+
return Array.isArray(e == null ? void 0 : e.actions) ? s = e.actions : typeof (e == null ? void 0 : e.actions) == "object" && (s = Object.entries(e.actions).map(([r, n]) => ({
|
|
126
|
+
actionKey: r,
|
|
127
|
+
label: n
|
|
128
|
+
}))), s.length && (t = s.map((r) => this.getDetails(r, !1))), t;
|
|
126
129
|
}
|
|
127
130
|
appendText(e, t, s = !0) {
|
|
128
131
|
return s && e.length ? `${e}
|
|
@@ -144,27 +147,27 @@ class M {
|
|
|
144
147
|
name: this.name,
|
|
145
148
|
avatar: this.avatar,
|
|
146
149
|
id: this.id
|
|
147
|
-
},
|
|
150
|
+
}, r = I(e, t);
|
|
148
151
|
return this.provider.createEntry(
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
r.key,
|
|
153
|
+
r.content,
|
|
151
154
|
S.Agent,
|
|
152
155
|
s,
|
|
153
|
-
|
|
156
|
+
r.timestamp
|
|
154
157
|
);
|
|
155
158
|
});
|
|
156
159
|
d(this, "typing", () => this.provider.setTypingState({ name: this.name, avatar: this.avatar }));
|
|
157
160
|
this.provider = e, this.id = t.id || U(), this.name = t.name, this.avatar = t.avatar;
|
|
158
161
|
}
|
|
159
162
|
update(e) {
|
|
160
|
-
var
|
|
163
|
+
var r;
|
|
161
164
|
const { name: t, avatar: s } = e;
|
|
162
|
-
s === null ? this.avatar = void 0 : s && (this.avatar = s), t === null ? this.name = void 0 : t && (this.name = t), (
|
|
165
|
+
s === null ? this.avatar = void 0 : s && (this.avatar = s), t === null ? this.name = void 0 : t && (this.name = t), (r = this.provider.controller) == null || r.events.dispatch("conversation:agent-updated", {
|
|
163
166
|
agent: this
|
|
164
167
|
});
|
|
165
168
|
}
|
|
166
169
|
}
|
|
167
|
-
class
|
|
170
|
+
class O {
|
|
168
171
|
constructor(e, t, s) {
|
|
169
172
|
d(this, "subscriptions", []);
|
|
170
173
|
d(this, "options");
|
|
@@ -174,15 +177,15 @@ class R {
|
|
|
174
177
|
};
|
|
175
178
|
}
|
|
176
179
|
static create(e, t, s) {
|
|
177
|
-
return new
|
|
180
|
+
return new O(e, t, s);
|
|
178
181
|
}
|
|
179
182
|
createAgent(e = {}) {
|
|
180
183
|
var t;
|
|
181
184
|
if (this.controller) {
|
|
182
|
-
const s = this.controller.getAgentById(e.id),
|
|
185
|
+
const s = this.controller.getAgentById(e.id), r = s ? new M(this, m(m({}, s), e)) : new M(this, e);
|
|
183
186
|
return s || (t = this.controller) == null || t.events.dispatch("conversation:agent-created", {
|
|
184
|
-
agent:
|
|
185
|
-
}),
|
|
187
|
+
agent: r
|
|
188
|
+
}), r;
|
|
186
189
|
}
|
|
187
190
|
}
|
|
188
191
|
print(e) {
|
|
@@ -197,9 +200,9 @@ class R {
|
|
|
197
200
|
return this.controller ? this.controller.loader() : () => () => {
|
|
198
201
|
};
|
|
199
202
|
}
|
|
200
|
-
createEntry(e, t, s,
|
|
203
|
+
createEntry(e, t, s, r, n) {
|
|
201
204
|
var a;
|
|
202
|
-
return (a = this.controller) == null ? void 0 : a.createEntry(e, t, s,
|
|
205
|
+
return (a = this.controller) == null ? void 0 : a.createEntry(e, t, s, r, n);
|
|
203
206
|
}
|
|
204
207
|
dispose() {
|
|
205
208
|
var e;
|
|
@@ -242,7 +245,7 @@ class R {
|
|
|
242
245
|
}
|
|
243
246
|
}
|
|
244
247
|
}
|
|
245
|
-
const
|
|
248
|
+
const j = (i) => `conversation-${i}`;
|
|
246
249
|
class te {
|
|
247
250
|
constructor() {
|
|
248
251
|
d(this, "_locking", Promise.resolve());
|
|
@@ -254,8 +257,8 @@ class te {
|
|
|
254
257
|
lock() {
|
|
255
258
|
this._locks += 1;
|
|
256
259
|
let e, t = new Promise(
|
|
257
|
-
(
|
|
258
|
-
this._locks -= 1,
|
|
260
|
+
(r) => e = () => {
|
|
261
|
+
this._locks -= 1, r();
|
|
259
262
|
}
|
|
260
263
|
), s = this._locking.then(() => e);
|
|
261
264
|
return this._locking = this._locking.then(() => t), s;
|
|
@@ -266,11 +269,11 @@ class se {
|
|
|
266
269
|
d(this, "sessionStorageKey");
|
|
267
270
|
d(this, "locker", new te());
|
|
268
271
|
d(this, "initialStoredAgents", []);
|
|
269
|
-
this.container = e, this.conversation = t, this.enabled = s, this.sessionStorageKey =
|
|
272
|
+
this.container = e, this.conversation = t, this.enabled = s, this.sessionStorageKey = j(t.id), t.onStarted(() => v(this, null, function* () {
|
|
270
273
|
if (t.messages.length > 0)
|
|
271
274
|
return;
|
|
272
|
-
const { agents:
|
|
273
|
-
|
|
275
|
+
const { agents: r } = yield this.read(), n = [];
|
|
276
|
+
r && r.forEach((o) => {
|
|
274
277
|
const c = t.providerIndex(o.providerName), h = c > -1 ? t.registeredProviders[c] : t.createProvider(o.providerName), u = new M(h, { name: o.name, avatar: o.avatar, id: o.id });
|
|
275
278
|
n.push(u);
|
|
276
279
|
});
|
|
@@ -298,9 +301,9 @@ class se {
|
|
|
298
301
|
t.print(o.content.items || o.content);
|
|
299
302
|
}
|
|
300
303
|
});
|
|
301
|
-
})), t.onMessageCreated((
|
|
304
|
+
})), t.onMessageCreated((r, n) => v(this, null, function* () {
|
|
302
305
|
this.write(n.message, "messages");
|
|
303
|
-
})), t.events.subscribe("conversation:agent-created", (
|
|
306
|
+
})), t.events.subscribe("conversation:agent-created", (r, n) => v(this, null, function* () {
|
|
304
307
|
const a = {
|
|
305
308
|
id: n.agent.id,
|
|
306
309
|
name: n.agent.name,
|
|
@@ -308,7 +311,7 @@ class se {
|
|
|
308
311
|
providerName: n.agent.provider.name
|
|
309
312
|
};
|
|
310
313
|
yield this.write(a, "agents");
|
|
311
|
-
})), t.events.subscribe("conversation:agent-updated", (
|
|
314
|
+
})), t.events.subscribe("conversation:agent-updated", (r, n) => v(this, null, function* () {
|
|
312
315
|
const { agents: a } = yield this.read();
|
|
313
316
|
yield this.write(
|
|
314
317
|
[
|
|
@@ -339,7 +342,7 @@ class se {
|
|
|
339
342
|
return v(this, null, function* () {
|
|
340
343
|
if (!this.enabled)
|
|
341
344
|
return;
|
|
342
|
-
const
|
|
345
|
+
const r = yield this.locker.lock();
|
|
343
346
|
return D(
|
|
344
347
|
this.container,
|
|
345
348
|
this.sessionStorageKey,
|
|
@@ -348,12 +351,12 @@ class se {
|
|
|
348
351
|
if (s === "add") {
|
|
349
352
|
const a = yield this.read();
|
|
350
353
|
if (t === "messages" && a.messages.findIndex((c) => c.key === e.key) > -1) {
|
|
351
|
-
|
|
354
|
+
r();
|
|
352
355
|
return;
|
|
353
356
|
}
|
|
354
357
|
let o = m({}, a);
|
|
355
358
|
return t === "messages" ? o.messages = [...o.messages, e] : t === "agents" && (o.agents = [...o.agents, e]), n(m(m({}, a), o)).then(() => {
|
|
356
|
-
|
|
359
|
+
r();
|
|
357
360
|
});
|
|
358
361
|
}
|
|
359
362
|
if (s === "update" && t === "agents") {
|
|
@@ -361,11 +364,11 @@ class se {
|
|
|
361
364
|
return n(b(m({}, a), {
|
|
362
365
|
agents: e
|
|
363
366
|
})).then(() => {
|
|
364
|
-
|
|
367
|
+
r();
|
|
365
368
|
});
|
|
366
369
|
}
|
|
367
370
|
return n(e).then(() => {
|
|
368
|
-
|
|
371
|
+
r();
|
|
369
372
|
});
|
|
370
373
|
}));
|
|
371
374
|
});
|
|
@@ -395,15 +398,15 @@ class ie {
|
|
|
395
398
|
this.controller = e;
|
|
396
399
|
}
|
|
397
400
|
}
|
|
398
|
-
const W = (
|
|
399
|
-
const s = yield
|
|
401
|
+
const W = (i, e, t) => v(void 0, null, function* () {
|
|
402
|
+
const s = yield i.getAsync("conversation"), r = yield i.getAsync("components"), n = s.controllers.find((a) => a.conversation.id === e);
|
|
400
403
|
if (n) {
|
|
401
404
|
const a = [...n.conversation.providers];
|
|
402
405
|
a.forEach((c) => {
|
|
403
406
|
n.conversation.setProviderOptions(c, { silent: !0 });
|
|
404
407
|
}), n.conversation.queueProviders(a), n.conversation.setProviders([t]);
|
|
405
|
-
const o =
|
|
406
|
-
|
|
408
|
+
const o = r.components().ofType("conversation");
|
|
409
|
+
r.write({
|
|
407
410
|
key: "setConversationProvider",
|
|
408
411
|
attributes: {
|
|
409
412
|
properties: { providers: [t] }
|
|
@@ -428,35 +431,35 @@ class ne {
|
|
|
428
431
|
return typeof e == "string" ? { body: e } : e.length > -1 && typeof e == "object" ? { items: e } : e;
|
|
429
432
|
}
|
|
430
433
|
}
|
|
431
|
-
var S = /* @__PURE__ */ ((
|
|
432
|
-
const I = (
|
|
433
|
-
let t, s = (e == null ? void 0 : e.key) || U(),
|
|
434
|
-
if (Array.isArray(
|
|
435
|
-
typeof
|
|
436
|
-
else if (typeof
|
|
437
|
-
t = { body:
|
|
438
|
-
else if (
|
|
439
|
-
t = m({},
|
|
434
|
+
var S = /* @__PURE__ */ ((i) => (i.User = "user", i.Agent = "agent", i.System = "system", i))(S || {});
|
|
435
|
+
const I = (i, e) => {
|
|
436
|
+
let t, s = (e == null ? void 0 : e.key) || U(), r = Date.now();
|
|
437
|
+
if (Array.isArray(i) && i.length > -1)
|
|
438
|
+
typeof i[0] == "string" ? t = { items: [i] } : t = { items: i };
|
|
439
|
+
else if (typeof i == "string")
|
|
440
|
+
t = { body: i };
|
|
441
|
+
else if (i = i || {}, i.type)
|
|
442
|
+
t = m({}, i);
|
|
440
443
|
else {
|
|
441
444
|
if (t = {
|
|
442
|
-
body:
|
|
443
|
-
actions:
|
|
444
|
-
title:
|
|
445
|
-
},
|
|
445
|
+
body: i.body,
|
|
446
|
+
actions: i.actions,
|
|
447
|
+
title: i.title
|
|
448
|
+
}, i.key && (s = i.key), i.timestamp && (r = i.timestamp), typeof i.form == "function") {
|
|
446
449
|
const n = X.create(s);
|
|
447
|
-
|
|
450
|
+
i.form(n);
|
|
448
451
|
const a = n.get();
|
|
449
452
|
t.form = a;
|
|
450
453
|
}
|
|
451
|
-
|
|
454
|
+
i.timestamp === null && (r = null);
|
|
452
455
|
}
|
|
453
|
-
return { content: t, key: s, timestamp:
|
|
454
|
-
}, z = (
|
|
456
|
+
return { content: t, key: s, timestamp: r };
|
|
457
|
+
}, z = (i, e) => {
|
|
455
458
|
if (!e)
|
|
456
459
|
return;
|
|
457
|
-
const t = JSON.stringify(e), s =
|
|
460
|
+
const t = JSON.stringify(e), s = i.findIndex((r) => t === JSON.stringify(r));
|
|
458
461
|
if (s > -1)
|
|
459
|
-
return
|
|
462
|
+
return i.splice(s, 1);
|
|
460
463
|
};
|
|
461
464
|
class oe {
|
|
462
465
|
constructor(e, t, s) {
|
|
@@ -484,26 +487,26 @@ class oe {
|
|
|
484
487
|
);
|
|
485
488
|
});
|
|
486
489
|
this.container = e, this.id = t;
|
|
487
|
-
const
|
|
488
|
-
this.events =
|
|
490
|
+
const r = e.get("$widget");
|
|
491
|
+
this.events = r.events.createChild(this), this.store = new re(e, this, s.rehydrate), this.conversationHistory = new ee(this);
|
|
489
492
|
}
|
|
490
493
|
setInitialStorage(e) {
|
|
491
494
|
this.store.setInitialData(e);
|
|
492
495
|
}
|
|
493
496
|
setProviders(e) {
|
|
494
497
|
const t = [], s = [];
|
|
495
|
-
this.providers.reduce((
|
|
496
|
-
const n = this.providers.indexOf(
|
|
497
|
-
n > -1 && (t.push(
|
|
498
|
-
}), e.forEach((
|
|
499
|
-
this.providers.indexOf(
|
|
498
|
+
this.providers.reduce((r, n) => (e.indexOf(n) === -1 && r.push(n), r), []).forEach((r) => {
|
|
499
|
+
const n = this.providers.indexOf(r);
|
|
500
|
+
n > -1 && (t.push(r), this.providers.splice(n, 1));
|
|
501
|
+
}), e.forEach((r) => {
|
|
502
|
+
this.providers.indexOf(r) === -1 && (s.push(r), this.providers.push(r));
|
|
500
503
|
}), (s.length || t.length) && this.events.dispatch("conversation:providers-changed", { added: s, removed: t });
|
|
501
504
|
}
|
|
502
505
|
createProvider(e) {
|
|
503
506
|
const t = this.providerIndex(e);
|
|
504
507
|
if (t > -1)
|
|
505
508
|
return this.registeredProviders[t];
|
|
506
|
-
const s =
|
|
509
|
+
const s = O.create(e, this.container, this);
|
|
507
510
|
return this.registeredProviders.push(s), s;
|
|
508
511
|
}
|
|
509
512
|
providerIndex(e) {
|
|
@@ -558,15 +561,15 @@ class oe {
|
|
|
558
561
|
onUnreadMessage(e) {
|
|
559
562
|
return this.events.subscribe("conversation:unread-message", e);
|
|
560
563
|
}
|
|
561
|
-
createEntry(e, t, s,
|
|
564
|
+
createEntry(e, t, s, r, n) {
|
|
562
565
|
const a = {
|
|
563
566
|
key: e,
|
|
564
567
|
content: t,
|
|
565
568
|
type: s,
|
|
566
|
-
sender:
|
|
569
|
+
sender: r || null,
|
|
567
570
|
timestamp: n || n === null ? n : Date.now()
|
|
568
571
|
};
|
|
569
|
-
this.messages.push(a), a.type === "agent" && z(this.typingActors,
|
|
572
|
+
this.messages.push(a), a.type === "agent" && z(this.typingActors, r);
|
|
570
573
|
const o = new ne((c) => {
|
|
571
574
|
if (c !== null) {
|
|
572
575
|
const h = c, { timestamp: u = void 0 } = h, l = B(h, ["timestamp"]);
|
|
@@ -615,25 +618,25 @@ class oe {
|
|
|
615
618
|
return this.conversationHistory.getConversationLogs();
|
|
616
619
|
}
|
|
617
620
|
}
|
|
618
|
-
const ae = (
|
|
619
|
-
const t =
|
|
621
|
+
const ae = (i, e) => {
|
|
622
|
+
const t = i.split("_contact");
|
|
620
623
|
return e.widgets.get(t[0]);
|
|
621
|
-
},
|
|
622
|
-
const e =
|
|
623
|
-
return c && !a ? { chatWidget: c, mainWidget:
|
|
624
|
-
}, ce = (
|
|
625
|
-
const { chatWidget: e } =
|
|
624
|
+
}, R = (i) => {
|
|
625
|
+
const e = i.get("$widget"), { name: t, implementation: s } = i.get("$widget"), r = t.indexOf("_contact") > -1 ? ae(t, s) : e, { data: n } = i.get("$settings"), { trigger: a } = r.container.get("$settings"), o = `${t.replace("_contact-method", "").replace("_contact", "")}_contact-method`, c = s.widgets.get(o);
|
|
626
|
+
return c && !a ? { chatWidget: c, mainWidget: r, data: n } : { mainWidget: r, data: n };
|
|
627
|
+
}, ce = (i) => {
|
|
628
|
+
const { chatWidget: e } = R(i);
|
|
626
629
|
return !!e;
|
|
627
|
-
},
|
|
628
|
-
const { mainWidget: s, data:
|
|
630
|
+
}, K = (i, e, t) => {
|
|
631
|
+
const { mainWidget: s, data: r, chatWidget: n } = R(i);
|
|
629
632
|
return n ? n.state === "activated" ? n.invoke("open").then(() => {
|
|
630
633
|
n.container.getAsync("conversation").then((a) => {
|
|
631
|
-
a.navigateToConversationIfActive(e.id).then(() => L(
|
|
634
|
+
a.navigateToConversationIfActive(e.id).then(() => L(i));
|
|
632
635
|
});
|
|
633
636
|
}) : n.activate().then(() => {
|
|
634
637
|
const { trigger: a } = n.container.get("$settings");
|
|
635
638
|
return a.action = "hide", n.invoke("setSettings", () => ({
|
|
636
|
-
data:
|
|
639
|
+
data: r,
|
|
637
640
|
trigger: a,
|
|
638
641
|
activate: !0
|
|
639
642
|
})).then(() => n.container.getAsync("components").then((o) => {
|
|
@@ -673,10 +676,10 @@ const ae = (r, e) => {
|
|
|
673
676
|
}
|
|
674
677
|
).then((a) => a(n.name)), n.container.getAsync("conversation").then((a) => {
|
|
675
678
|
a.setConversationEndedBehavior(E.Deactivate);
|
|
676
|
-
}).then(() => L(
|
|
677
|
-
}, de = (
|
|
678
|
-
const { mainWidget: s, chatWidget:
|
|
679
|
-
return
|
|
679
|
+
}).then(() => L(i)).then(() => !1))) : (s.container.getAsync("conversation").then((a) => a.navigateToConversationIfActive(e.id).then(() => a.setConversationEndedBehavior(E.Navigate))), !n);
|
|
680
|
+
}, de = (i, e, t = "conversation") => {
|
|
681
|
+
const { mainWidget: s, chatWidget: r } = R(i);
|
|
682
|
+
return r ? r.container.getAsync("router").then((n) => {
|
|
680
683
|
n.navigate(t, { id: e.id });
|
|
681
684
|
}) : s.container.getAsync("conversation").then((n) => {
|
|
682
685
|
var a;
|
|
@@ -697,7 +700,7 @@ const ae = (r, e) => {
|
|
|
697
700
|
});
|
|
698
701
|
});
|
|
699
702
|
}, P = "conversations";
|
|
700
|
-
var E = /* @__PURE__ */ ((
|
|
703
|
+
var E = /* @__PURE__ */ ((i) => (i.Deactivate = "deactivate", i.Navigate = "navigate", i.None = "none", i))(E || {});
|
|
701
704
|
class C {
|
|
702
705
|
constructor(e, t) {
|
|
703
706
|
d(this, "events");
|
|
@@ -721,13 +724,13 @@ class C {
|
|
|
721
724
|
this.buttonQuery = this.components.components().ofType("conversation-return-button"), e && (this.sessionInfo = e, e.id && e.route && this.writeToComponents({ active: !0, alert: { show: !1 } }));
|
|
722
725
|
}
|
|
723
726
|
), this.container.getAsync("router").then((e) => this.router = e), this.events.subscribe("conversation:ended", (e, t) => {
|
|
724
|
-
var s,
|
|
727
|
+
var s, r, n;
|
|
725
728
|
switch ((s = this.sessionInfo) == null ? void 0 : s.conversationEndedBehavior) {
|
|
726
729
|
case "deactivate":
|
|
727
730
|
this.container.get("$widget").deactivate();
|
|
728
731
|
break;
|
|
729
732
|
case "navigate":
|
|
730
|
-
const o = (
|
|
733
|
+
const o = (r = this.router) == null ? void 0 : r.getInitialRoute();
|
|
731
734
|
o && ((n = this.router) == null || n.navigate(o.name));
|
|
732
735
|
break;
|
|
733
736
|
}
|
|
@@ -739,8 +742,8 @@ class C {
|
|
|
739
742
|
}
|
|
740
743
|
static getInstance(e, t = "conversation") {
|
|
741
744
|
return Y(e)(() => e.getAsync(t).then((s) => {
|
|
742
|
-
let
|
|
743
|
-
return
|
|
745
|
+
let r = s;
|
|
746
|
+
return r || Q.getInstance(e).then((n) => (r = new C(e, n), r.initialize(), e.registerAsync(t, () => r), r));
|
|
744
747
|
}));
|
|
745
748
|
}
|
|
746
749
|
navigateToConversationIfActive(e) {
|
|
@@ -748,8 +751,8 @@ class C {
|
|
|
748
751
|
(t) => {
|
|
749
752
|
var s;
|
|
750
753
|
if (t && t.id === e && t.route) {
|
|
751
|
-
const { name:
|
|
752
|
-
(s = this.router) == null || s.navigate(
|
|
754
|
+
const { name: r, params: n } = t.route;
|
|
755
|
+
(s = this.router) == null || s.navigate(r, n);
|
|
753
756
|
}
|
|
754
757
|
}
|
|
755
758
|
);
|
|
@@ -764,12 +767,12 @@ class C {
|
|
|
764
767
|
}
|
|
765
768
|
createController(e, t) {
|
|
766
769
|
return v(this, null, function* () {
|
|
767
|
-
const s =
|
|
770
|
+
const s = j(e), { agents: r } = (yield w(
|
|
768
771
|
this.container,
|
|
769
772
|
s
|
|
770
773
|
)) || { agents: [] }, n = this.controllers.findIndex((o) => o.conversation.id === e);
|
|
771
774
|
let a;
|
|
772
|
-
return n > -1 ? a = this.controllers[n].conversation : a = new oe(this.container, e, t), a.setInitialStorage({ agents:
|
|
775
|
+
return n > -1 ? a = this.controllers[n].conversation : a = new oe(this.container, e, t), a.setInitialStorage({ agents: r || [] }), a;
|
|
773
776
|
});
|
|
774
777
|
}
|
|
775
778
|
registerProvider(e, t) {
|
|
@@ -777,18 +780,18 @@ class C {
|
|
|
777
780
|
name: e,
|
|
778
781
|
handler: t
|
|
779
782
|
};
|
|
780
|
-
this.providers.push(s), this.controllers.filter((
|
|
781
|
-
this.invokeHandler(s,
|
|
783
|
+
this.providers.push(s), this.controllers.filter((r) => r.conversation.providers.indexOf(e) > -1).forEach((r) => {
|
|
784
|
+
this.invokeHandler(s, r);
|
|
782
785
|
});
|
|
783
786
|
}
|
|
784
787
|
registerController(e, t) {
|
|
785
788
|
const s = this.controllers.findIndex((n) => n.conversation.id === e.id);
|
|
786
|
-
let
|
|
789
|
+
let r;
|
|
787
790
|
if (s < 0) {
|
|
788
|
-
|
|
791
|
+
r = { conversation: e, component: t }, this.controllers.push(r);
|
|
789
792
|
const n = (a) => {
|
|
790
793
|
a && this.providers.filter((o) => a.indexOf(o.name) > -1).forEach((o) => {
|
|
791
|
-
this.invokeHandler(o,
|
|
794
|
+
this.invokeHandler(o, r);
|
|
792
795
|
});
|
|
793
796
|
};
|
|
794
797
|
return this.subscriptions.push(
|
|
@@ -821,7 +824,7 @@ class C {
|
|
|
821
824
|
})
|
|
822
825
|
), n(e.providers), !0;
|
|
823
826
|
}
|
|
824
|
-
return
|
|
827
|
+
return r = this.controllers[s], !1;
|
|
825
828
|
}
|
|
826
829
|
writeToComponents(e, t = "conversationReturnButtonState") {
|
|
827
830
|
this.buttonQuery && this.components.write({
|
|
@@ -852,20 +855,20 @@ class C {
|
|
|
852
855
|
e();
|
|
853
856
|
}), this.controllers = [], this.providers = [];
|
|
854
857
|
}
|
|
855
|
-
static handleContactMethodClick(e, t, s,
|
|
858
|
+
static handleContactMethodClick(e, t, s, r) {
|
|
856
859
|
return v(this, null, function* () {
|
|
857
860
|
if (ce(t)) {
|
|
858
861
|
e.preventDefault();
|
|
859
862
|
let n = document.getElementById("humany-dynamic-anchor");
|
|
860
|
-
n || (n = document.createElement("a"), n.setAttribute("href", "#"), n.id = "humany-dynamic-anchor", document.body.appendChild(n)),
|
|
863
|
+
n || (n = document.createElement("a"), n.setAttribute("href", "#"), n.id = "humany-dynamic-anchor", document.body.appendChild(n)), K(t, s, n);
|
|
861
864
|
}
|
|
862
|
-
|
|
865
|
+
K(t, s);
|
|
863
866
|
});
|
|
864
867
|
}
|
|
865
868
|
static handleContactMethodSubmit(e, t) {
|
|
866
869
|
return v(this, null, function* () {
|
|
867
|
-
var s,
|
|
868
|
-
return (
|
|
870
|
+
var s, r;
|
|
871
|
+
return (r = (s = t == null ? void 0 : t.body.form.meta) == null ? void 0 : s.conversation) != null && r.id ? W(
|
|
869
872
|
e,
|
|
870
873
|
t.body.form.meta.conversation.id,
|
|
871
874
|
t.clientName
|
|
@@ -873,7 +876,7 @@ class C {
|
|
|
873
876
|
});
|
|
874
877
|
}
|
|
875
878
|
}
|
|
876
|
-
const he = (
|
|
879
|
+
const he = (i, e) => i.reduce((t, s, r) => {
|
|
877
880
|
var a, o;
|
|
878
881
|
const n = b(m({}, s), {
|
|
879
882
|
content: [b(m({}, s.content), { key: s.key })]
|
|
@@ -884,15 +887,15 @@ const he = (r, e) => r.reduce((t, s, i) => {
|
|
|
884
887
|
return c.timestamp = s.timestamp, c.content.push(b(m({}, s.content), { key: s.key })), t;
|
|
885
888
|
}
|
|
886
889
|
return t.push(n), t;
|
|
887
|
-
}, []), we = (
|
|
888
|
-
C.getInstance(
|
|
889
|
-
|
|
890
|
+
}, []), we = (i) => Promise.all([
|
|
891
|
+
C.getInstance(i),
|
|
892
|
+
i.getAsync("router")
|
|
890
893
|
]).then(([e, t]) => q(
|
|
891
|
-
|
|
894
|
+
i,
|
|
892
895
|
"conversation",
|
|
893
|
-
import("./conversation.
|
|
896
|
+
import("./conversation.f80bcb4a.js"),
|
|
894
897
|
(s) => v(void 0, null, function* () {
|
|
895
|
-
const { rehydrate:
|
|
898
|
+
const { rehydrate: r = !1 } = s.properties(), a = t.getRouteData().params.id || s.node.name || "component", o = yield e.createController(a, { rehydrate: r }), c = e.registerController(o, s), h = 3 * 60 * 1e3, u = (g) => {
|
|
896
899
|
const { providers: p = [] } = g;
|
|
897
900
|
if (p) {
|
|
898
901
|
const y = Array.isArray(p) ? p : [p];
|
|
@@ -951,17 +954,17 @@ const he = (r, e) => r.reduce((t, s, i) => {
|
|
|
951
954
|
};
|
|
952
955
|
}),
|
|
953
956
|
{ reuseController: !0 }
|
|
954
|
-
)), Ae = (
|
|
955
|
-
|
|
956
|
-
C.getInstance(
|
|
957
|
-
|
|
957
|
+
)), Ae = (i) => Promise.all([
|
|
958
|
+
Q.getInstance(i),
|
|
959
|
+
C.getInstance(i),
|
|
960
|
+
i.getAsync("router")
|
|
958
961
|
]).then(
|
|
959
962
|
([e, t, s]) => q(
|
|
960
|
-
|
|
963
|
+
i,
|
|
961
964
|
"conversation-return-button",
|
|
962
965
|
import("./return-button.fb63a16e.js"),
|
|
963
|
-
(
|
|
964
|
-
|
|
966
|
+
(r) => {
|
|
967
|
+
r.actions.create("toggle", (n = {}) => {
|
|
965
968
|
var a;
|
|
966
969
|
(a = t.getComponentRoute()) == null || a.then((o) => {
|
|
967
970
|
o && s.navigate(o.name, o.params);
|
|
@@ -970,9 +973,9 @@ const he = (r, e) => r.reduce((t, s, i) => {
|
|
|
970
973
|
}
|
|
971
974
|
)
|
|
972
975
|
);
|
|
973
|
-
var le = /* @__PURE__ */ ((
|
|
974
|
-
const Pe = (
|
|
975
|
-
(yield C.getInstance(
|
|
976
|
+
var le = /* @__PURE__ */ ((i) => (i.LinkList = "link-list", i.Separator = "separator", i.ButtonList = "button-list", i.Text = "text", i.HTML = "html", i.VideoRequest = "video-request", i))(le || {});
|
|
977
|
+
const Pe = (i, e, t) => i.getAsync("componentResolver").then((s) => v(void 0, null, function* () {
|
|
978
|
+
(yield C.getInstance(i)).addSubscription(
|
|
976
979
|
s.registerComponent(
|
|
977
980
|
e,
|
|
978
981
|
Z(() => t)
|