@telia-ace/widget-conversation 1.0.39-next.4 → 1.0.39-next.6

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,86 +1,83 @@
1
- var F = Object.defineProperty, G = Object.defineProperties;
2
- var J = Object.getOwnPropertyDescriptors;
3
- var x = Object.getOwnPropertySymbols;
4
- var $ = Object.prototype.hasOwnProperty, _ = Object.prototype.propertyIsEnumerable;
5
- var T = (r, e, t) => e in r ? F(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, m = (r, e) => {
1
+ var j = Object.defineProperty, F = Object.defineProperties;
2
+ var G = Object.getOwnPropertyDescriptors;
3
+ var k = Object.getOwnPropertySymbols;
4
+ var $ = Object.prototype.hasOwnProperty, H = Object.prototype.propertyIsEnumerable;
5
+ var R = (n, e, t) => e in n ? j(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, v = (n, e) => {
6
6
  for (var t in e || (e = {}))
7
- $.call(e, t) && T(r, t, e[t]);
8
- if (x)
9
- for (var t of x(e))
10
- _.call(e, t) && T(r, t, e[t]);
11
- return r;
12
- }, b = (r, e) => G(r, J(e));
13
- var B = (r, e) => {
7
+ $.call(e, t) && R(n, t, e[t]);
8
+ if (k)
9
+ for (var t of k(e))
10
+ H.call(e, t) && R(n, t, e[t]);
11
+ return n;
12
+ }, y = (n, e) => F(n, G(e));
13
+ var _ = (n, e) => {
14
14
  var t = {};
15
- for (var s in r)
16
- $.call(r, s) && e.indexOf(s) < 0 && (t[s] = r[s]);
17
- if (r != null && x)
18
- for (var s of x(r))
19
- e.indexOf(s) < 0 && _.call(r, s) && (t[s] = r[s]);
15
+ for (var s in n)
16
+ $.call(n, s) && e.indexOf(s) < 0 && (t[s] = n[s]);
17
+ if (n != null && k)
18
+ for (var s of k(n))
19
+ e.indexOf(s) < 0 && H.call(n, s) && (t[s] = n[s]);
20
20
  return t;
21
21
  };
22
- var d = (r, e, t) => (T(r, typeof e != "symbol" ? e + "" : e, t), t);
23
- var v = (r, e, t) => new Promise((s, i) => {
24
- var n = (c) => {
22
+ var g = (n, e, t) => new Promise((s, r) => {
23
+ var i = (c) => {
25
24
  try {
26
25
  o(t.next(c));
27
26
  } catch (h) {
28
- i(h);
27
+ r(h);
29
28
  }
30
29
  }, a = (c) => {
31
30
  try {
32
31
  o(t.throw(c));
33
32
  } catch (h) {
34
- i(h);
33
+ r(h);
35
34
  }
36
- }, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(n, a);
37
- o((t = t.apply(r, e)).next());
35
+ }, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(i, a);
36
+ o((t = t.apply(n, e)).next());
38
37
  });
39
38
  import { ComponentPlatform as Q } from "@telia-ace/widget-core";
40
- import { createStorageWriter as M, StorageCategory as N, readStorage as w, StorageMedium as A, StorageScope as V } from "@telia-ace/widget-services";
41
- import { uuid as U, lock as Y } from "@telia-ace/widget-utilities";
42
- import { FormBuilder as X } from "@telia-ace/widget-forms";
43
- import { closeAllModals as L } from "@telia-ace/widget-plugins";
44
- import { createReactComponent as q } from "@telia-ace/widget-ui";
45
- import { lazy as Z } from "react";
46
- class ee {
39
+ import { createStorageWriter as W, StorageCategory as D, readStorage as b, StorageMedium as w, StorageScope as J } from "@telia-ace/widget-services";
40
+ import { uuid as K, lock as V } from "@telia-ace/widget-utilities";
41
+ import { FormBuilder as Y } from "@telia-ace/widget-forms";
42
+ import { closeAllModals as B } from "@telia-ace/widget-plugins";
43
+ import { createReactComponent as U } from "@telia-ace/widget-ui";
44
+ import { lazy as X } from "react";
45
+ class Z {
47
46
  constructor(e) {
48
- d(this, "cache", /* @__PURE__ */ new Map());
49
- d(this, "subscriptions", []);
50
- this.controller = e;
51
- const { events: t } = e.container.get("$widget"), s = t.subscribe("data-client:fetched", (i, n) => {
52
- n.type === "contact-method" && this.cache.set(n.response.id, n.response);
47
+ this.controller = e, this.cache = /* @__PURE__ */ new Map(), this.subscriptions = [];
48
+ const { events: t } = e.container.get("$widget"), s = t.subscribe("data-client:fetched", (r, i) => {
49
+ i.type === "contact-method" && this.cache.set(i.response.id, i.response);
53
50
  });
54
51
  this.subscriptions.push(s);
55
52
  }
56
53
  getConversationLogs() {
57
54
  return this.controller.messages.reduce((t, s) => {
58
- const i = I(s), { key: n, content: a, type: o, sender: c, timestamp: h } = i.content, u = this.parseEntry(a, o, c, h);
59
- return u && t.push(u), t;
55
+ const r = E(s), { key: i, content: a, type: o, sender: c, timestamp: h } = r.content, l = this.parseEntry(a, o, c, h);
56
+ return l && t.push(l), t;
60
57
  }, []);
61
58
  }
62
- parseEntry(e, t, s, i) {
63
- const n = (h) => {
64
- let u = [], l = [], f;
59
+ parseEntry(e, t, s, r) {
60
+ const i = (h) => {
61
+ let l = [], d = [], m;
65
62
  if (Array.isArray(h)) {
66
- const [p, y] = h;
67
- f = y;
63
+ const [u, f] = h;
64
+ m = f;
68
65
  } else
69
- f = h;
70
- return this.createMessageContent(f).length && (l = [...l, this.createMessageContent(f)]), u = [...u, ...this.createMessageOptions(f)], {
71
- messagesAsList: l,
72
- options: u
66
+ m = h;
67
+ return this.createMessageContent(m).length && (d = [...d, this.createMessageContent(m)]), l = [...l, ...this.createMessageOptions(m)], {
68
+ messagesAsList: d,
69
+ options: l
73
70
  };
74
71
  };
75
72
  let a = [], o = [];
76
73
  if (Array.isArray(e.items)) {
77
74
  const { items: h } = e;
78
- h.forEach((u) => {
79
- const l = n(u);
80
- a = [...a, ...l.options], o = [...o, ...l.messagesAsList];
75
+ h.forEach((l) => {
76
+ const d = i(l);
77
+ a = [...a, ...d.options], o = [...o, ...d.messagesAsList];
81
78
  });
82
79
  } else {
83
- const h = n(e);
80
+ const h = i(e);
84
81
  a = [...a, ...h.options], o = [...o, ...h.messagesAsList];
85
82
  }
86
83
  return {
@@ -89,14 +86,14 @@ class ee {
89
86
  `) : void 0,
90
87
  source: this.createMessageSource(t),
91
88
  alias: this.createAlias(t, s),
92
- timestamp: i
89
+ timestamp: r
93
90
  };
94
91
  }
95
92
  createMessageSource(e) {
96
93
  return e;
97
94
  }
98
95
  createAlias(e, t) {
99
- return e === S.System ? "system" : (t == null ? void 0 : t.name) || "Me";
96
+ return e === P.System ? "system" : (t == null ? void 0 : t.name) || "Me";
100
97
  }
101
98
  handleContactMethod(e) {
102
99
  if (!this.cache.has(e))
@@ -108,13 +105,13 @@ class ee {
108
105
  getDetails(e, t = !0) {
109
106
  if (!e)
110
107
  return "";
111
- const { header: s, title: i, label: n, description: a, text: o, html: c, body: h, contactMethodId: u } = e;
112
- let l = "";
113
- if (u) {
114
- const f = this.handleContactMethod(u.toString());
115
- f && (l = this.appendText(l, f, t));
108
+ const { header: s, title: r, label: i, description: a, text: o, html: c, body: h, contactMethodId: l } = e;
109
+ let d = "";
110
+ if (l) {
111
+ const m = this.handleContactMethod(l.toString());
112
+ m && (d = this.appendText(d, m, t));
116
113
  }
117
- return s && (l = this.appendText(l, s, t)), i && (l = this.appendText(l, i, 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;
114
+ return s && (d = this.appendText(d, s, t)), r && (d = this.appendText(d, r, t)), a && (d = this.appendText(d, a, t)), o && (d = this.appendText(d, o, t)), i && (d = this.appendText(d, i, t)), c && (d = this.appendText(d, c, t)), h && typeof h == "string" && (d = this.appendText(d, h, t)), d;
118
115
  }
119
116
  createMessageContent(e) {
120
117
  let t = "";
@@ -122,10 +119,10 @@ class ee {
122
119
  }
123
120
  createMessageOptions(e) {
124
121
  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(([i, n]) => ({
126
- actionKey: i,
127
- label: n
128
- }))), s.length && (t = s.map((i) => this.getDetails(i, !1))), t;
122
+ 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, i]) => ({
123
+ actionKey: r,
124
+ label: i
125
+ }))), s.length && (t = s.map((r) => this.getDetails(r, !1))), t;
129
126
  }
130
127
  appendText(e, t, s = !0) {
131
128
  return s && e.length ? `${e}
@@ -137,55 +134,47 @@ ${t}` : e.length ? `${e} ${t}` : t;
137
134
  });
138
135
  }
139
136
  }
140
- class W {
137
+ class I {
141
138
  constructor(e, t) {
142
- d(this, "id");
143
- d(this, "name");
144
- d(this, "avatar");
145
- d(this, "print", (e, t) => {
146
- const s = {
139
+ this.provider = e, this.print = (s, r) => {
140
+ const i = {
147
141
  name: this.name,
148
142
  avatar: this.avatar,
149
143
  id: this.id
150
- }, i = I(e, t);
144
+ }, a = E(s, r);
151
145
  return this.provider.createEntry(
152
- i.key,
153
- i.content,
154
- S.Agent,
155
- s,
156
- i.timestamp
146
+ a.key,
147
+ a.content,
148
+ P.Agent,
149
+ i,
150
+ a.timestamp
157
151
  );
158
- });
159
- d(this, "typing", () => this.provider.setTypingState({ name: this.name, avatar: this.avatar }));
160
- this.provider = e, this.id = t.id || U(), this.name = t.name, this.avatar = t.avatar;
152
+ }, this.typing = () => this.provider.setTypingState({ name: this.name, avatar: this.avatar }), this.id = t.id || K(), this.name = t.name, this.avatar = t.avatar;
161
153
  }
162
154
  update(e) {
163
- var i;
155
+ var r;
164
156
  const { name: t, avatar: s } = e;
165
- s === null ? this.avatar = void 0 : s && (this.avatar = s), t === null ? this.name = void 0 : t && (this.name = t), (i = this.provider.controller) == null || i.events.dispatch("conversation:agent-updated", {
157
+ 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", {
166
158
  agent: this
167
159
  });
168
160
  }
169
161
  }
170
- class O {
162
+ class M {
171
163
  constructor(e, t, s) {
172
- d(this, "subscriptions", []);
173
- d(this, "options");
174
- d(this, "user");
175
- this.name = e, this.container = t, this.controller = s, this.user = s == null ? void 0 : s.user, this.options = {
164
+ this.name = e, this.container = t, this.controller = s, this.subscriptions = [], this.user = s == null ? void 0 : s.user, this.options = {
176
165
  silent: !1
177
166
  };
178
167
  }
179
168
  static create(e, t, s) {
180
- return new O(e, t, s);
169
+ return new M(e, t, s);
181
170
  }
182
171
  createAgent(e = {}) {
183
172
  var t;
184
173
  if (this.controller) {
185
- const s = this.controller.getAgentById(e.id), i = s ? new W(this, m(m({}, s), e)) : new W(this, e);
174
+ const s = this.controller.getAgentById(e.id), r = s ? new I(this, v(v({}, s), e)) : new I(this, e);
186
175
  return s || (t = this.controller) == null || t.events.dispatch("conversation:agent-created", {
187
- agent: i
188
- }), i;
176
+ agent: r
177
+ }), r;
189
178
  }
190
179
  }
191
180
  print(e) {
@@ -200,9 +189,9 @@ class O {
200
189
  return this.controller ? this.controller.loader() : () => () => {
201
190
  };
202
191
  }
203
- createEntry(e, t, s, i, n) {
192
+ createEntry(e, t, s, r, i) {
204
193
  var a;
205
- return (a = this.controller) == null ? void 0 : a.createEntry(e, t, s, i, n);
194
+ return (a = this.controller) == null ? void 0 : a.createEntry(e, t, s, r, i);
206
195
  }
207
196
  dispose() {
208
197
  var e;
@@ -245,11 +234,10 @@ class O {
245
234
  }
246
235
  }
247
236
  }
248
- const j = (r) => `conversation-${r}`;
249
- class te {
237
+ const q = (n) => `conversation-${n}`;
238
+ class ee {
250
239
  constructor() {
251
- d(this, "_locking", Promise.resolve());
252
- d(this, "_locks", 0);
240
+ this._locking = Promise.resolve(), this._locks = 0;
253
241
  }
254
242
  isLocked() {
255
243
  return this._locks > 0;
@@ -257,33 +245,30 @@ class te {
257
245
  lock() {
258
246
  this._locks += 1;
259
247
  let e, t = new Promise(
260
- (i) => e = () => {
261
- this._locks -= 1, i();
248
+ (r) => e = () => {
249
+ this._locks -= 1, r();
262
250
  }
263
251
  ), s = this._locking.then(() => e);
264
252
  return this._locking = this._locking.then(() => t), s;
265
253
  }
266
254
  }
267
- class se {
255
+ class te {
268
256
  constructor(e, t, s) {
269
- d(this, "sessionStorageKey");
270
- d(this, "locker", new te());
271
- d(this, "initialStoredAgents", []);
272
- this.container = e, this.conversation = t, this.enabled = s, this.sessionStorageKey = j(t.id), t.onStarted(() => v(this, null, function* () {
257
+ this.container = e, this.conversation = t, this.enabled = s, this.locker = new ee(), this.initialStoredAgents = [], this.sessionStorageKey = q(t.id), t.onStarted(() => g(this, null, function* () {
273
258
  if (t.messages.length > 0)
274
259
  return;
275
- const { agents: i } = yield this.read(), n = [];
276
- i && i.forEach((o) => {
277
- const c = t.providerIndex(o.providerName), h = c > -1 ? t.registeredProviders[c] : t.createProvider(o.providerName), u = new W(h, { name: o.name, avatar: o.avatar, id: o.id });
278
- n.push(u);
260
+ const { agents: r } = yield this.read(), i = [];
261
+ r && r.forEach((o) => {
262
+ const c = t.providerIndex(o.providerName), h = c > -1 ? t.registeredProviders[c] : t.createProvider(o.providerName), l = new I(h, { name: o.name, avatar: o.avatar, id: o.id });
263
+ i.push(l);
279
264
  });
280
265
  const { messages: a } = yield this.read();
281
266
  a.forEach((o) => {
282
267
  switch (o.type) {
283
268
  case "agent": {
284
- const c = n.find((h) => {
285
- var u;
286
- return h.id === ((u = o.sender) == null ? void 0 : u.id);
269
+ const c = i.find((h) => {
270
+ var l;
271
+ return h.id === ((l = o.sender) == null ? void 0 : l.id);
287
272
  });
288
273
  c && c.print(o.content.items || o.content, {
289
274
  key: o.key
@@ -301,23 +286,23 @@ class se {
301
286
  t.print(o.content.items || o.content);
302
287
  }
303
288
  });
304
- })), t.onMessageCreated((i, n) => v(this, null, function* () {
305
- this.write(n.message, "messages");
306
- })), t.events.subscribe("conversation:agent-created", (i, n) => v(this, null, function* () {
289
+ })), t.onMessageCreated((r, i) => g(this, null, function* () {
290
+ this.write(i.message, "messages");
291
+ })), t.events.subscribe("conversation:agent-created", (r, i) => g(this, null, function* () {
307
292
  const a = {
308
- id: n.agent.id,
309
- name: n.agent.name,
310
- avatar: n.agent.avatar,
311
- providerName: n.agent.provider.name
293
+ id: i.agent.id,
294
+ name: i.agent.name,
295
+ avatar: i.agent.avatar,
296
+ providerName: i.agent.provider.name
312
297
  };
313
298
  yield this.write(a, "agents");
314
- })), t.events.subscribe("conversation:agent-updated", (i, n) => v(this, null, function* () {
299
+ })), t.events.subscribe("conversation:agent-updated", (r, i) => g(this, null, function* () {
315
300
  const { agents: a } = yield this.read();
316
301
  yield this.write(
317
302
  [
318
- ...a.map((o) => o.id === n.agent.id ? b(m({}, o), {
319
- name: n.agent.name,
320
- avatar: n.agent.avatar
303
+ ...a.map((o) => o.id === i.agent.id ? y(v({}, o), {
304
+ name: i.agent.name,
305
+ avatar: i.agent.avatar
321
306
  }) : o)
322
307
  ],
323
308
  "agents",
@@ -329,84 +314,83 @@ class se {
329
314
  this.initialStoredAgents = e.agents;
330
315
  }
331
316
  isRehydrated() {
332
- return v(this, null, function* () {
317
+ return g(this, null, function* () {
333
318
  const { messages: e } = yield this.read();
334
319
  return e.length > 0;
335
320
  });
336
321
  }
337
322
  getStoredAgent(e) {
338
- if (!!this.enabled)
323
+ if (this.enabled)
339
324
  return this.initialStoredAgents.find((t) => t.id === e);
340
325
  }
341
326
  write(e, t, s = "add") {
342
- return v(this, null, function* () {
327
+ return g(this, null, function* () {
343
328
  if (!this.enabled)
344
329
  return;
345
- const i = yield this.locker.lock();
346
- return M(
330
+ const r = yield this.locker.lock();
331
+ return W(
347
332
  this.container,
348
333
  this.sessionStorageKey,
349
- N.Necessary
350
- ).then((n) => v(this, null, function* () {
334
+ D.Necessary
335
+ ).then((i) => g(this, null, function* () {
351
336
  if (s === "add") {
352
337
  const a = yield this.read();
353
338
  if (t === "messages" && a.messages.findIndex((c) => c.key === e.key) > -1) {
354
- i();
339
+ r();
355
340
  return;
356
341
  }
357
- let o = m({}, a);
358
- return t === "messages" ? o.messages = [...o.messages, e] : t === "agents" && (o.agents = [...o.agents, e]), n(m(m({}, a), o)).then(() => {
359
- i();
342
+ let o = v({}, a);
343
+ return t === "messages" ? o.messages = [...o.messages, e] : t === "agents" && (o.agents = [...o.agents, e]), i(v(v({}, a), o)).then(() => {
344
+ r();
360
345
  });
361
346
  }
362
347
  if (s === "update" && t === "agents") {
363
348
  const a = yield this.read();
364
- return n(b(m({}, a), {
349
+ return i(y(v({}, a), {
365
350
  agents: e
366
351
  })).then(() => {
367
- i();
352
+ r();
368
353
  });
369
354
  }
370
- return n(e).then(() => {
371
- i();
355
+ return i(e).then(() => {
356
+ r();
372
357
  });
373
358
  }));
374
359
  });
375
360
  }
376
361
  read() {
377
- return v(this, null, function* () {
378
- return w(this.container, this.sessionStorageKey).then((e) => e || {
362
+ return g(this, null, function* () {
363
+ return b(this.container, this.sessionStorageKey).then((e) => e || {
379
364
  messages: [],
380
365
  agents: []
381
366
  });
382
367
  });
383
368
  }
384
369
  }
385
- const re = se;
386
- class ie {
370
+ const se = te;
371
+ class re {
387
372
  constructor(e) {
388
- d(this, "print", (e, t) => {
389
- const s = I(e, t);
373
+ this.controller = e, this.print = (t, s) => {
374
+ const r = E(t, s);
390
375
  return this.controller.createEntry(
391
- s.key,
392
- s.content,
393
- S.User,
376
+ r.key,
377
+ r.content,
378
+ P.User,
394
379
  void 0,
395
- s.timestamp
380
+ r.timestamp
396
381
  );
397
- });
398
- this.controller = e;
382
+ };
399
383
  }
400
384
  }
401
- const D = (r, e, t) => v(void 0, null, function* () {
402
- const s = yield r.getAsync("conversation"), i = yield r.getAsync("components"), n = s.controllers.find((a) => a.conversation.id === e);
403
- if (n) {
404
- const a = [...n.conversation.providers];
385
+ const T = (n, e, t) => g(void 0, null, function* () {
386
+ const s = yield n.getAsync("conversation"), r = yield n.getAsync("components"), i = s.controllers.find((a) => a.conversation.id === e);
387
+ if (i) {
388
+ const a = [...i.conversation.providers];
405
389
  a.forEach((c) => {
406
- n.conversation.setProviderOptions(c, { silent: !0 });
407
- }), n.conversation.queueProviders(a), n.conversation.setProviders([t]);
408
- const o = i.components().ofType("conversation");
409
- i.write({
390
+ i.conversation.setProviderOptions(c, { silent: !0 });
391
+ }), i.conversation.queueProviders(a), i.conversation.setProviders([t]);
392
+ const o = r.components().ofType("conversation");
393
+ r.write({
410
394
  key: "setConversationProvider",
411
395
  attributes: {
412
396
  properties: { providers: [t] }
@@ -416,7 +400,7 @@ const D = (r, e, t) => v(void 0, null, function* () {
416
400
  });
417
401
  }
418
402
  });
419
- class ne {
403
+ class ie {
420
404
  constructor(e) {
421
405
  this.writer = e;
422
406
  }
@@ -431,89 +415,75 @@ class ne {
431
415
  return typeof e == "string" ? { body: e } : e.length > -1 && typeof e == "object" ? { items: e } : e;
432
416
  }
433
417
  }
434
- var S = /* @__PURE__ */ ((r) => (r.User = "user", r.Agent = "agent", r.System = "system", r))(S || {});
435
- const I = (r, e) => {
436
- let t, s = (e == null ? void 0 : e.key) || U(), i = Date.now();
437
- if (Array.isArray(r) && r.length > -1)
438
- typeof r[0] == "string" ? t = { items: [r] } : t = { items: r };
439
- else if (typeof r == "string")
440
- t = { body: r };
441
- else if (r = r || {}, r.type)
442
- t = m({}, r);
418
+ var P = /* @__PURE__ */ ((n) => (n.User = "user", n.Agent = "agent", n.System = "system", n))(P || {});
419
+ const E = (n, e) => {
420
+ let t, s = (e == null ? void 0 : e.key) || K(), r = Date.now();
421
+ if (Array.isArray(n) && n.length > -1)
422
+ typeof n[0] == "string" ? t = { items: [n] } : t = { items: n };
423
+ else if (typeof n == "string")
424
+ t = { body: n };
425
+ else if (n = n || {}, n.type)
426
+ t = v({}, n);
443
427
  else {
444
428
  if (t = {
445
- body: r.body,
446
- actions: r.actions,
447
- title: r.title
448
- }, r.key && (s = r.key), r.timestamp && (i = r.timestamp), typeof r.form == "function") {
449
- const n = X.create(s);
450
- r.form(n);
451
- const a = n.get();
429
+ body: n.body,
430
+ actions: n.actions,
431
+ title: n.title
432
+ }, n.key && (s = n.key), n.timestamp && (r = n.timestamp), typeof n.form == "function") {
433
+ const i = Y.create(s);
434
+ n.form(i);
435
+ const a = i.get();
452
436
  t.form = a;
453
437
  }
454
- r.timestamp === null && (i = null);
438
+ n.timestamp === null && (r = null);
455
439
  }
456
- return { content: t, key: s, timestamp: i };
457
- }, z = (r, e) => {
440
+ return { content: t, key: s, timestamp: r };
441
+ }, L = (n, e) => {
458
442
  if (!e)
459
443
  return;
460
- const t = JSON.stringify(e), s = r.findIndex((i) => t === JSON.stringify(i));
444
+ const t = JSON.stringify(e), s = n.findIndex((r) => t === JSON.stringify(r));
461
445
  if (s > -1)
462
- return r.splice(s, 1);
446
+ return n.splice(s, 1);
463
447
  };
464
- class oe {
448
+ class ne {
465
449
  constructor(e, t, s) {
466
- d(this, "formHandlers", {});
467
- d(this, "user", new ie(this));
468
- d(this, "events");
469
- d(this, "providers", []);
470
- d(this, "active", !1);
471
- d(this, "queuedProviders", []);
472
- d(this, "registeredProviders", []);
473
- d(this, "loaders", 0);
474
- d(this, "componentMounted", !1);
475
- d(this, "store");
476
- d(this, "messages", []);
477
- d(this, "typingActors", []);
478
- d(this, "conversationHistory");
479
- d(this, "print", (e) => {
480
- const t = I(e);
450
+ this.container = e, this.id = t, this.formHandlers = {}, this.user = new re(this), this.providers = [], this.active = !1, this.queuedProviders = [], this.registeredProviders = [], this.loaders = 0, this.componentMounted = !1, this.messages = [], this.typingActors = [], this.print = (i) => {
451
+ const a = E(i);
481
452
  return this.createEntry(
482
- t.key,
483
- t.content,
453
+ a.key,
454
+ a.content,
484
455
  "system",
485
456
  void 0,
486
- t.timestamp
457
+ a.timestamp
487
458
  );
488
- });
489
- this.container = e, this.id = t;
490
- const i = e.get("$widget");
491
- this.events = i.events.createChild(this), this.store = new re(e, this, s.rehydrate), this.conversationHistory = new ee(this);
459
+ };
460
+ const r = e.get("$widget");
461
+ this.events = r.events.createChild(this), this.store = new se(e, this, s.rehydrate), this.conversationHistory = new Z(this);
492
462
  }
493
463
  setInitialStorage(e) {
494
464
  this.store.setInitialData(e);
495
465
  }
496
466
  setProviders(e) {
497
467
  const t = [], s = [];
498
- this.providers.reduce((i, n) => (e.indexOf(n) === -1 && i.push(n), i), []).forEach((i) => {
499
- const n = this.providers.indexOf(i);
500
- n > -1 && (t.push(i), this.providers.splice(n, 1));
501
- }), e.forEach((i) => {
502
- this.providers.indexOf(i) === -1 && (s.push(i), this.providers.push(i));
468
+ this.providers.reduce((r, i) => (e.indexOf(i) === -1 && r.push(i), r), []).forEach((r) => {
469
+ const i = this.providers.indexOf(r);
470
+ i > -1 && (t.push(r), this.providers.splice(i, 1));
471
+ }), e.forEach((r) => {
472
+ this.providers.indexOf(r) === -1 && (s.push(r), this.providers.push(r));
503
473
  }), (s.length || t.length) && this.events.dispatch("conversation:providers-changed", { added: s, removed: t });
504
474
  }
505
475
  createProvider(e) {
506
476
  const t = this.providerIndex(e);
507
477
  if (t > -1)
508
478
  return this.registeredProviders[t];
509
- const s = O.create(e, this.container, this);
479
+ const s = M.create(e, this.container, this);
510
480
  return this.registeredProviders.push(s), s;
511
481
  }
512
482
  providerIndex(e) {
513
483
  return this.registeredProviders.findIndex((t) => t.name === e);
514
484
  }
515
485
  getAgentById(e) {
516
- if (!!e)
486
+ if (e)
517
487
  return this.store.getStoredAgent(e);
518
488
  }
519
489
  dispose() {
@@ -546,14 +516,14 @@ class oe {
546
516
  s > -1 && this.registeredProviders[s].setOptions(t);
547
517
  }
548
518
  changeProvider(e) {
549
- this.registeredProviders.find((s) => s.name === e) && D(this.container, this.id, e);
519
+ this.registeredProviders.find((s) => s.name === e) && T(this.container, this.id, e);
550
520
  }
551
521
  queueProviders(e) {
552
522
  this.queuedProviders = e;
553
523
  }
554
524
  onCompleteProvider() {
555
525
  const e = this.queuedProviders.pop();
556
- e && D(this.container, this.id, e);
526
+ e && T(this.container, this.id, e);
557
527
  }
558
528
  getComponentMountedState() {
559
529
  return this.componentMounted;
@@ -561,22 +531,22 @@ class oe {
561
531
  onUnreadMessage(e) {
562
532
  return this.events.subscribe("conversation:unread-message", e);
563
533
  }
564
- createEntry(e, t, s, i, n) {
534
+ createEntry(e, t, s, r, i) {
565
535
  const a = {
566
536
  key: e,
567
537
  content: t,
568
538
  type: s,
569
- sender: i || null,
570
- timestamp: n || n === null ? n : Date.now()
539
+ sender: r || null,
540
+ timestamp: i || i === null ? i : Date.now()
571
541
  };
572
- this.messages.push(a), a.type === "agent" && z(this.typingActors, i);
573
- const o = new ne((c) => {
542
+ this.messages.push(a), a.type === "agent" && L(this.typingActors, r);
543
+ const o = new ie((c) => {
574
544
  if (c !== null) {
575
- const h = c, { timestamp: u = void 0 } = h, l = B(h, ["timestamp"]);
576
- a.content = l, u && (a.timestamp = u);
545
+ const h = c, { timestamp: l = void 0 } = h, d = _(h, ["timestamp"]);
546
+ a.content = d, l && (a.timestamp = l);
577
547
  } else {
578
- const u = this.messages.indexOf(a);
579
- a.content = null, u > -1 && this.messages.splice(u, 1);
548
+ const l = this.messages.indexOf(a);
549
+ a.content = null, l > -1 && this.messages.splice(l, 1);
580
550
  }
581
551
  this.events.dispatch("conversation:message-updated", { message: a }), this.update();
582
552
  });
@@ -598,9 +568,12 @@ class oe {
598
568
  }
599
569
  setTypingState(e, t) {
600
570
  return this.typingActors.indexOf(e) === -1 && (this.typingActors.push(e), this.update()), () => {
601
- z(this.typingActors, e), this.update();
571
+ L(this.typingActors, e), this.update();
602
572
  };
603
573
  }
574
+ /**
575
+ * Displays a loader in the conversation.
576
+ */
604
577
  loader() {
605
578
  this.loaders = this.loaders + 1;
606
579
  let e = !1;
@@ -609,37 +582,37 @@ class oe {
609
582
  };
610
583
  }
611
584
  submitForm(e, t) {
612
- this.formHandlers[e] = b(m({}, this.formHandlers[e]), { submit: t });
585
+ this.formHandlers[e] = y(v({}, this.formHandlers[e]), { submit: t });
613
586
  }
614
587
  validateForm(e, t) {
615
- this.formHandlers[e] = b(m({}, this.formHandlers[e]), { validate: t });
588
+ this.formHandlers[e] = y(v({}, this.formHandlers[e]), { validate: t });
616
589
  }
617
590
  getHistory() {
618
591
  return this.conversationHistory.getConversationLogs();
619
592
  }
620
593
  }
621
- const ae = (r, e) => {
622
- const t = r.split("_contact");
594
+ const oe = (n, e) => {
595
+ const t = n.split("_contact");
623
596
  return e.widgets.get(t[0]);
624
- }, R = (r) => {
625
- const e = r.get("$widget"), { name: t, implementation: s } = r.get("$widget"), i = t.indexOf("_contact") > -1 ? ae(t, s) : e, { data: n } = r.get("$settings"), { trigger: a } = i.container.get("$settings"), o = `${t.replace("_contact-method", "").replace("_contact", "")}_contact-method`, c = s.widgets.get(o);
626
- return c && !a ? { chatWidget: c, mainWidget: i, data: n } : { mainWidget: i, data: n };
627
- }, ce = (r) => {
628
- const { chatWidget: e } = R(r);
597
+ }, N = (n) => {
598
+ const e = n.get("$widget"), { name: t, implementation: s } = n.get("$widget"), r = t.indexOf("_contact") > -1 ? oe(t, s) : e, { data: i } = n.get("$settings"), { trigger: a } = r.container.get("$settings"), o = `${t.replace("_contact-method", "").replace("_contact", "")}_contact-method`, c = s.widgets.get(o);
599
+ return c && !a ? { chatWidget: c, mainWidget: r, data: i } : { mainWidget: r, data: i };
600
+ }, ae = (n) => {
601
+ const { chatWidget: e } = N(n);
629
602
  return !!e;
630
- }, K = (r, e, t) => {
631
- const { mainWidget: s, data: i, chatWidget: n } = R(r);
632
- return n ? n.state === "activated" ? n.invoke("open").then(() => {
633
- n.container.getAsync("conversation").then((a) => {
634
- a.navigateToConversationIfActive(e.id).then(() => L(r));
603
+ }, z = (n, e, t) => {
604
+ const { mainWidget: s, data: r, chatWidget: i } = N(n);
605
+ return i ? i.state === "activated" ? i.invoke("open").then(() => {
606
+ i.container.getAsync("conversation").then((a) => {
607
+ a.navigateToConversationIfActive(e.id).then(() => B(n));
635
608
  });
636
- }) : n.activate().then(() => {
637
- const { trigger: a } = n.container.get("$settings");
638
- return a.action = "hide", n.invoke("setSettings", () => ({
639
- data: i,
609
+ }) : i.activate().then(() => {
610
+ const { trigger: a } = i.container.get("$settings");
611
+ return a.action = "hide", i.invoke("setSettings", () => ({
612
+ data: r,
640
613
  trigger: a,
641
614
  activate: !0
642
- })).then(() => n.container.getAsync("components").then((o) => {
615
+ })).then(() => i.container.getAsync("components").then((o) => {
643
616
  const c = o.components().ofType("contact-method");
644
617
  o.write({
645
618
  key: "setContactMethodId",
@@ -662,28 +635,28 @@ const ae = (r, e) => {
662
635
  provider: "localStorage"
663
636
  });
664
637
  }));
665
- }).then(() => n.invoke("attach", {
638
+ }).then(() => i.invoke("attach", {
666
639
  key: "contact-method",
667
640
  triggerDOMElement: t,
668
641
  withRenderState: "open"
669
- })).then(() => (M(
670
- n.container,
642
+ })).then(() => (W(
643
+ i.container,
671
644
  "activeStickyWidget",
672
- N.Necessary,
645
+ D.Necessary,
673
646
  {
674
- medium: A.Local,
675
- scope: V.Implementation
647
+ medium: w.Local,
648
+ scope: J.Implementation
676
649
  }
677
- ).then((a) => a(n.name)), n.container.getAsync("conversation").then((a) => {
678
- a.setConversationEndedBehavior(E.Deactivate);
679
- }).then(() => L(r)).then(() => !1))) : (s.container.getAsync("conversation").then((a) => a.navigateToConversationIfActive(e.id).then(() => a.setConversationEndedBehavior(E.Navigate))), !n);
680
- }, de = (r, e, t = "conversation") => {
681
- const { mainWidget: s, chatWidget: i } = R(r);
682
- return i ? i.container.getAsync("router").then((n) => {
683
- n.navigate(t, { id: e.id });
684
- }) : s.container.getAsync("conversation").then((n) => {
650
+ ).then((a) => a(i.name)), i.container.getAsync("conversation").then((a) => {
651
+ a.setConversationEndedBehavior(x.Deactivate);
652
+ }).then(() => B(n)).then(() => !1))) : (s.container.getAsync("conversation").then((a) => a.navigateToConversationIfActive(e.id).then(() => a.setConversationEndedBehavior(x.Navigate))), !i);
653
+ }, ce = (n, e, t = "conversation") => {
654
+ const { mainWidget: s, chatWidget: r } = N(n);
655
+ return r ? r.container.getAsync("router").then((i) => {
656
+ i.navigate(t, { id: e.id });
657
+ }) : s.container.getAsync("conversation").then((i) => {
685
658
  var a;
686
- (a = n.setConversationEndedBehavior(E.Navigate)) == null || a.then(() => {
659
+ (a = i.setConversationEndedBehavior(x.Navigate)) == null || a.then(() => {
687
660
  s.container.getAsync("router").then((o) => {
688
661
  s.container.getAsync("components").then((c) => {
689
662
  const h = c.components().ofType("conversation");
@@ -699,39 +672,30 @@ const ae = (r, e) => {
699
672
  });
700
673
  });
701
674
  });
702
- }, P = "conversations";
703
- var E = /* @__PURE__ */ ((r) => (r.Deactivate = "deactivate", r.Navigate = "navigate", r.None = "none", r))(E || {});
704
- class C {
675
+ }, A = "conversations";
676
+ var x = /* @__PURE__ */ ((n) => (n.Deactivate = "deactivate", n.Navigate = "navigate", n.None = "none", n))(x || {});
677
+ class S {
705
678
  constructor(e, t) {
706
- d(this, "events");
707
- d(this, "controllers", []);
708
- d(this, "providers", []);
709
- d(this, "disposeProviders", {});
710
- d(this, "subscriptions", []);
711
- d(this, "storageWriter", null);
712
- d(this, "router", null);
713
- d(this, "buttonQuery", null);
714
- d(this, "sessionInfo", null);
715
- this.container = e, this.components = t;
679
+ this.container = e, this.components = t, this.controllers = [], this.providers = [], this.disposeProviders = {}, this.subscriptions = [], this.storageWriter = null, this.router = null, this.buttonQuery = null, this.sessionInfo = null;
716
680
  const s = e.get("$widget");
717
681
  this.events = s.events.createChild(this);
718
682
  }
719
683
  initialize() {
720
- M(this.container, P, N.Necessary, {
721
- medium: A.Local
722
- }).then((e) => this.storageWriter = e), w(this.container, P, A.Local).then(
684
+ W(this.container, A, D.Necessary, {
685
+ medium: w.Local
686
+ }).then((e) => this.storageWriter = e), b(this.container, A, w.Local).then(
723
687
  (e) => {
724
688
  this.buttonQuery = this.components.components().ofType("conversation-return-button"), e && (this.sessionInfo = e, e.id && e.route && this.writeToComponents({ active: !0, alert: { show: !1 } }));
725
689
  }
726
690
  ), this.container.getAsync("router").then((e) => this.router = e), this.events.subscribe("conversation:ended", (e, t) => {
727
- var s, i, n;
691
+ var s, r, i;
728
692
  switch ((s = this.sessionInfo) == null ? void 0 : s.conversationEndedBehavior) {
729
693
  case "deactivate":
730
694
  this.container.get("$widget").deactivate();
731
695
  break;
732
696
  case "navigate":
733
- const o = (i = this.router) == null ? void 0 : i.getInitialRoute();
734
- o && ((n = this.router) == null || n.navigate(o.name));
697
+ const o = (r = this.router) == null ? void 0 : r.getInitialRoute();
698
+ o && ((i = this.router) == null || i.navigate(o.name));
735
699
  break;
736
700
  }
737
701
  this.writeToComponents({ active: !1 }), this.sessionInfo = null, this.storageWriter && this.storageWriter();
@@ -741,24 +705,24 @@ class C {
741
705
  this.subscriptions.push(e);
742
706
  }
743
707
  static getInstance(e, t = "conversation") {
744
- return Y(e)(() => e.getAsync(t).then((s) => {
745
- let i = s;
746
- return i || Q.getInstance(e).then((n) => (i = new C(e, n), i.initialize(), e.registerAsync(t, () => i), i));
708
+ return V(e)(() => e.getAsync(t).then((s) => {
709
+ let r = s;
710
+ return r || Q.getInstance(e).then((i) => (r = new S(e, i), r.initialize(), e.registerAsync(t, () => r), r));
747
711
  }));
748
712
  }
749
713
  navigateToConversationIfActive(e) {
750
- return w(this.container, P, A.Local).then(
714
+ return b(this.container, A, w.Local).then(
751
715
  (t) => {
752
716
  var s;
753
717
  if (t && t.id === e && t.route) {
754
- const { name: i, params: n } = t.route;
755
- (s = this.router) == null || s.navigate(i, n);
718
+ const { name: r, params: i } = t.route;
719
+ (s = this.router) == null || s.navigate(r, i);
756
720
  }
757
721
  }
758
722
  );
759
723
  }
760
724
  setConversationEndedBehavior(e) {
761
- return w(this.container, P, A.Local).then(
725
+ return b(this.container, A, w.Local).then(
762
726
  (t) => {
763
727
  let s = t;
764
728
  return s ? s.conversationEndedBehavior = e : s = { conversationEndedBehavior: e }, this.sessionInfo = s, this.storageWriter && this.storageWriter(this.sessionInfo) || Promise.resolve();
@@ -766,13 +730,13 @@ class C {
766
730
  );
767
731
  }
768
732
  createController(e, t) {
769
- return v(this, null, function* () {
770
- const s = j(e), { agents: i } = (yield w(
733
+ return g(this, null, function* () {
734
+ const s = q(e), { agents: r } = (yield b(
771
735
  this.container,
772
736
  s
773
- )) || { agents: [] }, n = this.controllers.findIndex((o) => o.conversation.id === e);
737
+ )) || { agents: [] }, i = this.controllers.findIndex((o) => o.conversation.id === e);
774
738
  let a;
775
- return n > -1 ? a = this.controllers[n].conversation : a = new oe(this.container, e, t), a.setInitialStorage({ agents: i || [] }), a;
739
+ return i > -1 ? a = this.controllers[i].conversation : a = new ne(this.container, e, t), a.setInitialStorage({ agents: r || [] }), a;
776
740
  });
777
741
  }
778
742
  registerProvider(e, t) {
@@ -780,18 +744,18 @@ class C {
780
744
  name: e,
781
745
  handler: t
782
746
  };
783
- this.providers.push(s), this.controllers.filter((i) => i.conversation.providers.indexOf(e) > -1).forEach((i) => {
784
- this.invokeHandler(s, i);
747
+ this.providers.push(s), this.controllers.filter((r) => r.conversation.providers.indexOf(e) > -1).forEach((r) => {
748
+ this.invokeHandler(s, r);
785
749
  });
786
750
  }
787
751
  registerController(e, t) {
788
- const s = this.controllers.findIndex((n) => n.conversation.id === e.id);
789
- let i;
752
+ const s = this.controllers.findIndex((i) => i.conversation.id === e.id);
753
+ let r;
790
754
  if (s < 0) {
791
- i = { conversation: e, component: t }, this.controllers.push(i);
792
- const n = (a) => {
755
+ r = { conversation: e, component: t }, this.controllers.push(r);
756
+ const i = (a) => {
793
757
  a && this.providers.filter((o) => a.indexOf(o.name) > -1).forEach((o) => {
794
- this.invokeHandler(o, i);
758
+ this.invokeHandler(o, r);
795
759
  });
796
760
  };
797
761
  return this.subscriptions.push(
@@ -802,19 +766,19 @@ class C {
802
766
  ), this.subscriptions.push(
803
767
  e.onProvidersChange((a, o) => {
804
768
  const { added: c, removed: h = [] } = o;
805
- h.forEach((u) => {
806
- (this.disposeProviders[u] || []).forEach((l) => {
807
- l();
769
+ h.forEach((l) => {
770
+ (this.disposeProviders[l] || []).forEach((d) => {
771
+ d();
808
772
  });
809
- }), n(c);
773
+ }), i(c);
810
774
  })
811
775
  ), this.subscriptions.push(
812
776
  e.onStarted((a, o) => {
813
- var h, u;
777
+ var h, l;
814
778
  const c = {
815
779
  id: e.id,
816
780
  route: (h = this.router) == null ? void 0 : h.getRouteData(),
817
- conversationEndedBehavior: (u = this.sessionInfo) == null ? void 0 : u.conversationEndedBehavior
781
+ conversationEndedBehavior: (l = this.sessionInfo) == null ? void 0 : l.conversationEndedBehavior
818
782
  };
819
783
  this.sessionInfo = c, this.storageWriter && this.storageWriter(c), this.writeToComponents({ active: o });
820
784
  })
@@ -822,9 +786,9 @@ class C {
822
786
  e.onUnreadMessage((a, o) => {
823
787
  this.events.dispatch("conversation:unread-message", o), this.writeToComponents({ alert: { show: o } });
824
788
  })
825
- ), n(e.providers), !0;
789
+ ), i(e.providers), !0;
826
790
  }
827
- return i = this.controllers[s], !1;
791
+ return r = this.controllers[s], !1;
828
792
  }
829
793
  writeToComponents(e, t = "conversationReturnButtonState") {
830
794
  this.buttonQuery && this.components.write({
@@ -842,7 +806,7 @@ class C {
842
806
  s && (this.disposeProviders[e.name] || (this.disposeProviders[e.name] = []), this.disposeProviders[e.name].push(s));
843
807
  }
844
808
  getComponentRoute() {
845
- return w(this.container, P, A.Local).then(
809
+ return b(this.container, A, w.Local).then(
846
810
  (e) => e == null ? void 0 : e.route
847
811
  );
848
812
  }
@@ -855,116 +819,116 @@ class C {
855
819
  e();
856
820
  }), this.controllers = [], this.providers = [];
857
821
  }
858
- static handleContactMethodClick(e, t, s, i) {
859
- return v(this, null, function* () {
860
- if (ce(t)) {
822
+ static handleContactMethodClick(e, t, s, r) {
823
+ return g(this, null, function* () {
824
+ if (ae(t)) {
861
825
  e.preventDefault();
862
- let n = document.getElementById("humany-dynamic-anchor");
863
- n || (n = document.createElement("a"), n.setAttribute("href", "#"), n.id = "humany-dynamic-anchor", document.body.appendChild(n)), K(t, s, n);
826
+ let i = document.getElementById("humany-dynamic-anchor");
827
+ i || (i = document.createElement("a"), i.setAttribute("href", "#"), i.id = "humany-dynamic-anchor", document.body.appendChild(i)), z(t, s, i);
864
828
  }
865
- K(t, s);
829
+ z(t, s);
866
830
  });
867
831
  }
868
832
  static handleContactMethodSubmit(e, t) {
869
- return v(this, null, function* () {
870
- var s, i;
871
- return (i = (s = t == null ? void 0 : t.body.form.meta) == null ? void 0 : s.conversation) != null && i.id ? D(
833
+ return g(this, null, function* () {
834
+ var s, r;
835
+ return (r = (s = t == null ? void 0 : t.body.form.meta) == null ? void 0 : s.conversation) != null && r.id ? T(
872
836
  e,
873
837
  t.body.form.meta.conversation.id,
874
838
  t.clientName
875
- ) : de(e, t);
839
+ ) : ce(e, t);
876
840
  });
877
841
  }
878
842
  }
879
- const he = (r, e) => r.reduce((t, s, i) => {
843
+ const he = (n, e) => n.reduce((t, s, r) => {
880
844
  var a, o;
881
- const n = b(m({}, s), {
882
- content: [b(m({}, s.content), { key: s.key })]
845
+ const i = y(v({}, s), {
846
+ content: [y(v({}, s.content), { key: s.key })]
883
847
  });
884
- if (t.length > 0 && s.type !== S.System) {
848
+ if (t.length > 0 && s.type !== P.System) {
885
849
  const c = t[t.length - 1];
886
850
  if ((!e && e !== 0 || Math.abs(c.timestamp - s.timestamp) < e) && ((a = c.sender) == null ? void 0 : a.name) === ((o = s.sender) == null ? void 0 : o.name) && c.type === s.type)
887
- return c.timestamp = s.timestamp, c.content.push(b(m({}, s.content), { key: s.key })), t;
888
- }
889
- return t.push(n), t;
890
- }, []), we = (r) => Promise.all([
891
- C.getInstance(r),
892
- r.getAsync("router")
893
- ]).then(([e, t]) => q(
894
- r,
851
+ return c.timestamp = s.timestamp, c.content.push(y(v({}, s.content), { key: s.key })), t;
852
+ }
853
+ return t.push(i), t;
854
+ }, []), be = (n) => Promise.all([
855
+ S.getInstance(n),
856
+ n.getAsync("router")
857
+ ]).then(([e, t]) => U(
858
+ n,
895
859
  "conversation",
896
- import("./conversation.be64b43a.js"),
897
- (s) => v(void 0, null, function* () {
898
- const { rehydrate: i = !1 } = s.properties(), a = t.getRouteData().params.id || s.node.name || "component", o = yield e.createController(a, { rehydrate: i }), c = e.registerController(o, s), h = 3 * 60 * 1e3, u = (g) => {
899
- const { providers: p = [] } = g;
900
- if (p) {
901
- const y = Array.isArray(p) ? p : [p];
902
- return o.setProviders(y), y;
860
+ import("./conversation-23bae0c6.js"),
861
+ (s) => g(void 0, null, function* () {
862
+ 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, l = (p) => {
863
+ const { providers: u = [] } = p;
864
+ if (u) {
865
+ const f = Array.isArray(u) ? u : [u];
866
+ return o.setProviders(f), f;
903
867
  }
904
868
  };
905
- u(s.properties(u)), o.setComponentMountedState(!0);
906
- const l = (g) => {
907
- const { loading: p, typingActors: y, messages: k } = g;
869
+ l(s.properties(l)), o.setComponentMountedState(!0);
870
+ const d = (p) => {
871
+ const { loading: u, typingActors: f, messages: C } = p;
908
872
  s.writeProperties({
909
- loading: p,
910
- typingActors: y,
911
- messages: he(k, h)
873
+ loading: u,
874
+ typingActors: f,
875
+ messages: he(C, h)
912
876
  });
913
877
  };
914
- l(o.getMessageStream()), c && (s.writeProperties({ conversationControllerId: o.id }), s.actions.create("user-submit", (g, p) => {
915
- if (p) {
916
- const { preventDefault: y, validationPromise: k } = p;
917
- if (y) {
918
- k && k().then((H) => {
919
- H && o.user.print(H);
878
+ d(o.getMessageStream()), c && (s.writeProperties({ conversationControllerId: o.id }), s.actions.create("user-submit", (p, u) => {
879
+ if (u) {
880
+ const { preventDefault: f, validationPromise: C } = u;
881
+ if (f) {
882
+ C && C().then((O) => {
883
+ O && o.user.print(O);
920
884
  });
921
885
  return;
922
886
  }
923
887
  }
924
- o.user.print(g.text);
925
- }), s.actions.create("user-typing", (g, p) => {
926
- }), s.actions.create("form", (g, p) => {
927
- }), s.actions.create("action", (g, p) => {
928
- }), s.actions.create("overlay-mounted", (g, p) => {
929
- }), s.actions.create("show-overlay", (g, p) => {
888
+ o.user.print(p.text);
889
+ }), s.actions.create("user-typing", (p, u) => {
890
+ }), s.actions.create("form", (p, u) => {
891
+ }), s.actions.create("action", (p, u) => {
892
+ }), s.actions.create("overlay-mounted", (p, u) => {
893
+ }), s.actions.create("show-overlay", (p, u) => {
930
894
  s.writeProperties({
931
895
  overlay: { conversation: !1, secondary: !1 }
932
896
  });
933
- }), s.actions.create("hide-overlay", (g, p) => {
897
+ }), s.actions.create("hide-overlay", (p, u) => {
934
898
  s.writeProperties({
935
899
  overlay: null
936
900
  });
937
- }), s.actions.create("show-overlay-conversation", (g, p) => {
901
+ }), s.actions.create("show-overlay-conversation", (p, u) => {
938
902
  s.writeProperties({
939
903
  overlay: { conversation: !0, secondary: !1 }
940
904
  });
941
- }), s.actions.create("hide-overlay-conversation", (g, p) => {
905
+ }), s.actions.create("hide-overlay-conversation", (p, u) => {
942
906
  s.writeProperties({
943
907
  overlay: { conversation: !1, secondary: !1 }
944
908
  });
945
909
  }));
946
- const f = o.events.subscribe(
910
+ const m = o.events.subscribe(
947
911
  "conversation:updated",
948
- (g, p) => {
949
- l(p);
912
+ (p, u) => {
913
+ d(u);
950
914
  }
951
915
  );
952
916
  return () => {
953
- o.setComponentMountedState(!1), f(), o.active || l({ messages: [], typingActors: [], loading: !1 });
917
+ o.setComponentMountedState(!1), m(), o.active || d({ messages: [], typingActors: [], loading: !1 });
954
918
  };
955
919
  }),
956
920
  { reuseController: !0 }
957
- )), Ae = (r) => Promise.all([
958
- Q.getInstance(r),
959
- C.getInstance(r),
960
- r.getAsync("router")
921
+ )), we = (n) => Promise.all([
922
+ Q.getInstance(n),
923
+ S.getInstance(n),
924
+ n.getAsync("router")
961
925
  ]).then(
962
- ([e, t, s]) => q(
963
- r,
926
+ ([e, t, s]) => U(
927
+ n,
964
928
  "conversation-return-button",
965
- import("./return-button.fb63a16e.js"),
966
- (i) => {
967
- i.actions.create("toggle", (n = {}) => {
929
+ import("./return-button-17ecf4af.js"),
930
+ (r) => {
931
+ r.actions.create("toggle", (i = {}) => {
968
932
  var a;
969
933
  (a = t.getComponentRoute()) == null || a.then((o) => {
970
934
  o && s.navigate(o.name, o.params);
@@ -973,24 +937,24 @@ const he = (r, e) => r.reduce((t, s, i) => {
973
937
  }
974
938
  )
975
939
  );
976
- var le = /* @__PURE__ */ ((r) => (r.LinkList = "link-list", r.Separator = "separator", r.ButtonList = "button-list", r.ItemList = "item-list", r.Text = "text", r.HTML = "html", r.VideoRequest = "video-request", r))(le || {});
977
- const Pe = (r, e, t) => r.getAsync("componentResolver").then((s) => v(void 0, null, function* () {
978
- (yield C.getInstance(r)).addSubscription(
940
+ var de = /* @__PURE__ */ ((n) => (n.LinkList = "link-list", n.Separator = "separator", n.ButtonList = "button-list", n.ItemList = "item-list", n.Text = "text", n.HTML = "html", n.VideoRequest = "video-request", n))(de || {});
941
+ const Ae = (n, e, t) => n.getAsync("componentResolver").then((s) => g(void 0, null, function* () {
942
+ (yield S.getInstance(n)).addSubscription(
979
943
  s.registerComponent(
980
944
  e,
981
- Z(() => t)
945
+ X(() => t)
982
946
  )
983
947
  );
984
948
  }));
985
949
  export {
986
- we as ConversationComponent,
987
- oe as ConversationController,
988
- E as ConversationEndedBehavior,
989
- ne as ConversationEntry,
990
- le as ConversationMessageListItemType,
991
- S as ConversationMessageType,
992
- C as ConversationPlatform,
993
- Ae as ConversationReturnButtonComponent,
994
- Pe as registerCustomMessageComponent
950
+ be as ConversationComponent,
951
+ ne as ConversationController,
952
+ x as ConversationEndedBehavior,
953
+ ie as ConversationEntry,
954
+ de as ConversationMessageListItemType,
955
+ P as ConversationMessageType,
956
+ S as ConversationPlatform,
957
+ we as ConversationReturnButtonComponent,
958
+ Ae as registerCustomMessageComponent
995
959
  };
996
960
  //# sourceMappingURL=index.js.map