@repzo/widget-react-native 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (448) hide show
  1. package/README.md +482 -0
  2. package/lib/commonjs/agent-ui-blocks.js +159 -0
  3. package/lib/commonjs/agent-ui-blocks.js.map +1 -0
  4. package/lib/commonjs/api/client.js +267 -0
  5. package/lib/commonjs/api/client.js.map +1 -0
  6. package/lib/commonjs/api/realtime.js +193 -0
  7. package/lib/commonjs/api/realtime.js.map +1 -0
  8. package/lib/commonjs/api/sse-parser.js +58 -0
  9. package/lib/commonjs/api/sse-parser.js.map +1 -0
  10. package/lib/commonjs/controller.js +23 -0
  11. package/lib/commonjs/controller.js.map +1 -0
  12. package/lib/commonjs/device-id.js +75 -0
  13. package/lib/commonjs/device-id.js.map +1 -0
  14. package/lib/commonjs/events.js +49 -0
  15. package/lib/commonjs/events.js.map +1 -0
  16. package/lib/commonjs/i18n.js +106 -0
  17. package/lib/commonjs/i18n.js.map +1 -0
  18. package/lib/commonjs/index.js +98 -0
  19. package/lib/commonjs/index.js.map +1 -0
  20. package/lib/commonjs/locales.js +85 -0
  21. package/lib/commonjs/locales.js.map +1 -0
  22. package/lib/commonjs/package.json +1 -0
  23. package/lib/commonjs/push/push-notifications.js +208 -0
  24. package/lib/commonjs/push/push-notifications.js.map +1 -0
  25. package/lib/commonjs/state/use-widget-state.js +23 -0
  26. package/lib/commonjs/state/use-widget-state.js.map +1 -0
  27. package/lib/commonjs/state/widget-store.js +1682 -0
  28. package/lib/commonjs/state/widget-store.js.map +1 -0
  29. package/lib/commonjs/storage.js +147 -0
  30. package/lib/commonjs/storage.js.map +1 -0
  31. package/lib/commonjs/types.js +44 -0
  32. package/lib/commonjs/types.js.map +1 -0
  33. package/lib/commonjs/ui/WidgetProvider.js +404 -0
  34. package/lib/commonjs/ui/WidgetProvider.js.map +1 -0
  35. package/lib/commonjs/ui/components/AgentUiBlocks.js +864 -0
  36. package/lib/commonjs/ui/components/AgentUiBlocks.js.map +1 -0
  37. package/lib/commonjs/ui/components/Avatar.js +76 -0
  38. package/lib/commonjs/ui/components/Avatar.js.map +1 -0
  39. package/lib/commonjs/ui/components/ConversationRow.js +155 -0
  40. package/lib/commonjs/ui/components/ConversationRow.js.map +1 -0
  41. package/lib/commonjs/ui/components/ErrorBoundary.js +44 -0
  42. package/lib/commonjs/ui/components/ErrorBoundary.js.map +1 -0
  43. package/lib/commonjs/ui/components/Gradient.js +168 -0
  44. package/lib/commonjs/ui/components/Gradient.js.map +1 -0
  45. package/lib/commonjs/ui/components/Launcher.js +125 -0
  46. package/lib/commonjs/ui/components/Launcher.js.map +1 -0
  47. package/lib/commonjs/ui/components/Markdown.js +257 -0
  48. package/lib/commonjs/ui/components/Markdown.js.map +1 -0
  49. package/lib/commonjs/ui/components/OutboundMessageCard.js +157 -0
  50. package/lib/commonjs/ui/components/OutboundMessageCard.js.map +1 -0
  51. package/lib/commonjs/ui/components/WidgetPanel.js +131 -0
  52. package/lib/commonjs/ui/components/WidgetPanel.js.map +1 -0
  53. package/lib/commonjs/ui/components/icons.js +383 -0
  54. package/lib/commonjs/ui/components/icons.js.map +1 -0
  55. package/lib/commonjs/ui/hooks/use-keyboard-overlap.js +113 -0
  56. package/lib/commonjs/ui/hooks/use-keyboard-overlap.js.map +1 -0
  57. package/lib/commonjs/ui/hooks/use-reduce-motion.js +38 -0
  58. package/lib/commonjs/ui/hooks/use-reduce-motion.js.map +1 -0
  59. package/lib/commonjs/ui/hooks/use-widget-insets.js +41 -0
  60. package/lib/commonjs/ui/hooks/use-widget-insets.js.map +1 -0
  61. package/lib/commonjs/ui/screens/chat/ChatView.js +590 -0
  62. package/lib/commonjs/ui/screens/chat/ChatView.js.map +1 -0
  63. package/lib/commonjs/ui/screens/chat/ChatView.styles.js +362 -0
  64. package/lib/commonjs/ui/screens/chat/ChatView.styles.js.map +1 -0
  65. package/lib/commonjs/ui/screens/chat/ChatView.types.js +6 -0
  66. package/lib/commonjs/ui/screens/chat/ChatView.types.js.map +1 -0
  67. package/lib/commonjs/ui/screens/conversations/ConversationsList.js +150 -0
  68. package/lib/commonjs/ui/screens/conversations/ConversationsList.js.map +1 -0
  69. package/lib/commonjs/ui/screens/conversations/ConversationsList.styles.js +118 -0
  70. package/lib/commonjs/ui/screens/conversations/ConversationsList.styles.js.map +1 -0
  71. package/lib/commonjs/ui/screens/conversations/ConversationsList.types.js +6 -0
  72. package/lib/commonjs/ui/screens/conversations/ConversationsList.types.js.map +1 -0
  73. package/lib/commonjs/ui/screens/home/HomeView.js +336 -0
  74. package/lib/commonjs/ui/screens/home/HomeView.js.map +1 -0
  75. package/lib/commonjs/ui/screens/home/HomeView.styles.js +245 -0
  76. package/lib/commonjs/ui/screens/home/HomeView.styles.js.map +1 -0
  77. package/lib/commonjs/ui/screens/home/HomeView.types.js +6 -0
  78. package/lib/commonjs/ui/screens/home/HomeView.types.js.map +1 -0
  79. package/lib/commonjs/ui/screens/home/greeting.js +49 -0
  80. package/lib/commonjs/ui/screens/home/greeting.js.map +1 -0
  81. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.js +229 -0
  82. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.js.map +1 -0
  83. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.styles.js +125 -0
  84. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.styles.js.map +1 -0
  85. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.types.js +6 -0
  86. package/lib/commonjs/ui/screens/pre-chat/PreChatForm.types.js.map +1 -0
  87. package/lib/commonjs/ui/styles/global.js +55 -0
  88. package/lib/commonjs/ui/styles/global.js.map +1 -0
  89. package/lib/commonjs/ui/styles/theme.js +148 -0
  90. package/lib/commonjs/ui/styles/theme.js.map +1 -0
  91. package/lib/commonjs/ui/utils/conversations.js +125 -0
  92. package/lib/commonjs/ui/utils/conversations.js.map +1 -0
  93. package/lib/commonjs/ui/utils/html.js +44 -0
  94. package/lib/commonjs/ui/utils/html.js.map +1 -0
  95. package/lib/commonjs/ui/utils/native-gradient.js +65 -0
  96. package/lib/commonjs/ui/utils/native-gradient.js.map +1 -0
  97. package/lib/commonjs/ui/utils/rtl.js +56 -0
  98. package/lib/commonjs/ui/utils/rtl.js.map +1 -0
  99. package/lib/commonjs/ui/utils/safe-url.js +67 -0
  100. package/lib/commonjs/ui/utils/safe-url.js.map +1 -0
  101. package/lib/module/agent-ui-blocks.js +152 -0
  102. package/lib/module/agent-ui-blocks.js.map +1 -0
  103. package/lib/module/api/client.js +261 -0
  104. package/lib/module/api/client.js.map +1 -0
  105. package/lib/module/api/realtime.js +189 -0
  106. package/lib/module/api/realtime.js.map +1 -0
  107. package/lib/module/api/sse-parser.js +53 -0
  108. package/lib/module/api/sse-parser.js.map +1 -0
  109. package/lib/module/controller.js +19 -0
  110. package/lib/module/controller.js.map +1 -0
  111. package/lib/module/device-id.js +69 -0
  112. package/lib/module/device-id.js.map +1 -0
  113. package/lib/module/events.js +44 -0
  114. package/lib/module/events.js.map +1 -0
  115. package/lib/module/i18n.js +99 -0
  116. package/lib/module/i18n.js.map +1 -0
  117. package/lib/module/index.js +55 -0
  118. package/lib/module/index.js.map +1 -0
  119. package/lib/module/locales.js +80 -0
  120. package/lib/module/locales.js.map +1 -0
  121. package/lib/module/package.json +1 -0
  122. package/lib/module/push/push-notifications.js +204 -0
  123. package/lib/module/push/push-notifications.js.map +1 -0
  124. package/lib/module/state/use-widget-state.js +18 -0
  125. package/lib/module/state/use-widget-state.js.map +1 -0
  126. package/lib/module/state/widget-store.js +1677 -0
  127. package/lib/module/state/widget-store.js.map +1 -0
  128. package/lib/module/storage.js +141 -0
  129. package/lib/module/storage.js.map +1 -0
  130. package/lib/module/types.js +40 -0
  131. package/lib/module/types.js.map +1 -0
  132. package/lib/module/ui/WidgetProvider.js +400 -0
  133. package/lib/module/ui/WidgetProvider.js.map +1 -0
  134. package/lib/module/ui/components/AgentUiBlocks.js +857 -0
  135. package/lib/module/ui/components/AgentUiBlocks.js.map +1 -0
  136. package/lib/module/ui/components/Avatar.js +71 -0
  137. package/lib/module/ui/components/Avatar.js.map +1 -0
  138. package/lib/module/ui/components/ConversationRow.js +150 -0
  139. package/lib/module/ui/components/ConversationRow.js.map +1 -0
  140. package/lib/module/ui/components/ErrorBoundary.js +39 -0
  141. package/lib/module/ui/components/ErrorBoundary.js.map +1 -0
  142. package/lib/module/ui/components/Gradient.js +165 -0
  143. package/lib/module/ui/components/Gradient.js.map +1 -0
  144. package/lib/module/ui/components/Launcher.js +121 -0
  145. package/lib/module/ui/components/Launcher.js.map +1 -0
  146. package/lib/module/ui/components/Markdown.js +253 -0
  147. package/lib/module/ui/components/Markdown.js.map +1 -0
  148. package/lib/module/ui/components/OutboundMessageCard.js +153 -0
  149. package/lib/module/ui/components/OutboundMessageCard.js.map +1 -0
  150. package/lib/module/ui/components/WidgetPanel.js +127 -0
  151. package/lib/module/ui/components/WidgetPanel.js.map +1 -0
  152. package/lib/module/ui/components/icons.js +370 -0
  153. package/lib/module/ui/components/icons.js.map +1 -0
  154. package/lib/module/ui/hooks/use-keyboard-overlap.js +109 -0
  155. package/lib/module/ui/hooks/use-keyboard-overlap.js.map +1 -0
  156. package/lib/module/ui/hooks/use-reduce-motion.js +34 -0
  157. package/lib/module/ui/hooks/use-reduce-motion.js.map +1 -0
  158. package/lib/module/ui/hooks/use-widget-insets.js +37 -0
  159. package/lib/module/ui/hooks/use-widget-insets.js.map +1 -0
  160. package/lib/module/ui/screens/chat/ChatView.js +586 -0
  161. package/lib/module/ui/screens/chat/ChatView.js.map +1 -0
  162. package/lib/module/ui/screens/chat/ChatView.styles.js +358 -0
  163. package/lib/module/ui/screens/chat/ChatView.styles.js.map +1 -0
  164. package/lib/module/ui/screens/chat/ChatView.types.js +4 -0
  165. package/lib/module/ui/screens/chat/ChatView.types.js.map +1 -0
  166. package/lib/module/ui/screens/conversations/ConversationsList.js +146 -0
  167. package/lib/module/ui/screens/conversations/ConversationsList.js.map +1 -0
  168. package/lib/module/ui/screens/conversations/ConversationsList.styles.js +114 -0
  169. package/lib/module/ui/screens/conversations/ConversationsList.styles.js.map +1 -0
  170. package/lib/module/ui/screens/conversations/ConversationsList.types.js +4 -0
  171. package/lib/module/ui/screens/conversations/ConversationsList.types.js.map +1 -0
  172. package/lib/module/ui/screens/home/HomeView.js +332 -0
  173. package/lib/module/ui/screens/home/HomeView.js.map +1 -0
  174. package/lib/module/ui/screens/home/HomeView.styles.js +242 -0
  175. package/lib/module/ui/screens/home/HomeView.styles.js.map +1 -0
  176. package/lib/module/ui/screens/home/HomeView.types.js +4 -0
  177. package/lib/module/ui/screens/home/HomeView.types.js.map +1 -0
  178. package/lib/module/ui/screens/home/greeting.js +44 -0
  179. package/lib/module/ui/screens/home/greeting.js.map +1 -0
  180. package/lib/module/ui/screens/pre-chat/PreChatForm.js +225 -0
  181. package/lib/module/ui/screens/pre-chat/PreChatForm.js.map +1 -0
  182. package/lib/module/ui/screens/pre-chat/PreChatForm.styles.js +121 -0
  183. package/lib/module/ui/screens/pre-chat/PreChatForm.styles.js.map +1 -0
  184. package/lib/module/ui/screens/pre-chat/PreChatForm.types.js +4 -0
  185. package/lib/module/ui/screens/pre-chat/PreChatForm.types.js.map +1 -0
  186. package/lib/module/ui/styles/global.js +51 -0
  187. package/lib/module/ui/styles/global.js.map +1 -0
  188. package/lib/module/ui/styles/theme.js +137 -0
  189. package/lib/module/ui/styles/theme.js.map +1 -0
  190. package/lib/module/ui/utils/conversations.js +115 -0
  191. package/lib/module/ui/utils/conversations.js.map +1 -0
  192. package/lib/module/ui/utils/html.js +39 -0
  193. package/lib/module/ui/utils/html.js.map +1 -0
  194. package/lib/module/ui/utils/native-gradient.js +60 -0
  195. package/lib/module/ui/utils/native-gradient.js.map +1 -0
  196. package/lib/module/ui/utils/rtl.js +49 -0
  197. package/lib/module/ui/utils/rtl.js.map +1 -0
  198. package/lib/module/ui/utils/safe-url.js +59 -0
  199. package/lib/module/ui/utils/safe-url.js.map +1 -0
  200. package/lib/typescript/commonjs/agent-ui-blocks.d.ts +20 -0
  201. package/lib/typescript/commonjs/agent-ui-blocks.d.ts.map +1 -0
  202. package/lib/typescript/commonjs/api/client.d.ts +115 -0
  203. package/lib/typescript/commonjs/api/client.d.ts.map +1 -0
  204. package/lib/typescript/commonjs/api/realtime.d.ts +39 -0
  205. package/lib/typescript/commonjs/api/realtime.d.ts.map +1 -0
  206. package/lib/typescript/commonjs/api/sse-parser.d.ts +13 -0
  207. package/lib/typescript/commonjs/api/sse-parser.d.ts.map +1 -0
  208. package/lib/typescript/commonjs/controller.d.ts +15 -0
  209. package/lib/typescript/commonjs/controller.d.ts.map +1 -0
  210. package/lib/typescript/commonjs/device-id.d.ts +15 -0
  211. package/lib/typescript/commonjs/device-id.d.ts.map +1 -0
  212. package/lib/typescript/commonjs/events.d.ts +41 -0
  213. package/lib/typescript/commonjs/events.d.ts.map +1 -0
  214. package/lib/typescript/commonjs/i18n.d.ts +78 -0
  215. package/lib/typescript/commonjs/i18n.d.ts.map +1 -0
  216. package/lib/typescript/commonjs/index.d.ts +103 -0
  217. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  218. package/lib/typescript/commonjs/locales.d.ts +18 -0
  219. package/lib/typescript/commonjs/locales.d.ts.map +1 -0
  220. package/lib/typescript/commonjs/package.json +1 -0
  221. package/lib/typescript/commonjs/push/push-notifications.d.ts +71 -0
  222. package/lib/typescript/commonjs/push/push-notifications.d.ts.map +1 -0
  223. package/lib/typescript/commonjs/state/use-widget-state.d.ts +10 -0
  224. package/lib/typescript/commonjs/state/use-widget-state.d.ts.map +1 -0
  225. package/lib/typescript/commonjs/state/widget-store.d.ts +227 -0
  226. package/lib/typescript/commonjs/state/widget-store.d.ts.map +1 -0
  227. package/lib/typescript/commonjs/storage.d.ts +42 -0
  228. package/lib/typescript/commonjs/storage.d.ts.map +1 -0
  229. package/lib/typescript/commonjs/types.d.ts +391 -0
  230. package/lib/typescript/commonjs/types.d.ts.map +1 -0
  231. package/lib/typescript/commonjs/ui/WidgetProvider.d.ts +15 -0
  232. package/lib/typescript/commonjs/ui/WidgetProvider.d.ts.map +1 -0
  233. package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts +27 -0
  234. package/lib/typescript/commonjs/ui/components/AgentUiBlocks.d.ts.map +1 -0
  235. package/lib/typescript/commonjs/ui/components/Avatar.d.ts +19 -0
  236. package/lib/typescript/commonjs/ui/components/Avatar.d.ts.map +1 -0
  237. package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts +26 -0
  238. package/lib/typescript/commonjs/ui/components/ConversationRow.d.ts.map +1 -0
  239. package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts +27 -0
  240. package/lib/typescript/commonjs/ui/components/ErrorBoundary.d.ts.map +1 -0
  241. package/lib/typescript/commonjs/ui/components/Gradient.d.ts +33 -0
  242. package/lib/typescript/commonjs/ui/components/Gradient.d.ts.map +1 -0
  243. package/lib/typescript/commonjs/ui/components/Launcher.d.ts +18 -0
  244. package/lib/typescript/commonjs/ui/components/Launcher.d.ts.map +1 -0
  245. package/lib/typescript/commonjs/ui/components/Markdown.d.ts +19 -0
  246. package/lib/typescript/commonjs/ui/components/Markdown.d.ts.map +1 -0
  247. package/lib/typescript/commonjs/ui/components/OutboundMessageCard.d.ts +20 -0
  248. package/lib/typescript/commonjs/ui/components/OutboundMessageCard.d.ts.map +1 -0
  249. package/lib/typescript/commonjs/ui/components/WidgetPanel.d.ts +26 -0
  250. package/lib/typescript/commonjs/ui/components/WidgetPanel.d.ts.map +1 -0
  251. package/lib/typescript/commonjs/ui/components/icons.d.ts +38 -0
  252. package/lib/typescript/commonjs/ui/components/icons.d.ts.map +1 -0
  253. package/lib/typescript/commonjs/ui/hooks/use-keyboard-overlap.d.ts +33 -0
  254. package/lib/typescript/commonjs/ui/hooks/use-keyboard-overlap.d.ts.map +1 -0
  255. package/lib/typescript/commonjs/ui/hooks/use-reduce-motion.d.ts +11 -0
  256. package/lib/typescript/commonjs/ui/hooks/use-reduce-motion.d.ts.map +1 -0
  257. package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts +16 -0
  258. package/lib/typescript/commonjs/ui/hooks/use-widget-insets.d.ts.map +1 -0
  259. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts +11 -0
  260. package/lib/typescript/commonjs/ui/screens/chat/ChatView.d.ts.map +1 -0
  261. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts +349 -0
  262. package/lib/typescript/commonjs/ui/screens/chat/ChatView.styles.d.ts.map +1 -0
  263. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts +48 -0
  264. package/lib/typescript/commonjs/ui/screens/chat/ChatView.types.d.ts.map +1 -0
  265. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts +10 -0
  266. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.d.ts.map +1 -0
  267. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.styles.d.ts +113 -0
  268. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.styles.d.ts.map +1 -0
  269. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts +31 -0
  270. package/lib/typescript/commonjs/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -0
  271. package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts +17 -0
  272. package/lib/typescript/commonjs/ui/screens/home/HomeView.d.ts.map +1 -0
  273. package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts +227 -0
  274. package/lib/typescript/commonjs/ui/screens/home/HomeView.styles.d.ts.map +1 -0
  275. package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts +40 -0
  276. package/lib/typescript/commonjs/ui/screens/home/HomeView.types.d.ts.map +1 -0
  277. package/lib/typescript/commonjs/ui/screens/home/greeting.d.ts +19 -0
  278. package/lib/typescript/commonjs/ui/screens/home/greeting.d.ts.map +1 -0
  279. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.d.ts +7 -0
  280. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.d.ts.map +1 -0
  281. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.styles.d.ts +115 -0
  282. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.styles.d.ts.map +1 -0
  283. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.types.d.ts +20 -0
  284. package/lib/typescript/commonjs/ui/screens/pre-chat/PreChatForm.types.d.ts.map +1 -0
  285. package/lib/typescript/commonjs/ui/styles/global.d.ts +46 -0
  286. package/lib/typescript/commonjs/ui/styles/global.d.ts.map +1 -0
  287. package/lib/typescript/commonjs/ui/styles/theme.d.ts +103 -0
  288. package/lib/typescript/commonjs/ui/styles/theme.d.ts.map +1 -0
  289. package/lib/typescript/commonjs/ui/utils/conversations.d.ts +41 -0
  290. package/lib/typescript/commonjs/ui/utils/conversations.d.ts.map +1 -0
  291. package/lib/typescript/commonjs/ui/utils/html.d.ts +10 -0
  292. package/lib/typescript/commonjs/ui/utils/html.d.ts.map +1 -0
  293. package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts +61 -0
  294. package/lib/typescript/commonjs/ui/utils/native-gradient.d.ts.map +1 -0
  295. package/lib/typescript/commonjs/ui/utils/rtl.d.ts +33 -0
  296. package/lib/typescript/commonjs/ui/utils/rtl.d.ts.map +1 -0
  297. package/lib/typescript/commonjs/ui/utils/safe-url.d.ts +21 -0
  298. package/lib/typescript/commonjs/ui/utils/safe-url.d.ts.map +1 -0
  299. package/lib/typescript/module/agent-ui-blocks.d.ts +20 -0
  300. package/lib/typescript/module/agent-ui-blocks.d.ts.map +1 -0
  301. package/lib/typescript/module/api/client.d.ts +115 -0
  302. package/lib/typescript/module/api/client.d.ts.map +1 -0
  303. package/lib/typescript/module/api/realtime.d.ts +39 -0
  304. package/lib/typescript/module/api/realtime.d.ts.map +1 -0
  305. package/lib/typescript/module/api/sse-parser.d.ts +13 -0
  306. package/lib/typescript/module/api/sse-parser.d.ts.map +1 -0
  307. package/lib/typescript/module/controller.d.ts +15 -0
  308. package/lib/typescript/module/controller.d.ts.map +1 -0
  309. package/lib/typescript/module/device-id.d.ts +15 -0
  310. package/lib/typescript/module/device-id.d.ts.map +1 -0
  311. package/lib/typescript/module/events.d.ts +41 -0
  312. package/lib/typescript/module/events.d.ts.map +1 -0
  313. package/lib/typescript/module/i18n.d.ts +78 -0
  314. package/lib/typescript/module/i18n.d.ts.map +1 -0
  315. package/lib/typescript/module/index.d.ts +103 -0
  316. package/lib/typescript/module/index.d.ts.map +1 -0
  317. package/lib/typescript/module/locales.d.ts +18 -0
  318. package/lib/typescript/module/locales.d.ts.map +1 -0
  319. package/lib/typescript/module/package.json +1 -0
  320. package/lib/typescript/module/push/push-notifications.d.ts +71 -0
  321. package/lib/typescript/module/push/push-notifications.d.ts.map +1 -0
  322. package/lib/typescript/module/state/use-widget-state.d.ts +10 -0
  323. package/lib/typescript/module/state/use-widget-state.d.ts.map +1 -0
  324. package/lib/typescript/module/state/widget-store.d.ts +227 -0
  325. package/lib/typescript/module/state/widget-store.d.ts.map +1 -0
  326. package/lib/typescript/module/storage.d.ts +42 -0
  327. package/lib/typescript/module/storage.d.ts.map +1 -0
  328. package/lib/typescript/module/types.d.ts +391 -0
  329. package/lib/typescript/module/types.d.ts.map +1 -0
  330. package/lib/typescript/module/ui/WidgetProvider.d.ts +15 -0
  331. package/lib/typescript/module/ui/WidgetProvider.d.ts.map +1 -0
  332. package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts +27 -0
  333. package/lib/typescript/module/ui/components/AgentUiBlocks.d.ts.map +1 -0
  334. package/lib/typescript/module/ui/components/Avatar.d.ts +19 -0
  335. package/lib/typescript/module/ui/components/Avatar.d.ts.map +1 -0
  336. package/lib/typescript/module/ui/components/ConversationRow.d.ts +26 -0
  337. package/lib/typescript/module/ui/components/ConversationRow.d.ts.map +1 -0
  338. package/lib/typescript/module/ui/components/ErrorBoundary.d.ts +27 -0
  339. package/lib/typescript/module/ui/components/ErrorBoundary.d.ts.map +1 -0
  340. package/lib/typescript/module/ui/components/Gradient.d.ts +33 -0
  341. package/lib/typescript/module/ui/components/Gradient.d.ts.map +1 -0
  342. package/lib/typescript/module/ui/components/Launcher.d.ts +18 -0
  343. package/lib/typescript/module/ui/components/Launcher.d.ts.map +1 -0
  344. package/lib/typescript/module/ui/components/Markdown.d.ts +19 -0
  345. package/lib/typescript/module/ui/components/Markdown.d.ts.map +1 -0
  346. package/lib/typescript/module/ui/components/OutboundMessageCard.d.ts +20 -0
  347. package/lib/typescript/module/ui/components/OutboundMessageCard.d.ts.map +1 -0
  348. package/lib/typescript/module/ui/components/WidgetPanel.d.ts +26 -0
  349. package/lib/typescript/module/ui/components/WidgetPanel.d.ts.map +1 -0
  350. package/lib/typescript/module/ui/components/icons.d.ts +38 -0
  351. package/lib/typescript/module/ui/components/icons.d.ts.map +1 -0
  352. package/lib/typescript/module/ui/hooks/use-keyboard-overlap.d.ts +33 -0
  353. package/lib/typescript/module/ui/hooks/use-keyboard-overlap.d.ts.map +1 -0
  354. package/lib/typescript/module/ui/hooks/use-reduce-motion.d.ts +11 -0
  355. package/lib/typescript/module/ui/hooks/use-reduce-motion.d.ts.map +1 -0
  356. package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts +16 -0
  357. package/lib/typescript/module/ui/hooks/use-widget-insets.d.ts.map +1 -0
  358. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts +11 -0
  359. package/lib/typescript/module/ui/screens/chat/ChatView.d.ts.map +1 -0
  360. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts +349 -0
  361. package/lib/typescript/module/ui/screens/chat/ChatView.styles.d.ts.map +1 -0
  362. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts +48 -0
  363. package/lib/typescript/module/ui/screens/chat/ChatView.types.d.ts.map +1 -0
  364. package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts +10 -0
  365. package/lib/typescript/module/ui/screens/conversations/ConversationsList.d.ts.map +1 -0
  366. package/lib/typescript/module/ui/screens/conversations/ConversationsList.styles.d.ts +113 -0
  367. package/lib/typescript/module/ui/screens/conversations/ConversationsList.styles.d.ts.map +1 -0
  368. package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts +31 -0
  369. package/lib/typescript/module/ui/screens/conversations/ConversationsList.types.d.ts.map +1 -0
  370. package/lib/typescript/module/ui/screens/home/HomeView.d.ts +17 -0
  371. package/lib/typescript/module/ui/screens/home/HomeView.d.ts.map +1 -0
  372. package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts +227 -0
  373. package/lib/typescript/module/ui/screens/home/HomeView.styles.d.ts.map +1 -0
  374. package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts +40 -0
  375. package/lib/typescript/module/ui/screens/home/HomeView.types.d.ts.map +1 -0
  376. package/lib/typescript/module/ui/screens/home/greeting.d.ts +19 -0
  377. package/lib/typescript/module/ui/screens/home/greeting.d.ts.map +1 -0
  378. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.d.ts +7 -0
  379. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.d.ts.map +1 -0
  380. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.styles.d.ts +115 -0
  381. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.styles.d.ts.map +1 -0
  382. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.types.d.ts +20 -0
  383. package/lib/typescript/module/ui/screens/pre-chat/PreChatForm.types.d.ts.map +1 -0
  384. package/lib/typescript/module/ui/styles/global.d.ts +46 -0
  385. package/lib/typescript/module/ui/styles/global.d.ts.map +1 -0
  386. package/lib/typescript/module/ui/styles/theme.d.ts +103 -0
  387. package/lib/typescript/module/ui/styles/theme.d.ts.map +1 -0
  388. package/lib/typescript/module/ui/utils/conversations.d.ts +41 -0
  389. package/lib/typescript/module/ui/utils/conversations.d.ts.map +1 -0
  390. package/lib/typescript/module/ui/utils/html.d.ts +10 -0
  391. package/lib/typescript/module/ui/utils/html.d.ts.map +1 -0
  392. package/lib/typescript/module/ui/utils/native-gradient.d.ts +61 -0
  393. package/lib/typescript/module/ui/utils/native-gradient.d.ts.map +1 -0
  394. package/lib/typescript/module/ui/utils/rtl.d.ts +33 -0
  395. package/lib/typescript/module/ui/utils/rtl.d.ts.map +1 -0
  396. package/lib/typescript/module/ui/utils/safe-url.d.ts +21 -0
  397. package/lib/typescript/module/ui/utils/safe-url.d.ts.map +1 -0
  398. package/metro.js +40 -0
  399. package/package.json +116 -0
  400. package/src/agent-ui-blocks.ts +302 -0
  401. package/src/api/client.ts +332 -0
  402. package/src/api/realtime.ts +225 -0
  403. package/src/api/sse-parser.ts +51 -0
  404. package/src/controller.ts +20 -0
  405. package/src/device-id.ts +71 -0
  406. package/src/events.ts +74 -0
  407. package/src/i18n.ts +114 -0
  408. package/src/index.tsx +199 -0
  409. package/src/locales.ts +80 -0
  410. package/src/push/push-notifications.ts +254 -0
  411. package/src/state/use-widget-state.ts +20 -0
  412. package/src/state/widget-store.ts +1815 -0
  413. package/src/storage.ts +153 -0
  414. package/src/types.ts +445 -0
  415. package/src/ui/WidgetProvider.tsx +434 -0
  416. package/src/ui/components/AgentUiBlocks.tsx +912 -0
  417. package/src/ui/components/Avatar.tsx +86 -0
  418. package/src/ui/components/ConversationRow.tsx +163 -0
  419. package/src/ui/components/ErrorBoundary.tsx +49 -0
  420. package/src/ui/components/Gradient.tsx +165 -0
  421. package/src/ui/components/Launcher.tsx +128 -0
  422. package/src/ui/components/Markdown.tsx +291 -0
  423. package/src/ui/components/OutboundMessageCard.tsx +154 -0
  424. package/src/ui/components/WidgetPanel.tsx +133 -0
  425. package/src/ui/components/icons.tsx +315 -0
  426. package/src/ui/hooks/use-keyboard-overlap.ts +134 -0
  427. package/src/ui/hooks/use-reduce-motion.ts +39 -0
  428. package/src/ui/hooks/use-widget-insets.ts +44 -0
  429. package/src/ui/screens/chat/ChatView.styles.ts +357 -0
  430. package/src/ui/screens/chat/ChatView.tsx +690 -0
  431. package/src/ui/screens/chat/ChatView.types.ts +46 -0
  432. package/src/ui/screens/conversations/ConversationsList.styles.ts +111 -0
  433. package/src/ui/screens/conversations/ConversationsList.tsx +144 -0
  434. package/src/ui/screens/conversations/ConversationsList.types.ts +33 -0
  435. package/src/ui/screens/home/HomeView.styles.ts +246 -0
  436. package/src/ui/screens/home/HomeView.tsx +336 -0
  437. package/src/ui/screens/home/HomeView.types.ts +42 -0
  438. package/src/ui/screens/home/greeting.ts +50 -0
  439. package/src/ui/screens/pre-chat/PreChatForm.styles.ts +120 -0
  440. package/src/ui/screens/pre-chat/PreChatForm.tsx +221 -0
  441. package/src/ui/screens/pre-chat/PreChatForm.types.ts +22 -0
  442. package/src/ui/styles/global.ts +50 -0
  443. package/src/ui/styles/theme.ts +155 -0
  444. package/src/ui/utils/conversations.ts +122 -0
  445. package/src/ui/utils/html.ts +58 -0
  446. package/src/ui/utils/native-gradient.ts +60 -0
  447. package/src/ui/utils/rtl.ts +43 -0
  448. package/src/ui/utils/safe-url.ts +63 -0
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.START_ALIGN = void 0;
7
+ exports.backDirection = backDirection;
8
+ exports.flipForRTL = flipForRTL;
9
+ exports.forwardDirection = forwardDirection;
10
+ exports.isRTL = isRTL;
11
+ var _reactNative = require("react-native");
12
+ /**
13
+ * Right-to-left helpers.
14
+ *
15
+ * Yoga mirrors `flexDirection: 'row'`, `flex-start`/`flex-end` and the
16
+ * `start`/`end` style props on its own once the host app has turned RTL on.
17
+ * What it cannot mirror is meaning: an arrow that points "forward" is drawn
18
+ * rightwards in English and leftwards in Arabic, and a bubble's tail corner
19
+ * swaps sides with it. Those decisions live here.
20
+ */
21
+
22
+ /**
23
+ * Text alignment follows the LAYOUT's direction, not the script's. Left to
24
+ * itself, a Latin string inside an Arabic screen renders hard against the
25
+ * left edge while everything around it is anchored right, which reads as a
26
+ * broken row rather than as mixed content.
27
+ *
28
+ * Read once at module load: switching direction requires an app restart.
29
+ */
30
+ const START_ALIGN = exports.START_ALIGN = _reactNative.I18nManager.isRTL ? 'right' : 'left';
31
+ function isRTL() {
32
+ return _reactNative.I18nManager.isRTL;
33
+ }
34
+
35
+ /** Deeper into the app: a disclosure chevron, a "continue" arrow. */
36
+ function forwardDirection() {
37
+ return _reactNative.I18nManager.isRTL ? 'left' : 'right';
38
+ }
39
+
40
+ /** Back out of the current screen. */
41
+ function backDirection() {
42
+ return _reactNative.I18nManager.isRTL ? 'right' : 'left';
43
+ }
44
+
45
+ /**
46
+ * Mirrors a glyph that is drawn pointing right. Cheaper and less error-prone
47
+ * than maintaining a second set of geometry for every directional icon.
48
+ */
49
+ function flipForRTL() {
50
+ return _reactNative.I18nManager.isRTL ? {
51
+ transform: [{
52
+ scaleX: -1
53
+ }]
54
+ } : undefined;
55
+ }
56
+ //# sourceMappingURL=rtl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","START_ALIGN","exports","I18nManager","isRTL","forwardDirection","backDirection","flipForRTL","transform","scaleX","undefined"],"sourceRoot":"../../../../src","sources":["ui/utils/rtl.ts"],"mappings":";;;;;;;;;;AAUA,IAAAA,YAAA,GAAAC,OAAA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,WAA6B,GAAAC,OAAA,CAAAD,WAAA,GAAGE,wBAAW,CAACC,KAAK,GAAG,OAAO,GAAG,MAAM;AAE1E,SAASA,KAAKA,CAAA,EAAY;EAC/B,OAAOD,wBAAW,CAACC,KAAK;AAC1B;;AAEA;AACO,SAASC,gBAAgBA,CAAA,EAAqB;EACnD,OAAOF,wBAAW,CAACC,KAAK,GAAG,MAAM,GAAG,OAAO;AAC7C;;AAEA;AACO,SAASE,aAAaA,CAAA,EAAqB;EAChD,OAAOH,wBAAW,CAACC,KAAK,GAAG,OAAO,GAAG,MAAM;AAC7C;;AAEA;AACA;AACA;AACA;AACO,SAASG,UAAUA,CAAA,EAAoD;EAC5E,OAAOJ,wBAAW,CAACC,KAAK,GAAG;IAAEI,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE,CAAC;IAAE,CAAC;EAAE,CAAC,GAAGC,SAAS;AACxE","ignoreList":[]}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isHttpUrl = isHttpUrl;
7
+ exports.isSafeExternalUrl = isSafeExternalUrl;
8
+ exports.openExternalUrl = openExternalUrl;
9
+ exports.setOpenUrlHandler = setOpenUrlHandler;
10
+ exports.urlScheme = urlScheme;
11
+ var _reactNative = require("react-native");
12
+ /**
13
+ * The one gate every widget link goes through before `Linking.openURL`.
14
+ *
15
+ * Agent and AI replies, campaign CTAs and attachment URLs are remote content.
16
+ * Opened blindly they could fire the host app's own deep links
17
+ * (`myapp://transfer?…`), Android `intent:` URLs, `sms:` or `file:` URIs. Only
18
+ * web, mail and phone links open by default; the host can route anything else
19
+ * itself through `boot({ onOpenUrl })`.
20
+ */
21
+
22
+ const ALLOWED_SCHEMES = new Set(['https:', 'http:', 'mailto:', 'tel:']);
23
+
24
+ // eslint-disable-next-line no-control-regex
25
+ const CONTROL_CHARS = /[\u0000-\u001F\u007F]/;
26
+ let hostHandler = null;
27
+
28
+ /** Set from `boot({ onOpenUrl })`; `null` restores the default policy. */
29
+ function setOpenUrlHandler(handler) {
30
+ hostHandler = handler;
31
+ }
32
+
33
+ /** Lower-cased scheme including the colon (`'https:'`), or null when relative. */
34
+ function urlScheme(url) {
35
+ const match = /^([a-z][a-z0-9+.-]*):/i.exec(url);
36
+ return match ? `${match[1].toLowerCase()}:` : null;
37
+ }
38
+
39
+ /** Absolute `http(s)://host…` — the only shape media URLs may take. */
40
+ function isHttpUrl(url) {
41
+ return !CONTROL_CHARS.test(url) && /^https?:\/\/[^/\s]/i.test(url);
42
+ }
43
+ function isSafeExternalUrl(url) {
44
+ if (!url || CONTROL_CHARS.test(url)) return false;
45
+ const scheme = urlScheme(url);
46
+ if (!scheme || !ALLOWED_SCHEMES.has(scheme)) return false;
47
+ return scheme === 'http:' || scheme === 'https:' ? isHttpUrl(url) : true;
48
+ }
49
+
50
+ /** Host handler first, then the allow-list. Never throws. */
51
+ async function openExternalUrl(url) {
52
+ const target = (url ?? '').trim();
53
+ if (!target) return;
54
+ if (hostHandler) {
55
+ try {
56
+ if (await hostHandler(target)) return;
57
+ } catch (error) {
58
+ console.warn('[repzo-widget] onOpenUrl threw — falling back to the default policy', error);
59
+ }
60
+ }
61
+ if (!isSafeExternalUrl(target)) {
62
+ console.warn(`[repzo-widget] blocked a link with a disallowed scheme (${urlScheme(target) ?? 'none'})`);
63
+ return;
64
+ }
65
+ _reactNative.Linking.openURL(target).catch(() => {});
66
+ }
67
+ //# sourceMappingURL=safe-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","ALLOWED_SCHEMES","Set","CONTROL_CHARS","hostHandler","setOpenUrlHandler","handler","urlScheme","url","match","exec","toLowerCase","isHttpUrl","test","isSafeExternalUrl","scheme","has","openExternalUrl","target","trim","error","console","warn","Linking","openURL","catch"],"sourceRoot":"../../../../src","sources":["ui/utils/safe-url.ts"],"mappings":";;;;;;;;;;AAUA,IAAAA,YAAA,GAAAC,OAAA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;;AAEvE;AACA,MAAMC,aAAa,GAAG,uBAAuB;AAE7C,IAAIC,WAAkC,GAAG,IAAI;;AAE7C;AACO,SAASC,iBAAiBA,CAACC,OAA8B,EAAQ;EACtEF,WAAW,GAAGE,OAAO;AACvB;;AAEA;AACO,SAASC,SAASA,CAACC,GAAW,EAAiB;EACpD,MAAMC,KAAK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AAM,CAAC,CAAC,CAAC;AACzC","ignoreList":[]}
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Structural parsing for agent-authored UI blocks.
5
+ *
6
+ * The CRM validates these with zod (`shared/agent-ui-blocks.ts`) before
7
+ * broadcasting, so this side only needs to reject malformed payloads rather
8
+ * than re-implement the schema — which keeps the SDK dependency-free. Action
9
+ * message formatting is copied verbatim so the transcript reads the same on
10
+ * web and mobile.
11
+ */
12
+
13
+ const KNOWN_BLOCK_TYPES = new Set(['product_service_card', 'product_choices', 'commerce_actions', 'cart_order_summary', 'contact_lead_form', 'consent', 'appointment_slot_picker', 'quote_preview', 'success_receipt']);
14
+ const KNOWN_ACTION_TYPES = new Set(['add_to_cart', 'buy_now', 'submit_contact', 'record_consent', 'select_appointment_provider', 'select_appointment_slot', 'open_record', 'accept_quote', 'next_action']);
15
+ function isRecord(value) {
16
+ return !!value && typeof value === 'object' && !Array.isArray(value);
17
+ }
18
+
19
+ // The renderer dereferences nested fields and hands strings to <Text>, so a
20
+ // block is only accepted when every field it touches has the right shape —
21
+ // one wrong type (`providers` missing, a numeric slot time, a string
22
+ // `amount`) must skip that block, not throw inside the host app's tree.
23
+
24
+ const isString = value => typeof value === 'string';
25
+ const isNumber = value => typeof value === 'number' && Number.isFinite(value);
26
+ const isOptional = (value, check) => value === undefined || value === null || check(value);
27
+ const isArrayOf = (value, check) => Array.isArray(value) && value.every(check);
28
+ function isAction(value) {
29
+ if (!isRecord(value)) return false;
30
+ return isString(value.id) && isString(value.label) && isString(value.type) && KNOWN_ACTION_TYPES.has(value.type) && isRecord(value.payload);
31
+ }
32
+ function isCommerceItem(value) {
33
+ return isRecord(value) && isString(value.name) && isNumber(value.quantity) && isNumber(value.unitPrice) && isNumber(value.lineTotal);
34
+ }
35
+ function isVariant(value) {
36
+ return isRecord(value) && isString(value.id) && isString(value.title) && isNumber(value.price) && isString(value.currency);
37
+ }
38
+ function isFormField(value) {
39
+ return isRecord(value) && isString(value.name) && isString(value.label) && isOptional(value.placeholder, isString) && isOptional(value.value, isString);
40
+ }
41
+ function isProvider(value) {
42
+ return isRecord(value) && isString(value.id) && isString(value.name);
43
+ }
44
+ function isSlot(value) {
45
+ return isRecord(value) && isString(value.startTime) && isString(value.endTime) && isString(value.slotToken) && isOptional(value.staffUserId, isString);
46
+ }
47
+ function isDay(value) {
48
+ return isRecord(value) && isString(value.date) && isArrayOf(value.slots, isSlot);
49
+ }
50
+ function isValidBlock(block) {
51
+ switch (block.type) {
52
+ case 'product_service_card':
53
+ {
54
+ const product = block.product;
55
+ return isRecord(product) && isString(product.name) && isNumber(product.price) && isString(product.currency) && isOptional(product.imageUrl, isString) && isOptional(product.shortDescription, isString) && isOptional(product.description, isString) && isOptional(product.unit, isString) && isOptional(product.durationMinutes, isNumber);
56
+ }
57
+ case 'product_choices':
58
+ return isString(block.productId) && isString(block.title) && Array.isArray(block.variants) && block.variants.length > 0 && block.variants.every(isVariant);
59
+ case 'commerce_actions':
60
+ return isArrayOf(block.actions, isAction);
61
+ case 'cart_order_summary':
62
+ return isString(block.title) && isString(block.currency) && isArrayOf(block.items, isCommerceItem) && isNumber(block.subtotal) && isNumber(block.total) && isOptional(block.discount, isNumber) && isOptional(block.tax, isNumber) && isOptional(block.shipping, isNumber) && isOptional(block.status, isString) && isOptional(block.action, isAction);
63
+ case 'contact_lead_form':
64
+ return isString(block.title) && isString(block.submitLabel) && isOptional(block.description, isString) && Array.isArray(block.fields) && block.fields.length > 0 && block.fields.every(isFormField);
65
+ case 'consent':
66
+ return isString(block.statement) && isArrayOf(block.channels, isString);
67
+ case 'appointment_slot_picker':
68
+ return isString(block.serviceId) && isString(block.serviceName) && isNumber(block.durationMinutes) && isOptional(block.timezone, isString) && isOptional(block.selectedProviderId, isString) && isOptional(block.providers, value => isArrayOf(value, isProvider)) && Array.isArray(block.days) && block.days.length > 0 && block.days.every(isDay);
69
+ case 'quote_preview':
70
+ return isString(block.name) && isString(block.currency) && isString(block.status) && isNumber(block.amount) && isOptional(block.serialNumber, isString) && isOptional(block.contactName, isString) && isOptional(block.validUntil, isString) && isOptional(block.actions, value => isArrayOf(value, isAction));
71
+ case 'success_receipt':
72
+ return isString(block.title) && isOptional(block.description, isString) && isOptional(block.reference, isString) && isOptional(block.amount, isNumber) && isOptional(block.currency, isString) && isOptional(block.nextActions, value => isArrayOf(value, isAction));
73
+ default:
74
+ return false;
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Drops blocks this SDK version does not know how to render, or whose fields
80
+ * don't match what the renderer reads. Optional lists the server may omit
81
+ * come back as empty arrays.
82
+ */
83
+ export function parseAgentUiBlocks(value) {
84
+ if (!Array.isArray(value)) return [];
85
+ const blocks = [];
86
+ for (const block of value) {
87
+ if (!isRecord(block)) continue;
88
+ if (!isString(block.id) || !isString(block.type)) continue;
89
+ if (!KNOWN_BLOCK_TYPES.has(block.type) || !isValidBlock(block)) continue;
90
+ const normalized = block.type === 'appointment_slot_picker' ? {
91
+ ...block,
92
+ providers: block.providers ?? []
93
+ } : block.type === 'quote_preview' ? {
94
+ ...block,
95
+ actions: block.actions ?? []
96
+ } : block.type === 'success_receipt' ? {
97
+ ...block,
98
+ nextActions: block.nextActions ?? []
99
+ } : block;
100
+ blocks.push(normalized);
101
+ }
102
+ return blocks;
103
+ }
104
+ export function getAgentUiBlocks(metadata) {
105
+ if (!isRecord(metadata)) return [];
106
+ return parseAgentUiBlocks(metadata.agentUiBlocks);
107
+ }
108
+ export function getProcedureForm(metadata) {
109
+ if (!isRecord(metadata)) return null;
110
+ const form = metadata.agentProcedureForm;
111
+ if (!isRecord(form) || !Array.isArray(form.fields) || form.fields.length === 0) return null;
112
+ return {
113
+ procedureId: typeof form.procedureId === 'string' ? form.procedureId : '',
114
+ procedureName: typeof form.procedureName === 'string' ? form.procedureName : 'Details',
115
+ fields: form.fields.filter(field => field && typeof field.name === 'string').map(field => ({
116
+ name: field.name,
117
+ label: typeof field.label === 'string' ? field.label : field.name,
118
+ type: ['email', 'phone', 'date', 'time', 'text'].includes(field.type) ? field.type : 'text',
119
+ required: field.required !== false
120
+ }))
121
+ };
122
+ }
123
+ export function formatAgentUiActionMessage(action) {
124
+ const payload = action.payload;
125
+ switch (action.type) {
126
+ case 'add_to_cart':
127
+ return `Add ${String(payload.productName || 'this item')} to my cart${payload.variantTitle ? ` (${String(payload.variantTitle)})` : ''}.`;
128
+ case 'buy_now':
129
+ if (payload.cartId) return `Create an order from cart ${String(payload.cartId)}.`;
130
+ if (action.module === 'appointments' || payload.productType === 'service') {
131
+ return `Book ${String(payload.productName || 'this service')}${payload.variantTitle ? ` (${String(payload.variantTitle)})` : ''}.`;
132
+ }
133
+ return `Buy ${String(payload.productName || 'this item')} now${payload.variantTitle ? ` (${String(payload.variantTitle)})` : ''}.`;
134
+ case 'select_appointment_provider':
135
+ return `Show appointment times for ${String(payload.serviceName || 'this service')} with ${String(payload.providerName || 'any available professional')}.`;
136
+ case 'select_appointment_slot':
137
+ return `Book ${String(payload.serviceName || 'this service')} on ${String(payload.date || 'the selected date')} at ${String(payload.startTime || 'the selected time')}${payload.providerName ? ` with ${String(payload.providerName)}` : ''}.`;
138
+ case 'accept_quote':
139
+ return `I accept quote ${String(payload.reference || payload.quoteId || '')}.`.trim();
140
+ case 'record_consent':
141
+ return `I consent to being contacted by ${Array.isArray(payload.channels) ? payload.channels.join(', ') : 'the selected channel'}.`;
142
+ case 'open_record':
143
+ return action.label;
144
+ case 'submit_contact':
145
+ return Object.entries(payload).filter(([, value]) => typeof value === 'string' && value.trim()).map(([key, value]) => `${key}: ${String(value).trim()}`).join('\n') || 'I have submitted my contact details.';
146
+ case 'next_action':
147
+ return action.label;
148
+ default:
149
+ return action.label;
150
+ }
151
+ }
152
+ //# sourceMappingURL=agent-ui-blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["KNOWN_BLOCK_TYPES","Set","KNOWN_ACTION_TYPES","isRecord","value","Array","isArray","isString","isNumber","Number","isFinite","isOptional","check","undefined","isArrayOf","every","isAction","id","label","type","has","payload","isCommerceItem","name","quantity","unitPrice","lineTotal","isVariant","title","price","currency","isFormField","placeholder","isProvider","isSlot","startTime","endTime","slotToken","staffUserId","isDay","date","slots","isValidBlock","block","product","imageUrl","shortDescription","description","unit","durationMinutes","productId","variants","length","actions","items","subtotal","total","discount","tax","shipping","status","action","submitLabel","fields","statement","channels","serviceId","serviceName","timezone","selectedProviderId","providers","days","amount","serialNumber","contactName","validUntil","reference","nextActions","parseAgentUiBlocks","blocks","normalized","push","getAgentUiBlocks","metadata","agentUiBlocks","getProcedureForm","form","agentProcedureForm","procedureId","procedureName","filter","field","map","includes","required","formatAgentUiActionMessage","String","productName","variantTitle","cartId","module","productType","providerName","quoteId","trim","join","Object","entries","key"],"sourceRoot":"../../src","sources":["agent-ui-blocks.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,MAAMA,iBAAiB,GAAG,IAAIC,GAAG,CAAC,CAChC,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,EACT,yBAAyB,EACzB,eAAe,EACf,iBAAiB,CAClB,CAAC;AAEF,MAAMC,kBAAkB,GAAG,IAAID,GAAG,CAAC,CACjC,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,6BAA6B,EAC7B,yBAAyB,EACzB,aAAa,EACb,cAAc,EACd,aAAa,CACd,CAAC;AAEF,SAASE,QAAQA,CAACC,KAAc,EAAoC;EAClE,OAAO,CAAC,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AACtE;;AAEA;AACA;AACA;AACA;;AAEA,MAAMG,QAAQ,GAAIH,KAAc,IAAsB,OAAOA,KAAK,KAAK,QAAQ;AAE/E,MAAMI,QAAQ,GAAIJ,KAAc,IAC9B,OAAOA,KAAK,KAAK,QAAQ,IAAIK,MAAM,CA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rB,KAAK,gBAAgB;MACnB,OACEwF,MAAM,CAACC,OAAO,CAACtF,OAAO,CAAC,CACpBqE,MAAM,CAAC,CAAC,GAAGtF,KAAK,CAAC,KAAK,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACoG,IAAI,CAAC,CAAC,CAAC,CAChEZ,GAAG,CAAC,CAAC,CAACgB,GAAG,EAAExG,KAAK,CAAC,KAAK,GAAGwG,GAAG,KAAKZ,MAAM,CAAC5F,KAAK,CAAC,CAACoG,IAAI,CAAC,CAAC,EAAE,CAAC,CACxDC,IAAI,CAAC,IAAI,CAAC,IAAI,sCAAsC;IAE3D,KAAK,aAAa;MAChB,OAAO5C,MAAM,CAAC3C,KAAK;IACrB;MACE,OAAO2C,MAAM,CAAC3C,KAAK;EACvB;AACF","ignoreList":[]}
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Fetch client for `/api/widget/*`.
5
+ *
6
+ * Ported from the web widget's `client/src/widget/lib/api.ts`, with
7
+ * localStorage swapped for the storage adapter and EventSource moved to
8
+ * `api/realtime.ts`. Visitor tokens live up to 14 days with no refresh, so a
9
+ * 401 triggers one silent re-init + retry (single-flight, owned by the store).
10
+ * The token itself lives in `SecureStorage`.
11
+ */
12
+
13
+ import { SecureStorage, TOKEN_KEY } from "../storage.js";
14
+ import { isHttpUrl, urlScheme } from "../ui/utils/safe-url.js";
15
+
16
+ /** Server `code`s that no retry or re-init can fix. */
17
+ const TERMINAL_CODES = new Set(['messenger_api_disabled', 'identity_verification_failed']);
18
+ export function isTerminalErrorCode(code) {
19
+ return !!code && TERMINAL_CODES.has(code);
20
+ }
21
+ export class RepzoWidgetError extends Error {
22
+ constructor(message, status, code = 'http') {
23
+ super(message);
24
+ this.name = 'RepzoWidgetError';
25
+ this.status = status;
26
+ this.code = code;
27
+ }
28
+
29
+ /** Builds the error for a non-2xx `{ message, code }` body. */
30
+ static fromResponse(status, body) {
31
+ const payload = body && typeof body === 'object' ? body : {};
32
+ const message = typeof payload.message === 'string' && payload.message ? payload.message : null;
33
+ const code = status === 403 && typeof payload.code === 'string' && isTerminalErrorCode(payload.code) ? payload.code : 'http';
34
+ return new RepzoWidgetError(message || `HTTP ${status}`, status, code);
35
+ }
36
+ }
37
+ export class WidgetApiClient {
38
+ baseUrl = '';
39
+ channelAccountId = '';
40
+ token = null;
41
+ tokenLoaded = false;
42
+
43
+ /**
44
+ * Set by the store: given the token that just got a 401, returns a valid
45
+ * token (fresh, or one another caller already minted), or null.
46
+ */
47
+ reauthorize = null;
48
+
49
+ /** Set by the store: a 403 with a terminal `code` came back from any endpoint. */
50
+ onTerminalError = null;
51
+ configure(baseUrl, channelAccountId) {
52
+ this.baseUrl = baseUrl.replace(/\/$/, '');
53
+ this.channelAccountId = channelAccountId;
54
+ }
55
+ getBaseUrl() {
56
+ return this.baseUrl;
57
+ }
58
+ getChannelAccountId() {
59
+ return this.channelAccountId;
60
+ }
61
+ async getToken() {
62
+ if (this.token) return this.token;
63
+ if (!this.tokenLoaded) {
64
+ this.tokenLoaded = true;
65
+ this.token = await SecureStorage.getItem(TOKEN_KEY);
66
+ }
67
+ return this.token;
68
+ }
69
+ async setToken(token) {
70
+ this.token = token;
71
+ this.tokenLoaded = true;
72
+ await SecureStorage.setItem(TOKEN_KEY, token);
73
+ }
74
+ async clearToken() {
75
+ this.token = null;
76
+ this.tokenLoaded = true;
77
+ await SecureStorage.removeItem(TOKEN_KEY);
78
+ }
79
+
80
+ /**
81
+ * Absolute URL for a server media path (avatars, attachments). Only ever
82
+ * returns `http(s)` — relative paths resolve against `baseUrl`; any other
83
+ * scheme (`file:`, `data:`, `intent:`, host deep links…) yields null.
84
+ */
85
+ resolveUrl(url) {
86
+ const trimmed = url?.trim();
87
+ if (!trimmed) return null;
88
+ if (isHttpUrl(trimmed)) return trimmed;
89
+ if (urlScheme(trimmed)) return null;
90
+ const resolved = `${this.baseUrl}${trimmed.startsWith('/') ? '' : '/'}${trimmed}`;
91
+ return isHttpUrl(resolved) ? resolved : null;
92
+ }
93
+ async request(path, options = {}) {
94
+ let sentToken = null;
95
+ const send = async () => {
96
+ const headers = {
97
+ 'Content-Type': 'application/json'
98
+ };
99
+ const token = options.authToken !== undefined ? options.authToken : await this.getToken();
100
+ sentToken = token;
101
+ if (token) headers.Authorization = `Bearer ${token}`;
102
+ try {
103
+ return await fetch(`${this.baseUrl}${path}`, {
104
+ method: options.method ?? 'GET',
105
+ headers,
106
+ body: options.body === undefined ? undefined : JSON.stringify(options.body)
107
+ });
108
+ } catch (error) {
109
+ throw new RepzoWidgetError(error instanceof Error ? error.message : 'Network request failed', 0, 'network');
110
+ }
111
+ };
112
+ let response = await send();
113
+
114
+ // The token expired or was revoked: mint a new session once.
115
+ if (response.status === 401 && !options.skipReauth && this.reauthorize) {
116
+ const refreshed = await this.reauthorize(sentToken);
117
+ if (refreshed) response = await send();
118
+ }
119
+ if (!response.ok) {
120
+ const body = await response.json().catch(() => null);
121
+ const error = RepzoWidgetError.fromResponse(response.status, body);
122
+ // skipReauth calls (init, logout-time) are handled by their caller,
123
+ // which knows whether the result is still current.
124
+ if (isTerminalErrorCode(error.code) && !options.skipReauth) this.onTerminalError?.(error);
125
+ throw error;
126
+ }
127
+ if (response.status === 204) return undefined;
128
+ return await response.json();
129
+ }
130
+
131
+ // ─── Endpoints ────────────────────────────────────────────────────────────
132
+
133
+ /** Public config. `platform` makes the server apply the Mobile SDKs overrides. */
134
+ getConfig(platform) {
135
+ const query = platform ? `?platform=${encodeURIComponent(platform)}` : '';
136
+ return this.request(`/api/widget/config/${encodeURIComponent(this.channelAccountId)}${query}`);
137
+ }
138
+ getOutboundMessage() {
139
+ return this.request(`/api/widget/outbound/${encodeURIComponent(this.channelAccountId)}`);
140
+ }
141
+
142
+ /**
143
+ * Does NOT store the returned token — the store persists it only once it
144
+ * knows the identity op that asked for it is still current.
145
+ */
146
+ async init(params) {
147
+ const visitorToken = params.resumeToken === false ? null : await this.getToken();
148
+ const user = params.user ? {
149
+ ...(params.user.email ? {
150
+ email: params.user.email
151
+ } : {}),
152
+ ...(params.user.name ? {
153
+ name: params.user.name
154
+ } : {}),
155
+ ...(params.user.phone ? {
156
+ phone: params.user.phone
157
+ } : {}),
158
+ ...(params.user.userId ? {
159
+ user_id: params.user.userId
160
+ } : {}),
161
+ ...(params.user.userHash ? {
162
+ user_hash: params.user.userHash
163
+ } : {})
164
+ } : undefined;
165
+ return this.request('/api/widget/init', {
166
+ method: 'POST',
167
+ skipReauth: true,
168
+ body: {
169
+ channelAccountId: this.channelAccountId,
170
+ visitorToken,
171
+ trackingVisitorId: params.trackingVisitorId,
172
+ platform: params.platform,
173
+ sdkVersion: params.sdkVersion,
174
+ ...(user ? {
175
+ user
176
+ } : {})
177
+ }
178
+ });
179
+ }
180
+
181
+ /** Revokes `token` server-side. A 401 means it was already dead — fine. */
182
+ async logout(token) {
183
+ try {
184
+ await this.request('/api/widget/logout', {
185
+ method: 'POST',
186
+ skipReauth: true,
187
+ authToken: token
188
+ });
189
+ } catch (error) {
190
+ if (error instanceof RepzoWidgetError && error.status === 401) return;
191
+ throw error;
192
+ }
193
+ }
194
+ sendMessage(data) {
195
+ return this.request('/api/widget/messages', {
196
+ method: 'POST',
197
+ body: data
198
+ });
199
+ }
200
+ listConversations() {
201
+ return this.request('/api/widget/conversations');
202
+ }
203
+ listMessages(conversationId, cursor) {
204
+ const query = cursor ? `?cursor=${encodeURIComponent(cursor)}` : '';
205
+ return this.request(`/api/widget/conversations/${encodeURIComponent(conversationId)}/messages${query}`);
206
+ }
207
+
208
+ /**
209
+ * Advances the visitor's read cursor for a thread they're watching live.
210
+ * Best effort and `skipReauth`: a burst of live replies must never turn an
211
+ * expired token into a burst of re-inits.
212
+ */
213
+ markConversationRead(conversationId) {
214
+ return this.request(`/api/widget/conversations/${encodeURIComponent(conversationId)}/read`, {
215
+ method: 'POST',
216
+ skipReauth: true
217
+ });
218
+ }
219
+ identify(data) {
220
+ return this.request('/api/widget/identify', {
221
+ method: 'POST',
222
+ body: data
223
+ });
224
+ }
225
+ sendTyping(conversationId, isTyping) {
226
+ return this.request('/api/widget/typing', {
227
+ method: 'POST',
228
+ body: {
229
+ conversationId,
230
+ isTyping
231
+ }
232
+ });
233
+ }
234
+ trackEvent(data) {
235
+ return this.request('/api/widget/events', {
236
+ method: 'POST',
237
+ body: {
238
+ ...data,
239
+ channelAccountId: this.channelAccountId
240
+ }
241
+ });
242
+ }
243
+ registerPushToken(data) {
244
+ return this.request('/api/widget/push-token', {
245
+ method: 'POST',
246
+ body: data
247
+ });
248
+ }
249
+
250
+ /** Logout passes the session's token explicitly and `skipReauth`. */
251
+ removePushToken(token, auth = {}) {
252
+ return this.request('/api/widget/push-token', {
253
+ method: 'DELETE',
254
+ body: {
255
+ token
256
+ },
257
+ ...auth
258
+ });
259
+ }
260
+ }
261
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SecureStorage","TOKEN_KEY","isHttpUrl","urlScheme","TERMINAL_CODES","Set","isTerminalErrorCode","code","has","RepzoWidgetError","Error","constructor","message","status","name","fromResponse","body","payload","WidgetApiClient","baseUrl","channelAccountId","token","tokenLoaded","reauthorize","onTerminalError","configure","replace","getBaseUrl","getChannelAccountId","getToken","getItem","setToken","setItem","clearToken","removeItem","resolveUrl","url","trimmed","trim","resolved","startsWith","request","path","options","sentToken","send","headers","authToken","undefined","Authorization","fetch","method","JSON","stringify","error","response","skipReauth","refreshed","ok","json","catch","getConfig","platform","query","encodeURIComponent","getOutboundMessage","init","params","visitorToken","resumeToken","user","email","phone","userId","user_id","userHash","user_hash","trackingVisitorId","sdkVersion","logout","sendMessage","data","listConversations","listMessages","conversationId","cursor","markConversationRead","identify","sendTyping","isTyping","trackEvent","registerPushToken","removePushToken","auth"],"sourceRoot":"../../../src","sources":["api/client.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,EAAEC,SAAS,QAAQ,eAAY;AAYrD,SAAS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