ai12z 3.3.5-alpha.0 → 3.4.0

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.
Files changed (148) hide show
  1. package/dist/cjs/{ai12z-bot-7aa40096.js → ai12z-bot-b00dcf4f.js} +253 -124
  2. package/dist/cjs/ai12z-bot-b00dcf4f.js.map +1 -0
  3. package/dist/cjs/ai12z-bot.cjs.entry.js +3 -3
  4. package/dist/cjs/ai12z-chat_3.cjs.entry.js +32 -10
  5. package/dist/cjs/ai12z-chat_3.cjs.entry.js.map +1 -1
  6. package/dist/cjs/{ai12z-cta-3d6f0243.js → ai12z-cta-fb8d7c0b.js} +25 -4
  7. package/dist/cjs/ai12z-cta-fb8d7c0b.js.map +1 -0
  8. package/dist/cjs/ai12z-cta.cjs.entry.js +3 -3
  9. package/dist/cjs/{ai12z-inline-search-5af28d9d.js → ai12z-inline-search-fd8cb912.js} +3 -3
  10. package/dist/cjs/{ai12z-inline-search-5af28d9d.js.map → ai12z-inline-search-fd8cb912.js.map} +1 -1
  11. package/dist/cjs/ai12z-inline-search.cjs.entry.js +3 -3
  12. package/dist/cjs/{ai12z-knowledge-box-005b5b85.js → ai12z-knowledge-box-1fbca515.js} +24 -5
  13. package/dist/cjs/ai12z-knowledge-box-1fbca515.js.map +1 -0
  14. package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +2 -2
  15. package/dist/cjs/{ai12z-search-panel-2c065bf9.js → ai12z-search-panel-cc9a1325.js} +2 -2
  16. package/dist/cjs/{ai12z-search-panel-2c065bf9.js.map → ai12z-search-panel-cc9a1325.js.map} +1 -1
  17. package/dist/cjs/ai12z-search-panel.cjs.entry.js +2 -2
  18. package/dist/cjs/dynamic-form.cjs.entry.js +1 -1
  19. package/dist/cjs/{index-19719993.js → index-7a98f320.js} +2 -2
  20. package/dist/cjs/{index-19719993.js.map → index-7a98f320.js.map} +1 -1
  21. package/dist/cjs/index.cjs.js +9 -9
  22. package/dist/cjs/item-list.cjs.entry.js +2 -2
  23. package/dist/cjs/library.cjs.js +1 -1
  24. package/dist/cjs/loader.cjs.js +1 -1
  25. package/dist/cjs/search-results-page.cjs.entry.js +3 -3
  26. package/dist/cjs/{search-results-view-9698b826.js → search-results-view-59510400.js} +35 -14
  27. package/dist/cjs/search-results-view-59510400.js.map +1 -0
  28. package/dist/cjs/{socket-service-8d8cf422.js → socket-service-d93a5433.js} +2 -2
  29. package/dist/cjs/{socket-service-8d8cf422.js.map → socket-service-d93a5433.js.map} +1 -1
  30. package/dist/cjs/{utils-e03d1710.js → utils-3a34a091.js} +23 -1
  31. package/dist/cjs/utils-3a34a091.js.map +1 -0
  32. package/dist/collection/components/ai12z-bot/ai12z-bot.js +249 -124
  33. package/dist/collection/components/ai12z-bot/ai12z-bot.js.map +1 -1
  34. package/dist/collection/components/ai12z-cta/ai12z-cta.js +22 -1
  35. package/dist/collection/components/ai12z-cta/ai12z-cta.js.map +1 -1
  36. package/dist/collection/components/ai12z-cta/components/Chat.js +28 -6
  37. package/dist/collection/components/ai12z-cta/components/Chat.js.map +1 -1
  38. package/dist/collection/components/ai12z-cta/components/ai12z-chat.css +6 -0
  39. package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js +23 -4
  40. package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js.map +1 -1
  41. package/dist/collection/components/ai12z-search-panel/search-results-view.js +32 -11
  42. package/dist/collection/components/ai12z-search-panel/search-results-view.js.map +1 -1
  43. package/dist/collection/components/input/input.css +0 -22
  44. package/dist/collection/utils/utils.js +21 -0
  45. package/dist/collection/utils/utils.js.map +1 -1
  46. package/dist/esm/{ai12z-bot-58dd3e22.js → ai12z-bot-07247cca.js} +253 -124
  47. package/dist/esm/ai12z-bot-07247cca.js.map +1 -0
  48. package/dist/esm/ai12z-bot.entry.js +3 -3
  49. package/dist/esm/ai12z-chat_3.entry.js +32 -10
  50. package/dist/esm/ai12z-chat_3.entry.js.map +1 -1
  51. package/dist/esm/{ai12z-cta-2fc523be.js → ai12z-cta-b3d6fc08.js} +25 -4
  52. package/dist/esm/ai12z-cta-b3d6fc08.js.map +1 -0
  53. package/dist/esm/ai12z-cta.entry.js +3 -3
  54. package/dist/esm/{ai12z-inline-search-a082bd18.js → ai12z-inline-search-d5252c97.js} +3 -3
  55. package/dist/esm/{ai12z-inline-search-a082bd18.js.map → ai12z-inline-search-d5252c97.js.map} +1 -1
  56. package/dist/esm/ai12z-inline-search.entry.js +3 -3
  57. package/dist/esm/{ai12z-knowledge-box-71a10937.js → ai12z-knowledge-box-7688725b.js} +24 -5
  58. package/dist/esm/ai12z-knowledge-box-7688725b.js.map +1 -0
  59. package/dist/esm/ai12z-knowledge-box.entry.js +2 -2
  60. package/dist/esm/{ai12z-search-panel-f9eabd62.js → ai12z-search-panel-b3d2d0a0.js} +2 -2
  61. package/dist/esm/{ai12z-search-panel-f9eabd62.js.map → ai12z-search-panel-b3d2d0a0.js.map} +1 -1
  62. package/dist/esm/ai12z-search-panel.entry.js +2 -2
  63. package/dist/esm/dynamic-form.entry.js +1 -1
  64. package/dist/esm/{index-fc3eb1dc.js → index-8bb0c170.js} +2 -2
  65. package/dist/esm/{index-fc3eb1dc.js.map → index-8bb0c170.js.map} +1 -1
  66. package/dist/esm/index.js +9 -9
  67. package/dist/esm/item-list.entry.js +2 -2
  68. package/dist/esm/library.js +1 -1
  69. package/dist/esm/loader.js +1 -1
  70. package/dist/esm/search-results-page.entry.js +3 -3
  71. package/dist/esm/{search-results-view-2f464371.js → search-results-view-e6fd8fa7.js} +35 -14
  72. package/dist/esm/search-results-view-e6fd8fa7.js.map +1 -0
  73. package/dist/esm/{socket-service-64fa6e19.js → socket-service-e8286872.js} +2 -2
  74. package/dist/esm/{socket-service-64fa6e19.js.map → socket-service-e8286872.js.map} +1 -1
  75. package/dist/esm/{utils-fa5a65e9.js → utils-0ba7b0d6.js} +23 -2
  76. package/dist/esm/utils-0ba7b0d6.js.map +1 -0
  77. package/dist/library/index.esm.js +1 -1
  78. package/dist/library/library.css +1 -1
  79. package/dist/library/library.esm.js +1 -1
  80. package/dist/library/library.esm.js.map +1 -1
  81. package/dist/library/p-195265e2.entry.js +2 -0
  82. package/dist/library/p-1c15f206.js +2 -0
  83. package/dist/library/p-1c15f206.js.map +1 -0
  84. package/dist/library/{p-b42e6cb8.js → p-1d115f2c.js} +2 -2
  85. package/dist/library/{p-dc7929d5.js → p-227fcf49.js} +2 -2
  86. package/dist/library/p-24d07f4d.entry.js +2 -0
  87. package/dist/library/p-35c8a27b.js +2 -0
  88. package/dist/library/p-35c8a27b.js.map +1 -0
  89. package/dist/library/p-41e46dbf.entry.js +2 -0
  90. package/dist/library/{p-a2697c01.js → p-4541791f.js} +2 -2
  91. package/dist/library/p-5c8ab5b9.js +2 -0
  92. package/dist/library/p-5c8ab5b9.js.map +1 -0
  93. package/dist/library/{p-e87d215d.js → p-60fd8119.js} +3 -3
  94. package/dist/library/{p-8dbc918f.js → p-622c2db6.js} +2 -2
  95. package/dist/library/p-622c2db6.js.map +1 -0
  96. package/dist/library/p-6ac8dc6e.entry.js +2 -0
  97. package/dist/library/p-6ac8dc6e.entry.js.map +1 -0
  98. package/dist/library/{p-859126a6.js → p-8529be4a.js} +2 -2
  99. package/dist/library/p-8529be4a.js.map +1 -0
  100. package/dist/library/{p-68f83f1c.entry.js → p-b85064f6.entry.js} +2 -2
  101. package/dist/library/p-bc1f7c69.entry.js +2 -0
  102. package/dist/library/{p-706e3933.entry.js → p-bdabf8ac.entry.js} +2 -2
  103. package/dist/library/p-dc407eb6.entry.js +2 -0
  104. package/dist/library/p-e8e84c4f.entry.js +2 -0
  105. package/dist/types/components/ai12z-bot/ai12z-bot.d.ts +6 -1
  106. package/dist/types/components/ai12z-cta/ai12z-cta.d.ts +1 -0
  107. package/dist/types/components/ai12z-knowledge-box/ai12z-knowledge-box.d.ts +1 -0
  108. package/dist/types/components/ai12z-search-panel/search-results-view.d.ts +1 -0
  109. package/dist/types/utils/utils.d.ts +2 -0
  110. package/package.json +2 -2
  111. package/dist/cjs/ai12z-bot-7aa40096.js.map +0 -1
  112. package/dist/cjs/ai12z-cta-3d6f0243.js.map +0 -1
  113. package/dist/cjs/ai12z-knowledge-box-005b5b85.js.map +0 -1
  114. package/dist/cjs/search-results-view-9698b826.js.map +0 -1
  115. package/dist/cjs/utils-e03d1710.js.map +0 -1
  116. package/dist/esm/ai12z-bot-58dd3e22.js.map +0 -1
  117. package/dist/esm/ai12z-cta-2fc523be.js.map +0 -1
  118. package/dist/esm/ai12z-knowledge-box-71a10937.js.map +0 -1
  119. package/dist/esm/search-results-view-2f464371.js.map +0 -1
  120. package/dist/esm/utils-fa5a65e9.js.map +0 -1
  121. package/dist/library/p-03269530.entry.js +0 -2
  122. package/dist/library/p-08bbb4b8.entry.js +0 -2
  123. package/dist/library/p-08bbb4b8.entry.js.map +0 -1
  124. package/dist/library/p-65aae1c6.entry.js +0 -2
  125. package/dist/library/p-6a90c905.js +0 -2
  126. package/dist/library/p-6a90c905.js.map +0 -1
  127. package/dist/library/p-859126a6.js.map +0 -1
  128. package/dist/library/p-8dbc918f.js.map +0 -1
  129. package/dist/library/p-90527e57.js +0 -2
  130. package/dist/library/p-90527e57.js.map +0 -1
  131. package/dist/library/p-b1bfa0cc.entry.js +0 -2
  132. package/dist/library/p-c5f0d025.js +0 -2
  133. package/dist/library/p-c5f0d025.js.map +0 -1
  134. package/dist/library/p-d77028d3.entry.js +0 -2
  135. package/dist/library/p-d77cc7ff.entry.js +0 -2
  136. package/dist/library/p-da2257d0.entry.js +0 -2
  137. /package/dist/library/{p-03269530.entry.js.map → p-195265e2.entry.js.map} +0 -0
  138. /package/dist/library/{p-b42e6cb8.js.map → p-1d115f2c.js.map} +0 -0
  139. /package/dist/library/{p-dc7929d5.js.map → p-227fcf49.js.map} +0 -0
  140. /package/dist/library/{p-65aae1c6.entry.js.map → p-24d07f4d.entry.js.map} +0 -0
  141. /package/dist/library/{p-b1bfa0cc.entry.js.map → p-41e46dbf.entry.js.map} +0 -0
  142. /package/dist/library/{p-a2697c01.js.map → p-4541791f.js.map} +0 -0
  143. /package/dist/library/{p-e87d215d.js.map → p-60fd8119.js.map} +0 -0
  144. /package/dist/library/{p-68f83f1c.entry.js.map → p-b85064f6.entry.js.map} +0 -0
  145. /package/dist/library/{p-d77028d3.entry.js.map → p-bc1f7c69.entry.js.map} +0 -0
  146. /package/dist/library/{p-706e3933.entry.js.map → p-bdabf8ac.entry.js.map} +0 -0
  147. /package/dist/library/{p-d77cc7ff.entry.js.map → p-dc407eb6.entry.js.map} +0 -0
  148. /package/dist/library/{p-da2257d0.entry.js.map → p-e8e84c4f.entry.js.map} +0 -0
@@ -5,8 +5,8 @@ const index$3 = require('./index-286c64af.js');
5
5
  const showdown = require('./showdown-f472e772.js');
6
6
  const index$2 = require('./index-8a74626f.js');
7
7
  const logger$1 = require('./logger-63779020.js');
8
- const utils = require('./utils-e03d1710.js');
9
- const index$1 = require('./index-19719993.js');
8
+ const utils = require('./utils-3a34a091.js');
9
+ const index$1 = require('./index-7a98f320.js');
10
10
  const globalStore = require('./global-store-1279b6b4.js');
11
11
 
12
12
  // ILiveAgentProvider.ts
@@ -677,6 +677,7 @@ const Ai12zBot = class {
677
677
  this.customJS = "";
678
678
  this.dataOverrideFunction = null;
679
679
  this.imagesBase64List = [];
680
+ this.ignoreChunks = false;
680
681
  this.toggleBot = e => {
681
682
  e.stopPropagation();
682
683
  this.isToggled = !this.isToggled;
@@ -698,6 +699,11 @@ const Ai12zBot = class {
698
699
  // console.log("survey results", sender.jsonObj)
699
700
  // const results = JSON.stringify(sender.data)
700
701
  let results = JSON.parse(JSON.stringify(sender.data));
702
+ utils.submitForm(this.dataKey, this.dataMode, sender.keyName, results).then(res => {
703
+ console.log("Form submission response:", res);
704
+ }).catch(err => {
705
+ console.error("Form submission error:", err);
706
+ });
701
707
  // results.description = sender.jsonObj.description ? sender.jsonObj.description : ""
702
708
  // const completedHtml = sender.jsonObj.completedHtml ? sender.jsonObj.completedHtml : "Thank You!"
703
709
  // const completeText = sender.jsonObj.completeText ? sender.jsonObj.completeText : "Submit"
@@ -807,17 +813,17 @@ const Ai12zBot = class {
807
813
  this.handleSend(label);
808
814
  };
809
815
  this.handleMessage = (data, aiMessageId) => {
810
- var _a;
811
816
  const converter = new showdown.showdown.Converter();
812
817
  // const aiMessageBubble = document.getElementById(aiMessageId);
813
- const aiMessageBubble = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#${aiMessageId}`);
814
- // const aiMessageBubble = this.element.querySelector('.ai12z-suggest-answer')
818
+ // const aiMessageBubble = await waitForElement(`#${aiMessageId}`, this.el)
819
+ const aiMessageBubble = this.el.shadowRoot.querySelector(`#${aiMessageId}`);
815
820
  if (!aiMessageBubble) {
816
821
  console.error(`Message bubble with ID ${aiMessageId} not found.`);
817
822
  return;
818
823
  }
819
824
  var bubbleText = aiMessageBubble.getAttribute("data-bubbleText") || "";
820
825
  bubbleText = bubbleText + data;
826
+ // console.log("bubbleText", bubbleText)
821
827
  aiMessageBubble.setAttribute("data-bubbleText", bubbleText);
822
828
  // Assuming data is a string containing the message content
823
829
  let html = converter.makeHtml(bubbleText);
@@ -872,14 +878,17 @@ const Ai12zBot = class {
872
878
  timestamp: timestamp,
873
879
  images: this.imagesBase64List,
874
880
  conversationId: this.conversationId,
881
+ isLoading: false,
875
882
  formModel: {},
876
883
  surveyDomId: "",
877
884
  },
878
885
  {
879
886
  text: this.botSettings.maxQuestion > 0 && this.questionCounter > this.botSettings.maxQuestion ? this.botSettings.msgLimit : "",
880
887
  isUser: false,
881
- id: `chatbot-${utils.generateUUID()}`,
888
+ id: '',
889
+ // id: this.isLiveAgent ? `chatbot-${generateUUID()}` : "",
882
890
  timestamp: "",
891
+ isLoading: true,
883
892
  images: [],
884
893
  conversationId: this.conversationId,
885
894
  formModel: {},
@@ -898,8 +907,9 @@ const Ai12zBot = class {
898
907
  this.inputEl.value = "";
899
908
  }
900
909
  else {
901
- this.currentDomId = this.messages[this.messages.length - 1].id;
910
+ this.currentDomId = "";
902
911
  if (this.isLiveAgent) {
912
+ this.messages = this.messages.slice(0, -1);
903
913
  this.liveAgentEventHandler.sendMessage({ sessionId: "", message: this.inputEl.value });
904
914
  if (this.inputEl.value) {
905
915
  this.inputEl.value = "";
@@ -908,6 +918,8 @@ const Ai12zBot = class {
908
918
  }
909
919
  else {
910
920
  this.checkLiveAgentMode();
921
+ this.isStreaming = true;
922
+ this.ignoreChunks = false;
911
923
  this.invokeSocket();
912
924
  }
913
925
  }
@@ -994,6 +1006,7 @@ const Ai12zBot = class {
994
1006
  this.scriptArray = [];
995
1007
  this.isAnimated = false;
996
1008
  this.isMinimized = false;
1009
+ this.isStreaming = false;
997
1010
  this.isOpened = false;
998
1011
  this.isContent = false;
999
1012
  this.isExpanded = undefined;
@@ -1424,10 +1437,23 @@ const Ai12zBot = class {
1424
1437
  }
1425
1438
  }
1426
1439
  }
1427
- watchStateHandler(_newValue, _oldValue) {
1440
+ // @Watch("currentDomId")
1441
+ // watchStateHandler(_newValue: boolean, _oldValue: boolean) {
1442
+ // this.socket.off("response")
1443
+ // this.socket.off("end_response")
1444
+ // // console.log("currentDomId changed")
1445
+ // // console.log("questionCounter", this.botSettings.maxQuestion)
1446
+ // if (this.botSettings.maxQuestion === undefined || this.botSettings.maxQuestion === 0) {
1447
+ // this.botSettings.maxQuestion = 0
1448
+ // this.handleBotMessages()
1449
+ // } else if (this.questionCounter <= this.botSettings.maxQuestion) {
1450
+ // this.handleBotMessages()
1451
+ // }
1452
+ // }
1453
+ handleSocketResponse() {
1428
1454
  this.socket.off("response");
1429
1455
  this.socket.off("end_response");
1430
- // console.log("currentDomId changed")
1456
+ console.log("currentDomId changed");
1431
1457
  // console.log("questionCounter", this.botSettings.maxQuestion)
1432
1458
  if (this.botSettings.maxQuestion === undefined || this.botSettings.maxQuestion === 0) {
1433
1459
  this.botSettings.maxQuestion = 0;
@@ -1442,6 +1468,7 @@ const Ai12zBot = class {
1442
1468
  text: "",
1443
1469
  isUser: false,
1444
1470
  id: `chatbot-${utils.generateUUID()}`,
1471
+ isLoading: true,
1445
1472
  timestamp: new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }),
1446
1473
  images: [],
1447
1474
  conversationId: this.conversationId,
@@ -1658,103 +1685,122 @@ const Ai12zBot = class {
1658
1685
  }
1659
1686
  handleBotMessages() {
1660
1687
  // const domId = this.messages[this.messages.length - 1].id
1661
- this.socket.on("response", event => {
1662
- this.handleMessage(event.data, `${this.currentDomId}`); // Use the unique ID to handle messages
1688
+ this.socket.on("response", async (event) => {
1689
+ // console.log("response", event)
1690
+ if (!this.currentDomId || this.currentDomId === '') {
1691
+ this.currentDomId = `chatbot-${utils.generateUUID()}`;
1692
+ // Update the last message with the generated ID
1693
+ if (this.messages.length > 0) {
1694
+ this.messages[this.messages.length - 1].id = this.currentDomId;
1695
+ this.messages = [...this.messages]; // Trigger reactivity
1696
+ }
1697
+ }
1698
+ requestAnimationFrame(() => {
1699
+ if (!this.ignoreChunks) {
1700
+ this.messages[this.messages.length - 1].isLoading = false;
1701
+ this.handleMessage(event.data, this.currentDomId);
1702
+ }
1703
+ });
1663
1704
  });
1664
1705
  this.socket.on("end_response", data => {
1665
- // console.log("end_response")
1706
+ // console.log("end_response", this.currentDomId)
1666
1707
  this.messageReceived.emit(data);
1667
- const converter = new showdown.showdown.Converter();
1668
- let finalHtml = converter.makeHtml(data.answer);
1669
- // document.getElementById("messageId").innerHTML = finalHtml;
1670
- finalHtml = this.updateAnchorTags(finalHtml);
1671
- finalHtml = utils.updateButtonEvents(finalHtml).body;
1672
- this.buttons = utils.updateButtonEvents(finalHtml).buttons;
1673
- this.searchResults = data;
1674
- this.conversationId = data.conversationId;
1675
- if (finalHtml.indexOf("[control") > -1) {
1676
- // console.log("controlType", data.controlType)
1677
- switch (data.controlType) {
1678
- case "form":
1679
- this.surveyDomId = "surveyElement-" + utils.generateUUID();
1680
- finalHtml = finalHtml.replace(RegExp(/\[[^>]*]/gm), `<div id=${this.surveyDomId} style="width:${this.botSettings.botVersion === "v1" ? "330px" : "100%"}" class="survey-container"></div>`);
1681
- // finalHtml = `<div id=${this.surveyDomId} style="width:${this.botSettings.botVersion === "v1" ? "330px" : "100%"}"></div>`
1682
- this.el.shadowRoot.querySelector(`#${this.currentDomId}`).innerHTML = finalHtml;
1683
- this.updateConversations(finalHtml, data);
1684
- break;
1685
- case "carousel":
1686
- case "list":
1687
- case "template":
1688
- // if (data.controlType && data.controlType !== null) {
1689
- // const newContent = splitContent(finalHtml)
1690
- // finalHtml = newContent.before
1691
- // this.updateConversations(finalHtml, data)
1692
- // const newMessage = this.generateMessage()
1693
- // this.messages = [...this.messages, newMessage]
1694
- // setTimeout(() => {
1695
- // data.controlType === "template" ? this.processTemplateData(newMessage, data) : this.processChatData(newMessage, data)
1696
- // }, 2000)
1697
- // if (newContent.after.trim().length > 0) {
1698
- // const afterMessage = this.generateMessage()
1699
- // afterMessage.text = newContent.after
1700
- // this.messages = [...this.messages, afterMessage]
1701
- // setTimeout(() => {
1702
- // if (afterMessage.id) {
1703
- // const bubbleEle = this.el.shadowRoot.querySelector(`#${afterMessage.id}`)
1704
- // if (bubbleEle && (bubbleEle.querySelector("#spinner") as HTMLElement)) {
1705
- // ;(bubbleEle.querySelector("#spinner") as HTMLElement).style.display = "none"
1706
- // }
1707
- // }
1708
- // }, 500)
1709
- // }
1710
- // }
1711
- if (data.controlType) {
1712
- const newContent = utils.splitContent(finalHtml);
1713
- finalHtml = newContent.before;
1714
- this.updateConversations(finalHtml, data);
1715
- const newMessage = this.generateMessage();
1716
- const messagesToAdd = [newMessage];
1717
- // Add after message if any
1718
- if (newContent.after.trim()) {
1719
- const afterMessage = this.generateMessage();
1720
- afterMessage.text = newContent.after;
1721
- afterMessage.id = afterMessage.id || `chatbot-${utils.generateUUID()}`;
1722
- messagesToAdd.push(afterMessage);
1723
- }
1724
- // 🔥 Single batched update
1725
- this.messages = [...this.messages, ...messagesToAdd];
1726
- // 🔁 Wait for DOM update (1 frame + microtask delay)
1727
- requestAnimationFrame(() => {
1728
- setTimeout(() => {
1729
- if (data.controlType === "template") {
1730
- this.processTemplateData(newMessage, data);
1731
- }
1732
- else {
1733
- this.processChatData(newMessage, data);
1734
- }
1735
- // Hide spinner for afterMessage if exists
1736
- const afterMessage = messagesToAdd[1];
1737
- if (afterMessage === null || afterMessage === void 0 ? void 0 : afterMessage.id) {
1738
- const bubbleEle = this.el.shadowRoot.querySelector(`#${afterMessage.id}`);
1739
- const spinner = bubbleEle === null || bubbleEle === void 0 ? void 0 : bubbleEle.querySelector("#spinner");
1740
- if (spinner)
1741
- spinner.style.display = "none";
1708
+ requestAnimationFrame(() => {
1709
+ if (!this.ignoreChunks) {
1710
+ const converter = new showdown.showdown.Converter();
1711
+ let finalHtml = converter.makeHtml(data.answer);
1712
+ // document.getElementById("messageId").innerHTML = finalHtml;
1713
+ finalHtml = this.updateAnchorTags(finalHtml);
1714
+ finalHtml = utils.updateButtonEvents(finalHtml).body;
1715
+ this.buttons = utils.updateButtonEvents(finalHtml).buttons;
1716
+ this.searchResults = data;
1717
+ this.conversationId = data.conversationId;
1718
+ if (finalHtml.indexOf("[control") > -1) {
1719
+ // console.log("controlType", data.controlType)
1720
+ switch (data.controlType) {
1721
+ case "form":
1722
+ this.surveyDomId = "surveyElement-" + utils.generateUUID();
1723
+ finalHtml = finalHtml.replace(RegExp(/\[[^>]*]/gm), `<div id=${this.surveyDomId} style="width:${this.botSettings.botVersion === "v1" ? "330px" : "100%"}" class="survey-container"></div>`);
1724
+ // finalHtml = `<div id=${this.surveyDomId} style="width:${this.botSettings.botVersion === "v1" ? "330px" : "100%"}"></div>`
1725
+ this.el.shadowRoot.querySelector(`#${this.currentDomId}`).innerHTML = finalHtml;
1726
+ this.updateConversations(finalHtml, data);
1727
+ break;
1728
+ case "carousel":
1729
+ case "list":
1730
+ case "template":
1731
+ // if (data.controlType && data.controlType !== null) {
1732
+ // const newContent = splitContent(finalHtml)
1733
+ // finalHtml = newContent.before
1734
+ // this.updateConversations(finalHtml, data)
1735
+ // const newMessage = this.generateMessage()
1736
+ // this.messages = [...this.messages, newMessage]
1737
+ // setTimeout(() => {
1738
+ // data.controlType === "template" ? this.processTemplateData(newMessage, data) : this.processChatData(newMessage, data)
1739
+ // }, 2000)
1740
+ // if (newContent.after.trim().length > 0) {
1741
+ // const afterMessage = this.generateMessage()
1742
+ // afterMessage.text = newContent.after
1743
+ // this.messages = [...this.messages, afterMessage]
1744
+ // setTimeout(() => {
1745
+ // if (afterMessage.id) {
1746
+ // const bubbleEle = this.el.shadowRoot.querySelector(`#${afterMessage.id}`)
1747
+ // if (bubbleEle && (bubbleEle.querySelector("#spinner") as HTMLElement)) {
1748
+ // ;(bubbleEle.querySelector("#spinner") as HTMLElement).style.display = "none"
1749
+ // }
1750
+ // }
1751
+ // }, 500)
1752
+ // }
1753
+ // }
1754
+ if (data.controlType) {
1755
+ const newContent = utils.splitContent(finalHtml);
1756
+ finalHtml = newContent.before;
1757
+ this.updateConversations(finalHtml, data);
1758
+ const newMessage = this.generateMessage();
1759
+ const messagesToAdd = [newMessage];
1760
+ // Add after message if any
1761
+ if (newContent.after.trim()) {
1762
+ const afterMessage = this.generateMessage();
1763
+ afterMessage.text = newContent.after;
1764
+ afterMessage.id = afterMessage.id || `chatbot-${utils.generateUUID()}`;
1765
+ messagesToAdd.push(afterMessage);
1742
1766
  }
1743
- }, 0);
1744
- });
1767
+ // 🔥 Single batched update
1768
+ this.messages = [...this.messages, ...messagesToAdd];
1769
+ // 🔁 Wait for DOM update (1 frame + microtask delay)
1770
+ requestAnimationFrame(() => {
1771
+ setTimeout(() => {
1772
+ if (data.controlType === "template") {
1773
+ this.processTemplateData(newMessage, data);
1774
+ }
1775
+ else {
1776
+ this.processChatData(newMessage, data);
1777
+ }
1778
+ // Hide spinner for afterMessage if exists
1779
+ const afterMessage = messagesToAdd[1];
1780
+ if (afterMessage === null || afterMessage === void 0 ? void 0 : afterMessage.id) {
1781
+ const bubbleEle = this.el.shadowRoot.querySelector(`#${afterMessage.id}`);
1782
+ const spinner = bubbleEle === null || bubbleEle === void 0 ? void 0 : bubbleEle.querySelector("#spinner");
1783
+ if (spinner)
1784
+ spinner.style.display = "none";
1785
+ }
1786
+ }, 0);
1787
+ });
1788
+ }
1745
1789
  }
1790
+ }
1791
+ else {
1792
+ const currentDomElement = this.el.shadowRoot.querySelector(`#${this.currentDomId}`);
1793
+ if (currentDomElement) {
1794
+ currentDomElement.style.width = "auto";
1795
+ }
1796
+ this.el.shadowRoot.querySelector(`#${this.currentDomId}`).innerHTML = finalHtml;
1797
+ this.updateConversations(finalHtml, data);
1798
+ }
1799
+ this.saveConversation();
1800
+ this.scrollToBottom();
1801
+ this.isStreaming = false;
1746
1802
  }
1747
- }
1748
- else {
1749
- const currentDomElement = this.el.shadowRoot.querySelector(`#${this.currentDomId}`);
1750
- if (currentDomElement) {
1751
- currentDomElement.style.width = "auto";
1752
- }
1753
- this.el.shadowRoot.querySelector(`#${this.currentDomId}`).innerHTML = finalHtml;
1754
- this.updateConversations(finalHtml, data);
1755
- }
1756
- this.saveConversation();
1757
- this.scrollToBottom();
1803
+ });
1758
1804
  });
1759
1805
  }
1760
1806
  updateAnchorTags(htmlContent) {
@@ -1775,6 +1821,7 @@ const Ai12zBot = class {
1775
1821
  id: this.currentDomId,
1776
1822
  text: finalHtml,
1777
1823
  isUser: false,
1824
+ isLoading: false,
1778
1825
  timestamp: new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }),
1779
1826
  images: [],
1780
1827
  conversationId: this.conversationId,
@@ -1787,8 +1834,14 @@ const Ai12zBot = class {
1787
1834
  sender: (_g = data === null || data === void 0 ? void 0 : data.sender) !== null && _g !== void 0 ? _g : null,
1788
1835
  };
1789
1836
  this.addEventListeners(`#${this.currentDomId}`);
1837
+ console.log("currrentDomid", this.currentDomId);
1838
+ console.log("message", updatedmsg);
1790
1839
  this.messages = this.messages.map(item => (item.id === this.currentDomId ? updatedmsg : item));
1791
- requestAnimationFrame(() => this.checkHighlightcode(this.currentDomId));
1840
+ requestAnimationFrame(() => {
1841
+ this.checkHighlightcode(this.currentDomId);
1842
+ // ✅ Reset for next message
1843
+ this.currentDomId = '';
1844
+ });
1792
1845
  }
1793
1846
  checkHighlightcode(highlightcodeId = "") {
1794
1847
  var _a;
@@ -1959,6 +2012,8 @@ const Ai12zBot = class {
1959
2012
  await new Promise(resolve => {
1960
2013
  this.socket.on("connect", () => {
1961
2014
  // console.log("Connected to Socket.IO server")
2015
+ // ✅ Set up listeners once when socket connects
2016
+ this.handleSocketResponse();
1962
2017
  resolve();
1963
2018
  });
1964
2019
  });
@@ -1997,6 +2052,14 @@ const Ai12zBot = class {
1997
2052
  if (error) {
1998
2053
  this.errored.emit(error);
1999
2054
  console.error("Error:", error);
2055
+ this.currentDomId = `chatbot-${utils.generateUUID()}`;
2056
+ this.messages[this.messages.length - 1].id = this.currentDomId;
2057
+ this.messages[this.messages.length - 1].text = "Error connecting to server. Please try again later.";
2058
+ }
2059
+ else {
2060
+ console.log("Data sent to server successfully");
2061
+ // this.handleSocketResponse()
2062
+ // console.log("Response:", response)
2000
2063
  }
2001
2064
  });
2002
2065
  if (this.inputEl) {
@@ -2202,7 +2265,7 @@ const Ai12zBot = class {
2202
2265
  if (ev.key === "Enter" && !ev.shiftKey) {
2203
2266
  // console.log("down arrow pressed")
2204
2267
  ev.preventDefault();
2205
- if (((_a = this.inputEl) === null || _a === void 0 ? void 0 : _a.value.trim().length) > 0) {
2268
+ if (((_a = this.inputEl) === null || _a === void 0 ? void 0 : _a.value.trim().length) > 0 && !this.isStreaming) {
2206
2269
  this.handleSend(this.inputEl.value);
2207
2270
  }
2208
2271
  }
@@ -2216,6 +2279,12 @@ const Ai12zBot = class {
2216
2279
  localStorage.setItem(`ai12z-bot-data`, JSON.stringify({ qCounter: this.questionCounter }));
2217
2280
  }, this.botSettings.autoResetTimer);
2218
2281
  }
2282
+ stopResponse() {
2283
+ this.ignoreChunks = true; // drop future chunks
2284
+ this.isStreaming = false;
2285
+ this.messages[this.messages.length - 1].isLoading = false;
2286
+ // this.socket.off('response');
2287
+ }
2219
2288
  scrollToBottom() {
2220
2289
  const container = this.el.shadowRoot.querySelector(".chat-body");
2221
2290
  if (container) {
@@ -2328,6 +2397,7 @@ const Ai12zBot = class {
2328
2397
  const conversationExists = this.getConversationHistory();
2329
2398
  let messageHistory = conversationExists.filter(item => { var _a; return item.conversationId === this.conversationId && item.projectId === ((_a = this.botSettings) === null || _a === void 0 ? void 0 : _a.pId); });
2330
2399
  this.isTypingIndicatorVisible = true;
2400
+ this.showTextarea = true;
2331
2401
  liveAgentSettings = {
2332
2402
  config: liveAgentSettings,
2333
2403
  userId: this.visitorID,
@@ -2346,11 +2416,23 @@ const Ai12zBot = class {
2346
2416
  this.liveAgentEventHandler.connectToLiveAgent(liveAgentProviderNames[0], liveAgentSettings);
2347
2417
  ChatEventBus.on("AGENT_SESSION_CREATED", () => {
2348
2418
  this.isLiveAgent = true;
2419
+ this.showTextarea = true;
2420
+ requestAnimationFrame(() => {
2421
+ var _a;
2422
+ const inputEl = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('[data-testid="user-input-textarea"]');
2423
+ console.log("inputEl", inputEl);
2424
+ if (inputEl) {
2425
+ this.inputEl = inputEl;
2426
+ }
2427
+ });
2349
2428
  this.liveAgentButtonText = "End liveagent chat";
2350
2429
  });
2351
2430
  ChatEventBus.on("AGENT_EVENT", (event) => {
2352
2431
  this.isTypingIndicatorVisible = false;
2353
2432
  if ((event === null || event === void 0 ? void 0 : event.length) > 0) {
2433
+ if (this.isLiveAgentEnabled && this.currentDomId === "") {
2434
+ this.currentDomId = this.messages[this.messages.length - 1].id;
2435
+ }
2354
2436
  const agentEventMessages = this.liveAgentEventHandler.addAgentEventMessage(event);
2355
2437
  if (agentEventMessages) {
2356
2438
  const currentDomElement = this.el.shadowRoot.querySelector(`#${this.currentDomId}`);
@@ -2361,6 +2443,7 @@ const Ai12zBot = class {
2361
2443
  if (this.inputEl) {
2362
2444
  this.inputEl.value = "";
2363
2445
  }
2446
+ this.currentDomId = "";
2364
2447
  }
2365
2448
  }
2366
2449
  });
@@ -2371,21 +2454,45 @@ const Ai12zBot = class {
2371
2454
  this.isTypingIndicatorVisible = false;
2372
2455
  });
2373
2456
  ChatEventBus.on("AGENT_MESSAGE", (message) => {
2374
- var _a;
2457
+ if (this.currentDomId === "") {
2458
+ // Get the last message in the messages array
2459
+ const lastMessage = this.messages[this.messages.length - 1];
2460
+ // check if last message is from user or agent
2461
+ if (!lastMessage.sender || lastMessage.sender === null) {
2462
+ // Generate a new temporary message object
2463
+ const tempMsg = this.generateMessage();
2464
+ // Generate a unique ID for the new message
2465
+ this.currentDomId = `chatbot-${utils.generateUUID()}`;
2466
+ tempMsg.id = this.currentDomId;
2467
+ tempMsg.isLoading = false;
2468
+ // Set sender to 'agent' for live agent messages
2469
+ this.messages = [...this.messages, tempMsg];
2470
+ }
2471
+ else {
2472
+ // If the last message is from the user or already has a sender, update its ID
2473
+ this.currentDomId = `chatbot-${utils.generateUUID()}`;
2474
+ this.messages[this.messages.length - 1].id = this.currentDomId;
2475
+ this.messages = [...this.messages]; // Trigger reactivity
2476
+ }
2477
+ }
2375
2478
  const retMessage = this.liveAgentEventHandler.handleAgentMessage(message);
2376
2479
  if (retMessage) {
2377
- const aiMessageBubble = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#${this.currentDomId}`);
2378
- if (aiMessageBubble) {
2379
- const converter = new showdown.showdown.Converter();
2380
- let bubbleText = aiMessageBubble.getAttribute("data-bubbleText") || "";
2381
- bubbleText = `${bubbleText} \n\n ${retMessage}`;
2382
- aiMessageBubble.setAttribute("data-bubbleText", bubbleText);
2383
- let html = converter.makeHtml(bubbleText);
2384
- this.updateConversations(html, message[0]);
2385
- }
2386
- setTimeout(() => {
2387
- this.scrollToBottom();
2388
- }, 10);
2480
+ // Wait for DOM to update before querying
2481
+ requestAnimationFrame(() => {
2482
+ var _a;
2483
+ const aiMessageBubble = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#${this.currentDomId}`);
2484
+ if (aiMessageBubble) {
2485
+ const converter = new showdown.showdown.Converter();
2486
+ let bubbleText = aiMessageBubble.getAttribute("data-bubbleText") || "";
2487
+ bubbleText = `${bubbleText} \n\n ${retMessage}`;
2488
+ aiMessageBubble.setAttribute("data-bubbleText", bubbleText);
2489
+ let html = converter.makeHtml(bubbleText);
2490
+ this.updateConversations(html, message[0]);
2491
+ }
2492
+ setTimeout(() => {
2493
+ this.scrollToBottom();
2494
+ }, 10);
2495
+ });
2389
2496
  }
2390
2497
  });
2391
2498
  ChatEventBus.on("AGENT_ERROR", () => {
@@ -2407,6 +2514,10 @@ const Ai12zBot = class {
2407
2514
  text: _message,
2408
2515
  },
2409
2516
  ]);
2517
+ // console.log("agentEventMessages", this.currentDomId)
2518
+ if (this.currentDomId === "") {
2519
+ this.currentDomId = this.messages[this.messages.length - 1].id;
2520
+ }
2410
2521
  if (agentEventMessages) {
2411
2522
  const currentDomElement = this.el.shadowRoot.querySelector(`#${this.currentDomId}`);
2412
2523
  if (currentDomElement) {
@@ -2464,7 +2575,9 @@ const Ai12zBot = class {
2464
2575
  this.toggleBot(e);
2465
2576
  this.showHistory = false;
2466
2577
  this.showWelcomeScreen = true;
2467
- this.handleSend(button.label);
2578
+ if (!this.isStreaming) {
2579
+ this.handleSend(button.label);
2580
+ }
2468
2581
  } }, button.label)))), index.h("div", { class: "w-full dropdown-item", role: "menuitem", tabindex: "-1" }, index.h("button", { class: "dropdown-item-button", onClick: e => {
2469
2582
  this.toggleBot(e);
2470
2583
  this.showHistory = true;
@@ -2510,7 +2623,7 @@ const Ai12zBot = class {
2510
2623
  const email = "";
2511
2624
  return (index.h("div", { class: `flex pb-3 gap-x-2 @md:gap-x-3
2512
2625
  ${message.isUser ? "self-end" : ""}
2513
- ${message.isUser ? "justify-end" : ""} end-user-message message-item`, style: { opacity: "1", transform: "none" } }, message.isUser && (index.h("div", { class: "flex flex-col items-end" }, index.h("div", { "data-testid": "message", class: "break-words @md:text-body2 box-border @md:pr-4 flex-1 rounded-lg py-2 px-4 user-msg text-body3", innerHTML: message.text }, (_a = message === null || message === void 0 ? void 0 : message.images) === null || _a === void 0 ? void 0 : _a.map(img => {
2626
+ ${message.isUser ? "justify-end" : ""} end-user-message message-item`, style: { opacity: "1", transform: "none" } }, message.isUser && (index.h("div", { class: "flex flex-col items-end" }, index.h("div", { "data-testid": "message", class: "break-words @md:text-body2 box-border @md:pr-4 flex-1 rounded-lg py-2 px-4 user-msg text-body3", innerHTML: message.text, id: message.id }, (_a = message === null || message === void 0 ? void 0 : message.images) === null || _a === void 0 ? void 0 : _a.map(img => {
2514
2627
  return index.h("img", { src: img, class: "thumbnail", alt: "thumbnail" });
2515
2628
  })), index.h("div", { class: "text-gray-30 pt-2 text-right text-body4" }, "Sent ", message.timestamp))), !message.isUser && (index.h("div", { class: "avatar-column" }, index.h("chat-avatar", { id: `la${message.id}`, senderType: (message === null || message === void 0 ? void 0 : message.sender) ? "agent" : "bot", avatarUrl: (_b = this.botSettings) === null || _b === void 0 ? void 0 : _b.botAvatar }))), !message.isUser && (index.h("div", { class: "flex flex-col", style: { width: "100%" } }, index.h("div", { "data-testid": "message", class: {
2516
2629
  "prose": message.controlType === "form" ? false : true,
@@ -2519,7 +2632,7 @@ const Ai12zBot = class {
2519
2632
  "opacity-100": this.isProse,
2520
2633
  "opacity-90": !this.isProse,
2521
2634
  "max-w-full break-words @md:text-body2 box-border @md:pr-4 flex-1 rounded-lg text-gray-30 pr-2 text-body3": true,
2522
- }, innerHTML: message.text, id: message.id }, message.text === "" && (index.h("div", { class: "w-full rounded-md", id: "spinner" }, index.h("div", { class: "flex animate-pulse space-x-4" }, index.h("div", { class: "flex-1 space-y-3 py-1" }, index.h("div", { class: "h-4 rounded bg-gray-200" }), index.h("div", { class: "space-y-3" }, index.h("div", { class: "grid grid-cols-3 gap-4" }, index.h("div", { class: "col-span-2 h-4 rounded bg-gray-200" }), index.h("div", { class: "col-span-1 h-4 rounded bg-gray-200" })), index.h("div", { class: "h-4 rounded bg-gray-200" }))))))), message.text !== "" && message.showIcon && (index.h("div", { class: "thumbs-container flex gap-2 mt-2" }, this.isPlayed && (index.h("button", { class: "copy-btn", onClick: () => {
2635
+ }, innerHTML: message.text, id: message.id }, message.isLoading && (index.h("div", { class: "w-full rounded-md", id: "spinner" }, index.h("div", { class: "flex animate-pulse space-x-4" }, index.h("div", { class: "flex-1 space-y-3 py-1" }, index.h("div", { class: "h-4 rounded bg-gray-200" }), index.h("div", { class: "space-y-3" }, index.h("div", { class: "grid grid-cols-3 gap-4" }, index.h("div", { class: "col-span-2 h-4 rounded bg-gray-200" }), index.h("div", { class: "col-span-1 h-4 rounded bg-gray-200" })), index.h("div", { class: "h-4 rounded bg-gray-200" }))))))), message.text !== "" && message.showIcon && (index.h("div", { class: "thumbs-container flex gap-2 mt-2" }, this.isPlayed && (index.h("button", { class: "copy-btn", onClick: () => {
2523
2636
  this.isPlayed = false;
2524
2637
  window.speechSynthesis.cancel();
2525
2638
  if (this.audioElement) {
@@ -2545,7 +2658,10 @@ const Ai12zBot = class {
2545
2658
  } }, index.h("input", { type: "file", multiple: true, name: "files[]", id: "fileInput", accept: "image/*", class: "image-upload__input", onChange: ($event) => {
2546
2659
  // this.isImage = true
2547
2660
  this.onInputChange($event.target.files);
2548
- }, ref: el => (this.uploadElem = el) }), index.h("div", { class: "mr-1" }, index.h("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", class: "h-5 w-5 shrink-0" }, index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M18.0322 5.02393C17.7488 5.00078 17.3766 5 16.8 5H11.5002C11.3 6 11.0989 6.91141 10.8903 7.85409C10.7588 8.44955 10.6432 8.97304 10.3675 9.41399C10.1262 9.80009 9.80009 10.1262 9.41399 10.3675C8.97304 10.6432 8.44955 10.7588 7.85409 10.8903C7.81276 10.8994 7.77108 10.9086 7.72906 10.9179L5.21693 11.4762C5.1442 11.4924 5.07155 11.5001 5 11.5002V16.8C5 17.3766 5.00078 17.7488 5.02393 18.0322C5.04612 18.3038 5.0838 18.4045 5.109 18.454C5.20487 18.6422 5.35785 18.7951 5.54601 18.891C5.59546 18.9162 5.69617 18.9539 5.96784 18.9761C6.25118 18.9992 6.62345 19 7.2 19H10C10.5523 19 11 19.4477 11 20C11 20.5523 10.5523 21 10 21H7.16144C6.6343 21 6.17954 21 5.80497 20.9694C5.40963 20.9371 5.01641 20.8658 4.63803 20.673C4.07354 20.3854 3.6146 19.9265 3.32698 19.362C3.13419 18.9836 3.06287 18.5904 3.03057 18.195C2.99997 17.8205 2.99998 17.3657 3 16.8385L3 11C3 8.92477 4.02755 6.93324 5.4804 5.4804C6.93324 4.02755 8.92477 3 11 3L16.8385 3C17.3657 2.99998 17.8205 2.99997 18.195 3.03057C18.5904 3.06287 18.9836 3.13419 19.362 3.32698C19.9265 3.6146 20.3854 4.07354 20.673 4.63803C20.8658 5.01641 20.9371 5.40963 20.9694 5.80497C21 6.17954 21 6.6343 21 7.16144V10C21 10.5523 20.5523 11 20 11C19.4477 11 19 10.5523 19 10V7.2C19 6.62345 18.9992 6.25118 18.9761 5.96784C18.9539 5.69617 18.9162 5.59546 18.891 5.54601C18.7951 5.35785 18.6422 5.20487 18.454 5.109C18.4045 5.0838 18.3038 5.04612 18.0322 5.02393ZM5.28014 9.41336L7.2952 8.96556C8.08861 8.78925 8.24308 8.74089 8.35381 8.67166C8.48251 8.59121 8.59121 8.48251 8.67166 8.35381C8.74089 8.24308 8.78925 8.08861 8.96556 7.2952L9.41336 5.28014C8.51014 5.59289 7.63524 6.15398 6.89461 6.89461C6.15398 7.63524 5.59289 8.51014 5.28014 9.41336ZM17 15C17 14.4477 17.4477 14 18 14C18.5523 14 19 14.4477 19 15V17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H19V21C19 21.5523 18.5523 22 18 22C17.4477 22 17 21.5523 17 21V19H15C14.4477 19 14 18.5523 14 18C14 17.4477 14.4477 17 15 17H17V15Z", fill: "currentColor" }))), index.h("div", null, "Upload Images")))))), index.h("div", { class: `${this.isContent ? "hidden" : ""} textarea` }, index.h("div", { id: "previewContainer" }), this.showTextarea && (index.h("textarea", { class: `resize-none overflow-hidden text-ellipsis focus:outline-none w-full ${this.hideAllButtons ? "hidden" : ""}`, "data-testid": "user-input-textarea", rows: this.rowCount, name: "userMessage", placeholder: (_u = (_t = this.botSettings) === null || _t === void 0 ? void 0 : _t.botPlaceholderText) !== null && _u !== void 0 ? _u : "Ask me anything",
2661
+ }, ref: el => (this.uploadElem = el) }), index.h("div", { class: "mr-1" }, index.h("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", class: "h-5 w-5 shrink-0" }, index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M18.0322 5.02393C17.7488 5.00078 17.3766 5 16.8 5H11.5002C11.3 6 11.0989 6.91141 10.8903 7.85409C10.7588 8.44955 10.6432 8.97304 10.3675 9.41399C10.1262 9.80009 9.80009 10.1262 9.41399 10.3675C8.97304 10.6432 8.44955 10.7588 7.85409 10.8903C7.81276 10.8994 7.77108 10.9086 7.72906 10.9179L5.21693 11.4762C5.1442 11.4924 5.07155 11.5001 5 11.5002V16.8C5 17.3766 5.00078 17.7488 5.02393 18.0322C5.04612 18.3038 5.0838 18.4045 5.109 18.454C5.20487 18.6422 5.35785 18.7951 5.54601 18.891C5.59546 18.9162 5.69617 18.9539 5.96784 18.9761C6.25118 18.9992 6.62345 19 7.2 19H10C10.5523 19 11 19.4477 11 20C11 20.5523 10.5523 21 10 21H7.16144C6.6343 21 6.17954 21 5.80497 20.9694C5.40963 20.9371 5.01641 20.8658 4.63803 20.673C4.07354 20.3854 3.6146 19.9265 3.32698 19.362C3.13419 18.9836 3.06287 18.5904 3.03057 18.195C2.99997 17.8205 2.99998 17.3657 3 16.8385L3 11C3 8.92477 4.02755 6.93324 5.4804 5.4804C6.93324 4.02755 8.92477 3 11 3L16.8385 3C17.3657 2.99998 17.8205 2.99997 18.195 3.03057C18.5904 3.06287 18.9836 3.13419 19.362 3.32698C19.9265 3.6146 20.3854 4.07354 20.673 4.63803C20.8658 5.01641 20.9371 5.40963 20.9694 5.80497C21 6.17954 21 6.6343 21 7.16144V10C21 10.5523 20.5523 11 20 11C19.4477 11 19 10.5523 19 10V7.2C19 6.62345 18.9992 6.25118 18.9761 5.96784C18.9539 5.69617 18.9162 5.59546 18.891 5.54601C18.7951 5.35785 18.6422 5.20487 18.454 5.109C18.4045 5.0838 18.3038 5.04612 18.0322 5.02393ZM5.28014 9.41336L7.2952 8.96556C8.08861 8.78925 8.24308 8.74089 8.35381 8.67166C8.48251 8.59121 8.59121 8.48251 8.67166 8.35381C8.74089 8.24308 8.78925 8.08861 8.96556 7.2952L9.41336 5.28014C8.51014 5.59289 7.63524 6.15398 6.89461 6.89461C6.15398 7.63524 5.59289 8.51014 5.28014 9.41336ZM17 15C17 14.4477 17.4477 14 18 14C18.5523 14 19 14.4477 19 15V17H21C21.5523 17 22 17.4477 22 18C22 18.5523 21.5523 19 21 19H19V21C19 21.5523 18.5523 22 18 22C17.4477 22 17 21.5523 17 21V19H15C14.4477 19 14 18.5523 14 18C14 17.4477 14.4477 17 15 17H17V15Z", fill: "currentColor" }))), index.h("div", null, "Upload Images")))))), index.h("div", { class: `${this.isContent ? "hidden" : ""} textarea` }, index.h("div", { id: "previewContainer" }), index.h("textarea", { class: `resize-none overflow-hidden text-ellipsis focus:outline-none w-full ${this.hideAllButtons ? "hidden" : ""}`, "data-testid": "user-input-textarea", rows: this.rowCount, name: "userMessage", placeholder: this.isLiveAgent
2662
+ ? "Type a message to the agent..."
2663
+ : ((_u = (_t = this.botSettings) === null || _t === void 0 ? void 0 : _t.botPlaceholderText) !== null && _u !== void 0 ? _u : "Ask me anything"),
2664
+ // placeholder={this.botSettings?.botPlaceholderText ?? "Ask me anything"}
2549
2665
  // aria-labelledby="message-submit"
2550
2666
  ref: el => (this.inputEl = el), onKeyUp: _e => {
2551
2667
  this.adjustHeight();
@@ -2554,7 +2670,7 @@ const Ai12zBot = class {
2554
2670
  if (e.key === "Enter" && !e.shiftKey) {
2555
2671
  this.isOpened = true;
2556
2672
  }
2557
- } }))), this.botSettings.enableMic && (index.h("label", { class: `absolute bottom-0 ${this.isContent ? "hidden" : ""} ${this.hideAllButtons ? "w-full" : "right-8"}` }, index.h("audio-recorder", { "component-type": "bot", onStartRecord: _ev => {
2673
+ } })), this.botSettings.enableMic && (index.h("label", { class: `absolute bottom-0 ${this.isContent ? "hidden" : ""} ${this.hideAllButtons ? "w-full" : "right-8"}` }, index.h("audio-recorder", { "component-type": "bot", onStartRecord: _ev => {
2558
2674
  // console.log("test", ev)
2559
2675
  this.hideAllButtons = true;
2560
2676
  }, onStopRecord: _ev => {
@@ -2569,7 +2685,7 @@ const Ai12zBot = class {
2569
2685
  this.showSubmit = true;
2570
2686
  }
2571
2687
  }, 1000);
2572
- }, style: { width: this.hideAllButtons ? "100%" : "10%" } }))), index.h("label", { class: `absolute right-0 bottom-0 ${this.isContent ? "hidden" : ""} ${this.hideAllButtons ? "hidden" : ""}` }, index.h("button", { class: "text-white transition rounded-full p-1.5 self-center btn-bg-color",
2688
+ }, style: { width: this.hideAllButtons ? "100%" : "10%" } }))), index.h("label", { class: `absolute right-0 bottom-0 ${this.isContent ? "hidden" : ""} ${this.hideAllButtons ? "hidden" : ""}` }, !this.isStreaming && index.h("button", { class: "text-white transition rounded-full p-1.5 self-center btn-bg-color",
2573
2689
  // class="rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-8 w-8"
2574
2690
  tabindex: "-1", id: "message-submit",
2575
2691
  // type="submit"
@@ -2581,8 +2697,22 @@ const Ai12zBot = class {
2581
2697
  }
2582
2698
  this.isOpened = true;
2583
2699
  // this.handleMessageSubmit(e)
2700
+ // this.isStreaming = true
2584
2701
  this.handleSend((_a = this.inputEl) === null || _a === void 0 ? void 0 : _a.value);
2585
- } }, index.h("i", { class: "block ai-icon text-body1" }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", class: "size-6" }, index.h("path", { "fill-rule": "evenodd", d: "M8 14a.75.75 0 0 1-.75-.75V4.56L4.03 7.78a.75.75 0 0 1-1.06-1.06l4.5-4.5a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.75 4.56v8.69A.75.75 0 0 1 8 14Z", "clip-rule": "evenodd" }))))), index.h("button", { class: `${this.isContent && !this.isMinimized ? "block" : "hidden"} rounded-full isContent`, "aria-label": "Return to AI", onClick: ev => {
2702
+ } }, index.h("i", { class: "block ai-icon text-body1" }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", class: "size-6" }, index.h("path", { "fill-rule": "evenodd", d: "M8 14a.75.75 0 0 1-.75-.75V4.56L4.03 7.78a.75.75 0 0 1-1.06-1.06l4.5-4.5a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.75 4.56v8.69A.75.75 0 0 1 8 14Z", "clip-rule": "evenodd" })))), this.isStreaming && index.h("button", { class: "text-white transition rounded-full p-1.5 self-center btn-bg-color",
2703
+ // class="rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-8 w-8"
2704
+ tabindex: "-1", id: "message-submit",
2705
+ // type="submit"
2706
+ onClick: e => {
2707
+ e.preventDefault();
2708
+ // if ((!this.inputEl || this.inputEl.value.trim() === "") && this.imagesBase64List && this.imagesBase64List.length === 0) {
2709
+ // return
2710
+ // }
2711
+ this.isOpened = true;
2712
+ this.stopResponse();
2713
+ // this.handleMessageSubmit(e)
2714
+ // this.handleSend(this.inputEl?.value)
2715
+ } }, index.h("i", { class: "block text-body1" }, index.h("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", class: "size-6" }, index.h("path", { d: "M4.5 5.75C4.5 5.05964 5.05964 4.5 5.75 4.5H14.25C14.9404 4.5 15.5 5.05964 15.5 5.75V14.25C15.5 14.9404 14.9404 15.5 14.25 15.5H5.75C5.05964 15.5 4.5 14.9404 4.5 14.25V5.75Z" }))))), index.h("button", { class: `${this.isContent && !this.isMinimized ? "block" : "hidden"} rounded-full isContent`, "aria-label": "Return to AI", onClick: ev => {
2586
2716
  ev.preventDefault();
2587
2717
  this.isContent = false;
2588
2718
  this.isOpened = true;
@@ -2602,7 +2732,6 @@ const Ai12zBot = class {
2602
2732
  }
2603
2733
  get el() { return index.getElement(this); }
2604
2734
  static get watchers() { return {
2605
- "currentDomId": ["watchStateHandler"],
2606
2735
  "surveyDomId": ["watchSurveyDomIdHandler"]
2607
2736
  }; }
2608
2737
  };
@@ -2610,4 +2739,4 @@ Ai12zBot.style = Ai12zBotStyle0 + (Ai12zBotStyle1 + (Ai12zBotStyle2 + Ai12zBotSt
2610
2739
 
2611
2740
  exports.Ai12zBot = Ai12zBot;
2612
2741
 
2613
- //# sourceMappingURL=ai12z-bot-7aa40096.js.map
2742
+ //# sourceMappingURL=ai12z-bot-b00dcf4f.js.map