quikchat 1.1.13 → 1.1.15

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.
@@ -80,11 +80,55 @@ function _unsupportedIterableToArray(r, a) {
80
80
  }
81
81
  }
82
82
 
83
+ // Auto-generated version file - DO NOT EDIT MANUALLY
84
+ // This file is automatically updated by tools/updateVersion.js
85
+
86
+ var quikchatVersion = {
87
+ version: "1.1.15",
88
+ license: "BSD-2",
89
+ url: "https://github/deftio/quikchat",
90
+ fun: true
91
+ };
92
+
93
+ /**
94
+ * QuikChat - A zero-dependency JavaScript chat widget for modern web applications
95
+ * @class quikchat
96
+ * @version 1.1.15
97
+ */
83
98
  var quikchat = /*#__PURE__*/function () {
84
99
  /**
100
+ * Creates a new QuikChat instance
101
+ * @constructor
102
+ * @param {string|HTMLElement} parentElement - CSS selector or DOM element to attach the chat widget to
103
+ * @param {Function} [onSend] - Callback function triggered when user sends a message
104
+ * @param {Object} [options] - Configuration options
105
+ * @param {string} [options.theme='quikchat-theme-light'] - CSS theme class name
106
+ * @param {boolean} [options.trackHistory=true] - Whether to track message history
107
+ * @param {Object} [options.titleArea] - Title area configuration
108
+ * @param {string} [options.titleArea.title='Chat'] - Title text/HTML
109
+ * @param {boolean} [options.titleArea.show=false] - Whether to show title area initially
110
+ * @param {'left'|'center'|'right'} [options.titleArea.align='center'] - Title alignment
111
+ * @param {Object} [options.messagesArea] - Messages area configuration
112
+ * @param {boolean} [options.messagesArea.alternating=true] - Alternate message colors
113
+ * @param {Object} [options.inputArea] - Input area configuration
114
+ * @param {boolean} [options.inputArea.show=true] - Whether to show input area initially
115
+ * @param {boolean} [options.sendOnEnter=true] - Send message on Enter key
116
+ * @param {boolean} [options.sendOnShiftEnter=false] - Send message on Shift+Enter
117
+ * @param {string} [options.instanceClass=''] - Additional CSS class for the widget instance
118
+ * @example
119
+ * // Basic usage
120
+ * const chat = new quikchat('#chat-container', (instance, message) => {
121
+ * console.log('User sent:', message);
122
+ * });
85
123
  *
86
- * @param string or DOM element parentElement
87
- * @param {*} meta
124
+ * @example
125
+ * // With options
126
+ * const chat = new quikchat('#chat', handleMessage, {
127
+ * theme: 'quikchat-theme-dark',
128
+ * titleArea: { title: 'Support Chat', show: true },
129
+ * sendOnEnter: false,
130
+ * sendOnShiftEnter: true
131
+ * });
88
132
  */
89
133
  function quikchat(parentElement) {
90
134
  var onSend = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
@@ -105,7 +149,8 @@ var quikchat = /*#__PURE__*/function () {
105
149
  show: true
106
150
  },
107
151
  sendOnEnter: true,
108
- sendOnShiftEnter: false
152
+ sendOnShiftEnter: false,
153
+ instanceClass: ''
109
154
  };
110
155
  var meta = _objectSpread2(_objectSpread2({}, defaultOpts), options); // merge options with defaults
111
156
 
@@ -117,6 +162,10 @@ var quikchat = /*#__PURE__*/function () {
117
162
  this._theme = meta.theme;
118
163
  this._onSend = onSend ? onSend : function () {}; // call back function for onSend
119
164
  this._createWidget();
165
+ if (meta.instanceClass) {
166
+ this._chatWidget.classList.add(meta.instanceClass);
167
+ }
168
+
120
169
  // title area
121
170
  if (meta.titleArea) {
122
171
  this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);
@@ -140,6 +189,7 @@ var quikchat = /*#__PURE__*/function () {
140
189
  this.trackHistory = meta.trackHistory || true;
141
190
  this._historyLimit = 10000000;
142
191
  this._history = [];
192
+ this._activeTags = new Set();
143
193
 
144
194
  // send on enter / shift enter
145
195
  this.sendOnEnter = meta.sendOnEnter;
@@ -214,24 +264,100 @@ var quikchat = /*#__PURE__*/function () {
214
264
  this._onMessageAdded = callback;
215
265
  }
216
266
 
267
+ /**
268
+ * Sets the callback function for when content is appended to a message
269
+ * @param {Function} callback - Function to call when content is appended
270
+ * @param {quikchat} callback.instance - The QuikChat instance
271
+ * @param {number} callback.msgId - The ID of the message being appended to
272
+ * @param {string} callback.content - The content being appended
273
+ * @since 1.1.15
274
+ * @example
275
+ * chat.setCallbackonMessageAppend((instance, msgId, content) => {
276
+ * console.log(`Appended "${content}" to message ${msgId}`);
277
+ * });
278
+ */
279
+ }, {
280
+ key: "setCallbackonMessageAppend",
281
+ value: function setCallbackonMessageAppend(callback) {
282
+ this._onMessageAppend = callback;
283
+ }
284
+
285
+ /**
286
+ * Sets the callback function for when a message's content is replaced
287
+ * @param {Function} callback - Function to call when content is replaced
288
+ * @param {quikchat} callback.instance - The QuikChat instance
289
+ * @param {number} callback.msgId - The ID of the message being replaced
290
+ * @param {string} callback.content - The new content
291
+ * @since 1.1.15
292
+ * @example
293
+ * chat.setCallbackonMessageReplace((instance, msgId, content) => {
294
+ * console.log(`Message ${msgId} replaced with: ${content}`);
295
+ * });
296
+ */
297
+ }, {
298
+ key: "setCallbackonMessageReplace",
299
+ value: function setCallbackonMessageReplace(callback) {
300
+ this._onMessageReplace = callback;
301
+ }
302
+
303
+ /**
304
+ * Sets the callback function for when a message is deleted
305
+ * @param {Function} callback - Function to call when a message is deleted
306
+ * @param {quikchat} callback.instance - The QuikChat instance
307
+ * @param {number} callback.msgId - The ID of the deleted message
308
+ * @since 1.1.15
309
+ * @example
310
+ * chat.setCallbackonMessageDelete((instance, msgId) => {
311
+ * console.log(`Message ${msgId} was deleted`);
312
+ * });
313
+ */
314
+ }, {
315
+ key: "setCallbackonMessageDelete",
316
+ value: function setCallbackonMessageDelete(callback) {
317
+ this._onMessageDelete = callback;
318
+ }
319
+
217
320
  // Public methods
321
+ /**
322
+ * Toggles the visibility of the title area
323
+ * @returns {void}
324
+ */
218
325
  }, {
219
326
  key: "titleAreaToggle",
220
327
  value: function titleAreaToggle() {
221
328
  this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();
222
329
  }
330
+
331
+ /**
332
+ * Shows the title area
333
+ * @returns {void}
334
+ */
223
335
  }, {
224
336
  key: "titleAreaShow",
225
337
  value: function titleAreaShow() {
226
338
  this._titleArea.style.display = '';
227
339
  this._adjustMessagesAreaHeight();
228
340
  }
341
+
342
+ /**
343
+ * Hides the title area
344
+ * @returns {void}
345
+ */
229
346
  }, {
230
347
  key: "titleAreaHide",
231
348
  value: function titleAreaHide() {
232
349
  this._titleArea.style.display = 'none';
233
350
  this._adjustMessagesAreaHeight();
234
351
  }
352
+
353
+ /**
354
+ * Sets the contents of the title area
355
+ * @param {string} title - HTML content to display in the title area
356
+ * @param {'left'|'center'|'right'} [align='center'] - Text alignment
357
+ * @returns {void}
358
+ * @example
359
+ * chat.titleAreaSetContents('<h2>Support Chat</h2>', 'center');
360
+ */
235
361
  }, {
236
362
  key: "titleAreaSetContents",
237
363
  value: function titleAreaSetContents(title) {
@@ -239,6 +365,11 @@ var quikchat = /*#__PURE__*/function () {
239
365
  this._titleArea.innerHTML = title;
240
366
  this._titleArea.style.textAlign = align;
241
367
  }
368
+
369
+ /**
370
+ * Gets the current contents of the title area
371
+ * @returns {string} The HTML content of the title area
372
+ */
242
373
  }, {
243
374
  key: "titleAreaGetContents",
244
375
  value: function titleAreaGetContents() {
@@ -313,10 +444,33 @@ var quikchat = /*#__PURE__*/function () {
313
444
  value: function messagesAreaAlternateColorsGet() {
314
445
  return this._messagesArea.classList.contains('quikchat-messages-area-alt');
315
446
  }
316
- // message functions
447
+ /**
448
+ * Adds a new message to the chat with full configuration options
449
+ * @param {Object} input - Message configuration object
450
+ * @param {string} [input.content=''] - Message content (HTML allowed)
451
+ * @param {string} [input.userString='user'] - Display name for the message sender
452
+ * @param {'left'|'right'|'center'} [input.align='right'] - Message alignment
453
+ * @param {string} [input.role='user'] - Role identifier (user, assistant, system)
454
+ * @param {number} [input.userID=-1] - User ID for the message
455
+ * @param {string|false} [input.timestamp=false] - ISO timestamp or false for auto
456
+ * @param {string|false} [input.updatedtime=false] - Last updated timestamp
457
+ * @param {boolean|'smart'} [input.scrollIntoView=true] - Scroll behavior (true/false/'smart')
458
+ * @param {boolean} [input.visible=true] - Whether message is initially visible
459
+ * @param {string[]} [input.tags=[]] - Tags for message categorization
460
+ * @returns {number} Message ID for the newly added message
461
+ * @example
462
+ * const msgId = chat.messageAddFull({
463
+ * content: 'Hello!',
464
+ * userString: 'Bot',
465
+ * align: 'left',
466
+ * scrollIntoView: 'smart',
467
+ * tags: ['greeting']
468
+ * });
469
+ */
317
470
  }, {
318
471
  key: "messageAddFull",
319
472
  value: function messageAddFull() {
473
+ var _this2 = this;
320
474
  var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
321
475
  content: "",
322
476
  userString: "user",
@@ -326,13 +480,22 @@ var quikchat = /*#__PURE__*/function () {
326
480
  timestamp: false,
327
481
  updatedtime: false,
328
482
  scrollIntoView: true,
329
- visible: true
483
+ visible: true,
484
+ tags: []
330
485
  };
331
486
  var msgid = this.msgid;
332
487
  var messageDiv = document.createElement('div');
333
488
  var msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');
334
489
  'quikchat-userid-' + String(input.userString).padStart(10, '0'); // hash this..
335
490
  messageDiv.classList.add('quikchat-message', msgidClass, 'quikchat-structure');
491
+ if (Array.isArray(input.tags)) {
492
+ input.tags.forEach(function (tag) {
493
+ if (typeof tag === 'string' && /^[a-zA-Z0-9-]+$/.test(tag)) {
494
+ messageDiv.classList.add("quikchat-tag-".concat(tag));
495
+ _this2._activeTags.add(tag);
496
+ }
497
+ });
498
+ }
336
499
  this.msgid++;
337
500
  var userDiv = document.createElement('div');
338
501
  userDiv.innerHTML = input.userString;
@@ -361,10 +524,15 @@ var quikchat = /*#__PURE__*/function () {
361
524
  messageDiv.style.display = 'none';
362
525
  }
363
526
 
364
- // Scroll to the last message only if the user is not actively scrolling up
365
- if (!this.userScrolledUp || input.scrollIntoView) {
527
+ // Handle scroll behavior based on scrollIntoView parameter
528
+ // 'smart' = only scroll if near bottom, true = always scroll, false = never scroll
529
+ if (input.scrollIntoView === true) {
530
+ this.messageScrollToBottom();
531
+ } else if (input.scrollIntoView === 'smart' && !this.userScrolledUp) {
366
532
  this.messageScrollToBottom();
367
533
  }
534
+ // If scrollIntoView is false, don't scroll at all
535
+
368
536
  this._textEntry.value = '';
369
537
  this._adjustMessagesAreaHeight();
370
538
  this._handleShortLongMessageCSS(messageDiv, input.align); // Handle CSS for short/long messages
@@ -391,6 +559,24 @@ var quikchat = /*#__PURE__*/function () {
391
559
  }
392
560
  return msgid;
393
561
  }
562
+
563
+ /**
564
+ * Adds a new message to the chat (simplified version of messageAddFull)
565
+ * @param {string} [content=''] - Message content (HTML allowed)
566
+ * @param {string} [userString='user'] - Display name for the message sender
567
+ * @param {'left'|'right'|'center'} [align='right'] - Message alignment
568
+ * @param {string} [role='user'] - Role identifier (user, assistant, system)
569
+ * @param {boolean|'smart'} [scrollIntoView=true] - Scroll behavior
570
+ * @param {boolean} [visible=true] - Whether message is initially visible
571
+ * @param {string[]} [tags=[]] - Tags for message categorization
572
+ * @returns {number} Message ID for the newly added message
573
+ * @example
574
+ * // Simple message
575
+ * chat.messageAddNew('Hello!', 'User', 'right');
576
+ *
577
+ * // Bot message with smart scroll
578
+ * chat.messageAddNew('Hi there!', 'Bot', 'left', 'assistant', 'smart');
579
+ */
394
580
  }, {
395
581
  key: "messageAddNew",
396
582
  value: function messageAddNew() {
@@ -400,17 +586,27 @@ var quikchat = /*#__PURE__*/function () {
400
586
  var role = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "user";
401
587
  var scrollIntoView = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
402
588
  var visible = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
589
+ var tags = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : [];
403
590
  var retvalue = this.messageAddFull({
404
591
  content: content,
405
592
  userString: userString,
406
593
  align: align,
407
594
  role: role,
408
595
  scrollIntoView: scrollIntoView,
409
- visible: visible
596
+ visible: visible,
597
+ tags: tags
410
598
  });
411
599
  // this.messageScrollToBottom();
412
600
  return retvalue;
413
601
  }
602
+
603
+ /**
604
+ * Removes a message from the chat by its ID
605
+ * @param {number} n - Message ID to remove
606
+ * @returns {boolean} True if message was removed, false if not found
607
+ * @example
608
+ * const success = chat.messageRemove(5);
609
+ */
414
610
  }, {
415
611
  key: "messageRemove",
416
612
  value: function messageRemove(n) {
@@ -430,11 +626,21 @@ var quikchat = /*#__PURE__*/function () {
430
626
  this._history.splice(this._history.findIndex(function (item) {
431
627
  return item.msgid === n;
432
628
  }), 1);
629
+
630
+ // Call the onMessageDelete callback if it exists
631
+ if (this._onMessageDelete) {
632
+ this._onMessageDelete(this, n);
633
+ }
433
634
  }
434
635
  return sucess;
435
636
  }
436
637
  /* returns the message html object from the DOM
437
638
  */
639
+ /**
640
+ * Gets the DOM element for a message by its ID
641
+ * @param {number} n - Message ID
642
+ * @returns {HTMLElement|null} The message DOM element or null if not found
643
+ */
438
644
  }, {
439
645
  key: "messageGetDOMObject",
440
646
  value: function messageGetDOMObject(n) {
@@ -449,6 +655,11 @@ var quikchat = /*#__PURE__*/function () {
449
655
  }
450
656
  /* returns the message content only
451
657
  */
658
+ /**
659
+ * Gets the content of a message by its ID
660
+ * @param {number} n - Message ID
661
+ * @returns {string} The message content or empty string if not found
662
+ */
452
663
  }, {
453
664
  key: "messageGetContent",
454
665
  value: function messageGetContent(n) {
@@ -500,10 +711,13 @@ var quikchat = /*#__PURE__*/function () {
500
711
  item.updatedtime = new Date().toISOString();
501
712
  success = true;
502
713
 
503
- // Scroll to the last message only if the user is not actively scrolling up
504
- if (!this.userScrolledUp) {
505
- this._messagesArea.lastElementChild.scrollIntoView();
714
+ // Call the onMessageAppend callback if it exists
715
+ if (this._onMessageAppend) {
716
+ this._onMessageAppend(this, n, content);
506
717
  }
718
+
719
+ // Don't auto-scroll on append - let user control this
720
+ // Users can call messageScrollToBottom() if they want to scroll
507
721
  } catch (error) {
508
722
  console.log("".concat(String(n), " : Message ID not found"));
509
723
  }
@@ -526,10 +740,13 @@ var quikchat = /*#__PURE__*/function () {
526
740
  item.updatedtime = new Date().toISOString();
527
741
  success = true;
528
742
 
529
- // Scroll to the last message only if the user is not actively scrolling up
530
- if (!this.userScrolledUp) {
531
- this._messagesArea.lastElementChild.scrollIntoView();
743
+ // Call the onMessageReplace callback if it exists
744
+ if (this._onMessageReplace) {
745
+ this._onMessageReplace(this, n, content);
532
746
  }
747
+
748
+ // Don't auto-scroll on append - let user control this
749
+ // Users can call messageScrollToBottom() if they want to scroll
533
750
  } catch (error) {
534
751
  console.log("".concat(String(n), " : Message ID not found"));
535
752
  }
@@ -665,6 +882,18 @@ var quikchat = /*#__PURE__*/function () {
665
882
  * @param {*} m
666
883
  * @returns array of history messages
667
884
  */
885
+ /**
886
+ * Gets a slice of message history
887
+ * @param {number} [n] - Start index (defaults to 0)
888
+ * @param {number} [m] - End index (defaults to history length)
889
+ * @returns {Array} Array of message objects
890
+ * @example
891
+ * // Get first 10 messages
892
+ * const messages = chat.historyGet(0, 10);
893
+ *
894
+ * // Get all messages
895
+ * const allMessages = chat.historyGet();
896
+ */
668
897
  }, {
669
898
  key: "historyGet",
670
899
  value: function historyGet(n, m) {
@@ -680,17 +909,204 @@ var quikchat = /*#__PURE__*/function () {
680
909
 
681
910
  return this._history.slice(n, m);
682
911
  }
912
+
913
+ /**
914
+ * Gets a copy of the entire message history
915
+ * @returns {Array} Complete array of all message objects
916
+ * @example
917
+ * const history = chat.historyGetAllCopy();
918
+ * console.log(`Total messages: ${history.length}`);
919
+ */
683
920
  }, {
684
921
  key: "historyGetAllCopy",
685
922
  value: function historyGetAllCopy() {
686
923
  return this._history.slice();
687
924
  }
925
+
926
+ /**
927
+ * Get a page of history messages with pagination support
928
+ * @param {number} page - Page number (1-based)
929
+ * @param {number} pageSize - Number of messages per page (default 50)
930
+ * @param {string} order - 'asc' for oldest first, 'desc' for newest first (default 'asc')
931
+ * @returns {object} Object with messages array, pagination info
932
+ */
933
+ }, {
934
+ key: "historyGetPage",
935
+ value: function historyGetPage() {
936
+ var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
937
+ var pageSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 50;
938
+ var order = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'asc';
939
+ var totalMessages = this._history.length;
940
+ var totalPages = Math.ceil(totalMessages / pageSize);
941
+ var currentPage = Math.max(1, Math.min(page, totalPages || 1));
942
+ var start, end;
943
+ if (order === 'desc') {
944
+ // For descending order, page 1 shows the newest messages
945
+ start = Math.max(0, totalMessages - currentPage * pageSize);
946
+ end = totalMessages - (currentPage - 1) * pageSize;
947
+ } else {
948
+ // For ascending order, page 1 shows the oldest messages
949
+ start = (currentPage - 1) * pageSize;
950
+ end = Math.min(start + pageSize, totalMessages);
951
+ }
952
+ var messages = this._history.slice(start, end);
953
+
954
+ // Reverse messages array if descending order requested
955
+ if (order === 'desc') {
956
+ messages.reverse();
957
+ }
958
+ return {
959
+ messages: messages,
960
+ pagination: {
961
+ currentPage: currentPage,
962
+ pageSize: pageSize,
963
+ totalPages: totalPages,
964
+ totalMessages: totalMessages,
965
+ hasNext: currentPage < totalPages,
966
+ hasPrevious: currentPage > 1,
967
+ order: order
968
+ }
969
+ };
970
+ }
971
+
972
+ /**
973
+ * Get information about history size and pagination
974
+ * @param {number} pageSize - Size to calculate pages for (default 50)
975
+ * @returns {object} History metadata
976
+ */
977
+ /**
978
+ * Search history for messages matching criteria
979
+ * @param {object} criteria - Search criteria object
980
+ * @param {string} criteria.text - Text to search for in message content
981
+ * @param {string} criteria.userString - Filter by user name
982
+ * @param {string} criteria.role - Filter by role
983
+ * @param {array} criteria.tags - Filter by tags (messages with any of these tags)
984
+ * @param {number} criteria.limit - Maximum results to return (default 100)
985
+ * @returns {array} Array of matching messages
986
+ */
987
+ /**
988
+ * Searches through message history with various filters
989
+ * @param {Object} [criteria={}] - Search criteria
990
+ * @param {string} [criteria.text] - Text to search for in message content
991
+ * @param {string} [criteria.userString] - Filter by specific user
992
+ * @param {string} [criteria.role] - Filter by role (user, assistant, system)
993
+ * @param {string[]} [criteria.tags] - Filter by tags (messages must have at least one)
994
+ * @param {number} [criteria.limit=100] - Maximum number of results
995
+ * @returns {Array} Array of matching messages
996
+ * @since 1.1.15
997
+ * @example
998
+ * // Search for messages containing 'error'
999
+ * const errors = chat.historySearch({ text: 'error' });
1000
+ *
1001
+ * // Find all bot messages
1002
+ * const botMessages = chat.historySearch({ role: 'assistant' });
1003
+ *
1004
+ * // Complex search
1005
+ * const results = chat.historySearch({
1006
+ * text: 'help',
1007
+ * userString: 'Support',
1008
+ * tags: ['urgent'],
1009
+ * limit: 20
1010
+ * });
1011
+ */
1012
+ }, {
1013
+ key: "historySearch",
1014
+ value: function historySearch() {
1015
+ var criteria = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1016
+ var results = this._history;
1017
+
1018
+ // Filter by text content (case-insensitive)
1019
+ if (criteria.text) {
1020
+ var searchText = criteria.text.toLowerCase();
1021
+ results = results.filter(function (msg) {
1022
+ return msg.content.toLowerCase().includes(searchText);
1023
+ });
1024
+ }
1025
+
1026
+ // Filter by user
1027
+ if (criteria.userString) {
1028
+ results = results.filter(function (msg) {
1029
+ return msg.userString === criteria.userString;
1030
+ });
1031
+ }
1032
+
1033
+ // Filter by role
1034
+ if (criteria.role) {
1035
+ results = results.filter(function (msg) {
1036
+ return msg.role === criteria.role;
1037
+ });
1038
+ }
1039
+
1040
+ // Filter by tags (match any tag)
1041
+ if (criteria.tags && criteria.tags.length > 0) {
1042
+ results = results.filter(function (msg) {
1043
+ return msg.tags && msg.tags.some(function (tag) {
1044
+ return criteria.tags.includes(tag);
1045
+ });
1046
+ });
1047
+ }
1048
+
1049
+ // Limit results
1050
+ var limit = criteria.limit || 100;
1051
+ if (results.length > limit) {
1052
+ results = results.slice(0, limit);
1053
+ }
1054
+ return results;
1055
+ }
1056
+
1057
+ /**
1058
+ * Gets metadata and statistics about the message history
1059
+ * @param {number} [pageSize=50] - Page size for calculating total pages
1060
+ * @returns {Object} History information object
1061
+ * @returns {number} returns.totalMessages - Total number of messages
1062
+ * @returns {number} returns.totalPages - Total pages based on page size
1063
+ * @returns {Object|null} returns.oldestMessage - First message info
1064
+ * @returns {Object|null} returns.newestMessage - Last message info
1065
+ * @returns {Object} returns.memoryUsage - Memory usage statistics
1066
+ * @since 1.1.15
1067
+ * @example
1068
+ * const info = chat.historyGetInfo();
1069
+ * console.log(`Messages: ${info.totalMessages}`);
1070
+ * console.log(`Memory: ${info.memoryUsage.estimatedSize} bytes`);
1071
+ */
1072
+ }, {
1073
+ key: "historyGetInfo",
1074
+ value: function historyGetInfo() {
1075
+ var pageSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 50;
1076
+ var totalMessages = this._history.length;
1077
+ return {
1078
+ totalMessages: totalMessages,
1079
+ totalPages: Math.ceil(totalMessages / pageSize),
1080
+ oldestMessage: totalMessages > 0 ? {
1081
+ msgid: this._history[0].msgid,
1082
+ timestamp: this._history[0].timestamp,
1083
+ userString: this._history[0].userString
1084
+ } : null,
1085
+ newestMessage: totalMessages > 0 ? {
1086
+ msgid: this._history[totalMessages - 1].msgid,
1087
+ timestamp: this._history[totalMessages - 1].timestamp,
1088
+ userString: this._history[totalMessages - 1].userString
1089
+ } : null,
1090
+ memoryUsage: {
1091
+ estimatedSize: JSON.stringify(this._history).length,
1092
+ averageMessageSize: totalMessages > 0 ? Math.round(JSON.stringify(this._history).length / totalMessages) : 0
1093
+ }
1094
+ };
1095
+ }
1096
+
1097
+ /**
1098
+ * Clears all messages and resets the chat
1099
+ * @returns {void}
1100
+ * @example
1101
+ * chat.historyClear(); // Removes all messages
1102
+ */
688
1103
  }, {
689
1104
  key: "historyClear",
690
1105
  value: function historyClear() {
691
1106
  this.msgid = 0;
692
1107
  this._messagesArea.innerHTML = "";
693
1108
  this._history = [];
1109
+ this._activeTags.clear();
694
1110
  }
695
1111
  }, {
696
1112
  key: "historyGetLength",
@@ -715,7 +1131,7 @@ var quikchat = /*#__PURE__*/function () {
715
1131
  }, {
716
1132
  key: "historyRestoreAll",
717
1133
  value: function historyRestoreAll(messageList) {
718
- var _this2 = this;
1134
+ var _this3 = this;
719
1135
  // clear all messages and history
720
1136
  this.historyClear();
721
1137
 
@@ -724,7 +1140,7 @@ var quikchat = /*#__PURE__*/function () {
724
1140
 
725
1141
  // add all messages
726
1142
  messageList.forEach(function (message) {
727
- _this2.messageAddFull(message);
1143
+ _this3.messageAddFull(message);
728
1144
  });
729
1145
  }
730
1146
  /**
@@ -753,15 +1169,82 @@ var quikchat = /*#__PURE__*/function () {
753
1169
  *
754
1170
  * @returns {object} - Returns the version and license information for the library.
755
1171
  */
1172
+ /**
1173
+ * Gets the QuikChat version information
1174
+ * @static
1175
+ * @returns {Object} Version information object
1176
+ * @returns {string} returns.version - Version number (e.g., '1.1.15')
1177
+ * @returns {string} returns.license - License type (e.g., 'BSD-2')
1178
+ * @returns {string} returns.url - Project URL
1179
+ * @returns {boolean} returns.fun - Easter egg flag
1180
+ * @example
1181
+ * const version = quikchat.version();
1182
+ * console.log(`QuikChat v${version.version}`);
1183
+ */
1184
+ }, {
1185
+ key: "setTagVisibility",
1186
+ value:
1187
+ /**
1188
+ * Sets visibility for all messages with a specific tag
1189
+ * @param {string} tagName - Tag name to control
1190
+ * @param {boolean} isVisible - Whether to show or hide messages with this tag
1191
+ * @returns {boolean} True if successful, false if invalid tag name
1192
+ * @since 1.1.14
1193
+ * @example
1194
+ * // Hide all system messages
1195
+ * chat.setTagVisibility('system', false);
1196
+ *
1197
+ * // Show urgent messages
1198
+ * chat.setTagVisibility('urgent', true);
1199
+ */
1200
+ function setTagVisibility(tagName, isVisible) {
1201
+ if (typeof tagName !== 'string' || !/^[a-zA-Z0-9-]+$/.test(tagName)) {
1202
+ return false;
1203
+ }
1204
+ var className = "quikchat-show-tag-".concat(tagName);
1205
+ if (isVisible) {
1206
+ this._chatWidget.classList.add(className);
1207
+ } else {
1208
+ this._chatWidget.classList.remove(className);
1209
+ }
1210
+ this._updateMessageStyles();
1211
+ return true;
1212
+ }
1213
+
1214
+ /**
1215
+ * Gets the visibility state of a tag
1216
+ * @param {string} tagName - Tag name to check
1217
+ * @returns {boolean} True if tag is visible, false otherwise
1218
+ * @since 1.1.14
1219
+ * @example
1220
+ * const isVisible = chat.getTagVisibility('system');
1221
+ */
1222
+ }, {
1223
+ key: "getTagVisibility",
1224
+ value: function getTagVisibility(tagName) {
1225
+ if (typeof tagName !== 'string' || !/^[a-zA-Z0-9-]+$/.test(tagName)) {
1226
+ return false;
1227
+ }
1228
+ return this._chatWidget.classList.contains("quikchat-show-tag-".concat(tagName));
1229
+ }
1230
+
1231
+ /**
1232
+ * Gets all active tags in the chat
1233
+ * @returns {string[]} Array of all tags currently in use
1234
+ * @since 1.1.14
1235
+ * @example
1236
+ * const tags = chat.getActiveTags();
1237
+ * console.log('Active tags:', tags);
1238
+ */
1239
+ }, {
1240
+ key: "getActiveTags",
1241
+ value: function getActiveTags() {
1242
+ return Array.from(this._activeTags);
1243
+ }
756
1244
  }], [{
757
1245
  key: "version",
758
1246
  value: function version() {
759
- return {
760
- "version": "1.1.13",
761
- "license": "BSD-2",
762
- "url": "https://github/deftio/quikchat",
763
- "fun": true
764
- };
1247
+ return quikchatVersion;
765
1248
  }
766
1249
 
767
1250
  /**
@@ -781,6 +1264,21 @@ var quikchat = /*#__PURE__*/function () {
781
1264
  * //Returns a 200 Lorem Ipsum characters starting from a random index
782
1265
  * loremIpsum(200);
783
1266
  */
1267
+
1268
+ /**
1269
+ * Generates Lorem Ipsum placeholder text
1270
+ * @static
1271
+ * @param {number} [numChars] - Length of text to generate (random if not specified)
1272
+ * @param {number} [startSpot] - Starting offset in Lorem text (random if not specified)
1273
+ * @param {boolean} [startWithCapitalLetter=true] - Whether to capitalize first letter
1274
+ * @returns {string} Generated Lorem Ipsum text
1275
+ * @example
1276
+ * // Generate 100 characters
1277
+ * const text = quikchat.loremIpsum(100);
1278
+ *
1279
+ * // Generate random length
1280
+ * const randomText = quikchat.loremIpsum();
1281
+ */
784
1282
  }, {
785
1283
  key: "loremIpsum",
786
1284
  value: function loremIpsum(numChars) {
@@ -820,7 +1318,27 @@ var quikchat = /*#__PURE__*/function () {
820
1318
  }
821
1319
  }, {
822
1320
  key: "tempMessageGenerator",
823
- value: function tempMessageGenerator(domElement, content, interval) {
1321
+ value:
1322
+ /**
1323
+ * Creates a temporary message that updates periodically
1324
+ * @static
1325
+ * @param {string|HTMLElement} domElement - Element selector or DOM element
1326
+ * @param {string} content - Initial message content
1327
+ * @param {number} interval - Update interval in milliseconds (min 100ms)
1328
+ * @param {Function} [cb=null] - Callback to generate new content
1329
+ * @param {string} cb.message - Current message
1330
+ * @param {number} cb.count - Update count
1331
+ * @returns {void}
1332
+ * @example
1333
+ * // Simple loading indicator
1334
+ * quikchat.tempMessageGenerator('#loading', 'Loading', 500);
1335
+ *
1336
+ * // Custom update function
1337
+ * quikchat.tempMessageGenerator('#status', 'Processing', 1000, (msg, count) => {
1338
+ * return `Processing... ${count}%`;
1339
+ * });
1340
+ */
1341
+ function tempMessageGenerator(domElement, content, interval) {
824
1342
  var cb = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
825
1343
  interval = Math.max(interval, 100); // Ensure at least 100ms interval
826
1344