@botonic/react 0.22.0-alpha.0 → 0.22.0-alpha.2

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 (702) hide show
  1. package/lib/cjs/app.d.ts +2 -0
  2. package/lib/cjs/app.js +10 -0
  3. package/lib/cjs/app.js.map +1 -0
  4. package/lib/cjs/botonic-tester.d.ts +18 -0
  5. package/lib/cjs/botonic-tester.js +68 -0
  6. package/lib/cjs/botonic-tester.js.map +1 -0
  7. package/lib/cjs/components/audio.d.ts +8 -0
  8. package/lib/cjs/components/audio.js +23 -0
  9. package/lib/cjs/components/audio.js.map +1 -0
  10. package/lib/cjs/components/button.d.ts +15 -0
  11. package/lib/cjs/components/button.js +145 -0
  12. package/lib/cjs/components/button.js.map +1 -0
  13. package/lib/cjs/components/buttons-disabler.d.ts +24 -0
  14. package/lib/cjs/components/buttons-disabler.js +88 -0
  15. package/lib/cjs/components/buttons-disabler.js.map +1 -0
  16. package/lib/cjs/components/carousel.d.ts +10 -0
  17. package/lib/cjs/components/carousel.js +107 -0
  18. package/lib/cjs/components/carousel.js.map +1 -0
  19. package/lib/cjs/components/components.d.ts +12 -0
  20. package/lib/{components → cjs/components}/components.js +6 -11
  21. package/lib/cjs/components/components.js.map +1 -0
  22. package/lib/cjs/components/custom-message.d.ts +12 -0
  23. package/lib/cjs/components/custom-message.js +59 -0
  24. package/lib/cjs/components/custom-message.js.map +1 -0
  25. package/lib/cjs/components/document.d.ts +8 -0
  26. package/lib/cjs/components/document.js +47 -0
  27. package/lib/cjs/components/document.js.map +1 -0
  28. package/lib/cjs/components/element.d.ts +4 -0
  29. package/lib/cjs/components/element.js +56 -0
  30. package/lib/cjs/components/element.js.map +1 -0
  31. package/lib/cjs/components/handoff.d.ts +1 -0
  32. package/lib/cjs/components/handoff.js +54 -0
  33. package/lib/cjs/components/handoff.js.map +1 -0
  34. package/lib/cjs/components/image.d.ts +8 -0
  35. package/lib/cjs/components/image.js +38 -0
  36. package/lib/cjs/components/image.js.map +1 -0
  37. package/lib/cjs/components/index.d.ts +20 -0
  38. package/lib/cjs/components/index.js +44 -0
  39. package/lib/cjs/components/index.js.map +1 -0
  40. package/lib/cjs/components/location.d.ts +11 -0
  41. package/lib/cjs/components/location.js +32 -0
  42. package/lib/cjs/components/location.js.map +1 -0
  43. package/lib/cjs/components/markdown.d.ts +7 -0
  44. package/lib/cjs/components/markdown.js +162 -0
  45. package/lib/cjs/components/markdown.js.map +1 -0
  46. package/lib/cjs/components/message-template.d.ts +1 -0
  47. package/lib/cjs/components/message-template.js +14 -0
  48. package/lib/cjs/components/message-template.js.map +1 -0
  49. package/lib/cjs/components/message.d.ts +1 -0
  50. package/lib/cjs/components/message.js +188 -0
  51. package/lib/cjs/components/message.js.map +1 -0
  52. package/lib/cjs/components/multichannel/facebook/facebook.d.ts +17 -0
  53. package/lib/cjs/components/multichannel/facebook/facebook.js +47 -0
  54. package/lib/cjs/components/multichannel/facebook/facebook.js.map +1 -0
  55. package/lib/cjs/components/multichannel/index.d.ts +6 -0
  56. package/lib/cjs/components/multichannel/index.js +14 -0
  57. package/lib/cjs/components/multichannel/index.js.map +1 -0
  58. package/lib/cjs/components/multichannel/multichannel-button.d.ts +1 -0
  59. package/lib/cjs/components/multichannel/multichannel-button.js +76 -0
  60. package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -0
  61. package/lib/cjs/components/multichannel/multichannel-carousel.d.ts +1 -0
  62. package/lib/cjs/components/multichannel/multichannel-carousel.js +78 -0
  63. package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -0
  64. package/lib/cjs/components/multichannel/multichannel-context.d.ts +11 -0
  65. package/lib/cjs/components/multichannel/multichannel-context.js +16 -0
  66. package/lib/cjs/components/multichannel/multichannel-context.js.map +1 -0
  67. package/lib/cjs/components/multichannel/multichannel-reply.d.ts +1 -0
  68. package/lib/cjs/components/multichannel/multichannel-reply.js +25 -0
  69. package/lib/cjs/components/multichannel/multichannel-reply.js.map +1 -0
  70. package/lib/cjs/components/multichannel/multichannel-text.d.ts +1 -0
  71. package/lib/cjs/components/multichannel/multichannel-text.js +132 -0
  72. package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -0
  73. package/lib/cjs/components/multichannel/multichannel-utils.d.ts +24 -0
  74. package/lib/cjs/components/multichannel/multichannel-utils.js +83 -0
  75. package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -0
  76. package/lib/cjs/components/multichannel/multichannel.d.ts +1 -0
  77. package/lib/cjs/components/multichannel/multichannel.js +60 -0
  78. package/lib/cjs/components/multichannel/multichannel.js.map +1 -0
  79. package/lib/cjs/components/pic.d.ts +6 -0
  80. package/lib/cjs/components/pic.js +30 -0
  81. package/lib/cjs/components/pic.js.map +1 -0
  82. package/lib/cjs/components/raw.d.ts +9 -0
  83. package/lib/cjs/components/raw.js +44 -0
  84. package/lib/cjs/components/raw.js.map +1 -0
  85. package/lib/cjs/components/reply.d.ts +9 -0
  86. package/lib/cjs/components/reply.js +54 -0
  87. package/lib/cjs/components/reply.js.map +1 -0
  88. package/lib/cjs/components/share-button.d.ts +1 -0
  89. package/lib/cjs/components/share-button.js +14 -0
  90. package/lib/cjs/components/share-button.js.map +1 -0
  91. package/lib/cjs/components/subtitle.d.ts +6 -0
  92. package/lib/cjs/components/subtitle.js +24 -0
  93. package/lib/cjs/components/subtitle.js.map +1 -0
  94. package/lib/cjs/components/text.d.ts +8 -0
  95. package/lib/cjs/components/text.js +47 -0
  96. package/lib/cjs/components/text.js.map +1 -0
  97. package/lib/cjs/components/timestamps.d.ts +10 -0
  98. package/lib/cjs/components/timestamps.js +51 -0
  99. package/lib/cjs/components/timestamps.js.map +1 -0
  100. package/lib/cjs/components/title.d.ts +6 -0
  101. package/lib/cjs/components/title.js +22 -0
  102. package/lib/cjs/components/title.js.map +1 -0
  103. package/lib/cjs/components/video.d.ts +8 -0
  104. package/lib/cjs/components/video.js +31 -0
  105. package/lib/cjs/components/video.js.map +1 -0
  106. package/lib/cjs/components/webchat-settings.d.ts +10 -0
  107. package/lib/cjs/components/webchat-settings.js +79 -0
  108. package/lib/cjs/components/webchat-settings.js.map +1 -0
  109. package/lib/cjs/components/whatsapp-template.d.ts +1 -0
  110. package/lib/cjs/components/whatsapp-template.js +25 -0
  111. package/lib/cjs/components/whatsapp-template.js.map +1 -0
  112. package/lib/cjs/constants.d.ts +168 -0
  113. package/lib/cjs/constants.js +190 -0
  114. package/lib/cjs/constants.js.map +1 -0
  115. package/lib/cjs/contexts.d.ts +69 -0
  116. package/lib/cjs/contexts.js +38 -0
  117. package/lib/cjs/contexts.js.map +1 -0
  118. package/lib/cjs/dev-app.d.ts +30 -0
  119. package/lib/cjs/dev-app.js +72 -0
  120. package/lib/cjs/dev-app.js.map +1 -0
  121. package/lib/cjs/index.d.ts +10 -0
  122. package/lib/cjs/index.js +28 -0
  123. package/lib/cjs/index.js.map +1 -0
  124. package/lib/cjs/message-utils.d.ts +19 -0
  125. package/lib/cjs/message-utils.js +61 -0
  126. package/lib/cjs/message-utils.js.map +1 -0
  127. package/lib/cjs/msg-to-botonic.d.ts +18 -0
  128. package/lib/cjs/msg-to-botonic.js +138 -0
  129. package/lib/cjs/msg-to-botonic.js.map +1 -0
  130. package/lib/cjs/node-app.d.ts +12 -0
  131. package/lib/cjs/node-app.js +25 -0
  132. package/lib/cjs/node-app.js.map +1 -0
  133. package/lib/cjs/react-bot.d.ts +8 -0
  134. package/lib/cjs/react-bot.js +34 -0
  135. package/lib/cjs/react-bot.js.map +1 -0
  136. package/lib/cjs/util/dom.d.ts +13 -0
  137. package/lib/cjs/util/dom.js +55 -0
  138. package/lib/cjs/util/dom.js.map +1 -0
  139. package/lib/cjs/util/environment.d.ts +6 -0
  140. package/lib/cjs/util/environment.js +68 -0
  141. package/lib/cjs/util/environment.js.map +1 -0
  142. package/lib/cjs/util/error-boundary.d.ts +7 -0
  143. package/lib/cjs/util/error-boundary.js +33 -0
  144. package/lib/cjs/util/error-boundary.js.map +1 -0
  145. package/lib/cjs/util/index.d.ts +0 -0
  146. package/lib/cjs/util/index.js +2 -0
  147. package/lib/cjs/util/index.js.map +1 -0
  148. package/lib/cjs/util/logs.d.ts +2 -0
  149. package/lib/cjs/util/logs.js +20 -0
  150. package/lib/cjs/util/logs.js.map +1 -0
  151. package/lib/cjs/util/objects.d.ts +3 -0
  152. package/lib/cjs/util/objects.js +44 -0
  153. package/lib/cjs/util/objects.js.map +1 -0
  154. package/lib/cjs/util/react.d.ts +12 -0
  155. package/lib/cjs/util/react.js +42 -0
  156. package/lib/cjs/util/react.js.map +1 -0
  157. package/lib/cjs/util/regexs.d.ts +2 -0
  158. package/lib/cjs/util/regexs.js +23 -0
  159. package/lib/cjs/util/regexs.js.map +1 -0
  160. package/lib/cjs/util/webchat.d.ts +11 -0
  161. package/lib/cjs/util/webchat.js +62 -0
  162. package/lib/cjs/util/webchat.js.map +1 -0
  163. package/lib/cjs/webchat/actions.d.ts +23 -0
  164. package/lib/cjs/webchat/actions.js +27 -0
  165. package/lib/cjs/webchat/actions.js.map +1 -0
  166. package/lib/cjs/webchat/components/attachment.d.ts +5 -0
  167. package/lib/cjs/webchat/components/attachment.js +29 -0
  168. package/lib/cjs/webchat/components/attachment.js.map +1 -0
  169. package/lib/cjs/webchat/components/common.d.ts +1 -0
  170. package/lib/cjs/webchat/components/common.js +14 -0
  171. package/lib/cjs/webchat/components/common.js.map +1 -0
  172. package/lib/cjs/webchat/components/conditional-animation.d.ts +1 -0
  173. package/lib/cjs/webchat/components/conditional-animation.js +17 -0
  174. package/lib/cjs/webchat/components/conditional-animation.js.map +1 -0
  175. package/lib/cjs/webchat/components/emoji-picker.d.ts +5 -0
  176. package/lib/cjs/webchat/components/emoji-picker.js +43 -0
  177. package/lib/cjs/webchat/components/emoji-picker.js.map +1 -0
  178. package/lib/cjs/webchat/components/persistent-menu.d.ts +10 -0
  179. package/lib/cjs/webchat/components/persistent-menu.js +45 -0
  180. package/lib/cjs/webchat/components/persistent-menu.js.map +1 -0
  181. package/lib/cjs/webchat/components/send-button.d.ts +3 -0
  182. package/lib/cjs/webchat/components/send-button.js +19 -0
  183. package/lib/cjs/webchat/components/send-button.js.map +1 -0
  184. package/lib/cjs/webchat/components/styled-scrollbar.d.ts +1 -0
  185. package/lib/cjs/webchat/components/styled-scrollbar.js +54 -0
  186. package/lib/cjs/webchat/components/styled-scrollbar.js.map +1 -0
  187. package/lib/cjs/webchat/components/typing-indicator.d.ts +1 -0
  188. package/lib/cjs/webchat/components/typing-indicator.js +11 -0
  189. package/lib/cjs/webchat/components/typing-indicator.js.map +1 -0
  190. package/lib/cjs/webchat/devices/device-adapter.d.ts +12 -0
  191. package/lib/cjs/webchat/devices/device-adapter.js +47 -0
  192. package/lib/cjs/webchat/devices/device-adapter.js.map +1 -0
  193. package/lib/cjs/webchat/devices/index.d.ts +11 -0
  194. package/lib/cjs/webchat/devices/index.js +23 -0
  195. package/lib/cjs/webchat/devices/index.js.map +1 -0
  196. package/lib/cjs/webchat/devices/scrollbar-controller.d.ts +12 -0
  197. package/lib/cjs/webchat/devices/scrollbar-controller.js +103 -0
  198. package/lib/cjs/webchat/devices/scrollbar-controller.js.map +1 -0
  199. package/lib/cjs/webchat/devices/webchat-resizer.d.ts +9 -0
  200. package/lib/cjs/webchat/devices/webchat-resizer.js +47 -0
  201. package/lib/cjs/webchat/devices/webchat-resizer.js.map +1 -0
  202. package/lib/cjs/webchat/header.d.ts +3 -0
  203. package/lib/cjs/webchat/header.js +85 -0
  204. package/lib/cjs/webchat/header.js.map +1 -0
  205. package/lib/cjs/webchat/hooks.d.ts +80 -0
  206. package/lib/cjs/webchat/hooks.js +219 -0
  207. package/lib/cjs/webchat/hooks.js.map +1 -0
  208. package/lib/cjs/webchat/index.d.ts +6 -0
  209. package/lib/cjs/webchat/index.js +17 -0
  210. package/lib/cjs/webchat/index.js.map +1 -0
  211. package/lib/cjs/webchat/message-list.d.ts +1 -0
  212. package/lib/cjs/webchat/message-list.js +39 -0
  213. package/lib/cjs/webchat/message-list.js.map +1 -0
  214. package/lib/cjs/webchat/messages-reducer.d.ts +1 -0
  215. package/lib/cjs/webchat/messages-reducer.js +58 -0
  216. package/lib/cjs/webchat/messages-reducer.js.map +1 -0
  217. package/lib/cjs/webchat/replies.d.ts +1 -0
  218. package/lib/cjs/webchat/replies.js +43 -0
  219. package/lib/cjs/webchat/replies.js.map +1 -0
  220. package/lib/cjs/webchat/session-view.d.ts +1 -0
  221. package/lib/cjs/webchat/session-view.js +101 -0
  222. package/lib/cjs/webchat/session-view.js.map +1 -0
  223. package/lib/cjs/webchat/use-storage-state-hook.d.ts +1 -0
  224. package/lib/cjs/webchat/use-storage-state-hook.js +42 -0
  225. package/lib/cjs/webchat/use-storage-state-hook.js.map +1 -0
  226. package/lib/cjs/webchat/webchat-dev.d.ts +7 -0
  227. package/lib/cjs/webchat/webchat-dev.js +60 -0
  228. package/lib/cjs/webchat/webchat-dev.js.map +1 -0
  229. package/lib/cjs/webchat/webchat-reducer.d.ts +1 -0
  230. package/lib/cjs/webchat/webchat-reducer.js +48 -0
  231. package/lib/cjs/webchat/webchat-reducer.js.map +1 -0
  232. package/lib/cjs/webchat/webchat.d.ts +3 -0
  233. package/lib/cjs/webchat/webchat.js +661 -0
  234. package/lib/cjs/webchat/webchat.js.map +1 -0
  235. package/lib/cjs/webchat/webview.d.ts +2 -0
  236. package/lib/cjs/webchat/webview.js +84 -0
  237. package/lib/cjs/webchat/webview.js.map +1 -0
  238. package/lib/cjs/webchat-app.d.ts +99 -0
  239. package/lib/cjs/webchat-app.js +270 -0
  240. package/lib/cjs/webchat-app.js.map +1 -0
  241. package/lib/cjs/webview-app.d.ts +7 -0
  242. package/lib/cjs/webview-app.js +102 -0
  243. package/lib/cjs/webview-app.js.map +1 -0
  244. package/lib/esm/app.d.ts +2 -0
  245. package/lib/esm/app.js +6 -0
  246. package/lib/esm/app.js.map +1 -0
  247. package/lib/esm/assets/attachment-icon.svg +7 -0
  248. package/lib/esm/assets/audio.svg +4 -0
  249. package/lib/esm/assets/botonic_react_logo100x100.png +0 -0
  250. package/lib/esm/assets/document.svg +3 -0
  251. package/lib/esm/assets/emojiButton.svg +6 -0
  252. package/lib/esm/assets/image.svg +4 -0
  253. package/lib/esm/assets/leftArrow.svg +3 -0
  254. package/lib/esm/assets/menuButton.svg +3 -0
  255. package/lib/esm/assets/rightArrow.svg +3 -0
  256. package/lib/esm/assets/send-button.svg +1 -0
  257. package/lib/esm/assets/video.svg +3 -0
  258. package/lib/esm/botonic-tester.d.ts +18 -0
  259. package/lib/esm/botonic-tester.js +62 -0
  260. package/lib/esm/botonic-tester.js.map +1 -0
  261. package/lib/esm/components/audio.d.ts +8 -0
  262. package/lib/esm/components/audio.js +18 -0
  263. package/lib/esm/components/audio.js.map +1 -0
  264. package/lib/esm/components/button.d.ts +15 -0
  265. package/lib/esm/components/button.js +140 -0
  266. package/lib/esm/components/button.js.map +1 -0
  267. package/lib/esm/components/buttons-disabler.d.ts +24 -0
  268. package/lib/esm/components/buttons-disabler.js +84 -0
  269. package/lib/esm/components/buttons-disabler.js.map +1 -0
  270. package/lib/esm/components/carousel.d.ts +9 -0
  271. package/lib/esm/components/carousel.js +102 -0
  272. package/lib/esm/components/carousel.js.map +1 -0
  273. package/lib/esm/components/components.d.ts +12 -0
  274. package/lib/esm/components/components.js +17 -0
  275. package/lib/esm/components/components.js.map +1 -0
  276. package/lib/esm/components/custom-message.d.ts +12 -0
  277. package/lib/esm/components/custom-message.js +55 -0
  278. package/lib/esm/components/custom-message.js.map +1 -0
  279. package/lib/esm/components/document.d.ts +8 -0
  280. package/lib/esm/components/document.js +42 -0
  281. package/lib/esm/components/document.js.map +1 -0
  282. package/lib/esm/components/element.d.ts +4 -0
  283. package/lib/esm/components/element.js +51 -0
  284. package/lib/esm/components/element.js.map +1 -0
  285. package/lib/esm/components/handoff.d.ts +1 -0
  286. package/lib/esm/components/handoff.js +49 -0
  287. package/lib/esm/components/handoff.js.map +1 -0
  288. package/lib/esm/components/image.d.ts +8 -0
  289. package/lib/esm/components/image.js +33 -0
  290. package/lib/esm/components/image.js.map +1 -0
  291. package/lib/esm/components/index.d.ts +19 -0
  292. package/lib/esm/components/index.js +21 -0
  293. package/lib/esm/components/index.js.map +1 -0
  294. package/lib/esm/components/location.d.ts +11 -0
  295. package/lib/esm/components/location.js +27 -0
  296. package/lib/esm/components/location.js.map +1 -0
  297. package/lib/esm/components/markdown.d.ts +7 -0
  298. package/lib/esm/components/markdown.js +152 -0
  299. package/lib/esm/components/markdown.js.map +1 -0
  300. package/lib/esm/components/message-template.d.ts +1 -0
  301. package/lib/esm/components/message-template.js +9 -0
  302. package/lib/esm/components/message-template.js.map +1 -0
  303. package/lib/esm/components/message.d.ts +1 -0
  304. package/lib/esm/components/message.js +184 -0
  305. package/lib/esm/components/message.js.map +1 -0
  306. package/lib/esm/components/multichannel/facebook/facebook.d.ts +17 -0
  307. package/lib/esm/components/multichannel/facebook/facebook.js +43 -0
  308. package/lib/esm/components/multichannel/facebook/facebook.js.map +1 -0
  309. package/lib/esm/components/multichannel/index.d.ts +6 -0
  310. package/lib/esm/components/multichannel/index.js +11 -0
  311. package/lib/esm/components/multichannel/index.js.map +1 -0
  312. package/lib/esm/components/multichannel/multichannel-button.d.ts +1 -0
  313. package/lib/esm/components/multichannel/multichannel-button.js +71 -0
  314. package/lib/esm/components/multichannel/multichannel-button.js.map +1 -0
  315. package/lib/esm/components/multichannel/multichannel-carousel.d.ts +1 -0
  316. package/lib/esm/components/multichannel/multichannel-carousel.js +73 -0
  317. package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -0
  318. package/lib/esm/components/multichannel/multichannel-context.d.ts +11 -0
  319. package/lib/esm/components/multichannel/multichannel-context.js +12 -0
  320. package/lib/esm/components/multichannel/multichannel-context.js.map +1 -0
  321. package/lib/esm/components/multichannel/multichannel-reply.d.ts +1 -0
  322. package/lib/esm/components/multichannel/multichannel-reply.js +20 -0
  323. package/lib/esm/components/multichannel/multichannel-reply.js.map +1 -0
  324. package/lib/esm/components/multichannel/multichannel-text.d.ts +1 -0
  325. package/lib/esm/components/multichannel/multichannel-text.js +127 -0
  326. package/lib/esm/components/multichannel/multichannel-text.js.map +1 -0
  327. package/lib/esm/components/multichannel/multichannel-utils.d.ts +24 -0
  328. package/lib/esm/components/multichannel/multichannel-utils.js +67 -0
  329. package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -0
  330. package/lib/esm/components/multichannel/multichannel.d.ts +1 -0
  331. package/lib/esm/components/multichannel/multichannel.js +55 -0
  332. package/lib/esm/components/multichannel/multichannel.js.map +1 -0
  333. package/lib/esm/components/pic.d.ts +6 -0
  334. package/lib/esm/components/pic.js +25 -0
  335. package/lib/esm/components/pic.js.map +1 -0
  336. package/lib/esm/components/raw.d.ts +9 -0
  337. package/lib/esm/components/raw.js +39 -0
  338. package/lib/esm/components/raw.js.map +1 -0
  339. package/lib/esm/components/reply.d.ts +9 -0
  340. package/lib/esm/components/reply.js +49 -0
  341. package/lib/esm/components/reply.js.map +1 -0
  342. package/lib/esm/components/share-button.d.ts +1 -0
  343. package/lib/esm/components/share-button.js +9 -0
  344. package/lib/esm/components/share-button.js.map +1 -0
  345. package/lib/esm/components/subtitle.d.ts +6 -0
  346. package/lib/esm/components/subtitle.js +19 -0
  347. package/lib/esm/components/subtitle.js.map +1 -0
  348. package/lib/esm/components/text.d.ts +8 -0
  349. package/lib/esm/components/text.js +42 -0
  350. package/lib/esm/components/text.js.map +1 -0
  351. package/lib/esm/components/timestamps.d.ts +10 -0
  352. package/lib/esm/components/timestamps.js +45 -0
  353. package/lib/esm/components/timestamps.js.map +1 -0
  354. package/lib/esm/components/title.d.ts +6 -0
  355. package/lib/esm/components/title.js +17 -0
  356. package/lib/esm/components/title.js.map +1 -0
  357. package/lib/esm/components/video.d.ts +8 -0
  358. package/lib/esm/components/video.js +26 -0
  359. package/lib/esm/components/video.js.map +1 -0
  360. package/lib/esm/components/webchat-settings.d.ts +10 -0
  361. package/lib/esm/components/webchat-settings.js +73 -0
  362. package/lib/esm/components/webchat-settings.js.map +1 -0
  363. package/lib/esm/components/whatsapp-template.d.ts +1 -0
  364. package/lib/esm/components/whatsapp-template.js +20 -0
  365. package/lib/esm/components/whatsapp-template.js.map +1 -0
  366. package/lib/esm/constants.d.ts +168 -0
  367. package/lib/esm/constants.js +186 -0
  368. package/lib/esm/constants.js.map +1 -0
  369. package/lib/esm/contexts.d.ts +69 -0
  370. package/lib/esm/contexts.js +34 -0
  371. package/lib/esm/contexts.js.map +1 -0
  372. package/lib/esm/dev-app.d.ts +30 -0
  373. package/lib/esm/dev-app.js +68 -0
  374. package/lib/esm/dev-app.js.map +1 -0
  375. package/lib/esm/index.d.ts +9 -0
  376. package/lib/esm/index.js +11 -0
  377. package/lib/esm/index.js.map +1 -0
  378. package/lib/esm/message-utils.d.ts +18 -0
  379. package/lib/esm/message-utils.js +41 -0
  380. package/lib/esm/message-utils.js.map +1 -0
  381. package/lib/esm/msg-to-botonic.d.ts +18 -0
  382. package/lib/esm/msg-to-botonic.js +132 -0
  383. package/lib/esm/msg-to-botonic.js.map +1 -0
  384. package/lib/esm/node-app.d.ts +12 -0
  385. package/lib/esm/node-app.js +21 -0
  386. package/lib/esm/node-app.js.map +1 -0
  387. package/lib/esm/react-bot.d.ts +7 -0
  388. package/lib/esm/react-bot.js +29 -0
  389. package/lib/esm/react-bot.js.map +1 -0
  390. package/lib/esm/util/dom.d.ts +13 -0
  391. package/lib/esm/util/dom.js +46 -0
  392. package/lib/esm/util/dom.js.map +1 -0
  393. package/lib/esm/util/environment.d.ts +6 -0
  394. package/lib/esm/util/environment.js +61 -0
  395. package/lib/esm/util/environment.js.map +1 -0
  396. package/lib/esm/util/error-boundary.d.ts +7 -0
  397. package/lib/esm/util/error-boundary.js +28 -0
  398. package/lib/esm/util/error-boundary.js.map +1 -0
  399. package/lib/esm/util/index.d.ts +0 -0
  400. package/lib/esm/util/index.js +2 -0
  401. package/lib/esm/util/index.js.map +1 -0
  402. package/lib/esm/util/logs.d.ts +2 -0
  403. package/lib/esm/util/logs.js +15 -0
  404. package/lib/esm/util/logs.js.map +1 -0
  405. package/lib/esm/util/objects.d.ts +3 -0
  406. package/lib/esm/util/objects.js +38 -0
  407. package/lib/esm/util/objects.js.map +1 -0
  408. package/lib/esm/util/react.d.ts +12 -0
  409. package/lib/esm/util/react.js +34 -0
  410. package/lib/esm/util/react.js.map +1 -0
  411. package/lib/esm/util/regexs.d.ts +2 -0
  412. package/lib/esm/util/regexs.js +18 -0
  413. package/lib/esm/util/regexs.js.map +1 -0
  414. package/lib/esm/util/webchat.d.ts +11 -0
  415. package/lib/esm/util/webchat.js +53 -0
  416. package/lib/esm/util/webchat.js.map +1 -0
  417. package/lib/esm/webchat/actions.d.ts +23 -0
  418. package/lib/esm/webchat/actions.js +24 -0
  419. package/lib/esm/webchat/actions.js.map +1 -0
  420. package/lib/esm/webchat/components/attachment.d.ts +5 -0
  421. package/lib/esm/webchat/components/attachment.js +24 -0
  422. package/lib/esm/webchat/components/attachment.js.map +1 -0
  423. package/lib/esm/webchat/components/common.d.ts +1 -0
  424. package/lib/esm/webchat/components/common.js +9 -0
  425. package/lib/esm/webchat/components/common.js.map +1 -0
  426. package/lib/esm/webchat/components/conditional-animation.d.ts +1 -0
  427. package/lib/esm/webchat/components/conditional-animation.js +12 -0
  428. package/lib/esm/webchat/components/conditional-animation.js.map +1 -0
  429. package/lib/esm/webchat/components/emoji-picker.d.ts +5 -0
  430. package/lib/esm/webchat/components/emoji-picker.js +37 -0
  431. package/lib/esm/webchat/components/emoji-picker.js.map +1 -0
  432. package/lib/esm/webchat/components/persistent-menu.d.ts +10 -0
  433. package/lib/esm/webchat/components/persistent-menu.js +39 -0
  434. package/lib/esm/webchat/components/persistent-menu.js.map +1 -0
  435. package/lib/esm/webchat/components/send-button.d.ts +3 -0
  436. package/lib/esm/webchat/components/send-button.js +14 -0
  437. package/lib/esm/webchat/components/send-button.js.map +1 -0
  438. package/lib/esm/webchat/components/styled-scrollbar.d.ts +1 -0
  439. package/lib/esm/webchat/components/styled-scrollbar.js +50 -0
  440. package/lib/esm/webchat/components/styled-scrollbar.js.map +1 -0
  441. package/lib/esm/webchat/components/styled-scrollbar.scss +12 -0
  442. package/lib/esm/webchat/components/typing-indicator.d.ts +1 -0
  443. package/lib/esm/webchat/components/typing-indicator.js +6 -0
  444. package/lib/esm/webchat/components/typing-indicator.js.map +1 -0
  445. package/lib/esm/webchat/components/typing-indicator.scss +38 -0
  446. package/lib/esm/webchat/devices/device-adapter.d.ts +12 -0
  447. package/lib/esm/webchat/devices/device-adapter.js +43 -0
  448. package/lib/esm/webchat/devices/device-adapter.js.map +1 -0
  449. package/lib/esm/webchat/devices/index.d.ts +11 -0
  450. package/lib/esm/webchat/devices/index.js +18 -0
  451. package/lib/esm/webchat/devices/index.js.map +1 -0
  452. package/lib/esm/webchat/devices/scrollbar-controller.d.ts +12 -0
  453. package/lib/esm/webchat/devices/scrollbar-controller.js +99 -0
  454. package/lib/esm/webchat/devices/scrollbar-controller.js.map +1 -0
  455. package/lib/esm/webchat/devices/webchat-resizer.d.ts +9 -0
  456. package/lib/esm/webchat/devices/webchat-resizer.js +43 -0
  457. package/lib/esm/webchat/devices/webchat-resizer.js.map +1 -0
  458. package/lib/esm/webchat/header.d.ts +3 -0
  459. package/lib/esm/webchat/header.js +79 -0
  460. package/lib/esm/webchat/header.js.map +1 -0
  461. package/lib/esm/webchat/hooks.d.ts +80 -0
  462. package/lib/esm/webchat/hooks.js +211 -0
  463. package/lib/esm/webchat/hooks.js.map +1 -0
  464. package/lib/esm/webchat/index.d.ts +6 -0
  465. package/lib/esm/webchat/index.js +11 -0
  466. package/lib/esm/webchat/index.js.map +1 -0
  467. package/lib/esm/webchat/message-list.d.ts +1 -0
  468. package/lib/esm/webchat/message-list.js +34 -0
  469. package/lib/esm/webchat/message-list.js.map +1 -0
  470. package/lib/esm/webchat/messages-reducer.d.ts +1 -0
  471. package/lib/esm/webchat/messages-reducer.js +54 -0
  472. package/lib/esm/webchat/messages-reducer.js.map +1 -0
  473. package/lib/esm/webchat/replies.d.ts +1 -0
  474. package/lib/esm/webchat/replies.js +38 -0
  475. package/lib/esm/webchat/replies.js.map +1 -0
  476. package/lib/esm/webchat/session-view.d.ts +1 -0
  477. package/lib/esm/webchat/session-view.js +96 -0
  478. package/lib/esm/webchat/session-view.js.map +1 -0
  479. package/lib/esm/webchat/use-storage-state-hook.d.ts +1 -0
  480. package/lib/esm/webchat/use-storage-state-hook.js +38 -0
  481. package/lib/esm/webchat/use-storage-state-hook.js.map +1 -0
  482. package/lib/esm/webchat/webchat-dev.d.ts +7 -0
  483. package/lib/esm/webchat/webchat-dev.js +56 -0
  484. package/lib/esm/webchat/webchat-dev.js.map +1 -0
  485. package/lib/esm/webchat/webchat-reducer.d.ts +1 -0
  486. package/lib/esm/webchat/webchat-reducer.js +44 -0
  487. package/lib/esm/webchat/webchat-reducer.js.map +1 -0
  488. package/lib/esm/webchat/webchat.d.ts +3 -0
  489. package/lib/esm/webchat/webchat.js +656 -0
  490. package/lib/esm/webchat/webchat.js.map +1 -0
  491. package/lib/esm/webchat/webview.d.ts +2 -0
  492. package/lib/esm/webchat/webview.js +78 -0
  493. package/lib/esm/webchat/webview.js.map +1 -0
  494. package/lib/esm/webchat-app.d.ts +98 -0
  495. package/lib/esm/webchat-app.js +266 -0
  496. package/lib/esm/webchat-app.js.map +1 -0
  497. package/lib/esm/webchat.template.html +37 -0
  498. package/lib/esm/webview-app.d.ts +7 -0
  499. package/lib/esm/webview-app.js +97 -0
  500. package/lib/esm/webview-app.js.map +1 -0
  501. package/lib/esm/webview.template.html +39 -0
  502. package/package.json +40 -27
  503. package/src/components/audio.jsx +2 -0
  504. package/src/components/document.jsx +2 -0
  505. package/src/components/image.jsx +2 -0
  506. package/src/components/location.jsx +2 -2
  507. package/src/components/message.jsx +4 -11
  508. package/src/components/multichannel/multichannel-text.jsx +2 -5
  509. package/src/components/pic.jsx +3 -1
  510. package/src/components/video.jsx +2 -0
  511. package/src/index.js +1 -1
  512. package/src/msg-to-botonic.jsx +11 -11
  513. package/src/util/environment.js +31 -2
  514. package/src/util/error-boundary.jsx +15 -30
  515. package/src/util/webchat.js +12 -13
  516. package/src/webchat/components/attachment.jsx +10 -2
  517. package/src/webchat/components/emoji-picker.jsx +7 -1
  518. package/src/webchat/hooks.js +2 -1
  519. package/src/webchat/use-storage-state-hook.js +13 -2
  520. package/src/webchat/webchat.jsx +5 -7
  521. package/src/{webview.jsx → webview-app.tsx} +7 -1
  522. package/lib/app.js +0 -19
  523. package/lib/app.js.map +0 -1
  524. package/lib/botonic-tester.js +0 -224
  525. package/lib/botonic-tester.js.map +0 -1
  526. package/lib/components/audio.js +0 -48
  527. package/lib/components/audio.js.map +0 -1
  528. package/lib/components/button.js +0 -224
  529. package/lib/components/button.js.map +0 -1
  530. package/lib/components/buttons-disabler.js +0 -133
  531. package/lib/components/buttons-disabler.js.map +0 -1
  532. package/lib/components/carousel.js +0 -194
  533. package/lib/components/carousel.js.map +0 -1
  534. package/lib/components/components.js.map +0 -1
  535. package/lib/components/custom-message.js +0 -131
  536. package/lib/components/custom-message.js.map +0 -1
  537. package/lib/components/document.js +0 -76
  538. package/lib/components/document.js.map +0 -1
  539. package/lib/components/element.js +0 -69
  540. package/lib/components/element.js.map +0 -1
  541. package/lib/components/handoff.js +0 -69
  542. package/lib/components/handoff.js.map +0 -1
  543. package/lib/components/image.js +0 -91
  544. package/lib/components/image.js.map +0 -1
  545. package/lib/components/index.d.ts +0 -228
  546. package/lib/components/index.js +0 -193
  547. package/lib/components/index.js.map +0 -1
  548. package/lib/components/location.js +0 -69
  549. package/lib/components/location.js.map +0 -1
  550. package/lib/components/markdown.js +0 -108
  551. package/lib/components/markdown.js.map +0 -1
  552. package/lib/components/message-template.js +0 -36
  553. package/lib/components/message-template.js.map +0 -1
  554. package/lib/components/message.js +0 -351
  555. package/lib/components/message.js.map +0 -1
  556. package/lib/components/multichannel/facebook/facebook.js +0 -96
  557. package/lib/components/multichannel/facebook/facebook.js.map +0 -1
  558. package/lib/components/multichannel/index.d.ts +0 -65
  559. package/lib/components/multichannel/index.js +0 -46
  560. package/lib/components/multichannel/index.js.map +0 -1
  561. package/lib/components/multichannel/multichannel-button.js +0 -119
  562. package/lib/components/multichannel/multichannel-button.js.map +0 -1
  563. package/lib/components/multichannel/multichannel-carousel.js +0 -143
  564. package/lib/components/multichannel/multichannel-carousel.js.map +0 -1
  565. package/lib/components/multichannel/multichannel-context.js +0 -24
  566. package/lib/components/multichannel/multichannel-context.js.map +0 -1
  567. package/lib/components/multichannel/multichannel-reply.js +0 -46
  568. package/lib/components/multichannel/multichannel-reply.js.map +0 -1
  569. package/lib/components/multichannel/multichannel-text.js +0 -222
  570. package/lib/components/multichannel/multichannel-text.js.map +0 -1
  571. package/lib/components/multichannel/multichannel-utils.js +0 -126
  572. package/lib/components/multichannel/multichannel-utils.js.map +0 -1
  573. package/lib/components/multichannel/multichannel.js +0 -111
  574. package/lib/components/multichannel/multichannel.js.map +0 -1
  575. package/lib/components/pic.js +0 -50
  576. package/lib/components/pic.js.map +0 -1
  577. package/lib/components/raw.js +0 -70
  578. package/lib/components/raw.js.map +0 -1
  579. package/lib/components/reply.js +0 -107
  580. package/lib/components/reply.js.map +0 -1
  581. package/lib/components/share-button.js +0 -36
  582. package/lib/components/share-button.js.map +0 -1
  583. package/lib/components/subtitle.js +0 -54
  584. package/lib/components/subtitle.js.map +0 -1
  585. package/lib/components/text.js +0 -80
  586. package/lib/components/text.js.map +0 -1
  587. package/lib/components/timestamps.js +0 -69
  588. package/lib/components/timestamps.js.map +0 -1
  589. package/lib/components/title.js +0 -52
  590. package/lib/components/title.js.map +0 -1
  591. package/lib/components/video.js +0 -51
  592. package/lib/components/video.js.map +0 -1
  593. package/lib/components/webchat-settings.js +0 -118
  594. package/lib/components/webchat-settings.js.map +0 -1
  595. package/lib/components/whatsapp-template.js +0 -53
  596. package/lib/components/whatsapp-template.js.map +0 -1
  597. package/lib/constants.js +0 -203
  598. package/lib/constants.js.map +0 -1
  599. package/lib/contexts.js +0 -57
  600. package/lib/contexts.js.map +0 -1
  601. package/lib/dev-app.js +0 -241
  602. package/lib/dev-app.js.map +0 -1
  603. package/lib/index.d.ts +0 -238
  604. package/lib/index.js +0 -131
  605. package/lib/index.js.map +0 -1
  606. package/lib/message-utils.js +0 -149
  607. package/lib/message-utils.js.map +0 -1
  608. package/lib/msg-to-botonic.js +0 -199
  609. package/lib/msg-to-botonic.js.map +0 -1
  610. package/lib/node-app.js +0 -97
  611. package/lib/node-app.js.map +0 -1
  612. package/lib/react-bot.js +0 -167
  613. package/lib/react-bot.js.map +0 -1
  614. package/lib/util/dom.js +0 -84
  615. package/lib/util/dom.js.map +0 -1
  616. package/lib/util/environment.js +0 -42
  617. package/lib/util/environment.js.map +0 -1
  618. package/lib/util/error-boundary.js +0 -105
  619. package/lib/util/error-boundary.js.map +0 -1
  620. package/lib/util/index.d.ts +0 -9
  621. package/lib/util/index.js +0 -2
  622. package/lib/util/index.js.map +0 -1
  623. package/lib/util/logs.js +0 -28
  624. package/lib/util/logs.js.map +0 -1
  625. package/lib/util/objects.js +0 -60
  626. package/lib/util/objects.js.map +0 -1
  627. package/lib/util/react.js +0 -75
  628. package/lib/util/react.js.map +0 -1
  629. package/lib/util/regexs.js +0 -31
  630. package/lib/util/regexs.js.map +0 -1
  631. package/lib/util/webchat.js +0 -92
  632. package/lib/util/webchat.js.map +0 -1
  633. package/lib/webchat/actions.js +0 -53
  634. package/lib/webchat/actions.js.map +0 -1
  635. package/lib/webchat/components/attachment.js +0 -68
  636. package/lib/webchat/components/attachment.js.map +0 -1
  637. package/lib/webchat/components/common.js +0 -29
  638. package/lib/webchat/components/common.js.map +0 -1
  639. package/lib/webchat/components/conditional-animation.js +0 -42
  640. package/lib/webchat/components/conditional-animation.js.map +0 -1
  641. package/lib/webchat/components/emoji-picker.js +0 -89
  642. package/lib/webchat/components/emoji-picker.js.map +0 -1
  643. package/lib/webchat/components/persistent-menu.js +0 -104
  644. package/lib/webchat/components/persistent-menu.js.map +0 -1
  645. package/lib/webchat/components/send-button.js +0 -45
  646. package/lib/webchat/components/send-button.js.map +0 -1
  647. package/lib/webchat/components/styled-scrollbar.js +0 -55
  648. package/lib/webchat/components/styled-scrollbar.js.map +0 -1
  649. package/lib/webchat/components/typing-indicator.js +0 -27
  650. package/lib/webchat/components/typing-indicator.js.map +0 -1
  651. package/lib/webchat/devices/device-adapter.js +0 -82
  652. package/lib/webchat/devices/device-adapter.js.map +0 -1
  653. package/lib/webchat/devices/index.js +0 -32
  654. package/lib/webchat/devices/index.js.map +0 -1
  655. package/lib/webchat/devices/scrollbar-controller.js +0 -152
  656. package/lib/webchat/devices/scrollbar-controller.js.map +0 -1
  657. package/lib/webchat/devices/webchat-resizer.js +0 -76
  658. package/lib/webchat/devices/webchat-resizer.js.map +0 -1
  659. package/lib/webchat/header.js +0 -116
  660. package/lib/webchat/header.js.map +0 -1
  661. package/lib/webchat/hooks.js +0 -359
  662. package/lib/webchat/hooks.js.map +0 -1
  663. package/lib/webchat/index.d.ts +0 -62
  664. package/lib/webchat/index.js +0 -32
  665. package/lib/webchat/index.js.map +0 -1
  666. package/lib/webchat/message-list.js +0 -88
  667. package/lib/webchat/message-list.js.map +0 -1
  668. package/lib/webchat/messages-reducer.js +0 -93
  669. package/lib/webchat/messages-reducer.js.map +0 -1
  670. package/lib/webchat/replies.js +0 -78
  671. package/lib/webchat/replies.js.map +0 -1
  672. package/lib/webchat/session-view.js +0 -106
  673. package/lib/webchat/session-view.js.map +0 -1
  674. package/lib/webchat/use-storage-state-hook.js +0 -60
  675. package/lib/webchat/use-storage-state-hook.js.map +0 -1
  676. package/lib/webchat/webchat-dev.js +0 -109
  677. package/lib/webchat/webchat-dev.js.map +0 -1
  678. package/lib/webchat/webchat-reducer.js +0 -108
  679. package/lib/webchat/webchat-reducer.js.map +0 -1
  680. package/lib/webchat/webchat.js +0 -1108
  681. package/lib/webchat/webchat.js.map +0 -1
  682. package/lib/webchat/webview.js +0 -122
  683. package/lib/webchat/webview.js.map +0 -1
  684. package/lib/webchat-app.js +0 -660
  685. package/lib/webchat-app.js.map +0 -1
  686. package/lib/webview.js +0 -231
  687. package/lib/webview.js.map +0 -1
  688. /package/lib/{assets → cjs/assets}/attachment-icon.svg +0 -0
  689. /package/lib/{assets → cjs/assets}/audio.svg +0 -0
  690. /package/lib/{assets → cjs/assets}/botonic_react_logo100x100.png +0 -0
  691. /package/lib/{assets → cjs/assets}/document.svg +0 -0
  692. /package/lib/{assets → cjs/assets}/emojiButton.svg +0 -0
  693. /package/lib/{assets → cjs/assets}/image.svg +0 -0
  694. /package/lib/{assets → cjs/assets}/leftArrow.svg +0 -0
  695. /package/lib/{assets → cjs/assets}/menuButton.svg +0 -0
  696. /package/lib/{assets → cjs/assets}/rightArrow.svg +0 -0
  697. /package/lib/{assets → cjs/assets}/send-button.svg +0 -0
  698. /package/lib/{assets → cjs/assets}/video.svg +0 -0
  699. /package/lib/{webchat → cjs/webchat}/components/styled-scrollbar.scss +0 -0
  700. /package/lib/{webchat → cjs/webchat}/components/typing-indicator.scss +0 -0
  701. /package/lib/{webchat.template.html → cjs/webchat.template.html} +0 -0
  702. /package/lib/{webview.template.html → cjs/webview.template.html} +0 -0
@@ -0,0 +1,656 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { INPUT, isMobile, params2queryString } from '@botonic/core';
3
+ import merge from 'lodash.merge';
4
+ import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState, } from 'react';
5
+ import Textarea from 'react-textarea-autosize';
6
+ import styled, { StyleSheetManager } from 'styled-components';
7
+ import { useAsyncEffect } from 'use-async-effect';
8
+ import { v4 as uuidv4 } from 'uuid';
9
+ import { Audio, Document, Image, Text, Video } from '../components';
10
+ import { Handoff } from '../components/handoff';
11
+ import { normalizeWebchatSettings } from '../components/webchat-settings';
12
+ import { COLORS, MAX_ALLOWED_SIZE_MB, ROLES, SENDERS, WEBCHAT, } from '../constants';
13
+ import { RequestContext, WebchatContext } from '../contexts';
14
+ import { getFullMimeWhitelist, getMediaType, isAllowedSize, isAudio, isDocument, isImage, isMedia, isText, isVideo, readDataURL, } from '../message-utils';
15
+ import { msgToBotonic } from '../msg-to-botonic';
16
+ import { scrollToBottom } from '../util/dom';
17
+ import { isDev, resolveImage } from '../util/environment';
18
+ import { deserializeRegex, stringifyWithRegexs } from '../util/regexs';
19
+ import { _getThemeProperty, getServerErrorMessage, initSession, shouldKeepSessionOnReload, } from '../util/webchat';
20
+ import { Attachment } from './components/attachment';
21
+ import { EmojiPicker, OpenedEmojiPicker } from './components/emoji-picker';
22
+ import { OpenedPersistentMenu, PersistentMenu, } from './components/persistent-menu';
23
+ import { SendButton } from './components/send-button';
24
+ import { TypingIndicator } from './components/typing-indicator';
25
+ import { DeviceAdapter } from './devices/device-adapter';
26
+ import { StyledWebchatHeader } from './header';
27
+ import { useComponentWillMount, usePrevious, useTyping, useWebchat, } from './hooks';
28
+ import { WebchatMessageList } from './message-list';
29
+ import { WebchatReplies } from './replies';
30
+ import { useStorageState } from './use-storage-state-hook';
31
+ import { WebviewContainer } from './webview';
32
+ export const getParsedAction = botonicAction => {
33
+ const splittedAction = botonicAction.split('create_case:');
34
+ if (splittedAction.length <= 1)
35
+ return undefined;
36
+ return JSON.parse(splittedAction[1]);
37
+ };
38
+ const StyledWebchat = styled.div `
39
+ position: fixed;
40
+ right: 20px;
41
+ bottom: 20px;
42
+ width: ${props => props.width}px;
43
+ height: ${props => props.height}px;
44
+ margin: auto;
45
+ background-color: ${COLORS.SOLID_WHITE};
46
+ border-radius: 10px;
47
+ box-shadow: ${COLORS.SOLID_BLACK_ALPHA_0_2} 0px 0px 12px;
48
+ display: flex;
49
+ flex-direction: column;
50
+ `;
51
+ const StyledTriggerButton = styled.div `
52
+ cursor: pointer;
53
+ position: fixed;
54
+ background: ${COLORS.SOLID_WHITE};
55
+ border-radius: 50%;
56
+ display: flex;
57
+ align-items: center;
58
+ justify-content: center;
59
+ overflow: hidden;
60
+ width: 65px;
61
+ height: 65px;
62
+ bottom: 20px;
63
+ right: 10px;
64
+ padding: 8px;
65
+ `;
66
+ const UserInputContainer = styled.div `
67
+ min-height: 52px;
68
+ position: relative;
69
+ display: flex;
70
+ align-items: center;
71
+ justify-content: flex-start;
72
+ gap: 16px;
73
+ padding: 0px 16px;
74
+ z-index: 1;
75
+ border-top: 1px solid ${COLORS.SOLID_BLACK_ALPHA_0_5};
76
+ `;
77
+ const TextAreaContainer = styled.div `
78
+ display: flex;
79
+ flex: 1 1 auto;
80
+ align-items: center;
81
+ `;
82
+ const TriggerImage = styled.img `
83
+ max-width: 100%;
84
+ max-height: 100%;
85
+ `;
86
+ const ErrorMessageContainer = styled.div `
87
+ position: relative;
88
+ display: flex;
89
+ z-index: 1;
90
+ justify-content: center;
91
+ width: 100%;
92
+ `;
93
+ const ErrorMessage = styled.div `
94
+ position: absolute;
95
+ top: 10px;
96
+ font-size: 14px;
97
+ line-height: 20px;
98
+ padding: 4px 11px;
99
+ display: flex;
100
+ background-color: ${COLORS.ERROR_RED};
101
+ color: ${COLORS.CONCRETE_WHITE};
102
+ border-radius: 5px;
103
+ align-items: center;
104
+ justify-content: center;
105
+ font-family: ${WEBCHAT.DEFAULTS.FONT_FAMILY};
106
+ `;
107
+ const DarkBackgroundMenu = styled.div `
108
+ background: ${COLORS.SOLID_BLACK};
109
+ opacity: 0.3;
110
+ z-index: 1;
111
+ right: 0;
112
+ bottom: 0;
113
+ border-radius: 10px;
114
+ position: absolute;
115
+ width: 100%;
116
+ height: 100%;
117
+ `;
118
+ // eslint-disable-next-line complexity, react/display-name
119
+ export const Webchat = forwardRef((props, ref) => {
120
+ const { webchatState, addMessage, addMessageComponent, updateMessage, updateReplies, updateLatestInput, updateTyping, updateWebview, updateSession, updateLastRoutePath, updateHandoff, updateTheme, updateDevSettings, toggleWebchat, toggleEmojiPicker, togglePersistentMenu, toggleCoverComponent, doRenderCustomComponent, setError, setOnline, clearMessages, openWebviewT, closeWebviewT, updateLastMessageDate, setCurrentAttachment,
121
+ // eslint-disable-next-line react-hooks/rules-of-hooks
122
+ } = props.webchatHooks || useWebchat();
123
+ const firstUpdate = useRef(true);
124
+ const isOnline = () => webchatState.online;
125
+ const currentDateString = () => new Date().toISOString();
126
+ const theme = merge(webchatState.theme, props.theme);
127
+ const { initialSession, initialDevSettings, onStateChange } = props;
128
+ const getThemeProperty = _getThemeProperty(theme);
129
+ const [customComponent, setCustomComponent] = useState(null);
130
+ const storage = props.storage;
131
+ const storageKey = typeof props.storageKey === 'function'
132
+ ? props.storageKey()
133
+ : props.storageKey;
134
+ const [botonicState, saveState] = useStorageState(storage, storageKey);
135
+ const host = props.host || document.body;
136
+ const deviceAdapter = new DeviceAdapter();
137
+ const saveWebchatState = webchatState => {
138
+ storage &&
139
+ saveState(JSON.parse(stringifyWithRegexs({
140
+ messages: webchatState.messagesJSON,
141
+ session: webchatState.session,
142
+ lastRoutePath: webchatState.lastRoutePath,
143
+ devSettings: webchatState.devSettings,
144
+ lastMessageUpdate: webchatState.lastMessageUpdate,
145
+ themeUpdates: webchatState.themeUpdates,
146
+ })));
147
+ };
148
+ const handleAttachment = event => {
149
+ if (!isAllowedSize(event.target.files[0].size)) {
150
+ throw new Error(`The file is too large. A maximum of ${MAX_ALLOWED_SIZE_MB}MB is allowed.`);
151
+ }
152
+ setCurrentAttachment({
153
+ fileName: event.target.files[0].name,
154
+ file: event.target.files[0],
155
+ attachmentType: getMediaType(event.target.files[0].type),
156
+ });
157
+ };
158
+ useEffect(() => {
159
+ if (webchatState.currentAttachment)
160
+ sendAttachment(webchatState.currentAttachment);
161
+ }, [webchatState.currentAttachment]);
162
+ const sendUserInput = async (input) => {
163
+ props.onUserInput &&
164
+ props.onUserInput({
165
+ user: webchatState.session.user,
166
+ input: input,
167
+ session: webchatState.session,
168
+ lastRoutePath: webchatState.lastRoutePath,
169
+ });
170
+ };
171
+ const sendChatEvent = async (chatEvent) => {
172
+ const chatEventInput = {
173
+ id: uuidv4(),
174
+ type: INPUT.CHAT_EVENT,
175
+ data: chatEvent,
176
+ };
177
+ props.onUserInput &&
178
+ props.onUserInput({
179
+ user: webchatState.session.user,
180
+ input: chatEventInput,
181
+ session: webchatState.session,
182
+ lastRoutePath: webchatState.lastRoutePath,
183
+ });
184
+ };
185
+ // Load styles stored in window._botonicInsertStyles by Webpack
186
+ useComponentWillMount(() => {
187
+ if (window._botonicInsertStyles && window._botonicInsertStyles.length) {
188
+ for (const botonicStyle of window._botonicInsertStyles) {
189
+ // Injecting styles at head is needed even if we use shadowDOM
190
+ // as some dependencies like simplebar rely on creating ephemeral elements
191
+ // on document.body and assume styles will be available globally
192
+ document.head.appendChild(botonicStyle);
193
+ // injecting styles in host node too so that shadowDOM works
194
+ if (props.shadowDOM)
195
+ host.appendChild(botonicStyle.cloneNode(true));
196
+ }
197
+ delete window._botonicInsertStyles;
198
+ }
199
+ if (props.shadowDOM) {
200
+ // emoji-picker-react injects styles in head, so we need to
201
+ // re-inject them in our host node to make it work with shadowDOM
202
+ for (const style of document.querySelectorAll('style')) {
203
+ if (style.textContent &&
204
+ style.textContent.includes('emoji-picker-react'))
205
+ host.appendChild(style.cloneNode(true));
206
+ }
207
+ }
208
+ });
209
+ // Load initial state from storage
210
+ useEffect(() => {
211
+ let { messages, session, lastRoutePath, devSettings, lastMessageUpdate, themeUpdates, } = botonicState || {};
212
+ session = initSession(session);
213
+ updateSession(session);
214
+ if (shouldKeepSessionOnReload({ initialDevSettings, devSettings })) {
215
+ if (messages) {
216
+ messages.forEach(m => {
217
+ addMessage(m);
218
+ const newComponent = msgToBotonic(Object.assign(Object.assign({}, m), { delay: 0, typing: 0 }), (props.theme.message && props.theme.message.customTypes) ||
219
+ props.theme.customMessageTypes);
220
+ if (newComponent)
221
+ addMessageComponent(newComponent);
222
+ });
223
+ }
224
+ if (initialSession)
225
+ updateSession(merge(initialSession, session));
226
+ if (lastRoutePath)
227
+ updateLastRoutePath(lastRoutePath);
228
+ }
229
+ else
230
+ updateSession(merge(initialSession, session));
231
+ if (devSettings)
232
+ updateDevSettings(devSettings);
233
+ else if (initialDevSettings)
234
+ updateDevSettings(initialDevSettings);
235
+ if (lastMessageUpdate)
236
+ updateLastMessageDate(lastMessageUpdate);
237
+ if (themeUpdates !== undefined)
238
+ updateTheme(merge(props.theme, themeUpdates), themeUpdates);
239
+ if (props.onInit)
240
+ setTimeout(() => props.onInit(), 100);
241
+ }, []);
242
+ useEffect(() => {
243
+ if (!webchatState.isWebchatOpen)
244
+ return;
245
+ deviceAdapter.init(host);
246
+ scrollToBottom({ behavior: 'auto', host });
247
+ }, [webchatState.isWebchatOpen]);
248
+ useEffect(() => {
249
+ if (onStateChange && typeof onStateChange === 'function')
250
+ onStateChange(webchatState);
251
+ saveWebchatState(webchatState);
252
+ }, [
253
+ webchatState.messagesJSON,
254
+ webchatState.session,
255
+ webchatState.lastRoutePath,
256
+ webchatState.devSettings,
257
+ webchatState.lastMessageUpdate,
258
+ ]);
259
+ useAsyncEffect(async () => {
260
+ if (!webchatState.online) {
261
+ setError({
262
+ message: getServerErrorMessage(props.server),
263
+ });
264
+ }
265
+ else {
266
+ if (!firstUpdate.current) {
267
+ setError(undefined);
268
+ }
269
+ }
270
+ }, [webchatState.online]);
271
+ useTyping({ webchatState, updateTyping, updateMessage, host });
272
+ useEffect(() => {
273
+ updateTheme(merge(props.theme, theme, webchatState.themeUpdates));
274
+ }, [props.theme, webchatState.themeUpdates]);
275
+ const openWebview = (webviewComponent, params) => updateWebview(webviewComponent, params);
276
+ const handleSelectedEmoji = event => {
277
+ textArea.current.value += event.emoji;
278
+ textArea.current.focus();
279
+ };
280
+ const closeWebview = options => {
281
+ updateWebview();
282
+ if (userInputEnabled) {
283
+ textArea.current.focus();
284
+ }
285
+ if (options && options.payload) {
286
+ sendPayload(options.payload);
287
+ }
288
+ else if (options && options.path) {
289
+ let params = '';
290
+ if (options.params)
291
+ params = params2queryString(options.params);
292
+ sendPayload(`__PATH_PAYLOAD__${options.path}?${params}`);
293
+ }
294
+ };
295
+ const handleMenu = () => {
296
+ togglePersistentMenu(!webchatState.isPersistentMenuOpen);
297
+ };
298
+ const handleEmojiClick = () => {
299
+ toggleEmojiPicker(!webchatState.isEmojiPickerOpen);
300
+ };
301
+ const persistentMenuOptions = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.persistentMenu, props.persistentMenu);
302
+ const darkBackgroundMenu = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.darkBackgroundMenu, false);
303
+ const getBlockInputs = (rule, inputData) => {
304
+ const processedInput = rule.preprocess
305
+ ? rule.preprocess(inputData)
306
+ : inputData;
307
+ return rule.match.some(regex => {
308
+ if (typeof regex === 'string')
309
+ regex = deserializeRegex(regex);
310
+ return regex.test(processedInput);
311
+ });
312
+ };
313
+ const checkBlockInput = input => {
314
+ // if is a text we check if it is a serialized RE
315
+ const blockInputs = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.blockInputs, props.blockInputs);
316
+ if (!Array.isArray(blockInputs))
317
+ return false;
318
+ for (const rule of blockInputs) {
319
+ if (getBlockInputs(rule, input.data)) {
320
+ addMessageComponent(_jsx(Text, Object.assign({ id: input.id, from: SENDERS.user, blob: false, style: {
321
+ backgroundColor: COLORS.SCORPION_GRAY,
322
+ borderColor: COLORS.SCORPION_GRAY,
323
+ padding: '8px 12px',
324
+ } }, { children: rule.message })));
325
+ updateReplies(false);
326
+ return true;
327
+ }
328
+ }
329
+ return false;
330
+ };
331
+ const closeMenu = () => {
332
+ togglePersistentMenu(false);
333
+ };
334
+ const persistentMenu = () => {
335
+ return (_jsx(OpenedPersistentMenu, { onClick: closeMenu, options: persistentMenuOptions, borderRadius: webchatState.theme.style.borderRadius || '10px' }));
336
+ };
337
+ const getCoverComponent = () => {
338
+ return getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.coverComponent, props.coverComponent &&
339
+ (props.coverComponent.component || props.coverComponent));
340
+ };
341
+ const CoverComponent = getCoverComponent();
342
+ const closeCoverComponent = () => {
343
+ toggleCoverComponent(false);
344
+ };
345
+ useEffect(() => {
346
+ if (!CoverComponent)
347
+ return;
348
+ if (!botonicState ||
349
+ (botonicState.messages && botonicState.messages.length == 0))
350
+ toggleCoverComponent(true);
351
+ }, []);
352
+ const coverComponent = () => {
353
+ const coverComponentProps = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.coverComponentProps, props.coverComponent && props.coverComponent.props);
354
+ if (CoverComponent && webchatState.isCoverComponentOpen)
355
+ return (_jsx(CoverComponent, Object.assign({ closeComponent: closeCoverComponent }, coverComponentProps)));
356
+ return null;
357
+ };
358
+ const messageComponentFromInput = input => {
359
+ let messageComponent = null;
360
+ if (isText(input)) {
361
+ messageComponent = (_jsx(Text, Object.assign({ id: input.id, payload: input.payload, from: SENDERS.user }, { children: input.data })));
362
+ }
363
+ else if (isMedia(input)) {
364
+ const temporaryDisplayUrl = URL.createObjectURL(input.data);
365
+ const mediaProps = {
366
+ id: input.id,
367
+ from: SENDERS.user,
368
+ src: temporaryDisplayUrl,
369
+ };
370
+ if (isImage(input))
371
+ messageComponent = _jsx(Image, Object.assign({}, mediaProps));
372
+ else if (isAudio(input))
373
+ messageComponent = _jsx(Audio, Object.assign({}, mediaProps));
374
+ else if (isVideo(input))
375
+ messageComponent = _jsx(Video, Object.assign({}, mediaProps));
376
+ else if (isDocument(input))
377
+ messageComponent = _jsx(Document, Object.assign({}, mediaProps));
378
+ }
379
+ return messageComponent;
380
+ };
381
+ const sendInput = async (input) => {
382
+ if (!input || Object.keys(input).length == 0)
383
+ return;
384
+ if (isText(input) && (!input.data || !input.data.trim()))
385
+ return; // in case trim() doesn't work in a browser we can use !/\S/.test(input.data)
386
+ if (isText(input) && checkBlockInput(input))
387
+ return;
388
+ if (!input.id)
389
+ input.id = uuidv4();
390
+ const messageComponent = messageComponentFromInput(input);
391
+ if (messageComponent)
392
+ addMessageComponent(messageComponent);
393
+ if (isMedia(input))
394
+ input.data = await readDataURL(input.data);
395
+ sendUserInput(input);
396
+ updateLatestInput(input);
397
+ isOnline() && updateLastMessageDate(currentDateString());
398
+ updateReplies(false);
399
+ togglePersistentMenu(false);
400
+ toggleEmojiPicker(false);
401
+ };
402
+ /* This is the public API this component exposes to its parents
403
+ https://stackoverflow.com/questions/37949981/call-child-method-from-parent
404
+ */
405
+ const updateSessionWithUser = userToUpdate => updateSession(merge(webchatState.session, { user: userToUpdate }));
406
+ useImperativeHandle(ref, () => ({
407
+ addBotResponse: ({ response, session, lastRoutePath }) => {
408
+ updateTyping(false);
409
+ if (Array.isArray(response))
410
+ response.map(r => addMessageComponent(r));
411
+ else if (response)
412
+ addMessageComponent(response);
413
+ if (session) {
414
+ updateSession(merge(session, { user: webchatState.session.user }));
415
+ const action = session._botonic_action || '';
416
+ const handoff = action.startsWith('create_case');
417
+ if (handoff && isDev)
418
+ addMessageComponent(_jsx(Handoff, {}));
419
+ updateHandoff(handoff);
420
+ }
421
+ if (lastRoutePath)
422
+ updateLastRoutePath(lastRoutePath);
423
+ updateLastMessageDate(currentDateString());
424
+ },
425
+ setTyping: typing => updateTyping(typing),
426
+ addUserMessage: message => sendInput(message),
427
+ updateUser: updateSessionWithUser,
428
+ openWebchat: () => toggleWebchat(true),
429
+ closeWebchat: () => toggleWebchat(false),
430
+ toggleWebchat: () => toggleWebchat(!webchatState.isWebchatOpen),
431
+ openCoverComponent: () => toggleCoverComponent(true),
432
+ closeCoverComponent: () => toggleCoverComponent(false),
433
+ renderCustomComponent: _customComponent => {
434
+ setCustomComponent(_customComponent);
435
+ doRenderCustomComponent(true);
436
+ },
437
+ unmountCustomComponent: () => doRenderCustomComponent(false),
438
+ toggleCoverComponent: () => toggleCoverComponent(!webchatState.isCoverComponentOpen),
439
+ openWebviewApi: component => openWebviewT(component),
440
+ setError,
441
+ setOnline,
442
+ getMessages: () => webchatState.messagesJSON,
443
+ isOnline,
444
+ clearMessages: () => {
445
+ clearMessages();
446
+ updateReplies(false);
447
+ },
448
+ getLastMessageUpdate: () => webchatState.lastMessageUpdate,
449
+ updateMessageInfo: (msgId, messageInfo) => {
450
+ const messageToUpdate = webchatState.messagesJSON.filter(m => m.id == msgId)[0];
451
+ const updatedMsg = merge(messageToUpdate, messageInfo);
452
+ if (updatedMsg.ack === 1)
453
+ delete updatedMsg.unsentInput;
454
+ updateMessage(updatedMsg);
455
+ },
456
+ updateWebchatSettings: settings => {
457
+ const themeUpdates = normalizeWebchatSettings(settings);
458
+ updateTheme(merge(webchatState.theme, themeUpdates), themeUpdates);
459
+ },
460
+ }));
461
+ const resolveCase = () => {
462
+ updateHandoff(false);
463
+ updateSession(Object.assign(Object.assign({}, webchatState.session), { _botonic_action: null }));
464
+ };
465
+ const prevSession = usePrevious(webchatState.session);
466
+ useEffect(() => {
467
+ // Resume conversation after handoff
468
+ if (prevSession &&
469
+ prevSession._botonic_action &&
470
+ !webchatState.session._botonic_action) {
471
+ const action = getParsedAction(prevSession._botonic_action);
472
+ if (action && action.on_finish)
473
+ sendPayload(action.on_finish);
474
+ }
475
+ }, [webchatState.session._botonic_action]);
476
+ const sendText = async (text, payload) => {
477
+ if (!text)
478
+ return;
479
+ const input = { type: INPUT.TEXT, data: text, payload };
480
+ await sendInput(input);
481
+ };
482
+ const sendPayload = async (payload) => {
483
+ if (!payload)
484
+ return;
485
+ const input = { type: INPUT.POSTBACK, payload };
486
+ await sendInput(input);
487
+ };
488
+ const sendAttachment = async (attachment) => {
489
+ if (attachment.file) {
490
+ const attachmentType = getMediaType(attachment.file.type);
491
+ if (!attachmentType)
492
+ return;
493
+ const input = {
494
+ type: attachmentType,
495
+ data: attachment.file,
496
+ };
497
+ await sendInput(input);
498
+ setCurrentAttachment(undefined);
499
+ }
500
+ };
501
+ const sendTextAreaText = () => {
502
+ sendText(textArea.current.value);
503
+ textArea.current.value = '';
504
+ };
505
+ let isTyping = false;
506
+ let typingTimeout = null;
507
+ function clearTimeoutWithReset(reset) {
508
+ const waitTime = 20 * 1000;
509
+ if (typingTimeout)
510
+ clearTimeout(typingTimeout);
511
+ if (reset)
512
+ typingTimeout = setTimeout(stopTyping, waitTime);
513
+ }
514
+ function startTyping() {
515
+ isTyping = true;
516
+ sendChatEvent('typing_on');
517
+ }
518
+ function stopTyping() {
519
+ clearTimeoutWithReset(false);
520
+ isTyping = false;
521
+ sendChatEvent('typing_off');
522
+ }
523
+ const onKeyDown = event => {
524
+ if (event.keyCode === 13 && event.shiftKey === false) {
525
+ event.preventDefault();
526
+ sendTextAreaText();
527
+ stopTyping();
528
+ }
529
+ };
530
+ const onKeyUp = () => {
531
+ if (textArea.current.value === '') {
532
+ stopTyping();
533
+ return;
534
+ }
535
+ if (!isTyping) {
536
+ startTyping();
537
+ }
538
+ clearTimeoutWithReset(true);
539
+ };
540
+ const webviewRequestContext = {
541
+ getString: stringId => props.getString(stringId, webchatState.session),
542
+ setLocale: locale => props.getString(locale, webchatState.session),
543
+ session: webchatState.session || {},
544
+ params: webchatState.webviewParams || {},
545
+ closeWebview: closeWebview,
546
+ defaultDelay: props.defaultDelay || 0,
547
+ defaultTyping: props.defaultTyping || 0,
548
+ };
549
+ useEffect(() => {
550
+ if (firstUpdate.current) {
551
+ firstUpdate.current = false;
552
+ return;
553
+ }
554
+ if (webchatState.isWebchatOpen && props.onOpen)
555
+ props.onOpen();
556
+ if (!webchatState.isWebchatOpen && props.onClose && !firstUpdate.current) {
557
+ props.onClose();
558
+ toggleEmojiPicker(false);
559
+ togglePersistentMenu(false);
560
+ }
561
+ }, [webchatState.isWebchatOpen]);
562
+ const getTriggerImage = () => {
563
+ const triggerImage = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.triggerButtonImage, null);
564
+ if (triggerImage === null) {
565
+ webchatState.theme.triggerButtonImage = WEBCHAT.DEFAULTS.LOGO;
566
+ return null;
567
+ }
568
+ return triggerImage;
569
+ };
570
+ const triggerButtonStyle = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.triggerButtonStyle);
571
+ const CustomTriggerButton = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.customTrigger, undefined);
572
+ const triggerButton = () => {
573
+ if (CustomTriggerButton) {
574
+ return _jsx(CustomTriggerButton, {});
575
+ }
576
+ return (_jsx(StyledTriggerButton, Object.assign({ role: ROLES.TRIGGER_BUTTON, style: Object.assign({}, triggerButtonStyle) }, { children: getTriggerImage() && (_jsx(TriggerImage, { src: resolveImage(getTriggerImage()) })) })));
577
+ };
578
+ const webchatMessageList = () => (_jsx(WebchatMessageList, Object.assign({ style: { flex: 1 } }, { children: webchatState.typing && _jsx(TypingIndicator, {}) })));
579
+ const webchatReplies = () => _jsx(WebchatReplies, { replies: webchatState.replies });
580
+ const isUserInputEnabled = () => {
581
+ const isUserInputEnabled = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.enableUserInput, props.enableUserInput !== undefined ? props.enableUserInput : true);
582
+ return isUserInputEnabled && !webchatState.isCoverComponentOpen;
583
+ };
584
+ const userInputEnabled = isUserInputEnabled();
585
+ const textArea = useRef(null);
586
+ const userInputArea = () => {
587
+ return (userInputEnabled && (_jsxs(UserInputContainer, Object.assign({ style: Object.assign({}, getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.userInputStyle)), className: 'user-input-container' }, { children: [webchatState.isEmojiPickerOpen && (_jsx(OpenedEmojiPicker, { height: webchatState.theme.style.height, onEmojiClick: handleSelectedEmoji, onClick: handleEmojiClick })), _jsx(PersistentMenu, { onClick: handleMenu, persistentMenu: props.persistentMenu }), _jsx(TextAreaContainer, { children: _jsx(Textarea, { inputRef: textArea, name: 'text', onFocus: () => deviceAdapter.onFocus(host), onBlur: () => deviceAdapter.onBlur(), maxRows: 4, wrap: 'soft', maxLength: '1000', placeholder: getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.textPlaceholder, WEBCHAT.DEFAULTS.PLACEHOLDER), autoFocus: true, onKeyDown: e => onKeyDown(e), onKeyUp: onKeyUp, style: Object.assign({ display: 'flex', fontSize: deviceAdapter.fontSize(14), width: '100%', border: 'none', resize: 'none', overflow: 'auto', outline: 'none', flex: '1 1 auto', padding: 10, paddingLeft: persistentMenuOptions ? 0 : 10, fontFamily: 'inherit' }, getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.userInputBoxStyle)) }) }), _jsx(EmojiPicker, { enableEmojiPicker: props.enableEmojiPicker, onClick: handleEmojiClick }), _jsx(Attachment, { enableAttachments: props.enableAttachments, onChange: handleAttachment, accept: getFullMimeWhitelist().join(',') }), _jsx(SendButton, { onClick: sendTextAreaText })] }))));
588
+ };
589
+ const webchatWebview = () => (_jsx(RequestContext.Provider, Object.assign({ value: webviewRequestContext }, { children: _jsx(WebviewContainer, { style: Object.assign(Object.assign({}, getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.webviewStyle)), mobileStyle), webview: webchatState.webview }) })));
590
+ let mobileStyle = {};
591
+ if (isMobile(getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileBreakpoint))) {
592
+ mobileStyle = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileStyle) || {
593
+ width: '100%',
594
+ height: '100%',
595
+ right: 0,
596
+ bottom: 0,
597
+ borderRadius: 0,
598
+ };
599
+ }
600
+ useEffect(() => {
601
+ // Prod mode
602
+ saveWebchatState(webchatState);
603
+ scrollToBottom({ host });
604
+ }, [webchatState.themeUpdates]);
605
+ // Only needed for dev/serve mode
606
+ const updateWebchatDevSettings = settings => {
607
+ // eslint-disable-next-line react-hooks/rules-of-hooks
608
+ useEffect(() => {
609
+ const themeUpdates = normalizeWebchatSettings(settings);
610
+ updateTheme(merge(webchatState.theme, themeUpdates), themeUpdates);
611
+ }, [webchatState.messagesJSON]);
612
+ };
613
+ const DarkenBackground = ({ component }) => {
614
+ return (_jsxs("div", { children: [darkBackgroundMenu && (_jsx(DarkBackgroundMenu, { style: {
615
+ borderRadius: webchatState.theme.style.borderRadius,
616
+ } })), component] }));
617
+ };
618
+ const _renderCustomComponent = () => {
619
+ if (!customComponent)
620
+ return _jsx(_Fragment, {});
621
+ else
622
+ return customComponent;
623
+ };
624
+ const WebchatComponent = (_jsxs(WebchatContext.Provider, Object.assign({ value: {
625
+ sendText,
626
+ sendAttachment,
627
+ sendPayload,
628
+ sendInput,
629
+ openWebview,
630
+ resolveCase,
631
+ webchatState,
632
+ getThemeProperty,
633
+ addMessage,
634
+ toggleWebchat,
635
+ updateMessage,
636
+ updateReplies,
637
+ updateLatestInput,
638
+ updateUser: updateSessionWithUser,
639
+ updateWebchatDevSettings: updateWebchatDevSettings,
640
+ } }, { children: [!webchatState.isWebchatOpen && (_jsx("div", Object.assign({ onClick: event => {
641
+ toggleWebchat(true);
642
+ event.preventDefault();
643
+ } }, { children: triggerButton() }))), webchatState.isWebchatOpen && (_jsxs(StyledWebchat
644
+ // TODO: Distinguis between multiple instances of webchat, e.g. `${uniqueId}-botonic-webchat`
645
+ , Object.assign({
646
+ // TODO: Distinguis between multiple instances of webchat, e.g. `${uniqueId}-botonic-webchat`
647
+ role: ROLES.WEBCHAT, id: WEBCHAT.DEFAULTS.ID, width: webchatState.width, height: webchatState.height, style: Object.assign(Object.assign({}, webchatState.theme.style), mobileStyle) }, { children: [_jsx(StyledWebchatHeader, { onCloseClick: () => {
648
+ toggleWebchat(false);
649
+ } }), webchatState.error.message && (_jsx(ErrorMessageContainer, { children: _jsx(ErrorMessage, { children: webchatState.error.message }) })), webchatMessageList(), webchatState.replies &&
650
+ Object.keys(webchatState.replies).length > 0 &&
651
+ webchatReplies(), webchatState.isPersistentMenuOpen && (_jsx(DarkenBackground, { component: persistentMenu() })), !webchatState.handoff && userInputArea(), webchatState.webview && webchatWebview(), webchatState.isCoverComponentOpen && coverComponent(), webchatState.isCustomComponentRendered &&
652
+ customComponent &&
653
+ _renderCustomComponent()] })))] })));
654
+ return props.shadowDOM ? (_jsx(StyleSheetManager, Object.assign({ target: host }, { children: WebchatComponent }))) : (WebchatComponent);
655
+ });
656
+ //# sourceMappingURL=webchat.js.map