ai12z 3.16.1-alpha.2 → 3.16.1-alpha.4

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 (232) hide show
  1. package/dist/cjs/ai12z-beacon.cjs.entry.js +35 -0
  2. package/dist/cjs/ai12z-bot.cjs.entry.js +129 -61
  3. package/dist/cjs/ai12z-category_2.cjs.entry.js +7 -7
  4. package/dist/cjs/ai12z-chat-message.cjs.entry.js +4 -4
  5. package/dist/cjs/ai12z-chat_2.cjs.entry.js +23 -19
  6. package/dist/cjs/ai12z-container.cjs.entry.js +4 -4
  7. package/dist/cjs/ai12z-cta.cjs.entry.js +11 -5
  8. package/dist/cjs/ai12z-form.cjs.entry.js +3 -3
  9. package/dist/cjs/ai12z-inline-search.cjs.entry.js +5 -5
  10. package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +27 -22
  11. package/dist/cjs/ai12z-search-panel.cjs.entry.js +4 -4
  12. package/dist/cjs/ai12z-spinner.cjs.entry.js +1 -1
  13. package/dist/cjs/beacon-B9ZWQpG6.js +321 -0
  14. package/dist/cjs/bodyScrollLock-C7gKTAfx.js +69 -0
  15. package/dist/cjs/chat-avatar_6.cjs.entry.js +12 -12
  16. package/dist/cjs/chatbot-history_2.cjs.entry.js +1 -1
  17. package/dist/cjs/{ctaHelpers-DUPj5SnE.js → ctaHelpers-CmoXzyRy.js} +1 -1
  18. package/dist/cjs/dynamic-form.cjs.entry.js +2 -2
  19. package/dist/cjs/image-uploader_2.cjs.entry.js +1 -1
  20. package/dist/cjs/{index-CKLC7f4y.js → index-DbNk7qkZ.js} +1 -1
  21. package/dist/cjs/index.cjs.js +14 -10
  22. package/dist/cjs/item-list.cjs.entry.js +2 -2
  23. package/dist/cjs/{keyboard-shortcuts-BWprLtLj.js → keyboard-shortcuts-BpiAXzLW.js} +2 -2
  24. package/dist/cjs/library.cjs.js +1 -1
  25. package/dist/cjs/loader.cjs.js +1 -1
  26. package/dist/cjs/{parseHelper-5fRVefLm.js → parseHelper-CbA81TvP.js} +1 -1
  27. package/dist/cjs/{processCarouselData-kCVPE4mw.js → processCarouselData-Dl_WYwVE.js} +1 -1
  28. package/dist/cjs/{reCaptchaHelpers-sfktrnTF.js → reCaptchaHelpers-mbTvATH6.js} +1 -1
  29. package/dist/cjs/search-results-page.cjs.entry.js +16 -14
  30. package/dist/cjs/{socket-service-5mM7NSYN.js → socket-service-Cx-4DSqu.js} +1 -1
  31. package/dist/cjs/{styleSheetRegistry-CaWjqgX7.js → styleSheetRegistry-BmpJ3hCP.js} +1 -1
  32. package/dist/cjs/{surveyHelpers-DohugkWP.js → surveyHelpers-DFh4q1hj.js} +1 -1
  33. package/dist/cjs/{utils-7C5_GnyF.js → utils-C2m26j54.js} +19 -2
  34. package/dist/collection/collection-manifest.json +1 -0
  35. package/dist/collection/components/ai12z-beacon/ai12z-beacon.js +74 -0
  36. package/dist/collection/components/ai12z-bot/ai12z-bot.js +59 -12
  37. package/dist/collection/components/ai12z-bot/chat-history.js +1 -1
  38. package/dist/collection/components/ai12z-bot/components/hamburger-menu/hamburger-menu.js +4 -4
  39. package/dist/collection/components/ai12z-bot/components/interaction-buttons/interaction-buttons.js +5 -5
  40. package/dist/collection/components/ai12z-bot/components/liveagent-chat/liveagent-chat.js +1 -1
  41. package/dist/collection/components/ai12z-bot/components/typing-indicator/typing-indicator.js +1 -1
  42. package/dist/collection/components/ai12z-container/ai12z-container.js +1 -1
  43. package/dist/collection/components/ai12z-cta/ai12z-cta.css +2 -1
  44. package/dist/collection/components/ai12z-cta/ai12z-cta.js +6 -0
  45. package/dist/collection/components/ai12z-cta/components/Chat.js +6 -2
  46. package/dist/collection/components/ai12z-cta/components/DynamicForm.js +1 -1
  47. package/dist/collection/components/ai12z-cta/components/audiorecorder/audio-recorder.js +4 -4
  48. package/dist/collection/components/ai12z-form/ai12z-form.js +1 -1
  49. package/dist/collection/components/ai12z-inline-search/ai12z-inline-search.js +3 -3
  50. package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js +22 -17
  51. package/dist/collection/components/ai12z-knowledge-box/components/ai12z-chat-message.js +2 -2
  52. package/dist/collection/components/ai12z-search-panel/ai12z-search-panel.js +3 -3
  53. package/dist/collection/components/ai12z-search-panel/search-results-view.js +12 -10
  54. package/dist/collection/components/input/ImageUploader.js +1 -1
  55. package/dist/collection/components/input/Input.js +9 -9
  56. package/dist/collection/components/spinner/Spinner.js +1 -1
  57. package/dist/collection/index.js +1 -0
  58. package/dist/collection/utils/beacon.js +319 -0
  59. package/dist/collection/utils/bodyScrollLock.js +65 -0
  60. package/dist/collection/utils/ctaHelpers.js +16 -0
  61. package/dist/collection/utils/liveagents/chateventbus.js +16 -0
  62. package/dist/collection/utils/liveagents/providers/salesforce.js +8 -2
  63. package/dist/collection/utils/utils.js +17 -2
  64. package/dist/components/ai12z-beacon.d.ts +11 -0
  65. package/dist/components/ai12z-beacon.js +1 -0
  66. package/dist/components/ai12z-bot.js +1 -1
  67. package/dist/components/ai12z-category.js +1 -1
  68. package/dist/components/ai12z-chat-message.js +1 -1
  69. package/dist/components/ai12z-chat.js +1 -1
  70. package/dist/components/ai12z-container.js +1 -1
  71. package/dist/components/ai12z-cta.js +1 -1
  72. package/dist/components/ai12z-form.js +1 -1
  73. package/dist/components/ai12z-inline-search.js +1 -1
  74. package/dist/components/ai12z-input-form.js +1 -1
  75. package/dist/components/ai12z-knowledge-box.js +1 -1
  76. package/dist/components/ai12z-search-panel.js +1 -1
  77. package/dist/components/ai12z-spinner.js +1 -1
  78. package/dist/components/audio-recorder.js +1 -1
  79. package/dist/components/chat-avatar.js +1 -1
  80. package/dist/components/chatbot-history.js +1 -1
  81. package/dist/components/delete-confirmation-modal.js +1 -1
  82. package/dist/components/dynamic-form.js +1 -1
  83. package/dist/components/hamburger-menu.js +1 -1
  84. package/dist/components/image-uploader.js +1 -1
  85. package/dist/components/index.js +1 -1
  86. package/dist/components/interaction-buttons.js +1 -1
  87. package/dist/components/item-list.js +1 -1
  88. package/dist/components/keyboard-shortcuts-dialog.js +1 -1
  89. package/dist/components/live-agent-chat.js +1 -1
  90. package/dist/components/{p-DQKllbP7.js → p-2TKoA-vX.js} +1 -1
  91. package/dist/components/{p-BBkc2Zz3.js → p-6PZtsZH1.js} +1 -1
  92. package/dist/components/{p-BugQD-4q.js → p-7D8UwFfY.js} +1 -1
  93. package/dist/components/{p-Cv-HbFj1.js → p-BblvvyaD.js} +1 -1
  94. package/dist/components/p-C-IKmqII.js +1 -0
  95. package/dist/components/p-C5vYK3Om.js +1 -0
  96. package/dist/components/{p-C3hnDJ1x.js → p-C7Fh_H3H.js} +1 -1
  97. package/dist/components/p-CVJPxD1X.js +2 -0
  98. package/dist/components/p-CX6EbMog.js +1 -0
  99. package/dist/components/{p-COOdy5C-.js → p-ClSkLu41.js} +1 -1
  100. package/dist/components/p-Cmj8wElU.js +1 -0
  101. package/dist/components/{p-C0caR14R.js → p-CrAK1XF4.js} +1 -1
  102. package/dist/components/p-CvPbldU0.js +1 -0
  103. package/dist/components/{p-tEjcbjhZ.js → p-CztWNvRK.js} +1 -1
  104. package/dist/components/p-DBojmc3T.js +1 -0
  105. package/dist/components/{p-DvJUX5RM.js → p-DRL0IYV2.js} +1 -1
  106. package/dist/components/p-DVnjJHuQ.js +1 -0
  107. package/dist/components/{p-BHZ4-nkE.js → p-DZ5YGUeY.js} +1 -1
  108. package/dist/components/{p-CcfettiK.js → p-D_3pXSAZ.js} +1 -1
  109. package/dist/components/{p-DiUq1_cL.js → p-D_u0brDS.js} +1 -1
  110. package/dist/components/p-Db3MSI1b.js +1 -0
  111. package/dist/components/{p-C2pbHN4a.js → p-DjYUZbG5.js} +1 -1
  112. package/dist/components/{p-BGqU6S_C.js → p-DmCL0aBr.js} +1 -1
  113. package/dist/components/p-DvxYmlU_.js +1 -0
  114. package/dist/components/p-Dy72Ri-1.js +1 -0
  115. package/dist/components/p-OAsYsTgR.js +1 -0
  116. package/dist/components/p-SMXYqOvq.js +31 -0
  117. package/dist/components/{p-DEkZRvM1.js → p-SoJiujnW.js} +1 -1
  118. package/dist/components/{p-k5IjpIIA.js → p-c6Z5KXDQ.js} +1 -1
  119. package/dist/components/{p-C3JmvA9z.js → p-fFDvCr1L.js} +1 -1
  120. package/dist/components/p-kJpnWRAF.js +1 -0
  121. package/dist/components/p-nxQB8VYC.js +1 -0
  122. package/dist/components/{p-NQcpUWMC.js → p-q7LAuIXC.js} +1 -1
  123. package/dist/components/{p-De--d4FT.js → p-rVmRQ8bG.js} +1 -1
  124. package/dist/components/{p-hbJqzZAj.js → p-yMwHPq7E.js} +1 -1
  125. package/dist/components/{p-BOiNZwPJ.js → p-zx_1qRzz.js} +1 -1
  126. package/dist/components/privacy-modal.js +1 -1
  127. package/dist/components/search-results-page.js +1 -1
  128. package/dist/components/typing-indicator.js +1 -1
  129. package/dist/esm/{SearchResult-C3g6BSvv.js → SearchResult-BVGx7wDE.js} +1 -1
  130. package/dist/esm/ai12z-beacon.entry.js +33 -0
  131. package/dist/esm/ai12z-bot.entry.js +129 -61
  132. package/dist/esm/ai12z-category_2.entry.js +11 -11
  133. package/dist/esm/ai12z-chat-message.entry.js +5 -5
  134. package/dist/esm/ai12z-chat_2.entry.js +25 -21
  135. package/dist/esm/ai12z-container.entry.js +5 -5
  136. package/dist/esm/ai12z-cta.entry.js +14 -8
  137. package/dist/esm/ai12z-form.entry.js +5 -5
  138. package/dist/esm/ai12z-inline-search.entry.js +7 -7
  139. package/dist/esm/ai12z-knowledge-box.entry.js +28 -23
  140. package/dist/esm/ai12z-search-panel.entry.js +6 -6
  141. package/dist/esm/ai12z-spinner.entry.js +2 -2
  142. package/dist/esm/{app-store-BSQPOUME.js → app-store-DvKLN4Xd.js} +1 -1
  143. package/dist/esm/beacon-CTeIOnFW.js +318 -0
  144. package/dist/esm/bodyScrollLock-DvxYmlU_.js +67 -0
  145. package/dist/esm/chat-avatar_6.entry.js +14 -14
  146. package/dist/esm/chatbot-history_2.entry.js +2 -2
  147. package/dist/esm/{ctaHelpers-BOdS23pG.js → ctaHelpers-BxYDDl6j.js} +1 -1
  148. package/dist/esm/dynamic-form.entry.js +3 -3
  149. package/dist/esm/image-uploader_2.entry.js +2 -2
  150. package/dist/esm/{index-CZVgVfgd.js → index-BSAVvAU7.js} +1 -1
  151. package/dist/esm/{index-B9OPtxv2.js → index-DrTyKvbY.js} +1 -1
  152. package/dist/esm/index.js +18 -15
  153. package/dist/esm/item-list.entry.js +3 -3
  154. package/dist/esm/{keyboard-shortcuts-9ySnK42C.js → keyboard-shortcuts-Iro3156u.js} +2 -2
  155. package/dist/esm/library.js +3 -3
  156. package/dist/esm/loader.js +3 -3
  157. package/dist/esm/{logger-C0PEnW3T.js → logger-DuhlzN1_.js} +1 -1
  158. package/dist/esm/{parseHelper-TNZZ7pZJ.js → parseHelper-D_HyZ-hh.js} +2 -2
  159. package/dist/esm/{processCarouselData-BbqNSwni.js → processCarouselData-MkXYTDY2.js} +1 -1
  160. package/dist/esm/{reCaptchaHelpers-BRdKn-CM.js → reCaptchaHelpers-M2SfYLz1.js} +1 -1
  161. package/dist/esm/{scriptStyleLoader-_-YNtQPs.js → scriptStyleLoader-C_wSk9Fd.js} +1 -1
  162. package/dist/esm/search-results-page.entry.js +18 -16
  163. package/dist/esm/{socket-service-BaSfS-C4.js → socket-service-DBZCOxQR.js} +2 -2
  164. package/dist/esm/{styleSheetRegistry-BccKic5X.js → styleSheetRegistry-CxLH9Q0z.js} +1 -1
  165. package/dist/esm/{surveyHelpers-BeCs_jb6.js → surveyHelpers-B_IO8diu.js} +1 -1
  166. package/dist/esm/{utils-C75qrx0v.js → utils-CgIk6Jbn.js} +19 -4
  167. package/dist/library/index.esm.js +1 -1
  168. package/dist/library/library.esm.js +1 -1
  169. package/dist/library/{p-cd6d00c7.entry.js → p-07ac3aeb.entry.js} +1 -1
  170. package/dist/library/{p-ac9bbba9.entry.js → p-25f8585a.entry.js} +1 -1
  171. package/dist/library/p-324fbc31.entry.js +1 -0
  172. package/dist/library/{p-d39e26f2.entry.js → p-338a8f28.entry.js} +1 -1
  173. package/dist/library/{p-4f5c680e.entry.js → p-4594fac4.entry.js} +1 -1
  174. package/dist/library/{p-03e6c526.entry.js → p-5903cc93.entry.js} +1 -1
  175. package/dist/library/{p-21e30d74.entry.js → p-64e9659d.entry.js} +1 -1
  176. package/dist/library/{p-d20ffcd1.entry.js → p-758ccdb5.entry.js} +1 -1
  177. package/dist/library/p-759e5580.entry.js +1 -0
  178. package/dist/library/p-952d0734.entry.js +1 -0
  179. package/dist/library/{p-4b1b23ad.entry.js → p-9f812fb1.entry.js} +1 -1
  180. package/dist/library/p-AtKfoKg4.js +1 -0
  181. package/dist/library/{p-C33Bq1u3.js → p-BBQFikkr.js} +1 -1
  182. package/dist/library/{p-CVoJ6Qcc.js → p-BMrTd5IO.js} +1 -1
  183. package/dist/library/p-BXxt773d.js +1 -0
  184. package/dist/library/{p-CsG0EN7R.js → p-BnkN4SP7.js} +1 -1
  185. package/dist/library/{p-BdtAdObU.js → p-BpnISGA6.js} +1 -1
  186. package/dist/library/{p-SsXpfHmP.js → p-BxgpzgHw.js} +1 -1
  187. package/dist/library/{p-D5B5YlEl.js → p-C9xkKjGV.js} +1 -1
  188. package/dist/library/{p-C7riVXol.js → p-CCEJFtl1.js} +3 -3
  189. package/dist/library/{p-CqE4eXes.js → p-CGdgvo_b.js} +1 -1
  190. package/dist/library/{p-CZ_3jJSY.js → p-D85u0uEM.js} +1 -1
  191. package/dist/library/{p-CfHNdl7N.js → p-DCiuGcUL.js} +1 -1
  192. package/dist/library/{p-B9OPtxv2.js → p-DrTyKvbY.js} +1 -1
  193. package/dist/library/p-DvxYmlU_.js +1 -0
  194. package/dist/library/{p-B18nLcR3.js → p-Dwtvt1Ju.js} +1 -1
  195. package/dist/library/{p-DginFHFR.js → p-Jb6LBYBH.js} +1 -1
  196. package/dist/library/{p-_4Q98Hn5.js → p-_n0zqQUg.js} +1 -1
  197. package/dist/library/{p-b744339c.entry.js → p-aa6b173e.entry.js} +1 -1
  198. package/dist/library/{p-0a6d1461.entry.js → p-ae810ce7.entry.js} +1 -1
  199. package/dist/library/p-b3d39c03.entry.js +1 -0
  200. package/dist/library/{p-6c81c334.entry.js → p-c60d1052.entry.js} +2 -2
  201. package/dist/library/p-da1f61b5.entry.js +1 -0
  202. package/dist/library/{p-09ccce13.entry.js → p-e18997fc.entry.js} +1 -1
  203. package/dist/library/p-f922f9f3.entry.js +1 -0
  204. package/dist/types/components/ai12z-beacon/ai12z-beacon.d.ts +8 -0
  205. package/dist/types/components/ai12z-bot/ai12z-bot.d.ts +1 -0
  206. package/dist/types/components/ai12z-knowledge-box/ai12z-knowledge-box.d.ts +1 -1
  207. package/dist/types/components.d.ts +29 -0
  208. package/dist/types/index.d.ts +1 -0
  209. package/dist/types/utils/beacon.d.ts +64 -0
  210. package/dist/types/utils/bodyScrollLock.d.ts +12 -0
  211. package/dist/types/utils/ctaHelpers.d.ts +1 -0
  212. package/dist/types/utils/liveagents/chateventbus.d.ts +16 -0
  213. package/dist/types/utils/utils.d.ts +13 -0
  214. package/package.json +4 -3
  215. package/dist/components/p-9ZSKFUQq.js +0 -1
  216. package/dist/components/p-B8jSr9lW.js +0 -1
  217. package/dist/components/p-C5rVF0zE.js +0 -2
  218. package/dist/components/p-CGQBDC3e.js +0 -31
  219. package/dist/components/p-CfmVopBG.js +0 -1
  220. package/dist/components/p-D-mcIUO8.js +0 -1
  221. package/dist/components/p-DlmdK220.js +0 -1
  222. package/dist/components/p-DndtP5Bd.js +0 -1
  223. package/dist/components/p-GhhnA1Fw.js +0 -1
  224. package/dist/components/p-Q3uBgncp.js +0 -1
  225. package/dist/components/p-ZQeNPv0R.js +0 -1
  226. package/dist/components/p-jD70af30.js +0 -1
  227. package/dist/library/p-1174b3f9.entry.js +0 -1
  228. package/dist/library/p-48be863a.entry.js +0 -1
  229. package/dist/library/p-74379d4c.entry.js +0 -1
  230. package/dist/library/p-8f41d206.entry.js +0 -1
  231. package/dist/library/p-97c4b33d.entry.js +0 -1
  232. package/dist/library/p-C7dGy5Bg.js +0 -1
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-v8T1EJAJ.js');
4
+ var beacon = require('./beacon-B9ZWQpG6.js');
5
+ require('./utils-C2m26j54.js');
6
+
7
+ const Ai12zBeacon = class {
8
+ constructor(hostRef) {
9
+ index.registerInstance(this, hostRef);
10
+ this.dataKey = index.Env.DATA_KEY || "";
11
+ this.dataMode = index.Env.DATA_MODE || "prod";
12
+ }
13
+ componentWillLoad() {
14
+ this.initializeBeacon();
15
+ }
16
+ onDataKeyChange() {
17
+ this.initializeBeacon();
18
+ }
19
+ initializeBeacon() {
20
+ if (!this.dataKey) {
21
+ return;
22
+ }
23
+ beacon.initBeacon(this.dataKey);
24
+ }
25
+ render() {
26
+ return index.h(index.Host, { key: '0c87acbc61ff504f2cc6406be2e255e92f9e3220', hidden: true });
27
+ }
28
+ static get watchers() { return {
29
+ "dataKey": [{
30
+ "onDataKeyChange": 0
31
+ }]
32
+ }; }
33
+ };
34
+
35
+ exports.ai12z_beacon = Ai12zBeacon;
@@ -2,19 +2,21 @@
2
2
 
3
3
  var index = require('./index-v8T1EJAJ.js');
4
4
  var responseAdapter = require('./response-adapter-CKKyyhMj.js');
5
- var processCarouselData = require('./processCarouselData-kCVPE4mw.js');
6
- var logger$1 = require('./logger-2ZBZCKdM.js');
7
- var utils = require('./utils-7C5_GnyF.js');
8
- var index$1 = require('./index-CKLC7f4y.js');
5
+ var processCarouselData = require('./processCarouselData-Dl_WYwVE.js');
6
+ var logger$2 = require('./logger-2ZBZCKdM.js');
7
+ var utils = require('./utils-C2m26j54.js');
8
+ var index$1 = require('./index-DbNk7qkZ.js');
9
9
  var globalStore = require('./global-store-R6x06KvJ.js');
10
- var reCaptchaHelpers = require('./reCaptchaHelpers-sfktrnTF.js');
10
+ var reCaptchaHelpers = require('./reCaptchaHelpers-mbTvATH6.js');
11
11
  var botHelpers = require('./botHelpers-D5Dj7TRA.js');
12
- var surveyHelpers = require('./surveyHelpers-DohugkWP.js');
12
+ var surveyHelpers = require('./surveyHelpers-DFh4q1hj.js');
13
13
  var scriptStyleLoader = require('./scriptStyleLoader-D-bqKqSb.js');
14
- var keyboardShortcuts = require('./keyboard-shortcuts-BWprLtLj.js');
15
- var ctaHelpers = require('./ctaHelpers-DUPj5SnE.js');
14
+ var keyboardShortcuts = require('./keyboard-shortcuts-BpiAXzLW.js');
15
+ var ctaHelpers = require('./ctaHelpers-CmoXzyRy.js');
16
16
  var appStore = require('./app-store-BtkiHvcw.js');
17
- var parseHelper = require('./parseHelper-5fRVefLm.js');
17
+ var parseHelper = require('./parseHelper-CbA81TvP.js');
18
+ var beacon = require('./beacon-B9ZWQpG6.js');
19
+ var bodyScrollLock = require('./bodyScrollLock-C7gKTAfx.js');
18
20
  require('./_commonjsHelpers-MBWFX2dn.js');
19
21
 
20
22
  // ILiveAgentProvider.ts
@@ -33,6 +35,22 @@ class LiveAgentAuthExpiredError extends Error {
33
35
  }
34
36
  }
35
37
 
38
+ /**
39
+ * Reduce a raw AGENT_ERROR reason to a fixed telemetry bucket. The raw text is
40
+ * untrusted upstream output and must not be re-logged or rendered by consumers
41
+ * — log the bucket instead. The emit site in salesforce.ts already records the
42
+ * full reason once (work items #4020, #4021).
43
+ */
44
+ function categorizeAgentErrorReason(reason) {
45
+ if (!reason)
46
+ return "unknown";
47
+ if (reason === "transport")
48
+ return "transport";
49
+ const status = /\b([1-5]\d{2})\b/.exec(reason);
50
+ if (status)
51
+ return `upstream_${status[1][0]}xx`;
52
+ return "upstream_other";
53
+ }
36
54
  class EventBus {
37
55
  constructor() {
38
56
  this.events = new Map();
@@ -54,8 +72,8 @@ class EventBus {
54
72
  }
55
73
  const ChatEventBus = new EventBus();
56
74
 
57
- const logger = new logger$1.Logger("SalesforceLiveAgentProvider", {
58
- logLevel: logger$1.LogLevel.Info, // Set to Debug for detailed logs",
75
+ const logger$1 = new logger$2.Logger("SalesforceLiveAgentProvider", {
76
+ logLevel: logger$2.LogLevel.Info, // Set to Debug for detailed logs",
59
77
  remoteLoggingUrl: "",
60
78
  });
61
79
  /**
@@ -86,12 +104,12 @@ class SalesforceLiveAgentProvider {
86
104
  },
87
105
  });
88
106
  if (!availabilityRes.ok) {
89
- logger.warn(`Agent availability check failed: ${availabilityRes.status} ${availabilityRes.statusText}`);
107
+ logger$1.warn(`Agent availability check failed: ${availabilityRes.status} ${availabilityRes.statusText}`);
90
108
  ChatEventBus.emit("AGENT_UNAVAILABLE", { reason: "request_error" });
91
109
  return false;
92
110
  }
93
111
  const availabilityData = await availabilityRes.json();
94
- logger.debug("Agent availability check result:", availabilityData);
112
+ logger$1.debug("Agent availability check result:", availabilityData);
95
113
  const entries = (_c = availabilityData === null || availabilityData === void 0 ? void 0 : availabilityData.conversationEntries) !== null && _c !== void 0 ? _c : [];
96
114
  const routingEntry = entries.find((e) => e.entryType === "RoutingResult");
97
115
  if (routingEntry) {
@@ -102,20 +120,20 @@ class SalesforceLiveAgentProvider {
102
120
  entryPayload = JSON.parse(entryPayload);
103
121
  }
104
122
  catch (_d) {
105
- logger.warn("Failed to parse RoutingResult entryPayload");
123
+ logger$1.warn("Failed to parse RoutingResult entryPayload");
106
124
  }
107
125
  }
108
126
  const failureReason = entryPayload === null || entryPayload === void 0 ? void 0 : entryPayload.failureReason;
109
127
  if (failureReason) {
110
- logger.warn("Routing failed with reason:", failureReason);
128
+ logger$1.warn("Routing failed with reason:", failureReason);
111
129
  ChatEventBus.emit("AGENT_UNAVAILABLE", { reason: failureReason });
112
130
  return false;
113
131
  }
114
- logger.debug("Agent routed successfully");
132
+ logger$1.debug("Agent routed successfully");
115
133
  return true;
116
134
  }
117
135
  // conversationEntries is empty — routing hasn't completed yet, retry
118
- logger.debug(`No RoutingResult yet (entries: ${entries.length}), retrying in ${POLL_INTERVAL_MS}ms…`);
136
+ logger$1.debug(`No RoutingResult yet (entries: ${entries.length}), retrying in ${POLL_INTERVAL_MS}ms…`);
119
137
  // await new Promise(resolve => setTimeout(resolve, POLL_INTERVAL_MS))
120
138
  await new Promise((resolve, reject) => {
121
139
  const t = setTimeout(resolve, POLL_INTERVAL_MS);
@@ -123,7 +141,7 @@ class SalesforceLiveAgentProvider {
123
141
  }).catch(() => null);
124
142
  }
125
143
  // Timed out — no routing result arrived within the window
126
- logger.warn("Timed out waiting for MIAW routing result");
144
+ logger$1.warn("Timed out waiting for MIAW routing result");
127
145
  ChatEventBus.emit("AGENT_UNAVAILABLE", { reason: "timeout" });
128
146
  return false;
129
147
  };
@@ -239,13 +257,13 @@ class SalesforceLiveAgentProvider {
239
257
  this.sendMessage({ isNewSession: true, sessionId: ((_m = this.sessionContext) === null || _m === void 0 ? void 0 : _m.sessionId) || "", message: formatInitialMessages });
240
258
  }
241
259
  if (await this.checkAgentAvailability(this.sessionContext.conversationId || "")) {
242
- logger.debug("Agent is available, starting to listen to messages");
260
+ logger$1.debug("Agent is available, starting to listen to messages");
243
261
  this.listenToMessages();
244
262
  }
245
263
  else {
246
264
  // AGENT_UNAVAILABLE (with reason: failureReason | "timeout" | "request_error")
247
265
  // was already emitted by checkAgentAvailability
248
- logger.warn("No agent assigned — skipping SSE listener setup");
266
+ logger$1.warn("No agent assigned — skipping SSE listener setup");
249
267
  }
250
268
  }
251
269
  }
@@ -255,7 +273,7 @@ class SalesforceLiveAgentProvider {
255
273
  */
256
274
  async initialize(startChatOptions) {
257
275
  var _a, _b, _c;
258
- logger.debug("Initializing Salesforce Live Agent Provider");
276
+ logger$1.debug("Initializing Salesforce Live Agent Provider");
259
277
  if (!this.configSettings) {
260
278
  this.configSettings = (startChatOptions === null || startChatOptions === void 0 ? void 0 : startChatOptions.config) || this.configSettings;
261
279
  }
@@ -279,7 +297,7 @@ class SalesforceLiveAgentProvider {
279
297
  await this.startSession();
280
298
  }
281
299
  catch (error) {
282
- logger.error("Error initializing Salesforce Live Agent Provider:", error);
300
+ logger$1.error("Error initializing Salesforce Live Agent Provider:", error);
283
301
  throw error;
284
302
  }
285
303
  }
@@ -304,7 +322,7 @@ class SalesforceLiveAgentProvider {
304
322
  }
305
323
  handleParticipantChange(event) {
306
324
  try {
307
- logger.debug("Participant change event received:", event.data);
325
+ logger$1.debug("Participant change event received:", event.data);
308
326
  if (!event.data)
309
327
  return;
310
328
  // Parse the event data
@@ -350,7 +368,7 @@ class SalesforceLiveAgentProvider {
350
368
  }
351
369
  }
352
370
  catch (error) {
353
- logger.error("Error handling participant change event:", error);
371
+ logger$1.error("Error handling participant change event:", error);
354
372
  // Handle error appropriately, e.g., log it or notify the user
355
373
  }
356
374
  }
@@ -381,7 +399,7 @@ class SalesforceLiveAgentProvider {
381
399
  * This is to prevent processing messages that are not relevant to the agent's response
382
400
  */
383
401
  if (((_b = (_a = data === null || data === void 0 ? void 0 : data.conversationEntry) === null || _a === void 0 ? void 0 : _a.sender) === null || _b === void 0 ? void 0 : _b.role) === "EndUser") {
384
- logger.debug("Ignoring message from EndUser role");
402
+ logger$1.debug("Ignoring message from EndUser role");
385
403
  return;
386
404
  }
387
405
  const entryPayload = JSON.parse(data.conversationEntry.entryPayload);
@@ -393,7 +411,7 @@ class SalesforceLiveAgentProvider {
393
411
  }
394
412
  }
395
413
  catch (error) {
396
- logger.error("Error handling participant message event:", error);
414
+ logger$1.error("Error handling participant message event:", error);
397
415
  // Handle error appropriately, e.g., log it or notify the user
398
416
  }
399
417
  }
@@ -413,7 +431,7 @@ class SalesforceLiveAgentProvider {
413
431
  // Parse the event data
414
432
  const data = JSON.parse(event.data);
415
433
  const entryPayload = JSON.parse(data.conversationEntry.entryPayload);
416
- logger.debug("Session status changed:", entryPayload === null || entryPayload === void 0 ? void 0 : entryPayload.sessionStatus);
434
+ logger$1.debug("Session status changed:", entryPayload === null || entryPayload === void 0 ? void 0 : entryPayload.sessionStatus);
417
435
  if ((entryPayload === null || entryPayload === void 0 ? void 0 : entryPayload.sessionStatus) === "Active") {
418
436
  ChatEventBus.emit("AGENT_SESSION_CREATED", true);
419
437
  }
@@ -431,13 +449,13 @@ class SalesforceLiveAgentProvider {
431
449
  }
432
450
  }
433
451
  catch (error) {
434
- logger.error("Error handling session status change event:", error);
452
+ logger$1.error("Error handling session status change event:", error);
435
453
  // Handle error appropriately, e.g., log it or notify the user
436
454
  }
437
455
  }
438
456
  listenToMessages() {
439
457
  var _a, _b, _c, _d;
440
- logger.debug("Listening to messages from Salesforce Live Agent");
458
+ logger$1.debug("Listening to messages from Salesforce Live Agent");
441
459
  // this.endpointSSE = "http://localhost:5050"
442
460
  // Close any existing connection before opening a new one (e.g. on resume)
443
461
  // so we don't leak a dangling SSE stream.
@@ -446,7 +464,7 @@ class SalesforceLiveAgentProvider {
446
464
  withCredentials: true,
447
465
  });
448
466
  if (!eventSource) {
449
- logger.error("Failed to create EventSource");
467
+ logger$1.error("Failed to create EventSource");
450
468
  throw new Error("Failed to create EventSource");
451
469
  }
452
470
  this.eventSource = eventSource;
@@ -460,32 +478,34 @@ class SalesforceLiveAgentProvider {
460
478
  // `upstream_error` event — see below — which is the preferred, unambiguous
461
479
  // channel; this stays as a defensive fallback.)
462
480
  const data = event === null || event === void 0 ? void 0 : event.data;
463
- logger.error(typeof data === "string" && data ? `❌ SSE server error frame: ${data}` : "❌ SSE Error: Connection lost or error occurred");
464
- ChatEventBus.emit("AGENT_ERROR", true);
481
+ logger$1.error(typeof data === "string" && data ? `❌ SSE server error frame: ${data}` : "❌ SSE Error: Connection lost or error occurred");
482
+ ChatEventBus.emit("AGENT_ERROR", {
483
+ reason: typeof data === "string" && data ? data : "transport",
484
+ });
465
485
  // Optionally, you can close the EventSource if needed
466
486
  eventSource.close();
467
487
  };
468
488
  eventSource.onopen = () => {
469
- logger.debug("✅ SSE Connection Established");
489
+ logger$1.debug("✅ SSE Connection Established");
470
490
  // ChatEventBus.emit("liveAgentReady", undefined)
471
491
  };
472
492
  const handleSSEMessage = (event) => {
473
493
  var _a, _b;
474
494
  try {
475
495
  const parsedEventData = JSON.parse(event.data);
476
- logger.debug("📡 Message Received on entrytype:", (_a = parsedEventData === null || parsedEventData === void 0 ? void 0 : parsedEventData.conversationEntry) === null || _a === void 0 ? void 0 : _a.entryType, " --- ", event.data);
496
+ logger$1.debug("📡 Message Received on entrytype:", (_a = parsedEventData === null || parsedEventData === void 0 ? void 0 : parsedEventData.conversationEntry) === null || _a === void 0 ? void 0 : _a.entryType, " --- ", event.data);
477
497
  // Handle incoming messages if needed
478
498
  switch ((_b = parsedEventData === null || parsedEventData === void 0 ? void 0 : parsedEventData.conversationEntry) === null || _b === void 0 ? void 0 : _b.entryType) {
479
499
  case "RoutingResult":
480
500
  case "RoutingWorkResult":
481
- logger.debug("Conversation Routing Result:", event.data);
501
+ logger$1.debug("Conversation Routing Result:", event.data);
482
502
  // Handle conversation routing result if needed
483
503
  // ChatEventBus.emit("AGENT_SESSION_CREATED", true)
484
504
  ChatEventBus.emit("FINDING_AGENT", event.data);
485
505
  // ChatEventBus.emit("AGENT_EVENT", [])
486
506
  break;
487
507
  case "ParticipantChanged":
488
- logger.debug("Conversation ParticipantChanged event received:", event === null || event === void 0 ? void 0 : event.data);
508
+ logger$1.debug("Conversation ParticipantChanged event received:", event === null || event === void 0 ? void 0 : event.data);
489
509
  // Check if the participant joining is an AGENT, not the user
490
510
  // ChatEventBus.emit("AGENT_SESSION_CREATED", true)
491
511
  this.handleParticipantChange(event);
@@ -499,7 +519,7 @@ class SalesforceLiveAgentProvider {
499
519
  break;
500
520
  case "DeliveryAcknowledgement":
501
521
  case "ReadAcknowledgement":
502
- logger.debug("Conversation event received:", event === null || event === void 0 ? void 0 : event.data);
522
+ logger$1.debug("Conversation event received:", event === null || event === void 0 ? void 0 : event.data);
503
523
  // Handle conversation close if needed
504
524
  // ChatEventBus.emit("AGENT_EVENT", event.data)
505
525
  break;
@@ -507,29 +527,29 @@ class SalesforceLiveAgentProvider {
507
527
  ChatEventBus.emit("TYPING_STARTED", true);
508
528
  break;
509
529
  case "TypingStoppedIndicator":
510
- logger.debug("Typing indicator received:", event.data);
530
+ logger$1.debug("Typing indicator received:", event.data);
511
531
  // Handle typing indicator if needed
512
532
  ChatEventBus.emit("TYPING_STOPPED", true);
513
533
  break;
514
534
  case "StreamingToken":
515
- logger.debug("Streaming token received", event.data);
535
+ logger$1.debug("Streaming token received", event.data);
516
536
  // Handle streaming token if needed
517
537
  // ChatEventBus.emit("streamingTokenReceived", event.data)
518
538
  break;
519
539
  case "ProgressIndicator":
520
- logger.debug("Progress indicator received", event.data);
540
+ logger$1.debug("Progress indicator received", event.data);
521
541
  // Handle progress indicator if needed
522
542
  // ChatEventBus.emit("progressIndicatorReceived", event.data)
523
543
  break;
524
544
  case "SessionStatusChanged":
525
- logger.debug("Session status changed event received", event.data);
545
+ logger$1.debug("Session status changed event received", event.data);
526
546
  // Handle session status change if needed
527
547
  this.handleSessionStatusChange(event);
528
548
  break;
529
549
  }
530
550
  }
531
551
  catch (e) {
532
- logger.error("Failed to parse event data:", e);
552
+ logger$1.error("Failed to parse event data:", e);
533
553
  return;
534
554
  }
535
555
  };
@@ -568,8 +588,12 @@ class SalesforceLiveAgentProvider {
568
588
  // so the specific status is logged and the user is notified. NOTE: the data is
569
589
  // plain text ("upstream returned 503"), so do NOT JSON.parse it.
570
590
  eventSource.addEventListener("upstream_error", (event) => {
571
- logger.error("❌ Live agent SSE upstream error:", event.data);
572
- ChatEventBus.emit("AGENT_ERROR", true);
591
+ logger$1.error("❌ Live agent SSE upstream error:", event.data);
592
+ ChatEventBus.emit("AGENT_ERROR", {
593
+ reason: typeof event.data === "string" && event.data
594
+ ? event.data
595
+ : "upstream_error",
596
+ });
573
597
  eventSource.close();
574
598
  });
575
599
  }
@@ -716,7 +740,7 @@ class SalesforceLiveAgentProvider {
716
740
  setTimeout(poll, 5000);
717
741
  }
718
742
  catch (err) {
719
- logger.error("Error on Polling", err.toString());
743
+ logger$1.error("Error on Polling", err.toString());
720
744
  reject(err);
721
745
  }
722
746
  };
@@ -731,7 +755,7 @@ class SalesforceLiveAgentProvider {
731
755
  * It checks the session context to determine if the session is active.
732
756
  */
733
757
  async isChatActive(sessionId) {
734
- logger.debug("sessionId", sessionId);
758
+ logger$1.debug("sessionId", sessionId);
735
759
  if (!this.sessionContext)
736
760
  return false;
737
761
  return this.sessionContext.isActive;
@@ -758,7 +782,7 @@ class SalesforceLiveAgentProvider {
758
782
  },
759
783
  });
760
784
  if (!(res === null || res === void 0 ? void 0 : res.ok)) {
761
- logger.warn(`Failed to end the chat`);
785
+ logger$1.warn(`Failed to end the chat`);
762
786
  }
763
787
  }
764
788
  }
@@ -770,7 +794,7 @@ class SalesforceLiveAgentProvider {
770
794
  * It returns an array of messages from the session context.
771
795
  */
772
796
  async getTranscript(sessionId) {
773
- logger.debug("sessionId", sessionId);
797
+ logger$1.debug("sessionId", sessionId);
774
798
  if (!this.sessionContext)
775
799
  return [];
776
800
  return this.sessionContext.initialMessages || [];
@@ -795,8 +819,8 @@ LiveAgentProvider.provider = "salesforce";
795
819
  /** Refactor the below to code to handle the liveagent events and integrate with the chat system ai12z-bot.tsx */
796
820
  class LiveAgentEventHandler {
797
821
  constructor() {
798
- this.logger = new logger$1.Logger("LiveAgentEventHandler", {
799
- logLevel: logger$1.LogLevel.Warn, // Set log level based on environment or configuration
822
+ this.logger = new logger$2.Logger("LiveAgentEventHandler", {
823
+ logLevel: logger$2.LogLevel.Warn, // Set log level based on environment or configuration
800
824
  });
801
825
  /**
802
826
  * Called when the `messageReceived` event is emitted.
@@ -1042,6 +1066,7 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
1042
1066
  }
1043
1067
  return t;
1044
1068
  };
1069
+ const logger = new logger$2.Logger("Ai12zBot");
1045
1070
  const Ai12zBot = class {
1046
1071
  constructor(hostRef) {
1047
1072
  index.registerInstance(this, hostRef);
@@ -1206,10 +1231,11 @@ const Ai12zBot = class {
1206
1231
  }
1207
1232
  };
1208
1233
  this.handleMessage = (data, aiMessageId) => {
1234
+ var _a;
1209
1235
  const converter = new processCarouselData.showdown.Converter();
1210
1236
  // const aiMessageBubble = document.getElementById(aiMessageId);
1211
1237
  // const aiMessageBubble = await waitForElement(`#${aiMessageId}`, this.el)
1212
- const aiMessageBubble = this.el.shadowRoot.querySelector(`#${aiMessageId}`);
1238
+ const aiMessageBubble = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#${aiMessageId}`);
1213
1239
  if (!aiMessageBubble) {
1214
1240
  console.error(`Message bubble with ID ${aiMessageId} not found.`);
1215
1241
  return;
@@ -1233,6 +1259,7 @@ const Ai12zBot = class {
1233
1259
  }
1234
1260
  };
1235
1261
  this.handleSend = async (eleValue, options = {}) => {
1262
+ var _a;
1236
1263
  const { isHide = false, isLiveChatEnded = false } = options;
1237
1264
  this.emptyMessageError = false;
1238
1265
  this.surveyDomId = "";
@@ -1294,6 +1321,7 @@ const Ai12zBot = class {
1294
1321
  ];
1295
1322
  if (this.messages.length === 2) {
1296
1323
  this.visitorID = utils.getOrCreateVisitorId();
1324
+ beacon.setConversationId(this.dataKey, this.conversationId);
1297
1325
  }
1298
1326
  this.checkHistory();
1299
1327
  setTimeout(() => {
@@ -1322,7 +1350,7 @@ const Ai12zBot = class {
1322
1350
  }
1323
1351
  }
1324
1352
  // this.invokeSocket()
1325
- const parent = this.el.shadowRoot.querySelector("#previewContainer");
1353
+ const parent = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("#previewContainer");
1326
1354
  if (parent) {
1327
1355
  parent.innerHTML = "";
1328
1356
  }
@@ -1379,6 +1407,7 @@ const Ai12zBot = class {
1379
1407
  this.scheduleAutoScroll();
1380
1408
  };
1381
1409
  this.addEventMessage = (_message) => {
1410
+ var _a;
1382
1411
  const agentEventMessages = this.liveAgentEventHandler.addAgentEventMessage([
1383
1412
  {
1384
1413
  text: _message,
@@ -1390,7 +1419,7 @@ const Ai12zBot = class {
1390
1419
  }
1391
1420
  }
1392
1421
  if (agentEventMessages && this.currentDomId) {
1393
- const currentDomElement = this.el.shadowRoot.querySelector(`#${this.currentDomId}`);
1422
+ const currentDomElement = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#${this.currentDomId}`);
1394
1423
  if (currentDomElement) {
1395
1424
  // Append the agent event messages to the current message bubble
1396
1425
  currentDomElement.parentNode.appendChild(agentEventMessages);
@@ -1416,7 +1445,12 @@ const Ai12zBot = class {
1416
1445
  this.handleTypingStopped = (_status) => {
1417
1446
  this.isTypingIndicatorVisible = false;
1418
1447
  };
1419
- this.handleAgentError = () => {
1448
+ this.handleAgentError = (payload) => {
1449
+ // Log only the bucketed category: the raw reason is untrusted upstream text
1450
+ // and is already recorded once at the emit site (salesforce.ts), so keeping
1451
+ // it out of this path avoids shipping it to console-capturing RUM tools and
1452
+ // avoids double-logging. Warn level is suppressed in production bundles.
1453
+ logger.warn("Live Agent error category:", categorizeAgentErrorReason(payload === null || payload === void 0 ? void 0 : payload.reason));
1420
1454
  this.addEventMessage("Something went wrong with Live Agent, please try again later");
1421
1455
  this.isLiveAgent = false;
1422
1456
  this.liveAgentSessionId = "";
@@ -1554,6 +1588,7 @@ const Ai12zBot = class {
1554
1588
  this.loadConversation();
1555
1589
  break;
1556
1590
  case "end":
1591
+ this.syncBodyScrollLock(false);
1557
1592
  this.messages = [...[]];
1558
1593
  this.conversationId = "";
1559
1594
  this.isOpened = false;
@@ -1660,6 +1695,7 @@ const Ai12zBot = class {
1660
1695
  return (activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === "TEXTAREA" || (activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === "INPUT";
1661
1696
  }
1662
1697
  handleNewConversation() {
1698
+ this.syncBodyScrollLock(true);
1663
1699
  // Clear messages and start a new conversation
1664
1700
  this.messages = [];
1665
1701
  this.conversationId = "";
@@ -1739,11 +1775,13 @@ const Ai12zBot = class {
1739
1775
  this.openChat((_a = options === null || options === void 0 ? void 0 : options.expanded) !== null && _a !== void 0 ? _a : false);
1740
1776
  }
1741
1777
  if (type === "minimize" && this.isOpened) {
1778
+ this.syncBodyScrollLock(false);
1742
1779
  this.minimizeChat();
1743
1780
  }
1744
1781
  this.checkHistory();
1745
1782
  if (type === "close") {
1746
1783
  // this.isChatOpen = false
1784
+ this.syncBodyScrollLock(false);
1747
1785
  this.searchResults = {};
1748
1786
  this.surveyDomId = "";
1749
1787
  this.showWelcomeScreen = true;
@@ -1751,6 +1789,7 @@ const Ai12zBot = class {
1751
1789
  // this.saveConversation()
1752
1790
  this.messages = [...[]];
1753
1791
  this.conversationId = "";
1792
+ this.isOpened = false;
1754
1793
  this.close.emit("close");
1755
1794
  this.announce("Chat closed");
1756
1795
  clearInterval(this.timer);
@@ -1769,6 +1808,7 @@ const Ai12zBot = class {
1769
1808
  this.timestamp = utils.formatTimestamp(new Date());
1770
1809
  this.updateScreenSize();
1771
1810
  await this.configBot();
1811
+ beacon.initBeacon(this.dataKey);
1772
1812
  this.visitorID = "ai12z-" + localStorage.getItem(`ai12z-visitorId`);
1773
1813
  // Now safely read state with valid pId
1774
1814
  this.hydrateStateFromStorage();
@@ -1791,6 +1831,9 @@ const Ai12zBot = class {
1791
1831
  if (botState) {
1792
1832
  this.isOpened = botState.isOpened;
1793
1833
  this.isMinimized = botState.isMinimized;
1834
+ if (this.isOpened) {
1835
+ this.syncBodyScrollLock(true, false);
1836
+ }
1794
1837
  this.isExpanded = botState.isExpanded;
1795
1838
  this.conversationId = botState.conversationId;
1796
1839
  if (!botState.newChat) {
@@ -1847,6 +1890,7 @@ const Ai12zBot = class {
1847
1890
  }
1848
1891
  }
1849
1892
  componentDidLoad() {
1893
+ var _a;
1850
1894
  globalStore.setBotElement(this.el); // register globally
1851
1895
  if (typeof window !== "undefined" && !window.Handlebars) {
1852
1896
  window.Handlebars = index$1.Handlebars;
@@ -1861,7 +1905,7 @@ const Ai12zBot = class {
1861
1905
  var ai12zChat = window["ai12z"] = {}
1862
1906
  `;
1863
1907
  document.head.appendChild(ai12zHeading);
1864
- this.el.shadowRoot.appendChild(ai12zHeading);
1908
+ (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.appendChild(ai12zHeading);
1865
1909
  // ✅ Initialize asset loader if not already done (configBot may have initialized it)
1866
1910
  if (!this.assetLoader) {
1867
1911
  this.initializeAssetLoader();
@@ -1922,6 +1966,10 @@ const Ai12zBot = class {
1922
1966
  // Remove event listener when component is destroyed
1923
1967
  document.removeEventListener("click", this.handleClickOutside.bind(this));
1924
1968
  window.removeEventListener("resize", this.updateScreenSize);
1969
+ // A debounced auto-scroll may still be pending; cancel it so it cannot
1970
+ // fire scrollToBottom() against a torn-down component.
1971
+ if (this.autoScrollTimer)
1972
+ clearTimeout(this.autoScrollTimer);
1925
1973
  }
1926
1974
  handleClickOutside(event) {
1927
1975
  // Check if the clicked target is outside the menu
@@ -1972,8 +2020,17 @@ const Ai12zBot = class {
1972
2020
  this.announceMessage = "";
1973
2021
  }, 1000);
1974
2022
  }
2023
+ syncBodyScrollLock(shouldOpen, wasOpen = this.isOpened) {
2024
+ if (shouldOpen && !wasOpen) {
2025
+ bodyScrollLock.bodyScrollLock.acquire("ai12z-bot");
2026
+ }
2027
+ if (!shouldOpen && wasOpen) {
2028
+ bodyScrollLock.bodyScrollLock.release("ai12z-bot");
2029
+ }
2030
+ }
1975
2031
  openChat(expanded = false) {
1976
2032
  var _a, _b;
2033
+ this.syncBodyScrollLock(true);
1977
2034
  this.unreadCount = 0;
1978
2035
  // document.title = `Chat opened – ${this.originalTitle}`
1979
2036
  index.ai12zManager.setActive("bot");
@@ -2148,7 +2205,8 @@ const Ai12zBot = class {
2148
2205
  hideSpinner(chatData) {
2149
2206
  // Logic for hiding the spinner (assumed to return a Promise if async is needed)
2150
2207
  return new Promise(resolve => {
2151
- const renderedBubble = this.el.shadowRoot.querySelector(`#${chatData.id}`);
2208
+ var _a;
2209
+ const renderedBubble = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#${chatData.id}`);
2152
2210
  if (renderedBubble) {
2153
2211
  const spinner = renderedBubble.querySelector("#spinner");
2154
2212
  if (spinner) {
@@ -2405,7 +2463,8 @@ const Ai12zBot = class {
2405
2463
  }
2406
2464
  }
2407
2465
  addEventListeners(msgId) {
2408
- const container = this.el.shadowRoot.querySelector(msgId);
2466
+ var _a;
2467
+ const container = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(msgId);
2409
2468
  if (container) {
2410
2469
  this.buttons.forEach(button => {
2411
2470
  const buttonElement = container.querySelector(`#${button.id}`);
@@ -2633,7 +2692,8 @@ const Ai12zBot = class {
2633
2692
  // this.socket.off('response');
2634
2693
  }
2635
2694
  scrollToBottom() {
2636
- const container = this.el.shadowRoot.querySelector(".chat-body");
2695
+ var _a;
2696
+ const container = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(".chat-body");
2637
2697
  if (container) {
2638
2698
  container.scroll({
2639
2699
  top: container.scrollHeight,
@@ -3003,6 +3063,7 @@ const Ai12zBot = class {
3003
3063
  this.isAnimated = true;
3004
3064
  this.updateBotState();
3005
3065
  }, "aria-label": "Collapse Bot to Side Panel", "aria-expanded": this.isExpanded ? "true" : "false", "aria-controls": "settings-panel" }, index.h("i", { class: "wes-block wes-icon--loading wes-text-body2 modal-toolbar-icon", title: "Collapse Bot to Side Panel" }, this.isExpanded && (index.h("svg", { viewBox: "0 0 32 32", xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", "aria-hidden": "true" }, index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M18.215 14.7076H27.692C28.3074 14.7076 28.492 14.0307 27.9997 13.5383L24.9843 10.4614L30.5228 4.86149C30.8305 4.5538 30.8305 3.99995 30.5228 3.69226L28.2459 1.41536C27.9382 1.16921 27.4459 1.16921 27.0767 1.4769L21.5381 7.01532L18.3997 3.99995C17.9073 3.50765 17.2304 3.69226 17.2304 4.30764V13.7845C17.2304 14.2153 17.7843 14.7076 18.215 14.7076ZM13.7847 17.2308H4.30766C3.69227 17.2308 3.50765 17.9077 3.99996 18.4L7.01537 21.4769L1.47686 27.0769C1.16917 27.3846 1.16917 27.9384 1.47686 28.2461L3.75381 30.523C4.0615 30.8307 4.55381 30.8307 4.92305 30.523L10.5231 24.923L13.6616 27.9384C14.0924 28.4923 14.7693 28.3076 14.7693 27.6923V18.2769C14.7693 17.8462 14.2154 17.2308 13.7847 17.2308Z" }))), !this.isExpanded && (index.h("svg", { viewBox: "0 0 32 32", xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", "aria-hidden": "true" }, index.h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M30.0308 1.23071H20.4923C19.8769 1.23071 19.6923 1.78455 20.1846 2.27686L23.2 5.29222L17.6615 10.8306C17.3538 11.1383 17.3538 11.6306 17.6615 11.9999L19.9384 14.2768C20.2461 14.5845 20.7384 14.5845 21.1077 14.2768L26.7077 8.67681L29.7231 11.6922C30.2154 12.1845 30.7692 11.9999 30.7692 11.3845V1.90763C30.7692 1.5384 30.4 1.23071 30.0308 1.23071ZM2.15379 30.7692H11.6307C12.2461 30.7692 12.4307 30.0923 11.9384 29.6L8.92303 26.5231L14.4615 20.9231C14.7692 20.6154 14.7692 20.0616 14.4615 19.7539L12.1846 17.477C11.8769 17.1693 11.3846 17.1693 11.0153 17.477L5.47687 23.0154L2.39995 20C1.8461 19.5077 1.23071 19.6923 1.23071 20.3077V29.7846C1.23071 30.2153 1.72302 30.7692 2.15379 30.7692Z" }))))), index.h("button", { 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-6 w-6 bot-btn-primary", "data-testid": "modal-minimize", tabindex: "0", "aria-label": "Minimize", onClick: () => {
3066
+ this.syncBodyScrollLock(false);
3006
3067
  this.isOpened = false;
3007
3068
  // this.isContent = false
3008
3069
  this.isContent = this.isExpanded && this.botSettings.isExpanded ? true : false;
@@ -3039,10 +3100,13 @@ const Ai12zBot = class {
3039
3100
  opacity: !this.isMinimized ? "1" : "0",
3040
3101
  transform: "translateX(0)",
3041
3102
  pointerEvents: !this.isMinimized ? "auto" : "none",
3042
- } }, !this.isOpened && (index.h("div", { class: `absolute right-4 md:right-0 border-2 border-white border-solid rounded-full ${this.isContent ? "" : "top-0"} minimize-input` }, index.h("button", { class: "rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-gray-500 bg-opacity-60 hover:bg-opacity-80 h-5 w-5 bot-btn-primary", "aria-label": "Minimize Bot", tabindex: "0", onClick: e => {
3103
+ } }, !this.isOpened && (index.h("div", { class: `absolute right-4 md:right-0 border-2 border-white border-solid rounded-full ${this.isContent ? "" : "top-0"} minimize-input` }, index.h("button", { class: "rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-gray-500 bg-opacity-60 hover:bg-opacity-80 h-5 w-5 bot-btn-primary", "aria-label": "Minimized to fab Bot", tabindex: "0", onClick: e => {
3043
3104
  e.preventDefault();
3044
- this.isMinimized = !this.isMinimized;
3045
- this.isOpened = !this.isMinimized;
3105
+ const nextMinimized = !this.isMinimized;
3106
+ const nextOpened = !nextMinimized;
3107
+ this.syncBodyScrollLock(nextOpened);
3108
+ this.isMinimized = nextMinimized;
3109
+ this.isOpened = nextOpened;
3046
3110
  this.updateBotState();
3047
3111
  } }, index.h("i", { class: "block ai-minimize-icon ai-text-caption", title: "Minimize Bot" }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", height: "52", width: "52", viewBox: "0 0 520 520", fill: "#fff", "aria-hidden": "true" }, index.h("path", { d: "M500 275c0 8-7 15-15 15H35c-8 0-15-7-15-15v-30c0-8 7-15 15-15h450c8 0 15 7 15 15z" })))))), index.h("fieldset", { class: `flex flex-col @md:mx-0 @md:rounded-t-xl transition-colors ${this.isMinimized && !this.isExpanded ? "" : "p-4 user-input-fieldset"}` }, !this.isExpanded && this.isOpened && this.messages.length === 0 && (index.h("privacy-modal", { show: this.showPrivacy, message: this.botSettings.privacyTemplate })), index.h("div", { class: "flex-1 align-bottom" }, index.h("div", { "aria-hidden": this.isTypingIndicatorVisible ? "false" : "true", class: `flex items-center justify-center w-full ${this.isTypingIndicatorVisible ? "h-12 opacity-100" : "h-0 opacity-0 pointer-events-none"}` }, index.h("typing-indicator", null)), index.h("div", { class: "grow-wrap show-grid after:whitespace-pre-wrap after:invisible relative", "data-replicated-value": "", "aria-disabled": "false" }, this.botSettings.imageUpload && (index.h("div", { "aria-disabled": "true", class: `absolute flex items-center left-0 bottom-0 h-full pl-4 pr-2 ${this.hideAllButtons ? "hidden" : ""} agent-input-icon` }, index.h("button", { class: "plus-icon bot-btn-primary", tabindex: "0", "aria-label": "Add Image", onClick: e => {
3048
3112
  e.stopPropagation();
@@ -3082,6 +3146,7 @@ const Ai12zBot = class {
3082
3146
  }, onKeyDown: e => {
3083
3147
  this.handleKeyDown(e);
3084
3148
  if (e.key === "Enter" && !e.shiftKey) {
3149
+ this.syncBodyScrollLock(true);
3085
3150
  this.isOpened = true;
3086
3151
  }
3087
3152
  }, onPaste: e => {
@@ -3115,16 +3180,19 @@ const Ai12zBot = class {
3115
3180
  }, 3000);
3116
3181
  return;
3117
3182
  }
3183
+ this.syncBodyScrollLock(true);
3118
3184
  this.isOpened = true;
3119
3185
  this.handleSend((_b = this.inputEl) === null || _b === void 0 ? void 0 : _b.value);
3120
3186
  } }, index.h("i", { class: "block ai-icon text-body1", title: "Send Message" }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", class: "size-6", "aria-hidden": "true" }, 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 bot-btn-primary", "aria-label": "Stop Streaming", tabindex: "0", id: "message-submit",
3121
3187
  // type="submit"
3122
3188
  onClick: e => {
3123
3189
  e.preventDefault();
3190
+ this.syncBodyScrollLock(true);
3124
3191
  this.isOpened = true;
3125
3192
  this.stopResponse();
3126
3193
  } }, index.h("i", { class: "block text-body1", title: "Stop Streaming" }, index.h("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", class: "size-6", "aria-hidden": "true" }, 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" }))))))), this.isExpanded && !this.isOpened && index.h("privacy-modal", { show: this.showPrivacy, message: this.botSettings.privacyTemplate }), this.messages.length === 0 && (index.h("div", { id: "input-enter-tip", role: "tooltip", class: "enter-tip" }, "Tip: Press Enter to send, Shift+Enter for new line")), this.emptyMessageError && (index.h("div", { class: "error-message-container" }, index.h("span", { id: "empty-message-error", class: "error-msg", role: "alert" }, "Message cannot be empty. Please enter a message to send."))), this.showErrorMessage && index.h("p", { class: "error-msg", innerHTML: this.errorMessage }), this.botSettings.buttons && this.botSettings.buttons.length > 0 && !this.isOpened && (index.h("div", { class: "bot-buttons-container flex flex-wrap gap-2 mt-2.5 mb-1" }, this.botSettings.buttons.map((button, index$1) => (index.h("button", { key: index$1, class: "px-4 py-2 ai12z-btn", onClick: e => {
3127
3194
  e.preventDefault();
3195
+ this.syncBodyScrollLock(true);
3128
3196
  this.isOpened = true;
3129
3197
  this.isContent = false;
3130
3198
  this.handleSend(button.label);