@webority/mobile-chat 0.128.0 → 0.134.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 (264) hide show
  1. package/lib/commonjs/AgentByline.js +1 -0
  2. package/lib/commonjs/ChatComposer.js +1 -0
  3. package/lib/commonjs/ChatConversationActions.js +1 -0
  4. package/lib/commonjs/ChatDictationButton.js +1 -0
  5. package/lib/commonjs/ChatEmbed.js +1 -0
  6. package/lib/commonjs/ChatEntrance.js +1 -0
  7. package/lib/commonjs/ChatFooter.js +1 -0
  8. package/lib/commonjs/ChatFrame.js +1 -0
  9. package/lib/commonjs/ChatHistory.js +1 -0
  10. package/lib/commonjs/ChatLiveBar.js +1 -0
  11. package/lib/commonjs/ChatMessageActions.js +1 -0
  12. package/lib/commonjs/ChatNudge.js +1 -0
  13. package/lib/commonjs/ChatOpenTickets.js +1 -0
  14. package/lib/commonjs/ChatPastChats.js +1 -0
  15. package/lib/commonjs/ChatScreen.js +1 -0
  16. package/lib/commonjs/ChatSheet.js +1 -0
  17. package/lib/commonjs/ChatStarters.js +1 -0
  18. package/lib/commonjs/ChatThread.js +1 -0
  19. package/lib/commonjs/ReadAloudButton.js +1 -0
  20. package/lib/commonjs/chatShared.js +1 -0
  21. package/lib/commonjs/features.map.json +40 -0
  22. package/lib/commonjs/index.js +1 -1
  23. package/lib/commonjs/loaders/ChatLoader.js +1 -0
  24. package/lib/commonjs/loaders/OrbLoader.js +1 -0
  25. package/lib/commonjs/loaders/PhrasesLoader.js +1 -0
  26. package/lib/commonjs/loaders/SkeletonLoader.js +1 -0
  27. package/lib/commonjs/loaders/StepsLoader.js +1 -0
  28. package/lib/commonjs/loaders/TypingPill.js +1 -0
  29. package/lib/commonjs/pushOpen.js +1 -0
  30. package/lib/commonjs/renderers/ActionPart.js +1 -0
  31. package/lib/commonjs/renderers/ChartPart.js +1 -0
  32. package/lib/commonjs/renderers/FigureText.js +1 -0
  33. package/lib/commonjs/renderers/FiguresPart.js +1 -0
  34. package/lib/commonjs/renderers/FilePart.js +1 -0
  35. package/lib/commonjs/renderers/HandoffPart.js +1 -0
  36. package/lib/commonjs/renderers/ImagePart.js +1 -0
  37. package/lib/commonjs/renderers/InputRequestPart.js +1 -0
  38. package/lib/commonjs/renderers/NoticePart.js +1 -0
  39. package/lib/commonjs/renderers/QuickRepliesPart.js +1 -0
  40. package/lib/commonjs/renderers/RecordCardPart.js +1 -0
  41. package/lib/commonjs/renderers/SourcesPart.js +1 -0
  42. package/lib/commonjs/renderers/TablePart.js +1 -0
  43. package/lib/commonjs/renderers/TextPart.js +1 -0
  44. package/lib/commonjs/renderers/TicketPart.js +1 -0
  45. package/lib/commonjs/renderers/VoiceClipPart.js +1 -0
  46. package/lib/commonjs/renderers/index.js +1 -0
  47. package/lib/commonjs/speech/azureSpeech.js +1 -0
  48. package/lib/commonjs/speech/expoAudio.js +1 -0
  49. package/lib/commonjs/speech/phoneSpeech.js +1 -0
  50. package/lib/commonjs/speech/speechText.js +1 -0
  51. package/lib/commonjs/types.js +1 -0
  52. package/lib/commonjs/useChat.js +1 -1
  53. package/lib/commonjs/useChatHaptics.js +1 -0
  54. package/lib/commonjs/useChatSound.js +1 -0
  55. package/lib/commonjs/useChatSpeech.js +1 -0
  56. package/lib/commonjs/useTranscriptActions.js +1 -0
  57. package/lib/module/AgentByline.js +1 -0
  58. package/lib/module/ChatComposer.js +1 -0
  59. package/lib/module/ChatConversationActions.js +1 -0
  60. package/lib/module/ChatDictationButton.js +1 -0
  61. package/lib/module/ChatEmbed.js +1 -0
  62. package/lib/module/ChatEntrance.js +1 -0
  63. package/lib/module/ChatFooter.js +1 -0
  64. package/lib/module/ChatFrame.js +1 -0
  65. package/lib/module/ChatHistory.js +1 -0
  66. package/lib/module/ChatLiveBar.js +1 -0
  67. package/lib/module/ChatMessageActions.js +1 -0
  68. package/lib/module/ChatNudge.js +1 -0
  69. package/lib/module/ChatOpenTickets.js +1 -0
  70. package/lib/module/ChatPastChats.js +1 -0
  71. package/lib/module/ChatScreen.js +1 -0
  72. package/lib/module/ChatSheet.js +1 -0
  73. package/lib/module/ChatStarters.js +1 -0
  74. package/lib/module/ChatThread.js +1 -0
  75. package/lib/module/ReadAloudButton.js +1 -0
  76. package/lib/module/chatShared.js +1 -0
  77. package/lib/module/features.map.json +40 -0
  78. package/lib/module/index.js +1 -1
  79. package/lib/module/loaders/ChatLoader.js +1 -0
  80. package/lib/module/loaders/OrbLoader.js +1 -0
  81. package/lib/module/loaders/PhrasesLoader.js +1 -0
  82. package/lib/module/loaders/SkeletonLoader.js +1 -0
  83. package/lib/module/loaders/StepsLoader.js +1 -0
  84. package/lib/module/loaders/TypingPill.js +1 -0
  85. package/lib/module/pushOpen.js +1 -0
  86. package/lib/module/renderers/ActionPart.js +1 -0
  87. package/lib/module/renderers/ChartPart.js +1 -0
  88. package/lib/module/renderers/FigureText.js +1 -0
  89. package/lib/module/renderers/FiguresPart.js +1 -0
  90. package/lib/module/renderers/FilePart.js +1 -0
  91. package/lib/module/renderers/HandoffPart.js +1 -0
  92. package/lib/module/renderers/ImagePart.js +1 -0
  93. package/lib/module/renderers/InputRequestPart.js +1 -0
  94. package/lib/module/renderers/NoticePart.js +1 -0
  95. package/lib/module/renderers/QuickRepliesPart.js +1 -0
  96. package/lib/module/renderers/RecordCardPart.js +1 -0
  97. package/lib/module/renderers/SourcesPart.js +1 -0
  98. package/lib/module/renderers/TablePart.js +1 -0
  99. package/lib/module/renderers/TextPart.js +1 -0
  100. package/lib/module/renderers/TicketPart.js +1 -0
  101. package/lib/module/renderers/VoiceClipPart.js +1 -0
  102. package/lib/module/renderers/index.js +1 -0
  103. package/lib/module/speech/azureSpeech.js +1 -0
  104. package/lib/module/speech/expoAudio.js +1 -0
  105. package/lib/module/speech/phoneSpeech.js +1 -0
  106. package/lib/module/speech/speechText.js +1 -0
  107. package/lib/module/types.js +1 -0
  108. package/lib/module/useChat.js +1 -1
  109. package/lib/module/useChatHaptics.js +1 -0
  110. package/lib/module/useChatSound.js +1 -0
  111. package/lib/module/useChatSpeech.js +1 -0
  112. package/lib/module/useTranscriptActions.js +1 -0
  113. package/lib/typescript/commonjs/AgentByline.d.ts +9 -0
  114. package/lib/typescript/commonjs/ChatComposer.d.ts +15 -0
  115. package/lib/typescript/commonjs/ChatConversationActions.d.ts +10 -0
  116. package/lib/typescript/commonjs/ChatDictationButton.d.ts +19 -0
  117. package/lib/typescript/commonjs/ChatEmbed.d.ts +11 -0
  118. package/lib/typescript/commonjs/ChatEntrance.d.ts +8 -0
  119. package/lib/typescript/commonjs/ChatFooter.d.ts +9 -0
  120. package/lib/typescript/commonjs/ChatFrame.d.ts +45 -0
  121. package/lib/typescript/commonjs/ChatHistory.d.ts +11 -0
  122. package/lib/typescript/commonjs/ChatLiveBar.d.ts +11 -0
  123. package/lib/typescript/commonjs/ChatMessageActions.d.ts +15 -0
  124. package/lib/typescript/commonjs/ChatNudge.d.ts +14 -0
  125. package/lib/typescript/commonjs/ChatOpenTickets.d.ts +12 -0
  126. package/lib/typescript/commonjs/ChatPastChats.d.ts +21 -0
  127. package/lib/typescript/commonjs/ChatScreen.d.ts +5 -0
  128. package/lib/typescript/commonjs/ChatSheet.d.ts +21 -0
  129. package/lib/typescript/commonjs/ChatStarters.d.ts +12 -0
  130. package/lib/typescript/commonjs/ChatThread.d.ts +36 -0
  131. package/lib/typescript/commonjs/ReadAloudButton.d.ts +11 -0
  132. package/lib/typescript/commonjs/chatShared.d.ts +4 -0
  133. package/lib/typescript/commonjs/index.d.ts +27 -21
  134. package/lib/typescript/commonjs/loaders/ChatLoader.d.ts +13 -0
  135. package/lib/typescript/commonjs/loaders/OrbLoader.d.ts +8 -0
  136. package/lib/typescript/commonjs/loaders/PhrasesLoader.d.ts +8 -0
  137. package/lib/typescript/commonjs/loaders/SkeletonLoader.d.ts +8 -0
  138. package/lib/typescript/commonjs/loaders/StepsLoader.d.ts +8 -0
  139. package/lib/typescript/commonjs/loaders/TypingPill.d.ts +7 -0
  140. package/lib/typescript/commonjs/pushOpen.d.ts +3 -0
  141. package/lib/typescript/commonjs/renderers/ActionPart.d.ts +3 -0
  142. package/lib/typescript/commonjs/renderers/ChartPart.d.ts +8 -0
  143. package/lib/typescript/commonjs/renderers/FigureText.d.ts +23 -0
  144. package/lib/typescript/commonjs/renderers/FiguresPart.d.ts +8 -0
  145. package/lib/typescript/commonjs/renderers/FilePart.d.ts +3 -0
  146. package/lib/typescript/commonjs/renderers/HandoffPart.d.ts +9 -0
  147. package/lib/typescript/commonjs/renderers/ImagePart.d.ts +8 -0
  148. package/lib/typescript/commonjs/renderers/InputRequestPart.d.ts +3 -0
  149. package/lib/typescript/commonjs/renderers/NoticePart.d.ts +8 -0
  150. package/lib/typescript/commonjs/renderers/QuickRepliesPart.d.ts +8 -0
  151. package/lib/typescript/commonjs/renderers/RecordCardPart.d.ts +8 -0
  152. package/lib/typescript/commonjs/renderers/SourcesPart.d.ts +8 -0
  153. package/lib/typescript/commonjs/renderers/TablePart.d.ts +8 -0
  154. package/lib/typescript/commonjs/renderers/TextPart.d.ts +8 -0
  155. package/lib/typescript/commonjs/renderers/TicketPart.d.ts +9 -0
  156. package/lib/typescript/commonjs/renderers/VoiceClipPart.d.ts +9 -0
  157. package/lib/typescript/commonjs/renderers/index.d.ts +3 -0
  158. package/lib/typescript/commonjs/speech/azureSpeech.d.ts +25 -0
  159. package/lib/typescript/commonjs/speech/expoAudio.d.ts +23 -0
  160. package/lib/typescript/commonjs/speech/phoneSpeech.d.ts +16 -0
  161. package/lib/typescript/commonjs/speech/speechText.d.ts +16 -0
  162. package/lib/typescript/commonjs/types.d.ts +29 -0
  163. package/lib/typescript/commonjs/useChat.d.ts +40 -10
  164. package/lib/typescript/commonjs/useChatHaptics.d.ts +3 -0
  165. package/lib/typescript/commonjs/useChatSound.d.ts +35 -0
  166. package/lib/typescript/commonjs/useChatSpeech.d.ts +4 -0
  167. package/lib/typescript/commonjs/useTranscriptActions.d.ts +10 -0
  168. package/lib/typescript/module/AgentByline.d.ts +9 -0
  169. package/lib/typescript/module/ChatComposer.d.ts +15 -0
  170. package/lib/typescript/module/ChatConversationActions.d.ts +10 -0
  171. package/lib/typescript/module/ChatDictationButton.d.ts +19 -0
  172. package/lib/typescript/module/ChatEmbed.d.ts +11 -0
  173. package/lib/typescript/module/ChatEntrance.d.ts +8 -0
  174. package/lib/typescript/module/ChatFooter.d.ts +9 -0
  175. package/lib/typescript/module/ChatFrame.d.ts +45 -0
  176. package/lib/typescript/module/ChatHistory.d.ts +11 -0
  177. package/lib/typescript/module/ChatLiveBar.d.ts +11 -0
  178. package/lib/typescript/module/ChatMessageActions.d.ts +15 -0
  179. package/lib/typescript/module/ChatNudge.d.ts +14 -0
  180. package/lib/typescript/module/ChatOpenTickets.d.ts +12 -0
  181. package/lib/typescript/module/ChatPastChats.d.ts +21 -0
  182. package/lib/typescript/module/ChatScreen.d.ts +5 -0
  183. package/lib/typescript/module/ChatSheet.d.ts +21 -0
  184. package/lib/typescript/module/ChatStarters.d.ts +12 -0
  185. package/lib/typescript/module/ChatThread.d.ts +36 -0
  186. package/lib/typescript/module/ReadAloudButton.d.ts +11 -0
  187. package/lib/typescript/module/chatShared.d.ts +4 -0
  188. package/lib/typescript/module/index.d.ts +27 -21
  189. package/lib/typescript/module/loaders/ChatLoader.d.ts +13 -0
  190. package/lib/typescript/module/loaders/OrbLoader.d.ts +8 -0
  191. package/lib/typescript/module/loaders/PhrasesLoader.d.ts +8 -0
  192. package/lib/typescript/module/loaders/SkeletonLoader.d.ts +8 -0
  193. package/lib/typescript/module/loaders/StepsLoader.d.ts +8 -0
  194. package/lib/typescript/module/loaders/TypingPill.d.ts +7 -0
  195. package/lib/typescript/module/pushOpen.d.ts +3 -0
  196. package/lib/typescript/module/renderers/ActionPart.d.ts +3 -0
  197. package/lib/typescript/module/renderers/ChartPart.d.ts +8 -0
  198. package/lib/typescript/module/renderers/FigureText.d.ts +23 -0
  199. package/lib/typescript/module/renderers/FiguresPart.d.ts +8 -0
  200. package/lib/typescript/module/renderers/FilePart.d.ts +3 -0
  201. package/lib/typescript/module/renderers/HandoffPart.d.ts +9 -0
  202. package/lib/typescript/module/renderers/ImagePart.d.ts +8 -0
  203. package/lib/typescript/module/renderers/InputRequestPart.d.ts +3 -0
  204. package/lib/typescript/module/renderers/NoticePart.d.ts +8 -0
  205. package/lib/typescript/module/renderers/QuickRepliesPart.d.ts +8 -0
  206. package/lib/typescript/module/renderers/RecordCardPart.d.ts +8 -0
  207. package/lib/typescript/module/renderers/SourcesPart.d.ts +8 -0
  208. package/lib/typescript/module/renderers/TablePart.d.ts +8 -0
  209. package/lib/typescript/module/renderers/TextPart.d.ts +8 -0
  210. package/lib/typescript/module/renderers/TicketPart.d.ts +9 -0
  211. package/lib/typescript/module/renderers/VoiceClipPart.d.ts +9 -0
  212. package/lib/typescript/module/renderers/index.d.ts +3 -0
  213. package/lib/typescript/module/speech/azureSpeech.d.ts +25 -0
  214. package/lib/typescript/module/speech/expoAudio.d.ts +23 -0
  215. package/lib/typescript/module/speech/phoneSpeech.d.ts +16 -0
  216. package/lib/typescript/module/speech/speechText.d.ts +16 -0
  217. package/lib/typescript/module/types.d.ts +29 -0
  218. package/lib/typescript/module/useChat.d.ts +40 -10
  219. package/lib/typescript/module/useChatHaptics.d.ts +3 -0
  220. package/lib/typescript/module/useChatSound.d.ts +35 -0
  221. package/lib/typescript/module/useChatSpeech.d.ts +4 -0
  222. package/lib/typescript/module/useTranscriptActions.d.ts +10 -0
  223. package/package.json +43 -15
  224. package/README.md +0 -185
  225. package/lib/commonjs/components/ActionCard.js +0 -1
  226. package/lib/commonjs/components/ChatComposer.js +0 -1
  227. package/lib/commonjs/components/ChatConversationList.js +0 -1
  228. package/lib/commonjs/components/ChatLauncher.js +0 -1
  229. package/lib/commonjs/components/ChatMarkdown.js +0 -1
  230. package/lib/commonjs/components/ChatMessage.js +0 -1
  231. package/lib/commonjs/components/ChatScreen.js +0 -1
  232. package/lib/commonjs/components/ChatThread.js +0 -1
  233. package/lib/commonjs/components/ComposerAttachments.js +0 -1
  234. package/lib/commonjs/components/ReplyRating.js +0 -1
  235. package/lib/module/components/ActionCard.js +0 -1
  236. package/lib/module/components/ChatComposer.js +0 -1
  237. package/lib/module/components/ChatConversationList.js +0 -1
  238. package/lib/module/components/ChatLauncher.js +0 -1
  239. package/lib/module/components/ChatMarkdown.js +0 -1
  240. package/lib/module/components/ChatMessage.js +0 -1
  241. package/lib/module/components/ChatScreen.js +0 -1
  242. package/lib/module/components/ChatThread.js +0 -1
  243. package/lib/module/components/ComposerAttachments.js +0 -1
  244. package/lib/module/components/ReplyRating.js +0 -1
  245. package/lib/typescript/commonjs/components/ActionCard.d.ts +0 -23
  246. package/lib/typescript/commonjs/components/ChatComposer.d.ts +0 -42
  247. package/lib/typescript/commonjs/components/ChatConversationList.d.ts +0 -22
  248. package/lib/typescript/commonjs/components/ChatLauncher.d.ts +0 -22
  249. package/lib/typescript/commonjs/components/ChatMarkdown.d.ts +0 -24
  250. package/lib/typescript/commonjs/components/ChatMessage.d.ts +0 -55
  251. package/lib/typescript/commonjs/components/ChatScreen.d.ts +0 -40
  252. package/lib/typescript/commonjs/components/ChatThread.d.ts +0 -30
  253. package/lib/typescript/commonjs/components/ComposerAttachments.d.ts +0 -12
  254. package/lib/typescript/commonjs/components/ReplyRating.d.ts +0 -19
  255. package/lib/typescript/module/components/ActionCard.d.ts +0 -23
  256. package/lib/typescript/module/components/ChatComposer.d.ts +0 -42
  257. package/lib/typescript/module/components/ChatConversationList.d.ts +0 -22
  258. package/lib/typescript/module/components/ChatLauncher.d.ts +0 -22
  259. package/lib/typescript/module/components/ChatMarkdown.d.ts +0 -24
  260. package/lib/typescript/module/components/ChatMessage.d.ts +0 -55
  261. package/lib/typescript/module/components/ChatScreen.d.ts +0 -40
  262. package/lib/typescript/module/components/ChatThread.d.ts +0 -30
  263. package/lib/typescript/module/components/ComposerAttachments.d.ts +0 -12
  264. package/lib/typescript/module/components/ReplyRating.d.ts +0 -19
@@ -0,0 +1 @@
1
+ "use strict";import{Permissions}from"@webority/mobile-core/permissions";import{Banner,Chip,Composer,IconButton,ProgressBar,Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{ChatDictationButton}from"./ChatDictationButton.js";import{ChatFooter}from"./ChatFooter.js";import{joinDictation}from"./speech/speechText.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const ALLOWANCE_SHOWN_AT=10,COUNTER_AT=.9,DEFAULT_MAX_LENGTH=4e3,openQuestion=e=>{for(let t=e.length-1;t>=0;t-=1){const s=e[t];for(const e of[...s?.parts??[]].reverse())if("InputRequest"===e.kind&&"Open"===e.state)return e.fields[0]?.label||e.title||null}return null};export function ChatComposer({chat:e,labels:t,pickAttachments:s,keyboardOffset:a,keyboardAware:o,safeArea:n,testID:i="chat-composer",focusRef:r}){const l=useTheme(),c=useMemo(()=>buildStyles(l),[l]),[m,u]=useState(""),[p,h]=useState(null),d=e.editing,f=useRef(null),g=useRef(null);useEffect(()=>{if(r)return r.current=()=>g.current?.focus(),()=>{r.current=null}},[r]),useEffect(()=>{d&&f.current?.(),u(d?d.text:"")},[d]);const x=e.attachments,b=x.some(e=>"Uploading"===e.status),y=x.some(e=>"Ready"===e.status),v=e.messagesLeftToday,j=e.profile?.limits.maxMessageLength??4e3,_=void 0!==s&&e.features.Attachments&&(e.profile?.limits.maxAttachments??0)>0,S=e.features.HumanHandoff&&("WaitingForAgent"===e.conversationState||"WithAgent"===e.conversationState),T=_&&!e.handoffPause?_jsx(IconButton,{icon:"paperclip",accessibilityLabel:t.attach,variant:"ghost",tone:"neutral",onPress:()=>{s&&s().then(t=>e.attach(t))},testID:`${i}-attach`}):void 0,A=d?_jsx(Banner,{message:t.editing,accessibilityRole:"summary",actions:[{label:t.cancel,onPress:()=>e.cancelEdit()}],testID:`${i}-editing`}):null,D=x.length>0?_jsx(View,{style:c.tray,testID:`${i}-attachments`,children:_jsx(View,{style:c.row,children:x.map(s=>_jsxs(View,{style:c.item,children:[_jsx(Chip,{label:s.fileName,variant:"soft",onRemove:()=>{e.removeAttachment(s.key)},labels:{remove:t.removeAttachment},removeTestID:`${i}-remove-${s.key}`,testID:`${i}-chip-${s.key}`}),"Uploading"===s.status?_jsx(ProgressBar,{progress:s.progress??void 0,label:t.attachmentUploading,height:4,containerStyle:c.progress}):null,"Failed"===s.status?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.error??t.attachmentFailed}):null]},s.key))})}):null,w=null!==v&&v<=10?_jsx(Text,{variant:"caption",color:0===v?"danger":"secondary",accessibilityLiveRegion:"polite",testID:`${i}-allowance`,children:t.allowance(v)}):null,C=p?_jsx(Banner,{message:p.message,tone:p.tone,dismissible:!0,onClose:()=>h(null),actions:p.openSettings?[{label:t.dictateOpenSettings,onPress:()=>{Permissions.openSettings()}}]:void 0,testID:`${i}-voice-notice`}):null,I=m.length>0,R=m.length>.9*j?_jsx(Text,{variant:"caption",color:"secondary",testID:`${i}-counter`,children:t.counter(m.length,j)}):null,L=A||D||w||R||C?_jsxs(_Fragment,{children:[A,D,w,R,C]}):void 0,P=!b&&(!!y||void 0),k=!0===e.profile?.experience.motion;return _jsx(Composer,{ref:g,onSend:t=>{f.current?.(),e.submit(t)},value:m,onChangeText:t=>{f.current?.(),u(t),S&&t.length>0&&e.notifyTyping()},loading:e.streaming&&e.features.Stop,ring:k&&(I||e.streaming),sendReveal:k?"onText":"always",onStop:e.features.Stop?()=>e.stop():void 0,stopLabel:t.stop,disabled:0===v||e.handoffPause,maxLength:j,canSend:P,placeholder:e.handoffPause?t.handoffMoment:openQuestion(e.messages)??t.placeholder,accessibilityLabel:t.composer,labels:{send:t.send},leading:T,trailing:_jsx(ChatDictationButton,{chat:e,labels:t,disabled:0===v||e.handoffPause,onText:e=>u(t=>joinDictation(t,e,j)),onNotice:h,stopRef:f}),above:L,below:_jsx(ChatFooter,{chat:e,labels:t}),keyboardAware:o,keyboardOffset:a,safeArea:n,testID:i})}const buildStyles=e=>StyleSheet.create({tray:{gap:e.space.xs},row:{flexDirection:"row",flexWrap:"wrap",gap:e.space.xs},item:{gap:e.space.xxs,maxWidth:"100%"},progress:{minWidth:120}});
@@ -0,0 +1 @@
1
+ "use strict";import{messagePlainText}from"@webority/chat-core";import{IconButton,Text}from"@webority/mobile-ui";import useTranscriptActions from"./useTranscriptActions.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const REPLY_AUTHORS=new Set(["Assistant","Agent","Script"]);export function ChatConversationActions({chat:s,labels:t,testID:e}){const n=useTranscriptActions(s,t),i=s.messages.some(s=>s.stored&&REPLY_AUTHORS.has(s.author.kind)&&""!==messagePlainText(s.parts));return s.streaming||s.thinking||s.loading||null===s.conversationId||!i||!n.canShare?null:_jsxs(_Fragment,{children:[_jsx(IconButton,{icon:"share",variant:"ghost",size:"sm",accessibilityLabel:t.shareConversation,onPress:()=>{n.shareConversation()},testID:e}),null!==n.notice?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:n.notice}):null]})}
@@ -0,0 +1 @@
1
+ "use strict";import{Logger}from"@webority/mobile-core";import{announce,IconButton}from"@webority/mobile-ui";import{useEffect,useRef,useState}from"react";import{PhoneSpeechError}from"./speech/phoneSpeech.js";import{useChatSpeech}from"./useChatSpeech.js";import{jsx as _jsx}from"react/jsx-runtime";export function ChatDictationButton({chat:e,labels:t,disabled:n=!1,onText:r,onNotice:i,testID:o="chat-dictation",stopRef:a}){const c=useChatSpeech(e),[s,u]=useState("idle"),l=useRef(null),d=useRef(!0),g=useRef(!1);if(useEffect(()=>{if(a)return a.current=()=>{null!==l.current&&(u("transcribing"),l.current.abort())},()=>{a.current=null}},[a]),useEffect(()=>(d.current=!0,()=>{d.current=!1,g.current=!0,l.current?.abort()}),[]),!e.features.Dictation||null===c)return null;const f="transcribing"===s,p="listening"===s,h=p?t.dictateStop:f?t.dictateTranscribing:t.dictate;return _jsx(IconButton,{icon:p?"stop":"microphone",accessibilityLabel:h,variant:"ghost",tone:"neutral",active:p,loading:f,disabled:n||f,onPress:()=>{if("listening"===s)return u("transcribing"),void l.current?.abort();if("idle"!==s)return;i(null),g.current=!1;const e=new AbortController;l.current=e,u("listening"),announce(t.dictateListening);let n=!1;(async()=>{try{await c.startDictation({signal:e.signal,onText:e=>{d.current&&(n=!0,r(e))},onEnd:()=>{d.current&&u("transcribing")},shouldDiscard:()=>g.current}),d.current&&!n&&i({message:t.dictationNotHeard,openSettings:!1,tone:"info"})}catch(e){if(!d.current)return;e instanceof PhoneSpeechError?i(dictationFailure(e,t)):(Logger.error("[chat] dictation failed",e),i({message:t.dictationFailed,openSettings:!1,tone:"info"}))}finally{d.current&&(l.current=null,u("idle"))}})()},testID:o})}const dictationFailure=(e,t)=>{switch(e.phoneCode){case"MicBlocked":return{message:t.dictationBlocked,openSettings:!0,tone:"danger"};case"MicDenied":return{message:t.dictationBlocked,openSettings:!1,tone:"danger"};case"MicUnavailable":return{message:t.dictationNoMicrophone,openSettings:!1,tone:"danger"};case"Unavailable":return{message:t.dictationUnavailable,openSettings:!1,tone:"info"};default:return{message:t.dictationFailed,openSettings:!1,tone:"info"}}};
@@ -0,0 +1 @@
1
+ "use strict";import{mergeLabels}from"@webority/chat-core";import{radiusOf,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatFrame}from"./ChatFrame.js";import{jsx as _jsx}from"react/jsx-runtime";export function ChatEmbed({chat:e,labels:t,renderers:o,layoutParts:r,loader:a="Steps",motion:s="On",pickAttachments:i,onOpenAttachment:n,onOpenTarget:l,onNavigate:m,openTicket:d,handoffHosts:h,resolveLink:c,keyboardOffset:f,title:b,headerActions:u,onClose:p,height:g=520,testID:k="chat-embed"}){const C=useTheme();return null===e.profile||e.features.VisitorChat?_jsx(View,{style:{height:g,overflow:"hidden",borderRadius:radiusOf(C,"lg"),borderWidth:1,borderColor:C.colors["border-subtle"],backgroundColor:C.colors.bg},testID:k,children:_jsx(ChatFrame,{chat:e,labels:mergeLabels(t),renderers:o,layoutParts:r,loader:a,motion:s,pickAttachments:i,onOpenAttachment:n,onOpenTarget:l,onNavigate:m,openTicket:d,handoffHosts:h,resolveLink:c,keyboardOffset:f,layout:"embedded",title:b,headerActions:u,onClose:p,testID:`${k}-frame`})}):null}
@@ -0,0 +1 @@
1
+ "use strict";import{useReducedMotion}from"@webority/mobile-ui";import{useEffect,useState}from"react";import{Animated}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const ENTER_MS=260,STAGGER_MS=45,RISE_PX=8,START_SCALE=.98;export function ChatEntrance({index:t=0,animate:e=!0,children:n}){const i=useReducedMotion(),a=!e||i,[r]=useState(()=>new Animated.Value(0));return useEffect(()=>{if(a)return void r.setValue(1);const e=Animated.timing(r,{toValue:1,duration:260,delay:45*t,useNativeDriver:!0});return e.start(),()=>e.stop()},[t,a,r]),_jsx(Animated.View,{style:{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[8,0]})},{scale:r.interpolate({inputRange:[0,1],outputRange:[.98,1]})}]},children:n})}
@@ -0,0 +1 @@
1
+ "use strict";import{showsCaptchaNote}from"@webority/chat-core";import{Text,useTheme}from"@webority/mobile-ui";import{Linking,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const GOOGLE_PRIVACY="https://policies.google.com/privacy",GOOGLE_TERMS="https://policies.google.com/terms",openLink=e=>{Linking.openURL(e).catch(()=>{})};export function ChatFooter({chat:e,labels:t}){const i=useTheme(),o=e.profile;if(!o)return null;const r=o.footer.disclaimer||t.disclaimer,n=o.footer.privacyUrl,a=o.footer.assuranceText,c=o.footer.privacyText,l=showsCaptchaNote(o);return Boolean(r)||Boolean(c)||Boolean(n)||Boolean(a)||l?_jsxs(View,{style:{gap:i.space.xxs,alignItems:"center"},children:[r?_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:r}):null,c?_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:c}):null,n?_jsx(Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(n),children:t.footerPrivacy}):null,a?_jsx(Text,{variant:"caption",color:"tertiary",align:"center",children:a}):null,l?_jsxs(Text,{variant:"caption",color:"tertiary",align:"center",children:[t.captchaNote," ",_jsx(Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_PRIVACY),children:t.captchaPrivacy})," ",_jsx(Text,{variant:"caption",color:"link",accessibilityRole:"link",onPress:()=>openLink(GOOGLE_TERMS),children:t.captchaTerms})]}):null]}):null}
@@ -0,0 +1 @@
1
+ "use strict";import{Banner,Button,IconButton,Spinner,Text,useTheme}from"@webority/mobile-ui";import{useRef,useState}from"react";import{View}from"react-native";import{ChatComposer}from"./ChatComposer.js";import{ChatConversationActions}from"./ChatConversationActions.js";import{ChatHistory}from"./ChatHistory.js";import{ChatLiveBar}from"./ChatLiveBar.js";import{ChatStarters}from"./ChatStarters.js";import{ChatThread}from"./ChatThread.js";import{useChatHaptics}from"./useChatHaptics.js";import{useChatSound}from"./useChatSound.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function ChatFrame({chat:e,labels:t,renderers:s,layoutParts:o,loader:r="Steps",motion:a="On",pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:m,handoffHosts:h,resolveLink:u,keyboardOffset:d,layout:f,title:p,headerActions:C,onClose:x,testID:j="chat-frame"}){const b=useTheme(),[y,g]=useState(!1),_=y&&!0===e.features.History;useChatHaptics(e),useChatSound(e);const v="sheet"!==f,I=null!==e.profile,k=useRef(null);if(I&&!e.features.VisitorChat)return null;const D=e.messages.length>0,S=e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind),T="screen"===f||S,B=!0===e.profile?.experience.sound.muteControl&&e.features.Sounds,w=_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:b.space.sm,paddingHorizontal:b.space.md,paddingVertical:b.space.sm,borderBottomWidth:1,borderBottomColor:b.colors["border-subtle"]},children:[_jsxs(View,{style:{flex:1,minWidth:0},children:[_jsx(Text,{variant:"title",accessibilityRole:"header",numberOfLines:1,children:p??e.profile?.assistant.name??t.panelTitle}),_jsx(Text,{variant:"caption",color:"secondary",children:t.headerStatus})]}),C,_?null:_jsx(ChatConversationActions,{chat:e,labels:t,testID:`${j}-conversation-actions`}),B?_jsx(Button,{label:e.muted?t.unmuteSounds:t.muteSounds,variant:"link",size:"sm",onPress:()=>e.session.setMuted(!e.muted),testID:`${j}-mute`}):null,e.features.History?_jsx(Button,{label:_?t.backToChat:t.history,variant:"link",size:"sm",onPress:()=>g(e=>!e),testID:`${j}-history`}):null,_||!T?null:_jsx(Button,{label:t.newChat,size:"sm",variant:"soft",leftIcon:"add",disabled:e.streaming||e.thinking,onPress:()=>e.newConversation(),testID:`${j}-new`}),x?_jsx(IconButton,{icon:"x",variant:"ghost",tone:"neutral",accessibilityLabel:t.close,onPress:x,testID:`${j}-close`}):null]});let $;return $=_?_jsx(ChatHistory,{chat:e,labels:t,onOpen:()=>g(!1),testID:`${j}-history-list`}):e.profileError?_jsx(Banner,{tone:"danger",message:e.profileError.message,accessibilityRole:"alert",testID:`${j}-profile-error`}):!I||e.loading?_jsx(View,{style:{flex:1,alignItems:"center",justifyContent:"center"},children:_jsx(Spinner,{message:t.loadingConversation,testID:`${j}-loading`})}):e.loadError?_jsx(Banner,{tone:"danger",message:e.loadError.message,accessibilityRole:"alert",testID:`${j}-load-error`}):D?_jsx(ChatThread,{chat:e,labels:t,renderers:s,layoutParts:o,loader:r,motion:a,pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:m,handoffHosts:h,resolveLink:u,focusComposer:()=>k.current?.(),keyboardAware:v,keyboardOffset:d,style:{flex:1},testID:`${j}-thread`}):_jsx(ChatStarters,{chat:e,labels:t,openTicket:m,testID:`${j}-starters`}),_jsxs(View,{style:{flex:1},testID:j,children:[w,_?null:_jsx(ChatLiveBar,{chat:e,labels:t,testID:`${j}-live`}),_jsx(View,{style:{flex:1},children:$}),_?null:_jsx(ChatComposer,{chat:e,labels:t,pickAttachments:n,keyboardOffset:d,keyboardAware:v,focusRef:k,testID:`${j}-composer`})]})}
@@ -0,0 +1 @@
1
+ "use strict";import{createConversationList}from"@webority/chat-core";import{Banner,Button,EmptyState,Skeleton,useTheme}from"@webority/mobile-ui";import{useCallback,useEffect,useState,useSyncExternalStore}from"react";import{ScrollView,View}from"react-native";import{ConversationRow}from"./ChatPastChats.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const EMPTY_LIST_STATE=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),NO_SUBSCRIPTION=()=>()=>{};export function ChatHistory({chat:e,labels:t,onOpen:s,testID:l="chat-history"}){const n=useTheme(),[o,i]=useState(null),r=null!==o&&o.client===e.client?o.list:null,a=useCallback(e=>r?r.subscribe(e):NO_SUBSCRIPTION(),[r]),c=useCallback(()=>r?r.getState():EMPTY_LIST_STATE,[r]),u=useSyncExternalStore(a,c);useEffect(()=>{const t=createConversationList({client:e.client});return i({client:e.client,list:t}),t.load(),()=>t.dispose()},[e.client]);const open=t=>{e.openConversation(t.publicId),s()},m=!u.loading&&null===u.error&&0===u.items.length;return _jsxs(ScrollView,{contentContainerStyle:{padding:n.space.md,gap:n.space.sm,flexGrow:1},accessibilityLabel:t.history,testID:l,children:[u.error?_jsx(Banner,{tone:"danger",message:t.loadFailed,actions:[{label:t.retry,onPress:()=>{r?.load()}}],testID:`${l}-error`}):null,m?_jsx(EmptyState,{size:"sm",title:t.historyEmptyTitle,description:t.historyEmptyText,testID:`${l}-empty`}):null,u.items.map(s=>_jsx(ConversationRow,{conversation:s,list:r,chat:e,labels:t,testID:l,onOpen:open,untitledTitle:t.untitled},s.publicId)),u.loading&&0===u.items.length?_jsxs(View,{style:{gap:n.space.sm},accessibilityElementsHidden:!0,children:[_jsx(Skeleton,{height:56}),_jsx(Skeleton,{height:56}),_jsx(Skeleton,{height:56})]}):null,!u.loading&&u.hasMore?_jsx(Button,{label:t.loadMore,variant:"outline",onPress:()=>{r?.loadMore()},testID:`${l}-more`}):null]})}
@@ -0,0 +1 @@
1
+ "use strict";import{Banner,Button,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const newestAgentName=(e,t)=>{for(let s=e.messages.length-1;s>=0;s-=1){const n=e.messages[s];if("Agent"===n?.author.kind)return n.author.displayName||t}return t};export function ChatLiveBar({chat:e,labels:t,testID:s="chat-live-bar"}){const n=useTheme();if(!e.features.HumanHandoff||null===e.conversationId)return null;const i=e.conversationState;if("Closed"===i)return null;if("Open"===i){return e.features.HumanHandoff&&e.messages.some(e=>"Visitor"===e.author.kind||"Customer"===e.author.kind)&&!e.streaming&&!e.thinking?_jsxs(View,{accessibilityLiveRegion:"polite",style:{paddingHorizontal:n.space.md,paddingVertical:n.space.xs},testID:s,children:[_jsx(Button,{label:t.talkToPerson,variant:"soft",size:"sm",leftIcon:"user",loading:e.handoffPending,onPress:()=>{e.requestHandoff()},testID:`${s}-talk`}),null!==e.handoffError?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:t.errorGeneric}):null]}):null}const a="Lost"===e.live,r="WaitingForAgent"===i?t.statusWaitingForAgent:t.statusWithAgent(newestAgentName(e,t.agent));return _jsxs(View,{accessibilityLiveRegion:"polite",style:{gap:n.space.xs,paddingHorizontal:n.space.md,paddingVertical:n.space.xs},testID:s,children:[_jsx(Text,{variant:"caption",color:"secondary",children:r}),a?_jsx(Banner,{tone:"warning",message:t.liveLost,actions:[{label:t.retry,onPress:()=>e.resumeLive()}],testID:`${s}-lost`}):null]})}
@@ -0,0 +1 @@
1
+ "use strict";import{buildTranscript,messagePlainText}from"@webority/chat-core";import{copyText}from"@webority/mobile-core/clipboard";import{Button,IconButton,Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{View}from"react-native";import{ReadAloudButton}from"./ReadAloudButton.js";import useTranscriptActions from"./useTranscriptActions.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const TEXT_AUTHORS=new Set(["Assistant","Agent","Script"]),RATED_AUTHORS=new Set(["Assistant","Agent"]);export function ChatMessageActions({chat:e,message:t,labels:s,isLast:i,isLastVisitor:a,testID:n}){const r=useTheme(),[o,l]=useState(!1),[c,u]=useState("idle"),m=useRef(null),d=useTranscriptActions(e,s),g=useMemo(()=>TEXT_AUTHORS.has(t.author.kind)&&buildTranscript([t],{labels:s,title:null,figureText:!1}).entries.length>0,[t,s]);if(useEffect(()=>()=>{null!==m.current&&clearTimeout(m.current)},[]),t.streaming)return null;const p=messagePlainText(t.parts),h=TEXT_AUTHORS.has(t.author.kind)&&""!==p,x=t.stored&&RATED_AUTHORS.has(t.author.kind),f=("Assistant"===t.author.kind||"Agent"===t.author.kind||"Script"===t.author.kind)&&""!==messagePlainText(t.parts).trim(),T=i&&"Assistant"===t.author.kind&&!e.streaming&&!e.thinking&&e.features.Regenerate&&e.messages.some(e=>e.stored&&"Visitor"===e.author.kind),b=a&&t.stored&&e.features.Edit&&!e.streaming&&!e.thinking,save=async s=>{try{await e.rate(t.id,s),u("saved")}catch{u("failed")}};return h&&e.features.Copy||g&&e.features.Share&&d.canShare||f||T||b||x&&e.features.Rating?_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:r.space.xs},testID:n,children:[h&&e.features.Copy?_jsx(Button,{label:o?s.copied:s.copy,variant:"link",size:"sm",onPress:()=>{(async()=>{await copyText(p)&&(l(!0),null!==m.current&&clearTimeout(m.current),m.current=setTimeout(()=>l(!1),2e3))})()},testID:`${n}-copy`}):null,g&&e.features.Share&&d.canShare?_jsx(Button,{label:s.share,variant:"link",size:"sm",leftIcon:"share",disabled:e.streaming||e.thinking,onPress:()=>{d.shareReply(t)},testID:`${n}-share`}):null,f?_jsx(ReadAloudButton,{chat:e,message:t,labels:s}):null,T?_jsx(Button,{label:s.regenerate,variant:"link",size:"sm",onPress:()=>{e.regenerate()},testID:`${n}-regenerate`}):null,b?_jsx(Button,{label:s.edit,variant:"link",size:"sm",onPress:()=>e.startEdit(t.id),testID:`${n}-edit`}):null,x&&e.features.Rating?_jsxs(_Fragment,{children:[_jsxs(View,{accessibilityRole:"summary",accessibilityLabel:s.rating,style:{flexDirection:"row",alignItems:"center",gap:r.space.xs},children:[_jsx(IconButton,{icon:"like",accessibilityLabel:s.rateUp,tone:"neutral",size:"sm",variant:"Up"===t.rating?"soft":"ghost",accessibilityState:{checked:"Up"===t.rating},onPress:()=>{save("Up")},testID:`${n}-rate-up`}),_jsx(IconButton,{icon:"dislike",accessibilityLabel:s.rateDown,tone:"neutral",size:"sm",variant:"Down"===t.rating?"soft":"ghost",accessibilityState:{checked:"Down"===t.rating},onPress:()=>{save("Down")},testID:`${n}-rate-down`})]}),"failed"===c?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:s.ratingFailed}):null,"saved"===c?_jsx(Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:s.rated}):null]}):null,null!==d.notice?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:d.notice}):null]}):null}
@@ -0,0 +1 @@
1
+ "use strict";import{resolveNudge}from"@webority/chat-core";import{Banner}from"@webority/mobile-ui";import{useEffect,useState}from"react";import{View}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const LAUNCHER_CLEARANCE=72,EDGE_INSET=16;export function ChatNudge({chat:e,labels:t,enabled:s,onActivate:o,bottomOffset:r,position:i,testID:n="chat-nudge"}){const a=e.profile,u=e.features,l=a?resolveNudge(a,u):null,[m,c]=useState(!1),[f,d]=useState(!1),[b,p]=useState(!1);if(useEffect(()=>{if(!s||!l||m)return void d(!1);if(b)return;const e=setTimeout(()=>{d(!0),p(!0)},1e3*l.delaySeconds);return()=>clearTimeout(e)},[s,l,m,b]),!l||!f||m)return null;return _jsx(View,{style:{position:"absolute",bottom:r+72,..."start"===i?{left:16}:{right:16},maxWidth:320},pointerEvents:"box-none",children:_jsx(Banner,{tone:"info",message:l.text,dismissible:!0,onClose:()=>c(!0),labels:{dismiss:t.nudgeDismiss},actions:[{label:t.launcher,onPress:o}],testID:n})})}
@@ -0,0 +1 @@
1
+ "use strict";import{Card,Chip,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SHOWN_AT_MOST=3;export function ChatOpenTickets({chat:e,labels:t,onOpenTicket:s,testID:i="chat-open-tickets"}){const n=useTheme();return e.features.OpenTickets&&0!==e.openTickets.length?_jsx(View,{accessibilityLabel:t.openTickets,style:{gap:n.space.xs},testID:i,children:e.openTickets.slice(0,3).map(e=>{const n=s?()=>s({ticketId:e.ticketId,number:e.number}):void 0;return _jsxs(Card,{variant:"outline",padding:"sm",interactive:void 0!==n,onPress:n,testID:`${i}-${e.ticketId}`,children:[_jsx(Text,{variant:"label",children:t.ticketAria(e.number)}),_jsx(Text,{variant:"bodySmall",numberOfLines:1,children:e.subject}),_jsx(Chip,{size:"sm",variant:"soft",label:t.ticketStatus(e.status)||e.status})]},e.ticketId)})}):null}
@@ -0,0 +1 @@
1
+ "use strict";import{createConversationList,formatChatDate}from"@webority/chat-core";import{Button,Card,IconButton,Input,Text,useTheme}from"@webority/mobile-ui";import{useCallback,useEffect,useState,useSyncExternalStore}from"react";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const PAGE_SIZE=20,EMPTY_LIST_STATE=Object.freeze({items:[],totalCount:null,loading:!1,error:null,hasMore:!1}),NO_SUBSCRIPTION=()=>()=>{};export function ChatPastChats({chat:e,labels:t,testID:n="chat-past-chats"}){const s=useTheme(),a=!0===e.features.History,[i,l]=useState(null),r=a&&null!==i&&i.client===e.client?i.list:null,o=useCallback(e=>r?r.subscribe(e):NO_SUBSCRIPTION(),[r]),c=useCallback(()=>r?r.getState():EMPTY_LIST_STATE,[r]),d=useSyncExternalStore(o,c);if(useEffect(()=>{if(!a)return;const t=createConversationList({client:e.client});return l({client:e.client,list:t}),t.load(),()=>t.dispose()},[e.client,a]),!a||0===d.items.length)return null;const open=t=>{e.openConversation(t.publicId)};return _jsx(View,{style:{gap:s.space.sm},testID:n,children:d.items.slice(0,20).map(s=>_jsx(ConversationRow,{conversation:s,list:r,chat:e,labels:t,testID:n,onOpen:open},s.publicId))})}export function ConversationRow({conversation:e,list:t,chat:n,labels:s,testID:a,onOpen:i,untitledTitle:l}){const r=useTheme(),[o,c]=useState("idle"),[d,u]=useState(""),[m,x]=useState(""),[h,p]=useState(!1),b=e.publicId,f=e.title||l||s.earlierChat,g=formatChatDate(e.lastActivityDateTimeUtc),cancel=()=>{x(""),c("idle")},saveRename=async()=>{const e=d.trim();if(!h&&t&&""!==e){p(!0),x("");try{await t.rename(b,e),c("idle")}catch{x(s.renameFailed)}finally{p(!1)}}};return _jsxs(Card,{variant:"outline",padding:"sm",onPress:"idle"===o?()=>i(e):void 0,accessibilityLabel:`${f}, ${g}`,testID:`${a}-item-${b}`,children:["idle"===o?_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:r.space.sm},children:[_jsxs(View,{style:{flex:1,minWidth:0},children:[_jsx(Text,{variant:"label",numberOfLines:1,children:f}),_jsx(Text,{variant:"caption",color:"secondary",children:g})]}),n.features.Rename?_jsx(IconButton,{icon:"edit",variant:"ghost",accessibilityLabel:s.rename,onPress:()=>{x(""),u(e.title??""),c("renaming")},testID:`${a}-rename-${b}`}):null,n.features.Delete?_jsx(IconButton,{icon:"trash",tone:"danger",variant:"ghost",accessibilityLabel:s.deleteChat,onPress:()=>{x(""),c("deleting")},testID:`${a}-delete-${b}`}):null]}):null,"renaming"===o?_jsxs(View,{style:{gap:r.space.sm},children:[_jsx(Input,{label:s.conversationTitle,value:d,onChangeText:u,maxLength:120,returnKeyType:"done",onSubmitEditing:()=>{saveRename()},testID:`${a}-rename-input-${b}`}),""!==m?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",testID:`${a}-rename-error-${b}`,children:m}):null,_jsxs(View,{style:{flexDirection:"row",justifyContent:"flex-end",gap:r.space.sm},children:[_jsx(Button,{label:s.cancel,variant:"ghost",disabled:h,onPress:cancel,testID:`${a}-rename-cancel-${b}`}),_jsx(Button,{label:s.renameSave,disabled:""===d.trim()||h,loading:h,onPress:()=>{saveRename()},testID:`${a}-rename-save-${b}`})]})]}):null,"deleting"===o?_jsxs(View,{style:{gap:r.space.sm},children:[_jsx(Text,{variant:"bodySmall",color:""!==m?"danger":"secondary",accessibilityLiveRegion:""!==m?"polite":void 0,testID:`${a}-delete-message-${b}`,children:""!==m?m:s.deleteConfirmMessage}),_jsxs(View,{style:{flexDirection:"row",justifyContent:"flex-end",gap:r.space.sm},children:[_jsx(Button,{label:s.cancel,variant:"ghost",disabled:h,onPress:cancel,testID:`${a}-delete-cancel-${b}`}),_jsx(Button,{label:s.deleteConfirm,tone:"danger",loading:h,onPress:()=>{(async()=>{if(!h&&t){p(!0),x("");try{await t.remove(b),b===n.conversationId&&n.newConversation(),c("idle")}catch{x(s.deleteFailed)}finally{p(!1)}}})()},testID:`${a}-delete-confirm-${b}`})]})]}):null]})}
@@ -0,0 +1 @@
1
+ "use strict";import{mergeLabels}from"@webority/chat-core";import{useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatFrame}from"./ChatFrame.js";import{jsx as _jsx}from"react/jsx-runtime";export function ChatScreen({chat:e,labels:t,renderers:o,layoutParts:r,loader:a="Steps",motion:s="On",pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:m,handoffHosts:h,resolveLink:f,keyboardOffset:p,title:u,headerActions:d,onClose:b,testID:k="chat-screen"}){const g=useTheme();return null===e.profile||e.features.VisitorChat?_jsx(View,{style:{flex:1,backgroundColor:g.colors.bg},testID:k,children:_jsx(ChatFrame,{chat:e,labels:mergeLabels(t),renderers:o,layoutParts:r,loader:a,motion:s,pickAttachments:n,onOpenAttachment:i,onOpenTarget:l,onNavigate:c,openTicket:m,handoffHosts:h,resolveLink:f,keyboardOffset:p,layout:"screen",title:u,headerActions:d,onClose:b,testID:`${k}-frame`})}):null}
@@ -0,0 +1 @@
1
+ "use strict";import{mergeLabels}from"@webority/chat-core";import{BottomSheet,FloatingActionButton,useTheme}from"@webority/mobile-ui";import{useEffect,useRef}from"react";import{AccessibilityInfo,findNodeHandle,View}from"react-native";import{ChatFrame}from"./ChatFrame.js";import{ChatNudge}from"./ChatNudge.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_SNAP_POINTS=["92%"];export function ChatSheet({chat:e,labels:t,renderers:o,layoutParts:s,loader:n="Steps",motion:i="On",pickAttachments:r,onOpenAttachment:a,onOpenTarget:l,onNavigate:c,keyboardOffset:f,open:u,defaultOpen:p=!1,onOpenChange:m,position:h="end",bottomOffset:b=16,snapPoints:d=DEFAULT_SNAP_POINTS,compact:g=!1,openTicket:y,handoffHosts:C,resolveLink:A,conversationId:O,onClose:j,testID:x="chat-sheet"}){const N=useTheme(),T=mergeLabels(t),_=void 0!==u,k=_?u:e.open,I=useRef(null),P=useRef(!1),v=useRef(O??null),L=e.setChatVisible;useEffect(()=>{P.current||(P.current=!0,_||!p||null===e.profile||e.open||e.session.open({trigger:"manual"}))},[_,p,e.profile,e.open,e.session]),useEffect(()=>{_&&(u&&!e.open&&e.session.open({trigger:"manual"}),!u&&e.open&&e.session.close("button"))},[_,u,e.open,e.session]);const D=useRef(k);if(useEffect(()=>{if(D.current&&!k){const e=findNodeHandle(I.current);null!==e&&AccessibilityInfo.setAccessibilityFocus(e)}D.current=k},[k]),useEffect(()=>{L(k)},[L,k]),useEffect(()=>{!_&&O&&O!==v.current&&null!==e.profile&&(v.current=O,e.open||(e.session.open({trigger:"manual"}),m?.(!0)))},[_,O,e.profile,e.open,e.session,m]),null===e.profile||!e.features.VisitorChat)return null;const setOpen=t=>{t?e.session.open({trigger:"manual"}):e.session.close("button"),m?.(t)},closeSheet=()=>{setOpen(!1),j?.()},E="start"===h?"bottomLeft":"bottomRight";return _jsxs(View,{testID:x,children:[k?null:_jsx(FloatingActionButton,{ref:I,icon:"messages",label:g?void 0:T.launcher,position:E,bottomOffset:b,accessibilityLabel:T.launcher,onPress:()=>setOpen(!0),testID:`${x}-launcher`}),_jsx(ChatNudge,{chat:e,labels:T,enabled:!k&&e.features.Nudges,onActivate:()=>setOpen(!0),bottomOffset:b,position:h,testID:`${x}-nudge`}),_jsx(BottomSheet,{open:k,onClose:closeSheet,snapPoints:d,keyboardBehavior:"shift",scrollable:!1,enablePanDownToClose:!0,enableBackdropPress:!0,accessibilityViewIsModal:!0,accessibilityLabel:T.panelTitle,children:_jsx(View,{style:{flex:1,backgroundColor:N.colors.bg},children:_jsx(ChatFrame,{chat:e,labels:T,renderers:o,layoutParts:s,loader:n,motion:i,pickAttachments:r,onOpenAttachment:a,onOpenTarget:l,onNavigate:c,openTicket:y,handoffHosts:C,resolveLink:A,keyboardOffset:f,onClose:closeSheet,layout:"sheet",testID:`${x}-frame`})})})]})}
@@ -0,0 +1 @@
1
+ "use strict";import{formatDate}from"@webority/mobile-core";import{Card,Chip,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatEntrance}from"./ChatEntrance.js";import{ChatOpenTickets}from"./ChatOpenTickets.js";import{ChatPastChats}from"./ChatPastChats.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function ChatStarters({chat:t,labels:e,openTicket:s,testID:a="chat-starters"}){const r=useTheme(),i=t.profile,n=t.greeting??"";if(!i)return null;const l=t.features.Starters&&t.starters.length>0,c=t.lastConversation,o=t.features.ResumeLast&&!t.features.History&&null!==c;return _jsxs(View,{accessibilityLabel:e.emptyTitle,style:{flex:1,justifyContent:"center",alignItems:"center",gap:r.space.md,padding:r.space.md},testID:a,children:[_jsx(Text,{variant:"h2",align:"center",children:n}),l?_jsx(View,{accessibilityRole:"none",accessibilityLabel:e.starters,style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"center",gap:r.space.xs},children:t.starters.map((e,s)=>_jsx(ChatEntrance,{index:s,children:_jsx(Chip,{label:e.label,leftIcon:e.icon?e.icon:void 0,onPress:()=>{t.submit(e.message)},testID:`${a}-${e.id}`})},e.id))}):null,o&&c?_jsxs(Card,{variant:"outline",padding:"sm",onPress:()=>{t.resumeLast()},testID:`${a}-resume`,children:[_jsx(Text,{variant:"caption",color:"secondary",children:e.resumeLast}),_jsx(Text,{variant:"label",numberOfLines:1,children:c.title||e.untitled}),_jsx(Text,{variant:"caption",color:"secondary",children:formatDate(c.lastActivityDateTimeUtc)})]}):null,t.features.History?_jsx(ChatPastChats,{chat:t,labels:e,testID:`${a}-past-chats`}):null,_jsx(ChatOpenTickets,{chat:t,labels:e,onOpenTicket:s})]})}
@@ -0,0 +1 @@
1
+ "use strict";import{createTurnApi,formatChatDateTime,handoffSettledIds,messagePlainText}from"@webority/chat-core";import{Button,MessageBubble,MessageList,Text,useTheme}from"@webority/mobile-ui";import{createElement,memo,useEffect,useMemo,useRef}from"react";import{AccessibilityInfo,findNodeHandle,View}from"react-native";import{AgentByline}from"./AgentByline.js";import{ChatEntrance}from"./ChatEntrance.js";import{ChatMessageActions}from"./ChatMessageActions.js";import{defaultOpenTarget,messageSignature}from"./chatShared.js";import{ChatLoader}from"./loaders/ChatLoader.js";import{TypingPill}from"./loaders/TypingPill.js";import{defaultRenderers}from"./renderers/index.js";import{NoticePart}from"./renderers/NoticePart.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const MINE=new Set(["Visitor","Customer"]),joinedText=e=>e.filter(e=>"Text"===e.kind).map(e=>e.text).join("\n\n"),renderPart=(e,t,s,a,i,r)=>{const n=e[t.kind];if(n)return createElement(n,{key:r,part:t,message:s,turn:a,pickAttachments:i});const o={kind:"Notice",code:"NeedsNewerApp",text:a.labels.needsNewerApp};return createElement(NoticePart,{key:r,part:o,message:s,turn:a})},sameMessage=(e,t)=>e.signature===t.signature&&e.message.id===t.message.id&&e.message.rating===t.message.rating&&e.message.stored===t.message.stored&&e.groupPosition===t.groupPosition&&e.isLast===t.isLast&&e.handoffSettled===t.handoffSettled&&e.isLastVisitor===t.isLastVisitor&&e.thinking===t.thinking&&e.streaming===t.streaming&&e.pickAttachments===t.pickAttachments&&e.labels===t.labels&&e.all===t.all&&e.layoutParts===t.layoutParts&&e.chat.session===t.chat.session&&e.chat.features===t.chat.features&&e.chat.onNavigate===t.chat.onNavigate&&e.onNavigate===t.onNavigate&&e.onOpenAttachment===t.onOpenAttachment&&e.onOpenTarget===t.onOpenTarget&&e.openTicket===t.openTicket&&e.resolveLink===t.resolveLink&&e.focusComposer===t.focusComposer&&e.byline===t.byline&&e.handoffHosts===t.handoffHosts;function ThreadMessageView({chat:e,message:t,labels:s,all:a,layoutParts:i,groupPosition:r,isLast:n,isLastVisitor:o,pickAttachments:l,onOpenAttachment:c,onOpenTarget:g,onNavigate:d,openTicket:m,handoffHosts:p,resolveLink:u,focusComposer:h,byline:f,sourceRows:y,testID:x}){const T=useTheme(),k=Object.assign(createTurnApi(e.session,{messageId:t.id,labels:s,openAttachment:c,openTarget:g??defaultOpenTarget,onNavigate:d??e.onNavigate,openTicket:m,handoffHosts:p,openCitation:e=>(e=>{const t=y.current.get(e),s=t?findNodeHandle(t):null;null!==s&&AccessibilityInfo.setAccessibilityFocus(s)})(String(e))}),{resolveLink:u,focusComposer:h,registerSourceRow:(e,t)=>{t?y.current.set(e,t):y.current.delete(e)}});let b=0;const nextSlot=()=>(b+=1,b),A=_jsx(ChatMessageActions,{chat:e,message:t,labels:s,isLast:n,isLastVisitor:o,testID:`${x}-actions`});if(MINE.has(t.author.kind)){const e=t.parts.filter(e=>"File"===e.kind),i=_jsxs(View,{style:{gap:T.space.xs},children:[e.map(e=>renderPart(a,e,t,k,l,`${t.id}-file-${nextSlot()}`)),A]});return _jsx(MessageBubble,{side:"mine",text:joinedText(t.parts),labels:{you:s.you},groupPosition:r,footer:i,testID:x})}const j="Agent"===t.author.kind,w=t.author.displayName||s.agent,N=(i?i(t):t.parts).map(e=>Array.isArray(e)?_jsx(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:T.space.xs},children:e.map(e=>renderPart(a,e,t,k,l,`${t.id}-part-${nextSlot()}`))},`${t.id}-group-${nextSlot()}`):renderPart(a,e,t,k,l,`${t.id}-item-${nextSlot()}`)),_=j&&f?[_jsx(AgentByline,{author:t.author,labels:s},`${t.id}-byline`),...N]:N,v=messagePlainText(t.parts);return _jsx(MessageBubble,{side:"theirs",author:j?void 0:t.author.displayName||s.assistant,text:j?`${s.agentSays(w)} ${v}`:v,streaming:t.streaming,groupPosition:r,footer:A,testID:x,children:_})}const ThreadMessage=memo(ThreadMessageView,sameMessage),TYPING_ORB_MARK=14,TYPING_ASSISTANT_MARK=8,TypingMark=({size:e})=>{const t=useTheme();return _jsx(View,{style:{width:e,height:e,borderRadius:t.radius.pill,backgroundColor:t.colors.primary}})},TYPING_DOT=6,TypingDots=()=>{const e=useTheme();return _jsx(View,{style:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},children:[0,1,2].map(t=>_jsx(View,{style:{width:6,height:6,borderRadius:3,backgroundColor:e.colors["text-muted"]}},t))})},TurnGap=()=>{const e=useTheme();return _jsx(View,{style:{height:e.space.lg}})},followNew=()=>!0;export function ChatThread({chat:e,labels:t,renderers:s,layoutParts:a,loader:i="Steps",motion:r="On",pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:g,handoffHosts:d,resolveLink:m,focusComposer:p,keyboardAware:u,keyboardOffset:h,empty:f,style:y,testID:x="chat-thread"}){const T=useTheme(),k=useMemo(()=>({...defaultRenderers,...s}),[s]),b=e.messages[0],A=e.greeting??"",j=useMemo(()=>""!==A&&void 0!==b&&MINE.has(b.author.kind)?{...b,id:"greeting",author:{...b.author,kind:"Assistant",displayName:null,avatarUrl:null},parts:[{kind:"Text",text:A}],stored:!1,streaming:!1,restored:!1,rating:null}:null,[A,b]),w=useMemo(()=>{const t=e.messages.filter(e=>!(e.streaming&&0===e.parts.length)).reverse();return j?[...t,j]:t},[e.messages,j]),N=e.messages[e.messages.length-1]?.id,_=useRef(new Map),v=useRef(null);useEffect(()=>{if(null!==v.current)for(const s of e.messages){if(MINE.has(s.author.kind)||s.streaming||s.restored||v.current.has(s.id))continue;if("Agent"===s.author.kind&&!s.stored)continue;v.current.add(s.id);const e=messagePlainText(s.parts);""!==e&&AccessibilityInfo.announceForAccessibility("Agent"===s.author.kind?`${t.agentSays(s.author.displayName||t.agent)} ${e}`:e)}else v.current=new Set(e.messages.map(e=>e.id))},[e.messages,t]);const M=useMemo(()=>{for(let t=e.messages.length-1;t>=0;t-=1){const s=e.messages[t];if(s?.stored&&"Visitor"===s.author.kind)return s.id}},[e.messages]),P=useMemo(()=>{const t=new Set;return e.messages.forEach((s,a)=>{if("Agent"!==s.author.kind)return;const i=e.messages[a-1];"Agent"===i?.author.kind&&(i.author.displayName||"")===(s.author.displayName||"")||t.add(s.id)}),t},[e.messages]),I=useMemo(()=>handoffSettledIds(e.messages),[e.messages]),L=e.turnError,S="daily_limit"===L?.code,C=null!==L&&/feature_off$/.test(L.code),$=S&&L?.resetsDateTimeUtc?` ${t.dailyLimitRefresh(formatChatDateTime(L.resetsDateTimeUtc))}`:"",D=e.streaming||null===L&&!e.stopped?null:_jsxs(View,{style:{gap:T.space.xs},testID:`${x}-error`,children:[_jsx(Text,null!==L?{variant:"bodySmall",color:"danger",accessibilityRole:S?void 0:"alert",accessibilityLiveRegion:S?"polite":void 0,children:`${L.message}${$}`}:{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:t.stopped}),!e.features.Retry||S||C?null:_jsx(View,{style:{flexDirection:"row"},children:_jsx(Button,{label:t.retry,variant:"link",size:"sm",onPress:()=>{e.retry()},testID:`${x}-retry`})})]}),V=e.thinking&&null!==e.profile?_jsx(ChatLoader,{style:i,steps:e.steps,phrases:e.profile.experience.pacing.thinkingPhrases,intervalMs:e.profile.experience.pacing.phraseIntervalMs,announce:t.preparingAnswer(e.profile.assistant.name),motion:r}):null,O=!0===e.pending?.typing?_jsx(TypingPill,{motion:r,mark:_jsx(TypingMark,{size:"Orb"===i?14:8})}):null,R=null!==e.agentTyping&&"WithAgent"===e.conversationState?_jsxs(View,{style:{gap:T.space.xs,alignSelf:"flex-start"},children:[_jsx(TypingPill,{motion:r,mark:_jsx(TypingDots,{})}),_jsx(Text,{variant:"caption",color:"secondary",accessibilityLiveRegion:"polite",children:t.agentTyping(e.agentTyping.displayName||t.agent)})]}):null,E=O||V||D||R?_jsxs(View,{style:{gap:T.space.sm},children:[O,V,R,D]}):void 0;return _jsx(MessageList,{messages:w,keyExtractor:e=>e.id,renderMessage:({item:s,groupPosition:i})=>_jsx(ChatEntrance,{animate:!s.restored,children:_jsx(ThreadMessage,{chat:e,message:s,signature:messageSignature(s),labels:t,all:k,layoutParts:a,groupPosition:i,isLast:s.id===N,isLastVisitor:s.id===M,handoffSettled:I.has(s.id),thinking:e.thinking,streaming:e.streaming,pickAttachments:n,onOpenAttachment:o,onOpenTarget:l,onNavigate:c,openTicket:g,handoffHosts:d,resolveLink:m,focusComposer:p,byline:P.has(s.id),sourceRows:_,testID:`${x}-${s.id}`})}),getAuthorKey:e=>e.author.kind,getDate:e=>e.createdDateTimeUtc,followNew:followNew,typing:E,empty:f,ItemSeparatorComponent:TurnGap,keyboardAware:u,keyboardOffset:h,accessibilityLabel:t.thread,style:y,testID:x})}
@@ -0,0 +1 @@
1
+ "use strict";import{messagePlainText}from"@webority/chat-core";import{Logger}from"@webority/mobile-core";import{IconButton,Text}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{PhoneSpeechError}from"./speech/phoneSpeech.js";import{useChatSpeech}from"./useChatSpeech.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";function spokenText(e){return messagePlainText(e.filter(e=>"Text"===e.kind)).replace(/ ?\[\d+\]/g,"").replace(/\s+/g," ").trim()}export function ReadAloudButton({chat:e,message:t,labels:r,testID:o="chat-read-aloud"}){const s=useChatSpeech(e),[a,n]=useState(!1),[i,u]=useState(!1),c=useRef(null),l=useRef(!0),m=useMemo(()=>spokenText(t.parts),[t.parts]);if(useEffect(()=>(l.current=!0,()=>{l.current=!1,c.current?.abort()}),[]),!e.features.ReadAloud||null===s||t.streaming||""===m.trim())return null;return _jsxs(_Fragment,{children:[_jsx(IconButton,{icon:a?"stop":"volume-high",accessibilityLabel:a?r.readAloudStop:r.readAloud,variant:"ghost",tone:"neutral",size:"sm",onPress:()=>{if(a)return void c.current?.abort();u(!1);const e=new AbortController;c.current=e,n(!0);(async()=>{try{await s.speak(m,{signal:e.signal})}catch(t){if(!l.current||e.signal.aborted)return;u(!0),t instanceof PhoneSpeechError||Logger.error("[chat] read aloud failed",t)}finally{l.current&&(c.current=null,n(!1))}})()},testID:o}),i?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:r.readAloudFailed}):null]})}
@@ -0,0 +1 @@
1
+ "use strict";import{Linking}from"react-native";export function messageSignature(t){let e=0;for(const n of t.parts)"Text"===n.kind&&(e+=n.text.length);return`${t.id}|${t.parts.length}|${e}`}const ABSOLUTE_WEB_URL=/^https?:\/\//i;export function defaultOpenTarget(t){ABSOLUTE_WEB_URL.test(t)&&Linking.openURL(t).catch(()=>{})}
@@ -0,0 +1,40 @@
1
+ {
2
+ "VisitorChat": "src/ChatFrame.tsx",
3
+ "Starters": "src/ChatStarters.tsx",
4
+ "Nudges": "src/ChatSheet.tsx",
5
+ "ResumeLast": "src/ChatStarters.tsx",
6
+ "OpenTickets": "src/ChatOpenTickets.tsx",
7
+ "History": "src/ChatFrame.tsx",
8
+ "Rename": "src/ChatPastChats.tsx",
9
+ "Delete": "src/ChatPastChats.tsx",
10
+ "SuggestedReplies": "src/renderers/QuickRepliesPart.tsx",
11
+ "Stop": "src/ChatComposer.tsx",
12
+ "Retry": "src/ChatThread.tsx",
13
+ "Edit": "src/ChatMessageActions.tsx",
14
+ "Regenerate": "src/ChatMessageActions.tsx",
15
+ "Sources": "src/renderers/SourcesPart.tsx",
16
+ "Rating": "src/ChatMessageActions.tsx",
17
+ "Copy": "src/ChatMessageActions.tsx",
18
+ "Share": "src/ChatMessageActions.tsx",
19
+ "Print": null,
20
+ "Attachments": "src/ChatComposer.tsx",
21
+ "RichAnswers": null,
22
+ "InputRequests": null,
23
+ "LeadCapture": null,
24
+ "Booking": null,
25
+ "Scripts": null,
26
+ "AiAnswers": null,
27
+ "HumanHandoff": "src/ChatLiveBar.tsx",
28
+ "Dictation": "src/ChatDictationButton.tsx",
29
+ "ReadAloud": "src/ReadAloudButton.tsx",
30
+ "VoiceClips": "src/renderers/VoiceClipPart.tsx",
31
+ "Sounds": "src/useChatHaptics.ts",
32
+ "AutoOpen": null,
33
+ "BehaviourStarters": "../chat-core/src/session.ts",
34
+ "LeadShortcuts": "src/renderers/InputRequestPart.tsx",
35
+ "LeadRecap": "src/renderers/ActionPart.tsx",
36
+ "FigureText": "src/renderers/TextPart.tsx",
37
+ "LinkHandoff": "src/renderers/QuickRepliesPart.tsx",
38
+ "Explain": null,
39
+ "PanelSwitch": null
40
+ }
@@ -1 +1 @@
1
- "use strict";export{ChatApiError,createChatClient,createChatSession,createConversationList,createSseParser,DEFAULT_CHAT_LABELS}from"@webority/markdown-core/chat";export{ActionCard}from"./components/ActionCard.js";export{ChatComposer}from"./components/ChatComposer.js";export{ChatConversationList}from"./components/ChatConversationList.js";export{ChatLauncher}from"./components/ChatLauncher.js";export{ChatMarkdown}from"./components/ChatMarkdown.js";export{ChatMessage}from"./components/ChatMessage.js";export{ChatScreen}from"./components/ChatScreen.js";export{ChatThread}from"./components/ChatThread.js";export{ReplyRating}from"./components/ReplyRating.js";export{useChat}from"./useChat.js";
1
+ "use strict";export{AgentByline}from"./AgentByline.js";export{ChatComposer}from"./ChatComposer.js";export{ChatConversationActions}from"./ChatConversationActions.js";export{ChatDictationButton}from"./ChatDictationButton.js";export{ChatEmbed}from"./ChatEmbed.js";export{ChatFooter}from"./ChatFooter.js";export{ChatHistory}from"./ChatHistory.js";export{ChatLiveBar}from"./ChatLiveBar.js";export{ChatMessageActions}from"./ChatMessageActions.js";export{ChatNudge}from"./ChatNudge.js";export{ChatOpenTickets}from"./ChatOpenTickets.js";export{ChatPastChats}from"./ChatPastChats.js";export{ChatScreen}from"./ChatScreen.js";export{ChatSheet}from"./ChatSheet.js";export{ChatStarters}from"./ChatStarters.js";export{ChatThread}from"./ChatThread.js";export{defaultOpenTarget,messageSignature}from"./chatShared.js";export{ChatLoader}from"./loaders/ChatLoader.js";export{TypingPill}from"./loaders/TypingPill.js";export{CHAT_PUSH_TYPE,chatConversationIdFromPush}from"./pushOpen.js";export{ReadAloudButton}from"./ReadAloudButton.js";export{defaultRenderers}from"./renderers/index.js";export{useChat}from"./useChat.js";export{useChatSpeech}from"./useChatSpeech.js";
@@ -0,0 +1 @@
1
+ "use strict";import{LOADER_STYLES,loaderView}from"@webority/chat-core";import{Text,useReducedMotion}from"@webority/mobile-ui";import{useEffect,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{OrbLoader}from"./OrbLoader.js";import{PhrasesLoader}from"./PhrasesLoader.js";import{SkeletonLoader}from"./SkeletonLoader.js";import{StepsLoader}from"./StepsLoader.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const ANNOUNCE_DELAY_MS=500;export function ChatLoader({style:e="Steps",steps:t=[],phrases:r,intervalMs:s,motion:o="On",announce:i,testID:a="chat-loader"}){if(!LOADER_STYLES.includes(e))throw new Error(`ChatLoader style must be one of ${LOADER_STYLES.join(", ")}; got "${e}".`);const n=useReducedMotion(),c="Reduced"===o||n,[u,d]=useState({style:e,count:0});useEffect(()=>{d({style:e,count:0})},[e]),useEffect(()=>{if(c)return;const t=setInterval(()=>{d(t=>({style:e,count:(t.style===e?t.count:0)+1}))},s);return()=>clearInterval(t)},[e,s,c]);const l=useRef(i),[f,m]=useState("");useEffect(()=>{const e=setTimeout(()=>m(l.current),500);return()=>clearTimeout(e)},[]);const L=c||u.style!==e?0:u.count,S=loaderView(e,t,r,L);return _jsxs(View,{role:"status",accessibilityLabel:S.label,accessibilityLiveRegion:"polite",testID:a,children:[loaderBody(e,S,c),_jsx(Text,{accessibilityLiveRegion:"polite",style:styles.announce,children:f})]})}const loaderBody=(e,t,r)=>{switch(e){case"Steps":return _jsx(StepsLoader,{view:t,reduced:r});case"Phrases":return _jsx(PhrasesLoader,{view:t,reduced:r});case"Orb":return _jsx(OrbLoader,{view:t,reduced:r});case"Skeleton":return _jsx(SkeletonLoader,{view:t,reduced:r})}},styles=StyleSheet.create({announce:{position:"absolute",width:1,height:1,opacity:0,overflow:"hidden"}});
@@ -0,0 +1 @@
1
+ "use strict";import{Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const CIRCLE=28,HALO=36,HALO_OPACITY=.6,BREATHE_MIN=.92,BREATHE_MAX=1.04,BREATHE_MS=1600;export function OrbLoader({view:e,reduced:t}){const r=useTheme(),i=useMemo(()=>buildStyles(r),[r]),s=useRef(new Animated.Value(t?1:.92)).current;return useEffect(()=>{if(t)return void s.setValue(1);const e=Animated.loop(Animated.sequence([Animated.timing(s,{toValue:1.04,duration:1600,useNativeDriver:!0}),Animated.timing(s,{toValue:.92,duration:1600,useNativeDriver:!0})]));return e.start(),()=>e.stop()},[s,t]),_jsxs(View,{style:i.row,children:[_jsxs(Animated.View,{style:[i.cell,{transform:[{scale:s}]}],children:[_jsx(View,{style:i.halo}),_jsx(View,{style:i.circle})]}),_jsx(Text,{variant:"bodySmall",color:"secondary",children:e.label})]})}const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},cell:{width:36,height:36,alignItems:"center",justifyContent:"center"},halo:{position:"absolute",width:36,height:36,borderRadius:e.radius.pill,backgroundColor:e.colors["primary-soft"],opacity:.6},circle:{width:28,height:28,borderRadius:e.radius.pill,backgroundColor:e.colors.primary}});
@@ -0,0 +1 @@
1
+ "use strict";import{Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DOT=12,CROSS_FADE_MS=180,LABEL_RISE_PX=8;export function PhrasesLoader({view:e,reduced:t}){const r=useTheme(),s=useMemo(()=>buildStyles(r),[r]),i=useRef(new Animated.Value(1)).current,a=useRef(new Animated.Value(0)).current,l=useRef(e.label);return useEffect(()=>{if(l.current===e.label)return;if(l.current=e.label,t)return i.setValue(1),void a.setValue(0);i.setValue(0),a.setValue(8);const r=Animated.parallel([Animated.timing(i,{toValue:1,duration:180,useNativeDriver:!0}),Animated.timing(a,{toValue:0,duration:180,useNativeDriver:!0})]);return r.start(),()=>r.stop()},[e.label,t,i,a]),_jsxs(View,{style:s.row,children:[_jsx(View,{style:s.dot}),_jsx(Animated.View,{style:[s.label,{opacity:i,transform:[{translateY:a}]}],children:_jsx(Text,{variant:"bodySmall",color:"secondary",numberOfLines:1,children:e.label})})]})}const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},dot:{width:12,height:12,borderRadius:e.radius.pill,backgroundColor:e.colors.primary},label:{flexShrink:1}});
@@ -0,0 +1 @@
1
+ "use strict";import{Skeleton,Text,useTheme}from"@webority/mobile-ui";import{useMemo}from"react";import{StyleSheet,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const LINE_HEIGHT=10,BLOCK_HEIGHT=44,LINE_WIDTHS=["92%","78%","85%","40%"];export function SkeletonLoader({view:e,reduced:t}){const s=useTheme(),i=useMemo(()=>buildStyles(s),[s]),o=t?"none":"shimmer";return _jsxs(View,{style:i.root,children:[_jsx(Text,{variant:"caption",color:"secondary",children:e.label}),_jsxs(View,{style:i.body,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[LINE_WIDTHS.map(e=>_jsx(Skeleton,{shape:"rounded",height:10,width:e,variant:o},e)),_jsx(Skeleton,{shape:"rect",height:44,width:"60%",variant:o})]})]})}const buildStyles=e=>StyleSheet.create({root:{gap:e.space.sm},body:{gap:e.space.xs}});
@@ -0,0 +1 @@
1
+ "use strict";import{Spinner,Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const ICON=16,PENDING_DOT=6,PENDING_OPACITY=.4,ROW_FADE_MS=280,CHECK_MARK="✓";export function StepsLoader({view:e,reduced:t}){const s=useTheme(),i=useMemo(()=>buildStyles(s),[s]);return _jsx(View,{accessibilityRole:"list",style:i.list,children:keyedSteps(e.steps).map(({key:s,label:n},r)=>_jsx(StepRow,{label:n,state:stateOf(r,e.activeIndex),reduced:t,styles:i},s))})}const keyedSteps=e=>{const t=new Map;return e.map(e=>{const s=(t.get(e)??0)+1;return t.set(e,s),{key:`${e}\0${s}`,label:e}})},stateOf=(e,t)=>e<t?"done":e===t?"active":"pending",StepRow=({label:e,state:t,reduced:s,styles:i})=>{const n=useRef(new Animated.Value(s?1:0)).current;useEffect(()=>{if(s)return void n.setValue(1);const e=Animated.timing(n,{toValue:1,duration:280,useNativeDriver:!0});return e.start(),()=>e.stop()},[n,s]);const r="active"===t;return _jsxs(Animated.View,{accessibilityState:{busy:r},style:[i.row,{opacity:n}],children:[_jsxs(View,{style:i.icon,children:["done"===t?_jsx(Text,{variant:"bodySmall",color:"secondary",children:"✓"}):null,r?_jsx(Spinner,{size:"sm"}):null,"pending"===t?_jsx(View,{style:i.pendingDot}):null]}),_jsx(Text,r?{variant:"label",color:"primary",children:e}:{variant:"bodySmall",color:"secondary",style:"pending"===t?i.pendingLabel:void 0,children:e})]})},buildStyles=e=>StyleSheet.create({list:{gap:e.space.sm},row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},icon:{width:16,height:16,alignItems:"center",justifyContent:"center"},pendingDot:{width:6,height:6,borderRadius:e.radius.pill,backgroundColor:e.colors["border-subtle"]},pendingLabel:{opacity:.4}});
@@ -0,0 +1 @@
1
+ "use strict";import{useReducedMotion,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DOT=6,LIFT_PX=4,CYCLE_MS=1200,HALF_MS=300,STEP_MS=140,STILL_OPACITY=[1,.65,.3],DOT_INDEXES=[0,1,2];export function TypingPill({motion:e,mark:t}){const i=useTheme(),s=useMemo(()=>buildStyles(i),[i]),o=useReducedMotion(),r="Reduced"===e||o;return _jsxs(View,{style:s.pill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[t,_jsx(View,{style:s.dots,children:DOT_INDEXES.map(e=>_jsx(Dot,{index:e,reduced:r,color:i.colors["text-subtle"],size:6},e))})]})}const Dot=({index:e,reduced:t,color:i,size:s})=>{const o=useRef(new Animated.Value(0)).current;useEffect(()=>{if(t)return void o.setValue(0);const i=Animated.loop(Animated.sequence([Animated.delay(140*e),Animated.timing(o,{toValue:1,duration:300,useNativeDriver:!0}),Animated.timing(o,{toValue:0,duration:300,useNativeDriver:!0}),Animated.delay(600-140*e)]));return i.start(),()=>i.stop()},[o,e,t]);const r={width:s,height:s,borderRadius:s/2,backgroundColor:i};if(t)return _jsx(View,{style:[r,{opacity:STILL_OPACITY[e]}]});const n=o.interpolate({inputRange:[0,1],outputRange:[0,-4]});return _jsx(Animated.View,{style:[r,{transform:[{translateY:n}]}]})},buildStyles=e=>StyleSheet.create({pill:{flexDirection:"row",alignItems:"center",alignSelf:"flex-start",gap:e.space.sm,backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.pill,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},dots:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});
@@ -0,0 +1 @@
1
+ "use strict";export const CHAT_PUSH_TYPE="ChatAgentReplied";const CONVERSATION_ID=/^[0-9a-fA-F-]{36}$/;export function chatConversationIdFromPush(t){if(!t||t.type!==CHAT_PUSH_TYPE)return null;const n=t.conversationId;return"string"==typeof n&&CONVERSATION_ID.test(n)?n:null}
@@ -0,0 +1 @@
1
+ "use strict";import{formatChatDate}from"@webority/chat-core";import{parseInline}from"@webority/markdown-core";import{Button,Card,OptionSheet,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{Linking,Text as RNText,View}from"react-native";import{NoticePart}from"./NoticePart.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const LEAD_CAPTURE="ChatLeadCapture",SAFE_LINK=/^https?:/,inlineNodes=(e,t)=>e.map(e=>{if("text"===e.type||"code"===e.type||"citation"===e.type)return e.text;if("link"===e.type){const n=inlineNodes(e.children,t);return SAFE_LINK.test(e.href)?_jsx(RNText,{accessibilityRole:"link",style:{color:t.colors.link,textDecorationLine:"underline"},onPress:()=>{Linking.openURL(e.href).catch(()=>{})},children:n},e.key):_jsx(RNText,{children:n},e.key)}if("image"===e.type)return null;const n="strong"===e.type?{fontWeight:t.weight.bold}:"em"===e.type?{fontStyle:"italic"}:{textDecorationLine:"line-through"};return _jsx(RNText,{style:n,children:inlineNodes(e.children,t)},e.key)}),splitLine=e=>{const t=e.indexOf(": ");return t<0?{term:e,detail:null}:{term:e.slice(0,t),detail:e.slice(t+2)}},statusLine=(e,t)=>{switch(e.state){case"Confirmed":return t.actionConfirmed;case"Done":return e.decidedDateTimeUtc?`${t.actionDone} ${formatChatDate(e.decidedDateTimeUtc)}`:t.actionDone;case"Rejected":return t.actionRejected;case"Expired":return t.actionExpired;case"Failed":return t.actionFailed;case"Repeat":return e.decidedDateTimeUtc?t.actionRepeat(formatChatDate(e.decidedDateTimeUtc)):t.actionDone;case"Pending":return""}};function ActionBody({part:e,turn:t}){const n=useTheme(),{labels:i,features:a}=t,[r,o]=useState(null),[s,l]=useState(""),[c,d]=useState(!1),run=async(e,t)=>{o(e),l("");try{await t()}catch(e){const t=e?.message;l("string"==typeof t&&""!==t?t:i.actionFailed),o(null)}},u=(e.editFields??[]).map(e=>({label:e.label,value:e.id})),m=a.LeadRecap&&e.actionKind===LEAD_CAPTURE,p=m&&u.length>0,x=m&&e.confirmLabel||i.actionConfirm,h=m&&e.rejectLabel||i.actionDismiss,f=null!==r;return _jsxs(Card,{variant:"outline",padding:"sm",children:[_jsxs(View,{style:{gap:n.space.sm},children:[_jsx(Text,{variant:"label",children:e.title}),e.lines.map(e=>{if(!m)return _jsx(Text,{variant:"bodySmall",children:e},e);const{term:t,detail:i}=splitLine(e);return _jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:n.space.xs},children:[_jsx(Text,{variant:"label",children:t}),null!==i?_jsx(Text,{variant:"bodySmall",children:i}):null]},e)}),m&&e.consentText?_jsx(Text,{variant:"caption",color:"secondary",children:inlineNodes(parseInline(e.consentText),n)}):null,"Pending"===e.state?_jsxs(_Fragment,{children:[""!==s?_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:s}):null,_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:n.space.sm},children:[_jsx(Button,{label:"confirm"===r?i.actionWorking:x,loading:"confirm"===r,disabled:f,onPress:()=>{run("confirm",()=>t.confirmAction(e.actionId))}}),_jsx(Button,{label:h,variant:"ghost",disabled:f,onPress:()=>{run("reject",()=>t.rejectAction(e.actionId))}})]})]}):_jsx(Text,{variant:"bodySmall",color:"Done"===e.state||"Confirmed"===e.state||"Repeat"===e.state?"success":"secondary",children:statusLine(e,i)}),p?_jsx(Button,{label:i.editSomething,variant:"ghost",disabled:f||"Pending"!==e.state,onPress:()=>d(!0)}):null,e.note?_jsx(Text,{variant:"caption",color:"secondary",children:e.note}):null]}),p?_jsx(OptionSheet,{open:c,onClose:()=>d(!1),title:i.editSomething,options:u,onChange:(e,n)=>{d(!1),t.chooseQuickReply({id:`lead.edit:${String(n.value)}`,label:n.label,action:"Send",target:null,navigateAfterMs:null,icon:null,variant:null})}}):null]})}export function ActionPart(e){const{part:t,message:n,turn:i}=e;if("Action"!==t.kind){const e={kind:"Notice",code:"NeedsNewerApp",text:i.labels.needsNewerApp};return _jsx(NoticePart,{part:e,message:n,turn:i})}return _jsx(ActionBody,{part:t,turn:i},t.actionId)}
@@ -0,0 +1 @@
1
+ "use strict";import{formatFigure,toFigureText}from"@webority/chat-core";import{formatCompactNumber,formatNumber,formatPercent}from"@webority/mobile-core";import{BarChart,Button,ProgressBar,Sparkline,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{View}from"react-native";import{FigureText,runsToText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TONES=["primary","info","success","warning","danger","neutral"],toneAt=e=>TONES[e%TONES.length]??"primary",MAX_SERIES=8,withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),writeValue=(e,t)=>{const r=0!==e&&Math.abs(e)<.001?runsToText(formatFigure(e)):formatNumber(e,{maximumFractionDigits:2});return t?`${r} ${t}`:r};export function ChartPart({part:e,turn:t}){const r=useTheme(),[a,i]=useState(!1),l="Donut"===e.chartType?e.series.slice(0,1):e.series.slice(0,8);if(l.every(e=>0===e.points.length))return _jsxs(View,{style:{gap:r.space.sm},children:[e.title?_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]});const{unit:s}=e,o=e.title?toFigureText(e.title):t.labels.chart,n=l.length>1;return _jsxs(View,{accessibilityLabel:o,style:{gap:r.space.sm},children:[e.title?_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0}):null,_jsx(Button,{label:a?t.labels.chartShowChart:t.labels.chartShowTable,variant:"link",size:"sm",onPress:()=>i(e=>!e)}),withPositions(l).map(({key:i,item:l})=>{const c=toneAt(i),m=toFigureText(l.name)||o,u=l.points;if(0===u.length)return _jsxs(View,{style:{gap:r.space.xs},children:[n?_jsx(Text,{variant:"caption",color:"secondary",children:toFigureText(l.name)}):null,_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.labels.chartEmpty})]},i);const x=u.map(e=>e.value),h=x.reduce((e,t)=>Math.min(e,t)),p=x.reduce((e,t)=>Math.max(e,t)),b=u[0],y=u[u.length-1];let g;if(a)g=_jsx(View,{accessibilityRole:"summary",style:{gap:r.space.xs},children:withPositions(u).map(({key:e,item:t})=>_jsxs(View,{style:{flexDirection:"row",justifyContent:"space-between",gap:r.space.sm},children:[_jsx(Text,{variant:"bodySmall",color:"primary",children:toFigureText(t.label)}),_jsx(Text,{variant:"bodySmall",color:"primary",children:writeValue(t.value,s)})]},e))});else if("Bar"===e.chartType)g=_jsx(BarChart,{data:u.map(e=>({label:toFigureText(e.label),value:e.value})),height:u.length>4?300:240,label:m,formatValue:e=>writeValue(e,s),formatTick:e=>s?`${formatCompactNumber(e)} ${s}`:formatCompactNumber(e),tone:c});else if("Line"===e.chartType)g=_jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Sparkline,{data:x,height:160,fill:!0,tone:c,label:m,formatLabel:e=>writeValue(e,s)}),_jsxs(View,{style:{flexDirection:"row",justifyContent:"space-between"},children:[_jsx(Text,{variant:"caption",color:"tertiary",children:toFigureText(b.label)}),u.length>1?_jsx(Text,{variant:"caption",color:"tertiary",children:toFigureText(y.label)}):null]}),_jsx(Text,{variant:"caption",color:"secondary",children:`${t.labels.chartLow(writeValue(h,s))} ${t.labels.chartHigh(writeValue(p,s))}`})]});else{const e=x.reduce((e,t)=>e+(Number.isFinite(t)&&t>0?t:0),0);g=_jsx(View,{accessibilityRole:"list",style:{gap:r.space.sm},children:withPositions(u).map(({key:t,item:r})=>{const a=e>0&&Number.isFinite(r.value)&&r.value>0?r.value/e:0;return _jsx(ProgressBar,{progress:a,height:8,tone:toneAt(t),label:_jsx(FigureText,{text:r.label,variant:"bodySmall"}),valueLabel:`${writeValue(r.value,s)} (${formatPercent(a,{maximumFractionDigits:0})})`},t)})})}return _jsxs(View,{style:{gap:r.space.xs},children:[n?_jsx(Text,{variant:"caption",color:"secondary",children:toFigureText(l.name)}):null,g]},i)})]})}
@@ -0,0 +1 @@
1
+ "use strict";import{toFigureRuns}from"@webority/chat-core";import{Text,useTheme}from"@webority/mobile-ui";import{Fragment,useMemo}from"react";import{Text as RNText,View}from"react-native";import{jsx as _jsx}from"react/jsx-runtime";const sizeStepOf=e=>"caption"===e?"xs":"bodySmall"===e||"label"===e?"sm":"title"===e?"lg":"base",inkFor=(e,t)=>"secondary"===t?e.colors["text-muted"]:"tertiary"===t?e.colors["text-subtle"]:"success"===t||"warning"===t||"danger"===t||"info"===t?e.colors[`${t}-text`]:e.colors["text-body"];export function runsToText(e){return e.map(e=>e.text).join("")}const withOffsets=e=>e.reduce((e,t)=>{const r=e[e.length-1],n=r?r.offset+r.run.text.length:0;return e.push({offset:n,run:t}),e},[]);function runNode(e,t,r){if("text"===e.kind)return e.text;const n="sub"===e.kind?Math.round(.4*t):-Math.round(.45*t),o=Math.round(.75*t);return _jsx(View,{style:{transform:[{translateY:n}]},children:_jsx(RNText,{style:{fontSize:o,lineHeight:o,includeFontPadding:!1,color:r},children:e.text})})}export function FigureRuns({runs:e,variant:t="bodySmall",color:r,strong:n=!1,numberOfLines:o,accessibilityLabel:s,testID:i,heading:u}){const a=useTheme(),c=a.text[sizeStepOf(t)].size,l=inkFor(a,r);return _jsx(Text,{variant:t,color:r,weight:n?"semibold":void 0,numberOfLines:o,testID:i,accessibilityRole:u?"header":void 0,accessibilityLabel:s??runsToText(e),children:withOffsets(e).map(({offset:e,run:t})=>_jsx(Fragment,{children:runNode(t,c,l)},e))})}export function FigureText({text:e,variant:t="bodySmall",enabled:r=!0,...n}){const o=useMemo(()=>r?toFigureRuns(e):[{kind:"text",text:e}],[e,r]);return _jsx(FigureRuns,{runs:o,variant:t,...n})}
@@ -0,0 +1 @@
1
+ "use strict";import{formatFigure,toFigureRuns,toFigureText}from"@webority/chat-core";import{formatNumber}from"@webority/mobile-core";import{StatTile,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{FigureRuns,runsToText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TONE={Neutral:"neutral",Positive:"success",Caution:"warning",Negative:"danger"},withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),valueRunsOf=e=>{if(0!==e.value&&Math.abs(e.value)<.001)return formatFigure(e.value);const t=formatNumber(e.value,{maximumFractionDigits:2});return[{kind:"text",text:e.value<0?t.replace("-","−"):t}]};export function FiguresPart({part:e,turn:t}){const i=useTheme();return 0===e.figures.length?null:_jsx(View,{accessibilityRole:"summary",accessibilityLabel:t.labels.figures,style:{flexDirection:"row",flexWrap:"wrap",gap:i.space.sm},children:withPositions(e.figures).map(({key:e,item:i})=>{const r=valueRunsOf(i),s=t.labels.figureStatus(i.status),u=toFigureText(i.label);return _jsx(View,{style:{flexGrow:1,minWidth:110},children:_jsx(StatTile,{label:u,value:_jsxs(View,{style:{flexDirection:"row",alignItems:"flex-end",flexWrap:"wrap"},children:[_jsx(FigureRuns,{runs:r,variant:"title",color:"primary",strong:!0}),i.unit?_jsx(FigureRuns,{runs:[{kind:"text",text:" "},...toFigureRuns(i.unit)],variant:"bodySmall",color:"secondary"}):null]}),tone:TONE[i.status],caption:s||void 0,accessibilityLabel:`${u}: ${runsToText(r)}${i.unit?` ${i.unit}`:""}${s?`, ${s}`:""}`})},e)})})}
@@ -0,0 +1 @@
1
+ "use strict";import{formatFileSize}from"@webority/chat-core";import{Chip}from"@webority/mobile-ui";import{NoticePart}from"./NoticePart.js";import{jsx as _jsx}from"react/jsx-runtime";export function FilePart(e){const{part:t,message:i,turn:r}=e;if("File"!==t.kind){const e={kind:"Notice",code:"NeedsNewerApp",text:r.labels.needsNewerApp};return _jsx(NoticePart,{part:e,message:i,turn:r})}const{openAttachment:o}=r;return _jsx(Chip,{label:`${t.fileName} (${formatFileSize(t.length)})`,leftIcon:"document-text",variant:"soft",size:"sm",accessibilityLabel:r.labels.fileOpen(t.fileName),onPress:o?()=>o(t):void 0})}
@@ -0,0 +1 @@
1
+ "use strict";import{Avatar,Card,Spinner,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function HandoffPart({part:e,turn:t}){const s=useTheme(),{labels:i}=t;if(!0===t.handoffSettled&&("Requested"===e.state||"Waiting"===e.state))return null;const a=t.isLast&&("Requested"===e.state||"Waiting"===e.state||"Joined"===e.state),n=e.agent?.displayName||i.handoffAgentFallback,r=e.agent?.avatarUrl;let o;switch(e.state){case"Requested":o=_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:s.space.sm},children:[_jsx(Spinner,{size:"sm"}),_jsx(Text,{variant:"bodySmall",children:i.handoffRequested})]});break;case"Waiting":o=_jsxs(View,{style:{gap:s.space.xs},children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:s.space.sm},children:[_jsx(Spinner,{size:"sm"}),"number"==typeof e.queuePosition?null:_jsx(Text,{variant:"label",children:i.handoffWaiting})]}),"number"==typeof e.queuePosition?_jsx(Text,{variant:"caption",color:"secondary",children:i.handoffQueued(e.queuePosition)}):null,_jsx(Text,{variant:"caption",color:"secondary",children:i.handoffQueuedText})]});break;case"Joined":o=_jsxs(View,{style:{gap:s.space.xs},children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:s.space.sm},children:[_jsxs(View,{style:{position:"relative"},children:[_jsx(Avatar,{size:"sm",name:n,source:r?{uri:r}:void 0}),_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:"absolute",right:0,bottom:0,width:8,height:8,borderRadius:s.radius.pill,backgroundColor:s.colors["success-text"]}})]}),_jsx(Text,{variant:"label",children:i.handoffJoined(n)})]}),_jsx(Text,{variant:"caption",color:"secondary",children:i.handoffJoinedText(n)})]});break;case"Left":o=_jsxs(View,{style:{gap:s.space.xs},children:[_jsx(Text,{variant:"bodySmall",children:i.handoffLeft(n)}),_jsx(Text,{variant:"caption",color:"secondary",children:i.handoffLeftText})]});break;case"Ended":o=_jsxs(View,{style:{gap:s.space.xs},children:[_jsx(Text,{variant:"bodySmall",children:i.handoffEnded}),_jsx(Text,{variant:"caption",color:"secondary",children:i.handoffEndedText})]})}return void 0===o?null:_jsx(Card,{variant:"outline",padding:"sm",accessibilityLiveRegion:a?"polite":void 0,children:o})}
@@ -0,0 +1 @@
1
+ "use strict";import{AuthedImage,Button,Modal,Text,useTheme,ZoomableImage}from"@webority/mobile-ui";import{useCallback,useEffect,useRef,useState}from"react";import{Pressable,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export function ImagePart({part:e,turn:t}){const a=useTheme(),s=useSafeAreaInsets(),[l,r]=useState(!1),[i,n]=useState(null),[o,c]=useState(!1),u=useRef(t.loadAttachmentUrl);u.current=t.loadAttachmentUrl;const m=useRef(0),d=useCallback(e=>{const t=++m.current;n(null),c(!1),u.current(e).then(e=>{m.current===t&&n(e)},()=>{m.current===t&&c(!0)})},[]);if(useEffect(()=>(d(e.attachmentId),()=>{m.current++}),[e.attachmentId,d]),o)return _jsxs(View,{style:{gap:a.space.xs},children:[_jsx(Text,{variant:"bodySmall",color:"secondary",children:e.alt}),_jsx(Button,{variant:"soft",size:"sm",label:t.labels.retry,onPress:()=>d(e.attachmentId),testID:`image-retry-${e.attachmentId}`})]});if(null===i)return _jsx(Text,{variant:"bodySmall",color:"secondary",children:e.alt});const b=null!==e.width&&null!==e.height&&e.width>0&&e.height>0?e.width/e.height:null,h=_jsx(Text,{variant:"bodySmall",color:"secondary",children:e.alt});return _jsxs(_Fragment,{children:[_jsx(Pressable,{accessibilityRole:"imagebutton",accessibilityLabel:t.labels.imageOpen(e.alt),onPress:()=>r(!0),children:_jsx(AuthedImage,{uri:i,contentFit:"contain",accessible:!0,accessibilityLabel:e.alt,labels:{loading:t.labels.imageLoading},style:{width:"100%",...null===b?{minHeight:160}:{aspectRatio:b},maxHeight:320,borderRadius:a.radius.md},fallback:h})}),_jsx(Modal,{open:l,onClose:()=>r(!1),backdropPressClose:!1,presentation:"fullScreen",accessibilityLabel:e.alt,children:_jsxs(View,{style:{flex:1,backgroundColor:a.colors.bg},children:[_jsx(ZoomableImage,{style:{flex:1},accessibilityLabel:e.alt,children:_jsx(AuthedImage,{uri:i,contentFit:"contain",style:{flex:1},accessibilityLabel:e.alt})}),_jsx(View,{style:{position:"absolute",top:s.top+a.space.sm,right:a.space.sm},children:_jsx(Button,{variant:"soft",size:"sm",label:t.labels.close,onPress:()=>r(!1)})})]})})]})}
@@ -0,0 +1 @@
1
+ "use strict";import{Button,Card,Checkbox,Chip,ChoiceGroup,Input,ProgressBar,Text,useTheme}from"@webority/mobile-ui";import{useCallback,useEffect,useRef,useState}from"react";import{AccessibilityInfo,findNodeHandle,View}from"react-native";import{NoticePart}from"./NoticePart.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const FIELD_TYPES=new Set(["Email","Phone","Name","Company","Text","LongText","Choice","MultiChoice","TimeSlot","File","Consent"]),isUndrawnField=e=>!FIELD_TYPES.has(e.type),fileNameOf=(e,t)=>{const i=e.name;return"string"==typeof i&&""!==i?i:t},slotFormat=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}),selectedIds=e=>""===e?[]:JSON.parse(e),KEYBOARD_TYPES={Email:"email-address",Phone:"phone-pad"},AUTO_COMPLETE={Email:"email",Phone:"tel",Name:"name",Company:"organization"},optionalSuffix=(e,t)=>e.required?"":` (${t.inputOptional})`,firstErrorKey=(e,t)=>e.find(e=>void 0!==t[e.key])?.key;function OpenRequest({part:e,turn:t,pickAttachments:i}){const r=useTheme(),{labels:s,features:n}=t,[a,l]=useState({}),[o,c]=useState({}),[u,d]=useState(""),[p,y]=useState(!1),[f,m]=useState({}),[x,h]=useState({}),[b,k]=useState({}),v=useRef({}),g=useRef({}),j=useRef(f),_=useRef(0),T=useRef(!1),C=useCallback(e=>{const t=v.current[e];if(t)return void t.focus();const i=g.current[e];if(!i)return;const r=findNodeHandle(i);null!==r&&AccessibilityInfo.setAccessibilityFocus(r)},[]);useEffect(()=>{if(p||!T.current)return;T.current=!1;const t=firstErrorKey(e.fields,o);void 0!==t&&C(t)},[p,o,e.fields,C]);const setValue=(e,t)=>l(i=>({...i,[e]:t})),commitUploads=e=>{j.current=e,m(e)},patchUpload=(e,t)=>{const i=j.current[e];i&&commitUploads({...j.current,[e]:{...i,...t}})},isLiveUpload=(e,t)=>j.current[e]?.token===t,w=Object.values(f).some(e=>"Ready"!==e.status),leave=async e=>{y(!0),d("");try{await e()}catch{d(s.errorGeneric),y(!1)}},S=n.LeadShortcuts,R=S&&1===e.fields.length&&!e.fields[0].required,E=S&&e.cancellable;return _jsx(Card,{variant:"outline",padding:"sm",accessibilityLabel:e.title||void 0,children:_jsxs(View,{style:{gap:r.space.sm},children:[e.title?_jsx(Text,{variant:"label",accessibilityRole:"header",children:e.title}):null,e.allowTyped?_jsx(Text,{variant:"caption",color:"secondary",children:s.typeAnswer}):null,e.fields.map(n=>{const l=a[n.key]??"",c=o[n.key];if("File"===n.type){const e=f[n.key];return _jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),e?_jsxs(View,{style:{gap:r.space.xxs},children:[_jsx(Chip,{label:e.fileName,variant:"soft",onRemove:()=>{return e=n.key,commitUploads(Object.fromEntries(Object.entries(j.current).filter(([t])=>t!==e))),void setValue(e,"");var e},labels:{remove:s.inputRemoveFile}}),"Uploading"===e.status?_jsx(ProgressBar,{progress:e.progress??void 0,label:s.attachmentUploading,height:4}):null,"Failed"===e.status?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:s.attachmentFailed}):null]}):_jsx(View,{style:{flexDirection:"row"},children:_jsx(Button,{label:s.inputChooseFile,variant:"soft",size:"sm",leftIcon:"paperclip",disabled:p||void 0===i,onPress:()=>{(async e=>{if(!i)return;let r;try{r=await i()}catch{return void d(s.errorGeneric)}const n=r[0];if(!n)return;_.current+=1;const a=_.current;commitUploads({...j.current,[e.key]:{fileName:fileNameOf(n,e.label),status:"Uploading",progress:null,token:a}});try{const i=await t.uploadInputFile(n,t=>{isLiveUpload(e.key,a)&&patchUpload(e.key,{progress:t})});isLiveUpload(e.key,a)&&(setValue(e.key,i),patchUpload(e.key,{status:"Ready",progress:null}))}catch{isLiveUpload(e.key,a)&&(setValue(e.key,""),patchUpload(e.key,{status:"Failed",progress:null}))}})(n)}})}),c?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"assertive",children:c}):null]},n.key)}if("MultiChoice"===n.type){const e=(n.options??[]).map(e=>({label:e.label,value:e.id}));return _jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),_jsx(View,{ref:e=>{g.current[n.key]=e},children:_jsx(ChoiceGroup,{selectionMode:"multiple",options:e,value:selectedIds(l),onChange:t=>setValue(n.key,JSON.stringify(e.filter(e=>t.includes(e.value)).map(e=>e.value))),accessibilityLabel:n.label,error:c,disabled:p})})]},n.key)}if("Choice"===n.type||"TimeSlot"===n.type){const e="TimeSlot"===n.type?(n.slots??[]).map(e=>({label:slotFormat.format(new Date(e.startDateTimeUtc)),value:e.id})):(n.options??[]).map(e=>({label:e.label,value:e.id}));return _jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Text,{variant:"label",children:`${n.label}${optionalSuffix(n,s)}`}),_jsx(View,{ref:e=>{g.current[n.key]=e},children:_jsx(ChoiceGroup,{options:e,value:""===l?void 0:l,onChange:e=>setValue(n.key,String(e)),accessibilityLabel:n.label,error:c,disabled:p})})]},n.key)}if("Consent"===n.type)return _jsx(Checkbox,{checked:"true"===l,onChange:e=>setValue(n.key,e?"true":"false"),label:n.consentText??n.label,error:c,disabled:p},n.key);const u=_jsx(Input,{ref:e=>{v.current[n.key]=e},label:n.label,placeholder:n.placeholder??void 0,value:l,onChangeText:e=>setValue(n.key,e),maxLength:n.maxLength??void 0,required:n.required,error:c,help:n.required?void 0:s.inputOptional,labelMode:"top",disabled:p,type:n.secret?"password":"LongText"===n.type?"textarea":"input",keyboardType:KEYBOARD_TYPES[n.type]??"default",autoCapitalize:"Email"===n.type?"none":void 0,autoComplete:AUTO_COMPLETE[n.type]},n.key);if(!("Otp"===n.verify&&("Email"===n.type||"Phone"===n.type)))return u;const y=b[n.key];return _jsxs(View,{style:{gap:r.space.xs},children:[u,_jsxs(View,{style:{gap:r.space.xs},children:[_jsx(Button,{label:s.inputSendCode,variant:"soft",size:"sm",disabled:p,onPress:()=>{(async i=>{if("Otp"===i.verify)try{await t.sendOtp(e.requestId,{fieldKey:i.key,value:(a[i.key]??"").trim()}),k(e=>({...e,[i.key]:"sent"}))}catch{k(e=>({...e,[i.key]:"failed"}))}})(n)},testID:`otp-send-${n.key}`}),_jsx(Input,{label:s.inputEnterCode,value:x[n.key]??"",onChangeText:e=>h(t=>({...t,[n.key]:e})),keyboardType:"number-pad",autoComplete:"one-time-code",disabled:p}),y?_jsx(Text,{variant:"caption",color:"failed"===y?"danger":"secondary",accessibilityLiveRegion:"polite",children:"failed"===y?s.inputCodeFailed:s.inputCodeSent}):null]})]},n.key)}),""!==u?_jsx(Text,{variant:"bodySmall",color:"danger",accessibilityLiveRegion:"polite",children:u}):null,_jsxs(View,{style:{flexDirection:"row",flexWrap:"wrap",gap:r.space.sm},children:[_jsx(Button,{label:p?s.inputSubmitting:e.submitLabel,loading:p,disabled:p||w,onPress:()=>{(async()=>{if(w)return;const i={},r={};for(const t of e.fields){const e=a[t.key]??"";if("Consent"===t.type){const n="true"===e;t.required&&!n&&(i[t.key]=s.inputConsentRequired),r[t.key]=n?"true":"false"}else if("Choice"===t.type||"TimeSlot"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else if("MultiChoice"===t.type){const n=selectedIds(e);t.required&&0===n.length&&(i[t.key]=s.inputRequired),r[t.key]=JSON.stringify(n)}else if("File"===t.type)t.required&&""===e&&(i[t.key]=s.inputRequired),r[t.key]=e;else{const n=t.secret?e:e.trim();t.required&&""===n&&(i[t.key]=s.inputRequired),r[t.key]=n}}const n={};for(const t of e.fields){if("Otp"!==t.verify)continue;const e=(x[t.key]??"").trim();""===e&&(i[t.key]=s.inputRequired),n[t.key]=e}if(c(i),Object.keys(i).length>0){const t=firstErrorKey(e.fields,i);return void(void 0!==t&&C(t))}y(!0),d("");try{const i=await t.answerInput(e.requestId,r,Object.keys(n).length>0?n:null);if(i.ok)return;c(i.errors),T.current=!0,d(i.message??"")}catch{d(s.errorGeneric)}y(!1)})()}}),w?_jsx(Text,{variant:"caption",color:"secondary",children:s.attachmentUploading}):null,R?_jsx(Button,{label:s.skip,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.skipInput(e.requestId))}}):null,E?_jsx(Button,{label:s.cancel,variant:"ghost",disabled:p,onPress:()=>{leave(()=>t.cancelLead())}}):null]})]})})}export function InputRequestPart(e){const{part:t,message:i,turn:r,pickAttachments:s}=e;if("InputRequest"!==t.kind||t.fields.some(isUndrawnField)){const e={kind:"Notice",code:"NeedsNewerApp",text:r.labels.needsNewerApp};return _jsx(NoticePart,{part:e,message:i,turn:r})}return"Answered"===t.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:t.answeredSummary||r.labels.inputAnswered}):"Skipped"===t.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputSkipped}):"Expired"===t.state?_jsx(Text,{variant:"bodySmall",color:"secondary",children:r.labels.inputExpired}):_jsx(OpenRequest,{part:t,turn:r,pickAttachments:s},t.requestId)}
@@ -0,0 +1 @@
1
+ "use strict";import{Banner}from"@webority/mobile-ui";import{jsx as _jsx}from"react/jsx-runtime";export function NoticePart({part:e}){const t="AssistantUnavailable"===e.code?"danger":"ActionLimitReached"===e.code||"ConversationTooLong"===e.code?"warning":"info";return _jsx(Banner,{message:e.text,tone:t,accessibilityRole:"alert"})}
@@ -0,0 +1 @@
1
+ "use strict";import{CHAT_HANDOFF_REQUEST_ID,isHandoffTarget}from"@webority/chat-core";import{Chip,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatEntrance}from"../ChatEntrance.js";import{defaultOpenTarget}from"../chatShared.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const QUIET_LOOK={variant:"outline"};function lookOf(e){switch(e){case"Primary":case"Cta":return{variant:"solid",tone:"primary"};default:return QUIET_LOOK}}export function QuickRepliesPart({part:e,turn:n}){const t=useTheme();if(!n.features.SuggestedReplies||!n.isLast||n.busy||0===e.replies.length)return null;const i=n.openTarget,a=n.onNavigate,r=void 0!==i&&i!==defaultOpenTarget,o="Composer"===e.placement,s=e.replies.filter(e=>"Send"===e.action||"Open"===e.action&&e.target&&i||"Navigate"===e.action&&n.features.LinkHandoff);if(0===s.length)return null;const l=o?void 0:s.find(e=>e.id===CHAT_HANDOFF_REQUEST_ID&&"Send"===e.action),c=l?s.filter(e=>e!==l):s,f=l?1:0,sendChip=(e,t)=>_jsx(Chip,{label:e.label,variant:t.variant,tone:t.tone,leftIcon:e.icon?e.icon:void 0,onPress:()=>{n.chooseQuickReply(e),n.focusComposer?.()}});return _jsxs(View,{accessibilityRole:"summary",accessibilityLabel:n.labels.quickReplies,accessibilityLiveRegion:n.handoffPause?"polite":void 0,style:{flexDirection:"row",flexWrap:"wrap",gap:t.space.xs,...o?{paddingHorizontal:t.space.md}:null},children:[l?_jsx(ChatEntrance,{index:0,children:_jsxs(View,{style:{flexBasis:"100%",alignItems:"flex-start",gap:t.space.xs},children:[_jsx(Text,{variant:"label",children:l.label}),sendChip(l,lookOf("Primary"))]})},l.id):null,c.map((e,t)=>{const o=t+f,s=l?QUIET_LOOK:lookOf(e.variant),c=e.icon?e.icon:void 0;if("Send"===e.action)return _jsx(ChatEntrance,{index:o,children:sendChip(e,s)},e.id);const d=e.target;if("Open"===e.action&&d&&i)return _jsx(ChatEntrance,{index:o,children:_jsx(Chip,{label:e.label,variant:s.variant,tone:s.tone,leftIcon:c,onPress:()=>i(d)})},e.id);if("Navigate"===e.action){const t=(e=>{if(!e)return null;if(isHandoffTarget(e,n.handoffHosts))return e;const t=n.resolveLink?.(e);return"string"==typeof t&&""!==t?t:null})(d),l=null===t?void 0:(e=>e.startsWith("/")?i&&r?()=>i(e):a?()=>a(e):void 0:i?()=>i(e):void 0)(t);return _jsx(ChatEntrance,null===t||void 0===l?{index:o,children:_jsx(Text,{variant:"bodySmall",color:"primary",children:e.label})}:{index:o,children:_jsx(Chip,{label:n.handoffPause?n.labels.handoffMoment:e.label,variant:n.handoffPause?QUIET_LOOK.variant:s.variant,tone:n.handoffPause?void 0:s.tone,leftIcon:c,disabled:n.handoffPause,onPress:()=>n.beginHandoff(e,l)})},e.id)}return null})]})}
@@ -0,0 +1 @@
1
+ "use strict";import{formatChatValue,toFigureText}from"@webority/chat-core";import{Button,Card,useTheme}from"@webority/mobile-ui";import{StyleSheet,View}from"react-native";import{FigureText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]),NUMERIC=new Set(["Integer","Decimal","MoneyMinor","Percent"]);export function RecordCardPart({part:e,turn:t}){const r=useTheme(),i=void 0!==t.openRecord&&null!==e.target;return _jsx(Card,{variant:"outline",padding:"sm",accessibilityRole:"summary",children:_jsxs(View,{style:{gap:r.space.xs},children:[_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0,numberOfLines:2,enabled:t.features.FigureText,heading:!0}),e.subtitle?_jsx(FigureText,{text:e.subtitle,variant:"bodySmall",color:"secondary",enabled:t.features.FigureText}):null,withPositions(e.fields).map(({key:e,item:i})=>_jsxs(View,{style:{gap:r.space.xs},children:[e>0?_jsx(View,{style:{height:StyleSheet.hairlineWidth,backgroundColor:r.colors["border-subtle"]}}):null,_jsxs(View,{style:{flexDirection:"row",justifyContent:"space-between",gap:r.space.sm},children:[_jsx(View,{style:{flexShrink:1},children:_jsx(FigureText,{text:i.label,variant:"caption",color:"secondary",enabled:t.features.FigureText})}),_jsx(View,{style:{flex:1,alignItems:NUMERIC.has(i.type)?"flex-end":"flex-start"},children:_jsx(FigureText,{text:formatChatValue(i.value,i.type,null),variant:"bodySmall",color:"primary",enabled:t.features.FigureText})})]})]},e)),i?_jsx(Button,{label:t.labels.recordOpen,variant:"link",size:"sm",accessibilityLabel:t.labels.recordOpenFor(toFigureText(e.title)),onPress:()=>t.openRecord?.(e),testID:`record-open-${e.recordId}`}):null]})})}
@@ -0,0 +1 @@
1
+ "use strict";import{Chip,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{ChatEntrance}from"../ChatEntrance.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const HTTP_LINK=/^https?:\/\//i;export function SourcesPart({part:e,turn:r}){const s=useTheme();if(!r.features.Sources||0===e.sources.length)return null;const t=r.openTarget;return _jsxs(View,{style:{gap:s.space.xs},children:[_jsx(Text,{variant:"caption",color:"secondary",children:r.labels.sources}),_jsx(View,{accessibilityRole:"list",accessibilityLabel:r.labels.sources,style:{flexDirection:"row",flexWrap:"wrap",gap:s.space.xs},children:e.sources.map((e,s)=>{const i=e.url,a=null!==i&&HTTP_LINK.test(i)&&void 0!==t?()=>t(i):void 0;return _jsx(ChatEntrance,{index:s,animate:!1,children:_jsx(View,{ref:s=>r.registerSourceRow?.(String(e.marker),s),children:_jsx(Chip,{label:`${e.marker} ${e.title}`,variant:"outline",size:"sm",accessibilityLabel:a?r.labels.openSource(e.title):void 0,onPress:a})})},e.marker)})})]})}
@@ -0,0 +1 @@
1
+ "use strict";import{formatChatValue,toFigureText}from"@webority/chat-core";import{AppIcon,Button,Card,Text,useTheme}from"@webority/mobile-ui";import{useState}from"react";import{ScrollView,StyleSheet,View}from"react-native";import{FigureText}from"./FigureText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const PREVIEW_ROWS=25,COLUMN_WIDTH={Text:140,Integer:88,Decimal:96,MoneyMinor:112,Percent:80,Date:112,DateTimeUtc:152},NUMERIC=new Set(["Integer","Decimal","MoneyMinor","Percent"]),withPositions=e=>e.reduce((e,t)=>(e.push({key:e.length,item:t}),e),[]);export function TablePart({part:e,turn:t}){const r=useTheme(),[i,l]=useState(!1),[n,s]=useState(0),[o,a]=useState(0),[c,u]=useState(0);if(0===e.columns.length||0===e.rows.length)return null;const plain=e=>t.features.FigureText?toFigureText(e):e,x=o>c+n+1,m=i?e.rows:e.rows.slice(0,25),h={height:StyleSheet.hairlineWidth,backgroundColor:r.colors["border-subtle"]},d={paddingVertical:r.space.xs,paddingHorizontal:r.space.sm},cellValue=(t,r,i)=>{const l=t[r];return null==l?null:formatChatValue(l,i.type,e.currency)};return _jsxs(View,{accessibilityLabel:e.title?plain(e.title):t.labels.table,style:{gap:r.space.xs},children:[e.title?_jsx(FigureText,{text:e.title,variant:"label",color:"primary",strong:!0,enabled:t.features.FigureText}):null,_jsxs(Card,{variant:"outline",padding:"sm",onLayout:e=>u(e.nativeEvent.layout.width),children:[_jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!0,nestedScrollEnabled:!0,onScroll:e=>s(e.nativeEvent.contentOffset.x),onContentSizeChange:e=>a(e),scrollEventThrottle:16,children:_jsxs(View,{children:[_jsx(View,{style:{flexDirection:"row"},children:e.columns.map(e=>_jsx(View,{style:[d,{width:COLUMN_WIDTH[e.type],alignItems:NUMERIC.has(e.type)?"flex-end":"flex-start"}],children:_jsx(FigureText,{text:e.label,variant:"label",color:"secondary",strong:!0,numberOfLines:2,enabled:t.features.FigureText})},e.key))}),_jsx(View,{style:h}),withPositions(m).map(({key:r,item:i})=>{const l=e.columns.map((e,t)=>`${plain(e.label)}: ${cellValue(i,t,e)??"-"}`).join(", ");return _jsxs(View,{accessible:!0,accessibilityLabel:l,children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{flexDirection:"row"},children:e.columns.map((e,r)=>{const l=cellValue(i,r,e);return _jsx(View,{style:[d,{width:COLUMN_WIDTH[e.type],alignItems:NUMERIC.has(e.type)?"flex-end":"flex-start"}],children:null===l?_jsx(Text,{variant:"bodySmall",color:"tertiary",children:"-"}):_jsx(FigureText,{text:l,variant:"bodySmall",color:"primary",numberOfLines:3,enabled:t.features.FigureText})},e.key)})}),_jsx(View,{style:h})]},r)})]})}),x?_jsx(View,{pointerEvents:"none",style:{position:"absolute",right:0,top:0,bottom:0,justifyContent:"center"},children:_jsx(AppIcon,{name:"chevron-right",size:"sm",color:"tertiary"})}):null]}),!i&&e.rows.length>25?_jsx(Button,{variant:"link",size:"sm",label:t.labels.tableShowAll(e.rows.length),onPress:()=>l(!0)}):null]})}
@@ -0,0 +1 @@
1
+ "use strict";import{isHandoffTarget}from"@webority/chat-core";import{Markdown,Text}from"@webority/mobile-ui";import{FigureText}from"./FigureText.js";import{jsx as _jsx}from"react/jsx-runtime";const CITATION=/^\d+$/;export function TextPart({part:t,message:e,turn:r}){return"Visitor"===e.author.kind||"Customer"===e.author.kind?r.features.FigureText?_jsx(FigureText,{text:t.text,variant:"body",color:"primary"}):_jsx(Text,{variant:"body",children:t.text}):_jsx(Markdown,{links:"app",headings:"text",resolveLink:t=>r.openTarget&&isHandoffTarget(t,r.handoffHosts)?t:null,onAppLinkPress:t=>r.openTarget?.(t),isCitation:t=>CITATION.test(t),onOpenCitation:r.openCitation?t=>r.openCitation?.(Number(t)):void 0,children:t.text})}
@@ -0,0 +1 @@
1
+ "use strict";import{Button,Card,Chip,Text,useTheme}from"@webority/mobile-ui";import{View}from"react-native";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function TicketPart({part:e,turn:t}){const i=useTheme(),{labels:s,openTicket:r}=t,a=s.ticketAria(e.number),n=s.ticketStatus(e.status),l=r?()=>r({ticketId:e.ticketId,number:e.number}):void 0;return _jsx(Card,{variant:"outline",padding:"sm",accessibilityLabel:n?`${a}, ${n}`:a,children:_jsxs(View,{style:{gap:i.space.xs},children:[_jsxs(View,{style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:i.space.sm},children:[_jsx(Text,{variant:"label",children:a}),n?_jsx(Chip,{size:"sm",variant:"soft",label:n}):null]}),_jsx(Text,{variant:"bodySmall",children:e.subject}),l?_jsx(Button,{label:s.ticketView,variant:"link",size:"sm",onPress:l,testID:`ticket-view-${e.ticketId}`}):null]})})}
@@ -0,0 +1 @@
1
+ "use strict";import{voiceClipBars}from"@webority/chat-core";import{Logger}from"@webority/mobile-core";import{Button,IconButton,Text,useTheme}from"@webority/mobile-ui";import{useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{playFile}from"../speech/expoAudio.js";import{discardFile,PhoneSpeechError}from"../speech/phoneSpeech.js";import{audioExtension,formatClipTime}from"../speech/speechText.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const expoFileSystem=()=>{try{return require("expo-file-system")}catch{throw new PhoneSpeechError("Unavailable","Unavailable","Voice files are not available in this app.")}};export function VoiceClipPart({part:e,turn:t}){const r=useTheme(),i=useMemo(()=>buildStyles(r),[r]),a=t.labels,[o,s]=useState(!1),[c,l]=useState(!1),[n,u]=useState(!1),[p,m]=useState(0),[h,d]=useState(!1),x=useRef(null),y=useRef(null),f=useRef(!0);useEffect(()=>(f.current=!0,()=>{f.current=!1,x.current?.stop(),x.current=null,null!==y.current&&discardFile(y.current)}),[]);const startPlayback=e=>{const t=playFile(e,e=>{f.current&&(m(e.positionMs),u(e.playing))});x.current=t;const release=()=>!(!f.current||x.current!==t)&&(x.current=null,u(!1),!0);t.finished.then(()=>{release()&&m(0)},e=>{release()&&(l(!0),Logger.error("[chat] voice clip playback failed",e))})},v=t.features.VoiceClips,b=null!==e.transcript&&""!==e.transcript?e.transcript:null,w=e.durationMs>0?Math.min(1,Math.max(0,p/e.durationMs)):0,g=useMemo(()=>voiceClipBars(e.attachmentId,40).map((e,t)=>({id:`bar-${t}`,position:t,level:e})),[e.attachmentId]);return _jsxs(View,{accessibilityRole:"summary",accessibilityLabel:a.voiceClip,testID:"chat-voice-clip",style:i.root,children:[v?_jsxs(View,{style:i.row,children:[_jsx(IconButton,{icon:n?"pause":"play",accessibilityLabel:n?a.voiceClipPause:a.voiceClipPlay,variant:"ghost",tone:"neutral",size:"sm",loading:o,disabled:o,onPress:()=>{const r=x.current;null===r?null===y.current?o||(async()=>{s(!0),l(!1);try{const r=new Uint8Array(await t.readAttachment(e.attachmentId)),{File:i,Paths:a}=expoFileSystem(),o=new i(a.cache,`wchat-clip-${e.attachmentId}${audioExtension(r)}`);if(o.create({overwrite:!0}),o.write(r),!f.current)return void discardFile(o.uri);y.current=o.uri,startPlayback(o.uri)}catch(e){if(!f.current)return;l(!0),Logger.error("[chat] voice clip failed to load",e)}finally{f.current&&s(!1)}})():startPlayback(y.current):n?r.pause():r.resume()},testID:"chat-voice-clip-play"}),_jsx(View,{style:i.wave,children:g.map(e=>_jsx(View,{testID:"chat-voice-clip-bar",style:[i.bar,{height:Math.max(4,Math.round(28*e.level)),backgroundColor:e.position<Math.floor(40*w)?r.colors.primary:r.colors["text-subtle"]}]},e.id))}),_jsx(Text,{variant:"caption",color:"secondary",children:a.voiceClipTime(formatClipTime(p),formatClipTime(e.durationMs))})]}):null,v&&null!==b?_jsxs(_Fragment,{children:[_jsx(Button,{label:h?a.voiceClipHideTranscript:a.voiceClipShowTranscript,variant:"link",size:"sm",accessibilityState:{expanded:h},onPress:()=>d(e=>!e),testID:"chat-voice-clip-transcript-toggle"}),h?_jsx(Text,{variant:"body",children:b}):null]}):null,v||null===b?null:_jsx(Text,{variant:"body",children:b}),c?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",children:a.voiceClipFailed}):null]})}const buildStyles=e=>StyleSheet.create({root:{gap:e.space.xs},row:{flexDirection:"row",alignItems:"center",gap:e.space.xs},wave:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},bar:{width:3}});
@@ -0,0 +1 @@
1
+ "use strict";import{ActionPart}from"./ActionPart.js";import{ChartPart}from"./ChartPart.js";import{FiguresPart}from"./FiguresPart.js";import{FilePart}from"./FilePart.js";import{HandoffPart}from"./HandoffPart.js";import{ImagePart}from"./ImagePart.js";import{InputRequestPart}from"./InputRequestPart.js";import{NoticePart}from"./NoticePart.js";import{QuickRepliesPart}from"./QuickRepliesPart.js";import{RecordCardPart}from"./RecordCardPart.js";import{SourcesPart}from"./SourcesPart.js";import{TablePart}from"./TablePart.js";import{TextPart}from"./TextPart.js";import{TicketPart}from"./TicketPart.js";import{VoiceClipPart}from"./VoiceClipPart.js";export const defaultRenderers={Text:TextPart,Sources:SourcesPart,QuickReplies:QuickRepliesPart,InputRequest:InputRequestPart,Action:ActionPart,Notice:NoticePart,Table:TablePart,Chart:ChartPart,Figures:FiguresPart,RecordCard:RecordCardPart,Image:ImagePart,File:FilePart,Ticket:TicketPart,Handoff:HandoffPart,VoiceClip:VoiceClipPart};
@@ -0,0 +1 @@
1
+ "use strict";import{ChatSpeechError}from"@webority/chat-core";import{buildSsml,clampSpeakText}from"./speechText.js";const TRANSCRIBE_API_VERSION="2024-11-15",TTS_OUTPUT_FORMAT="audio-24khz-48kbitrate-mono-mp3",REQUEST_TIMEOUT_MS=15e3,REGION_PATTERN=/^[a-z0-9]+$/;export class SpeechRequestError extends Error{constructor(e){super(`Speech request failed with status ${e}`),this.name="SpeechRequestError",this.status=e}}const assertRegion=e=>{if(!REGION_PATTERN.test(e))throw new ChatSpeechError("Unavailable","Speech is not available.")},withTimeout=async(e,t)=>{const r=new AbortController,abort=()=>r.abort(),o=setTimeout(abort,15e3);e?.aborted&&r.abort(),e?.addEventListener("abort",abort);try{return await t(r.signal)}finally{clearTimeout(o),e?.removeEventListener("abort",abort)}};export async function transcribeClip(e){const{token:t,uri:r,language:o,signal:a,fetchImpl:i=fetch}=e;assertRegion(t.region);const n=new FormData;return n.append("audio",{uri:r,name:"dictation.m4a",type:"audio/mp4"}),n.append("definition",JSON.stringify({locales:[o]})),withTimeout(a,async e=>{const r=await i(`https://${t.region}.api.cognitive.microsoft.com/speechtotext/transcriptions:transcribe?api-version=2024-11-15`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`},body:n,signal:e});if(!r.ok)throw new SpeechRequestError(r.status);return((await r.json()).combinedPhrases??[]).map(e=>e.text??"").join(" ").trim()})}export async function synthesizeSpeech(e){const{token:t,text:r,language:o,voice:a,signal:i,fetchImpl:n=fetch}=e;return assertRegion(t.region),withTimeout(i,async e=>{const i=await n(`https://${t.region}.tts.speech.microsoft.com/cognitiveservices/v1`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":TTS_OUTPUT_FORMAT,"User-Agent":"webority-chat"},body:buildSsml(clampSpeakText(r),o,a),signal:e});if(!i.ok)throw new SpeechRequestError(i.status);return new Uint8Array(await i.arrayBuffer())})}
@@ -0,0 +1 @@
1
+ "use strict";import{ChatSpeechError}from"@webority/chat-core";import{Logger}from"@webority/mobile-core";const expoAudio=()=>require("expo-audio"),expoFileSystem=()=>{try{return require("expo-file-system")}catch{throw new ChatSpeechError("Unavailable","Voice files are not available in this app.")}},RECORDING_OPTIONS={sampleRate:16e3,numberOfChannels:1,bitRate:48e3},setRecordingMode=e=>expoAudio().setAudioModeAsync({allowsRecording:e,playsInSilentMode:!0});export async function startRecording(){const e=expoAudio();await setRecordingMode(!0);const t=new e.AudioModule.AudioRecorder({...e.RecordingPresets.HIGH_QUALITY,...RECORDING_OPTIONS});let o=0;try{await t.prepareToRecordAsync(),o=Date.now(),t.record()}catch(e){throw await setRecordingMode(!1),e}return{async stop(){try{await t.stop();const e=t.uri;if(null===e)throw new Error("The recorder finished without a file.");const i=t.getStatus().durationMillis;return{uri:e,durationMs:i>0?i:Date.now()-o}}finally{await setRecordingMode(!1)}},async cancel(){try{t.isRecording&&await t.stop();const e=t.uri;if(null!==e){const{File:t}=expoFileSystem();try{new t(e).delete()}catch(e){Logger.warn("Removing a cancelled recording failed:",e)}}}finally{await setRecordingMode(!1)}}}}let active=null;export function playFile(e,t){active?.stop();let o=null,i=null,r=!1,resolveFinished=()=>{},rejectFinished=()=>{};const n=new Promise((e,t)=>{resolveFinished=e,rejectFinished=t}),release=()=>{i?.remove(),i=null,null!==o&&(o.pause(),o.remove(),o=null),active===a&&(active=null)},a={finished:n,pause:()=>o?.pause(),resume:()=>o?.play(),stop:()=>{r||(r=!0,release(),resolveFinished())}};active=a;const l=expoAudio();return l.setAudioModeAsync({playsInSilentMode:!0,allowsRecording:!1}).then(()=>{if(r)return;const n=l.createAudioPlayer({uri:e});o=n,i=n.addListener("playbackStatusUpdate",e=>{t?.({positionMs:1e3*e.currentTime,durationMs:e.duration>0?1e3*e.duration:null,playing:e.playing}),e.didJustFinish&&(r=!0,release(),resolveFinished())}),n.play()}).catch(e=>{r||(r=!0,release(),rejectFinished(e))}),a}
@@ -0,0 +1 @@
1
+ "use strict";import{ChatSpeechError,createSpeechTokenSource}from"@webority/chat-core";import{Logger}from"@webority/mobile-core";import{Permissions}from"@webority/mobile-core/permissions";import{synthesizeSpeech,transcribeClip}from"./azureSpeech.js";import{playFile,startRecording}from"./expoAudio.js";import{clampSpeakText,DEFAULT_SPEECH_LANGUAGE,DEFAULT_SPEECH_VOICE,MAX_DICTATION_MS,MIN_DICTATION_MS}from"./speechText.js";export class PhoneSpeechError extends ChatSpeechError{constructor(e,r,t){super(e,t),this.name="PhoneSpeechError",this.phoneCode=r}}const expoFileSystem=()=>{try{return require("expo-file-system")}catch{throw new PhoneSpeechError("Unavailable","Unavailable","Voice files are not available in this app.")}};export function discardFile(e){try{const{File:r}=expoFileSystem();new r(e).delete()}catch(e){Logger.warn("Removing a temporary audio file failed:",e)}}const failed=e=>e instanceof ChatSpeechError?e:(Logger.error("[chat] speech failed",e),new PhoneSpeechError("Failed","Failed")),waitForDictation=e=>new Promise(r=>{if(e?.aborted)return void r();const done=()=>{clearTimeout(t),e?.removeEventListener("abort",done),r()},t=setTimeout(done,MAX_DICTATION_MS);e?.addEventListener("abort",done)});export function createPhoneSpeech(e){const r=e.language??DEFAULT_SPEECH_LANGUAGE,t=e.voice??DEFAULT_SPEECH_VOICE,o=createSpeechTokenSource(e.getToken);let a=null,i=null,n=Promise.resolve();const token=async()=>{try{return await o.get()}catch(e){throw failed(e)}},dictate=async e=>{a?.abort(),i?.abort();const t=n,o=new AbortController,forward=()=>o.abort();e.signal?.aborted&&o.abort(),e.signal?.addEventListener("abort",forward),i=o;const c=t.then(()=>(async(e,t)=>{const o=await Permissions.ensure("microphone").catch(()=>{throw new PhoneSpeechError("Blocked","MicDenied","The microphone permission could not be checked.")});if("blocked"===o)throw new PhoneSpeechError("Blocked","MicBlocked");if("unavailable"===o)throw new PhoneSpeechError("NoMicrophone","MicUnavailable");if("granted"!==o)throw new PhoneSpeechError("Blocked","MicDenied");let a,i;try{a=await startRecording()}catch(e){throw failed(e)}e.onStarted?.(),await waitForDictation(t);try{i=await a.stop()}catch(r){throw e.onEnd?.(),failed(r)}if(e.shouldDiscard?.())return discardFile(i.uri),void e.onEnd?.();if(i.durationMs<MIN_DICTATION_MS)return discardFile(i.uri),void e.onEnd?.();try{const t=await transcribeClip({token:await token(),uri:i.uri,language:e.language??r});""!==t&&e.onText?.(t,!0),e.onEnd?.()}catch(r){throw e.onEnd?.(),failed(r)}finally{discardFile(i.uri)}})(e,o.signal));n=c.then(()=>{},()=>{});try{await c}finally{e.signal?.removeEventListener("abort",forward),i===o&&(i=null)}};return{dictation:!0,readAloud:!0,streamsText:!1,startDictation:e=>dictate(e),speak:(e,o)=>(async(e,o)=>{a?.abort();const i=new AbortController;a=i;const forward=()=>i.abort();o.signal?.aborted&&i.abort(),o.signal?.addEventListener("abort",forward);const n=i.signal;let c=null,s=null;const onAbort=()=>{s?.stop()};try{const a=clampSpeakText(e);if(""===a)return;const i=await synthesizeSpeech({token:await token(),text:a,language:o.language??r,voice:t,signal:n});if(n.aborted)return;const{File:l,Paths:d}=expoFileSystem();if(c=new l(d.cache,`wchat-read-${Date.now()}.mp3`),c.create({overwrite:!0}),c.write(i),n.aborted)return;s=playFile(c.uri),n.addEventListener("abort",onAbort),n.aborted&&s.stop(),await s.finished}catch(e){if(n.aborted)return;throw failed(e)}finally{n.removeEventListener("abort",onAbort),o.signal?.removeEventListener("abort",forward),a===i&&(a=null),null!==c&&discardFile(c.uri)}})(e,o)}}
@@ -0,0 +1 @@
1
+ "use strict";export const DEFAULT_SPEECH_LANGUAGE="en-IN";export const DEFAULT_SPEECH_VOICE="en-IN-NeerjaNeural";export const MAX_SPEAK_CHARS=6e3;export const MAX_DICTATION_MS=3e5;export const MIN_DICTATION_MS=600;const ascii=t=>Array.from(t,t=>t.charCodeAt(0)),OGG=ascii("OggS"),RIFF=ascii("RIFF"),EBML=[26,69,223,163],ID3=ascii("ID3"),MPEG_FRAME_HEADERS=[[255,251],[255,243],[255,242]],startsWith=(t,e,r)=>r.every((r,s)=>t[e+s]===r);export function audioExtension(t){return startsWith(t,0,OGG)?".ogg":startsWith(t,0,RIFF)?".wav":startsWith(t,0,EBML)?".webm":startsWith(t,0,ID3)||MPEG_FRAME_HEADERS.some(e=>startsWith(t,0,e))?".mp3":".m4a"}export function escapeSsml(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}export function buildSsml(t,e,r){return`<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="${escapeSsml(e)}"><voice name="${escapeSsml(r)}">${escapeSsml(t)}</voice></speak>`}export function clampSpeakText(t){const e=t.trim();if(e.length<=6e3)return e;const r=e.slice(0,6e3),s=r.lastIndexOf(". ");return-1===s?r.trim():r.slice(0,s+1)}export function formatClipTime(t){if(!Number.isFinite(t)||t<0)return"0:00";const e=Math.round(t/1e3);return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}export function joinDictation(t,e,r){const s=e.trim();if(""===s)return t;return`${t}${t.length>0&&!/\s$/.test(t)?" ":""}${s}`.slice(0,r)}
@@ -0,0 +1 @@
1
+ "use strict";export{};
@@ -1 +1 @@
1
- "use strict";import{createChatSession}from"@webority/markdown-core/chat";import{useEffect,useMemo,useRef,useSyncExternalStore}from"react";const requestFrame=e=>{const t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)};export const useChat=({client:e,pageContext:t})=>{const r=useRef(t);r.current=t;const n=useMemo(()=>createChatSession({client:e,pageContext:()=>r.current,schedule:requestFrame}),[e]);useEffect(()=>()=>n.dispose(),[n]);return{...useSyncExternalStore(n.subscribe,n.getState),...useMemo(()=>({submit:e=>n.submit(e),stop:()=>n.stop(),retry:e=>n.retry(e),regenerate:e=>n.regenerate(e),startEdit:e=>n.startEdit(e),cancelEdit:()=>n.cancelEdit(),attach:e=>n.attach(e),removeAttachment:e=>n.removeAttachment(e),openConversation:e=>n.openConversation(e),newConversation:()=>n.newConversation(),rate:(e,t,r)=>n.rate(e,t,r),refreshAllowance:()=>n.refreshAllowance(),reset:()=>n.reset()}),[n]),client:n.client}};
1
+ "use strict";import{createChatSession,DEFAULT_CHAT_LABELS,emptyFeatures}from"@webority/chat-core";import{useReducedMotion}from"@webority/mobile-ui";import{useCallback,useEffect,useMemo,useRef,useState,useSyncExternalStore}from"react";import{AppState}from"react-native";const requestFrame=e=>{const t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)},NO_SUBSCRIPTION=()=>()=>{},IDLE_STATE=Object.freeze({profile:null,profileError:null,features:Object.freeze(emptyFeatures()),conversationId:null,conversationState:"Open",title:null,continuesConversationId:null,messages:[],thinking:!1,steps:[],streaming:!1,loading:!1,loadError:null,turnError:null,stopped:!1,messagesLeftToday:null,editing:null,attachments:[],lastConversation:null,open:!1,muted:!1,greeting:null,starters:[],pending:null,agent:null,agentTyping:null,live:"Off",handoffPending:!1,handoffPause:!1,openTickets:[],draft:null}),IDLE_SESSION=new Proxy({},{get:(e,t)=>{if("symbol"!=typeof t&&"client"!==t&&"toJSON"!==t&&!t.startsWith("$$")){if("getState"===t)return()=>IDLE_STATE;if("subscribe"===t)return NO_SUBSCRIPTION;if("then"!==t)return()=>Promise.resolve()}}});export function useChat(e){const{client:t,screen:r,layout:n,narrow:s,conversationId:o,pageContext:a,behaviour:c,prefs:u,getCaptchaToken:i,onEvent:l,onError:f,onNavigate:p}=e,m=JSON.stringify(s??{}),d=useRef(p);d.current=p;const S=useCallback(e=>d.current?.(e),[]),E=useRef(o);E.current=o;const v=useRef(a);v.current=a;const g=useRef(c);g.current=c;const h=useRef(i);h.current=i;const y=useRef(l);y.current=l;const C=useRef(f);C.current=f;const b=useRef(u);b.current=u;const A=useReducedMotion(),R=useRef(A);R.current=A;const[I,L]=useState(null),[T,w]=useState(null);useEffect(()=>{const e=createChatSession(t,{screen:r,layout:n,pathname:()=>r||"/",narrow:JSON.parse(m),conversationId:E.current??void 0,pageContext:()=>v.current,behaviour:()=>g.current?.()??null,prefs:b.current,getCaptchaToken:e=>h.current?.(e)??Promise.reject(new Error("No captcha handler.")),onEvent:(e,t)=>y.current?.(e,t),onError:e=>C.current?.(e),schedule:requestFrame,reducedMotion:()=>R.current});return L({client:t,screen:r,layout:n,narrowKey:m,session:e}),()=>e.dispose()},[t,r,n,m]);const O=null!==I&&I.client===t&&I.screen===r&&I.layout===n&&I.narrowKey===m?I.session:IDLE_SESSION,N=useSyncExternalStore(O.subscribe,O.getState),k=useMemo(()=>({load:()=>O.load(),submit:e=>O.submit(e),chooseQuickReply:e=>O.chooseQuickReply(e),answerInput:(e,t)=>O.answerInput(e,t),confirmAction:e=>O.confirmAction(e),rejectAction:(e,t)=>O.rejectAction(e,t),stop:()=>O.stop(),retry:()=>O.retry(),regenerate:()=>O.regenerate(),startEdit:e=>O.startEdit(e),cancelEdit:()=>O.cancelEdit(),attach:e=>O.attach(e),removeAttachment:e=>O.removeAttachment(e),openConversation:e=>O.openConversation(e),resumeLast:()=>O.resumeLast(),newConversation:()=>O.newConversation(),rate:(e,t,r)=>O.rate(e,t,r),reset:()=>O.reset(),requestHandoff:async e=>{w(null);try{await O.requestHandoff(e)}catch(e){const t=e instanceof Error&&""!==e.message?e.message:DEFAULT_CHAT_LABELS.errorGeneric;throw w(t),e}},notifyTyping:()=>O.notifyTyping(),resumeLive:()=>O.resumeLive()}),[O]),_=useRef(o);useEffect(()=>{O!==IDLE_SESSION&&o&&o!==_.current&&(_.current=o,O.openConversation(o))},[o,O]);const F=useRef("active"===AppState.currentState),P=useRef(!0),D=useCallback(()=>O.setLiveActive(F.current&&P.current),[O]),x=useCallback(e=>{P.current=e,D()},[D]);useEffect(()=>{D();const e=AppState.addEventListener("change",e=>{"active"===e?(F.current=!0,O.endHandoffPause()):F.current=!1,D()});return()=>e.remove()},[D,O]);const j=useCallback((e,t)=>{y.current?.(e,t)},[]);return{...N,...k,session:O,client:t,emit:j,setChatVisible:x,handoffError:T,onNavigate:p?S:void 0}}
@@ -0,0 +1 @@
1
+ "use strict";import{useEffect,useRef}from"react";import{Vibration}from"react-native";const isReply=e=>"Assistant"===e.author.kind||"Script"===e.author.kind||"Agent"===e.author.kind;export function useChatHaptics(e){const t=useRef(null),s=e.features.Sounds&&!0===e.profile?.experience.sound.vibrate&&!e.muted,i=e.profile?.experience.sound.vibrateMs??0;useEffect(()=>{if(null!==t.current)for(const r of e.messages){if(!isReply(r)||r.streaming||t.current.has(r.id))continue;if(t.current.add(r.id),r.restored)continue;const e=r.parts.some(e=>"Notice"===e.kind);s&&!e&&Vibration.vibrate(i)}else t.current=new Set(e.messages.map(e=>e.id))},[e.messages,s,i])}
@@ -0,0 +1 @@
1
+ "use strict";import{Logger}from"@webority/mobile-core";import{useEffect,useRef}from"react";export const CUES={open:{from:420,to:920,seconds:.16,peak:.16},reply:{from:680,to:540,seconds:.11,peak:.06},sent:{from:540,to:760,seconds:.09,peak:.05}};const SAMPLE_RATE=22050,ATTACK_SECONDS=.01,written=new Map;function cueBytes(e){const t=Math.round(22050*e.seconds),n=2*t,s=new Uint8Array(44+n),o=new DataView(s.buffer),text=(e,t)=>{for(let n=0;n<t.length;n+=1)o.setUint8(e+n,t.charCodeAt(n))};text(0,"RIFF"),o.setUint32(4,36+n,!0),text(8,"WAVE"),text(12,"fmt "),o.setUint32(16,16,!0),o.setUint16(20,1,!0),o.setUint16(22,1,!0),o.setUint32(24,22050,!0),o.setUint32(28,44100,!0),o.setUint16(32,2,!0),o.setUint16(34,16,!0),text(36,"data"),o.setUint32(40,n,!0);const r=Math.min(.01,e.seconds/2);let i=0;for(let n=0;n<t;n+=1){const t=n/22050,s=e.from+(e.to-e.from)*t/e.seconds;i+=2*Math.PI*s/22050;const a=t<r?t/r:(e.seconds-t)/(e.seconds-r);o.setInt16(44+2*n,Math.round(32767*e.peak*a*Math.sin(i)),!0)}return s}export function playCue(e,t=1){(async()=>{let n=written.get(e);if(void 0===n){const{File:t,Paths:s}=require("expo-file-system"),o=new t(s.cache,`wchat-cue-${e}.wav`);o.create({overwrite:!0}),o.write(cueBytes(CUES[e])),n=o.uri,written.set(e,n)}const{createAudioPlayer:s}=require("expo-audio"),o=s({uri:n});o.volume=t,o.addListener("playbackStatusUpdate",e=>{e.didJustFinish&&o.remove()}),o.play()})().catch(e=>{Logger.warn("[chat] sound cue failed",e)})}function takeUnseen(e,t,n){if(t){e.wasLoading=!0;for(const t of n)e.seen.add(t.id);return[]}if(e.wasLoading||!e.seeded){e.wasLoading=!1,e.seeded=!0;for(const t of n)e.seen.add(t.id);return[]}const s=[];for(const t of n)e.seen.has(t.id)||(e.seen.add(t.id),s.push(t));return s}export function useChatSound(e){const t=e.features.Sounds?e.profile?.experience.sound??null:null,n=useRef(e);n.current=e;const s=useRef(e.open),o=useRef({seen:new Set,seeded:!1,wasLoading:!1}),{open:r,loading:i,messages:a}=e;useEffect(()=>{const e=s.current;s.current=r;const c=takeUnseen(o.current,i,a);if(null!==t&&!n.current.muted&&t.volume>0){r&&!e&&t.open&&playCue("open",t.volume);for(const e of c){if(e.restored||e.parts.some(e=>"Notice"===e.kind))continue;const n=e.author.kind;"Visitor"===n?!e.stored&&t.sent&&playCue("sent",t.volume):"Assistant"!==n&&"Script"!==n&&"Agent"!==n||!t.reply||playCue("reply",t.volume)}}},[r,i,a,t])}
@@ -0,0 +1 @@
1
+ "use strict";import{useMemo}from"react";import{createPhoneSpeech}from"./speech/phoneSpeech.js";const adapters=new WeakMap;export function useChatSpeech(e){const t=!0===e.profile?.speechAvailable;return useMemo(()=>{if(!t)return null;let r=adapters.get(e.client);return void 0===r&&(r=createPhoneSpeech({getToken:()=>e.client.getSpeechToken()}),adapters.set(e.client,r)),r},[e.client,t])}
@@ -0,0 +1 @@
1
+ "use strict";import{buildTranscript,transcriptToText}from"@webority/chat-core";import{Logger}from"@webority/mobile-core";import{useCallback,useEffect,useRef,useState}from"react";import{Share}from"react-native";const NOTICE_MS=3e3;async function shareMessages(e,r,t,s){const a=buildTranscript(e,r);if(0===a.entries.length)return;const c=transcriptToText(a,{heading:t,speakers:t});try{await Share.share({message:c,title:a.title})}catch(e){Logger.error("[chat] share failed",e),s()}}export default function useTranscriptActions(e,r){const[t,s]=useState(null),a=useRef(null),c=useRef(!1);useEffect(()=>(c.current=!0,()=>{c.current=!1,null!==a.current&&clearTimeout(a.current)}),[]);const u=useCallback(e=>{c.current&&(null!==a.current&&clearTimeout(a.current),s(e),a.current=setTimeout(()=>s(null),3e3))},[]),{messages:i,title:n}=e,l=e.features.FigureText,o=useCallback(e=>shareMessages([e],{labels:r,title:n,figureText:l},!1,()=>u(r.shareFailed)),[r,n,l,u]),f=useCallback(()=>shareMessages(i,{labels:r,title:n,figureText:l},!0,()=>u(r.shareFailed)),[i,r,n,l,u]);return{canShare:e.features.Share,notice:t,shareReply:o,shareConversation:f}}
@@ -0,0 +1,9 @@
1
+ import type { ChatAuthor, ChatLabels } from "@webority/chat-core";
2
+ import type React from "react";
3
+ export interface AgentBylineProps {
4
+ author: ChatAuthor;
5
+ labels: ChatLabels;
6
+ }
7
+ /** The name and picture of the person who wrote an agent message. The spoken text carries the name instead. */
8
+ export declare function AgentByline({ author, labels }: AgentBylineProps): React.ReactElement;
9
+ //# sourceMappingURL=AgentByline.d.ts.map
@@ -0,0 +1,15 @@
1
+ import type { ChatLabels, ChatUploadFile } from "@webority/chat-core";
2
+ import type React from "react";
3
+ import type { UseChatResult } from "./useChat";
4
+ export interface ChatComposerProps {
5
+ chat: UseChatResult;
6
+ labels: ChatLabels;
7
+ pickAttachments?: () => Promise<ChatUploadFile[]>;
8
+ keyboardOffset?: number;
9
+ keyboardAware?: boolean;
10
+ safeArea?: boolean;
11
+ testID?: string;
12
+ focusRef?: React.MutableRefObject<(() => void) | null>;
13
+ }
14
+ export declare function ChatComposer({ chat, labels, pickAttachments, keyboardOffset, keyboardAware, safeArea, testID, focusRef, }: ChatComposerProps): React.ReactElement;
15
+ //# sourceMappingURL=ChatComposer.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { type ChatLabels } from "@webority/chat-core";
2
+ import type React from "react";
3
+ import type { UseChatResult } from "./useChat";
4
+ export interface ChatConversationActionsProps {
5
+ chat: UseChatResult;
6
+ labels: ChatLabels;
7
+ testID?: string;
8
+ }
9
+ export declare function ChatConversationActions({ chat, labels, testID }: ChatConversationActionsProps): React.ReactElement | null;
10
+ //# sourceMappingURL=ChatConversationActions.d.ts.map
@@ -0,0 +1,19 @@
1
+ import type { ChatLabels } from "@webority/chat-core";
2
+ import type React from "react";
3
+ import type { UseChatResult } from "./useChat";
4
+ export interface DictationNotice {
5
+ message: string;
6
+ openSettings: boolean;
7
+ tone: "danger" | "info";
8
+ }
9
+ export interface ChatDictationButtonProps {
10
+ chat: UseChatResult;
11
+ labels: ChatLabels;
12
+ disabled?: boolean;
13
+ onText: (text: string) => void;
14
+ onNotice: (notice: DictationNotice | null) => void;
15
+ testID?: string;
16
+ stopRef?: React.MutableRefObject<(() => void) | null>;
17
+ }
18
+ export declare function ChatDictationButton({ chat, labels, disabled, onText, onNotice, testID, stopRef, }: ChatDictationButtonProps): React.ReactElement | null;
19
+ //# sourceMappingURL=ChatDictationButton.d.ts.map
@@ -0,0 +1,11 @@
1
+ import type React from "react";
2
+ import { type ChatShellProps } from "./ChatFrame";
3
+ import type { UseChatResult } from "./useChat";
4
+ export interface ChatEmbedProps extends ChatShellProps {
5
+ chat: UseChatResult;
6
+ /** The height of the embedded chat. Default 520. */
7
+ height?: number;
8
+ }
9
+ /** The chat drawn inside a bounded area of a screen, with a border and rounded corners. */
10
+ export declare function ChatEmbed({ chat, labels, renderers, layoutParts, loader, motion, pickAttachments, onOpenAttachment, onOpenTarget, onNavigate, openTicket, handoffHosts, resolveLink, keyboardOffset, title, headerActions, onClose, height, testID, }: ChatEmbedProps): React.ReactElement | null;
11
+ //# sourceMappingURL=ChatEmbed.d.ts.map