@enegelai/bot-widget 1.1.7 → 1.2.1

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.es.js CHANGED
@@ -1,9 +1,9 @@
1
- var pt = Object.defineProperty;
2
- var ht = (t, e, o) => e in t ? pt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
- var $ = (t, e, o) => (ht(t, typeof e != "symbol" ? e + "" : e, o), o);
4
- import { css as w, LitElement as le, html as l } from "lit";
5
- import { property as c, customElement as x, queryAll as ut, eventOptions as qe, query as Ce } from "lit/decorators.js";
6
- import { unsafeHTML as De } from "lit-html/directives/unsafe-html.js";
1
+ var st = Object.defineProperty;
2
+ var nt = (t, e, o) => e in t ? st(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var $ = (t, e, o) => (nt(t, typeof e != "symbol" ? e + "" : e, o), o);
4
+ import { css as v, LitElement as le, html as l, svg as Le } from "lit";
5
+ import { property as i, customElement as x, queryAll as it, eventOptions as Ve, query as _e } from "lit/decorators.js";
6
+ import { unsafeHTML as Z } from "lit-html/directives/unsafe-html.js";
7
7
  import "@shoelace-style/shoelace/dist/themes/light.css";
8
8
  import "@shoelace-style/shoelace/dist/themes/dark.css";
9
9
  import "@shoelace-style/shoelace/dist/components/button/button.js";
@@ -21,13 +21,14 @@ import "@shoelace-style/shoelace/dist/components/switch/switch.js";
21
21
  import "@shoelace-style/shoelace/dist/components/tooltip/tooltip.js";
22
22
  import "@shoelace-style/shoelace/dist/components/spinner/spinner.js";
23
23
  import "@shoelace-style/shoelace/dist/components/alert/alert.js";
24
- import { repeat as fe } from "lit/directives/repeat.js";
24
+ import { repeat as me } from "lit/directives/repeat.js";
25
25
  import { when as B } from "lit/directives/when.js";
26
- import { until as Ae } from "lit-html/directives/until.js";
27
- import bt from "markdown-it";
28
- import gt from "markdown-it-link-attributes";
29
- import ge from "highlight.js";
30
- function Fe(t) {
26
+ import { until as Oe } from "lit-html/directives/until.js";
27
+ import lt from "markdown-it";
28
+ import * as ct from "markdown-it-emoji";
29
+ import dt from "markdown-it-link-attributes";
30
+ import "@shoelace-style/shoelace/dist/components/popup/popup.js";
31
+ function qe(t) {
31
32
  return typeof t == "function" ? t() : t;
32
33
  }
33
34
  const ie = class ie extends Event {
@@ -35,28 +36,28 @@ const ie = class ie extends Event {
35
36
  * @param {string} key of the state that has changed
36
37
  * @param {unknown} value for the changed key
37
38
  */
38
- constructor(o, a, r) {
39
+ constructor(o, r, a) {
39
40
  super(ie.eventName, {
40
41
  cancelable: !1
41
42
  });
42
43
  $(this, "key");
43
44
  $(this, "state");
44
45
  $(this, "value");
45
- this.key = o, this.value = a, this.state = r;
46
+ this.key = o, this.value = r, this.state = a;
46
47
  }
47
48
  };
48
49
  $(ie, "eventName", "lit-state-changed");
49
- let E = ie;
50
- const mt = (t, e) => e !== t && (e === e || t === t);
51
- class G extends EventTarget {
50
+ let T = ie;
51
+ const pt = (t, e) => e !== t && (e === e || t === t);
52
+ class X extends EventTarget {
52
53
  constructor() {
53
54
  super();
54
55
  // hold a reference to hooks
55
56
  $(this, "hookMap", /* @__PURE__ */ new Map());
56
- this.constructor.finalize(), this.propertyMap && [...this.propertyMap].forEach(([o, a]) => {
57
- if (a.initialValue !== void 0) {
58
- const r = Fe(a.initialValue);
59
- this[o] = r, a.value = r;
57
+ this.constructor.finalize(), this.propertyMap && [...this.propertyMap].forEach(([o, r]) => {
58
+ if (r.initialValue !== void 0) {
59
+ const a = qe(r.initialValue);
60
+ this[o] = a, r.value = a;
60
61
  }
61
62
  });
62
63
  }
@@ -71,24 +72,24 @@ class G extends EventTarget {
71
72
  return !1;
72
73
  this.finalized = !0;
73
74
  const o = Object.keys(this.properties || {});
74
- for (const a of o)
75
- this.createProperty(a, this.properties[a]);
75
+ for (const r of o)
76
+ this.createProperty(r, this.properties[r]);
76
77
  return !0;
77
78
  }
78
- static createProperty(o, a) {
79
+ static createProperty(o, r) {
79
80
  this.finalize();
80
- const r = typeof o == "symbol" ? Symbol() : `__${o}`, s = this.getPropertyDescriptor(o, r, a);
81
+ const a = typeof o == "symbol" ? Symbol() : `__${o}`, s = this.getPropertyDescriptor(o, a, r);
81
82
  Object.defineProperty(this.prototype, o, s);
82
83
  }
83
- static getPropertyDescriptor(o, a, r) {
84
- const s = (r == null ? void 0 : r.hasChanged) || mt;
84
+ static getPropertyDescriptor(o, r, a) {
85
+ const s = (a == null ? void 0 : a.hasChanged) || pt;
85
86
  return {
86
87
  get() {
87
- return this[a];
88
+ return this[r];
88
89
  },
89
90
  set(n) {
90
- const i = this[o];
91
- this[a] = n, s(n, i) === !0 && this.dispatchStateEvent(o, n, this);
91
+ const c = this[o];
92
+ this[r] = n, s(n, c) === !0 && this.dispatchStateEvent(o, n, this);
92
93
  },
93
94
  configurable: !0,
94
95
  enumerable: !0
@@ -99,8 +100,8 @@ class G extends EventTarget {
99
100
  * properties marked as skipReset
100
101
  */
101
102
  reset() {
102
- this.hookMap.forEach((o) => o.reset()), [...this.propertyMap].filter(([o, a]) => !(a.skipReset === !0 || a.resetValue === void 0)).forEach(([o, a]) => {
103
- this[o] = a.resetValue;
103
+ this.hookMap.forEach((o) => o.reset()), [...this.propertyMap].filter(([o, r]) => !(r.skipReset === !0 || r.resetValue === void 0)).forEach(([o, r]) => {
104
+ this[o] = r.resetValue;
104
105
  });
105
106
  }
106
107
  /**
@@ -111,31 +112,31 @@ class G extends EventTarget {
111
112
  * @param nameOrNames
112
113
  * @returns a unsubscribe function.
113
114
  */
114
- subscribe(o, a, r) {
115
- a && !Array.isArray(a) && (a = [a]);
115
+ subscribe(o, r, a) {
116
+ r && !Array.isArray(r) && (r = [r]);
116
117
  const s = (n) => {
117
- (!a || a.includes(n.key)) && o(n.key, n.value, this);
118
+ (!r || r.includes(n.key)) && o(n.key, n.value, this);
118
119
  };
119
- return this.addEventListener(E.eventName, s, r), () => this.removeEventListener(E.eventName, s);
120
+ return this.addEventListener(T.eventName, s, a), () => this.removeEventListener(T.eventName, s);
120
121
  }
121
- dispatchStateEvent(o, a, r) {
122
- this.dispatchEvent(new E(o, a, r));
122
+ dispatchStateEvent(o, r, a) {
123
+ this.dispatchEvent(new T(o, r, a));
123
124
  }
124
125
  }
125
126
  // a map holding decorators definition.
126
- $(G, "propertyMap"), $(G, "properties"), $(G, "finalized", !1);
127
- class ft {
128
- constructor(e, o, a) {
127
+ $(X, "propertyMap"), $(X, "properties"), $(X, "finalized", !1);
128
+ class ht {
129
+ constructor(e, o, r) {
129
130
  $(this, "host");
130
131
  $(this, "state");
131
132
  $(this, "callback");
132
- this.host = e, this.state = o, this.host.addController(this), this.callback = a || (() => this.host.requestUpdate());
133
+ this.host = e, this.state = o, this.host.addController(this), this.callback = r || (() => this.host.requestUpdate());
133
134
  }
134
135
  hostConnected() {
135
- this.state.addEventListener(E.eventName, this.callback), this.callback();
136
+ this.state.addEventListener(T.eventName, this.callback), this.callback();
136
137
  }
137
138
  hostDisconnected() {
138
- this.state.removeEventListener(E.eventName, this.callback);
139
+ this.state.removeEventListener(T.eventName, this.callback);
139
140
  }
140
141
  }
141
142
  /**
@@ -143,21 +144,21 @@ class ft {
143
144
  * Copyright 2017 Google LLC
144
145
  * SPDX-License-Identifier: BSD-3-Clause
145
146
  */
146
- const Ze = ({ finisher: t, descriptor: e }) => (o, a) => {
147
- var r;
148
- if (a === void 0) {
149
- const s = (r = o.originalKey) !== null && r !== void 0 ? r : o.key, n = e != null ? { kind: "method", placement: "prototype", key: s, descriptor: e(o.key) } : { ...o, key: s };
150
- return t != null && (n.finisher = function(i) {
151
- t(i, s);
147
+ const De = ({ finisher: t, descriptor: e }) => (o, r) => {
148
+ var a;
149
+ if (r === void 0) {
150
+ const s = (a = o.originalKey) !== null && a !== void 0 ? a : o.key, n = e != null ? { kind: "method", placement: "prototype", key: s, descriptor: e(o.key) } : { ...o, key: s };
151
+ return t != null && (n.finisher = function(c) {
152
+ t(c, s);
152
153
  }), n;
153
154
  }
154
155
  {
155
156
  const s = o.constructor;
156
- e !== void 0 && Object.defineProperty(o, a, e(a)), t == null || t(s, a);
157
+ e !== void 0 && Object.defineProperty(o, r, e(r)), t == null || t(s, r);
157
158
  }
158
159
  };
159
160
  function I(t) {
160
- return Ze({
161
+ return De({
161
162
  // @ts-ignore ctor is typof State and not typeof ReactiveElement
162
163
  finisher: (e, o) => {
163
164
  if (Object.getOwnPropertyDescriptor(e.prototype, o))
@@ -166,7 +167,7 @@ function I(t) {
166
167
  }
167
168
  });
168
169
  }
169
- function yt(t, e) {
170
+ function ut(t, e) {
170
171
  if (t !== null && (e === Boolean || e === Number || e === Array || e === Object))
171
172
  try {
172
173
  t = JSON.parse(t);
@@ -176,96 +177,96 @@ function yt(t, e) {
176
177
  return t;
177
178
  }
178
179
  new URL(window.location.href);
179
- const vt = {
180
+ const gt = {
180
181
  prefix: "_ls"
181
182
  };
182
183
  function D(t) {
183
- return t = { ...vt, ...t }, Ze({
184
+ return t = { ...gt, ...t }, De({
184
185
  // @ts-ignore ctor is typof State and not typeof ReactiveElement
185
186
  finisher: (e, o) => {
186
- const a = Object.getOwnPropertyDescriptor(e.prototype, o);
187
- if (!a)
187
+ const r = Object.getOwnPropertyDescriptor(e.prototype, o);
188
+ if (!r)
188
189
  throw new Error("@local-storage decorator need to be called after @property");
189
- const r = `${(t == null ? void 0 : t.prefix) || ""}_${(t == null ? void 0 : t.key) || String(o)}`, s = e.propertyMap.get(o), n = s == null ? void 0 : s.type;
190
+ const a = `${(t == null ? void 0 : t.prefix) || ""}_${(t == null ? void 0 : t.key) || String(o)}`, s = e.propertyMap.get(o), n = s == null ? void 0 : s.type;
190
191
  if (s) {
191
- const m = s.initialValue;
192
- s.initialValue = () => yt(localStorage.getItem(r), n) ?? Fe(m), e.propertyMap.set(o, { ...s, ...t });
192
+ const _ = s.initialValue;
193
+ s.initialValue = () => ut(localStorage.getItem(a), n) ?? qe(_), e.propertyMap.set(o, { ...s, ...t });
193
194
  }
194
- const i = a == null ? void 0 : a.set, g = {
195
- ...a,
196
- set: function(m) {
197
- m !== void 0 && localStorage.setItem(r, n === Object || n === Array ? JSON.stringify(m) : m), i && i.call(this, m);
195
+ const c = r == null ? void 0 : r.set, w = {
196
+ ...r,
197
+ set: function(_) {
198
+ _ !== void 0 && localStorage.setItem(a, n === Object || n === Array ? JSON.stringify(_) : _), c && c.call(this, _);
198
199
  }
199
200
  };
200
- Object.defineProperty(e.prototype, o, g);
201
+ Object.defineProperty(e.prototype, o, w);
201
202
  }
202
203
  });
203
204
  }
204
- var wt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
205
- function xt(t) {
205
+ var bt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
206
+ function mt(t) {
206
207
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
207
208
  }
208
- var Ue = { exports: {} };
209
+ var Fe = { exports: {} };
209
210
  (function(t) {
210
211
  (function(e, o) {
211
212
  t.exports ? t.exports = o() : e.log = o();
212
- })(wt, function() {
213
+ })(bt, function() {
213
214
  var e = function() {
214
- }, o = "undefined", a = typeof window !== o && typeof window.navigator !== o && /Trident\/|MSIE /.test(window.navigator.userAgent), r = [
215
+ }, o = "undefined", r = typeof window !== o && typeof window.navigator !== o && /Trident\/|MSIE /.test(window.navigator.userAgent), a = [
215
216
  "trace",
216
217
  "debug",
217
218
  "info",
218
219
  "warn",
219
220
  "error"
220
221
  ];
221
- function s(h, f) {
222
- var y = h[f];
223
- if (typeof y.bind == "function")
224
- return y.bind(h);
222
+ function s(h, b) {
223
+ var f = h[b];
224
+ if (typeof f.bind == "function")
225
+ return f.bind(h);
225
226
  try {
226
- return Function.prototype.bind.call(y, h);
227
+ return Function.prototype.bind.call(f, h);
227
228
  } catch {
228
229
  return function() {
229
- return Function.prototype.apply.apply(y, [h, arguments]);
230
+ return Function.prototype.apply.apply(f, [h, arguments]);
230
231
  };
231
232
  }
232
233
  }
233
234
  function n() {
234
235
  console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
235
236
  }
236
- function i(h) {
237
- return h === "debug" && (h = "log"), typeof console === o ? !1 : h === "trace" && a ? n : console[h] !== void 0 ? s(console, h) : console.log !== void 0 ? s(console, "log") : e;
237
+ function c(h) {
238
+ return h === "debug" && (h = "log"), typeof console === o ? !1 : h === "trace" && r ? n : console[h] !== void 0 ? s(console, h) : console.log !== void 0 ? s(console, "log") : e;
238
239
  }
239
- function u(h, f) {
240
- for (var y = 0; y < r.length; y++) {
241
- var p = r[y];
242
- this[p] = y < h ? e : this.methodFactory(p, h, f);
240
+ function g(h, b) {
241
+ for (var f = 0; f < a.length; f++) {
242
+ var p = a[f];
243
+ this[p] = f < h ? e : this.methodFactory(p, h, b);
243
244
  }
244
245
  this.log = this.debug;
245
246
  }
246
- function g(h, f, y) {
247
+ function w(h, b, f) {
247
248
  return function() {
248
- typeof console !== o && (u.call(this, f, y), this[h].apply(this, arguments));
249
+ typeof console !== o && (g.call(this, b, f), this[h].apply(this, arguments));
249
250
  };
250
251
  }
251
- function m(h, f, y) {
252
- return i(h) || g.apply(this, arguments);
252
+ function _(h, b, f) {
253
+ return c(h) || w.apply(this, arguments);
253
254
  }
254
- function he(h, f, y) {
255
- var p = this, Oe;
256
- f = f ?? "WARN";
255
+ function he(h, b, f) {
256
+ var p = this, Ae;
257
+ b = b ?? "WARN";
257
258
  var M = "loglevel";
258
259
  typeof h == "string" ? M += ":" + h : typeof h == "symbol" && (M = void 0);
259
- function lt(d) {
260
- var P = (r[d] || "silent").toUpperCase();
260
+ function ot(d) {
261
+ var E = (a[d] || "silent").toUpperCase();
261
262
  if (!(typeof window === o || !M)) {
262
263
  try {
263
- window.localStorage[M] = P;
264
+ window.localStorage[M] = E;
264
265
  return;
265
266
  } catch {
266
267
  }
267
268
  try {
268
- window.document.cookie = encodeURIComponent(M) + "=" + P + ";";
269
+ window.document.cookie = encodeURIComponent(M) + "=" + E + ";";
269
270
  } catch {
270
271
  }
271
272
  }
@@ -279,16 +280,16 @@ var Ue = { exports: {} };
279
280
  }
280
281
  if (typeof d === o)
281
282
  try {
282
- var P = window.document.cookie, J = P.indexOf(
283
+ var E = window.document.cookie, Y = E.indexOf(
283
284
  encodeURIComponent(M) + "="
284
285
  );
285
- J !== -1 && (d = /^([^;]+)/.exec(P.slice(J))[1]);
286
+ Y !== -1 && (d = /^([^;]+)/.exec(E.slice(Y))[1]);
286
287
  } catch {
287
288
  }
288
289
  return p.levels[d] === void 0 && (d = void 0), d;
289
290
  }
290
291
  }
291
- function ct() {
292
+ function rt() {
292
293
  if (!(typeof window === o || !M)) {
293
294
  try {
294
295
  window.localStorage.removeItem(M);
@@ -308,47 +309,47 @@ var Ue = { exports: {} };
308
309
  WARN: 3,
309
310
  ERROR: 4,
310
311
  SILENT: 5
311
- }, p.methodFactory = y || m, p.getLevel = function() {
312
- return Oe;
313
- }, p.setLevel = function(d, P) {
312
+ }, p.methodFactory = f || _, p.getLevel = function() {
313
+ return Ae;
314
+ }, p.setLevel = function(d, E) {
314
315
  if (typeof d == "string" && p.levels[d.toUpperCase()] !== void 0 && (d = p.levels[d.toUpperCase()]), typeof d == "number" && d >= 0 && d <= p.levels.SILENT) {
315
- if (Oe = d, P !== !1 && lt(d), u.call(p, d, h), typeof console === o && d < p.levels.SILENT)
316
+ if (Ae = d, E !== !1 && ot(d), g.call(p, d, h), typeof console === o && d < p.levels.SILENT)
316
317
  return "No console available for logging";
317
318
  } else
318
319
  throw "log.setLevel() called with invalid level: " + d;
319
320
  }, p.setDefaultLevel = function(d) {
320
- f = d, He() || p.setLevel(d, !1);
321
+ b = d, He() || p.setLevel(d, !1);
321
322
  }, p.resetLevel = function() {
322
- p.setLevel(f, !1), ct();
323
+ p.setLevel(b, !1), rt();
323
324
  }, p.enableAll = function(d) {
324
325
  p.setLevel(p.levels.TRACE, d);
325
326
  }, p.disableAll = function(d) {
326
327
  p.setLevel(p.levels.SILENT, d);
327
328
  };
328
- var be = He();
329
- be == null && (be = f), p.setLevel(be, !1);
329
+ var ge = He();
330
+ ge == null && (ge = b), p.setLevel(ge, !1);
330
331
  }
331
332
  var j = new he(), ue = {};
332
- j.getLogger = function(f) {
333
- if (typeof f != "symbol" && typeof f != "string" || f === "")
333
+ j.getLogger = function(b) {
334
+ if (typeof b != "symbol" && typeof b != "string" || b === "")
334
335
  throw new TypeError("You must supply a name when creating a logger.");
335
- var y = ue[f];
336
- return y || (y = ue[f] = new he(
337
- f,
336
+ var f = ue[b];
337
+ return f || (f = ue[b] = new he(
338
+ b,
338
339
  j.getLevel(),
339
340
  j.methodFactory
340
- )), y;
341
+ )), f;
341
342
  };
342
- var it = typeof window !== o ? window.log : void 0;
343
+ var tt = typeof window !== o ? window.log : void 0;
343
344
  return j.noConflict = function() {
344
- return typeof window !== o && window.log === j && (window.log = it), j;
345
+ return typeof window !== o && window.log === j && (window.log = tt), j;
345
346
  }, j.getLoggers = function() {
346
347
  return ue;
347
348
  }, j.default = j, j;
348
349
  });
349
- })(Ue);
350
- var kt = Ue.exports;
351
- const ce = /* @__PURE__ */ xt(kt), _t = w`
350
+ })(Fe);
351
+ var yt = Fe.exports;
352
+ const ce = /* @__PURE__ */ mt(yt), ft = v`
352
353
  :host {
353
354
  }
354
355
  .cb-wrapper {
@@ -415,7 +416,7 @@ const ce = /* @__PURE__ */ xt(kt), _t = w`
415
416
  border-radius: 0;
416
417
  }
417
418
  }
418
- `, S = w`
419
+ `, H = v`
419
420
  :host {
420
421
  --primary-color: var(--sl-color-primary-600);
421
422
  }
@@ -475,8 +476,8 @@ const ce = /* @__PURE__ */ xt(kt), _t = w`
475
476
  .text-button:hover {
476
477
  text-decoration: underline;
477
478
  }
478
- `, Ne = w`
479
- ${S}
479
+ `, Ue = v`
480
+ ${H}
480
481
 
481
482
  :host {
482
483
  display: inline-flex;
@@ -498,217 +499,582 @@ const ce = /* @__PURE__ */ xt(kt), _t = w`
498
499
  color: white;
499
500
  }
500
501
  `;
501
- var Ct = Object.defineProperty, $t = Object.getOwnPropertyDescriptor, $e = (t, e, o, a) => {
502
- for (var r = a > 1 ? void 0 : a ? $t(e, o) : e, s = t.length - 1, n; s >= 0; s--)
503
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
504
- return a && r && Ct(e, o, r), r;
502
+ var vt = Object.defineProperty, wt = Object.getOwnPropertyDescriptor, Ce = (t, e, o, r) => {
503
+ for (var a = r > 1 ? void 0 : r ? wt(e, o) : e, s = t.length - 1, n; s >= 0; s--)
504
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
505
+ return r && a && vt(e, o, a), a;
505
506
  };
506
- let U = class extends le {
507
+ let N = class extends le {
507
508
  constructor() {
508
509
  super(...arguments), this.color = "primary", this.svg = "";
509
510
  }
510
511
  render() {
511
512
  return l`<span class="cb-icon color-${this.color}" part="base"
512
- >${De(this.svg)}</span
513
+ >${Z(this.svg)}</span
513
514
  >`;
514
515
  }
515
516
  };
516
- U.styles = Ne;
517
- $e([
518
- c({ type: String })
519
- ], U.prototype, "color", 2);
520
- $e([
521
- c({ type: String })
522
- ], U.prototype, "svg", 2);
523
- U = $e([
517
+ N.styles = Ue;
518
+ Ce([
519
+ i({ type: String })
520
+ ], N.prototype, "color", 2);
521
+ Ce([
522
+ i({ type: String })
523
+ ], N.prototype, "svg", 2);
524
+ N = Ce([
524
525
  x("cb-icon")
525
- ], U);
526
- const jt = w`
527
- ${S}
528
- :host {
529
- position: relative;
530
- font-weight: bold;
531
- font-size: 16px;
532
- line-height: 2rem;
533
- padding: 10px;
534
- box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
535
- width: 100%;
536
- text-align: left;
537
- color: rgba(255, 255, 255, 1);
538
- border-radius-top-left: 6px;
539
- border-radius-top-right: 6px;
540
- top: 0;
541
- box-sizing: border-box;
542
-
543
- //background: var(--primary-color);
544
- background: rgb(0, 208, 117);
545
-
546
- // position: fixed;
547
- // z-index: 100;
548
- // top: 0;
526
+ ], N);
527
+ let xt = (t) => crypto.getRandomValues(new Uint8Array(t)), kt = (t, e, o) => {
528
+ let r = (2 << Math.log(t.length - 1) / Math.LN2) - 1, a = -~(1.6 * r * e / t.length);
529
+ return (s = e) => {
530
+ let n = "";
531
+ for (; ; ) {
532
+ let c = o(a), g = a;
533
+ for (; g--; )
534
+ if (n += t[c[g] & r] || "", n.length === s)
535
+ return n;
549
536
  }
550
-
551
- .cb-header {
552
- display: flex;
553
- flex-direction: row;
554
- justify-content: space-between;
555
- align-items: center;
556
- position: relative;
537
+ };
538
+ }, _t = (t, e = 21) => kt(t, e, xt);
539
+ const Ct = _t("1234567890abcdefghijklmnopqrstuvwxyz", 10);
540
+ function ye(t = 10) {
541
+ return Ct(t);
542
+ }
543
+ function $t(t) {
544
+ return new Promise((e, o) => {
545
+ try {
546
+ navigator.clipboard.writeText(t).then(() => {
547
+ e(t);
548
+ });
549
+ } catch (r) {
550
+ o(r);
557
551
  }
558
-
559
- .title {
560
- justify-items: center;
552
+ });
553
+ }
554
+ function jt(t = !0) {
555
+ return new Promise((e) => {
556
+ const o = document.createElement("input");
557
+ o.type = "file", t && (o.multiple = !0), o.style.display = "none", o.addEventListener("change", () => {
558
+ const r = Array.prototype.slice.call(o.files);
559
+ e(r);
560
+ }), o.click();
561
+ });
562
+ }
563
+ const k = ce.noConflict();
564
+ k.setLevel("info");
565
+ class Mt {
566
+ constructor(e = {}) {
567
+ this.id = 0, this.url = (e == null ? void 0 : e.url) || null, this.orgId = (e == null ? void 0 : e.orgId) || null, this.botId = (e == null ? void 0 : e.botId) || null, this.convId = (e == null ? void 0 : e.convId) || null, this._options = e || {}, this._ws = null, this.started = !1, this.connected = !1, this.onMessage = (e == null ? void 0 : e.onMessage) || null, this.queue = [], this.pause = (o) => new Promise((r) => setTimeout(r, o)), k.info(`WSC: Created, url: ${this.url}`);
568
+ }
569
+ connect(e = {}) {
570
+ if (this.url = (e == null ? void 0 : e.url) || this.url, this.connected = !1, !this.url)
571
+ return k.error("WSC: URL must be provided to connect"), null;
572
+ const o = this.url;
573
+ k.info(`WSC: Connecting to ${o} ...`), this._ws = new WebSocket(o);
574
+ let r = setTimeout(() => {
575
+ k.error("WSC: connected message not received in time - terminating"), this._ws.close(), this._ws = null, this.connected = !1;
576
+ }, 15e3);
577
+ this._ws.onopen = () => {
578
+ k.info(`WSC: Connection to ${o} opened`);
579
+ }, this._ws.onmessage = (a) => {
580
+ let s = (a == null ? void 0 : a.data) || null;
581
+ if (!s)
582
+ return;
583
+ let n = null;
584
+ try {
585
+ n = JSON.parse(s);
586
+ } catch {
587
+ k.error(`Failed to parse message: ${s}`);
588
+ return;
589
+ }
590
+ (n == null ? void 0 : n.type) === "connected" && (k.info(`WS[${this.id}] Connected`), clearTimeout(r), this.connected = !0, this.sendQueuedMessages()), this.handleWscMessage(n);
591
+ }, this._ws.onerror = (a) => {
592
+ k.error("WSC: Socket error"), clearTimeout(r), this.connected = !1, this._ws = null;
593
+ }, this._ws.onclose = (a) => {
594
+ k.info(`WSC: Closed - code:${a.code}, reason:"${a.reason}"`), this.connected = !1, this._ws = null, this.reconnect();
595
+ };
596
+ }
597
+ reconnect() {
598
+ this.started && setTimeout(() => {
599
+ this.connect();
600
+ }, 1e3);
601
+ }
602
+ disconnect() {
603
+ if (!this._ws) {
604
+ k.info("WSC: already disconnected");
605
+ return;
561
606
  }
562
-
563
- .cb-setting-button {
564
- font-size: 1.5rem;
565
- color: white;
607
+ k.info("WSC: disconnect"), this._ws.close();
608
+ }
609
+ async start() {
610
+ this.started = !0, this.connect();
611
+ }
612
+ async stop() {
613
+ this.started = !1, this.disconnect();
614
+ }
615
+ // Attempt to connect, and reconnect if failed
616
+ async startOld() {
617
+ let e = 1, o = !0;
618
+ for (; o; ) {
619
+ if (k.info(`WSC: start: connecting, attempt ${e}`), await this.connect(), this.connected)
620
+ return k.info("WSC: connected"), !0;
621
+ e++, o = e <= 4, o && await this.pause(1e3);
566
622
  }
567
- `;
568
- var Mt = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, St = (t, e, o, a) => {
569
- for (var r = a > 1 ? void 0 : a ? Lt(e, o) : e, s = t.length - 1, n; s >= 0; s--)
570
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
571
- return a && r && Mt(e, o, r), r;
572
- };
573
- class C extends le {
574
- constructor() {
575
- super(...arguments), this.lang = "en";
623
+ return k.error(`WSC: start: failed to connect after ${e} attempts, exiting`), !1;
576
624
  }
577
- emit(e, o) {
578
- const a = new CustomEvent(e, {
579
- bubbles: !0,
580
- cancelable: !1,
581
- composed: !0,
582
- detail: {},
583
- ...o
584
- });
585
- return this.dispatchEvent(a), a;
625
+ handleWscMessage(e) {
626
+ this.onMessage && typeof this.onMessage == "function" && this.onMessage(e);
627
+ }
628
+ sendMessage(e) {
629
+ if (!this.connected) {
630
+ this.queue.push(JSON.stringify(e));
631
+ return;
632
+ }
633
+ this._ws.send(JSON.stringify(e));
634
+ }
635
+ sendQueuedMessages() {
636
+ if (Array.isArray(this.queue) && this.queue.length > 0)
637
+ for (let e = 0; e < this.queue.length; e++)
638
+ k.info("Sending queued message", this.queue[e]), this._ws.send(this.queue[e]);
639
+ this.queue = [];
586
640
  }
641
+ // Request assumes that response will be received.
642
+ // We wait for the response, and then return it.
643
+ // TODO Reconsider - disabled for now
644
+ /*
645
+ executeRequest(payload) {
646
+ return new Promise((resolve, reject) => {
647
+ if (!this._ws) {
648
+ logger.error(`WS[${this.id}]: _ws is NULL - exiting`);
649
+ resolve(null);
650
+ }
651
+
652
+ const id = `${this.idCounter++}`;
653
+ const req = Object.assign({ id: id }, payload);
654
+ this._ws.send(JSON.stringify(req));
655
+
656
+ // Setting up timeout for max time to wait for the response
657
+ let timerId = setTimeout(() => {
658
+ timerId = null;
659
+ logger.error(`WS[${this.id}]: Error: request timeout id:${id}, req:${JSON.stringify(req)}`);
660
+ reject(new Error(`WS[${this.id}]: Error: request timeout id:${id}, req:${JSON.stringify(req)}`));
661
+ }, 5000);
662
+ // Wait for response
663
+ this.once(`res-${id}`, (data) => {
664
+ logger.info(`WS: Response: ${id}: ${JSON.stringify(data)}`);
665
+ if (timerId) {
666
+ clearTimeout(timerId);
667
+ resolve(data);
668
+ }
669
+ });
670
+ });
671
+ }*/
587
672
  }
588
- St([
589
- c({ type: String })
590
- ], C.prototype, "lang", 2);
591
- const je = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8L2.146 2.854Z"/></svg>';
592
- var Ot = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, We = (t, e, o, a) => {
593
- for (var r = a > 1 ? void 0 : a ? Ht(e, o) : e, s = t.length - 1, n; s >= 0; s--)
594
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
595
- return a && r && Ot(e, o, r), r;
673
+ var St = Object.defineProperty, At = Object.getOwnPropertyDescriptor, z = (t, e, o, r) => {
674
+ for (var a = r > 1 ? void 0 : r ? At(e, o) : e, s = t.length - 1, n; s >= 0; s--)
675
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
676
+ return r && a && St(e, o, a), a;
596
677
  };
597
- const At = `<svg width="32" height="24" viewBox="0 0 32 24" fill="none" xmlns="http://www.w3.org/2000/svg">
598
- <g>
599
- <path fill-rule="evenodd" clip-rule="evenodd" d="M24.3481 14.0672C22.533 17.2743 20.3563 19.0776 15.6489 19.598C10.4618 20.1771 6.17492 16.8088 4.48156 14.2944C6.64105 15.0536 8.94167 15.3339 11.2218 15.1154C15.4497 14.7306 17.8624 13.0702 19.5927 10.3506C19.8546 9.94378 20.5629 8.66828 19.3234 8.23945C18.1871 7.84727 17.143 7.83627 16.3314 9.02014C15.0143 10.9517 13.4722 11.6921 10.2442 12.044C5.9425 12.5021 0.777569 9.67256 0.179913 10.2627C-0.889966 11.3182 2.58161 22.9224 15.3759 22.7795C19.9837 22.7281 23.2192 21.1668 26.2481 17.2816C26.9859 16.3396 26.7572 15.1961 25.9492 14.1222C25.4512 13.4587 24.7429 13.4111 24.3629 14.0818" fill="#FFFFFF"/>
600
- <path fill-rule="evenodd" clip-rule="evenodd" d="M27.7123 7.10689C29.4278 2.66462 27.7713 -0.131961 27.1368 -1.24653e-05C26.6203 0.11361 25.6611 3.03481 24.296 4.73548C19.7066 2.64629 16.8253 4.54489 16.8917 5.55283C16.9471 6.39217 20.7249 5.7874 24.2702 8.85154C28.0369 12.0953 28.1476 15.6102 29.2249 15.5956C30.0881 15.5956 31.9217 12.1759 27.7123 7.10689Z" fill="#FFFFFF"/>
601
- </g>
602
- </svg>`;
603
- let te = class extends C {
678
+ const S = ce.noConflict();
679
+ S.setLevel("info");
680
+ const F = "cb_";
681
+ class L extends X {
604
682
  constructor() {
605
- super(...arguments), this.title = "ChatBot";
606
- }
607
- render() {
608
- return l` <header class="cb-header" part="header">
609
- <span class="left">
610
- <sl-button
611
- @click=${this._clickHandler}
612
- class="cb-setting-button"
613
- variant="text"
614
- circle
615
- >
616
- <cb-icon color="white" svg="${At}"></cb-icon>
617
- </sl-button>
618
- </span>
619
- <span class="center title">${this.title}</span>
620
- <span class="right">
621
- <sl-button
622
- @click=${this._clickCloseHandler}
623
- class="cb-setting-button"
624
- variant="text"
625
- circle
626
- >
627
- <cb-icon color="white" svg="${je}"></cb-icon>
628
- </sl-button>
629
- </span>
630
- </header>`;
683
+ super(...arguments), this.actionIdCounter = 0, this.wsClient = null, this.replyMessage = null;
631
684
  }
632
- _clickHandler() {
633
- this.emit("setting:show");
685
+ // this is called at startup
686
+ setSetting(e) {
687
+ S.info("appState: Startup: setSetting", e), this.setting = e, this.initBot().catch((o) => {
688
+ S.info(`Exception during bot initialization: ${o.message}`);
689
+ });
634
690
  }
635
- _clickCloseHandler() {
636
- this.emit("chatbot:toggle", {
637
- detail: {
638
- open: !1
691
+ clearConversation() {
692
+ this.wsClient && (this.wsClient.stop().then(() => {
693
+ }), this.wsClient = null), this.conversationId = ye(), this.connectWs = "false", this.messages = [], this.actions = [], this.addMessage({
694
+ author: "assistant",
695
+ type: "text",
696
+ data: {
697
+ text: this.setting.welcomeMessage
639
698
  }
640
699
  });
641
700
  }
642
- };
643
- te.styles = jt;
644
- We([
645
- c({ type: String, attribute: "title" })
646
- ], te.prototype, "title", 2);
647
- te = We([
648
- x("cb-header")
649
- ], te);
650
- const Pt = w`
651
- ${S}
652
- .cb-footer {
653
- line-height: 60px;
654
- font-size: 16px;
655
- }
656
-
657
- .p-2 {
658
- padding: 0.5rem;
701
+ // set language
702
+ setLanguage(e) {
703
+ this.language = e;
704
+ }
705
+ // set theme
706
+ setTheme(e) {
707
+ this.theme = e;
708
+ }
709
+ async initBot() {
710
+ const o = `${this.setting.url.startsWith("localhost") ? "http" : "https"}://${this.setting.url}/api/bot/settings/${this.setting.orgId}/${this.setting.botId}`;
711
+ let r = null, a = null;
712
+ try {
713
+ r = await fetch(o, {
714
+ headers: {
715
+ "Access-Control-Allow-Origin": "null",
716
+ "X-Enegel-Signature": this.setting.botId
717
+ }
718
+ }), !r.ok || r.status !== 200 ? S.error(`Failed to get bot ${this.setting.botId} settings: ${r.status} ${r.statusText}`) : a = await r.json();
719
+ } catch (s) {
720
+ S.error(`Failed to get bot ${this.setting.botId} settings: ${s.message}`), a = null;
659
721
  }
660
-
661
- .link__item {
662
- color: var(--primary-color);
722
+ if (!a) {
723
+ S.error("No bot settings available - bot disabled"), this.disabled = !0;
724
+ return;
663
725
  }
664
- `;
665
- var zt = Object.defineProperty, Et = Object.getOwnPropertyDescriptor, Tt = (t, e, o, a) => {
666
- for (var r = a > 1 ? void 0 : a ? Et(e, o) : e, s = t.length - 1, n; s >= 0; s--)
667
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
668
- return a && r && zt(e, o, r), r;
669
- };
670
- let ye = class extends C {
671
- constructor() {
672
- super(...arguments), this.year = (/* @__PURE__ */ new Date()).getFullYear();
726
+ this.setting.welcomeMessage = (a == null ? void 0 : a.welcomeMessage) || "How can I help ?", Array.isArray(this.messages) && this.messages.length <= 0 && this.addMessage({
727
+ author: "assistant",
728
+ type: "text",
729
+ data: {
730
+ text: this.setting.welcomeMessage
731
+ }
732
+ }), this.connectWs === "true" && (S.info("appState: connectWs is true"), this.getWsClient().catch((s) => {
733
+ S.error(`Exception during ws client startup: ${s.message}`);
734
+ }));
673
735
  }
674
- render() {
675
- return l`
676
- <div class="cb-footer" part="footer">
677
- yugasun@${this.year}
678
- <a
679
- class="link__item underline"
680
- href="https://github.com/yugasun/chatbot"
681
- target="_blank"
682
- >
683
- Github
684
- </a>
685
- <span class="p-2"> | </span>
686
- <a
687
- class="link__item underline"
688
- href="https://lit.dev/"
689
- target="_blank"
690
- >
691
- Lit
692
- </a>
693
- <span class="p-2"> | </span>
694
- <a
695
- class="link__item underline"
696
- href="https://vitejs.dev"
697
- target="_blank"
698
- >
699
- Vite
700
- </a>
701
- </div>
702
- `;
736
+ // Lazy initialization: avoid connecting until we actually need to send something
737
+ // TODO Depending on state, start ws & connect immediately when initialized
738
+ // use case: page refresh in the middle of the conversation
739
+ async getWsClient() {
740
+ if (this.wsClient)
741
+ return this.wsClient;
742
+ const o = `${this.setting.url.startsWith("localhost") ? "ws" : "wss"}://${this.setting.url}/api/bot/connect/${this.setting.orgId}/${this.setting.botId}/${this.conversationId}`;
743
+ return S.info(`Initiating ws connection to ${o} ...`), this.wsClient = new Mt({
744
+ url: o,
745
+ orgId: this.setting.orgId,
746
+ botId: this.setting.botId,
747
+ convId: this.conversationId
748
+ }), await this.wsClient.start(), this.wsClient.onMessage = (r) => {
749
+ this.handleWscMessage(r);
750
+ }, this.wsClient;
703
751
  }
704
- };
705
- ye.styles = Pt;
706
- ye = Tt([
707
- x("cb-footer")
708
- ], ye);
709
- const It = w`
710
- ${S}
711
-
752
+ handleWscMessage(e) {
753
+ switch (e == null ? void 0 : e.type) {
754
+ case "message": {
755
+ if (this.replyMessage)
756
+ this.replyMessage.data.text = e.text, this.updateMessage(this.replyMessage, ""), this.replyMessage = null;
757
+ else {
758
+ const o = {
759
+ type: "text",
760
+ author: "assistant",
761
+ data: {
762
+ text: e.text
763
+ }
764
+ };
765
+ "userName" in e && (o.data.userName = e.userName, this.connectWs = "true"), "userAvatar" in e && (o.data.userAvatar = e.userAvatar, this.connectWs = "true");
766
+ const r = this.formatMessage(o);
767
+ this.messages = this.messages.concat([r]);
768
+ }
769
+ break;
770
+ }
771
+ case "message-chunk": {
772
+ this.replyMessage && (this.replyMessage = this.updateMessage(this.replyMessage, e.text));
773
+ break;
774
+ }
775
+ case "typing": {
776
+ this.replyMessage = {
777
+ author: "assistant",
778
+ type: "text",
779
+ isThinking: !0,
780
+ data: {
781
+ text: ""
782
+ }
783
+ }, this.addMessage(this.replyMessage);
784
+ break;
785
+ }
786
+ case "actions": {
787
+ this.addActions((e == null ? void 0 : e.actions) || []);
788
+ break;
789
+ }
790
+ }
791
+ }
792
+ addActions(e) {
793
+ if (Array.isArray(e) && e.length > 0) {
794
+ const o = e.map((r) => Object.assign(r, { internalId: this.actionIdCounter++ }));
795
+ this.actions = this.actions.concat(o);
796
+ }
797
+ }
798
+ removeAction(e) {
799
+ const o = this.actions.findIndex((r) => r.internalId === e);
800
+ if (o !== -1) {
801
+ this.actions.splice(o, 1);
802
+ const r = [];
803
+ this.actions = r.concat(this.actions);
804
+ }
805
+ }
806
+ async sendMessage(e) {
807
+ e = this.formatMessage(e), S.info("Send Message:", e), this.messages = this.messages.concat([e]);
808
+ const o = await this.getWsClient();
809
+ if (!o) {
810
+ S.error("Error - failed to obtain ws client"), this.replyMessage = null;
811
+ return;
812
+ }
813
+ o.sendMessage({
814
+ type: "message",
815
+ id: e.id,
816
+ text: e.data.text
817
+ });
818
+ }
819
+ // TODO revisit below
820
+ formatMessage(e) {
821
+ var o;
822
+ return e.id || (e.id = ye()), e.timestamp = Date.now(), e.author === "assistant" && (e.replyId = (o = this.messages[this.messages.length - 1]) == null ? void 0 : o.id), e;
823
+ }
824
+ // add message
825
+ addMessage(e) {
826
+ e = this.formatMessage(e), this.messages = this.messages.concat([e]);
827
+ }
828
+ addSystemMessage(e) {
829
+ this.addMessage({
830
+ type: "text",
831
+ author: "system",
832
+ data: {
833
+ text: e
834
+ }
835
+ });
836
+ }
837
+ // update message
838
+ updateMessage(e, o) {
839
+ const r = this.formatMessage(e);
840
+ return r.isThinking = !1, o && (r.data.text += o), this.messages = this.messages.map((a) => a.id === r.id ? r : a), r;
841
+ }
842
+ // remove message
843
+ removeMessage(e) {
844
+ this.messages = this.messages.filter((o) => o.id !== e);
845
+ }
846
+ // clear messages
847
+ clearMessages() {
848
+ this.messages = [];
849
+ }
850
+ }
851
+ z([
852
+ D({ prefix: F }),
853
+ I({ value: "en" })
854
+ ], L.prototype, "language", 2);
855
+ z([
856
+ D({ prefix: F }),
857
+ I({ value: "light" })
858
+ ], L.prototype, "theme", 2);
859
+ z([
860
+ D({ prefix: F }),
861
+ I({ value: "false" })
862
+ ], L.prototype, "connectWs", 2);
863
+ z([
864
+ D({ prefix: F }),
865
+ I({ value: ye() })
866
+ ], L.prototype, "conversationId", 2);
867
+ z([
868
+ D({ prefix: F }),
869
+ I({ type: Array, value: [] })
870
+ ], L.prototype, "messages", 2);
871
+ z([
872
+ I({
873
+ type: Array,
874
+ value: []
875
+ /*value: [
876
+ {
877
+ internalId: 1,
878
+ type: 'calendlyMeeting',
879
+ title: 'Book 1:1 meeting',
880
+ url: 'https://calendly.com/slava-sayko/1-1-meeting-with-sales?hide_gdpr_banner=1',
881
+ // TODO Any other properties
882
+ },
883
+ {
884
+ internalId: 2,
885
+ type: 'link',
886
+ title: 'Sign Up',
887
+ url: 'https://signup.ticketspice.com/',
888
+ // TODO Any other properties
889
+ },
890
+ ],*/
891
+ })
892
+ ], L.prototype, "actions", 2);
893
+ z([
894
+ I({ type: Boolean, value: !1 })
895
+ ], L.prototype, "disabled", 2);
896
+ z([
897
+ D({ prefix: F }),
898
+ I({
899
+ type: Object,
900
+ value: {
901
+ orgId: null,
902
+ botId: null,
903
+ url: null,
904
+ welcomeMessage: null
905
+ }
906
+ })
907
+ ], L.prototype, "setting", 2);
908
+ const m = new L(), Ht = v`
909
+ ${H}
910
+ :host {
911
+ position: relative;
912
+ font-weight: bold;
913
+ font-size: 16px;
914
+ line-height: 2rem;
915
+ padding: 10px;
916
+ box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
917
+ width: 100%;
918
+ text-align: left;
919
+ color: rgba(255, 255, 255, 1);
920
+ border-radius-top-left: 6px;
921
+ border-radius-top-right: 6px;
922
+ top: 0;
923
+ box-sizing: border-box;
924
+
925
+ //background: var(--primary-color);
926
+ background: var(--enegelai-bot-header-background, rgb(0, 208, 117));
927
+
928
+ // position: fixed;
929
+ // z-index: 100;
930
+ // top: 0;
931
+ }
932
+
933
+ .cb-header {
934
+ display: flex;
935
+ flex-direction: row;
936
+ justify-content: space-between;
937
+ align-items: center;
938
+ position: relative;
939
+ }
940
+
941
+ .title {
942
+ justify-items: center;
943
+ }
944
+
945
+ .cb-setting-button {
946
+ font-size: 1.5rem;
947
+ color: white;
948
+ }
949
+ `;
950
+ var Lt = Object.defineProperty, Ot = Object.getOwnPropertyDescriptor, Pt = (t, e, o, r) => {
951
+ for (var a = r > 1 ? void 0 : r ? Ot(e, o) : e, s = t.length - 1, n; s >= 0; s--)
952
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
953
+ return r && a && Lt(e, o, a), a;
954
+ };
955
+ class C extends le {
956
+ constructor() {
957
+ super(...arguments), this.lang = "en";
958
+ }
959
+ emit(e, o) {
960
+ const r = new CustomEvent(e, {
961
+ bubbles: !0,
962
+ cancelable: !1,
963
+ composed: !0,
964
+ detail: {},
965
+ ...o
966
+ });
967
+ return this.dispatchEvent(r), r;
968
+ }
969
+ }
970
+ Pt([
971
+ i({ type: String })
972
+ ], C.prototype, "lang", 2);
973
+ const $e = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8L2.146 2.854Z"/></svg>';
974
+ var It = Object.defineProperty, zt = Object.getOwnPropertyDescriptor, Ze = (t, e, o, r) => {
975
+ for (var a = r > 1 ? void 0 : r ? zt(e, o) : e, s = t.length - 1, n; s >= 0; s--)
976
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
977
+ return r && a && It(e, o, a), a;
978
+ };
979
+ let te = class extends C {
980
+ constructor() {
981
+ super(...arguments), this.title = "ChatBot";
982
+ }
983
+ render() {
984
+ return l` <header class="cb-header" part="header">
985
+ <span class="left">
986
+ <sl-button @click=${this._clickHandler} class="cb-setting-button" variant="text" circle>
987
+ <cb-icon color="white" svg="${m.setting.logoSvg}"></cb-icon>
988
+ </sl-button>
989
+ </span>
990
+ <span class="center title">${this.title}</span>
991
+ <span class="right">
992
+ <sl-button @click=${this._clickCloseHandler} class="cb-setting-button" variant="text" circle>
993
+ <cb-icon color="white" svg="${$e}"></cb-icon>
994
+ </sl-button>
995
+ </span>
996
+ </header>`;
997
+ }
998
+ _clickHandler() {
999
+ this.emit("setting:show");
1000
+ }
1001
+ _clickCloseHandler() {
1002
+ this.emit("chatbot:toggle", {
1003
+ detail: {
1004
+ open: !1
1005
+ }
1006
+ });
1007
+ }
1008
+ };
1009
+ te.styles = Ht;
1010
+ Ze([
1011
+ i({ type: String, attribute: "title" })
1012
+ ], te.prototype, "title", 2);
1013
+ te = Ze([
1014
+ x("cb-header")
1015
+ ], te);
1016
+ const Et = v`
1017
+ ${H}
1018
+ .cb-footer {
1019
+ line-height: 60px;
1020
+ font-size: 16px;
1021
+ }
1022
+
1023
+ .p-2 {
1024
+ padding: 0.5rem;
1025
+ }
1026
+
1027
+ .link__item {
1028
+ color: var(--primary-color);
1029
+ }
1030
+ `;
1031
+ var Tt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, Bt = (t, e, o, r) => {
1032
+ for (var a = r > 1 ? void 0 : r ? Rt(e, o) : e, s = t.length - 1, n; s >= 0; s--)
1033
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
1034
+ return r && a && Tt(e, o, a), a;
1035
+ };
1036
+ let fe = class extends C {
1037
+ constructor() {
1038
+ super(...arguments), this.year = (/* @__PURE__ */ new Date()).getFullYear();
1039
+ }
1040
+ render() {
1041
+ return l`
1042
+ <div class="cb-footer" part="footer">
1043
+ yugasun@${this.year}
1044
+ <a
1045
+ class="link__item underline"
1046
+ href="https://github.com/yugasun/chatbot"
1047
+ target="_blank"
1048
+ >
1049
+ Github
1050
+ </a>
1051
+ <span class="p-2"> | </span>
1052
+ <a
1053
+ class="link__item underline"
1054
+ href="https://lit.dev/"
1055
+ target="_blank"
1056
+ >
1057
+ Lit
1058
+ </a>
1059
+ <span class="p-2"> | </span>
1060
+ <a
1061
+ class="link__item underline"
1062
+ href="https://vitejs.dev"
1063
+ target="_blank"
1064
+ >
1065
+ Vite
1066
+ </a>
1067
+ </div>
1068
+ `;
1069
+ }
1070
+ };
1071
+ fe.styles = Et;
1072
+ fe = Bt([
1073
+ x("cb-footer")
1074
+ ], fe);
1075
+ const Vt = v`
1076
+ ${H}
1077
+
712
1078
  :host {
713
1079
  width: 100%;
714
1080
  height: 100%;
@@ -733,28 +1099,22 @@ const It = w`
733
1099
  }
734
1100
  */
735
1101
 
736
- /* total width */
1102
+ /*
737
1103
  :host::-webkit-scrollbar {
738
1104
  background-color: #fff;
739
1105
  width: 16px;
740
1106
  }
741
-
742
- /* background of the scrollbar except button or resizer */
743
1107
  :host::-webkit-scrollbar-track {
744
1108
  background-color: #fff;
745
1109
  }
746
-
747
- /* scrollbar itself */
748
1110
  :host::-webkit-scrollbar-thumb {
749
1111
  background-color: #babac0;
750
1112
  border-radius: 16px;
751
1113
  border: 4px solid #fff;
752
1114
  }
753
-
754
- /* set button(top and bottom of the scrollbar) */
755
1115
  :host::-webkit-scrollbar-button {
756
1116
  display: none;
757
- }
1117
+ }*/
758
1118
 
759
1119
  .cb-actions-list {
760
1120
  margin: 10px 0px 0px 0px;
@@ -808,17 +1168,17 @@ const It = w`
808
1168
  transition: background 0s;
809
1169
  }
810
1170
  `;
811
- var Rt = Object.defineProperty, Bt = Object.getOwnPropertyDescriptor, Vt = (t, e, o, a) => {
812
- for (var r = a > 1 ? void 0 : a ? Bt(e, o) : e, s = t.length - 1, n; s >= 0; s--)
813
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
814
- return a && r && Rt(e, o, r), r;
1171
+ var qt = Object.defineProperty, Dt = Object.getOwnPropertyDescriptor, Ft = (t, e, o, r) => {
1172
+ for (var a = r > 1 ? void 0 : r ? Dt(e, o) : e, s = t.length - 1, n; s >= 0; s--)
1173
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
1174
+ return r && a && qt(e, o, a), a;
815
1175
  };
816
1176
  let ve = class extends le {
817
1177
  render() {
818
1178
  return l` <div class="cb-thinking" style="color: rgb(34, 34, 34);"><span></span><span></span><span></span></div>`;
819
1179
  }
820
1180
  };
821
- ve.styles = w`
1181
+ ve.styles = v`
822
1182
  .cb-thinking {
823
1183
  text-align: center;
824
1184
  }
@@ -856,13 +1216,13 @@ ve.styles = w`
856
1216
  }
857
1217
  }
858
1218
  `;
859
- ve = Vt([
1219
+ ve = Ft([
860
1220
  x("cb-thinking")
861
1221
  ], ve);
862
- var qt = Object.defineProperty, Dt = Object.getOwnPropertyDescriptor, Ke = (t, e, o, a) => {
863
- for (var r = a > 1 ? void 0 : a ? Dt(e, o) : e, s = t.length - 1, n; s >= 0; s--)
864
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
865
- return a && r && qt(e, o, r), r;
1222
+ var Ut = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, Ne = (t, e, o, r) => {
1223
+ for (var a = r > 1 ? void 0 : r ? Zt(e, o) : e, s = t.length - 1, n; s >= 0; s--)
1224
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
1225
+ return r && a && Ut(e, o, a), a;
866
1226
  };
867
1227
  let oe = class extends C {
868
1228
  constructor() {
@@ -880,7 +1240,7 @@ let oe = class extends C {
880
1240
  </div>`;
881
1241
  }
882
1242
  };
883
- oe.styles = w`
1243
+ oe.styles = v`
884
1244
  .cb-uploading {
885
1245
  text-align: left;
886
1246
  }
@@ -898,14 +1258,14 @@ oe.styles = w`
898
1258
  margin-right: 5px;
899
1259
  }
900
1260
  `;
901
- Ke([
902
- c({ type: Array })
1261
+ Ne([
1262
+ i({ type: Array })
903
1263
  ], oe.prototype, "files", 2);
904
- oe = Ke([
1264
+ oe = Ne([
905
1265
  x("cb-uploading")
906
1266
  ], oe);
907
- const Ft = w`
908
- ${S}
1267
+ const Nt = v`
1268
+ ${H}
909
1269
  :host {
910
1270
  }
911
1271
 
@@ -925,12 +1285,12 @@ const Ft = w`
925
1285
  margin-right: 0.2em;
926
1286
  }
927
1287
  `;
928
- var Zt = Object.defineProperty, Ut = Object.getOwnPropertyDescriptor, Me = (t, e, o, a) => {
929
- for (var r = a > 1 ? void 0 : a ? Ut(e, o) : e, s = t.length - 1, n; s >= 0; s--)
930
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
931
- return a && r && Zt(e, o, r), r;
1288
+ var Wt = Object.defineProperty, Jt = Object.getOwnPropertyDescriptor, je = (t, e, o, r) => {
1289
+ for (var a = r > 1 ? void 0 : r ? Jt(e, o) : e, s = t.length - 1, n; s >= 0; s--)
1290
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
1291
+ return r && a && Wt(e, o, a), a;
932
1292
  };
933
- let N = class extends le {
1293
+ let W = class extends le {
934
1294
  constructor() {
935
1295
  super(...arguments), this.url = "", this.inverse = !1;
936
1296
  }
@@ -950,7 +1310,7 @@ let N = class extends le {
950
1310
  `;
951
1311
  }
952
1312
  };
953
- N.styles = w`
1313
+ W.styles = v`
954
1314
  :host {
955
1315
  --primary-color: var(--sl-color-primary-600);
956
1316
  }
@@ -975,31 +1335,31 @@ N.styles = w`
975
1335
  text-decoration: underline;
976
1336
  }
977
1337
  `;
978
- Me([
979
- c({ type: String })
980
- ], N.prototype, "url", 2);
981
- Me([
982
- c({ type: Boolean })
983
- ], N.prototype, "inverse", 2);
984
- N = Me([
1338
+ je([
1339
+ i({ type: String })
1340
+ ], W.prototype, "url", 2);
1341
+ je([
1342
+ i({ type: Boolean })
1343
+ ], W.prototype, "inverse", 2);
1344
+ W = je([
985
1345
  x("cb-external-link")
986
- ], N);
987
- const Nt = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2h-2v-1h2a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM1.928 15.849v-3.337h1.136v-.662H0v.662h1.134v3.337h.794Zm4.689-3.999h-.894L4.9 13.289h-.035l-.832-1.439h-.932l1.228 1.983l-1.24 2.016h.862l.853-1.415h.035l.85 1.415h.907l-1.253-1.992l1.274-2.007Zm1.93.662v3.337h-.794v-3.337H6.619v-.662h3.064v.662H8.546Z"/></svg>', Wt = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2h-1v-1h1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM1.6 11.85H0v3.999h.791v-1.342h.803c.287 0 .531-.057.732-.173c.203-.117.358-.275.463-.474a1.42 1.42 0 0 0 .161-.677c0-.25-.053-.476-.158-.677a1.176 1.176 0 0 0-.46-.477c-.2-.12-.443-.179-.732-.179Zm.545 1.333a.795.795 0 0 1-.085.38a.574.574 0 0 1-.238.241a.794.794 0 0 1-.375.082H.788V12.48h.66c.218 0 .389.06.512.181c.123.122.185.296.185.522Zm1.217-1.333v3.999h1.46c.401 0 .734-.08.998-.237a1.45 1.45 0 0 0 .595-.689c.13-.3.196-.662.196-1.084c0-.42-.065-.778-.196-1.075a1.426 1.426 0 0 0-.589-.68c-.264-.156-.599-.234-1.005-.234H3.362Zm.791.645h.563c.248 0 .45.05.609.152a.89.89 0 0 1 .354.454c.079.201.118.452.118.753a2.3 2.3 0 0 1-.068.592a1.14 1.14 0 0 1-.196.422a.8.8 0 0 1-.334.252a1.298 1.298 0 0 1-.483.082h-.563v-2.707Zm3.743 1.763v1.591h-.79V11.85h2.548v.653H7.896v1.117h1.606v.638H7.896Z"/></svg>', Kt = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2H9v-1h3a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM.706 13.189v2.66H0V11.85h.806l1.14 2.596h.026l1.14-2.596h.8v3.999h-.716v-2.66h-.038l-.946 2.159h-.516l-.952-2.16H.706Zm3.919 2.66V11.85h1.459c.406 0 .741.078 1.005.234c.263.157.46.383.589.68c.13.297.196.655.196 1.075c0 .422-.066.784-.196 1.084c-.131.301-.33.53-.595.689c-.264.158-.597.237-1 .237H4.626Zm1.353-3.354h-.562v2.707h.562c.186 0 .347-.028.484-.082a.8.8 0 0 0 .334-.252a1.14 1.14 0 0 0 .196-.422c.045-.168.067-.365.067-.592a2.1 2.1 0 0 0-.117-.753a.89.89 0 0 0-.354-.454c-.159-.102-.362-.152-.61-.152Z"/></svg>', Jt = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2h-1v-1h1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM3.517 14.841a1.13 1.13 0 0 0 .401.823c.13.108.289.192.478.252c.19.061.411.091.665.091c.338 0 .624-.053.859-.158c.236-.105.416-.252.539-.44c.125-.189.187-.408.187-.656c0-.224-.045-.41-.134-.56a1.001 1.001 0 0 0-.375-.357a2.027 2.027 0 0 0-.566-.21l-.621-.144a.97.97 0 0 1-.404-.176a.37.37 0 0 1-.144-.299c0-.156.062-.284.185-.384c.125-.101.296-.152.512-.152c.143 0 .266.023.37.068a.624.624 0 0 1 .246.181a.56.56 0 0 1 .12.258h.75a1.092 1.092 0 0 0-.2-.566a1.21 1.21 0 0 0-.5-.41a1.813 1.813 0 0 0-.78-.152c-.293 0-.551.05-.776.15c-.225.099-.4.24-.527.421c-.127.182-.19.395-.19.639c0 .201.04.376.122.524c.082.149.2.27.352.367c.152.095.332.167.539.213l.618.144c.207.049.361.113.463.193a.387.387 0 0 1 .152.326a.505.505 0 0 1-.085.29a.559.559 0 0 1-.255.193c-.111.047-.249.07-.413.07c-.117 0-.223-.013-.32-.04a.838.838 0 0 1-.248-.115a.578.578 0 0 1-.255-.384h-.765ZM.806 13.693c0-.248.034-.46.102-.633a.868.868 0 0 1 .302-.399a.814.814 0 0 1 .475-.137c.15 0 .283.032.398.097a.7.7 0 0 1 .272.26a.85.85 0 0 1 .12.381h.765v-.072a1.33 1.33 0 0 0-.466-.964a1.441 1.441 0 0 0-.489-.272a1.838 1.838 0 0 0-.606-.097c-.356 0-.66.074-.911.223c-.25.148-.44.359-.572.632c-.13.274-.196.6-.196.979v.498c0 .379.064.704.193.976c.131.271.322.48.572.626c.25.145.554.217.914.217c.293 0 .554-.055.785-.164c.23-.11.414-.26.55-.454a1.27 1.27 0 0 0 .226-.674v-.076h-.764a.799.799 0 0 1-.118.363a.7.7 0 0 1-.272.25a.874.874 0 0 1-.401.087a.845.845 0 0 1-.478-.132a.833.833 0 0 1-.299-.392a1.699 1.699 0 0 1-.102-.627v-.495Zm8.239 2.238h-.953l-1.338-3.999h.917l.896 3.138h.038l.888-3.138h.879l-1.327 4Z"/></svg>', Yt = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2h-1v-1h1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM1.6 11.85H0v3.999h.791v-1.342h.803c.287 0 .531-.057.732-.173c.203-.117.358-.275.463-.474a1.42 1.42 0 0 0 .161-.677c0-.25-.053-.476-.158-.677a1.176 1.176 0 0 0-.46-.477c-.2-.12-.443-.179-.732-.179Zm.545 1.333a.795.795 0 0 1-.085.38a.574.574 0 0 1-.238.241a.794.794 0 0 1-.375.082H.788V12.48h.66c.218 0 .389.06.512.181c.123.122.185.296.185.522Zm2.817-1.333h-1.6v3.999h.791v-1.342h.803c.287 0 .531-.057.732-.173c.203-.117.358-.275.463-.474c.108-.201.161-.427.161-.677c0-.25-.052-.476-.158-.677a1.176 1.176 0 0 0-.46-.477c-.2-.12-.443-.179-.732-.179Zm.545 1.333a.795.795 0 0 1-.085.38a.574.574 0 0 1-.238.241a.793.793 0 0 1-.375.082H4.15V12.48h.66c.218 0 .389.06.512.181c.123.122.185.296.185.522Zm2.767-.67v3.336H7.48v-3.337H6.346v-.662h3.065v.662H8.274Z"/></svg>', Gt = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2v-1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5Zm-7.839 9.166v.522c0 .256-.039.47-.117.641a.861.861 0 0 1-.322.387a.877.877 0 0 1-.469.126a.883.883 0 0 1-.471-.126a.868.868 0 0 1-.32-.386a1.55 1.55 0 0 1-.117-.642v-.522c0-.257.04-.471.117-.641a.868.868 0 0 1 .32-.387a.868.868 0 0 1 .471-.129c.176 0 .332.043.469.13a.861.861 0 0 1 .322.386c.078.17.117.384.117.641Zm.803.519v-.513c0-.377-.068-.7-.205-.972a1.46 1.46 0 0 0-.589-.63c-.254-.147-.56-.22-.917-.22c-.355 0-.662.073-.92.22a1.441 1.441 0 0 0-.589.627c-.136.271-.205.596-.205.975v.513c0 .375.069.7.205.973c.137.271.333.48.59.627c.257.144.564.216.92.216c.357 0 .662-.072.916-.216c.256-.147.452-.356.59-.627c.136-.274.204-.598.204-.973ZM0 11.926v4h1.459c.402 0 .735-.08.999-.238a1.45 1.45 0 0 0 .595-.689c.13-.3.196-.662.196-1.084c0-.42-.065-.778-.196-1.075a1.426 1.426 0 0 0-.59-.68c-.263-.156-.598-.234-1.004-.234H0Zm.791.645h.563c.248 0 .45.05.609.152a.89.89 0 0 1 .354.454c.079.201.118.452.118.753a2.3 2.3 0 0 1-.068.592a1.141 1.141 0 0 1-.196.422a.8.8 0 0 1-.334.252a1.298 1.298 0 0 1-.483.082H.79V12.57Zm7.422.483a1.732 1.732 0 0 0-.103.633v.495c0 .246.034.455.103.627a.834.834 0 0 0 .298.393a.845.845 0 0 0 .478.131a.868.868 0 0 0 .401-.088a.699.699 0 0 0 .273-.248a.8.8 0 0 0 .117-.364h.765v.076a1.268 1.268 0 0 1-.226.674c-.137.194-.32.345-.55.454a1.81 1.81 0 0 1-.786.164c-.36 0-.664-.072-.914-.216a1.424 1.424 0 0 1-.571-.627c-.13-.272-.194-.597-.194-.976v-.498c0-.379.066-.705.197-.978c.13-.274.321-.485.571-.633c.252-.149.556-.223.911-.223c.219 0 .421.032.607.097c.187.062.35.153.489.272a1.326 1.326 0 0 1 .466.964v.073H9.78a.85.85 0 0 0-.12-.38a.7.7 0 0 0-.273-.261a.802.802 0 0 0-.398-.097a.814.814 0 0 0-.475.138a.868.868 0 0 0-.301.398Z"/></svg>', Qt = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V11h-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5Zm-6.839 9.688v-.522a1.54 1.54 0 0 0-.117-.641a.861.861 0 0 0-.322-.387a.862.862 0 0 0-.469-.129a.868.868 0 0 0-.471.13a.868.868 0 0 0-.32.386a1.54 1.54 0 0 0-.117.641v.522c0 .256.04.47.117.641a.868.868 0 0 0 .32.387a.883.883 0 0 0 .471.126a.877.877 0 0 0 .469-.126a.861.861 0 0 0 .322-.386a1.55 1.55 0 0 0 .117-.642Zm.803-.516v.513c0 .375-.068.7-.205.973a1.47 1.47 0 0 1-.589.627c-.254.144-.56.216-.917.216a1.86 1.86 0 0 1-.92-.216a1.463 1.463 0 0 1-.589-.627a2.151 2.151 0 0 1-.205-.973v-.513c0-.379.069-.704.205-.975c.137-.274.333-.483.59-.627c.257-.147.564-.22.92-.22c.357 0 .662.073.916.22c.256.146.452.356.59.63c.136.271.204.595.204.972ZM1 15.925v-3.999h1.459c.406 0 .741.078 1.005.235c.264.156.46.382.589.68c.13.296.196.655.196 1.074c0 .422-.065.784-.196 1.084c-.131.301-.33.53-.595.689c-.264.158-.597.237-.999.237H1Zm1.354-3.354H1.79v2.707h.563c.185 0 .346-.028.483-.082a.8.8 0 0 0 .334-.252c.088-.114.153-.254.196-.422a2.3 2.3 0 0 0 .068-.592c0-.3-.04-.552-.118-.753a.89.89 0 0 0-.354-.454c-.158-.102-.361-.152-.61-.152Zm6.756 1.116c0-.248.034-.46.103-.633a.868.868 0 0 1 .301-.398a.814.814 0 0 1 .475-.138c.15 0 .283.032.398.097a.7.7 0 0 1 .273.26a.85.85 0 0 1 .12.381h.765v-.073a1.33 1.33 0 0 0-.466-.964a1.44 1.44 0 0 0-.49-.272a1.836 1.836 0 0 0-.606-.097c-.355 0-.66.074-.911.223c-.25.148-.44.359-.571.633c-.131.273-.197.6-.197.978v.498c0 .379.065.704.194.976c.13.271.321.48.571.627c.25.144.555.216.914.216c.293 0 .555-.054.785-.164c.23-.11.414-.26.551-.454a1.27 1.27 0 0 0 .226-.674v-.076h-.765a.8.8 0 0 1-.117.364a.699.699 0 0 1-.273.248a.874.874 0 0 1-.401.088a.845.845 0 0 1-.478-.131a.834.834 0 0 1-.298-.393a1.7 1.7 0 0 1-.103-.627v-.495Zm5.092-1.76h.894l-1.275 2.006l1.254 1.992h-.908l-.85-1.415h-.035l-.852 1.415h-.862l1.24-2.015l-1.228-1.984h.932l.832 1.439h.035l.823-1.439Z"/></svg>';
988
- var Xt = Object.defineProperty, eo = Object.getOwnPropertyDescriptor, Le = (t, e, o, a) => {
989
- for (var r = a > 1 ? void 0 : a ? eo(e, o) : e, s = t.length - 1, n; s >= 0; s--)
990
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
991
- return a && r && Xt(e, o, r), r;
1346
+ ], W);
1347
+ const Kt = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2h-2v-1h2a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM1.928 15.849v-3.337h1.136v-.662H0v.662h1.134v3.337h.794Zm4.689-3.999h-.894L4.9 13.289h-.035l-.832-1.439h-.932l1.228 1.983l-1.24 2.016h.862l.853-1.415h.035l.85 1.415h.907l-1.253-1.992l1.274-2.007Zm1.93.662v3.337h-.794v-3.337H6.619v-.662h3.064v.662H8.546Z"/></svg>', Yt = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2h-1v-1h1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM1.6 11.85H0v3.999h.791v-1.342h.803c.287 0 .531-.057.732-.173c.203-.117.358-.275.463-.474a1.42 1.42 0 0 0 .161-.677c0-.25-.053-.476-.158-.677a1.176 1.176 0 0 0-.46-.477c-.2-.12-.443-.179-.732-.179Zm.545 1.333a.795.795 0 0 1-.085.38a.574.574 0 0 1-.238.241a.794.794 0 0 1-.375.082H.788V12.48h.66c.218 0 .389.06.512.181c.123.122.185.296.185.522Zm1.217-1.333v3.999h1.46c.401 0 .734-.08.998-.237a1.45 1.45 0 0 0 .595-.689c.13-.3.196-.662.196-1.084c0-.42-.065-.778-.196-1.075a1.426 1.426 0 0 0-.589-.68c-.264-.156-.599-.234-1.005-.234H3.362Zm.791.645h.563c.248 0 .45.05.609.152a.89.89 0 0 1 .354.454c.079.201.118.452.118.753a2.3 2.3 0 0 1-.068.592a1.14 1.14 0 0 1-.196.422a.8.8 0 0 1-.334.252a1.298 1.298 0 0 1-.483.082h-.563v-2.707Zm3.743 1.763v1.591h-.79V11.85h2.548v.653H7.896v1.117h1.606v.638H7.896Z"/></svg>', Gt = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2H9v-1h3a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM.706 13.189v2.66H0V11.85h.806l1.14 2.596h.026l1.14-2.596h.8v3.999h-.716v-2.66h-.038l-.946 2.159h-.516l-.952-2.16H.706Zm3.919 2.66V11.85h1.459c.406 0 .741.078 1.005.234c.263.157.46.383.589.68c.13.297.196.655.196 1.075c0 .422-.066.784-.196 1.084c-.131.301-.33.53-.595.689c-.264.158-.597.237-1 .237H4.626Zm1.353-3.354h-.562v2.707h.562c.186 0 .347-.028.484-.082a.8.8 0 0 0 .334-.252a1.14 1.14 0 0 0 .196-.422c.045-.168.067-.365.067-.592a2.1 2.1 0 0 0-.117-.753a.89.89 0 0 0-.354-.454c-.159-.102-.362-.152-.61-.152Z"/></svg>', Xt = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2h-1v-1h1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM3.517 14.841a1.13 1.13 0 0 0 .401.823c.13.108.289.192.478.252c.19.061.411.091.665.091c.338 0 .624-.053.859-.158c.236-.105.416-.252.539-.44c.125-.189.187-.408.187-.656c0-.224-.045-.41-.134-.56a1.001 1.001 0 0 0-.375-.357a2.027 2.027 0 0 0-.566-.21l-.621-.144a.97.97 0 0 1-.404-.176a.37.37 0 0 1-.144-.299c0-.156.062-.284.185-.384c.125-.101.296-.152.512-.152c.143 0 .266.023.37.068a.624.624 0 0 1 .246.181a.56.56 0 0 1 .12.258h.75a1.092 1.092 0 0 0-.2-.566a1.21 1.21 0 0 0-.5-.41a1.813 1.813 0 0 0-.78-.152c-.293 0-.551.05-.776.15c-.225.099-.4.24-.527.421c-.127.182-.19.395-.19.639c0 .201.04.376.122.524c.082.149.2.27.352.367c.152.095.332.167.539.213l.618.144c.207.049.361.113.463.193a.387.387 0 0 1 .152.326a.505.505 0 0 1-.085.29a.559.559 0 0 1-.255.193c-.111.047-.249.07-.413.07c-.117 0-.223-.013-.32-.04a.838.838 0 0 1-.248-.115a.578.578 0 0 1-.255-.384h-.765ZM.806 13.693c0-.248.034-.46.102-.633a.868.868 0 0 1 .302-.399a.814.814 0 0 1 .475-.137c.15 0 .283.032.398.097a.7.7 0 0 1 .272.26a.85.85 0 0 1 .12.381h.765v-.072a1.33 1.33 0 0 0-.466-.964a1.441 1.441 0 0 0-.489-.272a1.838 1.838 0 0 0-.606-.097c-.356 0-.66.074-.911.223c-.25.148-.44.359-.572.632c-.13.274-.196.6-.196.979v.498c0 .379.064.704.193.976c.131.271.322.48.572.626c.25.145.554.217.914.217c.293 0 .554-.055.785-.164c.23-.11.414-.26.55-.454a1.27 1.27 0 0 0 .226-.674v-.076h-.764a.799.799 0 0 1-.118.363a.7.7 0 0 1-.272.25a.874.874 0 0 1-.401.087a.845.845 0 0 1-.478-.132a.833.833 0 0 1-.299-.392a1.699 1.699 0 0 1-.102-.627v-.495Zm8.239 2.238h-.953l-1.338-3.999h.917l.896 3.138h.038l.888-3.138h.879l-1.327 4Z"/></svg>', Qt = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2h-1v-1h1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5ZM1.6 11.85H0v3.999h.791v-1.342h.803c.287 0 .531-.057.732-.173c.203-.117.358-.275.463-.474a1.42 1.42 0 0 0 .161-.677c0-.25-.053-.476-.158-.677a1.176 1.176 0 0 0-.46-.477c-.2-.12-.443-.179-.732-.179Zm.545 1.333a.795.795 0 0 1-.085.38a.574.574 0 0 1-.238.241a.794.794 0 0 1-.375.082H.788V12.48h.66c.218 0 .389.06.512.181c.123.122.185.296.185.522Zm2.817-1.333h-1.6v3.999h.791v-1.342h.803c.287 0 .531-.057.732-.173c.203-.117.358-.275.463-.474c.108-.201.161-.427.161-.677c0-.25-.052-.476-.158-.677a1.176 1.176 0 0 0-.46-.477c-.2-.12-.443-.179-.732-.179Zm.545 1.333a.795.795 0 0 1-.085.38a.574.574 0 0 1-.238.241a.793.793 0 0 1-.375.082H4.15V12.48h.66c.218 0 .389.06.512.181c.123.122.185.296.185.522Zm2.767-.67v3.336H7.48v-3.337H6.346v-.662h3.065v.662H8.274Z"/></svg>', eo = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V14a2 2 0 0 1-2 2v-1a1 1 0 0 0 1-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5Zm-7.839 9.166v.522c0 .256-.039.47-.117.641a.861.861 0 0 1-.322.387a.877.877 0 0 1-.469.126a.883.883 0 0 1-.471-.126a.868.868 0 0 1-.32-.386a1.55 1.55 0 0 1-.117-.642v-.522c0-.257.04-.471.117-.641a.868.868 0 0 1 .32-.387a.868.868 0 0 1 .471-.129c.176 0 .332.043.469.13a.861.861 0 0 1 .322.386c.078.17.117.384.117.641Zm.803.519v-.513c0-.377-.068-.7-.205-.972a1.46 1.46 0 0 0-.589-.63c-.254-.147-.56-.22-.917-.22c-.355 0-.662.073-.92.22a1.441 1.441 0 0 0-.589.627c-.136.271-.205.596-.205.975v.513c0 .375.069.7.205.973c.137.271.333.48.59.627c.257.144.564.216.92.216c.357 0 .662-.072.916-.216c.256-.147.452-.356.59-.627c.136-.274.204-.598.204-.973ZM0 11.926v4h1.459c.402 0 .735-.08.999-.238a1.45 1.45 0 0 0 .595-.689c.13-.3.196-.662.196-1.084c0-.42-.065-.778-.196-1.075a1.426 1.426 0 0 0-.59-.68c-.263-.156-.598-.234-1.004-.234H0Zm.791.645h.563c.248 0 .45.05.609.152a.89.89 0 0 1 .354.454c.079.201.118.452.118.753a2.3 2.3 0 0 1-.068.592a1.141 1.141 0 0 1-.196.422a.8.8 0 0 1-.334.252a1.298 1.298 0 0 1-.483.082H.79V12.57Zm7.422.483a1.732 1.732 0 0 0-.103.633v.495c0 .246.034.455.103.627a.834.834 0 0 0 .298.393a.845.845 0 0 0 .478.131a.868.868 0 0 0 .401-.088a.699.699 0 0 0 .273-.248a.8.8 0 0 0 .117-.364h.765v.076a1.268 1.268 0 0 1-.226.674c-.137.194-.32.345-.55.454a1.81 1.81 0 0 1-.786.164c-.36 0-.664-.072-.914-.216a1.424 1.424 0 0 1-.571-.627c-.13-.272-.194-.597-.194-.976v-.498c0-.379.066-.705.197-.978c.13-.274.321-.485.571-.633c.252-.149.556-.223.911-.223c.219 0 .421.032.607.097c.187.062.35.153.489.272a1.326 1.326 0 0 1 .466.964v.073H9.78a.85.85 0 0 0-.12-.38a.7.7 0 0 0-.273-.261a.802.802 0 0 0-.398-.097a.814.814 0 0 0-.475.138a.868.868 0 0 0-.301.398Z"/></svg>', to = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" fill-rule="evenodd" d="M14 4.5V11h-1V4.5h-2A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v9H2V2a2 2 0 0 1 2-2h5.5L14 4.5Zm-6.839 9.688v-.522a1.54 1.54 0 0 0-.117-.641a.861.861 0 0 0-.322-.387a.862.862 0 0 0-.469-.129a.868.868 0 0 0-.471.13a.868.868 0 0 0-.32.386a1.54 1.54 0 0 0-.117.641v.522c0 .256.04.47.117.641a.868.868 0 0 0 .32.387a.883.883 0 0 0 .471.126a.877.877 0 0 0 .469-.126a.861.861 0 0 0 .322-.386a1.55 1.55 0 0 0 .117-.642Zm.803-.516v.513c0 .375-.068.7-.205.973a1.47 1.47 0 0 1-.589.627c-.254.144-.56.216-.917.216a1.86 1.86 0 0 1-.92-.216a1.463 1.463 0 0 1-.589-.627a2.151 2.151 0 0 1-.205-.973v-.513c0-.379.069-.704.205-.975c.137-.274.333-.483.59-.627c.257-.147.564-.22.92-.22c.357 0 .662.073.916.22c.256.146.452.356.59.63c.136.271.204.595.204.972ZM1 15.925v-3.999h1.459c.406 0 .741.078 1.005.235c.264.156.46.382.589.68c.13.296.196.655.196 1.074c0 .422-.065.784-.196 1.084c-.131.301-.33.53-.595.689c-.264.158-.597.237-.999.237H1Zm1.354-3.354H1.79v2.707h.563c.185 0 .346-.028.483-.082a.8.8 0 0 0 .334-.252c.088-.114.153-.254.196-.422a2.3 2.3 0 0 0 .068-.592c0-.3-.04-.552-.118-.753a.89.89 0 0 0-.354-.454c-.158-.102-.361-.152-.61-.152Zm6.756 1.116c0-.248.034-.46.103-.633a.868.868 0 0 1 .301-.398a.814.814 0 0 1 .475-.138c.15 0 .283.032.398.097a.7.7 0 0 1 .273.26a.85.85 0 0 1 .12.381h.765v-.073a1.33 1.33 0 0 0-.466-.964a1.44 1.44 0 0 0-.49-.272a1.836 1.836 0 0 0-.606-.097c-.355 0-.66.074-.911.223c-.25.148-.44.359-.571.633c-.131.273-.197.6-.197.978v.498c0 .379.065.704.194.976c.13.271.321.48.571.627c.25.144.555.216.914.216c.293 0 .555-.054.785-.164c.23-.11.414-.26.551-.454a1.27 1.27 0 0 0 .226-.674v-.076h-.765a.8.8 0 0 1-.117.364a.699.699 0 0 1-.273.248a.874.874 0 0 1-.401.088a.845.845 0 0 1-.478-.131a.834.834 0 0 1-.298-.393a1.7 1.7 0 0 1-.103-.627v-.495Zm5.092-1.76h.894l-1.275 2.006l1.254 1.992h-.908l-.85-1.415h-.035l-.852 1.415h-.862l1.24-2.015l-1.228-1.984h.932l.832 1.439h.035l.823-1.439Z"/></svg>';
1348
+ var oo = Object.defineProperty, ro = Object.getOwnPropertyDescriptor, Me = (t, e, o, r) => {
1349
+ for (var a = r > 1 ? void 0 : r ? ro(e, o) : e, s = t.length - 1, n; s >= 0; s--)
1350
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
1351
+ return r && a && oo(e, o, a), a;
992
1352
  };
993
1353
  const Pe = {
994
- pdf: Wt,
995
- txt: Nt,
996
- md: Kt,
997
- csv: Jt,
998
- ppd: Yt,
999
- doc: Gt,
1000
- docx: Qt
1354
+ pdf: Yt,
1355
+ txt: Kt,
1356
+ md: Gt,
1357
+ csv: Xt,
1358
+ ppd: Qt,
1359
+ doc: eo,
1360
+ docx: to
1001
1361
  };
1002
- let W = class extends C {
1362
+ let J = class extends C {
1003
1363
  constructor() {
1004
1364
  super(...arguments), this.filename = "", this.url = "";
1005
1365
  }
@@ -1029,17 +1389,17 @@ let W = class extends C {
1029
1389
  `;
1030
1390
  }
1031
1391
  };
1032
- W.styles = Ft;
1033
- Le([
1034
- c({ type: String })
1035
- ], W.prototype, "filename", 2);
1036
- Le([
1037
- c({ type: String })
1038
- ], W.prototype, "url", 2);
1039
- W = Le([
1392
+ J.styles = Nt;
1393
+ Me([
1394
+ i({ type: String })
1395
+ ], J.prototype, "filename", 2);
1396
+ Me([
1397
+ i({ type: String })
1398
+ ], J.prototype, "url", 2);
1399
+ J = Me([
1040
1400
  x("cb-file")
1041
- ], W);
1042
- const to = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="currentColor"><path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6Z"/><path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1ZM4.118 4L4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118ZM2.5 3h11V2h-11v1Z"/></g></svg>', oo = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" d="M8 8a3 3 0 1 0 0-6a3 3 0 0 0 0 6Zm2-3a2 2 0 1 1-4 0a2 2 0 0 1 4 0Zm4 8c0 1-1 1-1 1H3s-1 0-1-1s1-4 6-4s6 3 6 4Zm-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10c-2.29 0-3.516.68-4.168 1.332c-.678.678-.83 1.418-.832 1.664h10Z"/></svg>', ro = w`
1401
+ ], J);
1402
+ const ao = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="currentColor"><path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6Z"/><path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1ZM4.118 4L4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118ZM2.5 3h11V2h-11v1Z"/></g></svg>', so = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" d="M8 8a3 3 0 1 0 0-6a3 3 0 0 0 0 6Zm2-3a2 2 0 1 1-4 0a2 2 0 0 1 4 0Zm4 8c0 1-1 1-1 1H3s-1 0-1-1s1-4 6-4s6 3 6 4Zm-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10c-2.29 0-3.516.68-4.168 1.332c-.678.678-.83 1.418-.832 1.664h10Z"/></svg>', no = v`
1043
1403
  pre code.hljs {
1044
1404
  display: block;
1045
1405
  overflow-x: auto;
@@ -2204,9 +2564,9 @@ const to = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="curr
2204
2564
  pre {
2205
2565
  background-color: #282c34;
2206
2566
  }
2207
- `, ao = w`
2208
- ${S}
2209
- ${ro}
2567
+ `, io = v`
2568
+ ${H}
2569
+ ${no}
2210
2570
 
2211
2571
  .cb-message-row {
2212
2572
  width: 100%;
@@ -2300,7 +2660,7 @@ const to = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="curr
2300
2660
  //margin-left: auto;
2301
2661
  color: rgb(255, 255, 255);
2302
2662
  //background-color: var(--primary-color);
2303
- background-color: rgba(0, 208, 117, 1);
2663
+ background-color: var(--enegelai-bot-message-user-background, rgba(0, 208, 117, 1));
2304
2664
  text-align: left;
2305
2665
  padding: 6px 12px;
2306
2666
  }
@@ -2315,7 +2675,7 @@ const to = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="curr
2315
2675
  margin-left: 0px;
2316
2676
  margin-top: 2px;
2317
2677
  color: rgb(34, 34, 34);
2318
- background-color: rgba(234, 234, 234, 0.3);
2678
+ background-color: var(--enegelai-bot-message-bot-background, rgba(234, 234, 234, 0.3));
2319
2679
  padding: 4px 12px 6px 12px;
2320
2680
  }
2321
2681
 
@@ -2325,7 +2685,7 @@ const to = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="curr
2325
2685
  margin-left: 0px;
2326
2686
  margin-top: 2px;
2327
2687
  color: rgba(34, 34, 34, 0.6);
2328
- background-color: rgba(254, 243, 199, 0.5);
2688
+ background-color: var(--enegelai-bot-message-system-background, rgba(254, 243, 199, 0.5));
2329
2689
  padding: 4px 12px 6px 12px;
2330
2690
  }
2331
2691
 
@@ -2360,66 +2720,20 @@ const to = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="curr
2360
2720
  font-size: 1em;
2361
2721
  }
2362
2722
  `;
2363
- function ze(t, e) {
2364
- return `<pre class="code-block-wrapper"><div class="code-block-header"><span class="code-block-header__lang">${e}</span><span class="code-block-header__copy">Copy</span></div><code class="hljs code-block-body ${e}">${t}</code></pre>`;
2365
- }
2366
- function so() {
2367
- const t = new bt({
2368
- linkify: !0,
2369
- highlight(e, o) {
2370
- if (!!(o && ge.getLanguage(o))) {
2371
- const r = o ?? "";
2372
- return ze(ge.highlight(e, { language: r }).value, r);
2373
- }
2374
- return ze(ge.highlightAuto(e).value, "");
2375
- }
2723
+ function lo() {
2724
+ const t = new lt({
2725
+ linkify: !0
2376
2726
  });
2377
- return t.use(gt, { attrs: { target: "_blank", rel: "noopener" } }), t;
2727
+ return t.use(dt, { attrs: { target: "_blank", rel: "noopener" } }), t.use(ct), t;
2378
2728
  }
2379
- async function Ee(t) {
2380
- const e = so();
2381
- return l`${De(e.render(t))}`;
2729
+ async function Ie(t) {
2730
+ const e = lo();
2731
+ return l`${Z(e.render(t))}`;
2382
2732
  }
2383
- let no = (t) => crypto.getRandomValues(new Uint8Array(t)), io = (t, e, o) => {
2384
- let a = (2 << Math.log(t.length - 1) / Math.LN2) - 1, r = -~(1.6 * a * e / t.length);
2385
- return (s = e) => {
2386
- let n = "";
2387
- for (; ; ) {
2388
- let i = o(r), u = r;
2389
- for (; u--; )
2390
- if (n += t[i[u] & a] || "", n.length === s)
2391
- return n;
2392
- }
2393
- };
2394
- }, lo = (t, e = 21) => io(t, e, no);
2395
- const co = lo("1234567890abcdefghijklmnopqrstuvwxyz", 10);
2396
- function we(t = 10) {
2397
- return co(t);
2398
- }
2399
- function po(t) {
2400
- return new Promise((e, o) => {
2401
- try {
2402
- navigator.clipboard.writeText(t).then(() => {
2403
- e(t);
2404
- });
2405
- } catch (a) {
2406
- o(a);
2407
- }
2408
- });
2409
- }
2410
- function ho(t = !0) {
2411
- return new Promise((e) => {
2412
- const o = document.createElement("input");
2413
- o.type = "file", t && (o.multiple = !0), o.style.display = "none", o.addEventListener("change", () => {
2414
- const a = Array.prototype.slice.call(o.files);
2415
- e(a);
2416
- }), o.click();
2417
- });
2418
- }
2419
- var uo = Object.defineProperty, bo = Object.getOwnPropertyDescriptor, de = (t, e, o, a) => {
2420
- for (var r = a > 1 ? void 0 : a ? bo(e, o) : e, s = t.length - 1, n; s >= 0; s--)
2421
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
2422
- return a && r && uo(e, o, r), r;
2733
+ var co = Object.defineProperty, po = Object.getOwnPropertyDescriptor, de = (t, e, o, r) => {
2734
+ for (var a = r > 1 ? void 0 : r ? po(e, o) : e, s = t.length - 1, n; s >= 0; s--)
2735
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
2736
+ return r && a && co(e, o, a), a;
2423
2737
  };
2424
2738
  let V = class extends C {
2425
2739
  constructor() {
@@ -2444,473 +2758,142 @@ let V = class extends C {
2444
2758
  this.emit("message:remove", {
2445
2759
  detail: this.message
2446
2760
  });
2447
- }
2448
- _addCopyEvents() {
2449
- this.copyBtns.forEach((t) => {
2450
- t.addEventListener("click", () => {
2451
- var o, a;
2452
- const e = (a = (o = t.parentElement) == null ? void 0 : o.nextElementSibling) == null ? void 0 : a.textContent;
2453
- e && po(e).then(() => {
2454
- t.textContent = "Success", setTimeout(() => {
2455
- t.textContent = "Copy";
2456
- }, 500);
2457
- });
2458
- });
2459
- });
2460
- }
2461
- _removeCopyEvents() {
2462
- this.copyBtns.forEach((t) => {
2463
- t.removeEventListener("click", () => {
2464
- });
2465
- });
2466
- }
2467
- render() {
2468
- return B(
2469
- this.message.data || this.message.isThinking,
2470
- () => l`
2471
- <div class="cb-message-row" part="cb-message-row">
2472
- <!-- message -->
2473
- ${B(
2474
- this._isBot,
2475
- () => this.renderBotMessage(this.message),
2476
- () => this.renderUserMessage(this.message)
2477
- )}
2478
- </div>
2479
- `,
2480
- () => null
2481
- );
2482
- }
2483
- renderButtons(t = "left") {
2484
- return l`<div class="cb-message__buttons ${t}">
2485
- <!-- delete button -->
2486
- <sl-button class="cb-message__delete-button" name="trash" @click=${this._removeMessageHandler} circle variant="text" size="small">
2487
- <cb-icon svg="${to}" style="font-size: 1em !important;"></cb-icon>
2488
- </sl-button>
2489
- </div>`;
2490
- }
2491
- renderMessage(t) {
2492
- return l`
2493
- <div
2494
- class="cb-message__content
2495
- ${t.author}-message
2496
- message-type-${t.type}
2497
- ${t.isThinking ? "thinking" : ""}"
2498
- style="display: flex"
2499
- >
2500
- ${this.renderMessageContent(t)}
2501
- </div>
2502
- `;
2503
- }
2504
- async _getMessageText(t) {
2505
- return Ee(t.data.text);
2506
- }
2507
- renderMessageContent(t) {
2508
- var e;
2509
- return console.log("renderMessageContent!"), t.isThinking ? l`<cb-thinking></cb-thinking>` : t.isUploading ? l`<cb-uploading .files="${t.data.files || []}"></cb-uploading>` : t.type === "text" ? l`<div class="cb-message-text">
2510
- ${B(
2511
- t.data.userName,
2512
- () => l`<div style="font-size: 12px; color:#9ca3af">${t.data.userName}</div>`,
2513
- () => null
2514
- )}
2515
- ${Ae(
2516
- this._getMessageText(t).then((o) => l`${o}`)
2517
- )}
2518
- </div>` : t.type === "file" ? l`${fe(
2519
- t.data.files || [],
2520
- (o) => o.id,
2521
- (o) => l`<cb-file filename="${o.name}" url="${o.url}"></cb-file>`
2522
- )}` : l`<div class="cb-message-text">
2523
- ${Ae(
2524
- Ee(((e = t.data.text) == null ? void 0 : e.toString()) || "").then((o) => l`${o}`)
2525
- )}
2526
- </div>`;
2527
- }
2528
- renderBotMessageAvatar(t) {
2529
- if (t.data.userName && t.data.userName !== "") {
2530
- const e = t.data.userAvatar || "";
2531
- return l` <img src="${e}" style="width: 24px;height: 24px;" /> `;
2532
- }
2533
- return t.author === "system" ? l` <svg fill="currentColor" style="width: 24px;height: 24px;" viewBox="0 0 24 24">
2534
- <path
2535
- d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z"
2536
- />
2537
- </svg>` : l` <svg fill="currentColor" style="width: 24px;height: 24px;" viewBox="0 0 24 24">
2538
- <path
2539
- d="M8,14.25L4.75,11H7C7.25,5.39 9.39,1 12,1C14,1 15.77,3.64 16.55,7.45C20.36,8.23 23,10 23,12C23,13.83 20.83,15.43 17.6,16.3L17.89,14.27C19.8,13.72 21,12.91 21,12C21,10.94 19.35,10 16.87,9.5C16.95,10.29 17,11.13 17,12C17,18.08 14.76,23 12,23C10.17,23 8.57,20.83 7.7,17.6L9.73,17.89C10.28,19.8 11.09,21 12,21C13.66,21 15,16.97 15,12C15,11 14.95,10.05 14.85,9.15C13.95,9.05 13,9 12,9L10.14,9.06L10.43,7.05L12,7C12.87,7 13.71,7.05 14.5,7.13C14,4.65 13.06,3 12,3C10.46,3 9.18,6.5 9,11H11.25L8,14.25M14.25,16L11,19.25V17C5.39,16.75 1,14.61 1,12C1,10.17 3.17,8.57 6.4,7.7L6.11,9.73C4.2,10.28 3,11.09 3,12C3,13.54 6.5,14.82 11,15V12.75L14.25,16Z"
2540
- />
2541
- </svg>`;
2542
- }
2543
- renderBotMessage(t) {
2544
- return l`
2545
- <div class="cb-message cb-bot-message-wrapper" part="cb-message">
2546
- <div class="avatar assistant-avatar xsmall" style="margin-top:4px;">${this.renderBotMessageAvatar(t)}</div>
2547
- <div style="margin-left: 4px;width: 100%">${this.renderMessage(t)}</div>
2548
- </div>
2549
- `;
2550
- }
2551
- renderUserMessage(t) {
2552
- return l`
2553
- <div class="cb-message" part="cb-message" style="display: flex; justify-content: end;align-items: start;">
2554
- <!--<sl-avatar class="avatar user-avatar small" label="User">
2555
- <cb-icon slot="icon" svg="${oo}" color="white"></cb-icon>
2556
- </sl-avatar>-->
2557
- <div class="avatar user-avatar">
2558
- <svg viewBox="0 0 24 24" width="1.2em" height="1.2em" style="width: 24px;height: 24px;">
2559
- <path fill="currentColor" d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4Z" />
2560
- </svg>
2561
- </div>
2562
- ${this.renderMessage(t)}
2563
- </div>
2564
- `;
2565
- }
2566
- };
2567
- V.styles = ao;
2568
- de([
2569
- c({ type: Object })
2570
- ], V.prototype, "message", 2);
2571
- de([
2572
- c({ type: String })
2573
- ], V.prototype, "type", 2);
2574
- de([
2575
- ut(".code-block-header__copy")
2576
- ], V.prototype, "copyBtns", 2);
2577
- V = de([
2578
- x("cb-message")
2579
- ], V);
2580
- const k = ce.noConflict();
2581
- k.setLevel("info");
2582
- class go {
2583
- constructor(e = {}) {
2584
- this.id = 0, this.url = (e == null ? void 0 : e.url) || null, this._options = e || {}, this._ws = null, this.started = !1, this.connected = !1, this.onMessage = (e == null ? void 0 : e.onMessage) || null, this.queue = [], this.pause = (o) => new Promise((a) => setTimeout(a, o)), k.info(`WSC: Created, url: ${this.url}`);
2585
- }
2586
- connect(e = {}) {
2587
- if (this.url = (e == null ? void 0 : e.url) || this.url, this.connected = !1, !this.url)
2588
- return k.error("WSC: URL must be provided to connect"), null;
2589
- const o = this.url;
2590
- k.info(`WSC: Connecting to ${o} ...`), this._ws = new WebSocket(o);
2591
- let a = setTimeout(() => {
2592
- k.error("WSC: connected message not received in time - terminating"), this._ws.close(), this._ws = null, this.connected = !1;
2593
- }, 15e3);
2594
- this._ws.onopen = () => {
2595
- k.info(`WSC: Connection to ${o} opened`);
2596
- }, this._ws.onmessage = (r) => {
2597
- let s = (r == null ? void 0 : r.data) || null;
2598
- if (!s)
2599
- return;
2600
- let n = null;
2601
- try {
2602
- n = JSON.parse(s);
2603
- } catch {
2604
- k.error(`Failed to parse message: ${s}`);
2605
- return;
2606
- }
2607
- (n == null ? void 0 : n.type) === "connected" && (k.info(`WS[${this.id}] Connected`), clearTimeout(a), this.connected = !0, this.sendQueuedMessages()), this.handleWscMessage(n);
2608
- }, this._ws.onerror = (r) => {
2609
- k.error("WSC: Socket error"), clearTimeout(a), this.connected = !1, this._ws = null;
2610
- }, this._ws.onclose = (r) => {
2611
- k.info(`WSC: Closed - code:${r.code}, reason:"${r.reason}"`), this.connected = !1, this._ws = null, this.reconnect();
2612
- };
2613
- }
2614
- reconnect() {
2615
- this.started && setTimeout(() => {
2616
- this.connect();
2617
- }, 1e3);
2618
- }
2619
- disconnect() {
2620
- if (!this._ws) {
2621
- k.info("WSC: already disconnected");
2622
- return;
2623
- }
2624
- k.info("WSC: disconnect"), this._ws.close();
2625
- }
2626
- async start() {
2627
- this.started = !0, this.connect();
2628
- }
2629
- async stop() {
2630
- this.started = !1, this.disconnect();
2631
- }
2632
- // Attempt to connect, and reconnect if failed
2633
- async startOld() {
2634
- let e = 1, o = !0;
2635
- for (; o; ) {
2636
- if (k.info(`WSC: start: connecting, attempt ${e}`), await this.connect(), this.connected)
2637
- return k.info("WSC: connected"), !0;
2638
- e++, o = e <= 4, o && await this.pause(1e3);
2639
- }
2640
- return k.error(`WSC: start: failed to connect after ${e} attempts, exiting`), !1;
2641
- }
2642
- handleWscMessage(e) {
2643
- this.onMessage && typeof this.onMessage == "function" && this.onMessage(e);
2644
- }
2645
- sendMessage(e) {
2646
- if (!this.connected) {
2647
- this.queue.push(JSON.stringify(e));
2648
- return;
2649
- }
2650
- this._ws.send(JSON.stringify(e));
2651
- }
2652
- sendQueuedMessages() {
2653
- if (Array.isArray(this.queue) && this.queue.length > 0)
2654
- for (let e = 0; e < this.queue.length; e++)
2655
- k.info("Sending queued message", this.queue[e]), this._ws.send(this.queue[e]);
2656
- this.queue = [];
2657
- }
2658
- // Request assumes that response will be received.
2659
- // We wait for the response, and then return it.
2660
- // TODO Reconsider - disabled for now
2661
- /*
2662
- executeRequest(payload) {
2663
- return new Promise((resolve, reject) => {
2664
- if (!this._ws) {
2665
- logger.error(`WS[${this.id}]: _ws is NULL - exiting`);
2666
- resolve(null);
2667
- }
2668
-
2669
- const id = `${this.idCounter++}`;
2670
- const req = Object.assign({ id: id }, payload);
2671
- this._ws.send(JSON.stringify(req));
2672
-
2673
- // Setting up timeout for max time to wait for the response
2674
- let timerId = setTimeout(() => {
2675
- timerId = null;
2676
- logger.error(`WS[${this.id}]: Error: request timeout id:${id}, req:${JSON.stringify(req)}`);
2677
- reject(new Error(`WS[${this.id}]: Error: request timeout id:${id}, req:${JSON.stringify(req)}`));
2678
- }, 5000);
2679
- // Wait for response
2680
- this.once(`res-${id}`, (data) => {
2681
- logger.info(`WS: Response: ${id}: ${JSON.stringify(data)}`);
2682
- if (timerId) {
2683
- clearTimeout(timerId);
2684
- resolve(data);
2685
- }
2686
- });
2687
- });
2688
- }*/
2689
- }
2690
- var mo = Object.defineProperty, fo = Object.getOwnPropertyDescriptor, R = (t, e, o, a) => {
2691
- for (var r = a > 1 ? void 0 : a ? fo(e, o) : e, s = t.length - 1, n; s >= 0; s--)
2692
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
2693
- return a && r && mo(e, o, r), r;
2694
- };
2695
- const z = ce.noConflict();
2696
- z.setLevel("info");
2697
- const F = "cb_";
2698
- class A extends G {
2699
- constructor() {
2700
- super(...arguments), this.actionIdCounter = 0, this.wsClient = null, this.replyMessage = null;
2701
- }
2702
- // this is called at startup
2703
- setSetting(e) {
2704
- z.info("appState: Startup: setSetting", e), this.setting = e, Array.isArray(this.messages) && this.messages.length <= 0 && this.addMessage({
2705
- author: "assistant",
2706
- type: "text",
2707
- data: {
2708
- text: this.setting.welcomeMessage
2709
- }
2710
- }), this.connectWs === "true" && (z.info("appState: connectWs is true"), this.getWsClient().catch((o) => {
2711
- z.info(`Exception during ws client startup: ${o.message}`);
2712
- }));
2713
- }
2714
- clearConversation() {
2715
- this.wsClient && (this.wsClient.stop().then(() => {
2716
- }), this.wsClient = null), this.conversationId = we(), this.connectWs = "false", this.messages = [], this.actions = [], this.addMessage({
2717
- author: "assistant",
2718
- type: "text",
2719
- data: {
2720
- text: this.setting.welcomeMessage
2721
- }
2722
- });
2723
- }
2724
- // set language
2725
- setLanguage(e) {
2726
- this.language = e;
2727
- }
2728
- // set theme
2729
- setTheme(e) {
2730
- this.theme = e;
2731
- }
2732
- // Lazy initialization: avoid connecting until we actually need to send something
2733
- // TODO Depending on state, start ws & connect immediately when initialized
2734
- // use case: page refresh in the middle of the conversation
2735
- async getWsClient() {
2736
- if (this.wsClient)
2737
- return this.wsClient;
2738
- const e = `${this.setting.url}/api/bot/connect/${this.setting.orgId}/${this.setting.botId}/${this.conversationId}`;
2739
- return z.info(`Initiating ws connection to ${e} ...`), this.wsClient = new go({
2740
- url: e
2741
- }), await this.wsClient.start(), this.wsClient.onMessage = (o) => {
2742
- this.handleWscMessage(o);
2743
- }, this.wsClient;
2744
- }
2745
- handleWscMessage(e) {
2746
- switch (e == null ? void 0 : e.type) {
2747
- case "message": {
2748
- if (this.replyMessage)
2749
- this.replyMessage.data.text = e.text, this.updateMessage(this.replyMessage, ""), this.replyMessage = null;
2750
- else {
2751
- const o = {
2752
- type: "text",
2753
- author: "assistant",
2754
- data: {
2755
- text: e.text
2756
- }
2757
- };
2758
- "userName" in e && (o.data.userName = e.userName, this.connectWs = "true"), "userAvatar" in e && (o.data.userAvatar = e.userAvatar, this.connectWs = "true");
2759
- const a = this.formatMessage(o);
2760
- this.messages = this.messages.concat([a]);
2761
- }
2762
- break;
2763
- }
2764
- case "message-chunk": {
2765
- this.replyMessage && (this.replyMessage = this.updateMessage(this.replyMessage, e.text));
2766
- break;
2767
- }
2768
- case "typing": {
2769
- this.replyMessage = {
2770
- author: "assistant",
2771
- type: "text",
2772
- isThinking: !0,
2773
- data: {
2774
- text: ""
2775
- }
2776
- }, this.addMessage(this.replyMessage);
2777
- break;
2778
- }
2779
- case "actions": {
2780
- this.addActions((e == null ? void 0 : e.actions) || []);
2781
- break;
2782
- }
2783
- }
2784
- }
2785
- addActions(e) {
2786
- if (Array.isArray(e) && e.length > 0) {
2787
- const o = e.map((a) => Object.assign(a, { internalId: this.actionIdCounter++ }));
2788
- this.actions = this.actions.concat(o);
2789
- }
2790
- }
2791
- removeAction(e) {
2792
- const o = this.actions.findIndex((a) => a.internalId === e);
2793
- if (o !== -1) {
2794
- this.actions.splice(o, 1);
2795
- const a = [];
2796
- this.actions = a.concat(this.actions);
2797
- }
2798
- }
2799
- async sendMessage(e) {
2800
- e = this.formatMessage(e), z.info("Send Message:", e), this.messages = this.messages.concat([e]);
2801
- const o = await this.getWsClient();
2802
- if (!o) {
2803
- z.error("Error - failed to obtain ws client"), this.replyMessage = null;
2804
- return;
2805
- }
2806
- o.sendMessage({
2807
- type: "message",
2808
- id: e.id,
2809
- text: e.data.text
2761
+ }
2762
+ _addCopyEvents() {
2763
+ this.copyBtns.forEach((t) => {
2764
+ t.addEventListener("click", () => {
2765
+ var o, r;
2766
+ const e = (r = (o = t.parentElement) == null ? void 0 : o.nextElementSibling) == null ? void 0 : r.textContent;
2767
+ e && $t(e).then(() => {
2768
+ t.textContent = "Success", setTimeout(() => {
2769
+ t.textContent = "Copy";
2770
+ }, 500);
2771
+ });
2772
+ });
2810
2773
  });
2811
2774
  }
2812
- // TODO revisit below
2813
- formatMessage(e) {
2814
- var o;
2815
- return e.id || (e.id = we()), e.timestamp = Date.now(), e.author === "assistant" && (e.replyId = (o = this.messages[this.messages.length - 1]) == null ? void 0 : o.id), e;
2775
+ _removeCopyEvents() {
2776
+ this.copyBtns.forEach((t) => {
2777
+ t.removeEventListener("click", () => {
2778
+ });
2779
+ });
2816
2780
  }
2817
- // add message
2818
- addMessage(e) {
2819
- e = this.formatMessage(e), this.messages = this.messages.concat([e]);
2781
+ render() {
2782
+ return B(
2783
+ this.message.data || this.message.isThinking,
2784
+ () => l`
2785
+ <div class="cb-message-row" part="cb-message-row">
2786
+ <!-- message -->
2787
+ ${B(
2788
+ this._isBot,
2789
+ () => this.renderBotMessage(this.message),
2790
+ () => this.renderUserMessage(this.message)
2791
+ )}
2792
+ </div>
2793
+ `,
2794
+ () => null
2795
+ );
2820
2796
  }
2821
- addSystemMessage(e) {
2822
- this.addMessage({
2823
- type: "text",
2824
- author: "system",
2825
- data: {
2826
- text: e
2827
- }
2828
- });
2797
+ renderButtons(t = "left") {
2798
+ return l`<div class="cb-message__buttons ${t}">
2799
+ <!-- delete button -->
2800
+ <sl-button class="cb-message__delete-button" name="trash" @click=${this._removeMessageHandler} circle variant="text" size="small">
2801
+ <cb-icon svg="${ao}" style="font-size: 1em !important;"></cb-icon>
2802
+ </sl-button>
2803
+ </div>`;
2829
2804
  }
2830
- // update message
2831
- updateMessage(e, o) {
2832
- const a = this.formatMessage(e);
2833
- return a.isThinking = !1, o && (a.data.text += o), this.messages = this.messages.map((r) => r.id === a.id ? a : r), a;
2805
+ renderMessage(t) {
2806
+ return l`
2807
+ <div
2808
+ class="cb-message__content
2809
+ ${t.author}-message
2810
+ message-type-${t.type}
2811
+ ${t.isThinking ? "thinking" : ""}"
2812
+ style="display: flex"
2813
+ >
2814
+ ${this.renderMessageContent(t)}
2815
+ </div>
2816
+ `;
2834
2817
  }
2835
- // remove message
2836
- removeMessage(e) {
2837
- this.messages = this.messages.filter((o) => o.id !== e);
2818
+ async _getMessageText(t) {
2819
+ return Ie(t.data.text);
2838
2820
  }
2839
- // clear messages
2840
- clearMessages() {
2841
- this.messages = [];
2821
+ renderMessageContent(t) {
2822
+ var e;
2823
+ return t.isThinking ? l`<cb-thinking></cb-thinking>` : t.isUploading ? l`<cb-uploading .files="${t.data.files || []}"></cb-uploading>` : t.type === "text" ? l`<div class="cb-message-text">
2824
+ ${B(
2825
+ t.data.userName,
2826
+ () => l`<div style="font-size: 12px; color:#9ca3af">${t.data.userName}</div>`,
2827
+ () => null
2828
+ )}
2829
+ ${Oe(
2830
+ this._getMessageText(t).then((o) => l`${o}`)
2831
+ )}
2832
+ </div>` : t.type === "file" ? l`${me(
2833
+ t.data.files || [],
2834
+ (o) => o.id,
2835
+ (o) => l`<cb-file filename="${o.name}" url="${o.url}"></cb-file>`
2836
+ )}` : l`<div class="cb-message-text">
2837
+ ${Oe(
2838
+ Ie(((e = t.data.text) == null ? void 0 : e.toString()) || "").then((o) => l`${o}`)
2839
+ )}
2840
+ </div>`;
2842
2841
  }
2843
- }
2844
- R([
2845
- D({ prefix: F }),
2846
- I({ value: "en" })
2847
- ], A.prototype, "language", 2);
2848
- R([
2849
- D({ prefix: F }),
2850
- I({ value: "light" })
2851
- ], A.prototype, "theme", 2);
2852
- R([
2853
- D({ prefix: F }),
2854
- I({ value: "false" })
2855
- ], A.prototype, "connectWs", 2);
2856
- R([
2857
- D({ prefix: F }),
2858
- I({ value: we() })
2859
- ], A.prototype, "conversationId", 2);
2860
- R([
2861
- D({ prefix: F }),
2862
- I({ type: Array, value: [] })
2863
- ], A.prototype, "messages", 2);
2864
- R([
2865
- I({
2866
- type: Array,
2867
- value: []
2868
- /*value: [
2869
- {
2870
- internalId: 1,
2871
- type: 'calendlyMeeting',
2872
- title: 'Book 1:1 meeting',
2873
- url: 'https://calendly.com/slava-sayko/1-1-meeting-with-sales?hide_gdpr_banner=1',
2874
- // TODO Any other properties
2875
- },
2876
- {
2877
- internalId: 2,
2878
- type: 'link',
2879
- title: 'Sign Up',
2880
- url: 'https://signup.ticketspice.com/',
2881
- // TODO Any other properties
2882
- },
2883
- ],*/
2884
- })
2885
- ], A.prototype, "actions", 2);
2886
- R([
2887
- D({ prefix: F }),
2888
- I({
2889
- type: Object,
2890
- value: {
2891
- orgId: null,
2892
- botId: null,
2893
- url: null,
2894
- welcomeMessage: null
2842
+ renderBotMessageAvatar(t) {
2843
+ if (t.data.userName && t.data.userName !== "") {
2844
+ const e = t.data.userAvatar || "";
2845
+ return l` <img src="${e}" style="width: 24px;height: 24px;" /> `;
2895
2846
  }
2896
- })
2897
- ], A.prototype, "setting", 2);
2898
- const b = new A();
2899
- var yo = Object.defineProperty, vo = Object.getOwnPropertyDescriptor, K = (t, e, o, a) => {
2900
- for (var r = a > 1 ? void 0 : a ? vo(e, o) : e, s = t.length - 1, n; s >= 0; s--)
2901
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
2902
- return a && r && yo(e, o, r), r;
2847
+ return t.author === "system" ? Le`${Z(m.setting.systemIconSvg)}` : Le`${Z(m.setting.botIconSvg)}`;
2848
+ }
2849
+ renderBotMessage(t) {
2850
+ return l`
2851
+ <div class="cb-message cb-bot-message-wrapper" part="cb-message">
2852
+ <div class="avatar assistant-avatar xsmall" style="margin-top:4px;">${this.renderBotMessageAvatar(t)}</div>
2853
+ <div style="margin-left: 4px;width: 100%">${this.renderMessage(t)}</div>
2854
+ </div>
2855
+ `;
2856
+ }
2857
+ renderUserMessage(t) {
2858
+ return l`
2859
+ <div class="cb-message" part="cb-message" style="display: flex; justify-content: end;align-items: start;">
2860
+ <!--<sl-avatar class="avatar user-avatar small" label="User">
2861
+ <cb-icon slot="icon" svg="${so}" color="white"></cb-icon>
2862
+ </sl-avatar>-->
2863
+ <div class="avatar user-avatar">${Z(m.setting.userIconSvg)}</div>
2864
+ ${this.renderMessage(t)}
2865
+ </div>
2866
+ `;
2867
+ }
2868
+ };
2869
+ V.styles = io;
2870
+ de([
2871
+ i({ type: Object })
2872
+ ], V.prototype, "message", 2);
2873
+ de([
2874
+ i({ type: String })
2875
+ ], V.prototype, "type", 2);
2876
+ de([
2877
+ it(".code-block-header__copy")
2878
+ ], V.prototype, "copyBtns", 2);
2879
+ V = de([
2880
+ x("cb-message")
2881
+ ], V);
2882
+ var ho = Object.defineProperty, uo = Object.getOwnPropertyDescriptor, K = (t, e, o, r) => {
2883
+ for (var a = r > 1 ? void 0 : r ? uo(e, o) : e, s = t.length - 1, n; s >= 0; s--)
2884
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
2885
+ return r && a && ho(e, o, a), a;
2903
2886
  };
2904
2887
  const Q = ce.noConflict();
2905
2888
  Q.setLevel("info");
2906
- let T = class extends C {
2889
+ let R = class extends C {
2907
2890
  constructor() {
2908
2891
  super(...arguments), this.messages = [], this.actions = [], this.calendlyInjected = !1, this.activeCalendlyAction = -1;
2909
2892
  }
2910
2893
  render() {
2911
2894
  return l`
2912
2895
  <div class="cb-message-list" part="cb-message-list">
2913
- ${fe(
2896
+ ${me(
2914
2897
  this.messages,
2915
2898
  (t) => t.id + JSON.stringify(t.data),
2916
2899
  (t) => l`<cb-message .message="${t}"></cb-message>`
@@ -2922,7 +2905,7 @@ let T = class extends C {
2922
2905
  renderActions() {
2923
2906
  return !Array.isArray(this.actions) || this.actions.length <= 0 ? null : l`
2924
2907
  <div class="cb-actions-list">
2925
- ${fe(
2908
+ ${me(
2926
2909
  this.actions,
2927
2910
  (t) => t,
2928
2911
  (t) => this.renderAction(t)
@@ -2943,7 +2926,7 @@ let T = class extends C {
2943
2926
  switch (Q.info("Got Calendly Event:", t.data), t.data.event) {
2944
2927
  case "calendly.event_scheduled": {
2945
2928
  const e = this.activeCalendlyAction;
2946
- e >= 0 && (b.removeAction(e), b.addSystemMessage("Your meeting has been scheduled!"), this.activeCalendlyAction = -1);
2929
+ e >= 0 && (m.removeAction(e), m.addSystemMessage("Your meeting has been scheduled!"), this.activeCalendlyAction = -1);
2947
2930
  }
2948
2931
  }
2949
2932
  }
@@ -2958,8 +2941,8 @@ let T = class extends C {
2958
2941
  let e = document.createElement("link");
2959
2942
  e.href = "https://assets.calendly.com/assets/external/widget.css", e.rel = "stylesheet", document.body.appendChild(e);
2960
2943
  let o = document.createElement("script");
2961
- o.type = "text/javascript", o.src = "https://assets.calendly.com/assets/external/widget.js", document.body.appendChild(o), console.log("Injected Calendly"), window.addEventListener("message", (a) => {
2962
- a.origin === "https://calendly.com" && a.data.event && a.data.event.indexOf("calendly.") !== -1 && this.handleCalendlyEvent(a);
2944
+ o.type = "text/javascript", o.src = "https://assets.calendly.com/assets/external/widget.js", document.body.appendChild(o), console.log("Injected Calendly"), window.addEventListener("message", (r) => {
2945
+ r.origin === "https://calendly.com" && r.data.event && r.data.event.indexOf("calendly.") !== -1 && this.handleCalendlyEvent(r);
2963
2946
  }), this.calendlyInjected = !0;
2964
2947
  }
2965
2948
  return l`
@@ -2993,24 +2976,24 @@ let T = class extends C {
2993
2976
  `;
2994
2977
  }
2995
2978
  };
2996
- T.styles = It;
2979
+ R.styles = Vt;
2997
2980
  K([
2998
- c({ type: Array })
2999
- ], T.prototype, "messages", 2);
2981
+ i({ type: Array })
2982
+ ], R.prototype, "messages", 2);
3000
2983
  K([
3001
- c({ type: Array })
3002
- ], T.prototype, "actions", 2);
2984
+ i({ type: Array })
2985
+ ], R.prototype, "actions", 2);
3003
2986
  K([
3004
- qe({ capture: !1, passive: !0 })
3005
- ], T.prototype, "invokeLinkAction", 1);
2987
+ Ve({ capture: !1, passive: !0 })
2988
+ ], R.prototype, "invokeLinkAction", 1);
3006
2989
  K([
3007
- qe({ capture: !1, passive: !0 })
3008
- ], T.prototype, "invokeCalendlyAction", 1);
3009
- T = K([
2990
+ Ve({ capture: !1, passive: !0 })
2991
+ ], R.prototype, "invokeCalendlyAction", 1);
2992
+ R = K([
3010
2993
  x("cb-message-list")
3011
- ], T);
3012
- const wo = w`
3013
- ${S}
2994
+ ], R);
2995
+ const go = v`
2996
+ ${H}
3014
2997
 
3015
2998
  :host {
3016
2999
  width: 100%;
@@ -3052,13 +3035,13 @@ const wo = w`
3052
3035
  .cb-input-buttons {
3053
3036
  padding: 0 5px;
3054
3037
  }
3055
- `, xo = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" d="M15.854.146a.5.5 0 0 1 .11.54l-5.819 14.547a.75.75 0 0 1-1.329.124l-3.178-4.995L.643 7.184a.75.75 0 0 1 .124-1.33L15.314.037a.5.5 0 0 1 .54.11ZM6.636 10.07l2.761 4.338L14.13 2.576L6.636 10.07Zm6.787-8.201L1.591 6.602l4.339 2.76l7.494-7.493Z"/></svg>', ko = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" d="M4.5 3a2.5 2.5 0 0 1 5 0v9a1.5 1.5 0 0 1-3 0V5a.5.5 0 0 1 1 0v7a.5.5 0 0 0 1 0V3a1.5 1.5 0 1 0-3 0v9a2.5 2.5 0 0 0 5 0V5a.5.5 0 0 1 1 0v7a3.5 3.5 0 1 1-7 0V3z"/></svg>';
3056
- var _o = Object.defineProperty, Co = Object.getOwnPropertyDescriptor, O = (t, e, o, a) => {
3057
- for (var r = a > 1 ? void 0 : a ? Co(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3058
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
3059
- return a && r && _o(e, o, r), r;
3038
+ `, bo = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" d="M15.854.146a.5.5 0 0 1 .11.54l-5.819 14.547a.75.75 0 0 1-1.329.124l-3.178-4.995L.643 7.184a.75.75 0 0 1 .124-1.33L15.314.037a.5.5 0 0 1 .54.11ZM6.636 10.07l2.761 4.338L14.13 2.576L6.636 10.07Zm6.787-8.201L1.591 6.602l4.339 2.76l7.494-7.493Z"/></svg>', mo = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" d="M4.5 3a2.5 2.5 0 0 1 5 0v9a1.5 1.5 0 0 1-3 0V5a.5.5 0 0 1 1 0v7a.5.5 0 0 0 1 0V3a1.5 1.5 0 1 0-3 0v9a2.5 2.5 0 0 0 5 0V5a.5.5 0 0 1 1 0v7a3.5 3.5 0 1 1-7 0V3z"/></svg>';
3039
+ var yo = Object.defineProperty, fo = Object.getOwnPropertyDescriptor, O = (t, e, o, r) => {
3040
+ for (var a = r > 1 ? void 0 : r ? fo(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3041
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
3042
+ return r && a && yo(e, o, a), a;
3060
3043
  };
3061
- let L = class extends C {
3044
+ let A = class extends C {
3062
3045
  constructor() {
3063
3046
  super(...arguments), this.placeholder = "Type a message...", this.sendButtonLabel = "Send", this.enableFileUpload = !1, this.value = "", this.loading = !1, this.disabled = !1, this.currentKey = "";
3064
3047
  }
@@ -3079,7 +3062,7 @@ let L = class extends C {
3079
3062
  }), this.value = "", this.inputElement.blur();
3080
3063
  }
3081
3064
  async _sendFileHandler() {
3082
- const t = await ho();
3065
+ const t = await jt();
3083
3066
  this.emit("message:send:file", {
3084
3067
  detail: {
3085
3068
  files: t
@@ -3116,7 +3099,7 @@ let L = class extends C {
3116
3099
  variant="text"
3117
3100
  circle
3118
3101
  >
3119
- <cb-icon svg="${ko}"></cb-icon>
3102
+ <cb-icon svg="${mo}"></cb-icon>
3120
3103
  <!-- select file input -->
3121
3104
  <input
3122
3105
  type="file"
@@ -3139,7 +3122,7 @@ let L = class extends C {
3139
3122
  ?loading=${this.loading}
3140
3123
  circle
3141
3124
  >
3142
- <cb-icon svg="${xo}"></cb-icon>
3125
+ <cb-icon svg="${bo}"></cb-icon>
3143
3126
  </sl-button>
3144
3127
  </span>
3145
3128
  </div>
@@ -3149,36 +3132,36 @@ let L = class extends C {
3149
3132
  t.key === "Enter" && !t.shiftKey && this._sendHandler();
3150
3133
  }
3151
3134
  };
3152
- L.styles = wo;
3135
+ A.styles = go;
3153
3136
  O([
3154
- c({ type: String, attribute: "placeholder" })
3155
- ], L.prototype, "placeholder", 2);
3137
+ i({ type: String, attribute: "placeholder" })
3138
+ ], A.prototype, "placeholder", 2);
3156
3139
  O([
3157
- c({ type: String, attribute: "send-button-label" })
3158
- ], L.prototype, "sendButtonLabel", 2);
3140
+ i({ type: String, attribute: "send-button-label" })
3141
+ ], A.prototype, "sendButtonLabel", 2);
3159
3142
  O([
3160
- c({ type: Boolean, attribute: "enable-file-upload" })
3161
- ], L.prototype, "enableFileUpload", 2);
3143
+ i({ type: Boolean, attribute: "enable-file-upload" })
3144
+ ], A.prototype, "enableFileUpload", 2);
3162
3145
  O([
3163
- c({ type: String })
3164
- ], L.prototype, "value", 2);
3146
+ i({ type: String })
3147
+ ], A.prototype, "value", 2);
3165
3148
  O([
3166
- c({ type: Boolean })
3167
- ], L.prototype, "loading", 2);
3149
+ i({ type: Boolean })
3150
+ ], A.prototype, "loading", 2);
3168
3151
  O([
3169
- c({ type: Boolean })
3170
- ], L.prototype, "disabled", 2);
3152
+ i({ type: Boolean })
3153
+ ], A.prototype, "disabled", 2);
3171
3154
  O([
3172
- c({ type: String })
3173
- ], L.prototype, "currentKey", 2);
3155
+ i({ type: String })
3156
+ ], A.prototype, "currentKey", 2);
3174
3157
  O([
3175
- Ce("sl-textarea")
3176
- ], L.prototype, "inputElement", 2);
3177
- L = O([
3158
+ _e("sl-textarea")
3159
+ ], A.prototype, "inputElement", 2);
3160
+ A = O([
3178
3161
  x("cb-user-input")
3179
- ], L);
3180
- const $o = w`
3181
- ${S}
3162
+ ], A);
3163
+ const vo = v`
3164
+ ${H}
3182
3165
 
3183
3166
  sl-dialog::part(base) {
3184
3167
  z-index: 1000;
@@ -3212,10 +3195,10 @@ const $o = w`
3212
3195
  gap: 8px;
3213
3196
  }
3214
3197
  `;
3215
- var jo = Object.defineProperty, Mo = Object.getOwnPropertyDescriptor, pe = (t, e, o, a) => {
3216
- for (var r = a > 1 ? void 0 : a ? Mo(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3217
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
3218
- return a && r && jo(e, o, r), r;
3198
+ var wo = Object.defineProperty, xo = Object.getOwnPropertyDescriptor, pe = (t, e, o, r) => {
3199
+ for (var a = r > 1 ? void 0 : r ? xo(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3200
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
3201
+ return r && a && wo(e, o, a), a;
3219
3202
  };
3220
3203
  let q = class extends C {
3221
3204
  constructor() {
@@ -3248,7 +3231,7 @@ let q = class extends C {
3248
3231
  <cb-icon
3249
3232
  color="default"
3250
3233
  style="font-size: 1em;"
3251
- svg="${je}"
3234
+ svg="${$e}"
3252
3235
  ></cb-icon>
3253
3236
  </sl-button>
3254
3237
  </header>
@@ -3261,23 +3244,23 @@ let q = class extends C {
3261
3244
  </sl-dialog>`;
3262
3245
  }
3263
3246
  };
3264
- q.styles = $o;
3247
+ q.styles = vo;
3265
3248
  pe([
3266
- c({ type: Boolean })
3249
+ i({ type: Boolean })
3267
3250
  ], q.prototype, "open", 2);
3268
3251
  pe([
3269
- c({ type: String, attribute: "label" })
3252
+ i({ type: String, attribute: "label" })
3270
3253
  ], q.prototype, "label", 2);
3271
3254
  pe([
3272
- c({ type: Number })
3255
+ i({ type: Number })
3273
3256
  ], q.prototype, "zindex", 2);
3274
3257
  q = pe([
3275
3258
  x("cb-dialog")
3276
3259
  ], q);
3277
- var Lo = Object.defineProperty, So = Object.getOwnPropertyDescriptor, Je = (t, e, o, a) => {
3278
- for (var r = a > 1 ? void 0 : a ? So(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3279
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
3280
- return a && r && Lo(e, o, r), r;
3260
+ var ko = Object.defineProperty, _o = Object.getOwnPropertyDescriptor, We = (t, e, o, r) => {
3261
+ for (var a = r > 1 ? void 0 : r ? _o(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3262
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
3263
+ return r && a && ko(e, o, a), a;
3281
3264
  };
3282
3265
  let re = class extends C {
3283
3266
  constructor() {
@@ -3313,7 +3296,7 @@ let re = class extends C {
3313
3296
  this.emit("cancel");
3314
3297
  }
3315
3298
  };
3316
- re.styles = w`
3299
+ re.styles = v`
3317
3300
  .cb-clear-message-dialog {
3318
3301
  }
3319
3302
 
@@ -3321,13 +3304,13 @@ re.styles = w`
3321
3304
  z-index: 1000;
3322
3305
  }
3323
3306
  `;
3324
- Je([
3325
- c({ type: Boolean })
3307
+ We([
3308
+ i({ type: Boolean })
3326
3309
  ], re.prototype, "open", 2);
3327
- re = Je([
3310
+ re = We([
3328
3311
  x("cb-clear-message-dialog")
3329
3312
  ], re);
3330
- const Oo = w`
3313
+ const Co = v`
3331
3314
  :host {
3332
3315
  // width: 380px;
3333
3316
 
@@ -3387,12 +3370,12 @@ const Oo = w`
3387
3370
  grid-column-start: 2;
3388
3371
  }
3389
3372
  `;
3390
- var Ho = Object.defineProperty, Ao = Object.getOwnPropertyDescriptor, Z = (t, e, o, a) => {
3391
- for (var r = a > 1 ? void 0 : a ? Ao(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3392
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
3393
- return a && r && Ho(e, o, r), r;
3373
+ var $o = Object.defineProperty, jo = Object.getOwnPropertyDescriptor, U = (t, e, o, r) => {
3374
+ for (var a = r > 1 ? void 0 : r ? jo(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3375
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
3376
+ return r && a && $o(e, o, a), a;
3394
3377
  };
3395
- let H = class extends C {
3378
+ let P = class extends C {
3396
3379
  constructor() {
3397
3380
  super(...arguments), this.open = !1, this.clearMessageDialogOpen = !1, this.customRequest = !1;
3398
3381
  }
@@ -3528,13 +3511,13 @@ let H = class extends C {
3528
3511
  }
3529
3512
  // input change handler
3530
3513
  _inputChangeHandler(t) {
3531
- const { name: e, value: o } = t.target, [a, r] = e.split(".");
3532
- r ? this.setting[a][r] = o : this.setting[a] = o;
3514
+ const { name: e, value: o } = t.target, [r, a] = e.split(".");
3515
+ a ? this.setting[r][a] = o : this.setting[r] = o;
3533
3516
  }
3534
3517
  // checked change handler
3535
3518
  _checkChangeHandler(t) {
3536
- const { name: e, checked: o } = t.target, [a, r] = e.split(".");
3537
- r ? this.setting[a][r] = o : this.setting[a] = o, a === "customRequest" && (this.customRequest = o);
3519
+ const { name: e, checked: o } = t.target, [r, a] = e.split(".");
3520
+ a ? this.setting[r][a] = o : this.setting[r] = o, r === "customRequest" && (this.customRequest = o);
3538
3521
  }
3539
3522
  // emit setting confirm event
3540
3523
  _settingConfirmHandler() {
@@ -3555,73 +3538,99 @@ let H = class extends C {
3555
3538
  });
3556
3539
  }
3557
3540
  };
3558
- H.styles = Oo;
3559
- Z([
3560
- c({ type: Boolean })
3561
- ], H.prototype, "open", 2);
3562
- Z([
3563
- c({ type: Object })
3564
- ], H.prototype, "setting", 2);
3565
- Z([
3566
- c({ type: Boolean })
3567
- ], H.prototype, "clearMessageDialogOpen", 2);
3568
- Z([
3569
- Ce("sl-dialog")
3570
- ], H.prototype, "dialog", 2);
3571
- Z([
3572
- c({ type: Boolean })
3573
- ], H.prototype, "customRequest", 2);
3574
- H = Z([
3541
+ P.styles = Co;
3542
+ U([
3543
+ i({ type: Boolean })
3544
+ ], P.prototype, "open", 2);
3545
+ U([
3546
+ i({ type: Object })
3547
+ ], P.prototype, "setting", 2);
3548
+ U([
3549
+ i({ type: Boolean })
3550
+ ], P.prototype, "clearMessageDialogOpen", 2);
3551
+ U([
3552
+ _e("sl-dialog")
3553
+ ], P.prototype, "dialog", 2);
3554
+ U([
3555
+ i({ type: Boolean })
3556
+ ], P.prototype, "customRequest", 2);
3557
+ P = U([
3575
3558
  x("cb-setting")
3576
- ], H);
3577
- const Po = w`
3578
- ${S}
3579
- :host {
3580
- --primary-color: var(--sl-color-primary-600);
3559
+ ], P);
3560
+ const Mo = v`
3561
+ ${H}
3562
+ :host {
3563
+ --primary-color: var(--sl-color-primary-600);
3581
3564
 
3582
- --anchor-width: 50px;
3583
- }
3565
+ --anchor-width: 50px;
3566
+ }
3584
3567
 
3585
- .cb-anchor {
3586
- width: var(--anchor-width);
3587
- height: var(--anchor-width);
3588
- //background-color: var(--primary-color);
3589
- background: rgb(0, 208, 117);
3568
+ .cb-anchor {
3569
+ width: var(--anchor-width);
3570
+ height: var(--anchor-width);
3571
+ //background-color: var(--primary-color);
3572
+ background: rgb(0, 208, 117);
3590
3573
 
3591
- position: fixed;
3592
- right: 25px;
3593
- bottom: 25px;
3594
- border-radius: 50%;
3574
+ position: fixed;
3575
+ right: 25px;
3576
+ bottom: 25px;
3577
+ border-radius: 50%;
3595
3578
 
3596
- display: flex;
3597
- justify-content: center;
3598
- align-items: center;
3599
- color: white;
3600
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
3579
+ display: flex;
3580
+ justify-content: center;
3581
+ align-items: center;
3582
+ color: white;
3583
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
3601
3584
 
3602
- transition: all 0.3s ease-in-out;
3585
+ transition: all 0.3s ease-in-out;
3603
3586
 
3604
- z-index: 100;
3605
- }
3587
+ z-index: 100;
3588
+ }
3606
3589
 
3607
- .cb-anchor:hover {
3608
- transform: scale(1.1);
3609
- box-shadow: 0 0 100px rgba(0, 0, 0, 0.3);
3610
- }
3590
+ .cb-anchor:hover {
3591
+ transform: scale(1.1);
3592
+ box-shadow: 0 0 100px rgba(0, 0, 0, 0.3);
3593
+ }
3611
3594
 
3612
- .anchor-button {
3613
- font-size: 1.4em;
3614
- }
3595
+ .anchor-button {
3596
+ font-size: 1.4em;
3597
+ }
3598
+
3599
+ sl-button[variant='primary']::part(base) {
3600
+ background-color: rgb(0, 208, 117);
3601
+ border-color: rgb(0, 208, 117);
3602
+ }
3603
+
3604
+ .cb-engage-popup {
3605
+ min-width: 200px;
3606
+ min-height: 100px;
3607
+ color: rgb(34, 34, 34);
3608
+ padding: 10px;
3609
+ background-color: var(--sl-color-gray-50);
3610
+ //border: 1px solid;
3611
+ //border-color: var(--sl-color-gray-100);
3612
+ border-radius: 6px;
3613
+ font-size: 14px;
3614
+ -webkit-font-smoothing: subpixel-antialiased;
3615
+ font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
3616
+ //font-size: 0.9rem;
3617
+ font-style: normal;
3618
+ letter-spacing: normal;
3619
+ font-stretch: normal;
3620
+ font-variant: normal;
3621
+ cursor: pointer;
3622
+ box-shadow: rgba(148, 149, 150, 0.2) 20px 20px 40px 20px;
3623
+ //box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
3624
+ }
3615
3625
 
3616
- sl-button[variant="primary"]::part(base) {
3617
- background-color: rgb(0, 208, 117);
3618
- border-color: rgb(0, 208, 117);
3619
- }
3620
- `, zo = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" d="M16 8c0 3.866-3.582 7-8 7a9.06 9.06 0 0 1-2.347-.306c-.584.296-1.925.864-4.181 1.234c-.2.032-.352-.176-.273-.362c.354-.836.674-1.95.77-2.966C.744 11.37 0 9.76 0 8c0-3.866 3.582-7 8-7s8 3.134 8 7zM5 8a1 1 0 1 0-2 0a1 1 0 0 0 2 0zm4 0a1 1 0 1 0-2 0a1 1 0 0 0 2 0zm3 1a1 1 0 1 0 0-2a1 1 0 0 0 0 2z"/></svg>';
3621
- var Eo = Object.defineProperty, To = Object.getOwnPropertyDescriptor, Ye = (t, e, o, a) => {
3622
- for (var r = a > 1 ? void 0 : a ? To(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3623
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
3624
- return a && r && Eo(e, o, r), r;
3626
+ .cb-anchor sl-popup {
3627
+ --arrow-color: var(--sl-color-gray-300);
3628
+ }
3629
+ `, So = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><path fill="currentColor" d="M16 8c0 3.866-3.582 7-8 7a9.06 9.06 0 0 1-2.347-.306c-.584.296-1.925.864-4.181 1.234c-.2.032-.352-.176-.273-.362c.354-.836.674-1.95.77-2.966C.744 11.37 0 9.76 0 8c0-3.866 3.582-7 8-7s8 3.134 8 7zM5 8a1 1 0 1 0-2 0a1 1 0 0 0 2 0zm4 0a1 1 0 1 0-2 0a1 1 0 0 0 2 0zm3 1a1 1 0 1 0 0-2a1 1 0 0 0 0 2z"/></svg>';
3630
+ var Ao = Object.defineProperty, Ho = Object.getOwnPropertyDescriptor, Je = (t, e, o, r) => {
3631
+ for (var a = r > 1 ? void 0 : r ? Ho(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3632
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
3633
+ return r && a && Ao(e, o, a), a;
3625
3634
  };
3626
3635
  let ae = class extends C {
3627
3636
  constructor() {
@@ -3636,71 +3645,61 @@ let ae = class extends C {
3636
3645
  }
3637
3646
  }), this.open = t;
3638
3647
  }
3648
+ _popupClickHandler() {
3649
+ console.log("Popup clicked!");
3650
+ }
3639
3651
  render() {
3640
3652
  return l`
3641
- <div
3642
- class="cb-anchor ${this.open ? "open" : ""}"
3643
- part="cb-anchor"
3644
- @click=${this._clickHandler.bind(this)}
3645
- >
3646
- <sl-button
3647
- label="Start"
3648
- size="large"
3649
- variant="primary"
3650
- class="icon anchor-button"
3651
- circle
3652
- >
3653
- ${B(
3653
+ <div class="cb-anchor ${this.open ? "open" : ""}" part="cb-anchor" @click=${this._clickHandler.bind(this)}>
3654
+ <sl-popup placement="top-end" distance="16">
3655
+ <sl-button slot="anchor" label="Start" size="large" variant="primary" class="icon anchor-button" circle>
3656
+ ${B(
3654
3657
  this.open,
3655
- () => l`<cb-icon
3656
- color="white"
3657
- svg="${je}"
3658
- ></cb-icon>`,
3659
- () => l`<cb-icon
3660
- color="white"
3661
- svg="${zo}"
3662
- ></cb-icon>`
3658
+ () => l`<cb-icon color="white" svg="${$e}"></cb-icon>`,
3659
+ () => l`<cb-icon color="white" svg="${So}"></cb-icon>`
3663
3660
  )}
3664
- </sl-button>
3665
- </div>
3666
- `;
3661
+ </sl-button>
3662
+ <div class="cb-engage-popup">Popup</div>
3663
+ </sl-popup>
3664
+ </div>
3665
+ `;
3667
3666
  }
3668
3667
  };
3669
- ae.styles = Po;
3670
- Ye([
3671
- c({ type: Boolean })
3668
+ ae.styles = Mo;
3669
+ Je([
3670
+ i({ type: Boolean })
3672
3671
  ], ae.prototype, "open", 2);
3673
- ae = Ye([
3672
+ ae = Je([
3674
3673
  x("cb-anchor")
3675
3674
  ], ae);
3676
- const Io = w`
3677
- ${S}
3678
- `, xe = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="currentColor"><path d="M4.54.146A.5.5 0 0 1 4.893 0h6.214a.5.5 0 0 1 .353.146l4.394 4.394a.5.5 0 0 1 .146.353v6.214a.5.5 0 0 1-.146.353l-4.394 4.394a.5.5 0 0 1-.353.146H4.893a.5.5 0 0 1-.353-.146L.146 11.46A.5.5 0 0 1 0 11.107V4.893a.5.5 0 0 1 .146-.353L4.54.146zM5.1 1L1 5.1v5.8L5.1 15h5.8l4.1-4.1V5.1L10.9 1H5.1z"/><path d="M7.002 11a1 1 0 1 1 2 0a1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 4.995z"/></g></svg>', Ge = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="currentColor"><path d="M7.938 2.016A.13.13 0 0 1 8.002 2a.13.13 0 0 1 .063.016a.146.146 0 0 1 .054.057l6.857 11.667c.036.06.035.124.002.183a.163.163 0 0 1-.054.06a.116.116 0 0 1-.066.017H1.146a.115.115 0 0 1-.066-.017a.163.163 0 0 1-.054-.06a.176.176 0 0 1 .002-.183L7.884 2.073a.147.147 0 0 1 .054-.057zm1.044-.45a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566z"/><path d="M7.002 12a1 1 0 1 1 2 0a1 1 0 0 1-2 0zM7.1 5.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995z"/></g></svg>', Qe = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="currentColor"><path d="M2.5 8a5.5 5.5 0 0 1 8.25-4.764a.5.5 0 0 0 .5-.866A6.5 6.5 0 1 0 14.5 8a.5.5 0 0 0-1 0a5.5 5.5 0 1 1-11 0z"/><path d="M15.354 3.354a.5.5 0 0 0-.708-.708L8 9.293L5.354 6.646a.5.5 0 1 0-.708.708l3 3a.5.5 0 0 0 .708 0l7-7z"/></g></svg>', Xe = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="currentColor"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/><path d="m8.93 6.588l-2.29.287l-.082.38l.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319c.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246c-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0a1 1 0 0 1 2 0z"/></g></svg>';
3679
- var Ro = Object.defineProperty, Bo = Object.getOwnPropertyDescriptor, et = (t, e, o, a) => {
3680
- for (var r = a > 1 ? void 0 : a ? Bo(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3681
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
3682
- return a && r && Ro(e, o, r), r;
3675
+ const Lo = v`
3676
+ ${H}
3677
+ `, ze = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="currentColor"><path d="M4.54.146A.5.5 0 0 1 4.893 0h6.214a.5.5 0 0 1 .353.146l4.394 4.394a.5.5 0 0 1 .146.353v6.214a.5.5 0 0 1-.146.353l-4.394 4.394a.5.5 0 0 1-.353.146H4.893a.5.5 0 0 1-.353-.146L.146 11.46A.5.5 0 0 1 0 11.107V4.893a.5.5 0 0 1 .146-.353L4.54.146zM5.1 1L1 5.1v5.8L5.1 15h5.8l4.1-4.1V5.1L10.9 1H5.1z"/><path d="M7.002 11a1 1 0 1 1 2 0a1 1 0 0 1-2 0zM7.1 4.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 4.995z"/></g></svg>', Oo = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="currentColor"><path d="M7.938 2.016A.13.13 0 0 1 8.002 2a.13.13 0 0 1 .063.016a.146.146 0 0 1 .054.057l6.857 11.667c.036.06.035.124.002.183a.163.163 0 0 1-.054.06a.116.116 0 0 1-.066.017H1.146a.115.115 0 0 1-.066-.017a.163.163 0 0 1-.054-.06a.176.176 0 0 1 .002-.183L7.884 2.073a.147.147 0 0 1 .054-.057zm1.044-.45a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566z"/><path d="M7.002 12a1 1 0 1 1 2 0a1 1 0 0 1-2 0zM7.1 5.995a.905.905 0 1 1 1.8 0l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995z"/></g></svg>', Po = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="currentColor"><path d="M2.5 8a5.5 5.5 0 0 1 8.25-4.764a.5.5 0 0 0 .5-.866A6.5 6.5 0 1 0 14.5 8a.5.5 0 0 0-1 0a5.5 5.5 0 1 1-11 0z"/><path d="M15.354 3.354a.5.5 0 0 0-.708-.708L8 9.293L5.354 6.646a.5.5 0 1 0-.708.708l3 3a.5.5 0 0 0 .708 0l7-7z"/></g></svg>', Io = '<svg viewBox="0 0 16 16" width="1.2em" height="1.2em" ><g fill="currentColor"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/><path d="m8.93 6.588l-2.29.287l-.082.38l.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319c.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246c-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0a1 1 0 0 1 2 0z"/></g></svg>';
3678
+ var zo = Object.defineProperty, Eo = Object.getOwnPropertyDescriptor, Ke = (t, e, o, r) => {
3679
+ for (var a = r > 1 ? void 0 : r ? Eo(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3680
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
3681
+ return r && a && zo(e, o, a), a;
3683
3682
  };
3684
- const Te = {
3683
+ const Ee = {
3685
3684
  error: {
3686
3685
  variant: "danger",
3687
- icon: xe
3686
+ icon: ze
3688
3687
  },
3689
3688
  danger: {
3690
3689
  variant: "danger",
3691
- icon: xe
3690
+ icon: ze
3692
3691
  },
3693
3692
  warning: {
3694
3693
  variant: "warning",
3695
- icon: Ge
3694
+ icon: Oo
3696
3695
  },
3697
3696
  success: {
3698
3697
  variant: "success",
3699
- icon: Qe
3698
+ icon: Po
3700
3699
  },
3701
3700
  info: {
3702
3701
  variant: "primary",
3703
- icon: Xe
3702
+ icon: Io
3704
3703
  }
3705
3704
  };
3706
3705
  let se = class extends C {
@@ -3708,23 +3707,23 @@ let se = class extends C {
3708
3707
  super(...arguments), this.status = "info";
3709
3708
  }
3710
3709
  render() {
3711
- const { variant: t, icon: e } = Te[this.status] || Te.info;
3710
+ const { variant: t, icon: e } = Ee[this.status] || Ee.info;
3712
3711
  return l`<cb-icon svg=${e} color="${t}"></cb-icon>`;
3713
3712
  }
3714
3713
  };
3715
- se.styles = Ne;
3716
- et([
3717
- c({ type: String })
3714
+ se.styles = Ue;
3715
+ Ke([
3716
+ i({ type: String })
3718
3717
  ], se.prototype, "status", 2);
3719
- se = et([
3718
+ se = Ke([
3720
3719
  x("cb-status-icon")
3721
3720
  ], se);
3722
- var Vo = Object.defineProperty, qo = Object.getOwnPropertyDescriptor, Do = (t, e, o, a) => {
3723
- for (var r = a > 1 ? void 0 : a ? qo(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3724
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
3725
- return a && r && Vo(e, o, r), r;
3721
+ var To = Object.defineProperty, Ro = Object.getOwnPropertyDescriptor, Bo = (t, e, o, r) => {
3722
+ for (var a = r > 1 ? void 0 : r ? Ro(e, o) : e, s = t.length - 1, n; s >= 0; s--)
3723
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
3724
+ return r && a && To(e, o, a), a;
3726
3725
  };
3727
- let ke = class extends C {
3726
+ let we = class extends C {
3728
3727
  render() {
3729
3728
  return l` <sl-alert variant="danger" open>
3730
3729
  <cb-status-icon status="error" slot="icon"></cb-status-icon>
@@ -3740,14 +3739,14 @@ let ke = class extends C {
3740
3739
  this.emit("setting:show");
3741
3740
  }
3742
3741
  };
3743
- ke.styles = Io;
3744
- ke = Do([
3742
+ we.styles = Lo;
3743
+ we = Bo([
3745
3744
  x("cb-auth-alert")
3746
- ], ke);
3747
- class Ie extends Error {
3748
- constructor(e, o, a) {
3749
- const r = e.status || e.status === 0 ? e.status : "", s = e.statusText || "", n = `${r} ${s}`.trim(), i = n ? `status code ${n}` : "an unknown error";
3750
- super(`Request failed with ${i}`), Object.defineProperty(this, "response", {
3745
+ ], we);
3746
+ class Te extends Error {
3747
+ constructor(e, o, r) {
3748
+ const a = e.status || e.status === 0 ? e.status : "", s = e.statusText || "", n = `${a} ${s}`.trim(), c = n ? `status code ${n}` : "an unknown error";
3749
+ super(`Request failed with ${c}`), Object.defineProperty(this, "response", {
3751
3750
  enumerable: !0,
3752
3751
  configurable: !0,
3753
3752
  writable: !0,
@@ -3762,10 +3761,10 @@ class Ie extends Error {
3762
3761
  configurable: !0,
3763
3762
  writable: !0,
3764
3763
  value: void 0
3765
- }), this.name = "HTTPError", this.response = e, this.request = o, this.options = a;
3764
+ }), this.name = "HTTPError", this.response = e, this.request = o, this.options = r;
3766
3765
  }
3767
3766
  }
3768
- class tt extends Error {
3767
+ class Ye extends Error {
3769
3768
  constructor(e) {
3770
3769
  super("Request timed out"), Object.defineProperty(this, "request", {
3771
3770
  enumerable: !0,
@@ -3775,31 +3774,31 @@ class tt extends Error {
3775
3774
  }), this.name = "TimeoutError", this.request = e;
3776
3775
  }
3777
3776
  }
3778
- const X = (t) => t !== null && typeof t == "object", Y = (...t) => {
3777
+ const ee = (t) => t !== null && typeof t == "object", G = (...t) => {
3779
3778
  for (const e of t)
3780
- if ((!X(e) || Array.isArray(e)) && typeof e < "u")
3779
+ if ((!ee(e) || Array.isArray(e)) && typeof e < "u")
3781
3780
  throw new TypeError("The `options` argument must be an object");
3782
3781
  return Se({}, ...t);
3783
- }, ot = (t = {}, e = {}) => {
3784
- const o = new globalThis.Headers(t), a = e instanceof globalThis.Headers, r = new globalThis.Headers(e);
3785
- for (const [s, n] of r.entries())
3786
- a && n === "undefined" || n === void 0 ? o.delete(s) : o.set(s, n);
3782
+ }, Ge = (t = {}, e = {}) => {
3783
+ const o = new globalThis.Headers(t), r = e instanceof globalThis.Headers, a = new globalThis.Headers(e);
3784
+ for (const [s, n] of a.entries())
3785
+ r && n === "undefined" || n === void 0 ? o.delete(s) : o.set(s, n);
3787
3786
  return o;
3788
3787
  }, Se = (...t) => {
3789
3788
  let e = {}, o = {};
3790
- for (const a of t)
3791
- if (Array.isArray(a))
3792
- Array.isArray(e) || (e = []), e = [...e, ...a];
3793
- else if (X(a)) {
3794
- for (let [r, s] of Object.entries(a))
3795
- X(s) && r in e && (s = Se(e[r], s)), e = { ...e, [r]: s };
3796
- X(a.headers) && (o = ot(o, a.headers), e.headers = o);
3789
+ for (const r of t)
3790
+ if (Array.isArray(r))
3791
+ Array.isArray(e) || (e = []), e = [...e, ...r];
3792
+ else if (ee(r)) {
3793
+ for (let [a, s] of Object.entries(r))
3794
+ ee(s) && a in e && (s = Se(e[a], s)), e = { ...e, [a]: s };
3795
+ ee(r.headers) && (o = Ge(o, r.headers), e.headers = o);
3797
3796
  }
3798
3797
  return e;
3799
- }, Fo = (() => {
3798
+ }, Vo = (() => {
3800
3799
  let t = !1, e = !1;
3801
- const o = typeof globalThis.ReadableStream == "function", a = typeof globalThis.Request == "function";
3802
- return o && a && (e = new globalThis.Request("https://a.com", {
3800
+ const o = typeof globalThis.ReadableStream == "function", r = typeof globalThis.Request == "function";
3801
+ return o && r && (e = new globalThis.Request("https://a.com", {
3803
3802
  body: new globalThis.ReadableStream(),
3804
3803
  method: "POST",
3805
3804
  // @ts-expect-error - Types are outdated.
@@ -3807,20 +3806,20 @@ const X = (t) => t !== null && typeof t == "object", Y = (...t) => {
3807
3806
  return t = !0, "half";
3808
3807
  }
3809
3808
  }).headers.has("Content-Type")), t && !e;
3810
- })(), Zo = typeof globalThis.AbortController == "function", Uo = typeof globalThis.ReadableStream == "function", No = typeof globalThis.FormData == "function", rt = ["get", "post", "put", "patch", "head", "delete"], Wo = {
3809
+ })(), qo = typeof globalThis.AbortController == "function", Do = typeof globalThis.ReadableStream == "function", Fo = typeof globalThis.FormData == "function", Xe = ["get", "post", "put", "patch", "head", "delete"], Uo = {
3811
3810
  json: "application/json",
3812
3811
  text: "text/*",
3813
3812
  formData: "multipart/form-data",
3814
3813
  arrayBuffer: "*/*",
3815
3814
  blob: "*/*"
3816
- }, me = 2147483647, at = Symbol("stop"), Ko = (t) => rt.includes(t) ? t.toUpperCase() : t, Jo = ["get", "put", "head", "delete", "options", "trace"], Yo = [408, 413, 429, 500, 502, 503, 504], st = [413, 429, 503], Re = {
3815
+ }, be = 2147483647, Qe = Symbol("stop"), Zo = (t) => Xe.includes(t) ? t.toUpperCase() : t, No = ["get", "put", "head", "delete", "options", "trace"], Wo = [408, 413, 429, 500, 502, 503, 504], et = [413, 429, 503], Re = {
3817
3816
  limit: 2,
3818
- methods: Jo,
3819
- statusCodes: Yo,
3820
- afterStatusCodes: st,
3817
+ methods: No,
3818
+ statusCodes: Wo,
3819
+ afterStatusCodes: et,
3821
3820
  maxRetryAfter: Number.POSITIVE_INFINITY,
3822
3821
  backoffLimit: Number.POSITIVE_INFINITY
3823
- }, Go = (t = {}) => {
3822
+ }, Jo = (t = {}) => {
3824
3823
  if (typeof t == "number")
3825
3824
  return {
3826
3825
  ...Re,
@@ -3833,81 +3832,81 @@ const X = (t) => t !== null && typeof t == "object", Y = (...t) => {
3833
3832
  return {
3834
3833
  ...Re,
3835
3834
  ...t,
3836
- afterStatusCodes: st
3835
+ afterStatusCodes: et
3837
3836
  };
3838
3837
  };
3839
- async function Qo(t, e, o) {
3840
- return new Promise((a, r) => {
3838
+ async function Ko(t, e, o) {
3839
+ return new Promise((r, a) => {
3841
3840
  const s = setTimeout(() => {
3842
- e && e.abort(), r(new tt(t));
3841
+ e && e.abort(), a(new Ye(t));
3843
3842
  }, o.timeout);
3844
- o.fetch(t).then(a).catch(r).then(() => {
3843
+ o.fetch(t).then(r).catch(a).then(() => {
3845
3844
  clearTimeout(s);
3846
3845
  });
3847
3846
  });
3848
3847
  }
3849
- const Xo = !!globalThis.DOMException;
3848
+ const Yo = !!globalThis.DOMException;
3850
3849
  function Be(t) {
3851
- if (Xo)
3850
+ if (Yo)
3852
3851
  return new DOMException((t == null ? void 0 : t.reason) ?? "The operation was aborted.", "AbortError");
3853
3852
  const e = new Error((t == null ? void 0 : t.reason) ?? "The operation was aborted.");
3854
3853
  return e.name = "AbortError", e;
3855
3854
  }
3856
- async function er(t, { signal: e }) {
3857
- return new Promise((o, a) => {
3855
+ async function Go(t, { signal: e }) {
3856
+ return new Promise((o, r) => {
3858
3857
  if (e) {
3859
3858
  if (e.aborted) {
3860
- a(Be(e));
3859
+ r(Be(e));
3861
3860
  return;
3862
3861
  }
3863
- e.addEventListener("abort", r, { once: !0 });
3862
+ e.addEventListener("abort", a, { once: !0 });
3864
3863
  }
3865
- function r() {
3866
- a(Be(e)), clearTimeout(s);
3864
+ function a() {
3865
+ r(Be(e)), clearTimeout(s);
3867
3866
  }
3868
3867
  const s = setTimeout(() => {
3869
- e == null || e.removeEventListener("abort", r), o();
3868
+ e == null || e.removeEventListener("abort", a), o();
3870
3869
  }, t);
3871
3870
  });
3872
3871
  }
3873
3872
  class ne {
3874
3873
  // eslint-disable-next-line @typescript-eslint/promise-function-async
3875
3874
  static create(e, o) {
3876
- const a = new ne(e, o), r = async () => {
3877
- if (a._options.timeout > me)
3878
- throw new RangeError(`The \`timeout\` option cannot be greater than ${me}`);
3875
+ const r = new ne(e, o), a = async () => {
3876
+ if (r._options.timeout > be)
3877
+ throw new RangeError(`The \`timeout\` option cannot be greater than ${be}`);
3879
3878
  await Promise.resolve();
3880
- let i = await a._fetch();
3881
- for (const u of a._options.hooks.afterResponse) {
3882
- const g = await u(a.request, a._options, a._decorateResponse(i.clone()));
3883
- g instanceof globalThis.Response && (i = g);
3879
+ let c = await r._fetch();
3880
+ for (const g of r._options.hooks.afterResponse) {
3881
+ const w = await g(r.request, r._options, r._decorateResponse(c.clone()));
3882
+ w instanceof globalThis.Response && (c = w);
3884
3883
  }
3885
- if (a._decorateResponse(i), !i.ok && a._options.throwHttpErrors) {
3886
- let u = new Ie(i, a.request, a._options);
3887
- for (const g of a._options.hooks.beforeError)
3888
- u = await g(u);
3889
- throw u;
3884
+ if (r._decorateResponse(c), !c.ok && r._options.throwHttpErrors) {
3885
+ let g = new Te(c, r.request, r._options);
3886
+ for (const w of r._options.hooks.beforeError)
3887
+ g = await w(g);
3888
+ throw g;
3890
3889
  }
3891
- if (a._options.onDownloadProgress) {
3892
- if (typeof a._options.onDownloadProgress != "function")
3890
+ if (r._options.onDownloadProgress) {
3891
+ if (typeof r._options.onDownloadProgress != "function")
3893
3892
  throw new TypeError("The `onDownloadProgress` option must be a function");
3894
- if (!Uo)
3893
+ if (!Do)
3895
3894
  throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
3896
- return a._stream(i.clone(), a._options.onDownloadProgress);
3895
+ return r._stream(c.clone(), r._options.onDownloadProgress);
3897
3896
  }
3898
- return i;
3899
- }, n = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(r) : r();
3900
- for (const [i, u] of Object.entries(Wo))
3901
- n[i] = async () => {
3902
- a.request.headers.set("accept", a.request.headers.get("accept") || u);
3903
- const m = (await n).clone();
3904
- if (i === "json") {
3905
- if (m.status === 204 || (await m.clone().arrayBuffer()).byteLength === 0)
3897
+ return c;
3898
+ }, n = r._options.retry.methods.includes(r.request.method.toLowerCase()) ? r._retry(a) : a();
3899
+ for (const [c, g] of Object.entries(Uo))
3900
+ n[c] = async () => {
3901
+ r.request.headers.set("accept", r.request.headers.get("accept") || g);
3902
+ const _ = (await n).clone();
3903
+ if (c === "json") {
3904
+ if (_.status === 204 || (await _.clone().arrayBuffer()).byteLength === 0)
3906
3905
  return "";
3907
3906
  if (o.parseJson)
3908
- return o.parseJson(await m.text());
3907
+ return o.parseJson(await _.text());
3909
3908
  }
3910
- return m[i]();
3909
+ return _[c]();
3911
3910
  };
3912
3911
  return n;
3913
3912
  }
@@ -3942,17 +3941,17 @@ class ne {
3942
3941
  // TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
3943
3942
  credentials: this._input.credentials || "same-origin",
3944
3943
  ...o,
3945
- headers: ot(this._input.headers, o.headers),
3944
+ headers: Ge(this._input.headers, o.headers),
3946
3945
  hooks: Se({
3947
3946
  beforeRequest: [],
3948
3947
  beforeRetry: [],
3949
3948
  beforeError: [],
3950
3949
  afterResponse: []
3951
3950
  }, o.hooks),
3952
- method: Ko(o.method ?? this._input.method),
3951
+ method: Zo(o.method ?? this._input.method),
3953
3952
  // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
3954
3953
  prefixUrl: String(o.prefixUrl || ""),
3955
- retry: Go(o.retry),
3954
+ retry: Jo(o.retry),
3956
3955
  throwHttpErrors: o.throwHttpErrors !== !1,
3957
3956
  timeout: typeof o.timeout > "u" ? 1e4 : o.timeout,
3958
3957
  fetch: o.fetch ?? globalThis.fetch.bind(globalThis)
@@ -3963,30 +3962,30 @@ class ne {
3963
3962
  throw new Error("`input` must not begin with a slash when using `prefixUrl`");
3964
3963
  this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
3965
3964
  }
3966
- if (Zo) {
3965
+ if (qo) {
3967
3966
  if (this.abortController = new globalThis.AbortController(), this._options.signal) {
3968
- const a = this._options.signal;
3967
+ const r = this._options.signal;
3969
3968
  this._options.signal.addEventListener("abort", () => {
3970
- this.abortController.abort(a.reason);
3969
+ this.abortController.abort(r.reason);
3971
3970
  });
3972
3971
  }
3973
3972
  this._options.signal = this.abortController.signal;
3974
3973
  }
3975
- if (Fo && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
3976
- const r = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, r);
3977
- (No && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
3974
+ if (Vo && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
3975
+ const a = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, a);
3976
+ (Fo && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
3978
3977
  }
3979
3978
  this._options.json !== void 0 && (this._options.body = JSON.stringify(this._options.json), this.request.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json"), this.request = new globalThis.Request(this.request, { body: this._options.body }));
3980
3979
  }
3981
3980
  _calculateRetryDelay(e) {
3982
- if (this._retryCount++, this._retryCount < this._options.retry.limit && !(e instanceof tt)) {
3983
- if (e instanceof Ie) {
3981
+ if (this._retryCount++, this._retryCount < this._options.retry.limit && !(e instanceof Ye)) {
3982
+ if (e instanceof Te) {
3984
3983
  if (!this._options.retry.statusCodes.includes(e.response.status))
3985
3984
  return 0;
3986
- const a = e.response.headers.get("Retry-After");
3987
- if (a && this._options.retry.afterStatusCodes.includes(e.response.status)) {
3988
- let r = Number(a);
3989
- return Number.isNaN(r) ? r = Date.parse(a) - Date.now() : r *= 1e3, typeof this._options.retry.maxRetryAfter < "u" && r > this._options.retry.maxRetryAfter ? 0 : r;
3985
+ const r = e.response.headers.get("Retry-After");
3986
+ if (r && this._options.retry.afterStatusCodes.includes(e.response.status)) {
3987
+ let a = Number(r);
3988
+ return Number.isNaN(a) ? a = Date.parse(r) - Date.now() : a *= 1e3, typeof this._options.retry.maxRetryAfter < "u" && a > this._options.retry.maxRetryAfter ? 0 : a;
3990
3989
  }
3991
3990
  if (e.response.status === 413)
3992
3991
  return 0;
@@ -4003,16 +4002,16 @@ class ne {
4003
4002
  try {
4004
4003
  return await e();
4005
4004
  } catch (o) {
4006
- const a = Math.min(this._calculateRetryDelay(o), me);
4007
- if (a !== 0 && this._retryCount > 0) {
4008
- await er(a, { signal: this._options.signal });
4009
- for (const r of this._options.hooks.beforeRetry)
4010
- if (await r({
4005
+ const r = Math.min(this._calculateRetryDelay(o), be);
4006
+ if (r !== 0 && this._retryCount > 0) {
4007
+ await Go(r, { signal: this._options.signal });
4008
+ for (const a of this._options.hooks.beforeRetry)
4009
+ if (await a({
4011
4010
  request: this.request,
4012
4011
  options: this._options,
4013
4012
  error: o,
4014
4013
  retryCount: this._retryCount
4015
- }) === at)
4014
+ }) === Qe)
4016
4015
  return;
4017
4016
  return this._retry(e);
4018
4017
  }
@@ -4029,34 +4028,34 @@ class ne {
4029
4028
  if (o instanceof Response)
4030
4029
  return o;
4031
4030
  }
4032
- return this._options.timeout === !1 ? this._options.fetch(this.request.clone()) : Qo(this.request.clone(), this.abortController, this._options);
4031
+ return this._options.timeout === !1 ? this._options.fetch(this.request.clone()) : Ko(this.request.clone(), this.abortController, this._options);
4033
4032
  }
4034
4033
  /* istanbul ignore next */
4035
4034
  _stream(e, o) {
4036
- const a = Number(e.headers.get("content-length")) || 0;
4037
- let r = 0;
4038
- return e.status === 204 ? (o && o({ percent: 1, totalBytes: a, transferredBytes: r }, new Uint8Array()), new globalThis.Response(null, {
4035
+ const r = Number(e.headers.get("content-length")) || 0;
4036
+ let a = 0;
4037
+ return e.status === 204 ? (o && o({ percent: 1, totalBytes: r, transferredBytes: a }, new Uint8Array()), new globalThis.Response(null, {
4039
4038
  status: e.status,
4040
4039
  statusText: e.statusText,
4041
4040
  headers: e.headers
4042
4041
  })) : new globalThis.Response(new globalThis.ReadableStream({
4043
4042
  async start(s) {
4044
4043
  const n = e.body.getReader();
4045
- o && o({ percent: 0, transferredBytes: 0, totalBytes: a }, new Uint8Array());
4046
- async function i() {
4047
- const { done: u, value: g } = await n.read();
4048
- if (u) {
4044
+ o && o({ percent: 0, transferredBytes: 0, totalBytes: r }, new Uint8Array());
4045
+ async function c() {
4046
+ const { done: g, value: w } = await n.read();
4047
+ if (g) {
4049
4048
  s.close();
4050
4049
  return;
4051
4050
  }
4052
4051
  if (o) {
4053
- r += g.byteLength;
4054
- const m = a === 0 ? 0 : r / a;
4055
- o({ percent: m, transferredBytes: r, totalBytes: a }, g);
4052
+ a += w.byteLength;
4053
+ const _ = r === 0 ? 0 : a / r;
4054
+ o({ percent: _, transferredBytes: a, totalBytes: r }, w);
4056
4055
  }
4057
- s.enqueue(g), await i();
4056
+ s.enqueue(w), await c();
4058
4057
  }
4059
- await i();
4058
+ await c();
4060
4059
  }
4061
4060
  }), {
4062
4061
  status: e.status,
@@ -4066,12 +4065,12 @@ class ne {
4066
4065
  }
4067
4066
  }
4068
4067
  /*! MIT License © Sindre Sorhus */
4069
- const _e = (t) => {
4070
- const e = (o, a) => ne.create(o, Y(t, a));
4071
- for (const o of rt)
4072
- e[o] = (a, r) => ne.create(a, Y(t, r, { method: o }));
4073
- return e.create = (o) => _e(Y(o)), e.extend = (o) => _e(Y(t, o)), e.stop = at, e;
4074
- }, tr = _e(), or = tr, nt = or.extend({
4068
+ const xe = (t) => {
4069
+ const e = (o, r) => ne.create(o, G(t, r));
4070
+ for (const o of Xe)
4071
+ e[o] = (r, a) => ne.create(r, G(t, a, { method: o }));
4072
+ return e.create = (o) => xe(G(o)), e.extend = (o) => xe(G(t, o)), e.stop = Qe, e;
4073
+ }, Xo = xe(), Qo = Xo, er = Qo.extend({
4075
4074
  hooks: {
4076
4075
  beforeRequest: [
4077
4076
  () => {
@@ -4079,18 +4078,18 @@ const _e = (t) => {
4079
4078
  ]
4080
4079
  }
4081
4080
  });
4082
- async function rr(t, e) {
4083
- const { onmessage: o, onclose: a, ...r } = e, s = async (n, i) => {
4084
- const { value: u, done: g } = await i.read();
4085
- g ? (n.close(), a == null || a()) : (o == null || o(u), n.enqueue(u), s(n, i));
4081
+ async function tr(t, e) {
4082
+ const { onmessage: o, onclose: r, ...a } = e, s = async (n, c) => {
4083
+ const { value: g, done: w } = await c.read();
4084
+ w ? (n.close(), r == null || r()) : (o == null || o(g), n.enqueue(g), s(n, c));
4086
4085
  };
4087
- return r.body && typeof r.body == "object" && (r.body = JSON.stringify(r.body)), console.log("Fetching:", r), fetch(t, r).then((n) => {
4088
- const i = n.body.getReader();
4086
+ return a.body && typeof a.body == "object" && (a.body = JSON.stringify(a.body)), console.log("Fetching:", a), fetch(t, a).then((n) => {
4087
+ const c = n.body.getReader();
4089
4088
  return new ReadableStream({
4090
- start(g) {
4089
+ start(w) {
4091
4090
  s(
4092
- g,
4093
- i
4091
+ w,
4092
+ c
4094
4093
  );
4095
4094
  }
4096
4095
  });
@@ -4100,119 +4099,39 @@ async function rr(t, e) {
4100
4099
  }).text()
4101
4100
  );
4102
4101
  }
4103
- async function ar(t, e) {
4104
- const o = t.getReader(), a = new TextDecoder("utf-8");
4105
- let r = !1;
4106
- for (; !r; ) {
4107
- const { value: s, done: n } = await o.read();
4108
- if (s) {
4109
- let i = a.decode(s);
4110
- const u = i.lastIndexOf("data:"), g = i.lastIndexOf(`
4111
- `);
4112
- if (u !== -1 && (i = i.slice(u + 6)), g !== -1 && (i = i.slice(0, g)), i = i.trim(), i === `
4113
- ` || i === "")
4114
- continue;
4115
- if (i === "[DONE]") {
4116
- r = !0;
4117
- continue;
4118
- }
4119
- try {
4120
- const m = JSON.parse(i);
4121
- e(null, m);
4122
- } catch (m) {
4123
- console.log("error", m), e(m, null);
4124
- }
4125
- }
4126
- r = n;
4127
- }
4128
- }
4129
- async function sr(t) {
4130
- var r;
4131
- if (!t.apiKey)
4132
- throw new Error("apiKey is required");
4133
- const e = t.options ?? {};
4134
- e.model || (e.model = "gpt-3.5-turbo");
4135
- const o = await nt.post(t.url, {
4136
- json: {
4137
- messages: t.messages,
4138
- ...t.options ?? {}
4139
- },
4140
- headers: {
4141
- "Content-Type": "application/json",
4142
- Authorization: `Bearer ${t.apiKey}`
4143
- },
4144
- timeout: 1e3 * 60 * 10,
4145
- signal: t.signal
4146
- }), a = o.body;
4147
- if (!a)
4148
- throw new Error("No data");
4149
- if ((r = t.options) != null && r.stream) {
4150
- await ar(a, t.onMessage);
4151
- return;
4152
- }
4153
- return o.json();
4154
- }
4155
- async function nr(t, e) {
4102
+ async function or(t, e) {
4156
4103
  const o = new FormData();
4157
- for (let r = 0; r < e.length; r++)
4158
- o.append("files", e[r]);
4159
- const a = await nt.post(t, {
4104
+ for (let a = 0; a < e.length; a++)
4105
+ o.append("files", e[a]);
4106
+ const r = await er.post(t, {
4160
4107
  body: o
4161
4108
  });
4162
4109
  try {
4163
- return await a.json();
4164
- } catch (r) {
4110
+ return await r.json();
4111
+ } catch (a) {
4165
4112
  return {
4166
4113
  code: 1,
4167
4114
  url: "",
4168
- message: r.message
4115
+ message: a.message
4169
4116
  };
4170
4117
  }
4171
4118
  }
4172
- const Ve = {
4173
- error: {
4174
- variant: "danger",
4175
- icon: xe
4176
- },
4177
- warning: {
4178
- variant: "warning",
4179
- icon: Ge
4180
- },
4181
- success: {
4182
- variant: "success",
4183
- icon: Qe
4184
- },
4185
- info: {
4186
- variant: "primary",
4187
- icon: Xe
4188
- }
4189
- };
4190
- function ir(t) {
4191
- const e = document.createElement("div");
4192
- return e.textContent = t, e.innerHTML;
4193
- }
4194
- function lr(t = "info", e, o = 1e8) {
4195
- const { variant: a, icon: r } = Ve[t] || Ve.info, s = Object.assign(document.createElement("sl-alert"), {
4196
- variant: a,
4197
- closable: !0,
4198
- duration: o,
4199
- innerHTML: `
4200
- <cb-status-icon slot="icon" status="${t}"></cb-status-icon>
4201
- ${ir(e)}
4202
- `
4203
- });
4204
- return document.body.append(s), s.toast();
4205
- }
4206
- var cr = Object.defineProperty, dr = Object.getOwnPropertyDescriptor, _ = (t, e, o, a) => {
4207
- for (var r = a > 1 ? void 0 : a ? dr(e, o) : e, s = t.length - 1, n; s >= 0; s--)
4208
- (n = t[s]) && (r = (a ? n(e, o, r) : n(r)) || r);
4209
- return a && r && cr(e, o, r), r;
4119
+ var rr = Object.defineProperty, ar = Object.getOwnPropertyDescriptor, y = (t, e, o, r) => {
4120
+ for (var a = r > 1 ? void 0 : r ? ar(e, o) : e, s = t.length - 1, n; s >= 0; s--)
4121
+ (n = t[s]) && (a = (r ? n(e, o, a) : n(a)) || a);
4122
+ return r && a && rr(e, o, a), a;
4210
4123
  };
4211
- const ee = ce.noConflict();
4212
- ee.setLevel("info");
4213
- let v = class extends C {
4124
+ const ke = ce.noConflict();
4125
+ ke.setLevel("info");
4126
+ let u = class extends C {
4214
4127
  constructor() {
4215
- super(...arguments), this.store = new ft(this, b), this.displayLicense = !1, this.name = "ChatBot", this.orgId = "", this.botId = "", this.url = "ws://localhost:3070", this.welcomeMessage = "Hello! How can I help you today ?", this.stream = !1, this.customRequest = !1, this.enableFileUpload = !1, this.uploadFileUrl = "", this.open = !1, this.loading = !1, this.showSetting = !1, this.showAuthAlert = !1, this.fetchStream = rr;
4128
+ super(...arguments), this.store = new ht(this, m), this.displayLicense = !1, this.name = "ChatBot", this.orgId = "", this.botId = "", this.url = "ws://localhost:3070", this.welcomeMessage = "Hello! How can I help you today ?", this.logoSvg = ` <svg width="24" height="24" viewBox="0 0 40 40">
4129
+ <path
4130
+ d="M34.728 0.275L2.245 15.267c-3.748 1.749 -2.498 7.246 1.499 7.246h13.743v13.743c0 3.998 5.497 5.248 7.246 1.499l14.992 -32.483c1.249 -2.999 -1.999 -6.248 -4.998 -4.998z"
4131
+ fill="#E24D42"
4132
+ ></path>
4133
+ </svg>
4134
+ `, this.botIconSvg = '<svg fill="currentColor" width="24" height="24" viewBox="0 0 24 24"> <path d="M16 17V19H2V17S2 13 9 13 16 17 16 17M12.5 7.5A3.5 3.5 0 1 0 9 11A3.5 3.5 0 0 0 12.5 7.5M15.94 13A5.32 5.32 0 0 1 18 17V19H22V17S22 13.37 15.94 13M15 4A3.39 3.39 0 0 0 13.07 4.59A5 5 0 0 1 13.07 10.41A3.39 3.39 0 0 0 15 11A3.5 3.5 0 0 0 15 4Z" /></svg>', this.userIconSvg = '<svg fill="currentColor" viewBox="0 0 24 24" width="24" height="24"> <path d="M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4Z" /></svg>', this.systemIconSvg = '<svg fill="currentColor" width="24" height="24" viewBox="0 0 24 24"> <path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z"/></svg>', this.stream = !1, this.customRequest = !1, this.enableFileUpload = !1, this.uploadFileUrl = "", this.open = !1, this.loading = !1, this.showSetting = !1, this.showAuthAlert = !1, this.fetchStream = tr;
4216
4135
  }
4217
4136
  /**
4218
4137
  * decodeStreamData
@@ -4227,20 +4146,20 @@ let v = class extends C {
4227
4146
  isThinking: !0,
4228
4147
  data: {}
4229
4148
  };
4230
- return b.addMessage(t), t;
4149
+ return m.addMessage(t), t;
4231
4150
  }
4232
4151
  render() {
4233
- return l`
4152
+ return m.disabled ? (ke.error("Bot is disabled"), null) : l`
4234
4153
  <div class="cb-wrapper" style="${this.open ? "display:flex" : "display:none"}">
4235
4154
  <cb-header title="${this.name}"></cb-header>
4236
- <cb-message-list .messages=${b.messages} .actions=${b.actions}></cb-message-list>
4155
+ <cb-message-list .messages=${m.messages} .actions=${m.actions}></cb-message-list>
4237
4156
  <cb-user-input ?loading=${this.loading} ?disabled=${this.loading || this.showAuthAlert} ?enable-file-upload=${this.enableFileUpload}></cb-user-input>
4238
4157
  </div>
4239
4158
  <cb-anchor ?open=${this.open}></cb-anchor>
4240
4159
  `;
4241
4160
  }
4242
4161
  connectedCallback() {
4243
- super.connectedCallback(), ee.info("connectedCallback"), addEventListener("setting:show", () => {
4162
+ super.connectedCallback(), ke.info("connectedCallback"), addEventListener("setting:show", () => {
4244
4163
  this.showSetting = !0;
4245
4164
  }), addEventListener("message:send", this._addMessageHandler.bind(this)), addEventListener("message:remove", this._deleteMessageHandler.bind(this)), addEventListener("setting:confirm", this._settingConfirmHandler.bind(this)), addEventListener("setting:hide", () => {
4246
4165
  this.showSetting = !1;
@@ -4248,7 +4167,7 @@ let v = class extends C {
4248
4167
  const e = t.detail;
4249
4168
  this.open = e.open;
4250
4169
  }), addEventListener("message:clear", () => {
4251
- b.clearMessages();
4170
+ m.clearMessages();
4252
4171
  }), addEventListener("message:send:file", this._sendFileHandler.bind(this)), addEventListener("setting:show", () => {
4253
4172
  this.showSetting = !0;
4254
4173
  });
@@ -4257,116 +4176,131 @@ let v = class extends C {
4257
4176
  // Use to initialize
4258
4177
  // This is also called when state changes - ??? - i.e. when message added to the array
4259
4178
  updated(t) {
4260
- super.updated(t), ee.info("updated,_changedProperties:", t), t.size > 0 && this._initSetting(), setTimeout(() => {
4179
+ super.updated(t), t.size > 0 && this._initSetting(), setTimeout(() => {
4261
4180
  this._scrollToBottom();
4262
4181
  }, 0);
4263
4182
  }
4264
4183
  // initialize setting
4265
4184
  _initSetting() {
4266
- ee.info("_initSetting");
4267
- const t = b.setting;
4268
- t.orgId = this.orgId, t.botId = this.botId, t.url = this.url, t.welcomeMessage = this.welcomeMessage, b.setSetting(t);
4185
+ const t = m.setting;
4186
+ t.orgId = this.orgId, t.botId = this.botId, t.url = this.url, t.welcomeMessage = this.welcomeMessage, t.logoSvg = this.logoSvg, t.botIconSvg = this.botIconSvg, t.userIconSvg = this.userIconSvg, t.systemIconSvg = this.systemIconSvg, m.setSetting(t);
4269
4187
  }
4270
4188
  setLoading(t) {
4271
4189
  this.loading = t;
4272
4190
  }
4273
4191
  clearConversation() {
4274
- b.clearConversation();
4192
+ m.clearConversation();
4275
4193
  }
4276
4194
  // check auth
4277
4195
  _checkAuth() {
4278
4196
  }
4279
- // send to openai
4280
- async _sendToOpenai(t, e) {
4281
- let o = "";
4282
- const a = b.setting.openai.apiBase || "https://api.openai.com/v1", r = await sr({
4283
- url: `${a}/chat/completions`,
4284
- apiKey: b.setting.openai.apiKey,
4285
- messages: e,
4197
+ /* TODO Remove
4198
+ private async _sendToOpenai(newMsg: Chatbot.NewMessage, messages: Chatbot.OpenaiMessage[]) {
4199
+ let text = '';
4200
+ const apiBase = appState.setting.openai.apiBase || 'https://api.openai.com/v1';
4201
+ const data = await openai.chat({
4202
+ url: `${apiBase}/chat/completions`,
4203
+ apiKey: appState.setting.openai.apiKey,
4204
+ messages: messages,
4286
4205
  options: {
4287
- stream: b.setting.stream,
4288
- model: b.setting.openai.model
4206
+ stream: appState.setting.stream,
4207
+ model: appState.setting.openai.model,
4289
4208
  // temperature: 0.9,
4290
4209
  },
4291
- onMessage: (s, n) => {
4292
- var i;
4293
- if (s) {
4294
- console.error(s);
4210
+ onMessage: (err, data) => {
4211
+ if (err) {
4212
+ console.error(err);
4295
4213
  return;
4296
4214
  }
4297
- n && ((i = n.choices[0].delta) != null && i.content) && requestIdleCallback(() => {
4298
- o += n.choices[0].delta.content, b.updateMessage(t, o);
4299
- });
4300
- }
4215
+ if (data && data.choices[0].delta?.content) {
4216
+ requestIdleCallback(() => {
4217
+ // handle openai response
4218
+ text += data.choices[0].delta.content;
4219
+ // update message
4220
+ appState.updateMessage(newMsg, text);
4221
+ });
4222
+ }
4223
+ },
4301
4224
  });
4302
- !b.setting.stream && r && b.updateMessage(t, r.choices[0].message.content);
4303
- }
4304
- // send to bot service
4305
- async _sendHandler(t) {
4306
- this.setLoading(!0);
4307
- const e = {
4308
- author: "assistant",
4309
- type: "text",
4310
- isThinking: !0,
4311
- data: {}
4312
- };
4313
- if (b.addMessage(e), this.customRequest)
4314
- await this.emit("chatbot:send", {
4315
- detail: {
4316
- newMessage: e,
4317
- messages: t
4318
- },
4319
- bubbles: !0,
4320
- composed: !0
4321
- });
4322
- else
4323
- try {
4324
- await this._sendToOpenai(e, t);
4325
- } catch (o) {
4326
- lr("error", o.message), console.error(o);
4225
+ if (!appState.setting.stream && data) {
4226
+ // update message
4227
+ appState.updateMessage(newMsg, data.choices[0].message.content);
4228
+ }
4229
+ } */
4230
+ /* TODO Remove
4231
+ private async _sendHandler(messages: Chatbot.OpenaiMessage[]) {
4232
+ this.setLoading(true);
4233
+
4234
+ const newMsg: Chatbot.NewMessage = {
4235
+ author: 'assistant',
4236
+ type: 'text',
4237
+ isThinking: true,
4238
+ data: {},
4239
+ };
4240
+
4241
+ // add message to store
4242
+ appState.addMessage(newMsg);
4243
+
4244
+ if (this.customRequest) {
4245
+ await this.emit('chatbot:send', {
4246
+ detail: {
4247
+ newMessage: newMsg,
4248
+ messages,
4249
+ },
4250
+ bubbles: true,
4251
+ composed: true,
4252
+ });
4253
+ } else {
4254
+ try {
4255
+ await this._sendToOpenai(newMsg, messages);
4256
+ } catch (err) {
4257
+ notify('error', (err as Error).message);
4258
+ console.error(err);
4259
+ }
4327
4260
  }
4328
- this.setLoading(!1);
4329
- }
4261
+
4262
+ this.setLoading(false);
4263
+ }*/
4330
4264
  _addMessageHandler(t) {
4331
4265
  const e = t.detail;
4332
- b.sendMessage(e);
4266
+ m.sendMessage(e);
4333
4267
  }
4334
4268
  _deleteMessageHandler(t) {
4335
4269
  const e = t.detail;
4336
- b.removeMessage(e.id);
4270
+ m.removeMessage(e.id);
4337
4271
  }
4338
4272
  async _sendFileHandler(t) {
4339
- const e = t.detail, a = {
4273
+ const e = t.detail, r = {
4340
4274
  author: "user",
4341
4275
  type: "file",
4342
4276
  isUploading: !0,
4343
4277
  data: {
4344
- files: e.files.map((r, s) => ({
4345
- id: `${r.name}-${s}`,
4346
- name: r.name,
4347
- size: r.size,
4348
- type: r.type,
4278
+ files: e.files.map((a, s) => ({
4279
+ id: `${a.name}-${s}`,
4280
+ name: a.name,
4281
+ size: a.size,
4282
+ type: a.type,
4349
4283
  url: ""
4350
4284
  }))
4351
4285
  }
4352
4286
  };
4353
- if (b.addMessage(a), this.uploadFileUrl) {
4354
- const r = await nr(this.uploadFileUrl, e.files);
4355
- r.code === 0 && r.data && (a.isUploading = !1, a.data = {
4356
- files: r.data
4357
- }, b.updateMessage(a));
4287
+ if (m.addMessage(r), this.uploadFileUrl) {
4288
+ const a = await or(this.uploadFileUrl, e.files);
4289
+ a.code === 0 && a.data && (r.isUploading = !1, r.data = {
4290
+ files: a.data
4291
+ }, m.updateMessage(r));
4358
4292
  }
4359
4293
  this.emit("chatbot:file:send", {
4360
4294
  detail: {
4361
4295
  files: e.files,
4362
- message: a
4296
+ message: r
4363
4297
  }
4364
4298
  });
4365
4299
  }
4366
4300
  // setting confirm handler
4367
4301
  _settingConfirmHandler(t) {
4368
4302
  const e = t.detail;
4369
- b.setSetting(e.setting), this.showSetting = !1, this._checkAuth();
4303
+ m.setSetting(e.setting), this.showSetting = !1, this._checkAuth();
4370
4304
  }
4371
4305
  // scroll to bottom
4372
4306
  _scrollToBottom(t = !1) {
@@ -4374,60 +4308,73 @@ let v = class extends C {
4374
4308
  var e;
4375
4309
  (e = this._messageList) == null || e.scrollTo({
4376
4310
  top: this._messageList.scrollHeight,
4377
- behavior: t ? "smooth" : "auto"
4311
+ behavior: "auto"
4312
+ //smooth ? 'smooth' : 'auto',
4378
4313
  });
4379
4314
  });
4380
4315
  }
4381
4316
  };
4382
- v.styles = _t;
4383
- _([
4384
- c({ type: Boolean, attribute: "display-license" })
4385
- ], v.prototype, "displayLicense", 2);
4386
- _([
4387
- c({ type: String, attribute: "name" })
4388
- ], v.prototype, "name", 2);
4389
- _([
4390
- c({ type: String, attribute: "org-id" })
4391
- ], v.prototype, "orgId", 2);
4392
- _([
4393
- c({ type: String, attribute: "bot-id" })
4394
- ], v.prototype, "botId", 2);
4395
- _([
4396
- c({ type: String, attribute: "url" })
4397
- ], v.prototype, "url", 2);
4398
- _([
4399
- c({ type: String, attribute: "welcome-message" })
4400
- ], v.prototype, "welcomeMessage", 2);
4401
- _([
4402
- c({ type: Boolean, attribute: "stream" })
4403
- ], v.prototype, "stream", 2);
4404
- _([
4405
- c({ type: Boolean, attribute: "custom-request" })
4406
- ], v.prototype, "customRequest", 2);
4407
- _([
4408
- c({ type: Boolean, attribute: "enable-file-upload" })
4409
- ], v.prototype, "enableFileUpload", 2);
4410
- _([
4411
- c({ type: String, attribute: "upload-file-url" })
4412
- ], v.prototype, "uploadFileUrl", 2);
4413
- _([
4414
- c({ type: Boolean, attribute: "open" })
4415
- ], v.prototype, "open", 2);
4416
- _([
4417
- c({ type: Boolean })
4418
- ], v.prototype, "loading", 2);
4419
- _([
4420
- c({ type: Boolean })
4421
- ], v.prototype, "showSetting", 2);
4422
- _([
4423
- c({ type: Boolean })
4424
- ], v.prototype, "showAuthAlert", 2);
4425
- _([
4426
- Ce("cb-message-list")
4427
- ], v.prototype, "_messageList", 2);
4428
- v = _([
4429
- x("chat-bot")
4430
- ], v);
4317
+ u.styles = ft;
4318
+ y([
4319
+ i({ type: Boolean, attribute: "display-license" })
4320
+ ], u.prototype, "displayLicense", 2);
4321
+ y([
4322
+ i({ type: String, attribute: "name" })
4323
+ ], u.prototype, "name", 2);
4324
+ y([
4325
+ i({ type: String, attribute: "org-id" })
4326
+ ], u.prototype, "orgId", 2);
4327
+ y([
4328
+ i({ type: String, attribute: "bot-id" })
4329
+ ], u.prototype, "botId", 2);
4330
+ y([
4331
+ i({ type: String, attribute: "url" })
4332
+ ], u.prototype, "url", 2);
4333
+ y([
4334
+ i({ type: String, attribute: "welcome-message" })
4335
+ ], u.prototype, "welcomeMessage", 2);
4336
+ y([
4337
+ i({ type: String, attribute: "logo-svg" })
4338
+ ], u.prototype, "logoSvg", 2);
4339
+ y([
4340
+ i({ type: String, attribute: "bot-icon-svg" })
4341
+ ], u.prototype, "botIconSvg", 2);
4342
+ y([
4343
+ i({ type: String, attribute: "user-icon-svg" })
4344
+ ], u.prototype, "userIconSvg", 2);
4345
+ y([
4346
+ i({ type: String, attribute: "system-icon-svg" })
4347
+ ], u.prototype, "systemIconSvg", 2);
4348
+ y([
4349
+ i({ type: Boolean, attribute: "stream" })
4350
+ ], u.prototype, "stream", 2);
4351
+ y([
4352
+ i({ type: Boolean, attribute: "custom-request" })
4353
+ ], u.prototype, "customRequest", 2);
4354
+ y([
4355
+ i({ type: Boolean, attribute: "enable-file-upload" })
4356
+ ], u.prototype, "enableFileUpload", 2);
4357
+ y([
4358
+ i({ type: String, attribute: "upload-file-url" })
4359
+ ], u.prototype, "uploadFileUrl", 2);
4360
+ y([
4361
+ i({ type: Boolean, attribute: "open" })
4362
+ ], u.prototype, "open", 2);
4363
+ y([
4364
+ i({ type: Boolean })
4365
+ ], u.prototype, "loading", 2);
4366
+ y([
4367
+ i({ type: Boolean })
4368
+ ], u.prototype, "showSetting", 2);
4369
+ y([
4370
+ i({ type: Boolean })
4371
+ ], u.prototype, "showAuthAlert", 2);
4372
+ y([
4373
+ _e("cb-message-list")
4374
+ ], u.prototype, "_messageList", 2);
4375
+ u = y([
4376
+ x("enegelai-bot")
4377
+ ], u);
4431
4378
  export {
4432
- v as default
4379
+ u as default
4433
4380
  };