@botonic/plugin-flow-builder 0.57.0-rslib-esm.0 → 0.57.0-rslib-esm.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 (383) hide show
  1. package/README.md +1 -1
  2. package/lib/action/ai-agent-from-user-input.js.map +1 -0
  3. package/lib/action/context.js.map +1 -0
  4. package/lib/action/fallback.js.map +1 -0
  5. package/lib/action/first-interaction.js.map +1 -0
  6. package/lib/action/get-contents.js.map +1 -0
  7. package/lib/action/index.js.map +1 -0
  8. package/lib/action/payload.js.map +1 -0
  9. package/lib/api.js.map +1 -0
  10. package/lib/constants.js.map +1 -0
  11. package/lib/content-fields/content-fields-base.js.map +1 -0
  12. package/lib/content-fields/custom-conditional/custom-conditional-v2-evaluators.js.map +1 -0
  13. package/lib/content-fields/custom-conditional/custom-conditional-v2-resolver.js.map +1 -0
  14. package/lib/{esm/content-fields → content-fields}/custom-conditional/flow-custom-condition-v2.d.ts +1 -1
  15. package/lib/content-fields/custom-conditional/flow-custom-condition-v2.js.map +1 -0
  16. package/lib/{esm/content-fields → content-fields}/flow-ai-agent-base.js +6 -0
  17. package/lib/content-fields/flow-ai-agent-base.js.map +1 -0
  18. package/lib/content-fields/flow-ai-agent-router.js.map +1 -0
  19. package/lib/content-fields/flow-ai-agent.js.map +1 -0
  20. package/lib/content-fields/flow-bot-action.js.map +1 -0
  21. package/lib/content-fields/flow-button.js.map +1 -0
  22. package/lib/content-fields/flow-capture-user-input.js.map +1 -0
  23. package/lib/content-fields/flow-carousel.js.map +1 -0
  24. package/lib/content-fields/flow-channel-conditional.js.map +1 -0
  25. package/lib/content-fields/flow-country-conditional.js.map +1 -0
  26. package/lib/{esm/content-fields → content-fields}/flow-custom-conditional.d.ts +1 -1
  27. package/lib/content-fields/flow-custom-conditional.js.map +1 -0
  28. package/lib/content-fields/flow-element.js.map +1 -0
  29. package/lib/content-fields/flow-go-to-flow.js.map +1 -0
  30. package/lib/content-fields/flow-handoff.js.map +1 -0
  31. package/lib/content-fields/flow-image.js.map +1 -0
  32. package/lib/content-fields/flow-queue-status-conditional.js.map +1 -0
  33. package/lib/content-fields/flow-rating.js.map +1 -0
  34. package/lib/content-fields/flow-text.js.map +1 -0
  35. package/lib/content-fields/flow-video.js.map +1 -0
  36. package/lib/content-fields/flow-webview.js.map +1 -0
  37. package/lib/content-fields/flow-whatsapp-cta-url-button.js.map +1 -0
  38. package/lib/{esm/content-fields → content-fields}/flow-whatsapp-request-contact-info.d.ts +2 -1
  39. package/lib/{esm/content-fields → content-fields}/flow-whatsapp-request-contact-info.js +10 -0
  40. package/lib/content-fields/flow-whatsapp-request-contact-info.js.map +1 -0
  41. package/lib/content-fields/flow-whatsapp-template.js.map +1 -0
  42. package/lib/content-fields/hubtype-fields/ai-agent-router.js.map +1 -0
  43. package/lib/content-fields/hubtype-fields/ai-agent.js.map +1 -0
  44. package/lib/content-fields/hubtype-fields/bot-action.js.map +1 -0
  45. package/lib/content-fields/hubtype-fields/button.js.map +1 -0
  46. package/lib/content-fields/hubtype-fields/capture-user-input.js.map +1 -0
  47. package/lib/content-fields/hubtype-fields/carousel.js.map +1 -0
  48. package/lib/content-fields/hubtype-fields/channel-conditional.js.map +1 -0
  49. package/lib/content-fields/hubtype-fields/common.js.map +1 -0
  50. package/lib/content-fields/hubtype-fields/country-conditional.js.map +1 -0
  51. package/lib/content-fields/hubtype-fields/custom-conditional-v2.js.map +1 -0
  52. package/lib/content-fields/hubtype-fields/custom-conditional.js.map +1 -0
  53. package/lib/content-fields/hubtype-fields/fallback.js.map +1 -0
  54. package/lib/content-fields/hubtype-fields/function.js.map +1 -0
  55. package/lib/content-fields/hubtype-fields/go-to-flow.js.map +1 -0
  56. package/lib/content-fields/hubtype-fields/handoff.js.map +1 -0
  57. package/lib/content-fields/hubtype-fields/image.js.map +1 -0
  58. package/lib/content-fields/hubtype-fields/index.js.map +1 -0
  59. package/lib/content-fields/hubtype-fields/keyword.js.map +1 -0
  60. package/lib/content-fields/hubtype-fields/node-types.js.map +1 -0
  61. package/lib/content-fields/hubtype-fields/nodes.js.map +1 -0
  62. package/lib/content-fields/hubtype-fields/payload.js.map +1 -0
  63. package/lib/content-fields/hubtype-fields/queue-status-conditional.js.map +1 -0
  64. package/lib/content-fields/hubtype-fields/rating.js.map +1 -0
  65. package/lib/content-fields/hubtype-fields/smart-intent.js.map +1 -0
  66. package/lib/content-fields/hubtype-fields/text.js.map +1 -0
  67. package/lib/content-fields/hubtype-fields/url.js.map +1 -0
  68. package/lib/content-fields/hubtype-fields/video.js.map +1 -0
  69. package/lib/content-fields/hubtype-fields/webview.js.map +1 -0
  70. package/lib/content-fields/hubtype-fields/whatsapp-button-list.js.map +1 -0
  71. package/lib/content-fields/hubtype-fields/whatsapp-cta-url-button.js.map +1 -0
  72. package/lib/content-fields/hubtype-fields/whatsapp-request-contact-info.js.map +1 -0
  73. package/lib/content-fields/hubtype-fields/whatsapp-template.js.map +1 -0
  74. package/lib/{esm/content-fields → content-fields}/index.d.ts +1 -1
  75. package/lib/content-fields/index.js.map +1 -0
  76. package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +1 -0
  77. package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +1 -0
  78. package/lib/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +1 -0
  79. package/lib/content-fields/whatsapp-button-list/index.js.map +1 -0
  80. package/lib/filters/index.js.map +1 -0
  81. package/lib/flow-factory.js.map +1 -0
  82. package/lib/functions/index.js.map +1 -0
  83. package/lib/index.js.map +1 -0
  84. package/lib/services/hubtype-queues-api.js.map +1 -0
  85. package/lib/structured-output/flow-builder-content.js.map +1 -0
  86. package/lib/tracking.js.map +1 -0
  87. package/lib/types.js.map +1 -0
  88. package/lib/user-input/capture-user-input-api.js.map +1 -0
  89. package/lib/user-input/index.js.map +1 -0
  90. package/lib/user-input/keyword.js.map +1 -0
  91. package/lib/user-input/smart-intent.js.map +1 -0
  92. package/lib/utils/ai-agent.js.map +1 -0
  93. package/lib/utils/authentication.js.map +1 -0
  94. package/lib/utils/flow-locale.js.map +1 -0
  95. package/lib/utils/get-flow-builder-plugin.js.map +1 -0
  96. package/lib/{esm/utils → utils}/hubtype-assistant-content.d.ts +1 -0
  97. package/lib/{esm/utils → utils}/hubtype-assistant-content.js +13 -0
  98. package/lib/utils/hubtype-assistant-content.js.map +1 -0
  99. package/lib/utils/input.js.map +1 -0
  100. package/lib/webview/contents-context.js.map +1 -0
  101. package/lib/webview/index.js.map +1 -0
  102. package/lib/webview/types.js.map +1 -0
  103. package/lib/webview/use-webview-contents.js.map +1 -0
  104. package/package.json +9 -8
  105. package/src/content-fields/flow-ai-agent-base.tsx +11 -0
  106. package/src/content-fields/flow-whatsapp-request-contact-info.tsx +17 -1
  107. package/src/content-fields/index.ts +2 -2
  108. package/src/utils/hubtype-assistant-content.ts +14 -0
  109. package/lib/esm/action/ai-agent-from-user-input.js.map +0 -1
  110. package/lib/esm/action/context.js.map +0 -1
  111. package/lib/esm/action/fallback.js.map +0 -1
  112. package/lib/esm/action/first-interaction.js.map +0 -1
  113. package/lib/esm/action/get-contents.js.map +0 -1
  114. package/lib/esm/action/index.js.map +0 -1
  115. package/lib/esm/action/payload.js.map +0 -1
  116. package/lib/esm/api.js.map +0 -1
  117. package/lib/esm/constants.js.map +0 -1
  118. package/lib/esm/content-fields/content-fields-base.js.map +0 -1
  119. package/lib/esm/content-fields/custom-conditional/custom-conditional-v2-evaluators.js.map +0 -1
  120. package/lib/esm/content-fields/custom-conditional/custom-conditional-v2-resolver.js.map +0 -1
  121. package/lib/esm/content-fields/custom-conditional/flow-custom-condition-v2.js.map +0 -1
  122. package/lib/esm/content-fields/flow-ai-agent-base.js.map +0 -1
  123. package/lib/esm/content-fields/flow-ai-agent-router.js.map +0 -1
  124. package/lib/esm/content-fields/flow-ai-agent.js.map +0 -1
  125. package/lib/esm/content-fields/flow-bot-action.js.map +0 -1
  126. package/lib/esm/content-fields/flow-button.js.map +0 -1
  127. package/lib/esm/content-fields/flow-capture-user-input.js.map +0 -1
  128. package/lib/esm/content-fields/flow-carousel.js.map +0 -1
  129. package/lib/esm/content-fields/flow-channel-conditional.js.map +0 -1
  130. package/lib/esm/content-fields/flow-country-conditional.js.map +0 -1
  131. package/lib/esm/content-fields/flow-custom-conditional.js.map +0 -1
  132. package/lib/esm/content-fields/flow-element.js.map +0 -1
  133. package/lib/esm/content-fields/flow-go-to-flow.js.map +0 -1
  134. package/lib/esm/content-fields/flow-handoff.js.map +0 -1
  135. package/lib/esm/content-fields/flow-image.js.map +0 -1
  136. package/lib/esm/content-fields/flow-queue-status-conditional.js.map +0 -1
  137. package/lib/esm/content-fields/flow-rating.js.map +0 -1
  138. package/lib/esm/content-fields/flow-text.js.map +0 -1
  139. package/lib/esm/content-fields/flow-video.js.map +0 -1
  140. package/lib/esm/content-fields/flow-webview.js.map +0 -1
  141. package/lib/esm/content-fields/flow-whatsapp-cta-url-button.js.map +0 -1
  142. package/lib/esm/content-fields/flow-whatsapp-request-contact-info.js.map +0 -1
  143. package/lib/esm/content-fields/flow-whatsapp-template.js.map +0 -1
  144. package/lib/esm/content-fields/hubtype-fields/ai-agent-router.js.map +0 -1
  145. package/lib/esm/content-fields/hubtype-fields/ai-agent.js.map +0 -1
  146. package/lib/esm/content-fields/hubtype-fields/bot-action.js.map +0 -1
  147. package/lib/esm/content-fields/hubtype-fields/button.js.map +0 -1
  148. package/lib/esm/content-fields/hubtype-fields/capture-user-input.js.map +0 -1
  149. package/lib/esm/content-fields/hubtype-fields/carousel.js.map +0 -1
  150. package/lib/esm/content-fields/hubtype-fields/channel-conditional.js.map +0 -1
  151. package/lib/esm/content-fields/hubtype-fields/common.js.map +0 -1
  152. package/lib/esm/content-fields/hubtype-fields/country-conditional.js.map +0 -1
  153. package/lib/esm/content-fields/hubtype-fields/custom-conditional-v2.js.map +0 -1
  154. package/lib/esm/content-fields/hubtype-fields/custom-conditional.js.map +0 -1
  155. package/lib/esm/content-fields/hubtype-fields/fallback.js.map +0 -1
  156. package/lib/esm/content-fields/hubtype-fields/function.js.map +0 -1
  157. package/lib/esm/content-fields/hubtype-fields/go-to-flow.js.map +0 -1
  158. package/lib/esm/content-fields/hubtype-fields/handoff.js.map +0 -1
  159. package/lib/esm/content-fields/hubtype-fields/image.js.map +0 -1
  160. package/lib/esm/content-fields/hubtype-fields/index.js.map +0 -1
  161. package/lib/esm/content-fields/hubtype-fields/keyword.js.map +0 -1
  162. package/lib/esm/content-fields/hubtype-fields/node-types.js.map +0 -1
  163. package/lib/esm/content-fields/hubtype-fields/nodes.js.map +0 -1
  164. package/lib/esm/content-fields/hubtype-fields/payload.js.map +0 -1
  165. package/lib/esm/content-fields/hubtype-fields/queue-status-conditional.js.map +0 -1
  166. package/lib/esm/content-fields/hubtype-fields/rating.js.map +0 -1
  167. package/lib/esm/content-fields/hubtype-fields/smart-intent.js.map +0 -1
  168. package/lib/esm/content-fields/hubtype-fields/text.js.map +0 -1
  169. package/lib/esm/content-fields/hubtype-fields/url.js.map +0 -1
  170. package/lib/esm/content-fields/hubtype-fields/video.js.map +0 -1
  171. package/lib/esm/content-fields/hubtype-fields/webview.js.map +0 -1
  172. package/lib/esm/content-fields/hubtype-fields/whatsapp-button-list.js.map +0 -1
  173. package/lib/esm/content-fields/hubtype-fields/whatsapp-cta-url-button.js.map +0 -1
  174. package/lib/esm/content-fields/hubtype-fields/whatsapp-request-contact-info.js.map +0 -1
  175. package/lib/esm/content-fields/hubtype-fields/whatsapp-template.js.map +0 -1
  176. package/lib/esm/content-fields/index.js.map +0 -1
  177. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-row.js.map +0 -1
  178. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list-section.js.map +0 -1
  179. package/lib/esm/content-fields/whatsapp-button-list/flow-whatsapp-button-list.js.map +0 -1
  180. package/lib/esm/content-fields/whatsapp-button-list/index.js.map +0 -1
  181. package/lib/esm/filters/index.js.map +0 -1
  182. package/lib/esm/flow-factory.js.map +0 -1
  183. package/lib/esm/functions/index.js.map +0 -1
  184. package/lib/esm/index.js.map +0 -1
  185. package/lib/esm/package.json +0 -3
  186. package/lib/esm/services/hubtype-queues-api.js.map +0 -1
  187. package/lib/esm/structured-output/flow-builder-content.js.map +0 -1
  188. package/lib/esm/tracking.js.map +0 -1
  189. package/lib/esm/types.js.map +0 -1
  190. package/lib/esm/user-input/capture-user-input-api.js.map +0 -1
  191. package/lib/esm/user-input/index.js.map +0 -1
  192. package/lib/esm/user-input/keyword.js.map +0 -1
  193. package/lib/esm/user-input/smart-intent.js.map +0 -1
  194. package/lib/esm/utils/ai-agent.js.map +0 -1
  195. package/lib/esm/utils/authentication.js.map +0 -1
  196. package/lib/esm/utils/flow-locale.js.map +0 -1
  197. package/lib/esm/utils/get-flow-builder-plugin.js.map +0 -1
  198. package/lib/esm/utils/hubtype-assistant-content.js.map +0 -1
  199. package/lib/esm/utils/input.js.map +0 -1
  200. package/lib/esm/webview/contents-context.js.map +0 -1
  201. package/lib/esm/webview/index.js.map +0 -1
  202. package/lib/esm/webview/types.js.map +0 -1
  203. package/lib/esm/webview/use-webview-contents.js.map +0 -1
  204. /package/lib/{esm/action → action}/ai-agent-from-user-input.d.ts +0 -0
  205. /package/lib/{esm/action → action}/ai-agent-from-user-input.js +0 -0
  206. /package/lib/{esm/action → action}/context.d.ts +0 -0
  207. /package/lib/{esm/action → action}/context.js +0 -0
  208. /package/lib/{esm/action → action}/fallback.d.ts +0 -0
  209. /package/lib/{esm/action → action}/fallback.js +0 -0
  210. /package/lib/{esm/action → action}/first-interaction.d.ts +0 -0
  211. /package/lib/{esm/action → action}/first-interaction.js +0 -0
  212. /package/lib/{esm/action → action}/get-contents.d.ts +0 -0
  213. /package/lib/{esm/action → action}/get-contents.js +0 -0
  214. /package/lib/{esm/action → action}/index.d.ts +0 -0
  215. /package/lib/{esm/action → action}/index.js +0 -0
  216. /package/lib/{esm/action → action}/payload.d.ts +0 -0
  217. /package/lib/{esm/action → action}/payload.js +0 -0
  218. /package/lib/{esm/api.d.ts → api.d.ts} +0 -0
  219. /package/lib/{esm/api.js → api.js} +0 -0
  220. /package/lib/{esm/constants.d.ts → constants.d.ts} +0 -0
  221. /package/lib/{esm/constants.js → constants.js} +0 -0
  222. /package/lib/{esm/content-fields → content-fields}/content-fields-base.d.ts +0 -0
  223. /package/lib/{esm/content-fields → content-fields}/content-fields-base.js +0 -0
  224. /package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-evaluators.d.ts +0 -0
  225. /package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-evaluators.js +0 -0
  226. /package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-resolver.d.ts +0 -0
  227. /package/lib/{esm/content-fields → content-fields}/custom-conditional/custom-conditional-v2-resolver.js +0 -0
  228. /package/lib/{esm/content-fields → content-fields}/custom-conditional/flow-custom-condition-v2.js +0 -0
  229. /package/lib/{esm/content-fields → content-fields}/flow-ai-agent-base.d.ts +0 -0
  230. /package/lib/{esm/content-fields → content-fields}/flow-ai-agent-router.d.ts +0 -0
  231. /package/lib/{esm/content-fields → content-fields}/flow-ai-agent-router.js +0 -0
  232. /package/lib/{esm/content-fields → content-fields}/flow-ai-agent.d.ts +0 -0
  233. /package/lib/{esm/content-fields → content-fields}/flow-ai-agent.js +0 -0
  234. /package/lib/{esm/content-fields → content-fields}/flow-bot-action.d.ts +0 -0
  235. /package/lib/{esm/content-fields → content-fields}/flow-bot-action.js +0 -0
  236. /package/lib/{esm/content-fields → content-fields}/flow-button.d.ts +0 -0
  237. /package/lib/{esm/content-fields → content-fields}/flow-button.js +0 -0
  238. /package/lib/{esm/content-fields → content-fields}/flow-capture-user-input.d.ts +0 -0
  239. /package/lib/{esm/content-fields → content-fields}/flow-capture-user-input.js +0 -0
  240. /package/lib/{esm/content-fields → content-fields}/flow-carousel.d.ts +0 -0
  241. /package/lib/{esm/content-fields → content-fields}/flow-carousel.js +0 -0
  242. /package/lib/{esm/content-fields → content-fields}/flow-channel-conditional.d.ts +0 -0
  243. /package/lib/{esm/content-fields → content-fields}/flow-channel-conditional.js +0 -0
  244. /package/lib/{esm/content-fields → content-fields}/flow-country-conditional.d.ts +0 -0
  245. /package/lib/{esm/content-fields → content-fields}/flow-country-conditional.js +0 -0
  246. /package/lib/{esm/content-fields → content-fields}/flow-custom-conditional.js +0 -0
  247. /package/lib/{esm/content-fields → content-fields}/flow-element.d.ts +0 -0
  248. /package/lib/{esm/content-fields → content-fields}/flow-element.js +0 -0
  249. /package/lib/{esm/content-fields → content-fields}/flow-go-to-flow.d.ts +0 -0
  250. /package/lib/{esm/content-fields → content-fields}/flow-go-to-flow.js +0 -0
  251. /package/lib/{esm/content-fields → content-fields}/flow-handoff.d.ts +0 -0
  252. /package/lib/{esm/content-fields → content-fields}/flow-handoff.js +0 -0
  253. /package/lib/{esm/content-fields → content-fields}/flow-image.d.ts +0 -0
  254. /package/lib/{esm/content-fields → content-fields}/flow-image.js +0 -0
  255. /package/lib/{esm/content-fields → content-fields}/flow-queue-status-conditional.d.ts +0 -0
  256. /package/lib/{esm/content-fields → content-fields}/flow-queue-status-conditional.js +0 -0
  257. /package/lib/{esm/content-fields → content-fields}/flow-rating.d.ts +0 -0
  258. /package/lib/{esm/content-fields → content-fields}/flow-rating.js +0 -0
  259. /package/lib/{esm/content-fields → content-fields}/flow-text.d.ts +0 -0
  260. /package/lib/{esm/content-fields → content-fields}/flow-text.js +0 -0
  261. /package/lib/{esm/content-fields → content-fields}/flow-video.d.ts +0 -0
  262. /package/lib/{esm/content-fields → content-fields}/flow-video.js +0 -0
  263. /package/lib/{esm/content-fields → content-fields}/flow-webview.d.ts +0 -0
  264. /package/lib/{esm/content-fields → content-fields}/flow-webview.js +0 -0
  265. /package/lib/{esm/content-fields → content-fields}/flow-whatsapp-cta-url-button.d.ts +0 -0
  266. /package/lib/{esm/content-fields → content-fields}/flow-whatsapp-cta-url-button.js +0 -0
  267. /package/lib/{esm/content-fields → content-fields}/flow-whatsapp-template.d.ts +0 -0
  268. /package/lib/{esm/content-fields → content-fields}/flow-whatsapp-template.js +0 -0
  269. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/ai-agent-router.d.ts +0 -0
  270. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/ai-agent-router.js +0 -0
  271. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/ai-agent.d.ts +0 -0
  272. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/ai-agent.js +0 -0
  273. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/bot-action.d.ts +0 -0
  274. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/bot-action.js +0 -0
  275. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/button.d.ts +0 -0
  276. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/button.js +0 -0
  277. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/capture-user-input.d.ts +0 -0
  278. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/capture-user-input.js +0 -0
  279. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/carousel.d.ts +0 -0
  280. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/carousel.js +0 -0
  281. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/channel-conditional.d.ts +0 -0
  282. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/channel-conditional.js +0 -0
  283. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/common.d.ts +0 -0
  284. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/common.js +0 -0
  285. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/country-conditional.d.ts +0 -0
  286. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/country-conditional.js +0 -0
  287. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional-v2.d.ts +0 -0
  288. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional-v2.js +0 -0
  289. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional.d.ts +0 -0
  290. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/custom-conditional.js +0 -0
  291. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/fallback.d.ts +0 -0
  292. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/fallback.js +0 -0
  293. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/function.d.ts +0 -0
  294. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/function.js +0 -0
  295. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/go-to-flow.d.ts +0 -0
  296. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/go-to-flow.js +0 -0
  297. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/handoff.d.ts +0 -0
  298. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/handoff.js +0 -0
  299. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/image.d.ts +0 -0
  300. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/image.js +0 -0
  301. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/index.d.ts +0 -0
  302. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/index.js +0 -0
  303. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/keyword.d.ts +0 -0
  304. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/keyword.js +0 -0
  305. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/node-types.d.ts +0 -0
  306. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/node-types.js +0 -0
  307. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/nodes.d.ts +0 -0
  308. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/nodes.js +0 -0
  309. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/payload.d.ts +0 -0
  310. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/payload.js +0 -0
  311. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/queue-status-conditional.d.ts +0 -0
  312. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/queue-status-conditional.js +0 -0
  313. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/rating.d.ts +0 -0
  314. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/rating.js +0 -0
  315. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/smart-intent.d.ts +0 -0
  316. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/smart-intent.js +0 -0
  317. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/text.d.ts +0 -0
  318. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/text.js +0 -0
  319. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/url.d.ts +0 -0
  320. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/url.js +0 -0
  321. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/video.d.ts +0 -0
  322. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/video.js +0 -0
  323. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/webview.d.ts +0 -0
  324. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/webview.js +0 -0
  325. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-button-list.d.ts +0 -0
  326. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-button-list.js +0 -0
  327. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-cta-url-button.d.ts +0 -0
  328. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-cta-url-button.js +0 -0
  329. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-request-contact-info.d.ts +0 -0
  330. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-request-contact-info.js +0 -0
  331. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-template.d.ts +0 -0
  332. /package/lib/{esm/content-fields → content-fields}/hubtype-fields/whatsapp-template.js +0 -0
  333. /package/lib/{esm/content-fields → content-fields}/index.js +0 -0
  334. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-row.d.ts +0 -0
  335. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-row.js +0 -0
  336. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-section.d.ts +0 -0
  337. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list-section.js +0 -0
  338. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list.d.ts +0 -0
  339. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/flow-whatsapp-button-list.js +0 -0
  340. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/index.d.ts +0 -0
  341. /package/lib/{esm/content-fields → content-fields}/whatsapp-button-list/index.js +0 -0
  342. /package/lib/{esm/filters → filters}/index.d.ts +0 -0
  343. /package/lib/{esm/filters → filters}/index.js +0 -0
  344. /package/lib/{esm/flow-factory.d.ts → flow-factory.d.ts} +0 -0
  345. /package/lib/{esm/flow-factory.js → flow-factory.js} +0 -0
  346. /package/lib/{esm/functions → functions}/index.d.ts +0 -0
  347. /package/lib/{esm/functions → functions}/index.js +0 -0
  348. /package/lib/{esm/index.d.ts → index.d.ts} +0 -0
  349. /package/lib/{esm/index.js → index.js} +0 -0
  350. /package/lib/{esm/services → services}/hubtype-queues-api.d.ts +0 -0
  351. /package/lib/{esm/services → services}/hubtype-queues-api.js +0 -0
  352. /package/lib/{esm/structured-output → structured-output}/flow-builder-content.d.ts +0 -0
  353. /package/lib/{esm/structured-output → structured-output}/flow-builder-content.js +0 -0
  354. /package/lib/{esm/tracking.d.ts → tracking.d.ts} +0 -0
  355. /package/lib/{esm/tracking.js → tracking.js} +0 -0
  356. /package/lib/{esm/types.d.ts → types.d.ts} +0 -0
  357. /package/lib/{esm/types.js → types.js} +0 -0
  358. /package/lib/{esm/user-input → user-input}/capture-user-input-api.d.ts +0 -0
  359. /package/lib/{esm/user-input → user-input}/capture-user-input-api.js +0 -0
  360. /package/lib/{esm/user-input → user-input}/index.d.ts +0 -0
  361. /package/lib/{esm/user-input → user-input}/index.js +0 -0
  362. /package/lib/{esm/user-input → user-input}/keyword.d.ts +0 -0
  363. /package/lib/{esm/user-input → user-input}/keyword.js +0 -0
  364. /package/lib/{esm/user-input → user-input}/smart-intent.d.ts +0 -0
  365. /package/lib/{esm/user-input → user-input}/smart-intent.js +0 -0
  366. /package/lib/{esm/utils → utils}/ai-agent.d.ts +0 -0
  367. /package/lib/{esm/utils → utils}/ai-agent.js +0 -0
  368. /package/lib/{esm/utils → utils}/authentication.d.ts +0 -0
  369. /package/lib/{esm/utils → utils}/authentication.js +0 -0
  370. /package/lib/{esm/utils → utils}/flow-locale.d.ts +0 -0
  371. /package/lib/{esm/utils → utils}/flow-locale.js +0 -0
  372. /package/lib/{esm/utils → utils}/get-flow-builder-plugin.d.ts +0 -0
  373. /package/lib/{esm/utils → utils}/get-flow-builder-plugin.js +0 -0
  374. /package/lib/{esm/utils → utils}/input.d.ts +0 -0
  375. /package/lib/{esm/utils → utils}/input.js +0 -0
  376. /package/lib/{esm/webview → webview}/contents-context.d.ts +0 -0
  377. /package/lib/{esm/webview → webview}/contents-context.js +0 -0
  378. /package/lib/{esm/webview → webview}/index.d.ts +0 -0
  379. /package/lib/{esm/webview → webview}/index.js +0 -0
  380. /package/lib/{esm/webview → webview}/types.d.ts +0 -0
  381. /package/lib/{esm/webview → webview}/types.js +0 -0
  382. /package/lib/{esm/webview → webview}/use-webview-contents.d.ts +0 -0
  383. /package/lib/{esm/webview → webview}/use-webview-contents.js +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"flow-factory.js","sources":["../../src/flow-factory.ts"],"sourcesContent":["import type { BotContext } from '@botonic/core'\n\nimport type { FlowBuilderApi } from './api'\nimport {\n FlowAiAgent,\n FlowAiAgentRouter,\n FlowBotAction,\n FlowCarousel,\n FlowChannelConditional,\n type FlowContent,\n FlowCountryConditional,\n FlowCustomConditional,\n FlowCustomConditionalV2,\n FlowGoToFlow,\n FlowHandoff,\n FlowImage,\n FlowQueueStatusConditional,\n FlowRating,\n FlowText,\n FlowVideo,\n FlowWhatsappButtonList,\n FlowWhatsappCtaUrlButtonNode,\n FlowWhatsappRequestContactInfoNode,\n FlowWhatsappTemplate,\n} from './content-fields'\nimport { FlowCaptureUserInput } from './content-fields/flow-capture-user-input'\nimport {\n type HtFunctionNode,\n type HtNodeComponent,\n HtNodeWithContentType,\n} from './content-fields/hubtype-fields'\n\nexport class FlowFactory {\n public botContext: BotContext\n public cmsApi: FlowBuilderApi\n public locale: string\n\n constructor(botContext: BotContext, cmsApi: FlowBuilderApi, locale: string) {\n this.botContext = botContext\n this.cmsApi = cmsApi\n this.locale = locale\n }\n\n async getFlowContent(\n hubtypeContent: HtNodeComponent\n ): Promise<FlowContent | undefined> {\n switch (hubtypeContent.type) {\n case HtNodeWithContentType.TEXT:\n return FlowText.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi,\n this.botContext\n )\n case HtNodeWithContentType.IMAGE:\n return FlowImage.fromHubtypeCMS(hubtypeContent, this.locale)\n case HtNodeWithContentType.CAROUSEL:\n return FlowCarousel.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi,\n this.botContext\n )\n case HtNodeWithContentType.VIDEO:\n return FlowVideo.fromHubtypeCMS(hubtypeContent, this.locale)\n case HtNodeWithContentType.WHATSAPP_BUTTON_LIST:\n return FlowWhatsappButtonList.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi\n )\n case HtNodeWithContentType.WHATSAPP_CTA_URL_BUTTON:\n return FlowWhatsappCtaUrlButtonNode.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi,\n this.botContext\n )\n case HtNodeWithContentType.WHATSAPP_REQUEST_CONTACT_INFO:\n return FlowWhatsappRequestContactInfoNode.fromHubtypeCMS(\n hubtypeContent,\n this.locale\n )\n case HtNodeWithContentType.HANDOFF:\n return FlowHandoff.fromHubtypeCMS(\n hubtypeContent,\n this.locale,\n this.cmsApi\n )\n\n case HtNodeWithContentType.AI_AGENT_ROUTER:\n return FlowAiAgentRouter.fromHubtypeCMS(hubtypeContent, this.botContext)\n\n case HtNodeWithContentType.AI_AGENT:\n return FlowAiAgent.fromHubtypeCMS(hubtypeContent, this.botContext)\n\n case HtNodeWithContentType.RATING:\n return FlowRating.fromHubtypeCMS(hubtypeContent, this.locale)\n\n case HtNodeWithContentType.BOT_ACTION:\n return FlowBotAction.fromHubtypeCMS(hubtypeContent, this.cmsApi)\n\n case HtNodeWithContentType.FUNCTION:\n return this.resolveFlowFunctionContent(hubtypeContent)\n\n case HtNodeWithContentType.GO_TO_FLOW:\n return FlowGoToFlow.fromHubtypeCMS(hubtypeContent, this.cmsApi)\n\n case HtNodeWithContentType.WHATSAPP_TEMPLATE:\n return FlowWhatsappTemplate.fromHubtypeCMS(hubtypeContent, this.locale)\n\n case HtNodeWithContentType.CAPTURE_USER_INPUT:\n return FlowCaptureUserInput.fromHubtypeCMS(hubtypeContent)\n\n case HtNodeWithContentType.CUSTOM_CONDITION:\n return FlowCustomConditionalV2.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n\n default:\n return undefined\n }\n }\n\n private async resolveFlowFunctionContent(\n hubtypeContent: HtFunctionNode\n ): Promise<FlowContent | undefined> {\n switch (hubtypeContent.content.action) {\n case 'check-country':\n return FlowCountryConditional.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n case 'get-channel-type':\n return FlowChannelConditional.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n case 'check-queue-status':\n return FlowQueueStatusConditional.fromHubtypeCMS(\n hubtypeContent,\n this.locale\n )\n case 'check-bot-variable':\n return FlowCustomConditional.fromHubtypeCMS(\n hubtypeContent,\n this.botContext\n )\n default:\n return undefined\n }\n }\n}\n"],"names":["FlowAiAgent","FlowAiAgentRouter","FlowBotAction","FlowCarousel","FlowChannelConditional","FlowCountryConditional","FlowCustomConditional","FlowCustomConditionalV2","FlowGoToFlow","FlowHandoff","FlowImage","FlowQueueStatusConditional","FlowRating","FlowText","FlowVideo","FlowWhatsappButtonList","FlowWhatsappCtaUrlButtonNode","FlowWhatsappRequestContactInfoNode","FlowWhatsappTemplate","FlowCaptureUserInput","HtNodeWithContentType","FlowFactory","hubtypeContent","undefined","botContext","cmsApi","locale"],"mappings":";;;;;;;AAwByB;AACsD;AAKvC;AAEjC,MAAMqB,WAAWA;IAWtB,MAAM,eACJC,cAA+B,EACG;QAClC,OAAQA,eAAe,IAAI;YACzB,KAAKF,0BAA0B;gBAC7B,OAAOP,uBAAuB,CAC5BS,gBACA,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,UAAU;YAEnB,KAAKF,2BAA2B;gBAC9B,OAAOV,wBAAwB,CAACY,gBAAgB,IAAI,CAAC,MAAM;YAC7D,KAAKF,8BAA8B;gBACjC,OAAOjB,2BAA2B,CAChCmB,gBACA,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,UAAU;YAEnB,KAAKF,2BAA2B;gBAC9B,OAAON,wBAAwB,CAACQ,gBAAgB,IAAI,CAAC,MAAM;YAC7D,KAAKF,0CAA0C;gBAC7C,OAAOL,qCAAqC,CAC1CO,gBACA,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM;YAEf,KAAKF,6CAA6C;gBAChD,OAAOJ,2CAA2C,CAChDM,gBACA,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,UAAU;YAEnB,KAAKF,mDAAmD;gBACtD,OAAOH,iDAAiD,CACtDK,gBACA,IAAI,CAAC,MAAM;YAEf,KAAKF,6BAA6B;gBAChC,OAAOX,0BAA0B,CAC/Ba,gBACA,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM;YAGf,KAAKF,qCAAqC;gBACxC,OAAOnB,gCAAgC,CAACqB,gBAAgB,IAAI,CAAC,UAAU;YAEzE,KAAKF,8BAA8B;gBACjC,OAAOpB,0BAA0B,CAACsB,gBAAgB,IAAI,CAAC,UAAU;YAEnE,KAAKF,4BAA4B;gBAC/B,OAAOR,yBAAyB,CAACU,gBAAgB,IAAI,CAAC,MAAM;YAE9D,KAAKF,gCAAgC;gBACnC,OAAOlB,4BAA4B,CAACoB,gBAAgB,IAAI,CAAC,MAAM;YAEjE,KAAKF,8BAA8B;gBACjC,OAAO,IAAI,CAAC,0BAA0B,CAACE;YAEzC,KAAKF,gCAAgC;gBACnC,OAAOZ,2BAA2B,CAACc,gBAAgB,IAAI,CAAC,MAAM;YAEhE,KAAKF,uCAAuC;gBAC1C,OAAOF,mCAAmC,CAACI,gBAAgB,IAAI,CAAC,MAAM;YAExE,KAAKF,wCAAwC;gBAC3C,OAAOD,mCAAmC,CAACG;YAE7C,KAAKF,sCAAsC;gBACzC,OAAOb,sCAAsC,CAC3Ce,gBACA,IAAI,CAAC,UAAU;YAGnB;gBACE,OAAOC;QACX;IACF;IAEA,MAAc,2BACZD,cAA8B,EACI;QAClC,OAAQA,eAAe,OAAO,CAAC,MAAM;YACnC,KAAK;gBACH,OAAOjB,qCAAqC,CAC1CiB,gBACA,IAAI,CAAC,UAAU;YAEnB,KAAK;gBACH,OAAOlB,qCAAqC,CAC1CkB,gBACA,IAAI,CAAC,UAAU;YAEnB,KAAK;gBACH,OAAOX,yCAAyC,CAC9CW,gBACA,IAAI,CAAC,MAAM;YAEf,KAAK;gBACH,OAAOhB,oCAAoC,CACzCgB,gBACA,IAAI,CAAC,UAAU;YAEnB;gBACE,OAAOC;QACX;IACF;IAnHA,YAAYC,UAAsB,EAAEC,MAAsB,EAAEC,MAAc,CAAE;QAC1E,IAAI,CAAC,UAAU,GAAGF;QAClB,IAAI,CAAC,MAAM,GAAGC;QACd,IAAI,CAAC,MAAM,GAAGC;IAChB;AAgHF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"functions/index.js","sources":["../../../src/functions/index.ts"],"sourcesContent":["import type { ActionRequest } from '@botonic/react'\n\nimport type {\n HtFunctionArgument,\n HtFunctionArguments,\n HtFunctionNode,\n} from '../content-fields/hubtype-fields'\n\nexport const DEFAULT_FUNCTION_NAMES = [\n 'check-queue-status',\n 'get-channel-type',\n 'check-country',\n 'check-bot-variable',\n]\n\nexport class CustomFunction {\n public functions: Record<any, any>\n public currentRequest: ActionRequest\n public locale: string\n\n constructor(\n functions: Record<any, any>,\n currentRequest: ActionRequest,\n locale: string\n ) {\n this.functions = functions\n this.currentRequest = currentRequest\n this.locale = locale\n }\n\n async call(functionNode: HtFunctionNode): Promise<string> {\n const functionNodeId = functionNode.id\n const functionArguments = getArgumentsByLocale(\n functionNode.content.arguments,\n this.locale\n )\n const nameValues = functionArguments.map(arg => {\n return { [arg.name]: arg.value }\n })\n\n const args = Object.assign(\n {\n request: this.currentRequest,\n results: functionNode.content.result_mapping.map(r => r.result),\n },\n ...nameValues\n )\n const functionResult =\n await this.functions[functionNode.content.action](args)\n // TODO define result_mapping per locale??\n const result = functionNode.content.result_mapping.find(\n r => r.result === functionResult\n )\n if (!result?.target) {\n throw new Error(\n `No result found for result_mapping for node with id: ${functionNodeId}`\n )\n }\n return result.target.id\n }\n}\n\nexport function getArgumentsByLocale(\n args: HtFunctionArguments[],\n locale: string\n): HtFunctionArgument[] {\n let resultArguments: HtFunctionArgument[] = []\n for (const arg of args) {\n if ('locale' in arg && arg.locale === locale) {\n resultArguments = [...resultArguments, ...arg.values]\n }\n if ('type' in arg) {\n resultArguments = [...resultArguments, arg]\n }\n }\n\n return resultArguments\n}\n"],"names":["DEFAULT_FUNCTION_NAMES","CustomFunction","functionNode","functionNodeId","functionArguments","getArgumentsByLocale","nameValues","arg","args","Object","r","functionResult","result","Error","functions","currentRequest","locale","resultArguments"],"mappings":"AAQO,MAAMA,sBAAsBA,GAAG;IACpC;IACA;IACA;IACA;CACD;AAEM,MAAMC,cAAcA;IAezB,MAAM,KAAKC,YAA4B,EAAmB;QACxD,MAAMC,iBAAiB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version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import {\n INPUT,\n type Plugin,\n type PluginPreRequest,\n PROVIDER,\n type ResolvedPlugins,\n type Session,\n} from '@botonic/core'\nimport type { ActionRequest } from '@botonic/react'\nimport { v7 as uuidv7 } from 'uuid'\n\nimport { FlowBuilderApi } from './api'\nimport {\n EMPTY_PAYLOAD,\n FLOW_BUILDER_API_URL_PROD,\n SEPARATOR,\n SOURCE_INFO_SEPARATOR,\n} from './constants'\nimport type { FlowContent } from './content-fields'\nimport {\n type HtBotActionNode,\n type HtFlowBuilderData,\n type HtNodeWithContent,\n HtNodeWithContentType,\n} from './content-fields/hubtype-fields'\nimport { FlowFactory } from './flow-factory'\nimport { CustomFunction, DEFAULT_FUNCTION_NAMES } from './functions'\nimport {\n type AiAgentFunction,\n type BotonicPluginFlowBuilderOptions,\n type ContentFilter,\n FlowBuilderJSONVersion,\n type InShadowingConfig,\n type PayloadParamsBase,\n type RatingSubmittedInfo,\n type TrackEventFunction,\n} from './types'\nimport { getNextPayloadByUserInput } from './user-input'\nimport type { SmartIntentsInferenceConfig } from './user-input/smart-intent'\nimport { resolveGetAccessToken } from './utils/authentication'\nimport { inputHasTextOrTranscript } from './utils/input'\n\n// TODO: Create a proper service to wrap all calls and allow api versioning\n\nexport default class BotonicPluginFlowBuilder implements Plugin {\n public cmsApi: FlowBuilderApi\n private flow?: HtFlowBuilderData\n private functions: Record<any, any>\n private currentRequest: PluginPreRequest\n public getAccessToken: (session: Session) => string\n public trackEvent?: TrackEventFunction\n public getAiAgentResponse?: AiAgentFunction\n public smartIntentsConfig: SmartIntentsInferenceConfig\n public inShadowing: InShadowingConfig\n public contentFilters: ContentFilter[]\n\n // TODO: Rethink how we construct FlowBuilderApi to be simpler\n public jsonVersion: FlowBuilderJSONVersion\n public apiUrl: string\n public customRatingMessageEnabled: boolean\n public disableAIAgentInFirstInteraction: boolean\n\n constructor(options: BotonicPluginFlowBuilderOptions<ResolvedPlugins, any>) {\n this.apiUrl = options.apiUrl || FLOW_BUILDER_API_URL_PROD\n this.jsonVersion = options.jsonVersion || FlowBuilderJSONVersion.LATEST\n this.flow = options.flow\n this.getAccessToken = resolveGetAccessToken(options.getAccessToken)\n this.trackEvent = options.trackEvent\n this.getAiAgentResponse = options.getAiAgentResponse\n this.smartIntentsConfig = {\n ...options?.smartIntentsConfig,\n useLatest: this.jsonVersion === FlowBuilderJSONVersion.LATEST,\n }\n const customFunctions = options.customFunctions || {}\n this.functions = customFunctions\n this.inShadowing = {\n allowKeywords: options.inShadowing?.allowKeywords || false,\n allowSmartIntents: options.inShadowing?.allowSmartIntents || false,\n allowAiAgents: options.inShadowing?.allowAiAgents || false,\n }\n this.contentFilters = options.contentFilters || []\n this.customRatingMessageEnabled =\n options.customRatingMessageEnabled || false\n this.disableAIAgentInFirstInteraction =\n options.disableAIAgentInFirstInteraction || false\n }\n\n resolveFlowUrl(request: PluginPreRequest): string {\n if (request.session.is_test_integration) {\n return `${this.apiUrl}/v1/bot_flows/{bot_id}/versions/${FlowBuilderJSONVersion.DRAFT}/`\n }\n return `${this.apiUrl}/v1/bot_flows/{bot_id}/versions/${this.jsonVersion}/`\n }\n\n async pre(request: PluginPreRequest): Promise<void> {\n // When AI Agent is executed in Whatsapp, button payloads come as referral and must be converted to text being processed by the agent.\n this.convertWhatsappAiAgentEmptyPayloads(request)\n\n this.currentRequest = request\n this.cmsApi = await FlowBuilderApi.create({\n flowUrl: this.resolveFlowUrl(request),\n url: this.apiUrl,\n flow: this.flow,\n accessToken: this.getAccessToken(request.session),\n request: this.currentRequest,\n })\n\n const checkUserTextInput =\n inputHasTextOrTranscript(request.input) && !request.input.payload\n\n if (checkUserTextInput) {\n const resolvedLocale = this.cmsApi.getResolvedLocale()\n const nextPayload = await getNextPayloadByUserInput(\n this.cmsApi,\n resolvedLocale,\n request as unknown as ActionRequest,\n this.smartIntentsConfig\n )\n request.input.payload = nextPayload\n }\n\n await this.updateRequestBeforeRoutes(request)\n }\n\n private convertWhatsappAiAgentEmptyPayloads(request: PluginPreRequest): void {\n if (request.session.user.provider === PROVIDER.WHATSAPP) {\n const shouldUseReferral =\n request.input.referral &&\n request.input.payload?.startsWith(EMPTY_PAYLOAD)\n\n if (shouldUseReferral) {\n request.input.type = INPUT.TEXT\n request.input.data = request.input.referral\n }\n }\n }\n\n private async updateRequestBeforeRoutes(\n request: PluginPreRequest\n ): Promise<void> {\n this.cmsApi.removeCaptureUserInputId()\n if (request.input.payload) {\n request.input.payload = this.removeSourceSuffix(request.input.payload)\n\n if (this.cmsApi.isBotAction(request.input.payload)) {\n const cmsBotAction = this.cmsApi.getNodeById<HtBotActionNode>(\n request.input.payload\n )\n\n request.input.payload =\n this.cmsApi.createPayloadWithParams(cmsBotAction)\n\n // Re-execute convertWhatsappAiAgentEmptyPayloads function to handle\n // the case that a BotAction has a payload equals to EMPTY_PAYLOAD\n this.convertWhatsappAiAgentEmptyPayloads(request)\n }\n }\n }\n\n private removeSourceSuffix(payload: string): string {\n return payload.split(SOURCE_INFO_SEPARATOR)[0]\n }\n\n post(request: PluginPreRequest): void {\n request.input.nluResolution = undefined\n delete request.session.user.system_locale_updated\n }\n\n async getContentsByContentID(\n contentID: string,\n prevContents?: FlowContent[]\n ): Promise<FlowContent[]> {\n const node = this.cmsApi.getNodeByContentID(contentID) as HtNodeWithContent\n return await this.getContentsByNode(node, prevContents)\n }\n\n getUUIDByContentID(contentID: string): string {\n const node = this.cmsApi.getNodeByContentID(contentID)\n return node.id\n }\n\n private async getContentsById(\n id: string,\n prevContents?: FlowContent[]\n ): Promise<FlowContent[]> {\n const node = this.cmsApi.getNodeById(id) as HtNodeWithContent\n return await this.getContentsByNode(node, prevContents)\n }\n\n async getStartContents(): Promise<FlowContent[]> {\n const startNode = this.cmsApi.getStartNode()\n this.currentRequest.session.flow_thread_id = uuidv7()\n return await this.getContentsByNode(startNode)\n }\n\n async getContentsByNode(\n node: HtNodeWithContent,\n prevContents?: FlowContent[]\n ): Promise<FlowContent[]> {\n const contents = prevContents || []\n const resolvedLocale = this.cmsApi.getResolvedLocale()\n\n if (\n node.type === HtNodeWithContentType.FUNCTION &&\n !DEFAULT_FUNCTION_NAMES.includes(node.content.action)\n ) {\n const customFunctionResolver = new CustomFunction(\n this.functions,\n this.currentRequest,\n resolvedLocale\n )\n const targetId = await customFunctionResolver.call(node)\n return this.getContentsById(targetId, contents)\n }\n\n const flowFactory = new FlowFactory(\n this.currentRequest,\n this.cmsApi,\n resolvedLocale\n )\n const content = await flowFactory.getFlowContent(node)\n if (content) {\n contents.push(content)\n }\n\n // If node is BOT_ACTION not add more contents to render, next nodes render after execute action\n if (node.type === HtNodeWithContentType.BOT_ACTION) {\n return contents\n }\n\n // TODO: prevent infinite recursive calls\n if (content?.followUp) {\n return this.getContentsById(content.followUp.id, contents)\n } else if (node.follow_up) {\n console.log('FOLLOWUP FROM NODE-------> OLD SYSTEM')\n return this.getContentsById(node.follow_up.id, contents)\n }\n\n return contents\n }\n\n getPayloadParams<T extends PayloadParamsBase>(payload: string): T {\n const payloadParams = JSON.parse(payload.split(SEPARATOR)[1] || '{}')\n return payloadParams\n }\n\n getFlowName(flowId: string): string {\n return this.cmsApi.getFlowName(flowId)\n }\n\n getRatingSubmittedInfo(payload: string): RatingSubmittedInfo {\n const buttonId = payload?.split(SEPARATOR)[1]\n const ratingNode = this.cmsApi.getRatingNodeByButtonId(buttonId)\n\n const ratingButton = this.cmsApi.getRatingButtonById(ratingNode, buttonId)\n const possibleOptions = ratingNode.content.buttons.map(\n button => button.text\n )\n const possibleValues = ratingNode.content.buttons.map(\n button => button.value\n )\n\n return {\n ...ratingButton,\n possibleOptions,\n possibleValues,\n }\n }\n\n setInShadowing(inShadowing: InShadowingConfig): void {\n this.inShadowing = inShadowing\n }\n}\n\nexport * from './action'\nexport { AGENT_RATING_PAYLOAD, EMPTY_PAYLOAD } from './constants'\nexport * from './content-fields'\nexport type { HtBotActionNode } from './content-fields/hubtype-fields'\nexport {\n getCommonFlowContentEventArgsForContentId,\n trackFlowContent,\n} from './tracking'\nexport {\n type BotonicPluginFlowBuilderOptions,\n type ContentFilter,\n FlowBuilderJSONVersion,\n type PayloadParamsBase,\n type RatingSubmittedInfo,\n} from './types'\nexport * from './webview'\n"],"names":["INPUT","PROVIDER","v7","uuidv7","FlowBuilderApi","EMPTY_PAYLOAD","FLOW_BUILDER_API_URL_PROD","SEPARATOR","SOURCE_INFO_SEPARATOR","HtNodeWithContentType","FlowFactory","CustomFunction","DEFAULT_FUNCTION_NAMES","FlowBuilderJSONVersion","getNextPayloadByUserInput","resolveGetAccessToken","inputHasTextOrTranscript","BotonicPluginFlowBuilder","request","checkUserTextInput","resolvedLocale","nextPayload","shouldUseReferral","cmsBotAction","payload","undefined","contentID","prevContents","node","id","startNode","contents","customFunctionResolver","targetId","flowFactory","content","console","payloadParams","JSON","flowId","buttonId","ratingNode","ratingButton","possibleOptions","button","possibleValues","inShadowing","options","customFunctions","AGENT_RATING_PAYLOAD","getCommonFlowContentEventArgsForContentId","trackFlowContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOsB;AAEa;AAEG;AAMlB;AAOoB;AACI;AACwB;AAUpD;AACwC;AAEM;AACN;AAIzC,MAAMiB,wBAAwBA;IA2C3C,eAAeC,OAAyB,EAAU;QAChD,IAAIA,QAAQ,OAAO,CAAC,mBAAmB,EAAE;YACvC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,gCAAgC,EAAEL,4BAA4B,CAAC,CAAC,CAAC;QACzF;QACA,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,gCAAgC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7E;IAEA,MAAM,IAAIK,OAAyB,EAAiB;QAClD,sIAAsI;QACtI,IAAI,CAAC,mCAAmC,CAACA;QAEzC,IAAI,CAAC,cAAc,GAAGA;QACtB,IAAI,CAAC,MAAM,GAAG,MAAMd,qBAAqB,CAAC;YACxC,SAAS,IAAI,CAAC,cAAc,CAACc;YAC7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1
- {
2
- "type": "module"
3
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"services/hubtype-queues-api.js","sources":["../../../src/services/hubtype-queues-api.ts"],"sourcesContent":["import axios from 'axios'\n\nconst HUBTYPE_API_URL = process.env.HUBTYPE_API_URL || 'https://api.hubtype.com'\n\nexport interface AvailabilityData {\n available: boolean\n waiting_cases: number\n availability_threshold_waiting_cases: number\n open: boolean\n name: string\n available_agents: number\n}\nexport class HubtypeQueuesApi {\n public queueId: string\n public checkAvailableAgents: boolean\n\n constructor(queueId: string, checkAvailableAgents?: boolean) {\n this.queueId = queueId\n this.checkAvailableAgents = checkAvailableAgents || false\n }\n\n async getAvailability(): Promise<AvailabilityData> {\n const response = await axios.get(\n `${HUBTYPE_API_URL}/external/v1/queues/${this.queueId}/availability/`,\n // TODO: Make it configurable in the future\n {\n params: {\n check_queue_schedule: true,\n check_waiting_cases: false,\n check_available_agents: this.checkAvailableAgents,\n },\n }\n )\n return response.data\n }\n}\n"],"names":["axios","HUBTYPE_API_URL","process","HubtypeQueuesApi","response","queueId","checkAvailableAgents"],"mappings":";;;AAAyB;AAEzB,MAAMC,eAAeA,GAAGC,QAAQ,GAAG,CAAC,eAAe,IAAI;AAUhD,MAAMC,gBAAgBA;IAS3B,MAAM,kBAA6C;QACjD,MAAMC,WAAW,MAAMJ,SAAS,CAC9B,GAAGC,eAAeA,CAAC,oBAAoB,EAAE,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EACrE,2CAA2C;QAC3C;YACE,QAAQ;gBACN,sBAAsB;gBACtB,qBAAqB;gBACrB,wBAAwB,IAAI,CAAC,oBAAoB;YACnD;QACF;QAEF,OAAOG,SAAS,IAAI;IACtB;IAlBA,YAAYC,OAAe,EAAEC,oBAA8B,CAAE;QAC3D,IAAI,CAAC,OAAO,GAAGD;QACf,IAAI,CAAC,oBAAoB,GAAGC,wBAAwB;IACtD;AAgBF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"structured-output/flow-builder-content.js","sources":["../../../src/structured-output/flow-builder-content.ts"],"sourcesContent":["import type { BaseMessage } from '@botonic/core'\nimport { z } from 'zod'\n\nexport enum FlowBuilderOutputMessageType {\n FlowBuilderContent = 'flowBuilderContent',\n}\n\nexport interface FlowBuilderContentMessage\n extends BaseMessage<FlowBuilderOutputMessageType.FlowBuilderContent> {\n type: FlowBuilderOutputMessageType.FlowBuilderContent\n contentId: string\n}\n\nexport const FlowBuilderContentSchema = z\n .object({\n type: z.literal(FlowBuilderOutputMessageType.FlowBuilderContent),\n contentId: z.string(),\n })\n .describe(\n 'A Flow Builder content ID. Use it only when asked explicitly in the prompt'\n )\n"],"names":["z","FlowBuilderOutputMessageType","FlowBuilderContentSchema"],"mappings":";;;AACuB;AAEhB,IAAKC,iDAA4BA,0BAA5BA;;WAAAA;MAEX;AAQM,MAAMC,wBAAwBA,GAAGF,QAC/B,CAAC;IACN,MAAMA,SAAS;IACf,WAAWA,QAAQ;AACrB,GACC,QAAQ,CACP,8EACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tracking.js","sources":["../../src/tracking.ts"],"sourcesContent":["import { type BotContext, EventAction, type EventFlow } from '@botonic/core'\nimport type { ActionRequest } from '@botonic/react'\nimport { v7 as uuidv7 } from 'uuid'\n\nimport type { FlowBuilderApi } from './api'\nimport type { FlowContent } from './content-fields'\nimport {\n type HtNodeWithContent,\n HtNodeWithContentType,\n} from './content-fields/hubtype-fields'\nimport { getFlowBuilderPlugin } from './utils/get-flow-builder-plugin'\n\nexport async function trackEvent(\n request: ActionRequest,\n eventAction: EventAction,\n args?: Record<string, any>\n): Promise<void> {\n const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)\n if (flowBuilderPlugin.trackEvent) {\n await flowBuilderPlugin.trackEvent(request, eventAction, args)\n }\n return\n}\n\nexport async function trackFlowContent(\n request: ActionRequest,\n contents: FlowContent[]\n) {\n const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)\n const cmsApi = flowBuilderPlugin.cmsApi\n for (const content of contents) {\n await trackOneContent(request, content, cmsApi)\n }\n}\n\nexport async function trackOneContent(\n request: ActionRequest,\n content: FlowContent,\n cmsApi?: FlowBuilderApi\n) {\n if (!cmsApi) {\n const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)\n cmsApi = flowBuilderPlugin.cmsApi\n }\n\n const nodeContent = cmsApi.getNodeById<HtNodeWithContent>(content.id)\n if (nodeContent.type !== HtNodeWithContentType.AI_AGENT) {\n const event = getContentEventArgs(request, nodeContent)\n const { action, ...eventArgs } = event\n await trackEvent(request, action, eventArgs)\n }\n}\n\nfunction setSessionFlowThreadId(\n request: ActionRequest,\n flowThreadId: string\n): void {\n request.session.flow_thread_id = flowThreadId\n}\n\nfunction getContentEventArgs(\n request: ActionRequest,\n nodeContent: HtNodeWithContent\n): EventFlow {\n const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgs(request, nodeContent)\n\n setSessionFlowThreadId(request, flowThreadId)\n\n return {\n action: EventAction.FlowNode,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n flowThreadId,\n flowNodeIsMeaningful: nodeContent.is_meaningful ?? false,\n }\n}\n\ntype CommonFlowContentEventArgs = {\n flowThreadId: string\n flowId: string\n flowName: string\n flowNodeId: string\n flowNodeContentId: string\n}\n\nfunction getCommonFlowContentEventArgs(\n request: ActionRequest,\n nodeContent: HtNodeWithContent\n): CommonFlowContentEventArgs {\n const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)\n const flowName = flowBuilderPlugin.getFlowName(nodeContent.flow_id)\n const flowThreadId = request.session.flow_thread_id ?? uuidv7()\n\n return {\n flowThreadId,\n flowId: nodeContent.flow_id,\n flowName,\n flowNodeId: nodeContent.id,\n flowNodeContentId: nodeContent.code ?? '',\n }\n}\n\nexport function getCommonFlowContentEventArgsForContentId(\n botContext: BotContext,\n id: string\n): CommonFlowContentEventArgs {\n const flowBuilderPlugin = getFlowBuilderPlugin(botContext.plugins)\n const cmsApi = flowBuilderPlugin.cmsApi\n const nodeContent = cmsApi.getNodeById<HtNodeWithContent>(id)\n\n return getCommonFlowContentEventArgs(botContext, nodeContent)\n}\n"],"names":["EventAction","v7","uuidv7","HtNodeWithContentType","getFlowBuilderPlugin","trackEvent","request","eventAction","args","flowBuilderPlugin","trackFlowContent","contents","cmsApi","content","trackOneContent","nodeContent","event","getContentEventArgs","action","eventArgs","setSessionFlowThreadId","flowThreadId","flowId","flowName","flowNodeId","flowNodeContentId","getCommonFlowContentEventArgs","getCommonFlowContentEventArgsForContentId","botContext","id"],"mappings":";;;;;;;;;AAA4E;AAEzC;AAOK;AAC8B;AAE/D,eAAeK,UAAUA,CAC9BC,OAAsB,EACtBC,WAAwB,EACxBC,IAA0B;IAE1B,MAAMC,oBAAoBL,oBAAoBA,CAACE,QAAQ,OAAO;IAC9D,IAAIG,kBAAkB,UAAU,EAAE;QAChC,MAAMA,kBAAkB,UAAU,CAACH,SAASC,aAAaC;IAC3D;IACA;AACF;AAEO,eAAeE,gBAAgBA,CACpCJ,OAAsB,EACtBK,QAAuB;IAEvB,MAAMF,oBAAoBL,oBAAoBA,CAACE,QAAQ,OAAO;IAC9D,MAAMM,SAASH,kBAAkB,MAAM;IACvC,KAAK,MAAMI,WAAWF,SAAU;QAC9B,MAAMG,eAAeA,CAACR,SAASO,SAASD;IAC1C;AACF;AAEO,eAAeE,eAAeA,CACnCR,OAAsB,EACtBO,OAAoB,EACpBD,MAAuB;IAEvB,IAAI,CAACA,QAAQ;QACX,MAAMH,oBAAoBL,oBAAoBA,CAACE,QAAQ,OAAO;QAC9DM,SAASH,kBAAkB,MAAM;IACnC;IAEA,MAAMM,cAAcH,OAAO,WAAW,CAAoBC,QAAQ,EAAE;IACpE,IAAIE,YAAY,IAAI,KAAKZ,8BAA8B,EAAE;QACvD,MAAMa,QAAQC,mBAAmBA,CAACX,SAASS;QAC3C,MAAM,EAAEG,MAAM,EAAE,GAAGC,WAAW,GAAGH;QACjC,MAAMX,UAAUA,CAACC,SAASY,QAAQC;IACpC;AACF;AAEA,SAASC,sBAAsBA,CAC7Bd,OAAsB,EACtBe,YAAoB;IAEpBf,QAAQ,OAAO,CAAC,cAAc,GAAGe;AACnC;AAEA,SAASJ,mBAAmBA,CAC1BX,OAAsB,EACtBS,WAA8B;IAE9B,MAAM,EAAEM,YAAY,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GACrEC,6BAA6BA,CAACpB,SAASS;IAEzCK,sBAAsBA,CAACd,SAASe;IAEhC,OAAO;QACL,QAAQrB,oBAAoB;QAC5BsB;QACAC;QACAC;QACAC;QACAJ;QACA,sBAAsBN,YAAY,aAAa,IAAI;IACrD;AACF;AAUA,SAASW,6BAA6BA,CACpCpB,OAAsB,EACtBS,WAA8B;IAE9B,MAAMN,oBAAoBL,oBAAoBA,CAACE,QAAQ,OAAO;IAC9D,MAAMiB,WAAWd,kBAAkB,WAAW,CAACM,YAAY,OAAO;IAClE,MAAMM,eAAef,QAAQ,OAAO,CAAC,cAAc,IAAIJ,EAAMA;IAE7D,OAAO;QACLmB;QACA,QAAQN,YAAY,OAAO;QAC3BQ;QACA,YAAYR,YAAY,EAAE;QAC1B,mBAAmBA,YAAY,IAAI,IAAI;IACzC;AACF;AAEO,SAASY,yCAAyCA,CACvDC,UAAsB,EACtBC,EAAU;IAEV,MAAMpB,oBAAoBL,oBAAoBA,CAACwB,WAAW,OAAO;IACjE,MAAMhB,SAASH,kBAAkB,MAAM;IACvC,MAAMM,cAAcH,OAAO,WAAW,CAAoBiB;IAE1D,OAAOH,6BAA6BA,CAACE,YAAYb;AACnD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["import type {\n AiAgentArgs,\n BotContext,\n GuardrailRule,\n InferenceResponse,\n PluginPreRequest,\n ResolvedPlugins,\n} from '@botonic/core'\nimport type { FlowContent } from './content-fields'\nimport type {\n HtFlowBuilderData,\n HtRatingButton,\n} from './content-fields/hubtype-fields'\nimport type { FlowBuilderContentMessage } from './structured-output/flow-builder-content'\n\nexport interface InShadowingConfig {\n allowKeywords: boolean\n allowSmartIntents: boolean\n allowAiAgents: boolean\n}\n\nexport interface BotonicPluginFlowBuilderOptions<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> {\n apiUrl?: string\n jsonVersion?: FlowBuilderJSONVersion\n flow?: HtFlowBuilderData\n customFunctions?: Record<any, any>\n getAccessToken: () => string\n trackEvent?: TrackEventFunction<TPlugins, TExtraData>\n getAiAgentResponse?: AiAgentFunction<TPlugins, TExtraData>\n smartIntentsConfig?: { numSmartIntentsToUse: number }\n inShadowing?: Partial<InShadowingConfig>\n contentFilters?: ContentFilter<TPlugins, TExtraData>[]\n customRatingMessageEnabled?: boolean\n disableAIAgentInFirstInteraction?: boolean\n}\n\nexport type TrackEventFunction<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> = (\n request: BotContext<TPlugins, TExtraData>,\n eventAction: string,\n args?: Record<string, any>\n) => Promise<void>\n\nexport type AiAgentFunction<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> = (\n request: BotContext<TPlugins, TExtraData>,\n aiAgentArgs: AiAgentArgs\n) => Promise<InferenceResponse<FlowBuilderContentMessage>>\n\nexport type ContentFilter<\n TPlugins extends ResolvedPlugins = ResolvedPlugins,\n TExtraData = any,\n> = (\n request: BotContext<TPlugins, TExtraData>,\n content: FlowContent\n) => Promise<FlowContent> | FlowContent\n\nexport interface FlowBuilderApiOptions {\n url: string\n flowUrl: string\n flow?: HtFlowBuilderData\n accessToken: string\n request: PluginPreRequest\n}\n\nexport enum ProcessEnvNodeEnvs {\n PRODUCTION = 'production',\n DEVELOPMENT = 'development',\n}\n\nexport enum FlowBuilderJSONVersion {\n DRAFT = 'draft',\n LATEST = 'latest',\n}\n\nexport interface SmartIntentResponse {\n data: {\n smart_intent_title: string\n text: string\n smart_intents_used: {\n title: string\n description: string\n }[]\n }\n}\n\nexport interface PayloadParamsBase {\n contentID: string\n followUpContentID?: string\n}\n\nexport interface RatingSubmittedInfo extends HtRatingButton {\n possibleOptions: string[]\n possibleValues: number[]\n}\n\nexport type { AiAgentArgs, GuardrailRule }\n"],"names":["ProcessEnvNodeEnvs","FlowBuilderJSONVersion"],"mappings":"AAwEO,IAAKA,wBAAkBA,0BAAlBA;;;WAAAA;MAGX;AAEM,IAAKC,4BAAsBA,0BAAtBA;;;WAAAA;MAGX"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-input/capture-user-input-api.js","sources":["../../../src/user-input/capture-user-input-api.ts"],"sourcesContent":["import { EventAction, type EventCaptureUserInput } from '@botonic/core'\nimport type { ActionRequest } from '@botonic/react'\nimport axios from 'axios'\n\nimport type { FlowBuilderApi } from '../api'\nimport { FlowCaptureUserInput } from '../content-fields'\nimport {\n HtAiValidationType,\n type HtCaptureUserInputNode,\n} from '../content-fields/hubtype-fields'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\nimport { inputHasTextOrTranscript } from '../utils/input'\n\ninterface AiCaptureResponseSuccess {\n success: true\n value: string\n}\n\ninterface AiCaptureResponseFailure {\n success: false\n}\n\ntype AiCaptureResponse = AiCaptureResponseSuccess | AiCaptureResponseFailure\n\nexport class CaptureUserInputApi {\n private cmsApi: FlowBuilderApi\n private request: ActionRequest\n private textOrTranscript: string\n\n constructor(\n cmsApi: FlowBuilderApi,\n request: ActionRequest,\n textOrTranscript: string\n ) {\n this.cmsApi = cmsApi\n this.request = request\n this.textOrTranscript = textOrTranscript\n }\n\n async getNextNodeId(): Promise<string | undefined> {\n if (\n inputHasTextOrTranscript(this.request.input) &&\n this.cmsApi.shouldCaptureUserInput()\n ) {\n const captureUserInputNode = this.cmsApi.getCaptureUserInputNode()\n if (!captureUserInputNode || !this.textOrTranscript) {\n return undefined\n }\n const captureUserInput =\n FlowCaptureUserInput.fromHubtypeCMS(captureUserInputNode)\n\n if (captureUserInput.aiValidationType === HtAiValidationType.NONE) {\n this.cmsApi.setUserExtraDataVariable(\n captureUserInputNode.content.field_name,\n this.textOrTranscript\n )\n await this.trackUserInputCapture(captureUserInputNode, true)\n return captureUserInput.captureSuccessId\n }\n\n const aiCaptureResponse =\n await this.getAiCaptureResponse(captureUserInputNode)\n if (!aiCaptureResponse.success) {\n await this.trackUserInputCapture(captureUserInputNode, false)\n return captureUserInput.captureFailId\n }\n\n this.cmsApi.setUserExtraDataVariable(\n captureUserInputNode.content.field_name,\n aiCaptureResponse.value\n )\n await this.trackUserInputCapture(captureUserInputNode, true)\n return captureUserInput.captureSuccessId\n }\n return undefined\n }\n\n async getAiCaptureResponse(\n captureUserInputNode: HtCaptureUserInputNode\n ): Promise<AiCaptureResponse> {\n try {\n const url = `${process.env.HUBTYPE_API_URL}/external/v1/capture_user_input/`\n const data = {\n field_name: captureUserInputNode.content.field_name,\n validation_instructions:\n captureUserInputNode.content.ai_validation_instructions,\n user_input: this.textOrTranscript,\n }\n const pluginFlowBuilder = getFlowBuilderPlugin(this.request.plugins)\n const token = pluginFlowBuilder.getAccessToken(this.request.session)\n\n const config = {\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n },\n }\n\n const aiCaptureResponse = await axios.post<AiCaptureResponse>(\n url,\n data,\n config\n )\n\n return aiCaptureResponse.data\n } catch (error) {\n console.warn('Error getting ai/capture_user_input', error)\n }\n\n return {\n success: false,\n }\n }\n\n async trackUserInputCapture(\n captureUserInputNode: HtCaptureUserInputNode,\n captureSuccess: boolean\n ): Promise<void> {\n const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(\n this.request,\n captureUserInputNode.id\n )\n const event: EventCaptureUserInput = {\n action: EventAction.CaptureUserInput,\n flowThreadId,\n flowId,\n flowName,\n flowNodeId,\n flowNodeContentId,\n flowNodeIsMeaningful: false,\n fieldName: captureUserInputNode.content.field_name,\n userInput: this.textOrTranscript,\n captureSuccess,\n messageId: this.request.input.message_id,\n }\n const { action, ...eventArgs } = event\n await trackEvent(this.request, action, eventArgs)\n }\n}\n"],"names":["EventAction","axios","FlowCaptureUserInput","HtAiValidationType","getCommonFlowContentEventArgsForContentId","trackEvent","getFlowBuilderPlugin","inputHasTextOrTranscript","CaptureUserInputApi","captureUserInputNode","undefined","captureUserInput","aiCaptureResponse","url","process","data","pluginFlowBuilder","token","config","error","console","captureSuccess","flowThreadId","flowId","flowName","flowNodeId","flowNodeContentId","event","action","eventArgs","cmsApi","request","textOrTranscript"],"mappings":";;;;;;;;;;;;;;;AAAuE;AAE9C;AAG+B;AAIf;AAIrB;AACmD;AACd;AAalD,MAAMQ,mBAAmBA;IAe9B,MAAM,gBAA6C;QACjD,IACED,wBAAwBA,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,KAC3C,IAAI,CAAC,MAAM,CAAC,sBAAsB,IAClC;YACA,MAAME,uBAAuB,IAAI,CAAC,MAAM,CAAC,uBAAuB;YAChE,IAAI,CAACA,wBAAwB,CAAC,IAAI,CAAC,gBAAgB,EAAE;gBACnD,OAAOC;YACT;YACA,MAAMC,mBACJT,mCAAmC,CAACO;YAEtC,IAAIE,iBAAiB,gBAAgB,KAAKR,uBAAuB,EAAE;gBACjE,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAClCM,qBAAqB,OAAO,CAAC,UAAU,EACvC,IAAI,CAAC,gBAAgB;gBAEvB,MAAM,IAAI,CAAC,qBAAqB,CAACA,sBAAsB;gBACvD,OAAOE,iBAAiB,gBAAgB;YAC1C;YAEA,MAAMC,oBACJ,MAAM,IAAI,CAAC,oBAAoB,CAACH;YAClC,IAAI,CAACG,kBAAkB,OAAO,EAAE;gBAC9B,MAAM,IAAI,CAAC,qBAAqB,CAACH,sBAAsB;gBACvD,OAAOE,iBAAiB,aAAa;YACvC;YAEA,IAAI,CAAC,MAAM,CAAC,wBAAw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,CAAC,KAAK,CAAC,UAAU;QAC1C;QACA,MAAM,EAAEO,MAAM,EAAE,GAAGC,WAAW,GAAGF;QACjC,MAAMtB,UAAUA,CAAC,IAAI,CAAC,OAAO,EAAEuB,QAAQC;IACzC;IA7GA,YACEC,MAAsB,EACtBC,OAAsB,EACtBC,gBAAwB,CACxB;QACA,IAAI,CAAC,MAAM,GAAGF;QACd,IAAI,CAAC,OAAO,GAAGC;QACf,IAAI,CAAC,gBAAgB,GAAGC;IAC1B;AAsGF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-input/index.js","sources":["../../../src/user-input/index.ts"],"sourcesContent":["import type { ActionRequest } from '@botonic/react'\n\nimport type { FlowBuilderApi } from '../api'\nimport {\n getTextOrTranscript,\n isKeywordsAllowed,\n isSmartIntentsAllowed,\n} from '../utils/input'\nimport { CaptureUserInputApi } from './capture-user-input-api'\nimport { KeywordMatcher } from './keyword'\nimport {\n SmartIntentsApi,\n type SmartIntentsInferenceConfig,\n} from './smart-intent'\n\nexport async function getNextPayloadByUserInput(\n cmsApi: FlowBuilderApi,\n locale: string,\n request: ActionRequest,\n smartIntentsConfig: SmartIntentsInferenceConfig\n): Promise<string | undefined> {\n const userTextOrTranscript = getTextOrTranscript(request.input)\n if (userTextOrTranscript) {\n if (cmsApi.shouldCaptureUserInput()) {\n const captureUserInputApi = new CaptureUserInputApi(\n cmsApi,\n request,\n userTextOrTranscript\n )\n return await captureUserInputApi.getNextNodeId()\n }\n\n if (isKeywordsAllowed(request)) {\n const keywordMatcher = new KeywordMatcher({\n cmsApi,\n locale,\n request,\n userTextOrTranscript,\n })\n const keywordNode = await keywordMatcher.getNodeByInput()\n if (keywordNode) {\n return cmsApi.getPayload(keywordNode.target)\n }\n }\n\n if (isSmartIntentsAllowed(request)) {\n const smartIntentsApi = new SmartIntentsApi(\n cmsApi,\n request,\n smartIntentsConfig,\n userTextOrTranscript\n )\n const smartIntentNode = await smartIntentsApi.getNodeByInput()\n if (smartIntentNode) {\n return cmsApi.getPayload(smartIntentNode.target)\n }\n }\n }\n\n return undefined\n}\n"],"names":["getTextOrTranscript","isKeywordsAllowed","isSmartIntentsAllowed","CaptureUserInputApi","KeywordMatcher","SmartIntentsApi","getNextPayloadByUserInput","cmsApi","locale","request","smartIntentsConfig","userTextOrTranscript","captureUserInputApi","keywordMatcher","keywordNode","smartIntentsApi","smartIntentNode","undefined"],"mappings":";;;;;;;;;AAOuB;AACuC;AACpB;AAInB;AAEhB,eAAeM,yBAAyBA,CAC7CC,MAAsB,EACtBC,MAAc,EACdC,OAAsB,EACtBC,kBAA+C;IAE/C,MAAMC,uBAAuBX,mBAAmBA,CAACS,QAAQ,KAAK;IAC9D,IAAIE,sBAAsB;QACxB,IAAIJ,OAAO,sBAAsB,IAAI;YACnC,MAAMK,sBAAsB,IAAIT,mBAAmBA,CACjDI,QACAE,SACAE;YAEF,OAAO,MAAMC,oBAAoB,aAAa;QAChD;QAEA,IAAIX,iBAAiBA,CAACQ,UAAU;YAC9B,MAAMI,iBAAiB,IAAIT,cAAcA,CAAC;gBACxCG;gBACAC;gBACAC;gBACAE;YACF;YACA,MAAMG,cAAc,MAAMD,eAAe,cAAc;YACvD,IAAIC,aAAa;gBACf,OAAOP,OAAO,UAAU,CAACO,YAAY,MAAM;YAC7C;QACF;QAEA,IAAIZ,qBAAqBA,CAACO,UAAU;YAClC,MAAMM,kBAAkB,IAAIV,eAAeA,CACzCE,QACAE,SACAC,oBACAC;YAEF,MAAMK,kBAAkB,MAAMD,gBAAgB,cAAc;YAC5D,IAAIC,iBAAiB;gBACnB,OAAOT,OAAO,UAAU,CAACS,gBAAgB,MAAM;YACjD;QACF;IACF;IAEA,OAAOC;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-input/keyword.js","sources":["../../../src/user-input/keyword.ts"],"sourcesContent":["import { EventAction, type EventKeyword, NluType } from '@botonic/core'\nimport type { ActionRequest } from '@botonic/react'\n\nimport type { FlowBuilderApi } from '../api'\nimport { REG_EXP_PATTERN } from '../constants'\nimport type {\n HtKeywordNode,\n HtNodeWithContent,\n} from '../content-fields/hubtype-fields'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\n\ninterface KeywordProps {\n cmsApi: FlowBuilderApi\n locale: string\n request: ActionRequest\n userTextOrTranscript: string\n}\nexport class KeywordMatcher {\n public cmsApi: FlowBuilderApi\n public locale: string\n public request: ActionRequest\n public isRegExp: boolean\n public matchedKeyword?: string\n public keywordNodeId?: string\n public flowId?: string\n public userTextOrTranscript: string\n\n constructor({ cmsApi, locale, request, userTextOrTranscript }: KeywordProps) {\n this.cmsApi = cmsApi\n this.locale = locale\n this.request = request\n this.isRegExp = false\n this.userTextOrTranscript = userTextOrTranscript\n }\n\n async getNodeByInput(): Promise<HtKeywordNode | undefined> {\n const keywordNodes = this.cmsApi.getKeywordNodes()\n const keywordNode = this.getNodeByKeyword(\n this.userTextOrTranscript,\n keywordNodes\n )\n if (!keywordNode || !this.matchedKeyword) {\n return undefined\n }\n const targetPayload = this.cmsApi.getPayload(keywordNode.target)\n\n this.request.input.nluResolution = {\n type: NluType.Keyword,\n matchedValue: this.matchedKeyword,\n payload: targetPayload,\n }\n await this.trackKeywordEvent()\n return keywordNode\n }\n\n private getNodeByKeyword(\n userInput: string,\n keywordNodes: HtKeywordNode[]\n ): HtKeywordNode | undefined {\n const matchedKeywordNode = keywordNodes.find(node =>\n this.matchKeywords(userInput, node)\n )\n\n return matchedKeywordNode?.target ? matchedKeywordNode : undefined\n }\n\n private matchKeywords(userInput: string, node: HtKeywordNode): boolean {\n const result = node.content.keywords.find(keywords => {\n if (keywords.locale === this.locale) {\n this.keywordNodeId = node.id\n this.flowId = this.cmsApi.getNodeById<HtNodeWithContent>(\n node.id\n ).flow_id\n return this.inputMatchesAnyKeyword(userInput, keywords.values)\n }\n\n return false\n })\n\n return Boolean(result)\n }\n\n private inputMatchesAnyKeyword(\n userInput: string,\n keywords: string[]\n ): boolean {\n return keywords.some(keyword => {\n const regExpMatchArray = keyword.match(REG_EXP_PATTERN)\n\n if (regExpMatchArray) {\n const keywordAsRegExp = this.resolveKeywordAsRegExp(regExpMatchArray)\n const match = userInput.match(keywordAsRegExp)\n this.isRegExp = true\n this.matchedKeyword = match ? match[0] : undefined\n } else {\n this.isRegExp = false\n this.matchedKeyword = userInput.includes(keyword) ? keyword : undefined\n }\n\n return this.matchedKeyword !== undefined\n })\n }\n\n private resolveKeywordAsRegExp(regExpMatchArray: RegExpMatchArray): RegExp {\n const [, pattern, flags] = regExpMatchArray\n return new RegExp(pattern, flags)\n }\n\n private async trackKeywordEvent() {\n const { flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(\n this.request,\n this.keywordNodeId as string\n )\n\n const event: EventKeyword = {\n action: EventAction.Keyword,\n flowNodeId,\n flowId,\n flowName,\n flowNodeContentId,\n flowThreadId: this.request.session.flow_thread_id as string,\n nluKeywordName: this.matchedKeyword as string,\n nluKeywordIsRegex: this.isRegExp,\n nluKeywordMessageId: this.request.input.message_id,\n userInput: this.userTextOrTranscript,\n }\n const { action, ...eventArgs } = event\n await trackEvent(this.request, action, eventArgs)\n }\n}\n"],"names":["EventAction","NluType","REG_EXP_PATTERN","getCommonFlowContentEventArgsForContentId","trackEvent","KeywordMatcher","keywordNodes","keywordNode","undefined","targetPayload","userInput","matchedKeywordNode","node","result","keywords","Boolean","keyword","regExpMatchArray","keywordAsRegExp","match","pattern","flags","RegExp","flowId","flowName","flowNodeId","flowNodeContentId","event","action","eventArgs","cmsApi","locale","request","userTextOrTranscript"],"mappings":";;;;;;;AAAuE;AAIzB;AAQ1B;AAQb,MAAMK,cAAcA;IAkBzB,MAAM,iBAAqD;QACzD,MAAMC,eAAe,IAAI,CAAC,MAAM,CAAC,eAAe;QAChD,MAAMC,cAAc,IAAI,CAAC,gBAAgB,CACvC,IAAI,CAAC,oBAAoB,EACzBD;QAEF,IAAI,CAACC,eAAe,CAAC,IAAI,CAAC,cAAc,EAAE;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BAChB,IAAI,CAAC,cAAc,GAAGE,UAAU,QAAQ,CAACM,WAAWA,UAAUR;YAChE;YAEA,OAAO,IAAI,CAAC,cAAc,KAAKA;QACjC;IACF;IAEQ,uBAAuBS,gBAAkC,EAAU;QACzE,MAAM,GAAGG,SAASC,MAAM,GAAGJ;QAC3B,OAAO,IAAIK,OAAOF,SAASC;IAC7B;IAEA,MAAc,oBAAoB;QAChC,MAAM,EAAEE,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,iBAAiB,EAAE,GACvDvB,yCAAyCA,CACvC,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,aAAa;QAGtB,MAAMwB,QAAsB;YAC1B,QAAQ3B,mBAAmB;YAC3ByB;YACAF;YACAC;YACAE;YACA,cAAc,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc;YACjD,gBAAgB,IAAI,CAAC,cAAc;YACnC,mBAAmB,IAAI,CAAC,QAAQ;YAChC,qBAAqB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU;YAClD,WAAW,IAAI,CAAC,oBAAoB;QACtC;QACA,MAAM,EAAEE,MAAM,EAAE,GAAGC,WAAW,GAAGF;QACjC,MAAMvB,UAAUA,CAAC,IAAI,CAAC,OAAO,EAAEwB,QAAQC;IACzC;IAtGA,YAAY,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAEC,oBAAoB,EAAgB,CAAE;QAC3E,IAAI,CAAC,MAAM,GAAGH;QACd,IAAI,CAAC,MAAM,GAAGC;QACd,IAAI,CAAC,OAAO,GAAGC;QACf,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,oBAAoB,GAAGC;IAC9B;AAiGF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-input/smart-intent.js","sources":["../../../src/user-input/smart-intent.ts"],"sourcesContent":["import { EventAction, type EventIntentSmart, NluType } from '@botonic/core'\nimport type { ActionRequest } from '@botonic/react'\nimport axios from 'axios'\n\nimport type { FlowBuilderApi } from '../api'\nimport type { HtSmartIntentNode } from '../content-fields/hubtype-fields/smart-intent'\nimport {\n getCommonFlowContentEventArgsForContentId,\n trackEvent,\n} from '../tracking'\nimport type { SmartIntentResponse } from '../types'\nimport { getFlowBuilderPlugin } from '../utils/get-flow-builder-plugin'\n\nexport interface SmartIntentsInferenceParams {\n bot_id: string\n text: string\n num_smart_intents_to_use?: number\n use_latest: boolean\n disabled_smart_intent_titles: string[]\n}\n\nexport interface SmartIntentsInferenceConfig {\n useLatest: boolean\n numSmartIntentsToUse?: number\n}\n\nexport class SmartIntentsApi {\n constructor(\n public cmsApi: FlowBuilderApi,\n public currentRequest: ActionRequest,\n public smartIntentsConfig: SmartIntentsInferenceConfig,\n public userTextOrTranscript: string\n ) {}\n\n async getNodeByInput(): Promise<HtSmartIntentNode | undefined> {\n if (!this.userTextOrTranscript) {\n return undefined\n }\n const smartIntentNodes = this.cmsApi.getSmartIntentNodes()\n if (!smartIntentNodes.length) {\n return undefined\n }\n\n const disabledSmartIntentTitles = smartIntentNodes\n .filter(smartIntentNode => smartIntentNode.content.is_active === false)\n .map(smartIntentNode => smartIntentNode.content.title)\n\n const params = {\n bot_id: this.currentRequest.session.bot.id,\n text: this.userTextOrTranscript,\n num_smart_intents_to_use: this.smartIntentsConfig.numSmartIntentsToUse,\n use_latest: this.resolveUseLatest(),\n disabled_smart_intent_titles: disabledSmartIntentTitles,\n }\n\n try {\n const response = await this.getInference(params)\n const smartIntentNode = smartIntentNodes.find(\n smartIntentNode =>\n smartIntentNode.content.title === response.data.smart_intent_title\n )\n\n if (smartIntentNode) {\n const targetPayload = this.cmsApi.getPayload(smartIntentNode.target)\n this.currentRequest.input.nluResolution = {\n type: NluType.SmartIntent,\n matchedValue: smartIntentNode.content.title,\n payload: targetPayload,\n }\n\n const { flowId, flowName, flowNodeId, flowNodeContentId } =\n getCommonFlowContentEventArgsForContentId(\n this.currentRequest,\n smartIntentNode.id\n )\n\n const event: EventIntentSmart = {\n action: EventAction.IntentSmart,\n nluIntentSmartTitle: response.data.smart_intent_title,\n nluIntentSmartNumUsed: response.data.smart_intents_used.length,\n nluIntentSmartMessageId: this.currentRequest.input.message_id,\n userInput: this.userTextOrTranscript,\n flowThreadId: this.currentRequest.session.flow_thread_id as string,\n flowId,\n flowName,\n flowNodeContentId,\n flowNodeId,\n }\n const { action, ...eventArgs } = event\n\n await trackEvent(this.currentRequest, action, eventArgs)\n\n return smartIntentNode\n }\n } catch (e) {\n console.error(e)\n }\n return undefined\n }\n\n private resolveUseLatest(): boolean {\n if (this.currentRequest.session.is_test_integration) {\n return false\n }\n return this.smartIntentsConfig.useLatest\n }\n\n private async getInference(\n inferenceParams: SmartIntentsInferenceParams\n ): Promise<SmartIntentResponse> {\n const pluginFlowBuilder = getFlowBuilderPlugin(this.currentRequest.plugins)\n const token = pluginFlowBuilder.getAccessToken(this.currentRequest.session)\n\n return await axios({\n method: 'POST',\n url: `${process.env.HUBTYPE_API_URL}/external/v2/ai/smart_intents/inference/`,\n headers: {\n Authorization: `Bearer ${token}`,\n 'Content-Type': 'application/json',\n },\n data: inferenceParams,\n timeout: 10000,\n })\n }\n}\n"],"names":["EventAction","NluType","axios","getCommonFlowContentEventArgsForContentId","trackEvent","getFlowBuilderPlugin","SmartIntentsApi","undefined","smartIntentNodes","disabledSmartIntentTitles","smartIntentNode","params","response","targetPayload","flowId","flowName","flowNodeId","flowNodeContentId","event","action","eventArgs","e","console","inferenceParams","pluginFlowBuilder","token","process","cmsApi","currentRequest","smartIntentsConfig","userTextOrTranscript"],"mappings":";;;;;;;;;AAA2E;AAElD;AAOL;AAEmD;AAehE,MAAMM,eAAeA;IAQ1B,MAAM,iBAAyD;QAC7D,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAC9B,OAAOC;QACT;QACA,MAAMC,mBAAmB,IAAI,CAAC,MAAM,CAAC,mBAAmB;QACxD,IAAI,CAACA,iBAAiB,MAAM,EAAE;YAC5B,OAAOD;QACT;QAEA,MAAME,4BAA4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AE;oBACAD;gBACF;gBACA,MAAM,EAAEG,MAAM,EAAE,GAAGC,WAAW,GAAGF;gBAEjC,MAAMd,UAAUA,CAAC,IAAI,CAAC,cAAc,EAAEe,QAAQC;gBAE9C,OAAOV;YACT;QACF,EAAE,OAAOW,GAAG;YACVC,QAAQ,KAAK,CAACD;QAChB;QACA,OAAOd;IACT;IAEQ,mBAA4B;QAClC,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,mBAAmB,EAAE;YACnD,OAAO;QACT;QACA,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS;IAC1C;IAEA,MAAc,aACZgB,eAA4C,EACd;QAC9B,MAAMC,oBAAoBnB,oBAAoBA,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO;QAC1E,MAAMoB,QAAQD,kBAAkB,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO;QAE1E,OAAO,MAAMtB,KAAKA,CAAC;YACjB,QAAQ;YACR,KAAK,GAAGwB,QAAQ,GAAG,CAAC,eAAe,CAAC,wCAAwC,CAAC;YAC7E,SAAS;gBACP,eAAe,CAAC,OAAO,EAAED,OAAO;gBAChC,gBAAgB;YAClB;YACA,MAAMF;YACN,SAAS;QACX;IACF;IAhGA,YACSI,MAAsB,EACtBC,cAA6B,EAC7BC,kBAA+C,EAC/CC,oBAA4B,CACnC;aAJOH,SAAAA;aACAC,iBAAAA;aACAC,qBAAAA;aACAC,uBAAAA;IACN;AA4FL"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils/ai-agent.js","sources":["../../../src/utils/ai-agent.ts"],"sourcesContent":["import { FlowAiAgentRouter } from '../content-fields/flow-ai-agent-router'\nimport { FlowAiAgent, type FlowContent } from '../content-fields/index'\n\nexport { HubtypeAssistantContent } from './hubtype-assistant-content'\n\ntype AiAgentContentAndContentsBeforeAiAgent =\n | {\n aiAgentWorkerContent: FlowAiAgent\n contentsBeforeAiAgentWorker: FlowContent[]\n }\n | {\n aiAgentRouterContent: FlowAiAgentRouter\n contentsBeforeAiAgentRouter: FlowContent[]\n }\n\nexport function splitAiAgentContents(\n contents: FlowContent[]\n): AiAgentContentAndContentsBeforeAiAgent | undefined {\n const aiAgentRouterIndex = contents.findIndex(\n content => content instanceof FlowAiAgentRouter\n )\n if (aiAgentRouterIndex >= 0) {\n return {\n aiAgentRouterContent: contents[aiAgentRouterIndex] as FlowAiAgentRouter,\n contentsBeforeAiAgentRouter: contents.slice(0, aiAgentRouterIndex),\n }\n }\n\n const aiAgentIndex = contents.findIndex(\n content => content instanceof FlowAiAgent\n )\n if (aiAgentIndex < 0) {\n return undefined\n }\n\n const aiAgentWorkerContent = contents[aiAgentIndex] as FlowAiAgent\n const contentsBeforeAiAgentWorker = contents.slice(0, aiAgentIndex)\n\n return {\n aiAgentWorkerContent,\n contentsBeforeAiAgentWorker,\n }\n}\n"],"names":["FlowAiAgentRouter","FlowAiAgent","HubtypeAssistantContent","splitAiAgentContents","contents","aiAgentRouterIndex","content","aiAgentIndex","undefined","aiAgentWorkerContent","contentsBeforeAiAgentWorker"],"mappings":";;;;;;AAA0E;AACH;AAEF;AAY9D,SAASG,oBAAoBA,CAClCC,QAAuB;IAEvB,MAAMC,qBAAqBD,SAAS,SAAS,CAC3CE,CAAAA,UAAWA,mBAAmBN,iBAAiBA;IAEjD,IAAIK,sBAAsB,GAAG;QAC3B,OAAO;YACL,sBAAsBD,QAAQ,CAACC,mBAAmB;YAClD,6BAA6BD,SAAS,KAAK,CAAC,GAAGC;QACjD;IACF;IAEA,MAAME,eAAeH,SAAS,SAAS,CACrCE,CAAAA,UAAWA,mBAAmBL,WAAWA;IAE3C,IAAIM,eAAe,GAAG;QACpB,OAAOC;IACT;IAEA,MAAMC,uBAAuBL,QAAQ,CAACG,aAAa;IACnD,MAAMG,8BAA8BN,SAAS,KAAK,CAAC,GAAGG;IAEtD,OAAO;QACLE;QACAC;IACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils/authentication.js","sources":["../../../src/utils/authentication.ts"],"sourcesContent":["import type { Session } from '@botonic/core'\n\nimport { ProcessEnvNodeEnvs } from '../types'\n\nfunction getAccessTokenFromSession(session: Session): string {\n if (!session._access_token) {\n throw new Error('No access token found in session')\n }\n return session._access_token\n}\n\nexport function resolveGetAccessToken(\n getAccessToken: (session: Session) => string\n): (session: Session) => string {\n switch (process.env.NODE_ENV) {\n case ProcessEnvNodeEnvs.PRODUCTION:\n return getAccessTokenFromSession\n case ProcessEnvNodeEnvs.DEVELOPMENT:\n return getAccessToken\n default:\n throw new Error('No method defined for getting access token')\n }\n}\n"],"names":["ProcessEnvNodeEnvs","getAccessTokenFromSession","session","Error","resolveGetAccessToken","getAccessToken","process"],"mappings":";;;AAE6C;AAE7C,SAASC,yBAAyBA,CAACC,OAAgB;IACjD,IAAI,CAACA,QAAQ,aAAa,EAAE;QAC1B,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOD,QAAQ,aAAa;AAC9B;AAEO,SAASE,qBAAqBA,CACnCC,cAA4C;IAE5C,OAAQC,oBAAoB;QAC1B,KAAKN,6BAA6B;YAChC,OAAOC,yBAAyBA;QAClC,KAAKD,8BAA8B;YACjC,OAAOK;QACT;YACE,MAAM,IAAIF,MAAM;IACpB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils/flow-locale.js","sources":["../../../src/utils/flow-locale.ts"],"sourcesContent":["import type { BotContext } from '@botonic/core'\n\nexport class FlowLocale {\n constructor(\n private readonly botContext: BotContext,\n private readonly flowLocales: string[],\n private readonly defaultLocaleCode: string\n ) {}\n\n resolve(): string {\n const priorityLocale = this.isLanguageDetectionEnabled()\n ? this.getPriorityLocale()\n : this.botContext.getSystemLocale()\n\n if (priorityLocale) {\n const exactMatch = this.matchExactLocale(priorityLocale)\n if (exactMatch) {\n return this.applyLocale(exactMatch)\n }\n\n const languageMatch = this.matchLanguage(priorityLocale)\n if (languageMatch) {\n return this.applyLocale(languageMatch)\n }\n }\n\n return this.applyLocale(this.getDefaultLocale())\n }\n\n private isLanguageDetectionEnabled(): boolean {\n return !!this.botContext.settings?.LANGUAGE_DETECTION_ENABLED\n }\n\n /**\n * Rules:\n * - If user and system languages differ, user locale takes priority.\n * - If both share the same language, the more specific locale wins.\n * - If both have the same specificity, user locale wins.\n */\n private getPriorityLocale(): string | undefined {\n const userLocale = this.botContext.getUserLocale()\n const systemLocale = this.botContext.getSystemLocale()\n\n if (!userLocale || !systemLocale) {\n return undefined\n }\n\n const userLanguage = this.getLanguage(userLocale)\n const systemLanguage = this.getLanguage(systemLocale)\n\n if (userLanguage !== systemLanguage) {\n return userLocale\n }\n const userIsSpecific = this.isSpecificLocale(userLocale)\n const systemIsSpecific = this.isSpecificLocale(systemLocale)\n\n if (userIsSpecific && !systemIsSpecific) {\n return userLocale\n }\n if (!userIsSpecific && systemIsSpecific) {\n return systemLocale\n }\n\n return userLocale\n }\n\n private matchExactLocale(locale: string): string | undefined {\n return this.flowLocales.includes(locale) ? locale : undefined\n }\n\n private matchLanguage(locale: string): string | undefined {\n const language = this.getLanguage(locale)\n return this.flowLocales.includes(language) ? language : undefined\n }\n\n private getDefaultLocale(): string {\n return this.defaultLocaleCode || 'en'\n }\n\n private applyLocale(locale: string): string {\n this.botContext.setSystemLocale(locale)\n this.botContext.session.user.system_locale_updated = true\n return locale\n }\n\n private getLanguage(locale: string): string {\n return locale.split('-')[0]\n }\n\n private isSpecificLocale(locale: string): boolean {\n return locale.includes('-')\n }\n}\n"],"names":["FlowLocale","priorityLocale","exactMatch","languageMatch","userLocale","systemLocale","undefined","userLanguage","systemLanguage","userIsSpecific","systemIsSpecific","locale","language","botContext","flowLocales","defaultLocaleCode"],"mappings":"AAEO,MAAMA,UAAUA;IAOrB,UAAkB;QAChB,MAAMC,iBAAiB,IAAI,CAAC,0BAA0B,KAClD,IAAI,CAAC,iBAAiB,KACtB,IAAI,CAAC,UAAU,CAAC,eAAe;QAEnC,IAAIA,gBAAgB;YAClB,MAAMC,aAAa,IAAI,CAAC,gBAAgB,CAACD;Y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e,CAACA;QAChC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,qBAAqB,GAAG;QACrD,OAAOA;IACT;IAEQ,YAAYA,MAAc,EAAU;QAC1C,OAAOA,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE;IAC7B;IAEQ,iBAAiBA,MAAc,EAAW;QAChD,OAAOA,OAAO,QAAQ,CAAC;IACzB;IAxFA,YACmBE,UAAsB,EACtBC,WAAqB,EACrBC,iBAAyB,CAC1C;aAHiBF,aAAAA;aACAC,cAAAA;aACAC,oBAAAA;IAChB;AAqFL"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils/get-flow-builder-plugin.js","sources":["../../../src/utils/get-flow-builder-plugin.ts"],"sourcesContent":["import type { ResolvedPlugins } from '@botonic/core'\n\nimport type BotonicPluginFlowBuilder from '../index'\n\nconst FLOW_BUILDER_PLUGIN_NAME = 'BotonicPluginFlowBuilder'\n\nexport function getFlowBuilderPlugin(\n plugins: ResolvedPlugins\n): BotonicPluginFlowBuilder {\n const ERROR_MESSAGE = `You must include '@botonic/plugin-flow-builder' in your plugins file.`\n\n if (Object.values(plugins).length === 0) {\n throw new Error(ERROR_MESSAGE)\n }\n\n const flowBuilderPlugin = Object.values(plugins).find(\n plugin => plugin.constructor.name === FLOW_BUILDER_PLUGIN_NAME\n ) as unknown as BotonicPluginFlowBuilder\n\n if (!flowBuilderPlugin) {\n throw new Error(ERROR_MESSAGE)\n }\n\n return flowBuilderPlugin\n}\n"],"names":["FLOW_BUILDER_PLUGIN_NAME","getFlowBuilderPlugin","plugins","ERROR_MESSAGE","Object","Error","flowBuilderPlugin","plugin"],"mappings":"AAIA,MAAMA,wBAAwBA,GAAG;AAE1B,SAASC,oBAAoBA,CAClCC,OAAwB;IAExB,MAAMC,gBAAgB,CAAC,qEAAqE,CAAC;IAE7F,IAAIC,OAAO,MAAM,CAACF,SAAS,MAAM,KAAK,GAAG;QACvC,MAAM,IAAIG,MAAMF;IAClB;IAEA,MAAMG,oBAAoBF,OAAO,MAAM,CAACF,SAAS,IAAI,CACnDK,CAAAA,SAAUA,OAAO,WAAW,CAAC,IAAI,KAAKP,wBAAwBA;IAGhE,IAAI,CAACM,mBAAmB;QACtB,MAAM,IAAID,MAAMF;IAClB;IAEA,OAAOG;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils/hubtype-assistant-content.js","sources":["../../../src/utils/hubtype-assistant-content.ts"],"sourcesContent":["import { WhatsappCTAUrlHeaderType } from '@botonic/react'\nimport type { FlowContent } from '../content-fields'\nimport type { FlowButton } from '../content-fields/flow-button'\nimport { FlowCarousel } from '../content-fields/flow-carousel'\nimport { FlowImage } from '../content-fields/flow-image'\nimport { FlowText } from '../content-fields/flow-text'\nimport { FlowVideo } from '../content-fields/flow-video'\nimport { FlowWhatsappCtaUrlButtonNode } from '../content-fields/flow-whatsapp-cta-url-button'\nimport { FlowWhatsappTemplate } from '../content-fields/flow-whatsapp-template'\nimport { HtButtonStyle } from '../content-fields/hubtype-fields'\nimport { FlowWhatsappButtonList } from '../content-fields/whatsapp-button-list/flow-whatsapp-button-list'\n\n// biome-ignore lint/complexity/noStaticOnlyClass: namespace-like adapter with private static helpers\nexport class HubtypeAssistantContent {\n static adapt(content: FlowContent): string {\n if (content instanceof FlowText) {\n return HubtypeAssistantContent.formatFlowTextContent(content)\n }\n if (content instanceof FlowCarousel) {\n return HubtypeAssistantContent.formatCarouselContent(content)\n }\n if (content instanceof FlowImage) {\n return content.src ? `[Image]\\n${content.src}` : '[Image]'\n }\n if (content instanceof FlowVideo) {\n return content.src ? `[Video]\\n${content.src}` : '[Video]'\n }\n if (content instanceof FlowWhatsappButtonList) {\n return HubtypeAssistantContent.formatWhatsappButtonListContent(content)\n }\n if (content instanceof FlowWhatsappCtaUrlButtonNode) {\n return HubtypeAssistantContent.formatWhatsappCtaContent(content)\n }\n if (content instanceof FlowWhatsappTemplate) {\n return HubtypeAssistantContent.formatWhatsappTemplateContent(content)\n }\n return ''\n }\n\n private static quickReplyLabel(button: FlowButton): string {\n const buttonText = button.text?.trim()\n if (buttonText) {\n return buttonText\n }\n\n return button.payload || 'Option'\n }\n\n private static persistentButtonLabel(button: FlowButton): string {\n return button.text?.trim() || 'Button'\n }\n\n private static carouselButtonLabel(button: FlowButton): string {\n return button.text?.trim() || 'Action'\n }\n\n private static formatFlowTextContent(text: FlowText): string {\n const body = text.text?.trim() ?? ''\n const buttons = text.buttons\n\n if (!body && buttons.length === 0) {\n return ''\n }\n\n if (buttons.length === 0) {\n return text.text\n }\n\n const isQuickReply = text.buttonStyle === HtButtonStyle.QUICK_REPLY\n const blockTitle = isQuickReply ? 'Quick replies:' : 'Buttons:'\n const lines = buttons.map((button, i) => {\n const label = isQuickReply\n ? HubtypeAssistantContent.quickReplyLabel(button)\n : HubtypeAssistantContent.persistentButtonLabel(button)\n return ` [${i + 1}] ${label}`\n })\n\n const block = [blockTitle, ...lines].join('\\n')\n if (!body) {\n return block\n }\n\n return `${body}\\n\\n${block}`\n }\n\n private static formatCarouselContent(carousel: FlowCarousel): string {\n const elements = carousel.elements\n const n = elements.length\n const mainText = (carousel.whatsappText ?? '').trim()\n\n if (n === 0) {\n return mainText\n }\n\n let header: string\n if (!mainText) {\n header = `Carousel displayed with ${n} items:`\n } else if (mainText.endsWith(':')) {\n header = mainText\n } else {\n header = `${mainText}\\nCarousel with ${n} items:`\n }\n\n const itemLines = elements.map((element, index) => {\n const title = element.title?.trim() || 'Item'\n const subtitle = element.subtitle?.trim()\n const subtitlePart = subtitle ? ` - ${subtitle}` : ''\n const btnLabels: string[] = []\n if (element.button) {\n btnLabels.push(\n HubtypeAssistantContent.carouselButtonLabel(element.button)\n )\n }\n const btnPart = btnLabels.length > 0 ? ` [${btnLabels.join(', ')}]` : ''\n\n return ` ${index + 1}. \"${title}\"${subtitlePart}${btnPart}`\n })\n\n return [header, ...itemLines].join('\\n')\n }\n\n private static formatWhatsappButtonListContent(\n list: FlowWhatsappButtonList\n ): string {\n const body = list.text?.trim() ?? ''\n const hasSections = list.sections.some(s => s.rows.length > 0)\n\n if (!body && !hasSections) {\n return '[WhatsApp Button List]'\n }\n\n const parts: string[] = []\n if (body) {\n parts.push(body)\n }\n\n if (hasSections) {\n const sectionBlocks = list.sections.map(section => {\n const rowLines = section.rows.map(row => {\n const rowTitle = row.title?.trim() ?? ''\n const rowDescription = row.description?.trim() ?? ''\n if (!rowTitle && !rowDescription) {\n return ' - '\n }\n if (!rowTitle) {\n return ` - ${rowDescription}`\n }\n if (!rowDescription) {\n return ` - ${rowTitle}`\n }\n return ` - ${rowTitle}: ${rowDescription}`\n })\n const rowsText = rowLines.join('\\n')\n\n const sectionTitle = section.title?.trim()\n if (sectionTitle) {\n return `${sectionTitle}:\\n${rowsText}`\n }\n\n return rowsText\n })\n parts.push(sectionBlocks.join('\\n'))\n }\n\n return parts.join('\\n\\n')\n }\n\n private static formatWhatsappCtaContent(\n cta: FlowWhatsappCtaUrlButtonNode\n ): string {\n const hasStructuredData =\n (cta.headerType === WhatsappCTAUrlHeaderType.Text &&\n !!cta.header?.trim()) ||\n cta.text?.trim() ||\n cta.footer?.trim() ||\n cta.displayText?.trim() ||\n cta.url\n\n if (!hasStructuredData) {\n return cta.text?.trim() || '[WhatsApp CTA Button]'\n }\n\n const lines: string[] = []\n if (\n cta.headerType === WhatsappCTAUrlHeaderType.Text &&\n cta.header?.trim()\n ) {\n lines.push(cta.header.trim())\n }\n if (cta.text?.trim()) {\n lines.push(cta.text.trim())\n }\n if (cta.footer?.trim()) {\n lines.push(cta.footer.trim())\n }\n const ctaLine = `[${cta.displayText || ''}]${cta.url ? ` (${cta.url})` : ''}`\n lines.push(ctaLine)\n\n return lines.join('\\n')\n }\n\n private static formatWhatsappTemplateContent(\n template: FlowWhatsappTemplate\n ): string {\n const { name, language } = template.htWhatsappTemplate\n return `WhatsApp Template: ${name} (${language})`\n }\n}\n"],"names":["WhatsappCTAUrlHeaderType","FlowCarousel","FlowImage","FlowText","FlowVideo","FlowWhatsappCtaUrlButtonNode","FlowWhatsappTemplate","HtButtonStyle","FlowWhatsappButtonList","HubtypeAssistantContent","content","button","buttonText","text","body","buttons","isQuickReply","blockTitle","lines","i","label","block","carousel","elements","n","mainText","header","itemLines","element","index","title","subtitle","subtitlePart","btnLabels","btnPart","list","hasSections","s","parts","sectionBlocks","section","rowLines","row","rowTitle","rowDescription","rowsText","sectionTitle","cta","hasStructuredData","ctaLine","template","name","language"],"mappings":";;;;;;;;;;;;;;;;;;;AAAyD;AAGK;AACN;AACF;AACE;AACqC;AACd;AACf;AACyC;AAEzG,qGAAqG;AAC9F,MAAMS,uBAAuBA;IAClC,OAAO,MAAMC,OAAoB,EAAU;QACzC,IAAIA,mBAAmBP,QAAQA,EAAE;YAC/B,OAAOM,uBAAuBA,CAAC,qBAAqB,CAACC;QACvD;QACA,IAAIA,mBAAmBT,YAAYA,EAAE;YACnC,OAAOQ,uBAAuBA,CAAC,qBAAqB,CAACC;QACvD;QACA,IAAIA,mBAAmBR,SAASA,EAAE;YAChC,OAAOQ,QAAQ,GAAG,GAAG,CAAC,SAAS,EAAEA,QAAQ,GAAG,EAAE,GAAG;QACnD;QACA,IAAIA,mBAAmBN,SAASA,EAAE;YAChC,OAAOM,QAAQ,GAAG,GAAG,CAAC,SAAS,EAAEA,QAAQ,GAAG,EAAE,GAAG;QACnD;QACA,IAAIA,mBAAmBF,sBAAsBA,EAAE;YAC7C,OAAOC,uBAAuBA,CAAC,+BAA+B,CAACC;QACjE;QACA,IAAIA,mBAAmBL,4BAA4BA,EAAE;YACnD,OAAOI,uBAAuBA,CAAC,wBAAwB,CAACC;QAC1D;QACA,IAAIA,mBAAmBJ,oBAAoBA,EAAE;YAC3C,OAAOG,uBAAuBA,CAAC,6BAA6B,CAACC;QAC/D;QACA,OAAO;IACT;IAEA,OAAe,gBAAgBC,MAAkB,EAAU;QACzD,MAAMC,aAAaD,OAAO,IAAI,EAAE;QAChC,IAAIC,YAAY;YACd,OAAOA;QACT;QAEA,OAAOD,OAAO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GAAG,GAAG,CAAC,EAAE,EAAEA,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI;QAC7E7B,MAAM,IAAI,CAAC+B;QAEX,OAAO/B,MAAM,IAAI,CAAC;IACpB;IAEA,OAAe,8BACbgC,QAA8B,EACtB;QACR,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGF,SAAS,kBAAkB;QACtD,OAAO,CAAC,mBAAmB,EAAEC,KAAK,EAAE,EAAEC,SAAS,CAAC,CAAC;IACnD;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils/input.js","sources":["../../../src/utils/input.ts"],"sourcesContent":["import { INPUT, type Input } from '@botonic/core'\nimport type { ActionRequest } from '@botonic/react'\n\nimport type { InShadowingConfig } from '../types'\nimport { getFlowBuilderPlugin } from './get-flow-builder-plugin'\n\nexport function inputHasTextOrTranscript(input: Input): boolean {\n const isTextInput = Boolean(input.data) && input.type === INPUT.TEXT\n const isTranscriptText =\n Boolean(input.transcript) && input.type === INPUT.AUDIO\n\n return isTextInput || isTranscriptText\n}\n\nexport function getTextOrTranscript(input: Input): string | undefined {\n if (input.type === INPUT.TEXT && input.data) {\n return input.data\n }\n if (input.type === INPUT.AUDIO && input.transcript) {\n return input.transcript\n }\n\n console.error('No text or transcript found in input', input)\n return undefined\n}\n\nfunction isNluAllowed(\n request: ActionRequest,\n nluFlag: keyof InShadowingConfig\n): boolean {\n const shadowing = Boolean(request.session._shadowing)\n const flowBuilderPlugin = getFlowBuilderPlugin(request.plugins)\n return !shadowing || (shadowing && flowBuilderPlugin.inShadowing[nluFlag])\n}\n\nexport function isKeywordsAllowed(request: ActionRequest): boolean {\n return isNluAllowed(request, 'allowKeywords')\n}\n\nexport function isSmartIntentsAllowed(request: ActionRequest): boolean {\n return isNluAllowed(request, 'allowSmartIntents')\n}\n"],"names":["INPUT","getFlowBuilderPlugin","inputHasTextOrTranscript","input","isTextInput","Boolean","isTranscriptText","getTextOrTranscript","console","undefined","isNluAllowed","request","nluFlag","shadowing","flowBuilderPlugin","isKeywordsAllowed","isSmartIntentsAllowed"],"mappings":";;;;;AAAiD;AAIe;AAEzD,SAASE,wBAAwBA,CAACC,KAAY;IACnD,MAAMC,cAAcC,QAAQF,MAAM,IAAI,KAAKA,MAAM,IAAI,KAAKH,UAAU;IACpE,MAAMM,mBACJD,QAAQF,MAAM,UAAU,KAAKA,MAAM,IAAI,KAAKH,WAAW;IAEzD,OAAOI,eAAeE;AACxB;AAEO,SAASC,mBAAmBA,CAACJ,KAAY;IAC9C,IAAIA,MAAM,IAAI,KAAKH,UAAU,IAAIG,MAAM,IAAI,EAAE;QAC3C,OAAOA,MAAM,IAAI;IACnB;IACA,IAAIA,MAAM,IAAI,KAAKH,WAAW,IAAIG,MAAM,UAAU,EAAE;QAClD,OAAOA,MAAM,UAAU;IACzB;IAEAK,QAAQ,KAAK,CAAC,wCAAwCL;IACtD,OAAOM;AACT;AAEA,SAASC,YAAYA,CACnBC,OAAsB,EACtBC,OAAgC;IAEhC,MAAMC,YAAYR,QAAQM,QAAQ,OAAO,CAAC,UAAU;IACpD,MAAMG,oBAAoBb,oBAAoBA,CAACU,QAAQ,OAAO;IAC9D,OAAO,CAACE,aAAcA,aAAaC,kBAAkB,WAAW,CAACF,QAAQ;AAC3E;AAEO,SAASG,iBAAiBA,CAACJ,OAAsB;IACtD,OAAOD,YAAYA,CAACC,SAAS;AAC/B;AAEO,SAASK,qBAAqBA,CAACL,OAAsB;IAC1D,OAAOD,YAAYA,CAACC,SAAS;AAC/B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"webview/contents-context.js","sources":["../../../src/webview/contents-context.ts"],"sourcesContent":["import { createContext } from 'react'\n\nimport type { MapContentsType, WebviewContentsContextType } from './types'\n\nexport const createWebviewContentsContext = <T extends MapContentsType>() =>\n createContext<WebviewContentsContextType<T>>({\n getTextContent: () => '',\n getImageSrc: () => '',\n setCurrentLocale: () => undefined,\n contents: {} as Record<keyof T, string>,\n })\n"],"names":["createContext","createWebviewContentsContext","undefined"],"mappings":";;;AAAqC;AAI9B,MAAMC,4BAA4BA,GAAG,IAC1CD,aAAaA,CAAgC;QAC3C,gBAAgB,IAAM;QACtB,aAAa,IAAM;QACnB,kBAAkB,IAAME;QACxB,UAAU,CAAC;IACb,GAAE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"webview/index.js","sources":["../../../src/webview/index.ts"],"sourcesContent":["export { createWebviewContentsContext } from './contents-context'\nexport * from './types'\nexport { useWebviewContents } from './use-webview-contents'\n"],"names":["createWebviewContentsContext","useWebviewContents"],"mappings":";;;AAAiE;AAC1C;AACoC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"webview/types.js","sources":["../../../src/webview/types.ts"],"sourcesContent":["import type { FlowBuilderJSONVersion } from '../types'\n\nexport enum WebviewContentType {\n TEXT = 'webview-text',\n IMAGE = 'webview-image',\n}\n\nexport type WebviewContentsResponse = (\n | WebviewTextContent\n | WebviewImageContent\n)[]\n\nexport interface WebviewTextContent {\n code: string\n type: WebviewContentType.TEXT\n content: {\n text: { message: string; locale: string }[]\n }\n}\n\nexport interface WebviewImageContent {\n code: string\n type: WebviewContentType.IMAGE\n content: {\n image: { file: string; locale: string }[]\n }\n}\n\nexport type MapContentsType = Record<string, string>\n\nexport interface UseWebviewContentsProps<T extends MapContentsType> {\n apiUrl?: string\n version?: FlowBuilderJSONVersion\n botId: string\n webviewId: string\n providerId: string\n locale: string\n mapContents: Record<keyof T, string>\n}\n\nexport interface UseWebviewContents<T extends MapContentsType> {\n isLoading: boolean\n error: boolean\n webviewContentsContext: WebviewContentsContextType<T>\n}\n\nexport interface WebviewContentsContextType<T extends MapContentsType> {\n getTextContent: (code: string) => string\n getImageSrc: (code: string) => string\n setCurrentLocale: (locale: string) => void\n contents: Record<keyof T, string>\n}\n"],"names":["WebviewContentType"],"mappings":"AAEO,IAAKA,wBAAkBA,0BAAlBA;;;WAAAA;MAGX"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"webview/use-webview-contents.js","sources":["../../../src/webview/use-webview-contents.ts"],"sourcesContent":["import axios from 'axios'\nimport { useEffect, useState } from 'react'\n\nimport { FLOW_BUILDER_API_URL_PROD } from '../constants'\nimport { FlowBuilderJSONVersion } from '../types'\nimport {\n type MapContentsType,\n type UseWebviewContents,\n type UseWebviewContentsProps,\n type WebviewContentsResponse,\n WebviewContentType,\n type WebviewImageContent,\n type WebviewTextContent,\n} from './types'\n\nexport function useWebviewContents<T extends MapContentsType>({\n apiUrl = FLOW_BUILDER_API_URL_PROD,\n version = FlowBuilderJSONVersion.LATEST,\n botId,\n webviewId,\n providerId,\n locale,\n mapContents,\n}: UseWebviewContentsProps<T>): UseWebviewContents<T> {\n const [textContents, setTextContents] = useState<WebviewTextContent[]>()\n const [imageContents, setImageContents] = useState<WebviewImageContent[]>()\n const [contents, setContents] = useState<Record<keyof T, string>>(\n {} as Record<keyof T, string>\n )\n const [currentLocale, setCurrentLocale] = useState(locale)\n const [error, setError] = useState(false)\n\n const updateCurrentLocale = (textContents?: WebviewTextContent[]) => {\n if (!textContents || textContents.length === 0) {\n console.log('There is no text contents to check the locale')\n return\n }\n\n const locales = textContents[0].content.text.map(text => text.locale)\n const language = currentLocale.split('-')[0]\n\n if (locales.includes(currentLocale)) {\n setCurrentLocale(currentLocale)\n return\n }\n\n if (locales.includes(language)) {\n setCurrentLocale(language)\n return\n }\n\n console.error(\n `locale: ${currentLocale} cannot be resolved with: ${locales.join(', ')}`\n )\n }\n\n const getTextContent = (contentID: string): string => {\n return (\n textContents\n ?.find(textContent => textContent.code === contentID)\n ?.content.text.find(text => text.locale === currentLocale)?.message ||\n ''\n )\n }\n\n const getImageSrc = (contentID: string): string => {\n return (\n imageContents\n ?.find(imageContent => imageContent.code === contentID)\n ?.content.image.find(image => image.locale === currentLocale)?.file ||\n ''\n )\n }\n\n useEffect(() => {\n if (textContents || imageContents) {\n const contentsObject = {}\n for (const [key, value] of Object.entries<string>(mapContents)) {\n contentsObject[key] = getTextContent(value) || getImageSrc(value)\n }\n setContents(contentsObject as Record<keyof T, string>)\n }\n }, [textContents, imageContents, currentLocale])\n\n useEffect(() => {\n const getResponseContents = async () => {\n const url = `${apiUrl}/v1/bot_flows/${botId}/versions/${version}/webviews/${webviewId}/?provider_id=${providerId}`\n try {\n const response = await axios.get<WebviewContentsResponse>(url)\n\n const textResponseContents = response.data.filter(\n webviewContent => webviewContent.type === WebviewContentType.TEXT\n ) as WebviewTextContent[]\n setTextContents(textResponseContents)\n\n const imageResponseContents = response.data.filter(\n webviewContent => webviewContent.type === WebviewContentType.IMAGE\n ) as WebviewImageContent[]\n setImageContents(imageResponseContents)\n\n updateCurrentLocale(textResponseContents)\n } catch (error) {\n console.error('Error fetching webview contents:', error)\n setError(true)\n }\n }\n getResponseContents()\n }, [])\n\n return {\n isLoading: Object.keys(contents).length === 0,\n error,\n webviewContentsContext: {\n getTextContent,\n getImageSrc,\n setCurrentLocale,\n contents,\n },\n }\n}\n"],"names":["axios","useEffect","useState","FLOW_BUILDER_API_URL_PROD","FlowBuilderJSONVersion","WebviewContentType","useWebviewContents","apiUrl","version","botId","webviewId","providerId","locale","mapContents","textContents","setTextContents","imageContents","setImageContents","contents","setContents","currentLocale","setCurrentLocale","error","setError","updateCurrentLocale","console","locales","text","language","getTextContent","contentID","textContent","getImageSrc","imageContent","image","contentsObject","key","value","Object","getResponseContents","url","response","textResponseContents","webviewContent","imageResponseContents"],"mappings":";;;;;;;;;;;AAAyB;AACkB;AAEa;AACP;AASjC;AAET,SAASM,kBAAkBA,CAA4B,EAC5DC,SAASJ,yBAAyB,EAClCK,UAAUJ,6BAA6B,EACvCK,KAAK,EACLC,SAAS,EACTC,UAAU,EACVC,MAAM,EACNC,WAAW,EACgB;IAC3B,MAAM,CAACC,cAAcC,gBAAgB,GAAGb,QAAQA;IAChD,MAAM,CAACc,eAAeC,iBAAiB,GAAGf,QAAQA;IAClD,MAAM,CAACgB,UAAUC,YAAY,GAAGjB,QAAQA,CACtC,CAAC;IAEH,MAAM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c;IAE/CnB,SAASA,CAAC;QACR,MAAMsC,sBAAsB;YAC1B,MAAMC,MAAM,GAAGjC,OAAO,cAAc,EAAEE,MAAM,UAAU,EAAED,QAAQ,UAAU,EAAEE,UAAU,cAAc,EAAEC,YAAY;YAClH,IAAI;gBACF,MAAM8B,WAAW,MAAMzC,SAAS,CAA0BwC;gBAE1D,MAAME,uBAAuBD,SAAS,IAAI,CAAC,MAAM,CAC/CE,CAAAA,iBAAkBA,eAAe,IAAI,KAAKtC,uBAAuB;gBAEnEU,gBAAgB2B;gBAEhB,MAAME,wBAAwBH,SAAS,IAAI,CAAC,MAAM,CAChDE,CAAAA,iBAAkBA,eAAe,IAAI,KAAKtC,wBAAwB;gBAEpEY,iBAAiB2B;gBAEjBpB,oBAAoBkB;YACtB,EAAE,OAAOpB,OAAO;gBACdG,QAAQ,KAAK,CAAC,oCAAoCH;gBAClDC,SAAS;YACX;QACF;QACAgB;IACF,GAAG,EAAE;IAEL,OAAO;QACL,WAAWD,OAAO,IAAI,CAACpB,UAAU,MAAM,KAAK;QAC5CI;QACA,wBAAwB;YACtBO;YACAG;YACAX;YACAH;QACF;IACF;AACF"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes