quikchat 1.0.1 → 1.0.3
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/README.md +10 -1
- package/dist/quikchat.cjs.js +193 -20
- package/dist/quikchat.cjs.js.map +1 -1
- package/dist/quikchat.cjs.min.js +1 -1
- package/dist/quikchat.cjs.min.js.map +1 -1
- package/dist/quikchat.css +26 -9
- package/dist/quikchat.esm.js +193 -20
- package/dist/quikchat.esm.js.map +1 -1
- package/dist/quikchat.esm.min.js +1 -1
- package/dist/quikchat.esm.min.js.map +1 -1
- package/dist/quikchat.umd.js +193 -20
- package/dist/quikchat.umd.js.map +1 -1
- package/dist/quikchat.umd.min.js +1 -1
- package/dist/quikchat.umd.min.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -6,9 +6,12 @@ quikchat is a simple vanilla (no dependancies) JavaScript chat control that can
|
|
|
6
6
|
* Responsive design for various screen sizes.
|
|
7
7
|
* Themeable with css
|
|
8
8
|
* Hideable/Showable Title and Text Entry areas allows flexibility of usage
|
|
9
|
+
* Full history storage and retrieval
|
|
10
|
+
* History can be fed directly to OpenAI / Mistral / Ollama compatible API
|
|
9
11
|
|
|
10
12
|
## Demo
|
|
11
|
-
[Example Code and Demo](
|
|
13
|
+
[Example Code and Demo](../examples/index.html)
|
|
14
|
+
|
|
12
15
|
|
|
13
16
|
|
|
14
17
|
## Installation
|
|
@@ -23,6 +26,12 @@ html
|
|
|
23
26
|
<link rel="stylesheet" href="./path/to/quikchat.css">
|
|
24
27
|
```
|
|
25
28
|
|
|
29
|
+
### use quikchat Via CDN
|
|
30
|
+
```html
|
|
31
|
+
<script src="https://unpkg.com/quikchat"></script>
|
|
32
|
+
<link rel="stylesheet" href="https://unpkg.com/quikchat/dist/quikchat.css" />
|
|
33
|
+
```
|
|
34
|
+
|
|
26
35
|
Create a container element in your HTML where you want the chat interface to appear:
|
|
27
36
|
```html
|
|
28
37
|
<div id="chat-container"></div>
|
package/dist/quikchat.cjs.js
CHANGED
|
@@ -18,16 +18,45 @@ function _defineProperties(e, r) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
function _createClass(e, r, t) {
|
|
21
|
-
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
21
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
22
22
|
writable: !1
|
|
23
23
|
}), e;
|
|
24
24
|
}
|
|
25
|
+
function _defineProperty(e, r, t) {
|
|
26
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
27
|
+
value: t,
|
|
28
|
+
enumerable: !0,
|
|
29
|
+
configurable: !0,
|
|
30
|
+
writable: !0
|
|
31
|
+
}) : e[r] = t, e;
|
|
32
|
+
}
|
|
25
33
|
function _iterableToArray(r) {
|
|
26
34
|
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
27
35
|
}
|
|
28
36
|
function _nonIterableSpread() {
|
|
29
37
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
30
38
|
}
|
|
39
|
+
function ownKeys(e, r) {
|
|
40
|
+
var t = Object.keys(e);
|
|
41
|
+
if (Object.getOwnPropertySymbols) {
|
|
42
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
43
|
+
r && (o = o.filter(function (r) {
|
|
44
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
45
|
+
})), t.push.apply(t, o);
|
|
46
|
+
}
|
|
47
|
+
return t;
|
|
48
|
+
}
|
|
49
|
+
function _objectSpread2(e) {
|
|
50
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
51
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
52
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
53
|
+
_defineProperty(e, r, t[r]);
|
|
54
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
55
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return e;
|
|
59
|
+
}
|
|
31
60
|
function _toConsumableArray(r) {
|
|
32
61
|
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
33
62
|
}
|
|
@@ -53,14 +82,27 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
53
82
|
}
|
|
54
83
|
}
|
|
55
84
|
|
|
56
|
-
// quikchat.js
|
|
57
85
|
var quikchat = /*#__PURE__*/function () {
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* @param string or DOM element parentElement
|
|
89
|
+
* @param {*} meta
|
|
90
|
+
*/
|
|
58
91
|
function quikchat(parentElement) {
|
|
59
92
|
var meta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
60
93
|
theme: 'quikchat-theme-light',
|
|
61
|
-
onSend: function onSend() {}
|
|
94
|
+
onSend: function onSend() {},
|
|
95
|
+
trackHistory: true,
|
|
96
|
+
titleArea: {
|
|
97
|
+
title: "Title Area",
|
|
98
|
+
show: false,
|
|
99
|
+
align: "center"
|
|
100
|
+
}
|
|
62
101
|
};
|
|
63
102
|
_classCallCheck(this, quikchat);
|
|
103
|
+
if (typeof parentElement === 'string') {
|
|
104
|
+
parentElement = document.querySelector(parentElement);
|
|
105
|
+
}
|
|
64
106
|
this._parentElement = parentElement;
|
|
65
107
|
this._theme = meta.theme;
|
|
66
108
|
this._onSend = meta.onSend ? meta.onSend : function () {};
|
|
@@ -68,13 +110,16 @@ var quikchat = /*#__PURE__*/function () {
|
|
|
68
110
|
// title area
|
|
69
111
|
if (meta.titleArea) {
|
|
70
112
|
this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);
|
|
71
|
-
if (meta.titleArea.show) {
|
|
113
|
+
if (meta.titleArea.show == true) {
|
|
72
114
|
this.titleAreaShow();
|
|
73
115
|
} else {
|
|
74
116
|
this.titleAreaHide();
|
|
75
117
|
}
|
|
76
118
|
}
|
|
77
119
|
this._attachEventListeners();
|
|
120
|
+
this.trackHistory = meta.trackHistory || true;
|
|
121
|
+
this._historyLimit = 10000000;
|
|
122
|
+
this._history = [];
|
|
78
123
|
}
|
|
79
124
|
return _createClass(quikchat, [{
|
|
80
125
|
key: "_createWidget",
|
|
@@ -89,9 +134,6 @@ var quikchat = /*#__PURE__*/function () {
|
|
|
89
134
|
this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');
|
|
90
135
|
this.msgid = 0;
|
|
91
136
|
}
|
|
92
|
-
}, {
|
|
93
|
-
key: "$",
|
|
94
|
-
value: function $() {}
|
|
95
137
|
}, {
|
|
96
138
|
key: "_attachEventListeners",
|
|
97
139
|
value: function _attachEventListeners() {
|
|
@@ -114,6 +156,20 @@ var quikchat = /*#__PURE__*/function () {
|
|
|
114
156
|
}
|
|
115
157
|
});
|
|
116
158
|
}
|
|
159
|
+
// set the onSend function callback.
|
|
160
|
+
}, {
|
|
161
|
+
key: "setCallbackOnSend",
|
|
162
|
+
value: function setCallbackOnSend(callback) {
|
|
163
|
+
this._onSend = callback;
|
|
164
|
+
}
|
|
165
|
+
// set a callback for everytime a message is added (listener)
|
|
166
|
+
}, {
|
|
167
|
+
key: "setCallbackonMessageAdded",
|
|
168
|
+
value: function setCallbackonMessageAdded(callback) {
|
|
169
|
+
this._onMessageAdded = callback;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Public methods
|
|
117
173
|
}, {
|
|
118
174
|
key: "titleAreaToggle",
|
|
119
175
|
value: function titleAreaToggle() {
|
|
@@ -189,31 +245,66 @@ var quikchat = /*#__PURE__*/function () {
|
|
|
189
245
|
this._sendButton.style.minWidth = "".concat(minWidth, "px");
|
|
190
246
|
}
|
|
191
247
|
}, {
|
|
192
|
-
key: "
|
|
193
|
-
value: function
|
|
194
|
-
var
|
|
195
|
-
|
|
196
|
-
|
|
248
|
+
key: "messageAddFull",
|
|
249
|
+
value: function messageAddFull() {
|
|
250
|
+
var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
251
|
+
content: "",
|
|
252
|
+
userString: "user",
|
|
253
|
+
align: "right",
|
|
254
|
+
role: "user",
|
|
255
|
+
userID: -1
|
|
256
|
+
};
|
|
197
257
|
var msgid = this.msgid;
|
|
258
|
+
var messageDiv = document.createElement('div');
|
|
198
259
|
var msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');
|
|
260
|
+
'quikchat-userid-' + String(input.userString).padStart(10, '0'); // hash this..
|
|
199
261
|
messageDiv.classList.add('quikchat-message', msgidClass);
|
|
200
262
|
this.msgid++;
|
|
201
263
|
messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');
|
|
202
264
|
var userDiv = document.createElement('div');
|
|
203
|
-
userDiv.innerHTML =
|
|
204
|
-
userDiv.style = "width: 100%; text-align: ".concat(align, "; font-size: 1em; font-weight:700; color: #444;");
|
|
265
|
+
userDiv.innerHTML = input.userString;
|
|
266
|
+
userDiv.style = "width: 100%; text-align: ".concat(input.align, "; font-size: 1em; font-weight:700; color: #444;");
|
|
205
267
|
var contentDiv = document.createElement('div');
|
|
206
|
-
contentDiv.style = "width: 100%; text-align: ".concat(align, ";");
|
|
207
|
-
contentDiv.innerHTML =
|
|
268
|
+
contentDiv.style = "width: 100%; text-align: ".concat(input.align, ";");
|
|
269
|
+
contentDiv.innerHTML = input.content;
|
|
208
270
|
messageDiv.appendChild(userDiv);
|
|
209
271
|
messageDiv.appendChild(contentDiv);
|
|
210
272
|
this._messagesArea.appendChild(messageDiv);
|
|
211
273
|
this._messagesArea.lastChild.scrollIntoView();
|
|
212
274
|
this._textEntry.value = '';
|
|
213
275
|
this._adjustMessagesAreaHeight();
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
276
|
+
var timestamp = new Date().toISOString();
|
|
277
|
+
var updatedtime = timestamp;
|
|
278
|
+
if (this.trackHistory) {
|
|
279
|
+
this._history.push(_objectSpread2(_objectSpread2({
|
|
280
|
+
msgid: msgid
|
|
281
|
+
}, input), {}, {
|
|
282
|
+
timestamp: timestamp,
|
|
283
|
+
updatedtime: updatedtime,
|
|
284
|
+
messageDiv: messageDiv
|
|
285
|
+
}));
|
|
286
|
+
if (this._history.length > this._historyLimit) {
|
|
287
|
+
this._history.shift();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if (this._onMessageAdded) {
|
|
291
|
+
this._onMessageAdded(this, msgid);
|
|
292
|
+
}
|
|
293
|
+
return msgid;
|
|
294
|
+
}
|
|
295
|
+
}, {
|
|
296
|
+
key: "messageAddNew",
|
|
297
|
+
value: function messageAddNew() {
|
|
298
|
+
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
299
|
+
var userString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "user";
|
|
300
|
+
var align = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "right";
|
|
301
|
+
var role = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "user";
|
|
302
|
+
return this.messageAddFull({
|
|
303
|
+
content: content,
|
|
304
|
+
userString: userString,
|
|
305
|
+
align: align,
|
|
306
|
+
role: role
|
|
307
|
+
});
|
|
217
308
|
}
|
|
218
309
|
}, {
|
|
219
310
|
key: "messageRemove",
|
|
@@ -226,6 +317,15 @@ var quikchat = /*#__PURE__*/function () {
|
|
|
226
317
|
} catch (error) {
|
|
227
318
|
console.log("{String(n)} : Message ID not found");
|
|
228
319
|
}
|
|
320
|
+
if (sucess) {
|
|
321
|
+
// slow way to remove from history
|
|
322
|
+
//this._history = this._history.filter((item) => item.msgid !== n); // todo make this more efficient
|
|
323
|
+
|
|
324
|
+
// better way to delete this from history
|
|
325
|
+
this._history.splice(this._history.findIndex(function (item) {
|
|
326
|
+
return item.msgid === n;
|
|
327
|
+
}), 1);
|
|
328
|
+
}
|
|
229
329
|
return sucess;
|
|
230
330
|
}
|
|
231
331
|
/* returns the message html object from the DOM
|
|
@@ -250,7 +350,11 @@ var quikchat = /*#__PURE__*/function () {
|
|
|
250
350
|
var content = "";
|
|
251
351
|
// now use css selector to get the message
|
|
252
352
|
try {
|
|
253
|
-
|
|
353
|
+
// get from history..
|
|
354
|
+
content = this._history.filter(function (item) {
|
|
355
|
+
return item.msgid === n;
|
|
356
|
+
})[0].content;
|
|
357
|
+
//content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;
|
|
254
358
|
} catch (error) {
|
|
255
359
|
console.log("{String(n)} : Message ID not found");
|
|
256
360
|
}
|
|
@@ -265,7 +369,14 @@ var quikchat = /*#__PURE__*/function () {
|
|
|
265
369
|
var sucess = false;
|
|
266
370
|
try {
|
|
267
371
|
this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0'))).lastChild.innerHTML += content;
|
|
372
|
+
// update history
|
|
373
|
+
var item = this._history.filter(function (item) {
|
|
374
|
+
return item.msgid === n;
|
|
375
|
+
})[0];
|
|
376
|
+
item.content += content;
|
|
377
|
+
item.updatedtime = new Date().toISOString();
|
|
268
378
|
sucess = true;
|
|
379
|
+
this._messagesArea.lastChild.scrollIntoView();
|
|
269
380
|
} catch (error) {
|
|
270
381
|
console.log("{String(n)} : Message ID not found");
|
|
271
382
|
}
|
|
@@ -278,12 +389,62 @@ var quikchat = /*#__PURE__*/function () {
|
|
|
278
389
|
var sucess = false;
|
|
279
390
|
try {
|
|
280
391
|
this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0'))).lastChild.innerHTML = content;
|
|
392
|
+
// update history
|
|
393
|
+
this._history.filter(function (item) {
|
|
394
|
+
return item.msgid === n;
|
|
395
|
+
})[0].content = content;
|
|
281
396
|
sucess = true;
|
|
282
397
|
} catch (error) {
|
|
283
398
|
console.log("{String(n)} : Message ID not found");
|
|
284
399
|
}
|
|
285
400
|
return sucess;
|
|
286
401
|
}
|
|
402
|
+
// history functions
|
|
403
|
+
/**
|
|
404
|
+
*
|
|
405
|
+
* @param {*} n
|
|
406
|
+
* @param {*} m
|
|
407
|
+
* @returns array of history messages
|
|
408
|
+
*/
|
|
409
|
+
}, {
|
|
410
|
+
key: "historyGet",
|
|
411
|
+
value: function historyGet(n, m) {
|
|
412
|
+
if (n == undefined) {
|
|
413
|
+
n = 0;
|
|
414
|
+
m = this._history.length;
|
|
415
|
+
}
|
|
416
|
+
if (m === undefined) {
|
|
417
|
+
m = n < 0 ? m : n + 1;
|
|
418
|
+
}
|
|
419
|
+
// remember that entries could be deleted. TODO: So we need to return the actual history entries
|
|
420
|
+
// so now we need to find the array index that correspondes to messageIds n (start) and m (end)
|
|
421
|
+
|
|
422
|
+
return this._history.slice(n, m);
|
|
423
|
+
}
|
|
424
|
+
}, {
|
|
425
|
+
key: "historyClear",
|
|
426
|
+
value: function historyClear() {
|
|
427
|
+
this.msgid = 0;
|
|
428
|
+
this._history = [];
|
|
429
|
+
}
|
|
430
|
+
}, {
|
|
431
|
+
key: "historyGetLength",
|
|
432
|
+
value: function historyGetLength() {
|
|
433
|
+
return this._history.length;
|
|
434
|
+
}
|
|
435
|
+
}, {
|
|
436
|
+
key: "historyGetMessage",
|
|
437
|
+
value: function historyGetMessage(n) {
|
|
438
|
+
if (n >= 0 && n < this._history.length) {
|
|
439
|
+
this._history[n];
|
|
440
|
+
}
|
|
441
|
+
return {};
|
|
442
|
+
}
|
|
443
|
+
}, {
|
|
444
|
+
key: "historyGetMessageContent",
|
|
445
|
+
value: function historyGetMessageContent(n) {
|
|
446
|
+
return this._history[n].message;
|
|
447
|
+
}
|
|
287
448
|
}, {
|
|
288
449
|
key: "changeTheme",
|
|
289
450
|
value: function changeTheme(newTheme) {
|
|
@@ -291,6 +452,18 @@ var quikchat = /*#__PURE__*/function () {
|
|
|
291
452
|
this._chatWidget.classList.add(newTheme);
|
|
292
453
|
this._theme = newTheme;
|
|
293
454
|
}
|
|
455
|
+
}, {
|
|
456
|
+
key: "theme",
|
|
457
|
+
get: function get() {
|
|
458
|
+
return this._theme;
|
|
459
|
+
}
|
|
460
|
+
}], [{
|
|
461
|
+
key: "getVersion",
|
|
462
|
+
value: function getVersion() {
|
|
463
|
+
return {
|
|
464
|
+
"version": "1.0.3"
|
|
465
|
+
};
|
|
466
|
+
}
|
|
294
467
|
}]);
|
|
295
468
|
}();
|
|
296
469
|
|
package/dist/quikchat.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quikchat.cjs.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n }\n\n _createWidget() {\n const widgetHTML =\n `\n <div class=\"quikchat-base ${this.theme}\">\n <div class=\"quikchat-title-area\">\n <span style=\"font-size: 1.5em; font-weight: 600;\">Title Area</span>\n </div>\n <div class=\"quikchat-messages-area\"></div>\n <div class=\"quikchat-input-area\">\n <textarea class=\"quikchat-input-textbox\"></textarea>\n <button class=\"quikchat-input-send-btn\">Send</button>\n </div>\n </div>\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","_createClass","key","value","widgetHTML","concat","innerHTML","_chatWidget","querySelector","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","$","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","_adjustMessagesAreaHeight","textAlign","titleAreaGetContents","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","fontSize","parseFloat","getComputedStyle","minWidth","messageAddNew","message","user","messageDiv","document","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","messageRemove","n","sucess","removeChild","error","console","log","messageGetDOMObject","msg","messageGetContent","content","messageAppendContent","messageReplaceContent","changeTheme","newTheme","remove"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,IAEMA,QAAQ,gBAAA,YAAA;EACV,SAAAA,QAAAA,CAAYC,aAAa,EAA+D;IAAA,IAA7DC,IAAI,GAAAC,S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DOM element parentElement \n * @param {*} meta \n */\n constructor(parentElement, \n meta = { \n theme: 'quikchat-theme-light', \n onSend: () => { }, \n trackHistory: true,\n titleArea: {title: \"Title Area\", show: false, align: \"center\"}\n }) \n {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show == true) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n this.trackHistory = meta.trackHistory || true;\n this._historyLimit = 10000000;\n this._history = [];\n }\n\n _createWidget() {\n const widgetHTML =\n `\n <div class=\"quikchat-base ${this.theme}\">\n <div class=\"quikchat-title-area\">\n <span style=\"font-size: 1.5em; font-weight: 600;\">Title Area</span>\n </div>\n <div class=\"quikchat-messages-area\"></div>\n <div class=\"quikchat-input-area\">\n <textarea class=\"quikchat-input-textbox\"></textarea>\n <button class=\"quikchat-input-send-btn\">Send</button>\n </div>\n </div>\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n // set the onSend function callback.\n setCallbackOnSend(callback) {\n this._onSend = callback;\n }\n // set a callback for everytime a message is added (listener)\n setCallbackonMessageAdded(callback) {\n this._onMessageAdded = callback;\n }\n\n // Public methods\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n \n messageAddFull(input = {content: \"\", userString: \"user\", align : \"right\", role : \"user\", userID : -1}) {\n const msgid = this.msgid;\n const messageDiv = document.createElement('div');\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n const userIdClass = 'quikchat-userid-' + String(input.userString).padStart(10, '0'); // hash this..\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n \n const userDiv = document.createElement('div');\n userDiv.innerHTML = input.userString;\n userDiv.style = `width: 100%; text-align: ${input.align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${input.align};`;\n contentDiv.innerHTML = input.content;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n const timestamp = new Date().toISOString();\n const updatedtime = timestamp;\n if (this.trackHistory) {\n this._history.push({ msgid, ...input, timestamp, updatedtime, messageDiv});\n if (this._history.length > this._historyLimit) {\n this._history.shift();\n }\n }\n if (this._onMessageAdded) {\n this._onMessageAdded(this, msgid);\n };\n return msgid;\n }\n messageAddNew(content=\"\", userString=\"user\", align = \"right\", role = \"user\") {\n return this.messageAddFull( \n {content: content, userString: userString, align: align, role: role}\n );\n }\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n if (sucess) {\n // slow way to remove from history\n //this._history = this._history.filter((item) => item.msgid !== n); // todo make this more efficient\n\n // better way to delete this from history\n this._history.splice(this._history.findIndex((item) => item.msgid === n), 1);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n // get from history..\n content = this._history.filter((item) => item.msgid === n)[0].content;\n //content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n // update history\n let item = this._history.filter((item) => item.msgid === n)[0];\n item.content += content;\n item.updatedtime = new Date().toISOString();\n sucess = true;\n this._messagesArea.lastChild.scrollIntoView();\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n // update history\n this._history.filter((item) => item.msgid === n)[0].content = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n // history functions\n /**\n * \n * @param {*} n \n * @param {*} m \n * @returns array of history messages\n */\n historyGet(n,m) {\n\n if (n == undefined) {\n n = 0;\n m= this._history.length;\n }\n if (m === undefined) {\n m = n < 0 ? m: n + 1;\n }\n // remember that entries could be deleted. TODO: So we need to return the actual history entries\n // so now we need to find the array index that correspondes to messageIds n (start) and m (end)\n \n return this._history.slice(n,m);\n }\n\n historyClear() {\n this.msgid = 0;\n this._history = [];\n } \n\n historyGetLength() {\n return this._history.length;\n } \n\n historyGetMessage(n) {\n if ( n>=0 && n < this._history.length) {\n this._history[n];\n }\n return {};\n\n } \n\n historyGetMessageContent(n) {\n return this._history[n].message;\n }\n\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.3\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","trackHistory","titleArea","title","show","align","_classCallCheck","document","querySelector","_parentElement","_theme","_onSend","_createWidget","titleAreaSetContents","titleAreaShow","titleAreaHide","_attachEventListeners","_historyLimit","_history","_createClass","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","setCallbackOnSend","callback","setCallbackonMessageAdded","_onMessageAdded","titleAreaToggle","style","display","_adjustMessagesAreaHeight","textAlign","titleAreaGetContents","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","fontSize","parseFloat","getComputedStyle","minWidth","messageAddFull","input","content","userString","role","userID","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","timestamp","Date","toISOString","updatedtime","push","_objectSpread","shift","messageAddNew","messageRemove","n","sucess","removeChild","error","console","log","splice","findIndex","item","messageGetDOMObject","msg","messageGetContent","messageAppendContent","messageReplaceContent","historyGet","m","slice","historyClear","historyGetLength","historyGetMessage","historyGetMessageContent","message","changeTheme","newTheme","remove","get","getVersion"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACMA,QAAQ,gBAAA,YAAA;AACV;AACJ;AACA;AACA;AACA;EACI,SAAAA,QAAAA,CAAYC,aAAa,EAOrB;IAAA,IANIC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAAD,CAAAA,IAAAA,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G,OAAA;OAAQ,CAAA;AAChC,KAAA;AAAC,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
|
package/dist/quikchat.cjs.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var
|
|
1
|
+
"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=Array(e);i<e;i++)n[i]=t[i];return n}function e(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,a(n.key),n)}}function i(t,e,i){return(e=a(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function n(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function r(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){i(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function s(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(e,i){if(e){if("string"==typeof e)return t(e,i);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,i):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}var o=function(){return t=function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){},trackHistory:!0,titleArea:{title:"Title Area",show:!1,align:"center"}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"string"==typeof e&&(e=document.querySelector(e)),this._parentElement=e,this._theme=i.theme,this._onSend=i.onSend?i.onSend:function(){},this._createWidget(),i.titleArea&&(this.titleAreaSetContents(i.titleArea.title,i.titleArea.align),1==i.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this._attachEventListeners(),this.trackHistory=i.trackHistory||!0,this._historyLimit=1e7,this._history=[]},i=[{key:"_createWidget",value:function(){var t='\n <div class="quikchat-base '.concat(this.theme,'">\n <div class="quikchat-title-area">\n <span style="font-size: 1.5em; font-weight: 600;">Title Area</span>\n </div>\n <div class="quikchat-messages-area"></div>\n <div class="quikchat-input-area">\n <textarea class="quikchat-input-textbox"></textarea>\n <button class="quikchat-input-send-btn">Send</button>\n </div>\n </div>\n ');this._parentElement.innerHTML=t,this._chatWidget=this._parentElement.querySelector(".quikchat-base"),this._titleArea=this._chatWidget.querySelector(".quikchat-title-area"),this._messagesArea=this._chatWidget.querySelector(".quikchat-messages-area"),this._inputArea=this._chatWidget.querySelector(".quikchat-input-area"),this._textEntry=this._inputArea.querySelector(".quikchat-input-textbox"),this._sendButton=this._inputArea.querySelector(".quikchat-input-send-btn"),this.msgid=0}},{key:"_attachEventListeners",value:function(){var t=this;this._sendButton.addEventListener("click",(function(){return t._onSend(t,t._textEntry.value.trim())})),window.addEventListener("resize",(function(){return t._handleContainerResize()})),this._chatWidget.addEventListener("resize",(function(){return t._handleContainerResize()})),this._textEntry.addEventListener("keydown",(function(e){e.shiftKey&&13===e.keyCode&&(e.preventDefault(),t._onSend(t,t._textEntry.value.trim()))}))}},{key:"setCallbackOnSend",value:function(t){this._onSend=t}},{key:"setCallbackonMessageAdded",value:function(t){this._onMessageAdded=t}},{key:"titleAreaToggle",value:function(){"none"===this._titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this._titleArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this._titleArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"titleAreaSetContents",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this._titleArea.innerHTML=t,this._titleArea.style.textAlign=e}},{key:"titleAreaGetContents",value:function(){return this._titleArea.innerHTML}},{key:"inputAreaToggle",value:function(){this._inputArea.classList.toggle("hidden"),"none"===this._inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this._inputArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this._inputArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"_adjustMessagesAreaHeight",value:function(){var t=s(this._chatWidget.children).filter((function(t){return t.classList.contains("hidden")})).reduce((function(t,e){return t+e.offsetHeight}),0),e=this._chatWidget.offsetHeight;this._messagesArea.style.height="calc(100% - ".concat(e-t,"px)")}},{key:"_handleContainerResize",value:function(){this._adjustMessagesAreaHeight(),this._adjustSendButtonWidth()}},{key:"_adjustSendButtonWidth",value:function(){var t=this._sendButton.textContent.trim(),e=parseFloat(getComputedStyle(this._sendButton).fontSize)*t.length+16;this._sendButton.style.minWidth="".concat(e,"px")}},{key:"messageAddFull",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{content:"",userString:"user",align:"right",role:"user",userID:-1},e=this.msgid,i=document.createElement("div"),n="quikchat-msgid-"+String(e).padStart(10,"0");String(t.userString).padStart(10,"0"),i.classList.add("quikchat-message",n),this.msgid++,i.classList.add(this._messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var s=document.createElement("div");s.innerHTML=t.userString,s.style="width: 100%; text-align: ".concat(t.align,"; font-size: 1em; font-weight:700; color: #444;");var a=document.createElement("div");a.style="width: 100%; text-align: ".concat(t.align,";"),a.innerHTML=t.content,i.appendChild(s),i.appendChild(a),this._messagesArea.appendChild(i),this._messagesArea.lastChild.scrollIntoView(),this._textEntry.value="",this._adjustMessagesAreaHeight();var o=(new Date).toISOString(),u=o;return this.trackHistory&&(this._history.push(r(r({msgid:e},t),{},{timestamp:o,updatedtime:u,messageDiv:i})),this._history.length>this._historyLimit&&this._history.shift()),this._onMessageAdded&&this._onMessageAdded(this,e),e}},{key:"messageAddNew",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"user",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"right",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"user";return this.messageAddFull({content:t,userString:e,align:i,role:n})}},{key:"messageRemove",value:function(t){var e=!1;try{this._messagesArea.removeChild(this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))),e=!0}catch(t){console.log("{String(n)} : Message ID not found")}return e&&this._history.splice(this._history.findIndex((function(e){return e.msgid===t})),1),e}},{key:"messageGetDOMObject",value:function(t){var e=null;try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetContent",value:function(t){var e="";try{e=this._history.filter((function(e){return e.msgid===t}))[0].content}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageAppendContent",value:function(t,e){try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML+=e;var i=this._history.filter((function(e){return e.msgid===t}))[0];i.content+=e,i.updatedtime=(new Date).toISOString(),this._messagesArea.lastChild.scrollIntoView()}catch(t){console.log("{String(n)} : Message ID not found")}}},{key:"messageReplaceContent",value:function(t,e){var i=!1;try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML=e,this._history.filter((function(e){return e.msgid===t}))[0].content=e,i=!0}catch(t){console.log("{String(n)} : Message ID not found")}return i}},{key:"historyGet",value:function(t,e){return null==t&&(t=0,e=this._history.length),void 0===e&&(e=t<0?e:t+1),this._history.slice(t,e)}},{key:"historyClear",value:function(){this.msgid=0,this._history=[]}},{key:"historyGetLength",value:function(){return this._history.length}},{key:"historyGetMessage",value:function(t){return t>=0&&t<this._history.length&&this._history[t],{}}},{key:"historyGetMessageContent",value:function(t){return this._history[t].message}},{key:"changeTheme",value:function(t){this._chatWidget.classList.remove(this._theme),this._chatWidget.classList.add(t),this._theme=t}},{key:"theme",get:function(){return this._theme}}],n=[{key:"getVersion",value:function(){return{version:"1.0.3"}}}],i&&e(t.prototype,i),n&&e(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,n}();module.exports=o;
|
|
2
2
|
//# sourceMappingURL=quikchat.cjs.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quikchat.cjs.min.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n }\n\n _createWidget() {\n const widgetHTML =\n `\n <div class=\"quikchat-base ${this.theme}\">\n <div class=\"quikchat-title-area\">\n <span style=\"font-size: 1.5em; font-weight: 600;\">Title Area</span>\n </div>\n <div class=\"quikchat-messages-area\"></div>\n <div class=\"quikchat-input-area\">\n <textarea class=\"quikchat-input-textbox\"></textarea>\n <button class=\"quikchat-input-send-btn\">Send</button>\n </div>\n </div>\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n $() {\n }\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n\n messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\n }\n\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","_createClass","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","this","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","key","value","widgetHTML","concat","innerHTML","_chatWidget","querySelector","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","_adjustMessagesAreaHeight","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","document","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","sucess","removeChild","error","console","log","msg","content","newTheme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KAAKkB,YAAYqB,UAAU8B,IAAIc,GAC/BnF,KAAKE,OAASiF,CAClB,IAAC,CAvNS"}
|
|
1
|
+
{"version":3,"file":"quikchat.cjs.min.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n /**\n * \n * @param string or DOM element parentElement \n * @param {*} meta \n */\n constructor(parentElement, \n meta = { \n theme: 'quikchat-theme-light', \n onSend: () => { }, \n trackHistory: true,\n titleArea: {title: \"Title Area\", show: false, align: \"center\"}\n }) \n {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show == true) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n this.trackHistory = meta.trackHistory || true;\n this._historyLimit = 10000000;\n this._history = [];\n }\n\n _createWidget() {\n const widgetHTML =\n `\n <div class=\"quikchat-base ${this.theme}\">\n <div class=\"quikchat-title-area\">\n <span style=\"font-size: 1.5em; font-weight: 600;\">Title Area</span>\n </div>\n <div class=\"quikchat-messages-area\"></div>\n <div class=\"quikchat-input-area\">\n <textarea class=\"quikchat-input-textbox\"></textarea>\n <button class=\"quikchat-input-send-btn\">Send</button>\n </div>\n </div>\n `;\n\n this._parentElement.innerHTML = widgetHTML;\n this._chatWidget = this._parentElement.querySelector('.quikchat-base');\n this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');\n this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');\n this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');\n this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');\n this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');\n this.msgid = 0;\n }\n\n _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n // set the onSend function callback.\n setCallbackOnSend(callback) {\n this._onSend = callback;\n }\n // set a callback for everytime a message is added (listener)\n setCallbackonMessageAdded(callback) {\n this._onMessageAdded = callback;\n }\n\n // Public methods\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\n }\n\n inputAreaToggle() {\n this._inputArea.classList.toggle('hidden');\n this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this._inputArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this._inputArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n _adjustMessagesAreaHeight() {\n const hiddenElements = [...this._chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this._chatWidget.offsetHeight;\n this._messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n _handleContainerResize() {\n this._adjustMessagesAreaHeight();\n this._adjustSendButtonWidth();\n //console.log('Container resized');\n }\n\n _adjustSendButtonWidth() {\n const sendButtonText = this._sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this._sendButton.style.minWidth = `${minWidth}px`;\n }\n \n messageAddFull(input = {content: \"\", userString: \"user\", align : \"right\", role : \"user\", userID : -1}) {\n const msgid = this.msgid;\n const messageDiv = document.createElement('div');\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n const userIdClass = 'quikchat-userid-' + String(input.userString).padStart(10, '0'); // hash this..\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\n messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n \n const userDiv = document.createElement('div');\n userDiv.innerHTML = input.userString;\n userDiv.style = `width: 100%; text-align: ${input.align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${input.align};`;\n contentDiv.innerHTML = input.content;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n const timestamp = new Date().toISOString();\n const updatedtime = timestamp;\n if (this.trackHistory) {\n this._history.push({ msgid, ...input, timestamp, updatedtime, messageDiv});\n if (this._history.length > this._historyLimit) {\n this._history.shift();\n }\n }\n if (this._onMessageAdded) {\n this._onMessageAdded(this, msgid);\n };\n return msgid;\n }\n messageAddNew(content=\"\", userString=\"user\", align = \"right\", role = \"user\") {\n return this.messageAddFull( \n {content: content, userString: userString, align: align, role: role}\n );\n }\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n if (sucess) {\n // slow way to remove from history\n //this._history = this._history.filter((item) => item.msgid !== n); // todo make this more efficient\n\n // better way to delete this from history\n this._history.splice(this._history.findIndex((item) => item.msgid === n), 1);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n // get from history..\n content = this._history.filter((item) => item.msgid === n)[0].content;\n //content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n // update history\n let item = this._history.filter((item) => item.msgid === n)[0];\n item.content += content;\n item.updatedtime = new Date().toISOString();\n sucess = true;\n this._messagesArea.lastChild.scrollIntoView();\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n // update history\n this._history.filter((item) => item.msgid === n)[0].content = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n // history functions\n /**\n * \n * @param {*} n \n * @param {*} m \n * @returns array of history messages\n */\n historyGet(n,m) {\n\n if (n == undefined) {\n n = 0;\n m= this._history.length;\n }\n if (m === undefined) {\n m = n < 0 ? m: n + 1;\n }\n // remember that entries could be deleted. TODO: So we need to return the actual history entries\n // so now we need to find the array index that correspondes to messageIds n (start) and m (end)\n \n return this._history.slice(n,m);\n }\n\n historyClear() {\n this.msgid = 0;\n this._history = [];\n } \n\n historyGetLength() {\n return this._history.length;\n } \n\n historyGetMessage(n) {\n if ( n>=0 && n < this._history.length) {\n this._history[n];\n }\n return {};\n\n } \n\n historyGetMessageContent(n) {\n return this._history[n].message;\n }\n\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n get theme() {\n return this._theme;\n }\n\n static getVersion() {\n return {\"version\" : \"1.0.3\"}\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","trackHistory","titleArea","title","show","align","_classCallCheck","document","querySelector","this","_parentElement","_theme","_onSend","_createWidget","titleAreaSetContents","titleAreaShow","titleAreaHide","_attachEventListeners","_historyLimit","_history","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","callback","_onMessageAdded","style","display","_adjustMessagesAreaHeight","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","minWidth","parseFloat","getComputedStyle","fontSize","input","content","userString","role","userID","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","timestamp","Date","toISOString","updatedtime","push","_objectSpread","shift","messageAddFull","n","sucess","removeChild","error","console","log","splice","findIndex","item","msg","m","slice","message","newTheme","remove","get","version"],"mappings":"u3DACMA,EAAQ,WAkCT,SA5BD,SAAAA,EAAYC,GAOR,IANIC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CACHG,MAAO,uBACPC,OAAQ,WAAS,EACjBC,cAAc,EACdC,UAAW,CAACC,MAAO,aAAcC,MAAM,EAAOC,MAAO,wGACxDC,MAAAb,GAEwB,iBAAlBC,IACPA,EAAgBa,SAAS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